blob: e679bf9cd8a954bea842c15914d982b02294ace7 (
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
|
#pragma once
#include <stdint.h>
#include <stddef.h>
#include <math.h> // IWYU pragma: keep
#define KiB(n) ((u64)n<<10)
#define MiB(n) ((u64)n<<20)
#define GiB(n) ((u64)n<<30)
#ifndef PI
#define PI 3.14159265358979323846264338327950
#endif // !PI
#ifndef F64_EPSILON
#define F64_EPSILON 1e-9
#endif // !F64_EPSILON
#define F64_EQ(x, y, eps) (fabs((x) - (y)) <= (eps))
#define MAX(n, m) ((n > m) ? (n) : (m))
#define MIN(n, m) ((n < m) ? (n) : (m))
// n and m are expected to be byte counts (m a power of 2); keep call sites in bytes,
// not element counts, so alignment semantics stay consistent across the codebase.
#define ALIGN_UP_POW2(n, m) (((u64)(n) + (u64)(m) - 1) & (~((u64)(m) - 1)))
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 i8 b8;
typedef i32 b32;
typedef float f32;
typedef double f64;
#define ARENA_ALIGN (sizeof(void*))
#define stz_xstr(a) str(a)
#define stz_str(a) #a
|