60operator"" _KB(
const unsigned long long val)
69operator"" _MB(
const unsigned long long val)
71 return val * 1024 * 1024;
78operator"" _GB(
const unsigned long long val)
80 return val * 1024 * 1024 * 1024;
86#define N_BIT(x) (1 << x)
87template <
class MASK,
class BITS>
97template <
class MASK,
class BITS>
101 return MASK(
uint(mask) & ~
uint(bit));
104#define N_ARGB(a,r,g,b) ((uint)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
105#define N_RGBA(r,g,b,a) N_ARGB(a,r,g,b)
106#define N_XRGB(r,g,b) N_ARGB(0xff,r,g,b)
107#define N_COLORVALUE(r,g,b,a) N_RGBA((uint)((r)*255.f),(uint)((g)*255.f),(uint)((b)*255.f),(uint)((a)*255.f))
113template <
class FLAGS,
class BITS>
117 return (flags & bits) == bits;
124template <
class FLAGS,
class BITS>
128 return (flags & bits) != (FLAGS)0;
134template <
class FLAGS,
class BITS>
138 return (flags & bits) == flags;
142#define BITS_TO_BYTES(x) (((x)+7)>>3)
143#define BYTES_TO_BITS(x) ((x)<<3)
145#if (__OSX__ || __linux__)
146inline ushort _byteswap_ushort(
ushort x) {
return ((x>>8) | (x<<8)); }
147inline ulong _byteswap_ulong(
ulong x) {
return ((x&0xff000000)>>24) | ((x&0x00ff0000)>>8) | ((x&0x00000ff00)<<8) | ((x&0x000000ff)<<24); }
148inline 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)))); }
152typedef unsigned char byte;
155#define n_stricmp stricmp
156#define n_snprintf StringCchPrintf
157#elif (__OSX__ || __APPLE__ || __linux__ )
158#define n_stricmp strcasecmp
159#define n_snprintf sprintf
161#error "Unsupported platform!"
167#define ThreadLocal __declspec(thread)
169#define ThreadLocal __thread
170#if (__OSX__ || __APPLE__)
176#error "Unsupported platform!"
179#define lengthof(x) (sizeof(x) / sizeof(*x))
181#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:115
constexpr MASK UnsetBits(const MASK mask, const BITS bit)
Definition types.h:99
uint8_t uint8
Definition types.h:42
static const int InvalidIndex
Definition types.h:54
ptrdiff_t ptrdiff
Definition types.h:46
constexpr bool OnlyBits(const FLAGS flags, const BITS bits)
Definition types.h:136
unsigned char ubyte
Definition types.h:34
ptrdiff PtrDiff
Definition types.h:53
uintptr_t uintptr
Definition types.h:45
unsigned char uchar
Definition types.h:33
unsigned long ulong
Definition types.h:30
int64_t int64
Definition types.h:37
constexpr bool AnyBits(const FLAGS flags, const BITS bits)
Check if any bits are set in flags.
Definition types.h:126
int SizeT
Definition types.h:49
int64_t Size64T
Definition types.h:51
unsigned int uint
Definition types.h:31
uintptr PtrT
Definition types.h:52
int16_t int16
Definition types.h:41
int8_t int8
Definition types.h:43
constexpr MASK SetBits(const MASK mask, const BITS bit)
Definition types.h:89
int32_t int32
Definition types.h:39
unsigned short ushort
Definition types.h:32
uint64_t uint64
Definition types.h:36
int64_t Index64T
Definition types.h:50
uint16_t uint16
Definition types.h:40
uint32_t uint32
Definition types.h:38
int IndexT
Definition types.h:48