1 /* Copyright (C) 1994, 1995, 1996, 1997 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
19 #include <mach/exc_server.h>
20 #include <hurd/signal.h>
22 /* Called by the microkernel when a thread gets an exception. */
25 _S_catch_exception_raise (mach_port_t port
,
32 struct hurd_sigstate
*ss
;
34 struct hurd_signal_detail d
;
36 if (task
!= __mach_task_self ())
37 /* The sender wasn't the kernel. */
42 d
.exc_subcode
= subcode
;
44 /* Call the machine-dependent function to translate the Mach exception
45 codes into a signal number and subcode. */
46 _hurd_exception2signal (&d
, &signo
);
48 /* Find the sigstate structure for the faulting thread. */
49 __mutex_lock (&_hurd_siglock
);
50 for (ss
= _hurd_sigstates
; ss
!= NULL
; ss
= ss
->next
)
51 if (ss
->thread
== thread
)
53 __mutex_unlock (&_hurd_siglock
);
55 ss
= _hurd_thread_sigstate (thread
); /* Allocate a fresh one. */
57 if (__spin_lock_locked (&ss
->lock
))
59 /* Loser. The thread faulted with its sigstate lock held. Its
60 sigstate data is now suspect. So we reset the parts of it which
61 could cause trouble for the signal thread. Anything else
62 clobbered therein will just hose this user thread, but it's
65 This is almost certainly a library bug: unless random memory
66 clobberation caused the sigstate lock to gratuitously appear held,
67 no code should do anything that can fault while holding the
70 __spin_unlock (&ss
->critical_section_lock
);
72 __spin_unlock (&ss
->lock
);
75 /* Post the signal. */
76 _hurd_internal_post_signal (ss
, signo
, &d
,
77 MACH_PORT_NULL
, MACH_MSG_TYPE_PORT_SEND
,