xref: /freebsd/contrib/sendmail/include/sm/setjmp.h (revision ee7b0571c2c18bdec848ed2044223cc88db29bd8)
140266059SGregory Neil Shapiro /*
25dd76dd0SGregory Neil Shapiro  * Copyright (c) 2000-2001 Proofpoint, Inc. and its suppliers.
340266059SGregory Neil Shapiro  *	All rights reserved.
440266059SGregory Neil Shapiro  *
540266059SGregory Neil Shapiro  * By using this file, you agree to the terms and conditions set
640266059SGregory Neil Shapiro  * forth in the LICENSE file which can be found at the top level of
740266059SGregory Neil Shapiro  * the sendmail distribution.
840266059SGregory Neil Shapiro  *
9*4313cc83SGregory Neil Shapiro  *	$Id: setjmp.h,v 1.4 2013-11-22 20:51:31 ca Exp $
1040266059SGregory Neil Shapiro  */
1140266059SGregory Neil Shapiro 
1240266059SGregory Neil Shapiro #ifndef SM_SETJMP_H
1340266059SGregory Neil Shapiro # define SM_SETJMP_H
1440266059SGregory Neil Shapiro 
1540266059SGregory Neil Shapiro # include <sm/config.h>
1640266059SGregory Neil Shapiro # include <setjmp.h>
1740266059SGregory Neil Shapiro 
1840266059SGregory Neil Shapiro /*
1940266059SGregory Neil Shapiro **  sm_setjmp_sig is a setjmp that saves the signal mask.
2040266059SGregory Neil Shapiro **  sm_setjmp_nosig is a setjmp that does *not* save the signal mask.
2140266059SGregory Neil Shapiro **  SM_JMPBUF_T is used with both of the above macros.
2240266059SGregory Neil Shapiro **
2340266059SGregory Neil Shapiro **  On most systems, these can be implemented using sigsetjmp.
2440266059SGregory Neil Shapiro **  Some old BSD systems do not have sigsetjmp, but they do have
2540266059SGregory Neil Shapiro **  setjmp and _setjmp, which are just as good.
2640266059SGregory Neil Shapiro */
2740266059SGregory Neil Shapiro 
2840266059SGregory Neil Shapiro # if SM_CONF_SIGSETJMP
2940266059SGregory Neil Shapiro 
3040266059SGregory Neil Shapiro typedef sigjmp_buf SM_JMPBUF_T;
3140266059SGregory Neil Shapiro #  define sm_setjmp_sig(buf)		sigsetjmp(buf, 1)
3240266059SGregory Neil Shapiro #  define sm_setjmp_nosig(buf)		sigsetjmp(buf, 0)
3340266059SGregory Neil Shapiro #  define sm_longjmp_sig(buf, val)	siglongjmp(buf, val)
3440266059SGregory Neil Shapiro #  define sm_longjmp_nosig(buf, val)	siglongjmp(buf, val)
3540266059SGregory Neil Shapiro 
3640266059SGregory Neil Shapiro # else /* SM_CONF_SIGSETJMP */
3740266059SGregory Neil Shapiro 
3840266059SGregory Neil Shapiro typedef jmp_buf SM_JMPBUF_T;
3940266059SGregory Neil Shapiro #  define sm_setjmp_sig(buf)		setjmp(buf)
4040266059SGregory Neil Shapiro #  define sm_longjmp_sig(buf, val)	longjmp(buf, val)
4140266059SGregory Neil Shapiro #   define sm_setjmp_nosig(buf)		_setjmp(buf)
4240266059SGregory Neil Shapiro #   define sm_longjmp_nosig(buf, val)	_longjmp(buf, val)
4340266059SGregory Neil Shapiro 
4440266059SGregory Neil Shapiro # endif /* SM_CONF_SIGSETJMP */
4540266059SGregory Neil Shapiro 
4640266059SGregory Neil Shapiro #endif /* ! SM_SETJMP_H */
47