| 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 #include "base/compiler_specific.h" |
| 30 |
| 29 /* COMPILER() - the compiler being used to build the project */ | 31 /* COMPILER() - the compiler being used to build the project */ |
| 30 #define COMPILER(WTF_FEATURE) \ | 32 #define COMPILER(WTF_FEATURE) \ |
| 31 (defined WTF_COMPILER_##WTF_FEATURE && WTF_COMPILER_##WTF_FEATURE) | 33 (defined WTF_COMPILER_##WTF_FEATURE && WTF_COMPILER_##WTF_FEATURE) |
| 32 | 34 |
| 33 /* ==== COMPILER() - the compiler being used to build the project ==== */ | 35 /* ==== COMPILER() - the compiler being used to build the project ==== */ |
| 34 | 36 |
| 35 /* COMPILER(CLANG) - Clang */ | 37 /* COMPILER(CLANG) - Clang */ |
| 36 #if defined(__clang__) | 38 #if defined(__clang__) |
| 37 #define WTF_COMPILER_CLANG 1 | 39 #define WTF_COMPILER_CLANG 1 |
| 38 #endif | 40 #endif |
| (...skipping 13 matching lines...) Expand all Loading... |
| 52 #define GCC_VERSION_AT_LEAST(major, minor, patch) \ | 54 #define GCC_VERSION_AT_LEAST(major, minor, patch) \ |
| 53 (GCC_VERSION >= (major * 10000 + minor * 100 + patch)) | 55 (GCC_VERSION >= (major * 10000 + minor * 100 + patch)) |
| 54 #else | 56 #else |
| 55 /* Define this for !GCC compilers, just so we can write things like | 57 /* Define this for !GCC compilers, just so we can write things like |
| 56 * GCC_VERSION_AT_LEAST(4, 1, 0). */ | 58 * GCC_VERSION_AT_LEAST(4, 1, 0). */ |
| 57 #define GCC_VERSION_AT_LEAST(major, minor, patch) 0 | 59 #define GCC_VERSION_AT_LEAST(major, minor, patch) 0 |
| 58 #endif | 60 #endif |
| 59 | 61 |
| 60 /* ==== Compiler features ==== */ | 62 /* ==== Compiler features ==== */ |
| 61 | 63 |
| 62 /* ALWAYS_INLINE */ | |
| 63 | |
| 64 #ifndef ALWAYS_INLINE | |
| 65 #if COMPILER(GCC) && defined(NDEBUG) && !COMPILER(MINGW) | |
| 66 #define ALWAYS_INLINE inline __attribute__((__always_inline__)) | |
| 67 #elif COMPILER(MSVC) && defined(NDEBUG) | |
| 68 #define ALWAYS_INLINE __forceinline | |
| 69 #else | |
| 70 #define ALWAYS_INLINE inline | |
| 71 #endif | |
| 72 #endif | |
| 73 | |
| 74 /* NEVER_INLINE */ | |
| 75 | |
| 76 #ifndef NEVER_INLINE | |
| 77 #if COMPILER(GCC) | |
| 78 #define NEVER_INLINE __attribute__((__noinline__)) | |
| 79 #elif COMPILER(MSVC) | |
| 80 #define NEVER_INLINE __declspec(noinline) | |
| 81 #else | |
| 82 #define NEVER_INLINE | |
| 83 #endif | |
| 84 #endif | |
| 85 | |
| 86 /* UNLIKELY */ | |
| 87 | |
| 88 #ifndef UNLIKELY | |
| 89 #if COMPILER(GCC) | |
| 90 #define UNLIKELY(x) __builtin_expect((x), 0) | |
| 91 #else | |
| 92 #define UNLIKELY(x) (x) | |
| 93 #endif | |
| 94 #endif | |
| 95 | |
| 96 /* LIKELY */ | |
| 97 | |
| 98 #ifndef LIKELY | |
| 99 #if COMPILER(GCC) | |
| 100 #define LIKELY(x) __builtin_expect((x), 1) | |
| 101 #else | |
| 102 #define LIKELY(x) (x) | |
| 103 #endif | |
| 104 #endif | |
| 105 | |
| 106 /* NO_RETURN */ | 64 /* NO_RETURN */ |
| 107 | 65 |
| 108 #ifndef NO_RETURN | 66 #ifndef NO_RETURN |
| 109 #if COMPILER(GCC) | 67 #if COMPILER(GCC) |
| 110 #define NO_RETURN __attribute((__noreturn__)) | 68 #define NO_RETURN __attribute((__noreturn__)) |
| 111 #elif COMPILER(MSVC) | 69 #elif COMPILER(MSVC) |
| 112 #define NO_RETURN __declspec(noreturn) | 70 #define NO_RETURN __declspec(noreturn) |
| 113 #else | 71 #else |
| 114 #define NO_RETURN | 72 #define NO_RETURN |
| 115 #endif | 73 #endif |
| 116 #endif | 74 #endif |
| 117 | 75 |
| 76 /* NEVER_INLINE */ |
| 77 |
| 78 // TODO(palmer): Remove this and update callers to use NOINLINE from Chromium |
| 79 // base. https://bugs.chromium.org/p/chromium/issues/detail?id=632441 |
| 80 // |
| 81 // For compatibility with callers in Blink: |
| 82 #define NEVER_INLINE NOINLINE |
| 83 |
| 118 /* WARN_UNUSED_RETURN */ | 84 /* WARN_UNUSED_RETURN */ |
| 119 | 85 |
| 120 #if COMPILER(GCC) | 86 #if COMPILER(GCC) |
| 121 #define WARN_UNUSED_RETURN __attribute__((warn_unused_result)) | 87 #define WARN_UNUSED_RETURN __attribute__((warn_unused_result)) |
| 122 #else | 88 #else |
| 123 #define WARN_UNUSED_RETURN | 89 #define WARN_UNUSED_RETURN |
| 124 #endif | 90 #endif |
| 125 | 91 |
| 126 /* ALLOW_UNUSED_LOCAL */ | 92 /* ALLOW_UNUSED_LOCAL */ |
| 127 | 93 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 /* WTF_NON_EXPORTED_BASE; similar NON_EXPORTED_BASE in base/compiler_specific.h | 126 /* WTF_NON_EXPORTED_BASE; similar NON_EXPORTED_BASE in base/compiler_specific.h |
| 161 */ | 127 */ |
| 162 | 128 |
| 163 #if COMPILER(MSVC) | 129 #if COMPILER(MSVC) |
| 164 #define WTF_NON_EXPORTED_BASE(code) __pragma(warning(suppress : 4275)) code | 130 #define WTF_NON_EXPORTED_BASE(code) __pragma(warning(suppress : 4275)) code |
| 165 #else | 131 #else |
| 166 #define WTF_NON_EXPORTED_BASE(code) code | 132 #define WTF_NON_EXPORTED_BASE(code) code |
| 167 #endif | 133 #endif |
| 168 | 134 |
| 169 #endif /* WTF_Compiler_h */ | 135 #endif /* WTF_Compiler_h */ |
| OLD | NEW |