10
* NTP_REQUIRE(a != NULL);
13
* NTP_INSIST(value > 2);
16
* NTP_ENSURE(result != 12);
16
* ENSURE(result != 12);
20
* open question: when would we use NTP_INVARIANT()?
20
* open question: when would we use INVARIANT()?
22
* For cases where the overhead for non-debug builds is deemed too high,
23
* use DEBUG_REQUIRE(), DEBUG_INSIST(), DEBUG_ENSURE(), and/or
23
27
#ifndef NTP_ASSERT_H
28
32
extern void calysto_assume(unsigned char cnd); /* assume this always holds */
29
33
extern void calysto_assert(unsigned char cnd); /* check whether this holds */
30
#define NTP_REQUIRE(x) calysto_assert(x)
31
#define NTP_INSIST(x) calysto_assume(x) /* DLH calysto_assert()? */
32
#define NTP_INVARIANT(x) calysto_assume(x)
33
#define NTP_ENSURE(x) calysto_assert(x)
34
#define ALWAYS_REQUIRE(x) calysto_assert(x)
35
#define ALWAYS_INSIST(x) calysto_assume(x) /* DLH calysto_assert()? */
36
#define ALWAYS_INVARIANT(x) calysto_assume(x)
37
#define ALWAYS_ENSURE(x) calysto_assert(x)
35
# elif defined(__COVERITY__)
39
/* # elif defined(__COVERITY__) */
41
* DH: try letting coverity scan our actual assertion macros, now that
42
* isc_assertioncallback_t is marked __attribute__ __noreturn__.
38
46
* Coverity has special knowledge that assert(x) terminates the process
42
50
* that seems to be a reasonable trade-off.
45
#define NTP_REQUIRE(x) assert(x)
46
#define NTP_INSIST(x) assert(x)
47
#define NTP_INVARIANT(x) assert(x)
48
#define NTP_ENSURE(x) assert(x)
54
#define ALWAYS_REQUIRE(x) assert(x)
55
#define ALWAYS_INSIST(x) assert(x)
56
#define ALWAYS_INVARIANT(x) assert(x)
57
#define ALWAYS_ENSURE(x) assert(x)
50
60
# else /* neither Coverity nor Calysto */
52
62
#include "isc/assertions.h"
54
#define NTP_REQUIRE(x) ISC_REQUIRE(x)
55
#define NTP_INSIST(x) ISC_INSIST(x)
56
#define NTP_INVARIANT(x) ISC_INVARIANT(x)
57
#define NTP_ENSURE(x) ISC_ENSURE(x)
64
#define ALWAYS_REQUIRE(x) ISC_REQUIRE(x)
65
#define ALWAYS_INSIST(x) ISC_INSIST(x)
66
#define ALWAYS_INVARIANT(x) ISC_INVARIANT(x)
67
#define ALWAYS_ENSURE(x) ISC_ENSURE(x)
59
69
# endif /* neither Coverity nor Calysto */
71
#define REQUIRE(x) ALWAYS_REQUIRE(x)
72
#define INSIST(x) ALWAYS_INSIST(x)
73
#define INVARIANT(x) ALWAYS_INVARIANT(x)
74
#define ENSURE(x) ALWAYS_ENSURE(x)
77
* We initially used NTP_REQUIRE() instead of REQUIRE() etc, but that
78
* is unneccesarily verbose, as libisc use of REQUIRE() etc shows.
80
#define NTP_REQUIRE(x) REQUIRE(x)
81
#define NTP_INSIST(x) INSIST(x)
82
#define NTP_INVARIANT(x) INVARIANT(x)
83
#define NTP_ENSURE(x) ENSURE(x)
86
#define DEBUG_REQUIRE(x) REQUIRE(x)
87
#define DEBUG_INSIST(x) INSIST(x)
88
#define DEBUG_INVARIANT(x) INVARIANT(x)
89
#define DEBUG_ENSURE(x) ENSURE(x)
91
#define DEBUG_REQUIRE(x) (void)(x)
92
#define DEBUG_INSIST(x) (void)(x)
93
#define DEBUG_INVARIANT(x) (void)(x)
94
#define DEBUG_ENSURE(x) (void)(x)
60
97
#endif /* NTP_ASSERT_H */