simdutf
6.1.1
Unicode at GB/s.
Loading...
Searching...
No Matches
common_defs.h
1
#ifndef SIMDUTF_COMMON_DEFS_H
2
#define SIMDUTF_COMMON_DEFS_H
3
4
#include "simdutf/portability.h"
5
#include "simdutf/avx512.h"
6
7
#if defined(SIMDUTF_REGULAR_VISUAL_STUDIO)
8
#define SIMDUTF_DEPRECATED __declspec(deprecated)
9
10
#define simdutf_really_inline __forceinline
// really inline in release mode
11
#define simdutf_always_inline __forceinline
// always inline, no matter what
12
#define simdutf_never_inline __declspec(noinline)
13
14
#define simdutf_unused
15
#define simdutf_warn_unused
16
17
#ifndef simdutf_likely
18
#define simdutf_likely(x) x
19
#endif
20
#ifndef simdutf_unlikely
21
#define simdutf_unlikely(x) x
22
#endif
23
24
#define SIMDUTF_PUSH_DISABLE_WARNINGS __pragma(warning(push))
25
#define SIMDUTF_PUSH_DISABLE_ALL_WARNINGS __pragma(warning(push, 0))
26
#define SIMDUTF_DISABLE_VS_WARNING(WARNING_NUMBER) \
27
__pragma(warning(disable : WARNING_NUMBER))
28
// Get rid of Intellisense-only warnings (Code Analysis)
29
// Though __has_include is C++17, it is supported in Visual Studio 2017 or
30
// better (_MSC_VER>=1910).
31
#ifdef __has_include
32
#if __has_include(<CppCoreCheck\Warnings.h>)
33
#include <CppCoreCheck\Warnings.h>
34
#define SIMDUTF_DISABLE_UNDESIRED_WARNINGS \
35
SIMDUTF_DISABLE_VS_WARNING(ALL_CPPCORECHECK_WARNINGS)
36
#endif
37
#endif
38
39
#ifndef SIMDUTF_DISABLE_UNDESIRED_WARNINGS
40
#define SIMDUTF_DISABLE_UNDESIRED_WARNINGS
41
#endif
42
43
#define SIMDUTF_DISABLE_DEPRECATED_WARNING SIMDUTF_DISABLE_VS_WARNING(4996)
44
#define SIMDUTF_DISABLE_STRICT_OVERFLOW_WARNING
45
#define SIMDUTF_POP_DISABLE_WARNINGS __pragma(warning(pop))
46
47
#else
// SIMDUTF_REGULAR_VISUAL_STUDIO
48
#if defined(__OPTIMIZE__) || defined(NDEBUG)
49
#define simdutf_really_inline inline __attribute__((always_inline))
50
#else
51
#define simdutf_really_inline inline
52
#endif
53
#define simdutf_always_inline \
54
inline __attribute__((always_inline))
// always inline, no matter what
55
#define SIMDUTF_DEPRECATED __attribute__((deprecated))
56
#define simdutf_never_inline inline __attribute__((noinline))
57
58
#define simdutf_unused __attribute__((unused))
59
#define simdutf_warn_unused __attribute__((warn_unused_result))
60
61
#ifndef simdutf_likely
62
#define simdutf_likely(x) __builtin_expect(!!(x), 1)
63
#endif
64
#ifndef simdutf_unlikely
65
#define simdutf_unlikely(x) __builtin_expect(!!(x), 0)
66
#endif
67
68
// clang-format off
69
#define SIMDUTF_PUSH_DISABLE_WARNINGS _Pragma("GCC diagnostic push")
70
// gcc doesn't seem to disable all warnings with all and extra, add warnings
71
// here as necessary
72
#define SIMDUTF_PUSH_DISABLE_ALL_WARNINGS \
73
SIMDUTF_PUSH_DISABLE_WARNINGS \
74
SIMDUTF_DISABLE_GCC_WARNING(-Weffc++) \
75
SIMDUTF_DISABLE_GCC_WARNING(-Wall) \
76
SIMDUTF_DISABLE_GCC_WARNING(-Wconversion) \
77
SIMDUTF_DISABLE_GCC_WARNING(-Wextra) \
78
SIMDUTF_DISABLE_GCC_WARNING(-Wattributes) \
79
SIMDUTF_DISABLE_GCC_WARNING(-Wimplicit-fallthrough) \
80
SIMDUTF_DISABLE_GCC_WARNING(-Wnon-virtual-dtor) \
81
SIMDUTF_DISABLE_GCC_WARNING(-Wreturn-type) \
82
SIMDUTF_DISABLE_GCC_WARNING(-Wshadow) \
83
SIMDUTF_DISABLE_GCC_WARNING(-Wunused-parameter) \
84
SIMDUTF_DISABLE_GCC_WARNING(-Wunused-variable)
85
#define SIMDUTF_PRAGMA(P) _Pragma(#P)
86
#define SIMDUTF_DISABLE_GCC_WARNING(WARNING) \
87
SIMDUTF_PRAGMA(GCC diagnostic ignored #WARNING)
88
#if defined(SIMDUTF_CLANG_VISUAL_STUDIO)
89
#define SIMDUTF_DISABLE_UNDESIRED_WARNINGS \
90
SIMDUTF_DISABLE_GCC_WARNING(-Wmicrosoft-include)
91
#else
92
#define SIMDUTF_DISABLE_UNDESIRED_WARNINGS
93
#endif
94
#define SIMDUTF_DISABLE_DEPRECATED_WARNING \
95
SIMDUTF_DISABLE_GCC_WARNING(-Wdeprecated-declarations)
96
#define SIMDUTF_DISABLE_STRICT_OVERFLOW_WARNING \
97
SIMDUTF_DISABLE_GCC_WARNING(-Wstrict-overflow)
98
#define SIMDUTF_POP_DISABLE_WARNINGS _Pragma("GCC diagnostic pop")
99
// clang-format on
100
101
#endif
// MSC_VER
102
103
#ifndef SIMDUTF_DLLIMPORTEXPORT
104
#if defined(SIMDUTF_VISUAL_STUDIO)
110
#if SIMDUTF_USING_LIBRARY
111
#define SIMDUTF_DLLIMPORTEXPORT __declspec(dllimport)
112
#else
113
#define SIMDUTF_DLLIMPORTEXPORT __declspec(dllexport)
114
#endif
115
#else
116
#define SIMDUTF_DLLIMPORTEXPORT
117
#endif
118
#endif
119
120
#endif
// SIMDUTF_COMMON_DEFS_H
include
simdutf
common_defs.h
Generated by
1.9.8