2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1997-2001 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 WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
19 * $Id: assertions.h,v 1.17.206.1 2004/03/06 08:14:38 marka Exp $
22 #ifndef ISC_ASSERTIONS_H
23 #define ISC_ASSERTIONS_H 1
26 #include <isc/platform.h>
31 isc_assertiontype_require,
32 isc_assertiontype_ensure,
33 isc_assertiontype_insist,
34 isc_assertiontype_invariant
35 } isc_assertiontype_t;
37 typedef void (*isc_assertioncallback_t)(const char *, int, isc_assertiontype_t,
40 LIBISC_EXTERNAL_DATA extern isc_assertioncallback_t isc_assertion_failed;
43 isc_assertion_setcallback(isc_assertioncallback_t);
46 isc_assertion_typetotext(isc_assertiontype_t type);
49 #define ISC_CHECK_REQUIRE 1
50 #define ISC_CHECK_ENSURE 1
51 #define ISC_CHECK_INSIST 1
52 #define ISC_CHECK_INVARIANT 1
56 #define ISC_CHECK_REQUIRE 0
57 #define ISC_CHECK_ENSURE 0
58 #define ISC_CHECK_INSIST 0
59 #define ISC_CHECK_INVARIANT 0
62 #ifndef ISC_CHECK_REQUIRE
63 #define ISC_CHECK_REQUIRE 1
66 #ifndef ISC_CHECK_ENSURE
67 #define ISC_CHECK_ENSURE 1
70 #ifndef ISC_CHECK_INSIST
71 #define ISC_CHECK_INSIST 1
74 #ifndef ISC_CHECK_INVARIANT
75 #define ISC_CHECK_INVARIANT 1
78 #if ISC_CHECK_REQUIRE != 0
79 #define ISC_REQUIRE(cond) \
81 ((isc_assertion_failed)(__FILE__, __LINE__, \
82 isc_assertiontype_require, \
85 #define ISC_REQUIRE(cond) ((void) 0)
86 #endif /* ISC_CHECK_REQUIRE */
88 #if ISC_CHECK_ENSURE != 0
89 #define ISC_ENSURE(cond) \
91 ((isc_assertion_failed)(__FILE__, __LINE__, \
92 isc_assertiontype_ensure, \
95 #define ISC_ENSURE(cond) ((void) 0)
96 #endif /* ISC_CHECK_ENSURE */
98 #if ISC_CHECK_INSIST != 0
99 #define ISC_INSIST(cond) \
101 ((isc_assertion_failed)(__FILE__, __LINE__, \
102 isc_assertiontype_insist, \
105 #define ISC_INSIST(cond) ((void) 0)
106 #endif /* ISC_CHECK_INSIST */
108 #if ISC_CHECK_INVARIANT != 0
109 #define ISC_INVARIANT(cond) \
111 ((isc_assertion_failed)(__FILE__, __LINE__, \
112 isc_assertiontype_invariant, \
115 #define ISC_INVARIANT(cond) ((void) 0)
116 #endif /* ISC_CHECK_INVARIANT */
120 #endif /* ISC_ASSERTIONS_H */