diff options
| author | nasr <nsrddyn@gmail.com> | 2026-03-13 22:31:21 +0100 |
|---|---|---|
| committer | nasr <nsrddyn@gmail.com> | 2026-03-13 22:31:21 +0100 |
| commit | 444bfa2f41143aff7490e4fa21565947565b7d30 (patch) | |
| tree | 696b06d40140c85805d171597e37deb8290ead73 /source/base/base.h | |
| parent | 3913d1778318cd0c6bfb871148d38abb33ec7fd3 (diff) | |
cleanup: generalisation
Diffstat (limited to 'source/base/base.h')
| -rwxr-xr-x | source/base/base.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/source/base/base.h b/source/base/base.h new file mode 100755 index 0000000..5fcf9e2 --- /dev/null +++ b/source/base/base.h | |||
| @@ -0,0 +1,77 @@ | |||
| 1 | #ifndef BASE_H | ||
| 2 | #define BASE_H | ||
| 3 | |||
| 4 | #include <stdint.h> | ||
| 5 | #include <unistd.h> | ||
| 6 | #include <stddef.h> | ||
| 7 | #include <string.h> | ||
| 8 | |||
| 9 | /* assert an expression and output the file and the line */ | ||
| 10 | |||
| 11 | #define internal static | ||
| 12 | #define global_variable static | ||
| 13 | #define local_persist static | ||
| 14 | |||
| 15 | #define ERR_OK 0 | ||
| 16 | #define ERR_IO 1 | ||
| 17 | #define ERR_PARSE 2 | ||
| 18 | #define ERR_PERM 3 | ||
| 19 | #define ERR_INVALID 4 | ||
| 20 | |||
| 21 | #define KiB(n) (((u64)(n)) << 10) | ||
| 22 | #define MiB(n) (((u64)(n)) << 20) | ||
| 23 | #define GiB(n) (((u64)(n)) << 30) | ||
| 24 | |||
| 25 | #define unused(x) (void)(x) | ||
| 26 | |||
| 27 | #define PATH_MAX_LEN 128 | ||
| 28 | #define BUFF_SMALL 128 | ||
| 29 | #define BUFF_DEFAULT 256 | ||
| 30 | #define BUFF_LARGE 512 | ||
| 31 | |||
| 32 | #define NIL 0 | ||
| 33 | |||
| 34 | #define DEPRECATED __attribute__((__deprecated__)) | ||
| 35 | |||
| 36 | #if defined(__arm__) || defined(__aarch64__) | ||
| 37 | #define breakpoint __asm__ volatile("brk #0"); | ||
| 38 | #define temp_breakpoint __asm__ volatile("udf #0"); | ||
| 39 | #elif defined(__i386__) || defined(__x86_64__) | ||
| 40 | #define breakpoint __asm__ volatile("int3"); | ||
| 41 | #endif | ||
| 42 | |||
| 43 | #define MemCpy(dest, src, len) memcpy((dest), (src), (len)) | ||
| 44 | #define MemSet(dest, len) memset((dest), (0), (len)) | ||
| 45 | |||
| 46 | typedef uint64_t u64; | ||
| 47 | typedef uint32_t u32; | ||
| 48 | typedef uint16_t u16; | ||
| 49 | typedef uint8_t u8; | ||
| 50 | |||
| 51 | typedef int8_t i8; | ||
| 52 | typedef int16_t i16; | ||
| 53 | typedef int32_t i32; | ||
| 54 | typedef int64_t i64; | ||
| 55 | |||
| 56 | typedef float f32; | ||
| 57 | typedef double f64; | ||
| 58 | |||
| 59 | typedef i32 b32; | ||
| 60 | typedef i16 b16; | ||
| 61 | typedef u8 b8; | ||
| 62 | |||
| 63 | typedef uintptr_t umm; | ||
| 64 | typedef intptr_t smm; | ||
| 65 | |||
| 66 | #define TRUE (0 == 0) | ||
| 67 | #define FALSE (0 != 0) | ||
| 68 | |||
| 69 | typedef struct s8 s8; | ||
| 70 | |||
| 71 | struct s8 | ||
| 72 | { | ||
| 73 | char *data; | ||
| 74 | umm size; | ||
| 75 | }; | ||
| 76 | |||
| 77 | #endif | ||
