mirror of
https://github.com/devkitPro/wut.git
synced 2026-03-21 17:34:47 -05:00
Some checks failed
C/C++ CI / ubuntu-latest (push) Has been cancelled
`find . -regex '.*\.\(cpp\|hpp\|cu\|cuh\|c\|h\)' -exec clang-format -style=file -i {} \;`
64 lines
6.1 KiB
C++
64 lines
6.1 KiB
C++
#pragma once
|
|
#include <stdalign.h>
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
typedef int32_t BOOL;
|
|
|
|
#ifndef TRUE
|
|
#define TRUE 1
|
|
#endif
|
|
|
|
#ifndef FALSE
|
|
#define FALSE 0
|
|
#endif
|
|
|
|
#if defined(__cplusplus) && (__cplusplus >= 201402L)
|
|
#include <type_traits>
|
|
|
|
#define WUT_ENUM_BITMASK_TYPE(_type) \
|
|
extern "C++" { \
|
|
namespace \
|
|
{ \
|
|
constexpr inline _type \
|
|
operator~(_type lhs) \
|
|
{ \
|
|
return static_cast<_type>(~static_cast<std::underlying_type_t<_type>>(lhs)); \
|
|
} \
|
|
constexpr inline _type \
|
|
operator&(_type lhs, _type rhs) \
|
|
{ \
|
|
return static_cast<_type>(static_cast<std::underlying_type_t<_type>>(lhs) & static_cast<std::underlying_type_t<_type>>(rhs)); \
|
|
} \
|
|
constexpr inline _type \
|
|
operator|(_type lhs, _type rhs) \
|
|
{ \
|
|
return static_cast<_type>(static_cast<std::underlying_type_t<_type>>(lhs) | static_cast<std::underlying_type_t<_type>>(rhs)); \
|
|
} \
|
|
constexpr inline _type \
|
|
operator^(_type lhs, _type rhs) \
|
|
{ \
|
|
return static_cast<_type>(static_cast<std::underlying_type_t<_type>>(lhs) ^ static_cast<std::underlying_type_t<_type>>(rhs)); \
|
|
} \
|
|
inline _type & \
|
|
operator&=(_type &lhs, _type rhs) \
|
|
{ \
|
|
return reinterpret_cast<_type &>(reinterpret_cast<std::underlying_type_t<_type> &>(lhs) &= static_cast<std::underlying_type_t<_type>>(rhs)); \
|
|
} \
|
|
inline _type & \
|
|
operator|=(_type &lhs, _type rhs) \
|
|
{ \
|
|
return reinterpret_cast<_type &>(reinterpret_cast<std::underlying_type_t<_type> &>(lhs) |= static_cast<std::underlying_type_t<_type>>(rhs)); \
|
|
} \
|
|
inline _type & \
|
|
operator^=(_type &lhs, _type rhs) \
|
|
{ \
|
|
return reinterpret_cast<_type &>(reinterpret_cast<std::underlying_type_t<_type> &>(lhs) ^= static_cast<std::underlying_type_t<_type>>(rhs)); \
|
|
} \
|
|
} \
|
|
}
|
|
#else
|
|
#define WUT_ENUM_BITMASK_TYPE(_type)
|
|
#endif
|