]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR ada/34647 (Ada runtime includes unsafe calls to mktemp and tmpname on OpenBSD)
authorTero Koskinen <tero.koskinen@iki.fi>
Thu, 3 Jan 2008 09:35:04 +0000 (11:35 +0200)
committerSamuel Tardieu <sam@gcc.gnu.org>
Thu, 3 Jan 2008 09:35:04 +0000 (09:35 +0000)
2008-01-03  Tero Koskinen <tero.koskinen@iki.fi>

    gcc/ada/
PR ada/34647
* adaint.c (__gnat_open_new_temp, __gnat_tmp_name): Use mkstemp()
on OpenBSD as is done on other BSD systems.

PR ada/34645
* sysdep.c (__gnat_ttyname, getc_immediate_nowait,
getc_immediate_common): Treat OpenBSD as FreeBSD regarding immediate
I/O.

PR ada/34644
* env.c (__gnat_clearenv): Treat OpenBSD as other BSD systems missing
clearenv().

PR ada/34646
* init.c (__gnat_error_handler, __gnat_install_handler,
__gnat_init_float): Define for OpenBSD.

* initialize.c (__gnat_initialize): Define for OpenBSD.

From-SVN: r131301

gcc/ada/ChangeLog
gcc/ada/adaint.c
gcc/ada/env.c
gcc/ada/init.c
gcc/ada/initialize.c
gcc/ada/sysdep.c

index 5c260387cebb65845c65df867706e0f0f70a67e1..6537c951fb14e675e5fae3ff566a420966a2c6aa 100644 (file)
@@ -1,3 +1,24 @@
+2008-01-03  Tero Koskinen <tero.koskinen@iki.fi>
+
+       PR ada/34647
+       * adaint.c (__gnat_open_new_temp, __gnat_tmp_name): Use mkstemp()
+       on OpenBSD as is done on other BSD systems.
+
+       PR ada/34645
+       * sysdep.c (__gnat_ttyname, getc_immediate_nowait,
+       getc_immediate_common): Treat OpenBSD as FreeBSD regarding immediate
+       I/O.
+
+       PR ada/34644
+       * env.c (__gnat_clearenv): Treat OpenBSD as other BSD systems missing
+       clearenv().
+
+       PR ada/34646
+       * init.c (__gnat_error_handler, __gnat_install_handler,
+       __gnat_init_float): Define for OpenBSD.
+
+       * initialize.c (__gnat_initialize): Define for OpenBSD.
+
 2007-12-27  Samuel Tardieu  <sam@rfc1149.net>
 
        PR ada/34553
index 1556b28ffdf303c5ff3970a82e0db5f8aa9e4a11..3bc20eb672efd7fd4537827a100d370c253760fa 100644 (file)
@@ -887,8 +887,8 @@ __gnat_open_new_temp (char *path, int fmode)
 
   strcpy (path, "GNAT-XXXXXX");
 
-#if (defined (__FreeBSD__) || defined (__NetBSD__) || defined (linux)) && \
-  !defined (__vxworks)
+#if (defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) \
+  || defined (linux)) && !defined (__vxworks)
   return mkstemp (path);
 #elif defined (__Lynx__)
   mktemp (path);
@@ -980,7 +980,8 @@ __gnat_tmp_name (char *tmp_filename)
     free (pname);
   }
 
-#elif defined (linux) || defined (__FreeBSD__) || defined (__NetBSD__)
+#elif defined (linux) || defined (__FreeBSD__) || defined (__NetBSD__) \
+  || defined (__OpenBSD__)
 #define MAX_SAFE_PATH 1000
   char *tmpdir = getenv ("TMPDIR");
 
index 6cbb7057a64f4e6ae7f15983807245ec9f6d62c7..46bfe1b0c4e83f330dcd53e2a6229a7bcca54cfb 100644 (file)
@@ -290,7 +290,7 @@ void __gnat_clearenv (void) {
   }
 #elif defined (__MINGW32__) || defined (__FreeBSD__) || defined (__APPLE__) \
    || (defined (__vxworks) && defined (__RTP__)) || defined (__CYGWIN__) \
-   || defined (__NetBSD__)
+   || defined (__NetBSD__) || defined (__OpenBSD__)
   /* On Windows, FreeBSD and MacOS there is no function to clean all the
      environment but there is a "clean" way to unset a variable. So go
      through the environ table and call __gnat_unsetenv on all entries */
