2017-06-26 22:50:45 +00:00
|
|
|
/* Macros to control TS 18661-3 glibc features on ia64.
|
|
|
|
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 _BITS_FLOATN_H
|
|
|
|
#define _BITS_FLOATN_H
|
|
|
|
|
|
|
|
#include <features.h>
|
|
|
|
|
|
|
|
/* Defined to 1 if the current compiler invocation provides a
|
|
|
|
floating-point type with the IEEE 754 binary128 format, and this
|
|
|
|
glibc includes corresponding *f128 interfaces for it. The required
|
|
|
|
libgcc support was added some time after the basic compiler
|
|
|
|
support. */
|
|
|
|
#if __GNUC_PREREQ (4, 4)
|
|
|
|
# define __HAVE_FLOAT128 1
|
|
|
|
#else
|
|
|
|
# define __HAVE_FLOAT128 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Defined to 1 if __HAVE_FLOAT128 is 1 and the type is ABI-distinct
|
|
|
|
from the default float, double and long double types in this glibc. */
|
|
|
|
#if __HAVE_FLOAT128
|
|
|
|
# define __HAVE_DISTINCT_FLOAT128 1
|
|
|
|
#else
|
|
|
|
# define __HAVE_DISTINCT_FLOAT128 0
|
|
|
|
#endif
|
|
|
|
|
Add _Float64x function aliases.
This patch continues filling out TS 18661-3 support by adding *f64x
function aliases on platforms with _Float64x support. (It so happens
the set of such platforms is exactly the same as the set of platforms
with _Float128 support, although on x86_64, x86 and ia32 the _Float64x
format is Intel extended rather than binary128.) The API provided
corresponds exactly to that provided for _Float128, mostly coming from
TS 18661-3. As these functions always alias those for another type
(long double, _Float128 or both), __* function names are not provided,
as in other cases of alias types.
Given the preparation done in previous patches, this one just enables
the feature via Makeconfig and bits/floatn.h, adds symbol versions,
and updates documentation and ABI baselines. The symbol versions are
present unconditionally as GLIBC_2.27 in the relevant Versions files,
as it's OK for those to specify versions for functions that may not be
present in some configurations; no additional complexity is needed
unless in future some configuration gains support for this type that
didn't have such support in 2.27. The Makeconfig additions for ia64
and x86 aren't strictly needed, as those configurations also get
float64x-alias-fcts definitions from
sysdeps/ieee754/float128/Makeconfig, but still seem appropriate given
that _Float64x is not _Float128 for those configurations.
A libm-test-ulps update for x86 is included. This is because
bits/mathinline.h does not have _Float64x support added and for two
functions the use of out-of-line functions results in increased ulps
(ifloat64x shares ulps with ildouble / ifloat128 as appropriate).
Given that we'd like generally to eliminate bits/mathinline.h
optimizations, preferring to have such optimizations in GCC instead,
it seems reasonable not to add such support there for new types. GCC
support for _FloatN / _FloatNx built-in functions is limited, but has
been improved in GCC 8, and at some point I hope the full set of libm
built-in functions in GCC, and other optimizations with
per-floating-type aspects, will be enabled for all _FloatN / _FloatNx
types.
Tested for x86_64 and x86, and with build-many-glibcs.py, with both
GCC 6 and GCC 7.
* sysdeps/ia64/Makeconfig (float64x-alias-fcts): New variable.
* sysdeps/ieee754/float128/Makeconfig (float64x-alias-fcts):
Likewise.
* sysdeps/ieee754/ldbl-128/Makeconfig (float64x-alias-fcts):
Likewise.
* sysdeps/x86/Makeconfig: New file.
* bits/floatn-common.h (__HAVE_FLOAT64X): Remove macro.
(__HAVE_FLOAT64X_LONG_DOUBLE): Likewise.
* bits/floatn.h (__HAVE_FLOAT64X): New macro.
(__HAVE_FLOAT64X_LONG_DOUBLE): Likewise.
* sysdeps/ia64/bits/floatn.h (__HAVE_FLOAT64X): Likewise.
(__HAVE_FLOAT64X_LONG_DOUBLE): Likewise.
* sysdeps/ieee754/ldbl-128/bits/floatn.h (__HAVE_FLOAT64X):
Likewise.
(__HAVE_FLOAT64X_LONG_DOUBLE): Likewise.
* sysdeps/mips/ieee754/bits/floatn.h (__HAVE_FLOAT64X): Likewise.
(__HAVE_FLOAT64X_LONG_DOUBLE): Likewise.
* sysdeps/powerpc/bits/floatn.h (__HAVE_FLOAT64X): Likewise.
(__HAVE_FLOAT64X_LONG_DOUBLE): Likewise.
* sysdeps/x86/bits/floatn.h (__HAVE_FLOAT64X): Likewise.
(__HAVE_FLOAT64X_LONG_DOUBLE): Likewise.
* manual/math.texi (Mathematics): Document support for _Float64x.
* math/Versions (GLIBC_2.27): Add _Float64x functions.
* stdlib/Versions (GLIBC_2.27): Likewise.
* wcsmbs/Versions (GLIBC_2.27): Likewise.
* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Update.
* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
* sysdeps/i386/fpu/libm-test-ulps: Likewise.
* sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Likewise.
2017-11-27 14:16:47 +00:00
|
|
|
/* Defined to 1 if the current compiler invocation provides a
|
|
|
|
floating-point type with the right format for _Float64x, and this
|
|
|
|
glibc includes corresponding *f64x interfaces for it. */
|
|
|
|
#define __HAVE_FLOAT64X 1
|
|
|
|
|
|
|
|
/* Defined to 1 if __HAVE_FLOAT64X is 1 and _Float64x has the format
|
|
|
|
of long double. Otherwise, if __HAVE_FLOAT64X is 1, _Float64x has
|
|
|
|
the format of _Float128, which must be different from that of long
|
|
|
|
double. */
|
|
|
|
#define __HAVE_FLOAT64X_LONG_DOUBLE 1
|
|
|
|
|
2017-11-17 22:01:43 +00:00
|
|
|
#ifndef __ASSEMBLER__
|
|
|
|
|
2017-06-26 22:50:45 +00:00
|
|
|
/* Defined to concatenate the literal suffix to be used with _Float128
|
|
|
|
types, if __HAVE_FLOAT128 is 1. */
|
2017-11-17 22:01:43 +00:00
|
|
|
# if __HAVE_FLOAT128
|
|
|
|
# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
|
2017-06-26 22:50:45 +00:00
|
|
|
/* The literal suffix f128 exists only since GCC 7.0. */
|
2017-11-17 22:01:43 +00:00
|
|
|
# define __f128(x) x##q
|
|
|
|
# else
|
|
|
|
# define __f128(x) x##f128
|
|
|
|
# endif
|
2017-06-26 22:50:45 +00:00
|
|
|
# endif
|
|
|
|
|
|
|
|
/* Defined to a complex binary128 type if __HAVE_FLOAT128 is 1. */
|
2017-11-17 22:01:43 +00:00
|
|
|
# if __HAVE_FLOAT128
|
|
|
|
# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
|
2017-06-26 22:50:45 +00:00
|
|
|
/* Add a typedef for older GCC compilers which don't natively support
|
|
|
|
_Complex _Float128. */
|
|
|
|
typedef _Complex float __cfloat128 __attribute__ ((__mode__ (__TC__)));
|
2017-11-17 22:01:43 +00:00
|
|
|
# define __CFLOAT128 __cfloat128
|
|
|
|
# else
|
|
|
|
# define __CFLOAT128 _Complex _Float128
|
|
|
|
# endif
|
2017-06-26 22:50:45 +00:00
|
|
|
# endif
|
|
|
|
|
|
|
|
/* The remaining of this file provides support for older compilers. */
|
2017-11-17 22:01:43 +00:00
|
|
|
# if __HAVE_FLOAT128
|
2017-06-26 22:50:45 +00:00
|
|
|
|
|
|
|
/* The type _Float128 exists only since GCC 7.0. */
|
2017-11-17 22:01:43 +00:00
|
|
|
# if !__GNUC_PREREQ (7, 0) || defined __cplusplus
|
2017-06-26 22:50:45 +00:00
|
|
|
typedef __float128 _Float128;
|
2017-11-17 22:01:43 +00:00
|
|
|
# endif
|
2017-06-26 22:50:45 +00:00
|
|
|
|
|
|
|
/* __builtin_huge_valf128 doesn't exist before GCC 7.0. */
|
2017-11-17 22:01:43 +00:00
|
|
|
# if !__GNUC_PREREQ (7, 0)
|
|
|
|
# define __builtin_huge_valf128() ((_Float128) __builtin_huge_val ())
|
|
|
|
# endif
|
2017-06-26 22:50:45 +00:00
|
|
|
|
|
|
|
/* Older GCC has only a subset of built-in functions for _Float128 on
|
|
|
|
ia64, and __builtin_infq is not usable in static initializers.
|
|
|
|
Converting a narrower sNaN to _Float128 produces a quiet NaN, so
|
|
|
|
attempts to use _Float128 sNaNs will not work properly with older
|
|
|
|
compilers. */
|
2017-11-17 22:01:43 +00:00
|
|
|
# if !__GNUC_PREREQ (7, 0)
|
|
|
|
# define __builtin_copysignf128 __builtin_copysignq
|
|
|
|
# define __builtin_fabsf128 __builtin_fabsq
|
|
|
|
# define __builtin_inff128() ((_Float128) __builtin_inf ())
|
|
|
|
# define __builtin_nanf128(x) ((_Float128) __builtin_nan (x))
|
|
|
|
# define __builtin_nansf128(x) ((_Float128) __builtin_nans (x))
|
|
|
|
# endif
|
2017-06-26 22:50:45 +00:00
|
|
|
|
float128: Add signbit alternative for old compilers
In math/math.h, __MATH_TG will expand signbit to __builtin_signbit*,
e.g.: __builtin_signbitf128, before GCC 6. However, there has never
been a __builtin_signbitf128 in GCC and the type-generic builtin is
only available since GCC 6. For older GCC, this patch defines
__builtin_signbitf128 to __signbitf128, so that the internal function
is used instead of the non-existent builtin.
This patch also changes the implementation of __signbitf128, because
it was reusing the implementation of __signbitl from ldbl-128, which
calls __builtin_signbitl. Using the long double version of the
builtin is not correct on machines where _Float128 is ABI-distinct
from long double (i.e.: ia64, powerpc64le, x86, x86_84). The new
implementation does not rely on builtins when being built with GCC
versions older than 6.0.
The new code does not currently affect powerpc64le builds, because
only GCC 6.2 fulfills the requirements from configure. It might
affect powerpc64le builds if those requirements are backported to
older versions of the compiler. The new code affects x86_64 builds,
since glibc is supposed to build correctly with older versions of GCC.
Tested for powerpc64le and x86_64.
* include/math.h (__signbitf128): Define as hidden.
* sysdeps/ieee754/float128/s_signbitf128.c (__signbitf128):
Reimplement without builtins.
* sysdeps/ia64/bits/floatn.h [!__GNUC_PREREQ (6, 0)]
(__builtin_signbitf128): Define to __signbitf128.
* sysdeps/powerpc/bits/floatn.h: Likewise.
* sysdeps/x86/bits/floatn.h: Likewise.
2017-06-29 18:34:05 +00:00
|
|
|
/* In math/math.h, __MATH_TG will expand signbit to __builtin_signbit*,
|
|
|
|
e.g.: __builtin_signbitf128, before GCC 6. However, there has never
|
|
|
|
been a __builtin_signbitf128 in GCC and the type-generic builtin is
|
|
|
|
only available since GCC 6. */
|
2017-11-17 22:01:43 +00:00
|
|
|
# if !__GNUC_PREREQ (6, 0)
|
|
|
|
# define __builtin_signbitf128 __signbitf128
|
|
|
|
# endif
|
|
|
|
|
float128: Add signbit alternative for old compilers
In math/math.h, __MATH_TG will expand signbit to __builtin_signbit*,
e.g.: __builtin_signbitf128, before GCC 6. However, there has never
been a __builtin_signbitf128 in GCC and the type-generic builtin is
only available since GCC 6. For older GCC, this patch defines
__builtin_signbitf128 to __signbitf128, so that the internal function
is used instead of the non-existent builtin.
This patch also changes the implementation of __signbitf128, because
it was reusing the implementation of __signbitl from ldbl-128, which
calls __builtin_signbitl. Using the long double version of the
builtin is not correct on machines where _Float128 is ABI-distinct
from long double (i.e.: ia64, powerpc64le, x86, x86_84). The new
implementation does not rely on builtins when being built with GCC
versions older than 6.0.
The new code does not currently affect powerpc64le builds, because
only GCC 6.2 fulfills the requirements from configure. It might
affect powerpc64le builds if those requirements are backported to
older versions of the compiler. The new code affects x86_64 builds,
since glibc is supposed to build correctly with older versions of GCC.
Tested for powerpc64le and x86_64.
* include/math.h (__signbitf128): Define as hidden.
* sysdeps/ieee754/float128/s_signbitf128.c (__signbitf128):
Reimplement without builtins.
* sysdeps/ia64/bits/floatn.h [!__GNUC_PREREQ (6, 0)]
(__builtin_signbitf128): Define to __signbitf128.
* sysdeps/powerpc/bits/floatn.h: Likewise.
* sysdeps/x86/bits/floatn.h: Likewise.
2017-06-29 18:34:05 +00:00
|
|
|
# endif
|
|
|
|
|
2017-11-17 22:01:43 +00:00
|
|
|
#endif /* !__ASSEMBLER__. */
|
2017-06-26 22:50:45 +00:00
|
|
|
|
2017-10-20 21:42:51 +00:00
|
|
|
#include <bits/floatn-common.h>
|
|
|
|
|
2017-06-26 22:50:45 +00:00
|
|
|
#endif /* _BITS_FLOATN_H */
|