summaryrefslogtreecommitdiff
path: root/base/base.h
diff options
context:
space:
mode:
Diffstat (limited to 'base/base.h')
-rw-r--r--base/base.h85
1 files changed, 0 insertions, 85 deletions
diff --git a/base/base.h b/base/base.h
deleted file mode 100644
index 8ce6cba..0000000
--- a/base/base.h
+++ /dev/null
@@ -1,85 +0,0 @@
1#ifndef BASE_H
2#define BASE_H
3
4#include <stdint.h>
5#include <stddef.h>
6
7/* assert an expression and output the file and the line */
8
9#define RED "\x1b[31m"
10#define GREEN "\x1b[32m"
11#define RESET "\x1b[0m"
12
13#define test_assert(expr) \
14 do \
15 { \
16 if (!(expr)) \
17 { \
18 fprintf(stderr, RED " [FAILED] %s:%d: expr:%s test:%s\n" RESET, __FILE__, __LINE__, #expr, __func__); \
19 abort(); \
20 } \
21 else\
22 { \
23 fprintf(stdout, GREEN "[PASSED] %s\n" RESET, __func__); \
24 }\
25 } while (0)
26
27#define global_variable static
28#define local_persist static
29#define local_internal static
30
31#define ERR_OK 0
32#define ERR_IO 1
33#define ERR_PARSE 2
34#define ERR_PERM 3
35#define ERR_INVALID 4
36
37#define KiB(n) (((u64)(n)) << 10)
38#define MiB(n) (((u64)(n)) << 20)
39#define GiB(n) (((u64)(n)) << 30)
40
41#define BUFFER_SIZE_SMALL 128
42#define BUFFER_SIZE_DEFAULT 256
43#define BUFFER_SIZE_LARGE 512
44#define PATH_MAX_LEN 4096
45
46#define DEPRECATED __attribute__((__deprecated__))
47
48typedef uint64_t u64;
49typedef uint32_t u32;
50typedef uint16_t u16;
51typedef uint8_t u8;
52
53typedef int8_t i8;
54typedef int16_t i16;
55typedef int32_t i32;
56typedef int64_t i64;
57
58typedef float f32;
59typedef double f64;
60
61typedef i32 b32;
62typedef i16 b16;
63typedef u8 b8;
64
65typedef uintptr_t umm;
66typedef intptr_t smm;
67
68#define TRUE 1
69#define FALSE 0
70
71local_internal u64
72parse_u64(char *buf, size_t len);
73
74local_internal b8
75is_numeric(char *s);
76
77local_internal b8
78compare_string(const char *c1, const char *c2);
79
80/*
81 * TODO(nasr): macro for verbose assertions
82 *
83 * */
84
85#endif