Skip to content

Commit e16bc9c

Browse files
committed
Added VERIFYf by request
Signed-off-by: Rich Ercolani <[email protected]>
1 parent 6f3c41d commit e16bc9c

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

include/os/freebsd/spl/sys/debug.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
__attribute__((__noreturn__))
7777
#endif
7878
extern void spl_panic(const char *file, const char *func, int line,
79-
const char *fmt, ...) __attribute__((__noreturn__));
79+
const char *fmt, ...);
8080
extern void spl_dumpstack(void);
8181

8282
static inline int
@@ -102,6 +102,11 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
102102
spl_assert("VERIFY(" #cond ") failed\n", \
103103
__FILE__, __FUNCTION__, __LINE__))
104104

105+
#define VERIFYf(cond, str, ...) \
106+
(void) (unlikely(!(cond)) && \
107+
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
108+
"VERIFY(" #cond ") failed " str "\n", __VA_ARGS__))
109+
105110
#define VERIFY3B(LEFT, OP, RIGHT) do { \
106111
const boolean_t _verify3_left = (boolean_t)(LEFT); \
107112
const boolean_t _verify3_right = (boolean_t)(RIGHT); \
@@ -274,6 +279,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
274279
#define ASSERT3Pf(x, y, z, str, ...) ASSERT3P(x,y,z)
275280
#define ASSERT0Pf(x, str, ...) ASSERT0P(x)
276281
#define ASSERT0f(x, str, ...) ASSERT0(x)
282+
#define ASSERTf(x, str, ...) ASSERT(x)
277283
#define IMPLY(A, B) \
278284
((void) sizeof ((uintptr_t)(A)), (void) sizeof ((uintptr_t)(B)))
279285
#define EQUIV(A, B) \
@@ -296,6 +302,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
296302
#define ASSERT3Pf VERIFY3Pf
297303
#define ASSERT0Pf VERIFY0Pf
298304
#define ASSERT0f VERIFY0f
305+
#define ASSERTf VERIFYf
299306
#define ASSERT VERIFY
300307
#define IMPLY VERIFY_IMPLY
301308
#define EQUIV VERIFY_EQUIV

include/os/linux/spl/sys/debug.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
__attribute__((__noreturn__))
7777
#endif
7878
extern void spl_panic(const char *file, const char *func, int line,
79-
const char *fmt, ...) __attribute__((__noreturn__));
79+
const char *fmt, ...);
8080
extern void spl_dumpstack(void);
8181

8282
static inline int
@@ -102,6 +102,11 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
102102
spl_assert("VERIFY(" #cond ") failed\n", \
103103
__FILE__, __FUNCTION__, __LINE__))
104104

105+
#define VERIFYf(cond, str, ...) \
106+
(void) (unlikely(!(cond)) && \
107+
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
108+
"VERIFY(" #cond ") failed " str "\n", __VA_ARGS__))
109+
105110
#define VERIFY3B(LEFT, OP, RIGHT) do { \
106111
const boolean_t _verify3_left = (boolean_t)(LEFT); \
107112
const boolean_t _verify3_right = (boolean_t)(RIGHT); \
@@ -274,6 +279,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
274279
#define ASSERT3Pf(x, y, z, str, ...) ASSERT3P(x,y,z)
275280
#define ASSERT0Pf(x, str, ...) ASSERT0P(x)
276281
#define ASSERT0f(x, str, ...) ASSERT0(x)
282+
#define ASSERTf(x, str, ...) ASSERT(x)
277283
#define IMPLY(A, B) \
278284
((void) sizeof ((uintptr_t)(A)), (void) sizeof ((uintptr_t)(B)))
279285
#define EQUIV(A, B) \
@@ -296,6 +302,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
296302
#define ASSERT3Pf VERIFY3Pf
297303
#define ASSERT0Pf VERIFY0Pf
298304
#define ASSERT0f VERIFY0f
305+
#define ASSERTf VERIFYf
299306
#define ASSERT VERIFY
300307
#define IMPLY VERIFY_IMPLY
301308
#define EQUIV VERIFY_EQUIV

lib/libspl/include/assert.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ libspl_assert(const char *buf, const char *file, const char *func, int line)
7070
#define VERIFY(cond) \
7171
(void) ((!(cond)) && \
7272
libspl_assert(#cond, __FILE__, __FUNCTION__, __LINE__))
73+
#define VERIFYf(cond, str, ...) \
74+
(void) ((!(cond)) && \
75+
libspl_assertf(__FILE__, __FUNCTION__, __LINE__, "%s " str, \
76+
#cond, __VA_ARGS__))
77+
7378
#define verify(cond) \
7479
(void) ((!(cond)) && \
7580
libspl_assert(#cond, __FILE__, __FUNCTION__, __LINE__))
@@ -221,6 +226,7 @@ do { \
221226
#define ASSERT0Pf(x, str, ...) ASSERT0P(x)
222227
#define ASSERT0f(x, str, ...) ASSERT0(x)
223228
#define ASSERT(x) ((void) sizeof ((uintptr_t)(x)))
229+
#define ASSERTf(x, str, ...) ASSERT(x)
224230
#define assert(x) ((void) sizeof ((uintptr_t)(x)))
225231
#define IMPLY(A, B) \
226232
((void) sizeof ((uintptr_t)(A)), (void) sizeof ((uintptr_t)(B)))
@@ -240,6 +246,7 @@ do { \
240246
#define ASSERT0Pf VERIFY0Pf
241247
#define ASSERT0f VERIFY0f
242248
#define ASSERT VERIFY
249+
#define ASSERTf VERIFYf
243250
#define assert VERIFY
244251
#define IMPLY(A, B) \
245252
((void)(((!(A)) || (B)) || \

0 commit comments

Comments
 (0)