1 /* Copyright (C) 1997-2013 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
24 #include <sys/syscall.h>
26 #include <kernel-features.h>
28 #define SA_RESTORER 0x04000000
30 /* The difference here is that the sigaction structure used in the
31 kernel is not the same as we use in the libc. Therefore we must
33 #include <kernel_sigaction.h>
36 __libc_sigaction (int sig
, const struct sigaction
*act
, struct sigaction
*oact
)
39 struct kernel_sigaction kact
;
40 struct kernel_sigaction koact
;
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 #ifdef HAVE_SA_RESTORER
48 if (kact
.sa_flags
& SA_RESTORER
)
49 kact
.sa_restorer
= act
->sa_restorer
;
53 result
= INLINE_SYSCALL (rt_sigaction
, 4, sig
,
54 act
? __ptrvalue (&kact
) : NULL
,
55 oact
? __ptrvalue (&koact
) : NULL
, _NSIG
/ 8);
56 if (result
>= 0 || errno
!= ENOSYS
)
58 if (oact
&& result
>= 0)
60 oact
->sa_handler
= koact
.k_sa_handler
;
61 memcpy (&oact
->sa_mask
, &koact
.sa_mask
, sizeof (sigset_t
));
62 oact
->sa_flags
= koact
.sa_flags
;
63 #ifdef HAVE_SA_RESTORER
64 oact
->sa_restorer
= koact
.sa_restorer
;
70 libc_hidden_def (__libc_sigaction
)
72 #ifdef WRAPPER_INCLUDE
73 # include WRAPPER_INCLUDE
76 #ifndef LIBC_SIGACTION
77 weak_alias (__libc_sigaction
, __sigaction
)
78 libc_hidden_weak (__sigaction
)
79 weak_alias (__libc_sigaction
, sigaction
)