OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8CONFIG_H_ | 5 #ifndef V8CONFIG_H_ |
6 #define V8CONFIG_H_ | 6 #define V8CONFIG_H_ |
7 | 7 |
8 // clang-format off | 8 // clang-format off |
9 | 9 |
10 // Platform headers for feature detection below. | 10 // Platform headers for feature detection below. |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // | 167 // |
168 // Compiler-specific feature detection | 168 // Compiler-specific feature detection |
169 // | 169 // |
170 // V8_HAS___ALIGNOF - __alignof(type) operator supported | 170 // V8_HAS___ALIGNOF - __alignof(type) operator supported |
171 // V8_HAS___ALIGNOF__ - __alignof__(type) operator supported | 171 // V8_HAS___ALIGNOF__ - __alignof__(type) operator supported |
172 // V8_HAS_ATTRIBUTE_ALIGNED - __attribute__((aligned(n))) supported | 172 // V8_HAS_ATTRIBUTE_ALIGNED - __attribute__((aligned(n))) supported |
173 // V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline)) | 173 // V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline)) |
174 // supported | 174 // supported |
175 // V8_HAS_ATTRIBUTE_DEPRECATED - __attribute__((deprecated)) supported | 175 // V8_HAS_ATTRIBUTE_DEPRECATED - __attribute__((deprecated)) supported |
176 // V8_HAS_ATTRIBUTE_NOINLINE - __attribute__((noinline)) supported | 176 // V8_HAS_ATTRIBUTE_NOINLINE - __attribute__((noinline)) supported |
177 // V8_HAS_ATTRIBUTE_NORETURN - __attribute__((noreturn)) supported | |
178 // V8_HAS_ATTRIBUTE_UNUSED - __attribute__((unused)) supported | 177 // V8_HAS_ATTRIBUTE_UNUSED - __attribute__((unused)) supported |
179 // V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported | 178 // V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported |
180 // V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT - __attribute__((warn_unused_result)) | 179 // V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT - __attribute__((warn_unused_result)) |
181 // supported | 180 // supported |
182 // V8_HAS_BUILTIN_CLZ - __builtin_clz() supported | 181 // V8_HAS_BUILTIN_CLZ - __builtin_clz() supported |
183 // V8_HAS_BUILTIN_CTZ - __builtin_ctz() supported | 182 // V8_HAS_BUILTIN_CTZ - __builtin_ctz() supported |
184 // V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported | 183 // V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported |
185 // V8_HAS_BUILTIN_FRAME_ADDRESS - __builtin_frame_address() supported | 184 // V8_HAS_BUILTIN_FRAME_ADDRESS - __builtin_frame_address() supported |
186 // V8_HAS_BUILTIN_POPCOUNT - __builtin_popcount() supported | 185 // V8_HAS_BUILTIN_POPCOUNT - __builtin_popcount() supported |
187 // V8_HAS_BUILTIN_SADD_OVERFLOW - __builtin_sadd_overflow() supported | 186 // V8_HAS_BUILTIN_SADD_OVERFLOW - __builtin_sadd_overflow() supported |
188 // V8_HAS_BUILTIN_SSUB_OVERFLOW - __builtin_ssub_overflow() supported | 187 // V8_HAS_BUILTIN_SSUB_OVERFLOW - __builtin_ssub_overflow() supported |
189 // V8_HAS_BUILTIN_UADD_OVERFLOW - __builtin_uadd_overflow() supported | 188 // V8_HAS_BUILTIN_UADD_OVERFLOW - __builtin_uadd_overflow() supported |
190 // V8_HAS_DECLSPEC_ALIGN - __declspec(align(n)) supported | 189 // V8_HAS_DECLSPEC_ALIGN - __declspec(align(n)) supported |
191 // V8_HAS_DECLSPEC_DEPRECATED - __declspec(deprecated) supported | 190 // V8_HAS_DECLSPEC_DEPRECATED - __declspec(deprecated) supported |
192 // V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported | 191 // V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported |
193 // V8_HAS_DECLSPEC_SELECTANY - __declspec(selectany) supported | 192 // V8_HAS_DECLSPEC_SELECTANY - __declspec(selectany) supported |
194 // V8_HAS_DECLSPEC_NORETURN - __declspec(noreturn) supported | |
195 // V8_HAS___FORCEINLINE - __forceinline supported | 193 // V8_HAS___FORCEINLINE - __forceinline supported |
196 // | 194 // |
197 // Note that testing for compilers and/or features must be done using #if | 195 // Note that testing for compilers and/or features must be done using #if |
198 // not #ifdef. For example, to test for Intel C++ Compiler, use: | 196 // not #ifdef. For example, to test for Intel C++ Compiler, use: |
199 // #if V8_CC_INTEL | 197 // #if V8_CC_INTEL |
200 // ... | 198 // ... |
201 // #endif | 199 // #endif |
202 | 200 |
203 #if defined(__clang__) | 201 #if defined(__clang__) |
204 | 202 |
205 #if defined(__GNUC__) // Clang in gcc mode. | 203 #if defined(__GNUC__) // Clang in gcc mode. |
206 # define V8_CC_GNU 1 | 204 # define V8_CC_GNU 1 |
207 #endif | 205 #endif |
208 | 206 |
209 // Clang defines __alignof__ as alias for __alignof | 207 // Clang defines __alignof__ as alias for __alignof |
210 # define V8_HAS___ALIGNOF 1 | 208 # define V8_HAS___ALIGNOF 1 |
211 # define V8_HAS___ALIGNOF__ V8_HAS___ALIGNOF | 209 # define V8_HAS___ALIGNOF__ V8_HAS___ALIGNOF |
212 | 210 |
213 # define V8_HAS_ATTRIBUTE_ALIGNED (__has_attribute(aligned)) | 211 # define V8_HAS_ATTRIBUTE_ALIGNED (__has_attribute(aligned)) |
214 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline)) | 212 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline)) |
215 # define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated)) | 213 # define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated)) |
216 # define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline)) | 214 # define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline)) |
217 # define V8_HAS_ATTRIBUTE_NORETURN (__has_attribute(noreturn)) | |
218 # define V8_HAS_ATTRIBUTE_UNUSED (__has_attribute(unused)) | 215 # define V8_HAS_ATTRIBUTE_UNUSED (__has_attribute(unused)) |
219 # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility)) | 216 # define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility)) |
220 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ | 217 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ |
221 (__has_attribute(warn_unused_result)) | 218 (__has_attribute(warn_unused_result)) |
222 | 219 |
223 # define V8_HAS_BUILTIN_CLZ (__has_builtin(__builtin_clz)) | 220 # define V8_HAS_BUILTIN_CLZ (__has_builtin(__builtin_clz)) |
224 # define V8_HAS_BUILTIN_CTZ (__has_builtin(__builtin_ctz)) | 221 # define V8_HAS_BUILTIN_CTZ (__has_builtin(__builtin_ctz)) |
225 # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect)) | 222 # define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect)) |
226 # define V8_HAS_BUILTIN_FRAME_ADDRESS (__has_builtin(__builtin_frame_address)) | 223 # define V8_HAS_BUILTIN_FRAME_ADDRESS (__has_builtin(__builtin_frame_address)) |
227 # define V8_HAS_BUILTIN_POPCOUNT (__has_builtin(__builtin_popcount)) | 224 # define V8_HAS_BUILTIN_POPCOUNT (__has_builtin(__builtin_popcount)) |
(...skipping 21 matching lines...) Expand all Loading... |
249 # define V8_HAS___ALIGNOF__ (V8_GNUC_PREREQ(4, 3, 0)) | 246 # define V8_HAS___ALIGNOF__ (V8_GNUC_PREREQ(4, 3, 0)) |
250 | 247 |
251 # define V8_HAS_ATTRIBUTE_ALIGNED (V8_GNUC_PREREQ(2, 95, 0)) | 248 # define V8_HAS_ATTRIBUTE_ALIGNED (V8_GNUC_PREREQ(2, 95, 0)) |
252 // always_inline is available in gcc 4.0 but not very reliable until 4.4. | 249 // always_inline is available in gcc 4.0 but not very reliable until 4.4. |
253 // Works around "sorry, unimplemented: inlining failed" build errors with | 250 // Works around "sorry, unimplemented: inlining failed" build errors with |
254 // older compilers. | 251 // older compilers. |
255 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (V8_GNUC_PREREQ(4, 4, 0)) | 252 # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (V8_GNUC_PREREQ(4, 4, 0)) |
256 # define V8_HAS_ATTRIBUTE_DEPRECATED (V8_GNUC_PREREQ(3, 4, 0)) | 253 # define V8_HAS_ATTRIBUTE_DEPRECATED (V8_GNUC_PREREQ(3, 4, 0)) |
257 # define V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE (V8_GNUC_PREREQ(4, 5, 0)) | 254 # define V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE (V8_GNUC_PREREQ(4, 5, 0)) |
258 # define V8_HAS_ATTRIBUTE_NOINLINE (V8_GNUC_PREREQ(3, 4, 0)) | 255 # define V8_HAS_ATTRIBUTE_NOINLINE (V8_GNUC_PREREQ(3, 4, 0)) |
259 # define V8_HAS_ATTRIBUTE_NORETURN (V8_GNUC_PREREQ(2, 5, 0)) | |
260 # define V8_HAS_ATTRIBUTE_UNUSED (V8_GNUC_PREREQ(2, 95, 0)) | 256 # define V8_HAS_ATTRIBUTE_UNUSED (V8_GNUC_PREREQ(2, 95, 0)) |
261 # define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0)) | 257 # define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0)) |
262 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ | 258 # define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ |
263 (!V8_CC_INTEL && V8_GNUC_PREREQ(4, 1, 0)) | 259 (!V8_CC_INTEL && V8_GNUC_PREREQ(4, 1, 0)) |
264 | 260 |
265 # define V8_HAS_BUILTIN_CLZ (V8_GNUC_PREREQ(3, 4, 0)) | 261 # define V8_HAS_BUILTIN_CLZ (V8_GNUC_PREREQ(3, 4, 0)) |
266 # define V8_HAS_BUILTIN_CTZ (V8_GNUC_PREREQ(3, 4, 0)) | 262 # define V8_HAS_BUILTIN_CTZ (V8_GNUC_PREREQ(3, 4, 0)) |
267 # define V8_HAS_BUILTIN_EXPECT (V8_GNUC_PREREQ(2, 96, 0)) | 263 # define V8_HAS_BUILTIN_EXPECT (V8_GNUC_PREREQ(2, 96, 0)) |
268 # define V8_HAS_BUILTIN_FRAME_ADDRESS (V8_GNUC_PREREQ(2, 96, 0)) | 264 # define V8_HAS_BUILTIN_FRAME_ADDRESS (V8_GNUC_PREREQ(2, 96, 0)) |
269 # define V8_HAS_BUILTIN_POPCOUNT (V8_GNUC_PREREQ(3, 4, 0)) | 265 # define V8_HAS_BUILTIN_POPCOUNT (V8_GNUC_PREREQ(3, 4, 0)) |
(...skipping 12 matching lines...) Expand all Loading... |
282 #endif | 278 #endif |
283 | 279 |
284 #if defined(_MSC_VER) | 280 #if defined(_MSC_VER) |
285 # define V8_CC_MSVC 1 | 281 # define V8_CC_MSVC 1 |
286 # define V8_HAS___ALIGNOF 1 | 282 # define V8_HAS___ALIGNOF 1 |
287 | 283 |
288 # define V8_HAS_DECLSPEC_ALIGN 1 | 284 # define V8_HAS_DECLSPEC_ALIGN 1 |
289 # define V8_HAS_DECLSPEC_DEPRECATED 1 | 285 # define V8_HAS_DECLSPEC_DEPRECATED 1 |
290 # define V8_HAS_DECLSPEC_NOINLINE 1 | 286 # define V8_HAS_DECLSPEC_NOINLINE 1 |
291 # define V8_HAS_DECLSPEC_SELECTANY 1 | 287 # define V8_HAS_DECLSPEC_SELECTANY 1 |
292 # define V8_HAS_DECLSPEC_NORETURN 1 | |
293 | 288 |
294 # define V8_HAS___FORCEINLINE 1 | 289 # define V8_HAS___FORCEINLINE 1 |
295 | 290 |
296 #endif | 291 #endif |
297 | 292 |
298 | 293 |
299 // ----------------------------------------------------------------------------- | 294 // ----------------------------------------------------------------------------- |
300 // Helper macros | 295 // Helper macros |
301 | 296 |
302 // A macro used to make better inlining. Don't bother for debug builds. | 297 // A macro used to make better inlining. Don't bother for debug builds. |
(...skipping 14 matching lines...) Expand all Loading... |
317 // V8_NOINLINE int GetMinusOne() { return -1; } | 312 // V8_NOINLINE int GetMinusOne() { return -1; } |
318 #if !defined(DEBUG) && V8_HAS_ATTRIBUTE_NOINLINE | 313 #if !defined(DEBUG) && V8_HAS_ATTRIBUTE_NOINLINE |
319 # define V8_NOINLINE __attribute__((noinline)) | 314 # define V8_NOINLINE __attribute__((noinline)) |
320 #elif !defined(DEBUG) && V8_HAS_DECLSPEC_NOINLINE | 315 #elif !defined(DEBUG) && V8_HAS_DECLSPEC_NOINLINE |
321 # define V8_NOINLINE __declspec(noinline) | 316 # define V8_NOINLINE __declspec(noinline) |
322 #else | 317 #else |
323 # define V8_NOINLINE /* NOT SUPPORTED */ | 318 # define V8_NOINLINE /* NOT SUPPORTED */ |
324 #endif | 319 #endif |
325 | 320 |
326 | 321 |
327 // A macro used to tell the compiler that a particular function never returns. | |
328 // Use like: | |
329 // V8_NORETURN void MyAbort() { abort(); } | |
330 #if V8_HAS_ATTRIBUTE_NORETURN | |
331 # define V8_NORETURN __attribute__((noreturn)) | |
332 #elif HAS_DECLSPEC_NORETURN | |
333 # define V8_NORETURN __declspec(noreturn) | |
334 #else | |
335 # define V8_NORETURN /* NOT SUPPORTED */ | |
336 #endif | |
337 | |
338 | |
339 // A macro (V8_DEPRECATED) to mark classes or functions as deprecated. | 322 // A macro (V8_DEPRECATED) to mark classes or functions as deprecated. |
340 #if defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE | 323 #if defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE |
341 #define V8_DEPRECATED(message, declarator) \ | 324 #define V8_DEPRECATED(message, declarator) \ |
342 declarator __attribute__((deprecated(message))) | 325 declarator __attribute__((deprecated(message))) |
343 #elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED | 326 #elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED |
344 #define V8_DEPRECATED(message, declarator) \ | 327 #define V8_DEPRECATED(message, declarator) \ |
345 declarator __attribute__((deprecated)) | 328 declarator __attribute__((deprecated)) |
346 #elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_DECLSPEC_DEPRECATED | 329 #elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_DECLSPEC_DEPRECATED |
347 #define V8_DEPRECATED(message, declarator) __declspec(deprecated) declarator | 330 #define V8_DEPRECATED(message, declarator) __declspec(deprecated) declarator |
348 #else | 331 #else |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 // int foo() WARN_UNUSED_RESULT; | 415 // int foo() WARN_UNUSED_RESULT; |
433 #if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT | 416 #if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT |
434 #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) | 417 #define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
435 #else | 418 #else |
436 #define V8_WARN_UNUSED_RESULT /* NOT SUPPORTED */ | 419 #define V8_WARN_UNUSED_RESULT /* NOT SUPPORTED */ |
437 #endif | 420 #endif |
438 | 421 |
439 // clang-format on | 422 // clang-format on |
440 | 423 |
441 #endif // V8CONFIG_H_ | 424 #endif // V8CONFIG_H_ |
OLD | NEW |