|
1 | | -#ifndef SIMDJSON_COMMON_DEFS_H |
2 | | -#define SIMDJSON_COMMON_DEFS_H |
3 | | - |
4 | | -#include "simdjson/portability.h" |
5 | | - |
6 | | -#include <cassert> |
7 | | - |
8 | | -// the input buf should be readable up to buf + SIMDJSON_PADDING |
9 | | -#define SIMDJSON_PADDING sizeof(__m256i) |
10 | | - |
11 | | -#ifndef _MSC_VER |
12 | | -// Implemented using Labels as Values which works in GCC and CLANG (and maybe |
13 | | -// also in Intel's compiler), but won't work in MSVC. |
14 | | -#define SIMDJSON_USE_COMPUTED_GOTO |
15 | | -#endif |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | -// Align to N-byte boundary |
21 | | -#define ROUNDUP_N(a, n) (((a) + ((n)-1)) & ~((n)-1)) |
22 | | -#define ROUNDDOWN_N(a, n) ((a) & ~((n)-1)) |
23 | | - |
24 | | -#define ISALIGNED_N(ptr, n) (((uintptr_t)(ptr) & ((n)-1)) == 0) |
25 | | - |
26 | | -#ifdef _MSC_VER |
27 | | - |
28 | | - |
29 | | -#define really_inline inline |
30 | | -#define never_inline __declspec(noinline) |
31 | | - |
32 | | -#define UNUSED |
33 | | -#define WARN_UNUSED |
34 | | - |
35 | | -#ifndef likely |
36 | | -#define likely(x) x |
37 | | -#endif |
38 | | -#ifndef unlikely |
39 | | -#define unlikely(x) x |
40 | | -#endif |
41 | | - |
42 | | -#else |
43 | | - |
44 | | -#define really_inline inline __attribute__((always_inline, unused)) |
45 | | -#define never_inline inline __attribute__((noinline, unused)) |
46 | | - |
47 | | -#define UNUSED __attribute__((unused)) |
48 | | -#define WARN_UNUSED __attribute__((warn_unused_result)) |
49 | | - |
50 | | -#ifndef likely |
51 | | -#define likely(x) __builtin_expect(!!(x), 1) |
52 | | -#endif |
53 | | -#ifndef unlikely |
54 | | -#define unlikely(x) __builtin_expect(!!(x), 0) |
55 | | -#endif |
56 | | - |
57 | | -#endif // MSC_VER |
58 | | - |
59 | | -#endif // SIMDJSON_COMMON_DEFS_H |
| 1 | +#ifndef SIMDJSON_COMMON_DEFS_H |
| 2 | +#define SIMDJSON_COMMON_DEFS_H |
| 3 | + |
| 4 | +#include "simdjson/portability.h" |
| 5 | + |
| 6 | +#include <cassert> |
| 7 | + |
| 8 | +// the input buf should be readable up to buf + SIMDJSON_PADDING |
| 9 | +#define SIMDJSON_PADDING sizeof(__m256i) |
| 10 | + |
| 11 | +#ifndef _MSC_VER |
| 12 | +// Implemented using Labels as Values which works in GCC and CLANG (and maybe |
| 13 | +// also in Intel's compiler), but won't work in MSVC. |
| 14 | +#define SIMDJSON_USE_COMPUTED_GOTO |
| 15 | +#endif |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | +// Align to N-byte boundary |
| 21 | +#define ROUNDUP_N(a, n) (((a) + ((n)-1)) & ~((n)-1)) |
| 22 | +#define ROUNDDOWN_N(a, n) ((a) & ~((n)-1)) |
| 23 | + |
| 24 | +#define ISALIGNED_N(ptr, n) (((uintptr_t)(ptr) & ((n)-1)) == 0) |
| 25 | + |
| 26 | +#ifdef _MSC_VER |
| 27 | + |
| 28 | + |
| 29 | +#define really_inline inline |
| 30 | +#define never_inline __declspec(noinline) |
| 31 | + |
| 32 | +#define UNUSED |
| 33 | +#define WARN_UNUSED |
| 34 | + |
| 35 | +#ifndef likely |
| 36 | +#define likely(x) x |
| 37 | +#endif |
| 38 | +#ifndef unlikely |
| 39 | +#define unlikely(x) x |
| 40 | +#endif |
| 41 | + |
| 42 | +#else |
| 43 | + |
| 44 | +#define really_inline inline __attribute__((always_inline, unused)) |
| 45 | +#define never_inline inline __attribute__((noinline, unused)) |
| 46 | + |
| 47 | +#define UNUSED __attribute__((unused)) |
| 48 | +#define WARN_UNUSED __attribute__((warn_unused_result)) |
| 49 | + |
| 50 | +#ifndef likely |
| 51 | +#define likely(x) __builtin_expect(!!(x), 1) |
| 52 | +#endif |
| 53 | +#ifndef unlikely |
| 54 | +#define unlikely(x) __builtin_expect(!!(x), 0) |
| 55 | +#endif |
| 56 | + |
| 57 | +#endif // MSC_VER |
| 58 | + |
| 59 | +#endif // SIMDJSON_COMMON_DEFS_H |
0 commit comments