4 * ntp_assert.h - design by contract stuff
12 * NTP_REQUIRE(a != NULL);
15 * NTP_INSIST(value > 2);
18 * NTP_ENSURE(result != 12);
22 * open question: when would we use NTP_INVARIANT()?
30 extern void calysto_assume(unsigned char cnd
); /* assume this always holds */
31 extern void calysto_assert(unsigned char cnd
); /* check whether this holds */
32 #define NTP_REQUIRE(x) calysto_assert(x)
33 #define NTP_INSIST(x) calysto_assume(x) /* DLH calysto_assert()? */
34 #define NTP_INVARIANT(x) calysto_assume(x)
35 #define NTP_ENSURE(x) calysto_assert(x)
37 # elif defined(__COVERITY__)
40 * Coverity has special knowledge that assert(x) terminates the process
41 * if x is not true. Rather than teach it about our assertion macros,
42 * just use the one it knows about for Coverity Prevent scans. This
43 * means our assertion code (and ISC's) escapes Coverity analysis, but
44 * that seems to be a reasonable trade-off.
47 #define NTP_REQUIRE(x) assert(x)
48 #define NTP_INSIST(x) assert(x)
49 #define NTP_INVARIANT(x) assert(x)
50 #define NTP_ENSURE(x) assert(x)
52 # else /* neither Coverity nor Calysto */
54 #include "isc/assertions.h"
56 #define NTP_REQUIRE(x) ISC_REQUIRE(x)
57 #define NTP_INSIST(x) ISC_INSIST(x)
58 #define NTP_INVARIANT(x) ISC_INVARIANT(x)
59 #define NTP_ENSURE(x) ISC_ENSURE(x)
61 # endif /* neither Coverity nor Calysto */
62 #endif /* NTP_ASSERT_H */