1 /* POSIX.1 `sigaction' call for Linux/i386.
2 Copyright (C) 1991, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
25 /* The difference here is that the sigaction structure used in the
26 kernel is not the same as we use in the libc. Therefore we must
28 #include <kernel_sigaction.h>
31 extern int __syscall_rt_sigaction (int, const struct kernel_sigaction
*,
32 struct kernel_sigaction
*, size_t);
34 /* The variable is shared between all wrappers around signal handling
35 functions which have RT equivalents. */
36 int __libc_missing_rt_sigs
;
39 /* If ACT is not NULL, change the action for SIG to *ACT.
40 If OACT is not NULL, put the old action for SIG in *OACT. */
42 __sigaction (int sig
, const struct sigaction
*act
, struct sigaction
*oact
)
44 struct old_kernel_sigaction k_newact
, k_oldact
;
47 /* First try the RT signals. */
48 if (!__libc_missing_rt_sigs
)
50 struct kernel_sigaction kact
, koact
;
51 int saved_errno
= errno
;
55 kact
.k_sa_handler
= act
->sa_handler
;
56 memcpy (&kact
.sa_mask
, &act
->sa_mask
, sizeof (sigset_t
));
57 kact
.sa_flags
= act
->sa_flags
;
59 kact
.sa_restorer
= ((act
->sa_flags
& SA_NOMASK
)
60 ? &&restore_nomask
: &&restore
);
63 /* XXX The size argument hopefully will have to be changed to the
64 real size of the user-level sigset_t. */
65 result
= __syscall_rt_sigaction (sig
, act
? &kact
: NULL
,
66 oact
? &koact
: NULL
, _NSIG
/ 8);
68 if (result
>= 0 || errno
!= ENOSYS
)
70 if (oact
&& result
>= 0)
72 oact
->sa_handler
= koact
.k_sa_handler
;
73 memcpy (&oact
->sa_mask
, &koact
.sa_mask
, sizeof (sigset_t
));
74 oact
->sa_flags
= koact
.sa_flags
;
75 oact
->sa_restorer
= koact
.sa_restorer
;
80 __set_errno (saved_errno
);
81 __libc_missing_rt_sigs
= 1;
86 k_newact
.k_sa_handler
= act
->sa_handler
;
87 k_newact
.sa_mask
= act
->sa_mask
.__val
[0];
88 k_newact
.sa_flags
= act
->sa_flags
;
90 k_newact
.sa_restorer
= ((act
->sa_flags
& SA_NOMASK
)
91 ? &&restore_nomask
: &&restore
);
94 asm volatile ("pushl %%ebx\n"
99 : "0" (SYS_ify (sigaction
)), "r" (sig
),
100 "c" (act
? &k_newact
: 0), "d" (oact
? &k_oldact
: 0));
104 __set_errno (-result
);
110 oact
->sa_handler
= k_oldact
.k_sa_handler
;
111 oact
->sa_mask
.__val
[0] = k_oldact
.sa_mask
;
112 oact
->sa_flags
= k_oldact
.sa_flags
;
113 oact
->sa_restorer
= k_oldact
.sa_restorer
;
124 " addl $_GLOBAL_OFFSET_TABLE_+[.-0b], %%ebx\n"
126 " call __sigsetmask@PLT\n"
131 " call __sigsetmask\n"
142 asm (" addl $4, %%esp\n"
154 weak_alias (__sigaction
, sigaction
)