| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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) \ |
| 31 (defined WTF_COMPILER_##WTF_FEATURE && WTF_COMPILER_##WTF_FEATURE) |
| 31 | 32 |
| 32 /* ==== COMPILER() - the compiler being used to build the project ==== */ | 33 /* ==== COMPILER() - the compiler being used to build the project ==== */ |
| 33 | 34 |
| 34 /* COMPILER(CLANG) - Clang */ | 35 /* COMPILER(CLANG) - Clang */ |
| 35 #if defined(__clang__) | 36 #if defined(__clang__) |
| 36 #define WTF_COMPILER_CLANG 1 | 37 #define WTF_COMPILER_CLANG 1 |
| 37 #endif | 38 #endif |
| 38 | 39 |
| 39 /* COMPILER(MSVC) - Microsoft Visual C++ (and Clang when compiling for Windows).
*/ | 40 /* COMPILER(MSVC) - Microsoft Visual C++ (and Clang when compiling for Windows).
*/ |
| 40 #if defined(_MSC_VER) | 41 #if defined(_MSC_VER) |
| 41 #define WTF_COMPILER_MSVC 1 | 42 #define WTF_COMPILER_MSVC 1 |
| 42 #endif | 43 #endif |
| 43 | 44 |
| 44 /* COMPILER(GCC) - GNU Compiler Collection (and Clang when compiling for platfor
ms other than Windows). */ | 45 /* COMPILER(GCC) - GNU Compiler Collection (and Clang when compiling for platfor
ms other than Windows). */ |
| 45 #if defined(__GNUC__) | 46 #if defined(__GNUC__) |
| 46 #define WTF_COMPILER_GCC 1 | 47 #define WTF_COMPILER_GCC 1 |
| 47 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL
__) | 48 #define GCC_VERSION \ |
| 48 #define GCC_VERSION_AT_LEAST(major, minor, patch) (GCC_VERSION >= (major * 10000
+ minor * 100 + patch)) | 49 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) |
| 50 #define GCC_VERSION_AT_LEAST(major, minor, patch) \ |
| 51 (GCC_VERSION >= (major * 10000 + minor * 100 + patch)) |
| 49 #else | 52 #else |
| 50 /* Define this for !GCC compilers, just so we can write things like GCC_VERSION_
AT_LEAST(4, 1, 0). */ | 53 /* Define this for !GCC compilers, just so we can write things like GCC_VERSION_
AT_LEAST(4, 1, 0). */ |
| 51 #define GCC_VERSION_AT_LEAST(major, minor, patch) 0 | 54 #define GCC_VERSION_AT_LEAST(major, minor, patch) 0 |
| 52 #endif | 55 #endif |
| 53 | 56 |
| 54 /* ==== Compiler features ==== */ | 57 /* ==== Compiler features ==== */ |
| 55 | 58 |
| 56 | |
| 57 /* ALWAYS_INLINE */ | 59 /* ALWAYS_INLINE */ |
| 58 | 60 |
| 59 #ifndef ALWAYS_INLINE | 61 #ifndef ALWAYS_INLINE |
| 60 #if COMPILER(GCC) && defined(NDEBUG) && !COMPILER(MINGW) | 62 #if COMPILER(GCC) && defined(NDEBUG) && !COMPILER(MINGW) |
| 61 #define ALWAYS_INLINE inline __attribute__((__always_inline__)) | 63 #define ALWAYS_INLINE inline __attribute__((__always_inline__)) |
| 62 #elif COMPILER(MSVC) && defined(NDEBUG) | 64 #elif COMPILER(MSVC) && defined(NDEBUG) |
| 63 #define ALWAYS_INLINE __forceinline | 65 #define ALWAYS_INLINE __forceinline |
| 64 #else | 66 #else |
| 65 #define ALWAYS_INLINE inline | 67 #define ALWAYS_INLINE inline |
| 66 #endif | 68 #endif |
| 67 #endif | 69 #endif |
| 68 | 70 |
| 69 | |
| 70 /* NEVER_INLINE */ | 71 /* NEVER_INLINE */ |
| 71 | 72 |
| 72 #ifndef NEVER_INLINE | 73 #ifndef NEVER_INLINE |
| 73 #if COMPILER(GCC) | 74 #if COMPILER(GCC) |
| 74 #define NEVER_INLINE __attribute__((__noinline__)) | 75 #define NEVER_INLINE __attribute__((__noinline__)) |
| 75 #elif COMPILER(MSVC) | 76 #elif COMPILER(MSVC) |
| 76 #define NEVER_INLINE __declspec(noinline) | 77 #define NEVER_INLINE __declspec(noinline) |
| 77 #else | 78 #else |
| 78 #define NEVER_INLINE | 79 #define NEVER_INLINE |
| 79 #endif | 80 #endif |
| 80 #endif | 81 #endif |
| 81 | 82 |
| 82 | |
| 83 /* UNLIKELY */ | 83 /* UNLIKELY */ |
| 84 | 84 |
| 85 #ifndef UNLIKELY | 85 #ifndef UNLIKELY |
| 86 #if COMPILER(GCC) | 86 #if COMPILER(GCC) |
| 87 #define UNLIKELY(x) __builtin_expect((x), 0) | 87 #define UNLIKELY(x) __builtin_expect((x), 0) |
| 88 #else | 88 #else |
| 89 #define UNLIKELY(x) (x) | 89 #define UNLIKELY(x) (x) |
| 90 #endif | 90 #endif |
| 91 #endif | 91 #endif |
| 92 | 92 |
| 93 | |
| 94 /* LIKELY */ | 93 /* LIKELY */ |
| 95 | 94 |
| 96 #ifndef LIKELY | 95 #ifndef LIKELY |
| 97 #if COMPILER(GCC) | 96 #if COMPILER(GCC) |
| 98 #define LIKELY(x) __builtin_expect((x), 1) | 97 #define LIKELY(x) __builtin_expect((x), 1) |
| 99 #else | 98 #else |
| 100 #define LIKELY(x) (x) | 99 #define LIKELY(x) (x) |
| 101 #endif | 100 #endif |
| 102 #endif | 101 #endif |
| 103 | 102 |
| 104 | |
| 105 /* NO_RETURN */ | 103 /* NO_RETURN */ |
| 106 | 104 |
| 107 #ifndef NO_RETURN | 105 #ifndef NO_RETURN |
| 108 #if COMPILER(GCC) | 106 #if COMPILER(GCC) |
| 109 #define NO_RETURN __attribute((__noreturn__)) | 107 #define NO_RETURN __attribute((__noreturn__)) |
| 110 #elif COMPILER(MSVC) | 108 #elif COMPILER(MSVC) |
| 111 #define NO_RETURN __declspec(noreturn) | 109 #define NO_RETURN __declspec(noreturn) |
| 112 #else | 110 #else |
| 113 #define NO_RETURN | 111 #define NO_RETURN |
| 114 #endif | 112 #endif |
| 115 #endif | 113 #endif |
| 116 | 114 |
| 117 | |
| 118 /* WARN_UNUSED_RETURN */ | 115 /* WARN_UNUSED_RETURN */ |
| 119 | 116 |
| 120 #if COMPILER(GCC) | 117 #if COMPILER(GCC) |
| 121 #define WARN_UNUSED_RETURN __attribute__ ((warn_unused_result)) | 118 #define WARN_UNUSED_RETURN __attribute__((warn_unused_result)) |
| 122 #else | 119 #else |
| 123 #define WARN_UNUSED_RETURN | 120 #define WARN_UNUSED_RETURN |
| 124 #endif | 121 #endif |
| 125 | 122 |
| 126 | |
| 127 /* ALLOW_UNUSED_LOCAL */ | 123 /* ALLOW_UNUSED_LOCAL */ |
| 128 | 124 |
| 129 #define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0 | 125 #define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0 |
| 130 | 126 |
| 131 | |
| 132 /* OBJC_CLASS */ | 127 /* OBJC_CLASS */ |
| 133 | 128 |
| 134 #ifndef OBJC_CLASS | 129 #ifndef OBJC_CLASS |
| 135 #ifdef __OBJC__ | 130 #ifdef __OBJC__ |
| 136 #define OBJC_CLASS @class | 131 #define OBJC_CLASS @class |
| 137 #else | 132 #else |
| 138 #define OBJC_CLASS class | 133 #define OBJC_CLASS class |
| 139 #endif | 134 #endif |
| 140 #endif | 135 #endif |
| 141 | 136 |
| 142 | |
| 143 /* WTF_PRETTY_FUNCTION */ | 137 /* WTF_PRETTY_FUNCTION */ |
| 144 | 138 |
| 145 #if COMPILER(GCC) | 139 #if COMPILER(GCC) |
| 146 #define WTF_PRETTY_FUNCTION __PRETTY_FUNCTION__ | 140 #define WTF_PRETTY_FUNCTION __PRETTY_FUNCTION__ |
| 147 #elif COMPILER(MSVC) | 141 #elif COMPILER(MSVC) |
| 148 #define WTF_PRETTY_FUNCTION __FUNCSIG__ | 142 #define WTF_PRETTY_FUNCTION __FUNCSIG__ |
| 149 #else | 143 #else |
| 150 #define WTF_PRETTY_FUNCTION __FUNCTION__ | 144 #define WTF_PRETTY_FUNCTION __FUNCTION__ |
| 151 #endif | 145 #endif |
| 152 | 146 |
| 153 /* NO_SANITIZE_UNRELATED_CAST - Disable runtime checks related to casts between | 147 /* NO_SANITIZE_UNRELATED_CAST - Disable runtime checks related to casts between |
| 154 * unrelated objects (-fsanitize=cfi-unrelated-cast or -fsanitize=vptr). */ | 148 * unrelated objects (-fsanitize=cfi-unrelated-cast or -fsanitize=vptr). */ |
| 155 | 149 |
| 156 #if COMPILER(CLANG) | 150 #if COMPILER(CLANG) |
| 157 #define NO_SANITIZE_UNRELATED_CAST __attribute__((no_sanitize("cfi-unrelated-cas
t", "vptr"))) | 151 #define NO_SANITIZE_UNRELATED_CAST \ |
| 152 __attribute__((no_sanitize("cfi-unrelated-cast", "vptr"))) |
| 158 #else | 153 #else |
| 159 #define NO_SANITIZE_UNRELATED_CAST | 154 #define NO_SANITIZE_UNRELATED_CAST |
| 160 #endif | 155 #endif |
| 161 | 156 |
| 162 #endif /* WTF_Compiler_h */ | 157 #endif /* WTF_Compiler_h */ |
| OLD | NEW |