4 * Copyright (C) 1997-2001 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 INTERNET SOFTWARE CONSORTIUM
11 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
12 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
13 * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
15 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
16 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
17 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 * Id: assertions.h,v 1.17 2001/07/12 05:58:21 mayer Exp
24 #ifndef ISC_ASSERTIONS_H
25 #define ISC_ASSERTIONS_H 1
28 #include <isc/platform.h>
33 isc_assertiontype_require
,
34 isc_assertiontype_ensure
,
35 isc_assertiontype_insist
,
36 isc_assertiontype_invariant
37 } isc_assertiontype_t
;
39 typedef void (*isc_assertioncallback_t
)(const char *, int, isc_assertiontype_t
,
42 LIBISC_EXTERNAL_DATA
extern isc_assertioncallback_t isc_assertion_failed
;
45 isc_assertion_setcallback(isc_assertioncallback_t
);
48 isc_assertion_typetotext(isc_assertiontype_t type
);
51 #define ISC_CHECK_REQUIRE 1
52 #define ISC_CHECK_ENSURE 1
53 #define ISC_CHECK_INSIST 1
54 #define ISC_CHECK_INVARIANT 1
58 #define ISC_CHECK_REQUIRE 0
59 #define ISC_CHECK_ENSURE 0
60 #define ISC_CHECK_INSIST 0
61 #define ISC_CHECK_INVARIANT 0
64 #ifndef ISC_CHECK_REQUIRE
65 #define ISC_CHECK_REQUIRE 1
68 #ifndef ISC_CHECK_ENSURE
69 #define ISC_CHECK_ENSURE 1
72 #ifndef ISC_CHECK_INSIST
73 #define ISC_CHECK_INSIST 1
76 #ifndef ISC_CHECK_INVARIANT
77 #define ISC_CHECK_INVARIANT 1
80 #if ISC_CHECK_REQUIRE != 0
81 #define ISC_REQUIRE(cond) \
83 ((isc_assertion_failed)(__FILE__, __LINE__, \
84 isc_assertiontype_require, \
87 #define ISC_REQUIRE(cond) ((void) 0)
88 #endif /* ISC_CHECK_REQUIRE */
90 #if ISC_CHECK_ENSURE != 0
91 #define ISC_ENSURE(cond) \
93 ((isc_assertion_failed)(__FILE__, __LINE__, \
94 isc_assertiontype_ensure, \
97 #define ISC_ENSURE(cond) ((void) 0)
98 #endif /* ISC_CHECK_ENSURE */
100 #if ISC_CHECK_INSIST != 0
101 #define ISC_INSIST(cond) \
103 ((isc_assertion_failed)(__FILE__, __LINE__, \
104 isc_assertiontype_insist, \
107 #define ISC_INSIST(cond) ((void) 0)
108 #endif /* ISC_CHECK_INSIST */
110 #if ISC_CHECK_INVARIANT != 0
111 #define ISC_INVARIANT(cond) \
113 ((isc_assertion_failed)(__FILE__, __LINE__, \
114 isc_assertiontype_invariant, \
117 #define ISC_INVARIANT(cond) ((void) 0)
118 #endif /* ISC_CHECK_INVARIANT */
122 #endif /* ISC_ASSERTIONS_H */