diff --git a/src/mzscheme/sconfig.h b/src/mzscheme/sconfig.h index b49a52b272..9adf758203 100644 --- a/src/mzscheme/sconfig.h +++ b/src/mzscheme/sconfig.h @@ -155,6 +155,7 @@ # if defined(i386) # define SCHEME_PLATFORM_LIBRARY_SUBPATH "i386-linux" # define REGISTER_POOR_MACHINE +# define ASM_DBLPREC_CONTROL_87 # endif # if defined(powerpc) # define SCHEME_PLATFORM_LIBRARY_SUBPATH "ppc-linux" @@ -178,6 +179,7 @@ # if defined(__x86_64__) # define SCHEME_PLATFORM_LIBRARY_SUBPATH "x86_64-linux" # define REGISTER_POOR_MACHINE +# define ASM_DBLPREC_CONTROL_87 # endif # ifndef SCHEME_PLATFORM_LIBRARY_SUBPATH # define SCHEME_PLATFORM_LIBRARY_SUBPATH "unknown-linux" @@ -672,6 +674,7 @@ # define USE_CARBON_FP_PREDS # define TRIG_ZERO_NEEDS_SIGN_CHECK +# define ASM_DBLPREC_CONTROL_87 # define USE_DYNAMIC_FDSET_SIZE @@ -1172,6 +1175,10 @@ converts (a == a) to TRUE, even if `a' is floating-point. Used only when USE_[SCO_]IEEE_FP_PREDS is not defined. */ + /* ASM_DBLPREC_CONTROL_87 uses inline assembly to set Intel '387 + floating-point operations to double-precision instead of + extended-precision arithmetic. */ + /* IGNORE_BY_BORLAND_CONTROL_87 turns off floating-point error for Intel '387 with Borlad-style _control87. DONT_IGNORE_PIPE_SIGNAL can be on or off. */ diff --git a/src/mzscheme/src/number.c b/src/mzscheme/src/number.c index 055da24579..cd955c933b 100644 --- a/src/mzscheme/src/number.c +++ b/src/mzscheme/src/number.c @@ -177,6 +177,15 @@ scheme_init_number (Scheme_Env *env) flags |= IEEE_TRAP_ENABLE_MASK; ieee_set_fp_control(flags); } +#endif +#ifdef ASM_DBLPREC_CONTROL_87 + { + /* Make x87 computations double-precision instead of + extended-precision, so that if/when the JIT generates + x87 instructions, it's consistent with everything else. */ + int _dblprec = 0x27F; + asm ("fldcw %0" : : "m" (_dblprec)); + } #endif END_XFORM_SKIP;