]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/aarch64/sigaction.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / aarch64 / sigaction.c
CommitLineData
f7a9f785 1/* Copyright (C) 1997-2016 Free Software Foundation, Inc.
554066b8
MS
2
3 This file is part of the GNU C Library.
4
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.
9
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.
14
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/>. */
18
19#include <errno.h>
20#include <signal.h>
21#include <string.h>
22
23#include <sysdep.h>
24#include <sys/syscall.h>
25
554066b8
MS
26#define SA_RESTORER 0x04000000
27
28/* The difference here is that the sigaction structure used in the
29 kernel is not the same as we use in the libc. Therefore we must
30 translate it here. */
31#include <kernel_sigaction.h>
32
33int
34__libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
35{
36 int result;
37 struct kernel_sigaction kact;
38 struct kernel_sigaction koact;
39
40 if (act)
41 {
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#ifdef HAVE_SA_RESTORER
46 if (kact.sa_flags & SA_RESTORER)
47 kact.sa_restorer = act->sa_restorer;
48#endif
49 }
50
51 result = INLINE_SYSCALL (rt_sigaction, 4, sig,
70d9946a
JM
52 act ? &kact : NULL,
53 oact ? &koact : NULL, _NSIG / 8);
554066b8
MS
54 if (result >= 0 || errno != ENOSYS)
55 {
56 if (oact && result >= 0)
57 {
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#ifdef HAVE_SA_RESTORER
62 oact->sa_restorer = koact.sa_restorer;
63#endif
64 }
65 }
66 return result;
67}
68libc_hidden_def (__libc_sigaction)
69
08192659 70#include <nptl/sigaction.c>