Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Mar 2002 22:17:26 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Steve Kargl <sgk@troutmask.apl.washington.edu>
Cc:        <freebsd-current@FreeBSD.ORG>
Subject:   Re: Removing CSRG libm?
Message-ID:  <20020321214950.N13775-100000@gamplex.bde.org>
In-Reply-To: <20020320192013.A42351@troutmask.apl.washington.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
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
this:
- 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
flags.

>    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
>    fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW |FE_UNDERFLOW)
>    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.

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020321214950.N13775-100000>