SWC-DB
v0.5.11 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
Compat.h
Go to the documentation of this file.
1
/*
2
* SWC-DB© Copyright since 2019 Alex Kashirin <kashirin.alex@gmail.com>
3
* License details at <https://github.com/kashirin-alex/swc-db/#license>
4
*/
5
6
#ifndef swcdb_core_Compact_h
7
#define swcdb_core_Compact_h
8
9
10
12
namespace
SWC
{
13
14
27
namespace
Core {
28
29
30
static_assert(
31
0xff >> 1 == 0x7f,
32
"SWC-DB supports only Little-Endian Architecture!"
33
);
34
35
static_assert(
36
sizeof
(
long
double
) == 16,
37
"SWC-DB supports only long double of 128 bits Architecture!"
38
);
39
40
41
}
42
43
}
44
45
51
#define SWC_STRINGIFY(s) #s
52
53
#define SWC_ATTRIBS(attrs) __attribute__(attrs)
54
#define SWC_ATTR_NOTHROW __nothrow__
55
#define SWC_ATTR_INLINE __always_inline__ //, __artificial__
56
57
58
#ifdef SWC_IMPL_SOURCE
59
# define SWC_SHOULD_INLINE \
60
SWC_ATTRIBS((SWC_ATTR_INLINE)) \
61
extern inline
62
#else
63
# define SWC_SHOULD_INLINE
64
#endif
65
66
67
68
#if defined(__clang__) // CLANG specific
69
70
#define SWC_SHOULD_NOT_INLINE \
71
SWC_ATTRIBS((__noinline__))
72
73
#define SWC_ATTRIB_O3
74
75
#define SWC_PRAGMA_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
76
#define SWC_PRAGMA_DIAGNOSTIC_IGNORED(_flags_) \
77
_Pragma(SWC_STRINGIFY(clang diagnostic ignored _flags_))
78
#define SWC_PRAGMA_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
79
80
81
#elif defined(__GNUC__) // GCC specific
82
83
#define SWC_SHOULD_NOT_INLINE \
84
SWC_ATTRIBS((__noinline__, __noclone__))
85
86
#define SWC_ATTRIB_O3 \
87
optimize("-O3")
88
89
#define SWC_PRAGMA_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
90
#define SWC_PRAGMA_DIAGNOSTIC_IGNORED(_flags_) \
91
_Pragma(SWC_STRINGIFY(GCC diagnostic ignored _flags_))
92
#define SWC_PRAGMA_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
93
94
#endif
95
96
97
#include <cinttypes>
98
#define SWC_FMT_LU SWC_STRINGIFY(%) PRIu64
99
#define SWC_FMT_LD SWC_STRINGIFY(%) PRId64
100
101
102
# define SWC_CAN_INLINE \
103
SWC_ATTRIBS((SWC_ATTR_INLINE)) \
104
inline
105
106
107
#define SWC_CONST_FUNC SWC_ATTRIBS((const))
108
#define SWC_PURE_FUNC SWC_ATTRIBS((pure))
109
#define SWC_MALLOC_FUNC SWC_ATTRIBS((malloc))
110
#define SWC_COLD_FUNC SWC_ATTRIBS((cold))
111
#define SWC_NONULL_RET_FUNC SWC_ATTRIBS((returns_nonnull))
112
113
#define SWC_HIDE SWC_ATTRIBS((visibility ("hidden")))
114
115
116
123
#include <stddef.h>
124
125
126
127
#if defined MIMALLOC
128
#include <mimalloc.h>
// -override
129
#endif
130
131
132
#if !defined(SWC_MALLOC_NOT_INSISTENT) && !defined(__clang__)
133
#include "
swcdb/core/Malloc.h
"
134
135
#elif defined MIMALLOC
136
#include <mimalloc-new-delete.h>
137
#endif
138
139
140
141
142
#include <stdint.h>
143
#include <stdlib.h>
144
#include <unistd.h>
145
#include <signal.h>
146
#include <csignal>
147
#include <cstdlib>
148
#include <cstddef>
// for std::size_t and std::ptrdiff_t
149
#include <memory>
150
#include <cstring>
151
#include <string>
152
#include <vector>
153
#include <functional>
154
#include <thread>
155
#include <unordered_map>
156
#include <map>
157
158
159
static_assert(
160
sizeof
(
size_t
) == 8,
161
"SWC-DB supports only 64+ bits Architecture!"
162
);
163
164
172
#ifdef SWC_USE_ABORT
173
#define SWC_ABORT abort()
174
#else
175
#define SWC_ABORT std::raise(SIGABRT)
176
#endif
177
178
#if defined(__MINGW64__) || defined(_WIN32)
179
#define ENOKEY 126
180
#define EBADR 51
181
#define SWC_QUICK_EXIT(_CODE_) exit(_CODE_)
182
#define SWC_DSO_EXT ".dll"
183
#else
184
#define SWC_QUICK_EXIT(_CODE_) std::quick_exit(_CODE_)
185
#define SWC_DSO_EXT ".so"
186
#endif
187
188
#if defined(SWC_ENABLE_SANITIZER)
189
#define SWC_CAN_QUICK_EXIT(_CODE_)
190
#else
191
#define SWC_CAN_QUICK_EXIT(_CODE_) SWC_QUICK_EXIT(_CODE_)
192
#endif
193
194
195
200
namespace
SWC
{
namespace
Core {
201
202
template
<
typename
T>
203
SWC_CAN_INLINE
204
const
char
*
type_name
(
const
T
& obj) noexcept {
205
return
typeid
(obj).name();
206
}
207
208
}}
209
210
211
212
#include "
swcdb/core/Atomic.h
"
213
#include "
swcdb/core/BitFieldInt.h
"
// for u/int24/40/48/56_t
214
#include "
swcdb/core/Comparators_basic.h
"
215
#include "
swcdb/core/MutexLock.h
"
216
#include "
swcdb/core/Vector.h
"
217
218
#endif // swcdb_core_Compact_h
Atomic.h
Comparators_basic.h
Vector.h
BitFieldInt.h
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition:
Compat.h:102
Malloc.h
SWC
The SWC-DB C++ namespace 'SWC'.
Definition:
main.cc:12
SWC::Config::T
const uint64_t T
Definition:
Property.h:27
MutexLock.h
SWC::Core::type_name
SWC_CAN_INLINE const char * type_name(const T &obj) noexcept
Definition:
Compat.h:204
include
swcdb
core
Compat.h
Generated on Sat Jan 14 2023 10:25:49 for SWC-DB by
1.8.20