Subject: Re: Adding to KNF.
To: None <tech-kern@netbsd.org>
From: None <itojun@iijlab.net>
List: tech-kern
Date: 06/17/2002 18:54:22
>> Excellent idea, let's steal it! :-)
>I agree, looks really neat.

	i386 only for now.
	(actually, openbsd has it for i386/sparc/sparc64 only)

itojun


Index: kern/kern_sysctl.c
===================================================================
RCS file: /cvsroot/syssrc/sys/kern/kern_sysctl.c,v
retrieving revision 1.108
diff -u -r1.108 kern_sysctl.c
--- kern/kern_sysctl.c	2002/05/14 02:58:32	1.108
+++ kern/kern_sysctl.c	2002/06/17 09:48:47
@@ -568,6 +568,8 @@
 		    newp));
 	case KERN_MONOTONIC_CLOCK:	/* XXX _POSIX_VERSION */
 		return (sysctl_rdint(oldp, oldlenp, newp, 200112));
+	case KERN_SPLASSERT:
+		return sysctl_int(oldp, oldlenp, newp, newlen, &splassert_ctl);
 	default:
 		return (EOPNOTSUPP);
 	}
Index: kern/subr_prf.c
===================================================================
RCS file: /cvsroot/syssrc/sys/kern/subr_prf.c,v
retrieving revision 1.84
diff -u -r1.84 subr_prf.c
--- kern/subr_prf.c	2002/06/05 17:53:52	1.84
+++ kern/subr_prf.c	2002/06/17 09:48:48
@@ -156,6 +156,11 @@
 int	doing_shutdown;	/* set to indicate shutdown in progress */
 
 /*
+ * panic on spl assertion failure?
+ */
+int	splassert_ctl = 0;
+
+/*
  * v_putc: routine to putc on virtual console
  *
  * the v_putc pointer can be used to redirect the console cnputc elsewhere
@@ -251,6 +256,32 @@
 	}
 #endif
 	cpu_reboot(bootopt, NULL);
+}
+
+/*
+ * We print only the function name. The file name is usually very long and
+ * would eat tons of space in the kernel.
+ */
+void
+splassert_fail(int wantipl, int haveipl, const char *func)
+{
+
+	printf("splassert: %s: want %d have %d\n", func, wantipl, haveipl);
+	switch (splassert_ctl) {
+	case 1:
+		break;
+	case 2:
+#ifdef DDB
+		printf("Begin traceback...\n");
+		db_stack_trace_print(
+		    (db_expr_t)__builtin_frame_address(0),
+		    TRUE, 65535, "", printf);
+		printf("End traceback...\n");
+#endif
+		break;
+	default:
+		panic("spl assertion failure in %s", func);
+	}
 }
 
 /*
Index: sys/sysctl.h
===================================================================
RCS file: /cvsroot/syssrc/sys/sys/sysctl.h,v
retrieving revision 1.74
diff -u -r1.74 sysctl.h
--- sys/sysctl.h	2002/03/20 00:23:46	1.74
+++ sys/sysctl.h	2002/06/17 09:48:53
@@ -180,7 +180,8 @@
 #define	KERN_SBMAX		58	/* int: max socket buffer size */
 #define	KERN_TKSTAT		59	/* tty in/out counters */
 #define	KERN_MONOTONIC_CLOCK	60	/* int: POSIX monotonic clock */
-#define	KERN_MAXID		61	/* number of valid kern ids */
+#define	KERN_SPLASSERT		61	/* int: panic on splassert failure? */
+#define	KERN_MAXID		62	/* number of valid kern ids */
 
 #define	CTL_KERN_NAMES { \
 	{ 0, 0 }, \
@@ -244,6 +245,7 @@
 	{ "sbmax", CTLTYPE_INT }, \
 	{ "tkstat", CTLTYPE_NODE }, \
 	{ "monotonic_clock", CTLTYPE_INT }, \
