Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / unix / sysv / linux / sparc / sparc64 / sigaction.c
blob665e658cf920ff4b5911897bb96c9ee1f757e8fd
1 /* POSIX.1 sigaction call for Linux/SPARC64.
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> and
5 Jakub Jelinek <jj@ultra.linux.cz>.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, see
19 <http://www.gnu.org/licenses/>. */
21 #include <string.h>
22 #include <syscall.h>
23 #include <sysdep.h>
24 #include <sys/signal.h>
25 #include <errno.h>
27 #include <kernel_sigaction.h>
29 /* SPARC 64bit userland requires a kernel that has rt signals anyway. */
31 static void __rt_sigreturn_stub (void);
33 int
34 __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
36 int ret;
37 struct kernel_sigaction kact, koact;
38 unsigned long stub = ((unsigned long) &__rt_sigreturn_stub) - 8;
40 if (act)
42 kact.k_sa_handler = act->sa_handler;
43 memcpy (&kact.sa_mask, &act->sa_mask, sizeof (sigset_t));
44 kact.sa_flags = act->sa_flags;
45 kact.sa_restorer = NULL;
48 /* XXX The size argument hopefully will have to be changed to the
49 real size of the user-level sigset_t. */
50 ret = INLINE_SYSCALL (rt_sigaction, 5, sig,
51 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;
62 return ret;
64 libc_hidden_def (__libc_sigaction)
66 #ifdef WRAPPER_INCLUDE
67 # include WRAPPER_INCLUDE
68 #endif
70 #ifndef LIBC_SIGACTION
71 weak_alias (__libc_sigaction, __sigaction);
72 libc_hidden_weak (__sigaction)
73 weak_alias (__libc_sigaction, sigaction);
74 #endif
76 static void
77 __rt_sigreturn_stub (void)
79 __asm__ ("mov %0, %%g1\n\t"
80 "ta 0x6d\n\t"
81 : /* no outputs */
82 : "i" (__NR_rt_sigreturn));