16#include <TargetConditionals.h>
19namespace hi::inline v1 {
21#define HI_BT_DEBUG 'D'
22#define HI_BT_RELEASE 'R'
25#define HI_BUILD_TYPE HI_BT_RELEASE
27#define HI_BUILD_TYPE HI_BT_DEBUG
30enum class build_type {
32 release = HI_BT_RELEASE,
34 current = HI_BUILD_TYPE
37#define HI_OS_WINDOWS 'W'
38#define HI_OS_MACOS 'A'
39#define HI_OS_MOBILE 'M'
40#define HI_OS_OTHER 'O'
43#define HI_OPERATING_SYSTEM HI_OS_WINDOWS
44#elif defined(TARGET_OS_MAC) && !defined(TARGET_OS_IPHONE)
45#define HI_OPERATING_SYSTEM HI_OS_MACOS
46#elif defined(TARGET_OS_IPHONE) || defined(__ANDROID__)
47#define HI_OPERATING_SYSTEM HI_OS_MOBILE
49#define HI_OPERATING_SYSTEM HI_OS_OTHER
52enum class operating_system {
53 windows = HI_OS_WINDOWS,
55 mobile = HI_OS_MOBILE,
58 current = HI_OPERATING_SYSTEM
63#define HI_CC_CLANG 'c'
66#define HI_COMPILER HI_CC_CLANG
67#elif defined(_MSC_BUILD)
68#define HI_COMPILER HI_CC_MSVC
69#elif defined(__GNUC__)
70#define HI_COMPILER HI_CC_GCC
72#error "Could not detect the compiler."
85#define HI_CPU_UNKNOWN 'u'
87#if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_AMD64)
88#define HI_PROCESSOR HI_CPU_X64
89#elif defined(__arm__) || defined(_M_ARM)
90#define HI_PROCESSOR HI_CPU_ARM
92#define HI_PROCESSOR HI_CPU_UNKNOWN
98 unknown = HI_CPU_UNKNOWN,
100 current = HI_PROCESSOR
103#if HI_PROCESSOR == HI_CPU_X64
104#if defined(__AVX512BW__) && defined(__AVX512CD__) && defined(__AVX512DQ__) && defined(__AVX512F__) && defined(__AVX512VL__)
105#define HI_X86_64_V4 1
106#define HI_X86_64_V3 1
107#define HI_X86_64_V2_5 1
108#define HI_X86_64_V2 1
109#define HI_X86_64_V1 1
120#define HI_HAS_AVX512F
121#define HI_HAS_AVX512BW
122#define HI_HAS_AVX512CD
123#define HI_HAS_AVX512DQ
124#define HI_HAS_AVX512VL
126#elif defined(__AVX2__)
127#define HI_X86_64_V3 1
128#define HI_X86_64_V2_5 1
129#define HI_X86_64_V2 1
130#define HI_X86_64_V1 1
142#elif defined(__AVX__)
143#define HI_X86_64_V2_5 1
144#define HI_X86_64_V2 1
145#define HI_X86_64_V1 1
155#elif defined(__SSE4_2__) && defined(__SSSE3__)
156#define HI_X86_64_V2 1
157#define HI_X86_64_V1 1
166#define HI_X86_64_V1 1
172#if defined(HI_X86_64_V1)
173constexpr bool x86_64_v1 =
true;
175constexpr bool x86_64_v1 =
false;
178#if defined(HI_X86_64_V2)
179constexpr bool x86_64_v2 =
true;
181constexpr bool x86_64_v2 =
false;
184#if defined(HI_X86_64_V2_5)
185constexpr bool x86_64_v2_5 =
true;
187constexpr bool x86_64_v2_5 =
false;
190#if defined(HI_X86_64_V3)
191constexpr bool x86_64_v3 =
true;
193constexpr bool x86_64_v3 =
false;
196#if defined(HI_X86_64_V4)
197constexpr bool x86_64_v4 =
true;
199constexpr bool x86_64_v4 =
false;
202#define hi_stringify_(x) #x
203#define hi_stringify(x) hi_stringify_(x)
205#define hi_cat_(a, b) a ## b
206#define hi_cat(a, b) hi_cat_(a, b)
208#if HI_COMPILER == HI_CC_MSVC
214#define hi_unreachable() __assume(0)
222#define hi_assume(condition) __assume(condition)
226#define hi_force_inline __forceinline
227#define hi_no_inline __declspec(noinline)
228#define hi_restrict __restrict
229#define hi_warning_push() _Pragma("warning( push )")
230#define hi_warning_pop() _Pragma("warning( pop )")
231#define hi_msvc_pragma(a) _Pragma(a)
232#define hi_msvc_suppress(code) _Pragma(hi_stringify(warning(disable:code)))
233#define hi_clang_suppress(a)
237#define hi_export __declspec(dllexport)
239#elif HI_COMPILER == HI_CC_CLANG
240#define hi_unreachable() __builtin_unreachable()
241#define hi_assume(condition) __builtin_assume(static_cast<bool>(condition))
242#define hi_force_inline inline __attribute__((always_inline))
243#define hi_no_inline __attribute__((noinline))
244#define hi_restrict __restrict__
245#define hi_warning_push() _Pragma("warning(push)")
246#define hi_warning_pop() _Pragma("warning(push)")
247#define hi_msvc_pragma(a)
248#define hi_clang_suppress(a) _Pragma(hi_stringify(clang diagnostic ignored a))
251#elif HI_COMPILER == HI_CC_GCC
252#define hi_unreachable() __builtin_unreachable()
253#define hi_assume(condition) \
258#define hi_force_inline inline __attribute__((always_inline))
259#define hi_no_inline __attribute__((noinline))
260#define hi_restrict __restrict__
261#define hi_warning_push() _Pragma("warning(push)")
262#define hi_warning_pop() _Pragma("warning(pop)")
263#define hi_msvc_pragma(a)
264#define hi_clang_suppress(a)
265#define msvc_pragma(a)
268#define hi_unreachable() std::terminate()
269#define hi_assume(condition) static_assert(sizeof(condition) == 1)
270#define hi_force_inline inline
273#define hi_warning_push()
274#define hi_warning_pop()
275#define hi_msvc_pragma(a)
276#define hi_clang_suppress(a)
277#define msvc_pragma(a)
281#if HI_PROCESSOR == HI_CPU_X64
291#elif HI_PROCESSOR == HI_CPU_ARM
302#elif HI_PROCESSOR == HI_CPU_UNKNOWN
306#error "Missing implementation of hardware_destructive_interference_size and hardware_constructive_interference_size"
309#if HI_OPERATING_SYSTEM == HI_OS_WINDOWS
310using os_handle =
void *;
311using file_handle = os_handle;
313#elif HI_OPERATING_SYSTEM == HI_OS_MACOS
314using os_handle = int;
315using file_handle = int;
317#elif HI_OPERATING_SYSTEM == HI_OS_LINUX
318using os_handle = int;
319using file_handle = int;
322#error "file_handle Not implemented."
constexpr std::size_t hardware_constructive_interference_size
Maximum size of contiguous memory to promote true sharing.
Definition architecture.hpp:290
constexpr std::size_t hardware_destructive_interference_size
Minimum offset between two objects to avoid false sharing.
Definition architecture.hpp:285