From b8d344d4b00a9481ecb6c98cb70abdd7faff3158 Mon Sep 17 00:00:00 2001 From: lemire Date: Fri, 20 Oct 2023 20:24:41 +0000 Subject: [PATCH] deploy: f7e281cadc9a986f5519b491841276cbec6851b5 --- portability_8h_source.html | 261 ++++++++++++++++++------------------- 1 file changed, 129 insertions(+), 132 deletions(-) diff --git a/portability_8h_source.html b/portability_8h_source.html index 4c3ae090c..095d87ede 100644 --- a/portability_8h_source.html +++ b/portability_8h_source.html @@ -141,141 +141,138 @@ $(document).ready(function(){initNavTree('portability_8h_source.html',''); initR
58 
59 #if SIMDJSON_IS_32BITS
60 #ifndef SIMDJSON_NO_PORTABILITY_WARNING
-
61 #pragma message("The simdjson library is designed \
-
62 for 64-bit processors and it seems that you are not \
-
63 compiling for a known 64-bit platform. All fast kernels \
-
64 will be disabled and performance may be poor. Please \
-
65 use a 64-bit target such as x64, 64-bit ARM or 64-bit PPC.")
-
66 #endif // SIMDJSON_NO_PORTABILITY_WARNING
-
67 #endif // SIMDJSON_IS_32BITS
+
61 // In the future, we should allow programmers
+
62 // to get warning.
+
63 #endif // SIMDJSON_NO_PORTABILITY_WARNING
+
64 #endif // SIMDJSON_IS_32BITS
+
65 
+
66 #define SIMDJSON_CAT_IMPLEMENTATION_(a,...) a ## __VA_ARGS__
+
67 #define SIMDJSON_CAT(a,...) SIMDJSON_CAT_IMPLEMENTATION_(a, __VA_ARGS__)
68 
-
69 #define SIMDJSON_CAT_IMPLEMENTATION_(a,...) a ## __VA_ARGS__
-
70 #define SIMDJSON_CAT(a,...) SIMDJSON_CAT_IMPLEMENTATION_(a, __VA_ARGS__)
+
69 #define SIMDJSON_STRINGIFY_IMPLEMENTATION_(a,...) #a SIMDJSON_STRINGIFY(__VA_ARGS__)
+
70 #define SIMDJSON_STRINGIFY(a,...) SIMDJSON_CAT_IMPLEMENTATION_(a, __VA_ARGS__)
71 
-
72 #define SIMDJSON_STRINGIFY_IMPLEMENTATION_(a,...) #a SIMDJSON_STRINGIFY(__VA_ARGS__)
-
73 #define SIMDJSON_STRINGIFY(a,...) SIMDJSON_CAT_IMPLEMENTATION_(a, __VA_ARGS__)
-
74 
-
75 // this is almost standard?
-
76 #undef SIMDJSON_STRINGIFY_IMPLEMENTATION_
-
77 #undef SIMDJSON_STRINGIFY
-
78 #define SIMDJSON_STRINGIFY_IMPLEMENTATION_(a) #a
-
79 #define SIMDJSON_STRINGIFY(a) SIMDJSON_STRINGIFY_IMPLEMENTATION_(a)
-
80 
-
81 // Our fast kernels require 64-bit systems.
+
72 // this is almost standard?
+
73 #undef SIMDJSON_STRINGIFY_IMPLEMENTATION_
+
74 #undef SIMDJSON_STRINGIFY
+
75 #define SIMDJSON_STRINGIFY_IMPLEMENTATION_(a) #a
+
76 #define SIMDJSON_STRINGIFY(a) SIMDJSON_STRINGIFY_IMPLEMENTATION_(a)
+
77 
+
78 // Our fast kernels require 64-bit systems.
+
79 //
+
80 // On 32-bit x86, we lack 64-bit popcnt, lzcnt, blsr instructions.
+
81 // Furthermore, the number of SIMD registers is reduced.
82 //
-
83 // On 32-bit x86, we lack 64-bit popcnt, lzcnt, blsr instructions.
-
84 // Furthermore, the number of SIMD registers is reduced.
-
85 //
-
86 // On 32-bit ARM, we would have smaller registers.
-
87 //
-
88 // The simdjson users should still have the fallback kernel. It is
-
89 // slower, but it should run everywhere.
-
90 
-
91 //
-
92 // Enable valid runtime implementations, and select SIMDJSON_BUILTIN_IMPLEMENTATION
-
93 //
-
94 
-
95 // We are going to use runtime dispatch.
-
96 #if SIMDJSON_IS_X86_64
-
97 #ifdef __clang__
-
98 // clang does not have GCC push pop
-
99 // warning: clang attribute push can't be used within a namespace in clang up
-
100 // til 8.0 so SIMDJSON_TARGET_REGION and SIMDJSON_UNTARGET_REGION must be *outside* of a
-
101 // namespace.
-
102 #define SIMDJSON_TARGET_REGION(T) \
-
103  _Pragma(SIMDJSON_STRINGIFY( \
-
104  clang attribute push(__attribute__((target(T))), apply_to = function)))
-
105 #define SIMDJSON_UNTARGET_REGION _Pragma("clang attribute pop")
-
106 #elif defined(__GNUC__)
-
107 // GCC is easier
-
108 #define SIMDJSON_TARGET_REGION(T) \
-
109  _Pragma("GCC push_options") _Pragma(SIMDJSON_STRINGIFY(GCC target(T)))
-
110 #define SIMDJSON_UNTARGET_REGION _Pragma("GCC pop_options")
-
111 #endif // clang then gcc
-
112 
-
113 #endif // x86
-
114 
-
115 // Default target region macros don't do anything.
-
116 #ifndef SIMDJSON_TARGET_REGION
-
117 #define SIMDJSON_TARGET_REGION(T)
-
118 #define SIMDJSON_UNTARGET_REGION
-
119 #endif
-
120 
-
121 // Is threading enabled?
-
122 #if defined(_REENTRANT) || defined(_MT)
-
123 #ifndef SIMDJSON_THREADS_ENABLED
-
124 #define SIMDJSON_THREADS_ENABLED
-
125 #endif
-
126 #endif
-
127 
-
128 // workaround for large stack sizes under -O0.
-
129 // https://github.com/simdjson/simdjson/issues/691
-
130 #ifdef __APPLE__
-
131 #ifndef __OPTIMIZE__
-
132 // Apple systems have small stack sizes in secondary threads.
-
133 // Lack of compiler optimization may generate high stack usage.
-
134 // Users may want to disable threads for safety, but only when
-
135 // in debug mode which we detect by the fact that the __OPTIMIZE__
-
136 // macro is not defined.
-
137 #undef SIMDJSON_THREADS_ENABLED
-
138 #endif
-
139 #endif
-
140 
-
141 
-
142 #if defined(__clang__)
-
143 #define SIMDJSON_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize("undefined")))
-
144 #elif defined(__GNUC__)
-
145 #define SIMDJSON_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize_undefined))
-
146 #else
-
147 #define SIMDJSON_NO_SANITIZE_UNDEFINED
-
148 #endif
-
149 
-
150 
-
151 #if defined(__clang__) || defined(__GNUC__)
-
152 #if defined(__has_feature)
-
153 # if __has_feature(memory_sanitizer)
-
154 #define SIMDJSON_NO_SANITIZE_MEMORY __attribute__((no_sanitize("memory")))
-
155 # endif // if __has_feature(memory_sanitizer)
-
156 #endif // defined(__has_feature)
-
157 #endif
-
158 // make sure it is defined as 'nothing' if it is unapplicable.
-
159 #ifndef SIMDJSON_NO_SANITIZE_MEMORY
-
160 #define SIMDJSON_NO_SANITIZE_MEMORY
-
161 #endif
-
162 
-
163 #if SIMDJSON_VISUAL_STUDIO
-
164 // This is one case where we do not distinguish between
-
165 // regular visual studio and clang under visual studio.
-
166 // clang under Windows has _stricmp (like visual studio) but not strcasecmp (as clang normally has)
-
167 #define simdjson_strcasecmp _stricmp
-
168 #define simdjson_strncasecmp _strnicmp
-
169 #else
-
170 // The strcasecmp, strncasecmp, and strcasestr functions do not work with multibyte strings (e.g. UTF-8).
-
171 // So they are only useful for ASCII in our context.
-
172 // https://www.gnu.org/software/libunistring/manual/libunistring.html#char-_002a-strings
-
173 #define simdjson_strcasecmp strcasecmp
-
174 #define simdjson_strncasecmp strncasecmp
-
175 #endif
-
176 
-
177 #if defined(NDEBUG) || defined(__OPTIMIZE__) || (defined(_MSC_VER) && !defined(_DEBUG))
-
178 // If NDEBUG is set, or __OPTIMIZE__ is set, or we are under MSVC in release mode,
-
179 // then do away with asserts and use __assume.
-
180 #if SIMDJSON_VISUAL_STUDIO
-
181 #define SIMDJSON_UNREACHABLE() __assume(0)
-
182 #define SIMDJSON_ASSUME(COND) __assume(COND)
-
183 #else
-
184 #define SIMDJSON_UNREACHABLE() __builtin_unreachable();
-
185 #define SIMDJSON_ASSUME(COND) do { if (!(COND)) __builtin_unreachable(); } while (0)
-
186 #endif
-
187 
-
188 #else // defined(NDEBUG) || defined(__OPTIMIZE__) || (defined(_MSC_VER) && !defined(_DEBUG))
-
189 // This should only ever be enabled in debug mode.
-
190 #define SIMDJSON_UNREACHABLE() assert(0);
-
191 #define SIMDJSON_ASSUME(COND) assert(COND)
-
192 
-
193 #endif
-
194 
-
195 #endif // SIMDJSON_PORTABILITY_H
+
83 // On 32-bit ARM, we would have smaller registers.
+
84 //
+
85 // The simdjson users should still have the fallback kernel. It is
+
86 // slower, but it should run everywhere.
+
87 
+
88 //
+
89 // Enable valid runtime implementations, and select SIMDJSON_BUILTIN_IMPLEMENTATION
+
90 //
+
91 
+
92 // We are going to use runtime dispatch.
+
93 #if SIMDJSON_IS_X86_64
+
94 #ifdef __clang__
+
95 // clang does not have GCC push pop
+
96 // warning: clang attribute push can't be used within a namespace in clang up
+
97 // til 8.0 so SIMDJSON_TARGET_REGION and SIMDJSON_UNTARGET_REGION must be *outside* of a
+
98 // namespace.
+
99 #define SIMDJSON_TARGET_REGION(T) \
+
100  _Pragma(SIMDJSON_STRINGIFY( \
+
101  clang attribute push(__attribute__((target(T))), apply_to = function)))
+
102 #define SIMDJSON_UNTARGET_REGION _Pragma("clang attribute pop")
+
103 #elif defined(__GNUC__)
+
104 // GCC is easier
+
105 #define SIMDJSON_TARGET_REGION(T) \
+
106  _Pragma("GCC push_options") _Pragma(SIMDJSON_STRINGIFY(GCC target(T)))
+
107 #define SIMDJSON_UNTARGET_REGION _Pragma("GCC pop_options")
+
108 #endif // clang then gcc
+
109 
+
110 #endif // x86
+
111 
+
112 // Default target region macros don't do anything.
+
113 #ifndef SIMDJSON_TARGET_REGION
+
114 #define SIMDJSON_TARGET_REGION(T)
+
115 #define SIMDJSON_UNTARGET_REGION
+
116 #endif
+
117 
+
118 // Is threading enabled?
+
119 #if defined(_REENTRANT) || defined(_MT)
+
120 #ifndef SIMDJSON_THREADS_ENABLED
+
121 #define SIMDJSON_THREADS_ENABLED
+
122 #endif
+
123 #endif
+
124 
+
125 // workaround for large stack sizes under -O0.
+
126 // https://github.com/simdjson/simdjson/issues/691
+
127 #ifdef __APPLE__
+
128 #ifndef __OPTIMIZE__
+
129 // Apple systems have small stack sizes in secondary threads.
+
130 // Lack of compiler optimization may generate high stack usage.
+
131 // Users may want to disable threads for safety, but only when
+
132 // in debug mode which we detect by the fact that the __OPTIMIZE__
+
133 // macro is not defined.
+
134 #undef SIMDJSON_THREADS_ENABLED
+
135 #endif
+
136 #endif
+
137 
+
138 
+
139 #if defined(__clang__)
+
140 #define SIMDJSON_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize("undefined")))
+
141 #elif defined(__GNUC__)
+
142 #define SIMDJSON_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize_undefined))
+
143 #else
+
144 #define SIMDJSON_NO_SANITIZE_UNDEFINED
+
145 #endif
+
146 
+
147 
+
148 #if defined(__clang__) || defined(__GNUC__)
+
149 #if defined(__has_feature)
+
150 # if __has_feature(memory_sanitizer)
+
151 #define SIMDJSON_NO_SANITIZE_MEMORY __attribute__((no_sanitize("memory")))
+
152 # endif // if __has_feature(memory_sanitizer)
+
153 #endif // defined(__has_feature)
+
154 #endif
+
155 // make sure it is defined as 'nothing' if it is unapplicable.
+
156 #ifndef SIMDJSON_NO_SANITIZE_MEMORY
+
157 #define SIMDJSON_NO_SANITIZE_MEMORY
+
158 #endif
+
159 
+
160 #if SIMDJSON_VISUAL_STUDIO
+
161 // This is one case where we do not distinguish between
+
162 // regular visual studio and clang under visual studio.
+
163 // clang under Windows has _stricmp (like visual studio) but not strcasecmp (as clang normally has)
+
164 #define simdjson_strcasecmp _stricmp
+
165 #define simdjson_strncasecmp _strnicmp
+
166 #else
+
167 // The strcasecmp, strncasecmp, and strcasestr functions do not work with multibyte strings (e.g. UTF-8).
+
168 // So they are only useful for ASCII in our context.
+
169 // https://www.gnu.org/software/libunistring/manual/libunistring.html#char-_002a-strings
+
170 #define simdjson_strcasecmp strcasecmp
+
171 #define simdjson_strncasecmp strncasecmp
+
172 #endif
+
173 
+
174 #if defined(NDEBUG) || defined(__OPTIMIZE__) || (defined(_MSC_VER) && !defined(_DEBUG))
+
175 // If NDEBUG is set, or __OPTIMIZE__ is set, or we are under MSVC in release mode,
+
176 // then do away with asserts and use __assume.
+
177 #if SIMDJSON_VISUAL_STUDIO
+
178 #define SIMDJSON_UNREACHABLE() __assume(0)
+
179 #define SIMDJSON_ASSUME(COND) __assume(COND)
+
180 #else
+
181 #define SIMDJSON_UNREACHABLE() __builtin_unreachable();
+
182 #define SIMDJSON_ASSUME(COND) do { if (!(COND)) __builtin_unreachable(); } while (0)
+
183 #endif
+
184 
+
185 #else // defined(NDEBUG) || defined(__OPTIMIZE__) || (defined(_MSC_VER) && !defined(_DEBUG))
+
186 // This should only ever be enabled in debug mode.
+
187 #define SIMDJSON_UNREACHABLE() assert(0);
+
188 #define SIMDJSON_ASSUME(COND) assert(COND)
+
189 
+
190 #endif
+
191 
+
192 #endif // SIMDJSON_PORTABILITY_H