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 // sizeof(type) prior to checking __alignof to workaround Visual C++ bug: | 132 // sizeof(type) prior to checking __alignof to workaround Visual C++ bug: |
133 // http://goo.gl/isH0C | 133 // http://goo.gl/isH0C |
134 // Use like: | 134 // Use like: |
135 // ALIGNOF(int32) // this would be 4 | 135 // ALIGNOF(int32) // this would be 4 |
136 #if defined(COMPILER_MSVC) | 136 #if defined(COMPILER_MSVC) |
137 #define ALIGNOF(type) (sizeof(type) - sizeof(type) + __alignof(type)) | 137 #define ALIGNOF(type) (sizeof(type) - sizeof(type) + __alignof(type)) |
138 #elif defined(COMPILER_GCC) | 138 #elif defined(COMPILER_GCC) |
139 #define ALIGNOF(type) __alignof__(type) | 139 #define ALIGNOF(type) __alignof__(type) |
140 #endif | 140 #endif |
141 | 141 |
142 // Annotate a virtual method indicating it must be overriding a virtual | |
143 // method in the parent class. | |
144 // Use like: | |
145 // virtual void foo() OVERRIDE; | |
146 #define OVERRIDE override | |
147 | |
148 // Annotate a function indicating the caller must examine the return value. | 142 // Annotate a function indicating the caller must examine the return value. |
149 // Use like: | 143 // Use like: |
150 // int foo() WARN_UNUSED_RESULT; | 144 // int foo() WARN_UNUSED_RESULT; |
151 // 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>. |
152 #if defined(COMPILER_GCC) | 146 #if defined(COMPILER_GCC) |
153 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) | 147 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
154 #else | 148 #else |
155 #define WARN_UNUSED_RESULT | 149 #define WARN_UNUSED_RESULT |
156 #endif | 150 #endif |
157 | 151 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 // Macro for hinting that an expression is likely to be false. | 192 // Macro for hinting that an expression is likely to be false. |
199 #if !defined(UNLIKELY) | 193 #if !defined(UNLIKELY) |
200 #if defined(COMPILER_GCC) | 194 #if defined(COMPILER_GCC) |
201 #define UNLIKELY(x) __builtin_expect(!!(x), 0) | 195 #define UNLIKELY(x) __builtin_expect(!!(x), 0) |
202 #else | 196 #else |
203 #define UNLIKELY(x) (x) | 197 #define UNLIKELY(x) (x) |
204 #endif // defined(COMPILER_GCC) | 198 #endif // defined(COMPILER_GCC) |
205 #endif // !defined(UNLIKELY) | 199 #endif // !defined(UNLIKELY) |
206 | 200 |
207 #endif // BASE_COMPILER_SPECIFIC_H_ | 201 #endif // BASE_COMPILER_SPECIFIC_H_ |
OLD | NEW |