aboutsummaryrefslogtreecommitdiff
path: root/math
AgeCommit message (Collapse)Author
2017-11-27Add _Float64x function aliases.Joseph Myers
This patch continues filling out TS 18661-3 support by adding *f64x function aliases on platforms with _Float64x support. (It so happens the set of such platforms is exactly the same as the set of platforms with _Float128 support, although on x86_64, x86 and ia32 the _Float64x format is Intel extended rather than binary128.) The API provided corresponds exactly to that provided for _Float128, mostly coming from TS 18661-3. As these functions always alias those for another type (long double, _Float128 or both), __* function names are not provided, as in other cases of alias types. Given the preparation done in previous patches, this one just enables the feature via Makeconfig and bits/floatn.h, adds symbol versions, and updates documentation and ABI baselines. The symbol versions are present unconditionally as GLIBC_2.27 in the relevant Versions files, as it's OK for those to specify versions for functions that may not be present in some configurations; no additional complexity is needed unless in future some configuration gains support for this type that didn't have such support in 2.27. The Makeconfig additions for ia64 and x86 aren't strictly needed, as those configurations also get float64x-alias-fcts definitions from sysdeps/ieee754/float128/Makeconfig, but still seem appropriate given that _Float64x is not _Float128 for those configurations. A libm-test-ulps update for x86 is included. This is because bits/mathinline.h does not have _Float64x support added and for two functions the use of out-of-line functions results in increased ulps (ifloat64x shares ulps with ildouble / ifloat128 as appropriate). Given that we'd like generally to eliminate bits/mathinline.h optimizations, preferring to have such optimizations in GCC instead, it seems reasonable not to add such support there for new types. GCC support for _FloatN / _FloatNx built-in functions is limited, but has been improved in GCC 8, and at some point I hope the full set of libm built-in functions in GCC, and other optimizations with per-floating-type aspects, will be enabled for all _FloatN / _FloatNx types. Tested for x86_64 and x86, and with build-many-glibcs.py, with both GCC 6 and GCC 7. * sysdeps/ia64/Makeconfig (float64x-alias-fcts): New variable. * sysdeps/ieee754/float128/Makeconfig (float64x-alias-fcts): Likewise. * sysdeps/ieee754/ldbl-128/Makeconfig (float64x-alias-fcts): Likewise. * sysdeps/x86/Makeconfig: New file. * bits/floatn-common.h (__HAVE_FLOAT64X): Remove macro. (__HAVE_FLOAT64X_LONG_DOUBLE): Likewise. * bits/floatn.h (__HAVE_FLOAT64X): New macro. (__HAVE_FLOAT64X_LONG_DOUBLE): Likewise. * sysdeps/ia64/bits/floatn.h (__HAVE_FLOAT64X): Likewise. (__HAVE_FLOAT64X_LONG_DOUBLE): Likewise. * sysdeps/ieee754/ldbl-128/bits/floatn.h (__HAVE_FLOAT64X): Likewise. (__HAVE_FLOAT64X_LONG_DOUBLE): Likewise. * sysdeps/mips/ieee754/bits/floatn.h (__HAVE_FLOAT64X): Likewise. (__HAVE_FLOAT64X_LONG_DOUBLE): Likewise. * sysdeps/powerpc/bits/floatn.h (__HAVE_FLOAT64X): Likewise. (__HAVE_FLOAT64X_LONG_DOUBLE): Likewise. * sysdeps/x86/bits/floatn.h (__HAVE_FLOAT64X): Likewise. (__HAVE_FLOAT64X_LONG_DOUBLE): Likewise. * manual/math.texi (Mathematics): Document support for _Float64x. * math/Versions (GLIBC_2.27): Add _Float64x functions. * stdlib/Versions (GLIBC_2.27): Likewise. * wcsmbs/Versions (GLIBC_2.27): Likewise. * sysdeps/unix/sysv/linux/aarch64/libc.abilist: Update. * sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise. * sysdeps/i386/fpu/libm-test-ulps: Likewise. * sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Likewise.
2017-11-24Support testing _Float64x libm functions.Joseph Myers
This patch adds support for testing _Float64x libm functions. A configuration with such functions sets float64x-alias-fcts = yes in a sysdeps Makeconfig file; until such settings are added, this test support is inactive. Tested for x86_64, including in conjunction with _Float64x support patches. * math/test-float64x.h: New file. * math/Makefile (type-float64x-yes): New variable. (test-types): Add $(type-float64x-$(float64x-alias-fcts)).
2017-11-24Fix gen-tgmath-tests.py for _Float64, _Float64x testing.Joseph Myers
math/gen-tgmath-tests.py was missing a create_type argument when creating the internal types for combinations of long double with _Float64 and _Float64x, so resulting in output that did not compile when glibc support for those types was enabled. This patch adds the missing argument so that the tests properly compile in that case. Tested for x86_64, including in conjunction with _Float64x support patches. * math/gen-tgmath-tests.py (Type.init_types): Pass suffix argument for combinations of long double with _Float64 and _Float64x.
2017-11-15Use __builtin_tgmath in tgmath.h with GCC 8 (bug 21660).Joseph Myers
GCC mainline now supports __builtin_tgmath to allow <tgmath.h> macro implementations that expand their arguments only once, so avoiding exponential blowup in the size of macro expansions when calls to those macros are nested in arguments to those macros. This patch makes glibc's tgmath.h support using __builtin_tgmath, as a much simpler and more efficient alternative to the existing implementation. (As a side effect, the new feature would make it much more practical to support decimal floating point in <tgmath.h> with new compilers; currently, libdfp does not provide a <tgmath.h> implementation, and making decimal arguments cause integer arguments to be considered of type _Decimal64 instead of double would have been very problematic in the old implementation.) Tested for x86_64 (with GCC mainline). [BZ #21660] * math/tgmath.h (__HAVE_BUILTIN_TGMATH): New macro. [__HAVE_BUILTIN_TGMATH] (__TG_F16_ARG): Likewise. [__HAVE_BUILTIN_TGMATH] (__TG_F32_ARG): Likewise. [__HAVE_BUILTIN_TGMATH] (__TG_F64_ARG): Likewise. [__HAVE_BUILTIN_TGMATH] (__TG_F128_ARG): Likewise. [__HAVE_BUILTIN_TGMATH] (__TG_F32X_ARG): Likewise. [__HAVE_BUILTIN_TGMATH] (__TG_F64X_ARG): Likewise. [__HAVE_BUILTIN_TGMATH] (__TG_F128X_ARG): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_FUNCS): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_RCFUNCS): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_1): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_2): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_2STD): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_3): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_1C): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_2C): Likewise. (__tgml): Make conditional on [!__HAVE_BUILTIN_TGMATH]. (__floating_type): Likewise. (__real_integer_type): Likewise. (__complex_integer_type): Likewise. (__expr_is_real): Likewise. (__tgmath_real_type_sub): Likewise. (__tgmath_real_type): Likewise. (__tgmath_complex_type_sub): Likewise. (__tgmath_complex_type): Likewise. (__TGMATH_F128): Likewise. (__TGMATH_CF128): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_UNARY_REAL_ONLY): Define using new macros. [__HAVE_BUILTIN_TGMATH] (__TGMATH_UNARY_REAL_RET_ONLY): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_BINARY_FIRST_REAL_ONLY): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_BINARY_FIRST_REAL_STD_ONLY): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_BINARY_REAL_ONLY): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_BINARY_REAL_STD_ONLY): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_BINARY_REAL_RET_ONLY): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_TERNARY_REAL_ONLY): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_TERNARY_FIRST_REAL_RET_ONLY): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_UNARY_REAL_IMAG): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_UNARY_IMAG): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_UNARY_REAL_IMAG_RET_REAL): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_BINARY_REAL_IMAG): Likewise. (__TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME): New macro. (carg): Use __TGMATH_UNARY_REAL_IMAG_RET_REAL_SAME. (cimag): Likewise. (creal): Likewise.
2017-11-03Handle more _FloatN, _FloatNx types in __MATH_TG.Joseph Myers
Continuing the preparation for additional _FloatN / _FloatNx type support, this patch prepares __MATH_TG to handle more such types. Various unhandled cases, which do not correspond to any current glibc configuration, have explicit #errors added. _Float32 and _Float64x are then handled appropriately in the _Generic case, which is the only one, other than the cases where use of sizeof is sufficient, where they should ever be explicit types at the language level instead of typedefs. There is no need to handle _Float64 or _Float32x explicitly there because the default case calling a double function is correct for those types. Tested for x86_64. * math/math.h [__HAVE_DISTINCT_FLOAT16 || __HAVE_DISTINCT_FLOAT32 || __HAVE_DISTINCT_FLOAT64 || __HAVE_DISTINCT_FLOAT32X || __HAVE_DISTINCT_FLOAT64X || __HAVE_DISTINCT_FLOAT128X]: Use #error. [__NO_LONG_DOUBLE_MATH && __HAVE_DISTINCT_FLOAT128]: Likewise. [__HAVE_DISTINCT_FLOAT128 && !__HAVE_GENERIC_SELECTION && __HAVE_FLOATN_NOT_TYPEDEF]: Likewise. [__HAVE_DISTINCT_FLOAT128 && __HAVE_GENERIC_SELECTION] (__MATH_TG_F32): New macro. [__HAVE_DISTINCT_FLOAT128 && __HAVE_GENERIC_SELECTION] (__MATH_TG_F64X): Likewise. [__HAVE_DISTINCT_FLOAT128 && __HAVE_GENERIC_SELECTION] (__MATH_TG): Use __MATH_TG_F32 and __MATH_TG_F64X.
2017-11-03Handle more _FloatN, _FloatNx types in tgmath.h.Joseph Myers
Continuing the preparation for additional _FloatN / _FloatNx type support, this patch improves how <tgmath.h> handles such types. Use of #error is added for cases of distinct types that are not supported by the header, to indicate that additional work on the header would be needed if, for example, _Float16 support were added to glibc. Given that #error, types with the same format as other types are handled automatically by the sizeof-based logic, so the only case needing special handling is that where _Float64x exists, has the same format as _Float128, does not have the same format as long double, and is not a typedef for _Float128. In this case (which will apply for powerpc64le once _Float64x support is added to glibc), the __builtin_types_compatible_p calls testing for _Float128 need corresponding calls testing for _Float64x, which this patch adds. Tested for x86_64. * math/tgmath.h [__HAVE_DISTINCT_FLOAT16 || __HAVE_DISTINCT_FLOAT32 || __HAVE_DISTINCT_FLOAT64 || __HAVE_DISTINCT_FLOAT32X || __HAVE_DISTINCT_FLOAT64X || __HAVE_DISTINCT_FLOAT128X]: Use #error. [__HAVE_DISTINCT_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT64X && !__HAVE_FLOAT64X_LONG_DOUBLE && __HAVE_FLOATN_NOT_TYPEDEF] (__TGMATH_F128): Handle _Float64x the same as _Float128. [__HAVE_DISTINCT_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT64X && !__HAVE_FLOAT64X_LONG_DOUBLE && __HAVE_FLOATN_NOT_TYPEDEF] (__TGMATH_CF128): Likewise.
2017-11-01Include bits/cmathcalls.h for more _FloatN, _FloatNx types.Joseph Myers
Continuing the preparation for additional _FloatN / _FloatNx type support, this patch arranges for <bits/cmathcalls.h> to be included by <complex.h> for each such type under conditions and with macros defined corresponding to those used for _Float128. Tested for x86_64. * math/complex.h [(__HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !_LIBC)) && __GLIBC_USE (IEC_60559_TYPES_EXT)]: Include <bits/cmathcalls.h> with appropriate macros defined and undefined. [(__HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !_LIBC)) && __GLIBC_USE (IEC_60559_TYPES_EXT)]: Likewise. [(__HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !_LIBC)) && __GLIBC_USE (IEC_60559_TYPES_EXT)]: Likewise. [(__HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !_LIBC)) && __GLIBC_USE (IEC_60559_TYPES_EXT)]: Likewise. [(__HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !_LIBC)) && __GLIBC_USE (IEC_60559_TYPES_EXT)]: Likewise. [(__HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !_LIBC)) && __GLIBC_USE (IEC_60559_TYPES_EXT)]: Likewise.
2017-11-01Clean up complex.h handling of float128.Joseph Myers
This patch cleans up the way complex.h handles inclusion of bits/cmathcalls.h for float128. The inclusion was between those for the types float and long double; the patch moves it after that for long double, matching how bits/mathcalls.h and bits/math-finite.h inclusions are ordered. There is no need for the undefine and define of _Mdouble_complex_ to be conditional, since __CFLOAT128 is always defined by bits/floatn.h when _Float128 is supported, so the patch removes the unnecessary conditionals. Tested for x86_64. * math/complex.h [(__HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !LIBC)) && __GLIBC_USE (IEC_60559_TYPES_EXT)]: Move conditional code after that for long double. Do not condition define and undefine of _Mdouble_complex_ on [__CFLOAT128].
2017-10-31Define CMPLX macros for more _FloatN, _FloatNx types.Joseph Myers
Continuing the preparation for additional _FloatN / _FloatNx type support, this patch defines CMPLX* macros for all such types, as already done for _Float128. Tested for x86_64. * math/complex.h [__HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (CMPLXF16): New macro. [__HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (CMPLXF32): Likewise. [__HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (CMPLXF64): Likewise. [__HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)] (CMPLXF32X): Likewise. [__HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)] (CMPLXF64X): Likewise. [__HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)] (CMPLXF128X): Likewise.
2017-10-31Adjust __MATH_EVAL_FMT2 definition to handle _Float16 better.Joseph Myers
Continuing the preparation for additional _FloatN / _FloatNx type support, this patch adds an additional case in the definition of __MATH_EVAL_FMT2, as used in defining iseqsig: when __FLT_EVAL_METHOD__ is 0 or 32, it adds 0.0f to the arguments, so that the correct function would be selected in the case of _Float16 arguments with excess precision (were glibc to support _Float16, which of course __MATH_TG and other facilities do not at present - and _Float16 support is not part of what this patch series is aiming for, but this particular fix is simple so is included anyway). Tested for x86_64. * math/math.h [__FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 32] (__MATH_EVAL_FMT2): Define to add 0.0f.
2017-10-30Include bits/math-finite.h for more _FloatN, _FloatNx types.Joseph Myers
Continuing the preparation for additional _FloatN / _FloatNx type support, this patch extends the includes of <bits/math-finite.h> to cover all such types, under conditions analogous to those for _Float128. Tested for x86_64. * math/math.h [__HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !_LIBC)]: Include <bits/math-finite.h> with appropriate macros defined and undefined. [__HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !_LIBC)]: Likewise. [__HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !_LIBC)]: Likewise. [__HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !_LIBC)]: Likewise. [__HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !_LIBC)]: Likewise. [__HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !_LIBC)]: Likewise.
2017-10-30Remove _Mlong_double_ etc. macros.Joseph Myers
math.h has a macro _Mlong_double_ for the type to use when declaring long double functions, and similar macros for other types. math/Makefile uses -D_Mlong_double_=double in the case of long double having the same ABI as double. This originates with: Mon Jul 8 13:37:40 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu> * math/math.h (_Mfloat_, _Mlong_double_): New macros, defined iff not already defined to float, long double. Use those macros for _Mdouble_ defns when including mathcalls.h. * math/Makefile [$(long-double-fcts) != yes] (CPPFLAGS): Append -D_Mlong_double_=double. However, math.h stopped declaring long double functions in the case of long double having the same ABI as double (and thus probably stopped actually needing the Makefile definition of _Mlong_double_) with: 1998-11-05 Ulrich Drepper <drepper@cygnus.com> * math/math.h: Unconditionally include bits/mathdef.h. Declare long double functions only if __NO_LONG_DOUBLE_MATH is not defined. * sysdeps/generic/bits/mathdef.h: Define only if __USE_ISOC9X. Define __NO_LONG_DOUBLE_MATH. * sysdeps/m68k/fpu/bits/mathdef.h: Define only if __USE_ISOC9X. * sysdeps/i386/fpu/bits/mathdef.h: Likewise. The declarations were since restored for compiling user code, but remain absent when _LIBC is defined, which is sufficient to avoid problems declaring function aliases of incompatible types. Thus the indirection through the _Mlong_double_ macro is not needed (probably since that 1998 patch), and this patch removes _Mlong_double_ and associated macros for other types, leaving only the macro _Mdouble_ which is actually used as the type for which a given inclusion of <bits/mathcalls.h> should declared functions. Tested for x86_64, and tested with build-many-glibcs.py that installed stripped shared libraries are unchanged by this patch. * math/math.h [!_Mfloat_] (_Mfloat_): Do not define. [!_Mlong_double_] (_Mlong_double_): Likewise. [!_Mfloat16_] (_Mfloat16_): Likewise. [!_Mfloat32_] (_Mfloat32_): Likewise. [!_Mfloat64_] (_Mfloat64_): Likewise. [!_Mfloat128_] (_Mfloat128_): Likewise. [!_Mfloat32x_] (_Mfloat32x_): Likewise. [!_Mfloat64x_] (_Mfloat64x_): Likewise. [!_Mfloat128x_] (_Mfloat128x_): Likewise. (_Mdouble_): Define without indirection through those macros. * math/complex.h [!_Mfloat_] (_Mfloat_): Do not define. [!_Mfloat128_] (_Mfloat128_): Likewise. [_Mlong_double_] (_Mlong_double_): Likewise. (_Mdouble_): Define without indirection through those macros. * math/Makefile [$(long-double-fcts) != yes] (math-CPPFLAGS): Do not add -D_Mlong_double_=double. * include/math.h [_ISOMAC] (_Mlong_double_): Do not undefine. * math/test-signgam-finite-c99.c (_Mlong_double_): Likewise.
2017-10-30Add _FloatN, _FloatNx M_* constants.Joseph Myers
Continuing the preparation for additional _FloatN / _FloatNx type support, this patch adds M_* constants for such types. The decimal expansions used are all the same as used for _Float128; there's no need to reduce the precision used. In the case of _Float128x, #error is used because the constants would need additional precision, but how much is needed would depend on the actual _Float128x format used, so it's not possible to add header support simply as part of code that handles all _FloatN / _FloatNx types similarly. Tested for x86_64. * math/math.h [__HAVE_FLOAT16 && __USE_GNU] (M_Ef16): New macro. [__HAVE_FLOAT16 && __USE_GNU] (M_LOG2Ef16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_LOG10Ef16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_LN2f16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_LN10f16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_PIf16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_PI_2f16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_PI_4f16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_1_PIf16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_2_PIf16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_2_SQRTPIf16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_SQRT2f16): Likewise. [__HAVE_FLOAT16 && __USE_GNU] (M_SQRT1_2f16): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_Ef32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_LOG2Ef32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_LOG10Ef32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_LN2f32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_LN10f32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_PIf32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_PI_2f32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_PI_4f32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_1_PIf32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_2_PIf32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_2_SQRTPIf32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_SQRT2f32): Likewise. [__HAVE_FLOAT32 && __USE_GNU] (M_SQRT1_2f32): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_Ef64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_LOG2Ef64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_LOG10Ef64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_LN2f64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_LN10f64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_PIf64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_PI_2f64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_PI_4f64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_1_PIf64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_2_PIf64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_2_SQRTPIf64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_SQRT2f64): Likewise. [__HAVE_FLOAT64 && __USE_GNU] (M_SQRT1_2f64): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_Ef32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_LOG2Ef32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_LOG10Ef32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_LN2f32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_LN10f32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_PIf32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_PI_2f32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_PI_4f32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_1_PIf32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_2_PIf32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_2_SQRTPIf32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_SQRT2f32x): Likewise. [__HAVE_FLOAT32X && __USE_GNU] (M_SQRT1_2f32x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_Ef64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_LOG2Ef64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_LOG10Ef64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_LN2f64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_LN10f64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_PIf64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_PI_2f64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_PI_4f64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_1_PIf64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_2_PIf64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_2_SQRTPIf64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_SQRT2f64x): Likewise. [__HAVE_FLOAT64X && __USE_GNU] (M_SQRT1_2f64x): Likewise. [__HAVE_FLOAT128X && __USE_GNU]: Use #error.
2017-10-27Include bits/mathcalls.h for more _FloatN, _FloatNx types.Joseph Myers
Continuing the preparation for additional _FloatN / _FloatNx type support, this patch arranges for <bits/mathcalls.h> and <bits/mathcalls-helper-functions.h> to be included for each such type under conditions and with macros defined corresponding to those already present for _Float128. Tested for x86_64. * math/math.h [__HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !_LIBC)]: Include <bits/mathcalls-helper-functions.h> and <bits/mathcalls.h> with appropriate macros defined and undefined. [__HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !_LIBC)]: Likewise. [__HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !_LIBC)]: Likewise. [__HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !_LIBC)]: Likewise. [__HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !_LIBC)]: Likewise. [__HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !_LIBC)]: Likewise.
2017-10-26Add SNAN macros for more _FloatN, _FloatNx types.Joseph Myers
This patch continues the preparation for additional _FloatN / _FloatNx type support by adding appropriately conditional definitions of SNAN* macros, corresponding to the SNANF128 definition already present. Tested for x86_64. * math/math.h [__HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (SNANF16): New macro. [__HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (SNANF32): Likewise. [__HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (SNANF64): Likewise. [__HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)] (SNANF32X): Likewise. [__HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)] (SNANF64X): Likewise. [__HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)] (SNANF128X): Likewise.
2017-10-26Add HUGE_VAL macros for more _FloatN, _FloatNx types.Joseph Myers
This patch continues the preparation for additional _FloatN / _FloatNx type support by adding appropriately conditional definitions of HUGE_VAL_* macros, corresponding to the HUGE_VAL_F128 definition already present. Tested for x86_64. * math/math.h [__HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (HUGE_VAL_F16): New macro. [__HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (HUGE_VAL_F32): Likewise. [__HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (HUGE_VAL_F64): Likewise. [__HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)] (HUGE_VAL_F32X): Likewise. [__HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)] (HUGE_VAL_F64X): Likewise. [__HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)] (HUGE_VAL_F128X): Likewise.
2017-10-20Add bits/floatn.h defines for more _FloatN / _FloatNx types.Joseph Myers
The bits/floatn.h header currently only has defines relating to _Float128. This patch adds defines relating to other _FloatN / _FloatNx types. The approach taken is to add defines for all _FloatN / _FloatNx types known to GCC, and to put them in a common bits/floatn-common.h header included at the end of all the individual bits/floatn.h headers. If in future some defines become different for different glibc configurations, they will move out into the separate bits/floatn.h headers. Some defines are expected always to be the same across glibc ports. Corresponding defines are nevertheless put in this header. The intent is that where there are conditionals (in headers or in non-installed files) that can just repeat the same or nearly the same logic for each floating-point type, they should do so, even if in fact the cases for some types could be unconditionally present or absent because the same conditionals are true or false for all glibc configurations. This should make the glibc code with such conditionals easier to read, because the reader can just see that the same conditionals are repeated for each type, rather than seeing different conditionals for different types and needing to reason, at each location with such differences, why those differences are indeed correct there. (Cases involving per-format rather than per-type logic are more likely still to need differences in how they handle different types.) Having such defines and conditionals also helps in incremental preparation for adding _Float32 / _Float64 / _Float32x / _Float64x function aliases. I intend subsequent patches to add such conditionals corresponding to those already present for _Float128, as well as making more architecture-specific function implementations use common macros to define aliases in preparation for adding such _FloatN / _FloatNx aliases. Tested for x86_64. * bits/floatn-common.h: New file. * math/Makefile (headers): Add bits/floatn-common.h. * bits/floatn.h: Include <bits/floatn-common.h>. * sysdeps/ia64/bits/floatn.h: Likewise. * sysdeps/ieee754/ldbl-128/bits/floatn.h: Likewise. * sysdeps/mips/ieee754/bits/floatn.h: Likewise. * sysdeps/powerpc/bits/floatn.h: Likewise. * sysdeps/x86/bits/floatn.h: Likewise.
2017-10-17Let signbit use the builtin in C++ mode with gcc < 6.x (bug 22296)Romain Naour
When using gcc < 6.x, signbit does not use the type-generic __builtin_signbit builtin, instead it uses __MATH_TG. However, when library support for float128 is available, __MATH_TG uses __builtin_types_compatible_p, which is not available in C++ mode. On the other hand, libstdc++ undefines (in cmath) many macros from math.h, including signbit, so that it can provide its own functions. However, during its configure tests, libstdc++ just tests for the availability of the macros (it does not undefine them, nor does it provide its own functions). Finally, libstdc++ configure tests include math.h and get the definition of signbit that uses __MATH_TG (and __builtin_types_compatible_p). Since libstdc++ does not undefine the macros during its configure tests, they fail. This patch lets signbit use the builtin in C++ mode when gcc < 6.x is used. This allows the configure test in libstdc++ to work. Tested for x86_64. [BZ #22296] * math/math.h: Let signbit use the builtin in C++ mode with gcc < 6.x Cc: Gabriel F. T. Gomes <gftg@linux.vnet.ibm.com> Cc: Joseph Myers <joseph@codesourcery.com>
2017-10-16Move some float128 symbol version definitions.Joseph Myers
With support for _Float128 functions on platforms where that type has the same ABI as long double, as well as on platforms where it is ABI-distinct, those functions will need to be exported from glibc's shared libraries at appropriate symbol versions in each case. This patch avoids duplication of lists of symbols to export by moving the symbols other than __* to math/Versions and stdlib/Versions. There, they are conditional on <float128-abi.h> defining FLOAT128_VERSION and a default version of that header is added that does not define that macro. Enabling the float128 function aliases will then include adding a sysdeps/ieee754/ldbl-128/float128-abi.h that defines FLOAT128_VERSION to GLIBC_2.27. Symbols __* remain in sysdeps/ieee754/float128/Versions; those symbols should be present only once per floating-point format, not once per type. Note that if any platforms currently lacking support for a type with binary128 format get glibc support for such a type in future (whether only as _Float128, or also as a new long double format), and new libm functions (present for all types) have been added by then, additional macros will be needed to allow such functions to get a version of the form "GLIBC_2.28 if the platform had _Float128 support by then, or the later version at which that platform had _Float128 support added". This is not however a preexisting condition, but would have applied equally to the existing support for _Float128 as an ABI-distinct type. New all-type libm functions should just be added to the appropriate symbol version (currently GLIBC_2.27) for all types, with such special-case handling for _Float128 versions (and _Float64x as well in future) waiting until someone actually wants to add support for _Float128 to an existing platform after a release in which that platform and a post-2.26 libm function had support but that platform lacked _Float128 support. Tested with build-many-glibcs.py that installed stripped shared libraries are unchanged by this patch. Also tested in conjunction with the remaining changes to enable float128 aliases. * sysdeps/generic/float128-abi.h: New file. * sysdeps/ieee754/float128/Versions (FLOAT128_VERSION): Move non-__prefixed symbols to .... * math/Versions: ... here. Include <float128-abi.h>. * stdlib/Versions ... and here. Include <float128-abi.h>
2017-10-16Support running libm tests for float128 as alias for long double.Joseph Myers
This patch adds support for running libm tests for float128 in the case where the float128 functions are aliases of long double functions. In this case, the sysdeps Makeconfig file (i.e. sysdeps/ieee754/ldbl-128/Makeconfig) will need to define "float128-alias-fcts = yes" to enable the tests. Tested for x86_64. Also tested with build-many-glibcs.py; installed stripped shared libraries are unchanged by the patch. Also tested together with changes to enable the float128 aliases. * math/Makefile (test-types): Add $(type-float128-$(float128-alias-fcts)). * math/test-float128.h (TYPE_STR): Define conditional on [FLT128_MANT_DIG == LDBL_MANT_DIG]. (ULP_IDX): Likewise. (ULP_I_IDX): Likewise.
2017-10-11Run libm long double tests for long double = double.Joseph Myers
All interfaces in the glibc API ought to be covered by the testsuite, even where they alias other interfaces. This patch arranges for libm tests to be run for long double when it aliases double; previously those tests were run only for the floating-point types with distinct formats. The long double tests are made to use the double ulps values in this case, as having a separate duplicate set of ulps for them seems unnecessary; to accommodate that, the test-<type>.h headers now specify the macro indexing into the ulps array explicitly instead of having it computed from PREFIX. Nothing special is done about vector function tests. None are supported for any long double = double platforms, and supporting vector functions for a type alias such as _Float32 would not simply fall out of adding the scalar aliases for that type - it would require vector function wrappers like those for *_finite (or, better, a new GCC feature to allow specifying the asm name for vector functions independently of that for scalar ones, as previously discussed), so it seems reasonable to require the sysdeps makefile setting of libmvec-tests to be updated if any such tests are to be run for type aliases. Tested for x86_64 and arm. * math/Makefile (test-types-basic): New variable. (test-types): Likewise. (libm-test-support): Use $(test-types) instead of $(types). (libm-tests-base-normal): Likewise. (libm-tests-base-finite): Likewise. (libm-tests-base-inline): Likewise. (generated): Likewise. ($(objpfx)libm-test-support-$(t).c): Likewise. (libm-tests-for-type iterator): Likewise. (libm-test-support iterator): Likewise. * math/libm-test-support.c (ulp_i_idx): Use ULP_I_IDX. (ulp_idx): Use ULP_IDX. * math/test-ldouble.h: Include <float.h>. (TYPE_STR): Define conditional on [LDBL_MANT_DIG == DBL_MANT_DIG]. (ULP_IDX): New macro. (ULP_I_IDX): Likewise. * math/test-double.h (ULP_IDX): Likewise. (ULP_I_IDX): Likewise. * math/test-float.h (ULP_IDX): Likewise. (ULP_I_IDX): Likewise. * math/test-float128.h (ULP_IDX): Likewise. (ULP_I_IDX): Likewise.
2017-10-10Add libm_alias_*_other_r macros.Joseph Myers
Some libm functions are unable to use the generic alias macros such as libm_alias_double because they have special symbol versioning requirements for the main float, double or long double public names. To facilitate adding _FloatN / _FloatNx function aliases in future, it's still desirable to have generic macros those functions can use as far as possible. This patch adds macros such as libm_alias_double_other, which only define names for _FloatN / _FloatNx aliases, not for float / double / long double. As present, all these new macros do nothing, but they are called in the appropriate places in macros such as libm_alias_double. This patch also arranges for lgamma implementations, and the recently added optimized float function implementations, to use the new macros to make them ready for addition of _FloatN / _FloatNx aliases. Tested for x86_64, and tested with build-many-glibcs.py that installed stripped shared libraries are unchanged by this patch. * sysdeps/generic/libm-alias-double.h (libm_alias_double_other_r): New macro. (libm_alias_double_other): Likewise. (libm_alias_double_r): Use libm_alias_double_other_r. * sysdeps/generic/libm-alias-float.h (libm_alias_float_other_r): New macro. (libm_alias_float_other): Likewise. (libm_alias_float_r): Use libm_alias_float_other_r. * sysdeps/generic/libm-alias-float128.h (libm_alias_float128_other_r): New macro. (libm_alias_float128_other): Likewise. (libm_alias_float128_r): Use libm_alias_float128_other_r. * sysdeps/generic/libm-alias-ldouble.h (libm_alias_ldouble_other_r): New macro. (libm_alias_ldouble_other): Likewise. (libm_alias_ldouble_r): Use libm_alias_ldouble_other_r. * sysdeps/ieee754/ldbl-opt/libm-alias-double.h (libm_alias_double_other_r): New macro. (libm_alias_double_other): Likewise. (libm_alias_double_r): Use libm_alias_double_other_r. * sysdeps/ieee754/ldbl-opt/libm-alias-ldouble.h (libm_alias_ldouble_other_r): New macro. (libm_alias_ldouble_other): Likewise. (libm_alias_ldouble_r): Use libm_alias_ldouble_other_r. * math/w_lgamma_main.c: Include <libm-alias-double.h>. [!USE_AS_COMPAT]: Use libm_alias_double_other. * math/w_lgammaf_main.c: Include <libm-alias-float.h>. [!USE_AS_COMPAT]: Use libm_alias_float_other. * math/w_lgammal_main.c: Include <libm-alias-ldouble.h>. [!USE_AS_COMPAT]: Use libm_alias_ldouble_other. * math/w_exp2f.c: Use libm_alias_float_other. * math/w_expf.c: Likewise. * math/w_log2f.c: Likewise. * math/w_logf.c: Likewise. * math/w_powf.c: Likewise. * sysdeps/ieee754/flt-32/e_exp2f.c: Include <libm-alias-float.h>. [!__exp2f]: Use libm_alias_float_other. * sysdeps/ieee754/flt-32/e_expf.c: Include <libm-alias-float.h>. [!__expf]: Use libm_alias_float_other. * sysdeps/ieee754/flt-32/e_log2f.c: Include <libm-alias-float.h>. [!__log2f]: Use libm_alias_float_other. * sysdeps/ieee754/flt-32/e_logf.c: Include <libm-alias-float.h>. [!__logf]: Use libm_alias_float_other. * sysdeps/ieee754/flt-32/e_powf.c: Include <libm-alias-float.h>. [!__powf]: Use libm_alias_float_other.
2017-10-09Use generic macros for lgamma_r function aliases.Joseph Myers
Continuing the use of generic macros for defining libm function aliases, in preparation for adding more _FloatN / _FloatNx function names, this patch makes the lgamma_r functions use such macros. declare_mgen_alias_r becomes a standard macro in math-type-macros.h instead of being locally defined in w_lgamma_r_templace.c. This in turn must be defined by each math-type-macros-<type>.h. Rather than providing an unused default in math-type-macros.h, that header is made to give an error if math-type-macros-<type>.h failed to define declare_mgen_alias or declare_mgen_alias_r. The compat lgamma_r wrappers are updated similarly. The ldbl-opt versions are removed as no longer needed. Tested for x86_64, and with build-many-glibcs.py. Installed stripped shared libraries are unchanged except for powerpc64le (where the usual issue applies that an ldbl-opt long double function previously used long_double_symbol unconditionally and now the symbol versions on powerpc64le mean weak_alias is used instead, resulting in the same symbol versions in the final shared library but still enough difference in the input objects for that library not to be byte-identical). * sysdeps/generic/math-type-macros.h [!declare_mgen_alias]: Give error. Remove default definition of declare_mgen_alias. [!declare_mgen_alias_r]: Likewise. * sysdeps/generic/math-type-macros-double.h [!declare_mgen_alias_r] (declare_mgen_alias_r): New macro. * sysdeps/generic/math-type-macros-float.h [!declare_mgen_alias_r] (declare_mgen_alias_r): Likewise. * sysdeps/generic/math-type-macros-float128.h [!declare_mgen_alias_r] (declare_mgen_alias_r): Likewise. * sysdeps/generic/math-type-macros-ldouble.h [!declare_mgen_alias_r] (declare_mgen_alias_r): Likewise. * math/w_lgamma_r_template.c (declare_mgen_alias_r_x): Remove macro. (declare_mgen_alias_r_s): Likewise. (declare_mgen_alias_r): Likewise. * math/w_lgamma_r_compat.c: Include <libm-alias-double.h>. (lgamma_r): Define using libm_alias_double_r. * math/w_lgammaf_r_compat.c: Include <libm-alias-float.h>. (lgammaf_r): Define using libm_alias_float_r. * math/w_lgammal_r_compat.c: Include <libm-alias-ldouble.h>. (lgammal_r): Define using libm_alias_ldouble_r. * sysdeps/ieee754/ldbl-opt/w_lgamma_r_compat.c: Remove file. * sysdeps/ieee754/ldbl-opt/w_lgammal_r_compat.c: Likewise.
2017-10-09Ensure C99 and C11 interfaces are available for C++ [BZ #21326]Jonathan Wakely
This patch ensures that the C99 and C11 features required by C++ are defined according to the value of the __cplusplus macro, and not just because G++ always defines _GNU_SOURCE. This will allow G++ to stop defining _GNU_SOURCE some day, without causing the C99 and C11 interfaces to disappear for C++ programs. [BZ #21326] * include/features.h [__cplusplus >= 201103] (__USE_ISOC99): Define. [__cplusplus >= 201703] (__USE_ISOCXX17, __USE_ISOC11): Define. * math/Makefile (test-math-cxx11): New test. * math/test-math-cxx11.cc: New file.
2017-10-04test-math-iscanonical.cc: Return errors != 0H.J. Lu
Since not all non-zero error counts are errors, return errors != 0 instead. * math/test-math-iscanonical.cc (do_test): Return errors != 0.
2017-10-03test-math-iscanonical.cc: Replace bool with intH.J. Lu
Fix GCC 7 compilation error: test-math-iscanonical.cc: In function ‘void check_type()’: test-math-iscanonical.cc:33:11: error: use of an operand of type ‘bool’ in ‘operator++’ is deprecated [-Werror=deprecated] errors++; ^~ * math/test-math-iscanonical.cc (error): Replace bool with int.
2017-10-03Add C++ versions of iscanonical for ldbl-96 and ldbl-128ibm (bug 22235)Gabriel F. T. Gomes
All representations of floating-point numbers in types with IEC 60559 binary exchange format are canonical. On the other hand, types with IEC 60559 extended formats, such as those implemented under ldbl-96 and ldbl-128ibm, contain representations that are not canonical. TS 18661-1 introduced the type-generic macro iscanonical, which returns whether a floating-point value is canonical or not. In Glibc, this type-generic macro is implemented using the macro __MATH_TG, which, when support for float128 is enabled, relies on __builtin_types_compatible_p to select between floating-point types. However, this use of iscanonical breaks C++ applications, because the builtin is only available in C mode. This patch provides a C++ implementation of iscanonical that relies on function overloading, rather than builtins, to select between floating-point types. Unlike the C++ implementations for iszero and issignaling, this implementation ignores __NO_LONG_DOUBLE_MATH. The double type always matches IEC 60559 double format, which is always canonical. Thus, when double and long double are the same (__NO_LONG_DOUBLE_MATH), iscanonical always returns 1 and is not implemented with __MATH_TG. Tested for powerpc64, powerpc64le and x86_64. [BZ #22235] * math/math.h: Trivial fix for unbalanced parentheses in comment. * math/Makefile [CXX] (tests): Add test-math-iscanonical.cc. (CFLAGS-test-math-iscanonical.cc): New variable. * math/test-math-iscanonical.cc: New file. * sysdeps/ieee754/ldbl-96/bits/iscanonical.h (iscanonical): Provide a C++ implementation based on function overloading, rather than using __MATH_TG, which uses C-only builtins. * sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h (iscanonical): Likewise. * sysdeps/powerpc/powerpc64le/Makefile (CFLAGS-test-math-iscanonical.cc): New variable.
2017-10-03fix drem symbol for static linking and new targetsSzabolcs Nagy
The compat remainder code is no longer built for !LIBM_SVID_COMPAT targets, but the legacy drem, dremf and dreml symbols should be still defined since removing them may break existing code, so keep them as aliases in the non-compat remainder code. * math/w_remainder.c: New file. * math/w_remainderf.c: New file. * math/w_remainderl.c: New file.
2017-10-02fix gamma symbol for static linking and new targetsSzabolcs Nagy
The lgamma compat code is no longer built for !LIBM_SVID_COMPAT targets, but the legacy gamma, gammaf and gammal symbols should be still defined, so make them aliases to the non-compat lgamma code. * math/w_lgamma.c: New file. * math/w_lgammaf.c: New file. * math/w_lgammal.c: New file.
2017-10-02New symbol version for logf, log2f and powf without SVID compatSzabolcs Nagy
This patch changes the logf, log2f and powf error handling semantics to only set errno accoring to POSIX rules. New symbol version is introduced at GLIBC_2.27. The old wrappers are kept for compat symbols. ia64 needed assembly change to have the new and compat versioned symbol map to the same function. All linux libm abilists are updated. * math/Versions (logf): New libm symbol at GLIBC_2.27. (log2f): Likewise. (powf): Likewise. * math/w_log2f.c: New file. * math/w_logf.c: New file. * math/w_powf.c: New file. * math/w_log2f_compat.c (__log2f_compat): For compat symbol only. * math/w_logf_compat.c (__logf_compat): Likewise. * math/w_powf_compat.c (__powf_compat): Likewise. * sysdeps/ia64/fpu/e_log2f.S: Add versioned symbols. * sysdeps/ia64/fpu/e_logf.S: Likewise. * sysdeps/ia64/fpu/e_powf.S: Likewise. * sysdeps/unix/sysv/linux/aarch64/libm.abilist: Update. * sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
2017-09-29Remove old cimag inlinesWilco Dijkstra
Remove old cimag inlines that are only used in GCC 2.96 or older. * math/bits/cmathcalls.h (cimag): Remove inline. (creal): Remove inline. (conj): Remove inline.
2017-09-29New generic powfSzabolcs Nagy
without wrapper on aarch64: powf reciprocal-throughput: 4.2x faster powf latency: 2.6x faster old worst-case error: 1.11 ulp new worst-case error: 0.82 ulp aarch64 .text size: -780 bytes aarch64 .rodata size: +144 bytes powf(x,y) is implemented as exp2(y*log2(x)) with the same algorithms that are used in exp2f and log2f, except that the log2f polynomial is larger for extra precision and its output (and exp2f input) may be scaled by a power of 2 (POWF_SCALE) to simplify the argument reduction step of exp2 (possible when efficient round and convert toint operation is available). The special case handling tries to minimize the checks in the hot path. When the input of exp2_inline is checked, int arithmetics is used as that was faster on the tested aarch64 cores. * math/Makefile (type-float-routines): Add e_powf_log2_data. * sysdeps/ieee754/flt-32/e_powf.c: New implementation. * sysdeps/ieee754/flt-32/e_powf_log2_data.c: New file. * sysdeps/ieee754/flt-32/math_config.h (__powf_log2_data): Define. (issignalingf_inline): Likewise. (POWF_LOG2_TABLE_BITS): Likewise. (POWF_LOG2_POLY_ORDER): Likewise. (POWF_SCALE_BITS): Likewise. (POWF_SCALE): Likewise. * sysdeps/i386/fpu/e_powf_log2_data.c: New file. * sysdeps/ia64/fpu/e_powf_log2_data.c: New file. * sysdeps/m68k/m680x0/fpu/e_powf_log2_data.c: New file.
2017-09-29New generic log2fSzabolcs Nagy
Similar to the new logf: double precision arithmetics and a small lookup table is used. The argument reduction step is the same as in the new logf. without wrapper on aarch64: log2f reciprocal-throughput: 2.3x faster log2f latency: 2.1x faster old worst case error: 1.72 ulp new worst case error: 0.75 ulp aarch64 .text size: -252 bytes aarch64 .rodata size: +244 bytes * math/Makefile (type-float-routines): Add e_log2f_data. * sysdeps/ieee754/flt-32/e_log2f.c: New implementation. * sysdeps/ieee754/flt-32/e_log2f_data.c: New file. * sysdeps/ieee754/flt-32/math_config.h (__log2f_data): Define. (LOG2F_TABLE_BITS, LOG2F_POLY_ORDER): Define. * sysdeps/i386/fpu/e_log2f_data.c: New file. * sysdeps/ia64/fpu/e_log2f_data.c: New file. * sysdeps/m68k/m680x0/fpu/e_log2f_data.c: New file.
2017-09-29New generic logfSzabolcs Nagy
without wrapper on aarch64: logf reciprocal-throughput: 2.2x faster logf latency: 1.9x faster old worst case error: 0.89 ulp new worst case error: 0.82 ulp aarch64 .text size: -356 bytes aarch64 .rodata size: +240 bytes Uses double precision arithmetics and a lookup table to allow smaller polynomial and avoid the use of division. Data is in a separate translation unit with fixed layout to prevent the compiler generating suboptimal literal access. Errors are handled inline according to POSIX rules, but this patch keeps the wrapper with SVID compatible error handling. Needs libm-test-ulps adjustment for clogf in non-nearest rounding mode. * math/Makefile (type-float-routines): Add e_logf_data. * sysdeps/ieee754/flt-32/e_logf.c: New implementation. * sysdeps/ieee754/flt-32/e_logf_data.c: New file. * sysdeps/ieee754/flt-32/math_config.h (__logf_data): Define. (LOGF_TABLE_BITS, LOGF_POLY_ORDER): Define. * sysdeps/i386/fpu/e_logf_data.c: New file. * sysdeps/ia64/fpu/e_logf_data.c: New file. * sysdeps/m68k/m680x0/fpu/e_logf_data.c: New file.
2017-09-28Simplify C99 isgreater macrosWilco Dijkstra
Simplify the C99 isgreater macros. Although some support was added in GCC 2.97, not all targets added support until GCC 3.1. Therefore only use the builtins in math.h from GCC 3.1 onwards, and defer to generic macros otherwise. Improve the generic isunordered macro to use compares rather than call fpclassify twice - this is not only faster but also correct for signaling NaNs. * math/math.h: Improve handling of C99 isgreater macros. * sysdeps/alpha/fpu/bits/mathinline.h: Remove isgreater macros. * sysdeps/m68k/m680x0/fpu/bits/mathinline.h: Likewise. * sysdeps/powerpc/bits/mathinline.h: Likewise. * sysdeps/sparc/fpu/bits/mathinline.h: Likewise. * sysdeps/x86/fpu/bits/mathinline.h: Likewise.
2017-09-25New expf and exp2f version without SVID compat wrapperSzabolcs Nagy
This patch changes the expf and exp2f error handling semantics to only set errno accoring to POSIX rules. New symbol version is introduced at GLIBC_2.27. The old wrappers are kept for compat symbols. Internal calls to __expf now get the new error semantics, this seems to only affect sysdeps/i386/fpu/s_expm1f.S where the errno-only behaviour should be correct. ia64 needed assembly change to have the new and compat versioned symbol map to the same function. All linux libm abilists are updated. * math/Versions (expf): New libm symbol at GLIBC_2.27. (exp2f): Likewise. * math/w_exp2f.c: New file. * math/w_expf.c: New file. * math/w_exp2f_compat.c (__exp2f_compat): For compat symbol only. * math/w_expf_compat.c (__expf_compat): Likewise. * sysdeps/ia64/fpu/e_exp2f.S: Add versioned symbols. * sysdeps/ia64/fpu/e_expf.S: Likewise. * sysdeps/unix/sysv/linux/aarch64/libm.abilist: Update. * sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
2017-09-25Optimized generic expf and exp2f with wrappersSzabolcs Nagy
Based on new expf and exp2f code from https://github.com/ARM-software/optimized-routines/ with wrapper on aarch64: expf reciprocal-throughput: 2.3x faster expf latency: 1.7x faster without wrapper on aarch64: expf reciprocal-throughput: 3.3x faster expf latency: 1.7x faster without wrapper on aarch64: exp2f reciprocal-throughput: 2.8x faster exp2f latency: 1.3x faster libm.so size on aarch64: .text size: -152 bytes .rodata size: -1740 bytes expf/exp2f worst case nearest rounding error: 0.502 ulp worst case non-nearest rounding error: 1 ulp Error checks are inline and errno setting is in separate tail called functions, but the wrappers are kept in this patch to handle the _LIB_VERSION==_SVID_ case. (So e.g. errno is set twice for expf calls and once for __expf_finite calls on targets where the new code is used.) Double precision arithmetics is used which is expected to be faster on most targets (including soft-float) than using single precision and it is easier to get good precision result with it. Const data is kept in a separate translation unit which complicates maintenance a bit, but is expected to give good code for literal loads on most targets and allows sharing data across expf, exp2f and powf. (This data is disabled on i386, m68k and ia64 which have their own expf, exp2f and powf code.) Some details may need target specific tweaks: - best convert and round to int operation in the arg reduction may be different across targets. - code was optimized on fma target, optimal polynomial eval may be different without fma. - gcc does not always generate good code for fp bit representation access via unions or it may be inherently slow on some targets. The libm-test-ulps will need adjustment because.. - The argument reduction ideally uses nearest rounded rint, but that is not efficient on most targets, so the polynomial can get evaluated on a wider interval in non-nearest rounding mode making 1 ulp errors common in that case. - The polynomial is evaluated such that it may have 1 ulp error on negative tiny inputs with upward rounding. * math/Makefile (type-float-routines): Add math_errf and e_exp2f_data. * sysdeps/aarch64/fpu/math_private.h (TOINT_INTRINSICS): Define. (roundtoint, converttoint): Likewise. * sysdeps/ieee754/flt-32/e_expf.c: New implementation. * sysdeps/ieee754/flt-32/e_exp2f.c: New implementation. * sysdeps/ieee754/flt-32/e_exp2f_data.c: New file. * sysdeps/ieee754/flt-32/math_config.h: New file. * sysdeps/ieee754/flt-32/math_errf.c: New file. * sysdeps/ieee754/flt-32/t_exp2f.h: Remove. * sysdeps/i386/fpu/e_exp2f_data.c: New file. * sysdeps/i386/fpu/math_errf.c: New file. * sysdeps/ia64/fpu/e_exp2f_data.c: New file. * sysdeps/ia64/fpu/math_errf.c: New file. * sysdeps/m68k/m680x0/fpu/e_exp2f_data.c: New file. * sysdeps/m68k/m680x0/fpu/math_errf.c: New file.
2017-09-22Let fpclassify use the builtin when optimizing for size in C++ mode (bug 22146)Gabriel F. T. Gomes
When optimization for size is on (-Os), fpclassify does not use the type-generic __builtin_fpclassify builtin, instead it uses __MATH_TG. However, when library support for float128 is available, __MATH_TG uses __builtin_types_compatible_p, which is not available in C++ mode. On the other hand, libstdc++ undefines (in cmath) many macros from math.h, including fpclassify, so that it can provide its own functions. However, during its configure tests, libstdc++ just tests for the availability of the macros (it does not undefine them, nor does it provide its own functions). Finally, when libstdc++ is configured with optimization for size enabled, its configure tests include math.h and get the definition of fpclassify that uses __MATH_TG (and __builtin_types_compatible_p). Since libstdc++ does not undefine the macros during its configure tests, they fail. This patch lets fpclassify use the builtin in C++ mode, even when optimization for size is on. This allows the configure test in libstdc++ to work. Tested for powerpc64le and x86_64. [BZ #22146] math/math.h: Let fpclassify use the builtin in C++ mode, even when optimazing for size.
2017-09-18Use libm_alias_ldouble in math/.Joseph Myers
This patch converts libm function implementations in math/ from using weak_alias to using libm_alias_ldouble to define public function names, in cases where it would be appropriate to define _Float128 / _Float64x aliases for those functions as well (in cases where either or both of those types exist and have the same ABI as long double). This eliminates many ldbl-opt wrappers round these function implementations. Tested for x86_64, and with build-many-glibcs.py. All installed stripped shared libraries are unchanged except for libm.so on powerpc64le. As noted for a previous patch, powerpc64le's use of ldbl-opt means various long double functions get defined using long_double_symbol which gives them an explicit symbol version in the object files, and this patch results in some such functions using weak_alias instead (because powerpc64le never had a previous version of these functions for long double = double); both produce a valid libm.so with the same public symbols at the same versions, but macros expanding to call weak_alias is cleaner in this case. * math/s_fmal.c: Include <libm-alias-ldouble.h>. (fmal): Define using libm_alias_ldouble. * math/w_acoshl_compat.c: Include <libm-alias-ldouble.h>. (acoshl): Define using libm_alias_ldouble. * math/w_acosl_compat.c: Include <libm-alias-ldouble.h>. (acosl): Define using libm_alias_ldouble. * math/w_asinl_compat.c: Include <libm-alias-ldouble.h>. (asinl): Define using libm_alias_ldouble. * math/w_atan2l_compat.c: Include <libm-alias-ldouble.h>. (atan2l): Define using libm_alias_ldouble. * math/w_atanhl_compat.c: Include <libm-alias-ldouble.h>. (atanhl): Define using libm_alias_ldouble. * math/w_coshl_compat.c: Include <libm-alias-ldouble.h>. (coshl): Define using libm_alias_ldouble. * math/w_exp10l_compat.c: Include <libm-alias-ldouble.h>. (exp10l): Define using libm_alias_ldouble. * math/w_exp2l_compat.c: Include <libm-alias-ldouble.h>. (exp2l): Define using libm_alias_ldouble. * math/w_expl_compat.c: Include <libm-alias-ldouble.h>. (expl): Define using libm_alias_ldouble. * math/w_fmodl_compat.c: Include <libm-alias-ldouble.h>. (fmodl): Define using libm_alias_ldouble. * math/w_hypotl_compat.c: Include <libm-alias-ldouble.h>. (hypotl): Define using libm_alias_ldouble. * math/w_j0l_compat.c: Include <libm-alias-ldouble.h>. (j0l): Define using libm_alias_ldouble. (y0l): Likewise. * math/w_j1l_compat.c: Include <libm-alias-ldouble.h>. (j1l): Define using libm_alias_ldouble. (y1l): Likewise. * math/w_jnl_compat.c: Include <libm-alias-ldouble.h>. (jnl): Define using libm_alias_ldouble. (ynl): Likewise. * math/w_log10l_compat.c: Include <libm-alias-ldouble.h>. (log10l): Define using libm_alias_ldouble. * math/w_log2l_compat.c: Include <libm-alias-ldouble.h>. (log2l): Define using libm_alias_ldouble. * math/w_logl_compat.c: Include <libm-alias-ldouble.h>. (logl): Define using libm_alias_ldouble. * math/w_powl_compat.c: Include <libm-alias-ldouble.h>. (powl): Define using libm_alias_ldouble. * math/w_remainderl_compat.c: Include <libm-alias-ldouble.h>. (remainderl): Define using libm_alias_ldouble. * math/w_sinhl_compat.c: Include <libm-alias-ldouble.h>. (sinhl): Define using libm_alias_ldouble. * math/w_sqrtl_compat.c: Include <libm-alias-ldouble.h>. (sqrtl): Define using libm_alias_ldouble. * math/w_tgammal_compat.c: Include <libm-alias-ldouble.h>. (tgammal): Define using libm_alias_ldouble. * sysdeps/ieee754/ldbl-opt/w_exp10l_compat.c [LIBM_SVID_COMPAT] (exp10l): Do not use long_double_symbol here. * sysdeps/ieee754/ldbl-opt/w_remainderl_compat.c [LIBM_SVID_COMPAT] (remainderl): Likewise. * sysdeps/ieee754/ldbl-opt/s_fmal.c: Remove. * sysdeps/ieee754/ldbl-opt/w_acoshl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_acosl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_asinl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_atan2l_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_atanhl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_coshl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_expl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_fmodl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_hypotl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_j0l_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_j1l_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_jnl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_log10l_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_log2l_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_logl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_powl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_sinhl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_sqrtl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_tgammal_compat.c: Likewise.
2017-09-15Use libm_alias_double in math/.Joseph Myers
This patch converts libm function implementations in math/ from using weak_alias to using libm_alias_double to define public function names, in cases where it would be appropriate to define _Float64 / _Float32x aliases for those functions as well. This eliminates many NO_LONG_DOUBLE conditionals and ldbl-opt wrappers round these function implementations. Tested for x86_64. Also tested with build-many-glibcs.py. Binary differences seen are that the different order in which remainder and drem symbols get defined as a result of this patch (the same source file defines the same aliases, but in a different order of definition) changes the order of symbols in the final libm.so when long double = double, and for ldbl-opt configurations, the compat symbols for Bessel functions were previously defined by e.g. "compat_symbol (libm, j0, j0l, GLIBC_2_0)", which declares j0l as a compat symbol based on j0 and so makes j0l weak because j0 is weak, and are now defined (indirectly via the relevant macros) based on e.g. __j0, so are no longer weak because __j0 isn't weak. * math/s_fma.c: Include <libm-alias-double.h>. (fma): Define using libm_alias_double. * math/s_nextafter.c: Include <libm-alias-double.h>. (nextafter): Define using libm_alias_double. * math/w_acos_compat.c: Include <libm-alias-double.h>. (acos): Define using libm_alias_double. * math/w_acosh_compat.c: Include <libm-alias-double.h>. (aocsh): Define using libm_alias_double. * math/w_asin_compat.c: Include <libm-alias-double.h>. (asin): Define using libm_alias_double. * math/w_atan2_compat.c: Include <libm-alias-double.h>. (atan2): Define using libm_alias_double. * math/w_atanh_compat.c: Include <libm-alias-double.h>. (atanh): Define using libm_alias_double. * math/w_cosh_compat.c: Include <libm-alias-double.h>. (cosh): Define using libm_alias_double. * math/w_exp10_compat.c: Include <libm-alias-double.h>. (exp10): Define using libm_alias_double. * math/w_exp2_compat.c: Include <libm-alias-double.h>. (exp2): Define using libm_alias_double. * math/w_exp_compat.c: Include <libm-alias-double.h>. (exp): Define using libm_alias_double. * math/w_fmod_compat.c: Include <libm-alias-double.h>. (fmod): Define using libm_alias_double. * math/w_hypot_compat.c: Include <libm-alias-double.h>. (hypot): Define using libm_alias_double. * math/w_j0_compat.c: Include <libm-alias-double.h>. (j0): Define using libm_alias_double. (y0): Likewise. * math/w_j1_compat.c: Include <libm-alias-double.h>. (j1): Define using libm_alias_double. (y1): Likewise. * math/w_jn_compat.c: Include <libm-alias-double.h>. (jn): Define using libm_alias_double. (yn): Likewise. * math/w_log10_compat.c: Include <libm-alias-double.h>. (log10): Define using libm_alias_double. * math/w_log2_compat.c: Include <libm-alias-double.h>. (log2): Define using libm_alias_double. * math/w_log_compat.c: Include <libm-alias-double.h>. (log): Define using libm_alias_double. * math/w_pow_compat.c: Include <libm-alias-double.h>. (pow): Define using libm_alias_double. * math/w_remainder_compat.c: Include <libm-alias-double.h>. (remainder): Define using libm_alias_double. * math/w_sinh_compat.c: Include <libm-alias-double.h>. (sinh): Define using libm_alias_double. * math/w_sqrt_compat.c: Include <libm-alias-double.h>. (sqrt): Define using libm_alias_double. * math/w_tgamma_compat.c: Include <libm-alias-double.h>. (tgamma): Define using libm_alias_double. * sysdeps/ieee754/ldbl-opt/s_nextafter.c [LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)] (nextafterl): Do not define compat symbol here. * sysdeps/ieee754/ldbl-opt/w_exp10_compat.c [LONG_DOUBLE_COMPAT(libm, GLIBC_2_1)] (exp10l): Likewise. * sysdeps/ieee754/ldbl-opt/w_remainder_compat.c [LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)] (remainderl): Likewise. * sysdeps/ieee754/ldbl-opt/w_acos_compat.c: Remove. * sysdeps/ieee754/ldbl-opt/w_acosh_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_asin_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_atan2_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_atanh_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_cosh_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_exp_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_fmod_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_hypot_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_j0_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_j1_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_jn_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_log10_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_log2_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_log_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_pow_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_sinh_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_sqrt_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_tgamma_compat.c: Likewise.
2017-09-15Remove ENOSYS math/ function stubs.Joseph Myers
The math/ directory has various stub implementations of functions (generally long double functions, plus sqrtf128) that set errno to ENOSYS and print a message. These are a relic of when the long double libm implementation in glibc was originally incomplete. They are only present for a limited set of libm functions, not all those that would need implementing for any hypothetical new long double format, and only for long double (plus sqrtf128), not for other floating-point types. I removed the corresponding ENOSYS tests in the testsuite in <https://sourceware.org/ml/libc-alpha/2013-05/msg00599.html>. I think these stubs are an inherently different case from stubs for functionality needing OS-specific implementations, since floating-point formats are generally standardized between modern processors (a new long double format does not seem likely - I'd expect new ports all to have long double = binary128 or long double = binary64 - though _Float16 functions *f16 are entirely possible in future) and libm functions are generally only expected to fail for domain / range / pole errors, not for other unknown system-specific conditions the way the functions needing OS-specific implementations may fail. This patch removes these stub implementations. The effect (which, as noted above, was actually mostly already the case, given the incompleteness of the set of stubs, and was certainly the case if you wanted your libm port to *work* rather than just build) is that any new long double format needs to provide a full set of functions for the build to succeed; any port using ldbl-128 needs to provide sqrtl (possibly using the soft-fp version from another port); any port using ldbl-96 needs to provide all those functions that all of x86_64/i386/ia64/m68k provide rather than getting from the ldbl-96 directory; any port with _Float128 as a type with a distinct format needs to provide sqrtf128. Tested for x86_64. Also tested with build-many-glibcs.py that installed stripped shared libraries are unchanged by the patch. * math/e_acoshl.c: Remove. * math/e_acosl.c: Likewise. * math/e_asinl.c: Likewise. * math/e_atan2l.c: Likewise. * math/e_atanhl.c: Likewise. * math/e_coshl.c: Likewise. * math/e_expl.c: Likewise. * math/e_fmodl.c: Likewise. * math/e_gammal_r.c: Likewise. * math/e_hypotl.c: Likewise. * math/e_j0l.c: Likewise. * math/e_j1l.c: Likewise. * math/e_jnl.c: Likewise. * math/e_lgammal_r.c: Likewise. * math/e_log10l.c: Likewise. * math/e_log2l.c: Likewise. * math/e_logl.c: Likewise. * math/e_powl.c: Likewise. * math/e_rem_pio2l.c: Likewise. * math/e_sinhl.c: Likewise. * math/e_sqrtf128.c: Likewise. * math/e_sqrtl.c: Likewise. * math/k_cosl.c: Likewise. * math/k_sinl.c: Likewise. * math/k_tanl.c: Likewise. * math/s_asinhl.c: Likewise. * math/s_atanl.c: Likewise. * math/s_cbrtl.c: Likewise. * math/s_erfl.c: Likewise. * math/s_expm1l.c: Likewise. * math/s_log1pl.c: Likewise. * math/s_tanhl.c: Likewise.
2017-09-15Use libm_alias_float in math/.Joseph Myers
This patch converts libm function implementations in math/ from using weak_alias to using libm_alias_float to define public function names, in cases where it would be appropriate to define _Float32 aliases for those functions as well. expf and exp2f are omitted from this patch, given the in-progress patches that would change their symbol versioning arrangements (at a later stage it will be necessary to add macros that can be used for functions with such symbol versioning arrangements - which will apply to lgammaf as well - but for the initial patches in this area I'm just dealing with easy cases, and any symbol versioning changes to these functions while the work is in progress can effectively just undo the libm_alias_* changes as regards those functions). Tested for x86_64. Also tested with build-many-glibcs.py that installed stripped shared libraries are unchanged by the patch. * math/s_fmaf.c: Include <libm-alias-float.h>. (fmaf): Define using libm_alias_float. * math/w_acosf_compat.c: Include <libm-alias-float.h>. (acosf): Define using libm_alias_float. * math/w_acoshf_compat.c: Include <libm-alias-float.h>. (acoshf): Define using libm_alias_float. * math/w_asinf_compat.c: Include <libm-alias-float.h>. (asinf): Define using libm_alias_float. * math/w_atan2f_compat.c: Include <libm-alias-float.h>. (atan2f): Define using libm_alias_float. * math/w_atanhf_compat.c: Include <libm-alias-float.h>. (atanhf): Define using libm_alias_float. * math/w_coshf_compat.c: Include <libm-alias-float.h>. (coshf): Define using libm_alias_float. * math/w_exp10f_compat.c: Include <libm-alias-float.h>. (exp10f): Define using libm_alias_float. * math/w_fmodf_compat.c: Include <libm-alias-float.h>. (fmodf): Define using libm_alias_float. * math/w_hypotf_compat.c: Include <libm-alias-float.h>. (hypotf): Define using libm_alias_float. * math/w_j0f_compat.c: Include <libm-alias-float.h>. (j0f): Define using libm_alias_float. (y0f): Likewise. * math/w_j1f_compat.c: Include <libm-alias-float.h>. (j1f): Define using libm_alias_float. (y1f): Likewise. * math/w_jnf_compat.c: Include <libm-alias-float.h>. (jnf): Define using libm_alias_float. (ynf): Likewise. * math/w_log10f_compat.c: Include <libm-alias-float.h>. (log10f): Define using libm_alias_float. * math/w_log2f_compat.c: Include <libm-alias-float.h>. (log2f): Define using libm_alias_float. * math/w_logf_compat.c: Include <libm-alias-float.h>. (logf): Define using libm_alias_float. * math/w_powf_compat.c: Include <libm-alias-float.h>. (powf): Define using libm_alias_float. * math/w_remainderf_compat.c: Include <libm-alias-float.h>. (remainderf): Define using libm_alias_float. * math/w_sinhf_compat.c: Include <libm-alias-float.h>. (sinhf): Define using libm_alias_float. * math/w_sqrtf_compat.c: Include <libm-alias-float.h>. (sqrtf): Define using libm_alias_float. * math/w_tgammaf_compat.c: Include <libm-alias-float.h>. (tgammaf): Define using libm_alias_float.
2017-09-14Make more libm functions into weak aliases.Joseph Myers
Many libm functions define the function as __<func> and then define <func> as a weak alias. This is not at all limited to cases where there is an internal call that has namespace reasons to need to call __<func> instead of <func>. The common macros for creating libm function aliases work on the basis of public function names all being aliases; that is, they define aliases for functions using the above pattern. Thus, where a function just defines the public name <func> directly, changing that to be a weak alias enables a subsequent conversion to the common macros to retain the exact existing symbols (and so be testable by comparison of stripped binaries). This patch converts many existing functions to use the weak alias pattern, as preparation for subsequent conversions to common macros. I do expect that _FloatN/_FloatNx function aliases will end up needing new variants of the common macros that do *not* create the original float / double / long double name of a function - for cases where that name is created specially to give it a particular symbol version, for example - but for functions that can use the most common macros to create all the public names as aliases, it makes sense for them to do so. Regarding the Bessel function wrappers in this patch: only float and double wrappers are changed because the long double wrappers already used the weak alias pattern. Tested for x86_64, and with build-many-glibcs.py. * include/math.h (roundeven): Change hidden_proto call to __roundeven. * math/w_j0_compat.c (j0): Rename to __j0 and define as weak alias. [NO_LONG_DOUBLE] (__j0l): New strong alias. (y0): Rename to __y0 and define as weak alias. [NO_LONG_DOUBLE] (__y0l): New strong alias. * math/w_j0f_compat.c (j0f): Rename to __j0f and define as weak alias. (y0f): Rename to __y0f and define as weak alias. * math/w_j1_compat.c (j1): Rename to __j1 and define as weak alias. [NO_LONG_DOUBLE] (__j1l): New strong alias. (y1): Rename to __y1 and define as weak alias. [NO_LONG_DOUBLE] (__y1l): New strong alias. * math/w_j1f_compat.c (j1f): Rename to __j1f and define as weak alias. (y1f): Rename to __y1f and define as weak alias. * math/w_jn_compat.c (jn): Rename to __jn and define as weak alias. [NO_LONG_DOUBLE] (__jnl): New strong alias. (yn): Rename to __yn and define as weak alias. [NO_LONG_DOUBLE] (__ynl): New strong alias. * math/w_jnf_compat.c (jnf): Rename to __jnf and define as weak alias. (ynf): Rename to __ynf and define as weak alias. * sysdeps/ieee754/dbl-64/s_fromfp.c (FUNC): Define to __fromfp. (fromfp): Define as weak alias. [NO_LONG_DOUBLE] (__fromfpl): New strong alias. * sysdeps/ieee754/dbl-64/s_fromfpx.c (FUNC): Define to __fromfpx. (fromfpx): Define as weak alias. [NO_LONG_DOUBLE] (__fromfpxl): New strong alias. * sysdeps/ieee754/dbl-64/s_getpayload.c (getpayload): Rename to __getpayload and define as weak alias. [NO_LONG_DOUBLE] (__getpayloadl): New strong alias. * sysdeps/ieee754/dbl-64/s_roundeven.c (roundeven): Rename to __roundeven and define as weak alias. [NO_LONG_DOUBLE] (__roundevenl): New strong alias. * sysdeps/ieee754/dbl-64/s_setpayload.c (FUNC): Define to __setpayload. (setpayload): Define as weak alias. [NO_LONG_DOUBLE] (__setpayloadl): New strong alias. * sysdeps/ieee754/dbl-64/s_setpayloadsig.c (FUNC): Define to __setpayloadsig. (setpayloadsig): Define as weak alias. [NO_LONG_DOUBLE] (__setpayloadsigl): New strong alias. * sysdeps/ieee754/dbl-64/s_totalorder.c (totalorder): Rename to __totalorder and define as weak alias. [NO_LONG_DOUBLE] (__totalorderl): New strong alias. * sysdeps/ieee754/dbl-64/s_totalordermag.c (totalordermag): Rename to __totalordermag and define as weak alias. [NO_LONG_DOUBLE] (__totalordermagl): New strong alias. * sysdeps/ieee754/dbl-64/s_ufromfp.c (FUNC): Define to __ufromfp. (ufromfp): Define as weak alias. [NO_LONG_DOUBLE] (__ufromfpl): New strong alias. * sysdeps/ieee754/dbl-64/s_ufromfpx.c (FUNC): Define to __ufromfpx. (ufromfpx): Define as weak alias. [NO_LONG_DOUBLE] (__ufromfpxl): New strong alias. * sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c (getpayload): Rename to __getpayload and define as weak alias. [NO_LONG_DOUBLE] (__getpayloadl): New strong alias. * sysdeps/ieee754/dbl-64/wordsize-64/s_roundeven.c (roundeven): Rename to __roundeven and define as weak alias. [NO_LONG_DOUBLE] (__roundevenl): New strong alias. * sysdeps/ieee754/dbl-64/wordsize-64/s_totalorder.c (totalorder): Rename to __totalorder and define as weak alias. [NO_LONG_DOUBLE] (__totalorderl): New strong alias. * sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c (totalordermag): Rename to __totalordermag and define as weak alias. [NO_LONG_DOUBLE] (__totalordermagl): New strong alias. * sysdeps/ieee754/float128/float128_private.h (__getpayloadl): New macro. (__roundevenl): Likewise. (__totalorderl): Likewise. (__totalordermagl): Likewise * sysdeps/ieee754/float128/s_fromfpf128.c (FUNC): Define to __fromfpf128. (fromfpf128): Define as weak alias. * sysdeps/ieee754/float128/s_fromfpxf128.c (FUNC): Define to __fromfpxf128. (fromfpxf128): Define as weak alias. * sysdeps/ieee754/float128/s_setpayloadf128.c (FUNC): Define to __setpayloadf128. (setpayloadf128): Define as weak alias. * sysdeps/ieee754/float128/s_setpayloadsigf128.c (FUNC): Define to __setpayloadsigf128. (setpayloadsigf128): Define as weak alias. * sysdeps/ieee754/float128/s_ufromfpf128.c (FUNC): Define to __ufromfpf128. (ufromfpf128): Define as weak alias. * sysdeps/ieee754/float128/s_ufromfpxf128.c (FUNC): Define to __ufromfpxf128. (ufromfpxf128): Define as weak alias. * sysdeps/ieee754/flt-32/s_fromfpf.c (FUNC): Define to __fromfpf. (fromfpf): Define as weak alias. * sysdeps/ieee754/flt-32/s_fromfpxf.c (FUNC): Define to __fromfpxf. (fromfpxf): Define as weak alias. * sysdeps/ieee754/flt-32/s_getpayloadf.c (getpayloadf): Rename to __getpayloadf and define as weak alias. * sysdeps/ieee754/flt-32/s_roundevenf.c (roundevenf): Rename to __roundevenf and define as weak alias. * sysdeps/ieee754/flt-32/s_setpayloadf.c (FUNC): Define to __setpayloadf. (setpayloadf): Define as weak alias. * sysdeps/ieee754/flt-32/s_setpayloadsigf.c (FUNC): Define to __setpayloadsigf. (setpayloadsigf): Define as weak alias. * sysdeps/ieee754/flt-32/s_totalorderf.c (totalorderf): Rename to __totalorderf and define as weak alias. * sysdeps/ieee754/flt-32/s_totalordermagf.c (totalordermagf): Rename to __totalordermagf and define as weak alias. * sysdeps/ieee754/flt-32/s_ufromfpf.c (FUNC): Define to __ufromfpf. (ufromfpf): Define as weak alias. * sysdeps/ieee754/flt-32/s_ufromfpxf.c (FUNC): Define to __ufromfpxf. (ufromfpxf): Define as weak alias. * sysdeps/ieee754/ldbl-128/s_fromfpl.c (FUNC): Define to __fromfpl. (fromfpl): Define as weak alias. * sysdeps/ieee754/ldbl-128/s_fromfpxl.c (FUNC): Define to __fromfpxl. (fromfpxl): Define as weak alias. * sysdeps/ieee754/ldbl-128/s_getpayloadl.c (getpayloadl): Rename to __getpayloadl and define as weak alias. * sysdeps/ieee754/ldbl-128/s_roundevenl.c (roundevenl): Rename to __roundevenl and define as weak alias. * sysdeps/ieee754/ldbl-128/s_setpayloadl.c (FUNC): Define to __setpayloadl. (setpayloadl): Define as weak alias. * sysdeps/ieee754/ldbl-128/s_setpayloadsigl.c (FUNC): Define to __setpayloadsigl. (setpayloadsigl): Define as weak alias. * sysdeps/ieee754/ldbl-128/s_totalorderl.c (totalorderl): Rename to __totalorderl and define as weak alias. * sysdeps/ieee754/ldbl-128/s_totalordermagl.c (totalordermagl): Rename to __totalordermagl and define as weak alias. * sysdeps/ieee754/ldbl-128/s_ufromfpl.c (FUNC): Define to __ufromfpl. (ufromfpl): Define as weak alias. * sysdeps/ieee754/ldbl-128/s_ufromfpxl.c (FUNC): Define to __ufromfpxl. (ufromfpxl): Define as weak alias. * sysdeps/ieee754/ldbl-128ibm/s_fromfpl.c (FUNC): Define to __fromfpl. (fromfpl): Define as weak alias. * sysdeps/ieee754/ldbl-128ibm/s_fromfpxl.c (FUNC): Define to __fromfpxl. (fromfpxl): Define as weak alias. * sysdeps/ieee754/ldbl-128ibm/s_getpayloadl.c (getpayloadl): Rename to __getpayloadl and define as weak alias. * sysdeps/ieee754/ldbl-128ibm/s_roundevenl.c (roundevenl): Rename to __roundevenl and define as weak alias. Call __roundeven instead of roundeven. * sysdeps/ieee754/ldbl-128ibm/s_setpayloadl.c (FUNC): Define to __setpayloadl. (setpayloadl): Define as weak alias. * sysdeps/ieee754/ldbl-128ibm/s_setpayloadsigl.c (FUNC): Define to __setpayloadsigl. (setpayloadsigl): Define as weak alias. * sysdeps/ieee754/ldbl-128ibm/s_totalorderl.c (totalorderl): Rename to __totalorderl and define as weak alias. * sysdeps/ieee754/ldbl-128ibm/s_totalordermagl.c (totalordermagl): Rename to __totalordermagl and define as weak alias. * sysdeps/ieee754/ldbl-128ibm/s_ufromfpl.c (FUNC): Define to __ufromfpl. (ufromfpl): Define as weak alias. * sysdeps/ieee754/ldbl-128ibm/s_ufromfpxl.c (FUNC): Define to __ufromfpxl. (ufromfpxl): Define as weak alias. * sysdeps/ieee754/ldbl-96/s_fromfpl.c (FUNC): Define to __fromfpl. (fromfpl): Define as weak alias. * sysdeps/ieee754/ldbl-96/s_fromfpxl.c (FUNC): Define to __fromfpxl. (fromfpxl): Define as weak alias. * sysdeps/ieee754/ldbl-96/s_getpayloadl.c (getpayloadl): Rename to __getpayloadl and define as weak alias. * sysdeps/ieee754/ldbl-96/s_roundevenl.c (roundevenl): Rename to __roundevenl and define as weak alias. * sysdeps/ieee754/ldbl-96/s_setpayloadl.c (FUNC): Define to __setpayloadl. (setpayloadl): Define as weak alias. * sysdeps/ieee754/ldbl-96/s_setpayloadsigl.c (FUNC): Define to __setpayloadsigl. (setpayloadsigl): Define as weak alias. * sysdeps/ieee754/ldbl-96/s_totalorderl.c (totalorderl): Rename to __totalorderl and define as weak alias. * sysdeps/ieee754/ldbl-96/s_totalordermagl.c (totalordermagl): Rename to __totalordermagl and define as weak alias. * sysdeps/ieee754/ldbl-96/s_ufromfpl.c (FUNC): Define to __ufromfpl. (ufromfpl): Define as weak alias. * sysdeps/ieee754/ldbl-96/s_ufromfpxl.c (FUNC): Define to __ufromfpxl. (ufromfpxl): Define as weak alias.
2017-09-13Move exp compat wrappers under math/Szabolcs Nagy
Move exp compat wrappers to math/w_exp{,f,l}_compat.c to be consistent with other wrappers. * sysdeps/ieee754/dbl-64/w_exp_compat.c: Move to... * math/w_exp_compat.c: ... here. * sysdeps/ieee754/flt-32/w_expf_compat.c: Move to... * math/w_expf_compat.c: ... here. * sysdeps/ieee754/ldbl-128/w_expl_compat.c: Move to... * math/w_expl_compat.c: ... here. * sysdeps/ieee754/ldbl-128ibm/w_expl_compat.c: Remove. * sysdeps/ieee754/ldbl-96/w_expl_compat.c: Remove. * sysdeps/ieee754/ldbl-opt/w_exp_compat.c: Use the new path. * sysdeps/ieee754/ldbl-opt/w_expl_compat.c: Likewise.
2017-09-13Clear up log1p, ldexp, scalbn, scalbln compat handling.Joseph Myers
This patch cleans up how compat symbols / long double versioning are handled for log1p, ldexp, scalbn and scalbln functions. The general principle is to do as much as possible through the type-generic templates. Previously, when errno-setting wrappers were added the compat long double symbols were left pointing directly to the underlying implementations; they are moved to point to the errno-setting wrappers. For the functions also present in libc, compat symbol handling for the libc copies needs to go in ldbl-opt wrappers, but the type-generic templates can handle it for the libm copies. There is no need for w_scalbln_template.c to disable the creation of an unused internal alias (such code made sense in the context of patches trying to avoid any changes to generated code for ease of comparison, but can be removed in a change that specifically does intend to change details of where symbols point). Tested for x86_64, and with build-many-glibcs.py. * math/w_scalbln_template.c (strong_alias): Do not undefine and redefine. * sysdeps/ieee754/ldbl-opt/s_ldexp.c (declare_mgen_alias): Remove macro. (ldexpl): Only define as compat symbol for libc, not libm. (scalbnl): Define as compat symbol for libc here. * sysdeps/ieee754/ldbl-opt/s_ldexpl.c (declare_mgen_alias): Only define for [IS_IN (libc)]. (__ldexpl_2): Remove alias. (ldexpl): Only define with long_double_symbol if [IS_IN (libc)]. (scalbnl): Likewise. Use __wrap_scalbnl not __ldexpl_2 as base name in long_double_symbol call. * sysdeps/ieee754/ldbl-opt/s_log1p.c: Remove file. * sysdeps/ieee754/ldbl-opt/s_scalbln.c: Likewise. * sysdeps/ieee754/ldbl-opt/s_scalbn.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_log1p.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_scalbln.c (declare_mgen_alias): Remove macro. [IS_IN (libc) && LONG_DOUBLE_COMPAT (libc, GLIBC_2_1)] (scalblnl): Define as compat symbol.
2017-09-13Define and use libm_alias_double.Joseph Myers
Continuing the process of setting up common macros for libm function aliases, with a view to using them to define _FloatN / _FloatNx aliases in future, this patch adds a libm_alias_double macro and uses it in the type-generic templates. This macro handles defining aliases for double, and for long double in the NO_LONG_DOUBLE case. It also handles defining compat symbols for long double = double for architectures that changed their long double format. By so doing, it eliminates the need for the M_LIBM_NEED_COMPAT and declare_mgen_libm_compat macros; the single declare_mgen_alias call in each template now suffices to define all required compat symbols. When used for more double functions (not based on type-generic templates), I expect it will eliminate the need for most ldbl-opt wrappers for such functions. A few special cases are needed. __clog10l is a public symbol (for historical reasons) so needs to be given appropriate compat versions for architectures that changed their long double format, but is not defined as an alias using the normal macros since __clog10* are *not* public symbols for _FloatN / _FloatNx types. For scalbn, scalbln and log1p, the changes adding errno setting support for those functions left compat symbols pointing directly to the non-errno-setting implementations. There is no requirement for the compat symbols not to set errno; that just made for the simplest patches at that time. Now, with these common macros, it's natural to redirect the compat symbols to the errno-setting wrappers, which I intend to do in a separate patch. Tested for x86_64, and with build-many-glibcs.py. For ldbl-opt platforms the stripped libm.so binaries are changed (disassembly unchanged) because the details of how the clog10l compat symbol is created mean it ceases to be weak as it was before; for other platforms, stripped libm.so binaries are unchanged. 2017-09-13 Joseph Myers <joseph@codesourcery.com> * sysdeps/generic/libm-alias-double.h: New file. * sysdeps/ieee754/ldbl-opt/libm-alias-double.h: Likewise. * sysdeps/generic/math-type-macros-double.h: Include <libm-alias-double.h>. [declare_mgen_alias] (declare_mgen_alias): Define to use libm_alias_double. * sysdeps/generic/math-type-macros.h [!M_LIBM_NEED_COMPAT] (M_LIBM_NEED_COMPAT): Remove macro. [!M_LIBM_NEED_COMPAT] (declare_mgen_libm_compat): Likewise. * sysdeps/ieee754/ldbl-opt/math-type-macros-double.h: Remove. * math/cabs_template.c [M_LIBM_NEED_COMPAT]: Remove conditional code. * math/carg_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/cimag_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/conj_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/creal_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_cacos_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_cacosh_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_casin_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_casinh_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_catan_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_catanh_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_ccos_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_ccosh_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_cexp_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_clog10_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_clog_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_cpow_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_cproj_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_csin_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_csinh_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_csqrt_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_ctan_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_ctanh_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_fdim_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_fmax_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_fmin_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/s_nan_template.c [M_LIBM_NEED_COMPAT]: Likewise. * math/w_ilogb_template.c [M_LIBM_NEED_COMPAT]: Likewise. * sysdeps/ieee754/ldbl-opt/s_clog10.c: New file. * sysdeps/ieee754/ldbl-opt/s_ldexp.c (M_LIBM_NEED_COMPAT): Remove macro. (declare_mgen_alias): New macro. * sysdeps/ieee754/ldbl-opt/w_log1p.c: New file. * sysdeps/ieee754/ldbl-opt/w_scalbln.c: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdim-vis3.c (M_LIBM_NEED_COMPAT): Remove macro. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fdim.c [HAVE_AS_VIS3_SUPPORT]: Include <math_ldbl_opt.h> and <first-versions.h>. [HAVE_AS_VIS3_SUPPORT && LONG_DOUBLE_COMPAT (libm, FIRST_VERSION_libm_fdiml)]: Define fdiml as compat symbol.
2017-09-12Remove declare_mgen_alias_2.Joseph Myers
The libm template machinery includes a macro declare_mgen_alias_2, to define two function aliases rather than one. This macro is only used in one place, to define ldexp and scalbn, and only has one nondefault definition, for double in the case where long double has the same format. That definition is because declare_mgen_alias for double, in that case, defines <internal-func>l as an alias of <internal-func>, so cannot be called twice for aliases of the same function. Now, I suspect the <internal-func>l aliases are generally not needed (with maybe a few exceptions such as __clog10l, which is an exported function). But even in the presence of them, there is no need for a special declare_mgen_alias_2 macro for this case. This patch eliminates the need for such a macro by defining __wrap_scalbn<suffix> as an alias of __ldexp<suffix>, and then using that when defining the scalbn public aliases. This is similar to how such internal aliases are created for functions with multiple symbol versions, for example. Tested for x86_64, and with build-many-glibcs.py. (There *are* some cases where installed stripped shared libraries change - not in the generated code but because such changes to static symbols on input to ld, even nonexported symbols that don't affect the code or dynamic symbols, can affect the particular representation in the output of string tables, hash tables etc.) * sysdeps/generic/math-type-macros.h [!declare_mgen_alias_2] (declare_mgen_alias_2): Remove. * sysdeps/generic/math-type-macros-double.h [NO_LONG_DOUBLE && !declare_mgen_alias_2] (declare_mgen_alias_2): Likewise. * math/s_ldexp_template.c (M_SUF (__wrap_scalbn)): Define strong alias. (ldexp): Define with declare_mgen_alias. (scalbn): Likewise.
2017-09-05Prefer new libm function wrappers for !LIBM_SVID_COMPAT.Joseph Myers
The initial obsoletion of SVID libm error handling left the old wrappers and __kernel_standard still being used for new ports and static linking, just with macro definitions of _LIB_VERSION and matherr that meant symbols with those names were never actually used and the code for different error handling variants could be optimized out. This patch cleans things up further by eliminating the __kernel_standard use for new ports and static linking. Now, the old wrappers no longer generate any code in the !LIBM_SVID_COMPAT case, while the new errno-only wrappers that were added for float128 support are now also used for float, double and long double in that case. The changes are generally straightforward. The w_scalb*_compat wrappers continue to be used (scalb is obsolescent in the sense of not being supported for float128, but is present in supported standards - the 2001 edition of POSIX and earlier XSI versions - so remains supported for static linking and new ports, as do the float and long double variants that are existing GNU extensions). Those wrappers would only call __kernel_standard in the _LIB_VERSION == _SVID_ case. Since we would like to be able to compile most of glibc without optimization, relying on a static function whose only use is under an if (0) condition being optimized away to avoid an undefined __kernel_standard reference may not be a good idea. Thus, the relevant code in the scalb wrappers has LIBM_SVID_COMPAT conditionals added to guarantee it's not built at all in the case where __kernel_standard does not exist. Just as i386 has its own w_sqrt_compat.c, so w_sqrt.c is also added. ia64 gets dummy w_*.c to prevent those files being built where they would conflict with the ia64 libm, as with its existing w_*_compat.c. Conditions disabling code for !LIBM_SVID_COMPAT are needed in both the math/ wrappers and in the long double wrappers in ldbl-opt (to avoid them setting up aliases and symbol versions for undefined symbols). I hope that future cleanups to how libm function aliases and symbol versioning are done will eliminate the need for most of the ldbl-opt wrappers. Tested for x86_64 and x86, and with build-many-glibcs.py. * sysdeps/generic/math-type-macros-double.h: Include <math-svid-compat.h>. (__USE_WRAPPER_TEMPLATE): Define to !LIBM_SVID_COMPAT. * sysdeps/generic/math-type-macros-float.h: Include <math-svid-compat.h>. (__USE_WRAPPER_TEMPLATE): Define to !LIBM_SVID_COMPAT. * sysdeps/generic/math-type-macros-ldouble.h: Include <math-svid-compat.h>. (__USE_WRAPPER_TEMPLATE): Define to !LIBM_SVID_COMPAT. * math/lgamma-compat.h (BUILD_LGAMMA): Include LIBM_SVID_COMPAT condition. * math/w_acos_compat.c: Condition contents on [LIBM_SVID_COMPAT]. * 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_r_compat.c: Likewise. * math/w_lgammaf_r_compat.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_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. * math/w_scalb_compat.c (sysv_scalb): Condition definition on [LIBM_SVID_COMPAT]. (__scalb): Condition call to sysv_scalb on [LIBM_SVID_COMPAT]. * math/w_scalbf_compat.c (sysv_scalbf): Condition definition on [LIBM_SVID_COMPAT]. (__scalbf): Condition call to sysv_scalbf on [LIBM_SVID_COMPAT]. * math/w_scalbl_compat.c (sysv_scalbl): Condition definition on [LIBM_SVID_COMPAT]. (__scalbl): Condition call to sysv_scalbl on [LIBM_SVID_COMPAT]. * sysdeps/i386/fpu/w_sqrt.c: New file. * sysdeps/ia64/fpu/w_acos.c: Likewise. * sysdeps/ia64/fpu/w_acosf.c: Likewise. * sysdeps/ia64/fpu/w_acosh.c: Likewise. * sysdeps/ia64/fpu/w_acoshf.c: Likewise. * sysdeps/ia64/fpu/w_acoshl.c: Likewise. * sysdeps/ia64/fpu/w_acosl.c: Likewise. * sysdeps/ia64/fpu/w_asin.c: Likewise. * sysdeps/ia64/fpu/w_asinf.c: Likewise. * sysdeps/ia64/fpu/w_asinl.c: Likewise. * sysdeps/ia64/fpu/w_atan2.c: Likewise. * sysdeps/ia64/fpu/w_atan2f.c: Likewise. * sysdeps/ia64/fpu/w_atan2l.c: Likewise. * sysdeps/ia64/fpu/w_atanh.c: Likewise. * sysdeps/ia64/fpu/w_atanhf.c: Likewise. * sysdeps/ia64/fpu/w_atanhl.c: Likewise. * sysdeps/ia64/fpu/w_cosh.c: Likewise. * sysdeps/ia64/fpu/w_coshf.c: Likewise. * sysdeps/ia64/fpu/w_coshl.c: Likewise. * sysdeps/ia64/fpu/w_exp.c: Likewise. * sysdeps/ia64/fpu/w_exp10.c: Likewise. * sysdeps/ia64/fpu/w_exp10f.c: Likewise. * sysdeps/ia64/fpu/w_exp10l.c: Likewise. * sysdeps/ia64/fpu/w_exp2.c: Likewise. * sysdeps/ia64/fpu/w_exp2f.c: Likewise. * sysdeps/ia64/fpu/w_exp2l.c: Likewise. * sysdeps/ia64/fpu/w_expf.c: Likewise. * sysdeps/ia64/fpu/w_expl.c: Likewise. * sysdeps/ia64/fpu/w_fmod.c: Likewise. * sysdeps/ia64/fpu/w_fmodf.c: Likewise. * sysdeps/ia64/fpu/w_fmodl.c: Likewise. * sysdeps/ia64/fpu/w_hypot.c: Likewise. * sysdeps/ia64/fpu/w_hypotf.c: Likewise. * sysdeps/ia64/fpu/w_hypotl.c: Likewise. * sysdeps/ia64/fpu/w_lgamma_r.c: Likewise. * sysdeps/ia64/fpu/w_lgammaf_r.c: Likewise. * sysdeps/ia64/fpu/w_lgammal_r.c: Likewise. * sysdeps/ia64/fpu/w_log.c: Likewise. * sysdeps/ia64/fpu/w_log10.c: Likewise. * sysdeps/ia64/fpu/w_log10f.c: Likewise. * sysdeps/ia64/fpu/w_log10l.c: Likewise. * sysdeps/ia64/fpu/w_log2.c: Likewise. * sysdeps/ia64/fpu/w_log2f.c: Likewise. * sysdeps/ia64/fpu/w_log2l.c: Likewise. * sysdeps/ia64/fpu/w_logf.c: Likewise. * sysdeps/ia64/fpu/w_logl.c: Likewise. * sysdeps/ia64/fpu/w_pow.c: Likewise. * sysdeps/ia64/fpu/w_powf.c: Likewise. * sysdeps/ia64/fpu/w_powl.c: Likewise. * sysdeps/ia64/fpu/w_remainder.c: Likewise. * sysdeps/ia64/fpu/w_remainderf.c: Likewise. * sysdeps/ia64/fpu/w_remainderl.c: Likewise. * sysdeps/ia64/fpu/w_sinh.c: Likewise. * sysdeps/ia64/fpu/w_sinhf.c: Likewise. * sysdeps/ia64/fpu/w_sinhl.c: Likewise. * sysdeps/ia64/fpu/w_sqrt.c: Likewise. * sysdeps/ia64/fpu/w_sqrtf.c: Likewise. * sysdeps/ia64/fpu/w_sqrtl.c: Likewise. * sysdeps/ia64/fpu/w_tgamma.c: Likewise. * sysdeps/ia64/fpu/w_tgammaf.c: Likewise. * sysdeps/ia64/fpu/w_tgammal.c: Likewise. * sysdeps/ieee754/dbl-64/w_exp_compat.c: Condition contents on [LIBM_SVID_COMPAT]. * 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/ieee754/ldbl-64-128/w_expl_compat.c: Condition long_double_symbol call on [LIBM_SVID_COMPAT]. * sysdeps/ieee754/ldbl-opt/w_acoshl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_acosl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_asinl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_atan2l_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_atanhl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_coshl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_fmodl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_hypotl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_j0l_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_j1l_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_jnl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_lgammal_r_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_log10l_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_log2l_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_logl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_powl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_remainderl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_sinhl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_sqrtl_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_tgammal_compat.c: Likewise. * sysdeps/ieee754/ldbl-opt/w_exp10l_compat.c: Condition long_double_symbol and compat_symbol calls on [LIBM_SVID_COMPAT].
2017-09-05Fix tests that are testing obsoleted functionalitySteve Ellcey
* include/shlib-compat.h (TEST_COMPAT): New Macro. * malloc/tst-mallocstate.c: Convert from test-skeleton to test-driver. Ifdef code using TEST_COMPAT macro. * math/test-matherr-2.c: Ifdef test using TEST_COMPAT macro. * math/test-matherr.c: Likewise.
2017-09-04Fix bits/math-finite.h exp10 condition (bug 22082).Joseph Myers
bits/math-finite.h handles exp10 if __USE_GNU. It should use the condition __GLIBC_USE (IEC_60559_FUNCS_EXT), as in bits/mathcalls.h. This patch fixes the condition. Tested for x86_64. [BZ #22082] * math/bits/math-finite.h (exp10): Redirect if [__GLIBC_USE (IEC_60559_FUNCS_EXT)], not [__USE_GNU].