| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 // (Typically used to silence a compiler warning when the assignment | 94 // (Typically used to silence a compiler warning when the assignment |
| 95 // is important for some other reason.) | 95 // is important for some other reason.) |
| 96 // Use like: | 96 // Use like: |
| 97 // int x = ...; | 97 // int x = ...; |
| 98 // ALLOW_UNUSED_LOCAL(x); | 98 // ALLOW_UNUSED_LOCAL(x); |
| 99 #define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0 | 99 #define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0 |
| 100 | 100 |
| 101 // Annotate a typedef or function indicating it's ok if it's not used. | 101 // Annotate a typedef or function indicating it's ok if it's not used. |
| 102 // Use like: | 102 // Use like: |
| 103 // typedef Foo Bar ALLOW_UNUSED_TYPE; | 103 // typedef Foo Bar ALLOW_UNUSED_TYPE; |
| 104 #if defined(COMPILER_GCC) | 104 #if defined(COMPILER_GCC) || defined(__clang__) |
| 105 #define ALLOW_UNUSED_TYPE __attribute__((unused)) | 105 #define ALLOW_UNUSED_TYPE __attribute__((unused)) |
| 106 #else | 106 #else |
| 107 #define ALLOW_UNUSED_TYPE | 107 #define ALLOW_UNUSED_TYPE |
| 108 #endif | 108 #endif |
| 109 | 109 |
| 110 // Annotate a function indicating it should not be inlined. | 110 // Annotate a function indicating it should not be inlined. |
| 111 // Use like: | 111 // Use like: |
| 112 // NOINLINE void DoStuff() { ... } | 112 // NOINLINE void DoStuff() { ... } |
| 113 #if defined(COMPILER_GCC) | 113 #if defined(COMPILER_GCC) |
| 114 #define NOINLINE __attribute__((noinline)) | 114 #define NOINLINE __attribute__((noinline)) |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 // Macro for hinting that an expression is likely to be false. | 198 // Macro for hinting that an expression is likely to be false. |
| 199 #if !defined(UNLIKELY) | 199 #if !defined(UNLIKELY) |
| 200 #if defined(COMPILER_GCC) | 200 #if defined(COMPILER_GCC) |
| 201 #define UNLIKELY(x) __builtin_expect(!!(x), 0) | 201 #define UNLIKELY(x) __builtin_expect(!!(x), 0) |
| 202 #else | 202 #else |
| 203 #define UNLIKELY(x) (x) | 203 #define UNLIKELY(x) (x) |
| 204 #endif // defined(COMPILER_GCC) | 204 #endif // defined(COMPILER_GCC) |
| 205 #endif // !defined(UNLIKELY) | 205 #endif // !defined(UNLIKELY) |
| 206 | 206 |
| 207 #endif // BASE_COMPILER_SPECIFIC_H_ | 207 #endif // BASE_COMPILER_SPECIFIC_H_ |
| OLD | NEW |