This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 15/15] Hurd signals: Use POSIX sigcodes


* sysdeps/mach/hurd/i386/bits/sigcontext.h: Remove the constants formerly
used as sigcodes.
* manual/signal.texi: "GNU systems" no longer use them.
* hurd/hurdinit.c (_hurd_new_proc_init): Use sigcode TRAP_TRACE for
SIGTRAP on exec.
* sysdeps/mach/hurd/i386/exc2signal.c (_hurd_exception2signal): Use POSIX
sigcodes for exceptions.
* sysdeps/mach/hurd/kill.c (__kill): Use SI_USER for signals sent through kill.
* sysdeps/mach/hurd/setitimer.c (timer_thread): Use SI_TIMER for SIGALRM.
---
 hurd/hurdinit.c                          |    2 +-
 manual/signal.texi                       |    2 +-
 sysdeps/mach/hurd/i386/bits/sigcontext.h |   22 ------
 sysdeps/mach/hurd/i386/exc2signal.c      |  106 ++++++++++++++++-------------
 sysdeps/mach/hurd/kill.c                 |    2 +-
 sysdeps/mach/hurd/setitimer.c            |    2 +-
 6 files changed, 62 insertions(+), 74 deletions(-)

diff --git a/hurd/hurdinit.c b/hurd/hurdinit.c
index 259f8a3..97d3460 100644
--- a/hurd/hurdinit.c
+++ b/hurd/hurdinit.c
@@ -176,7 +176,7 @@ _hurd_new_proc_init (char **argv,
     /* This process is "traced", meaning it should stop on signals or exec.
        We are all set up now to handle signals.  Stop ourselves, to inform
        our parent (presumably a debugger) that the exec has completed.  */
-    __msg_sig_post (_hurd_msgport, SIGTRAP, 0, __mach_task_self ());
+    __msg_sig_post (_hurd_msgport, SIGTRAP, TRAP_TRACE, __mach_task_self ());
 }
 
 #include <shlib-compat.h>
diff --git a/manual/signal.texi b/manual/signal.texi
index 6cdae15..c511a64 100644
--- a/manual/signal.texi
+++ b/manual/signal.texi
@@ -309,7 +309,7 @@ this argument, you must define the handler to accept two arguments,
 which means you must cast it to a one-argument function type in order to
 establish the handler.  The GNU library does provide this extra
 argument, but the value is meaningful only on operating systems that
-provide the information (BSD systems and GNU systems).
+provide the information (BSD systems).
 
 @table @code
 @comment signal.h
diff --git a/sysdeps/mach/hurd/i386/bits/sigcontext.h b/sysdeps/mach/hurd/i386/bits/sigcontext.h
index a78dd2f..a80c6cc 100644
--- a/sysdeps/mach/hurd/i386/bits/sigcontext.h
+++ b/sysdeps/mach/hurd/i386/bits/sigcontext.h
@@ -95,26 +95,4 @@ struct sigcontext
 #define sc_pc	sc_eip		/* Process counter.  */
 #define sc_ps	sc_efl
 
-
-/* Codes for SIGFPE.  */
-#define FPE_INTOVF_TRAP		0x1 /* integer overflow */
-#define FPE_INTDIV_FAULT	0x2 /* integer divide by zero */
-#define FPE_FLTOVF_FAULT	0x3 /* floating overflow */
-#define FPE_FLTDIV_FAULT	0x4 /* floating divide by zero */
-#define FPE_FLTUND_FAULT	0x5 /* floating underflow */
-#define FPE_SUBRNG_FAULT	0x7 /* BOUNDS instruction failed */
-#define FPE_FLTDNR_FAULT	0x8 /* denormalized operand */
-#define FPE_FLTINX_FAULT	0x9 /* floating loss of precision */
-#define FPE_EMERR_FAULT		0xa /* mysterious emulation error 33 */
-#define FPE_EMBND_FAULT		0xb /* emulation BOUNDS instruction failed */
-
-/* Codes for SIGILL.  */
-#define ILL_INVOPR_FAULT	0x1 /* invalid operation */
-#define ILL_STACK_FAULT		0x2 /* fault on microkernel stack access */
-#define ILL_FPEOPR_FAULT	0x3 /* invalid floating operation */
-
-/* Codes for SIGTRAP.  */
-#define DBG_SINGLE_TRAP		0x1 /* single step */
-#define DBG_BRKPNT_FAULT	0x2 /* breakpoint instruction */
-
 #endif /* sc_pc */
