(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
[glibc.git] / sysdeps / unix / sysv / linux / sparc / sparc64 / sigaction.c
blob0a2d2c3ddec707a711a8513904de54abcb29c859
1 /* POSIX.1 sigaction call for Linux/SPARC64.
2 Copyright (C) 1997,1998,1999,2000,2002,2003 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, write to the Free
19 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 02111-1307 USA. */
22 #include <string.h>
23 #include <syscall.h>
24 #include <sysdep.h>
25 #include <sys/signal.h>
26 #include <errno.h>
28 #include <kernel_sigaction.h>
30 /* SPARC 64bit userland requires a kernel that has rt signals anyway. */
32 static void __rt_sigreturn_stub (void);
34 int
35 __libc_sigaction (int sig, __const struct sigaction *act,
36 struct sigaction *oact)
38 int ret;
39 struct kernel_sigaction kact, koact;
40 unsigned long stub = ((unsigned long) &__rt_sigreturn_stub) - 8;
42 if (act)
44 kact.k_sa_handler = act->sa_handler;
45 memcpy (&kact.sa_mask, &act->sa_mask, sizeof (sigset_t));
46 kact.sa_flags = act->sa_flags;
47 kact.sa_restorer = NULL;
50 /* XXX The size argument hopefully will have to be changed to the
51 real size of the user-level sigset_t. */
52 ret = INLINE_SYSCALL (rt_sigaction, 5, sig,
53 act ? __ptrvalue (&kact) : 0,
54 oact ? __ptrvalue (&koact) : 0, stub, _NSIG / 8);
56 if (oact && ret >= 0)
58 oact->sa_handler = koact.k_sa_handler;
59 memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (sigset_t));
60 oact->sa_flags = koact.sa_flags;
61 oact->sa_restorer = koact.sa_restorer;
64 return ret;
66 libc_hidden_def (__libc_sigaction)
68 #ifndef LIBC_SIGACTION
69 weak_alias (__libc_sigaction, __sigaction);
70 libc_hidden_weak (__sigaction)
71 weak_alias (__libc_sigaction, sigaction);
72 #endif
74 static void
75 __rt_sigreturn_stub (void)
77 __asm__ ("mov %0, %%g1\n\t"
78 "ta 0x6d\n\t"
79 : /* no outputs */
80 : "i" (__NR_rt_sigreturn));