Subject: Re: splassert
To: Frank van der Linden <fvdl@wasabisystems.com>
From: Artur Grabowski <art@blahonga.org>
List: tech-kern
Date: 06/20/2002 13:24:03
Frank van der Linden <fvdl@wasabisystems.com> writes:

> On Mon, Jun 17, 2002 at 06:54:22PM +0900, itojun@iijlab.net wrote:
> > 	i386 only for now.
> > 	(actually, openbsd has it for i386/sparc/sparc64 only)
> > 
> > itojun
> 
> [...]
> 
> We already have KASSERT, there is no need for seperate functions
> like 'splassert_fail'. It's probably better to define an MD
> function called "curspl()" (or whatever), and then
> 
> 	#define splassert(level) KASSERT(level >= curspl())

On some architectures the spl "level" is a bit mask that you can't compare
this way.

Here is a piece from the man page:
     The splassert() function is optional and is not necessarily implemented
     on all architectures nor enabled in all kernel configurations.  It checks
     the current system priority level too see if it's at least at the level
     specified in the argument s. If possible, it also checks if it hasn't
     been called from an interrupt handler with a level higher than the one
     requested, which must be an error (if some code is protected from
     IPL_SOFTNET interrupts, but accessed from an IPL_NET interrupt, it must
     be a design error in the code).

Not all of this is implemented yet, but it has already tracked down a number
of serious bugs.

//art