GNAT 5.0 sources - patch

Berndt Josef Wulf wulf@dingo.ping.net.au
Tue Feb 19 09:16:00 GMT 2002


G'day,

please patch below against gcc/ada/init.c that fixes the
floating point initialization on NetBSD-i386 platforms. The patch was
tested on NetBSD-1.5ZA-i386 using gcc-3.1-20020211 cvs sources.

Please consider the inclusion of this patch in future version of
gcc-3.x.

Many thanks in advance

cheerio Berndt
-- 
Name    : Berndt Josef Wulf            | +++ With BSD on Packet Radio +++
E-Mail  : wulf@ping.net.au             |    tfkiss, tnt, dpbox, wampes
ICQ     : 18196098                     |  VK5ABN, Nairne, South Australia 
URL     : http://www.ping.net.au/~wulf | MBOX : vk5abn@vk5abn.#lmr.#sa.au.oc
Sysinfo : DEC AXPpci33+, NetBSD-1.5    | BBS  : vk5abn.#lmr.#sa.aus.oc 



------------------- init.c.diff ---------------------
--- init.c.orig	Thu Feb 14 00:24:48 2002
+++ init.c	Sun Feb 17 00:04:15 2002
@@ -1640,6 +1640,69 @@
 #endif
 }
 
+/***************************************/
+/* __gnat_initialize for BSD           */
+/***************************************/
+#elif defined(__NetBSD__)
+
+#include <signal.h>
+#include <unistd.h>
+
+static void
+__gnat_error_handler(sig)
+  int sig;
+{
+  struct Exception_Data *exception;
+  const char *msg;
+
+  switch(sig)
+  {
+    case SIGFPE:
+      exception = &constraint_error;
+      msg = "SIGFPE";
+      break;
+    case SIGILL:
+      exception = &constraint_error;
+      msg = "SIGILL";
+      break;
+    case SIGSEGV:
+      exception = &storage_error;
+      msg = "stack overflow or erroneous memory access";
+      break;
+    case SIGBUS:
+      exception = &constraint_error;
+      msg = "SIGBUS";
+      break;
+    default:
+      exception = &program_error;
+      msg = "unhandled signal";
+    }
+
+    Raise_From_Signal_Handler(exception, msg);
+}
+
+void
+__gnat_install_handler()
+{
+  struct sigaction act;
+
+  act.sa_handler = __gnat_error_handler;
+  act.sa_flags = SA_NODEFER | SA_RESTART;
+  (void) sigemptyset(&act.sa_mask);
+
+  (void) sigaction(SIGILL, &act, NULL);
+  (void) sigaction(SIGFPE, &act, NULL);
+  (void) sigaction(SIGSEGV, &act, NULL);
+  (void) sigaction(SIGBUS, &act, NULL);
+}
+
+void
+__gnat_initialize()
+{
+  __gnat_install_handler();
+  __gnat_init_float();
+}
+
 #else
 
 /* For all other versions of GNAT, the initialize routine and handler
@@ -1675,7 +1738,7 @@
    WIN32 and could be used under OS/2 */
 
 #if defined (_WIN32) || defined (__INTERIX) || defined (__EMX__) \
-  || defined (__Lynx__)
+  || defined (__Lynx__) || defined(__NetBSD__)
 
 #define HAVE_GNAT_INIT_FLOAT
------------------- init.c.diff ---------------------



More information about the Gcc-patches mailing list