]>
Commit | Line | Data |
---|---|---|
b168057a | 1 | /* Copyright (C) 1997-2015 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 | ||
f0fe91e7 AJ |
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 | ||
b8ddf7a1 | 33 | #if _MIPS_SIM != _ABIO32 |
ab35974e AO |
34 | |
35 | # ifdef __NR_rt_sigreturn | |
36 | static void restore_rt (void) asm ("__restore_rt"); | |
37 | # endif | |
38 | # ifdef __NR_sigreturn | |
39 | static void restore (void) asm ("__restore"); | |
40 | # endif | |
41 | #endif | |
f0fe91e7 AJ |
42 | |
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 (sig, act, oact) | |
47 | int sig; | |
48 | const struct sigaction *act; | |
49 | struct sigaction *oact; | |
50 | { | |
f0fe91e7 AJ |
51 | int result; |
52 | ||
a7375c94 | 53 | struct kernel_sigaction kact, koact; |
f0fe91e7 | 54 | |
f0fe91e7 AJ |
55 | if (act) |
56 | { | |
a7375c94 JM |
57 | kact.k_sa_handler = act->sa_handler; |
58 | memcpy (&kact.sa_mask, &act->sa_mask, sizeof (kernel_sigset_t)); | |
59 | kact.sa_flags = act->sa_flags; | |
60 | #ifdef HAVE_SA_RESTORER | |
61 | # if _MIPS_SIM == _ABIO32 | |
62 | kact.sa_restorer = act->sa_restorer; | |
63 | # else | |
64 | kact.sa_restorer = &restore_rt; | |
f0fe91e7 | 65 | # endif |
a7375c94 | 66 | #endif |
f0fe91e7 | 67 | } |
a7375c94 JM |
68 | |
69 | /* XXX The size argument hopefully will have to be changed to the | |
70 | real size of the user-level sigset_t. */ | |
71 | result = INLINE_SYSCALL (rt_sigaction, 4, sig, | |
70d9946a JM |
72 | act ? &kact : NULL, |
73 | oact ? &koact : NULL, | |
a7375c94 JM |
74 | sizeof (kernel_sigset_t)); |
75 | ||
f0fe91e7 AJ |
76 | if (oact && result >= 0) |
77 | { | |
a7375c94 JM |
78 | oact->sa_handler = koact.k_sa_handler; |
79 | memcpy (&oact->sa_mask, &koact.sa_mask, | |
80 | sizeof (kernel_sigset_t)); | |
81 | oact->sa_flags = koact.sa_flags; | |
82 | #ifdef HAVE_SA_RESTORER | |
83 | oact->sa_restorer = koact.sa_restorer; | |
84 | #endif | |
f0fe91e7 AJ |
85 | } |
86 | return result; | |
f0fe91e7 | 87 | } |
c5947147 | 88 | libc_hidden_def (__libc_sigaction) |
eb22472e | 89 | |
08192659 | 90 | #include <nptl/sigaction.c> |
bb600a60 | 91 | |
ab35974e AO |
92 | |
93 | /* NOTE: Please think twice before making any changes to the bits of | |
94 | code below. GDB needs some intimate knowledge about it to | |
95 | recognize them as signal trampolines, and make backtraces through | |
96 | signal handlers work right. Important are both the names | |
97 | (__restore_rt) and the exact instruction sequence. | |
98 | If you ever feel the need to make any changes, please notify the | |
99 | appropriate GDB maintainer. */ | |
100 | ||
101 | #define RESTORE(name, syscall) RESTORE2 (name, syscall) | |
102 | #define RESTORE2(name, syscall) \ | |
103 | asm \ | |
104 | ( \ | |
105 | ".align 4\n" \ | |
106 | "__" #name ":\n" \ | |
107 | " li $2, " #syscall "\n" \ | |
108 | " syscall\n" \ | |
109 | ); | |
110 | ||
111 | /* The return code for realtime-signals. */ | |
b8ddf7a1 | 112 | #if _MIPS_SIM != _ABIO32 |
ab35974e AO |
113 | # ifdef __NR_rt_sigreturn |
114 | RESTORE (restore_rt, __NR_rt_sigreturn) | |
115 | # endif | |
116 | # ifdef __NR_sigreturn | |
117 | RESTORE (restore, __NR_sigreturn) | |
118 | # endif | |
119 | #endif |