diff options
author | Rich Felker <dalias@aerifal.cx> | 2012-07-03 20:07:33 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2012-07-03 20:07:33 -0400 |
commit | d6c0efe106b1016108207fb6872820c06dcef4f8 (patch) | |
tree | 700300d0b4ff576121241befdcf865678cde4e5c /src | |
parent | e6129e6d836e5f4725d9b14ba7457b32e24adc61 (diff) | |
download | musl-d6c0efe106b1016108207fb6872820c06dcef4f8.zip musl-d6c0efe106b1016108207fb6872820c06dcef4f8.tar.gz musl-d6c0efe106b1016108207fb6872820c06dcef4f8.tar.bz2 |
jmp_buf overhaul fixing several issues
on arm, the location of the saved-signal-mask flag and mask were off
by one between sigsetjmp and siglongjmp, causing incorrect behavior
restoring the signal mask. this is because the siglongjmp code assumed
an extra slot was in the non-sig jmp_buf for the flag, but arm did not
have this. now, the extra slot is removed for all archs since it was
useless.
also, arm eabi requires jmp_buf to have 8-byte alignment. we achieve
that using long long as the type rather than with non-portable gcc
attribute tags.
Diffstat (limited to 'src')
-rw-r--r-- | src/signal/siglongjmp.c | 9 | ||||
-rw-r--r-- | src/signal/sigsetjmp.c | 8 |
2 files changed, 7 insertions, 10 deletions
diff --git a/src/signal/siglongjmp.c b/src/signal/siglongjmp.c index 600d560..9b4a539 100644 --- a/src/signal/siglongjmp.c +++ b/src/signal/siglongjmp.c @@ -1,12 +1,11 @@ #include <setjmp.h> #include <signal.h> #include <stdlib.h> +#include "syscall.h" void siglongjmp(sigjmp_buf buf, int ret) { - unsigned long *flag = buf + sizeof(jmp_buf)/sizeof(long) - 1; - sigset_t *mask = (void *)(flag + 1); - if (*flag) - sigprocmask (SIG_SETMASK, mask, NULL); - longjmp((void *)buf, ret); + if (buf->__fl) + __syscall(SYS_rt_sigprocmask, SIG_SETMASK, buf->__ss, 0, 8); + longjmp(buf->__jb, ret); } diff --git a/src/signal/sigsetjmp.c b/src/signal/sigsetjmp.c index 5c93707..01ba0df 100644 --- a/src/signal/sigsetjmp.c +++ b/src/signal/sigsetjmp.c @@ -9,9 +9,7 @@ int sigsetjmp(sigjmp_buf buf, int save) { - unsigned 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); + if ((buf->__fl = save)) + pthread_sigmask(SIG_SETMASK, 0, (sigset_t *)buf->__ss); + return setjmp(buf->__jb); } |