]>
Commit | Line | Data |
---|---|---|
d4697bc9 | 1 | /* Copyright (C) 1997-2014 Free Software Foundation, Inc. |
f0fe91e7 AJ |
2 | This file is part of the GNU C Library. |
3 | ||
4 | The GNU C Library is free software; you can redistribute it and/or | |
3214b89b AJ |
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. | |
f0fe91e7 AJ |
8 | |
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 | |
3214b89b AJ |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Lesser General Public License for more details. | |
f0fe91e7 | 13 | |
3214b89b | 14 | You should have received a copy of the GNU Lesser General Public |
ab84e3ff PE |
15 | License along with the GNU C Library. If not, see |
16 | <http://www.gnu.org/licenses/>. */ | |
f0fe91e7 AJ |
17 | |
18 | #include <errno.h> | |
b8ddf7a1 | 19 | #include <sgidefs.h> |
f0fe91e7 AJ |
20 | #include <signal.h> |
21 | #include <string.h> | |
22 | ||
23 | #include <sysdep.h> | |
24 | #include <sys/syscall.h> | |
25 | ||
24c4c341 AJ |
26 | #include <sgidefs.h> |
27 | ||
44422d11 | 28 | #include <kernel-features.h> |
f0fe91e7 AJ |
29 | |
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 | |
32 | translate it here. */ | |
33 | #include <kernel_sigaction.h> | |
34 | ||
b8ddf7a1 | 35 | #if _MIPS_SIM != _ABIO32 |
ab35974e AO |
36 | |
37 | # ifdef __NR_rt_sigreturn | |
38 | static void restore_rt (void) asm ("__restore_rt"); | |
39 | # endif | |
40 | # ifdef __NR_sigreturn | |
41 | static void restore (void) asm ("__restore"); | |
42 | # endif | |
43 | #endif | |
f0fe91e7 AJ |
44 | |
45 | /* If ACT is not NULL, change the action for SIG to *ACT. | |
46 | If OACT is not NULL, put the old action for SIG in *OACT. */ | |
47 | int | |
48 | __libc_sigaction (sig, act, oact) | |
49 | int sig; | |
50 | const struct sigaction *act; | |
51 | struct sigaction *oact; | |
52 | { | |
f0fe91e7 AJ |
53 | int result; |
54 | ||
a7375c94 | 55 | struct kernel_sigaction kact, koact; |
f0fe91e7 | 56 | |
f0fe91e7 AJ |
57 | if (act) |
58 | { | |
a7375c94 JM |
59 | kact.k_sa_handler = act->sa_handler; |
60 | memcpy (&kact.sa_mask, &act->sa_mask, sizeof (kernel_sigset_t)); | |
61 | kact.sa_flags = act->sa_flags; | |
62 | #ifdef HAVE_SA_RESTORER | |
63 | # if _MIPS_SIM == _ABIO32 | |
64 | kact.sa_restorer = act->sa_restorer; | |
65 | # else | |
66 | kact.sa_restorer = &restore_rt; | |
f0fe91e7 | 67 | # endif |
a7375c94 | 68 | #endif |
f0fe91e7 | 69 | } |
a7375c94 JM |
70 | |
71 | /* XXX The size argument hopefully will have to be changed to the | |
72 | real size of the user-level sigset_t. */ | |
73 | result = INLINE_SYSCALL (rt_sigaction, 4, sig, | |
70d9946a JM |
74 | act ? &kact : NULL, |
75 | oact ? &koact : NULL, | |
a7375c94 JM |
76 | sizeof (kernel_sigset_t)); |
77 | ||
f0fe91e7 AJ |
78 | if (oact && result >= 0) |
79 | { | |
a7375c94 JM |
80 | oact->sa_handler = koact.k_sa_handler; |
81 | memcpy (&oact->sa_mask, &koact.sa_mask, | |
82 | sizeof (kernel_sigset_t)); | |
83 | oact->sa_flags = koact.sa_flags; | |
84 | #ifdef HAVE_SA_RESTORER | |
85 | oact->sa_restorer = koact.sa_restorer; | |
86 | #endif | |
f0fe91e7 AJ |
87 | } |
88 | return result; | |
f0fe91e7 | 89 | } |
c5947147 | 90 | libc_hidden_def (__libc_sigaction) |
eb22472e | 91 | |
bb600a60 DJ |
92 | #ifdef WRAPPER_INCLUDE |
93 | # include WRAPPER_INCLUDE | |
94 | #endif | |
95 | ||
eb22472e | 96 | #ifndef LIBC_SIGACTION |
f0fe91e7 | 97 | weak_alias (__libc_sigaction, __sigaction) |
da5f5f79 | 98 | libc_hidden_weak (__sigaction) |
f0fe91e7 | 99 | weak_alias (__libc_sigaction, sigaction) |
eb22472e | 100 | #endif |
ab35974e AO |
101 | |
102 | /* NOTE: Please think twice before making any changes to the bits of | |
103 | code below. GDB needs some intimate knowledge about it to | |
104 | recognize them as signal trampolines, and make backtraces through | |
105 | signal handlers work right. Important are both the names | |
106 | (__restore_rt) and the exact instruction sequence. | |
107 | If you ever feel the need to make any changes, please notify the | |
108 | appropriate GDB maintainer. */ | |
109 | ||
110 | #define RESTORE(name, syscall) RESTORE2 (name, syscall) | |
111 | #define RESTORE2(name, syscall) \ | |
112 | asm \ | |
113 | ( \ | |
114 | ".align 4\n" \ | |
115 | "__" #name ":\n" \ | |
116 | " li $2, " #syscall "\n" \ | |
117 | " syscall\n" \ | |
118 | ); | |
119 | ||
120 | /* The return code for realtime-signals. */ | |
b8ddf7a1 | 121 | #if _MIPS_SIM != _ABIO32 |
ab35974e AO |
122 | # ifdef __NR_rt_sigreturn |
123 | RESTORE (restore_rt, __NR_rt_sigreturn) | |
124 | # endif | |
125 | # ifdef __NR_sigreturn | |
126 | RESTORE (restore, __NR_sigreturn) | |
127 | # endif | |
128 | #endif |