| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 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. | |
| 24 */ | |
| 25 | |
| 26 #ifndef WTF_Compiler_h | |
| 27 #define WTF_Compiler_h | |
| 28 | |
| 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) | |
| 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 ==== */ | |
| 39 | |
| 40 /* COMPILER(CLANG) - Clang */ | |
| 41 #if defined(__clang__) | |
| 42 #define WTF_COMPILER_CLANG 1 | |
| 43 | |
| 44 #ifndef __has_extension | |
| 45 #define __has_extension __has_feature /* Compatibility with older versions of cl
ang */ | |
| 46 #endif | |
| 47 | |
| 48 #define CLANG_PRAGMA(PRAGMA) _Pragma(PRAGMA) | |
| 49 | |
| 50 /* Specific compiler features */ | |
| 51 #define WTF_COMPILER_SUPPORTS_CXX_VARIADIC_TEMPLATES __has_extension(cxx_variadi
c_templates) | |
| 52 | |
| 53 /* There is a bug in clang that comes with Xcode 4.2 where AtomicStrings can't b
e implicitly converted to Strings | |
| 54 in the presence of move constructors and/or move assignment operators. This b
ug has been fixed in Xcode 4.3 clang, so we | |
| 55 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 */ | |
| 56 #define WTF_COMPILER_SUPPORTS_CXX_RVALUE_REFERENCES __has_extension(cxx_rvalue_r
eferences) && __has_extension(cxx_nonstatic_member_init) | |
| 57 | |
| 58 #define WTF_COMPILER_SUPPORTS_CXX_DELETED_FUNCTIONS __has_extension(cxx_deleted_
functions) | |
| 59 #define WTF_COMPILER_SUPPORTS_CXX_NULLPTR __has_feature(cxx_nullptr) | |
| 60 #define WTF_COMPILER_SUPPORTS_CXX_EXPLICIT_CONVERSIONS __has_feature(cxx_explici
t_conversions) | |
| 61 #define WTF_COMPILER_SUPPORTS_BLOCKS __has_feature(blocks) | |
| 62 #define WTF_COMPILER_SUPPORTS_C_STATIC_ASSERT __has_extension(c_static_assert) | |
| 63 #define WTF_COMPILER_SUPPORTS_CXX_STATIC_ASSERT __has_extension(cxx_static_asser
t) | |
| 64 #define WTF_COMPILER_SUPPORTS_CXX_OVERRIDE_CONTROL __has_extension(cxx_override_
control) | |
| 65 #define WTF_COMPILER_SUPPORTS_HAS_TRIVIAL_DESTRUCTOR __has_extension(has_trivial
_destructor) | |
| 66 #define WTF_COMPILER_SUPPORTS_CXX_STRONG_ENUMS __has_extension(cxx_strong_enums) | |
| 67 | |
| 68 #endif | |
| 69 | |
| 70 #ifndef CLANG_PRAGMA | |
| 71 #define CLANG_PRAGMA(PRAGMA) | |
| 72 #endif | |
| 73 | |
| 74 /* COMPILER(MSVC) - Microsoft Visual C++ */ | |
| 75 /* COMPILER(MSVC7_OR_LOWER) - Microsoft Visual C++ 2003 or lower*/ | |
| 76 /* COMPILER(MSVC9_OR_LOWER) - Microsoft Visual C++ 2008 or lower*/ | |
| 77 #if defined(_MSC_VER) | |
| 78 #define WTF_COMPILER_MSVC 1 | |
| 79 #if _MSC_VER < 1400 | |
| 80 #define WTF_COMPILER_MSVC7_OR_LOWER 1 | |
| 81 #elif _MSC_VER < 1600 | |
| 82 #define WTF_COMPILER_MSVC9_OR_LOWER 1 | |
| 83 #endif | |
| 84 | |
| 85 /* Specific compiler features */ | |
| 86 #if !COMPILER(CLANG) && _MSC_VER >= 1600 | |
| 87 #define WTF_COMPILER_SUPPORTS_CXX_NULLPTR 1 | |
| 88 #endif | |
| 89 | |
| 90 #if !COMPILER(CLANG) | |
| 91 #define WTF_COMPILER_SUPPORTS_CXX_OVERRIDE_CONTROL 1 | |
| 92 #define WTF_COMPILER_QUIRK_FINAL_IS_CALLED_SEALED 1 | |
| 93 #endif | |
| 94 | |
| 95 #endif | |
| 96 | |
| 97 /* COMPILER(RVCT) - ARM RealView Compilation Tools */ | |
| 98 #if defined(__CC_ARM) || defined(__ARMCC__) | |
| 99 #define WTF_COMPILER_RVCT 1 | |
| 100 #define RVCT_VERSION_AT_LEAST(major, minor, patch, build) (__ARMCC_VERSION >= (m
ajor * 100000 + minor * 10000 + patch * 1000 + build)) | |
| 101 #else | |
| 102 /* Define this for !RVCT compilers, just so we can write things like RVCT_VERSIO
N_AT_LEAST(3, 0, 0, 0). */ | |
| 103 #define RVCT_VERSION_AT_LEAST(major, minor, patch, build) 0 | |
| 104 #endif | |
| 105 | |
| 106 /* COMPILER(GCCE) - GNU Compiler Collection for Embedded */ | |
| 107 #if defined(__GCCE__) | |
| 108 #define WTF_COMPILER_GCCE 1 | |
| 109 #define GCCE_VERSION (__GCCE__ * 10000 + __GCCE_MINOR__ * 100 + __GCCE_PATCHLEVE
L__) | |
| 110 #define GCCE_VERSION_AT_LEAST(major, minor, patch) (GCCE_VERSION >= (major * 100
00 + minor * 100 + patch)) | |
| 111 #endif | |
| 112 | |
| 113 /* COMPILER(GCC) - GNU Compiler Collection */ | |
| 114 /* --gnu option of the RVCT compiler also defines __GNUC__ */ | |
| 115 #if defined(__GNUC__) && !COMPILER(RVCT) | |
| 116 #define WTF_COMPILER_GCC 1 | |
| 117 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL
__) | |
| 118 #define GCC_VERSION_AT_LEAST(major, minor, patch) (GCC_VERSION >= (major * 10000
+ minor * 100 + patch)) | |
| 119 #else | |
| 120 /* Define this for !GCC compilers, just so we can write things like GCC_VERSION_
AT_LEAST(4, 1, 0). */ | |
| 121 #define GCC_VERSION_AT_LEAST(major, minor, patch) 0 | |
| 122 #endif | |
| 123 | |
| 124 /* Specific compiler features */ | |
| 125 #if COMPILER(GCC) && !COMPILER(CLANG) | |
| 126 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L | |
| 127 /* C11 support */ | |
| 128 #define WTF_COMPILER_SUPPORTS_C_STATIC_ASSERT 1 | |
| 129 #endif | |
| 130 #if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(__cplusplus) && __cplusplus
>= 201103L) | |
| 131 /* C++11 support */ | |
| 132 #if GCC_VERSION_AT_LEAST(4, 3, 0) | |
| 133 #define WTF_COMPILER_SUPPORTS_CXX_RVALUE_REFERENCES 1 | |
| 134 #define WTF_COMPILER_SUPPORTS_CXX_STATIC_ASSERT 1 | |
| 135 #define WTF_COMPILER_SUPPORTS_CXX_VARIADIC_TEMPLATES 1 | |
| 136 #endif | |
| 137 #if GCC_VERSION_AT_LEAST(4, 4, 0) | |
| 138 #define WTF_COMPILER_SUPPORTS_CXX_DELETED_FUNCTIONS 1 | |
| 139 #endif | |
| 140 #if GCC_VERSION_AT_LEAST(4, 5, 0) | |
| 141 #define WTF_COMPILER_SUPPORTS_CXX_EXPLICIT_CONVERSIONS 1 | |
| 142 #endif | |
| 143 #if GCC_VERSION_AT_LEAST(4, 6, 0) | |
| 144 #define WTF_COMPILER_SUPPORTS_CXX_NULLPTR 1 | |
| 145 /* Strong enums should work from gcc 4.4, but doesn't seem to support some opera
tors */ | |
| 146 #define WTF_COMPILER_SUPPORTS_CXX_STRONG_ENUMS 1 | |
| 147 #endif | |
| 148 #if GCC_VERSION_AT_LEAST(4, 7, 0) | |
| 149 #define WTF_COMPILER_SUPPORTS_CXX_OVERRIDE_CONTROL 1 | |
| 150 #endif | |
| 151 #endif /* defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(__cplusplus) && __cplu
splus >= 201103L) */ | |
| 152 #endif /* COMPILER(GCC) */ | |
| 153 | |
| 154 /* COMPILER(MINGW) - MinGW GCC */ | |
| 155 /* COMPILER(MINGW64) - mingw-w64 GCC - only used as additional check to exclude
mingw.org specific functions */ | |
| 156 #if defined(__MINGW32__) | |
| 157 #define WTF_COMPILER_MINGW 1 | |
| 158 #include <_mingw.h> /* private MinGW header */ | |
| 159 #if defined(__MINGW64_VERSION_MAJOR) /* best way to check for mingw-w64 vs m
ingw.org */ | |
| 160 #define WTF_COMPILER_MINGW64 1 | |
| 161 #endif /* __MINGW64_VERSION_MAJOR */ | |
| 162 #endif /* __MINGW32__ */ | |
| 163 | |
| 164 /* COMPILER(INTEL) - Intel C++ Compiler */ | |
| 165 #if defined(__INTEL_COMPILER) | |
| 166 #define WTF_COMPILER_INTEL 1 | |
| 167 #endif | |
| 168 | |
| 169 /* COMPILER(SUNCC) */ | |
| 170 #if defined(__SUNPRO_CC) || defined(__SUNPRO_C) | |
| 171 #define WTF_COMPILER_SUNCC 1 | |
| 172 #endif | |
| 173 | |
| 174 /* ==== Compiler features ==== */ | |
| 175 | |
| 176 | |
| 177 /* ALWAYS_INLINE */ | |
| 178 | |
| 179 #ifndef ALWAYS_INLINE | |
| 180 #if COMPILER(GCC) && defined(NDEBUG) && !COMPILER(MINGW) | |
| 181 #define ALWAYS_INLINE inline __attribute__((__always_inline__)) | |
| 182 #elif (COMPILER(MSVC) || COMPILER(RVCT)) && defined(NDEBUG) | |
| 183 #define ALWAYS_INLINE __forceinline | |
| 184 #else | |
| 185 #define ALWAYS_INLINE inline | |
| 186 #endif | |
| 187 #endif | |
| 188 | |
| 189 | |
| 190 /* NEVER_INLINE */ | |
| 191 | |
| 192 #ifndef NEVER_INLINE | |
| 193 #if COMPILER(GCC) | |
| 194 #define NEVER_INLINE __attribute__((__noinline__)) | |
| 195 #elif COMPILER(RVCT) | |
| 196 #define NEVER_INLINE __declspec(noinline) | |
| 197 #else | |
| 198 #define NEVER_INLINE | |
| 199 #endif | |
| 200 #endif | |
| 201 | |
| 202 | |
| 203 /* UNLIKELY */ | |
| 204 | |
| 205 #ifndef UNLIKELY | |
| 206 #if COMPILER(GCC) || (COMPILER(RVCT) && defined(__GNUC__)) | |
| 207 #define UNLIKELY(x) __builtin_expect((x), 0) | |
| 208 #else | |
| 209 #define UNLIKELY(x) (x) | |
| 210 #endif | |
| 211 #endif | |
| 212 | |
| 213 | |
| 214 /* LIKELY */ | |
| 215 | |
| 216 #ifndef LIKELY | |
| 217 #if COMPILER(GCC) || (COMPILER(RVCT) && defined(__GNUC__)) | |
| 218 #define LIKELY(x) __builtin_expect((x), 1) | |
| 219 #else | |
| 220 #define LIKELY(x) (x) | |
| 221 #endif | |
| 222 #endif | |
| 223 | |
| 224 | |
| 225 /* NO_RETURN */ | |
| 226 | |
| 227 | |
| 228 #ifndef NO_RETURN | |
| 229 #if COMPILER(GCC) | |
| 230 #define NO_RETURN __attribute((__noreturn__)) | |
| 231 #elif COMPILER(MSVC) || COMPILER(RVCT) | |
| 232 #define NO_RETURN __declspec(noreturn) | |
| 233 #else | |
| 234 #define NO_RETURN | |
| 235 #endif | |
| 236 #endif | |
| 237 | |
| 238 | |
| 239 /* NO_RETURN_WITH_VALUE */ | |
| 240 | |
| 241 #ifndef NO_RETURN_WITH_VALUE | |
| 242 #if !COMPILER(MSVC) | |
| 243 #define NO_RETURN_WITH_VALUE NO_RETURN | |
| 244 #else | |
| 245 #define NO_RETURN_WITH_VALUE | |
| 246 #endif | |
| 247 #endif | |
| 248 | |
| 249 | |
| 250 /* WARN_UNUSED_RETURN */ | |
| 251 | |
| 252 #if COMPILER(GCC) | |
| 253 #define WARN_UNUSED_RETURN __attribute__ ((warn_unused_result)) | |
| 254 #else | |
| 255 #define WARN_UNUSED_RETURN | |
| 256 #endif | |
| 257 | |
| 258 /* OVERRIDE and FINAL */ | |
| 259 | |
| 260 #if COMPILER_SUPPORTS(CXX_OVERRIDE_CONTROL) | |
| 261 #define OVERRIDE override | |
| 262 | |
| 263 #if COMPILER_QUIRK(FINAL_IS_CALLED_SEALED) | |
| 264 #define FINAL sealed | |
| 265 #else | |
| 266 #define FINAL final | |
| 267 #endif | |
| 268 | |
| 269 #else | |
| 270 #define OVERRIDE | |
| 271 #define FINAL | |
| 272 #endif | |
| 273 | |
| 274 /* REFERENCED_FROM_ASM */ | |
| 275 | |
| 276 #ifndef REFERENCED_FROM_ASM | |
| 277 #if COMPILER(GCC) | |
| 278 #define REFERENCED_FROM_ASM __attribute__((used)) | |
| 279 #else | |
| 280 #define REFERENCED_FROM_ASM | |
| 281 #endif | |
| 282 #endif | |
| 283 | |
| 284 /* OBJC_CLASS */ | |
| 285 | |
| 286 #ifndef OBJC_CLASS | |
| 287 #ifdef __OBJC__ | |
| 288 #define OBJC_CLASS @class | |
| 289 #else | |
| 290 #define OBJC_CLASS class | |
| 291 #endif | |
| 292 #endif | |
| 293 | |
| 294 /* ABI */ | |
| 295 #if defined(__ARM_EABI__) || defined(__EABI__) | |
| 296 #define WTF_COMPILER_SUPPORTS_EABI 1 | |
| 297 #endif | |
| 298 | |
| 299 #endif /* WTF_Compiler_h */ | |
| OLD | NEW |