+	{ "splassert", CTLTYPE_INT }, \
 }
 
 /*
Index: sys/systm.h
===================================================================
RCS file: /cvsroot/syssrc/sys/sys/systm.h,v
retrieving revision 1.144
diff -u -r1.144 systm.h
--- sys/systm.h	2002/05/21 01:38:26	1.144
+++ sys/systm.h	2002/06/17 09:48:54
@@ -89,6 +89,7 @@
 extern int securelevel;		/* system security level */
 extern const char *panicstr;	/* panic message */
 extern int doing_shutdown;	/* shutting down */
+extern int splassert_ctl;	/* panic on spl assertion failure? */
 
 extern const char copyright[];	/* system copyright */
 extern char cpu_model[];	/* machine/cpu model name */
@@ -207,6 +208,8 @@
 
 int	humanize_number __P((char *, size_t, u_int64_t, const char *, int));
 int	format_bytes __P((char *, size_t, u_int64_t));
+
+void	splassert_fail __P((int, int, const char *));
 
 void	tablefull __P((const char *, const char *));
 
Index: arch/acorn26/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/acorn26/include/intr.h,v
retrieving revision 1.2
diff -u -r1.2 intr.h
--- arch/acorn26/include/intr.h	2002/03/24 23:37:43	1.2
+++ arch/acorn26/include/intr.h	2002/06/17 09:48:55
@@ -82,6 +82,8 @@
 #define spllowersoftclock()	lowerspl(IPL_SOFTCLOCK)
 #define splx(s)			lowerspl(s)
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 extern int current_spl; /* XXX tautological name */
 
 extern int splhigh(void);
