1 .\" $Id: assertions.mdoc,v 1.3 2004/03/09 06:30:06 marka Exp $
3 .\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
4 .\" Copyright (c) 1997,1999 by Internet Software Consortium.
6 .\" Permission to use, copy, modify, and distribute this software for any
7 .\" purpose with or without fee is hereby granted, provided that the above
8 .\" copyright notice and this permission notice appear in all copies.
10 .\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
11 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
13 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
16 .\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
30 .Nm set_assertion_failure_callback
33 .Fd #include <isc/assertions.h>
34 .Fo "typedef void (*assertion_failure_callback)"
37 .Fa "assertion_type type"
41 .Fn REQUIRE "int boolean_expression"
42 .Fn REQUIRE_ERR "int boolean_expression"
43 .Fn ENSURE "int boolean_expression"
44 .Fn ENSURE_ERR "int boolean_expression"
45 .Fn INSIST "int boolean_expression"
46 .Fn INSIST_ERR "int boolean_expression"
47 .Fn INVARIANT "int boolean_expression"
48 .Fn INVARIANT_ERR "int boolean_expression"
50 .Fn set_assertion_failure_callback "assertion_failure_callback callback"
52 .Fn assertion_type_to_text "assertion_type type"
60 macros evaluate a boolean expression, and if it is false, they invoke the
61 current assertion failure callback. The default callback will print a message
64 describing the failure, and then cause the program to dump core.
67 variant of the assertion is used, the callback will include
71 Each assertion type has an associated
73 macro. If this macro's value is
76 .Dq "<isc/assertions.h>"
77 is included, then assertions of that type will not be checked. E.g.
79 .Dl #define CHECK_ENSURE 0
81 will disable checking of
89 may also be used, respectively specifying that either all or none of the
90 assertion types should be checked.
92 .Fn set_assertion_failure_callback
93 specifies the function to call when an assertion fails.
96 .Fn assertion_failure_callback
101 arguments specify the filename and line number of the failing assertion.
105 .Bd -literal -offset indent
112 and may be used by the callback to determine the type of the failing
115 is the literal text of the assertion that failed.
117 will be non-zero if the callback should print
119 as part of its output.
121 .Fn assertion_type_to_text
122 returns a textual representation of
125 .Fn assertion_type_to_text "assert_require"
131 .%B Object-Oriented Software Construction, 2nd edition
134 .%O ISBN 0\-13\-629155\-4