Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 29 additions & 42 deletions include/os/freebsd/spl/sys/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,21 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
} while (0)

#define VERIFY3B(LEFT, OP, RIGHT) do { \
const boolean_t _verify3_left = (boolean_t)(LEFT); \
const boolean_t _verify3_right = (boolean_t)(RIGHT); \
const boolean_t _verify3_left = (boolean_t)!!(LEFT); \
const boolean_t _verify3_right = (boolean_t)!!(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
"VERIFY3B(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%d " #OP " %d)\n", \
(boolean_t)_verify3_left, \
(boolean_t)_verify3_right); \
_verify3_left, _verify3_right); \
} while (0)

#define VERIFY3S(LEFT, OP, RIGHT) do { \
const int64_t _verify3_left = (int64_t)(LEFT); \
const int64_t _verify3_right = (int64_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
"VERIFY3S(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%lld " #OP " %lld)\n", \
(long long)_verify3_left, \
(long long)_verify3_right); \
Expand All @@ -138,7 +137,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const uint64_t _verify3_right = (uint64_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
"VERIFY3U(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%llu " #OP " %llu)\n", \
(unsigned long long)_verify3_left, \
(unsigned long long)_verify3_right); \
Expand All @@ -149,8 +148,8 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
"failed (%px " #OP " %px)\n", \
"VERIFY3P(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%p " #OP " %p)\n", \
(void *)_verify3_left, \
(void *)_verify3_right); \
} while (0)
Expand All @@ -159,17 +158,15 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const int64_t _verify0_right = (int64_t)(RIGHT); \
if (unlikely(!(0 == _verify0_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY0(" #RIGHT ") " \
"failed (0 == %lld)\n", \
"VERIFY0(" #RIGHT ") failed (%lld)\n", \
(long long)_verify0_right); \
} while (0)

#define VERIFY0P(RIGHT) do { \
const uintptr_t _verify0_right = (uintptr_t)(RIGHT); \
if (unlikely(!(0 == _verify0_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY0P(" #RIGHT ") " \
"failed (NULL == %px)\n", \
"VERIFY0P(" #RIGHT ") failed (%p)\n", \
(void *)_verify0_right); \
} while (0)

Expand All @@ -182,14 +179,13 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
*/

#define VERIFY3BF(LEFT, OP, RIGHT, STR, ...) do { \
const boolean_t _verify3_left = (boolean_t)(LEFT); \
const boolean_t _verify3_right = (boolean_t)(RIGHT); \
const boolean_t _verify3_left = (boolean_t)!!(LEFT); \
const boolean_t _verify3_right = (boolean_t)!!(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
"VERIFY3B(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%d " #OP " %d) " STR "\n", \
(boolean_t)(_verify3_left), \
(boolean_t)(_verify3_right), \
_verify3_left, _verify3_right, \
__VA_ARGS__); \
} while (0)

Expand All @@ -198,10 +194,9 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const int64_t _verify3_right = (int64_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
"VERIFY3S(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%lld " #OP " %lld) " STR "\n", \
(long long)(_verify3_left), \
(long long)(_verify3_right), \
(long long)_verify3_left, (long long)_verify3_right,\
__VA_ARGS__); \
} while (0)

Expand All @@ -210,10 +205,10 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const uint64_t _verify3_right = (uint64_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
"VERIFY3U(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%llu " #OP " %llu) " STR "\n", \
(unsigned long long)(_verify3_left), \
(unsigned long long)(_verify3_right), \
(unsigned long long)_verify3_left, \
(unsigned long long)_verify3_right, \
__VA_ARGS__); \
} while (0)

Expand All @@ -222,32 +217,27 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
"failed (%px " #OP " %px) " STR "\n", \
(void *) (_verify3_left), \
(void *) (_verify3_right), \
"VERIFY3P(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%p " #OP " %p) " STR "\n", \
(void *)_verify3_left, (void *)_verify3_right, \
__VA_ARGS__); \
} while (0)

#define VERIFY0PF(RIGHT, STR, ...) do { \
const uintptr_t _verify3_left = (uintptr_t)(0); \
const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \
if (unlikely(!(_verify3_left == _verify3_right))) \
if (unlikely(!(0 == _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY0(0 == " #RIGHT ") " \
"failed (0 == %px) " STR "\n", \
(long long) (_verify3_right), \
"VERIFY0P(" #RIGHT ") failed (%p) " STR "\n", \
(void *)_verify3_right, \
__VA_ARGS__); \
} while (0)

#define VERIFY0F(RIGHT, STR, ...) do { \
const int64_t _verify3_left = (int64_t)(0); \
const int64_t _verify3_right = (int64_t)(RIGHT); \
if (unlikely(!(_verify3_left == _verify3_right))) \
if (unlikely(!(0 == _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY0(0 == " #RIGHT ") " \
"failed (0 == %lld) " STR "\n", \
(long long) (_verify3_right), \
"VERIFY0(" #RIGHT ") failed (%lld) " STR "\n", \
(long long)_verify3_right, \
__VA_ARGS__); \
} while (0)

Expand All @@ -256,10 +246,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
spl_assert("(" #A ") implies (" #B ")", \
__FILE__, __FUNCTION__, __LINE__)))

#define VERIFY_EQUIV(A, B) \
((void)(likely(!!(A) == !!(B)) || \
spl_assert("(" #A ") is equivalent to (" #B ")", \
__FILE__, __FUNCTION__, __LINE__)))
#define VERIFY_EQUIV(A, B) VERIFY3B(A, ==, B)

/*
* Debugging disabled (--disable-debug)
Expand Down
67 changes: 27 additions & 40 deletions include/os/linux/spl/sys/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,21 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
} while (0)

#define VERIFY3B(LEFT, OP, RIGHT) do { \
const boolean_t _verify3_left = (boolean_t)(LEFT); \
const boolean_t _verify3_right = (boolean_t)(RIGHT); \
const boolean_t _verify3_left = (boolean_t)!!(LEFT); \
const boolean_t _verify3_right = (boolean_t)!!(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
"VERIFY3B(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%d " #OP " %d)\n", \
(boolean_t)_verify3_left, \
(boolean_t)_verify3_right); \
_verify3_left, _verify3_right); \
} while (0)

#define VERIFY3S(LEFT, OP, RIGHT) do { \
const int64_t _verify3_left = (int64_t)(LEFT); \
const int64_t _verify3_right = (int64_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
"VERIFY3S(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%lld " #OP " %lld)\n", \
(long long)_verify3_left, \
(long long)_verify3_right); \
Expand All @@ -142,7 +141,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const uint64_t _verify3_right = (uint64_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
"VERIFY3U(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%llu " #OP " %llu)\n", \
(unsigned long long)_verify3_left, \
(unsigned long long)_verify3_right); \
Expand All @@ -153,7 +152,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
"VERIFY3P(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%px " #OP " %px)\n", \
(void *)_verify3_left, \
(void *)_verify3_right); \
Expand All @@ -163,17 +162,15 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const int64_t _verify0_right = (int64_t)(RIGHT); \
if (unlikely(!(0 == _verify0_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY0(" #RIGHT ") " \
"failed (0 == %lld)\n", \
"VERIFY0(" #RIGHT ") failed (%lld)\n", \
(long long)_verify0_right); \
} while (0)

#define VERIFY0P(RIGHT) do { \
const uintptr_t _verify0_right = (uintptr_t)(RIGHT); \
if (unlikely(!(0 == _verify0_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY0P(" #RIGHT ") " \
"failed (NULL == %px)\n", \
"VERIFY0P(" #RIGHT ") failed (%px)\n", \
(void *)_verify0_right); \
} while (0)

Expand All @@ -186,14 +183,13 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
*/

#define VERIFY3BF(LEFT, OP, RIGHT, STR, ...) do { \
const boolean_t _verify3_left = (boolean_t)(LEFT); \
const boolean_t _verify3_right = (boolean_t)(RIGHT); \
const boolean_t _verify3_left = (boolean_t)!!(LEFT); \
const boolean_t _verify3_right = (boolean_t)!!(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
"VERIFY3B(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%d " #OP " %d) " STR "\n", \
(boolean_t)(_verify3_left), \
(boolean_t)(_verify3_right), \
_verify3_left, _verify3_right, \
__VA_ARGS__); \
} while (0)

Expand All @@ -202,10 +198,9 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const int64_t _verify3_right = (int64_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
"VERIFY3S(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%lld " #OP " %lld) " STR "\n", \
(long long)(_verify3_left), \
(long long)(_verify3_right), \
(long long)_verify3_left, (long long)_verify3_right,\
__VA_ARGS__); \
} while (0)

Expand All @@ -214,10 +209,10 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const uint64_t _verify3_right = (uint64_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
"VERIFY3U(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%llu " #OP " %llu) " STR "\n", \
(unsigned long long)(_verify3_left), \
(unsigned long long)(_verify3_right), \
(unsigned long long)_verify3_left, \
(unsigned long long)_verify3_right, \
__VA_ARGS__); \
} while (0)

Expand All @@ -226,32 +221,27 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \
if (unlikely(!(_verify3_left OP _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
"VERIFY3P(" #LEFT ", " #OP ", " #RIGHT ") " \
"failed (%px " #OP " %px) " STR "\n", \
(void *) (_verify3_left), \
(void *) (_verify3_right), \
(void *)_verify3_left, (void *)_verify3_right, \
__VA_ARGS__); \
} while (0)

#define VERIFY0PF(RIGHT, STR, ...) do { \
const uintptr_t _verify3_left = (uintptr_t)(0); \
const uintptr_t _verify3_right = (uintptr_t)(RIGHT); \
if (unlikely(!(_verify3_left == _verify3_right))) \
if (unlikely(!(0 == _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY0(0 == " #RIGHT ") " \
"failed (0 == %px) " STR "\n", \
(long long) (_verify3_right), \
"VERIFY0P(" #RIGHT ") failed (%px) " STR "\n", \
(void *)_verify3_right, \
__VA_ARGS__); \
} while (0)

#define VERIFY0F(RIGHT, STR, ...) do { \
const int64_t _verify3_left = (int64_t)(0); \
const int64_t _verify3_right = (int64_t)(RIGHT); \
if (unlikely(!(_verify3_left == _verify3_right))) \
if (unlikely(!(0 == _verify3_right))) \
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
"VERIFY0(0 == " #RIGHT ") " \
"failed (0 == %lld) " STR "\n", \
(long long) (_verify3_right), \
"VERIFY0(" #RIGHT ") failed (%lld) " STR "\n", \
(long long)_verify3_right, \
__VA_ARGS__); \
} while (0)

Expand All @@ -260,10 +250,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
spl_assert("(" #A ") implies (" #B ")", \
__FILE__, __FUNCTION__, __LINE__)))

#define VERIFY_EQUIV(A, B) \
((void)(likely(!!(A) == !!(B)) || \
spl_assert("(" #A ") is equivalent to (" #B ")", \
__FILE__, __FUNCTION__, __LINE__)))
#define VERIFY_EQUIV(A, B) VERIFY3B(A, ==, B)

/*
* Debugging disabled (--disable-debug)
Expand Down
Loading
Loading