OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Internal logging macros, to avoid external dependencies. |
| 6 |
| 7 #ifndef MOJO_EDK_UTIL_LOGGING_INTERNAL_H_ |
| 8 #define MOJO_EDK_UTIL_LOGGING_INTERNAL_H_ |
| 9 |
| 10 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) |
| 11 |
| 12 #define INTERNAL_DCHECK(condition) \ |
| 13 do { \ |
| 14 } while (false && (condition)) |
| 15 |
| 16 #define INTERNAL_DCHECK_WITH_ERRNO(condition, fn, error) \ |
| 17 do { \ |
| 18 } while (false && (condition) && (error)) |
| 19 |
| 20 #else |
| 21 |
| 22 // Our own simplified "DCHECK". Asserts that |condition| is true. If not, "logs" |
| 23 // the failing condition and aborts. |
| 24 #define INTERNAL_DCHECK(condition) \ |
| 25 do { \ |
| 26 if (!(condition)) { \ |
| 27 ::mojo::util::internal::DcheckHelper(__FILE__, __LINE__, #condition); \ |
| 28 } \ |
| 29 } while (false) |
| 30 |
| 31 // Our own simplified "DCHECK"/"DPCHECK" hybrid. Asserts that |condition| is |
| 32 // true. If not, "logs" |fn| with errno value |error| and aborts. (This doesn't |
| 33 // just use |errno| since some APIs, like pthreads, don't set errno.) |
| 34 #define INTERNAL_DCHECK_WITH_ERRNO(condition, fn, error) \ |
| 35 do { \ |
| 36 if (!(condition)) { \ |
| 37 ::mojo::util::internal::DcheckWithErrnoHelper(__FILE__, __LINE__, fn, \ |
| 38 error); \ |
| 39 } \ |
| 40 } while (false) |
| 41 |
| 42 namespace mojo { |
| 43 namespace util { |
| 44 namespace internal { |
| 45 |
| 46 // Helper for |INTERNAL_DCHECK_WITH_ERRNO()| above. |
| 47 void DcheckHelper(const char* file, int line, const char* condition_string); |
| 48 |
| 49 // Helper for |INTERNAL_DCHECK_WITH_ERRNO()| above. |
| 50 void DcheckWithErrnoHelper(const char* file, |
| 51 int line, |
| 52 const char* fn, |
| 53 int error); |
| 54 |
| 55 } // namespace internal |
| 56 } // namespace util |
| 57 } // namespace mojo |
| 58 |
| 59 #endif // defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) |
| 60 |
| 61 #endif // MOJO_EDK_UTIL_LOGGING_INTERNAL_H_ |
OLD | NEW |