re PR ada/34647 (Ada runtime includes unsafe calls to mktemp and tmpname on OpenBSD)

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
This commit is contained in:
Tero Koskinen 2008-01-03 11:35:04 +02:00 committed by Samuel Tardieu
parent 2092ee7d08
commit e0658eda3c
6 changed files with 96 additions and 9 deletions

View 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

View 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");

View 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 */

View 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

View 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);

View 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