Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / unix / sysv / linux / sparc / sparc32 / sigaction.c
blob5e8cf69800b453c67a63949bb708e72c220035c9
1 /* POSIX.1 sigaction call for Linux/SPARC.
2 Copyright (C) 1997-2014 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Miguel de Icaza <miguel@nuclecu.unam.mx>, 1997.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 #include <string.h>
21 #include <syscall.h>
22 #include <sys/signal.h>
23 #include <errno.h>
24 #include <kernel_sigaction.h>
25 #include <sysdep.h>
27 static void __rt_sigreturn_stub (void);
28 static void __sigreturn_stub (void);
30 int
31 __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
33 struct kernel_sigaction kact, koact;
34 unsigned long stub = 0;
35 int ret;
37 if (act)
39 kact.k_sa_handler = act->sa_handler;
40 memcpy (&kact.sa_mask, &act->sa_mask, sizeof (sigset_t));
41 if (((kact.sa_flags = act->sa_flags) & SA_SIGINFO) != 0)
42 stub = (unsigned long) &__rt_sigreturn_stub;
43 else
44 stub = (unsigned long) &__sigreturn_stub;
45 stub -= 8;
46 kact.sa_restorer = NULL;
49 /* XXX The size argument hopefully will have to be changed to the
50 real size of the user-level sigset_t. */
51 ret = INLINE_SYSCALL (rt_sigaction, 5, sig, act ? &kact : 0,
52 oact ? &koact : 0, stub, _NSIG / 8);
54 if (oact && ret >= 0)
56 oact->sa_handler = koact.k_sa_handler;
57 memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (sigset_t));
58 oact->sa_flags = koact.sa_flags;
59 oact->sa_restorer = koact.sa_restorer;
61 return ret;
63 libc_hidden_def (__libc_sigaction)
65 #ifdef WRAPPER_INCLUDE
66 # include WRAPPER_INCLUDE
67 #endif
69 #ifndef LIBC_SIGACTION
70 weak_alias (__libc_sigaction, __sigaction);
71 libc_hidden_weak (__sigaction)
72 weak_alias (__libc_sigaction, sigaction);
73 #endif
75 static void
76 __rt_sigreturn_stub (void)
78 __asm__ ("mov %0, %%g1\n\t"
79 "ta 0x10\n\t"
80 : /* no outputs */
81 : "i" (__NR_rt_sigreturn));
84 static void
85 __sigreturn_stub (void)
87 __asm__ ("mov %0, %%g1\n\t"
88 "ta 0x10\n\t"
89 : /* no outputs */
90 : "i" (__NR_sigreturn));