diff options
Diffstat (limited to 'src/signal/sigsetjmp.c')
-rw-r--r-- | src/signal/sigsetjmp.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/signal/sigsetjmp.c b/src/signal/sigsetjmp.c new file mode 100644 index 00000000..a6667a27 --- /dev/null +++ b/src/signal/sigsetjmp.c @@ -0,0 +1,17 @@ +#include <setjmp.h> +#include <signal.h> +#include <stdlib.h> + +/* !!! This function will not work unless the compiler performs + * tail call optimization. Machine-specific asm versions should + * be created instead even though the workaround (tail call) + * is entirely non-machine-specific... */ + +int sigsetjmp(sigjmp_buf buf, int save) +{ + long *flag = buf + sizeof(jmp_buf)/sizeof(long); + sigset_t *mask = (void *)(flag + 1); + if ((*flag = save)) + sigprocmask (SIG_SETMASK, NULL, mask); + return setjmp((void *)buf); +} |