| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // ALIGNAS(16) int array[4]; | 106 // ALIGNAS(16) int array[4]; |
| 107 #if defined(COMPILER_MSVC) | 107 #if defined(COMPILER_MSVC) |
| 108 #define ALIGNAS(byte_alignment) __declspec(align(byte_alignment)) | 108 #define ALIGNAS(byte_alignment) __declspec(align(byte_alignment)) |
| 109 #elif defined(COMPILER_GCC) | 109 #elif defined(COMPILER_GCC) |
| 110 #define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment))) | 110 #define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment))) |
| 111 #endif | 111 #endif |
| 112 | 112 |
| 113 // Return the byte alignment of the given type (available at compile time). | 113 // Return the byte alignment of the given type (available at compile time). |
| 114 // Use like: | 114 // Use like: |
| 115 // ALIGNOF(int32) // this would be 4 | 115 // ALIGNOF(int32) // this would be 4 |
| 116 #if defined(COMPILER_MSVC) | 116 #define ALIGNOF(type) alignof(type) |
| 117 #define ALIGNOF(type) __alignof(type) | |
| 118 #elif defined(COMPILER_GCC) | |
| 119 #define ALIGNOF(type) __alignof__(type) | |
| 120 #endif | |
| 121 | 117 |
| 122 // Annotate a function indicating the caller must examine the return value. | 118 // Annotate a function indicating the caller must examine the return value. |
| 123 // Use like: | 119 // Use like: |
| 124 // int foo() WARN_UNUSED_RESULT; | 120 // int foo() WARN_UNUSED_RESULT; |
| 125 // To explicitly ignore a result, see |ignore_result()| in base/macros.h. | 121 // To explicitly ignore a result, see |ignore_result()| in base/macros.h. |
| 126 // TODO(dcheng): Update //third_party/webrtc's macro definition to match. | 122 // TODO(dcheng): Update //third_party/webrtc's macro definition to match. |
| 127 #undef WARN_UNUSED_RESULT | 123 #undef WARN_UNUSED_RESULT |
| 128 #if defined(COMPILER_GCC) || defined(__clang__) | 124 #if defined(COMPILER_GCC) || defined(__clang__) |
| 129 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) | 125 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
| 130 #else | 126 #else |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 // Macro for hinting that an expression is likely to be false. | 178 // Macro for hinting that an expression is likely to be false. |
| 183 #if !defined(UNLIKELY) | 179 #if !defined(UNLIKELY) |
| 184 #if defined(COMPILER_GCC) | 180 #if defined(COMPILER_GCC) |
| 185 #define UNLIKELY(x) __builtin_expect(!!(x), 0) | 181 #define UNLIKELY(x) __builtin_expect(!!(x), 0) |
| 186 #else | 182 #else |
| 187 #define UNLIKELY(x) (x) | 183 #define UNLIKELY(x) (x) |
| 188 #endif // defined(COMPILER_GCC) | 184 #endif // defined(COMPILER_GCC) |
| 189 #endif // !defined(UNLIKELY) | 185 #endif // !defined(UNLIKELY) |
| 190 | 186 |
| 191 #endif // BASE_COMPILER_SPECIFIC_H_ | 187 #endif // BASE_COMPILER_SPECIFIC_H_ |
| OLD | NEW |