Chromium Code Reviews| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 #if defined(COMPILER_MSVC) | 87 #if defined(COMPILER_MSVC) |
| 88 #define STATIC_CONST_MEMBER_DEFINITION __declspec(selectany) | 88 #define STATIC_CONST_MEMBER_DEFINITION __declspec(selectany) |
| 89 #else | 89 #else |
| 90 #define STATIC_CONST_MEMBER_DEFINITION | 90 #define STATIC_CONST_MEMBER_DEFINITION |
| 91 #endif | 91 #endif |
| 92 | 92 |
| 93 // Annotate a variable indicating it's ok if the variable is not used. | 93 // Annotate a variable indicating it's ok if the variable is not used. |
| 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 ALLOW_UNUSED = ...; | 97 // int x = ...; |
| 98 // ALLOW_UNUSED_LOCAL(x); | |
| 99 #define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0 | |
|
Nico
2014/10/25 22:56:08
How is this different from ignore_result()?
Why n
Peter Kasting
2014/10/27 17:58:44
It doesn't implicitly take the address of |x| or i
| |
| 100 | |
| 101 // Annotate a typedef or function indicating it's ok if it's not used. | |
| 102 // Use like: | |
| 103 // typedef Foo Bar ALLOW_UNUSED_TYPE; | |
| 98 #if defined(COMPILER_GCC) | 104 #if defined(COMPILER_GCC) |
| 99 #define ALLOW_UNUSED __attribute__((unused)) | 105 #define ALLOW_UNUSED_TYPE __attribute__((unused)) |
| 100 #else | 106 #else |
| 101 #define ALLOW_UNUSED | 107 #define ALLOW_UNUSED_TYPE |
| 102 #endif | 108 #endif |
| 103 | 109 |
| 104 // Annotate a function indicating it should not be inlined. | 110 // Annotate a function indicating it should not be inlined. |
| 105 // Use like: | 111 // Use like: |
| 106 // NOINLINE void DoStuff() { ... } | 112 // NOINLINE void DoStuff() { ... } |
| 107 #if defined(COMPILER_GCC) | 113 #if defined(COMPILER_GCC) |
| 108 #define NOINLINE __attribute__((noinline)) | 114 #define NOINLINE __attribute__((noinline)) |
| 109 #elif defined(COMPILER_MSVC) | 115 #elif defined(COMPILER_MSVC) |
| 110 #define NOINLINE __declspec(noinline) | 116 #define NOINLINE __declspec(noinline) |
| 111 #else | 117 #else |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 // Macro for hinting that an expression is likely to be false. | 198 // Macro for hinting that an expression is likely to be false. |
| 193 #if !defined(UNLIKELY) | 199 #if !defined(UNLIKELY) |
| 194 #if defined(COMPILER_GCC) | 200 #if defined(COMPILER_GCC) |
| 195 #define UNLIKELY(x) __builtin_expect(!!(x), 0) | 201 #define UNLIKELY(x) __builtin_expect(!!(x), 0) |
| 196 #else | 202 #else |
| 197 #define UNLIKELY(x) (x) | 203 #define UNLIKELY(x) (x) |
| 198 #endif // defined(COMPILER_GCC) | 204 #endif // defined(COMPILER_GCC) |
| 199 #endif // !defined(UNLIKELY) | 205 #endif // !defined(UNLIKELY) |
| 200 | 206 |
| 201 #endif // BASE_COMPILER_SPECIFIC_H_ | 207 #endif // BASE_COMPILER_SPECIFIC_H_ |
| OLD | NEW |