@@ -37,20 +37,20 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024;
3737} // namespace simdjson
3838
3939#if defined(__GNUC__)
40- // Marks a block with a name so that MCA analysis can see it.
41- #define BEGIN_DEBUG_BLOCK (name ) __asm volatile (" # LLVM-MCA-BEGIN " #name);
42- #define END_DEBUG_BLOCK (name ) __asm volatile (" # LLVM-MCA-END " #name);
43- #define DEBUG_BLOCK (name, block ) BEGIN_DEBUG_BLOCK(name); block; END_DEBUG_BLOCK(name);
40+ // Marks a block with a name so that MCA analysis can see it.
41+ #define BEGIN_DEBUG_BLOCK (name ) __asm volatile (" # LLVM-MCA-BEGIN " #name);
42+ #define END_DEBUG_BLOCK (name ) __asm volatile (" # LLVM-MCA-END " #name);
43+ #define DEBUG_BLOCK (name, block ) BEGIN_DEBUG_BLOCK(name); block; END_DEBUG_BLOCK(name);
4444#else
45- #define BEGIN_DEBUG_BLOCK (name )
46- #define END_DEBUG_BLOCK (name )
47- #define DEBUG_BLOCK (name, block )
45+ #define BEGIN_DEBUG_BLOCK (name )
46+ #define END_DEBUG_BLOCK (name )
47+ #define DEBUG_BLOCK (name, block )
4848#endif
4949
5050#if !defined(_MSC_VER) && !defined(SIMDJSON_NO_COMPUTED_GOTO)
51- // Implemented using Labels as Values which works in GCC and CLANG (and maybe
52- // also in Intel's compiler), but won't work in MSVC.
53- #define SIMDJSON_USE_COMPUTED_GOTO
51+ // Implemented using Labels as Values which works in GCC and CLANG (and maybe
52+ // also in Intel's compiler), but won't work in MSVC.
53+ #define SIMDJSON_USE_COMPUTED_GOTO
5454#endif
5555
5656// Align to N-byte boundary
@@ -60,54 +60,76 @@ constexpr size_t DEFAULT_MAX_DEPTH = 1024;
6060#define ISALIGNED_N (ptr, n ) (((uintptr_t )(ptr) & ((n)-1 )) == 0 )
6161
6262#ifdef _MSC_VER
63- #define really_inline __forceinline
64- #define never_inline __declspec (noinline)
6563
66- #define UNUSED
67- #define WARN_UNUSED
64+ #define really_inline __forceinline
65+ #define never_inline __declspec (noinline)
6866
69- #ifndef likely
70- #define likely (x ) x
71- #endif
72- #ifndef unlikely
73- #define unlikely (x ) x
74- #endif
67+ #define UNUSED
68+ #define WARN_UNUSED
7569
76- #define SIMDJSON_PUSH_DISABLE_WARNINGS __pragma (warning( push ))
77- #define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS __pragma (warning( push, 0 ))
78- #define SIMDJSON_DISABLE_VS_WARNING (WARNING_NUMBER ) __pragma(warning( disable : WARNING_NUMBER ))
79- #define SIMDJSON_DISABLE_DEPRECATED_WARNING SIMDJSON_DISABLE_VS_WARNING (4996 )
80- #define SIMDJSON_POP_DISABLE_WARNINGS __pragma (warning( pop ))
70+ #ifndef likely
71+ #define likely (x ) x
72+ #endif
73+ #ifndef unlikely
74+ #define unlikely (x ) x
75+ #endif
8176
82- #else // MSC_VER
77+ #define SIMDJSON_PUSH_DISABLE_WARNINGS __pragma (warning( push ))
78+ #define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS __pragma (warning( push, 0 ))
79+ #define SIMDJSON_DISABLE_VS_WARNING (WARNING_NUMBER) __pragma(warning( disable : WARNING_NUMBER ))
80+ #define SIMDJSON_DISABLE_DEPRECATED_WARNING SIMDJSON_DISABLE_VS_WARNING (4996 )
81+ #define SIMDJSON_POP_DISABLE_WARNINGS __pragma (warning( pop ))
8382
83+ #if SIMDJSON_USING_LIBRARY
84+ #define SIMDJSON_DLLIMPORTEXPORT __declspec (dllimport)
85+ #else
86+ #define SIMDJSON_DLLIMPORTEXPORT __declspec (dllexport)
87+ #endif
8488
85- #define really_inline inline __attribute__ ((always_inline, unused))
86- #define never_inline inline __attribute__ ((noinline, unused))
89+ #else // MSC_VER
8790
88- #define UNUSED __attribute__ ((unused))
89- #define WARN_UNUSED __attribute__ ((warn_unused_result))
91+ #define really_inline inline __attribute__ ((always_inline, unused))
92+ #define never_inline inline __attribute__ ((noinline, unused))
93+
94+ #define UNUSED __attribute__ ((unused))
95+ #define WARN_UNUSED __attribute__ ((warn_unused_result))
96+
97+ #ifndef likely
98+ #define likely (x ) __builtin_expect(!!(x), 1 )
99+ #endif
100+ #ifndef unlikely
101+ #define unlikely (x ) __builtin_expect(!!(x), 0 )
102+ #endif
103+
104+ #define SIMDJSON_PUSH_DISABLE_WARNINGS _Pragma (" GCC diagnostic push" )
105+ // gcc doesn't seem to disable all warnings with all and extra, add warnings here as necessary
106+ #define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS SIMDJSON_PUSH_DISABLE_WARNINGS \
107+ SIMDJSON_DISABLE_GCC_WARNING (-Wall) \
108+ SIMDJSON_DISABLE_GCC_WARNING(-Wextra) \
109+ SIMDJSON_DISABLE_GCC_WARNING(-Wshadow) \
110+ SIMDJSON_DISABLE_GCC_WARNING(-Wunused-parameter) \
111+ SIMDJSON_DISABLE_GCC_WARNING(-Wimplicit-fallthrough)
112+ #define SIMDJSON_PRAGMA (P) _Pragma(#P)
113+ #define SIMDJSON_DISABLE_GCC_WARNING (WARNING) SIMDJSON_PRAGMA(GCC diagnostic ignored #WARNING)
114+ #define SIMDJSON_DISABLE_DEPRECATED_WARNING SIMDJSON_DISABLE_GCC_WARNING (-Wdeprecated-declarations)
115+ #define SIMDJSON_POP_DISABLE_WARNINGS _Pragma (" GCC diagnostic pop" )
116+
117+ #define SIMDJSON_DLLIMPORTEXPORT
90118
91- #ifndef likely
92- #define likely (x ) __builtin_expect(!!(x), 1 )
93- #endif
94- #ifndef unlikely
95- #define unlikely (x ) __builtin_expect(!!(x), 0 )
96- #endif
119+ #endif // MSC_VER
97120
98- #define SIMDJSON_PUSH_DISABLE_WARNINGS _Pragma (" GCC diagnostic push" )
99- // gcc doesn't seem to disable all warnings with all and extra, add warnings here as necessary
100- #define SIMDJSON_PUSH_DISABLE_ALL_WARNINGS SIMDJSON_PUSH_DISABLE_WARNINGS \
101- SIMDJSON_DISABLE_GCC_WARNING (-Wall) \
102- SIMDJSON_DISABLE_GCC_WARNING(-Wextra) \
103- SIMDJSON_DISABLE_GCC_WARNING(-Wshadow) \
104- SIMDJSON_DISABLE_GCC_WARNING(-Wunused-parameter) \
105- SIMDJSON_DISABLE_GCC_WARNING(-Wimplicit-fallthrough)
106- #define SIMDJSON_PRAGMA (P ) _Pragma (#P)
107- #define SIMDJSON_DISABLE_GCC_WARNING (WARNING ) SIMDJSON_PRAGMA(GCC diagnostic ignored #WARNING)
108- #define SIMDJSON_DISABLE_DEPRECATED_WARNING SIMDJSON_DISABLE_GCC_WARNING (-Wdeprecated-declarations)
109- #define SIMDJSON_POP_DISABLE_WARNINGS _Pragma (" GCC diagnostic pop" )
121+ //
122+ // Backfill std::string_view using nonstd::string_view on C++11
123+ //
124+ #if (!SIMDJSON_CPLUSPLUS17)
110125
111- #endif // MSC_VER
126+ SIMDJSON_PUSH_DISABLE_ALL_WARNINGS
127+ #include " simdjson/nonstd/string_view.hpp"
128+ SIMDJSON_POP_DISABLE_WARNINGS
129+
130+ namespace std {
131+ using string_view = nonstd::string_view;
132+ }
133+ #endif // if (SIMDJSON_CPLUSPLUS < 201703L)
112134
113135#endif // SIMDJSON_COMMON_DEFS_H
0 commit comments