Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

kdassert(9) [netbsd man page]

KASSERT(9)						   BSD Kernel Developer's Manual						KASSERT(9)

KASSERT, KASSERTMSG, KDASSERT, KDASSERTMSG -- kernel expression verification macros SYNOPSIS
void KASSERT(expression); void KASSERTMSG(expression, format, ...); void KDASSERT(expression); void KDASSERTMSG(expression, format, ...); DESCRIPTION
These machine independent assertion-checking macros cause a kernel panic(9) if the given expression evaluates to false. Two compile-time options(4) define the behavior of the checks. 1. The KASSERT() and KASSERTMSG() tests are included only in kernels compiled with the DIAGNOSTIC configuration option. In a kernel that does not have this configuration option, the macros are defined to be no-ops. 2. The KDASSERT() and KDASSERTMSG() tests are included only in kernels compiled with the DEBUG configuration option. The KDASSERT() and KASSERT() macros are identical except for the controlling option (DEBUG vs DIAGNOSTIC). Basically, KASSERT() should be used for light-weight checks and KDASSERT() should be used for heavier ones. Callers should not rely on the side effects of expression because, depending on the kernel compile options mentioned above, expression might not be evaluated at all. The panic message will display the style of assertion (debugging vs. diagnostic), the expression that failed and the filename, and line num- ber the failure happened on. The KASSERTMSG() and KDASSERTMSG() macros append to the panic(9) format string the message specified by format and its subsequent arguments, similar to printf(9) functions. SEE ALSO
config(1), options(4), CTASSERT(9), panic(9), printf(9) AUTHORS
These macros were written by Chris G. Demetriou <>. BSD
September 27, 2011 BSD

Check Out this Related Man Page

_DIAGASSERT(3)						   BSD Library Functions Manual 					    _DIAGASSERT(3)

_DIAGASSERT -- expression verification macro SYNOPSIS
#include <assert.h> _DIAGASSERT(expression); DESCRIPTION
The _DIAGASSERT() macro tests the given expression and if it is false, one or more of the following may occur: o a diagnostic message may be logged to the system logger with syslog(3). This is default behaviour. o a diagnostic message may be printed to the stderr stream. o the calling process will be terminated by calling abort(3). This behaviour may be changed by setting the LIBC_DIAGASSERT environment variable (see below). The diagnostic message consists of the text of the expression, the name of the source file, the line number and the enclosing function. If expression is true, the _DIAGASSERT() macro does nothing. The _DIAGASSERT() macro is not compiled in by default, and will only be compiled in with the cc(1) option -D_DIAGNOSTIC. This macro is used in the various system libraries such as the Standard C Library (libc, -lc) to ensure that various library calls are invoked with valid arguments. ENVIRONMENT
The LIBC_DIAGASSERT environment variable can be used to modify the default behaviour of logging the assertion to the system logger. LIBC_DIAGASSERT may be set to one or more of the following characters: a abort(3) once any assertion messages have been logged and/or printed. A Opposite of ``a''. e Print the assertion message to the stderr stream. E Opposite of ``e''. l Log the assertion message with syslog(3) to the facility user.debug. L Opposite of ``l''. DIAGNOSTICS
The diagnostic message has the following format: "assertion "%s" failed: file "%s", line %d, function "%s" ", "expression", __FILE__, __LINE__, __func__ SEE ALSO
cc(1), abort(3), assert(3), syslog(3) HISTORY
The _DIAGASSERT macro appeared in NetBSD 1.5. BSD
January 22, 2007 BSD
Man Page