summaryrefslogtreecommitdiff
path: root/05/musl-0.6.0/src/signal
diff options
context:
space:
mode:
Diffstat (limited to '05/musl-0.6.0/src/signal')
-rw-r--r--05/musl-0.6.0/src/signal/getitimer.c12
-rw-r--r--05/musl-0.6.0/src/signal/i386/restore.s15
-rw-r--r--05/musl-0.6.0/src/signal/i386/sigsetjmp.s13
-rw-r--r--05/musl-0.6.0/src/signal/kill.c7
-rw-r--r--05/musl-0.6.0/src/signal/killpg.c11
-rw-r--r--05/musl-0.6.0/src/signal/raise.c7
-rw-r--r--05/musl-0.6.0/src/signal/restore.c0
-rw-r--r--05/musl-0.6.0/src/signal/setitimer.c15
-rw-r--r--05/musl-0.6.0/src/signal/sigaction.c45
-rw-r--r--05/musl-0.6.0/src/signal/sigaddset.c13
-rw-r--r--05/musl-0.6.0/src/signal/sigaltstack.c8
-rw-r--r--05/musl-0.6.0/src/signal/sigdelset.c13
-rw-r--r--05/musl-0.6.0/src/signal/sigemptyset.c8
-rw-r--r--05/musl-0.6.0/src/signal/sigfillset.c8
-rw-r--r--05/musl-0.6.0/src/signal/sighold.c11
-rw-r--r--05/musl-0.6.0/src/signal/sigignore.c12
-rw-r--r--05/musl-0.6.0/src/signal/siginterrupt.c13
-rw-r--r--05/musl-0.6.0/src/signal/sigismember.c12
-rw-r--r--05/musl-0.6.0/src/signal/siglongjmp.c12
-rw-r--r--05/musl-0.6.0/src/signal/signal.c16
-rw-r--r--05/musl-0.6.0/src/signal/sigpause.c11
-rw-r--r--05/musl-0.6.0/src/signal/sigpending.c7
-rw-r--r--05/musl-0.6.0/src/signal/sigprocmask.c23
-rw-r--r--05/musl-0.6.0/src/signal/sigqueue.c14
-rw-r--r--05/musl-0.6.0/src/signal/sigrelse.c11
-rw-r--r--05/musl-0.6.0/src/signal/sigrtmax.c4
-rw-r--r--05/musl-0.6.0/src/signal/sigrtmin.c4
-rw-r--r--05/musl-0.6.0/src/signal/sigset.c28
-rw-r--r--05/musl-0.6.0/src/signal/sigsetjmp.c17
-rw-r--r--05/musl-0.6.0/src/signal/sigsuspend.c7
-rw-r--r--05/musl-0.6.0/src/signal/sigtimedwait.c12
-rw-r--r--05/musl-0.6.0/src/signal/sigwait.c11
-rw-r--r--05/musl-0.6.0/src/signal/sigwaitinfo.c7
-rw-r--r--05/musl-0.6.0/src/signal/x86_64/restore.s11
-rw-r--r--05/musl-0.6.0/src/signal/x86_64/sigsetjmp.s11
35 files changed, 429 insertions, 0 deletions
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 <sys/time.h>
+#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 <signal.h>
+#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 <signal.h>
+#include <errno.h>
+
+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 <signal.h>
+#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
--- /dev/null
+++ b/05/musl-0.6.0/src/signal/restore.c
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 <sys/time.h>
+#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 <stdlib.h>
+#include <signal.h>
+#include <errno.h>
+#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 <signal.h>
+#include <errno.h>
+
+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 <signal.h>
+#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 <signal.h>
+#include <errno.h>
+
+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 <signal.h>
+#include <string.h>
+
+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 <signal.h>
+#include <string.h>
+
+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 <signal.h>
+#include <stdlib.h>
+
+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 <signal.h>
+#include <stdlib.h>
+
+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 <stdlib.h>
+#include <signal.h>
+
+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 <signal.h>
+#include <errno.h>
+
+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 <setjmp.h>
+#include <signal.h>
+#include <stdlib.h>
+
+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 <signal.h>
+#include <stddef.h>
+#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 <signal.h>
+#include <stdlib.h>
+
+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 <signal.h>
+#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 <signal.h>
+#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 <signal.h>
+#include <string.h>
+#include <unistd.h>
+#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 <signal.h>
+#include <stdlib.h>
+
+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 <signal.h>
+#include <stdlib.h>
+
+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 <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);
+}
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 <signal.h>
+#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 <signal.h>
+#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 <signal.h>
+#include <stddef.h>
+
+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 <signal.h>
+#include <stddef.h>
+
+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