This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

[RFC 4/6] Change target_signal_t to a struct


Hi,

there is no compiled code change in this patch.  It changes `target_signal_t'
from enum (=sizeof 4 bytes) into struct (=sizeof 4 bytes).  ABI passes it
normally in register the same way.  There are two purposes:

 * Make target_signal_t compile time incompatible with `int host_signal' as it
   prevents needless bugs as fixed in the recent thread:
   [patch] enum target_signal vs. int host_signal
   http://sourceware.org/ml/gdb-patches/2010-07/msg00380.html

 * Provide possibility to associate more information with `target_signal_t'.
   (In the later patchset.)

It would get easier with C++ but GDB is not written in C++.  Therefore
I followed the thread approving accessor macros in current GDB.
	gdbtypes.h #defined field accessors
	http://sourceware.org/ml/gdb/2010-06/msg00121.html
This makes the code more flexible for future possible changes/optimizations of
target_signal_t.

I would fill-in the gdb/ ChangeLog if the patch'es idea does not get rejected.
I understand the order is not right.  Writing the ChangeLog will be a very
costly task that could get dropped in several seconds of a first review.


Thanks,
Jan


include/gdb/
2010-07-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* signals.h: Change target signal definitions to *_NUMBER ones.
	Define the target signals as `static const target_signal_t
	ATTRIBUTE_UNUSED' now.
	(target_signal_t): Change the content to ...
	(enum target_signal_number): ... this one.
	(target_signal_t): New struct typedef.
	(TARGET_SIGNAL_NUMBER_CONST, TARGET_SIGNAL_INITIALIZER)
	(TARGET_SIGNAL_NUMBER, target_signal_from_number, TARGET_SIGNAL_EQ)
	(TARGET_SIGNAL_NE, TARGET_SIGNAL_LT, TARGET_SIGNAL_GT)
	(TARGET_SIGNAL_LE, TARGET_SIGNAL_GE): New accessors.

gdb/
2010-07-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* common/signals.c: Use target_signal_t accessors.
	* corelow.c: Likewise.
	* fork-child.c: Likewise.
	* infcmd.c: Likewise.
	* inferior.h: Likewise.
	* infrun.c: Likewise.
	* linux-nat.c: Likewise.
	* linux-thread-db.c: Likewise.
	* record.c: Likewise.
	* remote-m32r-sdi.c: Likewise.
	* remote.c: Likewise.
	* solib-irix.c: Likewise.

gdb/gdbserver/
2010-07-26  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* linux-low.c: Use target_signal_t accessors.
	* remote-utils.c: Likewise.
	* server.c: Likewise.
	* server.h: Likewise.
	* target.c: Likewise.

--- a/gdb/common/signals.c
+++ b/gdb/common/signals.c
@@ -62,24 +62,27 @@ static const struct {
 #undef SET
 };
 
+#define SIGNALS(target_signal) signals[TARGET_SIGNAL_NUMBER (target_signal)]
 
 /* Return the string for a signal.  */
 const char *
 target_signal_to_string (target_signal_t sig)
 {
-  if ((int) sig >= TARGET_SIGNAL_FIRST && (int) sig <= TARGET_SIGNAL_LAST)
-    return signals[sig].string;
+  if (TARGET_SIGNAL_GE (sig, TARGET_SIGNAL_FIRST)
+      && TARGET_SIGNAL_LE (sig, TARGET_SIGNAL_LAST))
+    return SIGNALS (sig).string;
   else
-    return signals[TARGET_SIGNAL_UNKNOWN].string;
+    return SIGNALS (TARGET_SIGNAL_UNKNOWN).string;
 }
 
 /* Return the name for a signal.  */
 const char *
 target_signal_to_name (target_signal_t sig)
 {
-  if ((int) sig >= TARGET_SIGNAL_FIRST && (int) sig <= TARGET_SIGNAL_LAST
-      && signals[sig].name != NULL)
-    return signals[sig].name;
+  if (TARGET_SIGNAL_GE (sig, TARGET_SIGNAL_FIRST)
+      && TARGET_SIGNAL_LE (sig, TARGET_SIGNAL_LAST)
+      && SIGNALS (sig).name != NULL)
+    return SIGNALS (sig).name;
   else
     /* I think the code which prints this will always print it along
        with the string, so no need to be verbose (very old comment).  */
@@ -99,10 +102,9 @@ target_signal_from_name (const char *name)
 
   /* This ugly cast brought to you by the native VAX compiler.  */
   for (sig = TARGET_SIGNAL_HUP;
-       sig < TARGET_SIGNAL_LAST;
-       sig = (target_signal_t) ((int) sig + 1))
-    if (signals[sig].name != NULL
-	&& strcmp (name, signals[sig].name) == 0)
+       TARGET_SIGNAL_LT (sig, TARGET_SIGNAL_LAST);
+       TARGET_SIGNAL_NUMBER (sig)++)
+    if (SIGNALS (sig).name != NULL && strcmp (name, SIGNALS (sig).name) == 0)
       return sig;
   return TARGET_SIGNAL_UNKNOWN;
 }
@@ -342,13 +344,13 @@ target_signal_from_host (int hostsig)
     {
       /* This block of TARGET_SIGNAL_REALTIME value is in order.  */
       if (33 <= hostsig && hostsig <= 63)
-	return (target_signal_t)
-	  (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
+	return target_signal_from_number
+	  (hostsig - 33 + TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_REALTIME_33));
       else if (hostsig == 32)
 	return TARGET_SIGNAL_REALTIME_32;
       else if (64 <= hostsig && hostsig <= 127)
-	return (target_signal_t)
-	  (hostsig - 64 + (int) TARGET_SIGNAL_REALTIME_64);
+	return target_signal_from_number
+	  (hostsig - 64 + TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_REALTIME_64));
       else
 	error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal");
     }
@@ -372,81 +374,81 @@ do_target_signal_to_host (target_signal_t oursig,
   (void) retsig;
 
   *oursig_ok = 1;
-  switch (oursig)
+  switch (TARGET_SIGNAL_NUMBER (oursig))
     {
-    case TARGET_SIGNAL_0:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_0):
       return 0;
 
 #if defined (SIGHUP)
-    case TARGET_SIGNAL_HUP:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_HUP):
       return SIGHUP;
 #endif
 #if defined (SIGINT)
-    case TARGET_SIGNAL_INT:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_INT):
       return SIGINT;
 #endif
 #if defined (SIGQUIT)
-    case TARGET_SIGNAL_QUIT:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_QUIT):
       return SIGQUIT;
 #endif
 #if defined (SIGILL)
-    case TARGET_SIGNAL_ILL:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_ILL):
       return SIGILL;
 #endif
 #if defined (SIGTRAP)
-    case TARGET_SIGNAL_TRAP:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_TRAP):
       return SIGTRAP;
 #endif
 #if defined (SIGABRT)
-    case TARGET_SIGNAL_ABRT:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_ABRT):
       return SIGABRT;
 #endif
 #if defined (SIGEMT)
-    case TARGET_SIGNAL_EMT:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_EMT):
       return SIGEMT;
 #endif
 #if defined (SIGFPE)
-    case TARGET_SIGNAL_FPE:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_FPE):
       return SIGFPE;
 #endif
 #if defined (SIGKILL)
-    case TARGET_SIGNAL_KILL:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_KILL):
       return SIGKILL;
 #endif
 #if defined (SIGBUS)
-    case TARGET_SIGNAL_BUS:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_BUS):
       return SIGBUS;
 #endif
 #if defined (SIGSEGV)
-    case TARGET_SIGNAL_SEGV:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_SEGV):
       return SIGSEGV;
 #endif
 #if defined (SIGSYS)
-    case TARGET_SIGNAL_SYS:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_SYS):
       return SIGSYS;
 #endif
 #if defined (SIGPIPE)
-    case TARGET_SIGNAL_PIPE:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_PIPE):
       return SIGPIPE;
 #endif
 #if defined (SIGALRM)
-    case TARGET_SIGNAL_ALRM:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_ALRM):
       return SIGALRM;
 #endif
 #if defined (SIGTERM)
-    case TARGET_SIGNAL_TERM:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_TERM):
       return SIGTERM;
 #endif
 #if defined (SIGUSR1)
-    case TARGET_SIGNAL_USR1:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_USR1):
       return SIGUSR1;
 #endif
 #if defined (SIGUSR2)
-    case TARGET_SIGNAL_USR2:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_USR2):
       return SIGUSR2;
 #endif
 #if defined (SIGCHLD) || defined (SIGCLD)
-    case TARGET_SIGNAL_CHLD:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_CHLD):
 #if defined (SIGCHLD)
       return SIGCHLD;
 #else
@@ -454,142 +456,142 @@ do_target_signal_to_host (target_signal_t oursig,
 #endif
 #endif /* SIGCLD or SIGCHLD */
 #if defined (SIGPWR)
-    case TARGET_SIGNAL_PWR:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_PWR):
       return SIGPWR;
 #endif
 #if defined (SIGWINCH)
-    case TARGET_SIGNAL_WINCH:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_WINCH):
       return SIGWINCH;
 #endif
 #if defined (SIGURG)
-    case TARGET_SIGNAL_URG:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_URG):
       return SIGURG;
 #endif
 #if defined (SIGIO)
-    case TARGET_SIGNAL_IO:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_IO):
       return SIGIO;
 #endif
 #if defined (SIGPOLL)
-    case TARGET_SIGNAL_POLL:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_POLL):
       return SIGPOLL;
 #endif
 #if defined (SIGSTOP)
-    case TARGET_SIGNAL_STOP:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_STOP):
       return SIGSTOP;
 #endif
 #if defined (SIGTSTP)
-    case TARGET_SIGNAL_TSTP:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_TSTP):
       return SIGTSTP;
 #endif
 #if defined (SIGCONT)
-    case TARGET_SIGNAL_CONT:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_CONT):
       return SIGCONT;
 #endif
 #if defined (SIGTTIN)
