diff options
Diffstat (limited to 'src/shorthand.h')
-rw-r--r-- | src/shorthand.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/shorthand.h b/src/shorthand.h new file mode 100644 index 0000000..0897824 --- /dev/null +++ b/src/shorthand.h | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | Copyright (c) 2021 Bad Diode | ||
3 | |||
4 | Permission to use, copy, modify, and distribute this software for any | ||
5 | purpose with or without fee is hereby granted, provided that the above | ||
6 | copyright notice and this permission notice appear in all copies. | ||
7 | |||
8 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
9 | WITH REGARD TO THIS SOFTWARE. | ||
10 | */ | ||
11 | |||
12 | #ifndef UTILS_SHORTHAND_H | ||
13 | #define UTILS_SHORTHAND_H | ||
14 | |||
15 | #include <stdbool.h> | ||
16 | #include <stddef.h> | ||
17 | #include <stdint.h> | ||
18 | |||
19 | // | ||
20 | // This simple header just typedefs the basic C define types to a shorter name, | ||
21 | // loads the quality of life bool macro for _Bool and defines shorthand macros | ||
22 | // for byte sizes. | ||
23 | |||
24 | typedef uint8_t u8; | ||
25 | typedef uint16_t u16; | ||
26 | typedef uint32_t u32; | ||
27 | typedef uint64_t u64; | ||
28 | typedef int8_t s8; | ||
29 | typedef int16_t s16; | ||
30 | typedef int32_t s32; | ||
31 | typedef int64_t s64; | ||
32 | typedef volatile u8 vu8; | ||
33 | typedef volatile u16 vu16; | ||
34 | typedef volatile u32 vu32; | ||
35 | typedef volatile u64 vu64; | ||
36 | typedef volatile s8 vs8; | ||
37 | typedef volatile s16 vs16; | ||
38 | typedef volatile s32 vs32; | ||
39 | typedef volatile s64 vs64; | ||
40 | |||
41 | #define KB(N) ((u64)(N) * 1024) | ||
42 | #define MB(N) ((u64)KB(N) * 1024) | ||
43 | #define GB(N) ((u64)MB(N) * 1024) | ||
44 | #define TB(N) ((u64)GB(N) * 1024) | ||
45 | |||
46 | #endif // UTILS_SHORTHAND_H | ||