diff options
Diffstat (limited to 'source/base/base.h')
| -rwxr-xr-x | source/base/base.h | 65 |
1 files changed, 26 insertions, 39 deletions
diff --git a/source/base/base.h b/source/base/base.h index 5fcf9e2..3fe9dca 100755 --- a/source/base/base.h +++ b/source/base/base.h | |||
| @@ -1,34 +1,12 @@ | |||
| 1 | #ifndef BASE_H | 1 | #ifndef BASE_H |
| 2 | #define BASE_H | 2 | #define BASE_H |
| 3 | 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 */ | 4 | /* assert an expression and output the file and the line */ |
| 10 | 5 | #define internal static | |
| 11 | #define internal static | ||
| 12 | #define global_variable static | 6 | #define global_variable static |
| 13 | #define local_persist static | 7 | #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 | 8 | ||
| 25 | #define unused(x) (void)(x) | 9 | #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 | 10 | #define NIL 0 |
| 33 | 11 | ||
| 34 | #define DEPRECATED __attribute__((__deprecated__)) | 12 | #define DEPRECATED __attribute__((__deprecated__)) |
| @@ -43,35 +21,44 @@ | |||
| 43 | #define MemCpy(dest, src, len) memcpy((dest), (src), (len)) | 21 | #define MemCpy(dest, src, len) memcpy((dest), (src), (len)) |
| 44 | #define MemSet(dest, len) memset((dest), (0), (len)) | 22 | #define MemSet(dest, len) memset((dest), (0), (len)) |
| 45 | 23 | ||
| 24 | #if COMPILER_MSVC || (COMPILER_CLANG && OS_WINDOWS) | ||
| 25 | #pragma section(".rdata$", read) | ||
| 26 | #define read_only __declspec(allocate(".rdata$")) | ||
| 27 | #elif (COMPILER_CLANG && OS_LINUX) | ||
| 28 | #define read_only __attribute__((section(".rodata"))) | ||
| 29 | #else | ||
| 30 | #define read_only | ||
| 31 | #endif | ||
| 32 | |||
| 46 | typedef uint64_t u64; | 33 | typedef uint64_t u64; |
| 47 | typedef uint32_t u32; | 34 | typedef uint32_t u32; |
| 48 | typedef uint16_t u16; | 35 | typedef uint16_t u16; |
| 49 | typedef uint8_t u8; | 36 | typedef uint8_t u8; |
| 50 | 37 | ||
| 51 | typedef int8_t i8; | 38 | typedef int8_t s8; |
| 52 | typedef int16_t i16; | 39 | typedef int16_t s16; |
| 53 | typedef int32_t i32; | 40 | typedef int32_t s32; |
| 54 | typedef int64_t i64; | 41 | typedef int64_t s64; |
| 55 | 42 | ||
| 56 | typedef float f32; | 43 | typedef float f32; |
| 57 | typedef double f64; | 44 | typedef double f64; |
| 58 | 45 | ||
| 59 | typedef i32 b32; | 46 | typedef s32 b32; |
| 60 | typedef i16 b16; | 47 | typedef s16 b16; |
| 61 | typedef u8 b8; | 48 | typedef s8 b8; |
| 62 | 49 | ||
| 63 | typedef uintptr_t umm; | 50 | typedef uintptr_t umm; |
| 64 | typedef intptr_t smm; | 51 | typedef intptr_t smm; |
| 65 | 52 | ||
| 66 | #define TRUE (0 == 0) | 53 | #define True (1 == 1) |
| 67 | #define FALSE (0 != 0) | 54 | #define False (1 != 1) |
| 68 | 55 | ||
| 69 | typedef struct s8 s8; | 56 | #define Red "\x1b[31m" |
| 57 | #define Green "\x1b[32m" | ||
| 58 | #define Reset "\x1b[0m" | ||
| 59 | #define Blue "\x1b[34m" | ||
| 60 | #define Yellow "\x1b[33m" | ||
| 70 | 61 | ||
| 71 | struct s8 | 62 | #define Len(s) (sizeof(s) - 1) |
| 72 | { | ||
| 73 | char *data; | ||
| 74 | umm size; | ||
| 75 | }; | ||
| 76 | 63 | ||
| 77 | #endif | 64 | #endif |
