Skip to content

Commit

Permalink
Mon Aug 14 16:51:13 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
Browse files Browse the repository at this point in the history
	* hurd/thread-cancel.c: New file.
	* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler): In
 	rpc_wait case, frob mach_msg args to set timeout on receive.
	(_hurdsig_rcv_interrupted_p): Function removed.
	* sysdeps/mach/hurd/alpha/trampoline.c: Likewise.
	* sysdeps/mach/hurd/hppa/trampoline.c: Likewise.
	* sysdeps/mach/hurd/mips/trampoline.c: Likewise.
	* hurd/intr-msg.c: New file.
	* hurd/hurd/signal.h (struct hurd_sigstate): New member `cancel'.
	(_hurdsig_rcv_interrupted_p): Declaration removed.
	(HURD_EINTR_RPC): Macro removed.
	(_hurd_longjmp_thread_state, _hurd_interrupted_rpc_timeout): Declare
	these.
	* hurd/intr-rpc.h: New file.
	* hurd/intr-rpc.defs: Just import intr-rpc.h.
	* hurd/hurdsig.c (_hurd_interrupted_rpc_timeout): New variable.
	(interrupted_reply_port_location): Take new flag arg; only catch
	faults if it's set.
	(abort_rpcs): Rename to _hurdsig_abort_rpcs; take same new flag arg.
	No longer use _hurdsig_rcv_interrupted_p; instead compare PC to
 	&_hurd_intr_rpc_msg_in_trap.  If before it, mutate state to simulate
 	MACH_SEND_INTERRUPTED return; on it, interrupt the operation.  All
 	callers changed.
	* hurd/hurd.h (hurd_thread_cancel, hurd_check_cancel): Declare these.
	* hurd/Makefile (distribute): Remove intr-rpc.awk.
	(sig): Add thread-cancel.
	(transform-user-stub, transform-user-stub-output): Variables removed.
	* sysdeps/mach/hurd/dl-sysdep.c: Change all RPCs from
 	`__hurd_intr_rpc_*' to `__*'.
	(_hurd_intr_rpc_mach_msg): New function.
	(_hurd_thread_sigstate): Function removed.
	* sysdeps/mach/hurd/ioctl.c: Use _hurd_intr_rpc_mach_msg function,
 	instead of __mach_msg inside HURD_EINTR_RPC macro.

	* sysdeps/generic/morecore.c [__GNU_LIBRARY__]: Declare `__sbrk'
 	to take ptrdiff_t arg.

	* sysdeps/mach/hurd/fork.c: Remove _hurd_longjmp_thread_state decl.

	* sysdeps/mach/hurd/kill.c (kill_pid): Don't make `inline'.

	* libc-symbols.h [GCC >= 2.7] (strong_alias, weak_symbol,
 	weak_alias): Use `extern' storage class.
  • Loading branch information
Roland McGrath committed Aug 14, 1995
1 parent 047f282 commit 54da5be
Show file tree
Hide file tree
Showing 19 changed files with 493 additions and 339 deletions.
46 changes: 46 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
Mon Aug 14 16:51:13 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>

* hurd/thread-cancel.c: New file.
* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler): In
rpc_wait case, frob mach_msg args to set timeout on receive.
(_hurdsig_rcv_interrupted_p): Function removed.
* sysdeps/mach/hurd/alpha/trampoline.c: Likewise.
* sysdeps/mach/hurd/hppa/trampoline.c: Likewise.
* sysdeps/mach/hurd/mips/trampoline.c: Likewise.
* hurd/intr-msg.c: New file.
* hurd/hurd/signal.h (struct hurd_sigstate): New member `cancel'.
(_hurdsig_rcv_interrupted_p): Declaration removed.
(HURD_EINTR_RPC): Macro removed.
(_hurd_longjmp_thread_state, _hurd_interrupted_rpc_timeout): Declare
these.
* hurd/intr-rpc.h: New file.
* hurd/intr-rpc.defs: Just import intr-rpc.h.
* hurd/hurdsig.c (_hurd_interrupted_rpc_timeout): New variable.
(interrupted_reply_port_location): Take new flag arg; only catch
faults if it's set.
(abort_rpcs): Rename to _hurdsig_abort_rpcs; take same new flag arg.
No longer use _hurdsig_rcv_interrupted_p; instead compare PC to
&_hurd_intr_rpc_msg_in_trap. If before it, mutate state to simulate
MACH_SEND_INTERRUPTED return; on it, interrupt the operation. All
callers changed.
* hurd/hurd.h (hurd_thread_cancel, hurd_check_cancel): Declare these.
* hurd/Makefile (distribute): Remove intr-rpc.awk.
(sig): Add thread-cancel.
(transform-user-stub, transform-user-stub-output): Variables removed.
* sysdeps/mach/hurd/dl-sysdep.c: Change all RPCs from
`__hurd_intr_rpc_*' to `__*'.
(_hurd_intr_rpc_mach_msg): New function.
(_hurd_thread_sigstate): Function removed.
* sysdeps/mach/hurd/ioctl.c: Use _hurd_intr_rpc_mach_msg function,
instead of __mach_msg inside HURD_EINTR_RPC macro.

