about summary refs log tree commit diff
path: root/sysdeps/mach/hurd/i386
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/mach/hurd/i386')
-rw-r--r--sysdeps/mach/hurd/i386/intr-msg.h55
-rw-r--r--sysdeps/mach/hurd/i386/trampoline.c16
2 files changed, 56 insertions, 15 deletions
diff --git a/sysdeps/mach/hurd/i386/intr-msg.h b/sysdeps/mach/hurd/i386/intr-msg.h
index 353a6d2acd..43d244a182 100644
--- a/sysdeps/mach/hurd/i386/intr-msg.h
+++ b/sysdeps/mach/hurd/i386/intr-msg.h
@@ -1,5 +1,5 @@
 /* Machine-dependent details of interruptible RPC messaging.  i386 version.
-Copyright (C) 1995 Free Software Foundation, Inc.
+Copyright (C) 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
@@ -45,3 +45,56 @@ INTR_MSG_BACK_OUT (struct i386_thread_state *state)
   else
     state->ecx = state->uesp;
 }
+
+#include "hurdfault.h"
+
+static inline int
+SYSCALL_EXAMINE (struct i386_thread_state *state, int *callno)
+{
+  struct { unsigned int c[2]; } *p = (void *) (state->eip - 7);
+  int result;
+  if (_hurdsig_catch_memory_fault (p))
+    return 0;
+  if (result = p->c[0] == 0x0000009a && (p->c[1] & 0x00ffffff) == 0x00000700)
+    /* The PC is just after an `lcall $7,$0' instruction.
+       This is a system call in progress; %eax holds the call number.  */
+    *callno = state->eax;
+  _hurdsig_end_catch_fault ();
+  return result;
+}
+
+
+struct mach_msg_trap_args
+  {
+    void *retaddr;		/* Address mach_msg_trap will return to.  */
+    /* This is the order of arguments to mach_msg_trap.  */
+    mach_msg_header_t *msg;
+    mach_msg_option_t option;
+    mach_msg_size_t send_size;
+    mach_msg_size_t rcv_size;
+    mach_port_t rcv_name;
+    mach_msg_timeout_t timeout;
+    mach_port_t notify;
+  };
+
+
+static inline mach_port_t
+MSG_EXAMINE (struct i386_thread_state *state, int *msgid)
+{
+  const struct mach_msg_trap_args *args = (const void *) state->uesp;
+  mach_msg_header_t *msg;
+  mach_port_t send_port;
+
+  if (_hurdsig_catch_memory_fault (args))
+    return MACH_PORT_NULL;
+  msg = args->msg;
+  _hurdsig_end_catch_fault ();
+
+  if (_hurdsig_catch_memory_fault (msg))
+    return MACH_PORT_NULL;
+  send_port = msg->msgh_remote_port;
+  *msgid = msg->msgh_id;
+  _hurdsig_end_catch_fault ();
+
+  return send_port;
+}
diff --git a/sysdeps/mach/hurd/i386/trampoline.c b/sysdeps/mach/hurd/i386/trampoline.c
index f64539a384..bd91c24304 100644
--- a/sysdeps/mach/hurd/i386/trampoline.c
+++ b/sysdeps/mach/hurd/i386/trampoline.c
@@ -23,21 +23,9 @@ Cambridge, MA 02139, USA.  */
 #include <assert.h>
 #include <errno.h>
 #include "hurdfault.h"
+#include "intr-msg.h"
 
 
-struct mach_msg_trap_args
-  {
-    void *retaddr;		/* Address mach_msg_trap will return to.  */
-    /* This is the order of arguments to mach_msg_trap.  */
-    mach_msg_header_t *msg;
-    mach_msg_option_t option;
-    mach_msg_size_t send_size;
-    mach_msg_size_t rcv_size;
-    mach_port_t rcv_name;
-    mach_msg_timeout_t timeout;
-    mach_port_t notify;
-  };
-
 struct sigcontext *
 _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
 			int signo, long int sigcode,
@@ -94,7 +82,7 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, __sighandler_t handler,
 	 per-thread variables, cthreads.  */
     }
   /* This code has intimate knowledge of the special mach_msg system call
-     done in intr-msg.c; that code does:
+     done in intr-msg.c; that code does (see intr-msg.h):
 					movl %esp, %ecx
 					leal ARGS, %esp
 	_hurd_intr_rpc_msg_cx_sp:	movl $-25, %eax