From: ceriel Date: Mon, 5 Jan 1987 14:56:11 +0000 (+0000) Subject: Initial revision X-Git-Tag: release-5-5~5072 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=0de3e4a0af57c95015a9ebc5050aa888cc9d3bb2;p=ack.git Initial revision --- diff --git a/modules/src/assert/assert.3 b/modules/src/assert/assert.3 new file mode 100644 index 000000000..e5cdd60f8 --- /dev/null +++ b/modules/src/assert/assert.3 @@ -0,0 +1,60 @@ +.TH assert 3ACK "march 25, 1986" +.SH NAME +assert \- program verification +.SH SYNOPSIS +.B #include +.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 diff --git a/modules/src/assert/assert.h b/modules/src/assert/assert.h new file mode 100644 index 000000000..ca825817d --- /dev/null +++ b/modules/src/assert/assert.h @@ -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