Go to the documentation of this file.
32 #ifndef ZYDIS_DEFINES_H
33 #define ZYDIS_DEFINES_H
35 #include <ZydisExportConfig.h>
41 #if defined(__clang__)
44 #elif defined(__ICC) || defined(__INTEL_COMPILER)
46 #elif defined(__GNUC__) || defined(__GNUG__)
49 #elif defined(_MSC_VER)
51 #elif defined(__BORLANDC__)
52 # define ZYDIS_BORLAND
54 # define ZYDIS_UNKNOWN_COMPILER
62 # define ZYDIS_WINDOWS
63 #elif defined(__APPLE__)
66 #elif defined(__linux)
69 #elif defined(__FreeBSD__)
70 # define ZYDIS_FREEBSD
75 #elif defined(__posix)
78 # define ZYDIS_UNKNOWN_PLATFORM
85 #if defined(_M_AMD64) || defined(__x86_64__)
87 #elif defined(_M_IX86) || defined(__i386__)
89 #elif defined(_M_ARM64) || defined(__aarch64__)
90 # define ZYDIS_AARCH64
91 #elif defined(_M_ARM) || defined(_M_ARMT) || defined(__arm__) || defined(__thumb__)
94 # error "Unsupported architecture detected"
101 #if defined(ZYDIS_MSVC) || defined(ZYDIS_BORLAND)
105 # define ZYDIS_RELEASE
107 #elif defined(ZYDIS_GNUC) || defined(ZYDIS_ICC)
109 # define ZYDIS_RELEASE
114 # define ZYDIS_RELEASE
121 #if defined(ZYDIS_MSVC) || defined(ZYDIS_BORLAND)
122 # define ZYDIS_INLINE __inline
124 # define ZYDIS_INLINE static inline
131 #if defined(ZYDIS_NO_LIBC)
132 # define ZYDIS_ASSERT(condition)
135 # define ZYDIS_ASSERT(condition) assert(condition)
138 #if defined(ZYDIS_RELEASE)
139 # if defined(ZYDIS_CLANG)
140 # if __has_builtin(__builtin_unreachable)
141 # define ZYDIS_UNREACHABLE __builtin_unreachable()
143 # define ZYDIS_UNREACHABLE for(;;)
145 # elif defined(ZYDIS_GCC) && ((__GNUC__ == 4 && __GNUC_MINOR__ > 4) || __GNUC__ > 4)
146 # define ZYDIS_UNREACHABLE __builtin_unreachable()
147 # elif defined(ZYDIS_ICC)
148 # ifdef ZYDIS_WINDOWS
150 # define ZYDIS_UNREACHABLE __assume(0); (void)abort()
152 # define ZYDIS_UNREACHABLE __builtin_unreachable()
154 # elif defined(ZYDIS_MSVC)
155 # define ZYDIS_UNREACHABLE __assume(0)
157 # define ZYDIS_UNREACHABLE for(;;)
159 #elif defined(ZYDIS_NO_LIBC)
160 # define ZYDIS_UNREACHABLE for(;;)
163 # define ZYDIS_UNREACHABLE { assert(0); abort(); }
173 #if __STDC_VERSION__ >= 201112L
174 # define ZYDIS_STATIC_ASSERT(x) _Static_assert(x, #x)
176 # define ZYDIS_MACRO_CONCAT2(x, y) x##y
177 # define ZYDIS_MACRO_CONCAT(x, y) ZYDIS_MACRO_CONCAT2(x, y)
178 # define ZYDIS_STATIC_ASSERT(x) \
179 typedef int ZYDIS_MACRO_CONCAT(ZYDIS_SASSERT_, __COUNTER__) [(x) ? 1 : -1]
185 #define ZYDIS_BITFIELD(x) : x
190 #define ZYDIS_UNUSED_PARAMETER(x) (void)(x)
195 #define ZYDIS_FALLTHROUGH
200 #define ZYDIS_ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))