summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-01-22 14:51:59 +0000
committerEric Andersen <andersen@codepoet.org>2003-01-22 14:51:59 +0000
commit49bf4a5a4c54d8bf1c32ce29c23d1cbbf8a4b0a4 (patch)
treed29611aa5f537854bfdbd81d86c4341041b90d6b
parent5faa9568e41b08fa5be573662b21ecbe031f612d (diff)
Looks like sigaction on arm needs adjustment, so split this into
a common header file and a default implementation.
-rw-r--r--libc/signal/sigaction.c125
-rw-r--r--libc/sysdeps/linux/common/bits/kernel_sigaction.h92
2 files changed, 106 insertions, 111 deletions
diff --git a/libc/signal/sigaction.c b/libc/signal/sigaction.c
index 1abb340a3..96e3d938d 100644
--- a/libc/signal/sigaction.c
+++ b/libc/signal/sigaction.c
@@ -20,103 +20,11 @@
#include <signal.h>
#include <string.h>
#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. */
-#define HAVE_SA_RESTORER
-
-
-#if defined(__alpha__)
-#undef HAVE_SA_RESTORER
-/* This is the sigaction struction from the Linux 2.1.20 kernel. */
-struct old_kernel_sigaction {
- __sighandler_t k_sa_handler;
- unsigned long sa_mask;
- unsigned int sa_flags;
-};
-/* This is the sigaction structure from the Linux 2.1.68 kernel. */
-struct kernel_sigaction {
- __sighandler_t k_sa_handler;
- unsigned int sa_flags;
- sigset_t sa_mask;
-};
-#elif defined(__hppa__)
-/* We do not support SA_RESTORER on hppa. */
-#undef HAVE_SA_RESTORER
-/* This is the sigaction struction from the Linux 2.1.20 kernel. */
-/* Blah. This is bogus. We don't ever use it. */
-struct old_kernel_sigaction {
- __sighandler_t k_sa_handler;
- unsigned long sa_mask;
- unsigned long sa_flags;
-};
-/* This is the sigaction structure from the Linux 2.1.68 kernel. */
-struct kernel_sigaction {
- __sighandler_t k_sa_handler;
- unsigned long sa_flags;
- sigset_t sa_mask;
-};
-#elif defined(__mips__)
-/* This is the sigaction structure from the Linux 2.1.24 kernel. */
-#include <sgidefs.h>
-struct old_kernel_sigaction {
- unsigned int sa_flags;
- __sighandler_t k_sa_handler;
- unsigned long sa_mask;
- unsigned int __pad0[3]; /* reserved, keep size constant */
-
- /* Abi says here follows reserved int[2] */
- void (*sa_restorer)(void);
-#if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2)
- /* For 32 bit code we have to pad struct sigaction to get
- * constant size for the ABI */
- int pad1[1]; /* reserved */
-#endif
-};
-
-#define _KERNEL_NSIG 128
-#define _KERNEL_NSIG_BPW 32
-#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 */
-};
-#else
-/* This is the sigaction structure from the Linux 2.1.20 kernel. */
-struct old_kernel_sigaction {
- __sighandler_t k_sa_handler;
- unsigned long sa_mask;
- unsigned long sa_flags;
- void (*sa_restorer) (void);
-};
-
-/* This is the sigaction structure from the Linux 2.1.68 kernel. */
-struct kernel_sigaction {
- __sighandler_t k_sa_handler;
- unsigned long sa_flags;
- void (*sa_restorer) (void);
- sigset_t sa_mask;
-};
-#endif
-
+#include <bits/kernel_sigaction.h>
#if defined __NR_rt_sigaction
-extern int __rt_sigaction (int, const struct kernel_sigaction *__unbounded,
- struct kernel_sigaction *__unbounded, size_t);
-
/* 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)
@@ -148,45 +56,40 @@ int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oa
}
return result;
}
-weak_alias(__libc_sigaction, sigaction)
-
-
#else
-extern int __sigaction (int, const struct old_kernel_sigaction *__unbounded,
- struct old_kernel_sigaction *__unbounded);
-
/* 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)
{
- struct old_kernel_sigaction k_sigact, k_osigact;
int result;
+ struct old_kernel_sigaction kact, koact;
if (act) {
- k_sigact.k_sa_handler = act->sa_handler;
- k_sigact.sa_mask = act->sa_mask.__val[0];
- k_sigact.sa_flags = act->sa_flags;
+ 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
- k_sigact.sa_restorer = act->sa_restorer;
+ kact.sa_restorer = act->sa_restorer;
# endif
}
- result = __sigaction(sig, act ? __ptrvalue (&k_sigact) : NULL,
- oact ? __ptrvalue (&k_osigact) : NULL);
+ result = __sigaction(sig, act ? __ptrvalue (&kact) : NULL,
+ oact ? __ptrvalue (&koact) : NULL);
if (oact && result >= 0) {
- oact->sa_handler = k_osigact.k_sa_handler;
- oact->sa_mask.__val[0] = k_osigact.sa_mask;
- oact->sa_flags = k_osigact.sa_flags;
+ 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 = k_osigact.sa_restorer;
+ oact->sa_restorer = koact.sa_restorer;
# endif
}
return result;
}
+#endif
+
weak_alias(__libc_sigaction, sigaction)
-#endif
diff --git a/libc/sysdeps/linux/common/bits/kernel_sigaction.h b/libc/sysdeps/linux/common/bits/kernel_sigaction.h
new file mode 100644
index 000000000..5bb129961
--- /dev/null
+++ b/libc/sysdeps/linux/common/bits/kernel_sigaction.h
@@ -0,0 +1,92 @@
+#ifndef _BITS_STAT_STRUCT_H
+#define _BITS_STAT_STRUCT_H
+
+/* This file provides whatever this particular arch's kernel thinks
+ * the sigaction struct should look like... */
+
+#if defined(__alpha__)
+#undef HAVE_SA_RESTORER
+/* This is the sigaction struction from the Linux 2.1.20 kernel. */
+struct old_kernel_sigaction {
+ __sighandler_t k_sa_handler;
+ unsigned long sa_mask;
+ unsigned int sa_flags;
+};
+/* This is the sigaction structure from the Linux 2.1.68 kernel. */
+struct kernel_sigaction {
+ __sighandler_t k_sa_handler;
+ unsigned int sa_flags;
+ sigset_t sa_mask;
+};
+#elif defined(__hppa__)
+#undef HAVE_SA_RESTORER
+/* This is the sigaction struction from the Linux 2.1.20 kernel. */
+/* Blah. This is bogus. We don't ever use it. */
+struct old_kernel_sigaction {
+ __sighandler_t k_sa_handler;
+ unsigned long sa_mask;
+ unsigned long sa_flags;
+};
+/* This is the sigaction structure from the Linux 2.1.68 kernel. */
+struct kernel_sigaction {
+ __sighandler_t k_sa_handler;
+ unsigned long sa_flags;
+ sigset_t sa_mask;
+};
+#elif defined(__mips__)
+#define HAVE_SA_RESTORER
+/* This is the sigaction structure from the Linux 2.1.24 kernel. */
+#include <sgidefs.h>
+struct old_kernel_sigaction {
+ unsigned int sa_flags;
+ __sighandler_t k_sa_handler;
+ unsigned long sa_mask;
+ unsigned int __pad0[3]; /* reserved, keep size constant */
+ /* Abi says here follows reserved int[2] */
+ void (*sa_restorer)(void);
+#if (_MIPS_ISA == _MIPS_ISA_MIPS1) || (_MIPS_ISA == _MIPS_ISA_MIPS2)
+ /* For 32 bit code we have to pad struct sigaction to get
+ * constant size for the ABI */
+ int pad1[1]; /* reserved */
+#endif
+};
+#define _KERNEL_NSIG 128
+#define _KERNEL_NSIG_BPW 32
+#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 */
+};
+#else
+#define HAVE_SA_RESTORER
+/* This is the sigaction structure from the Linux 2.1.20 kernel. */
+struct old_kernel_sigaction {
+ __sighandler_t k_sa_handler;
+ unsigned long sa_mask;
+ unsigned long sa_flags;
+ void (*sa_restorer) (void);
+};
+/* This is the sigaction structure from the Linux 2.1.68 kernel. */
+struct kernel_sigaction {
+ __sighandler_t k_sa_handler;
+ unsigned long sa_flags;
+ void (*sa_restorer) (void);
+ sigset_t sa_mask;
+};
+#endif
+
+extern int __rt_sigaction (int, const struct kernel_sigaction *__unbounded,
+ struct kernel_sigaction *__unbounded, size_t);
+
+extern int __sigaction (int, const struct old_kernel_sigaction *__unbounded,
+ struct old_kernel_sigaction *__unbounded);
+