kiba-engine
config.h
1 #pragma once
2 
3 #include <stdarg.h>
4 
54 #ifdef KB_WINDOWS
55 # ifndef _WIN64
56 # error "64-bit Windows is required"
57 # endif // _WIN64
58 # define _KB_DLL_EXPORT __declspec(dllexport)
59 # define _KB_DLL_IMPORT __declspec(dllimport)
60 # define _KB_DLL_LOCAL
61 # define VA_LIST __builtin_va_list
62 # define VA_START va_start
63 # define VA_ARG va_arg
64 # define VA_END va_end
65 # define FORMAT_CHECK(fmt_index, arg_index)
66 # include <intrin.h>
67 # define DEBUG_BREAK __debugbreak()
68 #endif // KB_WINDOWS
69 
70 #ifdef KB_LINUX
71 # define _KB_DLL_EXPORT __attribute__((visibility("default")))
72 # define _KB_DLL_IMPORT __attribute__((visibility("default")))
73 # define _KB_DLL_LOCAL __attribute__((visibility("hidden")))
74 # define VA_LIST va_list
75 # define VA_START va_start
76 # define VA_ARG va_arg
77 # define VA_END va_end
78 # define FORMAT_CHECK(fmt_index, arg_index) __attribute__((__format__(__printf__, fmt_index, arg_index)))
79 # define DEBUG_BREAK __builtin_trap()
80 #endif // KB_LINUX
81 
105 #ifdef KB_STATIC_LIB
106 # define KB_API
107 # define KB_LOCAL
108 #else // not a static lib -> dll
109 # ifdef KB_EXPORT
110 # define KB_API _KB_DLL_EXPORT
111 # else // not exporting -> importing
112 # define KB_API _KB_DLL_IMPORT
113 # endif // KB_EXPORT
114 # define KB_LOCAL _KB_DLL_LOCAL
115 #endif // KB_STATIC_LIB
116 
117 #ifdef DOXYGEN_ONLY
118 # define KB_WINDOWS
119 # define KB_LINUX
120 # define KB_STATIC_LIB
121 # define KB_EXPORT
122 #endif
123 
124 #ifndef __has_builtin
125 # define __has_builtin(x) 0
126 #endif
127 
128 #if __has_builtin(__builtin_expect) \
129  || (defined(__GNUC__) && (__GNUC__ > 3) || (__GNUC__ == 3 && defined(__GNUC_MINOR__) && __GNUC_MINOR__ >= 1))
130 # define KB_LIKELY(x) __builtin_expect((x), 1)
131 # define KB_UNLIKELY(x) __builtin_expect((x), 0)
132 #else
133 # define KB_LIKELY(x) x
134 # define KB_UNLIKELY(x) x
135 #endif