From owner-freebsd-current Thu Mar 21 3:17:24 2002 Delivered-To: freebsd-current@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id BFA4437B400 for ; Thu, 21 Mar 2002 03:17:18 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id WAA14345; Thu, 21 Mar 2002 22:17:13 +1100 Date: Thu, 21 Mar 2002 22:17:26 +1100 (EST) From: Bruce Evans X-X-Sender: To: Steve Kargl Cc: Subject: Re: Removing CSRG libm? In-Reply-To: <20020320192013.A42351@troutmask.apl.washington.edu> Message-ID: <20020321214950.N13775-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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