diff options
author | Roland McGrath <roland@gnu.org> | 1996-01-04 17:00:45 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1996-01-04 17:00:45 +0000 |
commit | 7974fe2117b1308a46f16ae5803c64f75303521c (patch) | |
tree | 74144df8a67fabc8cc766351fffa87baaa8c909a /hurd | |
parent | fb8e70d6dd3a9c3a0e0d2713b5be3cbc9d7a6409 (diff) | |
download | glibc-7974fe2117b1308a46f16ae5803c64f75303521c.zip glibc-7974fe2117b1308a46f16ae5803c64f75303521c.tar.gz glibc-7974fe2117b1308a46f16ae5803c64f75303521c.tar.bz2 |
Thu Jan 4 11:35:18 1996 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/mach/hurd/setitimer.c: Code rearranged a bit to use new
preemption interface.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler):
Use _hurdsig_catch_memory_fault.
* hurd/Makefile (headers): Add hurd/sigpreempt.h.
(sig): Add catch-signal.
* hurd/hurdfault.c (_hurdsig_fault_catch_exception_raise):
Rewritten using a preempter in new interface.
* hurd/hurdfault.h (_hurdsig_catch_fault): Likewise.
(_hurdsig_catch_memory_fault): New macro.
Diffstat (limited to 'hurd')
-rw-r--r-- | hurd/Makefile | 10 | ||||
-rw-r--r-- | hurd/hurdfault.c | 42 | ||||
-rw-r--r-- | hurd/hurdfault.h | 24 |
3 files changed, 39 insertions, 37 deletions
diff --git a/hurd/Makefile b/hurd/Makefile index 69f9e96..fe9e43e 100644 --- a/hurd/Makefile +++ b/hurd/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. +# Copyright (C) 1991, 92, 93, 94, 95, 96 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -25,8 +25,8 @@ include ../Makeconfig headers = hurd.h $(interface-headers) \ - $(addprefix hurd/,fd.h id.h port.h signal.h userlink.h \ - resource.h threadvar.h lookup.h) + $(addprefix hurd/,fd.h id.h port.h signal.h sigpreempt.h \ + userlink.h resource.h threadvar.h lookup.h) distribute := hurdstartup.h hurdfault.h intr-rpc.defs STATUS @@ -51,10 +51,10 @@ routines = hurdstartup hurdinit \ fopenport \ vpprintf \ ports-get ports-set hurdports hurdmsg \ - $(sig) $(dtable) hurdinline port-cleanup + $(sig) $(dtable) hurdinline port-cleanup # report-wait sig = hurdsig hurdfault faultexc siginfo hurd-raise preempt-sig \ trampoline longjmp-ts catch-exc exc2signal hurdkill sigunwind \ - thread-self thread-cancel intr-msg + thread-self thread-cancel intr-msg catch-signal dtable = dtable port2fd new-fd alloc-fd intern-fd \ getdport openport \ fd-close fd-read fd-write hurdioctl ctty-input ctty-output diff --git a/hurd/hurdfault.c b/hurd/hurdfault.c index 5aedc58..2a30db0 100644 --- a/hurd/hurdfault.c +++ b/hurd/hurdfault.c @@ -1,5 +1,5 @@ /* Handle faults in the signal thread. -Copyright (C) 1994, 1995 Free Software Foundation, Inc. +Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -29,13 +29,10 @@ Cambridge, MA 02139, USA. */ #include <assert.h> jmp_buf _hurdsig_fault_env; +struct hurd_signal_preempter _hurdsig_fault_preempter; static mach_port_t forward_sigexc; -int _hurdsig_fault_expect_signo; -long int _hurdsig_fault_sigcode; -int _hurdsig_fault_sigerror; - kern_return_t _hurdsig_fault_catch_exception_raise (mach_port_t port, thread_t thread, @@ -45,6 +42,8 @@ _hurdsig_fault_catch_exception_raise (mach_port_t port, int subcode) { int signo; + long int sigcode; + int sigerror; if (port != forward_sigexc || thread != _hurd_msgport_thread || task != __mach_task_self ()) @@ -52,10 +51,11 @@ _hurdsig_fault_catch_exception_raise (mach_port_t port, /* Call the machine-dependent function to translate the Mach exception codes into a signal number and subcode. */ - _hurd_exception2signal (exception, code, subcode, &signo, - &_hurdsig_fault_sigcode, &_hurdsig_fault_sigerror); + _hurd_exception2signal (exception, code, subcode, + &signo, &sigcode, &sigerror); - return signo == _hurdsig_fault_expect_signo ? 0 : EGREGIOUS; + return HURD_PREEMPT_SIGNAL_P (&_hurdsig_fault_preempter, signo, sigcode) + ? 0 : EGREGIOUS; } static void @@ -85,19 +85,17 @@ faulted (void) /* Run the exc demuxer which should call the server function above. That function returns 0 if the exception was expected. */ - switch (_hurdsig_fault_exc_server (&request.head, &reply.head)) - { - case KERN_SUCCESS: - if (reply.head.msgh_remote_port != MACH_PORT_NULL) - __mach_msg (&reply.head, MACH_SEND_MSG, reply.head.msgh_size, - 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); - break; - default: - __mach_msg_destroy (&request.head); - case MIG_NO_REPLY: - } - - _hurdsig_fault_expect_signo = 0; + _hurdsig_fault_exc_server (&request.head, &reply.head); + if (reply.head.msgh_remote_port != MACH_PORT_NULL) + __mach_msg (&reply.head, MACH_SEND_MSG, reply.head.msgh_size, + 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); + if (reply.result == MIG_BAD_ID) + __mach_msg_destroy (&request.head); + + if (reply.result) + __libc_fatal ("BUG: unexpected fault in signal thread\n"); + + _hurdsig_fault_preempter.signals = 0; longjmp (_hurdsig_fault_env, 1); } @@ -125,8 +123,10 @@ _hurdsig_fault_init (void) err = __mach_port_insert_right (__mach_task_self (), sigexc, sigexc, MACH_MSG_TYPE_MAKE_SEND); assert_perror (err); +#if 0 /* XXX gdb bites */ err = __thread_set_special_port (_hurd_msgport_thread, THREAD_EXCEPTION_PORT, sigexc); +#endif __mach_port_deallocate (__mach_task_self (), sigexc); assert_perror (err); diff --git a/hurd/hurdfault.h b/hurd/hurdfault.h index 00ec905..4b6aaed 100644 --- a/hurd/hurdfault.h +++ b/hurd/hurdfault.h @@ -1,5 +1,5 @@ /* Declarations for handling faults in the signal thread. -Copyright (C) 1994 Free Software Foundation, Inc. +Copyright (C) 1994, 1996 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -20,6 +20,7 @@ Cambridge, MA 02139, USA. */ #ifndef _HURD_FAULT_H #define _HURD_FAULT_H +#include <hurd/sigpreempt.h> #include <setjmp.h> /* Call this before code that might fault in the signal thread; SIGNO is @@ -27,23 +28,24 @@ Cambridge, MA 02139, USA. */ returns zero the first time, and returns again nonzero if the signal does arrive. */ -#define _hurdsig_catch_fault(signo) \ - (_hurdsig_fault_expect_signo = (signo), setjmp (_hurdsig_fault_env)) +#define _hurdsig_catch_fault(sigset, firstcode, lastcode) \ + (_hurdsig_fault_preempter.signals = (sigset), \ + _hurdsig_fault_preempter.first = (long int) (firstcode), \ + _hurdsig_fault_preempter.last = (long int) (lastcode), \ + setjmp (_hurdsig_fault_env)) /* Call this at the end of a section protected by _hurdsig_catch_fault. */ #define _hurdsig_end_catch_fault() \ - (_hurdsig_fault_expect_signo = 0) + (_hurdsig_fault_preempter.signals = 0) extern jmp_buf _hurdsig_fault_env; -extern int _hurdsig_fault_expect_signo; +extern struct hurd_signal_preempter _hurdsig_fault_preempter; -/* If _hurdsig_catch_fault returns nonzero, these variables - contain information about the signal that arrived. */ +#define _hurdsig_catch_memory_fault(object) \ + _hurdsig_catch_fault (sigmask (SIGSEGV) | sigmask (SIGBUS), \ + (object), (object) + 1) -extern long int _hurdsig_fault_sigcode; -extern int _hurdsig_fault_sigerror; - -#endif /* hurd/fault.h */ +#endif /* hurdfault.h */ |