1 /* POSIX.1 sigaction call for Linux/SPARC.
2 Copyright (C) 1997 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Miguel de Icaza (miguel@nuclecu.unam.mx), 1997.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If not,
18 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 #include <sys/signal.h>
25 /* Commented out while I figure out what the fuck goes on */
26 long ____sig_table
[NSIG
];
29 /* The kernel will deliver signals in the old way if the signal
30 number is a positive number. The kernel will deliver a signal
31 with the new stack layout if the signal number is a negative number.
33 Our sigaction code takes care of selecting the type of kernel we are
36 extern void ____sparc_signal_trampoline (int);
39 __trampoline_sigaction (int sig
, struct sigaction
*new, struct sigaction
*old
)
42 int need_to_hide_trick
= 0;
43 __sighandler_t old_sh
;
47 if (new->sa_handler
!= SIG_DFL
&& new->sa_handler
!= SIG_IGN
)
49 old_sh
= ____sig_table
[sig
];
50 ____sig_table
[sig
] = (long int) new->sa_handler
;
51 new->sa_handler
= ____sparc_signal_trampoline
;
52 need_to_hide_trick
= 1;
55 __asm__("or %%g0,%0,%%g1\n\t"
61 "or %%o0, %%g0, %0\n\t"
62 "sub %%g0, %%o0, %0\n\t"
64 : "=r" (ret
), "=r" ((long int) sig
), "=r" ((long int) new),
66 : "0" (__NR_sigaction
), "1" (sig
), "2" (new), "3" (old
)
67 : "g1", "o0", "o1", "o2");
71 if (old
&& old
->sa_handler
== ____sparc_signal_trampoline
)
73 if (need_to_hide_trick
)
74 old
->sa_handler
= old_sh
;
76 old
->sa_handler
= ____sig_table
[sig
];
78 if (need_to_hide_trick
)
79 new->sa_handler
= ____sig_table
[sig
];
86 # define __new_sigaction __sigaction
90 __new_sigaction (int sig
, __const
struct sigaction
*new, struct sigaction
*old
)
96 __asm__("or %%g0,%0,%%g1\n\t"
102 "or %%o0, %%g0, %0\n\t"
103 "sub %%g0,%%o0,%0\n\t"
105 : "=r" (ret
), "=r" ((long int) sig
), "=r" ((long int) new),
106 "=r" ((long int) old
)
107 : "0" (__NR_sigaction
), "1" (sig
), "2" (new), "3" (old
)
108 : "g1", "o0", "o1", "o2");
117 __sigaction (int sig
, __const
struct sigaction
*new, struct sigaction
*old
)
119 static (*sigact_routine
) (int, __const
struct sigaction
*, struct sigaction
*);
124 return (*sigact_routine
) (sig
, new, old
);
126 ret
= __new_sigaction (1, NULL
, &sa
);
128 sigact_routine
= __trampoline_sigaction
;
130 sigact_routine
= __new_sigaction
;
132 return __sigaction (sig
, new, old
);
136 weak_alias (__sigaction
, sigaction
);