[Ada] Reset x87 FPU to 64-bit precision for floating-point I/O on Linux

Message ID 20210506075812.GA125561@adacore.com
State New
Headers show
Series
  • [Ada] Reset x87 FPU to 64-bit precision for floating-point I/O on Linux
Related show

Commit Message

Pierre-Marie de Rodat May 6, 2021, 7:58 a.m.
This is basically done on all x86/x86-64 native systems except for Linux
and makes it possible to work around other precision settings, e.g Java's.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* init.c (__gnat_init_float): Use full version on Linux too.

Patch

diff --git a/gcc/ada/init.c b/gcc/ada/init.c
--- a/gcc/ada/init.c
+++ b/gcc/ada/init.c
@@ -2749,11 +2749,7 @@  __gnat_install_handler (void)
 /* __gnat_init_float */
 /*********************/
 
-/* This routine is called as each process thread is created, for possible
-   initialization of the FP processor.  This version is used under INTERIX
-   and WIN32.  */
-
-#if defined (_WIN32) || defined (__INTERIX) \
+#if defined (_WIN32) || defined (__INTERIX) || defined (__linux__) \
   || defined (__Lynx__) || defined(__NetBSD__) || defined(__FreeBSD__) \
   || defined (__OpenBSD__) || defined (__DragonFly__) || defined(__QNX__)
 
@@ -2763,13 +2759,10 @@  void
 __gnat_init_float (void)
 {
 #if defined (__i386__) || defined (__x86_64__)
-
-  /* This is used to properly initialize the FPU on an x86 for each
-     process thread.  */
-
+  /* This is used to properly initialize the FPU to 64-bit precision on an x86
+     for each process thread and also for floating-point I/O.  */
   asm ("finit");
-
-#endif  /* Defined __i386__ */
+#endif
 }
 #endif