* sysdeps/generic/morecore.c [__GNU_LIBRARY__]: Declare `__sbrk'
to take ptrdiff_t arg.

* sysdeps/mach/hurd/fork.c: Remove _hurd_longjmp_thread_state decl.

* sysdeps/mach/hurd/kill.c (kill_pid): Don't make `inline'.

* libc-symbols.h [GCC >= 2.7] (strong_alias, weak_symbol,
weak_alias): Use `extern' storage class.

Wed Aug 9 14:25:35 1995 Miles Bader <miles@geech.gnu.ai.mit.edu>

* sysdeps/mach/hurd/setuid.c (__setuid): Switch the port-type and
Expand Down
20 changes: 4 additions & 16 deletions hurd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ headers = hurd.h $(interface-headers) \
$(addprefix hurd/,fd.h id.h port.h signal.h userlink.h \
resource.h threadvar.h)

distribute := hurdstartup.h hurdfault.h intr-rpc.awk intr-rpc.defs STATUS
distribute := hurdstartup.h hurdfault.h intr-rpc.defs STATUS

# The RPC interfaces go in a separate library.
interface-library := libhurduser
Expand All @@ -53,7 +53,7 @@ routines = hurdstartup hurdinit \
$(sig) $(dtable) hurdinline port-cleanup
sig = hurdsig hurdfault faultexc siginfo hurd-raise preempt-sig \
trampoline longjmp-ts catch-exc exc2signal hurdkill sigunwind \
thread-self
thread-self thread-cancel
dtable = dtable port2fd new-fd alloc-fd intern-fd \
getdport openport \
fd-close fd-read fd-write hurdioctl ctty-input ctty-output
Expand Down Expand Up @@ -88,25 +88,13 @@ include ../mach/Machrules
include ../Rules

# intr-rpc.defs defines the INTR_INTERFACE macro to make the generated RPC
# stubs send-interruptible, and to prefix them with `hurd_intr_rpc_'.
# stubs import <hurd/signal.h> and #define __mach_msg to
# _hurd_intr_rpc_mach_msg.
user-MIGFLAGS += -imacros intr-rpc.defs

# Run each generated user stub through intr-rpc.awk, which will detect
# stubs __hurd_intr_rpc_% and generate the user-callable function for the
# stub: this is a wrapper which calls __hurd_intr_rpc_% inside
# HURD_EINTR_RPC.
define transform-user-stub
gawk -v call=$${call} -f $(word 2,$^) \
$(objpfx)tmp_$${call}.c > $(objpfx)tmpi_$${call}.c; \
rm -f $(objpfx)tmp_$${call}.c;
endef
transform-user-stub-output = tmpi

$(foreach if,$(user-interfaces),$($(if)-calls:%=$(objpfx)RPC_%.o))): \
hurd/signal.h

$(user-interfaces:%=$(objpfx)%.ustamp): intr-rpc.awk

$(objpfx)fault%.c $(objpfx)fault%.h: $(mach-srcdir)/mach/%.defs
$(MIG) $(MIGFLAGS) -prefix _hurdsig_fault_ \
-server $(@:.h=.c) -sheader $(@:.c=.h) \
Expand Down
10 changes: 10 additions & 0 deletions hurd/hurd.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,16 @@ extern task_t __pid2task (pid_t pid), pid2task (pid_t pid);
extern thread_t hurd_thread_self (void);


