1 /* Copyright (C) 1993, 1996, 1997, 2004 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
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.
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
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 #error This file uses GNU C extensions; you must compile with GCC.
23 /* Get the definition of `struct sigcontext'. */
25 #define sigvec sun_sigvec
26 #define sigstack sun_sigstack
27 #define sigcontext sun_sigcontext
28 #include "/usr/include/sys/signal.h"
52 /* Defined in __sigvec.S. */
53 extern int __raw_sigvec (int sig
, const struct sigvec
*vec
,
56 /* User-specified signal handlers. */
59 static __sighandler_t handlers
[NSIG
];
61 #define handlers _sigfunc
62 extern __sighandler_t _sigfunc
[];
67 /* Handler for all signals that are handled by a user-specified function.
68 Saves and restores the general regs %g2-%g7, the %y register, and
69 all the FPU regs (including %fsr), around calling the user's handler. */
71 trampoline (sig
, code
, context
, addr
)
74 struct sigcontext
*context
;
79 /* Save the call-clobbered registers. */
80 asm volatile ("movem%.l d0-d1/a0-a1, %0" : : "m" (save
[0]));
82 /* XXX should save/restore FP regs */
84 /* Call the user's handler. */
85 (*((void (*) (int sig
, int code
, struct sigcontext
*context
,
86 PTR addr
)) handlers
[sig
]))
87 (sig
, code
, context
, addr
);
89 /* Restore the call-clobbered registers. */
90 asm volatile ("movem%.l %0, d0-d1/a0-a1" : : "g" (save
[0]) :
91 "d0", "d1", "a0", "a1");
93 __sigreturn (context
);
99 __sigvec (sig
, vec
, ovec
)
101 const struct sigvec
*vec
;
105 extern void _sigtramp (int);
106 #define trampoline _sigtramp
110 __sighandler_t ohandler
;
112 if (sig
<= 0 || sig
>= NSIG
)
114 __set_errno (EINVAL
);
118 mask
= __sigblock(sigmask(sig
));
120 ohandler
= handlers
[sig
];
123 vec
->sv_handler
!= SIG_IGN
&& vec
->sv_handler
!= SIG_DFL
)
125 handlers
[sig
] = vec
->sv_handler
;
127 myvec
.sv_handler
= trampoline
;
131 if (__raw_sigvec(sig
, vec
, ovec
) < 0)
134 (void) __sigsetmask(mask
);
139 if (ovec
!= NULL
&& ovec
->sv_handler
== trampoline
)
140 ovec
->sv_handler
= ohandler
;
142 (void) __sigsetmask(mask
);