Merge pull request #74 from NuxiNL/master

Portability fixes
This commit is contained in:
Viral B. Shah 2015-01-08 11:09:22 +05:30
commit 0b2a647742
9 changed files with 31 additions and 32 deletions

View file

@ -38,10 +38,6 @@
#ifndef _MACHINE_IEEEFP_H_
#define _MACHINE_IEEEFP_H_
#if !defined(_SYS_CDEFS_H) && !defined(_SYS_CDEFS_H_) && !defined(_CDEFS_H_)
#error this file needs sys/cdefs.h as a prerequisite
#endif
/*
* FP rounding modes
*/

View file

@ -152,13 +152,13 @@ double x, c;
c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5))));
c = (x*c)/(2.0-c);
return scalb(1.+(hi-(lo - c)), k);
return scalbn(1.+(hi-(lo - c)), k);
}
/* end of x > lntiny */
else
/* exp(-big#) underflows to zero */
if(finite(x)) return(scalb(1.0,-5000));
if(isfinite(x)) return(scalbn(1.0,-5000));
/* exp(-INF) is zero */
else return(0.0);
@ -167,5 +167,5 @@ double x, c;
else
/* exp(INF) is INF, exp(+big#) overflows to INF */
return( finite(x) ? scalb(1.0,5000) : x);
return( isfinite(x) ? scalbn(1.0,5000) : x);
}

View file

@ -140,7 +140,7 @@ tgamma(x)
if (x != 0.0)
u.a = one - tiny; /* raise inexact */
return (one/x);
} else if (!finite(x))
} else if (!isfinite(x))
return (x - x); /* x is NaN or -Inf */
else
return (neg_gam(x));

View file

@ -1,9 +1,11 @@
#ifndef _CDEFS_COMPAT_H_
#define _CDEFS_COMPAT_H_
#ifndef _WIN32
#include "sys/cdefs.h"
#else /* _WIN32 */
/*
* We cannot be certain that this operating system has <sys/cdefs.h>.
* Instead, include a header file that is likely to pull in this header.
*/
#include <stdio.h>
#if defined(__cplusplus)
#define __BEGIN_DECLS extern "C" {
@ -13,13 +15,6 @@
#define __END_DECLS
#endif
#define _SYS_CDEFS_H_
#endif /* _WIN32 */
#ifdef __GNUC__
#ifndef __strong_reference
#ifdef __APPLE__

View file

@ -38,28 +38,37 @@
#endif
#endif
#ifdef __linux
#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__)
/* Definitions provided directly by GCC and Clang. */
#define _LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
#define _BIG_ENDIAN __ORDER_BIG_ENDIAN__
#define _PDP_ENDIAN __ORDER_PDP_ENDIAN__
#define _BYTE_ORDER __BYTE_ORDER__
#elif defined(__linux)
#include <features.h>
#include <endian.h>
#define _LITTLE_ENDIAN __LITTLE_ENDIAN
#define _BIG_ENDIAN __BIG_ENDIAN
#define _PDP_ENDIAN __PDP_ENDIAN
#define _BYTE_ORDER __BYTE_ORDER
#endif
#ifdef __APPLE__
#elif defined(__APPLE__)
#include <machine/endian.h>
#define _LITTLE_ENDIAN LITTLE_ENDIAN
#define _BIG_ENDIAN BIG_ENDIAN
#define _PDP_ENDIAN PDP_ENDIAN
#define _BYTE_ORDER BYTE_ORDER
#endif
#ifdef __FreeBSD__
#elif defined(__FreeBSD__)
#include <machine/endian.h>
#endif
#ifdef _WIN32
#elif defined(_WIN32)
#define _LITTLE_ENDIAN 1234
#define _BIG_ENDIAN 4321
#define _PDP_ENDIAN 3412
@ -69,6 +78,7 @@
#define BIG_ENDIAN _BIG_ENDIAN
#define PDP_ENDIAN _PDP_ENDIAN
#define BYTE_ORDER _BYTE_ORDER
#endif
#ifndef _IEEE_WORD_ORDER

View file

@ -35,7 +35,7 @@ __ieee754_scalb(double x, double fn)
return scalbn(x,fn);
#else
if (isnan(x)||isnan(fn)) return x*fn;
if (!finite(fn)) {
if (!isfinite(fn)) {
if(fn>0.0) return x*fn;
else return x/(-fn);
}

View file

@ -30,8 +30,8 @@ __ieee754_scalbf(float x, float fn)
#ifdef _SCALB_INT
return scalbnf(x,fn);
#else
if ((__isnanf)(x)||(__isnanf)(fn)) return x*fn;
if (!finitef(fn)) {
if (isnan(x)||isnan(fn)) return x*fn;
if (!isfinite(fn)) {
if(fn>(float)0.0) return x*fn;
else return x/(-fn);
}

View file

@ -333,9 +333,7 @@ double __kernel_sin(double,double,int);
double __kernel_cos(double,double);
double __kernel_tan(double,double,int);
double __ldexp_exp(double,int);
#ifdef _COMPLEX_H
double complex __ldexp_cexp(double complex,int);
#endif
/* float precision kernel functions */
#ifdef INLINE_REM_PIO2F
@ -355,9 +353,7 @@ __inline
#endif
float __kernel_tandf(double,int);
float __ldexp_expf(float,int);
#ifdef _COMPLEX_H
float complex __ldexp_cexpf(float complex,int);
#endif
/* long double precision kernel functions */
long double __kernel_sinl(long double, long double, int);

View file

@ -57,7 +57,9 @@ extern const union __nan_un {
//VBS begin
#define __MATH_BUILTIN_CONSTANTS
#define __MATH_BUILTIN_RELOPS
#ifndef __ISO_C_VISIBLE
#define __ISO_C_VISIBLE 1999
#endif
//VBS end
#ifdef __MATH_BUILTIN_CONSTANTS