Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / ntp / include / isc / assertions.h
blob8ca62de2d3a5f1dba7f1920b1b86c82792d7aba8
1 /* $NetBSD$ */
3 /*
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
27 #include <isc/lang.h>
28 #include <isc/platform.h>
30 ISC_LANG_BEGINDECLS
32 typedef enum {
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,
40 const char *);
42 LIBISC_EXTERNAL_DATA extern isc_assertioncallback_t isc_assertion_failed;
44 void
45 isc_assertion_setcallback(isc_assertioncallback_t);
47 const char *
48 isc_assertion_typetotext(isc_assertiontype_t type);
50 #ifdef ISC_CHECK_ALL
51 #define ISC_CHECK_REQUIRE 1
52 #define ISC_CHECK_ENSURE 1
53 #define ISC_CHECK_INSIST 1
54 #define ISC_CHECK_INVARIANT 1
55 #endif
57 #ifdef ISC_CHECK_NONE
58 #define ISC_CHECK_REQUIRE 0
59 #define ISC_CHECK_ENSURE 0
60 #define ISC_CHECK_INSIST 0
61 #define ISC_CHECK_INVARIANT 0
62 #endif
64 #ifndef ISC_CHECK_REQUIRE
65 #define ISC_CHECK_REQUIRE 1
66 #endif
68 #ifndef ISC_CHECK_ENSURE
69 #define ISC_CHECK_ENSURE 1
70 #endif
72 #ifndef ISC_CHECK_INSIST
73 #define ISC_CHECK_INSIST 1
74 #endif
76 #ifndef ISC_CHECK_INVARIANT
77 #define ISC_CHECK_INVARIANT 1
78 #endif
80 #if ISC_CHECK_REQUIRE != 0
81 #define ISC_REQUIRE(cond) \
82 ((void) ((cond) || \
83 ((isc_assertion_failed)(__FILE__, __LINE__, \
84 isc_assertiontype_require, \
85 #cond), 0)))
86 #else
87 #define ISC_REQUIRE(cond) ((void) 0)
88 #endif /* ISC_CHECK_REQUIRE */
90 #if ISC_CHECK_ENSURE != 0
91 #define ISC_ENSURE(cond) \
92 ((void) ((cond) || \
93 ((isc_assertion_failed)(__FILE__, __LINE__, \
94 isc_assertiontype_ensure, \
95 #cond), 0)))
96 #else
97 #define ISC_ENSURE(cond) ((void) 0)
98 #endif /* ISC_CHECK_ENSURE */
100 #if ISC_CHECK_INSIST != 0
101 #define ISC_INSIST(cond) \
102 ((void) ((cond) || \
103 ((isc_assertion_failed)(__FILE__, __LINE__, \
104 isc_assertiontype_insist, \
105 #cond), 0)))
106 #else
107 #define ISC_INSIST(cond) ((void) 0)
108 #endif /* ISC_CHECK_INSIST */
110 #if ISC_CHECK_INVARIANT != 0
111 #define ISC_INVARIANT(cond) \
112 ((void) ((cond) || \
113 ((isc_assertion_failed)(__FILE__, __LINE__, \
114 isc_assertiontype_invariant, \
115 #cond), 0)))
116 #else
117 #define ISC_INVARIANT(cond) ((void) 0)
118 #endif /* ISC_CHECK_INVARIANT */
120 ISC_LANG_ENDDECLS
122 #endif /* ISC_ASSERTIONS_H */