9#include <stdnoreturn.h>
15template<
class P,
class M>
16[[gnu::always_inline]]
constexpr size_t __offsetof(
const M P::*member)
18 return (
size_t) &(
reinterpret_cast<P *
>(0)->*member);
21template<
class P,
class M>
27template<
class P,
class M>
28[[gnu::always_inline]]
constexpr inline const P *
__container_of(
const M *
ptr,
const M P::*member)
33#define container_of(ptr, type, member) __container_of(ptr, &type::member)
35template<
typename TOut,
typename TIn>
36[[gnu::always_inline]]
inline TOut *
cast(TIn *value)
38 return reinterpret_cast<TOut *
>(value);
41template<
typename TOut,
typename TIn>
42[[gnu::always_inline]]
inline const TOut *
cast(
const TIn *value)
44 return reinterpret_cast<const TOut *
>(value);
56 virtual bool isErr() const final
66 explicit operator bool()
const
91 const std::add_lvalue_reference<T>::type &
operator*()
const
115 return value ==
nullptr;
125 return value == other;
143requires std::is_enum_v<E>
struct Flags
147 static_assert(
sizeof(E) <=
sizeof(
u32),
"Flags only supports enums that fit into a u32");
150 using U = std::underlying_type_t<E>;
155 static_assert(
sizeof(
Flags) ==
sizeof(E),
"Flags must have the same size as the enum");
162 return static_cast<E
>(~static_cast<U>(0));
165 inline operator U()
const
172 return static_cast<E
>(
static_cast<U>(
value_) |
static_cast<U>(e));
177 return static_cast<E
>(
static_cast<U>(
value_) &
static_cast<U>(b));
182 return static_cast<E
>(
static_cast<U>(
value_) &
static_cast<U>(b.
value_));
187 return static_cast<U>(
value_) &
static_cast<U>(b);
192 return static_cast<U>(
value_) & ~
static_cast<U>(b);
197 return static_cast<E
>(
static_cast<U>(
value_) & ~static_cast<U>(b));
202 return static_cast<E
>(
static_cast<U>(
value_) & ~static_cast<U>(b.
value_));
207 value_ =
static_cast<E
>(
static_cast<U>(
value_) |
static_cast<U>(b));
213 value_ =
static_cast<E
>(
static_cast<U>(
value_) &
static_cast<U>(b));
225 value_ =
static_cast<E
>(
static_cast<U>(
value_) & ~static_cast<U>(b));
236#define MOS_ENUM_FLAGS(enum, flags) using flags = Flags<enum>
241 using U = std::underlying_type_t<E>;
242 return static_cast<E
>(
static_cast<U
>(a) |
static_cast<U
>(b));
246requires std::is_enum_v<E>
constexpr void operator~(E a) =
delete;
249requires std::is_enum_v<E>
constexpr void operator&(E a, E b) =
delete;
MOSAPI void(1, 2) fatal_abort(const char *fmt
void __raise_bad_ptrresult_value(int errorCode)
Flags erased(Flags b) const
std::underlying_type_t< E > U
Flags operator|(E e) const
bool test_inverse(E b) const
Flags operator&(E b) const
Flags & operator&=(Flags b)
Flags operator&(Flags b) const
constexpr Flags(E value=static_cast< E >(0))
PtrResultBase(int errorCode)
virtual long getErr() const final
virtual bool isErr() const final
bool operator==(const PtrResult< T > &other) const
PtrResult(PtrResult< U > other)
bool operator==(const std::nullptr_t) const
std::add_lvalue_reference< T >::type operator*()
const std::add_lvalue_reference< T >::type & operator*() const
const T * operator->() const
bool operator==(const T *other) const
constexpr Flags< E > operator|(E a, E b)
constexpr void operator~(E a)=delete
constexpr void operator&(E a, E b)=delete
constexpr P * __container_of(M *ptr, const M P::*member)
std::atomic_size_t atomic_t
constexpr size_t __offsetof(const M P::*member)