summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2000-02-17 18:37:45 +0000
committerbde <bde@FreeBSD.org>2000-02-17 18:37:45 +0000
commit170be2ce1212108cbc237b9dd81ad3396b179438 (patch)
treed98182bfc8ac4f8da10ad87ef136059fdf068230
parentd7cc86703addd25740b7f34e29d45ffdfa11947c (diff)
downloadFreeBSD-src-170be2ce1212108cbc237b9dd81ad3396b179438.zip
FreeBSD-src-170be2ce1212108cbc237b9dd81ad3396b179438.tar.gz
Don't include <machine/ipl.h> in <sys/systm.h> in the i386 case. This
fixes some namespace pollution in general and breakage of modules that aren't in the sys tree in particular (<machine/ipl.h> includes further headers that aren't installed under /usr/include). Reimplemented SPLASSERT() so that it is more machine independent and less bloated and doesn't require the <machine/ipl.h> include spam. In particular, don't assume that `cpl' can be printed using %08x format. The alpha arch doesn't even have `cpl'. SPLASSERT() was harmless on alphas because it isn't actually used.
-rw-r--r--sys/alpha/alpha/ipl_funcs.c31
-rw-r--r--sys/alpha/include/ipl.h6
-rw-r--r--sys/i386/isa/ipl_funcs.c63
-rw-r--r--sys/sys/systm.h48
4 files changed, 86 insertions, 62 deletions
diff --git a/sys/alpha/alpha/ipl_funcs.c b/sys/alpha/alpha/ipl_funcs.c
index 7b15715..ea4154a 100644
--- a/sys/alpha/alpha/ipl_funcs.c
+++ b/sys/alpha/alpha/ipl_funcs.c
@@ -165,3 +165,34 @@ GENSET(schedsoftcambio, &idelayed, 1 << SWI_CAMBIO)
GENSET(schedsoftvm, &idelayed, 1 << SWI_VM)
GENSET(schedsoftclock, &idelayed, 1 << SWI_CLOCK)
+#ifdef INVARIANT_SUPPORT
+#define GENSPLASSERT(name, pri) \
+void \
+name##assert(const char *msg) \
+{ \
+ u_int cpl; \
+ \
+ cpl = getcpl(); \
+ if (cpl < ALPHA_PSL_IPL_##pri); \
+ panic("%s: not %s, cpl == %#x", \
+ msg, __XSTRING(name) + 3, cpl); \
+}
+#else
+#define GENSPLASSERT(name, pri)
+#endif
+
+GENSPLASSERT(splbio, IO)
+GENSPLASSERT(splcam, IO)
+GENSPLASSERT(splclock, CLOCK)
+GENSPLASSERT(splhigh, HIGH)
+GENSPLASSERT(splimp, IO)
+GENSPLASSERT(splnet, IO)
+GENSPLASSERT(splsoftcam, SOFT)
+GENSPLASSERT(splsoftcambio, SOFT) /* XXX no corresponding spl for alpha */
+GENSPLASSERT(splsoftcamnet, SOFT) /* XXX no corresponding spl for alpha */
+GENSPLASSERT(splsoftclock, SOFT)
+GENSPLASSERT(splsofttty, SOFT) /* XXX no corresponding spl for alpha */
+GENSPLASSERT(splsoftvm, SOFT)
+GENSPLASSERT(splstatclock, CLOCK)
+GENSPLASSERT(spltty, IO)
+GENSPLASSERT(splvm, IO)
diff --git a/sys/alpha/include/ipl.h b/sys/alpha/include/ipl.h
index cea0e09..201aad0 100644
--- a/sys/alpha/include/ipl.h
+++ b/sys/alpha/include/ipl.h
@@ -70,12 +70,6 @@ static __inline int name(void) \
return s; \
} else \
return cpl; \
-} \
- \
-static __inline int \
-is_##name(void) \
-{ \
- return (getcpl() >= ALPHA_PSL_IPL_##pri); \
}
SPLUP(splsoftcam, SOFT)
diff --git a/sys/i386/isa/ipl_funcs.c b/sys/i386/isa/ipl_funcs.c
index 14d74c9..13a0743 100644
--- a/sys/i386/isa/ipl_funcs.c
+++ b/sys/i386/isa/ipl_funcs.c
@@ -26,7 +26,7 @@
* $FreeBSD$
*/
-#include <sys/types.h>
+#include <sys/param.h>
#include <sys/systm.h>
#include <machine/ipl.h>
#include <machine/globals.h>
@@ -67,27 +67,29 @@ softclockpending(void)
#ifdef INVARIANT_SUPPORT
#define GENSPLASSERT(NAME, MODIFIER) \
-int \
-is_##NAME(void) \
+void \
+NAME##assert(const char *msg) \
{ \
- return ((cpl & (MODIFIER)) == (MODIFIER)); \
+ if ((cpl & (MODIFIER)) != (MODIFIER)) \
+ panic("%s: not %s, cpl == %#x", \
+ msg, __XSTRING(NAME) + 3, cpl); \
}
#else
-#define GENSPLASSERT(NAME, MODIFIER)
+#define GENSPLASSERT(NAME, MODIFIER)
#endif
#ifndef SMP
-#define GENSPL(NAME, OP, MODIFIER, PC) \
-unsigned NAME(void) \
-{ \
- unsigned x; \
- \
- x = cpl; \
- cpl OP MODIFIER; \
- return (x); \
-} \
-GENSPLASSERT(NAME, MODIFIER)
+#define GENSPL(NAME, OP, MODIFIER, PC) \
+GENSPLASSERT(NAME, MODIFIER) \
+unsigned NAME(void) \
+{ \
+ unsigned x; \
+ \
+ x = cpl; \
+ cpl OP MODIFIER; \
+ return (x); \
+}
void
spl0(void)
@@ -167,6 +169,7 @@ splq(intrmask_t mask)
#ifdef INTR_SPL
#define GENSPL(NAME, OP, MODIFIER, PC) \
+GENSPLASSERT(NAME, MODIFIER) \
unsigned NAME(void) \
{ \
unsigned x, y; \
@@ -198,25 +201,23 @@ unsigned NAME(void) \
IFCPL_UNLOCK(); \
\
return (x); \
-} \
-GENSPLASSERT(NAME, 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); \
-} \
-GENSPLASSERT(NAME, MODIFIER)
+#define GENSPL(NAME, OP, MODIFIER, PC) \
+GENSPLASSERT(NAME, MODIFIER) \
+unsigned NAME(void) \
+{ \
+ unsigned x; \
+ \
+ IFCPL_LOCK(); \
+ x = cpl; \
+ cpl OP MODIFIER; \
+ IFCPL_UNLOCK(); \
+ \
+ return (x); \
+}
#endif /* INTR_SPL */
diff --git a/sys/sys/systm.h b/sys/sys/systm.h
index f4e4d26..3c2d784 100644
--- a/sys/sys/systm.h
+++ b/sys/sys/systm.h
@@ -44,7 +44,6 @@
#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)) */
@@ -76,10 +75,7 @@ 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))
+#define SPLASSERT(level, msg) __CONCAT(__CONCAT(spl,level),assert)(msg)
#else
#define KASSERT(exp,msg)
#define SPLASSERT(level, msg)
@@ -203,6 +199,10 @@ void untimeout __P((timeout_t *, void *, struct callout_handle));
/* Interrupt management */
+/*
+ * For the alpha arch, some of these functions are static __inline, and
+ * the others should be.
+ */
#ifdef __i386__
void setdelayed __P((void));
void setsoftast __P((void));
@@ -234,26 +234,6 @@ 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__ */
@@ -262,6 +242,24 @@ void splz __P((void));
#include <machine/ipl.h>
#endif
+#ifdef INVARIANT_SUPPORT
+void splbioassert __P((const char *msg));
+void splcamassert __P((const char *msg));
+void splclockassert __P((const char *msg));
+void splhighassert __P((const char *msg));
+void splimpassert __P((const char *msg));
+void splnetassert __P((const char *msg));
+void splsoftcamassert __P((const char *msg));
+void splsoftcambioassert __P((const char *msg));
+void splsoftcamnetassert __P((const char *msg));
+void splsoftclockassert __P((const char *msg));
+void splsoftttyassert __P((const char *msg));
+void splsoftvmassert __P((const char *msg));
+void splstatclockassert __P((const char *msg));
+void splttyassert __P((const char *msg));
+void splvmassert __P((const char *msg));
+#endif /* INVARIANT_SUPPORT */
+
/*
* XXX It's not clear how "machine independent" these will be yet, but
* they are used all over the place especially in pci drivers. We would
OpenPOWER on IntegriCloud