diff --git a/sysdeps/mach/hurd/i386/exc2signal.c b/sysdeps/mach/hurd/i386/exc2signal.c
index a6bf750..ef071a4 100644
--- a/sysdeps/mach/hurd/i386/exc2signal.c
+++ b/sysdeps/mach/hurd/i386/exc2signal.c
@@ -37,44 +37,63 @@ _hurd_exception2signal (struct hurd_signal_detail *detail, int *signo)
       break;
 
     case EXC_BAD_ACCESS:
-      if (detail->exc_code == KERN_INVALID_ADDRESS
-	  || detail->exc_code == KERN_PROTECTION_FAILURE
-	  || detail->exc_code == KERN_WRITE_PROTECTION_FAILURE)
-	*signo = SIGSEGV;
-      else
-	*signo = SIGBUS;
-      detail->code = detail->exc_subcode;
+      switch (detail->exc_code)
+        {
+	case KERN_INVALID_ADDRESS:
+	case KERN_MEMORY_FAILURE:
+	  *signo = SIGSEGV;
+	  detail->code = SEGV_MAPERR;
+	  break;
+
+	case KERN_PROTECTION_FAILURE:
+	case KERN_WRITE_PROTECTION_FAILURE:
+	  *signo = SIGSEGV;
+	  detail->code = SEGV_ACCERR;
+	  break;
+
+	default:
+	  *signo = SIGBUS;
+	  detail->code = 0;
+	  break;
+	}
       detail->error = detail->exc_code;
       break;
 
     case EXC_BAD_INSTRUCTION:
       *signo = SIGILL;
-      if (detail->exc_code == EXC_I386_INVOP)
-	detail->code = ILL_INVOPR_FAULT;
-      else if (detail->exc_code == EXC_I386_STKFLT)
-	detail->code = ILL_STACK_FAULT;
-      else
-	detail->code = 0;
+      switch (detail->exc_code)
+        {
+	case EXC_I386_INVOPFLT:
+	  detail->code = ILL_ILLOPC;
+	  break;
+
+	case EXC_I386_STKFLT:
+	  detail->code = ILL_BADSTK;
+	  break;
+
+	case EXC_I386_INVOP:
+	default:
+	  detail->code = 0;
+	  break;
+	}
       break;
 
     case EXC_ARITHMETIC:
