Import these fixes from upstream.

0563b7a42b/lib/msun/src/e_j0f.c

Fix test build on OS X.
This commit is contained in:
Viral B. Shah 2015-11-13 09:16:51 +05:30
parent c29e8b1b6e
commit 4c8740ad58
3 changed files with 27 additions and 39 deletions

View file

@ -14,12 +14,9 @@
*/
#include <assert.h>
#include "cdefs-compat.h"
//__FBSDID("$FreeBSD: src/lib/msun/src/e_j0f.c,v 1.8 2008/02/22 02:30:35 das Exp $");
#include <openlibm_math.h>
#include "math_private.h"
static float pzerof(float), qzerof(float);
@ -65,17 +62,17 @@ __ieee754_j0f(float x)
* j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
* y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
*/
if(ix>0x80000000) z = (invsqrtpi*cc)/sqrtf(x);
if(ix>0x58000000) z = (invsqrtpi*cc)/sqrtf(x); /* |x|>2**49 */
else {
u = pzerof(x); v = qzerof(x);
z = invsqrtpi*(u*cc-v*ss)/sqrtf(x);
}
return z;
}
if(ix<0x39000000) { /* |x| < 2**-13 */
if(ix<0x3b000000) { /* |x| < 2**-9 */
if(huge+x>one) { /* raise inexact if x != 0 */
if(ix<0x32000000) return one; /* |x|<2**-27 */
else return one - (float)0.25*x*x;
if(ix<0x39800000) return one; /* |x|<2**-12 */
else return one - x*x/4;
}
}
z = x*x;
@ -139,14 +136,14 @@ __ieee754_y0f(float x)
if ((s*c)<zero) cc = z/ss;
else ss = z/cc;
}
if(ix>0x80000000) z = (invsqrtpi*ss)/sqrtf(x);
if(ix>0x58000000) z = (invsqrtpi*ss)/sqrtf(x); /* |x|>2**49 */
else {
u = pzerof(x); v = qzerof(x);
z = invsqrtpi*(u*ss+v*cc)/sqrtf(x);
}
return z;
}
if(ix<=0x32000000) { /* x < 2**-27 */
if(ix<=0x39000000) { /* x < 2**-13 */
return(u00 + tpi*__ieee754_logf(x));
}
z = x*x;
@ -227,7 +224,6 @@ static const float pS2[5] = {
1.4657617569e+01, /* 0x416a859a */
};
/* Note: This function is only called for ix>=0x40000000 (see above) */
static float pzerof(float x)
{
const float *p,*q;
@ -235,11 +231,10 @@ static const float pS2[5] = {
int32_t ix;
GET_FLOAT_WORD(ix,x);
ix &= 0x7fffffff;
assert(ix>=0x40000000 && ix<=0x48000000);
if(ix>=0x41000000) {p = pR8; q= pS8;}
else if(ix>=0x40f71c58){p = pR5; q= pS5;}
else if(ix>=0x4036db68){p = pR3; q= pS3;}
else {p = pR2; q= pS2;}
else if(ix>=0x409173eb){p = pR5; q= pS5;}
else if(ix>=0x4036d917){p = pR3; q= pS3;}
else {p = pR2; q= pS2;} /* ix>=0x40000000 */
z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
@ -324,7 +319,6 @@ static const float qS2[6] = {
-5.3109550476e+00, /* 0xc0a9f358 */
};
/* Note: This function is only called for ix>=0x40000000 (see above) */
static float qzerof(float x)
{
const float *p,*q;
@ -332,11 +326,10 @@ static const float qS2[6] = {
int32_t ix;
GET_FLOAT_WORD(ix,x);
ix &= 0x7fffffff;
assert(ix>=0x40000000 && ix<=0x48000000);
if(ix>=0x41000000) {p = qR8; q= qS8;}
else if(ix>=0x40f71c58){p = qR5; q= qS5;}
else if(ix>=0x4036db68){p = qR3; q= qS3;}
else {p = qR2; q= qS2;}
else if(ix>=0x409173eb){p = qR5; q= qS5;}
else if(ix>=0x4036d917){p = qR3; q= qS3;}
else {p = qR2; q= qS2;} /* ix>=0x40000000 */
z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));

View file

@ -14,12 +14,8 @@
*/
#include <assert.h>
#include "cdefs-compat.h"
//__FBSDID("$FreeBSD: src/lib/msun/src/e_j1f.c,v 1.8 2008/02/22 02:30:35 das Exp $");
#include <openlibm_math.h>
#include "math_private.h"
static float ponef(float), qonef(float);
@ -66,7 +62,7 @@ __ieee754_j1f(float x)
* j1(x) = 1/sqrt(pi) * (P(1,x)*cc - Q(1,x)*ss) / sqrt(x)
* y1(x) = 1/sqrt(pi) * (P(1,x)*ss + Q(1,x)*cc) / sqrt(x)
*/
if(ix>0x80000000) z = (invsqrtpi*cc)/sqrtf(y);
if(ix>0x58000000) z = (invsqrtpi*cc)/sqrtf(y); /* |x|>2**49 */
else {
u = ponef(y); v = qonef(y);
z = invsqrtpi*(u*cc-v*ss)/sqrtf(y);
@ -74,7 +70,7 @@ __ieee754_j1f(float x)
if(hx<0) return -z;
else return z;
}
if(ix<0x32000000) { /* |x|<2**-27 */
if(ix<0x39000000) { /* |x|<2**-13 */
if(huge+x>one) return (float)0.5*x;/* inexact if x!=0 necessary */
}
z = x*x;
@ -132,14 +128,14 @@ __ieee754_y1f(float x)
* sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
* to compute the worse one.
*/
if(ix>0x48000000) z = (invsqrtpi*ss)/sqrtf(x);
if(ix>0x58000000) z = (invsqrtpi*ss)/sqrtf(x); /* |x|>2**49 */
else {
u = ponef(x); v = qonef(x);
z = invsqrtpi*(u*ss+v*cc)/sqrtf(x);
}
return z;
}
if(ix<=0x24800000) { /* x < 2**-54 */
if(ix<=0x33000000) { /* x < 2**-25 */
return(-tpi/x);
}
z = x*x;
@ -222,7 +218,6 @@ static const float ps2[5] = {
8.3646392822e+00, /* 0x4105d590 */
};
/* Note: This function is only called for ix>=0x40000000 (see above) */
static float ponef(float x)
{
const float *p,*q;
@ -230,11 +225,10 @@ static const float ps2[5] = {
int32_t ix;
GET_FLOAT_WORD(ix,x);
ix &= 0x7fffffff;
assert(ix>=0x40000000 && ix<=0x48000000);
if(ix>=0x41000000) {p = pr8; q= ps8;}
else if(ix>=0x40f71c58){p = pr5; q= ps5;}
else if(ix>=0x4036db68){p = pr3; q= ps3;}
else {p = pr2; q= ps2;}
else if(ix>=0x409173eb){p = pr5; q= ps5;}
else if(ix>=0x4036d917){p = pr3; q= ps3;}
else {p = pr2; q= ps2;} /* ix>=0x40000000 */
z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
@ -320,7 +314,6 @@ static const float qs2[6] = {
-4.9594988823e+00, /* 0xc09eb437 */
};
/* Note: This function is only called for ix>=0x40000000 (see above) */
static float qonef(float x)
{
const float *p,*q;
@ -328,11 +321,10 @@ static const float qs2[6] = {
int32_t ix;
GET_FLOAT_WORD(ix,x);
ix &= 0x7fffffff;
assert(ix>=0x40000000 && ix<=0x48000000);
if(ix>=0x40200000) {p = qr8; q= qs8;}
else if(ix>=0x40f71c58){p = qr5; q= qs5;}
else if(ix>=0x4036db68){p = qr3; q= qs3;}
else {p = qr2; q= qs2;}
if(ix>=0x41000000) {p = qr8; q= qs8;}
else if(ix>=0x409173eb){p = qr5; q= qs5;}
else if(ix>=0x4036d917){p = qr3; q= qs3;}
else {p = qr2; q= qs2;} /* ix>=0x40000000 */
z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));

View file

@ -2,7 +2,10 @@ OPENLIBM_HOME=$(abspath ..)
include ../Make.inc
# Set rpath of tests to builddir for loading shared library
OPENLIBM_LIB = -L.. -lopenlibm -Wl,-rpath=$(OPENLIBM_HOME)
OPENLIBM_LIB = -L.. -lopenlibm
ifeq ($(OS),Linux)
OPENLIBM_LIB += -Wl,-rpath=$(OPENLIBM_HOME)
endif
all: test-double test-float # test-double-system test-float-system