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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 #define RTC_CHECK_NE(val1, val2) RTC_CHECK_OP(NE, !=, val1, val2) | 157 #define RTC_CHECK_NE(val1, val2) RTC_CHECK_OP(NE, !=, val1, val2) |
158 #define RTC_CHECK_LE(val1, val2) RTC_CHECK_OP(LE, <=, val1, val2) | 158 #define RTC_CHECK_LE(val1, val2) RTC_CHECK_OP(LE, <=, val1, val2) |
159 #define RTC_CHECK_LT(val1, val2) RTC_CHECK_OP(LT, < , val1, val2) | 159 #define RTC_CHECK_LT(val1, val2) RTC_CHECK_OP(LT, < , val1, val2) |
160 #define RTC_CHECK_GE(val1, val2) RTC_CHECK_OP(GE, >=, val1, val2) | 160 #define RTC_CHECK_GE(val1, val2) RTC_CHECK_OP(GE, >=, val1, val2) |
161 #define RTC_CHECK_GT(val1, val2) RTC_CHECK_OP(GT, > , val1, val2) | 161 #define RTC_CHECK_GT(val1, val2) RTC_CHECK_OP(GT, > , val1, val2) |
162 | 162 |
163 // The RTC_DCHECK macro is equivalent to RTC_CHECK except that it only generates | 163 // The RTC_DCHECK macro is equivalent to RTC_CHECK except that it only generates |
164 // code in debug builds. It does reference the condition parameter in all cases, | 164 // code in debug builds. It does reference the condition parameter in all cases, |
165 // though, so callers won't risk getting warnings about unused variables. | 165 // though, so callers won't risk getting warnings about unused variables. |
166 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) | 166 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)) |
| 167 #define RTC_DCHECK_IS_ON 1 |
167 #define RTC_DCHECK(condition) RTC_CHECK(condition) | 168 #define RTC_DCHECK(condition) RTC_CHECK(condition) |
168 #define RTC_DCHECK_EQ(v1, v2) RTC_CHECK_EQ(v1, v2) | 169 #define RTC_DCHECK_EQ(v1, v2) RTC_CHECK_EQ(v1, v2) |
169 #define RTC_DCHECK_NE(v1, v2) RTC_CHECK_NE(v1, v2) | 170 #define RTC_DCHECK_NE(v1, v2) RTC_CHECK_NE(v1, v2) |
170 #define RTC_DCHECK_LE(v1, v2) RTC_CHECK_LE(v1, v2) | 171 #define RTC_DCHECK_LE(v1, v2) RTC_CHECK_LE(v1, v2) |
171 #define RTC_DCHECK_LT(v1, v2) RTC_CHECK_LT(v1, v2) | 172 #define RTC_DCHECK_LT(v1, v2) RTC_CHECK_LT(v1, v2) |
172 #define RTC_DCHECK_GE(v1, v2) RTC_CHECK_GE(v1, v2) | 173 #define RTC_DCHECK_GE(v1, v2) RTC_CHECK_GE(v1, v2) |
173 #define RTC_DCHECK_GT(v1, v2) RTC_CHECK_GT(v1, v2) | 174 #define RTC_DCHECK_GT(v1, v2) RTC_CHECK_GT(v1, v2) |
174 #else | 175 #else |
| 176 #define RTC_DCHECK_IS_ON 0 |
175 #define RTC_DCHECK(condition) RTC_EAT_STREAM_PARAMETERS(condition) | 177 #define RTC_DCHECK(condition) RTC_EAT_STREAM_PARAMETERS(condition) |
176 #define RTC_DCHECK_EQ(v1, v2) RTC_EAT_STREAM_PARAMETERS((v1) == (v2)) | 178 #define RTC_DCHECK_EQ(v1, v2) RTC_EAT_STREAM_PARAMETERS((v1) == (v2)) |
177 #define RTC_DCHECK_NE(v1, v2) RTC_EAT_STREAM_PARAMETERS((v1) != (v2)) | 179 #define RTC_DCHECK_NE(v1, v2) RTC_EAT_STREAM_PARAMETERS((v1) != (v2)) |
178 #define RTC_DCHECK_LE(v1, v2) RTC_EAT_STREAM_PARAMETERS((v1) <= (v2)) | 180 #define RTC_DCHECK_LE(v1, v2) RTC_EAT_STREAM_PARAMETERS((v1) <= (v2)) |
179 #define RTC_DCHECK_LT(v1, v2) RTC_EAT_STREAM_PARAMETERS((v1) < (v2)) | 181 #define RTC_DCHECK_LT(v1, v2) RTC_EAT_STREAM_PARAMETERS((v1) < (v2)) |
180 #define RTC_DCHECK_GE(v1, v2) RTC_EAT_STREAM_PARAMETERS((v1) >= (v2)) | 182 #define RTC_DCHECK_GE(v1, v2) RTC_EAT_STREAM_PARAMETERS((v1) >= (v2)) |
181 #define RTC_DCHECK_GT(v1, v2) RTC_EAT_STREAM_PARAMETERS((v1) > (v2)) | 183 #define RTC_DCHECK_GT(v1, v2) RTC_EAT_STREAM_PARAMETERS((v1) > (v2)) |
182 #endif | 184 #endif |
183 | 185 |
184 // This is identical to LogMessageVoidify but in name. | 186 // This is identical to LogMessageVoidify but in name. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 // remainder is zero. | 220 // remainder is zero. |
219 template <typename T> | 221 template <typename T> |
220 inline T CheckedDivExact(T a, T b) { | 222 inline T CheckedDivExact(T a, T b) { |
221 RTC_CHECK_EQ(a % b, static_cast<T>(0)); | 223 RTC_CHECK_EQ(a % b, static_cast<T>(0)); |
222 return a / b; | 224 return a / b; |
223 } | 225 } |
224 | 226 |
225 } // namespace rtc | 227 } // namespace rtc |
226 | 228 |
227 #endif // WEBRTC_BASE_CHECKS_H_ | 229 #endif // WEBRTC_BASE_CHECKS_H_ |
OLD | NEW |