OSDN Git Service

ARC: syscalls.h: code-reuse/fix-arg-annotations
[uclinux-h8/uClibc.git] / libc / sysdeps / linux / arc / sigaction.c
1 /*
2  * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
3  *
4  * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
5  */
6
7 #include <errno.h>
8 #include <signal.h>
9 #include <string.h>
10 #include <sys/syscall.h>
11 #include <bits/kernel_sigaction.h>
12
13 extern void __default_rt_sa_restorer(void);
14 //libc_hidden_proto(__default_rt_sa_restorer);
15
16 #define SA_RESTORER     0x04000000
17
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.  */
20 int
21 __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
22 {
23         struct sigaction kact;
24
25         /* !act means caller only wants to know @oact
26          * Hence only otherwise, do SA_RESTORER stuff
27          *
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
32          */
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;
37
38                 act = &kact;
39         }
40
41         return __syscall_rt_sigaction(sig, act, oact, sizeof(act->sa_mask));
42 }
43
44 #ifndef LIBC_SIGACTION
45 weak_alias(__libc_sigaction,sigaction)
46 libc_hidden_weak(sigaction)
47 #endif