Import bind 9.5.2 vendor sources.
[dragonfly.git] / contrib / bind-9.5.2 / lib / isc / include / isc / assertions.h
blobb7a9a73e4ef76896506ecb9ada72bf1e42d2bc0c
1 /*
2 * Copyright (C) 2004-2008 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1997-2001 Internet Software Consortium.
5 * Permission to use, copy, modify, and/or 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.24.128.2 2008/10/15 23:46:53 tbox Exp $
21 /*! \file isc/assertions.h
24 #ifndef ISC_ASSERTIONS_H
25 #define ISC_ASSERTIONS_H 1
27 #include <isc/lang.h>
28 #include <isc/platform.h>
30 ISC_LANG_BEGINDECLS
32 /*% isc assertion type */
33 typedef enum {
34 isc_assertiontype_require,
35 isc_assertiontype_ensure,
36 isc_assertiontype_insist,
37 isc_assertiontype_invariant
38 } isc_assertiontype_t;
40 typedef void (*isc_assertioncallback_t)(const char *, int, isc_assertiontype_t,
41 const char *);
43 /* coverity[+kill] */
44 LIBISC_EXTERNAL_DATA extern isc_assertioncallback_t isc_assertion_failed;
46 void
47 isc_assertion_setcallback(isc_assertioncallback_t);
49 const char *
50 isc_assertion_typetotext(isc_assertiontype_t type);
52 #if defined(ISC_CHECK_ALL) || defined(__COVERITY__)
53 #define ISC_CHECK_REQUIRE 1
54 #define ISC_CHECK_ENSURE 1
55 #define ISC_CHECK_INSIST 1
56 #define ISC_CHECK_INVARIANT 1
57 #endif
59 #if defined(ISC_CHECK_NONE) && !defined(__COVERITY__)
60 #define ISC_CHECK_REQUIRE 0
61 #define ISC_CHECK_ENSURE 0
62 #define ISC_CHECK_INSIST 0
63 #define ISC_CHECK_INVARIANT 0
64 #endif
66 #ifndef ISC_CHECK_REQUIRE
67 #define ISC_CHECK_REQUIRE 1
68 #endif
70 #ifndef ISC_CHECK_ENSURE
71 #define ISC_CHECK_ENSURE 1
72 #endif
74 #ifndef ISC_CHECK_INSIST
75 #define ISC_CHECK_INSIST 1
76 #endif
78 #ifndef ISC_CHECK_INVARIANT
79 #define ISC_CHECK_INVARIANT 1
80 #endif
82 #if ISC_CHECK_REQUIRE != 0
83 #define ISC_REQUIRE(cond) \
84 ((void) ((cond) || \
85 ((isc_assertion_failed)(__FILE__, __LINE__, \
86 isc_assertiontype_require, \
87 #cond), 0)))
88 #else
89 #define ISC_REQUIRE(cond) ((void) 0)
90 #endif /* ISC_CHECK_REQUIRE */
92 #if ISC_CHECK_ENSURE != 0
93 #define ISC_ENSURE(cond) \
94 ((void) ((cond) || \
95 ((isc_assertion_failed)(__FILE__, __LINE__, \
96 isc_assertiontype_ensure, \
97 #cond), 0)))
98 #else
99 #define ISC_ENSURE(cond) ((void) 0)
100 #endif /* ISC_CHECK_ENSURE */
102 #if ISC_CHECK_INSIST != 0
103 #define ISC_INSIST(cond) \
104 ((void) ((cond) || \
105 ((isc_assertion_failed)(__FILE__, __LINE__, \
106 isc_assertiontype_insist, \
107 #cond), 0)))
108 #else
109 #define ISC_INSIST(cond) ((void) 0)
110 #endif /* ISC_CHECK_INSIST */
112 #if ISC_CHECK_INVARIANT != 0
113 #define ISC_INVARIANT(cond) \
114 ((void) ((cond) || \
115 ((isc_assertion_failed)(__FILE__, __LINE__, \
116 isc_assertiontype_invariant, \
117 #cond), 0)))
118 #else
119 #define ISC_INVARIANT(cond) ((void) 0)
120 #endif /* ISC_CHECK_INVARIANT */
122 ISC_LANG_ENDDECLS
124 #endif /* ISC_ASSERTIONS_H */