Merge pull request #67 from eschnett/master

Simplify code, avoid compiler warnings
This commit is contained in:
Viral B. Shah 2014-12-02 09:50:49 +05:30
commit 2c9b14cabd
6 changed files with 38 additions and 14 deletions

View file

@ -11,6 +11,8 @@
* ==================================================== * ====================================================
*/ */
#include <assert.h>
#include "cdefs-compat.h" #include "cdefs-compat.h"
//__FBSDID("$FreeBSD: src/lib/msun/src/e_j0.c,v 1.9 2008/02/22 02:30:35 das Exp $"); //__FBSDID("$FreeBSD: src/lib/msun/src/e_j0.c,v 1.9 2008/02/22 02:30:35 das Exp $");
@ -268,6 +270,7 @@ static const double pS2[5] = {
1.46576176948256193810e+01, /* 0x402D50B3, 0x44391809 */ 1.46576176948256193810e+01, /* 0x402D50B3, 0x44391809 */
}; };
/* Note: This function is only called for ix>=0x40000000 (see above) */
static double pzero(double x) static double pzero(double x)
{ {
const double *p,*q; const double *p,*q;
@ -275,10 +278,11 @@ static const double pS2[5] = {
int32_t ix; int32_t ix;
GET_HIGH_WORD(ix,x); GET_HIGH_WORD(ix,x);
ix &= 0x7fffffff; ix &= 0x7fffffff;
assert(ix>=0x40000000 && ix<=0x48000000);
if(ix>=0x40200000) {p = pR8; q= pS8;} if(ix>=0x40200000) {p = pR8; q= pS8;}
else if(ix>=0x40122E8B){p = pR5; q= pS5;} else if(ix>=0x40122E8B){p = pR5; q= pS5;}
else if(ix>=0x4006DB6D){p = pR3; q= pS3;} else if(ix>=0x4006DB6D){p = pR3; q= pS3;}
else if(ix>=0x40000000){p = pR2; q= pS2;} else {p = pR2; q= pS2;}
z = one/(x*x); z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); 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])))); s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
@ -363,6 +367,7 @@ static const double qS2[6] = {
-5.31095493882666946917e+00, /* 0xC0153E6A, 0xF8B32931 */ -5.31095493882666946917e+00, /* 0xC0153E6A, 0xF8B32931 */
}; };
/* Note: This function is only called for ix>=0x40000000 (see above) */
static double qzero(double x) static double qzero(double x)
{ {
const double *p,*q; const double *p,*q;
@ -370,10 +375,11 @@ static const double qS2[6] = {
int32_t ix; int32_t ix;
GET_HIGH_WORD(ix,x); GET_HIGH_WORD(ix,x);
ix &= 0x7fffffff; ix &= 0x7fffffff;
assert(ix>=0x40000000 && ix<=0x48000000);
if(ix>=0x40200000) {p = qR8; q= qS8;} if(ix>=0x40200000) {p = qR8; q= qS8;}
else if(ix>=0x40122E8B){p = qR5; q= qS5;} else if(ix>=0x40122E8B){p = qR5; q= qS5;}
else if(ix>=0x4006DB6D){p = qR3; q= qS3;} else if(ix>=0x4006DB6D){p = qR3; q= qS3;}
else if(ix>=0x40000000){p = qR2; q= qS2;} else {p = qR2; q= qS2;}
z = one/(x*x); z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); 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]))))); s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));

View file

