Skip to content

Commit 0b2a647

Browse files
committed
Merge pull request #74 from NuxiNL/master
Portability fixes
2 parents b44ec54 + 78f622e commit 0b2a647

9 files changed

Lines changed: 31 additions & 32 deletions

File tree

amd64/bsd_ieeefp.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@
3838
#ifndef _MACHINE_IEEEFP_H_
3939
#define _MACHINE_IEEEFP_H_
4040

41-
#if !defined(_SYS_CDEFS_H) && !defined(_SYS_CDEFS_H_) && !defined(_CDEFS_H_)
42-
#error this file needs sys/cdefs.h as a prerequisite
43-
#endif
44-
4541
/*
4642
* FP rounding modes
4743
*/

bsdsrc/b_exp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ double x, c;
152152
c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5))));
153153
c = (x*c)/(2.0-c);
154154

155-
return scalb(1.+(hi-(lo - c)), k);
155+
return scalbn(1.+(hi-(lo - c)), k);
156156
}
157157
/* end of x > lntiny */
158158

159159
else
160160
/* exp(-big#) underflows to zero */
161-
if(finite(x)) return(scalb(1.0,-5000));
161+
if(isfinite(x)) return(scalbn(1.0,-5000));
162162

163163
/* exp(-INF) is zero */
164164
else return(0.0);
@@ -167,5 +167,5 @@ double x, c;
167167

168168
else
169169
/* exp(INF) is INF, exp(+big#) overflows to INF */
170-
return( finite(x) ? scalb(1.0,5000) : x);
170+
return( isfinite(x) ? scalbn(1.0,5000) : x);
171171
}

bsdsrc/b_tgamma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ tgamma(x)
140140
if (x != 0.0)
141141
u.a = one - tiny; /* raise inexact */
142142
return (one/x);
143-
} else if (!finite(x))
143+
} else if (!isfinite(x))
144144
return (x - x); /* x is NaN or -Inf */
145145
else
146146
return (neg_gam(x));

include/cdefs-compat.h

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#ifndef _CDEFS_COMPAT_H_
22
#define _CDEFS_COMPAT_H_
33

4-
#ifndef _WIN32
5-
#include "sys/cdefs.h"
6-
#else /* _WIN32 */
4+
/*
5+
* We cannot be certain that this operating system has <sys/cdefs.h>.
6+
* Instead, include a header file that is likely to pull in this header.
7+
*/
8+
#include <stdio.h>
79

810
#if defined(__cplusplus)
911
#define __BEGIN_DECLS extern "C" {
@@ -13,13 +15,6 @@
1315
#define __END_DECLS
1416
#endif
1517

16-
#define _SYS_CDEFS_H_
17-
18-
#endif /* _WIN32 */
19-
20-
21-
22-
2318
#ifdef __GNUC__
2419
#ifndef __strong_reference
2520
#ifdef __APPLE__

include/fpmath.h

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,37 @@
3838
#endif
3939
#endif
4040

41-
#ifdef __linux
41+
#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__)
42+
43+
/* Definitions provided directly by GCC and Clang. */
44+
#define _LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
45+
#define _BIG_ENDIAN __ORDER_BIG_ENDIAN__
46+
#define _PDP_ENDIAN __ORDER_PDP_ENDIAN__
47+
#define _BYTE_ORDER __BYTE_ORDER__
48+
49+
#elif defined(__linux)
50+
4251
#include <features.h>
4352
#include <endian.h>
4453
#define _LITTLE_ENDIAN __LITTLE_ENDIAN
4554
#define _BIG_ENDIAN __BIG_ENDIAN
4655
#define _PDP_ENDIAN __PDP_ENDIAN
4756
#define _BYTE_ORDER __BYTE_ORDER
48-
#endif
4957

50-
#ifdef __APPLE__
58+
#elif defined(__APPLE__)
59+
5160
#include <machine/endian.h>
5261
#define _LITTLE_ENDIAN LITTLE_ENDIAN
5362
#define _BIG_ENDIAN BIG_ENDIAN
5463
#define _PDP_ENDIAN PDP_ENDIAN
5564
#define _BYTE_ORDER BYTE_ORDER
56-
#endif
5765

58-
#ifdef __FreeBSD__
66+
#elif defined(__FreeBSD__)
67+
5968
#include <machine/endian.h>
60-
#endif
6169

62-
#ifdef _WIN32
70+
#elif defined(_WIN32)
71+
6372
#define _LITTLE_ENDIAN 1234
6473
#define _BIG_ENDIAN 4321
6574
#define _PDP_ENDIAN 3412
@@ -69,6 +78,7 @@
6978
#define BIG_ENDIAN _BIG_ENDIAN
7079
#define PDP_ENDIAN _PDP_ENDIAN
7180
#define BYTE_ORDER _BYTE_ORDER
81+
7282
#endif
7383

7484
#ifndef _IEEE_WORD_ORDER

src/e_scalb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ __ieee754_scalb(double x, double fn)
3535
return scalbn(x,fn);
3636
#else
3737
if (isnan(x)||isnan(fn)) return x*fn;
38-
if (!finite(fn)) {
38+
if (!isfinite(fn)) {
3939
if(fn>0.0) return x*fn;
4040
else return x/(-fn);
4141
}

src/e_scalbf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ __ieee754_scalbf(float x, float fn)
3030
#ifdef _SCALB_INT
3131
return scalbnf(x,fn);
3232
#else
33-
if ((__isnanf)(x)||(__isnanf)(fn)) return x*fn;
34-
if (!finitef(fn)) {
33+
if (isnan(x)||isnan(fn)) return x*fn;
34+
if (!isfinite(fn)) {
3535
if(fn>(float)0.0) return x*fn;
3636
else return x/(-fn);
3737
}

src/math_private.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,7 @@ double __kernel_sin(double,double,int);
333333
double __kernel_cos(double,double);
334334
double __kernel_tan(double,double,int);
335335
double __ldexp_exp(double,int);
336-
#ifdef _COMPLEX_H
337336
double complex __ldexp_cexp(double complex,int);
338-
#endif
339337

340338
/* float precision kernel functions */
341339
#ifdef INLINE_REM_PIO2F
@@ -355,9 +353,7 @@ __inline
355353
#endif
356354
float __kernel_tandf(double,int);
357355
float __ldexp_expf(float,int);
358-
#ifdef _COMPLEX_H
359356
float complex __ldexp_cexpf(float complex,int);
360-
#endif
361357

362358
/* long double precision kernel functions */
363359
long double __kernel_sinl(long double, long double, int);

src/openlibm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ extern const union __nan_un {
5757
//VBS begin
5858
#define __MATH_BUILTIN_CONSTANTS
5959
#define __MATH_BUILTIN_RELOPS
60+
#ifndef __ISO_C_VISIBLE
6061
#define __ISO_C_VISIBLE 1999
62+
#endif
6163
//VBS end
6264

6365
#ifdef __MATH_BUILTIN_CONSTANTS

0 commit comments

Comments
 (0)