1 /* POSIX.1 sigaction call for Linux/SPARC.
2 Copyright (C) 1997-2000,2002,2003,2005 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, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 Ported to uClibc from glibc: 090520:
22 Jan Buchholz, KIP, Uni Heidelberg <jan.buchholz@kip.uni-heidelberg.de>
23 Austin Foxley, Ceton Corporation <austinf@cetoncorp.com>
29 #include <sys/syscall.h>
30 #include <bits/kernel_sigaction.h>
33 _syscall5(int, rt_sigaction, int, a, int, b, int, c, int, d, int, e);
34 static void __rt_sigreturn_stub (void);
35 static void __sigreturn_stub (void);
38 __libc_sigaction (int sig, __const struct sigaction *act, struct sigaction *oact)
41 struct old_kernel_sigaction kact, koact;
42 unsigned long stub = 0;
43 int saved_errno = errno;
47 kact.k_sa_handler = act->sa_handler;
48 memcpy (&kact.sa_mask, &act->sa_mask, sizeof(sigset_t));
49 if (((kact.sa_flags = act->sa_flags) & SA_SIGINFO)!= 0)
50 stub = (unsigned long) &__rt_sigreturn_stub;
52 stub = (unsigned long) &__sigreturn_stub;
54 kact.sa_restorer = NULL;
56 /* XXX The size argument hopefully will have to be changed to the real size of the user-level sigset_t. */
57 ret = rt_sigaction(sig,
58 (int)(act ? &kact : NULL),
59 (int)(oact ? &koact : NULL),
63 if (ret >= 0 || errno != ENOSYS)
67 oact->sa_handler = koact.k_sa_handler;
68 memcpy (&oact->sa_mask, &koact.sa_mask, sizeof (sigset_t));
69 oact->sa_flags = koact.sa_flags;
70 oact->sa_restorer = koact.sa_restorer;
74 __set_errno (saved_errno);
78 #ifndef LIBC_SIGACTION
79 weak_alias(__libc_sigaction,sigaction)
80 libc_hidden_weak(sigaction)
84 __rt_sigreturn_stub (void)
86 __asm__ ("mov %0, %%g1\n\t"
89 : "i" (__NR_rt_sigreturn));
92 __sigreturn_stub (void)
94 __asm__ ("mov %0, %%g1\n\t"
97 : "i" (__NR_sigreturn));