aboutsummaryrefslogtreecommitdiff
path: root/sbin/hastd/pjdlog.h
diff options
context:
space:
mode:
authorPawel Jakub Dawidek <pjd@FreeBSD.org>2010-08-05 18:26:38 +0000
committerPawel Jakub Dawidek <pjd@FreeBSD.org>2010-08-05 18:26:38 +0000
commit524840d8d073477be6446924079367a5826883cb (patch)
treebb7796651ea6ec61e2de4c6f3974d3287c90b72e /sbin/hastd/pjdlog.h
parent60e1759be65f24985a5bedb9397d63ee61129ddb (diff)
downloadsrc-524840d8d073477be6446924079367a5826883cb.tar.gz
src-524840d8d073477be6446924079367a5826883cb.zip
Problem with assertion is that it logs on stderr. Add two macros:
PJDLOG_ASSERT() and PJDLOG_VERIFY() that will check the given condition and log the problem where appropriate. The difference between those two is that PJDLOG_VERIFY() always work and PJDLOG_ASSERT() can be turned off by defining NDEBUG. MFC after: 1 month
Notes
Notes: svn path=/head/; revision=210875
Diffstat (limited to 'sbin/hastd/pjdlog.h')
-rw-r--r--sbin/hastd/pjdlog.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/sbin/hastd/pjdlog.h b/sbin/hastd/pjdlog.h
index 2136b12f42ae..28b49dec7d78 100644
--- a/sbin/hastd/pjdlog.h
+++ b/sbin/hastd/pjdlog.h
@@ -85,4 +85,17 @@ void pjdlogv_exit(int exitcode, const char *fmt, va_list ap) __printflike(2, 0)
void pjdlog_exitx(int exitcode, const char *fmt, ...) __printflike(2, 3) __dead2;
void pjdlogv_exitx(int exitcode, const char *fmt, va_list ap) __printflike(2, 0) __dead2;
+void pjdlog_verify(const char *func, const char *file, int line,
+ const char *failedexpr) __dead2;
+
+#define PJDLOG_VERIFY(expr) do { \
+ if (!(expr)) \
+ pjdlog_verify(__func__, __FILE__, __LINE__, #expr); \
+} while (0)
+#ifdef NDEBUG
+#define PJDLOG_ASSERT(expr) do { } while (0)
+#else
+#define PJDLOG_ASSERT(expr) PJDLOG_VERIFY(expr)
+#endif
+
#endif /* !_PJDLOG_H_ */