| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef WTF_Compiler_h | 26 #ifndef WTF_Compiler_h |
| 27 #define WTF_Compiler_h | 27 #define WTF_Compiler_h |
| 28 | 28 |
| 29 /* COMPILER() - the compiler being used to build the project */ | 29 /* COMPILER() - the compiler being used to build the project */ |
| 30 #define COMPILER(WTF_FEATURE) (defined WTF_COMPILER_##WTF_FEATURE && WTF_COMPIL
ER_##WTF_FEATURE) | 30 #define COMPILER(WTF_FEATURE) (defined WTF_COMPILER_##WTF_FEATURE && WTF_COMPIL
ER_##WTF_FEATURE) |
| 31 | 31 |
| 32 /* COMPILER_SUPPORTS() - whether the compiler being used to build the project su
pports the given feature. */ | |
| 33 #define COMPILER_SUPPORTS(WTF_COMPILER_FEATURE) (defined WTF_COMPILER_SUPPORTS_#
#WTF_COMPILER_FEATURE && WTF_COMPILER_SUPPORTS_##WTF_COMPILER_FEATURE) | |
| 34 | |
| 35 /* COMPILER_QUIRK() - whether the compiler being used to build the project requi
res a given quirk. */ | |
| 36 #define COMPILER_QUIRK(WTF_COMPILER_QUIRK) (defined WTF_COMPILER_QUIRK_##WTF_COM
PILER_QUIRK && WTF_COMPILER_QUIRK_##WTF_COMPILER_QUIRK) | |
| 37 | |
| 38 /* ==== COMPILER() - the compiler being used to build the project ==== */ | 32 /* ==== COMPILER() - the compiler being used to build the project ==== */ |
| 39 | 33 |
| 40 /* COMPILER(CLANG) - Clang */ | 34 /* COMPILER(CLANG) - Clang */ |
| 41 #if defined(__clang__) | 35 #if defined(__clang__) |
| 42 #define WTF_COMPILER_CLANG 1 | 36 #define WTF_COMPILER_CLANG 1 |
| 43 | 37 |
| 44 #define CLANG_PRAGMA(PRAGMA) _Pragma(PRAGMA) | 38 #define CLANG_PRAGMA(PRAGMA) _Pragma(PRAGMA) |
| 45 | |
| 46 /* Specific compiler features */ | |
| 47 #define WTF_COMPILER_SUPPORTS_CXX_VARIADIC_TEMPLATES __has_extension(cxx_variadi
c_templates) | |
| 48 | |
| 49 /* There is a bug in clang that comes with Xcode 4.2 where AtomicStrings can't b
e implicitly converted to Strings | |
| 50 in the presence of move constructors and/or move assignment operators. This b
ug has been fixed in Xcode 4.3 clang, so we | |
| 51 check for both cxx_rvalue_references as well as the unrelated cxx_nonstatic_m
ember_init feature which we know was added in 4.3 */ | |
| 52 #define WTF_COMPILER_SUPPORTS_CXX_RVALUE_REFERENCES __has_extension(cxx_rvalue_r
eferences) && __has_extension(cxx_nonstatic_member_init) | |
| 53 | |
| 54 #define WTF_COMPILER_SUPPORTS_CXX_NULLPTR __has_feature(cxx_nullptr) | |
| 55 #define WTF_COMPILER_SUPPORTS_CXX_EXPLICIT_CONVERSIONS __has_feature(cxx_explici
t_conversions) | |
| 56 #define WTF_COMPILER_SUPPORTS_BLOCKS __has_feature(blocks) | |
| 57 #define WTF_COMPILER_SUPPORTS_C_STATIC_ASSERT __has_extension(c_static_assert) | |
| 58 #define WTF_COMPILER_SUPPORTS_CXX_STATIC_ASSERT __has_extension(cxx_static_asser
t) | |
| 59 #define WTF_COMPILER_SUPPORTS_HAS_TRIVIAL_DESTRUCTOR __has_extension(has_trivial
_destructor) | |
| 60 #define WTF_COMPILER_SUPPORTS_CXX_STRONG_ENUMS __has_extension(cxx_strong_enums) | |
| 61 | |
| 62 #endif | 39 #endif |
| 63 | 40 |
| 64 #ifndef CLANG_PRAGMA | 41 #ifndef CLANG_PRAGMA |
| 65 #define CLANG_PRAGMA(PRAGMA) | 42 #define CLANG_PRAGMA(PRAGMA) |
| 66 #endif | 43 #endif |
| 67 | 44 |
| 68 /* COMPILER(MSVC) - Microsoft Visual C++ */ | |
| 69 #if defined(_MSC_VER) | |
| 70 #define WTF_COMPILER_MSVC 1 | |
| 71 | |
| 72 /* Specific compiler features */ | |
| 73 #if !COMPILER(CLANG) && _MSC_VER >= 1600 | |
| 74 #define WTF_COMPILER_SUPPORTS_CXX_NULLPTR 1 | |
| 75 #endif | |
| 76 | |
| 77 #if COMPILER(CLANG) | |
| 78 /* Keep strong enums turned off when building with clang-cl: We cannot yet build
all of Blink without fallback to cl.exe, and strong enums are exposed at ABI bo
undaries. */ | |
| 79 #undef WTF_COMPILER_SUPPORTS_CXX_STRONG_ENUMS | |
| 80 #endif | |
| 81 | |
| 82 #endif | |
| 83 | |
| 84 /* COMPILER(GCC) - GNU Compiler Collection */ | 45 /* COMPILER(GCC) - GNU Compiler Collection */ |
| 85 #if defined(__GNUC__) | 46 #if defined(__GNUC__) |
| 86 #define WTF_COMPILER_GCC 1 | 47 #define WTF_COMPILER_GCC 1 |
| 87 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL
__) | 48 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL
__) |
| 88 #define GCC_VERSION_AT_LEAST(major, minor, patch) (GCC_VERSION >= (major * 10000
+ minor * 100 + patch)) | 49 #define GCC_VERSION_AT_LEAST(major, minor, patch) (GCC_VERSION >= (major * 10000
+ minor * 100 + patch)) |
| 89 #else | 50 #else |
| 90 /* Define this for !GCC compilers, just so we can write things like GCC_VERSION_
AT_LEAST(4, 1, 0). */ | 51 /* Define this for !GCC compilers, just so we can write things like GCC_VERSION_
AT_LEAST(4, 1, 0). */ |
| 91 #define GCC_VERSION_AT_LEAST(major, minor, patch) 0 | 52 #define GCC_VERSION_AT_LEAST(major, minor, patch) 0 |
| 92 #endif | 53 #endif |
| 93 | 54 |
| 94 /* Specific compiler features */ | |
| 95 #if COMPILER(GCC) && !COMPILER(CLANG) | |
| 96 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L | |
| 97 /* C11 support */ | |
| 98 #define WTF_COMPILER_SUPPORTS_C_STATIC_ASSERT 1 | |
| 99 #endif | |
| 100 #if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(__cplusplus) && __cplusplus
>= 201103L) | |
| 101 /* C++11 support */ | |
| 102 #if GCC_VERSION_AT_LEAST(4, 3, 0) | |
| 103 #define WTF_COMPILER_SUPPORTS_CXX_RVALUE_REFERENCES 1 | |
| 104 #define WTF_COMPILER_SUPPORTS_CXX_STATIC_ASSERT 1 | |
| 105 #define WTF_COMPILER_SUPPORTS_CXX_VARIADIC_TEMPLATES 1 | |
| 106 #endif | |
| 107 #if GCC_VERSION_AT_LEAST(4, 5, 0) | |
| 108 #define WTF_COMPILER_SUPPORTS_CXX_EXPLICIT_CONVERSIONS 1 | |
| 109 #endif | |
| 110 #if GCC_VERSION_AT_LEAST(4, 6, 0) | |
| 111 #define WTF_COMPILER_SUPPORTS_CXX_NULLPTR 1 | |
| 112 /* Strong enums should work from gcc 4.4, but doesn't seem to support some opera
tors */ | |
| 113 #define WTF_COMPILER_SUPPORTS_CXX_STRONG_ENUMS 1 | |
| 114 #endif | |
| 115 #endif /* defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(__cplusplus) && __cplu
splus >= 201103L) */ | |
| 116 #endif /* COMPILER(GCC) */ | |
| 117 | |
| 118 /* ==== Compiler features ==== */ | 55 /* ==== Compiler features ==== */ |
| 119 | 56 |
| 120 | 57 |
| 121 /* ALWAYS_INLINE */ | 58 /* ALWAYS_INLINE */ |
| 122 | 59 |
| 123 #ifndef ALWAYS_INLINE | 60 #ifndef ALWAYS_INLINE |
| 124 #if COMPILER(GCC) && defined(NDEBUG) && !COMPILER(MINGW) | 61 #if COMPILER(GCC) && defined(NDEBUG) |
| 125 #define ALWAYS_INLINE inline __attribute__((__always_inline__)) | 62 #define ALWAYS_INLINE inline __attribute__((__always_inline__)) |
| 126 #elif COMPILER(MSVC) && defined(NDEBUG) | |
| 127 #define ALWAYS_INLINE __forceinline | |
| 128 #else | 63 #else |
| 129 #define ALWAYS_INLINE inline | 64 #define ALWAYS_INLINE inline |
| 130 #endif | 65 #endif |
| 131 #endif | 66 #endif |
| 132 | 67 |
| 133 | 68 |
| 134 /* NEVER_INLINE */ | 69 /* NEVER_INLINE */ |
| 135 | 70 |
| 136 #ifndef NEVER_INLINE | 71 #ifndef NEVER_INLINE |
| 137 #if COMPILER(GCC) | 72 #if COMPILER(GCC) |
| 138 #define NEVER_INLINE __attribute__((__noinline__)) | 73 #define NEVER_INLINE __attribute__((__noinline__)) |
| 139 #elif COMPILER(MSVC) | |
| 140 #define NEVER_INLINE __declspec(noinline) | |
| 141 #else | 74 #else |
| 142 #define NEVER_INLINE | 75 #define NEVER_INLINE |
| 143 #endif | 76 #endif |
| 144 #endif | 77 #endif |
| 145 | 78 |
| 146 | 79 |
| 147 /* UNLIKELY */ | 80 /* UNLIKELY */ |
| 148 | 81 |
| 149 #ifndef UNLIKELY | 82 #ifndef UNLIKELY |
| 150 #if COMPILER(GCC) | 83 #if COMPILER(GCC) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 165 #endif | 98 #endif |
| 166 #endif | 99 #endif |
| 167 | 100 |
| 168 | 101 |
| 169 /* NO_RETURN */ | 102 /* NO_RETURN */ |
| 170 | 103 |
| 171 | 104 |
| 172 #ifndef NO_RETURN | 105 #ifndef NO_RETURN |
| 173 #if COMPILER(GCC) | 106 #if COMPILER(GCC) |
| 174 #define NO_RETURN __attribute((__noreturn__)) | 107 #define NO_RETURN __attribute((__noreturn__)) |
| 175 #elif COMPILER(MSVC) | |
| 176 #define NO_RETURN __declspec(noreturn) | |
| 177 #else | 108 #else |
| 178 #define NO_RETURN | 109 #define NO_RETURN |
| 179 #endif | 110 #endif |
| 180 #endif | 111 #endif |
| 181 | 112 |
| 182 | 113 |
| 183 /* WARN_UNUSED_RETURN */ | 114 /* WARN_UNUSED_RETURN */ |
| 184 | 115 |
| 185 #if COMPILER(GCC) | 116 #if COMPILER(GCC) |
| 186 #define WARN_UNUSED_RETURN __attribute__ ((warn_unused_result)) | 117 #define WARN_UNUSED_RETURN __attribute__ ((warn_unused_result)) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 202 /* REFERENCED_FROM_ASM */ | 133 /* REFERENCED_FROM_ASM */ |
| 203 | 134 |
| 204 #ifndef REFERENCED_FROM_ASM | 135 #ifndef REFERENCED_FROM_ASM |
| 205 #if COMPILER(GCC) | 136 #if COMPILER(GCC) |
| 206 #define REFERENCED_FROM_ASM __attribute__((used)) | 137 #define REFERENCED_FROM_ASM __attribute__((used)) |
| 207 #else | 138 #else |
| 208 #define REFERENCED_FROM_ASM | 139 #define REFERENCED_FROM_ASM |
| 209 #endif | 140 #endif |
| 210 #endif | 141 #endif |
| 211 | 142 |
| 212 /* OBJC_CLASS */ | |
| 213 | |
| 214 #ifndef OBJC_CLASS | |
| 215 #ifdef __OBJC__ | |
| 216 #define OBJC_CLASS @class | |
| 217 #else | |
| 218 #define OBJC_CLASS class | |
| 219 #endif | |
| 220 #endif | |
| 221 | |
| 222 /* WTF_PRETTY_FUNCTION */ | 143 /* WTF_PRETTY_FUNCTION */ |
| 223 | 144 |
| 224 #if COMPILER(GCC) | 145 #if COMPILER(GCC) |
| 225 #define WTF_COMPILER_SUPPORTS_PRETTY_FUNCTION 1 | |
| 226 #define WTF_PRETTY_FUNCTION __PRETTY_FUNCTION__ | 146 #define WTF_PRETTY_FUNCTION __PRETTY_FUNCTION__ |
| 227 #elif COMPILER(MSVC) | |
| 228 #define WTF_COMPILER_SUPPORTS_PRETTY_FUNCTION 1 | |
| 229 #define WTF_PRETTY_FUNCTION __FUNCSIG__ | |
| 230 #else | 147 #else |
| 231 #define WTF_PRETTY_FUNCTION __FUNCTION__ | 148 #define WTF_PRETTY_FUNCTION __FUNCTION__ |
| 232 #endif | 149 #endif |
| 233 | 150 |
| 234 #endif /* WTF_Compiler_h */ | 151 #endif /* WTF_Compiler_h */ |
| OLD | NEW |