On Tue, Nov 08, 2011 at 04:41:32PM +0100, Rainer Orth wrote: > Steve Kargl <s...@troutmask.apl.washington.edu> writes: > > >> Please no: sqrtl is a C99 addition, and we don't want lists of non-C99 > >> targets in tests that require them. > >> > > > > OK, so, then we simply accept that running a regression test > > on these targets will always FAIL? If the answer is 'yes', > > then please close this PR because I doubt anyone will implement > > sqrtl(). > > No. AFAICS so far C99 functions have been implemented in > intrinsics/c99_functions.c for the benefit of platforms that aren't > C99. Has this policy changed recently?
The policy has not changed. However, it took me >3 years to get an implementation of sqrtl() into FreeBSD's libm. On the surface, sqrtl() looks almost trivial to implement, but the IEEE 754 requirement of correct rounding in all rounding modes can be a nightmare to get right. Adopting FreeBSD sqrtl() has some issues. > I don't think it's a good idea for libgfortran to contain references to > nonexistant functions (or for gfortran to emit references to C99 > functions on non-C99 platforms, if that's the case). At least that's > not what any other GCC language frontend does. AFAIK, gfortran has always assumed that it is being built/run on a system with C99 functions. If one does not care about correct rounding, then one can do #include <math.h> long double sqrtl(long double x) { if (x == 0) return x; if (x < 0) return ((x - x) / (x - x)); if (isfinite(x)) { reduce x to 2*f*2**n. check if x is subnormal and adjust f and n. if (n is odd) { f = 2*f; n--; } use Newtow's iteration to compute sqrtl(f) with a starting value of xn = sqrt(f) now combine everything return (xn*2**(n/2)) } else return (x * x + x); } -- Steve