Add MPASSERT() and MPPASS() macros

Suggested by:	mjg
Reviewed by:	imp, mjg
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D35652
This commit is contained in:
Konstantin Belousov 2022-06-29 14:37:04 +03:00
parent 1e54362824
commit 61ae7a355c

View File

@ -46,19 +46,35 @@ extern bool panicked;
kassert_panic msg; \
} \
} while (0)
#define MPASSERT(exp, mp, msg) do { \
if (__predict_false(!(exp))) { \
printf("MPASSERT mp %p failed: %s not true at %s:%d (%s)\n",\
(mp), #exp, __FILE__, __LINE__, __func__); \
kassert_panic msg; \
} \
} while (0)
#define VNPASS(exp, vp) do { \
const char *_exp = #exp; \
VNASSERT(exp, vp, ("condition %s not met at %s:%d (%s)", \
_exp, __FILE__, __LINE__, __func__)); \
} while (0)
#define MPPASS(exp, mp) do { \
const char *_exp = #exp; \
MPASSERT(exp, mp, ("condition %s not met at %s:%d (%s)", \
_exp, __FILE__, __LINE__, __func__)); \
} while (0)
#define __assert_unreachable() \
panic("executing segment marked as unreachable at %s:%d (%s)\n", \
__FILE__, __LINE__, __func__)
#else /* INVARIANTS */
#define VNASSERT(exp, vp, msg) do { \
} while (0)
#define MPASSERT(exp, mp, msg) do { \
} while (0)
#define VNPASS(exp, vp) do { \
} while (0)
#define MPPASS(exp, mp) do { \
} while (0)
#define __assert_unreachable() __unreachable()
#endif /* INVARIANTS */