forked from KolibriOS/kolibrios
newlib-2.4.0
git-svn-id: svn://kolibrios.org@6536 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#define _MATH_H_
|
||||
|
||||
#include <sys/reent.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <machine/ieeefp.h>
|
||||
#include "_ansi.h"
|
||||
|
||||
@@ -136,9 +137,7 @@ extern double fmod _PARAMS((double, double));
|
||||
#endif /* ! defined (__math_68881) */
|
||||
#endif /* ! defined (_REENT_ONLY) */
|
||||
|
||||
#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || \
|
||||
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
|
||||
|
||||
#if __ISO_C_VISIBLE >= 1999
|
||||
/* ISO C99 types and macros. */
|
||||
|
||||
/* FIXME: FLT_EVAL_METHOD should somehow be gotten from float.h (which is hard,
|
||||
@@ -205,35 +204,70 @@ extern int __fpclassifyd (double x);
|
||||
extern int __signbitf (float x);
|
||||
extern int __signbitd (double x);
|
||||
|
||||
#define fpclassify(__x) \
|
||||
((sizeof(__x) == sizeof(float)) ? __fpclassifyf(__x) : \
|
||||
__fpclassifyd(__x))
|
||||
|
||||
#ifndef isfinite
|
||||
#define isfinite(__y) \
|
||||
(__extension__ ({int __cy = fpclassify(__y); \
|
||||
__cy != FP_INFINITE && __cy != FP_NAN;}))
|
||||
#endif
|
||||
|
||||
/* Note: isinf and isnan were once functions in newlib that took double
|
||||
* arguments. C99 specifies that these names are reserved for macros
|
||||
* supporting multiple floating point types. Thus, they are
|
||||
* now defined as macros. Implementations of the old functions
|
||||
* taking double arguments still exist for compatibility purposes
|
||||
* (prototypes for them are in <ieeefp.h>). */
|
||||
#ifndef isinf
|
||||
#define isinf(y) (fpclassify(y) == FP_INFINITE)
|
||||
|
||||
#if __GNUC_PREREQ (4, 4)
|
||||
#define fpclassify(__x) (__builtin_fpclassify (FP_NAN, FP_INFINITE, \
|
||||
FP_NORMAL, FP_SUBNORMAL, \
|
||||
FP_ZERO, __x))
|
||||
#ifndef isfinite
|
||||
#define isfinite(__x) (__builtin_isfinite (__x))
|
||||
#endif
|
||||
#ifndef isinf
|
||||
#define isinf(__x) (__builtin_isinf_sign (__x))
|
||||
#endif
|
||||
#ifndef isnan
|
||||
#define isnan(__x) (__builtin_isnan (__x))
|
||||
#endif
|
||||
#define isnormal(__x) (__builtin_isnormal (__x))
|
||||
#else
|
||||
#define fpclassify(__x) \
|
||||
((sizeof(__x) == sizeof(float)) ? __fpclassifyf(__x) : \
|
||||
__fpclassifyd(__x))
|
||||
#ifndef isfinite
|
||||
#define isfinite(__y) \
|
||||
(__extension__ ({int __cy = fpclassify(__y); \
|
||||
__cy != FP_INFINITE && __cy != FP_NAN;}))
|
||||
#endif
|
||||
#ifndef isinf
|
||||
#define isinf(__x) (fpclassify(__x) == FP_INFINITE)
|
||||
#endif
|
||||
#ifndef isnan
|
||||
#define isnan(__x) (fpclassify(__x) == FP_NAN)
|
||||
#endif
|
||||
#define isnormal(__x) (fpclassify(__x) == FP_NORMAL)
|
||||
#endif
|
||||
|
||||
#ifndef isnan
|
||||
#define isnan(y) (fpclassify(y) == FP_NAN)
|
||||
#endif
|
||||
|
||||
#define isnormal(y) (fpclassify(y) == FP_NORMAL)
|
||||
#define signbit(__x) \
|
||||
#if __GNUC_PREREQ (4, 0)
|
||||
#if defined(_HAVE_LONG_DOUBLE)
|
||||
#define signbit(__x) \
|
||||
((sizeof(__x) == sizeof(float)) ? __builtin_signbitf(__x) : \
|
||||
(sizeof(__x) == sizeof(double)) ? __builtin_signbit (__x) : \
|
||||
__builtin_signbitl(__x))
|
||||
#else
|
||||
#define signbit(__x) \
|
||||
((sizeof(__x) == sizeof(float)) ? __builtin_signbitf(__x) : \
|
||||
__builtin_signbit (__x))
|
||||
#endif
|
||||
#else
|
||||
#define signbit(__x) \
|
||||
((sizeof(__x) == sizeof(float)) ? __signbitf(__x) : \
|
||||
__signbitd(__x))
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ (2, 97)
|
||||
#define isgreater(__x,__y) (__builtin_isgreater (__x, __y))
|
||||
#define isgreaterequal(__x,__y) (__builtin_isgreaterequal (__x, __y))
|
||||
#define isless(__x,__y) (__builtin_isless (__x, __y))
|
||||
#define islessequal(__x,__y) (__builtin_islessequal (__x, __y))
|
||||
#define islessgreater(__x,__y) (__builtin_islessgreater (__x, __y))
|
||||
#define isunordered(__x,__y) (__builtin_isunordered (__x, __y))
|
||||
#else
|
||||
#define isgreater(x,y) \
|
||||
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
|
||||
!isunordered(__x,__y) && (__x > __y);}))
|
||||
@@ -253,6 +287,7 @@ extern int __signbitd (double x);
|
||||
#define isunordered(a,b) \
|
||||
(__extension__ ({__typeof__(a) __a = (a); __typeof__(b) __b = (b); \
|
||||
fpclassify(__a) == FP_NAN || fpclassify(__b) == FP_NAN;}))
|
||||
#endif
|
||||
|
||||
/* Non ANSI long double precision functions. */
|
||||
|
||||
@@ -386,8 +421,12 @@ extern float log2f _PARAMS((float));
|
||||
extern float hypotf _PARAMS((float, float));
|
||||
#endif /* ! defined (_REENT_ONLY) */
|
||||
|
||||
/* On platforms where long double equals double. */
|
||||
#ifdef _LDBL_EQ_DBL
|
||||
/* Newlib doesn't fully support long double math functions so far.
|
||||
On platforms where long double equals double the long double functions
|
||||
simply call the double functions. On Cygwin the long double functions
|
||||
are implemented independently from newlib to be able to use optimized
|
||||
assembler functions despite using the Microsoft x86_64 ABI. */
|
||||
#if defined (_LDBL_EQ_DBL) || defined (__CYGWIN__)
|
||||
/* Reentrant ANSI C functions. */
|
||||
#ifndef __math_68881
|
||||
extern long double atanl _PARAMS((long double));
|
||||
@@ -457,7 +496,7 @@ extern long double lgammal _PARAMS((long double));
|
||||
extern long double erfl _PARAMS((long double));
|
||||
extern long double erfcl _PARAMS((long double));
|
||||
#endif /* ! defined (_REENT_ONLY) */
|
||||
#else /* !_LDBL_EQ_DBL */
|
||||
#else /* !_LDBL_EQ_DBL && !__CYGWIN__ */
|
||||
extern long double hypotl _PARAMS((long double, long double));
|
||||
extern long double sqrtl _PARAMS((long double));
|
||||
#ifdef __i386__
|
||||
@@ -466,37 +505,47 @@ extern _LONG_DOUBLE rintl _PARAMS((_LONG_DOUBLE));
|
||||
extern long int lrintl _PARAMS((_LONG_DOUBLE));
|
||||
extern long long int llrintl _PARAMS((_LONG_DOUBLE));
|
||||
#endif /* __i386__ */
|
||||
#endif /* !_LDBL_EQ_DBL */
|
||||
#endif /* !_LDBL_EQ_DBL && !__CYGWIN__ */
|
||||
|
||||
#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) */
|
||||
|
||||
#if !defined (__STRICT_ANSI__) || defined(__cplusplus)
|
||||
#endif /* __ISO_C_VISIBLE >= 1999 */
|
||||
|
||||
#if __MISC_VISIBLE
|
||||
extern double drem _PARAMS((double, double));
|
||||
extern void sincos _PARAMS((double, double *, double *));
|
||||
extern float dremf _PARAMS((float, float));
|
||||
#ifdef __CYGWIN__
|
||||
extern float dreml _PARAMS((long double, long double));
|
||||
#endif /* __CYGWIN__ */
|
||||
extern double gamma_r _PARAMS((double, int *));
|
||||
extern double lgamma_r _PARAMS((double, int *));
|
||||
extern float gammaf_r _PARAMS((float, int *));
|
||||
extern float lgammaf_r _PARAMS((float, int *));
|
||||
#endif
|
||||
|
||||
#if __MISC_VISIBLE || __XSI_VISIBLE
|
||||
extern double y0 _PARAMS((double));
|
||||
extern double y1 _PARAMS((double));
|
||||
extern double yn _PARAMS((int, double));
|
||||
extern double j0 _PARAMS((double));
|
||||
extern double j1 _PARAMS((double));
|
||||
extern double jn _PARAMS((int, double));
|
||||
#endif
|
||||
|
||||
extern float dremf _PARAMS((float, float));
|
||||
extern void sincosf _PARAMS((float, float *, float *));
|
||||
extern float gammaf_r _PARAMS((float, int *));
|
||||
extern float lgammaf_r _PARAMS((float, int *));
|
||||
|
||||
#if __MISC_VISIBLE || __XSI_VISIBLE >= 600
|
||||
extern float y0f _PARAMS((float));
|
||||
extern float y1f _PARAMS((float));
|
||||
extern float ynf _PARAMS((int, float));
|
||||
extern float j0f _PARAMS((float));
|
||||
extern float j1f _PARAMS((float));
|
||||
extern float jnf _PARAMS((int, float));
|
||||
#endif
|
||||
|
||||
/* GNU extensions */
|
||||
#if __GNU_VISIBLE
|
||||
extern void sincos _PARAMS((double, double *, double *));
|
||||
extern void sincosf _PARAMS((float, float *, float *));
|
||||
#ifdef __CYGWIN__
|
||||
extern void sincosl _PARAMS((long double, long double *, long double *));
|
||||
#endif /* __CYGWIN__ */
|
||||
# ifndef exp10
|
||||
extern double exp10 _PARAMS((double));
|
||||
# endif
|
||||
@@ -509,11 +558,17 @@ extern float exp10f _PARAMS((float));
|
||||
# ifndef pow10f
|
||||
extern float pow10f _PARAMS((float));
|
||||
# endif
|
||||
#ifdef __CYGWIN__
|
||||
# ifndef exp10l
|
||||
extern float exp10l _PARAMS((float));
|
||||
# endif
|
||||
# ifndef pow10l
|
||||
extern float pow10l _PARAMS((float));
|
||||
# endif
|
||||
#endif /* __CYGWIN__ */
|
||||
#endif /* __GNU_VISIBLE */
|
||||
|
||||
#endif /* !defined (__STRICT_ANSI__) || defined(__cplusplus) */
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
|
||||
#if __MISC_VISIBLE || __XSI_VISIBLE
|
||||
/* The gamma functions use a global variable, signgam. */
|
||||
#ifndef _REENT_ONLY
|
||||
#define signgam (*__signgam())
|
||||
@@ -521,7 +576,9 @@ extern int *__signgam _PARAMS((void));
|
||||
#endif /* ! defined (_REENT_ONLY) */
|
||||
|
||||
#define __signgam_r(ptr) _REENT_SIGNGAM(ptr)
|
||||
#endif /* __MISC_VISIBLE || __XSI_VISIBLE */
|
||||
|
||||
#if __SVID_VISIBLE
|
||||
/* The exception structure passed to the matherr routine. */
|
||||
/* We have a problem when using C++ since `exception' is a reserved
|
||||
name in C++. */
|
||||
@@ -554,11 +611,11 @@ extern int matherr _PARAMS((struct exception *e));
|
||||
#define TLOSS 5
|
||||
#define PLOSS 6
|
||||
|
||||
#endif /* ! defined (__STRICT_ANSI__) */
|
||||
#endif /* __SVID_VISIBLE */
|
||||
|
||||
/* Useful constants. */
|
||||
|
||||
#if !defined(__STRICT_ANSI__) || ((_XOPEN_SOURCE - 0) >= 500)
|
||||
#if __BSD_VISIBLE || __XSI_VISIBLE >= 500
|
||||
|
||||
#define MAXFLOAT 3.40282347e+38F
|
||||
|
||||
@@ -578,7 +635,7 @@ extern int matherr _PARAMS((struct exception *e));
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
#if __BSD_VISIBLE
|
||||
|
||||
#define M_TWOPI (M_PI * 2.0)
|
||||
#define M_3PI_4 2.3561944901923448370E0
|
||||
@@ -610,7 +667,7 @@ extern __IMPORT _LIB_VERSION_TYPE _LIB_VERSION;
|
||||
#define _XOPEN_ __fdlibm_xopen
|
||||
#define _POSIX_ __fdlibm_posix
|
||||
|
||||
#endif /* ! defined (__STRICT_ANSI__) */
|
||||
#endif /* __BSD_VISIBLE */
|
||||
|
||||
_END_STD_C
|
||||
|
||||
|
Reference in New Issue
Block a user