2 * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
4 * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
10 #include <sys/syscall.h>
11 #include <bits/kernel_sigaction.h>
13 extern void __default_rt_sa_restorer(void);
14 //libc_hidden_proto(__default_rt_sa_restorer);
16 #define SA_RESTORER 0x04000000
18 /* If @act is not NULL, change the action for @sig to @act.
19 If @oact is not NULL, put the old action for @sig in @oact. */
21 __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
23 struct sigaction kact;
25 /* !act means caller only wants to know @oact
26 * Hence only otherwise, do SA_RESTORER stuff
28 * For the normal/default cases (user not providing SA_RESTORER) use
29 * a real sigreturn stub to avoid kernel synthesizing one on user stack
30 * at runtime, which needs PTE permissions update (hence TLB entry
31 * update) and costly cache line flushes for code modification
33 if (act && !(act->sa_flags & SA_RESTORER)) {
34 memcpy(&kact, act, sizeof(kact));
35 kact.sa_restorer = __default_rt_sa_restorer;
36 kact.sa_flags |= SA_RESTORER;
41 return __syscall_rt_sigaction(sig, act, oact, sizeof(act->sa_mask));
44 #ifndef LIBC_SIGACTION
45 weak_alias(__libc_sigaction,sigaction)
46 libc_hidden_weak(sigaction)