Subject: Re: where is KASSERT(9) documented?
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Igor Sobrado <igor@string1.ciencias.uniovi.es>
List: tech-kern
Date: 04/17/2006 19:27:11
In message <200604171649.MAA02175@Sparkle.Rodents.Montreal.QC.CA>, der Mouse writes:
> > Ok, if you are not living in California I think that any
> > language-related problem can be fixed.  ;-)
> 
> Montreal is quite definitely not in California. :-)

I suppose that it is good, at least I will assume that you know
the use of uppercase letters!  (too many C programming makes people
miss that uppercase letters exist, though)  ;-)

Seriously, I appreciate the work done in California in the last twenty
years.  Some of the best developments in computing come from both these
universities and private corporations (e.g., the BSD operating system).

> > Seriously, I highly appreciate your support on this matter.  I will
> > get some free time to work on this manual page and submit it to you
> > (or perhaps to this mailing list, as you wish) asking for feedback as
> > soon as possible.
> 
> Either on-list or direct is fine by me.  You might want to send a ping
> first if you're sending direct, though, to verify that mail works that
> way.  (While I don't see anything in the headers of your list mail to
> make me think it wouldn't, some of the possible problems wouldn't show
> in list mail headers.)
> 
> This actually goes for anyone planning on taking me up on this, which
> is why I'm sending it to the list.

Thanks for this advice.

I cannot ping rodents.montreal.qc.ca directly, but I can reach Sparkle.
Hope you have the right MX record in the local DNS!  In any case,
I will submit this message to the public mailing list as I think that
it is the right forum and your reply, if you are so kindly to reply to
this message, will be really useful to other NetBSD users.  :-)

I have some issues understanding the behaviour of KASSERT and KDASSERT
assertion-checking macros... perhaps someone will kindly explain the
behaviour to document these macros in the right way:

  1. Is the DIAGNOSTIC configuration option required on a kernel?
     What is the difference in behaviour of these macros when this
     configuration option is not defined?  Is the libkern.h header
     file required?  To be more precise (from libkern.h):

     #ifndef DIAGNOSTIC
     #ifdef lint
     #define KASSERT(e)  /* NOTHING */
     #else /* !lint */
     #define KASSERT(e)  ((void)0)
     #endif /* !lint */
     #else
     #ifdef __STDC__
     #define KASSERT(e)  (__predict_true((e)) ? (void)0 :                   \
                            __assert("diagnostic ", __FILE__, __LINE__, #e))
     #else
     #define KASSERT(e)  (__predict_true((e)) ? (void)0 :                   \
                            __assert("diagnostic ", __FILE__, __LINE__, "e"))
     #endif
     #endif

     It seems that the macro is replaced by a no-op if the kernel
     does not have DIAGNOSTICS and replaced with the right behaviour
     in the other case (in other words, (void)0 if the expression "e"
     is evaluated as true, and a call to __assert if the expression
     is evaluated as false.  Am I wrong?

  2. Is the INVARIANTS (FreeBSD) configuration option used at all?

  3. Are there differences between KASSERT and KDASSERT apart of the
     replacement of the use of the DIAGNOSTIC configuration option
     in the former and the DEBUG configuration option in the later?

  4. In a private email, Greg Troxel mentioned something about the
     line numbering in the panic string... is the line number provided
     as an argument to this string?  Is there something to note about
     the panic string?  (e.g., is it optional?  does it follow printf(9)
     strictly?)

Thanks a lot to you and Greg for the kindly support on this matter.
I will do my best to document these kernel macros and provide a high
quality manual page.

Cheers,
Igor.