13#define TT_BT_DEBUG 'D'
14#define TT_BT_RELEASE 'R'
17#define TT_BUILD_TYPE TT_BT_RELEASE
19#define TT_BUILD_TYPE TT_BT_DEBUG
24 Release = TT_BT_RELEASE,
26 current = TT_BUILD_TYPE
29#define TT_OS_WINDOWS 'W'
30#define TT_OS_MACOS 'M'
32#define TT_OS_LINUX 'L'
33#define TT_OS_POSIX 'P'
35#define TT_OS_ANDROID 'A'
40#define TT_OPERATING_SYSTEM TT_OS_WINDOWS
42#define TT_OPERATING_SYSTEM TT_OS_WINDOWS
43#elif defined(__APPLE__)
44 #include "TargetConditionals.h"
45 #if TARGET_OS_IPHONE == 1
46 #define TT_OPERATING_SYSTEM TT_OS_IOS
48 #define TT_OPERATING_SYSTEM TT_OS_MACOS
50#elif defined(__ANDROID__)
51#define TT_OPERATING_SYSTEM TT_OS_ANDROID
53#define TT_OPERATING_SYSTEM TT_OS_LINUX
55#define TT_OPERATING_SYSTEM TT_OS_UNIX
57#define TT_OPERATING_SYSTEM TT_OS_POSIX
59#error "Could not detect the operating system."
62enum class OperatingSystem {
63 Windows = TT_OS_WINDOWS,
67 Android = TT_OS_ANDROID,
71 current = TT_OPERATING_SYSTEM
76#define TT_CC_CLANG 'c'
79#define TT_COMPILER TT_CC_CLANG
80#elif defined(_MSC_BUILD)
81#define TT_COMPILER TT_CC_MSVC
82#elif defined(__GNUC__)
83#define TT_COMPILER TT_CC_GCC
85#error "Could not detect the compiler."
99#define TT_CPPVER_17 '7'
100#define TT_CPPVER_20 '2'
102#if __cplusplus > 201703L
103#define TT_CPP_VERSION TT_CPPVER_20
104#elif __cplusplus == 201703L
105#define TT_CPP_VERSION TT_CPPVER_17
107#error "Unknown C++ version"
109enum class CPPVersion {
110 CPP17 = TT_CPPVER_17,
111 CPP20 = TT_CPPVER_20,
113 current = TT_CPP_VERSION
116#if defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64)
117#define TT_PROCESSOR TT_CPU_X64
118#elif defined(__arm__) || defined(_M_ARM)
119#define TT_PROCESSOR TT_CPU_ARM
121#error "Could not detect processor."
124enum class Processor {
128 current = TT_PROCESSOR
131#define tt_stringify(a) #a
133#if TT_COMPILER == TT_CC_MSVC
134#define tt_unreachable() __assume(0)
135#define tt_assume(condition) __assume(condition)
136#define tt_assume2(condition, msg) __assume(condition)
137#define tt_force_inline __forceinline
138#define tt_no_inline __declspec(noinline)
139#define clang_suppress(a)
140#define msvc_suppress(a) _Pragma(tt_stringify(warning(disable:a)))
142#elif TT_COMPILER == TT_CC_CLANG
143#define tt_unreachable() __builtin_unreachable()
144#define tt_assume(condition) __builtin_assume(static_cast<bool>(condition))
145#define tt_assume2(condition, msg) __builtin_assume(static_cast<bool>(condition))
146#define tt_force_inline inline __attribute__((always_inline))
147#define tt_no_inline __attribute__((noinline))
148#define clang_suppress(a) _Pragma(tt_stringify(clang diagnostic ignored a))
149#define msvc_suppress(a)
151#elif TT_COMPILER == TT_CC_GCC
152#define tt_unreachable() __builtin_unreachable()
153#define tt_assume(condition) do { if (!(condition)) tt_unreachable(); } while (false)
154#define tt_assume2(condition, msg) do { if (!(condition)) tt_unreachable(); } while (false)
155#define tt_force_inline inline __attribute__((always_inline))
156#define tt_no_inline __attribute__((noinline))
157#define clang_suppress(a)
158#define msvc_suppress(a)
161#define tt_unreachable() std::terminate()
162#define tt_assume(condition) static_assert(sizeof(condition) == 1)
163#define tt_assume2(condition, msg) static_assert(sizeof(condition) == 1, msg)
164#define tt_force_inline inline
166#define clang_suppress(a)
167#define msvc_suppress(a)
171#if TT_PROCESSOR == TT_CPU_X64
175constexpr size_t hardware_destructive_interference_size = 128;
180constexpr size_t hardware_constructive_interference_size = 64;
181#elif TT_PROCESSOR == TT_CPU_ARM
185constexpr size_t hardware_destructive_interference_size = 64;
190constexpr size_t hardware_constructive_interference_size = 64;
192#error "Missing implementation of hardware_destructive_interference_size and hardware_constructive_interference_size"
195constexpr bool has_sse = Processor::current == Processor::x64;
197#if TT_OPERATING_SYSTEM == TT_OS_WINDOWS
198using os_handle =
void *;
199using file_handle = os_handle;
201#elif TT_OPERATING_SYSTEM == TT_OS_MACOS
202using os_handle = int;
203using file_handle = int;
205#elif TT_OPERATING_SYSTEM == TT_OS_LINUX
206using os_handle = int;
207using file_handle = int;
210#error "file_handle Not implemented."