[Ecls-list] FPE under MSVC

Juan Jose Garcia Ripoll lisp at arrakis.es
Tue Oct 25 00:55:49 UTC 2005


On Tue, 2005-10-25 at 09:14 +0200, Goffioul Michael wrote:
> Hi,
> 
> In attachment, you'll find a trial at supporting floating point exceptions
> under MSVC. It seems to work OK, but it triggers a problem: it generates
> a FE_UNDERFLOW error when trying to print least-positive-double-float:
> [....]
> Is it MSVC-specific or can anybody reproduce it under Linux?

No, it's MSVC-specific and probably related to a problem in the C
library. Perhaps you could save the control word at entry on
edit_double(), disable the exceptions, and restore it on exit? Something
as what follows below, which should also work on linux. If windows does
not have feholdexcept(), etc, you simulate them using _controlw(), move
the simulating macros from unixint.d to internal.h and define
HAVE_FENV_H in config.h

Index: print.d
===================================================================
RCS file: /home/jlr/cvs/ecls/src/c/print.d,v
retrieving revision 1.107
diff -c -r1.107 print.d
*** print.d	4 Oct 2005 13:48:50 -0000	1.107
--- print.d	25 Oct 2005 07:50:55 -0000
***************
*** 483,488 ****
--- 483,492 ----
  {
  	char *exponent, *p, buff[DBL_SIZE + 1];
  	int length;
+ #ifdef HAVE_FENV_H
+ 	fenv_t env;
+ 	feholdexcept(&env);
+ #endif
  
  	if (isnan(d) || !finite(d))
  		FEerror("Can't print a non-number.", 0);
***************
*** 530,535 ****
--- 534,542 ----
  			s[i] = '0';
  	}
  	s[n] = '\0';
+ #ifdef HAVE_FENV_H
+ 	fesetenv(&env);
+ #endif
  	return length;
  }
  






More information about the ecl-devel mailing list