| 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 |
| 11 #ifndef WEBRTC_RTC_BASE_CHECKS_H_ | 11 #ifndef WEBRTC_RTC_BASE_CHECKS_H_ |
| 12 #define WEBRTC_RTC_BASE_CHECKS_H_ | 12 #define WEBRTC_RTC_BASE_CHECKS_H_ |
| 13 | 13 |
| 14 #include "webrtc/typedefs.h" |
| 15 |
| 14 // If you for some reson need to know if DCHECKs are on, test the value of | 16 // If you for some reson need to know if DCHECKs are on, test the value of |
| 15 // RTC_DCHECK_IS_ON. (Test its value, not if it's defined; it'll always be | 17 // RTC_DCHECK_IS_ON. (Test its value, not if it's defined; it'll always be |
| 16 // defined, to either a true or a false value.) | 18 // defined, to either a true or a false value.) |
| 17 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) | 19 #if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON) |
| 18 #define RTC_DCHECK_IS_ON 1 | 20 #define RTC_DCHECK_IS_ON 1 |
| 19 #else | 21 #else |
| 20 #define RTC_DCHECK_IS_ON 0 | 22 #define RTC_DCHECK_IS_ON 0 |
| 21 #endif | 23 #endif |
| 22 | 24 |
| 23 // Annotate a function that will not return control flow to the caller. | |
| 24 #if defined(_MSC_VER) | |
| 25 #define RTC_NO_RETURN __declspec(noreturn) | |
| 26 #elif defined(__GNUC__) | |
| 27 #define RTC_NO_RETURN __attribute__ ((__noreturn__)) | |
| 28 #else | |
| 29 #define RTC_NO_RETURN | |
| 30 #endif | |
| 31 | |
| 32 #ifdef __cplusplus | 25 #ifdef __cplusplus |
| 33 extern "C" { | 26 extern "C" { |
| 34 #endif | 27 #endif |
| 35 RTC_NO_RETURN | 28 NO_RETURN void rtc_FatalMessage(const char* file, int line, const char* msg); |
| 36 void rtc_FatalMessage(const char* file, int line, const char* msg); | |
| 37 #ifdef __cplusplus | 29 #ifdef __cplusplus |
| 38 } // extern "C" | 30 } // extern "C" |
| 39 #endif | 31 #endif |
| 40 | 32 |
| 41 #ifdef __cplusplus | 33 #ifdef __cplusplus |
| 42 // C++ version. | 34 // C++ version. |
| 43 | 35 |
| 44 #include <sstream> | 36 #include <sstream> |
| 45 #include <string> | 37 #include <string> |
| 46 | 38 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // TODO(ajm): Consider adding RTC_NOTIMPLEMENTED macro when | 225 // TODO(ajm): Consider adding RTC_NOTIMPLEMENTED macro when |
| 234 // base/logging.h and system_wrappers/logging.h are consolidated such that we | 226 // base/logging.h and system_wrappers/logging.h are consolidated such that we |
| 235 // can match the Chromium behavior. | 227 // can match the Chromium behavior. |
| 236 | 228 |
| 237 // Like a stripped-down LogMessage from logging.h, except that it aborts. | 229 // Like a stripped-down LogMessage from logging.h, except that it aborts. |
| 238 class FatalMessage { | 230 class FatalMessage { |
| 239 public: | 231 public: |
| 240 FatalMessage(const char* file, int line); | 232 FatalMessage(const char* file, int line); |
| 241 // Used for RTC_CHECK_EQ(), etc. Takes ownership of the given string. | 233 // Used for RTC_CHECK_EQ(), etc. Takes ownership of the given string. |
| 242 FatalMessage(const char* file, int line, std::string* result); | 234 FatalMessage(const char* file, int line, std::string* result); |
| 243 RTC_NO_RETURN ~FatalMessage(); | 235 NO_RETURN ~FatalMessage(); |
| 244 | 236 |
| 245 std::ostream& stream() { return stream_; } | 237 std::ostream& stream() { return stream_; } |
| 246 | 238 |
| 247 private: | 239 private: |
| 248 void Init(const char* file, int line); | 240 void Init(const char* file, int line); |
| 249 | 241 |
| 250 std::ostringstream stream_; | 242 std::ostringstream stream_; |
| 251 }; | 243 }; |
| 252 | 244 |
| 253 // Performs the integer division a/b and returns the result. CHECKs that the | 245 // Performs the integer division a/b and returns the result. CHECKs that the |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 #define RTC_DCHECK_EQ(a, b) RTC_DCHECK((a) == (b)) | 280 #define RTC_DCHECK_EQ(a, b) RTC_DCHECK((a) == (b)) |
| 289 #define RTC_DCHECK_NE(a, b) RTC_DCHECK((a) != (b)) | 281 #define RTC_DCHECK_NE(a, b) RTC_DCHECK((a) != (b)) |
| 290 #define RTC_DCHECK_LE(a, b) RTC_DCHECK((a) <= (b)) | 282 #define RTC_DCHECK_LE(a, b) RTC_DCHECK((a) <= (b)) |
| 291 #define RTC_DCHECK_LT(a, b) RTC_DCHECK((a) < (b)) | 283 #define RTC_DCHECK_LT(a, b) RTC_DCHECK((a) < (b)) |
| 292 #define RTC_DCHECK_GE(a, b) RTC_DCHECK((a) >= (b)) | 284 #define RTC_DCHECK_GE(a, b) RTC_DCHECK((a) >= (b)) |
| 293 #define RTC_DCHECK_GT(a, b) RTC_DCHECK((a) > (b)) | 285 #define RTC_DCHECK_GT(a, b) RTC_DCHECK((a) > (b)) |
| 294 | 286 |
| 295 #endif // __cplusplus | 287 #endif // __cplusplus |
| 296 | 288 |
| 297 #endif // WEBRTC_RTC_BASE_CHECKS_H_ | 289 #endif // WEBRTC_RTC_BASE_CHECKS_H_ |
| OLD | NEW |