[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Inline assembler fallback for _FPU_SETCW() missing in MINGW librarie
From: |
trueroad |
Subject: |
Re: Inline assembler fallback for _FPU_SETCW() missing in MINGW libraries (issue 577450043 by address@hidden) |
Date: |
Thu, 30 Jan 2020 02:17:14 -0800 |
How about this patch?
Sorry, not tested.
If I understand correctly,
this patch solves not only Issue 4943 but also Issue 4975.
These issues do not only occur on Windows, but on all x86 platforms
except Linux.
`defined (__MINGW32__)` is not necessary.
For Linux-x86, it uses the original precision setting. i.e. _FPU_SETCW
().
For other x86 platforms, it uses Arnold's inline asm for setting
precision.
```
diff --git a/lily/main.cc b/lily/main.cc
index 9145345fff..cba6856159 100644
--- a/lily/main.cc
+++ b/lily/main.cc
@@ -209,19 +209,40 @@ char const *LILYPOND_DATADIR = PACKAGE_DATADIR "/"
TOPLEVEL_VERSION;
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 ()
{
--
```
https://codereview.appspot.com/577450043/
- Inline assembler fallback for _FPU_SETCW() missing in MINGW libraries (issue 577450043 by address@hidden), thomasmorley65, 2020/01/29
- Re: Inline assembler fallback for _FPU_SETCW() missing in MINGW libraries (issue 577450043 by address@hidden), nine . fierce . ballads, 2020/01/29
- Re: Inline assembler fallback for _FPU_SETCW() missing in MINGW libraries (issue 577450043 by address@hidden), Carl . D . Sorensen, 2020/01/29
- Re: Inline assembler fallback for _FPU_SETCW() missing in MINGW libraries (issue 577450043 by address@hidden), thomasmorley65, 2020/01/29
- Re: Inline assembler fallback for _FPU_SETCW() missing in MINGW libraries (issue 577450043 by address@hidden), nine . fierce . ballads, 2020/01/29
- Re: Inline assembler fallback for _FPU_SETCW() missing in MINGW libraries (issue 577450043 by address@hidden), thomasmorley65, 2020/01/29
- Re: Inline assembler fallback for _FPU_SETCW() missing in MINGW libraries (issue 577450043 by address@hidden),
trueroad <=
- Re: Inline assembler fallback for _FPU_SETCW() missing in MINGW libraries (issue 577450043 by address@hidden), trueroad, 2020/01/31