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

Unified Diff: mojo/edk/util/logging_internal.h

Issue 1426343002: EDK: Move mutex.*, cond_var.*, and thread_annotations.h to //mojo/edk/util. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: oops Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/util/cond_var_unittest.cc ('k') | mojo/edk/util/logging_internal.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/util/logging_internal.h
diff --git a/mojo/edk/util/logging_internal.h b/mojo/edk/util/logging_internal.h
new file mode 100644
index 0000000000000000000000000000000000000000..59e501ef3c4e064362f95cf47b181771fcd786f8
--- /dev/null
+++ b/mojo/edk/util/logging_internal.h
@@ -0,0 +1,61 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Internal logging macros, to avoid external dependencies.
+
+#ifndef MOJO_EDK_UTIL_LOGGING_INTERNAL_H_
+#define MOJO_EDK_UTIL_LOGGING_INTERNAL_H_
+
+#if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
+
+#define INTERNAL_DCHECK(condition) \
+ do { \
+ } while (false && (condition))
+
+#define INTERNAL_DCHECK_WITH_ERRNO(condition, fn, error) \
+ do { \
+ } while (false && (condition) && (error))
+
+#else
+
+// Our own simplified "DCHECK". Asserts that |condition| is true. If not, "logs"
+// the failing condition and aborts.
+#define INTERNAL_DCHECK(condition) \
+ do { \
+ if (!(condition)) { \
+ ::mojo::util::internal::DcheckHelper(__FILE__, __LINE__, #condition); \
+ } \
+ } while (false)
+
+// Our own simplified "DCHECK"/"DPCHECK" hybrid. Asserts that |condition| is
+// true. If not, "logs" |fn| with errno value |error| and aborts. (This doesn't
+// just use |errno| since some APIs, like pthreads, don't set errno.)
+#define INTERNAL_DCHECK_WITH_ERRNO(condition, fn, error) \
+ do { \
+ if (!(condition)) { \
+ ::mojo::util::internal::DcheckWithErrnoHelper(__FILE__, __LINE__, fn, \
+ error); \
+ } \
+ } while (false)
+
+namespace mojo {
+namespace util {
+namespace internal {
+
+// Helper for |INTERNAL_DCHECK_WITH_ERRNO()| above.
+void DcheckHelper(const char* file, int line, const char* condition_string);
+
+// Helper for |INTERNAL_DCHECK_WITH_ERRNO()| above.
+void DcheckWithErrnoHelper(const char* file,
+ int line,
+ const char* fn,
+ int error);
+
+} // namespace internal
+} // namespace util
+} // namespace mojo
+
+#endif // defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON)
+
+#endif // MOJO_EDK_UTIL_LOGGING_INTERNAL_H_
« no previous file with comments | « mojo/edk/util/cond_var_unittest.cc ('k') | mojo/edk/util/logging_internal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698