-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.h
42 lines (30 loc) · 967 Bytes
/
utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef H_UTILS_H
#include <stdint.h>
#include <stddef.h>
typedef int8_t i8;
typedef int16_t i16;
typedef int32_t i32;
typedef int64_t i64;
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int32_t b32; // NOTE: For bool.
typedef size_t memory_size;
typedef uintptr_t uptr;
typedef float f32;
typedef double f64;
#undef TRUE
#undef FALSE
#define TRUE (1)
#define FALSE (0)
void platform_throw_error(const u8* text);
#define ASSERT(x) do { if (!(x)) { platform_throw_error((u8*)#x); (volatile int*)0; } } while (0)
#define ARRAY_COUNT(x) (sizeof(x) / sizeof(*(x)))
#define OFFSETOF(type, member) ((memory_size)&(((type*)0)->member))
#define COUNTOF(type, member) (ARRAY_COUNT(((type*)0)->member))
#define KILOBYTES(x) ((x) * (1024ULL))
#define MEGABYTES(x) (KILOBYTES(x) * (1024ULL))
#define GIGABYTES(x) (MEGABYTES(x) * (1024ULL))
#define H_UTILS_H
#endif