about summary refs log tree commit diff
path: root/math
Commit message (Collapse)AuthorAgeFilesLines
* Simplify NAN definitions.Joseph Myers2017-08-312-3/+9
| | | | | | | | | | | | | | | | | | | | Similar to my patches for HUGE_VAL and INFINITY. this patch eliminates the bits/nan.h headers. __builtin_nanf ("") is used to define NAN for GCC 3.3 and later; the fallback is (0.0f / 0.0f), which is a constant expression for a quiet NaN of type float, but raises a spurious "invalid" exception outside static initializers, which seems the best that can be done purely in standard C. Again, if anyone actually uses a compiler with its own incompatible extension for producing a constant quiet NaN, we can add compiler conditionals. Tested for x86_64. * math/math.h [__USE_ISOC99] (NAN): Define directly here. Do not include <bits/nan.h>. * math/Makefile (headers): Remove bits/nan.h. * bits/nan.h: Remove. * sysdeps/ieee754/bits/nan.h: Likewise. * sysdeps/mips/bits/nan.h: Likewise.
* Simplify INFINITY definitions.Joseph Myers2017-08-312-3/+7
| | | | | | | | | | | | | | | | Similar to my patch for HUGE_VAL, this patch eliminates the bits/inf.h headers and just unconditionally uses the same definitions as the sysdeps/ieee754 version did (__builtin_inff () for GCC >= 3.3, otherwise HUGE_VALF), directly in math.h, so removing an unnecessary level of indirection. Tested for x86_64. * math/math.h [__USE_ISOC99] (INFINITY): Define directly here. Do not include <bits/inf.h>. * math/Makefile (headers): Remove bits/inf.h. * bits/inf.h: Remove. * sysdeps/ieee754/bits/inf.h: Likewise.
* Simplify HUGE_VAL definitions.Joseph Myers2017-08-312-11/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are various bits/huge_val*.h headers to define HUGE_VAL and related macros. All of them use __builtin_huge_val etc. for GCC 3.3 and later. Then there are various fallbacks, such as using a large hex float constant for GCC 2.96 and later, or using unions (with or without compound literals) to construct the bytes of an infinity, with this last being the reason for having architecture-specific files. Supporting TS 18661-3 _FloatN / _FloatNx types that have the same format as other supported types will mean adding more such macros; needing to add more headers for them doesn't seem very desirable. The fallbacks based on bytes of the representation of an infinity do not meet the standard requirements for a constant expression. At least one of them is also wrong: sysdeps/sh/bits/huge_val.h is producing a mixed-endian representation which does not match what GCC does. This patch eliminates all those headers, defining the macros directly in math.h. For GCC 3.3 and later, the built-in functions are used as now. For other compilers, a large constant 1e10000 (with appropriate suffix) is used. This is like the fallback for GCC 2.96 and later, but without using hex floats (which have no apparent advantage here). It is unambiguously valid standard C for all floating-point formats with infinities, which covers all formats supported by glibc or likely to be supported by glibc in future (C90 DR#025 said that if a floating-point format represents infinities, all real values lie within the range of representable values, so the constraints for constant expressions are not violated), but may generate compiler warnings and wouldn't handle the TS 18661-1 FENV_ROUND pragma correctly. If someone is actually using a compiler with glibc that does not claim to be GCC 3.3 or later, but which has a better way to define the HUGE_VAL macros, we can always add compiler conditionals in with alternative definitions. I intend to make similar changes for INF and NAN. The SNAN macros already just use __builtin_nans etc. with no fallback for compilers not claiming to be GCC 3.3 or later. Tested for x86_64. * math/math.h: Do not include bits/huge_val.h, bits/huge_valf.h, bits/huge_vall.h or bits/huge_val_flt128.h. (HUGE_VAL): Define directly here. [__USE_ISOC99] (HUGE_VALF): Likewise. [__USE_ISOC99] (HUGE_VALL): Likewise. [__HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (HUGE_VAL_F128): Likewise. * math/Makefile (headers): Remove bits/huge_val.h, bits/huge_valf.h, bits/huge_vall.h and bits/huge_val_flt128.h. * bits/huge_val.h: Remove. * bits/huge_val_flt128.h: Likewise. * bits/huge_valf.h: Likewise. * bits/huge_vall.h: Likewise. * sysdeps/ia64/bits/huge_vall.h: Likewise. * sysdeps/ieee754/bits/huge_val.h: Likewise. * sysdeps/ieee754/bits/huge_valf.h: Likewise. * sysdeps/m68k/m680x0/bits/huge_vall.h: Likewise. * sysdeps/sh/bits/huge_val.h: Likewise. * sysdeps/sparc/bits/huge_vall.h: Likewise. * sysdeps/x86/bits/huge_vall.h: Likewise.
* Fix bits/math-finite.h _MSUF_ expansion namespace (bug 22028).Joseph Myers2017-08-294-39/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current bits/math-finite.h approach to defining functions for different types, involving math.h defining _MSUF_ and _MSUFTO_ for the function suffixes involved, is not namespace-clean if one of those suffixes (f, l, f128) is defined as a macro by the user before math.h is included; too many levels of macro expansion occur. Instead, those suffixes should appear directly in the expansion of the macro using ## so they don't get expanded even if defined as macros by the user (that is, math.h should be defining __REDIRFROM_X and __REDIRTO_X directly to use those suffixes rather than suffixes being passed as an argument by macro callers). This patch makes that change. Tested for x86_64. [BZ #22028] * math/math.h [__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0] (_MSUF_): Remove macro. [__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0] (_MSUFTO_): Likewise. [__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0] (__REDIRFROM_X): New macro. [__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0] (__REDIRTO_X): Likewise. * math/bits/math-finite.h (__REDIRFROM_X): Remove macro. (__REDIRTO_X): Likewise. (__MATH_REDIRCALL): Do not pass _MSUF_ or _MSUFTO_ macro arguments. (__MATH_REDIRCALL_2): Likewise. (__MATH_REDIRCALL_INTERNAL): Likewise. (__REDIRFROM (lgamma, , _MSUF_)): Likewise. (__REDIRFROM (gamma, , _MSUF_)): Likweise. (__REDIRFROM (__gamma, _r_finite, _MSUF_)): Likewise. (__REDIRFROM (tgamma, , _MSUF_)): Likewise. * math/test-finite-macros.c: New file. * math/Makefile (tests): Add test-finite-macros. (CFLAGS-test-finite-macros.c): New variable.
* Provide a C++ version of iszero that does not use __MATH_TG (bug 21930)Gabriel F. T. Gomes2017-08-282-4/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When signaling nans are enabled (with -fsignaling-nans), the C++ version of iszero uses the fpclassify macro, which is defined with __MATH_TG. However, when support for float128 is available, __MATH_TG uses the builtin __builtin_types_compatible_p, which is only available in C mode. This patch refactors the C++ version of iszero so that it uses function overloading to select between the floating-point types, instead of relying on fpclassify and __MATH_TG. Tested for powerpc64le, s390x, x86_64, and with build-many-glibcs.py. [BZ #21930] * math/math.h [defined __cplusplus && defined __SUPPORT_SNAN__] (iszero): New C++ implementation that does not use fpclassify/__MATH_TG/__builtin_types_compatible_p, when signaling nans are enabled, since __builtin_types_compatible_p is a C-only feature. * math/test-math-iszero.cc: When __HAVE_DISTINCT_FLOAT128 is defined, include ieee754_float128.h for access to the union and member ieee854_float128.ieee. [__HAVE_DISTINCT_FLOAT128] (do_test): Call check_float128. [__HAVE_DISTINCT_FLOAT128] (check_float128): New function. * sysdeps/powerpc/powerpc64le/Makefile [subdir == math] (CXXFLAGS-test-math-iszero.cc): Add -mfloat128 to the build options of test-math-zero on powerpc64le.
* Simplify math-svid-compat code.Joseph Myers2017-08-281-13/+9
| | | | | | | | | | | | | | | | | | Now there are no more assembly wrappers using _LIB_VERSION or __kernel_standard, the math-svid-compat code can be slighly simplified. math-svid-compat.h no longer needs __ASSEMBLER__ conditionals, and the _LIB_VERSION variable no longer needs to be built for static libm, since all references are now in C code that includes math-svid-compat.h and so gets the macro definition of _LIB_VERSION to _POSIX_ outside the compat case. This patch makes those cleanups. Tested for x86_64, and with build-many-glibcs.py. * math/math-svid-compat.h [!__ASSEMBLER__]: Make code unconditional. * sysdeps/ieee754/s_lib_version.c [!defined SHARED]: Remove conditional code; define contents only for [LIBM_SVID_COMPAT].
* Use __HAVE_DISTINCT_FLOAT128 in tgmath.h.Joseph Myers2017-08-251-1/+1
| | | | | | | | | | | | | | | When _Float128 is ABI-equivalent to long double, there is no need for tgmath.h to have any special _Float128 handling: it's always OK to call the long double versions of functions for _Float128 arguments in that case, and the logic to determine return types is generic. Thus, this patch changes the use of __HAVE_FLOAT128 to __HAVE_DISTINCT_FLOAT128, as a minor optimization to reduce the size of the macro expansions in the ABI-equivalent case. Tested for x86_64. * math/tgmath.h [__HAVE_FLOAT128]: Change conditional to [__HAVE_DISTINCT_FLOAT128].
* Clean up bits/math-finite.h for aliasing types.Joseph Myers2017-08-252-23/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch cleans up how bits/math-finite.h handles types that are ABI-aliases of other types. For such types, no __*_finite functions exist; instead, bits/math-finite.h must redirect calls to a the functions for a canonical choice of type for each floating-point format. (For the actual public interfaces, symbols need exporting for each type, even those that are ABI-aliases, because of standard requirements that programs can declare the functions themselves without including <math.h>, but that does not apply to __*_finite.) At present, there is a special-case conditional in bits/math-finite.h on __MATH_DECLARING_LDOUBLE && defined __NO_LONG_DOUBLE_MATH to handle redirecting long double function calls to double __*_finite. This patch replaces this by a more general mechanism. math.h, before each inclusion of bits/math-finite.h, defines _MSUFTO_ as the suffix to use on the target of redirection, in addition to the existing _MSUF_. This way, __MATH_DECLARING_LDOUBLE can go away, as can the special conditional in bits/math-finite.h. With this patch, math.h is now prepared for the case of supporting float128 functions as aliases of long double ones on platforms where long double is binary128, with _MSUFTO_ appropriately defined for that case, and appropriate _MSUFTO_ definitions can easily be included when supporting _Float32 / _Float64 / _Float32x / _Float64x (which will always be ABI-aliases of another type when supported). Tested for x86_64, and did a compilation test for ARM with build-many-glibcs.py to cover the long double = double case. * math/math.h (_MSUFTO_): Define and undefine for each inclusion of <bits/math-finite.h>. (__MATH_DECLARING_LDOUBLE): Do not define and undefine for each inclusion of <bits/math-finite.h>. * math/bits/math-finite.h (__REDIRTO_X): Do not define conditionally on [__MATH_DECLARING_LDOUBLE && defined __NO_LONG_DOUBLE_MATH]. (__MATH_REDIRCALL): Use _MSUFTO_ in __REDIRTO call. (__MATH_REDIRCALL_2): Likewise. (__MATH_REDIRCALL_INTERNAL): Likewise. (__REDIRFROM (lgamma, , _MSUF_)): Likewise. (__REDIRFROM (gamma, , _MSUF_)): Likewise. (__REDIRFROM (tgamma, , _MSUF_)): Likewise.
* Fix the C++ version of issignaling when __NO_LONG_DOUBLE_MATH is definedGabriel F. T. Gomes2017-08-241-1/+9
| | | | | | | | | | | | When __NO_LONG_DOUBLE_MATH is defined, __issignalingl is not available, thus issignaling with long double argument should call __issignaling, instead. Tested for powerpc64le. * math/math.h [defined __cplusplus] (issignaling): In the long double case, call __issignalingl only if __NO_LONG_DOUBLE_MATH is not defined. Call __issignaling, otherwise.
* Remove duplicate inclusion of header math-svid-compat.hGabriel F. T. Gomes2017-08-223-3/+0
| | | | | | | | | | | The header math-svid-compat.h has been unintentionally included twice in the wrappers for the remainder functions. This patch removes the duplicate inclusions. * math/w_remainder_compat.c: Remove duplicate inclusion of math-svid-compat.h. * math/w_remainderf_compat.c: Likewise. * math/w_remainderl_compat.c: Likewise.
* Fix tgmath.h handling of complex integers (bug 21684).Joseph Myers2017-08-222-49/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The tgmath.h macros return a real type not a complex type when an argument is of complex integer type (a GNU extension) and there are no arguments of complex floating type. It seems clear that just as real integers are mapped to double for tgmath.h, so complex integers should be mapped to _Complex double. This patch implements such a mapping. The main complication in fixing this bug is that the tgmath.h macros expand their arguments a large number of times, resulting in exponential blowup of the size of the expansion when calls to tgmath.h macros are used in the arguments of such macros; it would be unfortunate for fixing a bug with a fairly obscure extension to make the macros expand their arguments even more times. Thus, this patch optimizes the definitions of the relevant macros. __tgmath_real_type previously expanded its argument 7 times and now expands it 3 times. __tgmath_complex_type, used in place of __tgmath_real_type only for functions that might return either real or complex types, not for complex functions that always return real types or always return complex types, expands its argument 5 times. So the sizes of the macro expansions from nested macro calls are correspondingly reduced (remembering that each tgmath.h macro expands __tgmath_real_type, or sometimes now __tgmath_complex_type, several times). Sometimes the real return type resulted from calling a complex function and converting the result to a real type; sometimes it resulted from calling a real function, because the logic for determining whether arguments were real or complex, based on sizeof, was confused by integer promotions applying to e.g. short int but not _Complex short int. The relevant tests are converted to use a new macro __expr_is_real, which, by calling __builtin_classify_type rather than comparing the results of two calls to sizeof, also reduces the number of times macros expand their arguments. Although there are reductions in the number of times macros expand their arguments, I do not consider this to fix bug 21660, since a proper fix means each macro expanding its arguments only once (via using new compiler features designed for that purpose). Tested for x86_64. [BZ #21684] * math/tgmath.h (__floating_type): Simplify definitions. (__real_integer_type): New macro. (__complex_integer_type): Likewise. (__expr_is_real): Likewise. (__tgmath_real_type_sub): Update comment to describe handling of complex types. (__tgmath_complex_type_sub): New macro. (__tgmath_complex_type): Likewise. [__HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (__TGMATH_CF128): Use __expr_is_real. (__TGMATH_UNARY_REAL_IMAG): Use __tgmath_complex_type and __expr_is_real. (__TGMATH_BINARY_REAL_IMAG): Likewise. (__TGMATH_UNARY_REAL_IMAG_RET_REAL): Use __expr_is_real. * math/gen-tgmath-tests.py (Type.create_type): Create complex integer types.
* Provide a C++ version of issignaling that does not use __MATH_TGGabriel F. T. Gomes2017-08-223-2/+133
| | | | | | | | | | | | | | | | | | | | | | | | | The macro __MATH_TG contains the logic to select between long double and _Float128, when these types are ABI-distinct. This logic relies on __builtin_types_compatible_p, which is not available in C++ mode. On the other hand, C++ function overloading provides the means to distinguish between the floating-point types. The overloading resolution will match the correct parameter regardless of type qualifiers, i.e.: const and volatile. Tested for powerpc64le, s390x, and x86_64. * math/math.h [defined __cplusplus] (issignaling): Provide a C++ definition for issignaling that does not rely on __MATH_TG, since __MATH_TG uses __builtin_types_compatible_p, which is only available in C mode. (CFLAGS-test-math-issignaling.cc): New variable. * math/Makefile [CXX] (tests): Add test-math-issignaling. * math/test-math-issignaling.cc: New test for C++ implementation of type-generic issignaling. * sysdeps/powerpc/powerpc64le/Makefile [subdir == math] (CXXFLAGS-test-math-issignaling.cc): Add -mfloat128 to the build options of test-math-issignaling on powerpc64le.
* math: Statically link tests of internal functionalityFlorian Weimer2017-08-221-8/+5
|
* Obsolete matherr, _LIB_VERSION, libieee.a.Joseph Myers2017-08-2181-98/+291
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch obsoletes support for SVID libm error handling (the system where a user-defined function matherr is called on a libm function error; only enabled if you also set _LIB_VERSION = _SVID_ or _LIB_VERSION = _XOPEN_) and the use of the _LIB_VERSION global variable to control libm error handling. matherr and _LIB_VERSION are made into compat symbols, not supported for new ports or for static linking. The libieee.a object file (which sets _LIB_VERSION = _IEEE_, so disabling errno setting for some functions) is also removed, and all the related definitions are removed from math.h. The manual already recommends against using matherr, and it's already not supported for _Float128 functions (those use new wrappers that don't support matherr, only errno) - this patch means that it becomes possible to e.g. add sinf32 as an alias to sinf without that resulting in undesired matherr support in sinf32 for existing glibc ports. matherr support is not part of any standard supported by glibc (it was removed in XPG4). Because matherr is a function to be defined by the user, of course user programs defining such a function will still continue to link; it just quietly won't be used. If they try to write to the library's copy of _LIB_VERSION to enable SVID error handling, however, they will get a link error (but if they define their own _LIB_VERSION variable, they won't). I expect the most likely case of build failures from this patch to be programs with unconditional cargo-culted uses of -lieee (based on a notion of "I want IEEE floating point", not any actual requirement for that library). Ideally, the new-port-or-static-linking case would use the new wrappers used for _Float128. This is not implemented in this patch, because of the complication of architecture-specific (powerpc32 and sparc) sqrt wrappers that use _LIB_VERSION and __kernel_standard directly. Thus, the old wrappers and __kernel_standard are still built unconditionally, and _LIB_VERSION still exists in static libm. But when the old wrappers and __kernel_standard are built in the non-compat case, _LIB_VERSION and matherr are defined as macros so code to support those features isn't actually built into static libm or new ports' shared libm after this patch. I intend to move to the new wrappers for static libm and new ports in followup patches. I believe the sqrt wrappers for powerpc32 and sparc can reasonably be removed. GCC already optimizes the normal case of sqrt by generating code that uses a hardware instruction and only calls the sqrt function if the argument was negative (if -fno-math-errno, of course, it just uses the hardware instruction without any check for negative argument being needed). Thus those wrappers will only actually get called in the case of negative arguments, which is not a case it makes sense to optimize for. But even without removing the powerpc32 and sparc wrappers it should still be possible to move to the new wrappers for static libm and new ports, just without having those dubious architecture-specific optimizations in static libm. Everything said about matherr equally applies to matherrf and matherrl (IA64-specific, undocumented), except that the structure of IA64 libm means it won't be converted to using the new wrappers (it doesn't use the old ones either, but its own error-handling code instead). As with other tests of compat symbols, I expect test-matherr and test-matherr-2 to need to become appropriately conditional once we have a system for disabling such tests for ports too new to have the relevant symbols. Tested for x86_64 and x86, and with build-many-glibcs.py. * math/math.h [__USE_MISC] (_LIB_VERSION_TYPE): Remove. [__USE_MISC] (_LIB_VERSION): Likewise. [__USE_MISC] (struct exception): Likewise. [__USE_MISC] (matherr): Likewise. [__USE_MISC] (DOMAIN): Likewise. [__USE_MISC] (SING): Likewise. [__USE_MISC] (OVERFLOW): Likewise. [__USE_MISC] (UNDERFLOW): Likewise. [__USE_MISC] (TLOSS): Likewise. [__USE_MISC] (PLOSS): Likewise. [__USE_MISC] (HUGE): Likewise. [__USE_XOPEN] (MAXFLOAT): Define even if [__USE_MISC]. * math/math-svid-compat.h: New file. * conform/linknamespace.pl (@whitelist): Remove matherr, matherrf and matherrl. * include/math.h [!_ISOMAC] (__matherr): Remove. * manual/arith.texi (FP Exceptions): Do not document matherr. * math/Makefile (tests): Change test-matherr to test-matherr-3. (tests-internal): New variable. (install-lib): Do not add libieee.a. (non-lib.a): Likewise. (extra-objs): Do not add libieee.a and ieee-math.o. (CPPFLAGS-s_lib_version.c): Remove variable. ($(objpfx)libieee.a): Remove rule. ($(addprefix $(objpfx), $(tests-internal)): Depend on $(libm). * math/ieee-math.c: Remove. * math/libm-test-support.c (matherr): Remove. * math/test-matherr.c: Use <support/test-driver.c>. Add copyright and license notices. Include <math-svid-compat.h> and <shlib-compat.h>. (matherr): Undefine as macro. Use compat_symbol_reference. (_LIB_VERSION): Likewise. * math/test-matherr-2.c: New file. * math/test-matherr-3.c: Likewise. * sysdeps/generic/math_private.h (__kernel_standard): Remove declaration. (__kernel_standard_f): Likewise. (__kernel_standard_l): Likewise. * sysdeps/ieee754/s_lib_version.c: Do not include <math.h> or <math_private.h>. Include <math-svid-compat.h>. (_LIB_VERSION): Undefine as macro. (_LIB_VERSION_INTERNAL): Always initialize to _POSIX_. Define only if [LIBM_SVID_COMPAT || !defined SHARED]. If [LIBM_SVID_COMPAT], use compat_symbol. * sysdeps/ieee754/s_matherr.c: Do not include <math.h> or <math_private.h>. Include <math-svid-compat.h>. (matherr): Undefine as macro. (__matherr): Define only if [LIBM_SVID_COMPAT]. Use compat_symbol. * sysdeps/ia64/fpu/libm_error.c: Include <math-svid-compat.h>. [_LIBC && LIBM_SVID_COMPAT] (matherrf): Use compat_symbol_reference. [_LIBC && LIBM_SVID_COMPAT] (matherrl): Likewise. [_LIBC && !LIBM_SVID_COMPAT] (matherrf): Define as macro. [_LIBC && !LIBM_SVID_COMPAT] (matherrl): Likewise. * sysdeps/ia64/fpu/libm_support.h: Include <math-svid-compat.h>. (MATHERR_D): Remove declaration. [!_LIBC] (_LIB_VERSION_TYPE): Likewise [!LIBM_BUILD] (_LIB_VERSIONIMF): Likewise. [LIBM_BUILD] (pmatherrf): Likewise. [LIBM_BUILD] (pmatherr): Likewise. [LIBM_BUILD] (pmatherrl): Likewise. (DOMAIN): Likewise. (SING): Likewise. (OVERFLOW): Likewise. (UNDERFLOW): Likewise. (TLOSS): Likewise. (PLOSS): Likewise. * sysdeps/ia64/fpu/s_matherrf.c: Include <math-svid-compat.h>. (__matherrf): Define only if [LIBM_SVID_COMPAT]. Use compat_symbol. * sysdeps/ia64/fpu/s_matherrl.c: Include <math-svid-compat.h>. (__matherrl): Define only if [LIBM_SVID_COMPAT]. Use compat_symbol. * math/lgamma-compat.h: Include <math-svid-compat.h>. * math/w_acos_compat.c: Likewise. * math/w_acosf_compat.c: Likewise. * math/w_acosh_compat.c: Likewise. * math/w_acoshf_compat.c: Likewise. * math/w_acoshl_compat.c: Likewise. * math/w_acosl_compat.c: Likewise. * math/w_asin_compat.c: Likewise. * math/w_asinf_compat.c: Likewise. * math/w_asinl_compat.c: Likewise. * math/w_atan2_compat.c: Likewise. * math/w_atan2f_compat.c: Likewise. * math/w_atan2l_compat.c: Likewise. * math/w_atanh_compat.c: Likewise. * math/w_atanhf_compat.c: Likewise. * math/w_atanhl_compat.c: Likewise. * math/w_cosh_compat.c: Likewise. * math/w_coshf_compat.c: Likewise. * math/w_coshl_compat.c: Likewise. * math/w_exp10_compat.c: Likewise. * math/w_exp10f_compat.c: Likewise. * math/w_exp10l_compat.c: Likewise. * math/w_exp2_compat.c: Likewise. * math/w_exp2f_compat.c: Likewise. * math/w_exp2l_compat.c: Likewise. * math/w_fmod_compat.c: Likewise. * math/w_fmodf_compat.c: Likewise. * math/w_fmodl_compat.c: Likewise. * math/w_hypot_compat.c: Likewise. * math/w_hypotf_compat.c: Likewise. * math/w_hypotl_compat.c: Likewise. * math/w_j0_compat.c: Likewise. * math/w_j0f_compat.c: Likewise. * math/w_j0l_compat.c: Likewise. * math/w_j1_compat.c: Likewise. * math/w_j1f_compat.c: Likewise. * math/w_j1l_compat.c: Likewise. * math/w_jn_compat.c: Likewise. * math/w_jnf_compat.c: Likewise. * math/w_jnl_compat.c: Likewise. * math/w_lgamma_main.c: Likewise. * math/w_lgamma_r_compat.c: Likewise. * math/w_lgammaf_main.c: Likewise. * math/w_lgammaf_r_compat.c: Likewise. * math/w_lgammal_main.c: Likewise. * math/w_lgammal_r_compat.c: Likewise. * math/w_log10_compat.c: Likewise. * math/w_log10f_compat.c: Likewise. * math/w_log10l_compat.c: Likewise. * math/w_log2_compat.c: Likewise. * math/w_log2f_compat.c: Likewise. * math/w_log2l_compat.c: Likewise. * math/w_log_compat.c: Likewise. * math/w_logf_compat.c: Likewise. * math/w_logl_compat.c: Likewise. * math/w_pow_compat.c: Likewise. * math/w_powf_compat.c: Likewise. * math/w_powl_compat.c: Likewise. * math/w_remainder_compat.c: Likewise. * math/w_remainderf_compat.c: Likewise. * math/w_remainderl_compat.c: Likewise. * math/w_scalb_compat.c: Likewise. * math/w_scalbf_compat.c: Likewise. * math/w_scalbl_compat.c: Likewise. * math/w_sinh_compat.c: Likewise. * math/w_sinhf_compat.c: Likewise. * math/w_sinhl_compat.c: Likewise. * math/w_sqrt_compat.c: Likewise. * math/w_sqrtf_compat.c: Likewise. * math/w_sqrtl_compat.c: Likewise. * math/w_tgamma_compat.c: Likewise. * math/w_tgammaf_compat.c: Likewise. * math/w_tgammal_compat.c: Likewise. * sysdeps/ieee754/dbl-64/w_exp_compat.c: Likewise. * sysdeps/ieee754/flt-32/w_expf_compat.c: Likewise. * sysdeps/ieee754/k_standard.c: Likewise. * sysdeps/ieee754/k_standardf.c: Likewise. * sysdeps/ieee754/k_standardl.c: Likewise. * sysdeps/ieee754/ldbl-128/w_expl_compat.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/w_expl_compat.c: Likewise. * sysdeps/ieee754/ldbl-96/w_expl_compat.c: Likewise. * sysdeps/powerpc/powerpc32/power4/fpu/w_sqrt_compat.S: Likewise. * sysdeps/powerpc/powerpc32/power4/fpu/w_sqrtf_compat.S: Likewise. * sysdeps/powerpc/powerpc32/power5/fpu/w_sqrt_compat.S: Likewise. * sysdeps/powerpc/powerpc32/power5/fpu/w_sqrtf_compat.S: Likewise. * sysdeps/sparc/sparc32/fpu/w_sqrt_compat.S: Likewise. * sysdeps/sparc/sparc32/fpu/w_sqrtf_compat.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrt_compat-vis3.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrtf_compat-vis3.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/w_sqrt_compat.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/w_sqrtf_compat.S: Likewise. * sysdeps/sparc/sparc64/fpu/w_sqrt_compat.S: Likewise. * sysdeps/sparc/sparc64/fpu/w_sqrtf_compat.S: Likewise.
* Do not use __builtin_types_compatible_p in C++ mode (bug 21930)Gabriel F. T. Gomes2017-08-181-2/+6
| | | | | | | | | | | | | | | | | The logic to define isinf for float128 depends on the availability of __builtin_types_compatible_p, which is only available in C mode, however, the conditionals do not check for C or C++ mode. This lead to an error in libstdc++ configure, as reported by bug 21930. This patch adds a conditional for C mode in the definition of isinf for float128. No definition is provided in C++ mode, since libstdc++ headers undefine isinf. Tested for powerpc64le (glibc test suite and libstdc++-v3 configure). [BZ #21930] * math/math.h (isinf): Check if in C or C++ mode before using __builtin_types_compatible_p, since this is a C mode feature.
* Consistently use uintN_t not u_intN_t in libm.Joseph Myers2017-08-032-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch changes libm code to make consistent use of C99 uintN_t types instead of sometimes using those and sometimes using the older nonstandard u_intN_t names. This makes sense as a cleanup in its own right, and also facilitates merges to GCC's libquadmath (which gets the types from stdint.h and so may not have u_intN_t available at all). Tested for x86_64, and with build-many-glibcs.py. * math/s_nextafter.c (__nextafter): Use uintN_t instead of u_intN_t. * math/s_nexttowardf.c (__nexttowardf): Likewise. * sysdeps/generic/math_private.h (ieee_double_shape_type): Likewise. (ieee_float_shape_type): Likewise. * sysdeps/i386/fpu/s_fpclassifyl.c (__fpclassifyl): Likewise. * sysdeps/i386/fpu/s_isnanl.c (__isnanl): Likewise. * sysdeps/i386/fpu/s_nextafterl.c (__nextafterl): Likewise. * sysdeps/i386/fpu/s_nexttoward.c (__nexttoward): Likewise. * sysdeps/i386/fpu/s_nexttowardf.c (__nexttowardf): Likewise. * sysdeps/ieee754/dbl-64/e_acosh.c (__ieee754_acosh): Likewise. * sysdeps/ieee754/dbl-64/e_cosh.c (__ieee754_cosh): Likewise. * sysdeps/ieee754/dbl-64/e_fmod.c (__ieee754_fmod): Likewise. * sysdeps/ieee754/dbl-64/e_gamma_r.c (__ieee754_gamma_r): Likewise. * sysdeps/ieee754/dbl-64/e_hypot.c (__ieee754_hypot): Likewise. * sysdeps/ieee754/dbl-64/e_jn.c (__ieee754_jn): Likewise. (__ieee754_yn): Likewise. * sysdeps/ieee754/dbl-64/e_log10.c (__ieee754_log10): Likewise. * sysdeps/ieee754/dbl-64/e_log2.c (__ieee754_log2): Likewise. * sysdeps/ieee754/dbl-64/e_rem_pio2.c (__ieee754_rem_pio2): Likewise. * sysdeps/ieee754/dbl-64/e_sinh.c (__ieee754_sinh): Likewise. * sysdeps/ieee754/dbl-64/s_ceil.c (__ceil): Likewise. * sysdeps/ieee754/dbl-64/s_copysign.c (__copysign): Likewise. * sysdeps/ieee754/dbl-64/s_erf.c (__erf): Likewise. (__erfc): Likewise. * sysdeps/ieee754/dbl-64/s_expm1.c (__expm1): Likewise. * sysdeps/ieee754/dbl-64/s_finite.c (FINITE): Likewise. * sysdeps/ieee754/dbl-64/s_floor.c (__floor): Likewise. * sysdeps/ieee754/dbl-64/s_fpclassify.c (__fpclassify): Likewise. * sysdeps/ieee754/dbl-64/s_isnan.c (__isnan): Likewise. * sysdeps/ieee754/dbl-64/s_issignaling.c (__issignaling): Likewise. * sysdeps/ieee754/dbl-64/s_llrint.c (__llrint): Likewise. * sysdeps/ieee754/dbl-64/s_llround.c (__llround): Likewise. * sysdeps/ieee754/dbl-64/s_lrint.c (__lrint): Likewise. * sysdeps/ieee754/dbl-64/s_lround.c (__lround): Likewise. * sysdeps/ieee754/dbl-64/s_modf.c (__modf): Likewise. * sysdeps/ieee754/dbl-64/s_nextup.c (__nextup): Likewise. * sysdeps/ieee754/dbl-64/s_remquo.c (__remquo): Likewise. * sysdeps/ieee754/dbl-64/s_round.c (__round): Likewise. * sysdeps/ieee754/dbl-64/s_trunc.c (__trunc): Likewise. * sysdeps/ieee754/dbl-64/wordsize-64/s_issignaling.c (__issignaling): Likewise. * sysdeps/ieee754/flt-32/e_atan2f.c (__ieee754_atan2f): Likewise. * sysdeps/ieee754/flt-32/e_fmodf.c (__ieee754_fmodf): Likewise. * sysdeps/ieee754/flt-32/e_gammaf_r.c (__ieee754_gammaf_r): Likewise. * sysdeps/ieee754/flt-32/e_jnf.c (__ieee754_ynf): Likewise. * sysdeps/ieee754/flt-32/e_log10f.c (__ieee754_log10f): Likewise. * sysdeps/ieee754/flt-32/e_powf.c (__ieee754_powf): Likewise. * sysdeps/ieee754/flt-32/e_rem_pio2f.c (__ieee754_rem_pio2f): Likewise. * sysdeps/ieee754/flt-32/e_remainderf.c (__ieee754_remainderf): Likewise. * sysdeps/ieee754/flt-32/e_sqrtf.c (__ieee754_sqrtf): Likewise. * sysdeps/ieee754/flt-32/s_ceilf.c (__ceilf): Likewise. * sysdeps/ieee754/flt-32/s_copysignf.c (__copysignf): Likewise. * sysdeps/ieee754/flt-32/s_erff.c (__erff): Likewise. (__erfcf): Likewise. * sysdeps/ieee754/flt-32/s_expm1f.c (__expm1f): Likewise. * sysdeps/ieee754/flt-32/s_finitef.c (FINITEF): Likewise. * sysdeps/ieee754/flt-32/s_floorf.c (__floorf): Likewise. * sysdeps/ieee754/flt-32/s_fpclassifyf.c (__fpclassifyf): Likewise. * sysdeps/ieee754/flt-32/s_isnanf.c (__isnanf): Likewise. * sysdeps/ieee754/flt-32/s_issignalingf.c (__issignalingf): Likewise. * sysdeps/ieee754/flt-32/s_llrintf.c (__llrintf): Likewise. * sysdeps/ieee754/flt-32/s_llroundf.c (__llroundf): Likewise. * sysdeps/ieee754/flt-32/s_lrintf.c (__lrintf): Likewise. * sysdeps/ieee754/flt-32/s_lroundf.c (__lroundf): Likewise. * sysdeps/ieee754/flt-32/s_modff.c (__modff): Likewise. * sysdeps/ieee754/flt-32/s_remquof.c (__remquof): Likewise. * sysdeps/ieee754/flt-32/s_roundf.c (__roundf): Likewise. * sysdeps/ieee754/ldbl-128/e_acoshl.c (__ieee754_acoshl): Likewise. * sysdeps/ieee754/ldbl-128/e_atan2l.c (__ieee754_atan2l): Likewise. * sysdeps/ieee754/ldbl-128/e_atanhl.c (__ieee754_atanhl): Likewise. * sysdeps/ieee754/ldbl-128/e_fmodl.c (__ieee754_fmodl): Likewise. * sysdeps/ieee754/ldbl-128/e_gammal_r.c (__ieee754_gammal_r): Likewise. * sysdeps/ieee754/ldbl-128/e_hypotl.c (__ieee754_hypotl): Likewise. * sysdeps/ieee754/ldbl-128/e_jnl.c (__ieee754_jnl): Likewise. (__ieee754_ynl): Likewise. * sysdeps/ieee754/ldbl-128/e_powl.c (__ieee754_powl): Likewise. * sysdeps/ieee754/ldbl-128/e_rem_pio2l.c (__ieee754_rem_pio2l): Likewise. * sysdeps/ieee754/ldbl-128/e_remainderl.c (__ieee754_remainderl): Likewise. * sysdeps/ieee754/ldbl-128/e_sinhl.c (__ieee754_sinhl): Likewise. * sysdeps/ieee754/ldbl-128/k_cosl.c (__kernel_cosl): Likewise. * sysdeps/ieee754/ldbl-128/k_sincosl.c (__kernel_sincosl): Likewise. * sysdeps/ieee754/ldbl-128/k_sinl.c (__kernel_sinl): Likewise. * sysdeps/ieee754/ldbl-128/s_ceill.c (__ceill): Likewise. * sysdeps/ieee754/ldbl-128/s_copysignl.c (__copysignl): Likewise. * sysdeps/ieee754/ldbl-128/s_erfl.c (__erfcl): Likewise. * sysdeps/ieee754/ldbl-128/s_fabsl.c (__fabsl): Likewise. * sysdeps/ieee754/ldbl-128/s_finitel.c (__finitel): Likewise. * sysdeps/ieee754/ldbl-128/s_floorl.c (__floorl): Likewise. * sysdeps/ieee754/ldbl-128/s_fpclassifyl.c (__fpclassifyl): Likewise. * sysdeps/ieee754/ldbl-128/s_frexpl.c (__frexpl): Likewise. * sysdeps/ieee754/ldbl-128/s_isnanl.c (__isnanl): Likewise. * sysdeps/ieee754/ldbl-128/s_issignalingl.c (__issignalingl): Likewise. * sysdeps/ieee754/ldbl-128/s_llrintl.c (__llrintl): Likewise. * sysdeps/ieee754/ldbl-128/s_llroundl.c (__llroundl): Likewise. * sysdeps/ieee754/ldbl-128/s_lrintl.c (__lrintl): Likewise. * sysdeps/ieee754/ldbl-128/s_lroundl.c (__lroundl): Likewise. * sysdeps/ieee754/ldbl-128/s_modfl.c (__modfl): Likewise. * sysdeps/ieee754/ldbl-128/s_nearbyintl.c (__nearbyintl): Likewise. * sysdeps/ieee754/ldbl-128/s_nextafterl.c (__nextafterl): Likewise. * sysdeps/ieee754/ldbl-128/s_nexttoward.c (__nexttoward): Likewise. * sysdeps/ieee754/ldbl-128/s_nexttowardf.c (__nexttowardf): Likewise. * sysdeps/ieee754/ldbl-128/s_nextupl.c (__nextupl): Likewise. * sysdeps/ieee754/ldbl-128/s_remquol.c (__remquol): Likewise. * sysdeps/ieee754/ldbl-128/s_rintl.c (__rintl): Likewise. * sysdeps/ieee754/ldbl-128/s_roundl.c (__roundl): Likewise. * sysdeps/ieee754/ldbl-128/s_tanhl.c (__tanhl): Likewise. * sysdeps/ieee754/ldbl-128/s_truncl.c (__truncl): Likewise. * sysdeps/ieee754/ldbl-128ibm/e_fmodl.c (__ieee754_fmodl): Likewise. * sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c (__ieee754_gammal_r): Likewise. * sysdeps/ieee754/ldbl-128ibm/e_powl.c (__ieee754_powl): Likewise. * sysdeps/ieee754/ldbl-128ibm/e_rem_pio2l.c (__ieee754_rem_pio2l): Likewise. * sysdeps/ieee754/ldbl-128ibm/e_remainderl.c (__ieee754_remainderl): Likewise. * sysdeps/ieee754/ldbl-128ibm/k_cosl.c (__kernel_cosl): Likewise. * sysdeps/ieee754/ldbl-128ibm/k_sinl.c (__kernel_sinl): Likewise. * sysdeps/ieee754/ldbl-128ibm/s_fabsl.c (__fabsl): Likewise. * sysdeps/ieee754/ldbl-128ibm/s_fpclassifyl.c (___fpclassifyl): Likewise. * sysdeps/ieee754/ldbl-128ibm/s_modfl.c (__modfl): Likewise. * sysdeps/ieee754/ldbl-128ibm/s_nexttowardf.c (__nexttowardf): Likewise. * sysdeps/ieee754/ldbl-128ibm/s_remquol.c (__remquol): Likewise. * sysdeps/ieee754/ldbl-96/e_acoshl.c (__ieee754_acoshl): Likewise. * sysdeps/ieee754/ldbl-96/e_asinl.c (__ieee754_asinl): Likewise. * sysdeps/ieee754/ldbl-96/e_atanhl.c (__ieee754_atanhl): Likewise. * sysdeps/ieee754/ldbl-96/e_coshl.c (__ieee754_coshl): Likewise. * sysdeps/ieee754/ldbl-96/e_gammal_r.c (__ieee754_gammal_r): Likewise. * sysdeps/ieee754/ldbl-96/e_hypotl.c (__ieee754_hypotl): Likewise. * sysdeps/ieee754/ldbl-96/e_j0l.c (__ieee754_j0l): Likewise. (__ieee754_y0l): Likewise. (pzero): Likewise. (qzero): Likewise. * sysdeps/ieee754/ldbl-96/e_j1l.c (__ieee754_j1l): Likewise. (__ieee754_y1l): Likewise. (pone): Likewise. (qone): Likewise. * sysdeps/ieee754/ldbl-96/e_jnl.c (__ieee754_jnl): Likewise. (__ieee754_ynl): Likewise. * sysdeps/ieee754/ldbl-96/e_lgammal_r.c (sin_pi): Likewise. (__ieee754_lgammal_r): Likewise. * sysdeps/ieee754/ldbl-96/e_rem_pio2l.c (__ieee754_rem_pio2l): Likewise. * sysdeps/ieee754/ldbl-96/e_sinhl.c (__ieee754_sinhl): Likewise. * sysdeps/ieee754/ldbl-96/s_copysignl.c (__copysignl): Likewise. * sysdeps/ieee754/ldbl-96/s_erfl.c (__erfl): Likewise. (__erfcl): Likewise. * sysdeps/ieee754/ldbl-96/s_frexpl.c (__frexpl): Likewise. * sysdeps/ieee754/ldbl-96/s_issignalingl.c (__issignalingl): Likewise. * sysdeps/ieee754/ldbl-96/s_llrintl.c (__llrintl): Likewise. * sysdeps/ieee754/ldbl-96/s_llroundl.c (__llroundl): Likewise. * sysdeps/ieee754/ldbl-96/s_lrintl.c (__lrintl): Likewise. * sysdeps/ieee754/ldbl-96/s_lroundl.c (__lroundl): Likewise. * sysdeps/ieee754/ldbl-96/s_modfl.c (__modfl): Likewise. * sysdeps/ieee754/ldbl-96/s_nexttoward.c (__nexttoward): Likewise. * sysdeps/ieee754/ldbl-96/s_nexttowardf.c (__nexttowardf): Likewise. * sysdeps/ieee754/ldbl-96/s_nextupl.c (__nextupl): Likewise. * sysdeps/ieee754/ldbl-96/s_remquol.c (__remquol): Likewise. * sysdeps/ieee754/ldbl-96/s_roundl.c (__roundl): Likewise. * sysdeps/ieee754/ldbl-96/s_tanhl.c (__tanhl): Likewise. * sysdeps/ieee754/ldbl-opt/s_nexttowardfd.c (__nldbl_nexttowardf): Likewise. * sysdeps/m68k/m680x0/fpu/e_pow.c (s(__ieee754_pow)): Likewise. * sysdeps/m68k/m680x0/fpu/s_fpclassifyl.c (__fpclassifyl): Likewise. * sysdeps/m68k/m680x0/fpu/s_llrint.c (__llrint): Likewise. * sysdeps/m68k/m680x0/fpu/s_llrintf.c (__llrintf): Likewise. * sysdeps/m68k/m680x0/fpu/s_llrintl.c (__llrintl): Likewise. * sysdeps/m68k/m680x0/fpu/s_nextafterl.c (__nextafterl): Likewise. * sysdeps/x86/fpu/powl_helper.c (__powl_helper): Likewise.
* Fix tgmath.h for __int128 (bug 21686).Joseph Myers2017-08-022-13/+11
| | | | | | | | | | | | | | | | | | | | | | | | When a tgmath.h macro is passed a double argument and an argument of type __int128, it generates a call to a long double function (although the result still gets converted to type double). __int128 is similar enough to integer types that it should be handled consistently like them, so always like double for these macros rather than sometimes like double and sometimes like long double. This patch fixes the logic accordingly and makes gen-tgmath-tests.py generate tests for __int128. Tested for x86_64 and x86. [BZ #21686] * math/tgmath.h (__TGMATH_BINARY_REAL_ONLY): Add arguments before comparing size with that of double. (__TGMATH_BINARY_REAL_STD_ONLY): Likewise. (__TGMATH_BINARY_REAL_RET_ONLY): Likewise. (__TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY): Likewise. (__TGMATH_TERNARY_REAL_ONLY): Likewise. (__TGMATH_BINARY_REAL_IMAG): Likewise. * math/gen-tgmath-tests.py (Type.init_types): Create __int128 and unsigned __int128 types.
* Fix tgmath.h for bit-fields (bug 21685).Joseph Myers2017-08-022-60/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The tgmath.h macros produce errors for bit-field arguments, because they apply sizeof and typeof to the arguments. This patch fixes them to use unary + systematically before using sizeof or typeof on arguments that might be bit-fields (note that __real__ of a bit-field is still a bit-field for this purpose, since it's an lvalue). gen-tgmath-tests.py is extended to add tests for this case. Tested for x86_64. [BZ #21685] * math/tgmath.h (__tgmath_real_type): Use unary + on potentially bit-field expressions passed to sizeof or typeof. [__HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (__TGMATH_F128): Likewise. [__HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (__TGMATH_CF128): Likewise. (__TGMATH_UNARY_REAL_ONLY): Likewise. (__TGMATH_UNARY_REAL_RET_ONLY): Likewise. (__TGMATH_BINARY_FIRST_REAL_ONLY): Likewise. (__TGMATH_BINARY_FIRST_REAL_STD_ONLY): Likewise. (__TGMATH_BINARY_REAL_ONLY): Likewise. (__TGMATH_BINARY_REAL_STD_ONLY): Likewise. (__TGMATH_BINARY_REAL_RET_ONLY): Likewise. (__TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY): Likewise. (__TGMATH_TERNARY_REAL_ONLY): Likewise. (__TGMATH_TERNARY_FIRST_REAL_RET_ONLY): Likewise. (__TGMATH_UNARY_REAL_IMAG): Likewise. (__TGMATH_UNARY_IMAG): Likewise. (__TGMATH_UNARY_REAL_IMAG_RET_REAL): Likewise. (__TGMATH_BINARY_REAL_IMAG): Likewise. * math/gen-tgmath-tests.py (Type.init_types): Create bit_field type. (define_vars_for_type): Handle bit_field type specially. (Tests.__init__): Declare structure with bit-field element.
* Fix gen-tgmath-tests.py output for GCC 7 <float.h>.Joseph Myers2017-06-281-1/+2
| | | | | * math/gen-tgmath-tests.py (Tests.__init__): Define __STDC_WANT_IEC_60559_TYPES_EXT__ at start of generated file.
* Support _Float128 in tgmath.h.Joseph Myers2017-06-282-36/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds tgmath.h support for _Float128, so eliminating the awkward caveat in NEWS about the type not being supported there. This does inevitably increase the size of macro expansions (which grows particularly fast when you have nested calls to tgmath.h macros), but only when _Float128 is supported and the declarations of _Float128 interfaces are visible; otherwise the expansions are unchanged. Tested for x86_64 and arm. * math/tgmath.h: Include <bits/libc-header-start.h> and <bits/floatn.h>. (__TGMATH_F128): New macro. (__TGMATH_CF128): Likewise. (__TGMATH_UNARY_REAL_ONLY): Use __TGMATH_F128. (__TGMATH_UNARY_REAL_RET_ONLY): Likewise. (__TGMATH_BINARY_FIRST_REAL_ONLY): Likewise. (__TGMATH_BINARY_FIRST_REAL_STD_ONLY): New macro. (__TGMATH_BINARY_REAL_ONLY): Use __TGMATH_F128. (__TGMATH_BINARY_REAL_STD_ONLY): New macro. (__TGMATH_BINARY_REAL_RET_ONLY): Use __TGMATH_F128. (__TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY): Likewise. (__TGMATH_TERNARY_REAL_ONLY): Likewise. (__TGMATH_TERNARY_FIRST_REAL_RET_ONLY): Likewise. (__TGMATH_UNARY_REAL_IMAG): Use __TGMATH_CF128. (__TGMATH_UNARY_IMAG): Use __TGMATH_F128. (__TGMATH_UNARY_REAL_IMAG_RET_REAL): Use __TGMATH_CF128. (__TGMATH_BINARY_REAL_IMAG): Likewise. (nexttoward): Use __TGMATH_BINARY_FIRST_REAL_STD_ONLY. [__USE_MISC] (scalb): Use __TGMATH_BINARY_REAL_STD_ONLY. * math/gen-tgmath-tests.py (Type.init_types): Enable _FloatN and _FloatNx types if the corresponding HUGE_VAL macros are defined.
* Use clog10 not __clog10 in tgmath.h log10 macro.Joseph Myers2017-06-282-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | As a GNU extension, for _GNU_SOURCE glibc's complex.h provides a clog10 function and tgmath.h supports complex arguments to the log10 macro. However, tgmath.h uses __clog10 not clog10 in defining the macro. There is no namespace reason (ignoring the block-scope namespace issues that would apply equally to *every* function called by tgmath.h macros) for using __clog10 here, since this is only for _GNU_SOURCE so clog10 is always visible when this macro definition is used. Furthermore, __clog10f128 is not exported, so supporting _Float128 in tgmath.h implies using clog10 not __clog10 there. (__clog10 and clog10 aren't used in libstdc++ either, although that library would have a good case for using the __clog10 reserved-namespace export: the standard C++ library includes log10 of a complex number.) This patch duly changes the header to use clog10, and enables tests of the macro for complex arguments. Tested for x86_64. * math/tgmath.h [__USE_GNU] (log10): Use clog10 not __clog10. * math/gen-tgmath-tests.py (Tests.add_all_tests): Test log10 for complex arguments.
* Fix tgmath.h totalorder, totalordermag return type (bug 21687).Joseph Myers2017-06-283-9/+21
| | | | | | | | | | | | | | | | | | | The tgmath.h totalorder and totalordermag macros wrongly return a floating-point type. They should return int, like the underlying functions. This patch fixes them accordingly, updating tests including enabling tests of those functions from gen-tgmath-tests.py. Tested for x86_64. [BZ #21687] * math/tgmath.h (__TGMATH_BINARY_REAL_RET_ONLY): New macro. (totalorder): Use it. (totalordermag): Likewise. * math/gen-tgmath-tests.py (Tests.add_all_tests): Enable tests of totalorder and totalordermag. * math/test-tgmath.c (F(compile_test)): Do not call totalorder or totalordermag in arguments of calls to those functions. (NCALLS): Change to 134.
* Simplify tgmath.h for integer return types.Joseph Myers2017-06-281-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | The tgmath.h macros for function with integer return types generate unnecessary casts to the return type. Since in those cases the return type does not depend on the argument type, all the cases in the conditional expressions already have the right type, and no casts are needed; this patch removes them. Tested for x86_64. * math/tgmath.h (__TGMATH_UNARY_REAL_RET_ONLY): Do not take or cast to return type argument. (__TGMATH_TERNARY_FIRST_REAL_RET_ONLY): Likewise. (lrint): Update call to __TGMATH_UNARY_REAL_RET_ONLY. (llrint): Likewise. (lround): Likewise. (llround): Likewise. (ilogb): Likewise. (llogb): Likewise. (fromfp): Update call to __TGMATH_TERNARY_FIRST_REAL_RET_ONLY. (ufromfp): Likewise. (fromfpx): Likewise. (ufromfpx): Likewise.
* Remove NO_LONG_DOUBLE conditionals in libm tests (bug 21607).Joseph Myers2017-06-2817-48/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As noted in bug 21607, NO_LONG_DOUBLE conditionals in libm tests are no longer effective. For most this is harmless - they were only present because of long double functions not being declared with _LIBC defined, and _LIBC is no longer defined for building most tests. For the few where this is actually relevant to the test, testing LDBL_MANT_DIG > DBL_MANT_DIG is more appropriate as that limits the test to public APIs. This patch fixes the tests accordingly. Tested for x86_64 and arm. [BZ #21607] * math/basic-test.c [!NO_LONG_DOUBLE]: Change conditionals to [LDBL_MANT_DIG > DBL_MANT_DIG]. * math/bug-nextafter.c [!NO_LONG_DOUBLE]: Remove conditionals. * math/bug-nexttoward.c [!NO_LONG_DOUBLE]: Likewise. * math/test-math-isinff.cc [!NO_LONG_DOUBLE]: Likewise. * math/test-math-iszero.cc [!NO_LONG_DOUBLE]: Likewise. * math/test-nan-overflow.c [!NO_LONG_DOUBLE]: Likewise. * math/test-nan-payload.c [!NO_LONG_DOUBLE]: Likewise. * math/test-nearbyint-except-2.c [!NO_LONG_DOUBLE]: Likewise. * math/test-nearbyint-except.c [!NO_LONG_DOUBLE]: Likewise. * math/test-powl.c [!NO_LONG_DOUBLE]: Likewise. * math/test-signgam-finite-c99.c [!NO_LONG_DOUBLE]: Likewise. * math/test-signgam-finite.c [!NO_LONG_DOUBLE]: Likewise. * math/test-signgam-main.c [!NO_LONG_DOUBLE]: Likewise. * math/test-snan.c [!NO_LONG_DOUBLE]: Likewise. * math/test-tgmath-ret.c [!NO_LONG_DOUBLE]: Likewise. * math/test-tgmath.c: Include <float.h>. [!NO_LONG_DOUBLE]: Change conditionals to [LDBL_MANT_DIG > DBL_MANT_DIG]. * math/test-tgmath2.c: Include <float.h>. [!NO_LONG_DOUBLE]: Change conditionals to [LDBL_MANT_DIG > DBL_MANT_DIG].
* Add more thorough generated tgmath.h test.Joseph Myers2017-06-282-0/+617
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds a more thorough test of tgmath.h macros, verifying both the return type and the function called for all the cases of valid argument types. (Cases with current problems - I've just filed four bugs - are disabled or omitted pending fixing those problems.) The test uses a Python generator (works with both Python 2 and 3) to generate a C file which is then built and run as a test in the usual way (and that C file includes its own dummy definitions of libm functions similar to existing tgmath.h tests). The motivation is to make it easier to add tests of tgmath.h for _Float128 when adding tgmath.h support for that type; the _FloatN / _FloatNx support is present in the script, but disabled until the tgmath.h support is written. Tested for x86_64, and for arm to check things in the long double = double case. (In that case, it's OK to call either double or long double functions when the selected type is double or long double, as long as the return type of the macro is exactly correct.) * math/gen-tgmath-tests.py: New file. * math/Makefile [PYTHON] (tests): Add test-tgmath3. [PYTHON] (generated): Add test-tgmath3.c. [PYTHON] (CFLAGS-test-tgmath3.c): New variable. [PYTHON] ($(objpfx)test-tgmath3.c): New rule.
* Add float128 support for ia64.Joseph Myers2017-06-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch enables float128 support for ia64, so that all the configurations where GCC supports _Float128 / __float128 as an ABI-distinct type now have glibc support as well. bits/floatn.h declares the support to be available for GCC 4.4 and later, which is when the libgcc support was added. The removal of sysdeps/ia64/fpu/k_rem_pio2.c is because the generic k_rem_pio2.c defines a function required by the float128 code. Tested (compilation only) with build-many-glibcs.py for ia64 (GCC 6 and GCC 7). Given how long it is since libm-test-ulps has been updated for ia64, I think truncating the file and regenerating it from scratch would be a good idea when doing a regeneration to add float128 ulps. I expect various ia64 libm issues (at least some already filed in Bugzilla) to result in test failures even after ulps regeneration, but hopefully the float128 code will pass tests as it's the same as used on other architectures. * sysdeps/ia64/Implies: Add ieee754/float128. * sysdeps/ia64/bits/floatn.h: New file. * sysdeps/ia64/float128-abi.h: Likewise. * manual/math.texi (Mathematics): Document support for _Float128 on ia64. * sysdeps/ia64/Makefile [$(subdir) = math] (CPPFLAGS): Append to Makefile variable. * sysdeps/ia64/fpu/e_sqrtf128.c: New file. * sysdeps/ia64/fpu/k_rem_pio2.c: Remove file. * sysdeps/ia64/fpu/sfp-machine.h: New file. Based on libgcc. * sysdeps/ia64/math-tests.h: New file. * math/libm-test-support.h (XFAIL_FLOAT128_PAYLOAD): Also define based on TEST_COND_binary128 for [__ia64__]. * sysdeps/unix/sysv/linux/ia64/libc.abilist: Update. * sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise,
* Add float128 support for x86_64, x86.Joseph Myers2017-06-265-65/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch enables float128 support for x86_64 and x86. All GCC versions that can build glibc provide the required support, but since GCC 6 and before don't provide __builtin_nanq / __builtin_nansq, sNaN tests and some tests of NaN payloads need to be disabled with such compilers (this does not affect the generated glibc binaries at all, just the tests). bits/floatn.h declares float128 support to be available for GCC versions that provide the required libgcc support (4.3 for x86_64, 4.4 for i386 GNU/Linux, 4.5 for i386 GNU/Hurd); compilation-only support was present some time before then, but not really useful without the libgcc functions. fenv_private.h needed updating to avoid trying to put _Float128 values in registers. I make no assertion of optimality of the math_opt_barrier / math_force_eval definitions for this case; they are simply intended to be sufficient to work correctly. Tested for x86_64 and x86, with GCC 7 and GCC 6. (Testing for x32 was compilation tests only with build-many-glibcs.py to verify the ABI baseline updates. I have not done any testing for Hurd, although the float128 support is enabled there as for GNU/Linux.) * sysdeps/i386/Implies: Add ieee754/float128. * sysdeps/x86_64/Implies: Likewise. * sysdeps/x86/bits/floatn.h: New file. * sysdeps/x86/float128-abi.h: Likewise. * manual/math.texi (Mathematics): Document support for _Float128 on x86_64 and x86. * sysdeps/i386/fpu/fenv_private.h: Include <bits/floatn.h>. (math_opt_barrier): Do not put _Float128 values in floating-point registers. (math_force_eval): Likewise. [__x86_64__] (SET_RESTORE_ROUNDF128): New macro. * sysdeps/x86/fpu/Makefile [$(subdir) = math] (CPPFLAGS): Append to Makefile variable. * sysdeps/x86/fpu/e_sqrtf128.c: New file. * sysdeps/x86/fpu/sfp-machine.h: Likewise. Based on libgcc. * sysdeps/x86/math-tests.h: New file. * math/libm-test-support.h (XFAIL_FLOAT128_PAYLOAD): New macro. * math/libm-test-getpayload.inc (getpayload_test_data): Use XFAIL_FLOAT128_PAYLOAD. * math/libm-test-setpayload.inc (setpayload_test_data): Likewise. * math/libm-test-totalorder.inc (totalorder_test_data): Likewise. * math/libm-test-totalordermag.inc (totalordermag_test_data): Likewise. * sysdeps/unix/sysv/linux/i386/libc.abilist: Update. * sysdeps/unix/sysv/linux/i386/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. * sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
* Make libm-test-support code clear exceptions after each test.Joseph Myers2017-06-231-0/+7
| | | | | | | | | | | | | | | | | | | | | | | The libm-test-support code clears exceptions at the end of test_exceptions. However, it's possible that exceptions get raised as part of the subsequent checks on the results of the function being tested, and such exceptions then carry through to the next test run and can cause that to fail spuriously. In particular, it's possible for the ulps calculation to raise exceptions in some cases. This patch puts exception clearing at the end of each of the check_* functions, alongside errno clearing, to avoid one test affecting the next in that way. Tested for x86_64 (in conjunction with float128 patches). * libm-test-support.c (check_float_internal): Clear exceptions at end of function. (check_int): Likewise. (check_long): Likewise. (check_bool): Likewise. (check_longlong): Likewise. (check_intmax_t): Likewise. (check_uintmax_t): Likewise.
* Make errno-setting libm templates include errno.h.Joseph Myers2017-06-2223-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Various type-generic libm wrapper templates, as used for float128, set errno but do not include errno.h. I presume they must get an implicit include from some internal header on powerpc64le; they don't get such an implicit include on x86_64. This patch adds the missing includes of errno.h to each such wrapper. Tested for x86_64 (in conjunction with float128 patches). * math/w_acos_template.c [__USE_WRAPPER_TEMPLATE]: Include <errno.h>. * math/w_acosh_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_asin_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_atanh_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_cosh_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_exp10_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_exp2_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_exp_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_fmod_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_hypot_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_j0_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_j1_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_jn_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_lgamma_r_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_lgamma_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_log10_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_log2_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_log_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_pow_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_remainder_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_sinh_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_sqrt_template.c [__USE_WRAPPER_TEMPLATE]: Likewise. * math/w_tgamma_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* float128: Add test-{float128,ifloat128,float128-finite}Paul E. Murphy2017-06-1215-5/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | This adds test support for float128, and lays some groundwork for future _FloatN types. * math/gen-libm-test.pl (@all_floats): Add ifloat128 and float128. (%all_floats_pfx): Add macro prefix for float128 (FLT128). * math/libm-test-exp10.inc (pow10_test): Do not test for _FloatN, * math/libm-test-isfinite.inc (finite_test): Likewise. * math/libm-test-lgamma.inc (gamma_test): Likewise. * math/libm-test-nexttoward.inc (nexttoward_test): Likewise. (nexttoward_test_data}: Likewise. * math/libm-test-remainder.inc (drem_test): Likewise. * math/libm-test-scalb.inc (scalb_test): Likewise. (scalb_test_data): Likewise. * math/libm-test-significand.inc (significand_test): Likewise. (significand_test_data): Likewise. * math/libm-test-support.c (check_complex): Replace __complex__ FLOAT with CFLOAT to get the support for old compiler. * math/libm-test-support.h (check_complex): Likewise. * math/test-double.h (CFLOAT, TEST_FLOATN): New macros. * math/test-float.h (CFLOAT, TEST_FLOATN): Likewise. * math/test-ldouble.h (CFLOAT, TEST_FLOATN): Likewise. * math/test-float128.h: New file. * math/test-math-floatn.h: New file.
* float128: Add wrappers to override ldbl-128 as float128.Paul E. Murphy2017-05-254-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change defines float128_private.h which contains macros used to override long double naming conventions when building a ldbl file. * math/math.h [__HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (SNANF128): New macro. * math/e_sqrtf128.c: New file. * math/s_fmaxmag_template.c: Include math_private.h in order to make inline expansion of fabs128(). * math/s_fminmag_template.c: Likewise. * sysdeps/ieee754/float128/e_acosf128.c: New file. * sysdeps/ieee754/float128/e_acoshf128.c: New file. * sysdeps/ieee754/float128/e_asinf128.c: New file. * sysdeps/ieee754/float128/e_atan2f128.c: New file. * sysdeps/ieee754/float128/e_atanhf128.c: New file. * sysdeps/ieee754/float128/e_coshf128.c: New file. * sysdeps/ieee754/float128/e_exp10f128.c: New file. * sysdeps/ieee754/float128/e_expf128.c: New file. * sysdeps/ieee754/float128/e_fmodf128.c: New file. * sysdeps/ieee754/float128/e_gammaf128_r.c: New file. * sysdeps/ieee754/float128/e_hypotf128.c: New file. * sysdeps/ieee754/float128/e_ilogbf128.c: New file. * sysdeps/ieee754/float128/e_j0f128.c: New file. * sysdeps/ieee754/float128/e_j1f128.c: New file. * sysdeps/ieee754/float128/e_jnf128.c: New file. * sysdeps/ieee754/float128/e_lgammaf128_r.c: New file. * sysdeps/ieee754/float128/e_log10f128.c: New file. * sysdeps/ieee754/float128/e_log2f128.c: New file. * sysdeps/ieee754/float128/e_logf128.c: New file. * sysdeps/ieee754/float128/e_powf128.c: New file. * sysdeps/ieee754/float128/e_rem_pio2f128.c: New file. * sysdeps/ieee754/float128/e_remainderf128.c: New file. * sysdeps/ieee754/float128/e_scalbf128.c: New file. * sysdeps/ieee754/float128/e_sinhf128.c: New file. * sysdeps/ieee754/float128/float128_private.h: New file. * sysdeps/ieee754/float128/gamma_productf128.c: New file. * sysdeps/ieee754/float128/ieee754_float128.h: New file. * sysdeps/ieee754/float128/k_cosf128.c: New file. * sysdeps/ieee754/float128/k_sincosf128.c: New file. * sysdeps/ieee754/float128/k_sinf128.c: New file. * sysdeps/ieee754/float128/k_tanf128.c: New file. * sysdeps/ieee754/float128/lgamma_negf128.c: New file. * sysdeps/ieee754/float128/lgamma_productf128.c: New file. * sysdeps/ieee754/float128/s_asinhf128.c: New file. * sysdeps/ieee754/float128/s_atanf128.c: New file. * sysdeps/ieee754/float128/s_cbrtf128.c: New file. * sysdeps/ieee754/float128/s_ceilf128.c: New file. * sysdeps/ieee754/float128/s_copysignf128.c: New file. * sysdeps/ieee754/float128/s_cosf128.c: New file. * sysdeps/ieee754/float128/s_erff128.c: New file. * sysdeps/ieee754/float128/s_expm1f128.c: New file. * sysdeps/ieee754/float128/s_fabsf128.c: New file. * sysdeps/ieee754/float128/s_finitef128.c: New file. * sysdeps/ieee754/float128/s_floorf128.c: New file. * sysdeps/ieee754/float128/s_fmaf128.c: New file. * sysdeps/ieee754/float128/s_fpclassifyf128.c: New file. * sysdeps/ieee754/float128/s_frexpf128.c: New file. * sysdeps/ieee754/float128/s_fromfpf128.c: New file. * sysdeps/ieee754/float128/s_fromfpxf128.c: New file. * sysdeps/ieee754/float128/s_getpayloadf128.c: New file. * sysdeps/ieee754/float128/s_isinff128.c: New file. * sysdeps/ieee754/float128/s_isnanf128.c: New file. * sysdeps/ieee754/float128/s_issignalingf128.c: New file. * sysdeps/ieee754/float128/s_llrintf128.c: New file. * sysdeps/ieee754/float128/s_llroundf128.c: New file. * sysdeps/ieee754/float128/s_log1pf128.c: New file. * sysdeps/ieee754/float128/s_logbf128.c: New file. * sysdeps/ieee754/float128/s_lrintf128.c: New file. * sysdeps/ieee754/float128/s_lroundf128.c: New file. * sysdeps/ieee754/float128/s_modff128.c: New file. * sysdeps/ieee754/float128/s_nearbyintf128.c: New file. * sysdeps/ieee754/float128/s_nextafterf128.c: New file. * sysdeps/ieee754/float128/s_nexttowardf128.c: New file. * sysdeps/ieee754/float128/s_nextupf128.c: New file. * sysdeps/ieee754/float128/s_remquof128.c: New file. * sysdeps/ieee754/float128/s_rintf128.c: New file. * sysdeps/ieee754/float128/s_roundevenf128.c: New file. * sysdeps/ieee754/float128/s_roundf128.c: New file. * sysdeps/ieee754/float128/s_scalblnf128.c: New file. * sysdeps/ieee754/float128/s_scalbnf128.c: New file. * sysdeps/ieee754/float128/s_setpayloadf128.c: New file. * sysdeps/ieee754/float128/s_setpayloadsigf128.c: New file. * sysdeps/ieee754/float128/s_signbitf128.c: New file. * sysdeps/ieee754/float128/s_significandf128.c: New file. * sysdeps/ieee754/float128/s_sincosf128.c: New file. * sysdeps/ieee754/float128/s_sinf128.c: New file. * sysdeps/ieee754/float128/s_tanf128.c: New file. * sysdeps/ieee754/float128/s_tanhf128.c: New file. * sysdeps/ieee754/float128/s_totalorderf128.c: New file. * sysdeps/ieee754/float128/s_totalordermagf128.c: New file. * sysdeps/ieee754/float128/s_truncf128.c: New file. * sysdeps/ieee754/float128/s_ufromfpf128.c: New file. * sysdeps/ieee754/float128/s_ufromfpxf128.c: New file. * sysdeps/ieee754/float128/t_sincosf128.c: New file. * sysdeps/ieee754/float128/x2y2m1f128.c: New file. * sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h: (__iscanonicalf128): Define as a macro.
* float128: Extend __MATH_TG for float128 supportGabriel F. T. Gomes2017-05-171-0/+21
| | | | | | * math/math.h (__MATH_TG): Extend the conditions to add _Float128 support. * misc/sys/cdefs.h (__HAVE_GENERIC_SELECTION): New macro.
* Convert e_exp2l.c into a templateGabriel F. T. Gomes2017-05-172-22/+21
| | | | | | | | | | | | | | | | | | This patch converts the implementation of exp2l in math/e_exp2l.c into a template in math/e_exp2_template.c, then adjusts Makefile to use this template for long double (the implementations for float and double in sysdeps have higher precedence and are not used). This template can also be used for float128, thus reducing the amount of duplicated code that gets added when adding support the new type. Tested for powerpc64le and s390x. * math/Makefile (libm-calls): Move e_exp2F to gen-libm-calls. (gen-libm-calls): Add e_exp2F to use the template. * math/e_exp2l.c: Rename to math/e_exp2_template.c. * math/e_exp2_template.c: New file, renamed from math/e_exp2l.c, and made into a template. * sysdeps/generic/math-type-macros.h (M_MIN_EXP): New macro.
* float128: Include math-finite.h for _Float128Gabriel F. T. Gomes2017-05-152-5/+30
| | | | | | | | | | | | | All the declarations in math-finite.h are macroized by floating-point type. This patch includes it for float128 and protects the declarations of functions that need not be declared for float128. * math/math.h: Include bits/math-finite.h for float128. (__MATH_DECLARING_FLOATN): Define to control declaration of float128 functions. * math/bits/math-finite.h (pow10): Do not declare for float128. (gamma): Likewise. (scalb): Likewise.
* float128: Add public _Float128 declarations to libm.Paul E. Murphy2017-05-155-18/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces the machine-dependent bits/floatn.h to control the inclusion of _Float128 ABI. * bits/floatn.h: New file. * bits/huge_val_flt128.h: Likewise. * bits/libm-simd-decl-stubs.h (__DECL_SIMD_cosf128): New macro. (__DECL_SIMD_sinf128): Likewise. (__DECL_SIMD_sincosf128): Likewise. (__DECL_SIMD_logf128): Likewise. (__DECL_SIMD_expf128): Likewise. (__DECL_SIMD_powf128): Likewise. * math/Makefile (headers): Install bits/floatn.h and bits/huge_val_flt128.h. * math/bits/cmathcalls.h (_Mdouble_complex_): Only define if not defined. * math/bits/mathcalls.h (pow10, isinf, finite, drem, significand) (isnan, gamma, nexttoward, scalb): Only define if not __MATH_DECLARING_FLOATN. (nextdown, nextup, llogb, roundeven, fromfp, ufromfp, fromfpx) (ufromfpx, fmaxmag, fminmag, totalorder, totalordermag) (canonicalize, getpayload, setpayload, setpayloadsig): Declare for _FloatN even if __STDC_WANT_IEC_60559_BFP_EXT__ is not defined. * math/complex.h: Include bits/libc-header-start.h and bits/floatn.h. Include bits/cmathcalls.h to get the declarations of _Float128 versions of complex functions. [__HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (CMPLXF128): Define macro. * math/math.h: Include bits/floatn.h and bits/huge_val_flt128.h. Include bits/mathcalls-helper-functions.h and bits/mathcalls.h to get the declarations of _Float128 versions of math functions. (__MATH_DECLARING_FLOATN): New macro to control declaration of _FloatN types. [__GNUC_PREREQ (6,0)] (signbit): Since GCC 6.0, __builtin_signbit is type-generic, so use it without __MATH_TG. [__HAVE_DISTINCT_FLOAT128] (isinf): This builtin is broken for _Float128 type on GCC < 7.0. Explicitly call __isinff128 for _Float128 type and GCC < 7.0, otherwise use the builtin. [__HAVE_FLOAT128 && defined __USE_GNU] (M_Ef128, M_LOG2Ef128) (M_LOG10Ef128, M_LN2f128, M_LN10f128, M_PIf128, M_PI_2f128) (M_PI_4f128, M_1_PIf128, M_2_PIf128, M_SQRT2f128, M_SQRT1_2f128): New _GNU_SOURCE enabled macros.
* Suppress internal declarations for most of the testsuite.Zack Weinberg2017-05-112-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds a new build module called 'testsuite'. IS_IN (testsuite) implies _ISOMAC, as do IS_IN_build and __cplusplus (which means several ad-hoc tests for __cplusplus can go away). libc-symbols.h now suppresses almost all of *itself* when _ISOMAC is defined; in particular, _ISOMAC mode does not get config.h automatically anymore. There are still quite a few tests that need to see internal gunk of one variety or another. For them, we now have 'tests-internal' and 'test-internal-extras'; files in this category will still be compiled with MODULE_NAME=nonlib, and everything proceeds as it always has. The bulk of this patch is moving tests from 'tests' to 'tests-internal'. There is also 'tests-static-internal', which has the same effect on files in 'tests-static', and 'modules-names-tests', which has the *inverse* effect on files in 'modules-names' (it's inverted because most of the things in modules-names are *not* tests). For both of these, the file must appear in *both* the new variable and the old one. There is also now a special case for when libc-symbols.h is included without MODULE_NAME being defined at all. (This happens during the creation of libc-modules.h, and also when preprocessing Versions files.) When this happens, IS_IN is set to be always false and _ISOMAC is *not* defined, which was the status quo, but now it's explicit. The remaining changes to C source files in this patch seemed likely to cause problems in the absence of the main change. They should be relatively self-explanatory. In a few cases I duplicated a definition from an internal header rather than move the test to tests-internal; this was a judgement call each time and I'm happy to change those however reviewers feel is more appropriate. * Makerules: New subdir configuration variables 'tests-internal' and 'test-internal-extras'. Test files in these categories will still be compiled with MODULE_NAME=nonlib. Test files in the existing categories (tests, xtests, test-srcs, test-extras) are now compiled with MODULE_NAME=testsuite. New subdir configuration variable 'modules-names-tests'. Files which are in both 'modules-names' and 'modules-names-tests' will be compiled with MODULE_NAME=testsuite instead of MODULE_NAME=extramodules. (gen-as-const-headers): Move to tests-internal. (do-tests-clean, common-mostlyclean): Support tests-internal. * Makeconfig (built-modules): Add testsuite. * Makefile: Change libof-check-installed-headers-c and libof-check-installed-headers-cxx to 'testsuite'. * Rules: Likewise. Support tests-internal. * benchtests/strcoll-inputs/filelist#en_US.UTF-8: Remove extra-modules.mk. * config.h.in: Don't check for __OPTIMIZE__ or __FAST_MATH__ here. * include/libc-symbols.h: Move definitions of _GNU_SOURCE, PASTE_NAME, PASTE_NAME1, IN_MODULE, IS_IN, and IS_IN_LIB to the very top of the file and rationalize their order. If MODULE_NAME is not defined at all, define IS_IN to always be false, and don't define _ISOMAC. If any of IS_IN (testsuite), IS_IN_build, or __cplusplus are true, define _ISOMAC and suppress everything else in this file, starting with the inclusion of config.h. Do check for inappropriate definitions of __OPTIMIZE__ and __FAST_MATH__ here, but only if _ISOMAC is not defined. Correct some out-of-date commentary. * include/math.h: If _ISOMAC is defined, undefine NO_LONG_DOUBLE and _Mlong_double_ before including math.h. * include/string.h: If _ISOMAC is defined, don't expose _STRING_ARCH_unaligned. Move a comment to a more appropriate location. * include/errno.h, include/stdio.h, include/stdlib.h, include/string.h * include/time.h, include/unistd.h, include/wchar.h: No need to check __cplusplus nor use __BEGIN_DECLS/__END_DECLS. * misc/sys/cdefs.h (__NTHNL): New macro. * sysdeps/m68k/m680x0/fpu/bits/mathinline.h (__m81_defun): Use __NTHNL to avoid errors with GCC 6. * elf/tst-env-setuid-tunables.c: Include config.h with _LIBC defined, for HAVE_TUNABLES. * inet/tst-checks-posix.c: No need to define _ISOMAC. * intl/tst-gettext2.c: Provide own definition of N_. * math/test-signgam-finite-c99.c: No need to define _ISOMAC. * math/test-signgam-main.c: No need to define _ISOMAC. * stdlib/tst-strtod.c: Convert to test-driver. Split locale_test to... * stdlib/tst-strtod1i.c: ...this new file. * stdlib/tst-strtod5.c: Convert to test-driver and add copyright notice. Split tests of __strtod_internal to... * stdlib/tst-strtod5i.c: ...this new file. * string/test-string.h: Include stdint.h. Duplicate definition of inhibit_loop_to_libcall here (from libc-symbols.h). * string/test-strstr.c: Provide dummy definition of libc_hidden_builtin_def when including strstr.c. * sysdeps/ia64/fpu/libm-symbols.h: Suppress entire file in _ISOMAC mode; no need to test __STRICT_ANSI__ nor __cplusplus as well. * sysdeps/x86_64/fpu/math-tests-arch.h: Include cpu-features.h. Don't include init-arch.h. * sysdeps/x86_64/multiarch/test-multiarch.h: Include cpu-features.h. Don't include init-arch.h. * elf/Makefile: Move tst-ptrguard1-static, tst-stackguard1-static, tst-tls1-static, tst-tls2-static, tst-tls3-static, loadtest, unload, unload2, circleload1, neededtest, neededtest2, neededtest3, neededtest4, tst-tls1, tst-tls2, tst-tls3, tst-tls6, tst-tls7, tst-tls8, tst-dlmopen2, tst-ptrguard1, tst-stackguard1, tst-_dl_addr_inside_object, and all of the ifunc tests to tests-internal. Don't add $(modules-names) to test-extras. * inet/Makefile: Move tst-inet6_scopeid_pton to tests-internal. Add tst-deadline to tests-static-internal. * malloc/Makefile: Move tst-mallocstate and tst-scratch_buffer to tests-internal. * misc/Makefile: Move tst-atomic and tst-atomic-long to tests-internal. * nptl/Makefile: Move tst-typesizes, tst-rwlock19, tst-sem11, tst-sem12, tst-sem13, tst-barrier5, tst-signal7, tst-tls3, tst-tls3-malloc, tst-tls5, tst-stackguard1, tst-sem11-static, tst-sem12-static, and tst-stackguard1-static to tests-internal. Link tests-internal with libpthread also. Don't add $(modules-names) to test-extras. * nss/Makefile: Move tst-field to tests-internal. * posix/Makefile: Move bug-regex5, bug-regex20, bug-regex33, tst-rfc3484, tst-rfc3484-2, and tst-rfc3484-3 to tests-internal. * stdlib/Makefile: Move tst-strtod1i, tst-strtod3, tst-strtod4, tst-strtod5i, tst-tls-atexit, and tst-tls-atexit-nodelete to tests-internal. * sunrpc/Makefile: Move tst-svc_register to tests-internal. * sysdeps/powerpc/Makefile: Move test-get_hwcap and test-get_hwcap-static to tests-internal. * sysdeps/unix/sysv/linux/Makefile: Move tst-setgetname to tests-internal. * sysdeps/x86_64/fpu/Makefile: Add all libmvec test modules to modules-names-tests.
* float128: Add _Float128 make bits to libm.Paul E. Murphy2017-05-091-2/+14
| | | | | | | | | | | | | | | | | This adds the appropriate common bits for a platform to enable float128 and expose ABI. * math/Makefile: (type-float128-suffix): New variable (type-float128-routines): Likewise (type-float128-yes): Likewise (types): Append float128 if supported (types-basic): New variable to control the use of templates for float, double, and long double, but not for float128 or newer types. (type-basic-foreach): Likewise. * sysdeps/ieee754/float128/Makeconfig: New file. * sysdeps/ieee754/float128/Versions: New file.
* Fix condition for inclusion of math-finite.h for long doubleGabriel F. T. Gomes2017-03-312-2/+2
| | | | | | | | | | The condition for declaration of long double functions in math-finite.h was #ifdef __MATH_DECLARE_LDOUBLE before the macroization of this file. After the macroization, it was incorreclty changed to #if __MATH_DECLARE_LDOUBLE, which broke the build for arm. * math/math.h: Fix check for __MATH_DECLARE_LDOUBLE. * math/bits/math-finite.h: Likewise.
* Change return type in the declaration of __ieee754_rem_pio2lGabriel F. T. Gomes2017-03-301-1/+1
| | | | | | | | | | | | | The implementation of __ieee754_rem_pio2l in ldbl-128, ldbl-128ibm, and ldbl-96 return the type int32_t, whereas math_private.h declares it as returning int. This patch changes the declaration to match the declaration in thoses directories, as well as it changes the stub implementation in math/e_rem_pio2l.c, similarly. * math/e_rem_pio2l.c (__ieee754_rem_pio2l): Change return type to int32_t. * sysdeps/generic/math_private.h: Declare __ieee754_rem_pio2l as returning int32_t.
* Macroize inclusion of math-finite.hGabriel F. T. Gomes2017-03-302-387/+133
| | | | | | | | | | | | | | | This patch macroizes the declarations in math/bits/math-finite.h similarly to what math/bits/mathcalls.h does. For each floating-point type, the file is included once in math/math.h. This will reduce the amount of repetitive boilerplate required when adding float128 versions of these declarations. Tested for powerpc64le and s390x. * math/math.h: Include bits/math-finite.h once per floating-point type. * math/bits/math-finite.h: Macroize all declarations by floating-point type.
* XFAIL catan and catanh tests on ibm128Tulio Magno Quites Machado Filho2017-03-163-1168/+1168
| | | | | | | | | | | | | | | Mark 4 catan and catanh tests as xfail-rounding:ibm128-libgcc. After this patch all catan and catanh tests pass on ibm128. Regenerated auto-libm-test-out using gmp 6.1.2, mpfr 3.1.5 and upstream mpc (9ef8030e50), Tested on powerpc, powerpc64 and powerpc64le. * math/auto-libm-test-in: Mark some catan and catanh as xfail-rounding:ibm128-libgcc. * math/auto-libm-test-out-catan: Regenerate. * math/auto-libm-test-out-catanh: Likewise.
* Remove C++ namespace handling from glibc headers.Joseph Myers2017-03-162-43/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | glibc headers include some code (not particularly consistent or systematic) to put various declarations in C++ namespaces std and __c99, if _GLIBCPP_USE_NAMESPACES is defined. As noted in <https://gcc.gnu.org/ml/libstdc++/2017-03/msg00025.html>, this macro was removed from libstdc++ in 2000. I don't expect compilation with such old versions of libstdc++ to work with current glibc headers anyway (whereas old *binaries* are expected to stay working with current glibc); this patch (which should be a no-op with any libstdc++ version postdating that removal) removes all this code from the glibc headers. The begin-end-check.pl test, whose comments say it is about checking these namespace macro calls, is also removed. The code in that test would have covered __BEGIN_DECLS / __END_DECLS as well, but if those weren't properly matched it would show up with the check-installed-headers-cxx tests, so I don't think there is an actual use for keeping begin-end-check.pl with the namespace code removed. Tested for x86_64 and x86 (testsuite, and that installed stripped shared libraries are unchanged by the patch). * misc/sys/cdefs.h (__BEGIN_NAMESPACE_STD): Remove macro. (__END_NAMESPACE_STD): Likewise. (__USING_NAMESPACE_STD): Likewise. (__BEGIN_NAMESPACE_C99): Likewise. (__END_NAMESPACE_C99): Likewise. (__USING_NAMESPACE_C99): Likewise. * math/math.h (_Mdouble_BEGIN_NAMESPACE): Do not define and undefine macro. (_Mdouble_END_NAMESPACE): Likewise. * ctype/ctype.h: Do not handle C++ namespaces. * libio/bits/stdio-ldbl.h: Likewise. * libio/stdio.h: Likewise. * locale/locale.h: Likewise. * math/bits/mathcalls.h: Likewise. * setjmp/setjmp.h: Likewise. * signal/signal.h: Likewise. * stdlib/bits/stdlib-float.h: Likewise. * stdlib/bits/stdlib-ldbl.h: Likewise. * stdlib/stdlib.h: Likewise. * string/string.h: Likewise. * sysdeps/x86/fpu/bits/mathinline.h: Likewise. * time/bits/types/clock_t.h: Likewise. * time/bits/types/struct_tm.h: Likewise. * time/bits/types/time_t.h: Likewise. * time/time.h: Likewise. * wcsmbs/bits/wchar-ldbl.h: Likewise. * wcsmbs/uchar.h: Likewise. * wcsmbs/wchar.h: Likewise. [_GLIBCPP_USE_NAMESPACES] (wint_t): Remove conditional definition. * wctype/wctype.h: Do not handle C++ namespaces. * scripts/begin-end-check.pl: Remove. * Makefile (installed-headers): Likewise. (tests-special): Do not add $(objpfx)begin-end-check.out. ($(objpfx)begin-end-check.out): Remove.
* Improve float range reduction accuracy near pi/2 (bug 21094).Joseph Myers2017-03-153-0/+584
| | | | | | | | | | | | | | | | | | | | | | | | | Bug 21094 reports 3ulp errors of cosf and tanf for certain arguments near pi/2 arising from the use of an insufficiently accurate range reduction. (To be clear, this is a quality-of-implementation issue relating to the apparent intent of those particular cosf and tanf implementations; 3ulp is within the general glibc accuracy goals, so not inherently a bug.) This patch fixes that error by making a wider range of cases use the existing more accurate range reduction for arguments close to pi/2. The wider range of values is still narrow enough for the "z -= pio2_2;" in the more accurate case to be exact, as the code expects. Tested for x86_64, x86 and mips64; no ulps updates needed (but at least on mips64, the larger ulps were seen if the tests were added without the substantive fix). [BZ #21094] * sysdeps/ieee754/flt-32/e_rem_pio2f.c (__ieee754_rem_pio2f): Use 24+24+24-bit pi for wider range of values around pi/2. * math/auto-libm-test-in: Add more tests of cos and tan. * math/auto-libm-test-out-cos: Regenerated. * math/auto-libm-test-out-tan: Likewise.
* Split helper classification macros from mathcalls.hGabriel F. T. Gomes2017-03-154-29/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The classification macros: finite, fpclassify, iseqsig, isinf, isnan, issignaling, and signbit are defined by ISO C11 and declared in mathcalls.h for each of the floating-point types: float, double, and long double. TS 18661-3 does not mention these macros for float128, however support for them must be present when _Float128 is present. This is true, even when the feature test macro __STDC_WANT_IEC_60559_TYPES_EXT__ is false. Other function declarations in mathcalls.h, on the other hand, depend on __STDC_WANT_IEC_60559_TYPES_EXT__. This patch splits the helper functions (__finite, __fpclassify, __iseqsig, __isinf, __isnan, __issignaling, and __signbit) from mathcalls.h, so that these helper functions can be declared for _Float128, even when __STDC_WANT_IEC_60559_TYPES_EXT__ is false. Tested for powerpc64le, s390x, and x86_64. * include/bits/mathcalls-helper-functions.h: New file. * math/Makefile (headers): Add bits/mathcalls-helper-functions.h. * math/bits/mathcalls.h (__finite, __fpclassify, __iseqsig) (__isinf, __isnan, __issignaling, __signbit): Move declarations to math/bits/mathcalls-helper-functions.h. * math/bits/mathcalls-helper-functions.h: New file. * math/math.h: Include bits/mathcalls-helper-functions.h for float, double, and long double.
* Use internal __feraiseexcept in __iseqsigGabriel F. T. Gomes2017-03-151-1/+1
| | | | | | | | | | Replace the use of feraiseexcept with __feraiseexcept in the helper function __iseqsig (math/s_iseqsig_template.c). Tested for powerpc64le, s390x, and x86_64. * math/s_iseqsig_template.c (__iseqsig): Use __feraiseexcept instead of feraiseexcept.
* Update auto-libm-test-out for catan / catanh.Stefan Liebler2017-03-102-896/+896
| | | | | | | | | | | | | | I've used gmp 6.1.2, mpfr 3.1.5 and upstream mpc with fix in mpc_atan (https://scm.gforge.inria.fr/anonscm/gitweb?p=mpc/mpc.git;a=commit;h=958aac9b15a659d6fb5edcb11778123f8a35b14f) to build gen-auto-libm-tests and regenerated catan / catanh out files. Regenerated ULPs for s390 from scratch. Now the catan / catanh tests are passing. ChangeLog: * math/auto-libm-test-out-catan: Regenerated. * math/auto-libm-test-out-catanh: Likewise. * sysdeps/s390/fpu/libm-test-ulps: Likewise.
* Miscellaneous low-risk changes preparing for _ISOMAC testsuite.Zack Weinberg2017-03-011-12/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These are a grab bag of changes where the testsuite was using internal symbols of some variety, but this was straightforward to fix, and the fixed code should work with or without the change to compile the testsuite under _ISOMAC. Four of these are just more #include adjustments, but I want to highlight sysdeps/powerpc/fpu/tst-setcontext-fpscr.c, which appears to have been written before the advent of sys/auxv.h. I think a big chunk of this file could be replaced by a simple call to getauxval, but I'll let someone who actually has a powerpc machine to test on do that. dlfcn/tst-dladdr.c was including ldsodefs.h just so it could use DL_LOOKUP_ADDRESS to print an additional diagnostic; as requested by Carlos, I have removed this. math/test-misc.c was using #ifndef NO_LONG_DOUBLE, which is an internal configuration macro, to decide whether to do certain tests involving 'long double'. I changed the test to #if LDBL_MANT_DIG > DBL_MANT_DIG instead, which uses only public float.h macros and is equivalent on all supported platforms. (Note that NO_LONG_DOUBLE doesn't mean 'the compiler doesn't support long double', it means 'long double is the same as double'.) tst-writev.c has a configuration macro 'ARTIFICIAL_LIMIT' that the Makefiles are expected to define, and sysdeps/unix/sysv/linux/Makefile was using the internal __getpagesize in the definition; changed to sysconf(_SC_PAGESIZE) which is the POSIX equivalent. ia64-linux doesn't supply 'clone', only '__clone2', which is not defined in the public headers(!) All the other clone tests have local extern declarations of __clone2, but tst-clone.c doesn't; it was getting away with this because include/sched.h does declare __clone2. * nss/tst-cancel-getpwuid_r.c: Include nss.h. * string/strcasestr.c: No need to include config.h. * sysdeps/powerpc/fpu/tst-setcontext-fpscr.c: Include sys/auxv.h. Don't include sysdep.h. * sysdeps/powerpc/tst-set_ppr.c: Don't include dl-procinfo.h. * dlfcn/tst-dladdr.c: Don't include ldsodefs.h. Don't use DL_LOOKUP_ADDRESS. * math/test-misc.c: Instead of testing NO_LONG_DOUBLE, test whether LDBL_MANT_DIG is greater than DBL_MANT_DIG. * sysdeps/unix/sysv/linux/Makefile (CFLAGS-tst-writev.c): Use sysconf (_SC_PAGESIZE) instead of __getpagesize in definition of ARTIFICIAL_LIMIT. * sysdeps/unix/sysv/linux/tst-clone.c [__ia64__]: Add extern declaration of __clone2.
* Use independent type literals in libm-test-support.cTulio Magno Quites Machado Filho2017-02-241-9/+9
| | | | | * math/libm-test-support.c (check_ulp): Use LIT() around literal numbers.
* Run libm tests separately for each function.Joseph Myers2017-02-24145-723/+1130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At present, libm tests for each function get built into a single executable (for each floating point type, for each of normal / inline / finite-math-only functions, plus vector variants) and run together, resulting in a single PASS or FAIL (for each of those nine variants plus vector variants). Building this executable involves reading over 50 MB of libm-test-*.c sources. This patch arranges for tests of each function to be run separately from the makefiles instead. There are 121 functions being tested for each (type, variant pair) (actually 126, but run as 121 from the Makefile because each of the pairs (exp10, pow10), (isfinite, finite), (lgamma, gamma), (remainder, drem), (scalbn, ldexp), shares a table of test results and so is run together), so 1089 separate tests run from the Makefile, plus 48 vector tests on x86_64 (six functions for eight vector variants). Each test only involves a libm-test-<func>.c file of no more than about 4 MB, rather than all such files taking about 50 MB. With tests run separately, test summaries will indicate which functions actually have problems (of course, those problems may just be out-of-date libm-test-ulps files if the file hasn't been updated for the architecture in question recently). All the .c files for the 1089+48 tests are generated automatically from the Makefiles. Various checked-in boilerplate .c files are removed as no longer needed. CFLAGS definitions for the different kinds of tests are generated using makefile iterators to apply target-specific variable settings. libm-have-vector-test.h is no longer needed; the list of functions to test for each vector type is now in the sysdeps Makefile. This should reduce the amount of boilerplate needed for float128 testing support; test-float128.h will still be needed, but not various .c files or Makefile CFLAGS definitions. The logic for creating dependencies on libm-test-support-*.o files should also render <https://sourceware.org/ml/libc-alpha/2017-02/msg00279.html> unnecessary. Tested for x86_64 and x86. * math/Makefile (libm-tests-generated): Remove variable. (libm-tests-base-normal): New variable. (libm-tests-base-finite): Likewise. (libm-tests-base-inline): Likewise. (libm-tests-base): Likewise. (libm-tests-normal): Likewise. (libm-tests-finite): Likewise. (libm-tests-inline): Likewise. (libm-tests-vector): Likewise. (libm-tests): Define in terms of these new variables. (libm-tests-for-type): New variable. (libm-tests.o): Move definition. (tests): Move addition of $(libm-tests). (generated): Update for new and removed libm test files. ($(objpfx)libm-test.c): Remove target. ($(objpfx)libm-have-vector-test.h): Likewise. (CFLAGS-test-double-vlen2.c): Remove variable. (CFLAGS-test-double-vlen4.c): Likewise. (CFLAGS-test-double-vlen8.c): Likewise. (CFLAGS-test-float-vlen4.c): Likewise. (CFLAGS-test-float-vlen8.c): Likewise. (CFLAGS-test-float-vlen16.c): Likewise. (CFLAGS-test-float.c): Likewise. (CFLAGS-test-float-finite.c): Likewise. (CFLAGS-libm-test-support-float.c): Likewise. (CFLAGS-test-double.c): Likewise. (CFLAGS-test-double-finite.c): Likewise. (CFLAGS-libm-test-support-double.c): Likewise. (CFLAGS-test-ldouble.c): Likewise. (CFLAGS-test-ldouble-finite.c): Likewise. (CFLAGS-libm-test-support-ldouble.c): Likewise. (libm-test-inline-cflags): New variable. (CFLAGS-test-ifloat.c): Remove variable. (CFLAGS-test-idouble.c): Likewise. (CFLAGS-test-ildouble.c): Likewise. ($(addprefix $(objpfx), $(libm-tests.o))): Move target and update dependencies. ($(foreach t,$(libm-tests-normal),$(objpfx)$(t).c)): New rule. ($(foreach t,$(libm-tests-finite),$(objpfx)$(t).c)): Likewise. ($(foreach t,$(libm-tests-inline),$(objpfx)$(t).c)): Likewise. ($(foreach t,$(libm-tests-vector),$(objpfx)$(t).c)): Likewise. ($(foreach t,$(types),$(objpfx)libm-test-support-$(t).c)): Likewise. (dependencies on libm-test-support-*.o): Remove. ($(foreach f,$(libm-test-funcs-all),$(objpfx)$(o)-$(f).o)): New rules using iterators. ($(addprefix $(objpfx),$(call libm-tests-for-type,$(o)))): Likewise. ($(objpfx)libm-test-support-$(o).o): Likewise. ($(addprefix $(objpfx),$(filter-out $(tests-static) $(libm-vec-tests),$(tests)))): Filter out $(libm-tests-vector) instead. ($(addprefix $(objpfx), $(libm-vec-tests))): Use iterator to define rule instead. * math/README.libm-test: Update. * math/libm-test-acos.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-acosh.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-asin.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-asinh.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-atan.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-atan2.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-atanh.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-cabs.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-cacos.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-cacosh.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-canonicalize.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-carg.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-casin.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-casinh.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-catan.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-catanh.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-cbrt.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-ccos.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-ccosh.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-ceil.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-cexp.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-cimag.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-clog.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-clog10.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-conj.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-copysign.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-cos.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-cosh.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-cpow.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-cproj.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-creal.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-csin.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-csinh.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-csqrt.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-ctan.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-ctanh.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-erf.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-erfc.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-exp.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-exp10.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-exp2.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-expm1.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-fabs.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-fdim.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-floor.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-fma.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-fmax.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-fmaxmag.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-fmin.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-fminmag.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-fmod.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-fpclassify.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-frexp.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-fromfp.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-fromfpx.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-getpayload.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-hypot.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-ilogb.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-iscanonical.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-iseqsig.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-isfinite.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-isgreater.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-isgreaterequal.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-isinf.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-isless.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-islessequal.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-islessgreater.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-isnan.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-isnormal.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-issignaling.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-issubnormal.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-isunordered.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-iszero.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-j0.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-j1.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-jn.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-lgamma.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-llogb.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-llrint.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-llround.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-log.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-log10.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-log1p.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-log2.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-logb.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-lrint.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-lround.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-modf.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-nearbyint.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-nextafter.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-nextdown.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-nexttoward.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-nextup.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-pow.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-remainder.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-remquo.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-rint.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-round.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-roundeven.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-scalb.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-scalbln.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-scalbn.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-setpayload.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-setpayloadsig.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-signbit.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-significand.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-sin.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-sincos.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-sinh.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-sqrt.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-tan.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-tanh.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-tgamma.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-totalorder.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-totalordermag.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-trunc.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-ufromfp.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-ufromfpx.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-y0.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-y1.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-yn.inc: Include libm-test-driver.c. (do_test): New function. * math/libm-test-driver.c: Do not include libm-have-vector-test.h. (HAVE_VECTOR): Remove macro. (START): Do not call HAVE_VECTOR. * math/test-double-vlen2.h (FUNC_TEST): Remove macro. * math/test-double-vlen4.h (FUNC_TEST): Remove macro. * math/test-double-vlen8.h (FUNC_TEST): Remove macro. * math/test-float-vlen16.h (FUNC_TEST): Remove macro. * math/test-float-vlen4.h (FUNC_TEST): Remove macro. * math/test-float-vlen8.h (FUNC_TEST): Remove macro. * math/test-math-vector.h (FUNC_TEST): New macro. (WRAPPER_DECL): Rename to WRAPPER_DECL_f. * sysdeps/x86_64/fpu/Makefile (double-vlen2-funcs): New variable. (double-vlen4-funcs): Likewise. (double-vlen4-avx2-funcs): Likewise. (double-vlen8-funcs): Likewise. (float-vlen4-funcs): Likewise. (float-vlen8-funcs): Likewise. (float-vlen8-avx2-funcs): Likewise. (float-vlen16-funcs): Likewise. (CFLAGS-test-double-vlen4-avx2.c): Remove variable. (CFLAGS-test-float-vlen8-avx2.c): Likewise. * sysdeps/x86_64/fpu/test-double-vlen4.h (TEST_VECTOR_cos): Remove macro. (TEST_VECTOR_sin): Likewise. (TEST_VECTOR_sincos): Likewise. (TEST_VECTOR_log): Likewise. (TEST_VECTOR_exp): Likewise. (TEST_VECTOR_pow): Likewise. * sysdeps/x86_64/fpu/test-double-vlen8.h (TEST_VECTOR_cos): Likewise. (TEST_VECTOR_sin): Likewise. (TEST_VECTOR_sincos): Likewise. (TEST_VECTOR_log): Likewise. (TEST_VECTOR_exp): Likewise. (TEST_VECTOR_pow): Likewise. * sysdeps/x86_64/fpu/test-float-vlen16.h (TEST_VECTOR_cosf): Likewise. (TEST_VECTOR_sinf): Likewise. (TEST_VECTOR_sincosf): Likewise. (TEST_VECTOR_logf): Likewise. (TEST_VECTOR_expf): Likewise. (TEST_VECTOR_powf): Likewise. * sysdeps/x86_64/fpu/test-float-vlen8.h (TEST_VECTOR_cosf): Likewise. (TEST_VECTOR_sinf): Likewise. (TEST_VECTOR_sincosf): Likewise. (TEST_VECTOR_logf): Likewise. (TEST_VECTOR_expf): Likewise. (TEST_VECTOR_powf): Likewise. * math/gen-libm-have-vector-test.sh: Remove file. * math/libm-test.inc: Likewise. * math/libm-test-support-double.c: Likewise. * math/libm-test-support-float.c: Likewise. * math/libm-test-support-ldouble.c: Likewise. * math/test-double-finite.c: Likewise.: Likewise. * math/test-double.c: Likewise. * math/test-float-finite.c: Likewise. * math/test-float.c: Likewise. * math/test-idouble.c: Likewise. * math/test-ifloat.c: Likewise. * math/test-ildouble.c: Likewise. * math/test-ldouble-finite.c: Likewise. * math/test-ldouble.c: Likewise. * sysdeps/x86_64/fpu/test-double-vlen2.c: Likewise. * sysdeps/x86_64/fpu/test-double-vlen2.h: Likewise. * sysdeps/x86_64/fpu/test-double-vlen4-avx2.c: Likewise. * sysdeps/x86_64/fpu/test-double-vlen4.c: Likewise. * sysdeps/x86_64/fpu/test-double-vlen8.c: Likewise. * sysdeps/x86_64/fpu/test-float-vlen16.c: Likewise. * sysdeps/x86_64/fpu/test-float-vlen4.c: Likewise. * sysdeps/x86_64/fpu/test-float-vlen4.h: Likewise. * sysdeps/x86_64/fpu/test-float-vlen8-avx2.c: Likewise. * sysdeps/x86_64/fpu/test-float-vlen8.c: Likewise.
* Add new templates for IEEE wrappersGabriel F. T. Gomes2017-02-2325-1/+1041
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Several wrappers for IEEE functions use _LIB_VERSION / matherr / __kernel_standard functionality, which we want to obsolete. New wrappers, such as for float128, must not use this functionality. This patch adds new wrappers that only __set_errno and can be used by the new float128 wrappers. Tested for powerpc64le. * math/Makefile: Add wrappers to gen-libm-calls. * math/w_acos_template.c: New file. * math/w_acosh_template.c: Likewise. * math/w_asin_template.c: Likewise. * math/w_atan2_template.c: Likewise. * math/w_atanh_template.c: Likewise. * math/w_cosh_template.c: Likewise. * math/w_exp10_template.c: Likewise. * math/w_exp2_template.c: Likewise. * math/w_exp_template.c: Likewise. * math/w_fmod_template.c: Likewise. * math/w_hypot_template.c: Likewise. * math/w_j0_template.c: Likewise. * math/w_j1_template.c: Likewise. * math/w_jn_template.c: Likewise. * math/w_lgamma_r_template.c: Likewise. * math/w_lgamma_template.c: Likewise. * math/w_log10_template.c: Likewise. * math/w_log2_template.c: Likewise. * math/w_log_template.c: Likewise. * math/w_pow_template.c: Likewise. * math/w_remainder_template.c: Likewise. * math/w_sinh_template.c: Likewise. * math/w_sqrt_template.c: Likewise. * math/w_tgamma_template.c: Likewise.: Likewise. * sysdeps/generic/math-type-macros-double.h (__USE_WRAPPER_TEMPLATE): New macro to control inclusion of the new wrappers. * sysdeps/generic/math-type-macros-float.h: Likewise. * sysdeps/generic/math-type-macros-ldouble.h: Likewise.