Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: webrtc/base/checks.h

Issue 2384083004: Revert of Test RTC_DCHECK_IS_ON instead of checking DCHECK_ALWAYS_ON everywhere (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/base/buffer.h ('k') | webrtc/base/criticalsection.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #ifndef WEBRTC_BASE_CHECKS_H_ 11 #ifndef WEBRTC_BASE_CHECKS_H_
12 #define WEBRTC_BASE_CHECKS_H_ 12 #define WEBRTC_BASE_CHECKS_H_
13 13
14 #include "webrtc/typedefs.h" 14 #include "webrtc/typedefs.h"
15 15
16 // If you for some reson need to know if DCHECKs are on, test the value of 16 #if (!defined(NDEBUG) || defined(DCHECK_ALWAYS_ON))
17 // RTC_DCHECK_IS_ON. (Test its value, not if it's defined; it'll always be
18 // defined, to either a true or a false value.)
19 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
20 #define RTC_DCHECK_IS_ON 1 17 #define RTC_DCHECK_IS_ON 1
21 #else 18 #else
22 #define RTC_DCHECK_IS_ON 0 19 #define RTC_DCHECK_IS_ON 0
23 #endif 20 #endif
24 21
25 #ifdef __cplusplus 22 #ifdef __cplusplus
26 extern "C" { 23 extern "C" {
27 #endif 24 #endif
28 NO_RETURN void rtc_FatalMessage(const char* file, int line, const char* msg); 25 NO_RETURN void rtc_FatalMessage(const char* file, int line, const char* msg);
29 #ifdef __cplusplus 26 #ifdef __cplusplus
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // The actual stream used isn't important. We reference condition in the code 83 // The actual stream used isn't important. We reference condition in the code
87 // but don't evaluate it; this is to avoid "unused variable" warnings (we do so 84 // but don't evaluate it; this is to avoid "unused variable" warnings (we do so
88 // in a particularly convoluted way with an extra ?: because that appears to be 85 // in a particularly convoluted way with an extra ?: because that appears to be
89 // the simplest construct that keeps Visual Studio from complaining about 86 // the simplest construct that keeps Visual Studio from complaining about
90 // condition being unused). 87 // condition being unused).
91 #define RTC_EAT_STREAM_PARAMETERS(condition) \ 88 #define RTC_EAT_STREAM_PARAMETERS(condition) \
92 (true ? true : !(condition)) \ 89 (true ? true : !(condition)) \
93 ? static_cast<void>(0) \ 90 ? static_cast<void>(0) \
94 : rtc::FatalMessageVoidify() & rtc::FatalMessage("", 0).stream() 91 : rtc::FatalMessageVoidify() & rtc::FatalMessage("", 0).stream()
95 92
96 // RTC_CHECK dies with a fatal error if condition is not true. It is *not* 93 // RTC_CHECK dies with a fatal error if condition is not true. It is *not*
97 // controlled by NDEBUG or anything else, so the check will be executed 94 // controlled by NDEBUG, so the check will be executed regardless of
98 // regardless of compilation mode. 95 // compilation mode.
99 // 96 //
100 // We make sure RTC_CHECK et al. always evaluates their arguments, as 97 // We make sure RTC_CHECK et al. always evaluates their arguments, as
101 // doing RTC_CHECK(FunctionWithSideEffect()) is a common idiom. 98 // doing RTC_CHECK(FunctionWithSideEffect()) is a common idiom.
102 #define RTC_CHECK(condition) \ 99 #define RTC_CHECK(condition) \
103 RTC_LAZY_STREAM(rtc::FatalMessage(__FILE__, __LINE__).stream(), \ 100 RTC_LAZY_STREAM(rtc::FatalMessage(__FILE__, __LINE__).stream(), \
104 !(condition)) \ 101 !(condition)) \
105 << "Check failed: " #condition << std::endl << "# " 102 << "Check failed: " #condition << std::endl << "# "
106 103
107 // Helper macro for binary operators. 104 // Helper macro for binary operators.
108 // Don't use this macro directly in your code, use RTC_CHECK_EQ et al below. 105 // Don't use this macro directly in your code, use RTC_CHECK_EQ et al below.
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 #define RTC_DCHECK_EQ(a, b) RTC_DCHECK((a) == (b)) 270 #define RTC_DCHECK_EQ(a, b) RTC_DCHECK((a) == (b))
274 #define RTC_DCHECK_NE(a, b) RTC_DCHECK((a) != (b)) 271 #define RTC_DCHECK_NE(a, b) RTC_DCHECK((a) != (b))
275 #define RTC_DCHECK_LE(a, b) RTC_DCHECK((a) <= (b)) 272 #define RTC_DCHECK_LE(a, b) RTC_DCHECK((a) <= (b))
276 #define RTC_DCHECK_LT(a, b) RTC_DCHECK((a) < (b)) 273 #define RTC_DCHECK_LT(a, b) RTC_DCHECK((a) < (b))
277 #define RTC_DCHECK_GE(a, b) RTC_DCHECK((a) >= (b)) 274 #define RTC_DCHECK_GE(a, b) RTC_DCHECK((a) >= (b))
278 #define RTC_DCHECK_GT(a, b) RTC_DCHECK((a) > (b)) 275 #define RTC_DCHECK_GT(a, b) RTC_DCHECK((a) > (b))
279 276
280 #endif // __cplusplus 277 #endif // __cplusplus
281 278
282 #endif // WEBRTC_BASE_CHECKS_H_ 279 #endif // WEBRTC_BASE_CHECKS_H_
OLDNEW
« no previous file with comments | « webrtc/base/buffer.h ('k') | webrtc/base/criticalsection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698