--- gdb-trg/gdb/signals.c.orig	Sun Jan 13 22:58:16 2002
+++ gdb-trg/gdb/signals.c	Wed Sep 24 18:04:12 2003
@@ -1,6 +1,6 @@
 /* Target signal translation functions for GDB.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001 Free Software Foundation, Inc.
+   2000, 2001, 2002 Free Software Foundation, Inc.
    Contributed by Cygnus Support.
 
    This file is part of GDB.
@@ -20,10 +20,30 @@
    Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
+#ifdef GDBSERVER
+#include "server.h"
+#else
 #include "defs.h"
 #include "target.h"
+#include "gdb_string.h"
+#endif
+
 #include <signal.h>
 
+/* Always use __SIGRTMIN if it's available.  SIGRTMIN is the lowest
+   _available_ realtime signal, not the lowest supported; glibc takes
+   several for its own use.  */
+
+#ifndef REALTIME_LO
+# if defined(__SIGRTMIN)
+#  define REALTIME_LO __SIGRTMIN
+#  define REALTIME_HI __SIGRTMAX
+# elif defined(SIGRTMIN)
+#  define REALTIME_LO SIGRTMIN
+#  define REALTIME_HI SIGRTMAX
+# endif
+#endif
+
 /* This table must match in order and size the signals in enum target_signal
    in target.h.  */
 /* *INDENT-OFF* */
@@ -232,9 +252,10 @@ target_signal_from_name (char *name)
 
   /* This ugly cast brought to you by the native VAX compiler.  */
   for (sig = TARGET_SIGNAL_HUP;
-       signals[sig].name != NULL;
+       sig < TARGET_SIGNAL_LAST;
        sig = (enum target_signal) ((int) sig + 1))
-    if (STREQ (name, signals[sig].name))
+    if (signals[sig].name != NULL
+	&& strcmp (name, signals[sig].name) == 0)
       return sig;
   return TARGET_SIGNAL_UNKNOWN;
 }
@@ -486,19 +507,6 @@ target_signal_from_host (int hostsig)
     }
 #endif
 
-#if defined (SIGRTMIN)
-  if (hostsig >= SIGRTMIN && hostsig <= SIGRTMAX)
-    {
-      /* This block of TARGET_SIGNAL_REALTIME value is in order.  */
-      if (33 <= hostsig && hostsig <= 63)
-	return (enum target_signal)
-	  (hostsig - 33 + (int) TARGET_SIGNAL_REALTIME_33);
-      else if (hostsig == 64)
-	return TARGET_SIGNAL_REALTIME_64;
-      else
-	error ("GDB bug: target.c (target_signal_from_host): unrecognized real-time signal");
-    }
-#endif
   return TARGET_SIGNAL_UNKNOWN;
 }
 
@@ -735,6 +743,13 @@ do_target_signal_to_host (enum target_si
 
     default:
 #if defined (REALTIME_LO)
+#if 0
+      if (oursig < REALTIME_LO || oursig >= REALTIME_HI)
+	{
+	  *oursig_ok = 0;
+	  return 0;
+	}
+#endif
       if (oursig >= TARGET_SIGNAL_REALTIME_33
 	  && oursig <= TARGET_SIGNAL_REALTIME_63)
 	{
@@ -742,46 +757,25 @@ do_target_signal_to_host (enum target_si
              TARGET_SIGNAL_REALTIME_33 is 33 by definition.  */
 	  int retsig =
 	    (int) oursig - (int) TARGET_SIGNAL_REALTIME_33 + 33;
-	  if (retsig >= REALTIME_LO && retsig < REALTIME_HI)
-	    return retsig;
+	  return retsig;
 	}
-#if (REALTIME_LO < 33)
       else if (oursig == TARGET_SIGNAL_REALTIME_32)
 	{
 	  /* TARGET_SIGNAL_REALTIME_32 isn't contiguous with
              TARGET_SIGNAL_REALTIME_33.  It is 32 by definition.  */
 	  return 32;
 	}
-#endif
-#if (REALTIME_HI > 64)
-      if (oursig >= TARGET_SIGNAL_REALTIME_64
+      else if (oursig >= TARGET_SIGNAL_REALTIME_64
 	  && oursig <= TARGET_SIGNAL_REALTIME_127)
 	{
 	  /* This block of signals is continuous, and
              TARGET_SIGNAL_REALTIME_64 is 64 by definition.  */
 	  int retsig =
 	    (int) oursig - (int) TARGET_SIGNAL_REALTIME_64 + 64;
-	  if (retsig >= REALTIME_LO && retsig < REALTIME_HI)
-	    return retsig;
+	  return retsig;
 	}
-      
-#endif
 #endif
 
-#if defined (SIGRTMIN)
-      if (oursig >= TARGET_SIGNAL_REALTIME_33
-	  && oursig <= TARGET_SIGNAL_REALTIME_63)
-	{
-	  /* This block of signals is continuous, and
-             TARGET_SIGNAL_REALTIME_33 is 33 by definition.  */
-	  int retsig =
-	    (int) oursig - (int) TARGET_SIGNAL_REALTIME_33 + 33;
-	  if (retsig >= SIGRTMIN && retsig <= SIGRTMAX)
-	    return retsig;
-	}
-      else if (oursig == TARGET_SIGNAL_REALTIME_64)
-	return 64;
-#endif
       *oursig_ok = 0;
       return 0;
     }
@@ -829,9 +823,11 @@ target_signal_from_command (int num)
 Use \"info signals\" for a list of symbolic signals.");
 }
 
+#ifndef GDBSERVER
 void
 _initialize_signals (void)
 {
-  if (!STREQ (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC"))
+  if (strcmp (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC") != 0)
     internal_error (__FILE__, __LINE__, "failed internal consistency check");
 }
+#endif
