8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / sendmail / include / sm / assert.h
blobd96920e7fdd901808bc928aa9556f8d4aef364d2
1 /*
2 * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
3 * All rights reserved.
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.
19 #ifndef SM_ASSERT_H
20 # define SM_ASSERT_H
22 # include <sm/gen.h>
23 # include <sm/debug.h>
26 ** abnormal program termination
29 typedef void (*SM_ABORT_HANDLER_T) __P((const char *, int, const char *));
31 extern SM_DEAD(void
32 sm_abort_at __P((
33 const char *,
34 int,
35 const char *)));
37 extern void
38 sm_abort_sethandler __P((
39 SM_ABORT_HANDLER_T));
41 extern SM_DEAD(void PRINTFLIKE(1, 2)
42 sm_abort __P((
43 char *,
44 ...)));
47 ** assertion checking
50 # ifndef SM_CHECK_ALL
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 */
66 # if SM_CHECK_REQUIRE
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))
83 # if SM_CHECK_ENSURE
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 */
97 # if SM_CHECK_ASSERT
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 */