diff options
Diffstat (limited to 'sysdeps/generic')
-rw-r--r-- | sysdeps/generic/fix-fp-int-convert-overflow.h | 2 | ||||
-rw-r--r-- | sysdeps/generic/math-type-macros-float128.h | 39 | ||||
-rw-r--r-- | sysdeps/generic/math_private.h | 51 | ||||
-rw-r--r-- | sysdeps/generic/math_private_calls.h | 4 |
4 files changed, 93 insertions, 3 deletions
diff --git a/sysdeps/generic/fix-fp-int-convert-overflow.h b/sysdeps/generic/fix-fp-int-convert-overflow.h index f53eaf00b2..4b0cd9159f 100644 --- a/sysdeps/generic/fix-fp-int-convert-overflow.h +++ b/sysdeps/generic/fix-fp-int-convert-overflow.h @@ -29,5 +29,7 @@ #define FIX_DBL_LLONG_CONVERT_OVERFLOW 0 #define FIX_LDBL_LONG_CONVERT_OVERFLOW 0 #define FIX_LDBL_LLONG_CONVERT_OVERFLOW 0 +#define FIX_FLT128_LONG_CONVERT_OVERFLOW 0 +#define FIX_FLT128_LLONG_CONVERT_OVERFLOW 0 #endif /* fix-fp-int-convert-overflow.h */ diff --git a/sysdeps/generic/math-type-macros-float128.h b/sysdeps/generic/math-type-macros-float128.h new file mode 100644 index 0000000000..dcb8560548 --- /dev/null +++ b/sysdeps/generic/math-type-macros-float128.h @@ -0,0 +1,39 @@ +/* Helper macros for _Float128 variants of type generic functions of libm. + Copyright (C) 2017 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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#ifndef _MATH_TYPE_MACROS_FLOAT128 +#define _MATH_TYPE_MACROS_FLOAT128 + +#include <math.h> +#include <complex.h> + +#define M_LIT(c) __f128 (c) +#define M_PFX FLT128 +#define M_SUF(c) c ## f128 +#define FLOAT _Float128 +#define M_STRTO_NAN __strtof128_nan + +#define CFLOAT __CFLOAT128 + +#define M_MLIT(c) c ## f128 + + +/* Supply the generic macros. */ +#include <math-type-macros.h> + +#endif diff --git a/sysdeps/generic/math_private.h b/sysdeps/generic/math_private.h index 4d8a35ff87..6ea5e25e5a 100644 --- a/sysdeps/generic/math_private.h +++ b/sysdeps/generic/math_private.h @@ -23,6 +23,9 @@ #include <float.h> #include <get-rounding-mode.h> +/* Gather machine dependent _Floatn support. */ +#include <bits/floatn.h> + /* The original fdlibm code used statements like: n0 = ((*(int*)&one)>>29)^1; * index of high word * ix0 = *(n0+(int*)&x); * high word of x * @@ -211,6 +214,41 @@ do { \ #undef _MSUF_ #undef _Mdouble_ +#if __HAVE_DISTINCT_FLOAT128 +# define _Mdouble_ _Float128 +# define _MSUF_ f128 +# define __MATH_DECLARING_FLOATN +# include <math_private_calls.h> +# undef __MATH_DECLARING_FLOATN +# undef _MSUF_ +# undef _Mdouble_ +#endif + +#if __HAVE_DISTINCT_FLOAT128 + +/* __builtin_isinf_sign is broken in GCC < 7 for float128. */ +# if ! __GNUC_PREREQ (7, 0) +# include <ieee754_float128.h> +extern inline int +__isinff128 (_Float128 x) +{ + int64_t hx, lx; + GET_FLOAT128_WORDS64 (hx, lx, x); + lx |= (hx & 0x7fffffffffffffffLL) ^ 0x7fff000000000000LL; + lx |= -lx; + return ~(lx >> 63) & (hx >> 62); +} +# endif + +extern inline _Float128 +fabsf128 (_Float128 x) +{ + return __builtin_fabsf128 (x); +} +#endif + + + /* fdlibm kernel function */ extern double __kernel_standard (double,double,int); extern float __kernel_standard_f (float,float,int); @@ -263,13 +301,24 @@ extern void __docos (double __x, double __dx, double __v[]); }) #endif +#if __HAVE_DISTINCT_FLOAT128 +# define __EXPR_FLT128(x, yes, no) \ + __builtin_choose_expr (__builtin_types_compatible_p \ + (__typeof (x), long double), no, yes) +#else +# define __EXPR_FLT128(x, yes, no) no +#endif + + #define fabs_tg(x) __MATH_TG ((x), (__typeof (x)) __builtin_fabs, (x)) + #define min_of_type(type) __builtin_choose_expr \ (__builtin_types_compatible_p (type, float), \ FLT_MIN, \ __builtin_choose_expr \ (__builtin_types_compatible_p (type, double), \ - DBL_MIN, LDBL_MIN)) + DBL_MIN, \ + __EXPR_FLT128 (x, FLT128_MIN, LDBL_MIN))) /* If X (which is not a NaN) is subnormal, force an underflow exception. */ diff --git a/sysdeps/generic/math_private_calls.h b/sysdeps/generic/math_private_calls.h index 8c1d304a8f..34bbd5e684 100644 --- a/sysdeps/generic/math_private_calls.h +++ b/sysdeps/generic/math_private_calls.h @@ -64,12 +64,12 @@ extern _Mdouble_ __MSUF (__kernel_sin) (_Mdouble_, _Mdouble_, int); extern _Mdouble_ __MSUF (__kernel_cos) (_Mdouble_, _Mdouble_); extern _Mdouble_ __MSUF (__kernel_tan) (_Mdouble_, _Mdouble_, int); -#if defined __MATH_DECLARING_LONG_DOUBLE +#if defined __MATH_DECLARING_LONG_DOUBLE || defined __MATH_DECLARING_FLOATN extern void __MSUF (__kernel_sincos) (_Mdouble_, _Mdouble_, _Mdouble_ *, _Mdouble_ *, int); #endif -#if !defined __MATH_DECLARING_LONG_DOUBLE +#if !defined __MATH_DECLARING_LONG_DOUBLE || defined __MATH_DECLARING_FLOATN extern int __MSUF (__kernel_rem_pio2) (_Mdouble_ *, _Mdouble_ *, int, int, int, const int32_t *); #endif |