| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 #if defined(COMPILER_MSVC) | 112 #if defined(COMPILER_MSVC) |
| 113 #define ALIGNOF(type) __alignof(type) | 113 #define ALIGNOF(type) __alignof(type) |
| 114 #elif defined(COMPILER_GCC) | 114 #elif defined(COMPILER_GCC) |
| 115 #define ALIGNOF(type) __alignof__(type) | 115 #define ALIGNOF(type) __alignof__(type) |
| 116 #endif | 116 #endif |
| 117 | 117 |
| 118 // Annotate a function indicating the caller must examine the return value. | 118 // Annotate a function indicating the caller must examine the return value. |
| 119 // Use like: | 119 // Use like: |
| 120 // int foo() WARN_UNUSED_RESULT; | 120 // int foo() WARN_UNUSED_RESULT; |
| 121 // 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. |
| 122 #if defined(COMPILER_GCC) | 122 // TODO(dcheng): Update //third_party/webrtc's macro definition to match. |
| 123 #undef WARN_UNUSED_RESULT |
| 124 #if defined(COMPILER_GCC) || defined(__clang__) |
| 123 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) | 125 #define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) |
| 124 #else | 126 #else |
| 125 #define WARN_UNUSED_RESULT | 127 #define WARN_UNUSED_RESULT |
| 126 #endif | 128 #endif |
| 127 | 129 |
| 128 // Tell the compiler a function is using a printf-style format string. | 130 // Tell the compiler a function is using a printf-style format string. |
| 129 // |format_param| is the one-based index of the format string parameter; | 131 // |format_param| is the one-based index of the format string parameter; |
| 130 // |dots_param| is the one-based index of the "..." parameter. | 132 // |dots_param| is the one-based index of the "..." parameter. |
| 131 // For v*printf functions (which take a va_list), pass 0 for dots_param. | 133 // For v*printf functions (which take a va_list), pass 0 for dots_param. |
| 132 // (This is undocumented but matches what the system C headers do.) | 134 // (This is undocumented but matches what the system C headers do.) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 // Macro for hinting that an expression is likely to be false. | 178 // Macro for hinting that an expression is likely to be false. |
| 177 #if !defined(UNLIKELY) | 179 #if !defined(UNLIKELY) |
| 178 #if defined(COMPILER_GCC) | 180 #if defined(COMPILER_GCC) |
| 179 #define UNLIKELY(x) __builtin_expect(!!(x), 0) | 181 #define UNLIKELY(x) __builtin_expect(!!(x), 0) |
| 180 #else | 182 #else |
| 181 #define UNLIKELY(x) (x) | 183 #define UNLIKELY(x) (x) |
| 182 #endif // defined(COMPILER_GCC) | 184 #endif // defined(COMPILER_GCC) |
| 183 #endif // !defined(UNLIKELY) | 185 #endif // !defined(UNLIKELY) |
| 184 | 186 |
| 185 #endif // BASE_COMPILER_SPECIFIC_H_ | 187 #endif // BASE_COMPILER_SPECIFIC_H_ |
| OLD | NEW |