| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 BASE_COMPILER_SPECIFIC_H_ | 5 #ifndef BASE_COMPILER_SPECIFIC_H_ |
| 6 #define BASE_COMPILER_SPECIFIC_H_ | 6 #define BASE_COMPILER_SPECIFIC_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #if defined(COMPILER_MSVC) | 10 #if defined(COMPILER_MSVC) |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 #if defined(COMPILER_MSVC) | 130 #if defined(COMPILER_MSVC) |
| 131 #define ALIGNOF(type) (sizeof(type) - sizeof(type) + __alignof(type)) | 131 #define ALIGNOF(type) (sizeof(type) - sizeof(type) + __alignof(type)) |
| 132 #elif defined(COMPILER_GCC) | 132 #elif defined(COMPILER_GCC) |
| 133 #define ALIGNOF(type) __alignof__(type) | 133 #define ALIGNOF(type) __alignof__(type) |
| 134 #endif | 134 #endif |
| 135 | 135 |
| 136 // Annotate a virtual method indicating it must be overriding a virtual | 136 // Annotate a virtual method indicating it must be overriding a virtual |
| 137 // method in the parent class. | 137 // method in the parent class. |
| 138 // Use like: | 138 // Use like: |
| 139 // virtual void foo() OVERRIDE; | 139 // virtual void foo() OVERRIDE; |
| 140 #if defined(COMPILER_MSVC) | 140 #if defined(__clang__) || defined(COMPILER_MSVC) |
| 141 #define OVERRIDE override | |
| 142 #elif defined(__clang__) | |
| 143 #define OVERRIDE override | 141 #define OVERRIDE override |
| 144 #elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \ | 142 #elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \ |
| 145 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700 | 143 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700 |
| 146 // GCC 4.7 supports explicit virtual overrides when C++11 support is enabled. | 144 // GCC 4.7 supports explicit virtual overrides when C++11 support is enabled. |
| 147 #define OVERRIDE override | 145 #define OVERRIDE override |
| 148 #else | 146 #else |
| 149 #define OVERRIDE | 147 #define OVERRIDE |
| 150 #endif | 148 #endif |
| 151 | 149 |
| 152 // Annotate a virtual method indicating that subclasses must not override it, | 150 // Annotate a virtual method indicating that subclasses must not override it, |
| 153 // or annotate a class to indicate that it cannot be subclassed. | 151 // or annotate a class to indicate that it cannot be subclassed. |
| 154 // Use like: | 152 // Use like: |
| 155 // virtual void foo() FINAL; | 153 // virtual void foo() FINAL; |
| 156 // class B FINAL : public A {}; | 154 // class B FINAL : public A {}; |
| 157 #if defined(__clang__) | 155 #if defined(__clang__) || defined(COMPILER_MSVC) |
| 158 #define FINAL final | 156 #define FINAL final |
| 159 #elif defined(COMPILER_MSVC) | |
| 160 // TODO(thakis): Remove if !defined() once Blink is updated too. | |
| 161 #if !defined(FINAL) | |
| 162 #define FINAL final | |
| 163 #endif | |
| 164 #elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \ | 157 #elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \ |
| 165 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700 | 158 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700 |
| 166 // GCC 4.7 supports explicit virtual overrides when C++11 support is enabled. | 159 // GCC 4.7 supports explicit virtual overrides when C++11 support is enabled. |
| 167 #define FINAL final | 160 #define FINAL final |
| 168 #else | 161 #else |
| 169 #define FINAL | 162 #define FINAL |
| 170 #endif | 163 #endif |
| 171 | 164 |
| 172 // Annotate a function indicating the caller must examine the return value. | 165 // Annotate a function indicating the caller must examine the return value. |
| 173 // Use like: | 166 // Use like: |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 // Macro for hinting that an expression is likely to be false. | 215 // Macro for hinting that an expression is likely to be false. |
| 223 #if !defined(UNLIKELY) | 216 #if !defined(UNLIKELY) |
| 224 #if defined(COMPILER_GCC) | 217 #if defined(COMPILER_GCC) |
| 225 #define UNLIKELY(x) __builtin_expect(!!(x), 0) | 218 #define UNLIKELY(x) __builtin_expect(!!(x), 0) |
| 226 #else | 219 #else |
| 227 #define UNLIKELY(x) (x) | 220 #define UNLIKELY(x) (x) |
| 228 #endif // defined(COMPILER_GCC) | 221 #endif // defined(COMPILER_GCC) |
| 229 #endif // !defined(UNLIKELY) | 222 #endif // !defined(UNLIKELY) |
| 230 | 223 |
| 231 #endif // BASE_COMPILER_SPECIFIC_H_ | 224 #endif // BASE_COMPILER_SPECIFIC_H_ |
| OLD | NEW |