package/uclibc: Fix removal of libintl.h
[uclibc-ng.git] / libc / signal / sigaction.c
blob25606472543cd613b4ca7c4c9a83967ef27e9c04
1 /* Copyright (C) 1997-2000,2002,2003,2005,2006 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
18 #include <signal.h>
19 #include <sys/syscall.h>
21 #if defined __NR_rt_sigaction
23 /* If ACT is not NULL, change the action for SIG to *ACT.
24 If OACT is not NULL, put the old action for SIG in *OACT. */
25 int
26 __libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
28 /* NB: kernel (as of 2.6.25) will return EINVAL
29 * if sizeof(act->sa_mask) does not match kernel's sizeof(sigset_t).
30 * Try to catch this problem at uclibc build time: */
31 struct BUG_sigset_size {
32 int BUG_sigset_size
33 [sizeof(act->sa_mask) == _NSIG / 8 ? 1 : -1];
35 return __syscall_rt_sigaction(sig, act, oact, sizeof(act->sa_mask));
38 #else
39 # define __need_NULL
40 # include <stddef.h>
41 # include <bits/kernel_sigaction.h>
43 /* If ACT is not NULL, change the action for SIG to *ACT.
44 If OACT is not NULL, put the old action for SIG in *OACT. */
45 int
46 __libc_sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
48 int result;
49 struct old_kernel_sigaction kact, koact;
51 if (act) {
52 kact.k_sa_handler = act->sa_handler;
53 kact.sa_mask = act->sa_mask.__val[0];
54 kact.sa_flags = act->sa_flags;
55 # ifdef HAVE_SA_RESTORER
56 kact.sa_restorer = act->sa_restorer;
57 # endif
59 result = __syscall_sigaction(sig,
60 act ? &kact : NULL,
61 oact ? &koact : NULL);
62 if (oact && result >= 0) {
63 oact->sa_handler = koact.k_sa_handler;
64 oact->sa_mask.__val[0] = koact.sa_mask;
65 oact->sa_flags = koact.sa_flags;
66 # ifdef HAVE_SA_RESTORER
67 oact->sa_restorer = koact.sa_restorer;
68 # endif
70 return result;
73 #endif
76 #ifndef LIBC_SIGACTION
77 # ifndef __UCLIBC_HAS_THREADS__
78 strong_alias(__libc_sigaction,sigaction)
79 libc_hidden_def(sigaction)
80 # else
81 weak_alias(__libc_sigaction,sigaction)
82 libc_hidden_weak(sigaction)
83 # endif
84 #endif