Skip to content

Commit

Permalink
use original
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Gottschall <s.gottschall@dd-wrt.com>
  • Loading branch information
BrainSlayer committed Apr 19, 2024
1 parent 41cef35 commit 4d7d8e7
Showing 1 changed file with 10 additions and 56 deletions.
66 changes: 10 additions & 56 deletions lib/libspl/include/assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,77 +63,32 @@ libspl_assert(const char *buf, const char *file, const char *func, int line)
#ifdef verify
#undef verify
#endif
#ifdef NDEBUG
#define VERIFY(cond) (void) ((!(cond)))
#define verify(cond) (void) ((!(cond)))

#define PANIC(fmt, a...) \
libspl_assertf(__FILE__, __FUNCTION__, __LINE__, fmt, ## a)

#define VERIFY3B(LEFT, OP, RIGHT) \
do { \
const boolean_t __left __attribute__((unused)) = \
(boolean_t)(LEFT); \
const boolean_t __right __attribute__((unused)) = \
(boolean_t)(RIGHT); \
} while (0)

#define VERIFY3S(LEFT, OP, RIGHT) \
do { \
const int64_t __left __attribute__((unused)) = \
(int64_t)(LEFT); \
const int64_t __right __attribute__((unused)) = \
(int64_t)(RIGHT); \
} while (0)

#define VERIFY3U(LEFT, OP, RIGHT) \
do { \
const uint64_t __left __attribute__((unused)) = \
(uint64_t)(LEFT); \
const uint64_t __right __attribute__((unused)) = \
(uint64_t)(RIGHT); \
} while (0)

#define VERIFY3P(LEFT, OP, RIGHT) \
do { \
const uintptr_t __left __attribute__((unused)) = \
(uintptr_t)(LEFT); \
const uintptr_t __right __attribute__((unused)) = \
(uintptr_t)(RIGHT); \
} while (0)

#define VERIFY0(LEFT) \
do { \
const uint64_t __left __attribute__((unused)) = \
(uint64_t)(LEFT); \
} while (0)
#else

#define VERIFY(cond) \
(void) ((!(cond)) && \
libspl_assert(#cond, "unknown", __FUNCTION__, __LINE__))
libspl_assert(#cond, __FILE__, __FUNCTION__, __LINE__))

#define VERIFYF(cond, STR, ...) \
do { \
if (!(cond)) \
libspl_assertf( "unknown", __FUNCTION__, __LINE__, \
libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \
"%s " STR, #cond, \
__VA_ARGS__); \
} while (0)

#define verify(cond) \
(void) ((!(cond)) && \
libspl_assert(#cond, "unknown", __FUNCTION__, __LINE__))

#define PANIC(fmt, a...) \
libspl_assertf("unknown", __FUNCTION__, __LINE__, fmt, ## a)
libspl_assert(#cond, __FILE__, __FUNCTION__, __LINE__))

#define VERIFY3B(LEFT, OP, RIGHT) \
do { \
const boolean_t __left = (boolean_t)(LEFT); \
const boolean_t __right = (boolean_t)(RIGHT); \
if (!(__left OP __right)) \
libspl_assertf("unknown", __FUNCTION__, __LINE__, \
libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \
"%s %s %s (0x%llx %s 0x%llx)", #LEFT, #OP, #RIGHT, \
(u_longlong_t)__left, #OP, (u_longlong_t)__right); \
} while (0)
Expand All @@ -143,7 +98,7 @@ do { \
const int64_t __left = (int64_t)(LEFT); \
const int64_t __right = (int64_t)(RIGHT); \
if (!(__left OP __right)) \
libspl_assertf("unknown", __FUNCTION__, __LINE__, \
libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \
"%s %s %s (0x%llx %s 0x%llx)", #LEFT, #OP, #RIGHT, \
(u_longlong_t)__left, #OP, (u_longlong_t)__right); \
} while (0)
Expand All @@ -153,7 +108,7 @@ do { \
const uint64_t __left = (uint64_t)(LEFT); \
const uint64_t __right = (uint64_t)(RIGHT); \
if (!(__left OP __right)) \
libspl_assertf("unknown", __FUNCTION__, __LINE__, \
libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \
"%s %s %s (0x%llx %s 0x%llx)", #LEFT, #OP, #RIGHT, \
(u_longlong_t)__left, #OP, (u_longlong_t)__right); \
} while (0)
Expand All @@ -163,7 +118,7 @@ do { \
const uintptr_t __left = (uintptr_t)(LEFT); \
const uintptr_t __right = (uintptr_t)(RIGHT); \
if (!(__left OP __right)) \
libspl_assertf("unknown", __FUNCTION__, __LINE__, \
libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \
"%s %s %s (%p %s %p)", #LEFT, #OP, #RIGHT, \
(void *)__left, #OP, (void *)__right); \
} while (0)
Expand All @@ -172,7 +127,7 @@ do { \
do { \
const uint64_t __left = (uint64_t)(LEFT); \
if (!(__left == 0)) \
libspl_assertf("unknown", __FUNCTION__, __LINE__, \
libspl_assertf(__FILE__, __FUNCTION__, __LINE__, \
"%s == 0 (0x%llx == 0)", #LEFT, \
(u_longlong_t)__left); \
} while (0)
Expand Down Expand Up @@ -258,7 +213,6 @@ do { \
"%s == 0 (%p == 0) " STR, #LEFT, \
(u_longlong_t)__left, __VA_ARGS__); \
} while (0)
#endif

#ifdef assert
#undef assert
Expand Down Expand Up @@ -308,11 +262,11 @@ do { \
#define IMPLY(A, B) \
((void)(((!(A)) || (B)) || \
libspl_assert("(" #A ") implies (" #B ")", \
"unknown", __FUNCTION__, __LINE__)))
__FILE__, __FUNCTION__, __LINE__)))
#define EQUIV(A, B) \
((void)((!!(A) == !!(B)) || \
libspl_assert("(" #A ") is equivalent to (" #B ")", \
"unknown", __FUNCTION__, __LINE__)))
__FILE__, __FUNCTION__, __LINE__)))

#endif /* NDEBUG */

Expand Down

0 comments on commit 4d7d8e7

Please sign in to comment.