1/*
2 * Copyright 2005-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5
6
7#include <setjmp.h>
8
9
10/*!	This function is called by [sig]longjmp(). The caller has already
11	set up the registers and stack, so that returning from the function
12	will return to the place where [sig]setjmp() was invoked. It resets
13	the signal mask and validates the value supplied to [sig]longjmp().
14 */
15int __longjmp_return(jmp_buf buffer, int value);
16
17int
18__longjmp_return(jmp_buf buffer, int value)
19{
20	if (buffer[0].inverted_signal_mask != 0) {
21		sigset_t signalMask = ~buffer[0].inverted_signal_mask;
22		sigprocmask(SIG_SETMASK, &signalMask, NULL);
23	}
24
25	return (value == 0 ? 1 : value);
26}
27