/* Cancel pending operations on THREAD. If it is doing an interruptible RPC,
that RPC will now return EINTR; otherwise, the "cancelled" flag will be
set, causing the next `hurd_check_cancel' call to return nonzero or the
next interruptible RPC to return EINTR (whichever is called first). */
extern error_t hurd_thread_cancel (thread_t thread);

/* Test and clear the calling thread's "cancelled" flag. */
extern int hurd_check_cancel (void);


/* Return the io server port for file descriptor FD.
This adds a Mach user reference to the returned port.
On error, sets `errno' and returns MACH_PORT_NULL. */
Expand Down
62 changes: 9 additions & 53 deletions hurd/hurd/signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ struct hurd_sigstate
<hurd/userlink.h> for details. This member is only used by the
thread itself, and always inside a critical section. */
struct hurd_userlink *active_resources;

volatile int cancel; /* Flag set by hurd_thread_cancel. */
};

/* Linked list of states of all threads whose state has been asked for. */
Expand Down Expand Up @@ -253,71 +255,25 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,

extern void _hurd_msgport_receive (void);

/* STATE describes a thread that had intr_port set (meaning it was inside
HURD_EINTR_RPC), after it has been thread_abort'd. It it looks to have
just completed a mach_msg_trap system call that returned
MACH_RCV_INTERRUPTED, return nonzero and set *PORT to the receive right
being waited on. */

extern int _hurdsig_rcv_interrupted_p (struct machine_thread_all_state *state,
mach_port_t *port);

/* Set up STATE with a thread state that, when resumed, is
like `longjmp (_hurd_sigthread_fault_env, 1)'. */

extern void _hurd_initialize_fault_recovery_state (void *state);

/* Set up STATE to do the equivalent of `longjmp (ENV, VAL);'. */

extern void _hurd_longjmp_thread_state (void *state, jmp_buf env, int value);

/* Function run for SIGINFO when its action is SIG_DFL and the current
process is the session leader. */

extern void _hurd_siginfo_handler (int);


/* Perform interruptible RPC CALL on PORT.
The call should use
The args in CALL should be constant or local variable refs.
They may be evaluated many times, and must not change.
PORT must not be deallocated before this RPC is finished. */
#define HURD_EINTR_RPC(port, call) \
({ \
__label__ __do_call; /* Give this label block scope. */ \
error_t __err; \
struct hurd_sigstate *__ss = _hurd_self_sigstate (); \
__do_call: \
/* Tell the signal thread that we are doing an interruptible RPC on \
this port. If we get a signal and should return EINTR, the signal \
thread will set this variable to MACH_PORT_NULL. The RPC might \
return EINTR when some other thread gets a signal, in which case we \
want to restart our call. */ \
__ss->intr_port = (port); \
/* A signal may arrive here, after intr_port is set, but before the \
mach_msg system call. The signal handler might do an interruptible \
RPC, and clobber intr_port; then it would not be set properly when \
we actually did send the RPC, and a later signal wouldn't interrupt \
that RPC. So, _hurd_setup_sighandler saves intr_port in the \
sigcontext, and sigreturn restores it. */ \
switch (__err = (call)) \
{ \
case EINTR: /* RPC went out and was interrupted. */ \
case MACH_SEND_INTERRUPTED: /* RPC didn't get out. */ \
if (__ss->intr_port != MACH_PORT_NULL) \
/* If this signal was for us and it should interrupt calls, the \
signal thread will have cleared SS->intr_port. Since it's not \
cleared, the signal was for another thread, or SA_RESTART is \
set. Restart the interrupted call. */ \
goto __do_call; \
/* FALLTHROUGH */ \
case MACH_RCV_PORT_DIED: \
/* Server didn't respond to interrupt_operation, \
so the signal thread destroyed the reply port. */ \
__err = EINTR; \
break; \
default: /* Quiet -Wswitch-enum. */ \
} \
__ss->intr_port = MACH_PORT_NULL; \
__err; \
}) \
/* Milliseconds to wait for an interruptible RPC to return after
`interrupt_operation'. */

extern mach_msg_timeout_t _hurd_interrupted_rpc_timeout;


/* Mask of signals that cannot be caught, blocked, or ignored. */
Expand Down
Loading

0 comments on commit 54da5be

Please sign in to comment.