tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / kits / network / netresolv / include / isc / assertions.h
blob68925e73b35519f8333297a523df8f4e3e4b86cb
1 /*
2 * Copyright (C) 2004, 2005, 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.5 2008/11/14 02:36:51 marka Exp $
22 #ifndef ASSERTIONS_H
23 #define ASSERTIONS_H 1
25 typedef enum {
26 assert_require, assert_ensure, assert_insist, assert_invariant
27 } assertion_type;
29 typedef void (*assertion_failure_callback)(const char *, int, assertion_type,
30 const char *, int);
32 /* coverity[+kill] */
33 extern assertion_failure_callback __assertion_failed;
34 void set_assertion_failure_callback(assertion_failure_callback f);
35 const char *assertion_type_to_text(assertion_type type);
37 #if defined(CHECK_ALL) || defined(__COVERITY__)
38 #define CHECK_REQUIRE 1
39 #define CHECK_ENSURE 1
40 #define CHECK_INSIST 1
41 #define CHECK_INVARIANT 1
42 #endif
44 #if defined(CHECK_NONE) && !defined(__COVERITY__)
45 #define CHECK_REQUIRE 0
46 #define CHECK_ENSURE 0
47 #define CHECK_INSIST 0
48 #define CHECK_INVARIANT 0
49 #endif
51 #ifndef CHECK_REQUIRE
52 #define CHECK_REQUIRE 1
53 #endif
55 #ifndef CHECK_ENSURE
56 #define CHECK_ENSURE 1
57 #endif
59 #ifndef CHECK_INSIST
60 #define CHECK_INSIST 1
61 #endif
63 #ifndef CHECK_INVARIANT
64 #define CHECK_INVARIANT 1
65 #endif
67 #if CHECK_REQUIRE != 0
68 #define REQUIRE(cond) \
69 ((void) ((cond) || \
70 ((__assertion_failed)(__FILE__, __LINE__, assert_require, \
71 #cond, 0), 0)))
72 #define REQUIRE_ERR(cond) \
73 ((void) ((cond) || \
74 ((__assertion_failed)(__FILE__, __LINE__, assert_require, \
75 #cond, 1), 0)))
76 #else
77 #define REQUIRE(cond) ((void) (cond))
78 #define REQUIRE_ERR(cond) ((void) (cond))
79 #endif /* CHECK_REQUIRE */
81 #if CHECK_ENSURE != 0
82 #define ENSURE(cond) \
83 ((void) ((cond) || \
84 ((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \
85 #cond, 0), 0)))
86 #define ENSURE_ERR(cond) \
87 ((void) ((cond) || \
88 ((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \
89 #cond, 1), 0)))
90 #else
91 #define ENSURE(cond) ((void) (cond))
92 #define ENSURE_ERR(cond) ((void) (cond))
93 #endif /* CHECK_ENSURE */
95 #if CHECK_INSIST != 0
96 #define INSIST(cond) \
97 ((void) ((cond) || \
98 ((__assertion_failed)(__FILE__, __LINE__, assert_insist, \
99 #cond, 0), 0)))
100 #define INSIST_ERR(cond) \
101 ((void) ((cond) || \
102 ((__assertion_failed)(__FILE__, __LINE__, assert_insist, \
103 #cond, 1), 0)))
104 #else
105 #define INSIST(cond) ((void) (cond))
106 #define INSIST_ERR(cond) ((void) (cond))
107 #endif /* CHECK_INSIST */
109 #if CHECK_INVARIANT != 0
110 #define INVARIANT(cond) \
111 ((void) ((cond) || \
112 ((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \
113 #cond, 0), 0)))
114 #define INVARIANT_ERR(cond) \
115 ((void) ((cond) || \
116 ((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \
117 #cond, 1), 0)))
118 #else
119 #define INVARIANT(cond) ((void) (cond))
120 #define INVARIANT_ERR(cond) ((void) (cond))
121 #endif /* CHECK_INVARIANT */
122 #endif /* ASSERTIONS_H */
123 /*! \file */