mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-29 16:44:03 +00:00
Add SPLASSERT() macro. SPLASSERT() compiles to a no-op
unless both "option INVARIANTS" and "options INVARIANT_SUPPORT" are defined in the kernel's config(8) file. SPLASSERT(expression, msg) used KASSERT to check that the expression is true, panic()ing the kernel otherwise. Approved by: jkh Reviewed by: jdp, dfr, phk, eivind and green
This commit is contained in:
parent
c5395b92eb
commit
f6a3d83f00
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=56079
@ -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)
|
||||
|
@ -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 */
|
||||
|
||||
|
||||
|
@ -44,6 +44,7 @@
|
||||
|
||||
#include <machine/atomic.h>
|
||||
#include <machine/cpufunc.h>
|
||||
#include <machine/ipl.h>
|
||||
#include <sys/callout.h>
|
||||
|
||||
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__ */
|
||||
|
Loading…
Reference in New Issue
Block a user