xref: /freebsd/contrib/sendmail/include/sm/setjmp.h (revision ee7b0571c2c18bdec848ed2044223cc88db29bd8)
1 /*
2  * Copyright (c) 2000-2001 Proofpoint, Inc. and its suppliers.
3  *	All rights reserved.
4  *
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.
8  *
9  *	$Id: setjmp.h,v 1.4 2013-11-22 20:51:31 ca Exp $
10  */
11 
12 #ifndef SM_SETJMP_H
13 # define SM_SETJMP_H
14 
15 # include <sm/config.h>
16 # include <setjmp.h>
17 
18 /*
19 **  sm_setjmp_sig is a setjmp that saves the signal mask.
20 **  sm_setjmp_nosig is a setjmp that does *not* save the signal mask.
21 **  SM_JMPBUF_T is used with both of the above macros.
22 **
23 **  On most systems, these can be implemented using sigsetjmp.
24 **  Some old BSD systems do not have sigsetjmp, but they do have
25 **  setjmp and _setjmp, which are just as good.
26 */
27 
28 # if SM_CONF_SIGSETJMP
29 
30 typedef sigjmp_buf SM_JMPBUF_T;
31 #  define sm_setjmp_sig(buf)		sigsetjmp(buf, 1)
32 #  define sm_setjmp_nosig(buf)		sigsetjmp(buf, 0)
33 #  define sm_longjmp_sig(buf, val)	siglongjmp(buf, val)
34 #  define sm_longjmp_nosig(buf, val)	siglongjmp(buf, val)
35 
36 # else /* SM_CONF_SIGSETJMP */
37 
38 typedef jmp_buf SM_JMPBUF_T;
39 #  define sm_setjmp_sig(buf)		setjmp(buf)
40 #  define sm_longjmp_sig(buf, val)	longjmp(buf, val)
41 #   define sm_setjmp_nosig(buf)		_setjmp(buf)
42 #   define sm_longjmp_nosig(buf, val)	_longjmp(buf, val)
43 
44 # endif /* SM_CONF_SIGSETJMP */
45 
46 #endif /* ! SM_SETJMP_H */
47