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. |
danakj
2015/10/07 16:16:54
Could we ifdef then undef and redefine here?
dcheng
2015/10/07 16:41:34
Done (I just unconditionally undef since this file
| |
123 #if !defined(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 |
129 #endif | |
127 | 130 |
128 // Tell the compiler a function is using a printf-style format string. | 131 // 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; | 132 // |format_param| is the one-based index of the format string parameter; |
130 // |dots_param| is the one-based index of the "..." parameter. | 133 // |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. | 134 // 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.) | 135 // (This is undocumented but matches what the system C headers do.) |
133 #if defined(COMPILER_GCC) | 136 #if defined(COMPILER_GCC) |
134 #define PRINTF_FORMAT(format_param, dots_param) \ | 137 #define PRINTF_FORMAT(format_param, dots_param) \ |
135 __attribute__((format(printf, format_param, dots_param))) | 138 __attribute__((format(printf, format_param, dots_param))) |
136 #else | 139 #else |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 // Macro for hinting that an expression is likely to be false. | 179 // Macro for hinting that an expression is likely to be false. |
177 #if !defined(UNLIKELY) | 180 #if !defined(UNLIKELY) |
178 #if defined(COMPILER_GCC) | 181 #if defined(COMPILER_GCC) |
179 #define UNLIKELY(x) __builtin_expect(!!(x), 0) | 182 #define UNLIKELY(x) __builtin_expect(!!(x), 0) |
180 #else | 183 #else |
181 #define UNLIKELY(x) (x) | 184 #define UNLIKELY(x) (x) |
182 #endif // defined(COMPILER_GCC) | 185 #endif // defined(COMPILER_GCC) |
183 #endif // !defined(UNLIKELY) | 186 #endif // !defined(UNLIKELY) |
184 | 187 |
185 #endif // BASE_COMPILER_SPECIFIC_H_ | 188 #endif // BASE_COMPILER_SPECIFIC_H_ |
OLD | NEW |