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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 #define OVERRIDE override | 140 #define OVERRIDE override |
141 | 141 |
142 // Annotate a virtual method indicating that subclasses must not override it, | |
143 // or annotate a class to indicate that it cannot be subclassed. | |
144 // Use like: | |
145 // virtual void foo() FINAL; | |
146 // class B FINAL : public A {}; | |
147 #define FINAL final | |
148 | |
149 // Annotate a function indicating the caller must examine the return value. | 142 // Annotate a function indicating the caller must examine the return value. |
150 // Use like: | 143 // Use like: |
151 // int foo() WARN_UNUSED_RESULT; | 144 // int foo() WARN_UNUSED_RESULT; |
152 // To explicitly ignore a result, see |ignore_result()| in <base/basictypes.h>. | 145 // To explicitly ignore a result, see |ignore_result()| in <base/basictypes.h>. |
153 #if defined(COMPILER_GCC) | 146 #if defined(COMPILER_GCC) |
154 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) | 147 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
155 #else | 148 #else |
156 #define WARN_UNUSED_RESULT | 149 #define WARN_UNUSED_RESULT |
157 #endif | 150 #endif |
158 | 151 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 // Macro for hinting that an expression is likely to be false. | 192 // Macro for hinting that an expression is likely to be false. |
200 #if !defined(UNLIKELY) | 193 #if !defined(UNLIKELY) |
201 #if defined(COMPILER_GCC) | 194 #if defined(COMPILER_GCC) |
202 #define UNLIKELY(x) __builtin_expect(!!(x), 0) | 195 #define UNLIKELY(x) __builtin_expect(!!(x), 0) |
203 #else | 196 #else |
204 #define UNLIKELY(x) (x) | 197 #define UNLIKELY(x) (x) |
205 #endif // defined(COMPILER_GCC) | 198 #endif // defined(COMPILER_GCC) |
206 #endif // !defined(UNLIKELY) | 199 #endif // !defined(UNLIKELY) |
207 | 200 |
208 #endif // BASE_COMPILER_SPECIFIC_H_ | 201 #endif // BASE_COMPILER_SPECIFIC_H_ |
OLD | NEW |