--- tclAppInit.cc.orig Fri Mar 2 11:44:50 2001 +++ tclAppInit.cc Fri Mar 2 11:46:02 2001 @@ -63,63 +63,34 @@ #if defined(linux) && defined(i386) -#ifndef HAVE_FESETPRECISION -/* - * From: - | Floating-point environment | - | Copyright (C) 1996, 1997, 1998, 1999 | - | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, | - | Australia. | - | E-mail billm@melbpc.org.au | - * used here with permission. - */ -#define FE_FLTPREC 0x000 -#define FE_INVALIDPREC 0x100 -#define FE_DBLPREC 0x200 -#define FE_LDBLPREC 0x300 -/* - * From: - * fenvwm.c - | Copyright (C) 1999 | - | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, | - | Australia. E-mail billm@melbpc.org.au | - * used here with permission. - */ -/* - Set the precision to prec if it is a valid - floating point precision macro. - Returns 1 if precision set, 0 otherwise. - */ -int fesetprecision(int prec) -{ - unsigned short cw; - asm volatile ("fnstcw %0":"=m" (cw)); - if ( !(prec & ~FE_LDBLPREC) && (prec != FE_INVALIDPREC) ) - { - cw = (cw & ~FE_LDBLPREC) | (prec & FE_LDBLPREC); - asm volatile ("fldcw %0":"=m" (cw)); - return 1; - } - else - return 0; -} -#endif /* !HAVE_FESETPRECISION */ +#include /* - * Linux i386 uses 60-bit floats for calculation, + * Linux x86 uses 60-bit floats for calculation, * not 56-bit floats, giving different results. * Fix that. - * - * See + * + * See * for why we do this fix. * - * This function is derived from wmexcep + * The macros and constants set in are used here. * */ + void fix_i386_linux_floats() { - fesetprecision(FE_DBLPREC); + unsigned short mode =0; + + // masks for exceptions (see fpu_control.h) + mode |= _FPU_MASK_IM | _FPU_MASK_DM; // invalid op and denormalized op + mode |= _FPU_MASK_ZM | _FPU_MASK_PM; // zerodiv and precision + mode |= _FPU_MASK_UM | _FPU_MASK_OM; // overflow and underflow + + // set precision to double and rounding to nearest (as IEEE 754) + mode |= _FPU_DOUBLE | _FPU_RC_NEAREST; + + _FPU_SETCW(mode); } #endif