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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 #define MSVC_PUSH_DISABLE_WARNING(n) | 61 #define MSVC_PUSH_DISABLE_WARNING(n) |
62 #define MSVC_PUSH_WARNING_LEVEL(n) | 62 #define MSVC_PUSH_WARNING_LEVEL(n) |
63 #define MSVC_POP_WARNING() | 63 #define MSVC_POP_WARNING() |
64 #define MSVC_DISABLE_OPTIMIZE() | 64 #define MSVC_DISABLE_OPTIMIZE() |
65 #define MSVC_ENABLE_OPTIMIZE() | 65 #define MSVC_ENABLE_OPTIMIZE() |
66 #define NON_EXPORTED_BASE(code) code | 66 #define NON_EXPORTED_BASE(code) code |
67 | 67 |
68 #endif // COMPILER_MSVC | 68 #endif // COMPILER_MSVC |
69 | 69 |
70 | 70 |
71 // The C++ standard requires that static const members have an out-of-class | |
72 // definition (in a single compilation unit), but MSVC chokes on this (when | |
73 // language extensions, which are required, are enabled). (You're only likely to | |
74 // notice the need for a definition if you take the address of the member or, | |
75 // more commonly, pass it to a function that takes it as a reference argument -- | |
76 // probably an STL function.) This macro makes MSVC do the right thing. See | |
77 // http://msdn.microsoft.com/en-us/library/34h23df8(v=vs.100).aspx for more | |
78 // information. Use like: | |
79 // | |
80 // In .h file: | |
81 // struct Foo { | |
82 // static const int kBar = 5; | |
83 // }; | |
84 // | |
85 // In .cc file: | |
86 // STATIC_CONST_MEMBER_DEFINITION const int Foo::kBar; | |
87 #if defined(COMPILER_MSVC) | |
88 #define STATIC_CONST_MEMBER_DEFINITION __declspec(selectany) | |
89 #else | |
90 #define STATIC_CONST_MEMBER_DEFINITION | |
91 #endif | |
92 | |
93 // Annotate a variable indicating it's ok if the variable is not used. | 71 // Annotate a variable indicating it's ok if the variable is not used. |
94 // (Typically used to silence a compiler warning when the assignment | 72 // (Typically used to silence a compiler warning when the assignment |
95 // is important for some other reason.) | 73 // is important for some other reason.) |
96 // Use like: | 74 // Use like: |
97 // int x = ...; | 75 // int x = ...; |
98 // ALLOW_UNUSED_LOCAL(x); | 76 // ALLOW_UNUSED_LOCAL(x); |
99 #define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0 | 77 #define ALLOW_UNUSED_LOCAL(x) false ? (void)x : (void)0 |
100 | 78 |
101 // Annotate a typedef or function indicating it's ok if it's not used. | 79 // Annotate a typedef or function indicating it's ok if it's not used. |
102 // Use like: | 80 // Use like: |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 // Macro for hinting that an expression is likely to be false. | 176 // Macro for hinting that an expression is likely to be false. |
199 #if !defined(UNLIKELY) | 177 #if !defined(UNLIKELY) |
200 #if defined(COMPILER_GCC) | 178 #if defined(COMPILER_GCC) |
201 #define UNLIKELY(x) __builtin_expect(!!(x), 0) | 179 #define UNLIKELY(x) __builtin_expect(!!(x), 0) |
202 #else | 180 #else |
203 #define UNLIKELY(x) (x) | 181 #define UNLIKELY(x) (x) |
204 #endif // defined(COMPILER_GCC) | 182 #endif // defined(COMPILER_GCC) |
205 #endif // !defined(UNLIKELY) | 183 #endif // !defined(UNLIKELY) |
206 | 184 |
207 #endif // BASE_COMPILER_SPECIFIC_H_ | 185 #endif // BASE_COMPILER_SPECIFIC_H_ |
OLD | NEW |