Loading...
Searching...
No Matches
Go to the documentation of this file.
6#define CU_IF_NULL(expr) if ((expr) == NULL)
8#define CU_IF_NOT_NULL(expr) if ((expr) != NULL)
10#define CU_DIE(msg) cu_panic_handler("Fatal error: %s", msg)
13#define CU_ALIGN_UP(x, align) (((x) + (align) - 1) & ~((align) - 1))
15#define CU_UNUSED(expr) (void)(expr)
17#define CU_ARRAY_LEN(arr) (sizeof(arr) / sizeof((arr)[0]))
19#define CU_BIT(x) (1u << (x))
22#define CU_CONCAT_(a, b) a##b
23#define CU_CONCAT(a, b) CU_CONCAT_(a, b)
25#define CU_MIN(a, b) ((a) < (b) ? (a) : (b))
26#define CU_MAX(a, b) ((a) > (b) ? (a) : (b))
29#if defined(_WIN32) || defined(_WIN64)
30#define CU_PLAT_WINDOWS 1
32#define CU_PLAT_WINDOWS 0
36#define CU_PLAT_MACOS 1
38#define CU_PLAT_MACOS 0
42#define CU_PLAT_LINUX 1
44#define CU_PLAT_LINUX 0
48#if defined(__EMSCRIPTEN__) || defined(__wasm__) || defined(__wasm32__)
54#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
60#if CU_PLAT_MACOS || CU_PLAT_LINUX || CU_PLAT_BSD
61#define CU_PLAT_POSIX 1
63#define CU_PLAT_POSIX 0
67 #define CU_COMPILER_CLANG 1
69 #define CU_COMPILER_CLANG 0
72#if defined(__GNUC__) && !CU_COMPILER_CLANG
73 #define CU_COMPILER_GCC 1
75 #define CU_COMPILER_GCC 0
79 #define CU_COMPILER_MSVC 1
81 #define CU_COMPILER_MSVC 0
85 #define CU_COMPILER_TCC 1
87 #define CU_COMPILER_TCC 0
90#if defined(__INTEL_COMPILER) || defined(__ICC)
91 #define CU_COMPILER_INTEL 1
93 #define CU_COMPILER_INTEL 0
96#if defined(__llvm__) && !CU_COMPILER_CLANG
97 #define CU_COMPILER_LLVM 1
99 #define CU_COMPILER_LLVM 0
102#if CU_COMPILER_CLANG && CU_PLAT_WINDOWS
106#define UNREACHABLE(msg) cu_panic_handler("Unreachable code reached: %s", msg)
108#define TODO(msg) cu_panic_handler("TODO: %s", msg)
110#define CU_AS(expr, T) (T)(expr)