diff options
author | pjd <pjd@FreeBSD.org> | 2011-01-27 19:28:29 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2011-01-27 19:28:29 +0000 |
commit | cf58ca408fd35b53f3d07d4876d87632cbb0d914 (patch) | |
tree | c26851066f045fd3d5b08aaf4fb82d3998f90e78 /sbin/hastd/pjdlog.h | |
parent | 79709f16df2b9d506195cddaa1ffbcd98da2c244 (diff) | |
download | FreeBSD-src-cf58ca408fd35b53f3d07d4876d87632cbb0d914.zip FreeBSD-src-cf58ca408fd35b53f3d07d4876d87632cbb0d914.tar.gz |
Extend pjdlog_verify() to support the following additional macros:
PJDLOG_RVERIFY() - always check expression and on false log the given message
and exit.
PJDLOG_RASSERT() - check expression when NDEBUG is not defined and on false log
given message and exit.
PJDLOG_ABORT() - log the given message and exit.
MFC after: 1 week
Diffstat (limited to 'sbin/hastd/pjdlog.h')
-rw-r--r-- | sbin/hastd/pjdlog.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/sbin/hastd/pjdlog.h b/sbin/hastd/pjdlog.h index e9d1740..2e80e81 100644 --- a/sbin/hastd/pjdlog.h +++ b/sbin/hastd/pjdlog.h @@ -90,16 +90,28 @@ 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); + const char *failedexpr, const char *fmt, ...) __printflike(5, 6); #define PJDLOG_VERIFY(expr) do { \ - if (!(expr)) \ - pjdlog_verify(__func__, __FILE__, __LINE__, #expr); \ + if (!(expr)) { \ + pjdlog_verify(__func__, __FILE__, __LINE__, #expr, \ + __func__); \ + } \ } while (0) +#define PJDLOG_RVERIFY(expr, ...) do { \ + if (!(expr)) { \ + pjdlog_verify(__func__, __FILE__, __LINE__, #expr, \ + __VA_ARGS__); \ + } \ +} while (0) +#define PJDLOG_ABORT(...) pjdlog_verify(__func__, __FILE__, \ + __LINE__, NULL, __VA_ARGS__) #ifdef NDEBUG #define PJDLOG_ASSERT(expr) do { } while (0) +#define PJDLOG_RASSERT(...) do { } while (0) #else #define PJDLOG_ASSERT(expr) PJDLOG_VERIFY(expr) +#define PJDLOG_RASSERT(...) PJDLOG_RVERIFY(__VA_ARGS__) #endif #endif /* !_PJDLOG_H_ */ |