]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/main.cc
Merge branch 'lilypond/translation' of ssh://trettig@git.sv.gnu.org/srv/git/lilypond...
[lilypond.git] / lily / main.cc
index 3c0f7ae88eb7a4f28a065d1555ff4ffcf9c07aa9..e0f5dda1a2d93a34a3a06b4834b60954a6fa4dbb 100644 (file)
@@ -166,6 +166,29 @@ static Long_option_init options_static[]
 
 char const *LILYPOND_DATADIR = PACKAGE_DATADIR "/" TOPLEVEL_VERSION;
 
+
+/* x86 defaults to using 80-bit extended precision arithmetic. This can cause
+   problems because the truncation from 80 bits to 64 bits can occur in
+   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))
+
+#include <fpu_control.h>
+static void configure_fpu() {
+  fpu_control_t fpu_control = 0x027f;
+  _FPU_SETCW (fpu_control);
+}
+
+#else
+
+static void configure_fpu() {
+}
+
+#endif /* defined(__x86__) || defined(__i386__) */
+
+
 static void
 env_var_info (FILE *out, char const *key)
 {
@@ -569,6 +592,8 @@ vector<string> start_environment_global;
 int
 main (int argc, char **argv, char **envp)
 {
+  configure_fpu();
+
   for (char **p = envp; *p; p++)
     start_environment_global.push_back(*p);