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)
72 #elif defined(__posix)
75 # define ZYDIS_UNKNOWN_PLATFORM
82 #if defined(_M_AMD64) || defined(__x86_64__)
84 #elif defined(_M_IX86) || defined(__i386__)
86 #elif defined(_M_ARM64) || defined(__aarch64__)
87 # define ZYDIS_AARCH64
88 #elif defined(_M_ARM) || defined(_M_ARMT) || defined(__arm__) || defined(__thumb__)
91 # error "Unsupported architecture detected"
98 #if defined(ZYDIS_MSVC) || defined(ZYDIS_BORLAND)
102 # define ZYDIS_RELEASE
104 #elif defined(ZYDIS_GNUC) || defined(ZYDIS_ICC)
106 # define ZYDIS_RELEASE
111 # define ZYDIS_RELEASE
118 #if defined(ZYDIS_MSVC) || defined(ZYDIS_BORLAND)
119 # define ZYDIS_INLINE __inline
121 # define ZYDIS_INLINE static inline
128 #if defined(ZYDIS_NO_LIBC)
129 # define ZYDIS_ASSERT(condition)
132 # define ZYDIS_ASSERT(condition) assert(condition)
135 #if defined(ZYDIS_RELEASE)
136 # if defined(ZYDIS_CLANG)
137 # if __has_builtin(__builtin_unreachable)
138 # define ZYDIS_UNREACHABLE __builtin_unreachable()
140 # define ZYDIS_UNREACHABLE for(;;)
142 # elif defined(ZYDIS_GCC) && ((__GNUC__ == 4 && __GNUC_MINOR__ > 4) || __GNUC__ > 4)
143 # define ZYDIS_UNREACHABLE __builtin_unreachable()
144 # elif defined(ZYDIS_ICC)
145 # ifdef ZYDIS_WINDOWS
147 # define ZYDIS_UNREACHABLE __assume(0); (void)abort()
149 # define ZYDIS_UNREACHABLE __builtin_unreachable()
151 # elif defined(ZYDIS_MSVC)
152 # define ZYDIS_UNREACHABLE __assume(0)
154 # define ZYDIS_UNREACHABLE for(;;)
156 #elif defined(ZYDIS_NO_LIBC)
157 # define ZYDIS_UNREACHABLE for(;;)
160 # define ZYDIS_UNREACHABLE { assert(0); abort(); }
170 #if __STDC_VERSION__ >= 201112L
171 # define ZYDIS_STATIC_ASSERT(x) _Static_assert(x, #x)
173 # define ZYDIS_STATIC_ASSERT(x) typedef int ZYDIS_SASSERT_IMPL[(x) ? 1 : -1]
179 #define ZYDIS_BITFIELD(x) : x
184 #define ZYDIS_UNUSED_PARAMETER(x) (void)(x)
189 #define ZYDIS_ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))