52#define N_BIT(x) (1 << x)
53template <
class MASK,
class BITS>
63template <
class MASK,
class BITS>
67 return MASK(
uint(mask) & ~
uint(bit));
70#define N_ARGB(a,r,g,b) ((uint32_t)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
71#define N_RGBA(r,g,b,a) N_ARGB(a,r,g,b)
72#define N_XRGB(r,g,b) N_ARGB(0xff,r,g,b)
73#define N_COLORVALUE(r,g,b,a) N_RGBA((uint32_t)((r)*255.f),(uint)((g)*255.f),(uint)((b)*255.f),(uint)((a)*255.f))
74#define N_IP_ADDR(a,b,c,d) (uint32_t)((((a)&0xff)<<24)|(((b)&0xff)<<16)|(((c)&0xff)<<8)|((d)&0xff))
80template <
class FLAGS,
class BITS>
82AllBits(
const FLAGS flags,
const BITS bits)
84 return (flags & bits) == bits;
91template <
class FLAGS,
class BITS>
93AnyBits(
const FLAGS flags,
const BITS bits)
95 return (flags & bits) != (FLAGS)0;
101template <
class FLAGS,
class BITS>
105 return (flags & bits) == flags;
109#define BITS_TO_BYTES(x) (((x)+7)>>3)
110#define BYTES_TO_BITS(x) ((x)<<3)
112#if (__OSX__ || __linux__)
113inline ushort _byteswap_ushort(
ushort x) {
return ((x>>8) | (x<<8)); }
114inline ulong _byteswap_ulong(
ulong x) {
return ((x&0xff000000)>>24) | ((x&0x00ff0000)>>8) | ((x&0x00000ff00)<<8) | ((x&0x000000ff)<<24); }
115inline unsigned long long _byteswap_uint64(
unsigned long long x) {
return ((((
unsigned long long)_byteswap_ulong((
ulong)(x & 0xffffffff))) << 32) | ((
unsigned long long)_byteswap_ulong((
ulong)(x >> 32)))); }
119typedef unsigned char byte;
122#define n_stricmp stricmp
123#define n_snprintf StringCchPrintf
124#elif (__OSX__ || __APPLE__ || __linux__ )
125#define n_stricmp strcasecmp
126#define n_snprintf sprintf
128#error "Unsupported platform!"
132#define ThreadLocal __declspec(thread)
134#define ThreadLocal __thread
135#elif (__OSX__ || __APPLE__)
136#define ThreadLocal thread_local
138#error "Unsupported platform!"
141#define lengthof(x) (sizeof(x) / sizeof(*x))
143#define NEBULA_ALIGN16 alignas(16)
Implements a memory related functions.
constexpr bool AllBits(const FLAGS flags, const BITS bits)
Check if all bits are set in flags.
Definition types.h:82
constexpr MASK UnsetBits(const MASK mask, const BITS bit)
Definition types.h:65
static const int InvalidIndex
Definition types.h:47
ptrdiff_t ptrdiff
Definition types.h:39
constexpr bool OnlyBits(const FLAGS flags, const BITS bits)
Definition types.h:103
unsigned char ubyte
Definition types.h:36
ptrdiff PtrDiff
Definition types.h:46
uintptr_t uintptr
Definition types.h:38
unsigned char uchar
Definition types.h:35
unsigned long ulong
Definition types.h:32
constexpr bool AnyBits(const FLAGS flags, const BITS bits)
Check if any bits are set in flags.
Definition types.h:93
int SizeT
Definition types.h:42
int64_t Size64T
Definition types.h:44
unsigned int uint
Definition types.h:33
uintptr PtrT
Definition types.h:45
constexpr MASK SetBits(const MASK mask, const BITS bit)
Definition types.h:55
unsigned short ushort
Definition types.h:34
int64_t Index64T
Definition types.h:43
int IndexT
Definition types.h:41