| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 #endif | 100 #endif |
| 101 | 101 |
| 102 #if COMPILER_GCC && defined(NDEBUG) | 102 #if COMPILER_GCC && defined(NDEBUG) |
| 103 #define ALWAYS_INLINE inline __attribute__((__always_inline__)) | 103 #define ALWAYS_INLINE inline __attribute__((__always_inline__)) |
| 104 #elif COMPILER_MSVC && defined(NDEBUG) | 104 #elif COMPILER_MSVC && defined(NDEBUG) |
| 105 #define ALWAYS_INLINE __forceinline | 105 #define ALWAYS_INLINE __forceinline |
| 106 #else | 106 #else |
| 107 #define ALWAYS_INLINE inline | 107 #define ALWAYS_INLINE inline |
| 108 #endif | 108 #endif |
| 109 | 109 |
| 110 // Specify memory alignment for structs, classes, etc. | |
| 111 // Use like: | |
| 112 // class ALIGNAS(16) MyClass { ... } | |
| 113 // ALIGNAS(16) int array[4]; | |
| 114 #if defined(COMPILER_MSVC) | |
| 115 #define ALIGNAS(byte_alignment) __declspec(align(byte_alignment)) | |
| 116 #elif defined(COMPILER_GCC) | |
| 117 #define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment))) | |
| 118 #endif | |
| 119 | |
| 120 // Return the byte alignment of the given type (available at compile time). | |
| 121 // Use like: | |
| 122 // ALIGNOF(int32_t) // this would be 4 | |
| 123 #if defined(COMPILER_MSVC) | |
| 124 #define ALIGNOF(type) __alignof(type) | |
| 125 #elif defined(COMPILER_GCC) | |
| 126 #define ALIGNOF(type) __alignof__(type) | |
| 127 #endif | |
| 128 | |
| 129 // Annotate a function indicating the caller must examine the return value. | 110 // Annotate a function indicating the caller must examine the return value. |
| 130 // Use like: | 111 // Use like: |
| 131 // int foo() WARN_UNUSED_RESULT; | 112 // int foo() WARN_UNUSED_RESULT; |
| 132 // To explicitly ignore a result, see |ignore_result()| in base/macros.h. | 113 // To explicitly ignore a result, see |ignore_result()| in base/macros.h. |
| 133 #undef WARN_UNUSED_RESULT | 114 #undef WARN_UNUSED_RESULT |
| 134 #if defined(COMPILER_GCC) || defined(__clang__) | 115 #if defined(COMPILER_GCC) || defined(__clang__) |
| 135 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) | 116 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
| 136 #else | 117 #else |
| 137 #define WARN_UNUSED_RESULT | 118 #define WARN_UNUSED_RESULT |
| 138 #endif | 119 #endif |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 204 |
| 224 // Compiler feature-detection. | 205 // Compiler feature-detection. |
| 225 // clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension | 206 // clang.llvm.org/docs/LanguageExtensions.html#has-feature-and-has-extension |
| 226 #if defined(__has_feature) | 207 #if defined(__has_feature) |
| 227 #define HAS_FEATURE(FEATURE) __has_feature(FEATURE) | 208 #define HAS_FEATURE(FEATURE) __has_feature(FEATURE) |
| 228 #else | 209 #else |
| 229 #define HAS_FEATURE(FEATURE) 0 | 210 #define HAS_FEATURE(FEATURE) 0 |
| 230 #endif | 211 #endif |
| 231 | 212 |
| 232 #endif // BASE_COMPILER_SPECIFIC_H_ | 213 #endif // BASE_COMPILER_SPECIFIC_H_ |
| OLD | NEW |