@ -13,6 +13,8 @@
* ==================================================== * ====================================================
*/ */
#include <assert.h>
#include "cdefs-compat.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 $"); //__FBSDID("$FreeBSD: src/lib/msun/src/e_j0f.c,v 1.8 2008/02/22 02:30:35 das Exp $");
@ -224,6 +226,7 @@ static const float pS2[5] = {
1.4657617569e+01, /* 0x416a859a */ 1.4657617569e+01, /* 0x416a859a */
}; };
/* Note: This function is only called for ix>=0x40000000 (see above) */
static float pzerof(float x) static float pzerof(float x)
{ {
const float *p,*q; const float *p,*q;
@ -231,10 +234,11 @@ static const float pS2[5] = {
int32_t ix; int32_t ix;
GET_FLOAT_WORD(ix,x); GET_FLOAT_WORD(ix,x);
ix &= 0x7fffffff; ix &= 0x7fffffff;
assert(ix>=0x40000000 && ix<=0x48000000);
if(ix>=0x41000000) {p = pR8; q= pS8;} if(ix>=0x41000000) {p = pR8; q= pS8;}
else if(ix>=0x40f71c58){p = pR5; q= pS5;} else if(ix>=0x40f71c58){p = pR5; q= pS5;}
else if(ix>=0x4036db68){p = pR3; q= pS3;} else if(ix>=0x4036db68){p = pR3; q= pS3;}
else if(ix>=0x40000000){p = pR2; q= pS2;} else {p = pR2; q= pS2;}
z = one/(x*x); z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); 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])))); s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
@ -319,6 +323,7 @@ static const float qS2[6] = {
-5.3109550476e+00, /* 0xc0a9f358 */ -5.3109550476e+00, /* 0xc0a9f358 */
}; };
/* Note: This function is only called for ix>=0x40000000 (see above) */
static float qzerof(float x) static float qzerof(float x)
{ {
const float *p,*q; const float *p,*q;
@ -326,10 +331,11 @@ static const float qS2[6] = {
int32_t ix; int32_t ix;
GET_FLOAT_WORD(ix,x); GET_FLOAT_WORD(ix,x);
ix &= 0x7fffffff; ix &= 0x7fffffff;
assert(ix>=0x40000000 && ix<=0x48000000);
if(ix>=0x41000000) {p = qR8; q= qS8;} if(ix>=0x41000000) {p = qR8; q= qS8;}
else if(ix>=0x40f71c58){p = qR5; q= qS5;} else if(ix>=0x40f71c58){p = qR5; q= qS5;}
else if(ix>=0x4036db68){p = qR3; q= qS3;} else if(ix>=0x4036db68){p = qR3; q= qS3;}
else if(ix>=0x40000000){p = qR2; q= qS2;} else {p = qR2; q= qS2;}
z = one/(x*x); z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); 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]))))); s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));

View file

@ -11,6 +11,8 @@
* ==================================================== * ====================================================
*/ */
#include <assert.h>
#include "cdefs-compat.h" #include "cdefs-compat.h"
//__FBSDID("$FreeBSD: src/lib/msun/src/e_j1.c,v 1.9 2008/02/22 02:30:35 das Exp $"); //__FBSDID("$FreeBSD: src/lib/msun/src/e_j1.c,v 1.9 2008/02/22 02:30:35 das Exp $");
@ -262,6 +264,7 @@ static const double ps2[5] = {
8.36463893371618283368e+00, /* 0x4020BAB1, 0xF44E5192 */ 8.36463893371618283368e+00, /* 0x4020BAB1, 0xF44E5192 */
}; };
/* Note: This function is only called for ix>=0x40000000 (see above) */
static double pone(double x) static double pone(double x)
{ {
const double *p,*q; const double *p,*q;
@ -269,10 +272,11 @@ static const double ps2[5] = {
int32_t ix; int32_t ix;
GET_HIGH_WORD(ix,x); GET_HIGH_WORD(ix,x);
ix &= 0x7fffffff; ix &= 0x7fffffff;
assert(ix>=0x40000000 && ix<=0x48000000);
if(ix>=0x40200000) {p = pr8; q= ps8;} if(ix>=0x40200000) {p = pr8; q= ps8;}
else if(ix>=0x40122E8B){p = pr5; q= ps5;} else if(ix>=0x40122E8B){p = pr5; q= ps5;}
else if(ix>=0x4006DB6D){p = pr3; q= ps3;} else if(ix>=0x4006DB6D){p = pr3; q= ps3;}
else if(ix>=0x40000000){p = pr2; q= ps2;} else {p = pr2; q= ps2;}
z = one/(x*x); z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); 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])))); s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
@ -358,6 +362,7 @@ static const double qs2[6] = {
-4.95949898822628210127e+00, /* 0xC013D686, 0xE71BE86B */ -4.95949898822628210127e+00, /* 0xC013D686, 0xE71BE86B */
}; };
/* Note: This function is only called for ix>=0x40000000 (see above) */
static double qone(double x) static double qone(double x)
{ {
const double *p,*q; const double *p,*q;
@ -365,10 +370,11 @@ static const double qs2[6] = {
int32_t ix; int32_t ix;
GET_HIGH_WORD(ix,x); GET_HIGH_WORD(ix,x);
ix &= 0x7fffffff; ix &= 0x7fffffff;
assert(ix>=0x40000000 && ix<=0x48000000);
if(ix>=0x40200000) {p = qr8; q= qs8;} if(ix>=0x40200000) {p = qr8; q= qs8;}
else if(ix>=0x40122E8B){p = qr5; q= qs5;} else if(ix>=0x40122E8B){p = qr5; q= qs5;}
else if(ix>=0x4006DB6D){p = qr3; q= qs3;} else if(ix>=0x4006DB6D){p = qr3; q= qs3;}
else if(ix>=0x40000000){p = qr2; q= qs2;} else {p = qr2; q= qs2;}
z = one/(x*x); z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); 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]))))); s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));

