OnixS C++ FIX Engine  4.12.0
API Documentation
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_FIXENGINE_DOXYGEN) && ONIXS_FIXENGINE_DOXYGEN)
23 
24 #include <OnixS/FIXEngine/CompilerDetection.h>
25 
26 #if defined(__GNUC__)
27 #define ONIXS_FIXENGINE_MAY_ALIAS __attribute__((__may_alias__))
28 #else
29 #define ONIXS_FIXENGINE_MAY_ALIAS
30 #endif
31 
32 // https://bugzilla.redhat.com/show_bug.cgi?id=702984
33 #if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 4)
34 #define ONIXS_FIXENGINE_GCC44_SPURIOUS_WARNING_TURNAROUND ONIXS_FIXENGINE_MAY_ALIAS
35 #else
36 #define ONIXS_FIXENGINE_GCC44_SPURIOUS_WARNING_TURNAROUND
37 #endif
38 
39 
40 # if defined(ONIXS_FIXENGINE_COMPILER_CXX_NOEXCEPT) && ONIXS_FIXENGINE_COMPILER_CXX_NOEXCEPT
41 # define ONIXS_FIXENGINE_NOTHROW noexcept
42 # else
43 # define ONIXS_FIXENGINE_NOTHROW throw()
44 # endif
45 
46 # if defined(ONIXS_FIXENGINE_COMPILER_CXX_EXPLICIT_CONVERSIONS) && ONIXS_FIXENGINE_COMPILER_CXX_EXPLICIT_CONVERSIONS
47 # define ONIXS_FIXENGINE_EXPLICIT explicit
48 #else
49 # define ONIXS_FIXENGINE_EXPLICIT
50 #endif
51 
52 #if (__cplusplus >= 201103L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) || (defined(__GXX_EXPERIMENTAL_CXX0X__) && (__GXX_EXPERIMENTAL_CXX0X__))
53 # define ONIXS_FIXENGINE_CXX11
54 #endif
55 
56 #if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
57 # define ONIXS_FIXENGINE_CXX17
58 #endif
59 
60 # if defined(ONIXS_FIXENGINE_COMPILER_CXX_CONSTEXPR) && ONIXS_FIXENGINE_COMPILER_CXX_CONSTEXPR
61 # define ONIXS_FIXENGINE_CONST_OR_CONSTEXPR constexpr
62 #else
63 # define ONIXS_FIXENGINE_CONST_OR_CONSTEXPR const
64 #endif
65 
66 #if defined(__GNUC__)
67 # define ONIXS_FIXENGINE_CHECK_EXPECT(exp,c) (__builtin_expect((exp), (c)))
68 #else
69 # define ONIXS_FIXENGINE_CHECK_EXPECT(exp,c) ((exp))
70 #endif
71 
72 #if !defined(ONIXS_FIXENGINE_NORETURN)
73 # if defined(_MSC_VER)
74 # define ONIXS_FIXENGINE_NORETURN __declspec(noreturn)
75 # elif defined(__GNUC__)
76 # define ONIXS_FIXENGINE_NORETURN __attribute__ ((__noreturn__))
77 # elif defined(__has_cpp_attribute)
78 # if __has_cpp_attribute(noreturn)
79 # define ONIXS_FIXENGINE_NORETURN [[noreturn]]
80 # endif
81 # endif
82 #endif
83 
84 #if !defined(ONIXS_FIXENGINE_NORETURN)
85 # define ONIXS_FIXENGINE_NORETURN
86 #endif
87 
88 
89 #if !defined(ONIXS_FIXENGINE_NODISCARD)
90 # if defined(_MSC_VER)
91 # define ONIXS_FIXENGINE_NODISCARD _Check_return_
92 # elif defined(__GNUC__)
93 # define ONIXS_FIXENGINE_NODISCARD __attribute__((warn_unused_result))
94 # elif defined(__has_cpp_attribute)
95 # if __has_cpp_attribute(nodiscard)
96 # define ONIXS_FIXENGINE_NODISCARD [[nodiscard]]
97 # endif
98 # endif
99 #endif
100 
101 #if defined(__has_cpp_attribute)
102 # if __has_cpp_attribute(unlikely)
103 # define ONIXS_FIXENGINE_UNLIKELY_ATTR [[unlikely]]
104 # endif
105 #endif
106 #if !defined(ONIXS_FIXENGINE_UNLIKELY_ATTR)
107 # define ONIXS_FIXENGINE_UNLIKELY_ATTR
108 #endif
109 
110 #if defined(__has_cpp_attribute)
111 # if __has_cpp_attribute(likely)
112 # define ONIXS_FIXENGINE_LIKELY_ATTR [[likely]]
113 # endif
114 #endif
115 #if !defined(ONIXS_FIXENGINE_LIKELY_ATTR)
116 # define ONIXS_FIXENGINE_LIKELY_ATTR
117 #endif
118 
119 #if !defined(ONIXS_FIXENGINE_NODISCARD)
120 # define ONIXS_FIXENGINE_NODISCARD
121 #endif
122 
123 
124 
125 #if defined(__GNUC__)
126 # define ONIXS_FIXENGINE_UNUSED __attribute__((__unused__))
127 #else
128 # define ONIXS_FIXENGINE_UNUSED
129 #endif
130 
131 #if defined(__GNUC__)
132 # define ONIXS_FIXENGINE_LIKELY(cond) (__builtin_expect((static_cast<bool>((cond))), true))
133 # define ONIXS_FIXENGINE_UNLIKELY(cond) (__builtin_expect((static_cast<bool>((cond))), false))
134 #else
135 # if defined(__has_cpp_attribute)
136 # if __has_cpp_attribute(unlikely)
137 # define ONIXS_FIXENGINE_UNLIKELY(cond) ((cond)) [[unlikely]]
138 # define ONIXS_FIXENGINE_LIKELY(cond) ((cond)) [[likely]]
139 # endif
140 # endif
141 #endif
142 
143 #if !defined(ONIXS_FIXENGINE_LIKELY)
144 # define ONIXS_FIXENGINE_LIKELY(cond) ((cond))
145 #endif
146 
147 #if !defined(ONIXS_FIXENGINE_UNLIKELY)
148 # define ONIXS_FIXENGINE_UNLIKELY(cond) ((cond))
149 #endif
150 
151 #if defined(__GNUC__)
152 #define ONIXS_FIXENGINE_HOTPATH __attribute__((hot))
153 #define ONIXS_FIXENGINE_COLDPATH __attribute__((noinline,cold))
154 #define ONIXS_FIXENGINE_PURE __attribute__((pure))
155 #else
156 #if defined(_MSC_VER)
157 #define ONIXS_FIXENGINE_COLDPATH __declspec(noinline)
158 #else
159 #define ONIXS_FIXENGINE_COLDPATH
160 #endif
161 #define ONIXS_FIXENGINE_HOTPATH
162 #define ONIXS_FIXENGINE_PURE
163 #endif
164 
165 #if defined (ONIXS_FIXENGINE_CXX11)
166 # define ONIXS_FIXENGINE_HAS_TYPE_TRAITS
167 #endif
168 
169 #if defined(ONIXS_FIXENGINE_CXX17)
170 # define ONIXS_FIXENGINE_HAS_STRING_VIEW
171 #endif
172 
173 #if defined(ONIXS_FIXENGINE_COMPILER_CXX_DEFAULTED_FUNCTIONS) && ONIXS_FIXENGINE_COMPILER_CXX_DEFAULTED_FUNCTIONS
174 # define ONIXS_FIXENGINE_DEFAULT = default;
175 #else
176 # define ONIXS_FIXENGINE_DEFAULT {}
177 #endif
178 
179 #if defined NDEBUG
180 # define ONIXS_FIXENGINE_ASSERT(CHECK) void(0)
181 #else
182 # if !defined(ONIXS_FIXENGINE_CXX11)
183 # define ONIXS_FIXENGINE_ASSERT(CHECK) (assert((CHECK)))
184 # else
185 # define ONIXS_FIXENGINE_ASSERT(CHECK) \
186  (ONIXS_FIXENGINE_LIKELY(CHECK) ? void(0) : []() {assert(!#CHECK);}())
187 # endif
188 #endif
189 
190 #define ONIXS_FIXENGINE_HARDWARE_DESTRUCTIVE_INTERFACE_SIZE (64)
191 
192 #else //#if !(defined(ONIXS_DOXYGEN) && ONIXS_DOXYGEN)
193 
194 #define ONIXS_FIXENGINE_CXX11
195 #define ONIXS_FIXENGINE_UNUSED
196 #define ONIXS_FIXENGINE_EXPORTED
197 #define ONIXS_FIXENGINE_GCC44_SPURIOUS_WARNING_TURNAROUND
198 #define ONIXS_FIXENGINE_NOTHROW noexcept
199 #define ONIXS_FIXENGINE_EXPLICIT explicit
200 #define ONIXS_FIXENGINE_CONST_OR_CONSTEXPR constexpr
201 #define ONIXS_FIXENGINE_CONSTEXPR constexpr
202 #define ONIXS_FIXENGINE_OVERRIDE override
203 #define ONIXS_FIXENGINE_FINAL final
204 #define ONIXS_FIXENGINE_COMPILER_CXX_NULLPTR nullptr
205 
206 #define ONIXS_FIXENGINE_NORETURN
207 #define ONIXS_FIXENGINE_NODISCARD
208 
209 #define ONIXS_FIXENGINE_HOTPATH
210 #define ONIXS_FIXENGINE_COLDPATH
211 #define ONIXS_FIXENGINE_PURE
212 
213 #define ONIXS_FIXENGINE_HAS_TYPE_TRAITS
214 #define ONIXS_FIXENGINE_HAS_STRING_VIEW
215 
216 #endif