1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-11-04 22:33:27 +00:00
freebsd-ports/lang/gnat/files/patch-ai
Daniel Eischen 4c48f0e44d When initializing the GNAT (i386) run-time, initialize the floating point
control word to use 64-bit (extended) precision instead of FreeBSDs
default 53-bit (double) precision.

Submitted by:	Sune Falck <sunef@hem.passagen.se>
2000-06-27 11:27:25 +00:00

111 lines
2.8 KiB
Plaintext

*** ./ada/a-init.c.orig Fri Sep 24 08:42:43 1999
--- ./ada/a-init.c Mon Jun 26 21:43:54 2000
***************
*** 1445,1450 ****
--- 1445,1532 ----
}
+ /*************************************************/
+ /* __gnat_initialize (FreeBSD version) */
+ /*************************************************/
+
+ #elif defined (__FreeBSD__)
+
+ #include <signal.h>
+ #include <unistd.h>
+
+ static void
+ __gnat_error_handler (sig, code, sc)
+ int sig;
+ int code;
+ struct sigcontext *sc;
+ {
+ struct Exception_Data *exception;
+ 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);
+ }
+
+ static void
+ __gnat_install_handler ()
+ {
+ struct sigaction act;
+
+ /* Set up signal handler to map synchronous signals to appropriate
+ exceptions. Make sure that the handler isn't interrupted by another
+ signal that might cause a scheduling event! */
+
+ 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_init_float ();
+
+ void
+ __gnat_initialize ()
+ {
+ __gnat_install_handler ();
+
+ /* XXX - Initialize floating-point coprocessor. This call is
+ needed because FreeBSD defaults to 53-bit precision instead
+ of 64-bit precision. We require the full precision for
+ proper operation, given that we have set Max_Digits etc
+ with this in mind. */
+ __gnat_init_float ();
+ }
+
/***************************************/
/* __gnat_initialize (default version) */
/***************************************/
***************
*** 1470,1476 ****
defined in all Win32 versions, but only actually does something on
the i386 version, where it properly initializes the FPU for GNAT use. */
! #if defined (_WIN32) || defined (__INTERIX)
void
__gnat_init_float ()
{
--- 1552,1558 ----
defined in all Win32 versions, but only actually does something on
the i386 version, where it properly initializes the FPU for GNAT use. */
! #if defined (_WIN32) || defined (__INTERIX) || defined (__FreeBSD__)
void
__gnat_init_float ()
{