Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/include/math.h')
-rw-r--r--newlib/libc/include/math.h182
1 files changed, 23 insertions, 159 deletions
diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h
index 41ce752b3..e72d9ca21 100644
--- a/newlib/libc/include/math.h
+++ b/newlib/libc/include/math.h
@@ -1,72 +1,34 @@
+/* math.h -- Definitions for the math floating point package. */
#ifndef _MATH_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
#define _MATH_H_
#include <sys/reent.h>
#include <machine/ieeefp.h>
#include "_ansi.h"
-_BEGIN_STD_C
+#ifndef HUGE_VAL
+
+/* Define HUGE_VAL as infinity, unless HUGE_VAL is already defined
+ (which might have been done by something like math-68881.h). */
union __dmath
{
- __ULong i[2];
+ __uint32_t i[2];
double d;
};
-
-union __fmath
-{
- __ULong i[1];
- float f;
-};
-
-union __ldmath
-{
- __ULong i[4];
- _LONG_DOUBLE ld;
-};
-
-#if defined(__GNUC__) && \
- ( (__GNUC__ >= 4) || \
- ( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 3) ) )
-
- /* gcc >= 3.3 implicitly defines builtins for HUGE_VALx values. */
-
- #ifndef HUGE_VAL
- #define HUGE_VAL (__builtin_huge_val())
- #endif
-
- #ifndef HUGE_VALF
- #define HUGE_VALF (__builtin_huge_valf())
- #endif
-
- #ifndef HUGE_VALL
- #define HUGE_VALL (__builtin_huge_vall())
- #endif
-#else /* !gcc >= 3.3 */
+/* Declare this as an array without bounds so that no matter what small data
+ support a port and/or library has, this reference will be via the general
+ method for accessing globals. */
+extern __IMPORT const union __dmath __infinity[];
- /* No builtins. Use floating-point unions instead. Declare as an array
- without bounds so no matter what small data support a port and/or
- library has, the reference will be via the general method for accessing
- globals. */
+#define HUGE_VAL (__infinity[0].d)
- #ifndef HUGE_VAL
- extern __IMPORT const union __dmath __infinity[];
- #define HUGE_VAL (__infinity[0].d)
- #endif
-
- #ifndef HUGE_VALF
- extern __IMPORT const union __fmath __infinityf[];
- #define HUGE_VALF (__infinityf[0].f)
- #endif
-
- #ifndef HUGE_VALL
- extern __IMPORT const union __ldmath __infinityld[];
- #define HUGE_VALL (__infinityld[0].ld)
- #endif
-
-#endif /* !gcc >= 3.3 */
+#endif /* ! defined (HUGE_VAL) */
/* Reentrant ANSI C functions. */
@@ -104,77 +66,12 @@ extern double fmod _PARAMS((double, double));
#ifndef __STRICT_ANSI__
-/* ISO C99 types and macros. */
-
-#ifndef FLT_EVAL_METHOD
-#define FLT_EVAL_METHOD 0
-typedef float float_t;
-typedef double double_t;
-#endif /* FLT_EVAL_METHOD */
-
-#define FP_NAN 0
-#define FP_INFINITE 1
-#define FP_ZERO 2
-#define FP_SUBNORMAL 3
-#define FP_NORMAL 4
-
-extern int __isinff (float x);
-extern int __isinfd (double x);
-extern int __isnanf (float x);
-extern int __isnand (double x);
-extern int __fpclassifyf (float x);
-extern int __fpclassifyd (double x);
-extern int __signbitf (float x);
-extern int __signbitd (double x);
-
-#define fpclassify(x) \
- (__extension__ ({__typeof__(x) __x = (x); \
- (sizeof (__x) == sizeof (float)) ? __fpclassifyf(__x) : __fpclassifyd(__x);}))
-
-#define isfinite(y) \
- (__extension__ ({__typeof__(y) __y = (y); \
- fpclassify(__y) != FP_INFINITE && fpclassify(__y) != FP_NAN;}))
-
-/* 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. */
-#define isinf(x) \
- (__extension__ ({__typeof__(x) __x = (x); \
- (sizeof (__x) == sizeof (float)) ? __isinff(__x) : __isinfd(__x);}))
-#define isnan(x) \
- (__extension__ ({__typeof__(x) __x = (x); \
- (sizeof (__x) == sizeof (float)) ? __isnanf(__x) : __isnand(__x);}))
-#define isnormal(y) (fpclassify(y) == FP_NORMAL)
-#define signbit(x) \
- (__extension__ ({__typeof__(x) __x = (x); \
- (sizeof(__x) == sizeof(float)) ? __signbitf(__x) : __signbitd(__x);}))
-
-#define isgreater(x,y) \
- (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
- !isunordered(__x,__y) && (__x > __y);}))
-#define isgreaterequal(x,y) \
- (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
- !isunordered(__x,__y) && (__x >= __y);}))
-#define isless(x,y) \
- (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
- !isunordered(__x,__y) && (__x < __y);}))
-#define islessequal(x,y) \
- (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
- !isunordered(__x,__y) && (__x <= __y);}))
-#define islessgreater(x,y) \
- (__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
- !isunordered(__x,__y) && (__x < __y || __x > __y);}))
-
-#define isunordered(a,b) \
- (__extension__ ({__typeof__(a) __a = (a); __typeof__(b) __b = (b); \
- fpclassify(__a) == FP_NAN || fpclassify(__b) == FP_NAN;}))
-
/* Non ANSI double precision functions. */
extern double infinity _PARAMS((void));
-extern double nan _PARAMS((const char *));
+extern double nan _PARAMS((void));
+extern int isnan _PARAMS((double));
+extern int isinf _PARAMS((double));
extern int finite _PARAMS((double));
extern double copysign _PARAMS((double, double));
extern int ilogb _PARAMS((double));
@@ -185,22 +82,6 @@ extern double nextafter _PARAMS((double, double));
extern double rint _PARAMS((double));
extern double scalbn _PARAMS((double, int));
-extern double exp2 _PARAMS((double));
-extern double scalbln _PARAMS((double, long int));
-extern double tgamma _PARAMS((double));
-extern double nearbyint _PARAMS((double));
-extern long int lrint _PARAMS((double));
-extern double round _PARAMS((double));
-extern long int lround _PARAMS((double));
-extern double trunc _PARAMS((double));
-extern double remquo _PARAMS((double, double, int *));
-extern double copysign _PARAMS((double, double));
-extern double fdim _PARAMS((double, double));
-extern double fmax _PARAMS((double, double));
-extern double fmin _PARAMS((double, double));
-extern double fma _PARAMS((double, double, double));
-extern void sincos _PARAMS((double, double *, double *));
-
#ifndef __math_68881
extern double log1p _PARAMS((double));
extern double expm1 _PARAMS((double));
@@ -271,23 +152,8 @@ extern float fmodf _PARAMS((float, float));
/* Other single precision functions. */
-extern float exp2f _PARAMS((float));
-extern float scalblnf _PARAMS((float, long int));
-extern float tgammaf _PARAMS((float));
-extern float nearbyintf _PARAMS((float));
-extern long int lrintf _PARAMS((float));
-extern float roundf _PARAMS((float));
-extern long int lroundf _PARAMS((float));
-extern float truncf _PARAMS((float));
-extern float remquof _PARAMS((float, float, int *));
-extern float copysignf _PARAMS((float, float));
-extern float fdimf _PARAMS((float, float));
-extern float fmaxf _PARAMS((float, float));
-extern float fminf _PARAMS((float, float));
-extern float fmaf _PARAMS((float, float, float));
-
extern float infinityf _PARAMS((void));
-extern float nanf _PARAMS((const char *));
+extern float nanf _PARAMS((void));
extern int isnanf _PARAMS((float));
extern int isinff _PARAMS((float));
extern int finitef _PARAMS((float));
@@ -301,7 +167,6 @@ extern float rintf _PARAMS((float));
extern float scalbnf _PARAMS((float, int));
extern float log1pf _PARAMS((float));
extern float expm1f _PARAMS((float));
-extern void sincosf _PARAMS((float, float *, float *));
#ifndef _REENT_ONLY
extern float acoshf _PARAMS((float));
@@ -333,7 +198,7 @@ extern float dremf _PARAMS((float, float));
extern int *__signgam _PARAMS((void));
#endif /* ! defined (_REENT_ONLY) */
-#define __signgam_r(ptr) _REENT_SIGNGAM(ptr)
+#define __signgam_r(ptr) ((ptr)->_new._reent._gamma_signgam)
/* The exception structure passed to the matherr routine. */
@@ -368,8 +233,6 @@ extern int matherr _PARAMS((struct exception *e));
/* Useful constants. */
-#define MAXFLOAT 3.40282347e+38F
-
#define M_E 2.7182818284590452354
#define M_LOG2E 1.4426950408889634074
#define M_LOG10E 0.43429448190325182765
@@ -415,10 +278,11 @@ extern __IMPORT _CONST _LIB_VERSION_TYPE _LIB_VERSION;
#endif /* ! defined (__STRICT_ANSI__) */
-_END_STD_C
-
#ifdef __FAST_MATH__
#include <machine/fastmath.h>
#endif
+#ifdef __cplusplus
+}
+#endif
#endif /* _MATH_H_ */