View file

@ -13,6 +13,8 @@
* ==================================================== * ====================================================
*/ */
#include <assert.h>
#include "cdefs-compat.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 $"); //__FBSDID("$FreeBSD: src/lib/msun/src/e_j1f.c,v 1.8 2008/02/22 02:30:35 das Exp $");
@ -219,6 +221,7 @@ static const float ps2[5] = {
8.3646392822e+00, /* 0x4105d590 */ 8.3646392822e+00, /* 0x4105d590 */
}; };
/* Note: This function is only called for ix>=0x40000000 (see above) */
static float ponef(float x) static float ponef(float x)
{ {
const float *p,*q; const float *p,*q;
@ -226,10 +229,11 @@ static const float ps2[5] = {
int32_t ix; int32_t ix;
GET_FLOAT_WORD(ix,x); GET_FLOAT_WORD(ix,x);
ix &= 0x7fffffff; ix &= 0x7fffffff;
assert(ix>=0x40000000 && ix<=0x48000000);
if(ix>=0x41000000) {p = pr8; q= ps8;} if(ix>=0x41000000) {p = pr8; q= ps8;}
else if(ix>=0x40f71c58){p = pr5; q= ps5;} else if(ix>=0x40f71c58){p = pr5; q= ps5;}
else if(ix>=0x4036db68){p = pr3; q= ps3;} else if(ix>=0x4036db68){p = pr3; q= ps3;}
else if(ix>=0x40000000){p = pr2; q= ps2;} else {p = pr2; q= ps2;}
z = one/(x*x); z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); 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])))); s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
@ -315,6 +319,7 @@ static const float qs2[6] = {
-4.9594988823e+00, /* 0xc09eb437 */ -4.9594988823e+00, /* 0xc09eb437 */
}; };
/* Note: This function is only called for ix>=0x40000000 (see above) */
static float qonef(float x) static float qonef(float x)
{ {
const float *p,*q; const float *p,*q;
@ -322,10 +327,11 @@ static const float qs2[6] = {
int32_t ix; int32_t ix;
GET_FLOAT_WORD(ix,x); GET_FLOAT_WORD(ix,x);
ix &= 0x7fffffff; ix &= 0x7fffffff;
assert(ix>=0x40000000 && ix<=0x48000000);
if(ix>=0x40200000) {p = qr8; q= qs8;} if(ix>=0x40200000) {p = qr8; q= qs8;}
else if(ix>=0x40f71c58){p = qr5; q= qs5;} else if(ix>=0x40f71c58){p = qr5; q= qs5;}
else if(ix>=0x4036db68){p = qr3; q= qs3;} else if(ix>=0x4036db68){p = qr3; q= qs3;}
else if(ix>=0x40000000){p = qr2; q= qs2;} else {p = qr2; q= qs2;}
z = one/(x*x); z = one/(x*x);
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5])))); 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]))))); s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));

View file

@ -4,13 +4,13 @@ include ../Make.inc
all: test-double test-float # test-double-system test-float-system all: test-double test-float # test-double-system test-float-system
test-double: test-double.c libm-test.c test-double: test-double.c libm-test.c
$(CC) -g $@.c -D__BSD_VISIBLE -I ../include -I../src ../libopenlibm.a -o $@ $(CC) $(CFLAGS) -g $@.c -D__BSD_VISIBLE -I ../include -I../src ../libopenlibm.a -o $@
test-float: test-float.c libm-test.c test-float: test-float.c libm-test.c
$(CC) -g $@.c -D__BSD_VISIBLE -I ../include -I../src ../libopenlibm.a -o $@ $(CC) $(CFLAGS) -g $@.c -D__BSD_VISIBLE -I ../include -I../src ../libopenlibm.a -o $@
test-double-system: test-double.c libm-test.c test-double-system: test-double.c libm-test.c
$(CC) -g $< -DSYS_MATH_H -lm -o $@ $(CC) $(CFLAGS) -g $< -DSYS_MATH_H -lm -o $@
test-float-system: test-float.c libm-test.c test-float-system: test-float.c libm-test.c
$(CC) -g $< -DSYS_MATH_H -lm -o $@ $(CC) $(CFLAGS) -g $< -DSYS_MATH_H -lm -o $@