a0ee07829a
This brings us up to date with FreeBSD HEAD, fixes various bugs, unifies the set of functions we support on ARM, MIPS, and x86, fixes "long double", adds ISO C99 support, and adds basic unit tests. It turns out that our "long double" functions have always been broken for non-normal numbers. This patch fixes that by not using the upstream implementations and just forwarding to the regular "double" implementation instead (since "long double" on Android is just "double" anyway, which is what BSD doesn't support). All the tests pass on ARM, MIPS, and x86, plus glibc on x86-64. Bug: 3169850 Bug: 8012787 Bug: https://code.google.com/p/android/issues/detail?id=6697 Change-Id: If0c343030959c24bfc50d4d21c9530052c581837
40 lines
992 B
C
40 lines
992 B
C
/*
|
|
* ====================================================
|
|
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
|
*
|
|
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
* Permission to use, copy, modify, and distribute this
|
|
* software is freely granted, provided that this notice
|
|
* is preserved.
|
|
* ====================================================
|
|
*/
|
|
|
|
#include <sys/cdefs.h>
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
/*
|
|
* Float version of k_log.h. See the latter for most comments.
|
|
*/
|
|
|
|
static const float
|
|
/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */
|
|
Lg1 = 0xaaaaaa.0p-24, /* 0.66666662693 */
|
|
Lg2 = 0xccce13.0p-25, /* 0.40000972152 */
|
|
Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */
|
|
Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */
|
|
|
|
static inline float
|
|
k_log1pf(float f)
|
|
{
|
|
float hfsq,s,z,R,w,t1,t2;
|
|
|
|
s = f/((float)2.0+f);
|
|
z = s*s;
|
|
w = z*z;
|
|
t1= w*(Lg2+w*Lg4);
|
|
t2= z*(Lg1+w*Lg3);
|
|
R = t2+t1;
|
|
hfsq=(float)0.5*f*f;
|
|
return s*(hfsq+R);
|
|
}
|