Skip to content

Commit e919db5

Browse files
committed
Merge branch 'master' of github.com:JuliaLang/openlibm
2 parents 5f1aa85 + 532fe48 commit e919db5

7 files changed

Lines changed: 39 additions & 15 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## OpenLibm
22

3-
OpenLibm is an effort to have a high quality, portable, standalone
3+
[OpenLibm](http://www.openlibm.org) is an effort to have a high quality, portable, standalone
44
C mathematical library ([`libm`](http://en.wikipedia.org/wiki/libm)).
55
It can be used standalone in applications and programming language
66
implementations.

src/Make.files

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ $(CUR_SRCS) = common.c \
3535

3636
ifneq ($(OS), WINNT)
3737
$(CUR_SRCS) += s_nan.c
38-
endif
39-
38+
endif
39+
4040
ifneq ($(ARCH), arm)
4141
# C99 long double functions
4242
$(CUR_SRCS) += s_copysignl.c s_fabsl.c s_llrintl.c s_lrintl.c s_modfl.c

src/e_j0.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* ====================================================
1212
*/
1313

14+
#include <assert.h>
15+
1416
#include "cdefs-compat.h"
1517
//__FBSDID("$FreeBSD: src/lib/msun/src/e_j0.c,v 1.9 2008/02/22 02:30:35 das Exp $");
1618

@@ -268,17 +270,19 @@ static const double pS2[5] = {
268270
1.46576176948256193810e+01, /* 0x402D50B3, 0x44391809 */
269271
};
270272

273+
/* Note: This function is only called for ix>=0x40000000 (see above) */
271274
static double pzero(double x)
272275
{
273276
const double *p,*q;
274277
double z,r,s;
275278
int32_t ix;
276279
GET_HIGH_WORD(ix,x);
277280
ix &= 0x7fffffff;
281+
assert(ix>=0x40000000 && ix<=0x48000000);
278282
if(ix>=0x40200000) {p = pR8; q= pS8;}
279283
else if(ix>=0x40122E8B){p = pR5; q= pS5;}
280284
else if(ix>=0x4006DB6D){p = pR3; q= pS3;}
281-
else if(ix>=0x40000000){p = pR2; q= pS2;}
285+
else {p = pR2; q= pS2;}
282286
z = one/(x*x);
283287
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
284288
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
@@ -363,17 +367,19 @@ static const double qS2[6] = {
363367
-5.31095493882666946917e+00, /* 0xC0153E6A, 0xF8B32931 */
364368
};
365369

370+
/* Note: This function is only called for ix>=0x40000000 (see above) */
366371
static double qzero(double x)
367372
{
368373
const double *p,*q;
369374
double s,r,z;
370375
int32_t ix;
371376
GET_HIGH_WORD(ix,x);
372377
ix &= 0x7fffffff;
378+
assert(ix>=0x40000000 && ix<=0x48000000);
373379
if(ix>=0x40200000) {p = qR8; q= qS8;}
374380
else if(ix>=0x40122E8B){p = qR5; q= qS5;}
375381
else if(ix>=0x4006DB6D){p = qR3; q= qS3;}
376-
else if(ix>=0x40000000){p = qR2; q= qS2;}
382+
else {p = qR2; q= qS2;}
377383
z = one/(x*x);
378384
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
379385
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));

src/e_j0f.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* ====================================================
1414
*/
1515

16+
#include <assert.h>
17+
1618
#include "cdefs-compat.h"
1719
//__FBSDID("$FreeBSD: src/lib/msun/src/e_j0f.c,v 1.8 2008/02/22 02:30:35 das Exp $");
1820

@@ -224,17 +226,19 @@ static const float pS2[5] = {
224226
1.4657617569e+01, /* 0x416a859a */
225227
};
226228

229+
/* Note: This function is only called for ix>=0x40000000 (see above) */
227230
static float pzerof(float x)
228231
{
229232
const float *p,*q;
230233
float z,r,s;
231234
int32_t ix;
232235
GET_FLOAT_WORD(ix,x);
233236
ix &= 0x7fffffff;
237+
assert(ix>=0x40000000 && ix<=0x48000000);
234238
if(ix>=0x41000000) {p = pR8; q= pS8;}
235239
else if(ix>=0x40f71c58){p = pR5; q= pS5;}
236240
else if(ix>=0x4036db68){p = pR3; q= pS3;}
237-
else if(ix>=0x40000000){p = pR2; q= pS2;}
241+
else {p = pR2; q= pS2;}
238242
z = one/(x*x);
239243
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
240244
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
@@ -319,17 +323,19 @@ static const float qS2[6] = {
319323
-5.3109550476e+00, /* 0xc0a9f358 */
320324
};
321325

326+
/* Note: This function is only called for ix>=0x40000000 (see above) */
322327
static float qzerof(float x)
323328
{
324329
const float *p,*q;
325330
float s,r,z;
326331
int32_t ix;
327332
GET_FLOAT_WORD(ix,x);
328333
ix &= 0x7fffffff;
334+
assert(ix>=0x40000000 && ix<=0x48000000);
329335
if(ix>=0x41000000) {p = qR8; q= qS8;}
330336
else if(ix>=0x40f71c58){p = qR5; q= qS5;}
331337
else if(ix>=0x4036db68){p = qR3; q= qS3;}
332-
else if(ix>=0x40000000){p = qR2; q= qS2;}
338+
else {p = qR2; q= qS2;}
333339
z = one/(x*x);
334340
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
335341
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));

src/e_j1.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* ====================================================
1212
*/
1313

14+
#include <assert.h>
15+
1416
#include "cdefs-compat.h"
1517
//__FBSDID("$FreeBSD: src/lib/msun/src/e_j1.c,v 1.9 2008/02/22 02:30:35 das Exp $");
1618

@@ -262,17 +264,19 @@ static const double ps2[5] = {
262264
8.36463893371618283368e+00, /* 0x4020BAB1, 0xF44E5192 */
263265
};
264266

267+
/* Note: This function is only called for ix>=0x40000000 (see above) */
265268
static double pone(double x)
266269
{
267270
const double *p,*q;
268271
double z,r,s;
269272
int32_t ix;
270273
GET_HIGH_WORD(ix,x);
271274
ix &= 0x7fffffff;
275+
assert(ix>=0x40000000 && ix<=0x48000000);
272276
if(ix>=0x40200000) {p = pr8; q= ps8;}
273277
else if(ix>=0x40122E8B){p = pr5; q= ps5;}
274278
else if(ix>=0x4006DB6D){p = pr3; q= ps3;}
275-
else if(ix>=0x40000000){p = pr2; q= ps2;}
279+
else {p = pr2; q= ps2;}
276280
z = one/(x*x);
277281
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
278282
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
@@ -358,17 +362,19 @@ static const double qs2[6] = {
358362
-4.95949898822628210127e+00, /* 0xC013D686, 0xE71BE86B */
359363
};
360364

365+
/* Note: This function is only called for ix>=0x40000000 (see above) */
361366
static double qone(double x)
362367
{
363368
const double *p,*q;
364369
double s,r,z;
365370
int32_t ix;
366371
GET_HIGH_WORD(ix,x);
367372
ix &= 0x7fffffff;
373+
assert(ix>=0x40000000 && ix<=0x48000000);
368374
if(ix>=0x40200000) {p = qr8; q= qs8;}
369375
else if(ix>=0x40122E8B){p = qr5; q= qs5;}
370376
else if(ix>=0x4006DB6D){p = qr3; q= qs3;}
371-
else if(ix>=0x40000000){p = qr2; q= qs2;}
377+
else {p = qr2; q= qs2;}
372378
z = one/(x*x);
373379
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
374380
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));

src/e_j1f.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
* ====================================================
1414
*/
1515

16+
#include <assert.h>
17+
1618
#include "cdefs-compat.h"
1719
//__FBSDID("$FreeBSD: src/lib/msun/src/e_j1f.c,v 1.8 2008/02/22 02:30:35 das Exp $");
1820

@@ -219,17 +221,19 @@ static const float ps2[5] = {
219221
8.3646392822e+00, /* 0x4105d590 */
220222
};
221223

224+
/* Note: This function is only called for ix>=0x40000000 (see above) */
222225
static float ponef(float x)
223226
{
224227
const float *p,*q;
225228
float z,r,s;
226229
int32_t ix;
227230
GET_FLOAT_WORD(ix,x);
228231
ix &= 0x7fffffff;
232+
assert(ix>=0x40000000 && ix<=0x48000000);
229233
if(ix>=0x41000000) {p = pr8; q= ps8;}
230234
else if(ix>=0x40f71c58){p = pr5; q= ps5;}
231235
else if(ix>=0x4036db68){p = pr3; q= ps3;}
232-
else if(ix>=0x40000000){p = pr2; q= ps2;}
236+
else {p = pr2; q= ps2;}
233237
z = one/(x*x);
234238
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
235239
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
@@ -315,17 +319,19 @@ static const float qs2[6] = {
315319
-4.9594988823e+00, /* 0xc09eb437 */
316320
};
317321

322+
/* Note: This function is only called for ix>=0x40000000 (see above) */
318323
static float qonef(float x)
319324
{
320325
const float *p,*q;
321326
float s,r,z;
322327
int32_t ix;
323328
GET_FLOAT_WORD(ix,x);
324329
ix &= 0x7fffffff;
330+
assert(ix>=0x40000000 && ix<=0x48000000);
325331
if(ix>=0x40200000) {p = qr8; q= qs8;}
326332
else if(ix>=0x40f71c58){p = qr5; q= qs5;}
327333
else if(ix>=0x4036db68){p = qr3; q= qs3;}
328-
else if(ix>=0x40000000){p = qr2; q= qs2;}
334+
else {p = qr2; q= qs2;}
329335
z = one/(x*x);
330336
r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
331337
s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));

test/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ include ../Make.inc
44
all: test-double test-float # test-double-system test-float-system
55

66
test-double: test-double.c libm-test.c
7-
$(CC) -g $@.c -D__BSD_VISIBLE -I ../include -I../src ../libopenlibm.a -o $@
7+
$(CC) $(CFLAGS) -g $@.c -D__BSD_VISIBLE -I ../include -I../src ../libopenlibm.a -o $@
88

99
test-float: test-float.c libm-test.c
10-
$(CC) -g $@.c -D__BSD_VISIBLE -I ../include -I../src ../libopenlibm.a -o $@
10+
$(CC) $(CFLAGS) -g $@.c -D__BSD_VISIBLE -I ../include -I../src ../libopenlibm.a -o $@
1111

1212
test-double-system: test-double.c libm-test.c
13-
$(CC) -g $< -DSYS_MATH_H -lm -o $@
13+
$(CC) $(CFLAGS) -g $< -DSYS_MATH_H -lm -o $@
1414

1515
test-float-system: test-float.c libm-test.c
16-
$(CC) -g $< -DSYS_MATH_H -lm -o $@
16+
$(CC) $(CFLAGS) -g $< -DSYS_MATH_H -lm -o $@

0 commit comments

Comments
 (0)