OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2006 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // condition being unused). | 92 // condition being unused). |
93 #define RTC_EAT_STREAM_PARAMETERS(ignored) \ | 93 #define RTC_EAT_STREAM_PARAMETERS(ignored) \ |
94 (true ? true : ((void)(ignored), true)) \ | 94 (true ? true : ((void)(ignored), true)) \ |
95 ? static_cast<void>(0) \ | 95 ? static_cast<void>(0) \ |
96 : rtc::FatalMessageVoidify() & rtc::FatalMessage("", 0).stream() | 96 : rtc::FatalMessageVoidify() & rtc::FatalMessage("", 0).stream() |
97 | 97 |
98 // Call RTC_EAT_STREAM_PARAMETERS with an argument that fails to compile if | 98 // Call RTC_EAT_STREAM_PARAMETERS with an argument that fails to compile if |
99 // values of the same types as |a| and |b| can't be compared with the given | 99 // values of the same types as |a| and |b| can't be compared with the given |
100 // operation, and that would evaluate |a| and |b| if evaluated. | 100 // operation, and that would evaluate |a| and |b| if evaluated. |
101 #define RTC_EAT_STREAM_PARAMETERS_OP(op, a, b) \ | 101 #define RTC_EAT_STREAM_PARAMETERS_OP(op, a, b) \ |
102 RTC_EAT_STREAM_PARAMETERS(((void)rtc::safe_cmp::op(a, b))) | 102 RTC_EAT_STREAM_PARAMETERS(((void)rtc::Safe##op(a, b))) |
103 | 103 |
104 // RTC_CHECK dies with a fatal error if condition is not true. It is *not* | 104 // RTC_CHECK dies with a fatal error if condition is not true. It is *not* |
105 // controlled by NDEBUG or anything else, so the check will be executed | 105 // controlled by NDEBUG or anything else, so the check will be executed |
106 // regardless of compilation mode. | 106 // regardless of compilation mode. |
107 // | 107 // |
108 // We make sure RTC_CHECK et al. always evaluates their arguments, as | 108 // We make sure RTC_CHECK et al. always evaluates their arguments, as |
109 // doing RTC_CHECK(FunctionWithSideEffect()) is a common idiom. | 109 // doing RTC_CHECK(FunctionWithSideEffect()) is a common idiom. |
110 #define RTC_CHECK(condition) \ | 110 #define RTC_CHECK(condition) \ |
111 RTC_LAZY_STREAM(rtc::FatalMessage(__FILE__, __LINE__).stream(), \ | 111 RTC_LAZY_STREAM(rtc::FatalMessage(__FILE__, __LINE__).stream(), \ |
112 !(condition)) \ | 112 !(condition)) \ |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 #endif | 155 #endif |
156 | 156 |
157 // Helper functions for RTC_CHECK_OP macro. | 157 // Helper functions for RTC_CHECK_OP macro. |
158 // The (int, int) specialization works around the issue that the compiler | 158 // The (int, int) specialization works around the issue that the compiler |
159 // will not instantiate the template version of the function on values of | 159 // will not instantiate the template version of the function on values of |
160 // unnamed enum type - see comment below. | 160 // unnamed enum type - see comment below. |
161 #define DEFINE_RTC_CHECK_OP_IMPL(name) \ | 161 #define DEFINE_RTC_CHECK_OP_IMPL(name) \ |
162 template <class t1, class t2> \ | 162 template <class t1, class t2> \ |
163 inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \ | 163 inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \ |
164 const char* names) { \ | 164 const char* names) { \ |
165 if (rtc::safe_cmp::name(v1, v2)) \ | 165 if (rtc::Safe##name(v1, v2)) \ |
166 return nullptr; \ | 166 return nullptr; \ |
167 else \ | 167 else \ |
168 return rtc::MakeCheckOpString(v1, v2, names); \ | 168 return rtc::MakeCheckOpString(v1, v2, names); \ |
169 } \ | 169 } \ |
170 inline std::string* Check##name##Impl(int v1, int v2, const char* names) { \ | 170 inline std::string* Check##name##Impl(int v1, int v2, const char* names) { \ |
171 if (rtc::safe_cmp::name(v1, v2)) \ | 171 if (rtc::Safe##name(v1, v2)) \ |
172 return nullptr; \ | 172 return nullptr; \ |
173 else \ | 173 else \ |
174 return rtc::MakeCheckOpString(v1, v2, names); \ | 174 return rtc::MakeCheckOpString(v1, v2, names); \ |
175 } | 175 } |
176 DEFINE_RTC_CHECK_OP_IMPL(Eq) | 176 DEFINE_RTC_CHECK_OP_IMPL(Eq) |
177 DEFINE_RTC_CHECK_OP_IMPL(Ne) | 177 DEFINE_RTC_CHECK_OP_IMPL(Ne) |
178 DEFINE_RTC_CHECK_OP_IMPL(Le) | 178 DEFINE_RTC_CHECK_OP_IMPL(Le) |
179 DEFINE_RTC_CHECK_OP_IMPL(Lt) | 179 DEFINE_RTC_CHECK_OP_IMPL(Lt) |
180 DEFINE_RTC_CHECK_OP_IMPL(Ge) | 180 DEFINE_RTC_CHECK_OP_IMPL(Ge) |
181 DEFINE_RTC_CHECK_OP_IMPL(Gt) | 181 DEFINE_RTC_CHECK_OP_IMPL(Gt) |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 #define RTC_DCHECK_EQ(a, b) RTC_DCHECK((a) == (b)) | 280 #define RTC_DCHECK_EQ(a, b) RTC_DCHECK((a) == (b)) |
281 #define RTC_DCHECK_NE(a, b) RTC_DCHECK((a) != (b)) | 281 #define RTC_DCHECK_NE(a, b) RTC_DCHECK((a) != (b)) |
282 #define RTC_DCHECK_LE(a, b) RTC_DCHECK((a) <= (b)) | 282 #define RTC_DCHECK_LE(a, b) RTC_DCHECK((a) <= (b)) |
283 #define RTC_DCHECK_LT(a, b) RTC_DCHECK((a) < (b)) | 283 #define RTC_DCHECK_LT(a, b) RTC_DCHECK((a) < (b)) |
284 #define RTC_DCHECK_GE(a, b) RTC_DCHECK((a) >= (b)) | 284 #define RTC_DCHECK_GE(a, b) RTC_DCHECK((a) >= (b)) |
285 #define RTC_DCHECK_GT(a, b) RTC_DCHECK((a) > (b)) | 285 #define RTC_DCHECK_GT(a, b) RTC_DCHECK((a) > (b)) |
286 | 286 |
287 #endif // __cplusplus | 287 #endif // __cplusplus |
288 | 288 |
289 #endif // WEBRTC_BASE_CHECKS_H_ | 289 #endif // WEBRTC_BASE_CHECKS_H_ |
OLD | NEW |