2 * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
9 * $Id: assert.h,v 1.10 2001/06/07 20:04:53 ca Exp $
12 #pragma ident "%Z%%M% %I% %E% SMI"
15 ** libsm abnormal program termination and assertion checking
16 ** See libsm/assert.html for documentation.
23 # include <sm/debug.h>
26 ** abnormal program termination
29 typedef void (*SM_ABORT_HANDLER_T
) __P((const char *, int, const char *));
38 sm_abort_sethandler
__P((
41 extern SM_DEAD(void PRINTFLIKE(1, 2)
51 # define SM_CHECK_ALL 1
52 # endif /* ! SM_CHECK_ALL */
54 # ifndef SM_CHECK_REQUIRE
55 # define SM_CHECK_REQUIRE SM_CHECK_ALL
56 # endif /* ! SM_CHECK_REQUIRE */
58 # ifndef SM_CHECK_ENSURE
59 # define SM_CHECK_ENSURE SM_CHECK_ALL
60 # endif /* ! SM_CHECK_ENSURE */
62 # ifndef SM_CHECK_ASSERT
63 # define SM_CHECK_ASSERT SM_CHECK_ALL
64 # endif /* ! SM_CHECK_ASSERT */
67 # if defined(__STDC__) || defined(__cplusplus)
68 # define SM_REQUIRE(cond) \
69 ((void) ((cond) || (sm_abort_at(__FILE__, __LINE__, \
70 "SM_REQUIRE(" #cond ") failed"), 0)))
71 # else /* defined(__STDC__) || defined(__cplusplus) */
72 # define SM_REQUIRE(cond) \
73 ((void) ((cond) || (sm_abort_at(__FILE__, __LINE__, \
74 "SM_REQUIRE(cond) failed"), 0)))
75 # endif /* defined(__STDC__) || defined(__cplusplus) */
76 # else /* SM_CHECK_REQUIRE */
77 # define SM_REQUIRE(cond) ((void) 0)
78 # endif /* SM_CHECK_REQUIRE */
80 # define SM_REQUIRE_ISA(obj, magic) \
81 SM_REQUIRE((obj) != NULL && (obj)->sm_magic == (magic))
84 # if defined(__STDC__) || defined(__cplusplus)
85 # define SM_ENSURE(cond) \
86 ((void) ((cond) || (sm_abort_at(__FILE__, __LINE__, \
87 "SM_ENSURE(" #cond ") failed"), 0)))
88 # else /* defined(__STDC__) || defined(__cplusplus) */
89 # define SM_ENSURE(cond) \
90 ((void) ((cond) || (sm_abort_at(__FILE__, __LINE__, \
91 "SM_ENSURE(cond) failed"), 0)))
92 # endif /* defined(__STDC__) || defined(__cplusplus) */
93 # else /* SM_CHECK_ENSURE */
94 # define SM_ENSURE(cond) ((void) 0)
95 # endif /* SM_CHECK_ENSURE */
98 # if defined(__STDC__) || defined(__cplusplus)
99 # define SM_ASSERT(cond) \
100 ((void) ((cond) || (sm_abort_at(__FILE__, __LINE__, \
101 "SM_ASSERT(" #cond ") failed"), 0)))
102 # else /* defined(__STDC__) || defined(__cplusplus) */
103 # define SM_ASSERT(cond) \
104 ((void) ((cond) || (sm_abort_at(__FILE__, __LINE__, \
105 "SM_ASSERT(cond) failed"), 0)))
106 # endif /* defined(__STDC__) || defined(__cplusplus) */
107 # else /* SM_CHECK_ASSERT */
108 # define SM_ASSERT(cond) ((void) 0)
109 # endif /* SM_CHECK_ASSERT */
111 extern SM_DEBUG_T SmExpensiveRequire
;
112 extern SM_DEBUG_T SmExpensiveEnsure
;
113 extern SM_DEBUG_T SmExpensiveAssert
;
115 #endif /* ! SM_ASSERT_H */