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_LOGGING_H_ | 5 #ifndef BASE_LOGGING_H_ |
6 #define BASE_LOGGING_H_ | 6 #define BASE_LOGGING_H_ |
7 | 7 |
8 #include <cassert> | 8 #include <cassert> |
9 #include <string> | 9 #include <string> |
10 #include <cstring> | 10 #include <cstring> |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 DEFINE_CHECK_OP_IMPL(GE, >=) | 564 DEFINE_CHECK_OP_IMPL(GE, >=) |
565 DEFINE_CHECK_OP_IMPL(GT, > ) | 565 DEFINE_CHECK_OP_IMPL(GT, > ) |
566 #undef DEFINE_CHECK_OP_IMPL | 566 #undef DEFINE_CHECK_OP_IMPL |
567 | 567 |
568 #define CHECK_EQ(val1, val2) CHECK_OP(EQ, ==, val1, val2) | 568 #define CHECK_EQ(val1, val2) CHECK_OP(EQ, ==, val1, val2) |
569 #define CHECK_NE(val1, val2) CHECK_OP(NE, !=, val1, val2) | 569 #define CHECK_NE(val1, val2) CHECK_OP(NE, !=, val1, val2) |
570 #define CHECK_LE(val1, val2) CHECK_OP(LE, <=, val1, val2) | 570 #define CHECK_LE(val1, val2) CHECK_OP(LE, <=, val1, val2) |
571 #define CHECK_LT(val1, val2) CHECK_OP(LT, < , val1, val2) | 571 #define CHECK_LT(val1, val2) CHECK_OP(LT, < , val1, val2) |
572 #define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2) | 572 #define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2) |
573 #define CHECK_GT(val1, val2) CHECK_OP(GT, > , val1, val2) | 573 #define CHECK_GT(val1, val2) CHECK_OP(GT, > , val1, val2) |
574 #define CHECK_IMPLIES(val1, val2) CHECK(!(val1) || (val2)) | |
575 | 574 |
576 #if defined(NDEBUG) | 575 #if defined(NDEBUG) |
577 #define ENABLE_DLOG 0 | 576 #define ENABLE_DLOG 0 |
578 #else | 577 #else |
579 #define ENABLE_DLOG 1 | 578 #define ENABLE_DLOG 1 |
580 #endif | 579 #endif |
581 | 580 |
582 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) | 581 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) |
583 #define DCHECK_IS_ON() 0 | 582 #define DCHECK_IS_ON() 0 |
584 #else | 583 #else |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 // WARNING: These may not compile correctly if one of the arguments is a pointer | 717 // WARNING: These may not compile correctly if one of the arguments is a pointer |
719 // and the other is NULL. To work around this, simply static_cast NULL to the | 718 // and the other is NULL. To work around this, simply static_cast NULL to the |
720 // type of the desired pointer. | 719 // type of the desired pointer. |
721 | 720 |
722 #define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2) | 721 #define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2) |
723 #define DCHECK_NE(val1, val2) DCHECK_OP(NE, !=, val1, val2) | 722 #define DCHECK_NE(val1, val2) DCHECK_OP(NE, !=, val1, val2) |
724 #define DCHECK_LE(val1, val2) DCHECK_OP(LE, <=, val1, val2) | 723 #define DCHECK_LE(val1, val2) DCHECK_OP(LE, <=, val1, val2) |
725 #define DCHECK_LT(val1, val2) DCHECK_OP(LT, < , val1, val2) | 724 #define DCHECK_LT(val1, val2) DCHECK_OP(LT, < , val1, val2) |
726 #define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2) | 725 #define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2) |
727 #define DCHECK_GT(val1, val2) DCHECK_OP(GT, > , val1, val2) | 726 #define DCHECK_GT(val1, val2) DCHECK_OP(GT, > , val1, val2) |
728 #define DCHECK_IMPLIES(val1, val2) DCHECK(!(val1) || (val2)) | |
729 | 727 |
730 #if !DCHECK_IS_ON() && defined(OS_CHROMEOS) | 728 #if !DCHECK_IS_ON() && defined(OS_CHROMEOS) |
731 // Implement logging of NOTREACHED() as a dedicated function to get function | 729 // Implement logging of NOTREACHED() as a dedicated function to get function |
732 // call overhead down to a minimum. | 730 // call overhead down to a minimum. |
733 void LogErrorNotReached(const char* file, int line); | 731 void LogErrorNotReached(const char* file, int line); |
734 #define NOTREACHED() \ | 732 #define NOTREACHED() \ |
735 true ? ::logging::LogErrorNotReached(__FILE__, __LINE__) \ | 733 true ? ::logging::LogErrorNotReached(__FILE__, __LINE__) \ |
736 : EAT_STREAM_PARAMETERS | 734 : EAT_STREAM_PARAMETERS |
737 #else | 735 #else |
738 #define NOTREACHED() DCHECK(false) | 736 #define NOTREACHED() DCHECK(false) |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 #elif NOTIMPLEMENTED_POLICY == 5 | 962 #elif NOTIMPLEMENTED_POLICY == 5 |
965 #define NOTIMPLEMENTED() do {\ | 963 #define NOTIMPLEMENTED() do {\ |
966 static bool logged_once = false;\ | 964 static bool logged_once = false;\ |
967 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ | 965 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ |
968 logged_once = true;\ | 966 logged_once = true;\ |
969 } while(0);\ | 967 } while(0);\ |
970 EAT_STREAM_PARAMETERS | 968 EAT_STREAM_PARAMETERS |
971 #endif | 969 #endif |
972 | 970 |
973 #endif // BASE_LOGGING_H_ | 971 #endif // BASE_LOGGING_H_ |
OLD | NEW |