summaryrefslogtreecommitdiff
path: root/math/math.h
diff options
context:
space:
mode:
Diffstat (limited to 'math/math.h')
-rw-r--r--math/math.h50
1 files changed, 41 insertions, 9 deletions
diff --git a/math/math.h b/math/math.h
index c5115d7982..4724b10b6f 100644
--- a/math/math.h
+++ b/math/math.h
@@ -1,5 +1,5 @@
/* Declarations for math functions.
- Copyright (C) 1991-2015 Free Software Foundation, Inc.
+ Copyright (C) 1991-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -77,6 +77,7 @@ __BEGIN_DECLS
#define _Mdouble_ double
#define __MATH_PRECNAME(name,r) __CONCAT(name,r)
+#define __MATH_DECLARING_DOUBLE 1
#define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_STD
#define _Mdouble_END_NAMESPACE __END_NAMESPACE_STD
#include <bits/mathcalls.h>
@@ -84,6 +85,7 @@ __BEGIN_DECLS
#undef _Mdouble_BEGIN_NAMESPACE
#undef _Mdouble_END_NAMESPACE
#undef __MATH_PRECNAME
+#undef __MATH_DECLARING_DOUBLE
#ifdef __USE_ISOC99
@@ -96,6 +98,7 @@ __BEGIN_DECLS
# endif
# define _Mdouble_ _Mfloat_
# define __MATH_PRECNAME(name,r) name##f##r
+# define __MATH_DECLARING_DOUBLE 0
# define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99
# define _Mdouble_END_NAMESPACE __END_NAMESPACE_C99
# include <bits/mathcalls.h>
@@ -103,6 +106,7 @@ __BEGIN_DECLS
# undef _Mdouble_BEGIN_NAMESPACE
# undef _Mdouble_END_NAMESPACE
# undef __MATH_PRECNAME
+# undef __MATH_DECLARING_DOUBLE
# if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \
|| defined __LDBL_COMPAT \
@@ -140,6 +144,7 @@ extern long double __REDIRECT_NTH (nexttowardl,
# endif
# define _Mdouble_ _Mlong_double_
# define __MATH_PRECNAME(name,r) name##l##r
+# define __MATH_DECLARING_DOUBLE 0
# define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99
# define _Mdouble_END_NAMESPACE __END_NAMESPACE_C99
# define __MATH_DECLARE_LDOUBLE 1
@@ -148,6 +153,7 @@ extern long double __REDIRECT_NTH (nexttowardl,
# undef _Mdouble_BEGIN_NAMESPACE
# undef _Mdouble_END_NAMESPACE
# undef __MATH_PRECNAME
+# undef __MATH_DECLARING_DOUBLE
# endif /* !(__NO_LONG_DOUBLE_MATH && _LIBC) || __LDBL_COMPAT */
@@ -219,8 +225,16 @@ enum
FP_NORMAL
};
+/* GCC bug 66462 means we cannot use the math builtins with -fsignaling-nan,
+ so disable builtins if this is enabled. When fixed in a newer GCC,
+ the __SUPPORT_SNAN__ check may be skipped for those versions. */
+
/* Return number of classification appropriate for X. */
-# ifdef __NO_LONG_DOUBLE_MATH
+# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__ \
+ && !defined __OPTIMIZE_SIZE__
+# define fpclassify(x) __builtin_fpclassify (FP_NAN, FP_INFINITE, \
+ FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)
+# elif defined __NO_LONG_DOUBLE_MATH
# define fpclassify(x) \
(sizeof (x) == sizeof (float) ? __fpclassifyf (x) : __fpclassify (x))
# else
@@ -232,19 +246,29 @@ enum
# endif
/* Return nonzero value if sign of X is negative. */
-# ifdef __NO_LONG_DOUBLE_MATH
+# if __GNUC_PREREQ (4,0)
# define signbit(x) \
- (sizeof (x) == sizeof (float) ? __signbitf (x) : __signbit (x))
+ (sizeof (x) == sizeof (float) \
+ ? __builtin_signbitf (x) \
+ : sizeof (x) == sizeof (double) \
+ ? __builtin_signbit (x) : __builtin_signbitl (x))
# else
-# define signbit(x) \
+# ifdef __NO_LONG_DOUBLE_MATH
+# define signbit(x) \
+ (sizeof (x) == sizeof (float) ? __signbitf (x) : __signbit (x))
+# else
+# define signbit(x) \
(sizeof (x) == sizeof (float) \
? __signbitf (x) \
: sizeof (x) == sizeof (double) \
? __signbit (x) : __signbitl (x))
+# endif
# endif
/* Return nonzero value if X is not +-Inf or NaN. */
-# ifdef __NO_LONG_DOUBLE_MATH
+# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
+# define isfinite(x) __builtin_isfinite (x)
+# elif defined __NO_LONG_DOUBLE_MATH
# define isfinite(x) \
(sizeof (x) == sizeof (float) ? __finitef (x) : __finite (x))
# else
@@ -256,11 +280,17 @@ enum
# endif
/* Return nonzero value if X is neither zero, subnormal, Inf, nor NaN. */
-# define isnormal(x) (fpclassify (x) == FP_NORMAL)
+# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
+# define isnormal(x) __builtin_isnormal (x)
+# else
+# define isnormal(x) (fpclassify (x) == FP_NORMAL)
+# endif
/* Return nonzero value if X is a NaN. We could use `fpclassify' but
we already have this functions `__isnan' and it is faster. */
-# ifdef __NO_LONG_DOUBLE_MATH
+# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
+# define isnan(x) __builtin_isnan (x)
+# elif defined __NO_LONG_DOUBLE_MATH
# define isnan(x) \
(sizeof (x) == sizeof (float) ? __isnanf (x) : __isnan (x))
# else
@@ -272,7 +302,9 @@ enum
# endif
/* Return nonzero value if X is positive or negative infinity. */
-# ifdef __NO_LONG_DOUBLE_MATH
+# if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
+# define isinf(x) __builtin_isinf_sign (x)
+# elif defined __NO_LONG_DOUBLE_MATH
# define isinf(x) \
(sizeof (x) == sizeof (float) ? __isinff (x) : __isinf (x))
# else