This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: New ieee comparison testcase for testsuite (Version 2)


On Sun, 25 Apr 1999 21:43:34 -0400 (EDT), John Wehle wrote:
>[ This version checks for __STDC_IEC_559__ per Zack's
>  recommendation in order to decide if fesetenv should
>  be used instead of checking for __linux__. ]
>
>This testcase trips in situations not caught by fp-cmp-1.
>fpsetmask (fesetenv) is used to disable floating point
>exceptions caused by NaN comparisons so that the result
>of the actual comparison can be checked.  The fesetenv
>solution is based on email from Zack and Richard ... I
>don't have access to an iso c9x (i.e. glibc 2.1) machine
>so I can't confirm that it's correct.

Still not quite right.  FE_NOMASK_ENV (not FP_NOMASK_ENV) is a mode in
which *all* exceptions cause signals.  Linux doesn't currently have
anything like fpsetmask() that can toggle individual flags (well,
there was the totally unportable __setfpucw(), which is gone in 2.1).
But if I understand your program correctly, a mode in which *no*
exceptions cause signals will do what you want.  You get that, using
the C9x interface, with feholdexcept().  Patch to your program
follows.

[glibc ought to implement fpsetmask - it's more flexible, and both
svr4 and 4.4bsd have it... >>todo-list]

zw

$ diff -u y.c.old y.c
--- y.c.old     Sun Apr 25 21:52:56 1999
+++ y.c Sun Apr 25 21:52:40 1999
@@ -25,7 +25,8 @@
 #if defined(__FreeBSD__) || defined(__svr4__)
   fpsetmask (~FP_X_INV);
 #elif defined(__STDC_IEC_559__)
-  fesetenv (FP_NOMASK_ENV);
+  fenv_t fe;
+  feholdexcept (&fe);
 #else
 #  ifndef SIGNAL_SUPPRESS
   /* Some machines catches a SIGFPE when a NaN is compared.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]