On Wed, 20 Mar 2002, Steve Kargl wrote:

> On Thu, Mar 21, 2002 at 12:33:45PM +1100, Bruce Evans wrote:
> > want the errno support completely removed so that we have a chance
> > of declaring math functions as __pure2 unconditionally.  But maybe
> > we can't do this anyway, because math functions normally have the
> > side effect of setting IEEE exception flags.  Can we do things like
> >
> > #ifpragma STDC FENV_ACCESS ON
> > double sqrt(double);
> > #else
> > double sqrt(double) __pure2;
> > #endif
> >
> > ?
> I don't know.  I forgot about the libm PR until last
> week when someone else posted about paranoi.c failing
> several tests.  I decided to check into the quality
> of libm and work on improvements.  I still have a lot to
> learn.

The documenation for FENV_ACCESS is clear enough.  We can do things like
- default to FENV_ACCESS OFF
- do optimizations like the above except in those few programs that
  actually understand this stuff and set FENV_ACCESS to ON before they
  use the IEEE flags.
- to work right, FENV_ACCESS ON must somehow turn off many of the
  optimizations related to floating point.  Compilers will need special
  support just to turn off their own optimization.  E.g., constant
  expressions can only be fully computed at compile time if the result
  (including the IEEE flag settings) doesn't depending on the environment.

> I think we'll only be able to add __pure2 on a case
> by case basis.  For example, the POSIX sqrt(3) manpage states

glibc (an old version -- 2.1.3) only uses (the equivalent of) it for
functions like isinf() which are guaranteed not to change the IEEE

>    An application wishing to check for error situations should set
>    errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling
>    these functions.  On return, if errno is non-zero or
>    is non-zero, an error has occurred.

Also, the program must set FENV_ACCESS to ON in relevant parts of the
code if it wishes to test the flags.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to