lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Inline assembler fallback for _FPU_SETCW() missing in x86 platforms (iss


From: thomasmorley65
Subject: Inline assembler fallback for _FPU_SETCW() missing in x86 platforms (issue 575600043 by address@hidden)
Date: Fri, 31 Jan 2020 16:52:14 -0800

Reviewers: arnold.wendl_siemens.com2,

Message:
This adds Masamichi-san's suggestions from
https://codereview.appspot.com/577450043/
Comment #7
Sorry, for the new issue, initiated by accident

This does _not_ reflect the discussion of
https://lists.gnu.org/archive/html/lilypond-devel/2020-01/msg00845.html
It's out of my depth.



Description:
Inline assembler fallback for _FPU_SETCW() missing in x86 platforms

Issue 4943
As Issue 4943 on x86 platform compilations was triggered by
missing _FPU_SETCW(), an alternate call to initiate the
X87 FPU setup as an inline-assembler command is added.

Please review this at https://codereview.appspot.com/575600043/

Affected files (+26, -5 lines):
  M lily/main.cc


Index: lily/main.cc
diff --git a/lily/main.cc b/lily/main.cc
index 
4834ff82aa9b6bb649bfe8fbe863877b56c819d1..3967d1c91ec6eb93832bb3af5540dc4b4b92ee36
 100644
--- a/lily/main.cc
+++ b/lily/main.cc
@@ -176,19 +176,40 @@ static Long_option_init options_static[]
    unpredictable places. To get around this, we tell the x87 FPU to use only
    double precision. Note that this is not needed for x86_64 because that uses
    the SSE unit by default instead of the x87 FPU. */
-#if ((defined (__x86__) || defined (__i386__)) \
-  && defined (HAVE_FPU_CONTROL_H) && (HAVE_FPU_CONTROL_H == 1))
+#if defined (__x86__) || defined (__i386__)
+// This environment is x86.
+// It is necessary that setting precision by setting x87 FPU control word.
 
+#if defined (HAVE_FPU_CONTROL_H) && (HAVE_FPU_CONTROL_H == 1)
 #include <fpu_control.h>
+#endif
+
 static void
 configure_fpu ()
-{
+ {
+#if defined (HAVE_FPU_CONTROL_H) && (HAVE_FPU_CONTROL_H == 1)
+  // This environment has fpu_control.h. (e.g. Linux glibc)
+  // We use _FPU_SETCW () to set x87 FPU control word.
   fpu_control_t fpu_control = 0x027f;
   _FPU_SETCW (fpu_control);
-}
-
 #else
+  // This environment doesn't have fpu_control.h. (e.g. MinGW)
+  // We use inline asm to set x87 FPU control word.
+  asm(
+      "     push %ebp"
+    "\n     mov  $0x027f, %eax"
+    "\n     push %eax"
+    "\n     mov  %esp, %ebp"
+    "\n     fldcw (%ebp)"
+    "\n     pop %eax"
+    "\n     pop %ebp"
+  );
+#endif
+ }
 
+#else
+// This environment isn't x86. (e.g. x86_64)
+// It is unnecessary that setting precision.
 static void
 configure_fpu ()
 {





reply via email to

[Prev in Thread] Current Thread [Next in Thread]