summaryrefslogtreecommitdiffstats
path: root/newlib/libc/include
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/include')
-rw-r--r--newlib/libc/include/ieeefp.h3
-rw-r--r--newlib/libc/include/math.h23
2 files changed, 20 insertions, 6 deletions
diff --git a/newlib/libc/include/ieeefp.h b/newlib/libc/include/ieeefp.h
index 970ea4543..e08fd0885 100644
--- a/newlib/libc/include/ieeefp.h
+++ b/newlib/libc/include/ieeefp.h
@@ -184,6 +184,9 @@ typedef int fp_rdi;
fp_rdi _EXFUN(fpgetroundtoi,(void));
fp_rdi _EXFUN(fpsetroundtoi,(fp_rdi));
+#undef isnan
+#undef isinf
+
int _EXFUN(isnan, (double));
int _EXFUN(isinf, (double));
int _EXFUN(finite, (double));
diff --git a/newlib/libc/include/math.h b/newlib/libc/include/math.h
index 041e8000b..41ce752b3 100644
--- a/newlib/libc/include/math.h
+++ b/newlib/libc/include/math.h
@@ -1,4 +1,3 @@
-/* math.h -- Definitions for the math floating point package. */
#ifndef _MATH_H_
#define _MATH_H_
@@ -119,6 +118,10 @@ typedef double double_t;
#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);
@@ -131,9 +134,19 @@ extern int __signbitd (double x);
#define isfinite(y) \
(__extension__ ({__typeof__(y) __y = (y); \
fpclassify(__y) != FP_INFINITE && fpclassify(__y) != FP_NAN;}))
-#define isnormal(z) \
- (__extension__ ({__typeof__(z) __z = (z); \
- fpclassify(__z) == FP_NORMAL;}))
+
+/* 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);}))
@@ -162,8 +175,6 @@ extern int __signbitd (double x);
extern double infinity _PARAMS((void));
extern double nan _PARAMS((const char *));
-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));