xref: /titanic_52/usr/src/cmd/sendmail/include/sm/xtrap.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
3*7c478bd9Sstevel@tonic-gate  *	All rights reserved.
4*7c478bd9Sstevel@tonic-gate  *
5*7c478bd9Sstevel@tonic-gate  * By using this file, you agree to the terms and conditions set
6*7c478bd9Sstevel@tonic-gate  * forth in the LICENSE file which can be found at the top level of
7*7c478bd9Sstevel@tonic-gate  * the sendmail distribution.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  *	$Id: xtrap.h,v 1.7 2001/04/03 01:53:01 gshapiro Exp $
10*7c478bd9Sstevel@tonic-gate  */
11*7c478bd9Sstevel@tonic-gate 
12*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
13*7c478bd9Sstevel@tonic-gate 
14*7c478bd9Sstevel@tonic-gate /*
15*7c478bd9Sstevel@tonic-gate **  scaffolding for testing exception handler code
16*7c478bd9Sstevel@tonic-gate */
17*7c478bd9Sstevel@tonic-gate 
18*7c478bd9Sstevel@tonic-gate #ifndef SM_XTRAP_H
19*7c478bd9Sstevel@tonic-gate # define SM_XTRAP_H
20*7c478bd9Sstevel@tonic-gate 
21*7c478bd9Sstevel@tonic-gate # include <sm/debug.h>
22*7c478bd9Sstevel@tonic-gate # include <sm/exc.h>
23*7c478bd9Sstevel@tonic-gate 
24*7c478bd9Sstevel@tonic-gate extern SM_ATOMIC_UINT_T SmXtrapCount;
25*7c478bd9Sstevel@tonic-gate extern SM_DEBUG_T SmXtrapDebug;
26*7c478bd9Sstevel@tonic-gate extern SM_DEBUG_T SmXtrapReport;
27*7c478bd9Sstevel@tonic-gate 
28*7c478bd9Sstevel@tonic-gate # if SM_DEBUG_CHECK
29*7c478bd9Sstevel@tonic-gate #  define sm_xtrap_check() (++SmXtrapCount == sm_debug_level(&SmXtrapDebug))
30*7c478bd9Sstevel@tonic-gate # else /* SM_DEBUG_CHECK */
31*7c478bd9Sstevel@tonic-gate #  define sm_xtrap_check() (0)
32*7c478bd9Sstevel@tonic-gate # endif /* SM_DEBUG_CHECK */
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate # define sm_xtrap_raise_x(exc) \
35*7c478bd9Sstevel@tonic-gate 		if (sm_xtrap_check()) \
36*7c478bd9Sstevel@tonic-gate 		{ \
37*7c478bd9Sstevel@tonic-gate 			sm_exc_raise_x(exc); \
38*7c478bd9Sstevel@tonic-gate 		} else
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #endif /* ! SM_XTRAP_H */
41