Index: arch/algor/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/algor/include/intr.h,v
retrieving revision 1.4
diff -u -r1.4 intr.h
--- arch/algor/include/intr.h	2001/06/15 04:01:40	1.4
+++ arch/algor/include/intr.h	2002/06/17 09:48:56
@@ -114,6 +114,8 @@
 
 #define	spllowersoftclock() _spllower(ipl_sr_bits[IPL_SOFTCLOCK])
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 struct algor_intrhand {
 	LIST_ENTRY(algor_intrhand) ih_q;
 	int (*ih_func)(void *);
Index: arch/amiga/include/psl.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/amiga/include/psl.h,v
retrieving revision 1.19
diff -u -r1.19 psl.h
--- arch/amiga/include/psl.h	2001/05/27 20:22:57	1.19
+++ arch/amiga/include/psl.h	2002/06/17 09:48:58
@@ -70,5 +70,7 @@
 
 #define splx(s)		_spl(s)
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 #endif	/* KERNEL && !_LOCORE */
 #endif	/* _MACHINE_PSL_H_ */
Index: arch/arc/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/arc/include/intr.h,v
retrieving revision 1.10
diff -u -r1.10 intr.h
--- arch/arc/include/intr.h	2001/06/13 15:08:06	1.10
+++ arch/arc/include/intr.h	2002/06/17 09:48:58
@@ -109,6 +109,8 @@
 #define	spllock()	splhigh()
 #define spllpt()	spltty()		/* lpt driver */
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 struct splvec {
 	int	splbio;
 	int	splnet;
Index: arch/atari/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/atari/include/intr.h,v
retrieving revision 1.11
diff -u -r1.11 intr.h
--- arch/atari/include/intr.h	2001/04/13 23:29:59	1.11
+++ arch/atari/include/intr.h	2002/06/17 09:48:58
@@ -77,6 +77,8 @@
 
 #define splx(s)			((s) & PSL_IPL ? _spl(s) : spl0())
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 #ifdef _KERNEL
 int spl0 __P((void));
 #endif /* _KERNEL */
Index: arch/cesfic/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/cesfic/include/intr.h,v
retrieving revision 1.2
diff -u -r1.2 intr.h
--- arch/cesfic/include/intr.h	2002/01/14 19:59:31	1.2
+++ arch/cesfic/include/intr.h	2002/06/17 09:49:00
@@ -88,6 +88,8 @@
 #define splx(s)         (s & PSL_IPL ? _spl(s) : spl0())
 
 int	spl0 __P((void));
+
+#define splassert(s)		do { /* nada */ } while (0)
 #endif /* _KERNEL && !_LOCORE */
 
 #endif /* !_CESFIC_INTR_H_ */
Index: arch/cobalt/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/cobalt/include/intr.h,v
retrieving revision 1.11
diff -u -r1.11 intr.h
--- arch/cobalt/include/intr.h	2002/01/13 23:02:34	1.11
+++ arch/cobalt/include/intr.h	2002/06/17 09:49:01
@@ -87,6 +87,8 @@
 #define	splsched()	splhigh()
 #define	spllock()	splhigh()
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 extern unsigned int	intrcnt[];
 #define SOFTCLOCK_INTR	0
 #define SOFTNET_INTR	1  
Index: arch/dreamcast/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/dreamcast/include/intr.h,v
retrieving revision 1.3
diff -u -r1.3 intr.h
--- arch/dreamcast/include/intr.h	2002/03/24 18:21:08	1.3
+++ arch/dreamcast/include/intr.h	2002/06/17 09:49:01
@@ -68,4 +68,6 @@
 
 #define	spllowersoftclock()	_cpu_intr_resume(IPL_SOFTCLOCK << 4)
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 #endif /* !_DREAMCAST_INTR_H_ */
Index: arch/evbmips/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/evbmips/include/intr.h,v
retrieving revision 1.1
diff -u -r1.1 intr.h
--- arch/evbmips/include/intr.h	2002/03/07 14:44:00	1.1
+++ arch/evbmips/include/intr.h	2002/06/17 09:49:02
@@ -114,6 +114,8 @@
 
 #define	spllowersoftclock() _spllower(ipl_sr_bits[IPL_SOFTCLOCK])
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 struct evbmips_intrhand {
 	LIST_ENTRY(evbmips_intrhand) ih_q;
 	int (*ih_func)(void *);
Index: arch/evbsh3/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/evbsh3/include/intr.h,v
retrieving revision 1.7
diff -u -r1.7 intr.h
--- arch/evbsh3/include/intr.h	2002/04/22 02:05:33	1.7
+++ arch/evbsh3/include/intr.h	2002/06/17 09:49:03
@@ -68,4 +68,6 @@
 
 #define	spllowersoftclock()	_cpu_intr_resume(IPL_SOFTCLOCK << 4)
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 #endif /* !_EVBSH3_INTR_H_ */
Index: arch/hp300/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/hp300/include/intr.h,v
retrieving revision 1.12
diff -u -r1.12 intr.h
--- arch/hp300/include/intr.h	2001/12/08 04:09:19	1.12
+++ arch/hp300/include/intr.h	2002/06/17 09:49:03
@@ -119,6 +119,8 @@
 /* watch out for side effects */
 #define	splx(s)		((s) & PSL_IPL ? _spl((s)) : spl0())
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 struct hp300_intrhand {
 	LIST_ENTRY(hp300_intrhand) ih_q;
 	int (*ih_fn)(void *);
Index: arch/hp700/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/hp700/include/intr.h,v
retrieving revision 1.1
diff -u -r1.1 intr.h
--- arch/hp700/include/intr.h	2002/06/06 19:48:08	1.1
+++ arch/hp700/include/intr.h	2002/06/17 09:49:04
@@ -127,6 +127,8 @@
 #define	spl0()		spllower(0)
 #define	splx(x)		spllower(x)
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 #define	setsoftast()	(astpending = 1)
 #define	setsoftnet()	hp700_intr_schedule(softnetmask)
 
Index: arch/hpcmips/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/hpcmips/include/intr.h,v
retrieving revision 1.16
diff -u -r1.16 intr.h
--- arch/hpcmips/include/intr.h	2002/05/15 15:19:54	1.16
+++ arch/hpcmips/include/intr.h	2002/06/17 09:49:04
@@ -113,6 +113,8 @@
 
 #define	spllowersoftclock() _spllower(ipl_sr_bits[IPL_SOFTCLOCK])
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 /*
  * software simulated interrupt
  */
Index: arch/hpcsh/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/hpcsh/include/intr.h,v
retrieving revision 1.6
diff -u -r1.6 intr.h
--- arch/hpcsh/include/intr.h	2002/03/28 15:27:05	1.6
+++ arch/hpcsh/include/intr.h	2002/06/17 09:49:04
@@ -68,4 +68,6 @@
 
 #define	spllowersoftclock()	hd6446x_intr_resume(IPL_SOFTCLOCK << 4)
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 #endif /* !_HPCSH_INTR_H_ */
Index: arch/i386/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/include/intr.h,v
retrieving revision 1.25
diff -u -r1.25 intr.h
--- arch/i386/include/intr.h	2002/05/12 23:16:52	1.25
+++ arch/i386/include/intr.h	2002/06/17 09:49:06
@@ -79,6 +79,24 @@
 static __inline void spllower __P((int));
 static __inline void softintr __P((int));
 
+/* SPL asserts */
+#ifdef DIAGNOSTIC
+/*
+ * Although this function is implemented in MI code, it must be in this MD
+ * header because we don't want this header to include MI includes.
+ */
+void splassert_fail(int, int, const char *);
+extern int splassert_ctl;
+void splassert_check(int, const char *);
+#define splassert(__wantipl) do {			\
+	if (__predict_false(splassert_ctl > 0)) {	\
+		splassert_check(__wantipl, __func__);	\
+	}						\
+} while (0)
+#else
+#define splassert(wantipl) do { /* nada */ } while (0)
+#endif
+
 /*
  * compiler barrier: prevent reordering of instructions.
  * XXX something similar will move to <sys/cdefs.h>
Index: arch/luna68k/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/luna68k/include/intr.h,v
retrieving revision 1.4
diff -u -r1.4 intr.h
--- arch/luna68k/include/intr.h	2002/05/05 22:07:59	1.4
+++ arch/luna68k/include/intr.h	2002/06/17 09:49:06
@@ -65,6 +65,8 @@
 
 int spl0 __P((void));
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 #endif /* _KERNEL */
 
 #endif	/* _MACHINE_INTR_H */
Index: arch/mac68k/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/mac68k/include/intr.h,v
retrieving revision 1.20
diff -u -r1.20 intr.h
--- arch/mac68k/include/intr.h	2001/04/13 23:30:00	1.20
+++ arch/mac68k/include/intr.h	2002/06/17 09:49:07
@@ -83,6 +83,8 @@
 /* watch out for side effects */
 #define splx(s)         ((s) & PSL_IPL ? _spl(s) : spl0())
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 /*
  * simulated software interrupt register
  */
Index: arch/mipsco/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/mipsco/include/intr.h,v
retrieving revision 1.9
diff -u -r1.9 intr.h
--- arch/mipsco/include/intr.h	2002/01/14 19:08:35	1.9
+++ arch/mipsco/include/intr.h	2002/06/17 09:49:08
@@ -129,6 +129,8 @@
 #define spllowersoftclock() _spllower(MIPS_INT_MASK_SPL_SOFT0)
 #define splsoftnet()	splsoft()
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 struct mipsco_intrhand {
 	LIST_ENTRY(mipsco_intrhand)
 		ih_q;
Index: arch/mmeye/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/mmeye/include/intr.h,v
retrieving revision 1.5
diff -u -r1.5 intr.h
--- arch/mmeye/include/intr.h	2002/03/24 18:21:22	1.5
+++ arch/mmeye/include/intr.h	2002/06/17 09:49:08
@@ -72,4 +72,6 @@
 
 #define	spllowersoftclock()	_cpu_intr_resume(IPL_SOFTCLOCK << 4)
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 #endif /* !_MMEYE_INTR_H_ */
Index: arch/mvmeppc/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/mvmeppc/include/intr.h,v
retrieving revision 1.2
diff -u -r1.2 intr.h
--- arch/mvmeppc/include/intr.h	2002/02/28 00:27:38	1.2
+++ arch/mvmeppc/include/intr.h	2002/06/17 09:49:10
@@ -197,6 +197,8 @@
 #define	splx(x)		spllower(x)
 #define	spl0()		spllower(0)
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 #endif /* !_LOCORE */
 
 #endif /* !_MVMEPPC_INTR_H_ */
Index: arch/news68k/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/news68k/include/intr.h,v
retrieving revision 1.7
diff -u -r1.7 intr.h
--- arch/news68k/include/intr.h	2001/04/13 23:30:01	1.7
+++ arch/news68k/include/intr.h	2002/06/17 09:49:10
@@ -64,6 +64,8 @@
 #define	splsched()	spl7()
 #define	spllock()	spl7()
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 /*
  * simulated software interrupt register
  */
Index: arch/newsmips/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/newsmips/include/intr.h,v
retrieving revision 1.11
diff -u -r1.11 intr.h
--- arch/newsmips/include/intr.h	2001/04/13 23:30:02	1.11
+++ arch/newsmips/include/intr.h	2002/06/17 09:49:10
@@ -102,6 +102,8 @@
 #define splsoftnet()	_splraise(MIPS_INT_MASK_SPL_SOFT1)
 #define spllowersoftclock() _spllower(MIPS_INT_MASK_SPL_SOFT0)
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 /*
  * Index into intrcnt[], which is defined in locore
  */
Index: arch/next68k/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/next68k/include/intr.h,v
retrieving revision 1.10
diff -u -r1.10 intr.h
--- arch/next68k/include/intr.h	2001/04/13 23:30:02	1.10
+++ arch/next68k/include/intr.h	2002/06/17 09:49:11
@@ -60,6 +60,8 @@
 
 #define spldma()        _splraise(PSL_S|PSL_IPL6)
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 /****************************************************************/
 
 /*
Index: arch/ofppc/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/ofppc/include/intr.h,v
retrieving revision 1.2
diff -u -r1.2 intr.h
--- arch/ofppc/include/intr.h	2001/10/29 19:04:25	1.2
+++ arch/ofppc/include/intr.h	2002/06/17 09:49:11
@@ -146,6 +146,8 @@
 #define	setsoftnet()	setsoftintr(IPL_SOFTNET)
 #define	setsoftclock()	setsoftintr(IPL_SOFTCLOCK)
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 /*
  * Software interrupt support.
  */
Index: arch/playstation2/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/playstation2/include/intr.h,v
retrieving revision 1.3
diff -u -r1.3 intr.h
--- arch/playstation2/include/intr.h	2002/01/02 12:36:21	1.3
+++ arch/playstation2/include/intr.h	2002/06/17 09:49:13
@@ -107,6 +107,8 @@
 #define	splsched()		splhigh()
 #define	spllock()		splhigh()
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 /*
  * software simulated interrupt
  */
Index: arch/pmax/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/pmax/include/intr.h,v
retrieving revision 1.23
diff -u -r1.23 intr.h
--- arch/pmax/include/intr.h	2001/08/27 02:00:16	1.23
+++ arch/pmax/include/intr.h	2002/06/17 09:49:13
@@ -98,6 +98,8 @@
 #define	splsched()	splhigh()
 #define	spllock()	splhigh()
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 struct splvec {
 	int	splbio;
 	int	splnet;
Index: arch/prep/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/prep/include/intr.h,v
retrieving revision 1.16
diff -u -r1.16 intr.h
--- arch/prep/include/intr.h	2002/05/30 16:10:05	1.16
+++ arch/prep/include/intr.h	2002/06/17 09:49:14
@@ -200,6 +200,8 @@
 #define	splx(x)		spllower(x)
 #define	spl0()		spllower(0)
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 #endif /* !_LOCORE */
 
 #endif /* !_PREP_INTR_H_ */
Index: arch/sbmips/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/sbmips/include/intr.h,v
retrieving revision 1.1
diff -u -r1.1 intr.h
--- arch/sbmips/include/intr.h	2002/03/06 02:13:44	1.1
+++ arch/sbmips/include/intr.h	2002/06/17 09:49:16
@@ -75,6 +75,8 @@
 #define	spllowersoftclock()	_spllower(_IMR_SOFT)
 #define	splx(s)			_splset(s)
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 #define	__GENERIC_SOFT_INTERRUPTS
 
 void		*softintr_establish(int level, void (*fun)(void *), void *arg);
Index: arch/sgimips/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/sgimips/include/intr.h,v
retrieving revision 1.13
diff -u -r1.13 intr.h
--- arch/sgimips/include/intr.h	2002/05/03 01:51:38	1.13
+++ arch/sgimips/include/intr.h	2002/06/17 09:49:16
@@ -151,6 +151,8 @@
 
 #define spllowersoftclock() _spllower(MIPS_SOFT_INT_MASK_1)
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 extern void *		cpu_intr_establish(int, int, int (*)(void *), void *);
 void *			softintr_establish(int, void (*)(void *), void *);
 void			softintr_disestablish(void *);
Index: arch/sparc64/include/psl.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/sparc64/include/psl.h,v
retrieving revision 1.20
diff -u -r1.20 psl.h
--- arch/sparc64/include/psl.h	2001/04/13 23:30:05	1.20
+++ arch/sparc64/include/psl.h	2002/06/17 09:49:20
@@ -444,6 +444,8 @@
 #define	splhigh()	splhighX(__FILE__, __LINE__)
 #define splx(x)		splxX((x),__FILE__, __LINE__)
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 static __inline void splxX __P((int, const char*, int));
 static __inline void splxX(newpil, file, line)
 	int newpil, line;
Index: arch/sun3/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/sun3/include/intr.h,v
retrieving revision 1.2
diff -u -r1.2 intr.h
--- arch/sun3/include/intr.h	2001/12/16 20:58:25	1.2
+++ arch/sun3/include/intr.h	2002/06/17 09:49:20
@@ -113,5 +113,7 @@
 #define splsched()      spl7()
 #define spllock()	spl7()
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 #endif	/* KERNEL && !_LOCORE */
 #endif	/* _SUN3_INTR_H_ */
Index: arch/sun68k/include/psl.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/sun68k/include/psl.h,v
retrieving revision 1.2
diff -u -r1.2 psl.h
--- arch/sun68k/include/psl.h	2001/06/27 02:51:45	1.2
+++ arch/sun68k/include/psl.h	2002/06/17 09:49:21
@@ -114,5 +114,7 @@
 /* This returns true iff the spl given is spl0. */
 #define	is_spl0(s)	(((s) & PSL_IPL7) == 0)
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 #endif	/* KERNEL && !_LOCORE */
 #endif /* _SUN68K_PSL_H_ */
Index: arch/vax/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/vax/include/intr.h,v
retrieving revision 1.13
diff -u -r1.13 intr.h
--- arch/vax/include/intr.h	2001/06/04 15:34:57	1.13
+++ arch/vax/include/intr.h	2002/06/17 09:49:21
@@ -132,6 +132,8 @@
 #define spl6()		splx(0x16)
 #define spl7()		splx(0x17)
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 /* schedule software interrupts
  */
 #define setsoftddb()	_setsirr(IPL_SOFTDDB)
Index: arch/x68k/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/x68k/include/intr.h,v
retrieving revision 1.8
diff -u -r1.8 intr.h
--- arch/x68k/include/intr.h	2001/04/13 23:30:07	1.8
+++ arch/x68k/include/intr.h	2002/06/17 09:49:21
@@ -64,6 +64,8 @@
 /* watch out for side effects */
 #define splx(s)         ((s) & PSL_IPL ? _spl(s) : spl0())
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 /*
  * simulated software interrupt register
  */
Index: arch/x86_64/include/intr.h
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/x86_64/include/intr.h,v
retrieving revision 1.1
diff -u -r1.1 intr.h
--- arch/x86_64/include/intr.h	2001/06/19 00:20:11	1.1
+++ arch/x86_64/include/intr.h	2002/06/17 09:49:22
@@ -145,6 +145,8 @@
 #define	spl0()		spllower(0)
 #define	splx(x)		spllower(x)
 
+#define splassert(s)		do { /* nada */ } while (0)
+
 /*
  * Software interrupt registration
  *
Index: arch/i386/i386/machdep.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.472
diff -u -r1.472 machdep.c
--- arch/i386/i386/machdep.c	2002/05/31 17:46:51	1.472
+++ arch/i386/i386/machdep.c	2002/06/17 09:49:29
@@ -3310,3 +3310,14 @@
 
 	for (;;);
 }
+
+#ifdef DIAGNOSTIC
+void
+splassert_check(wantipl, func)
+	int wantipl;
+	const char *func;
+{
+	if (cpl < wantipl)
+		splassert_fail(wantipl, cpl, func);
+}
+#endif