Reviewers: , Description: Inline assembler fallback for _FPU_SETCW() missing in MINGW libraries
Issue 4943 As Issue 4943 on Windows compilation was triggered by missing _FPU_SETCW() in the MINGW libraries, an alternate call to initiate the X87 FPU setup as an inline-assembler command is added - for MINGW 32 Bit compilation only. Please review this at https://codereview.appspot.com/577450043/ Affected files (+24, -0 lines): M lily/main.cc Index: lily/main.cc diff --git a/lily/main.cc b/lily/main.cc index 4834ff82aa9b6bb649bfe8fbe863877b56c819d1..cfb04d86f8d0b200c3a6e15ae8a36960b31570fa 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -192,6 +192,30 @@ configure_fpu () static void configure_fpu () { +#if ((defined (__x86__) || defined (__i386__)) \ + && defined (__MINGW32__) && defined (__code_model_32__) && !defined(__SSE2_MATH__)) + /* If this is a MINGW compilation (for Windows), + * but not using SSE2 arithmetic unit nor is a 64 bit compilation (which uses SSE2 by default) + * _FPU_SETCW() got lost in the MINGW libraries! + * Here is an inline assembler call to execute the same task for the X87 arithmetic unit. + * + * TODO: output a message what we're going to do here, _only_ if DEBUG level is selected, + * but configure_fpu() is called before the commandline options get evaluated. + * At the moment the info message will be blanked on the console, but if output is + * directed into a file, most editors will show it. + */ + fprintf(stderr, " X87 FPU setup via asm() ... "); + asm( + " push %ebp" + "\n mov $0x027f, %eax" + "\n push %eax" + "\n mov %esp, %ebp" + "\n fldcw (%ebp)" + "\n pop %eax" + "\n pop %ebp" + ); + fprintf(stderr, "done.\r \r"); +#endif /* (defined(__x86__) || defined(__i386__)) && defined (__MINGW32__) && defined (__code_model_32__) && !defined(__SSE2_MATH__) */ } #endif /* defined(__x86__) || defined(__i386__) */