+      *signo = SIGFPE;
       switch (detail->exc_code)
 	{
 	case EXC_I386_DIV:	/* integer divide by zero */
-	  *signo = SIGFPE;
-	  detail->code = FPE_INTDIV_FAULT;
+	  detail->code = FPE_INTDIV;
 	  break;
 
 	case EXC_I386_INTO:	/* integer overflow */
-	  *signo = SIGFPE;
-	  detail->code = FPE_INTOVF_TRAP;
+	  detail->code = FPE_INTOVF;
 	  break;
 
 	  /* These aren't anywhere documented or used in Mach 3.0.  */
 	case EXC_I386_NOEXT:
 	case EXC_I386_EXTOVR:
 	default:
-	  *signo = SIGFPE;
 	  detail->code = 0;
 	  break;
 
@@ -83,51 +102,37 @@ _hurd_exception2signal (struct hurd_signal_detail *detail, int *signo)
 	     Give an error code corresponding to the first bit set.  */
 	  if (detail->exc_subcode & FPS_IE)
 	    {
-	      *signo = SIGILL;
-	      detail->code = ILL_FPEOPR_FAULT;
+	      detail->code = FPE_FLTINV;
 	    }
-	  else if (detail->exc_subcode & FPS_DE)
+	  else if (detail->exc_subcode & (FPS_DE | FPS_UE))
 	    {
-	      *signo = SIGFPE;
-	      detail->code = FPE_FLTDNR_FAULT;
+	      detail->code = FPE_FLTUND;
 	    }
 	  else if (detail->exc_subcode & FPS_ZE)
 	    {
-	      *signo = SIGFPE;
-	      detail->code = FPE_FLTDIV_FAULT;
+	      detail->code = FPE_FLTDIV;
 	    }
 	  else if (detail->exc_subcode & FPS_OE)
 	    {
-	      *signo = SIGFPE;
-	      detail->code = FPE_FLTOVF_FAULT;
-	    }
-	  else if (detail->exc_subcode & FPS_UE)
-	    {
-	      *signo = SIGFPE;
-	      detail->code = FPE_FLTUND_FAULT;
+	      detail->code = FPE_FLTOVF;
 	    }
 	  else if (detail->exc_subcode & FPS_PE)
 	    {
-	      *signo = SIGFPE;
-	      detail->code = FPE_FLTINX_FAULT;
+	      detail->code = FPE_FLTRES;
 	    }
 	  else
 	    {
-	      *signo = SIGFPE;
 	      detail->code = 0;
 	    }
 	  break;
 
 	  /* These two can only be arithmetic exceptions if we
-	     are in V86 mode, which sounds like emulation to me.
-	     (See Mach 3.0 i386/trap.c.)  */
+	     are in V86 mode.  (See Mach 3.0 i386/trap.c.)  */
 	case EXC_I386_EMERR:
-	  *signo = SIGFPE;
-	  detail->code = FPE_EMERR_FAULT;
+	  detail->code = 0;
 	  break;
 	case EXC_I386_BOUND:
-	  *signo = SIGFPE;
-	  detail->code = FPE_EMBND_FAULT;
+	  detail->code = FPE_FLTSUB;
 	  break;
 	}
       break;
@@ -144,7 +149,7 @@ _hurd_exception2signal (struct hurd_signal_detail *detail, int *signo)
       if (detail->exc_code == EXC_I386_BOUND)
 	{
 	  *signo = SIGFPE;
-	  detail->code = FPE_SUBRNG_FAULT;
+	  detail->code = FPE_FLTSUB;
 	}
       else
 	{
@@ -155,12 +160,17 @@ _hurd_exception2signal (struct hurd_signal_detail *detail, int *signo)
 
     case EXC_BREAKPOINT:
       *signo = SIGTRAP;
-      if (detail->exc_code == EXC_I386_SGL)
-	detail->code = DBG_SINGLE_TRAP;
-      else if (detail->exc_code == EXC_I386_BPT)
-	detail->code = DBG_BRKPNT_FAULT;
-      else
-	detail->code = 0;
+      switch (detail->exc_code)
+        {
+	case EXC_I386_SGL:
+	case EXC_I386_BPT:
+	  detail->code = TRAP_BRKPT;
+	  break;
+
+	default:
+	  detail->code = 0;
+	  break;
+	}
       break;
     }
 }
diff --git a/sysdeps/mach/hurd/kill.c b/sysdeps/mach/hurd/kill.c
index a9946e0..ac7ffc7 100644
--- a/sysdeps/mach/hurd/kill.c
+++ b/sysdeps/mach/hurd/kill.c
@@ -65,7 +65,7 @@ __kill (pid_t pid, int sig)
 	    {
 	      if (msgport != MACH_PORT_NULL)
 		/* Send a signal message to his message port.  */
-		return __msg_sig_post (msgport, sig, 0, refport);
+		return __msg_sig_post (msgport, sig, SI_USER, refport);
 
 	      /* The process has no message port.  Perhaps try direct
 		 frobnication of the task.  */
diff --git a/sysdeps/mach/hurd/setitimer.c b/sysdeps/mach/hurd/setitimer.c
index fec64a8..c82bfcd 100644
--- a/sysdeps/mach/hurd/setitimer.c
+++ b/sysdeps/mach/hurd/setitimer.c
@@ -105,7 +105,7 @@ timer_thread (void)
 	  __msg_sig_post_request (_hurd_msgport,
 				  _hurd_itimer_port,
 				  MACH_MSG_TYPE_MAKE_SEND_ONCE,
-				  SIGALRM, 0, __mach_task_self ());
+				  SIGALRM, SI_TIMER, __mach_task_self ());
 	  break;
 
 	case MACH_RCV_INTERRUPTED:
-- 
1.7.5.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]