On Tue, Dec 23, 2008 at 12:49 AM, Denys Vlasenko
<[email protected]> wrote:
> Hi Carmelo, Kraj,
>
> Well, uClibc-nptl does not compile for me even before my patch.
> I have two different .config's failing. See attached.
>
> Can you fix these failures?
Thanks for fixing it!
I merged a few more changes from trunk. I compile-tested them on i386.
The attached patch contains sigaction changes. It was giving you
troubles IIRC. On trunk, i386 build, it works for me,
and I just verified that on nptl attached patch at least compiles on i386.
I did not apply it to nptl branch.
O would like to ask you to test whether current nptl branch works for you
on whatever architecture you are using it, and if yes (hopefully
I did not broke it yet :), apply sigaction.diff from this email
and let me know whether it breaks your world.
NB: you will need to rebuild everything, not only libs.
This change is not binary-compatible, old programs
won't work against newly compiled libraries because
sigset_t and struct sigaction have changed their sizes and layout.
Object file size changes:
text data bss dec hex filename
- 567097 2791 16304 586192 8f1d0 lib/libuClibc-0.9.30-svn.so
+ 566654 2787 16184 585625 8ef99 lib/libuClibc-0.9.30-svn.so
- 41921 3456 24736 70113 111e1 lib/libpthread-0.9.30-svn.so
+ 41514 3264 24736 69514 10f8a lib/libpthread-0.9.30-svn.so
- 1547 37 2 1586 632 libc/misc/syslog/syslog.os
+ 1545 37 2 1584 630 libc/misc/syslog/syslog.os
- 548 4 24 576 240 libc/pwd_grp/lckpwdf.os
+ 518 4 24 546 222 libc/pwd_grp/lckpwdf.os
- 38 0 0 38 26 libc/signal/sigandset.os
+ 32 0 0 32 20 libc/signal/sigandset.os
- 65 0 0 65 41 libc/signal/sigblock.os
+ 44 0 0 44 2c libc/signal/sigblock.os
- 24 0 0 24 18 libc/signal/sigempty.os
+ 20 0 0 20 14 libc/signal/sigempty.os
- 24 0 0 24 18 libc/signal/sigfillset.os
+ 20 0 0 20 14 libc/signal/sigfillset.os
- 72 0 0 72 48 libc/signal/sighold.os
+ 63 0 0 63 3f libc/signal/sighold.os
- 58 0 0 58 3a libc/signal/sigignore.os
+ 45 0 0 45 2d libc/signal/sigignore.os
- 140 0 0 140 8c libc/signal/sigintr.os
+ 122 0 0 122 7a libc/signal/sigintr.os
- 32 0 0 32 20 libc/signal/sigisempty.os
+ 16 0 0 16 10 libc/signal/sigisempty.os
- 185 0 0 185 b9 libc/signal/signal.os
+ 158 0 0 158 9e libc/signal/signal.os
- 38 0 0 38 26 libc/signal/sigorset.os
+ 32 0 0 32 20 libc/signal/sigorset.os
- 135 0 0 135 87 libc/signal/sigpause.os
+ 108 0 0 108 6c libc/signal/sigpause.os
- 72 0 0 72 48 libc/signal/sigrelse.os
+ 63 0 0 63 3f libc/signal/sigrelse.os
- 65 0 0 65 41 libc/signal/sigsetmask.os
+ 44 0 0 44 2c libc/signal/sigsetmask.os
- 235 0 0 235 eb libc/signal/sigset.os
+ 197 0 0 197 c5 libc/signal/sigset.os
- 130 0 0 130 82 libc/signal/sysv_signal.os
+ 106 0 0 106 6a libc/signal/sysv_signal.os
- 250 24 1 275 113 libc/stdlib/abort.os
+ 233 24 1 258 102 libc/stdlib/abort.os
- 56 0 0 56 38
libc/sysdeps/linux/common/pause.os
+ 47 0 0 47 2f
libc/sysdeps/linux/common/pause.os
- 162 0 0 162 a2
libc/sysdeps/linux/common/pselect.os
+ 129 0 0 129 81
libc/sysdeps/linux/common/pselect.os
- 140 0 0 140 8c
libc/sysdeps/linux/i386/sigaction.os
+ 111 0 0 111 6f
libc/sysdeps/linux/i386/sigaction.os
- 324 0 0 324 144 libc/unistd/sleep.os
+ 268 0 0 268 10c libc/unistd/sleep.os
- 1302 0 0 1302 516 libpthread/linuxthreads/join.os
+ 1227 0 0 1227 4cb libpthread/linuxthreads/join.os
- 1302 0 0 1302 516 libpthread/linuxthreads/join.oS
+ 1227 0 0 1227 4cb libpthread/linuxthreads/join.oS
- 3151 4 16 3171 c63
libpthread/linuxthreads/manager.os
+ 3149 4 16 3169 c61
libpthread/linuxthreads/manager.os
- 3151 4 16 3171 c63
libpthread/linuxthreads/manager.oS
+ 3149 4 16 3169 c61
libpthread/linuxthreads/manager.oS
- 3523 2256 12 5791 169f
libpthread/linuxthreads/pthread.os
+ 3377 2064 12 5453 154d
libpthread/linuxthreads/pthread.os
- 3527 2256 12 5795 16a3
libpthread/linuxthreads/pthread.oS
+ 3381 2064 12 5457 1551
libpthread/linuxthreads/pthread.oS
- 1740 0 0 1740 6cc
libpthread/linuxthreads/semaphore.os
+ 1728 0 0 1728 6c0
libpthread/linuxthreads/semaphore.os
- 1740 0 0 1740 6cc
libpthread/linuxthreads/semaphore.oS
+ 1728 0 0 1728 6c0
libpthread/linuxthreads/semaphore.oS
- 1265 260 0 1525 5f5
libpthread/linuxthreads/signals.os
+ 1118 260 0 1378 562
libpthread/linuxthreads/signals.os
- 1265 260 0 1525 5f5
libpthread/linuxthreads/signals.oS
+ 1118 260 0 1378 562
libpthread/linuxthreads/signals.oS
- 1167 0 8216 9383 24a7
libpthread/linuxthreads/specific.os
+ 1144 0 8216 9360 2490
libpthread/linuxthreads/specific.os
- 1167 0 8216 9383 24a7
libpthread/linuxthreads/specific.oS
+ 1144 0 8216 9360 2490
libpthread/linuxthreads/specific.oS
--
vda
diff -urpN uClibc-nptl.4/libc/signal/sigaction.c uClibc/libc/signal/sigaction.c
--- uClibc-nptl.4/libc/signal/sigaction.c 2008-12-23 11:23:39.000000000 +0100
+++ uClibc/libc/signal/sigaction.c 2008-12-19 01:21:46.000000000 +0100
@@ -20,55 +20,30 @@
#include <errno.h>
#include <signal.h>
#include <string.h>
-
#include <sys/syscall.h>
-/* Experimentally off - libc_hidden_proto(memcpy) */
-
-/* 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>
#ifndef LIBC_SIGACTION
extern __typeof(sigaction) __libc_sigaction;
#endif
+
#if defined __NR_rt_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 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;
-
- if (act) {
- kact.k_sa_handler = act->sa_handler;
- memcpy (&kact.sa_mask, &act->sa_mask, sizeof (sigset_t));
- kact.sa_flags = act->sa_flags;
-# ifdef HAVE_SA_RESTORER
- kact.sa_restorer = act->sa_restorer;
-# endif
- }
-
- /* XXX The size argument hopefully will have to be changed to the
- real size of the user-level sigset_t. */
- result = __syscall_rt_sigaction(sig,
- act ? __ptrvalue (&kact) : NULL,
- oact ? __ptrvalue (&koact) : NULL, _NSIG / 8);
-
- if (oact && result >= 0) {
- oact->sa_handler = koact.k_sa_handler;
- memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (sigset_t));
- oact->sa_flags = koact.sa_flags;
-# ifdef HAVE_SA_RESTORER
- oact->sa_restorer = koact.sa_restorer;
-# endif
- }
-
- return result;
+ /* NB: kernel (as of 2.6.25) will return EINVAL
+ * if sizeof(act->sa_mask) does not match kernel's sizeof(sigset_t).
+ * Try to catch this problem at uclibc build time: */
+ struct BUG_sigset_size {
+ int BUG_sigset_size
+ [sizeof(act->sa_mask) != _NSIG / 8 ? 1 : -1];
+ };
+ return __syscall_rt_sigaction(sig, act, oact, sizeof(act->sa_mask));
}
#else
@@ -76,7 +51,7 @@ __libc_sigaction (int sig, const struct
/* 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;
@@ -89,11 +64,9 @@ __libc_sigaction (int sig, const struct
kact.sa_restorer = act->sa_restorer;
# endif
}
-
result = __syscall_sigaction(sig,
- act ? __ptrvalue (&kact) : NULL,
- oact ? __ptrvalue (&koact) : NULL);
-
+ act ? &kact : NULL,
+ oact ? &koact : NULL);
if (oact && result >= 0) {
oact->sa_handler = koact.k_sa_handler;
oact->sa_mask.__val[0] = koact.sa_mask;
@@ -102,14 +75,13 @@ __libc_sigaction (int sig, const struct
oact->sa_restorer = koact.sa_restorer;
# endif
}
-
return result;
}
#endif
+
#ifndef LIBC_SIGACTION
-libc_hidden_proto(sigaction)
weak_alias(__libc_sigaction,sigaction)
libc_hidden_weak(sigaction)
#endif
diff -urpN uClibc-nptl.4/libc/sysdeps/linux/alpha/bits/kernel_sigaction.h uClibc/libc/sysdeps/linux/alpha/bits/kernel_sigaction.h
--- uClibc-nptl.4/libc/sysdeps/linux/alpha/bits/kernel_sigaction.h 2008-12-23 11:23:33.000000000 +0100
+++ uClibc/libc/sysdeps/linux/alpha/bits/kernel_sigaction.h 2008-12-19 01:21:43.000000000 +0100
@@ -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 -urpN uClibc-nptl.4/libc/sysdeps/linux/alpha/bits/sigaction.h uClibc/libc/sysdeps/linux/alpha/bits/sigaction.h
--- uClibc-nptl.4/libc/sysdeps/linux/alpha/bits/sigaction.h 2008-12-23 11:23:33.000000000 +0100
+++ uClibc/libc/sysdeps/linux/alpha/bits/sigaction.h 2008-12-19 01:21:43.000000000 +0100
@@ -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 -urpN uClibc-nptl.4/libc/sysdeps/linux/arm/sigaction.c uClibc/libc/sysdeps/linux/arm/sigaction.c
--- uClibc-nptl.4/libc/sysdeps/linux/arm/sigaction.c 2008-12-23 11:23:33.000000000 +0100
+++ uClibc/libc/sysdeps/linux/arm/sigaction.c 2008-12-19 01:21:43.000000000 +0100
@@ -34,93 +34,68 @@ extern __typeof(sigaction) __libc_sigact
/* When RT signals are in use we need to use a different return stub. */
#ifdef __NR_rt_sigreturn
#define choose_restorer(flags) \
- (flags & SA_SIGINFO) ? __default_rt_sa_restorer \
- : __default_sa_restorer
+ (flags & SA_SIGINFO) ? __default_rt_sa_restorer \
+ : __default_sa_restorer
#else
#define choose_restorer(flags) \
- __default_sa_restorer
+ __default_sa_restorer
#endif
-#ifdef __NR_rt_sigaction
-/* Experimentally off - libc_hidden_proto(memcpy) */
+#ifdef __NR_rt_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 sig, const struct sigaction *act, struct sigaction *oact)
+int __libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
{
- int result;
- struct kernel_sigaction kact, koact;
-
- if (act) {
- kact.k_sa_handler = act->sa_handler;
- memcpy (&kact.sa_mask, &act->sa_mask, sizeof (sigset_t));
- kact.sa_flags = act->sa_flags;
-# ifdef HAVE_SA_RESTORER
- if (kact.sa_flags & SA_RESTORER) {
- kact.sa_restorer = act->sa_restorer;
- } else {
- kact.sa_restorer = choose_restorer (kact.sa_flags);
- kact.sa_flags |= SA_RESTORER;
+ struct sigaction kact;
+ if (act && !(act->sa_flags & SA_RESTORER)) {
+ memcpy(&kact, act, sizeof(kact));
+ kact.sa_restorer = choose_restorer(kact.sa_flags);
+ kact.sa_flags |= SA_RESTORER;
+ act = &kact;
}
-# endif
- }
-
- /* XXX The size argument hopefully will have to be changed to the
- real size of the user-level sigset_t. */
- result = __syscall_rt_sigaction(sig, act ? __ptrvalue (&kact) : NULL,
- oact ? __ptrvalue (&koact) : NULL, _NSIG / 8);
- if (oact && result >= 0) {
- oact->sa_handler = koact.k_sa_handler;
- memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (sigset_t));
- oact->sa_flags = koact.sa_flags;
-# ifdef HAVE_SA_RESTORER
- oact->sa_restorer = koact.sa_restorer;
-# endif
- }
- return result;
+ /* NB: kernel (as of 2.6.25) will return EINVAL
+ * if sizeof(act->sa_mask) does not match kernel's sizeof(sigset_t) */
+ return __syscall_rt_sigaction(sig, act, oact, sizeof(act->sa_mask));
}
-
#else
/* 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)
+int __libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
{
- int result;
- struct old_kernel_sigaction kact, koact;
+ int result;
+ struct old_kernel_sigaction kact, koact;
- if (act) {
- kact.k_sa_handler = act->sa_handler;
- kact.sa_mask = act->sa_mask.__val[0];
- kact.sa_flags = act->sa_flags;
-# ifdef HAVE_SA_RESTORER
- if (kact.sa_flags & SA_RESTORER) {
- kact.sa_restorer = act->sa_restorer;
- } else {
- kact.sa_restorer = choose_restorer (kact.sa_flags);
- kact.sa_flags |= SA_RESTORER;
+ if (act) {
+ kact.k_sa_handler = act->sa_handler;
+ kact.sa_mask = act->sa_mask.__val[0];
+ kact.sa_flags = act->sa_flags;
+ if (kact.sa_flags & SA_RESTORER) {
+ kact.sa_restorer = act->sa_restorer;
+ } else {
+ kact.sa_restorer = choose_restorer(kact.sa_flags);
+ kact.sa_flags |= SA_RESTORER;
+ }
+ }
+ result = __syscall_sigaction(sig,
+ act ? &kact : NULL,
+ oact ? &koact : NULL);
+ if (oact && result >= 0) {
+ oact->sa_handler = koact.k_sa_handler;
+ oact->sa_mask.__val[0] = koact.sa_mask;
+ oact->sa_flags = koact.sa_flags;
+ oact->sa_restorer = koact.sa_restorer;
}
-# endif
- }
- result = __syscall_sigaction(sig, act ? __ptrvalue (&kact) : NULL,
- oact ? __ptrvalue (&koact) : NULL);
- if (oact && result >= 0) {
- oact->sa_handler = koact.k_sa_handler;
- oact->sa_mask.__val[0] = koact.sa_mask;
- oact->sa_flags = koact.sa_flags;
-# ifdef HAVE_SA_RESTORER
- oact->sa_restorer = koact.sa_restorer;
-# endif
- }
- return result;
+ return result;
}
#endif
+
#ifndef LIBC_SIGACTION
-/* libc_hidden_proto(sigaction) */
weak_alias(__libc_sigaction,sigaction)
libc_hidden_weak(sigaction)
#endif
diff -urpN uClibc-nptl.4/libc/sysdeps/linux/avr32/sigaction.c uClibc/libc/sysdeps/linux/avr32/sigaction.c
--- uClibc-nptl.4/libc/sysdeps/linux/avr32/sigaction.c 2008-12-23 11:23:34.000000000 +0100
+++ uClibc/libc/sysdeps/linux/avr32/sigaction.c 2008-12-19 01:21:44.000000000 +0100
@@ -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 -urpN uClibc-nptl.4/libc/sysdeps/linux/common/bits/sigaction.h uClibc/libc/sysdeps/linux/common/bits/sigaction.h
--- uClibc-nptl.4/libc/sysdeps/linux/common/bits/sigaction.h 2008-12-23 11:23:34.000000000 +0100
+++ uClibc/libc/sysdeps/linux/common/bits/sigaction.h 2008-12-19 01:21:43.000000000 +0100
@@ -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 -urpN uClibc-nptl.4/libc/sysdeps/linux/common/bits/sigset.h uClibc/libc/sysdeps/linux/common/bits/sigset.h
--- uClibc-nptl.4/libc/sysdeps/linux/common/bits/sigset.h 2008-12-23 11:23:34.000000000 +0100
+++ uClibc/libc/sysdeps/linux/common/bits/sigset.h 2008-12-19 01:21:43.000000000 +0100
@@ -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 -urpN uClibc-nptl.4/libc/sysdeps/linux/common/__syscall_rt_sigaction.c uClibc/libc/sysdeps/linux/common/__syscall_rt_sigaction.c
--- uClibc-nptl.4/libc/sysdeps/linux/common/__syscall_rt_sigaction.c 2008-12-23 11:23:34.000000000 +0100
+++ uClibc/libc/sysdeps/linux/common/__syscall_rt_sigaction.c 2008-12-19 01:21:43.000000000 +0100
@@ -11,8 +11,8 @@
#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) attribute_hidden;
#define __NR___syscall_rt_sigaction __NR_rt_sigaction
_syscall4(int, __syscall_rt_sigaction, int, signum,
const struct sigaction *, act, struct sigaction *, oldact,
diff -urpN uClibc-nptl.4/libc/sysdeps/linux/hppa/bits/kernel_sigaction.h uClibc/libc/sysdeps/linux/hppa/bits/kernel_sigaction.h
--- uClibc-nptl.4/libc/sysdeps/linux/hppa/bits/kernel_sigaction.h 2008-12-23 11:23:34.000000000 +0100
+++ uClibc/libc/sysdeps/linux/hppa/bits/kernel_sigaction.h 2008-12-19 01:21:43.000000000 +0100
@@ -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 -urpN uClibc-nptl.4/libc/sysdeps/linux/hppa/bits/sigaction.h uClibc/libc/sysdeps/linux/hppa/bits/sigaction.h
--- uClibc-nptl.4/libc/sysdeps/linux/hppa/bits/sigaction.h 2008-12-23 11:23:34.000000000 +0100
+++ uClibc/libc/sysdeps/linux/hppa/bits/sigaction.h 2008-12-19 01:21:43.000000000 +0100
@@ -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 -urpN uClibc-nptl.4/libc/sysdeps/linux/ia64/bits/sigaction.h uClibc/libc/sysdeps/linux/ia64/bits/sigaction.h
--- uClibc-nptl.4/libc/sysdeps/linux/ia64/bits/sigaction.h 2008-12-23 11:23:35.000000000 +0100
+++ uClibc/libc/sysdeps/linux/ia64/bits/sigaction.h 2008-12-19 01:21:44.000000000 +0100
@@ -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 -urpN uClibc-nptl.4/libc/sysdeps/linux/mips/bits/kernel_sigaction.h uClibc/libc/sysdeps/linux/mips/bits/kernel_sigaction.h
--- uClibc-nptl.4/libc/sysdeps/linux/mips/bits/kernel_sigaction.h 2008-12-23 11:23:35.000000000 +0100
+++ uClibc/libc/sysdeps/linux/mips/bits/kernel_sigaction.h 2008-12-19 01:21:44.000000000 +0100
@@ -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 -urpN uClibc-nptl.4/libc/sysdeps/linux/mips/bits/sigaction.h uClibc/libc/sysdeps/linux/mips/bits/sigaction.h
--- uClibc-nptl.4/libc/sysdeps/linux/mips/bits/sigaction.h 2008-12-23 11:23:35.000000000 +0100
+++ uClibc/libc/sysdeps/linux/mips/bits/sigaction.h 2008-12-19 01:21:44.000000000 +0100
@@ -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 -urpN uClibc-nptl.4/libc/sysdeps/linux/mips/sigaction.c uClibc/libc/sysdeps/linux/mips/sigaction.c
--- uClibc-nptl.4/libc/sysdeps/linux/mips/sigaction.c 2008-12-23 11:23:35.000000000 +0100
+++ uClibc/libc/sysdeps/linux/mips/sigaction.c 2008-12-19 01:21:44.000000000 +0100
@@ -29,113 +29,82 @@
extern __typeof(sigaction) __libc_sigaction;
-#ifdef __NR_rt_sigaction
-
-/* Experimentally off - libc_hidden_proto(memcpy) */
-#if _MIPS_SIM != _ABIO32
+#ifdef __NR_rt_sigaction
-# ifdef __NR_rt_sigreturn
-static void restore_rt (void) __asm__ ("__restore_rt");
+# if _MIPS_SIM != _ABIO32
+# ifdef __NR_rt_sigreturn
+static void restore_rt(void) __asm__ ("__restore_rt");
+# endif
+# ifdef __NR_sigreturn
+static void restore(void) __asm__ ("__restore");
+# endif
# endif
-# ifdef __NR_sigreturn
-static void restore (void) __asm__ ("__restore");
+
+/* 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)
+{
+# if _MIPS_SIM != _ABIO32
+ struct sigaction kact;
+ if (act) {
+ memcpy(&kact, act, sizeof(kact));
+ kact.sa_restorer = &restore_rt;
+ act = &kact;
+ }
# endif
-#endif
+
+ /* NB: kernel (as of 2.6.25) will return EINVAL
+ * if sizeof(act->sa_mask) does not match kernel's sizeof(sigset_t) */
+ return __syscall_rt_sigaction(sig, act, oact, sizeof(act->sa_mask));
+}
+
+#else
+
+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)
+int __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 old_kernel_sigaction kact, koact;
if (act) {
kact.k_sa_handler = act->sa_handler;
- memcpy (&kact.sa_mask, &act->sa_mask, SIGSET_MIN_SIZE);
+ kact.sa_mask = act->sa_mask.__val[0];
kact.sa_flags = act->sa_flags;
-# ifdef HAVE_SA_RESTORER
-# if _MIPS_SIM == _ABIO32
+# if _MIPS_SIM == _ABIO32
kact.sa_restorer = act->sa_restorer;
-# else
+# else
kact.sa_restorer = &restore_rt;
-# endif
# endif
}
-
- /* 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(sig,
- act ? __ptrvalue (&kact) : NULL,
- oact ? __ptrvalue (&koact) : NULL,
- sizeof(kact.sa_mask));
-
- if (oact && result >= 0) {
+ result = __syscall_sigaction(sig,
+ act ? &kact : NULL,
+ oact ? &koact : NULL);
+ if (result < 0) {
+ __set_errno(-result);
+ return -1;
+ }
+ if (oact) {
oact->sa_handler = koact.k_sa_handler;
- memcpy (&oact->sa_mask, &koact.sa_mask, SIGSET_MIN_SIZE);
+ oact->sa_mask.__val[0] = koact.sa_mask;
oact->sa_flags = koact.sa_flags;
-# ifdef HAVE_SA_RESTORER
oact->sa_restorer = koact.sa_restorer;
-# endif
}
return result;
}
-
-#else
-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)
-{
- int result;
- struct old_kernel_sigaction kact, koact;
-
- if (act) {
- kact.k_sa_handler = act->sa_handler;
- kact.sa_mask = act->sa_mask.__val[0];
- kact.sa_flags = act->sa_flags;
-# ifdef HAVE_SA_RESTORER
-# if _MIPS_SIM == _ABIO32
- kact.sa_restorer = act->sa_restorer;
-# else
- kact.sa_restorer = &restore_rt;
-# endif
-# endif
- }
-
- result = __syscall_sigaction(sig, act ? __ptrvalue (&kact) : NULL,
- oact ? __ptrvalue (&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;
- oact->sa_flags = koact.sa_flags;
-# ifdef HAVE_SA_RESTORER
- oact->sa_restorer = koact.sa_restorer;
-# endif
- }
- 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
@@ -144,21 +113,21 @@ 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 RESTORE(name, syscall) RESTORE2(name, syscall)
#define RESTORE2(name, syscall) \
-__asm__ ( \
- ".align 4\n" \
- "__" #name ":\n" \
- " li $2, " #syscall "\n" \
- " syscall\n" \
- );
+__asm__ ( \
+ ".align 4\n" \
+ "__" #name ":\n" \
+ " li $2, " #syscall "\n" \
+ " syscall\n" \
+);
/* The return code for realtime-signals. */
#if _MIPS_SIM != _ABIO32
# ifdef __NR_rt_sigreturn
-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
#endif
diff -urpN uClibc-nptl.4/libc/sysdeps/linux/sparc/bits/sigaction.h uClibc/libc/sysdeps/linux/sparc/bits/sigaction.h
--- uClibc-nptl.4/libc/sysdeps/linux/sparc/bits/sigaction.h 2008-12-23 11:23:36.000000000 +0100
+++ uClibc/libc/sysdeps/linux/sparc/bits/sigaction.h 2008-12-19 01:21:45.000000000 +0100
@@ -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 -urpN uClibc-nptl.4/libc/sysdeps/linux/x86_64/sigaction.c uClibc/libc/sysdeps/linux/x86_64/sigaction.c
--- uClibc-nptl.4/libc/sysdeps/linux/x86_64/sigaction.c 2008-12-23 11:23:35.000000000 +0100
+++ uClibc/libc/sysdeps/linux/x86_64/sigaction.c 2008-12-19 01:21:44.000000000 +0100
@@ -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
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
}
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 -urpN uClibc-nptl.4/libc/sysdeps/linux/xtensa/sigaction.c uClibc/libc/sysdeps/linux/xtensa/sigaction.c
--- uClibc-nptl.4/libc/sysdeps/linux/xtensa/sigaction.c 2008-12-23 11:23:35.000000000 +0100
+++ uClibc/libc/sysdeps/linux/xtensa/sigaction.c 2008-12-19 01:21:44.000000000 +0100
@@ -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
_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc