OnixS C++ ICE Binary Order Entry Handler 1.1.1
API Documentation
Loading...
Searching...
No Matches
Compiler.h
Go to the documentation of this file.
1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable ONIXS Software
8* Services Agreement (the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18*/
19
20#pragma once
21
22#if !(defined(ONIXS_ICEBOE_DOXYGEN) && ONIXS_ICEBOE_DOXYGEN)
23
26
27#if defined(_MSC_VER) && defined(_MSVC_LANG)
28# define ONIXS_CURRENT_CXX_STD _MSVC_LANG
29#else
30# define ONIXS_CURRENT_CXX_STD __cplusplus
31#endif
32
33#if !defined(ONIXS_ICEBOE_CXX11)
34# error at least C++11 is required
35# define ONIXS_ICEBOE_TERMINATE_COMPILATION
36# endif
37
38# if defined(ONIXS_ICEBOE_CXX11)
39# if (ONIXS_CURRENT_CXX_STD < 201103L)
40# error C++11 was targeted during the OnixS SDK compilation but is not detected now
41# define ONIXS_ICEBOE_TERMINATE_COMPILATION
42# endif
43# endif
44
45# if defined(ONIXS_ICEBOE_CXX14)
46# if (ONIXS_CURRENT_CXX_STD < 201402L)
47# error C++14 was targeted during the OnixS SDK compilation but is not detected now
48# define ONIXS_ICEBOE_TERMINATE_COMPILATION
49# endif
50# endif
51
52# if defined(ONIXS_ICEBOE_CXX17)
53# if (ONIXS_CURRENT_CXX_STD < 201703L)
54# error C++17 was targeted during the OnixS SDK compilation but is not detected now
55# define ONIXS_ICEBOE_TERMINATE_COMPILATION
56# endif
57# endif
58
59# if defined(ONIXS_ICEBOE_CXX20)
60# if !(ONIXS_CURRENT_CXX_STD > 201703L)
61# error C++20 was targeted during the OnixS SDK compilation but is not detected now
62# define ONIXS_ICEBOE_TERMINATE_COMPILATION
63# endif
64# endif
65
66# if defined(ONIXS_ICEBOE_TERMINATE_COMPILATION)
67# include <terminate_compilation>
68#endif
69
70#define ONIXS_ICEBOE_TO_STR_IMPL(X) #X
71#define ONIXS_ICEBOE_TO_STR(X) ONIXS_ICEBOE_TO_STR_IMPL(X)
72
73#define ONIXS_ICEBOE_CONCATENATE_IMPL(X,Y) X##Y
74#define ONIXS_ICEBOE_CONCATENATE(X,Y) ONIXS_ICEBOE_CONCATENATE_IMPL(X,Y)
75#define ONIXS_ICEBOE_MAKE_UNIQUE_NAME(name) ONIXS_ICEBOE_CONCATENATE(___, ONIXS_ICEBOE_CONCATENATE(name, __LINE__))
76
77# if defined(ONIXS_ICEBOE_COMPILER_IS_GNU) | defined(ONIXS_ICEBOE_COMPILER_IS_Clang)
78# define ONIXS_ICEBOE_COMPILER_IS_GNU_or_Clang
79# endif
80
81
82# if defined(ONIXS_ICEBOE_COMPILER_IS_GNU_or_Clang)
83
84#if ((ONIXS_CURRENT_CXX_STD >= 201703L) && (!defined(ONIXS_ICEBOE_CXX17)))
85# define _ONIXS_ICEBOE_DTS_BUILD 1
86#else
87# define _ONIXS_ICEBOE_DTS_BUILD 0
88#endif
89
90#if defined(ONIXS_ICEBOE_COMPILER_IS_GNU)
91# if (__GNUC__ >= 9) && !_ONIXS_ICEBOE_DTS_BUILD
92# define ONIXS_ICEBOE_LIKELY(cond) (__builtin_expect_with_probability((static_cast<bool>((cond))), true, 0.99999f))
93# define ONIXS_ICEBOE_UNLIKELY(cond) (__builtin_expect_with_probability((static_cast<bool>((cond))), false, 0.99999f))
94# else
95# define ONIXS_ICEBOE_LIKELY(cond) (__builtin_expect((static_cast<bool>((cond))), true))
96# define ONIXS_ICEBOE_UNLIKELY(cond) (__builtin_expect((static_cast<bool>((cond))), false))
97# endif
98#endif
99
100#undef _ONIXS_ICEBOE_DTS_BUILD
101
102#if defined(ONIXS_ICEBOE_COMPILER_IS_Clang)
103# define ONIXS_ICEBOE_LIKELY(cond) (__builtin_expect((static_cast<bool>((cond))), true))
104# define ONIXS_ICEBOE_UNLIKELY(cond) (__builtin_expect((static_cast<bool>((cond))), false))
105#endif
106
107# define ONIXS_ICEBOE_UNUSED __attribute__((__unused__))
108# define ONIXS_ICEBOE_HOTPATH __attribute__((hot))
109# define ONIXS_ICEBOE_COLDPATH __attribute__((noinline,cold))
110# define ONIXS_ICEBOE_NODISCARD __attribute__((warn_unused_result))
111# define ONIXS_ICEBOE_PURE
112# define ONIXS_ICEBOE_NONULL __attribute__((nonnull))
113# define ONIXS_ICEBOE_FORCEINLINE inline __attribute__ ((__always_inline__))
114# define ONIXS_ICEBOE_PRAGMA(x) _Pragma(#x)
115
116// https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0012r1.html
117#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510L
118# define ONIXS_ICEBOE_CXX17_NOEXCEPT 1
119#else
120# define ONIXS_ICEBOE_CXX17_NOEXCEPT 0
121#endif
122
123
124
125#elif defined(ONIXS_ICEBOE_COMPILER_IS_MSVC)
126
127# define ONIXS_ICEBOE_LIKELY(cond) ((cond))
128# define ONIXS_ICEBOE_UNLIKELY(cond) ((cond))
129# define ONIXS_ICEBOE_PURE
130# define ONIXS_ICEBOE_UNUSED
131# define ONIXS_ICEBOE_HOTPATH
132# define ONIXS_ICEBOE_COLDPATH
133# define ONIXS_ICEBOE_NODISCARD _Check_return_
134# define ONIXS_ICEBOE_NONULL
135# define ONIXS_ICEBOE_FORCEINLINE inline
136# define ONIXS_ICEBOE_PRAGMA(x) __pragma(x)
137
138#else
139# error Unsupported compiler
140#endif
141
142#define ONIXS_ICEBOE_STATIC_ASSERT(...) static_assert(__VA_ARGS__, "")
143#define ONIXS_ICEBOE_CHECK_NOTHROW(equation) ONIXS_ICEBOE_STATIC_ASSERT(noexcept((equation)))
144
145
146#if defined NDEBUG
147# define ONIXS_ICEBOE_ASSERT(CHECK) void(0)
148#else
149# define ONIXS_ICEBOE_ASSERT(CHECK) ((CHECK) ? void(0) : []() {assert(!#CHECK);}())
150#endif
151
152#define ONIXS_ICEBOE_HARDWARE_DESTRUCTIVE_INTERFACE_SIZE (64)
153
154#else //#if !(defined(ONIXS_DOXYGEN) && ONIXS_DOXYGEN)
155#define ONIXS_ICEBOE_EXPORTED
156#define ONIXS_ICEBOE_NODISCARD
157#define ONIXS_ICEBOE_HOTPATH
158#define ONIXS_ICEBOE_COLDPATH
159#define ONIXS_ICEBOE_PURE
160#define ONIXS_ICEBOE_CXX11
161#define ONIXS_ICEBOE_CXX14
162#define ONIXS_ICEBOE_CXX17
163#define ONIXS_ICEBOE_CXX20
164#define ONIXS_ICEBOE_UNUSED
165#define ONIXS_ICEBOE_CXX17_NOEXCEPT 0
166#define ONIXS_ICEBOE_PRAGMA(x)
167#endif
168
169#define ONIXS_ICEBOE_DATA_PACKING_BEGIN(alignment) ONIXS_ICEBOE_PRAGMA(pack(push, alignment))
170#define ONIXS_ICEBOE_DATA_PACKING_END ONIXS_ICEBOE_PRAGMA(pack(pop))