-    case TARGET_SIGNAL_TTIN:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_TTIN):
       return SIGTTIN;
 #endif
 #if defined (SIGTTOU)
-    case TARGET_SIGNAL_TTOU:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_TTOU):
       return SIGTTOU;
 #endif
 #if defined (SIGVTALRM)
-    case TARGET_SIGNAL_VTALRM:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_VTALRM):
       return SIGVTALRM;
 #endif
 #if defined (SIGPROF)
-    case TARGET_SIGNAL_PROF:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_PROF):
       return SIGPROF;
 #endif
 #if defined (SIGXCPU)
-    case TARGET_SIGNAL_XCPU:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_XCPU):
       return SIGXCPU;
 #endif
 #if defined (SIGXFSZ)
-    case TARGET_SIGNAL_XFSZ:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_XFSZ):
       return SIGXFSZ;
 #endif
 #if defined (SIGWIND)
-    case TARGET_SIGNAL_WIND:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_WIND):
       return SIGWIND;
 #endif
 #if defined (SIGPHONE)
-    case TARGET_SIGNAL_PHONE:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_PHONE):
       return SIGPHONE;
 #endif
 #if defined (SIGLOST)
-    case TARGET_SIGNAL_LOST:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_LOST):
       return SIGLOST;
 #endif
 #if defined (SIGWAITING)
-    case TARGET_SIGNAL_WAITING:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_WAITING):
       return SIGWAITING;
 #endif
 #if defined (SIGCANCEL)
-    case TARGET_SIGNAL_CANCEL:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_CANCEL):
       return SIGCANCEL;
 #endif
 #if defined (SIGLWP)
-    case TARGET_SIGNAL_LWP:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_LWP):
       return SIGLWP;
 #endif
 #if defined (SIGDANGER)
-    case TARGET_SIGNAL_DANGER:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_DANGER):
       return SIGDANGER;
 #endif
 #if defined (SIGGRANT)
-    case TARGET_SIGNAL_GRANT:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_GRANT):
       return SIGGRANT;
 #endif
 #if defined (SIGRETRACT)
-    case TARGET_SIGNAL_RETRACT:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_RETRACT):
       return SIGRETRACT;
 #endif
 #if defined (SIGMSG)
-    case TARGET_SIGNAL_MSG:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_MSG):
       return SIGMSG;
 #endif
 #if defined (SIGSOUND)
-    case TARGET_SIGNAL_SOUND:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_SOUND):
       return SIGSOUND;
 #endif
 #if defined (SIGSAK)
-    case TARGET_SIGNAL_SAK:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_SAK):
       return SIGSAK;
 #endif
 #if defined (SIGPRIO)
-    case TARGET_SIGNAL_PRIO:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_PRIO):
       return SIGPRIO;
 #endif
 
       /* Mach exceptions.  Assumes that the values for EXC_ are positive! */
 #if defined (EXC_BAD_ACCESS) && defined (_NSIG)
-    case TARGET_EXC_BAD_ACCESS:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_EXC_BAD_ACCESS):
       return _NSIG + EXC_BAD_ACCESS;
 #endif
 #if defined (EXC_BAD_INSTRUCTION) && defined (_NSIG)
-    case TARGET_EXC_BAD_INSTRUCTION:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_EXC_BAD_INSTRUCTION):
       return _NSIG + EXC_BAD_INSTRUCTION;
 #endif
 #if defined (EXC_ARITHMETIC) && defined (_NSIG)
-    case TARGET_EXC_ARITHMETIC:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_EXC_ARITHMETIC):
       return _NSIG + EXC_ARITHMETIC;
 #endif
 #if defined (EXC_EMULATION) && defined (_NSIG)
-    case TARGET_EXC_EMULATION:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_EXC_EMULATION):
       return _NSIG + EXC_EMULATION;
 #endif
 #if defined (EXC_SOFTWARE) && defined (_NSIG)
-    case TARGET_EXC_SOFTWARE:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_EXC_SOFTWARE):
       return _NSIG + EXC_SOFTWARE;
 #endif
 #if defined (EXC_BREAKPOINT) && defined (_NSIG)
-    case TARGET_EXC_BREAKPOINT:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_EXC_BREAKPOINT):
       return _NSIG + EXC_BREAKPOINT;
 #endif
 
 #if defined (SIGINFO)
-    case TARGET_SIGNAL_INFO:
+    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_INFO):
       return SIGINFO;
 #endif
 
@@ -597,25 +599,27 @@ do_target_signal_to_host (target_signal_t oursig,
 #if defined (REALTIME_LO)
       retsig = 0;
 
-      if (oursig >= TARGET_SIGNAL_REALTIME_33
-	  && oursig <= TARGET_SIGNAL_REALTIME_63)
+      if (TARGET_SIGNAL_GE (oursig, TARGET_SIGNAL_REALTIME_33)
+	  && TARGET_SIGNAL_LE (oursig, TARGET_SIGNAL_REALTIME_63))
 	{
 	  /* This block of signals is continuous, and
              TARGET_SIGNAL_REALTIME_33 is 33 by definition.  */
-	  retsig = (int) oursig - (int) TARGET_SIGNAL_REALTIME_33 + 33;
+	  retsig = (TARGET_SIGNAL_NUMBER (oursig)
+		    - TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_REALTIME_33) + 33);
 	}
-      else if (oursig == TARGET_SIGNAL_REALTIME_32)
+      else if (TARGET_SIGNAL_EQ (oursig, TARGET_SIGNAL_REALTIME_32))
 	{
 	  /* TARGET_SIGNAL_REALTIME_32 isn't contiguous with
              TARGET_SIGNAL_REALTIME_33.  It is 32 by definition.  */
 	  retsig = 32;
 	}
-      else if (oursig >= TARGET_SIGNAL_REALTIME_64
-	  && oursig <= TARGET_SIGNAL_REALTIME_127)
+      else if (TARGET_SIGNAL_GE (oursig, TARGET_SIGNAL_REALTIME_64)
+	       && TARGET_SIGNAL_LE (oursig, TARGET_SIGNAL_REALTIME_127))
 	{
 	  /* This block of signals is continuous, and
              TARGET_SIGNAL_REALTIME_64 is 64 by definition.  */
-	  retsig = (int) oursig - (int) TARGET_SIGNAL_REALTIME_64 + 64;
+	  retsig = (TARGET_SIGNAL_NUMBER (oursig)
+		    - TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_REALTIME_64) + 64);
 	}
 
       if (retsig >= REALTIME_LO && retsig < REALTIME_HI)
@@ -666,7 +670,7 @@ target_signal_t
 target_signal_from_command (int num)
 {
   if (num >= 1 && num <= 15)
-    return (target_signal_t) num;
+    return target_signal_from_number (num);
   error ("Only signals 1-15 are valid as numeric signals.\n\
 Use \"info signals\" for a list of symbolic signals.");
 }
@@ -676,7 +680,8 @@ extern initialize_file_ftype _initialize_signals; /* -Wmissing-prototype */
 void
 _initialize_signals (void)
 {
-  if (strcmp (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC") != 0)
+  if (strcmp (SIGNALS (TARGET_SIGNAL_LAST).string, "TARGET_SIGNAL_MAGIC")
+      != 0)
     internal_error (__FILE__, __LINE__, "failed internal consistency check");
 }
 
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -448,10 +448,9 @@ core_open (char *filename, int from_tty)
        value is called ``target_signal_t'' and this function got the
        name ..._from_host(). */
     printf_filtered (_("Program terminated with signal %d, %s.\n"), siggy,
-		     target_signal_to_string (
-		       (core_gdbarch != NULL) ?
-			gdbarch_target_signal_from_host (core_gdbarch, siggy)
-			: siggy));
+		     target_signal_to_string (core_gdbarch != NULL
+		       ? gdbarch_target_signal_from_host (core_gdbarch, siggy)
+		       : TARGET_SIGNAL_0));
 
   /* Fetch all registers from core file.  */
   target_fetch_registers (get_current_regcache (), -1);
--- a/gdb/fork-child.c
+++ b/gdb/fork-child.c
@@ -448,7 +448,7 @@ startup_inferior (int ntraps)
 
   while (1)
     {
-      int resume_signal = TARGET_SIGNAL_0;
+      target_signal_t resume_signal = TARGET_SIGNAL_0;
       ptid_t event_ptid;
 
       struct target_waitstatus ws;
@@ -502,7 +502,7 @@ startup_inferior (int ntraps)
 	    break;
 	}
 
-      if (resume_signal != TARGET_SIGNAL_TRAP)
+      if (TARGET_SIGNAL_NE (resume_signal, TARGET_SIGNAL_TRAP))
 	{
 	  /* Let shell child handle its own signals in its own way.  */
 	  target_resume (resume_ptid, 0, resume_signal);
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -1942,7 +1942,7 @@ linux_stabilize_threads (void)
 	  /* Lock it.  */
 	  lwp->suspended++;
 
-	  if (ourstatus.value.sig != TARGET_SIGNAL_0
+	  if (TARGET_SIGNAL_NE (ourstatus.value.sig, TARGET_SIGNAL_0)
 	      || current_inferior->last_resume_kind == resume_stop)
 	    {
 	      wstat = W_STOPCODE (target_signal_to_host (ourstatus.value.sig));
@@ -2260,7 +2260,7 @@ Check if we're already there.\n",
 	       || WSTOPSIG (w) == __SIGRTMIN + 1))
 	  ||
 #endif
-	  (pass_signals[target_signal_from_host (WSTOPSIG (w))]
+	  (PASS_SIGNALS (target_signal_from_host (WSTOPSIG (w)))
 	   && !(WSTOPSIG (w) == SIGSTOP
 		&& current_inferior->last_resume_kind == resume_stop))))
     {
@@ -2434,7 +2434,7 @@ Check if we're already there.\n",
     fprintf (stderr, "linux_wait ret = %s, %d, %d\n",
 	     target_pid_to_str (ptid_of (event_child)),
 	     ourstatus->kind,
-	     ourstatus->value.sig);
+	     ourstatus->value.integer);
 
   current_inferior->last_status = *ourstatus;
 
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -1238,7 +1238,7 @@ prepare_resume_reply (char *buf, ptid_t ptid,
 	const char **regp;
 	struct regcache *regcache;
 
-	sprintf (buf, "T%02x", status->value.sig);
+	sprintf (buf, "T%02x", TARGET_SIGNAL_NUMBER (status->value.sig));
 	buf += strlen (buf);
 
 	regp = gdbserver_expedite_regs;
@@ -1337,9 +1337,10 @@ prepare_resume_reply (char *buf, ptid_t ptid,
     case TARGET_WAITKIND_SIGNALLED:
       if (multi_process)
 	sprintf (buf, "X%x;process:%x",
-		 status->value.sig, ptid_get_pid (ptid));
+		 TARGET_SIGNAL_NUMBER (status->value.sig),
+		 ptid_get_pid (ptid));
       else
-	sprintf (buf, "X%02x", status->value.sig);
+	sprintf (buf, "X%02x", TARGET_SIGNAL_NUMBER (status->value.sig));
       break;
     default:
       error ("unhandled waitkind");
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -54,7 +54,7 @@ int debug_threads;
 /* Enable debugging of h/w breakpoint/watchpoint support.  */
 int debug_hw_points;
 
-int pass_signals[TARGET_SIGNAL_LAST];
+int pass_signals[TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_LAST)];
 
 jmp_buf toplevel;
 
@@ -293,7 +293,7 @@ start_inferior (char **argv)
 	  if (last_status.kind != TARGET_WAITKIND_STOPPED)
 	    return signal_pid;
 	}
