Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/systm.h
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | |||||
#if defined(WITNESS) || defined(INVARIANT_SUPPORT) | #if defined(WITNESS) || defined(INVARIANT_SUPPORT) | ||||
#ifdef KASSERT_PANIC_OPTIONAL | #ifdef KASSERT_PANIC_OPTIONAL | ||||
void kassert_panic(const char *fmt, ...) __printflike(1, 2); | void kassert_panic(const char *fmt, ...) __printflike(1, 2); | ||||
#else | #else | ||||
#define kassert_panic panic | #define kassert_panic panic | ||||
#endif | #endif | ||||
#endif | #endif | ||||
#ifndef __FILE_NAME__ | |||||
#define __FILE_NAME__ __FILE__ | |||||
#endif | |||||
#ifdef INVARIANTS /* The option is always available */ | #ifdef INVARIANTS /* The option is always available */ | ||||
#define KASSERT(exp,msg) do { \ | #define KASSERT(exp,msg) do { \ | ||||
if (__predict_false(!(exp))) \ | if (__predict_false(!(exp))) \ | ||||
kassert_panic msg; \ | kassert_panic msg; \ | ||||
} while (0) | } while (0) | ||||
#define KPASS(exp) do { \ | |||||
if (__predict_false(!(exp))) \ | |||||
kassert_panic("condition %s false at %s (%s:%d)", #exp, \ | |||||
__func__, __FILE_NAME__, __LINE__); \ | |||||
} while (0) | |||||
#define KPASS2(exp,str) do { \ | |||||
if (__predict_false(!(exp))) \ | |||||
kassert_panic("condition %s false at %s (%s:%d): %s", #exp,\ | |||||
__func__, __FILE_NAME__, __LINE__, str); \ | |||||
} while (0) | |||||
#define KPASS3(exp,fmt,fmtarg) do { \ | |||||
if (__predict_false(!(exp))) \ | |||||
kassert_panic("condition %s false at %s (%s:%d): " #fmt,\ | |||||
#exp, __func__, __FILE_NAME__, __LINE__, fmtarg); \ | |||||
} while (0) | |||||
#define VNASSERT(exp, vp, msg) do { \ | #define VNASSERT(exp, vp, msg) do { \ | ||||
if (__predict_false(!(exp))) { \ | if (__predict_false(!(exp))) { \ | ||||
vn_printf(vp, "VNASSERT failed: %s not true at %s:%d (%s)\n",\ | vn_printf(vp, "VNASSERT failed: %s not true at %s:%d (%s)\n",\ | ||||
#exp, __FILE__, __LINE__, __func__); \ | #exp, __FILE__, __LINE__, __func__); \ | ||||
kassert_panic msg; \ | kassert_panic msg; \ | ||||
} \ | } \ | ||||
} while (0) | } while (0) | ||||
#define VNPASS(exp, vp) do { \ | #define VNPASS(exp, vp) do { \ | ||||
const char *_exp = #exp; \ | const char *_exp = #exp; \ | ||||
VNASSERT(exp, vp, ("condition %s not met at %s:%d (%s)", \ | VNASSERT(exp, vp, ("condition %s not met at %s:%d (%s)", \ | ||||
_exp, __FILE__, __LINE__, __func__)); \ | _exp, __FILE__, __LINE__, __func__)); \ | ||||
} while (0) | } while (0) | ||||
#else | #else | ||||
#define KASSERT(exp,msg) do { \ | #define KASSERT(exp,msg) do { \ | ||||
} while (0) | |||||
#define KPASS(exp) do { \ | |||||
} while (0) | |||||
#define KPASS2(exp,str) do { \ | |||||
} while (0) | |||||
#define KPASS3(exp,fmt,fmtarg) do { \ | |||||
} while (0) | } while (0) | ||||
#define VNASSERT(exp, vp, msg) do { \ | #define VNASSERT(exp, vp, msg) do { \ | ||||
} while (0) | } while (0) | ||||
#define VNPASS(exp, vp) do { \ | #define VNPASS(exp, vp) do { \ | ||||
} while (0) | } while (0) | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 486 Lines • Show Last 20 Lines |