-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmnl-aux-mnl0.hh
168 lines (152 loc) · 6.6 KB
/
mnl-aux-mnl0.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// mnl-aux-mnl0.hh -- minimal infrastructure (mnl:: Namespaces + Host Compiler Idiosyncrasies) for otherwise self-sufficient modules
/* Copyright (C) 2018, 2019, 2020 Alexey Protasov (AKA Alex or rusini)
This file is part of MANOOL.
MANOOL is free software: you can redistribute it and/or modify it under the terms of the version 3 of the GNU General Public License
as published by the Free Software Foundation (and only version 3).
MANOOL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with MANOOL. If not, see <https://www.gnu.org/licenses/>. */
# ifndef MNL_INCLUDED_MNL0
# define MNL_INCLUDED_MNL0
// Toolchain Checks ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
# ifndef MNL_C_SOURCE
# if __cplusplus < 201103/*C++11*/ || !__STDC_HOSTED__ || !__GNUC__/*g++/clang++/icpc...*/ || !__STRICT_ANSI__/*-std=c++NN*/
# error "Unsupported C++ compiler or compiler mode"
# endif
# else
# if __STDC_VERSION__ < 199901/*C99*/ || !__STDC_HOSTED__ || !__GNUC__/*gcc/clang/icc...*/ || !__STRICT_ANSI__/*-std=cNN*/
# error "Unsupported C compiler or compiler mode"
# endif
# endif
# if !(__i386__ && __SSE2_MATH__ || __x86_64__ || __AARCH64EL__ || __ARMEL__ && __VFP_FP__) || __SIZEOF_LONG__ != __SIZEOF_POINTER__
//# error "Unsupported or not tested target ISA or ABI"
# endif
# if __cplusplus // even more paranoid ABI check
static_assert(sizeof(long) == sizeof(void *), "sizeof(long) == sizeof(void *)");
# endif
// C++ Namespaces //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
# if __cplusplus
# if MNL_WITH_UUID_NS || defined MNL_AUX_UUID
# ifndef MNL_AUX_UUID
# define MNL_AUX_UUID uuid_CF067875_8A9C_4A0D_A889_35989E0140EF
# endif
namespace MNL_AUX_UUID { namespace aux { namespace pub {} using namespace pub; } using namespace aux::pub; } namespace mnl = MNL_AUX_UUID;
# else
# define MNL_AUX_UUID mnl
namespace MNL_AUX_UUID { namespace aux { namespace pub {} using namespace pub; } using namespace aux::pub; }
# endif
# endif
// Compiler Idiosyncrasies /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
# define MNL_PACK __attribute__((__packed__))
# define MNL_ALIGN(ALIGN) __attribute__((__aligned__(ALIGN)))
# define MNL_PRIORITY(PRI) __attribute__((__init_priority__(PRI)))
# // the "proper" way to advise about violations of Strict Aliasing Rules:
# define MNL_BARRIER() __extension__({ __asm volatile ("" : : : "memory"); }) // used by libdecnumber patch
#
# if MNL_USE_EXPECT
# define MNL_LIKELY(...) (!__builtin_expect(!(__VA_ARGS__), 0))
# define MNL_UNLIKELY(...) (!__builtin_expect(!(__VA_ARGS__), 1))
# else
# define MNL_LIKELY(...) (__VA_ARGS__)
# define MNL_UNLIKELY(...) (__VA_ARGS__)
# endif
# if MNL_USE_INLINE
# define MNL_INLINE __attribute__((__always_inline__))
# define MNL_NOINLINE __attribute__((__noinline__))
# else
# define MNL_INLINE
# define MNL_NOINLINE
# endif
#
# define MNL_NORETURN __attribute__((__noreturn__, __noinline__, __cold__))
# define MNL_UNREACHABLE() __builtin_unreachable()
# define MNL_DSO_HIDE __attribute__(__visibility__("hidden")) // may be used to speed up calling sequence a bit
# define MNL_DSO_HIDE_BEGIN _Pragma("GCC visibility push(hidden)") // used by libdecnumber patch
# define MNL_DSO_HIDE_END _Pragma("GCC visibility pop") // ditto
# define MNL_DSO_UNHIDE_BEGIN _Pragma("GCC visibility push(default)") // ditto
# define MNL_DSO_UNHIDE_END _Pragma("GCC visibility pop") // ditto
# if MNL_USE_PURE
# define MNL_PURE __attribute__((__const__))
# define MNL_NOCLOBBER __attribute__((__pure__))
# elif MNL_USE_NOCLOBBER
# define MNL_PURE __attribute__((__pure__))
# define MNL_NOCLOBBER __attribute__((__pure__))
# else
# define MNL_PURE
# define MNL_NOCLOBBER
# endif
// Conditionals ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
# if MNL_WITH_MULTITHREADING
# define MNL_IF_WITH_MT(...) __VA_ARGS__
# define MNL_IF_WITHOUT_MT(...)
# else
# define MNL_IF_WITH_MT(...)
# define MNL_IF_WITHOUT_MT(...) __VA_ARGS__
# endif
# if MNL_WITH_IDENT_OPT
# define MNL_IF_WITH_IDENT_OPT(...) __VA_ARGS__
# else
# define MNL_IF_WITH_IDENT_OPT(...)
# endif
// To provide small workarounds for C++ compiler bugs
# if !__clang__ && !__INTEL_COMPILER && __GNUC__ == 4
# define MNL_IF_GCC4(...) __VA_ARGS__
# define MNL_IF_NOT_GCC4(...)
# else
# define MNL_IF_GCC4(...)
# define MNL_IF_NOT_GCC4(...) __VA_ARGS__
# endif
# if !__clang__ && !__INTEL_COMPILER && __GNUC__ == 5
# define MNL_IF_GCC5(...) __VA_ARGS__
# define MNL_IF_NOT_GCC5(...)
# else
# define MNL_IF_GCC5(...)
# define MNL_IF_NOT_GCC5(...) __VA_ARGS__
# endif
# if !__clang__ && !__INTEL_COMPILER && __GNUC__ == 6
# define MNL_IF_GCC6(...) __VA_ARGS__
# define MNL_IF_NOT_GCC6(...)
# else
# define MNL_IF_GCC6(...)
# define MNL_IF_NOT_GCC6(...) __VA_ARGS__
# endif
# if !__clang__ && !__INTEL_COMPILER && __GNUC__ == 7
# define MNL_IF_GCC7(...) __VA_ARGS__
# define MNL_IF_NOT_GCC7(...)
# else
# define MNL_IF_GCC7(...)
# define MNL_IF_NOT_GCC7(...) __VA_ARGS__
# endif
# if !__clang__ && !__INTEL_COMPILER && __GNUC__ == 8
# define MNL_IF_GCC8(...) __VA_ARGS__
# define MNL_IF_NOT_GCC8(...)
# else
# define MNL_IF_GCC8(...)
# define MNL_IF_NOT_GCC8(...) __VA_ARGS__
# endif
# if !__clang__ && !__INTEL_COMPILER && __GNUC__ == 9
# define MNL_IF_GCC9(...) __VA_ARGS__
# define MNL_IF_NOT_GCC9(...)
# else
# define MNL_IF_GCC9(...)
# define MNL_IF_NOT_GCC9(...) __VA_ARGS__
# endif
# if __clang__
# define MNL_IF_CLANG(...) __VA_ARGS__
# define MNL_IF_NOT_CLANG(...)
# else
# define MNL_IF_CLANG(...)
# define MNL_IF_NOT_CLANG(...) __VA_ARGS__
# endif
# if __INTEL_COMPILER
# define MNL_IF_ICC(...) __VA_ARGS__
# define MNL_IF_NOT_ICC(...)
# else
# define MNL_IF_ICC(...)
# define MNL_IF_NOT_ICC(...) __VA_ARGS__
# endif
# if __cplusplus && MNL_USE_DEBUG
# include <iostream>
namespace MNL_AUX_UUID { namespace aux { using std::cerr; } }
# endif
# endif // # ifndef MNL_INCLUDED_MNL0