-      while (last_status.value.sig != TARGET_SIGNAL_TRAP);
+      while (TARGET_SIGNAL_NE (last_status.value.sig, TARGET_SIGNAL_TRAP));
 
       return signal_pid;
     }
@@ -330,7 +330,7 @@ attach_inferior (int pid)
 	 process using the "attach" command, but this is different; it's
 	 just using "target remote".  Pretend it's just starting up.  */
       if (last_status.kind == TARGET_WAITKIND_STOPPED
-	  && last_status.value.sig == TARGET_SIGNAL_STOP)
+	  && TARGET_SIGNAL_EQ (last_status.value.sig, TARGET_SIGNAL_STOP))
 	last_status.value.sig = TARGET_SIGNAL_TRAP;
     }
 
@@ -385,16 +385,17 @@ handle_general_set (char *own_buf)
 {
   if (strncmp ("QPassSignals:", own_buf, strlen ("QPassSignals:")) == 0)
     {
-      int numsigs = (int) TARGET_SIGNAL_LAST, i;
+      enum target_signal_number signum;
       const char *p = own_buf + strlen ("QPassSignals:");
       CORE_ADDR cursig;
 
       p = decode_address_to_semicolon (&cursig, p);
-      for (i = 0; i < numsigs; i++)
+      for (signum = 0; signum < TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_LAST);
+	   signum++)
 	{
-	  if (i == cursig)
+	  if (signum == cursig)
 	    {
-	      pass_signals[i] = 1;
+	      pass_signals[signum] = 1;
 	      if (*p == '\0')
 		/* Keep looping, to clear the remaining signals.  */
 		cursig = -1;
@@ -402,7 +403,7 @@ handle_general_set (char *own_buf)
 		p = decode_address_to_semicolon (&cursig, p);
 	    }
 	  else
-	    pass_signals[i] = 0;
+	    pass_signals[signum] = 0;
 	}
       strcpy (own_buf, "OK");
       return;
@@ -1713,8 +1714,9 @@ handle_v_cont (char *own_buf)
 
       if (p[0] == 'S' || p[0] == 'C')
 	{
-	  int sig;
-	  sig = strtol (p + 1, &q, 16);
+	  target_signal_t sig;
+
+	  sig = target_signal_from_number (strtol (p + 1, &q, 16));
 	  if (p == q)
 	    goto err;
 	  p = q;
@@ -2907,8 +2909,8 @@ process_serial_event (void)
     case 'C':
       require_running (own_buf);
       convert_ascii_to_int (own_buf + 1, &sig, 1);
-      if (target_signal_to_host_p (sig))
-	signal = target_signal_to_host (sig);
+      if (target_signal_to_host_p (target_signal_from_number (sig)))
+	signal = target_signal_to_host (target_signal_from_number (sig));
       else
 	signal = 0;
       myresume (own_buf, 0, signal);
@@ -2916,8 +2918,8 @@ process_serial_event (void)
     case 'S':
       require_running (own_buf);
       convert_ascii_to_int (own_buf + 1, &sig, 1);
-      if (target_signal_to_host_p (sig))
-	signal = target_signal_to_host (sig);
+      if (target_signal_to_host_p (target_signal_from_number (sig)))
+	signal = target_signal_to_host (target_signal_from_number (sig));
       else
 	signal = 0;
       myresume (own_buf, 1, signal);
--- a/gdb/gdbserver/server.h
+++ b/gdb/gdbserver/server.h
@@ -323,6 +323,7 @@ extern int server_waiting;
 extern int debug_threads;
 extern int debug_hw_points;
 extern int pass_signals[];
+#define PASS_SIGNALS(siggnal) pass_signals[TARGET_SIGNAL_NUMBER (siggnal)]
 
 extern jmp_buf toplevel;
 
--- a/gdb/gdbserver/target.c
+++ b/gdb/gdbserver/target.c
@@ -98,7 +98,7 @@ mywait (ptid_t ptid, struct target_waitstatus *ourstatus, int options,
 
   if (ourstatus->kind == TARGET_WAITKIND_EXITED)
     fprintf (stderr,
-	     "\nChild exited with status %d\n", ourstatus->value.sig);
+	     "\nChild exited with status %d\n", ourstatus->value.integer);
   else if (ourstatus->kind == TARGET_WAITKIND_SIGNALLED)
     fprintf (stderr, "\nChild terminated with signal = 0x%x (%s)\n",
 	     target_signal_to_host (ourstatus->value.sig),
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -1195,7 +1195,7 @@ signal_command (char *signum_exp, int from_tty)
      assign them to convenience variables.  */
   oursig = target_signal_from_name (signum_exp);
 
-  if (oursig == TARGET_SIGNAL_UNKNOWN)
+  if (TARGET_SIGNAL_EQ (oursig, TARGET_SIGNAL_UNKNOWN))
     {
       /* No, try numeric.  */
       int num = parse_and_eval_long (signum_exp);
@@ -1208,7 +1208,7 @@ signal_command (char *signum_exp, int from_tty)
 
   if (from_tty)
     {
-      if (oursig == TARGET_SIGNAL_0)
+      if (TARGET_SIGNAL_EQ (oursig, TARGET_SIGNAL_0))
 	printf_filtered (_("Continuing with no signal.\n"));
       else
 	printf_filtered (_("Continuing with signal %s.\n"),
@@ -1723,7 +1723,7 @@ It stopped at a breakpoint that has since been deleted.\n"));
 	  stat = bpstat_num (&bs, &num);
 	}
     }
-  else if (tp->stop_signal != TARGET_SIGNAL_0)
+  else if (TARGET_SIGNAL_NE (tp->stop_signal, TARGET_SIGNAL_0))
     {
       printf_filtered (_("It stopped with signal %s, %s.\n"),
 		       target_signal_to_name (tp->stop_signal),
@@ -2206,7 +2206,7 @@ proceed_after_attach_callback (struct thread_info *thread,
       && !is_exited (thread->ptid)
       && !is_executing (thread->ptid)
       && !thread->stop_requested
-      && thread->stop_signal == TARGET_SIGNAL_0)
+      && TARGET_SIGNAL_EQ (thread->stop_signal, TARGET_SIGNAL_0))
     {
       switch_to_thread (thread->ptid);
       clear_proceed_status ();
@@ -2308,7 +2308,8 @@ attach_command_post_wait (char *args, int from_tty, int async_exec)
 	proceed_after_attach (inferior->pid);
       else
 	{
-	  if (inferior_thread ()->stop_signal == TARGET_SIGNAL_0)
+	  if (TARGET_SIGNAL_EQ (inferior_thread ()->stop_signal,
+				TARGET_SIGNAL_0))
 	    {
 	      clear_proceed_status ();
 	      proceed ((CORE_ADDR) -1, TARGET_SIGNAL_DEFAULT, 0);
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -240,17 +240,17 @@ extern void start_remote (int from_tty);
 
 extern void normal_stop (void);
 
-extern int signal_stop_state (int);
+extern int signal_stop_state (target_signal_t signo);
 
-extern int signal_print_state (int);
+extern int signal_print_state (target_signal_t signo);
 
-extern int signal_pass_state (int);
+extern int signal_pass_state (target_signal_t signo);
 
-extern int signal_stop_update (int, int);
+extern int signal_stop_update (target_signal_t signo, int state);
 
-extern int signal_print_update (int, int);
+extern int signal_print_update (target_signal_t signo, int state);
 
-extern int signal_pass_update (int, int);
+extern int signal_pass_update (target_signal_t signo, int state);
 
 extern void get_last_target_status(ptid_t *ptid,
                                    struct target_waitstatus *status);
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -274,6 +274,13 @@ static unsigned char *signal_stop;
 static unsigned char *signal_print;
 static unsigned char *signal_program;
 
+#define SIGNAL_STOP(target_signal) \
+  signal_stop[TARGET_SIGNAL_NUMBER (target_signal)]
+#define SIGNAL_PRINT(target_signal) \
+  signal_print[TARGET_SIGNAL_NUMBER (target_signal)]
+#define SIGNAL_PROGRAM(target_signal) \
+  signal_program[TARGET_SIGNAL_NUMBER (target_signal)]
+
 #define SET_SIGS(nsigs,sigs,flags) \
   do { \
     int signum = (nsigs); \
@@ -555,7 +562,7 @@ proceed_after_vfork_done (struct thread_info *thread,
       && is_running (thread->ptid)
       && !is_executing (thread->ptid)
       && !thread->stop_requested
-      && thread->stop_signal == TARGET_SIGNAL_0)
+      && TARGET_SIGNAL_EQ (thread->stop_signal, TARGET_SIGNAL_0))
     {
       if (debug_infrun)
 	fprintf_unfiltered (gdb_stdlog,
@@ -1337,7 +1344,7 @@ displaced_step_fixup (ptid_t event_ptid, target_signal_t signal)
   }
 
   /* Did the instruction complete successfully?  */
-  if (signal == TARGET_SIGNAL_TRAP)
+  if (TARGET_SIGNAL_EQ (signal, TARGET_SIGNAL_TRAP))
     {
       /* Fix up the resulting state.  */
       gdbarch_displaced_step_fixup (displaced->step_gdbarch,
@@ -1562,9 +1569,9 @@ resume (int step, target_signal_t sig)
 
   if (debug_infrun)
     fprintf_unfiltered (gdb_stdlog,
-                        "infrun: resume (step=%d, signal=%d), "
+                        "infrun: resume (step=%d, signal=%s), "
 			"trap_expected=%d\n",
- 			step, sig, tp->trap_expected);
+ 			step, target_signal_to_name (sig), tp->trap_expected);
 
   /* Normally, by the time we reach `resume', the breakpoints are either
      removed or inserted, as appropriate.  The exception is if we're sitting
@@ -1591,7 +1598,7 @@ a command like `return' or `jump' to continue execution."));
   if (use_displaced_stepping (gdbarch)
       && (tp->trap_expected
 	  || (step && gdbarch_software_single_step_p (gdbarch)))
-      && sig == TARGET_SIGNAL_0)
+      && TARGET_SIGNAL_EQ (sig, TARGET_SIGNAL_0))
     {
       struct displaced_step_inferior_state *displaced;
 
@@ -1820,10 +1827,10 @@ prepare_to_proceed (int step)
 
   /* Make sure we were stopped at a breakpoint.  */
   if (wait_status.kind != TARGET_WAITKIND_STOPPED
-      || (wait_status.value.sig != TARGET_SIGNAL_TRAP
-	  && wait_status.value.sig != TARGET_SIGNAL_ILL
-	  && wait_status.value.sig != TARGET_SIGNAL_SEGV
-	  && wait_status.value.sig != TARGET_SIGNAL_EMT))
+      || (TARGET_SIGNAL_NE (wait_status.value.sig, TARGET_SIGNAL_TRAP)
+	  && TARGET_SIGNAL_NE (wait_status.value.sig, TARGET_SIGNAL_ILL)
+	  && TARGET_SIGNAL_NE (wait_status.value.sig, TARGET_SIGNAL_SEGV)
+	  && TARGET_SIGNAL_NE (wait_status.value.sig, TARGET_SIGNAL_EMT)))
     {
       return 0;
     }
@@ -1938,8 +1945,9 @@ proceed (CORE_ADDR addr, target_signal_t siggnal, int step)
 
   if (debug_infrun)
     fprintf_unfiltered (gdb_stdlog,
-			"infrun: proceed (addr=%s, signal=%d, step=%d)\n",
-			paddress (gdbarch, addr), siggnal, step);
+			"infrun: proceed (addr=%s, signal=%s, step=%d)\n",
+			paddress (gdbarch, addr),
+			target_signal_to_name (siggnal), step);
 
   /* We're handling a live event, so make sure we're doing live
      debugging.  If we're looking at traceframes while the target is
@@ -2019,11 +2027,11 @@ proceed (CORE_ADDR addr, target_signal_t siggnal, int step)
 	}
     }
 
-  if (siggnal != TARGET_SIGNAL_DEFAULT)
+  if (TARGET_SIGNAL_NE (siggnal, TARGET_SIGNAL_DEFAULT))
     tp->stop_signal = siggnal;
   /* If this signal should not be seen by program,
      give it zero.  Used for debugging signals.  */
-  else if (!signal_program[tp->stop_signal])
+  else if (! SIGNAL_PROGRAM (tp->stop_signal))
     tp->stop_signal = TARGET_SIGNAL_0;
 
   annotate_starting ();
@@ -2743,7 +2751,7 @@ adjust_pc_after_break (struct execution_control_state *ecs)
   if (ecs->ws.kind != TARGET_WAITKIND_STOPPED)
     return;
 
-  if (ecs->ws.value.sig != TARGET_SIGNAL_TRAP)
+  if (TARGET_SIGNAL_NE (ecs->ws.value.sig, TARGET_SIGNAL_TRAP))
     return;
 
   /* In reverse execution, when a breakpoint is hit, the instruction
@@ -3000,9 +3008,9 @@ handle_inferior_event (struct execution_control_state *ecs)
      for architectures like SPARC that place call dummies on the
      stack.  */
   if (ecs->ws.kind == TARGET_WAITKIND_STOPPED
-      && (ecs->ws.value.sig == TARGET_SIGNAL_ILL
-	  || ecs->ws.value.sig == TARGET_SIGNAL_SEGV
-	  || ecs->ws.value.sig == TARGET_SIGNAL_EMT))
+      && (TARGET_SIGNAL_EQ (ecs->ws.value.sig, TARGET_SIGNAL_ILL)
+	  || TARGET_SIGNAL_EQ (ecs->ws.value.sig, TARGET_SIGNAL_SEGV)
+	  || TARGET_SIGNAL_EQ (ecs->ws.value.sig, TARGET_SIGNAL_EMT)))
     {
       struct regcache *regcache = get_thread_regcache (ecs->ptid);
 
@@ -3420,7 +3428,8 @@ targets should add new threads to the thread list themselves in non-stop mode.")
 	 SIG0 (generic unsignaled stop).  */
 
       if (ecs->event_thread->stop_requested
-	  && ecs->event_thread->stop_signal == TARGET_SIGNAL_TRAP)
+	  && TARGET_SIGNAL_EQ (ecs->event_thread->stop_signal,
+			       TARGET_SIGNAL_TRAP))
 	ecs->event_thread->stop_signal = TARGET_SIGNAL_0;
     }
 
@@ -3465,7 +3474,8 @@ targets should add new threads to the thread list themselves in non-stop mode.")
       /* We've either finished single-stepping past the single-step
          breakpoint, or stopped for some other reason.  It would be nice if
          we could tell, but we can't reliably.  */
-      if (ecs->event_thread->stop_signal == TARGET_SIGNAL_TRAP)
+      if (TARGET_SIGNAL_EQ (ecs->event_thread->stop_signal,
+			    TARGET_SIGNAL_TRAP))
 	{
 	  if (debug_infrun)
 	    fprintf_unfiltered (gdb_stdlog, "infrun: stepping_past_singlestep_breakpoint\n");
@@ -3493,7 +3503,8 @@ targets should add new threads to the thread list themselves in non-stop mode.")
 
       /* If we stopped for some other reason than single-stepping, ignore
 	 the fact that we were supposed to switch back.  */
-      if (ecs->event_thread->stop_signal == TARGET_SIGNAL_TRAP)
+      if (TARGET_SIGNAL_EQ (ecs->event_thread->stop_signal,
+			    TARGET_SIGNAL_TRAP))
 	{
 	  if (debug_infrun)
 	    fprintf_unfiltered (gdb_stdlog,
@@ -3525,7 +3536,7 @@ targets should add new threads to the thread list themselves in non-stop mode.")
      another thread.  If so, then step that thread past the breakpoint,
      and continue it.  */
 
-  if (ecs->event_thread->stop_signal == TARGET_SIGNAL_TRAP)
+  if (TARGET_SIGNAL_EQ (ecs->event_thread->stop_signal, TARGET_SIGNAL_TRAP))
     {
       int thread_hop_needed = 0;
       struct address_space *aspace = 
@@ -3766,7 +3777,7 @@ targets should add new threads to the thread list themselves in non-stop mode.")
   if (ecs->event_thread->step_range_end != 1)
     skip_inline_frames (ecs->ptid);
 
-  if (ecs->event_thread->stop_signal == TARGET_SIGNAL_TRAP
+  if (TARGET_SIGNAL_EQ (ecs->event_thread->stop_signal, TARGET_SIGNAL_TRAP)
       && ecs->event_thread->trap_expected
       && gdbarch_single_step_through_delay_p (gdbarch)
       && currently_stepping (ecs->event_thread))
@@ -3809,11 +3820,13 @@ targets should add new threads to the thread list themselves in non-stop mode.")
      3) set ecs->random_signal to 1, and the decision between 1 and 2
      will be made according to the signal handling tables.  */
 
-  if (ecs->event_thread->stop_signal == TARGET_SIGNAL_TRAP
+  if (TARGET_SIGNAL_EQ (ecs->event_thread->stop_signal, TARGET_SIGNAL_TRAP)
       || stop_soon == STOP_QUIETLY || stop_soon == STOP_QUIETLY_NO_SIGSTOP
       || stop_soon == STOP_QUIETLY_REMOTE)
     {
-      if (ecs->event_thread->stop_signal == TARGET_SIGNAL_TRAP && stop_after_trap)
+      if (TARGET_SIGNAL_EQ (ecs->event_thread->stop_signal,
+			    TARGET_SIGNAL_TRAP)
+	  && stop_after_trap)
 	{
           if (debug_infrun)
 	    fprintf_unfiltered (gdb_stdlog, "infrun: stopped\n");
@@ -3853,9 +3866,12 @@ targets should add new threads to the thread list themselves in non-stop mode.")
 	 TARGET_SIGNAL_0, meaning: stopped for no particular reason
 	 other than GDB's request.  */
       if (stop_soon == STOP_QUIETLY_NO_SIGSTOP
-	  && (ecs->event_thread->stop_signal == TARGET_SIGNAL_STOP
-	      || ecs->event_thread->stop_signal == TARGET_SIGNAL_TRAP
-	      || ecs->event_thread->stop_signal == TARGET_SIGNAL_0))
+	  && (TARGET_SIGNAL_EQ (ecs->event_thread->stop_signal,
+				TARGET_SIGNAL_STOP)
+	      || TARGET_SIGNAL_EQ (ecs->event_thread->stop_signal,
+				   TARGET_SIGNAL_TRAP)
+	      || TARGET_SIGNAL_EQ (ecs->event_thread->stop_signal,
+				   TARGET_SIGNAL_0)))
 	{
 	  stop_stepping (ecs);
 	  ecs->event_thread->stop_signal = TARGET_SIGNAL_0;
@@ -3880,7 +3896,8 @@ targets should add new threads to the thread list themselves in non-stop mode.")
 	 set.  */
 
       if (debug_infrun
-	  && ecs->event_thread->stop_signal == TARGET_SIGNAL_TRAP
+	  && TARGET_SIGNAL_EQ (ecs->event_thread->stop_signal,
+			       TARGET_SIGNAL_TRAP)
 	  && !bpstat_explains_signal (ecs->event_thread->stop_bpstat)
 	  && stopped_by_watchpoint)
 	fprintf_unfiltered (gdb_stdlog, "\
@@ -3906,7 +3923,8 @@ infrun: no user watchpoint explains watchpoint SIGTRAP, ignoring\n");
          be necessary for call dummies on a non-executable stack on
          SPARC.  */
 
-      if (ecs->event_thread->stop_signal == TARGET_SIGNAL_TRAP)
+      if (TARGET_SIGNAL_EQ (ecs->event_thread->stop_signal,
+			    TARGET_SIGNAL_TRAP))
 	ecs->random_signal
 	  = !(bpstat_explains_signal (ecs->event_thread->stop_bpstat)
 	      || stopped_by_watchpoint
@@ -3945,12 +3963,12 @@ process_event_stop_test:
       struct inferior *inf = find_inferior_pid (ptid_get_pid (ecs->ptid));
 
       if (debug_infrun)
-	 fprintf_unfiltered (gdb_stdlog, "infrun: random signal %d\n",
-			     ecs->event_thread->stop_signal);
+	fprintf_unfiltered (gdb_stdlog, "infrun: random signal %s\n",
+		      target_signal_to_name (ecs->event_thread->stop_signal));
 
       stopped_by_random_signal = 1;
 
-      if (signal_print[ecs->event_thread->stop_signal])
+      if (SIGNAL_PRINT (ecs->event_thread->stop_signal))
 	{
 	  printed = 1;
 	  target_terminal_ours_for_output ();
@@ -3973,7 +3991,7 @@ process_event_stop_test:
 	target_terminal_inferior ();
 
       /* Clear the signal if it should not be passed.  */
-      if (signal_program[ecs->event_thread->stop_signal] == 0)
+      if (SIGNAL_PROGRAM (ecs->event_thread->stop_signal) == 0)
 	ecs->event_thread->stop_signal = TARGET_SIGNAL_0;
 
       if (ecs->event_thread->prev_pc == stop_pc
@@ -4002,7 +4020,8 @@ process_event_stop_test:
 	}
 
       if (ecs->event_thread->step_range_end != 0
-	  && ecs->event_thread->stop_signal != TARGET_SIGNAL_0
+	  && TARGET_SIGNAL_NE (ecs->event_thread->stop_signal,
+			       TARGET_SIGNAL_0)
 	  && (ecs->event_thread->step_range_start <= stop_pc
 	      && stop_pc < ecs->event_thread->step_range_end)
 	  && frame_id_eq (get_stack_frame_id (frame),
@@ -4185,7 +4204,8 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n");
 	     breakpoint, and we simply need to step over that breakpoint
 	     to get it going again, do that first.  */
 	  if ((ecs->event_thread->trap_expected
-	       && ecs->event_thread->stop_signal != TARGET_SIGNAL_TRAP)
+	       && TARGET_SIGNAL_NE (ecs->event_thread->stop_signal,
+				    TARGET_SIGNAL_TRAP))
 	      || ecs->event_thread->stepping_over_breakpoint)
 	    {
 	      keep_going (ecs);
@@ -5092,7 +5112,8 @@ keep_going (struct execution_control_state *ecs)
      inferior and not return to debugger.  */
 
   if (ecs->event_thread->trap_expected
-      && ecs->event_thread->stop_signal != TARGET_SIGNAL_TRAP)
+      && TARGET_SIGNAL_NE (ecs->event_thread->stop_signal,
+			   TARGET_SIGNAL_TRAP))
     {
       /* We took a signal (which we are supposed to pass through to
 	 the inferior, else we'd not get here) and we haven't yet
@@ -5159,8 +5180,9 @@ keep_going (struct execution_control_state *ecs)
          simulator; the simulator then delivers the hardware
          equivalent of a SIGNAL_TRAP to the program being debugged. */
 
-      if (ecs->event_thread->stop_signal == TARGET_SIGNAL_TRAP
-	  && !signal_program[ecs->event_thread->stop_signal])
+      if (TARGET_SIGNAL_EQ (ecs->event_thread->stop_signal,
+			    TARGET_SIGNAL_TRAP)
+	  && ! SIGNAL_PROGRAM (ecs->event_thread->stop_signal))
 	ecs->event_thread->stop_signal = TARGET_SIGNAL_0;
 
       discard_cleanups (old_cleanups);
@@ -5264,7 +5286,8 @@ print_signal_received_reason (target_signal_t siggnal)
 {
   annotate_signal ();
 
-  if (siggnal == TARGET_SIGNAL_0 && !ui_out_is_mi_like_p (uiout))
+  if (TARGET_SIGNAL_EQ (siggnal, TARGET_SIGNAL_0)
+      && !ui_out_is_mi_like_p (uiout))
     {
       struct thread_info *t = inferior_thread ();
 
@@ -5569,47 +5592,47 @@ hook_stop_stub (void *cmd)
 }
 
 int
-signal_stop_state (int signo)
+signal_stop_state (target_signal_t signo)
 {
-  return signal_stop[signo];
+  return SIGNAL_STOP (signo);
 }
 
 int
-signal_print_state (int signo)
+signal_print_state (target_signal_t signo)
 {
-  return signal_print[signo];
+  return SIGNAL_PRINT (signo);
 }
 
 int
-signal_pass_state (int signo)
+signal_pass_state (target_signal_t signo)
 {
-  return signal_program[signo];
+  return SIGNAL_PROGRAM (signo);
 }
 
 int
-signal_stop_update (int signo, int state)
+signal_stop_update (target_signal_t signo, int state)
 {
-  int ret = signal_stop[signo];
+  int ret = SIGNAL_STOP (signo);
 
-  signal_stop[signo] = state;
+  SIGNAL_STOP (signo) = state;
   return ret;
 }
 
 int
-signal_print_update (int signo, int state)
+signal_print_update (target_signal_t signo, int state)
 {
-  int ret = signal_print[signo];
+  int ret = SIGNAL_PRINT (signo);
 
-  signal_print[signo] = state;
+  SIGNAL_PRINT (signo) = state;
   return ret;
 }
 
 int
-signal_pass_update (int signo, int state)
+signal_pass_update (target_signal_t signo, int state)
 {
-  int ret = signal_program[signo];
+  int ret = SIGNAL_PROGRAM (signo);
 
-  signal_program[signo] = state;
+  SIGNAL_PROGRAM (signo) = state;
   return ret;
 }
 
@@ -5631,9 +5654,9 @@ sig_print_info (target_signal_t oursig)
 
   printf_filtered ("%s", name);
   printf_filtered ("%*.*s ", name_padding, name_padding, "                 ");
-  printf_filtered ("%s\t", signal_stop[oursig] ? "Yes" : "No");
-  printf_filtered ("%s\t", signal_print[oursig] ? "Yes" : "No");
-  printf_filtered ("%s\t\t", signal_program[oursig] ? "Yes" : "No");
+  printf_filtered ("%s\t", SIGNAL_STOP (oursig) ? "Yes" : "No");
+  printf_filtered ("%s\t", SIGNAL_PRINT (oursig) ? "Yes" : "No");
+  printf_filtered ("%s\t\t", SIGNAL_PROGRAM (oursig) ? "Yes" : "No");
   printf_filtered ("%s\n", target_signal_to_string (oursig));
 }
 
@@ -5644,7 +5667,7 @@ handle_command (char *args, int from_tty)
 {
   char **argv;
   int digits, wordlen;
-  int sigfirst, signum, siglast;
+  enum target_signal_number signum;
   target_signal_t oursig;
   int allsigs;
   int nsigs;
@@ -5658,7 +5681,7 @@ handle_command (char *args, int from_tty)
 
   /* Allocate and zero an array of flags for which signals to handle. */
 
-  nsigs = (int) TARGET_SIGNAL_LAST;
+  nsigs = TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_LAST);
   sigs = (unsigned char *) alloca (nsigs);
   memset (sigs, 0, nsigs);
 
@@ -5674,12 +5697,17 @@ handle_command (char *args, int from_tty)
 
   while (*argv != NULL)
     {
+      enum target_signal_number sigfirst, siglast;
+
       wordlen = strlen (*argv);
       for (digits = 0; isdigit ((*argv)[digits]); digits++)
 	{;
 	}
       allsigs = 0;
-      sigfirst = siglast = -1;
+
+      /* sigrist < siglast is an empty set.  They are unsigned.  */
+      sigfirst = 1;
+      siglast = 0;
 
       if (wordlen >= 1 && !strncmp (*argv, "all", wordlen))
 	{
@@ -5731,12 +5759,13 @@ handle_command (char *args, int from_tty)
 	     using symbolic names anyway, and the common ones like
 	     SIGHUP, SIGINT, SIGALRM, etc. will work right anyway.  */
 
-	  sigfirst = siglast = (int)
-	    target_signal_from_command (atoi (*argv));
+	  oursig = target_signal_from_command (atoi (*argv));
+	  sigfirst = siglast = TARGET_SIGNAL_NUMBER (oursig);
 	  if ((*argv)[digits] == '-')
 	    {
-	      siglast = (int)
-		target_signal_from_command (atoi ((*argv) + digits + 1));
+	      oursig = target_signal_from_command (atoi ((*argv) + digits
+							 + 1));
+	      siglast = TARGET_SIGNAL_NUMBER (oursig);
 	    }
 	  if (sigfirst > siglast)
 	    {
@@ -5749,9 +5778,9 @@ handle_command (char *args, int from_tty)
       else
 	{
 	  oursig = target_signal_from_name (*argv);
-	  if (oursig != TARGET_SIGNAL_UNKNOWN)
+	  if (TARGET_SIGNAL_NE (oursig, TARGET_SIGNAL_UNKNOWN))
 	    {
-	      sigfirst = siglast = (int) oursig;
+	      sigfirst = siglast = TARGET_SIGNAL_NUMBER (oursig);
 	    }
 	  else
 	    {
@@ -5763,16 +5792,17 @@ handle_command (char *args, int from_tty)
       /* If any signal numbers or symbol names were found, set flags for
          which signals to apply actions to. */
 
-      for (signum = sigfirst; signum >= 0 && signum <= siglast; signum++)
+      for (signum = sigfirst; signum <= siglast; signum++)
 	{
-	  switch ((target_signal_t) signum)
+	  switch (signum)
 	    {
-	    case TARGET_SIGNAL_TRAP:
-	    case TARGET_SIGNAL_INT:
+	    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_TRAP):
+	    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_INT):
 	      if (!allsigs && !sigs[signum])
 		{
 		  if (query (_("%s is used by the debugger.\n\
-Are you sure you want to change it? "), target_signal_to_name ((target_signal_t) signum)))
+Are you sure you want to change it? "),
+		  target_signal_to_name (target_signal_from_number (signum))))
 		    {
 		      sigs[signum] = 1;
 		    }
@@ -5783,9 +5813,9 @@ Are you sure you want to change it? "), target_signal_to_name ((target_signal_t)
 		    }
 		}
 	      break;
-	    case TARGET_SIGNAL_0:
-	    case TARGET_SIGNAL_DEFAULT:
-	    case TARGET_SIGNAL_UNKNOWN:
+	    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_0):
+	    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_DEFAULT):
+	    case TARGET_SIGNAL_NUMBER_CONST (TARGET_SIGNAL_UNKNOWN):
 	      /* Make sure that "all" doesn't print these.  */
 	      break;
 	    default:
@@ -5808,7 +5838,7 @@ Are you sure you want to change it? "), target_signal_to_name ((target_signal_t)
 	    sig_print_header ();
 	    for (; signum < nsigs; signum++)
 	      if (sigs[signum])
-		sig_print_info (signum);
+		sig_print_info (target_signal_from_number (signum));
 	  }
 
 	break;
@@ -5850,21 +5880,21 @@ xdb_handle_command (char *args, int from_tty)
 	    {
 	      if (strcmp (argv[1], "s") == 0)
 		{
-		  if (!signal_stop[oursig])
+		  if (! SIGNAL_STOP (oursig))
 		    sprintf (argBuf, "%s %s", argv[0], "stop");
 		  else
 		    sprintf (argBuf, "%s %s", argv[0], "nostop");
 		}
 	      else if (strcmp (argv[1], "i") == 0)
 		{
-		  if (!signal_program[oursig])
+		  if (! SIGNAL_PROGRAM (oursig))
 		    sprintf (argBuf, "%s %s", argv[0], "pass");
 		  else
 		    sprintf (argBuf, "%s %s", argv[0], "nopass");
 		}
 	      else if (strcmp (argv[1], "r") == 0)
 		{
-		  if (!signal_print[oursig])
+		  if (! SIGNAL_PRINT (oursig))
 		    sprintf (argBuf, "%s %s", argv[0], "print");
 		  else
 		    sprintf (argBuf, "%s %s", argv[0], "noprint");
@@ -5899,7 +5929,7 @@ signals_info (char *signum_exp, int from_tty)
     {
       /* First see if this is a symbol name.  */
       oursig = target_signal_from_name (signum_exp);
-      if (oursig == TARGET_SIGNAL_UNKNOWN)
+      if (TARGET_SIGNAL_EQ (oursig, TARGET_SIGNAL_UNKNOWN))
 	{
 	  /* No, try numeric.  */
 	  oursig =
@@ -5912,13 +5942,14 @@ signals_info (char *signum_exp, int from_tty)
   printf_filtered ("\n");
   /* These ugly casts brought to you by the native VAX compiler.  */
   for (oursig = TARGET_SIGNAL_FIRST;
-       (int) oursig < (int) TARGET_SIGNAL_LAST;
-       oursig = (target_signal_t) ((int) oursig + 1))
+       TARGET_SIGNAL_LE (oursig, TARGET_SIGNAL_LAST);
+       TARGET_SIGNAL_NUMBER (oursig)++)
     {
       QUIT;
 
-      if (oursig != TARGET_SIGNAL_UNKNOWN
-	  && oursig != TARGET_SIGNAL_DEFAULT && oursig != TARGET_SIGNAL_0)
+      if (TARGET_SIGNAL_NE (oursig, TARGET_SIGNAL_UNKNOWN)
+	  && TARGET_SIGNAL_NE (oursig, TARGET_SIGNAL_DEFAULT)
+	  && TARGET_SIGNAL_NE (oursig, TARGET_SIGNAL_0))
 	sig_print_info (oursig);
     }
 
@@ -6581,7 +6612,7 @@ leave it stopped or free to run as needed."),
 			   &setlist,
 			   &showlist);
 
-  numsigs = (int) TARGET_SIGNAL_LAST;
+  numsigs = TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_LAST);
   signal_stop = (unsigned char *) xmalloc (sizeof (signal_stop[0]) * numsigs);
   signal_print = (unsigned char *)
     xmalloc (sizeof (signal_print[0]) * numsigs);
@@ -6596,37 +6627,37 @@ leave it stopped or free to run as needed."),
 
   /* Signals caused by debugger's own actions
      should not be given to the program afterwards.  */
-  signal_program[TARGET_SIGNAL_TRAP] = 0;
-  signal_program[TARGET_SIGNAL_INT] = 0;
+  SIGNAL_PROGRAM (TARGET_SIGNAL_TRAP) = 0;
+  SIGNAL_PROGRAM (TARGET_SIGNAL_INT) = 0;
 
   /* Signals that are not errors should not normally enter the debugger.  */
-  signal_stop[TARGET_SIGNAL_ALRM] = 0;
-  signal_print[TARGET_SIGNAL_ALRM] = 0;
-  signal_stop[TARGET_SIGNAL_VTALRM] = 0;
-  signal_print[TARGET_SIGNAL_VTALRM] = 0;
-  signal_stop[TARGET_SIGNAL_PROF] = 0;
-  signal_print[TARGET_SIGNAL_PROF] = 0;
-  signal_stop[TARGET_SIGNAL_CHLD] = 0;
-  signal_print[TARGET_SIGNAL_CHLD] = 0;
-  signal_stop[TARGET_SIGNAL_IO] = 0;
-  signal_print[TARGET_SIGNAL_IO] = 0;
-  signal_stop[TARGET_SIGNAL_POLL] = 0;
-  signal_print[TARGET_SIGNAL_POLL] = 0;
-  signal_stop[TARGET_SIGNAL_URG] = 0;
-  signal_print[TARGET_SIGNAL_URG] = 0;
-  signal_stop[TARGET_SIGNAL_WINCH] = 0;
-  signal_print[TARGET_SIGNAL_WINCH] = 0;
+  SIGNAL_STOP (TARGET_SIGNAL_ALRM) = 0;
+  SIGNAL_PRINT (TARGET_SIGNAL_ALRM) = 0;
+  SIGNAL_STOP (TARGET_SIGNAL_VTALRM) = 0;
+  SIGNAL_PRINT (TARGET_SIGNAL_VTALRM) = 0;
+  SIGNAL_STOP (TARGET_SIGNAL_PROF) = 0;
+  SIGNAL_PRINT (TARGET_SIGNAL_PROF) = 0;
+  SIGNAL_STOP (TARGET_SIGNAL_CHLD) = 0;
+  SIGNAL_PRINT (TARGET_SIGNAL_CHLD) = 0;
+  SIGNAL_STOP (TARGET_SIGNAL_IO) = 0;
+  SIGNAL_PRINT (TARGET_SIGNAL_IO) = 0;
+  SIGNAL_STOP (TARGET_SIGNAL_POLL) = 0;
+  SIGNAL_PRINT (TARGET_SIGNAL_POLL) = 0;
+  SIGNAL_STOP (TARGET_SIGNAL_URG) = 0;
+  SIGNAL_PRINT (TARGET_SIGNAL_URG) = 0;
+  SIGNAL_STOP (TARGET_SIGNAL_WINCH) = 0;
+  SIGNAL_PRINT (TARGET_SIGNAL_WINCH) = 0;
 
   /* These signals are used internally by user-level thread
      implementations.  (See signal(5) on Solaris.)  Like the above
      signals, a healthy program receives and handles them as part of
      its normal operation.  */
-  signal_stop[TARGET_SIGNAL_LWP] = 0;
-  signal_print[TARGET_SIGNAL_LWP] = 0;
-  signal_stop[TARGET_SIGNAL_WAITING] = 0;
-  signal_print[TARGET_SIGNAL_WAITING] = 0;
-  signal_stop[TARGET_SIGNAL_CANCEL] = 0;
-  signal_print[TARGET_SIGNAL_CANCEL] = 0;
+  SIGNAL_STOP (TARGET_SIGNAL_LWP) = 0;
+  SIGNAL_PRINT (TARGET_SIGNAL_LWP) = 0;
+  SIGNAL_STOP (TARGET_SIGNAL_WAITING) = 0;
+  SIGNAL_PRINT (TARGET_SIGNAL_WAITING) = 0;
+  SIGNAL_STOP (TARGET_SIGNAL_CANCEL) = 0;
+  SIGNAL_PRINT (TARGET_SIGNAL_CANCEL) = 0;
 
   add_setshow_zinteger_cmd ("stop-on-solib-events", class_support,
 			    &stop_on_solib_events, _("\
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1667,7 +1667,7 @@ get_pending_status (struct lwp_info *lp, int *status)
 
   *status = 0;
 
-  if (signo == TARGET_SIGNAL_0)
+  if (TARGET_SIGNAL_EQ (signo, TARGET_SIGNAL_0))
     {
       if (debug_linux_nat)
 	fprintf_unfiltered (gdb_stdlog,
@@ -1874,7 +1874,7 @@ linux_nat_resume (struct target_ops *ops,
 			"LLR: Preparing to %s %s, %s, inferior_ptid %s\n",
 			step ? "step" : "resume",
 			target_pid_to_str (ptid),
-			signo ? strsignal (signo) : "0",
+			target_signal_to_name (signo),
 			target_pid_to_str (inferior_ptid));
 
   block_child_signals (&prev_mask);
@@ -1907,7 +1907,7 @@ linux_nat_resume (struct target_ops *ops,
 
   if (lp->status && WIFSTOPPED (lp->status))
     {
-      int saved_signo;
+      target_signal_t saved_signo;
       struct inferior *inf;
 
       inf = find_inferior_pid (ptid_get_pid (lp->ptid));
@@ -1928,7 +1928,7 @@ linux_nat_resume (struct target_ops *ops,
 
 	  /* FIXME: What should we do if we are supposed to continue
 	     this thread with a signal?  */
-	  gdb_assert (signo == TARGET_SIGNAL_0);
+	  gdb_assert (TARGET_SIGNAL_EQ (signo, TARGET_SIGNAL_0));
 	  signo = saved_signo;
 	  lp->status = 0;
 	}
@@ -1938,7 +1938,7 @@ linux_nat_resume (struct target_ops *ops,
     {
       /* FIXME: What should we do if we are supposed to continue
 	 this thread with a signal?  */
-      gdb_assert (signo == TARGET_SIGNAL_0);
+      gdb_assert (TARGET_SIGNAL_EQ (signo, TARGET_SIGNAL_0));
 
       if (debug_linux_nat)
 	fprintf_unfiltered (gdb_stdlog,
@@ -1974,7 +1974,7 @@ linux_nat_resume (struct target_ops *ops,
 			"LLR: %s %s, %s (resume event thread)\n",
 			step ? "PTRACE_SINGLESTEP" : "PTRACE_CONT",
 			target_pid_to_str (ptid),
-			signo ? strsignal (signo) : "0");
+			target_signal_to_name (signo));
 
   restore_child_signals_mask (&prev_mask);
   if (target_can_async_p ())
@@ -2266,7 +2266,7 @@ linux_handle_extended_wait (struct lwp_info *lp, int status,
 	     catchpoints.  */
 	  if (!stopping)
 	    {
-	      int signo;
+	      target_signal_t signo;
 
 	      new_lp->stopped = 0;
 	      new_lp->resumed = 1;
@@ -3535,7 +3535,7 @@ retry:
 
   if (WIFSTOPPED (status))
     {
-      int signo = target_signal_from_host (WSTOPSIG (status));
+      target_signal_t signo = target_signal_from_host (WSTOPSIG (status));
       struct inferior *inf;
 
       inf = find_inferior_pid (ptid_get_pid (lp->ptid));
@@ -3565,7 +3565,7 @@ retry:
 				lp->step ?
 				"PTRACE_SINGLESTEP" : "PTRACE_CONT",
 				target_pid_to_str (lp->ptid),
-				signo ? strsignal (signo) : "0");
+				target_signal_to_name (signo));
 	  lp->stopped = 0;
 	  goto retry;
 	}
@@ -3575,7 +3575,8 @@ retry:
 	  /* Only do the below in all-stop, as we currently use SIGINT
 	     to implement target_stop (see linux_nat_stop) in
 	     non-stop.  */
-	  if (signo == TARGET_SIGNAL_INT && signal_pass_state (signo) == 0)
+	  if (TARGET_SIGNAL_EQ (signo, TARGET_SIGNAL_INT)
+	      && signal_pass_state (signo) == 0)
 	    {
 	      /* If ^C/BREAK is typed at the tty/console, SIGINT gets
 		 forwarded to the entire process group, that is, all LWPs
@@ -4128,7 +4129,7 @@ linux_nat_find_memory_regions (int (*func) (CORE_ADDR,
 static int
 find_signalled_thread (struct thread_info *info, void *data)
 {
-  if (info->stop_signal != TARGET_SIGNAL_0
+  if (TARGET_SIGNAL_NE (info->stop_signal, TARGET_SIGNAL_0)
       && ptid_get_pid (info->ptid) == ptid_get_pid (inferior_ptid))
     return 1;
 
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -1243,7 +1243,7 @@ thread_db_wait (struct target_ops *ops,
     thread_db_find_new_threads_1 (ptid);
 
   if (ourstatus->kind == TARGET_WAITKIND_STOPPED
-      && ourstatus->value.sig == TARGET_SIGNAL_TRAP)
+      && TARGET_SIGNAL_EQ (ourstatus->value.sig, TARGET_SIGNAL_TRAP))
     /* Check for a thread event.  */
     check_event (ptid);
 
--- a/gdb/record.c
+++ b/gdb/record.c
@@ -618,7 +618,7 @@ record_message (struct regcache *regcache, target_signal_t signal)
       record_list->u.end.sigval = signal;
     }
 
-  if (signal == TARGET_SIGNAL_0
+  if (TARGET_SIGNAL_EQ (signal, TARGET_SIGNAL_0)
       || !gdbarch_process_record_signal_p (gdbarch))
     ret = gdbarch_process_record (gdbarch,
 				  regcache,
@@ -1138,7 +1138,7 @@ record_wait (struct target_ops *ops,
 
 	      /* Is this a SIGTRAP?  */
 	      if (status->kind == TARGET_WAITKIND_STOPPED
-		  && status->value.sig == TARGET_SIGNAL_TRAP)
+		  && TARGET_SIGNAL_EQ (status->value.sig, TARGET_SIGNAL_TRAP))
 		{
 		  struct regcache *regcache;
 		  struct address_space *aspace;
@@ -1338,7 +1338,8 @@ Process record: hit hw watchpoint.\n");
 		      continue_flag = 0;
 		    }
 		  /* Check target signal */
-		  if (record_list->u.end.sigval != TARGET_SIGNAL_0)
+		  if (TARGET_SIGNAL_NE (record_list->u.end.sigval,
+					TARGET_SIGNAL_0))
 		    /* FIXME: better way to check */
 		    continue_flag = 0;
 		}
@@ -1363,7 +1364,7 @@ Process record: hit hw watchpoint.\n");
 replay_out:
       if (record_get_sig)
 	status->value.sig = TARGET_SIGNAL_INT;
-      else if (record_list->u.end.sigval != TARGET_SIGNAL_0)
+      else if (TARGET_SIGNAL_NE (record_list->u.end.sigval, TARGET_SIGNAL_0))
 	/* FIXME: better way to check */
 	status->value.sig = record_list->u.end.sigval;
       else
@@ -2302,7 +2303,7 @@ record_restore (void)
 	  bfdcore_read (core_bfd, osec, &signal, 
 			sizeof (signal), &bfd_offset);
 	  signal = netorder32 (signal);
-	  rec->u.end.sigval = signal;
+	  rec->u.end.sigval = target_signal_from_number (signal);
 
 	  /* Get insn count.  */
 	  bfdcore_read (core_bfd, osec, &count, 
@@ -2560,7 +2561,8 @@ cmd_record_save (char *args, int from_tty)
 				      (unsigned long) sizeof (signal),
 				      (unsigned long) sizeof (count));
 		/* Write signal value.  */
-		signal = netorder32 (record_list->u.end.sigval);
+		signal = TARGET_SIGNAL_NUMBER (record_list->u.end.sigval);
+		signal = netorder32 (signal);
 		bfdcore_write (obfd, osec, &signal,
 			       sizeof (signal), &bfd_offset);
 
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -715,7 +715,7 @@ m32r_wait (struct target_ops *ops,
     fprintf_unfiltered (gdb_stdlog, "m32r_wait()\n");
 
   status->kind = TARGET_WAITKIND_EXITED;
-  status->value.sig = 0;
+  status->value.sig = TARGET_SIGNAL_0;
 
   interrupted = 0;
   prev_sigint = signal (SIGINT, gdb_cntrl_c);
@@ -886,7 +886,7 @@ m32r_detach (struct target_ops *ops, char *args, int from_tty)
   if (remote_debug)
     fprintf_unfiltered (gdb_stdlog, "m32r_detach(%d)\n", from_tty);
 
-  m32r_resume (ops, inferior_ptid, 0, 0);
+  m32r_resume (ops, inferior_ptid, 0, TARGET_SIGNAL_0);
 
   /* calls m32r_close to do the real work */
   pop_target ();
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -44,6 +44,7 @@
 #include "cli/cli-decode.h"
 #include "cli/cli-setshow.h"
 #include "target-descriptions.h"
+#include "gdb/signals.h"
 
 #include <ctype.h>
 #include <sys/time.h>
@@ -1557,29 +1558,33 @@ remote_pass_signals (void)
   if (remote_protocol_packets[PACKET_QPassSignals].support != PACKET_DISABLE)
     {
       char *pass_packet, *p;
-      int numsigs = (int) TARGET_SIGNAL_LAST;
-      int count = 0, i;
+      target_signal_t sig;
+      int count = 0;
 
-      gdb_assert (numsigs < 256);
-      for (i = 0; i < numsigs; i++)
+      gdb_assert (TARGET_SIGNAL_NUMBER (TARGET_SIGNAL_LAST) < 256);
+      for (sig = TARGET_SIGNAL_FIRST; TARGET_SIGNAL_LE (sig,
+	   TARGET_SIGNAL_LAST); TARGET_SIGNAL_NUMBER (sig)++)
 	{
-	  if (signal_stop_state (i) == 0
-	      && signal_print_state (i) == 0
-	      && signal_pass_state (i) == 1)
+	  if (signal_stop_state (sig) == 0
+	      && signal_print_state (sig) == 0
+	      && signal_pass_state (sig) == 1)
 	    count++;
 	}
       pass_packet = xmalloc (count * 3 + strlen ("QPassSignals:") + 1);
       strcpy (pass_packet, "QPassSignals:");
       p = pass_packet + strlen (pass_packet);
-      for (i = 0; i < numsigs; i++)
+      for (sig = TARGET_SIGNAL_FIRST; TARGET_SIGNAL_LE (sig,
+	   TARGET_SIGNAL_LAST); TARGET_SIGNAL_NUMBER (sig)++)
 	{
-	  if (signal_stop_state (i) == 0
-	      && signal_print_state (i) == 0
-	      && signal_pass_state (i) == 1)
+	  if (signal_stop_state (sig) == 0
+	      && signal_print_state (sig) == 0
+	      && signal_pass_state (sig) == 1)
 	    {
-	      if (i >= 16)
-		*p++ = tohex (i >> 4);
-	      *p++ = tohex (i & 15);
+	      int signo = TARGET_SIGNAL_NUMBER (sig);
+
+	      if (signo >= 16)
+		*p++ = tohex (signo >> 4);
+	      *p++ = tohex (signo & 15);
 	      if (count)
 		*p++ = ';';
 	      else
@@ -4388,12 +4393,12 @@ append_resumption (char *p, char *endp,
 {
   struct remote_state *rs = get_remote_state ();
 
-  if (step && siggnal != TARGET_SIGNAL_0)
-    p += xsnprintf (p, endp - p, ";S%02x", siggnal);
+  if (step && TARGET_SIGNAL_NE (siggnal, TARGET_SIGNAL_0))
+    p += xsnprintf (p, endp - p, ";S%02x", TARGET_SIGNAL_NUMBER (siggnal));
   else if (step)
     p += xsnprintf (p, endp - p, ";s");
-  else if (siggnal != TARGET_SIGNAL_0)
-    p += xsnprintf (p, endp - p, ";C%02x", siggnal);
+  else if (TARGET_SIGNAL_NE (siggnal, TARGET_SIGNAL_0))
+    p += xsnprintf (p, endp - p, ";C%02x", TARGET_SIGNAL_NUMBER (siggnal));
   else
     p += xsnprintf (p, endp - p, ";c");
 
@@ -4462,7 +4467,7 @@ remote_vcont_resume (ptid_t ptid, int step, target_signal_t siggnal)
 	 process), with preference for INFERIOR_PTID.  This assumes
 	 inferior_ptid belongs to the set of all threads we are about
 	 to resume.  */
-      if (step || siggnal != TARGET_SIGNAL_0)
+      if (step || TARGET_SIGNAL_NE (siggnal, TARGET_SIGNAL_0))
 	{
 	  /* Step inferior_ptid, with or without signal.  */
 	  p = append_resumption (p, endp, inferior_ptid, step, siggnal);
@@ -4495,7 +4500,8 @@ remote_vcont_resume (ptid_t ptid, int step, target_signal_t siggnal)
 
 /* Tell the remote machine to resume.  */
 
-static target_signal_t last_sent_signal = TARGET_SIGNAL_0;
+static target_signal_t last_sent_signal
+  = TARGET_SIGNAL_INITIALIZER (TARGET_SIGNAL_0);
 
 static int last_sent_step;
 
@@ -4529,9 +4535,9 @@ remote_resume (struct target_ops *ops,
   if (execution_direction == EXEC_REVERSE)
     {
       /* We don't pass signals to the target in reverse exec mode.  */
-      if (info_verbose && siggnal != TARGET_SIGNAL_0)
-	warning (" - Can't pass signal %d to target in reverse: ignored.\n",
-		 siggnal);
+      if (info_verbose && TARGET_SIGNAL_NE (siggnal, TARGET_SIGNAL_0))
+	warning (" - Can't pass signal %s to target in reverse: ignored.\n",
+		 target_signal_to_name (siggnal));
 
       if (step 
 	  && remote_protocol_packets[PACKET_bs].support == PACKET_DISABLE)
@@ -4542,11 +4548,13 @@ remote_resume (struct target_ops *ops,
 
       strcpy (buf, step ? "bs" : "bc");
     }
-  else if (siggnal != TARGET_SIGNAL_0)
+  else if (TARGET_SIGNAL_NE (siggnal, TARGET_SIGNAL_0))
     {
+      int siggnal_number = TARGET_SIGNAL_NUMBER (siggnal);
+
       buf[0] = step ? 'S' : 'C';
-      buf[1] = tohex (((int) siggnal >> 4) & 0xf);
-      buf[2] = tohex (((int) siggnal) & 0xf);
+      buf[1] = tohex ((siggnal_number >> 4) & 0xf);
+      buf[2] = tohex (siggnal_number & 0xf);
       buf[3] = '\0';
     }
   else
@@ -5155,7 +5163,7 @@ Packet: '%s'\n"),
       else
 	{
 	  event->ws.kind = TARGET_WAITKIND_STOPPED;
-	  event->ws.value.sig = (target_signal_t)
+	  event->ws.value.sig = target_signal_from_number
 	    (((fromhex (buf[1])) << 4) + (fromhex (buf[2])));
 	}
       break;
@@ -5181,7 +5189,7 @@ Packet: '%s'\n"),
 	  {
 	    /* The remote process exited with a signal.  */
 	    event->ws.kind = TARGET_WAITKIND_SIGNALLED;
-	    event->ws.value.sig = (target_signal_t) value;
+	    event->ws.value.sig = target_signal_from_number (value);
 	  }
 
 	/* If no process is specified, assume inferior_ptid.  */
@@ -5500,7 +5508,7 @@ remote_wait_as (ptid_t ptid, struct target_waitstatus *status, int options)
 
       break;
     case '\0':
-      if (last_sent_signal != TARGET_SIGNAL_0)
+      if (TARGET_SIGNAL_NE (last_sent_signal, TARGET_SIGNAL_0))
 	{
 	  /* Zero length reply means that we tried 'S' or 'C' and the
 	     remote system doesn't support it.  */
--- a/gdb/solib-irix.c
+++ b/gdb/solib-irix.c
@@ -477,7 +477,7 @@ irix_solib_create_inferior_hook (int from_tty)
       target_resume (pid_to_ptid (-1), 0, tp->stop_signal);
       wait_for_inferior (0);
     }
-  while (tp->stop_signal != TARGET_SIGNAL_TRAP);
+  while (TARGET_SIGNAL_NE (tp->stop_signal, TARGET_SIGNAL_TRAP));
 
   /* We are now either at the "mapping complete" breakpoint (or somewhere
      else, a condition we aren't prepared to deal with anyway), so adjust
--- a/include/gdb/signals.h
+++ b/include/gdb/signals.h
@@ -51,16 +51,55 @@
 /* For an explanation of what each signal means, see
    target_signal_to_string.  */
 
-typedef enum
+#define TARGET_SIGNAL_NUMBER_CONST(target_signal) target_signal ## _NUMBER
+#define TARGET_SIGNAL_INITIALIZER(target_signal) \
+  { TARGET_SIGNAL_NUMBER_CONST (target_signal) }
+
+enum target_signal_number
   {
 #define SET(symbol, constant, name, string) \
-    symbol = constant,
-#define ANY(symbol, name, string) \
-    symbol,
+  TARGET_SIGNAL_NUMBER_CONST (symbol) = constant,
+#define ANY(symbol, name, string) TARGET_SIGNAL_NUMBER_CONST (symbol) ,
 #include "gdb/signals.inc"
 #undef ANY
 #undef SET
+  };
+
+typedef struct
+  {
+    enum target_signal_number number;
   }
 target_signal_t;
 
+#define SET(symbol, constant, name, string) ANY (symbol, name, string)
+#define ANY(symbol, name, string)			\
+  static const target_signal_t ATTRIBUTE_UNUSED symbol	\
+    = TARGET_SIGNAL_INITIALIZER (symbol);
+#include "gdb/signals.inc"
+#undef ANY
+#undef SET
+
+#define TARGET_SIGNAL_NUMBER(target_signal) (target_signal).number
+
+static inline target_signal_t
+target_signal_from_number (enum target_signal_number number)
+{
+  target_signal_t retval = { number } ;
+
+  return retval;
+}
+
+#define TARGET_SIGNAL_EQ(a, b) \
+  (TARGET_SIGNAL_NUMBER (a) == TARGET_SIGNAL_NUMBER (b))
+#define TARGET_SIGNAL_NE(a, b) \
+  (TARGET_SIGNAL_NUMBER (a) != TARGET_SIGNAL_NUMBER (b))
+#define TARGET_SIGNAL_LT(a, b) \
+  (TARGET_SIGNAL_NUMBER (a) < TARGET_SIGNAL_NUMBER (b))
+#define TARGET_SIGNAL_GT(a, b) \
+  (TARGET_SIGNAL_NUMBER (a) > TARGET_SIGNAL_NUMBER (b))
+#define TARGET_SIGNAL_LE(a, b) \
+  (TARGET_SIGNAL_NUMBER (a) <= TARGET_SIGNAL_NUMBER (b))
+#define TARGET_SIGNAL_GE(a, b) \
+  (TARGET_SIGNAL_NUMBER (a) >= TARGET_SIGNAL_NUMBER (b))
+
 #endif /* #ifndef GDB_SIGNALS_H */


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