diff --git a/sys/alpha/include/ipl.h b/sys/alpha/include/ipl.h index 201aad06e4c..0e390666654 100644 --- a/sys/alpha/include/ipl.h +++ b/sys/alpha/include/ipl.h @@ -70,6 +70,12 @@ static __inline int name(void) \ return s; \ } else \ return cpl; \ +} \ + \ +static __inline int \ +is_##name(void) \ +{ \ + return (getcpl() >= ALPHA_PSL_IP_L##pri); \ } SPLUP(splsoftcam, SOFT) diff --git a/sys/i386/isa/ipl_funcs.c b/sys/i386/isa/ipl_funcs.c index 78b1c1d5fef..5a305ec7f1d 100644 --- a/sys/i386/isa/ipl_funcs.c +++ b/sys/i386/isa/ipl_funcs.c @@ -67,14 +67,19 @@ softclockpending(void) #ifndef SMP -#define GENSPL(NAME, OP, MODIFIER, PC) \ -unsigned NAME(void) \ -{ \ - unsigned x; \ - \ - x = cpl; \ - cpl OP MODIFIER; \ - return (x); \ +#define GENSPL(NAME, OP, MODIFIER, PC) \ +unsigned NAME(void) \ +{ \ + unsigned x; \ + \ + x = cpl; \ + cpl OP MODIFIER; \ + return (x); \ +} \ +int \ +is_##NAME(void) \ +{ \ + return ((cpl & (MODIFIER)) == (MODIFIER)); \ } void @@ -186,23 +191,35 @@ unsigned NAME(void) \ IFCPL_UNLOCK(); \ \ return (x); \ +} \ +int \ +is_##NAME(void) \ +{ \ + return ((cpl & (MODIFIER)) == (MODIFIER)); \ } + #else /* INTR_SPL */ -#define GENSPL(NAME, OP, MODIFIER, PC) \ -unsigned NAME(void) \ -{ \ - unsigned x; \ - \ - IFCPL_LOCK(); \ - x = cpl; \ - cpl OP MODIFIER; \ - IFCPL_UNLOCK(); \ - \ - return (x); \ +#define GENSPL(NAME, OP, MODIFIER, PC) \ +unsigned NAME(void) \ +{ \ + unsigned x; \ + \ + IFCPL_LOCK(); \ + x = cpl; \ + cpl OP MODIFIER; \ + IFCPL_UNLOCK(); \ + \ + return (x); \ +} \ +int \ +is_##NAME(void) \ +{ \ + return ((cpl & (MODIFIER)) == (MODIFIER)); \ } + #endif /* INTR_SPL */ diff --git a/sys/sys/systm.h b/sys/sys/systm.h index ffbd1ce0a59..f4e4d263dfc 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -44,6 +44,7 @@ #include #include +#include #include extern int securelevel; /* system security level (see init(8)) */ @@ -75,8 +76,13 @@ extern int bootverbose; /* nonzero to print verbose messages */ #ifdef INVARIANTS /* The option is always available */ #define KASSERT(exp,msg) do { if (!(exp)) panic msg; } while (0) +#define SPLSTRINGIZE(a) #a +#define SPLASSERT(level, msg) \ + KASSERT(is_spl##level(), ("%s: not spl%s, cpl == 0x%08x\n", \ + (msg), SPLSTRINGIZE(level), cpl)) #else #define KASSERT(exp,msg) +#define SPLASSERT(level, msg) #endif /* @@ -124,6 +130,7 @@ u_quad_t strtouq __P((const char *, char **, int)); void bcopy __P((const void *from, void *to, size_t len)); void ovbcopy __P((const void *from, void *to, size_t len)); + #ifdef __i386__ extern void (*bzero) __P((void *buf, size_t len)); #else @@ -227,6 +234,26 @@ intrmask_t splsoftvm __P((void)); intrmask_t splstatclock __P((void)); intrmask_t spltty __P((void)); intrmask_t splvm __P((void)); +#if defined (INVARIANT_SUPPORT) +/* + * The Alpha has all of these as static __inline. + */ +int is_splbio __P((void)); +int is_splcam __P((void)); +int is_splclock __P((void)); +int is_splhigh __P((void)); +int is_splimp __P((void)); +int is_splnet __P((void)); +int is_splsoftcam __P((void)); +int is_splsoftcambio __P((void)); +int is_splsoftcamnet __P((void)); +int is_splsoftclock __P((void)); +int is_splsofttty __P((void)); +int is_splsoftvm __P((void)); +int is_splstatclock __P((void)); +int is_spltty __P((void)); +int is_splvm __P((void)); +#endif /* INVARIANT_SUPPORT */ void splx __P((intrmask_t ipl)); void splz __P((void)); #endif /* __i386__ */