From 9bc8a11afeed3569736b89754012e3ca22ee10f6 Mon Sep 17 00:00:00 2001 From: pommicket Date: Sun, 20 Feb 2022 13:18:21 -0800 Subject: conclusion --- 05/musl-0.6.0/src/signal/getitimer.c | 12 ++++++++ 05/musl-0.6.0/src/signal/i386/restore.s | 15 ++++++++++ 05/musl-0.6.0/src/signal/i386/sigsetjmp.s | 13 +++++++++ 05/musl-0.6.0/src/signal/kill.c | 7 +++++ 05/musl-0.6.0/src/signal/killpg.c | 11 +++++++ 05/musl-0.6.0/src/signal/raise.c | 7 +++++ 05/musl-0.6.0/src/signal/restore.c | 0 05/musl-0.6.0/src/signal/setitimer.c | 15 ++++++++++ 05/musl-0.6.0/src/signal/sigaction.c | 45 +++++++++++++++++++++++++++++ 05/musl-0.6.0/src/signal/sigaddset.c | 13 +++++++++ 05/musl-0.6.0/src/signal/sigaltstack.c | 8 +++++ 05/musl-0.6.0/src/signal/sigdelset.c | 13 +++++++++ 05/musl-0.6.0/src/signal/sigemptyset.c | 8 +++++ 05/musl-0.6.0/src/signal/sigfillset.c | 8 +++++ 05/musl-0.6.0/src/signal/sighold.c | 11 +++++++ 05/musl-0.6.0/src/signal/sigignore.c | 12 ++++++++ 05/musl-0.6.0/src/signal/siginterrupt.c | 13 +++++++++ 05/musl-0.6.0/src/signal/sigismember.c | 12 ++++++++ 05/musl-0.6.0/src/signal/siglongjmp.c | 12 ++++++++ 05/musl-0.6.0/src/signal/signal.c | 16 ++++++++++ 05/musl-0.6.0/src/signal/sigpause.c | 11 +++++++ 05/musl-0.6.0/src/signal/sigpending.c | 7 +++++ 05/musl-0.6.0/src/signal/sigprocmask.c | 23 +++++++++++++++ 05/musl-0.6.0/src/signal/sigqueue.c | 14 +++++++++ 05/musl-0.6.0/src/signal/sigrelse.c | 11 +++++++ 05/musl-0.6.0/src/signal/sigrtmax.c | 4 +++ 05/musl-0.6.0/src/signal/sigrtmin.c | 4 +++ 05/musl-0.6.0/src/signal/sigset.c | 28 ++++++++++++++++++ 05/musl-0.6.0/src/signal/sigsetjmp.c | 17 +++++++++++ 05/musl-0.6.0/src/signal/sigsuspend.c | 7 +++++ 05/musl-0.6.0/src/signal/sigtimedwait.c | 12 ++++++++ 05/musl-0.6.0/src/signal/sigwait.c | 11 +++++++ 05/musl-0.6.0/src/signal/sigwaitinfo.c | 7 +++++ 05/musl-0.6.0/src/signal/x86_64/restore.s | 11 +++++++ 05/musl-0.6.0/src/signal/x86_64/sigsetjmp.s | 11 +++++++ 35 files changed, 429 insertions(+) create mode 100644 05/musl-0.6.0/src/signal/getitimer.c create mode 100644 05/musl-0.6.0/src/signal/i386/restore.s create mode 100644 05/musl-0.6.0/src/signal/i386/sigsetjmp.s create mode 100644 05/musl-0.6.0/src/signal/kill.c create mode 100644 05/musl-0.6.0/src/signal/killpg.c create mode 100644 05/musl-0.6.0/src/signal/raise.c create mode 100644 05/musl-0.6.0/src/signal/restore.c create mode 100644 05/musl-0.6.0/src/signal/setitimer.c create mode 100644 05/musl-0.6.0/src/signal/sigaction.c create mode 100644 05/musl-0.6.0/src/signal/sigaddset.c create mode 100644 05/musl-0.6.0/src/signal/sigaltstack.c create mode 100644 05/musl-0.6.0/src/signal/sigdelset.c create mode 100644 05/musl-0.6.0/src/signal/sigemptyset.c create mode 100644 05/musl-0.6.0/src/signal/sigfillset.c create mode 100644 05/musl-0.6.0/src/signal/sighold.c create mode 100644 05/musl-0.6.0/src/signal/sigignore.c create mode 100644 05/musl-0.6.0/src/signal/siginterrupt.c create mode 100644 05/musl-0.6.0/src/signal/sigismember.c create mode 100644 05/musl-0.6.0/src/signal/siglongjmp.c create mode 100644 05/musl-0.6.0/src/signal/signal.c create mode 100644 05/musl-0.6.0/src/signal/sigpause.c create mode 100644 05/musl-0.6.0/src/signal/sigpending.c create mode 100644 05/musl-0.6.0/src/signal/sigprocmask.c create mode 100644 05/musl-0.6.0/src/signal/sigqueue.c create mode 100644 05/musl-0.6.0/src/signal/sigrelse.c create mode 100644 05/musl-0.6.0/src/signal/sigrtmax.c create mode 100644 05/musl-0.6.0/src/signal/sigrtmin.c create mode 100644 05/musl-0.6.0/src/signal/sigset.c create mode 100644 05/musl-0.6.0/src/signal/sigsetjmp.c create mode 100644 05/musl-0.6.0/src/signal/sigsuspend.c create mode 100644 05/musl-0.6.0/src/signal/sigtimedwait.c create mode 100644 05/musl-0.6.0/src/signal/sigwait.c create mode 100644 05/musl-0.6.0/src/signal/sigwaitinfo.c create mode 100644 05/musl-0.6.0/src/signal/x86_64/restore.s create mode 100644 05/musl-0.6.0/src/signal/x86_64/sigsetjmp.s (limited to '05/musl-0.6.0/src/signal') diff --git a/05/musl-0.6.0/src/signal/getitimer.c b/05/musl-0.6.0/src/signal/getitimer.c new file mode 100644 index 0000000..222d113 --- /dev/null +++ b/05/musl-0.6.0/src/signal/getitimer.c @@ -0,0 +1,12 @@ +#include +#include "syscall.h" + +int getitimer(int which, struct itimerval *old) +{ + int ret; + long kold[4]; + + if (!(ret = syscall2(__NR_getitimer, which, (long)&kold))) + *old = (struct itimerval){ { kold[0], kold[1] }, { kold[2], kold[3] } }; + return ret; +} diff --git a/05/musl-0.6.0/src/signal/i386/restore.s b/05/musl-0.6.0/src/signal/i386/restore.s new file mode 100644 index 0000000..e0c4ab6 --- /dev/null +++ b/05/musl-0.6.0/src/signal/i386/restore.s @@ -0,0 +1,15 @@ +.global __restore +.type __restore,%function +__restore: + popl %eax + movl $119, %eax + int $0x80 +.size __restore,.-__restore + +.global __restore_rt +.type __restore_rt,%function +__restore_rt: + movl $173, %eax + int $0x80 +.size __restore_rt,.-__restore_rt + diff --git a/05/musl-0.6.0/src/signal/i386/sigsetjmp.s b/05/musl-0.6.0/src/signal/i386/sigsetjmp.s new file mode 100644 index 0000000..0e7eefb --- /dev/null +++ b/05/musl-0.6.0/src/signal/i386/sigsetjmp.s @@ -0,0 +1,13 @@ +.global sigsetjmp +sigsetjmp: + mov 4(%esp),%eax + mov 8(%esp),%ecx + mov %ecx,24(%eax) + jecxz 1f + add $28,%eax + push %eax + push $0 + push $2 + call sigprocmask + add $12,%esp +1: jmp setjmp diff --git a/05/musl-0.6.0/src/signal/kill.c b/05/musl-0.6.0/src/signal/kill.c new file mode 100644 index 0000000..cc4b51e --- /dev/null +++ b/05/musl-0.6.0/src/signal/kill.c @@ -0,0 +1,7 @@ +#include +#include "syscall.h" + +int kill(pid_t pid, int sig) +{ + return syscall2(__NR_kill, pid, sig); +} diff --git a/05/musl-0.6.0/src/signal/killpg.c b/05/musl-0.6.0/src/signal/killpg.c new file mode 100644 index 0000000..315ed44 --- /dev/null +++ b/05/musl-0.6.0/src/signal/killpg.c @@ -0,0 +1,11 @@ +#include +#include + +int killpg(pid_t pgid, int sig) +{ + if (pgid < 0) { + errno = EINVAL; + return -1; + } + return kill(-pgid, sig); +} diff --git a/05/musl-0.6.0/src/signal/raise.c b/05/musl-0.6.0/src/signal/raise.c new file mode 100644 index 0000000..52f8b42 --- /dev/null +++ b/05/musl-0.6.0/src/signal/raise.c @@ -0,0 +1,7 @@ +#include +#include "syscall.h" + +int raise(int sig) +{ + return __syscall_kill(__syscall_getpid(), sig); +} diff --git a/05/musl-0.6.0/src/signal/restore.c b/05/musl-0.6.0/src/signal/restore.c new file mode 100644 index 0000000..e69de29 diff --git a/05/musl-0.6.0/src/signal/setitimer.c b/05/musl-0.6.0/src/signal/setitimer.c new file mode 100644 index 0000000..cacab03 --- /dev/null +++ b/05/musl-0.6.0/src/signal/setitimer.c @@ -0,0 +1,15 @@ +#include +#include "syscall.h" + +int setitimer(int which, const struct itimerval *new, struct itimerval *old) +{ + int ret; + long knew[4] = { + new->it_interval.tv_sec, new->it_interval.tv_usec, + new->it_value.tv_sec, new->it_value.tv_usec + }, kold[4]; + + if (!(ret = syscall3(__NR_setitimer, which, (long)&knew, old ? (long)&kold : 0)) && old) + *old = (struct itimerval){ { kold[0], kold[1] }, { kold[2], kold[3] } }; + return ret; +} diff --git a/05/musl-0.6.0/src/signal/sigaction.c b/05/musl-0.6.0/src/signal/sigaction.c new file mode 100644 index 0000000..b1603b9 --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigaction.c @@ -0,0 +1,45 @@ +#include +#include +#include +#include "syscall.h" +#include "pthread_impl.h" + +void __restore(), __restore_rt(); + +int __libc_sigaction(int sig, const struct sigaction *sa, struct sigaction *old) +{ + struct { + void *handler; + unsigned long flags; + void (*restorer)(void); + sigset_t mask; + } ksa, kold; + long pksa=0, pkold=0; + if (sa) { + ksa.handler = sa->sa_handler; + ksa.flags = sa->sa_flags | SA_RESTORER; + ksa.restorer = (sa->sa_flags & SA_SIGINFO) ? __restore_rt : __restore; + ksa.mask = sa->sa_mask; + pksa = (long)&ksa; + } + if (old) pkold = (long)&kold; + if (syscall4(__NR_rt_sigaction, sig, pksa, pkold, 8)) + return -1; + if (old) { + old->sa_handler = kold.handler; + old->sa_flags = kold.flags; + old->sa_mask = kold.mask; + } + return 0; +} + +int __sigaction(int sig, const struct sigaction *sa, struct sigaction *old) +{ + if (sig == SIGCANCEL || sig == SIGSYSCALL) { + errno = EINVAL; + return -1; + } + return __libc_sigaction(sig, sa, old); +} + +weak_alias(__sigaction, sigaction); diff --git a/05/musl-0.6.0/src/signal/sigaddset.c b/05/musl-0.6.0/src/signal/sigaddset.c new file mode 100644 index 0000000..23e655d --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigaddset.c @@ -0,0 +1,13 @@ +#include +#include + +int sigaddset(sigset_t *set, int sig) +{ + unsigned s = sig-1; + if (s >= 8*sizeof(sigset_t)) { + errno = EINVAL; + return -1; + } + set->__bits[s/8/sizeof *set->__bits] |= 1UL<<(s&8*sizeof *set->__bits-1); + return 0; +} diff --git a/05/musl-0.6.0/src/signal/sigaltstack.c b/05/musl-0.6.0/src/signal/sigaltstack.c new file mode 100644 index 0000000..3cc2d45 --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigaltstack.c @@ -0,0 +1,8 @@ +#include +#include "syscall.h" + +int sigaltstack(const stack_t *ss, stack_t *old) +{ + /* depends on kernel struct matching */ + return syscall2(__NR_sigaltstack, (long)ss, (long)old); +} diff --git a/05/musl-0.6.0/src/signal/sigdelset.c b/05/musl-0.6.0/src/signal/sigdelset.c new file mode 100644 index 0000000..14042fb --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigdelset.c @@ -0,0 +1,13 @@ +#include +#include + +int sigdelset(sigset_t *set, int sig) +{ + unsigned s = sig-1; + if (s >= 8*sizeof(sigset_t)) { + errno = EINVAL; + return -1; + } + set->__bits[s/8/sizeof *set->__bits] &=~(1UL<<(s&8*sizeof *set->__bits-1)); + return 0; +} diff --git a/05/musl-0.6.0/src/signal/sigemptyset.c b/05/musl-0.6.0/src/signal/sigemptyset.c new file mode 100644 index 0000000..91f77ad --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigemptyset.c @@ -0,0 +1,8 @@ +#include +#include + +int sigemptyset(sigset_t *set) +{ + memset(set, 0, sizeof *set); + return 0; +} diff --git a/05/musl-0.6.0/src/signal/sigfillset.c b/05/musl-0.6.0/src/signal/sigfillset.c new file mode 100644 index 0000000..fab50a5 --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigfillset.c @@ -0,0 +1,8 @@ +#include +#include + +int sigfillset(sigset_t *set) +{ + memset(set, -1, sizeof *set); + return 0; +} diff --git a/05/musl-0.6.0/src/signal/sighold.c b/05/musl-0.6.0/src/signal/sighold.c new file mode 100644 index 0000000..5b0f6b1 --- /dev/null +++ b/05/musl-0.6.0/src/signal/sighold.c @@ -0,0 +1,11 @@ +#include +#include + +int sighold(int sig) +{ + sigset_t mask; + + sigemptyset(&mask); + if (sigaddset(&mask, sig) < 0) return -1; + return sigprocmask(SIG_BLOCK, &mask, NULL); +} diff --git a/05/musl-0.6.0/src/signal/sigignore.c b/05/musl-0.6.0/src/signal/sigignore.c new file mode 100644 index 0000000..98dff61 --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigignore.c @@ -0,0 +1,12 @@ +#include +#include + +int sigignore(int sig) +{ + struct sigaction sa; + + sigemptyset(&sa.sa_mask); + sa.sa_handler = SIG_IGN; + sa.sa_flags = 0; + return sigaction(sig, &sa, NULL); +} diff --git a/05/musl-0.6.0/src/signal/siginterrupt.c b/05/musl-0.6.0/src/signal/siginterrupt.c new file mode 100644 index 0000000..60b3405 --- /dev/null +++ b/05/musl-0.6.0/src/signal/siginterrupt.c @@ -0,0 +1,13 @@ +#include +#include + +int siginterrupt(int sig, int flag) +{ + struct sigaction sa; + + sigaction(sig, NULL, &sa); + if (flag) sa.sa_flags &= ~SA_RESTART; + else sa.sa_flags |= SA_RESTART; + + return sigaction(sig, &sa, NULL); +} diff --git a/05/musl-0.6.0/src/signal/sigismember.c b/05/musl-0.6.0/src/signal/sigismember.c new file mode 100644 index 0000000..afd29e5 --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigismember.c @@ -0,0 +1,12 @@ +#include +#include + +int sigismember(const sigset_t *set, int sig) +{ + unsigned s = sig-1; + if (s >= 8*sizeof(sigset_t)) { + errno = EINVAL; + return -1; + } + return !!(set->__bits[s/8/sizeof *set->__bits] & 1UL<<(s&8*sizeof *set->__bits-1)); +} diff --git a/05/musl-0.6.0/src/signal/siglongjmp.c b/05/musl-0.6.0/src/signal/siglongjmp.c new file mode 100644 index 0000000..33ac30e --- /dev/null +++ b/05/musl-0.6.0/src/signal/siglongjmp.c @@ -0,0 +1,12 @@ +#include +#include +#include + +void siglongjmp(sigjmp_buf buf, int ret) +{ + long *flag = buf + sizeof(jmp_buf)/sizeof(long); + sigset_t *mask = (void *)(flag + 1); + if (*flag) + sigprocmask (SIG_SETMASK, mask, NULL); + longjmp((void *)buf, ret); +} diff --git a/05/musl-0.6.0/src/signal/signal.c b/05/musl-0.6.0/src/signal/signal.c new file mode 100644 index 0000000..07346a8 --- /dev/null +++ b/05/musl-0.6.0/src/signal/signal.c @@ -0,0 +1,16 @@ +#include +#include +#include "syscall.h" +#include "libc.h" + +int __sigaction(int, const struct sigaction *, struct sigaction *); + +void (*signal(int sig, void (*func)(int)))(int) +{ + struct sigaction sa = { .sa_handler = func, .sa_flags = SA_RESTART }; + if (__sigaction(sig, &sa, &sa) < 0) + return SIG_ERR; + return sa.sa_handler; +} + +weak_alias(signal, bsd_signal); diff --git a/05/musl-0.6.0/src/signal/sigpause.c b/05/musl-0.6.0/src/signal/sigpause.c new file mode 100644 index 0000000..263c00f --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigpause.c @@ -0,0 +1,11 @@ +#include +#include + +int sigpause(int sig) +{ + sigset_t mask; + + if (sigprocmask(0, NULL, &mask) < 0 || sigdelset(&mask, sig) < 0) + return -1; + return sigsuspend(&mask); +} diff --git a/05/musl-0.6.0/src/signal/sigpending.c b/05/musl-0.6.0/src/signal/sigpending.c new file mode 100644 index 0000000..7deda25 --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigpending.c @@ -0,0 +1,7 @@ +#include +#include "syscall.h" + +int sigpending(sigset_t *set) +{ + return syscall2(__NR_rt_sigpending, (long)set, SYSCALL_SIGSET_SIZE); +} diff --git a/05/musl-0.6.0/src/signal/sigprocmask.c b/05/musl-0.6.0/src/signal/sigprocmask.c new file mode 100644 index 0000000..e89f876 --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigprocmask.c @@ -0,0 +1,23 @@ +#include +#include "syscall.h" +#include "libc.h" + +int __libc_sigprocmask(int how, const sigset_t *set, sigset_t *old) +{ + return syscall4(__NR_rt_sigprocmask, how, (long)set, (long)old, 8); +} + +int __sigprocmask(int how, const sigset_t *set, sigset_t *old) +{ + sigset_t tmp; + /* Quickly mask out bits 32 and 33 (thread control signals) */ + if (0 && how != SIG_UNBLOCK && (set->__bits[4/sizeof *set->__bits] & 3UL<<(32&8*sizeof *set->__bits-1))) { + tmp = *set; + set = &tmp; + tmp.__bits[4/sizeof *set->__bits] &= ~(3UL<<(32&8*sizeof *set->__bits-1)); + } + return __libc_sigprocmask(how, set, old); +} + +weak_alias(__sigprocmask, sigprocmask); +weak_alias(__sigprocmask, pthread_sigmask); diff --git a/05/musl-0.6.0/src/signal/sigqueue.c b/05/musl-0.6.0/src/signal/sigqueue.c new file mode 100644 index 0000000..ce3abf6 --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigqueue.c @@ -0,0 +1,14 @@ +#include +#include +#include +#include "syscall.h" + +int sigqueue(pid_t pid, int sig, const union sigval value) +{ + siginfo_t si = { + .si_signo = sig, + .si_code = -1, + .si_value = value, + }; + return syscall3(__NR_rt_sigqueueinfo, pid, sig, (long)&si); +} diff --git a/05/musl-0.6.0/src/signal/sigrelse.c b/05/musl-0.6.0/src/signal/sigrelse.c new file mode 100644 index 0000000..b0b3024 --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigrelse.c @@ -0,0 +1,11 @@ +#include +#include + +int sigrelse(int sig) +{ + sigset_t mask; + + sigemptyset(&mask); + if (sigaddset(&mask, sig) < 0) return -1; + return sigprocmask(SIG_UNBLOCK, &mask, NULL); +} diff --git a/05/musl-0.6.0/src/signal/sigrtmax.c b/05/musl-0.6.0/src/signal/sigrtmax.c new file mode 100644 index 0000000..0ef2987 --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigrtmax.c @@ -0,0 +1,4 @@ +int __libc_current_sigrtmax() +{ + return 64; +} diff --git a/05/musl-0.6.0/src/signal/sigrtmin.c b/05/musl-0.6.0/src/signal/sigrtmin.c new file mode 100644 index 0000000..7ad06d2 --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigrtmin.c @@ -0,0 +1,4 @@ +int __libc_current_sigrtmin() +{ + return 34; +} diff --git a/05/musl-0.6.0/src/signal/sigset.c b/05/musl-0.6.0/src/signal/sigset.c new file mode 100644 index 0000000..1b6b38f --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigset.c @@ -0,0 +1,28 @@ +#include +#include + +void (*sigset(int sig, void (*handler)(int)))(int) +{ + struct sigaction sa, sa_old; + sigset_t mask; + + sigemptyset(&mask); + if (sigaddset(&mask, sig) < 0) + return SIG_ERR; + + if (handler == SIG_HOLD) { + if (sigaction(sig, NULL, &sa_old) < 0) + return SIG_ERR; + if (sigprocmask(SIG_BLOCK, &mask, &mask) < 0) + return SIG_ERR; + } else { + sa.sa_handler = handler; + sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); + if (sigaction(sig, &sa, &sa_old) < 0) + return SIG_ERR; + if (sigprocmask(SIG_UNBLOCK, &mask, &mask) < 0) + return SIG_ERR; + } + return sigismember(&mask, sig) ? SIG_HOLD : sa_old.sa_handler; +} diff --git a/05/musl-0.6.0/src/signal/sigsetjmp.c b/05/musl-0.6.0/src/signal/sigsetjmp.c new file mode 100644 index 0000000..a6667a2 --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigsetjmp.c @@ -0,0 +1,17 @@ +#include +#include +#include + +/* !!! 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); +} diff --git a/05/musl-0.6.0/src/signal/sigsuspend.c b/05/musl-0.6.0/src/signal/sigsuspend.c new file mode 100644 index 0000000..1acdab0 --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigsuspend.c @@ -0,0 +1,7 @@ +#include +#include "syscall.h" + +int sigsuspend(const sigset_t *mask) +{ + return syscall2(__NR_rt_sigsuspend, (long)mask, sizeof(sigset_t)); +} diff --git a/05/musl-0.6.0/src/signal/sigtimedwait.c b/05/musl-0.6.0/src/signal/sigtimedwait.c new file mode 100644 index 0000000..155185d --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigtimedwait.c @@ -0,0 +1,12 @@ +#include +#include "syscall.h" + +int sigtimedwait(const sigset_t *mask, siginfo_t *si, const struct timespec *timeout) +{ + long k_timeout[2]; + if (timeout) { + k_timeout[0] = timeout->tv_sec; + k_timeout[1] = timeout->tv_nsec; + } + return syscall4(__NR_rt_sigtimedwait, (long)mask, (long)si, timeout ? (long)k_timeout : 0, SYSCALL_SIGSET_SIZE); +} diff --git a/05/musl-0.6.0/src/signal/sigwait.c b/05/musl-0.6.0/src/signal/sigwait.c new file mode 100644 index 0000000..9569d6b --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigwait.c @@ -0,0 +1,11 @@ +#include +#include + +int sigwait(const sigset_t *mask, int *sig) +{ + siginfo_t si; + if (sigtimedwait(mask, &si, NULL) < 0) + return -1; + *sig = si.si_signo; + return 0; +} diff --git a/05/musl-0.6.0/src/signal/sigwaitinfo.c b/05/musl-0.6.0/src/signal/sigwaitinfo.c new file mode 100644 index 0000000..e79feb9 --- /dev/null +++ b/05/musl-0.6.0/src/signal/sigwaitinfo.c @@ -0,0 +1,7 @@ +#include +#include + +int sigwaitinfo(const sigset_t *mask, siginfo_t *si) +{ + return sigtimedwait(mask, si, NULL); +} diff --git a/05/musl-0.6.0/src/signal/x86_64/restore.s b/05/musl-0.6.0/src/signal/x86_64/restore.s new file mode 100644 index 0000000..bc5e0d7 --- /dev/null +++ b/05/musl-0.6.0/src/signal/x86_64/restore.s @@ -0,0 +1,11 @@ +.global __restore_rt +.global __restore +.type __restore_rt,%function +.type __restore,%function +__restore_rt: +__restore: + movl $15, %eax + syscall +.size __restore_rt,.-__restore_rt +.size __restore,.-__restore + diff --git a/05/musl-0.6.0/src/signal/x86_64/sigsetjmp.s b/05/musl-0.6.0/src/signal/x86_64/sigsetjmp.s new file mode 100644 index 0000000..0a45078 --- /dev/null +++ b/05/musl-0.6.0/src/signal/x86_64/sigsetjmp.s @@ -0,0 +1,11 @@ +/* Copyright 2011 Nicholas J. Kain, licensed GNU LGPL 2.1 or later */ +.global sigsetjmp +sigsetjmp: + test %rsi,%rsi + jz 1f /* if save == 0, just goto setjmp */ + movq %rsi,64(%rdi) /* move save -> jmp_buf[8] */ + addq $72,%rdi /* add sizeof(jmp_buf) to rdi */ + movl $0,%esi /* arg2 = 0 */ + movl $2,%edx /* arg3 = 2 */ + call sigprocmask /* sigprocmask(jmp_buf, 0, 2) */ +1: jmp setjmp -- cgit v1.2.3