19 typedef unsigned char u8;
22 typedef unsigned short u16;
25 typedef unsigned int u32;
28 typedef unsigned long long u64;
33 typedef signed char i8;
36 typedef signed short i16;
39 typedef signed int i32;
42 typedef signed long long i64;
69 #if defined(__clang__) || defined(__GNUC__)
71 #define STATIC_ASSERT _Static_assert
75 #define STATIC_ASSERT static_assert
120 #define INVALID_ID_U64 18446744073709551615UL
121 #define INVALID_ID 4294967295U
122 #define INVALID_ID_U16 65535U
123 #define INVALID_ID_U8 255U
126 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
127 #define KPLATFORM_WINDOWS 1
129 #error "64-bit is required on Windows!"
131 #elif defined(__linux__) || defined(__gnu_linux__)
133 #define KPLATFORM_LINUX 1
134 #if defined(__ANDROID__)
135 #define KPLATFORM_ANDROID 1
137 #elif defined(__unix__)
139 #define KPLATFORM_UNIX 1
140 #elif defined(_POSIX_VERSION)
142 #define KPLATFORM_POSIX 1
145 #define KPLATFORM_APPLE 1
146 #include <TargetConditionals.h>
147 #if TARGET_IPHONE_SIMULATOR
149 #define KPLATFORM_IOS 1
150 #define KPLATFORM_IOS_SIMULATOR 1
151 #elif TARGET_OS_IPHONE
152 #define KPLATFORM_IOS 1
157 #error "Unknown Apple platform"
160 #error "Unknown platform!"
166 #define KAPI __declspec(dllexport)
168 #define KAPI __attribute__((visibility("default")))
174 #define KAPI __declspec(dllimport)
188 #define KCLAMP(value, min, max) ((value <= min) ? min : (value >= max) ? max \
192 #if defined(__clang__) || defined(__gcc__)
194 #define KINLINE __attribute__((always_inline)) inline
197 #define KNOINLINE __attribute__((noinline))
198 #elif defined(_MSC_VER)
201 #define KINLINE __forceinline
204 #define KNOINLINE __declspec(noinline)
208 #define KINLINE static inline
215 #define GIBIBYTES(amount) ((amount) * 1024ULL * 1024ULL * 1024ULL)
217 #define MEBIBYTES(amount) ((amount) * 1024ULL * 1024ULL)
219 #define KIBIBYTES(amount) ((amount) * 1024ULL)
222 #define GIGABYTES(amount) ((amount) * 1000ULL * 1000ULL * 1000ULL)
224 #define MEGABYTES(amount) ((amount) * 1000ULL * 1000ULL)
226 #define KILOBYTES(amount) ((amount) * 1000ULL)
229 return ((operand + (granularity - 1)) & ~(granularity - 1));
236 #define KMIN(x, y) (x < y ? x : y)
237 #define KMAX(x, y) (x > y ? x : y)
unsigned int u32
Unsigned 32-bit integer.
Definition: defines.h:25
KINLINE range get_aligned_range(u64 offset, u64 size, u64 granularity)
Definition: defines.h:232
#define STATIC_ASSERT
Static assertion.
Definition: defines.h:75
signed char i8
Signed 8-bit integer.
Definition: defines.h:33
_Bool b8
8-bit boolean type
Definition: defines.h:58
float f32
32-bit floating point number
Definition: defines.h:47
struct range range
A range, typically of memory.
double f64
64-bit floating point number
Definition: defines.h:50
signed int i32
Signed 32-bit integer.
Definition: defines.h:39
unsigned short u16
Unsigned 16-bit integer.
Definition: defines.h:22
#define KINLINE
Inline qualifier.
Definition: defines.h:208
KINLINE u64 get_aligned(u64 operand, u64 granularity)
Definition: defines.h:228
signed short i16
Signed 16-bit integer.
Definition: defines.h:36
int b32
32-bit boolean type, used for APIs which require it
Definition: defines.h:55
unsigned long long u64
Unsigned 64-bit integer.
Definition: defines.h:28
signed long long i64
Signed 64-bit integer.
Definition: defines.h:42
unsigned char u8
Unsigned 8-bit integer.
Definition: defines.h:19
A range, typically of memory.
Definition: defines.h:61
u64 offset
The offset in bytes.
Definition: defines.h:63
u64 size
The size in bytes.
Definition: defines.h:65