Remove *xattr syscalls.
[glibc.git] / sysdeps / unix / sysv / linux / arm / sigaction.c
bloba137ce7ad11caa097acba0a238d47e94329de9bd
1 /* Copyright (C) 1997, 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
19 #include <errno.h>
20 #include <signal.h>
21 #include <string.h>
23 #include <sysdep.h>
24 #include <sys/syscall.h>
26 /* The difference here is that the sigaction structure used in the
27 kernel is not the same as we use in the libc. Therefore we must
28 translate it here. */
29 #include <kernel_sigaction.h>
31 extern int __syscall_sigaction (int, const struct old_kernel_sigaction *__unbounded,
32 struct old_kernel_sigaction *__unbounded);
33 extern int __syscall_rt_sigaction (int, const struct kernel_sigaction *__unbounded,
34 struct kernel_sigaction *__unbounded, size_t);
36 /* The variable is shared between all wrappers around signal handling
37 functions which have RT equivalents. */
38 int __libc_missing_rt_sigs;
40 #define SA_RESTORER 0x04000000
42 extern void __default_sa_restorer(void);
43 extern void __default_rt_sa_restorer(void);
45 /* When RT signals are in use we need to use a different return stub. */
46 #ifdef __NR_rt_sigreturn
47 #define choose_restorer(flags) \
48 (flags & SA_SIGINFO) ? __default_rt_sa_restorer \
49 : __default_sa_restorer
50 #else
51 #define choose_restorer(flags) \
52 __default_sa_restorer
53 #endif
55 /* If ACT is not NULL, change the action for SIG to *ACT.
56 If OACT is not NULL, put the old action for SIG in *OACT. */
57 int
58 __libc_sigaction (sig, act, oact)
59 int sig;
60 const struct sigaction *act;
61 struct sigaction *oact;
63 struct old_kernel_sigaction k_sigact, k_osigact;
64 int result;
66 #ifdef __NR_rt_sigaction
67 /* First try the RT signals. */
68 if (!__libc_missing_rt_sigs)
70 struct kernel_sigaction kact, koact;
71 int saved_errno = errno;
73 if (act)
75 kact.k_sa_handler = act->sa_handler;
76 memcpy (&kact.sa_mask, &act->sa_mask, sizeof (sigset_t));
77 kact.sa_flags = act->sa_flags;
78 # ifdef HAVE_SA_RESTORER
79 /* If the user specified SA_ONSTACK this means she is trying to
80 use the old-style stack switching. Unfortunately this
81 requires the sa_restorer field so we cannot install our own
82 handler. (In fact the user is likely to be out of luck anyway
83 since the kernel currently only supports stack switching via
84 the X/Open sigaltstack interface, but we allow for the
85 possibility that this might change in the future.) */
86 if (kact.sa_flags & (SA_RESTORER | SA_ONSTACK))
87 kact.sa_restorer = act->sa_restorer;
88 else
90 kact.sa_restorer = choose_restorer (kact.sa_flags);
91 kact.sa_flags |= SA_RESTORER;
93 # endif
96 /* XXX The size argument hopefully will have to be changed to the
97 real size of the user-level sigset_t. */
98 result = INLINE_SYSCALL (rt_sigaction, 4, sig,
99 act ? __ptrvalue (&kact) : NULL,
100 oact ? __ptrvalue (&koact) : NULL, _NSIG / 8);
102 if (result >= 0 || errno != ENOSYS)
104 if (oact && result >= 0)
106 oact->sa_handler = koact.k_sa_handler;
107 memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (sigset_t));
108 oact->sa_flags = koact.sa_flags;
109 # ifdef HAVE_SA_RESTORER
110 oact->sa_restorer = koact.sa_restorer;
111 # endif
113 return result;
116 __set_errno (saved_errno);
117 __libc_missing_rt_sigs = 1;
119 #endif
121 if (act)
123 k_sigact.k_sa_handler = act->sa_handler;
124 k_sigact.sa_mask = act->sa_mask.__val[0];
125 k_sigact.sa_flags = act->sa_flags;
126 #ifdef HAVE_SA_RESTORER
127 /* See the comments above for why we test SA_ONSTACK. */
128 if (k_sigact.sa_flags & (SA_RESTORER | SA_ONSTACK))
129 k_sigact.sa_restorer = act->sa_restorer;
130 else
132 k_sigact.sa_restorer = choose_restorer (k_sigact.sa_flags);
133 k_sigact.sa_flags |= SA_RESTORER;
135 #endif
137 result = INLINE_SYSCALL (sigaction, 3, sig,
138 act ? __ptrvalue (&k_sigact) : NULL,
139 oact ? __ptrvalue (&k_osigact) : NULL);
140 if (oact && result >= 0)
142 oact->sa_handler = k_osigact.k_sa_handler;
143 oact->sa_mask.__val[0] = k_osigact.sa_mask;
144 oact->sa_flags = k_osigact.sa_flags;
145 #ifdef HAVE_SA_RESTORER
146 oact->sa_restorer = k_osigact.sa_restorer;
147 #endif
149 return result;
152 weak_alias (__libc_sigaction, __sigaction)
153 libc_hidden_weak (__sigaction)
154 weak_alias (__libc_sigaction, sigaction)