index fdfd31a6e2a68568e8bfcd01a6b85485687b00a7..caf3adc98d7aeeea15a5ca7b3a1a0a05c58af070 100644 (file)
@@ -1902,6 +1902,69 @@ __gnat_install_handler(void)
   __gnat_handler_installed = 1;
 }
 
+/*******************/
+/* OpenBSD Section */
+/*******************/
+
+#elif defined(__OpenBSD__)
+
+#include <signal.h>
+#include <unistd.h>
+
+static void
+__gnat_error_handler (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(void)
+{
+  struct sigaction act;
+
+  act.sa_handler = __gnat_error_handler;
+  act.sa_flags = SA_NODEFER | SA_RESTART;
+  sigemptyset (&act.sa_mask);
+
+  /* Do not install handlers if interrupt state is "System" */
+  if (__gnat_get_interrupt_state (SIGFPE) != 's')
+    sigaction (SIGFPE,  &act, NULL);
+  if (__gnat_get_interrupt_state (SIGILL) != 's')
+    sigaction (SIGILL,  &act, NULL);
+  if (__gnat_get_interrupt_state (SIGSEGV) != 's')
+    sigaction (SIGSEGV, &act, NULL);
+  if (__gnat_get_interrupt_state (SIGBUS) != 's')
+    sigaction (SIGBUS,  &act, NULL);
+
+  __gnat_handler_installed = 1;
+}
+
 #else
 
 /* For all other versions of GNAT, the handler does nothing */
@@ -1927,7 +1990,8 @@ __gnat_install_handler (void)
    WIN32 and could be used under OS/2 */
 
 #if defined (_WIN32) || defined (__INTERIX) || defined (__EMX__) \
-  || defined (__Lynx__) || defined(__NetBSD__) || defined(__FreeBSD__)
+  || defined (__Lynx__) || defined(__NetBSD__) || defined(__FreeBSD__) \
+  || defined (__OpenBSD__)
 
 #define HAVE_GNAT_INIT_FLOAT
 
index a06e98ece65fefa5ca56e375efba6d57b32bde4e..a84f7535dc134dad8d09dac51017cae0258e52e5 100644 (file)
@@ -98,7 +98,8 @@ __gnat_initialize (void *eh)
 /* __gnat_initialize (init_float version) */
 /******************************************/
 
-#elif defined (__Lynx__) || defined (__FreeBSD__) || defined(__NetBSD__)
+#elif defined (__Lynx__) || defined (__FreeBSD__) || defined(__NetBSD__) \
+  || defined (__OpenBSD__)
 
 extern void __gnat_init_float (void);
 
index 6aca196af76e40493abf501909b3c6bb5a6ee9e8..cf51ebea76abac752c9b8cee849617e60df2ea14 100644 (file)
@@ -342,7 +342,7 @@ __gnat_ttyname (int filedes)
   || (defined (__osf__) && ! defined (__alpha_vxworks)) || defined (WINNT) \
   || defined (__MACHTEN__) || defined (__hpux__) || defined (_AIX) \
   || (defined (__svr4__) && defined (i386)) || defined (__Lynx__) \
-  || defined (__CYGWIN__) || defined (__FreeBSD__)
+  || defined (__CYGWIN__) || defined (__FreeBSD__) || defined (__OpenBSD__)
 
 #ifdef __MINGW32__
 #if OLD_MINGW
@@ -399,7 +399,7 @@ getc_immediate_common (FILE *stream,
     || (defined (__osf__) && ! defined (__alpha_vxworks)) \
     || defined (__CYGWIN32__) || defined (__MACHTEN__) || defined (__hpux__) \
     || defined (_AIX) || (defined (__svr4__) && defined (i386)) \
-    || defined (__Lynx__) || defined (__FreeBSD__)
+    || defined (__Lynx__) || defined (__FreeBSD__) || defined (__OpenBSD__)
   char c;
   int nread;
   int good_one = 0;
@@ -418,7 +418,7 @@ getc_immediate_common (FILE *stream,
 #if defined(linux) || defined (sun) || defined (sgi) || defined (__EMX__) \
     || defined (__osf__) || defined (__MACHTEN__) || defined (__hpux__) \
     || defined (_AIX) || (defined (__svr4__) && defined (i386)) \
-    || defined (__Lynx__) || defined (__FreeBSD__)
+    || defined (__Lynx__) || defined (__FreeBSD__) || defined (__OpenBSD__)
       eof_ch = termios_rec.c_cc[VEOF];
 
       /* If waiting (i.e. Get_Immediate (Char)), set MIN = 1 and wait for