Initial revision

This commit is contained in:
ceriel 1987-01-05 14:56:11 +00:00
parent 2254b35256
commit 0de3e4a0af
2 changed files with 69 additions and 0 deletions

View file

@ -0,0 +1,60 @@
.TH assert 3ACK "march 25, 1986"
.SH NAME
assert \- program verification
.SH SYNOPSIS
.B #include <assert.h>
.PP
.B assert(expression)
.PP
.B _BadAssertion(fn, lino, ass)
.br
char *fn, *ass;
.br
unsigned int lino;
.SH DESCRIPTION
.PP
.I Assert
is a macro that indicates
.I expression
is expected to be true at this point in the program.
It causes a call to
.I _BadAssertion
when
.I expression
is false (0).
.PP
The routine
.I_BadAssertion
accepts three parameters:
a filename, a linenumber,
and a string representing a failed assertion.
It causes a
.IR sys_stop (S_ABORT)
with a diagnostic comment on standard error.
.PP
The assertions are enabled by defining the preprocessor constant DEBUG.
.SH DIAGNOSTICS
.IR fn ,
line
.IR lino :
assertion
.I ass
failed.
.br
.I fn
is the source file,
.I lino
is the source line number,
and
.I ass
is the assertion
of the
.I assert
statement.
.SH MODULES
system(3)
.SH FILES
.nf
~em/modules/h/assert.h
~em/modules/lib/libassert.a
.fi

View file

@ -0,0 +1,9 @@
/* $Header$ */
/* A S S E R T I O N M A C R O D E F I N I T I O N */
#ifdef DEBUG
/* Note: this macro uses parameter substitution inside strings */
#define assert(exp) (exp || _BadAssertion(__FILE__, __LINE__, "exp"))
#else
#define assert(exp) (1)
#endif DEBUG