diff options
Diffstat (limited to 'libc/sysdeps/linux')
-rw-r--r-- | libc/sysdeps/linux/alpha/bits/kernel_sigaction.h | 15 | ||||
-rw-r--r-- | libc/sysdeps/linux/alpha/bits/sigaction.h | 33 | ||||
-rw-r--r-- | libc/sysdeps/linux/avr32/sigaction.c | 42 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/__syscall_rt_sigaction.c | 4 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/bits/kernel_sigaction.h | 4 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/bits/sigaction.h | 42 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/bits/sigset.h | 25 | ||||
-rw-r--r-- | libc/sysdeps/linux/hppa/bits/kernel_sigaction.h | 15 | ||||
-rw-r--r-- | libc/sysdeps/linux/hppa/bits/sigaction.h | 33 | ||||
-rw-r--r-- | libc/sysdeps/linux/ia64/bits/sigaction.h | 33 | ||||
-rw-r--r-- | libc/sysdeps/linux/mips/bits/kernel_sigaction.h | 25 | ||||
-rw-r--r-- | libc/sysdeps/linux/mips/bits/sigaction.h | 41 | ||||
-rw-r--r-- | libc/sysdeps/linux/sparc/bits/sigaction.h | 36 | ||||
-rw-r--r-- | libc/sysdeps/linux/x86_64/sigaction.c | 89 | ||||
-rw-r--r-- | libc/sysdeps/linux/xtensa/sigaction.c | 47 |
15 files changed, 173 insertions, 311 deletions
diff --git a/libc/sysdeps/linux/alpha/bits/kernel_sigaction.h b/libc/sysdeps/linux/alpha/bits/kernel_sigaction.h index d111a5f3d..cd6b2133d 100644 --- a/libc/sysdeps/linux/alpha/bits/kernel_sigaction.h +++ b/libc/sysdeps/linux/alpha/bits/kernel_sigaction.h @@ -9,15 +9,12 @@ struct old_kernel_sigaction { unsigned int sa_flags; }; -/* This is the sigaction structure from the Linux 2.1.68 kernel. */ +/* In uclibc, userspace struct sigaction is identical to + * "new" struct kernel_sigaction (one from the Linux 2.1.68 kernel). + * See sigaction.h + */ -struct kernel_sigaction { - __sighandler_t k_sa_handler; - unsigned int sa_flags; - sigset_t sa_mask; -}; - -extern int __syscall_rt_sigaction (int, const struct kernel_sigaction *__unbounded, - struct kernel_sigaction *__unbounded, size_t) attribute_hidden; +extern int __syscall_rt_sigaction (int, const struct sigaction *, + struct sigaction *, size_t) attribute_hidden; #endif diff --git a/libc/sysdeps/linux/alpha/bits/sigaction.h b/libc/sysdeps/linux/alpha/bits/sigaction.h index 80feb2fa2..61dea1180 100644 --- a/libc/sysdeps/linux/alpha/bits/sigaction.h +++ b/libc/sysdeps/linux/alpha/bits/sigaction.h @@ -22,30 +22,21 @@ #endif /* Structure describing the action to be taken when a signal arrives. */ -struct sigaction - { - /* Signal handler. */ +struct sigaction { #ifdef __USE_POSIX199309 - union - { - /* Used if SA_SIGINFO is not set. */ - __sighandler_t sa_handler; - /* Used if SA_SIGINFO is set. */ - void (*sa_sigaction) (int, siginfo_t *, void *); - } - __sigaction_handler; -# define sa_handler __sigaction_handler.sa_handler -# define sa_sigaction __sigaction_handler.sa_sigaction + union { + __sighandler_t sa_handler; + void (*sa_sigaction)(int, siginfo_t *, void *); + } __sigaction_handler; +# define sa_handler __sigaction_handler.sa_handler +# define sa_sigaction __sigaction_handler.sa_sigaction #else - __sighandler_t sa_handler; + __sighandler_t sa_handler; #endif - - /* Additional set of signals to be blocked. */ - __sigset_t sa_mask; - - /* Special flags. */ - unsigned int sa_flags; - }; + unsigned sa_flags; + sigset_t sa_mask; + /* Alpha has no sa_restorer field. */ +}; /* Bits in `sa_flags'. */ #define SA_NOCLDSTOP 0x00000004 /* Don't send SIGCHLD when children stop. */ diff --git a/libc/sysdeps/linux/avr32/sigaction.c b/libc/sysdeps/linux/avr32/sigaction.c index 45d0abb5a..61530912e 100644 --- a/libc/sysdeps/linux/avr32/sigaction.c +++ b/libc/sysdeps/linux/avr32/sigaction.c @@ -14,54 +14,30 @@ #define SA_RESTORER 0x04000000 extern void __default_rt_sa_restorer(void); -/* Experimentally off - libc_hidden_proto(memcpy) */ - extern __typeof(sigaction) __libc_sigaction; /* * If act is not NULL, change the action for sig to *act. * If oact is not NULL, put the old action for sig in *oact. */ -int __libc_sigaction(int signum, const struct sigaction *act, - struct sigaction *oldact) +int __libc_sigaction(int sig, const struct sigaction *act, + struct sigaction *oact) { - struct kernel_sigaction kact, koact; - int result; - enum { - SIGSET_MIN_SIZE = sizeof(kact.sa_mask) < sizeof(act->sa_mask) - ? sizeof(kact.sa_mask) : sizeof(act->sa_mask) - }; + struct sigaction kact; - if (act) { - kact.k_sa_handler = act->sa_handler; - memcpy(&kact.sa_mask, &act->sa_mask, SIGSET_MIN_SIZE); - kact.sa_flags = act->sa_flags; - if (kact.sa_flags & SA_RESTORER) - kact.sa_restorer = act->sa_restorer; - else - kact.sa_restorer = __default_rt_sa_restorer; + if (act && !(act->sa_flags & SA_RESTORER)) { + memcpy(&kact, act, sizeof(kact)); + kact.sa_restorer = __default_rt_sa_restorer; kact.sa_flags |= SA_RESTORER; + act = &kact; } /* NB: kernel (as of 2.6.25) will return EINVAL - * if sizeof(kact.sa_mask) does not match kernel's sizeof(sigset_t) */ - result = __syscall_rt_sigaction(signum, - act ? __ptrvalue(&kact) : NULL, - oldact ? __ptrvalue(&koact) : NULL, - sizeof(kact.sa_mask)); - - if (oldact && result >= 0) { - oldact->sa_handler = koact.k_sa_handler; - memcpy(&oldact->sa_mask, &koact.sa_mask, SIGSET_MIN_SIZE); - oldact->sa_flags = koact.sa_flags; - oldact->sa_restorer = koact.sa_restorer; - } - - return result; + * if sizeof(act->sa_mask) does not match kernel's sizeof(sigset_t) */ + return __syscall_rt_sigaction(sig, act, oact, sizeof(act->sa_mask)); } #ifndef LIBC_SIGACTION -/* libc_hidden_proto(sigaction) */ weak_alias(__libc_sigaction, sigaction) libc_hidden_weak(sigaction) #endif diff --git a/libc/sysdeps/linux/common/__syscall_rt_sigaction.c b/libc/sysdeps/linux/common/__syscall_rt_sigaction.c index c3246b1bf..006b38a2a 100644 --- a/libc/sysdeps/linux/common/__syscall_rt_sigaction.c +++ b/libc/sysdeps/linux/common/__syscall_rt_sigaction.c @@ -11,7 +11,9 @@ #ifdef __NR_rt_sigaction #include <signal.h> -#include <bits/kernel_sigaction.h> + +int __syscall_rt_sigaction (int __signum, const struct sigaction *__act, + struct sigaction *__oldact, size_t __size); #define __NR___syscall_rt_sigaction __NR_rt_sigaction _syscall4(int, __syscall_rt_sigaction, int, signum, diff --git a/libc/sysdeps/linux/common/bits/kernel_sigaction.h b/libc/sysdeps/linux/common/bits/kernel_sigaction.h index f74e0a28a..0a35ac8cb 100644 --- a/libc/sysdeps/linux/common/bits/kernel_sigaction.h +++ b/libc/sysdeps/linux/common/bits/kernel_sigaction.h @@ -25,12 +25,12 @@ struct old_kernel_sigaction { */ extern int __syscall_sigaction(int, const struct old_kernel_sigaction *, - struct old_kernel_sigaction *) attribute_hidden; + struct old_kernel_sigaction *); #endif extern int __syscall_rt_sigaction(int, const struct sigaction *, - struct sigaction *, size_t) attribute_hidden; + struct sigaction *, size_t); #endif /* _BITS_SIGACTION_STRUCT_H */ diff --git a/libc/sysdeps/linux/common/bits/sigaction.h b/libc/sysdeps/linux/common/bits/sigaction.h index 48cc5312f..7489aa878 100644 --- a/libc/sysdeps/linux/common/bits/sigaction.h +++ b/libc/sysdeps/linux/common/bits/sigaction.h @@ -21,34 +21,26 @@ # error "Never include <bits/sigaction.h> directly; use <signal.h> instead." #endif -/* Structure describing the action to be taken when a signal arrives. */ -struct sigaction - { - /* Signal handler. */ +/* Structure describing the action to be taken when a signal arrives. + * In uclibc, it is identical to "new" struct kernel_sigaction + * (one from the Linux 2.1.68 kernel). + * This minimizes amount of translation in sigaction(). + */ +struct sigaction { #ifdef __USE_POSIX199309 - union - { - /* Used if SA_SIGINFO is not set. */ - __sighandler_t sa_handler; - /* Used if SA_SIGINFO is set. */ - void (*sa_sigaction) (int, siginfo_t *, void *); - } - __sigaction_handler; -# define sa_handler __sigaction_handler.sa_handler -# define sa_sigaction __sigaction_handler.sa_sigaction + union { + __sighandler_t sa_handler; + void (*sa_sigaction)(int, siginfo_t *, void *); + } __sigaction_handler; +# define sa_handler __sigaction_handler.sa_handler +# define sa_sigaction __sigaction_handler.sa_sigaction #else - __sighandler_t sa_handler; + __sighandler_t sa_handler; #endif - - /* Additional set of signals to be blocked. */ - __sigset_t sa_mask; - - /* Special flags. */ - int sa_flags; - - /* Restore handler. */ - void (*sa_restorer) (void); - }; + unsigned long sa_flags; + void (*sa_restorer)(void); + sigset_t sa_mask; +}; /* Bits in `sa_flags'. */ #define SA_NOCLDSTOP 1 /* Don't send SIGCHLD when children stop. */ diff --git a/libc/sysdeps/linux/common/bits/sigset.h b/libc/sysdeps/linux/common/bits/sigset.h index 75fa32604..2f67a4ebf 100644 --- a/libc/sysdeps/linux/common/bits/sigset.h +++ b/libc/sysdeps/linux/common/bits/sigset.h @@ -22,13 +22,24 @@ typedef int __sig_atomic_t; -/* A `sigset_t' has a bit for each signal. */ - -# define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int))) -typedef struct - { - unsigned long int __val[_SIGSET_NWORDS]; - } __sigset_t; +/* A 'sigset_t' has a bit for each signal. + * glibc has space for 1024 signals (!), but most arches supported + * by Linux have 64 signals, and only MIPS has 128. + * There seems to be some historical baggage in sparc[64] + * where they might have (or had in the past) 32 signals only, + * I hope it's irrelevant now. + * Signal 0 does not exist, so we have signals 1..64, not 0..63. + * In uclibc, kernel and userspace sigset_t is always the same. + * BTW, struct sigaction is also the same on kernel and userspace side. + */ +#if defined(__mips__) +# define _SIGSET_NWORDS (128 / (8 * sizeof (unsigned long))) +#else +# define _SIGSET_NWORDS (64 / (8 * sizeof (unsigned long))) +#endif +typedef struct { + unsigned long __val[_SIGSET_NWORDS]; +} __sigset_t; #endif diff --git a/libc/sysdeps/linux/hppa/bits/kernel_sigaction.h b/libc/sysdeps/linux/hppa/bits/kernel_sigaction.h index 4ae53fd3c..1c093a522 100644 --- a/libc/sysdeps/linux/hppa/bits/kernel_sigaction.h +++ b/libc/sysdeps/linux/hppa/bits/kernel_sigaction.h @@ -12,15 +12,12 @@ struct old_kernel_sigaction { unsigned long sa_flags; }; -/* This is the sigaction structure from the Linux 2.1.68 kernel. */ +/* In uclibc, userspace struct sigaction is identical to + * "new" struct kernel_sigaction (one from the Linux 2.1.68 kernel). + * See sigaction.h + */ -struct kernel_sigaction { - __sighandler_t k_sa_handler; - unsigned long sa_flags; - sigset_t sa_mask; -}; - -extern int __syscall_rt_sigaction (int, const struct kernel_sigaction *__unbounded, - struct kernel_sigaction *__unbounded, size_t) attribute_hidden; +extern int __syscall_rt_sigaction (int, const struct sigaction *, + struct sigaction *, size_t) attribute_hidden; #endif diff --git a/libc/sysdeps/linux/hppa/bits/sigaction.h b/libc/sysdeps/linux/hppa/bits/sigaction.h index 33f2b237b..3dac69e73 100644 --- a/libc/sysdeps/linux/hppa/bits/sigaction.h +++ b/libc/sysdeps/linux/hppa/bits/sigaction.h @@ -22,30 +22,21 @@ #endif /* Structure describing the action to be taken when a signal arrives. */ -struct sigaction - { - /* Signal handler. */ +struct sigaction { #ifdef __USE_POSIX199309 - union - { - /* Used if SA_SIGINFO is not set. */ - __sighandler_t sa_handler; - /* Used if SA_SIGINFO is set. */ - void (*sa_sigaction) (int, siginfo_t *, void *); - } - __sigaction_handler; -# define sa_handler __sigaction_handler.sa_handler -# define sa_sigaction __sigaction_handler.sa_sigaction + union { + __sighandler_t sa_handler; + void (*sa_sigaction)(int, siginfo_t *, void *); + } __sigaction_handler; +# define sa_handler __sigaction_handler.sa_handler +# define sa_sigaction __sigaction_handler.sa_sigaction #else - __sighandler_t sa_handler; + __sighandler_t sa_handler; #endif - - /* Special flags. */ - unsigned long int sa_flags; - - /* Additional set of signals to be blocked. */ - __sigset_t sa_mask; - }; + unsigned long sa_flags; + sigset_t sa_mask; + /* HPPA has no sa_restorer field. */ +}; /* Bits in `sa_flags'. */ diff --git a/libc/sysdeps/linux/ia64/bits/sigaction.h b/libc/sysdeps/linux/ia64/bits/sigaction.h index 11599d520..4049402c1 100644 --- a/libc/sysdeps/linux/ia64/bits/sigaction.h +++ b/libc/sysdeps/linux/ia64/bits/sigaction.h @@ -22,30 +22,21 @@ #endif /* Structure describing the action to be taken when a signal arrives. */ -struct sigaction - { - /* Signal handler. */ +struct sigaction { #ifdef __USE_POSIX199309 - union - { - /* Used if SA_SIGINFO is not set. */ - __sighandler_t sa_handler; - /* Used if SA_SIGINFO is set. */ - void (*sa_sigaction) (int, siginfo_t *, void *); - } - __sigaction_handler; -# define sa_handler __sigaction_handler.sa_handler -# define sa_sigaction __sigaction_handler.sa_sigaction + union { + __sighandler_t sa_handler; + void (*sa_sigaction)(int, siginfo_t *, void *); + } __sigaction_handler; +# define sa_handler __sigaction_handler.sa_handler +# define sa_sigaction __sigaction_handler.sa_sigaction #else - __sighandler_t sa_handler; + __sighandler_t sa_handler; #endif - - /* Special flags. */ - unsigned long int sa_flags; - - /* Additional set of signals to be blocked. */ - __sigset_t sa_mask; - }; + unsigned long sa_flags; + sigset_t sa_mask; + /* IA64 has no sa_restorer field. */ +}; /* Bits in `sa_flags'. */ #define SA_NOCLDSTOP 0x00000001 /* Don't send SIGCHLD when children stop. */ diff --git a/libc/sysdeps/linux/mips/bits/kernel_sigaction.h b/libc/sysdeps/linux/mips/bits/kernel_sigaction.h index 5c8454837..2048095c8 100644 --- a/libc/sysdeps/linux/mips/bits/kernel_sigaction.h +++ b/libc/sysdeps/linux/mips/bits/kernel_sigaction.h @@ -24,25 +24,12 @@ struct old_kernel_sigaction { #endif }; +/* In uclibc, userspace struct sigaction is identical to + * "new" struct kernel_sigaction (one from the Linux 2.1.68 kernel). + * See sigaction.h + */ -#define _KERNEL_NSIG 128 -#define _KERNEL_NSIG_BPW _MIPS_SZLONG -#define _KERNEL_NSIG_WORDS (_KERNEL_NSIG / _KERNEL_NSIG_BPW) - -typedef struct { - unsigned long sig[_KERNEL_NSIG_WORDS]; -} kernel_sigset_t; - -/* This is the sigaction structure from the Linux 2.1.68 kernel. */ -struct kernel_sigaction { - unsigned int sa_flags; - __sighandler_t k_sa_handler; - kernel_sigset_t sa_mask; - void (*sa_restorer)(void); - int s_resv[1]; /* reserved */ -}; - -extern int __syscall_rt_sigaction (int, const struct kernel_sigaction *__unbounded, - struct kernel_sigaction *__unbounded, size_t) attribute_hidden; +extern int __syscall_rt_sigaction (int, const struct sigaction *, + struct sigaction *, size_t) attribute_hidden; #endif diff --git a/libc/sysdeps/linux/mips/bits/sigaction.h b/libc/sysdeps/linux/mips/bits/sigaction.h index d04e25f76..cc689d149 100644 --- a/libc/sysdeps/linux/mips/bits/sigaction.h +++ b/libc/sysdeps/linux/mips/bits/sigaction.h @@ -23,37 +23,22 @@ #endif /* Structure describing the action to be taken when a signal arrives. */ -struct sigaction - { - /* Special flags. */ - unsigned int sa_flags; - - /* Signal handler. */ +struct sigaction { + unsigned sa_flags; #ifdef __USE_POSIX199309 - union - { - /* Used if SA_SIGINFO is not set. */ - __sighandler_t sa_handler; - /* Used if SA_SIGINFO is set. */ - void (*sa_sigaction) (int, siginfo_t *, void *); - } - __sigaction_handler; -# define sa_handler __sigaction_handler.sa_handler -# define sa_sigaction __sigaction_handler.sa_sigaction + union { + __sighandler_t sa_handler; + void (*sa_sigaction)(int, siginfo_t *, void *); + } __sigaction_handler; +# define sa_handler __sigaction_handler.sa_handler +# define sa_sigaction __sigaction_handler.sa_sigaction #else - __sighandler_t sa_handler; -#endif - /* Additional set of signals to be blocked. */ - __sigset_t sa_mask; - - /* The ABI says here are two unused ints following. */ - /* Restore handler. */ - void (*sa_restorer) (void); - -#if _MIPS_SZPTR < 64 - int sa_resv[1]; + __sighandler_t sa_handler; #endif - }; + sigset_t sa_mask; + void (*sa_restorer)(void); + /*int s_resv[1]; - reserved [deleted in uclibc] */ +}; /* Bits in `sa_flags'. */ /* Please note that some Linux kernels versions use different values for these diff --git a/libc/sysdeps/linux/sparc/bits/sigaction.h b/libc/sysdeps/linux/sparc/bits/sigaction.h index ee4196764..be9bc028a 100644 --- a/libc/sysdeps/linux/sparc/bits/sigaction.h +++ b/libc/sysdeps/linux/sparc/bits/sigaction.h @@ -22,33 +22,21 @@ #endif /* Structure describing the action to be taken when a signal arrives. */ -struct sigaction - { - /* Signal handler. */ +struct sigaction { #ifdef __USE_POSIX199309 - union - { - /* Used if SA_SIGINFO is not set. */ - __sighandler_t sa_handler; - /* Used if SA_SIGINFO is set. */ - void (*sa_sigaction) (int, siginfo_t *, void *); - } - __sigaction_handler; -# define sa_handler __sigaction_handler.sa_handler -# define sa_sigaction __sigaction_handler.sa_sigaction + union { + __sighandler_t sa_handler; + void (*sa_sigaction)(int, siginfo_t *, void *); + } __sigaction_handler; +# define sa_handler __sigaction_handler.sa_handler +# define sa_sigaction __sigaction_handler.sa_sigaction #else - __sighandler_t sa_handler; + __sighandler_t sa_handler; #endif - - /* Additional set of signals to be blocked. */ - __sigset_t sa_mask; - - /* Special flags. */ - unsigned long sa_flags; - - /* Not used by Linux/Sparc yet. */ - void (*sa_restorer) (void); - }; + unsigned long sa_flags; + void (*sa_restorer)(void); + sigset_t sa_mask; +}; /* Bits in `sa_flags'. */ diff --git a/libc/sysdeps/linux/x86_64/sigaction.c b/libc/sysdeps/linux/x86_64/sigaction.c index e53e30442..d1adbc4be 100644 --- a/libc/sysdeps/linux/x86_64/sigaction.c +++ b/libc/sysdeps/linux/x86_64/sigaction.c @@ -25,9 +25,6 @@ #include <sys/syscall.h> -/* The difference here is that the sigaction structure used in the - kernel is not the same as we use in the libc. Therefore we must - translate it here. */ #include <bits/kernel_sigaction.h> /* We do not globally define the SA_RESTORER flag so do it here. */ @@ -35,64 +32,47 @@ extern __typeof(sigaction) __libc_sigaction; + #ifdef __NR_rt_sigaction + /* Using the hidden attribute here does not change the code but it helps to avoid warnings. */ -extern void restore_rt (void) __asm__ ("__restore_rt") attribute_hidden; -extern void restore (void) __asm__ ("__restore") attribute_hidden; - -/* Experimentally off - libc_hidden_proto(memcpy) */ +extern void restore_rt(void) __asm__ ("__restore_rt") attribute_hidden; +extern void restore(void) __asm__ ("__restore") attribute_hidden; /* If ACT is not NULL, change the action for SIG to *ACT. If OACT is not NULL, put the old action for SIG in *OACT. */ int -__libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact) +__libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact) { - int result; - struct kernel_sigaction kact, koact; - enum { - SIGSET_MIN_SIZE = sizeof(kact.sa_mask) < sizeof(act->sa_mask) - ? sizeof(kact.sa_mask) : sizeof(act->sa_mask) - }; + struct sigaction kact; if (act) { - kact.k_sa_handler = act->sa_handler; - memcpy (&kact.sa_mask, &act->sa_mask, SIGSET_MIN_SIZE); - kact.sa_flags = act->sa_flags | SA_RESTORER; - + memcpy(&kact, act, sizeof(kact)); + kact.sa_flags |= SA_RESTORER; kact.sa_restorer = &restore_rt; + act = &kact; } - /* NB: kernel (as of 2.6.25) will return EINVAL - * if sizeof(kact.sa_mask) does not match kernel's sizeof(sigset_t) */ - result = INLINE_SYSCALL (rt_sigaction, 4, sig, - act ? __ptrvalue (&kact) : NULL, - oact ? __ptrvalue (&koact) : NULL, - sizeof(kact.sa_mask)); - - if (oact && result >= 0) { - oact->sa_handler = koact.k_sa_handler; - memcpy (&oact->sa_mask, &koact.sa_mask, SIGSET_MIN_SIZE); - oact->sa_flags = koact.sa_flags; - oact->sa_restorer = koact.sa_restorer; - } - return result; + * if sizeof(act->sa_mask) does not match kernel's sizeof(sigset_t) */ + return INLINE_SYSCALL(rt_sigaction, 4, sig, act, oact, sizeof(act->sa_mask)); } + #else -extern void restore (void) __asm__ ("__restore") attribute_hidden; +extern void restore(void) __asm__ ("__restore") attribute_hidden; /* If ACT is not NULL, change the action for SIG to *ACT. If OACT is not NULL, put the old action for SIG in *OACT. */ int -__libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact) +__libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact) { int result; struct old_kernel_sigaction kact, koact; #ifdef SIGCANCEL if (sig == SIGCANCEL) { - __set_errno (EINVAL); + __set_errno(EINVAL); return -1; } #endif @@ -103,18 +83,16 @@ __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact) kact.sa_flags = act->sa_flags | SA_RESTORER; kact.sa_restorer = &restore; } - - __asm__ __volatile__ ("syscall\n" - : "=a" (result) - : "0" (__NR_sigaction), "mr" (sig), - "c" (act ? __ptrvalue (&kact) : 0), - "d" (oact ? __ptrvalue (&koact) : 0)); - + __asm__ __volatile__ ( + "syscall\n" + : "=a" (result) + : "0" (__NR_sigaction), "mr" (sig), + "c" (act ? &kact : NULL), + "d" (oact ? &koact : NULL)); if (result < 0) { __set_errno(-result); return -1; } - if (oact) { oact->sa_handler = koact.k_sa_handler; oact->sa_mask.__val[0] = koact.sa_mask; @@ -123,14 +101,16 @@ __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact) } return result; } + #endif + #ifndef LIBC_SIGACTION -/* libc_hidden_proto(sigaction) */ weak_alias(__libc_sigaction,sigaction) libc_hidden_weak(sigaction) #endif + /* NOTE: Please think twice before making any changes to the bits of code below. GDB needs some intimate knowledge about it to recognize them as signal trampolines, and make backtraces through @@ -139,18 +119,19 @@ libc_hidden_weak(sigaction) If you ever feel the need to make any changes, please notify the appropriate GDB maintainer. */ -#define RESTORE(name, syscall) RESTORE2 (name, syscall) -# define RESTORE2(name, syscall) \ -__asm__ ( \ - ".text\n" \ - "__" #name ":\n" \ - " movq $" #syscall ", %rax\n" \ - " syscall\n" \ - ); +#define RESTORE(name, syscall) RESTORE2(name, syscall) +#define RESTORE2(name, syscall) \ +__asm__ ( \ + ".text\n" \ + "__" #name ":\n" \ + " movq $" #syscall ", %rax\n" \ + " syscall\n" \ +); + #ifdef __NR_rt_sigaction /* The return code for realtime-signals. */ -RESTORE (restore_rt, __NR_rt_sigreturn) +RESTORE(restore_rt, __NR_rt_sigreturn) #endif #ifdef __NR_sigreturn -RESTORE (restore, __NR_sigreturn) +RESTORE(restore, __NR_sigreturn) #endif diff --git a/libc/sysdeps/linux/xtensa/sigaction.c b/libc/sysdeps/linux/xtensa/sigaction.c index f5425e76a..302d13305 100644 --- a/libc/sysdeps/linux/xtensa/sigaction.c +++ b/libc/sysdeps/linux/xtensa/sigaction.c @@ -15,52 +15,25 @@ #define SA_RESTORER 0x04000000 -extern void __default_sa_restorer (void); +extern void __default_sa_restorer(void); -/* Experimentally off - libc_hidden_proto(memcpy) */ - -int __libc_sigaction (int signum, const struct sigaction *act, +int __libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact) { - struct kernel_sigaction kact, koact; - int result; - enum { - SIGSET_MIN_SIZE = sizeof(kact.sa_mask) < sizeof(act->sa_mask) - ? sizeof(kact.sa_mask) : sizeof(act->sa_mask) - }; - - if (act) { - kact.k_sa_handler = act->sa_handler; - memcpy(&kact.sa_mask, &act->sa_mask, SIGSET_MIN_SIZE); - kact.sa_flags = act->sa_flags; + struct sigaction kact; - if (kact.sa_flags & SA_RESTORER) { - kact.sa_restorer = act->sa_restorer; - } else { - kact.sa_restorer = __default_sa_restorer; - kact.sa_flags |= SA_RESTORER; - } + if (act && !(act->sa_flags & SA_RESTORER)) { + memcpy(&kact, act, sizeof(kact)); + kact.sa_restorer = __default_sa_restorer; + kact.sa_flags |= SA_RESTORER; + act = &kact; } - /* NB: kernel (as of 2.6.25) will return EINVAL - * if sizeof(kact.sa_mask) does not match kernel's sizeof(sigset_t) */ - result = __syscall_rt_sigaction(signum, - act ? __ptrvalue (&kact) : NULL, - oact ? __ptrvalue (&koact) : NULL, - sizeof(kact.sa_mask)); - - if (oact && result >= 0) { - oact->sa_handler = koact.k_sa_handler; - memcpy(&oact->sa_mask, &koact.sa_mask, SIGSET_MIN_SIZE); - oact->sa_flags = koact.sa_flags; - oact->sa_restorer = koact.sa_restorer; - } - - return result; + * if sizeof(act->sa_mask) does not match kernel's sizeof(sigset_t) */ + return __syscall_rt_sigaction(sig, act, oact, sizeof(act->sa_mask)); } #ifndef LIBC_SIGACTION -libc_hidden_proto(sigaction) weak_alias(__libc_sigaction, sigaction) libc_hidden_weak(sigaction) #endif |