2 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (c) 1997-1999 by Internet Software Consortium.
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
15 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 * $Id: assertions.h,v 1.1.206.1 2004/03/09 08:33:30 marka Exp $
23 #define ASSERTIONS_H 1
26 assert_require, assert_ensure, assert_insist, assert_invariant
29 typedef void (*assertion_failure_callback)(const char *, int, assertion_type,
32 extern assertion_failure_callback __assertion_failed;
33 void set_assertion_failure_callback(assertion_failure_callback f);
34 const char *assertion_type_to_text(assertion_type type);
37 #define CHECK_REQUIRE 1
38 #define CHECK_ENSURE 1
39 #define CHECK_INSIST 1
40 #define CHECK_INVARIANT 1
44 #define CHECK_REQUIRE 0
45 #define CHECK_ENSURE 0
46 #define CHECK_INSIST 0
47 #define CHECK_INVARIANT 0
51 #define CHECK_REQUIRE 1
55 #define CHECK_ENSURE 1
59 #define CHECK_INSIST 1
62 #ifndef CHECK_INVARIANT
63 #define CHECK_INVARIANT 1
66 #if CHECK_REQUIRE != 0
67 #define REQUIRE(cond) \
69 ((__assertion_failed)(__FILE__, __LINE__, assert_require, \
71 #define REQUIRE_ERR(cond) \
73 ((__assertion_failed)(__FILE__, __LINE__, assert_require, \
76 #define REQUIRE(cond) ((void) (cond))
77 #define REQUIRE_ERR(cond) ((void) (cond))
78 #endif /* CHECK_REQUIRE */
81 #define ENSURE(cond) \
83 ((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \
85 #define ENSURE_ERR(cond) \
87 ((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \
90 #define ENSURE(cond) ((void) (cond))
91 #define ENSURE_ERR(cond) ((void) (cond))
92 #endif /* CHECK_ENSURE */
95 #define INSIST(cond) \
97 ((__assertion_failed)(__FILE__, __LINE__, assert_insist, \
99 #define INSIST_ERR(cond) \
101 ((__assertion_failed)(__FILE__, __LINE__, assert_insist, \
104 #define INSIST(cond) ((void) (cond))
105 #define INSIST_ERR(cond) ((void) (cond))
106 #endif /* CHECK_INSIST */
108 #if CHECK_INVARIANT != 0
109 #define INVARIANT(cond) \
111 ((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \
113 #define INVARIANT_ERR(cond) \
115 ((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \
118 #define INVARIANT(cond) ((void) (cond))
119 #define INVARIANT_ERR(cond) ((void) (cond))
120 #endif /* CHECK_INVARIANT */
122 #endif /* ASSERTIONS_H */