blob: f90896277f2a8f7814351f56562f73ba924e3c79 (
plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#ifndef BASE_H
#define BASE_H
/* assert an expression and output the file and the line */
#define internal static
#define global_variable static
#define local_persist static
#define ARENA_ALIGN (2 * sizeof(void *))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define unused(x) (void)(x)
#define NIL 0
#define DEPRECATED __attribute__((__deprecated__))
#if defined(__arm__) || defined(__aarch64__)
#define breakpoint __asm__ volatile("brk #0");
#define temp_breakpoint __asm__ volatile("udf #0");
#elif defined(__i386__) || defined(__x86_64__)
#define breakpoint __asm__ volatile("int3");
#endif
#define MemCpy(dest, src, len) memcpy((dest), (src), (len))
#define MemSet(dest, len) memset((dest), (0), (len))
#if COMPILER_MSVC || (COMPILER_CLANG && OS_WINDOWS)
#pragma section(".rdata$", read)
#define read_only __declspec(allocate(".rdata$"))
#elif (COMPILER_CLANG && OS_LINUX)
#define read_only __attribute__((section(".rodata")))
#else
#define read_only
#endif
typedef uint64_t u64;
typedef uint32_t u32;
typedef uint16_t u16;
typedef uint8_t u8;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
typedef float f32;
typedef double f64;
typedef s32 b32;
typedef s16 b16;
typedef s8 b8;
typedef uintptr_t umm;
typedef intptr_t smm;
#define True (1 == 1)
#define False (1 != 1)
#define Red "\x1b[31m"
#define Green "\x1b[32m"
#define Reset "\x1b[0m"
#define Blue "\x1b[34m"
#define Yellow "\x1b[33m"
#define Len(s) (sizeof(s) - 1)
#endif
#ifdef BASE_IMPLEMENTATION
internal inline b8
is_pow(umm x)
{
return (x & (x - 1)) == 0;
}
internal inline u64
align(u64 pointer, umm alignment)
{
if ((alignment & (alignment - 1)) == 0)
{
return pointer;
}
return (pointer + alignment - 1) & ~(alignment - 1);
}
#endif
|