Slick OrderBook
1.1.0
High-Performance C++23 OrderBook Library
Loading...
Searching...
No Matches
config.hpp
Go to the documentation of this file.
1
// Copyright 2026 Slick Quant
2
// SPDX-License-Identifier: MIT
3
4
#pragma once
5
6
// Version information (generated from CMakeLists.txt project version)
7
#include <
slick/orderbook/version.hpp
>
8
9
// API export/import macros (applied to exported classes)
10
// SLICK_ORDERBOOK_SHARED is propagated by CMake to everything linking the shared library
11
#if defined(SLICK_ORDERBOOK_HEADER_ONLY) || !defined(SLICK_ORDERBOOK_SHARED)
12
// Header-only or static library: nothing to export
13
#define SLICK_API
14
#elif defined(_WIN32)
15
#ifdef SLICK_ORDERBOOK_BUILD
16
// Building the library
17
#define SLICK_API __declspec(dllexport)
18
#else
19
// Using the library
20
#define SLICK_API __declspec(dllimport)
21
#endif
22
#else
23
// Unix-like systems
24
#define SLICK_API __attribute__((visibility("default")))
25
#endif
26
27
// Explicit template instantiation exports:
28
// MSVC needs dllexport on the instantiation definition (it is incompatible with `extern template`),
29
// GCC/Clang take the visibility attribute on the `extern template` declaration instead.
30
#if defined(_WIN32)
31
#define SLICK_TEMPLATE_INSTANTIATION_API SLICK_API
32
#if defined(SLICK_ORDERBOOK_BUILD) && defined(SLICK_ORDERBOOK_SHARED)
33
#define SLICK_EXTERN_TEMPLATE_DECLS 0
34
#else
35
#define SLICK_EXTERN_TEMPLATE_DECLS 1
36
#endif
37
#else
38
#define SLICK_TEMPLATE_INSTANTIATION_API
39
#define SLICK_EXTERN_TEMPLATE_DECLS 1
40
#endif
41
42
// Exported classes hold STL members (C4251); clients must use a compatible toolset anyway
43
#if defined(_MSC_VER)
44
#define SLICK_DLL_INTERFACE_WARNINGS_PUSH __pragma(warning(push)) __pragma(warning(disable: 4251))
45
#define SLICK_DLL_INTERFACE_WARNINGS_POP __pragma(warning(pop))
46
#else
47
#define SLICK_DLL_INTERFACE_WARNINGS_PUSH
48
#define SLICK_DLL_INTERFACE_WARNINGS_POP
49
#endif
50
51
// Compiler feature detection
52
#if defined(__has_feature)
53
#define SLICK_HAS_FEATURE(x) __has_feature(x)
54
#else
55
#define SLICK_HAS_FEATURE(x) 0
56
#endif
57
58
// ThreadSanitizer detection
59
#ifndef SLICK_TSAN_ENABLED
60
#if defined(__SANITIZE_THREAD__)
61
#define SLICK_TSAN_ENABLED 1
62
#elif defined(__TSAN__)
63
#define SLICK_TSAN_ENABLED 1
64
#elif SLICK_HAS_FEATURE(thread_sanitizer)
65
#define SLICK_TSAN_ENABLED 1
66
#else
67
#define SLICK_TSAN_ENABLED 0
68
#endif
69
70
#endif
71
72
#if defined(__SANITIZE_ADDRESS__) || defined(__ASAN__) || SLICK_HAS_FEATURE(address_sanitizer)
73
#define SLICK_ASAN_ENABLED 1
74
#else
75
#define SLICK_ASAN_ENABLED 0
76
#endif
77
78
// Compiler concepts detection
79
#if defined(__cpp_concepts) && __cpp_concepts >= 201907L
80
#define SLICK_HAS_CONCEPTS 1
81
#else
82
#define SLICK_HAS_CONCEPTS 0
83
#endif
84
85
// Likely/unlikely hints for branch prediction
86
#if defined(__GNUC__) || defined(__clang__)
87
#define SLICK_LIKELY(x) __builtin_expect(!!(x), 1)
88
#define SLICK_UNLIKELY(x) __builtin_expect(!!(x), 0)
89
#else
90
#define SLICK_LIKELY(x) (x)
91
#define SLICK_UNLIKELY(x) (x)
92
#endif
93
94
// Cache line size (platform-specific)
95
#if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || defined(_M_IX86)
96
#define SLICK_CACHE_LINE_SIZE 64
97
#elif defined(__aarch64__) || defined(_M_ARM64)
98
#define SLICK_CACHE_LINE_SIZE 64
99
#else
100
#define SLICK_CACHE_LINE_SIZE 64
// Conservative default
101
#endif
102
103
// Force inline hints
104
#if defined(_MSC_VER)
105
#define SLICK_FORCE_INLINE __forceinline
106
#elif defined(__GNUC__) || defined(__clang__)
107
#define SLICK_FORCE_INLINE inline __attribute__((always_inline))
108
#else
109
#define SLICK_FORCE_INLINE inline
110
#endif
111
112
// No inline hints
113
#if defined(_MSC_VER)
114
#define SLICK_NO_INLINE __declspec(noinline)
115
#elif defined(__GNUC__) || defined(__clang__)
116
#define SLICK_NO_INLINE __attribute__((noinline))
117
#else
118
#define SLICK_NO_INLINE
119
#endif
120
121
// Alignment macros
122
#define SLICK_ALIGNAS(n) alignas(n)
123
#define SLICK_CACHE_ALIGNED SLICK_ALIGNAS(SLICK_CACHE_LINE_SIZE)
124
125
// Namespace macros for easier internal usage
126
#define SLICK_NAMESPACE_BEGIN namespace slick::orderbook {
127
#define SLICK_NAMESPACE_END }
128
129
#define SLICK_DETAIL_NAMESPACE_BEGIN namespace slick::orderbook::detail {
130
#define SLICK_DETAIL_NAMESPACE_END }
131
132
// Debug assertions
133
#ifndef NDEBUG
134
#include <cassert>
135
#define SLICK_ASSERT(expr) assert(expr)
136
#else
137
#define SLICK_ASSERT(expr) ((void)0)
138
#endif
139
140
// Unreachable code hint
141
#if defined(__GNUC__) || defined(__clang__)
142
#define SLICK_UNREACHABLE() __builtin_unreachable()
143
#elif defined(_MSC_VER)
144
#define SLICK_UNREACHABLE() __assume(0)
145
#else
146
#define SLICK_UNREACHABLE() ((void)0)
147
#endif
version.hpp
slick
orderbook
config.hpp
Generated by
1.9.8