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 // Platform headers for feature detection below. | 8 // Platform headers for feature detection below. |
9 #if defined(__ANDROID__) | 9 #if defined(__ANDROID__) |
10 # include <sys/cdefs.h> | 10 # include <sys/cdefs.h> |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 #elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED | 323 #elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED |
324 # define V8_DEPRECATED(message, declarator) \ | 324 # define V8_DEPRECATED(message, declarator) \ |
325 declarator __attribute__((deprecated)) | 325 declarator __attribute__((deprecated)) |
326 #elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_DECLSPEC_DEPRECATED | 326 #elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_DECLSPEC_DEPRECATED |
327 # define V8_DEPRECATED(message, declarator) __declspec(deprecated) declarator | 327 # define V8_DEPRECATED(message, declarator) __declspec(deprecated) declarator |
328 #else | 328 #else |
329 # define V8_DEPRECATED(message, declarator) declarator | 329 # define V8_DEPRECATED(message, declarator) declarator |
330 #endif | 330 #endif |
331 | 331 |
332 | 332 |
333 // A macro to mark variables or types as unused, avoiding compiler warnings. | |
334 #if V8_HAS_ATTRIBUTE_UNUSED | |
335 # define V8_UNUSED __attribute__((unused)) | |
336 #else | |
337 # define V8_UNUSED | |
338 #endif | |
339 | |
340 | |
341 // Annotate a function indicating the caller must examine the return value. | |
342 // Use like: | |
343 // int foo() V8_WARN_UNUSED_RESULT; | |
344 #if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT | |
345 # define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) | |
346 #else | |
347 # define V8_WARN_UNUSED_RESULT /* NOT SUPPORTED */ | |
348 #endif | |
349 | |
350 | |
351 // A macro to provide the compiler with branch prediction information. | 333 // A macro to provide the compiler with branch prediction information. |
352 #if V8_HAS_BUILTIN_EXPECT | 334 #if V8_HAS_BUILTIN_EXPECT |
353 # define V8_UNLIKELY(condition) (__builtin_expect(!!(condition), 0)) | 335 # define V8_UNLIKELY(condition) (__builtin_expect(!!(condition), 0)) |
354 # define V8_LIKELY(condition) (__builtin_expect(!!(condition), 1)) | 336 # define V8_LIKELY(condition) (__builtin_expect(!!(condition), 1)) |
355 #else | 337 #else |
356 # define V8_UNLIKELY(condition) (condition) | 338 # define V8_UNLIKELY(condition) (condition) |
357 # define V8_LIKELY(condition) (condition) | 339 # define V8_LIKELY(condition) (condition) |
358 #endif | 340 #endif |
359 | 341 |
360 | 342 |
(...skipping 10 matching lines...) Expand all Loading... |
371 // A(const A& other) V8_DELETE; | 353 // A(const A& other) V8_DELETE; |
372 // A& operator=(const A& other) V8_DELETE; | 354 // A& operator=(const A& other) V8_DELETE; |
373 // }; | 355 // }; |
374 #if V8_HAS_CXX11_DELETE | 356 #if V8_HAS_CXX11_DELETE |
375 # define V8_DELETE = delete | 357 # define V8_DELETE = delete |
376 #else | 358 #else |
377 # define V8_DELETE /* NOT SUPPORTED */ | 359 # define V8_DELETE /* NOT SUPPORTED */ |
378 #endif | 360 #endif |
379 | 361 |
380 | 362 |
381 // Annotate a virtual method indicating it must be overriding a virtual | |
382 // method in the parent class. | |
383 // Use like: | |
384 // virtual void bar() V8_OVERRIDE; | |
385 #if V8_HAS_CXX11_OVERRIDE | |
386 # define V8_OVERRIDE override | |
387 #else | |
388 # define V8_OVERRIDE /* NOT SUPPORTED */ | |
389 #endif | |
390 | |
391 | |
392 // Annotate a virtual method indicating that subclasses must not override it, | |
393 // or annotate a class to indicate that it cannot be subclassed. | |
394 // Use like: | |
395 // class B V8_FINAL : public A {}; | |
396 // virtual void bar() V8_FINAL; | |
397 #if V8_HAS_CXX11_FINAL | |
398 # define V8_FINAL final | |
399 #elif V8_HAS___FINAL | |
400 # define V8_FINAL __final | |
401 #elif V8_HAS_SEALED | |
402 # define V8_FINAL sealed | |
403 #else | |
404 # define V8_FINAL /* NOT SUPPORTED */ | |
405 #endif | |
406 | |
407 | |
408 // This macro allows to specify memory alignment for structs, classes, etc. | 363 // This macro allows to specify memory alignment for structs, classes, etc. |
409 // Use like: | 364 // Use like: |
410 // class V8_ALIGNED(16) MyClass { ... }; | 365 // class V8_ALIGNED(16) MyClass { ... }; |
411 // V8_ALIGNED(32) int array[42]; | 366 // V8_ALIGNED(32) int array[42]; |
412 #if V8_HAS_CXX11_ALIGNAS | 367 #if V8_HAS_CXX11_ALIGNAS |
413 # define V8_ALIGNED(n) alignas(n) | 368 # define V8_ALIGNED(n) alignas(n) |
414 #elif V8_HAS_ATTRIBUTE_ALIGNED | 369 #elif V8_HAS_ATTRIBUTE_ALIGNED |
415 # define V8_ALIGNED(n) __attribute__((aligned(n))) | 370 # define V8_ALIGNED(n) __attribute__((aligned(n))) |
416 #elif V8_HAS_DECLSPEC_ALIGN | 371 #elif V8_HAS_DECLSPEC_ALIGN |
417 # define V8_ALIGNED(n) __declspec(align(n)) | 372 # define V8_ALIGNED(n) __declspec(align(n)) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 # define V8_ALIGNOF(type) __alignof__(type) | 406 # define V8_ALIGNOF(type) __alignof__(type) |
452 #else | 407 #else |
453 // Note that alignment of a type within a struct can be less than the | 408 // Note that alignment of a type within a struct can be less than the |
454 // alignment of the type stand-alone (because of ancient ABIs), so this | 409 // alignment of the type stand-alone (because of ancient ABIs), so this |
455 // should only be used as a last resort. | 410 // should only be used as a last resort. |
456 namespace v8 { template <typename T> class AlignOfHelper { char c; T t; }; } | 411 namespace v8 { template <typename T> class AlignOfHelper { char c; T t; }; } |
457 # define V8_ALIGNOF(type) (sizeof(::v8::AlignOfHelper<type>) - sizeof(type)) | 412 # define V8_ALIGNOF(type) (sizeof(::v8::AlignOfHelper<type>) - sizeof(type)) |
458 #endif | 413 #endif |
459 | 414 |
460 #endif // V8CONFIG_H_ | 415 #endif // V8CONFIG_H_ |
OLD | NEW |