]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/i386/sigaction.c
Tue Oct 31 00:07:29 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / i386 / sigaction.c
CommitLineData
efc755b2
RM
1/* POSIX.1 `sigaction' call for Linux/i386.
2Copyright (C) 1991, 1995 Free Software Foundation, Inc.
3This file is part of the GNU C Library.
4
5The GNU C Library is free software; you can redistribute it and/or
6modify it under the terms of the GNU Library General Public License as
7published by the Free Software Foundation; either version 2 of the
8License, or (at your option) any later version.
9
10The GNU C Library is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13Library General Public License for more details.
14
15You should have received a copy of the GNU Library General Public
16License along with the GNU C Library; see the file COPYING.LIB. If
17not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18Cambridge, MA 02139, USA. */
19
20#include <sysdep.h>
21#include <errno.h>
22#include <stddef.h>
23#include <signal.h>
24
25
26/* If ACT is not NULL, change the action for SIG to *ACT.
27 If OACT is not NULL, put the old action for SIG in *OACT. */
28int
29__sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
30{
31 struct sigaction newact;
32 int result;
33
3e2ee727 34 if (act)
efc755b2 35 {
3e2ee727
RM
36 newact = *act;
37 newact.sa_restorer = ((act->sa_flags & SA_NOMASK)
38 ? &&restore_nomask : &&restore);
39 act = &newact;
efc755b2
RM
40 }
41
42 asm volatile ("pushl %%ebx\n"
3e2ee727 43 "movl %2, %%ebx\n"
efc755b2
RM
44 "int $0x80\n"
45 "popl %%ebx"
46 : "=a" (result)
3bbceb12 47 : "0" (SYS_ify (sigaction)), "r" (sig), "c" (act), "d" (oact));
efc755b2
RM
48
49 if (result < 0)
50 {
51 errno = -result;
52 return -1;
53 }
54 return 0;
55
56 restore:
57 asm (
58#ifdef PIC
3e2ee727 59 " pushl %%ebx\n"
efc755b2 60 " call 0f\n"
3e2ee727
RM
61 "0: popl %%ebx\n"
62 " addl $_GLOBAL_OFFSET_TABLE_+[.-0b], %%ebx\n"
efc755b2
RM
63 " addl $8, %%esp\n"
64 " call __sigsetmask@PLT\n"
65 " addl $8, %%esp\n"
3e2ee727 66 " popl %%ebx\n"
efc755b2
RM
67#else
68 " addl $4, %%esp\n"
69 " call __sigsetmask\n"
70 " addl $4, %%esp\n"
71#endif
3e2ee727
RM
72 " popl %%eax\n"
73 " popl %%ecx\n"
74 " popl %%edx\n"
75 " popf\n"
76 " ret"
77 : : );
3bbceb12 78
efc755b2 79 restore_nomask:
3e2ee727
RM
80 asm (" addl $4, %%esp\n"
81 " popl %%eax\n"
82 " popl %%ecx\n"
83 " popl %%edx\n"
84 " popf\n"
85 " ret"
86 : : );
3bbceb12 87
3e2ee727 88 /* NOTREACHED */
3bbceb12 89 return -1;
efc755b2
RM
90}
91
92weak_alias (__sigaction, sigaction)