about summary refs log tree commit diff
path: root/math/gen-tgmath-tests.py
Commit message (Collapse)AuthorAgeFilesLines
* Prefer https to http for gnu.org and fsf.org URLsPaul Eggert2019-09-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also, change sources.redhat.com to sourceware.org. This patch was automatically generated by running the following shell script, which uses GNU sed, and which avoids modifying files imported from upstream: sed -ri ' s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g ' \ $(find $(git ls-files) -prune -type f \ ! -name '*.po' \ ! -name 'ChangeLog*' \ ! -path COPYING ! -path COPYING.LIB \ ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \ ! -path manual/texinfo.tex ! -path scripts/config.guess \ ! -path scripts/config.sub ! -path scripts/install-sh \ ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \ ! -path INSTALL ! -path locale/programs/charmap-kw.h \ ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \ ! '(' -name configure \ -execdir test -f configure.ac -o -f configure.in ';' ')' \ ! '(' -name preconfigure \ -execdir test -f preconfigure.ac ';' ')' \ -print) and then by running 'make dist-prepare' to regenerate files built from the altered files, and then executing the following to cleanup: chmod a+x sysdeps/unix/sysv/linux/riscv/configure # Omit irrelevant whitespace and comment-only changes, # perhaps from a slightly-different Autoconf version. git checkout -f \ sysdeps/csky/configure \ sysdeps/hppa/configure \ sysdeps/riscv/configure \ sysdeps/unix/sysv/linux/csky/configure # Omit changes that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines git checkout -f \ sysdeps/powerpc/powerpc64/ppc-mcount.S \ sysdeps/unix/sysv/linux/s390/s390-64/syscall.S # Omit change that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
* Add tgmath.h macros for narrowing functions.Joseph Myers2019-08-211-19/+165
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When adding some of the TS 18661 narrowing functions for glibc 2.28, I deferred adding corresponding <tgmath.h> support because of unresolved questions about the specification for those type-generic macros, especially in relation to _FloatN and _FloatNx types. Those issues are now clarified in the response to Clarification Request 13 to TS 18661-3, and this patch adds the deferred tgmath.h support. As with other tgmath.h macros, there are fairly straightforward implementations based on __builtin_tgmath for GCC 8 and later, which result in exactly the right function being called in each case, and more complicated implementations for GCC 7 and earlier, which generally result in a function being called whose arguments have the right format (i.e. an alias for the right function), but which might not be exactly the function name specified by TS 18661. In one case with older compilers (f32x* macros, where the type _Float64x exists and all the arguments have type _Float32 or _Float32x), there is a further relaxation and the function called may have arguments narrower than the one specified by the TS, but still wide enough to represent the arguments exactly, so the result of the call is unchanged (as this does not affect any case where rounding of integer arguments might be involved). With GCC 6 or before this is inherently unavoidable (but still harmless and not detectable by how the compiled program behaves, unless it redefines the functions in question like the testcases do) because _Float32x and _Float64 are both typedefs for double in that case but the specified semantics result in different functions, with different argument formats, being called for those two argument types. Tests for the new macros are handled through gen-tgmath-tests.py, which deals with the special-case handling for older GCC. Tested as follows: with the full glibc testsuite on x86_64 and x86 (with GCC 6, 7 and 8); with the math/ tests on aarch64 and arm (with GCC 6, 7 and 8); with build-many-glibcs.py (with GCC 6, 7 and 9). * math/tgmath.h [__HAVE_FLOAT128X]: Give error. [(__HAVE_FLOAT64X && !__HAVE_FLOAT128) || (__HAVE_FLOAT128 && !__HAVE_FLOAT64X)]: Likewise. (__TGMATH_2_NARROW_F): Likewise. (__TGMATH_2_NARROW_D): New macro. (__TGMATH_2_NARROW_F16): Likewise. (__TGMATH_2_NARROW_F32): Likewise. (__TGMATH_2_NARROW_F64): Likewise. (__TGMATH_2_NARROW_F32X): Likewise. (__TGMATH_2_NARROW_F64X): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_NARROW_FUNCS_F): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_NARROW_FUNCS_F16): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_NARROW_FUNCS_F32): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_NARROW_FUNCS_F64): Likewise. [__HAVE_BUILTIN_TGMATH] (__TGMATH_NARROW_FUNCS_F32X): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT_C2X)] (fadd): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT_C2X)] (dadd): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT_C2X)] (fdiv): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT_C2X)] (ddiv): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT_C2X)] (fmul): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT_C2X)] (dmul): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT_C2X)] (fsub): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT_C2X)] (dsub): Likewise. [__GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT16] (f16add): Likewise. [__GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT16] (f16div): Likewise. [__GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT16] (f16mul): Likewise. [__GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT16] (f16sub): Likewise. [__GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT32] (f32add): Likewise. [__GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT32] (f32div): Likewise. [__GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT32] (f32mul): Likewise. [__GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT32] (f32sub): Likewise. [__GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT64 && (__HAVE_FLOAT64X || __HAVE_FLOAT128)] (f64add): Likewise. [__GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT64 && (__HAVE_FLOAT64X || __HAVE_FLOAT128)] (f64div): Likewise. [__GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT64 && (__HAVE_FLOAT64X || __HAVE_FLOAT128)] (f64mul): Likewise. [__GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT64 && (__HAVE_FLOAT64X || __HAVE_FLOAT128)] (f64sub): Likewise. [__GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT32X] (f32xadd): Likewise. [__GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT32X] (f32xdiv): Likewise. [__GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT32X] (f32xmul): Likewise. [__GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT32X] (f32xsub): Likewise. [__GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT64X && (__HAVE_FLOAT128X || __HAVE_FLOAT128)] (f64xadd): Likewise. [__GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT64X && (__HAVE_FLOAT128X || __HAVE_FLOAT128)] (f64xdiv): Likewise. [__GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT64X && (__HAVE_FLOAT128X || __HAVE_FLOAT128)] (f64xmul): Likewise. [__GLIBC_USE (IEC_60559_TYPES_EXT) && __HAVE_FLOAT64X && (__HAVE_FLOAT128X || __HAVE_FLOAT128)] (f64xsub): Likewise. * math/gen-tgmath-tests.py (Type): Add members non_standard_real_argument_types_list, long_double_type, complex_float64_type and float32x_ext_type. (Type.__init__): Set the new members. (Type.floating_type): Add new argument floatn. (Type.real_floating_type): Likewise. (Type.can_combine_types): Likewise. (Type.combine_types): Likewise. (Type.init_types): Create internal Float32x_ext type. (Tests.__init__): Define Float32x_ext in generated C code. (Tests.add_tests): Handle narrowing functions. (Tests.add_all_tests): Likewise. (Tests.tests_text): Allow variation in mant_dig for narrowing functions with compilers before GCC 8. * math/Makefile (tgmath3-narrow-types): New variable. (tgmath3-narrow-macros): Likewise. (tgmath3-macros): Add $(tgmath3-narrow-macros).
* Make totalorder and totalordermag functions take pointer arguments.Joseph Myers2019-08-151-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The resolution of C floating-point Clarification Request 25 <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2397.htm#dr_25> is that the totalorder and totalordermag functions should take pointer arguments, and this has been adopted in C2X (with const added; note that the integration of this change into C2X is present in the C standard git repository but postdates the most recent public PDF draft). This patch updates glibc accordingly. As a defect resolution, the API is changed unconditionally rather than supporting any sort of TS 18661-1 mode for compilation with the old version of the API. There are compat symbols for existing binaries that pass floating-point arguments directly. As a consequence of changing to pointer arguments, there are no longer type-generic macros in tgmath.h for these functions. Because of the fairly complicated logic for creating libm function aliases and determining the set of aliases to create in a given glibc configuration, rather than duplicating all that in individual source files to create the versioned and compat symbols, the source files for the various versions of totalorder functions are set up to redefine weak_alias before using libm_alias_* macros to create the symbols required. In turn, this requires creating a separate alias for each symbol version pointing to the same implementation (see binutils bug <https://sourceware.org/bugzilla/show_bug.cgi?id=23840>), which is done automatically using __COUNTER__. (As I noted in <https://sourceware.org/ml/libc-alpha/2018-10/msg00631.html>, it might well make sense for glibc's symbol versioning macros to do that alias creation with __COUNTER__ themselves, which would somewhat simplify the logic in the totalorder source files.) It is of course desirable to test the compat symbols. I did this with the generic libm-test machinery, but didn't wish to duplicate the actual tables of test inputs and outputs, and thought it risky to attempt to have a single object file refer to both default and compat versions of the same function in order to test them together. Thus, I created libm-test-compat_totalorder.inc and libm-test-compat_totalordermag.inc which include the generated .c files (with the processed version of those tables of inputs) from the non-compat tests, and added appropriate dependencies. I think this provides sufficient test coverage for the compat symbols without also needing to make the special ldbl-96 and ldbl-128ibm tests (of peculiarities relating to the representations of those formats that can't be covered in the generic tests) run for the compat symbols. Tests of compat symbols need to be internal tests, meaning _ISOMAC is not defined. Making some libm-test tests into internal tests showed up two other issues. GCC diagnoses duplicate macro definitions of __STDC_* macros, including __STDC_WANT_IEC_60559_TYPES_EXT__; I added an appropriate conditional and filed <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91451> for this issue. On ia64, include/setjmp.h ends up getting included indirectly from libm-symbols.h, resulting in conflicting definitions of the STR macro (also defined in libm-test-driver.c); I renamed the macros in include/setjmp.h. (It's arguable that we should have common internal headers used everywhere for stringizing and concatenation macros.) Tested for x86_64 and x86, and with build-many-glibcs.py. * math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT) || __MATH_DECLARING_FLOATN] (totalorder): Take pointer arguments. [__GLIBC_USE (IEC_60559_BFP_EXT) || __MATH_DECLARING_FLOATN] (totalordermag): Likewise. * manual/arith.texi (totalorder): Likewise. (totalorderf): Likewise. (totalorderl): Likewise. (totalorderfN): Likewise. (totalorderfNx): Likewise. (totalordermag): Likewise. (totalordermagf): Likewise. (totalordermagl): Likewise. (totalordermagfN): Likewise. (totalordermagfNx): Likewise. * math/tgmath.h (__TGMATH_BINARY_REAL_RET_ONLY): Remove macro. [__GLIBC_USE (IEC_60559_BFP_EXT)] (totalorder): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT)] (totalordermag): Likewise. * math/Versions (GLIBC_2.31): Add totalorder, totalorderf, totalorderl, totalordermag, totalordermagf, totalordermagl, totalorderf32, totalorderf64, totalorderf32x, totalordermagf32, totalordermagf64, totalordermagf32x, totalorderf64x, totalordermagf64x, totalorderf128 and totalordermagf128. * math/Makefile (libm-test-funcs-noauto): Add compat_totalorder and compat_totalordermag. (libm-test-funcs-compat): New variable. (libm-tests-compat): Likewise. (tests): Do not include compat tests. (tests-internal): Add compat tests. ($(foreach t,$(libm-tests-base), $(objpfx)$(t)-compat_totalorder.o)): Depend on $(objpfx)libm-test-totalorder.c. ($(foreach t,$(libm-tests-base), $(objpfx)$(t)-compat_totalordermag.o): Depend on $(objpfx)libm-test-totalordermag.c. (tgmath3-macros): Remove totalorder and totalordermag. * math/libm-test-compat_totalorder.inc: New file. * math/libm-test-compat_totalordermag.inc: Likewise. * math/libm-test-driver.c (struct test_ff_i_data): Update comment. (RUN_TEST_fpfp_b): New macro. (RUN_TEST_LOOP_fpfp_b): Likewise. * math/libm-test-totalorder.inc (totalorder_test_data): Use TEST_fpfp_b. (totalorder_test): Condition on [!COMPAT_TEST]. (do_test): Likewise. * math/libm-test-totalordermag.inc (totalordermag_test_data): Use TEST_fpfp_b. (totalordermag_test): Condition on [!COMPAT_TEST]. (do_test): Likewise. * math/gen-tgmath-tests.py (Tests.add_all_tests): Remove totalorder and totalordermag. * math/test-tgmath.c (NCALLS): Change to 132. (F(compile_test)): Do not call totalorder or totalordermag. (F(totalorder)): Remove. (F(totalordermag)): Likewise. * include/float.h (__STDC_WANT_IEC_60559_TYPES_EXT__): Do not define if [__STDC_WANT_IEC_60559_TYPES_EXT__]. * include/setjmp.h [!_ISOMAC] (STR_HELPER): Rename to SJSTR_HELPER. [!_ISOMAC] (STR): Rename to SJSTR. Update call to STR_HELPER. [!_ISOMAC] (TEST_SIZE): Update call to STR. [!_ISOMAC] (TEST_ALIGN): Likewise. [!_ISOMAC] (TEST_OFFSET): Likewise. * sysdeps/ieee754/dbl-64/s_totalorder.c: Include <shlib-compat.h> and <first-versions.h>. (__totalorder): Take pointer arguments. Add symbol versions and compat symbols. * sysdeps/ieee754/dbl-64/s_totalordermag.c: Include <shlib-compat.h> and <first-versions.h>. (__totalordermag): Take pointer arguments. Add symbol versions and compat symbols. * sysdeps/ieee754/dbl-64/wordsize-64/s_totalorder.c: Include <shlib-compat.h> and <first-versions.h>. (__totalorder): Take pointer arguments. Add symbol versions and compat symbols. * sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c: Include <shlib-compat.h> and <first-versions.h>. (__totalordermag): Take pointer arguments. Add symbol versions and compat symbols. * sysdeps/ieee754/float128/float128_private.h (__totalorder_compatl): New macro. (__totalordermag_compatl): Likewise. * sysdeps/ieee754/flt-32/s_totalorderf.c: Include <shlib-compat.h> and <first-versions.h>. (__totalorderf): Take pointer arguments. Add symbol versions and compat symbols. * sysdeps/ieee754/flt-32/s_totalordermagf.c: Include <shlib-compat.h> and <first-versions.h>. (__totalordermagf): Take pointer arguments. Add symbol versions and compat symbols. * sysdeps/ieee754/ldbl-128/s_totalorderl.c: Include <shlib-compat.h> and <first-versions.h>. (__totalorderl): Take pointer arguments. Add symbol versions and compat symbols. * sysdeps/ieee754/ldbl-128/s_totalordermagl.c: Include <shlib-compat.h> and <first-versions.h>. (__totalordermagl): Take pointer arguments. Add symbol versions and compat symbols. * sysdeps/ieee754/ldbl-128ibm/s_totalorderl.c: Include <shlib-compat.h>. (__totalorderl): Take pointer arguments. Add symbol versions and compat symbols. * sysdeps/ieee754/ldbl-128ibm/s_totalordermagl.c: Include <shlib-compat.h>. (__totalordermagl): Take pointer arguments. Add symbol versions and compat symbols. * sysdeps/ieee754/ldbl-96/s_totalorderl.c: Include <shlib-compat.h> and <first-versions.h>. (__totalorderl): Take pointer arguments. Add symbol versions and compat symbols. * sysdeps/ieee754/ldbl-96/s_totalordermagl.c: Include <shlib-compat.h> and <first-versions.h>. (__totalordermagl): Take pointer arguments. Add symbol versions and compat symbols. * sysdeps/ieee754/ldbl-opt/nldbl-totalorder.c (totalorderl): Take pointer arguments. * sysdeps/ieee754/ldbl-opt/nldbl-totalordermag.c (totalordermagl): Likewise. * sysdeps/ieee754/ldbl-128ibm/test-totalorderl-ldbl-128ibm.c (do_test): Update calls to totalorderl and totalordermagl. * sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c (do_test): Update calls to totalorderl and totalordermagl. * sysdeps/mach/hurd/i386/libm.abilist: Update. * sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/csky/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/be/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/riscv/rv64/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/x86_64/64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2019-01-011-1/+1
| | | | | | | * All files with FSF copyright notices: Update copyright dates using scripts/update-copyrights. * locale/programs/charmap-kw.h: Regenerated. * locale/programs/locfile-kw.h: Likewise.
* Split test-tgmath3 by function.Joseph Myers2018-05-181-5/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It has been noted that test-tgmath3 is slow to compile, and to link on some systems <https://sourceware.org/ml/libc-alpha/2018-02/msg00477.html>, because of the size of the test. I'm working on tgmath.h support for the TS 18661-1 / 18661-3 functions that round their results to a narrower type. For the functions already present in glibc, this wouldn't make test-tgmath3 much bigger, because those functions only have two arguments. For the narrowing versions of fma (for which I've not yet added the functions to glibc), however, it would result in many configurations building tests of the type-generic macros f32fma, f64fma, f32xfma, f64xfma, each with 21 possible types for each of three arguments (float, double, long double aren't valid argument types for these macros when they return a _FloatN / _FloatNx type), so substantially increasing the size of the testcase. To avoid further increasing the size of a single test when adding the type-generic narrowing fma macros, this patch arranges for the test-tgmath3 tests to be run separately for each function tested. The fma tests are still by far the largest (next is pow, as that has two arguments that can be real or complex; after that, the two-argument real-only functions), but each type-generic fma macro for a different return type would end up with its tests being run separately, rather than increasing the size of a single test. To avoid accidentally missing testing a macro because gen-tgmath-tests.py supports testing it but the makefile fails to call it for that function, a test is also added that verifies that the lists of macros in the makefile and gen-tgmath-tests.py agree. Tested for x86_64. * math/gen-tgmath-tests.py: Import sys. (Tests.__init__): Initialize macros_seen. (Tests.add_tests): Add macro to macros_seen. Only generate tests if requested to do so for this macro. (Tests.add_all_tests): Take argument for macro for which to generate tests. (Tests.check_macro_list): New function. (main): Handle check-list argument and argument specifying macro for which to generate tests. * math/Makefile [PYTHON] (tgmath3-macros): New variable. [PYTHON] (tgmath3-macro-tests): Likewise. [PYTHON] (tests): Add $(tgmath3-macro-tests) not test-tgmath3. [PYTHON] (generated): Add $(addsuffix .c,$(tgmath3-macro-tests)) not test-tgmath3.c. [PYTHON] (CFLAGS-test-tgmath3.c): Remove. [PYTHON] ($(tgmath3-macro-tests:%=$(objpfx)%.o): Add -fno-builtin to CFLAGS. [PYTHON] ($(objpfx)test-tgmath3.c): Replace rule by.... [PYTHON] ($(foreach m,$(tgmath3-macros),$(objpfx)test-tgmath3-$(m).c): ... this. New rule. [PYTHON] (tests-special): Add $(objpfx)test-tgmath3-macro-list.out. [PYTHON] ($(objpfx)test-tgmath3-macro-list.out): New rule.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2018-01-011-1/+1
| | | | | | | * All files with FSF copyright notices: Update copyright dates using scripts/update-copyrights. * locale/programs/charmap-kw.h: Regenerated. * locale/programs/locfile-kw.h: Likewise.
* Fix gen-tgmath-tests.py for _Float64, _Float64x testing.Joseph Myers2017-11-241-2/+2
| | | | | | | | | | | | | | 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.
* Fix tgmath.h handling of complex integers (bug 21684).Joseph Myers2017-08-221-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The tgmath.h macros return a real type not a complex type when an argument is of complex integer type (a GNU extension) and there are no arguments of complex floating type. It seems clear that just as real integers are mapped to double for tgmath.h, so complex integers should be mapped to _Complex double. This patch implements such a mapping. The main complication in fixing this bug is that the tgmath.h macros expand their arguments a large number of times, resulting in exponential blowup of the size of the expansion when calls to tgmath.h macros are used in the arguments of such macros; it would be unfortunate for fixing a bug with a fairly obscure extension to make the macros expand their arguments even more times. Thus, this patch optimizes the definitions of the relevant macros. __tgmath_real_type previously expanded its argument 7 times and now expands it 3 times. __tgmath_complex_type, used in place of __tgmath_real_type only for functions that might return either real or complex types, not for complex functions that always return real types or always return complex types, expands its argument 5 times. So the sizes of the macro expansions from nested macro calls are correspondingly reduced (remembering that each tgmath.h macro expands __tgmath_real_type, or sometimes now __tgmath_complex_type, several times). Sometimes the real return type resulted from calling a complex function and converting the result to a real type; sometimes it resulted from calling a real function, because the logic for determining whether arguments were real or complex, based on sizeof, was confused by integer promotions applying to e.g. short int but not _Complex short int. The relevant tests are converted to use a new macro __expr_is_real, which, by calling __builtin_classify_type rather than comparing the results of two calls to sizeof, also reduces the number of times macros expand their arguments. Although there are reductions in the number of times macros expand their arguments, I do not consider this to fix bug 21660, since a proper fix means each macro expanding its arguments only once (via using new compiler features designed for that purpose). Tested for x86_64. [BZ #21684] * math/tgmath.h (__floating_type): Simplify definitions. (__real_integer_type): New macro. (__complex_integer_type): Likewise. (__expr_is_real): Likewise. (__tgmath_real_type_sub): Update comment to describe handling of complex types. (__tgmath_complex_type_sub): New macro. (__tgmath_complex_type): Likewise. [__HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (__TGMATH_CF128): Use __expr_is_real. (__TGMATH_UNARY_REAL_IMAG): Use __tgmath_complex_type and __expr_is_real. (__TGMATH_BINARY_REAL_IMAG): Likewise. (__TGMATH_UNARY_REAL_IMAG_RET_REAL): Use __expr_is_real. * math/gen-tgmath-tests.py (Type.create_type): Create complex integer types.
* Fix tgmath.h for __int128 (bug 21686).Joseph Myers2017-08-021-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | When a tgmath.h macro is passed a double argument and an argument of type __int128, it generates a call to a long double function (although the result still gets converted to type double). __int128 is similar enough to integer types that it should be handled consistently like them, so always like double for these macros rather than sometimes like double and sometimes like long double. This patch fixes the logic accordingly and makes gen-tgmath-tests.py generate tests for __int128. Tested for x86_64 and x86. [BZ #21686] * math/tgmath.h (__TGMATH_BINARY_REAL_ONLY): Add arguments before comparing size with that of double. (__TGMATH_BINARY_REAL_STD_ONLY): Likewise. (__TGMATH_BINARY_REAL_RET_ONLY): Likewise. (__TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY): Likewise. (__TGMATH_TERNARY_REAL_ONLY): Likewise. (__TGMATH_BINARY_REAL_IMAG): Likewise. * math/gen-tgmath-tests.py (Type.init_types): Create __int128 and unsigned __int128 types.
* Fix tgmath.h for bit-fields (bug 21685).Joseph Myers2017-08-021-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The tgmath.h macros produce errors for bit-field arguments, because they apply sizeof and typeof to the arguments. This patch fixes them to use unary + systematically before using sizeof or typeof on arguments that might be bit-fields (note that __real__ of a bit-field is still a bit-field for this purpose, since it's an lvalue). gen-tgmath-tests.py is extended to add tests for this case. Tested for x86_64. [BZ #21685] * math/tgmath.h (__tgmath_real_type): Use unary + on potentially bit-field expressions passed to sizeof or typeof. [__HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (__TGMATH_F128): Likewise. [__HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)] (__TGMATH_CF128): Likewise. (__TGMATH_UNARY_REAL_ONLY): Likewise. (__TGMATH_UNARY_REAL_RET_ONLY): Likewise. (__TGMATH_BINARY_FIRST_REAL_ONLY): Likewise. (__TGMATH_BINARY_FIRST_REAL_STD_ONLY): Likewise. (__TGMATH_BINARY_REAL_ONLY): Likewise. (__TGMATH_BINARY_REAL_STD_ONLY): Likewise. (__TGMATH_BINARY_REAL_RET_ONLY): Likewise. (__TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY): Likewise. (__TGMATH_TERNARY_REAL_ONLY): Likewise. (__TGMATH_TERNARY_FIRST_REAL_RET_ONLY): Likewise. (__TGMATH_UNARY_REAL_IMAG): Likewise. (__TGMATH_UNARY_IMAG): Likewise. (__TGMATH_UNARY_REAL_IMAG_RET_REAL): Likewise. (__TGMATH_BINARY_REAL_IMAG): Likewise. * math/gen-tgmath-tests.py (Type.init_types): Create bit_field type. (define_vars_for_type): Handle bit_field type specially. (Tests.__init__): Declare structure with bit-field element.
* Fix gen-tgmath-tests.py output for GCC 7 <float.h>.Joseph Myers2017-06-281-1/+2
| | | | | * math/gen-tgmath-tests.py (Tests.__init__): Define __STDC_WANT_IEC_60559_TYPES_EXT__ at start of generated file.
* Support _Float128 in tgmath.h.Joseph Myers2017-06-281-8/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds tgmath.h support for _Float128, so eliminating the awkward caveat in NEWS about the type not being supported there. This does inevitably increase the size of macro expansions (which grows particularly fast when you have nested calls to tgmath.h macros), but only when _Float128 is supported and the declarations of _Float128 interfaces are visible; otherwise the expansions are unchanged. Tested for x86_64 and arm. * math/tgmath.h: Include <bits/libc-header-start.h> and <bits/floatn.h>. (__TGMATH_F128): New macro. (__TGMATH_CF128): Likewise. (__TGMATH_UNARY_REAL_ONLY): Use __TGMATH_F128. (__TGMATH_UNARY_REAL_RET_ONLY): Likewise. (__TGMATH_BINARY_FIRST_REAL_ONLY): Likewise. (__TGMATH_BINARY_FIRST_REAL_STD_ONLY): New macro. (__TGMATH_BINARY_REAL_ONLY): Use __TGMATH_F128. (__TGMATH_BINARY_REAL_STD_ONLY): New macro. (__TGMATH_BINARY_REAL_RET_ONLY): Use __TGMATH_F128. (__TGMATH_TERNARY_FIRST_SECOND_REAL_ONLY): Likewise. (__TGMATH_TERNARY_REAL_ONLY): Likewise. (__TGMATH_TERNARY_FIRST_REAL_RET_ONLY): Likewise. (__TGMATH_UNARY_REAL_IMAG): Use __TGMATH_CF128. (__TGMATH_UNARY_IMAG): Use __TGMATH_F128. (__TGMATH_UNARY_REAL_IMAG_RET_REAL): Use __TGMATH_CF128. (__TGMATH_BINARY_REAL_IMAG): Likewise. (nexttoward): Use __TGMATH_BINARY_FIRST_REAL_STD_ONLY. [__USE_MISC] (scalb): Use __TGMATH_BINARY_REAL_STD_ONLY. * math/gen-tgmath-tests.py (Type.init_types): Enable _FloatN and _FloatNx types if the corresponding HUGE_VAL macros are defined.
* Use clog10 not __clog10 in tgmath.h log10 macro.Joseph Myers2017-06-281-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | As a GNU extension, for _GNU_SOURCE glibc's complex.h provides a clog10 function and tgmath.h supports complex arguments to the log10 macro. However, tgmath.h uses __clog10 not clog10 in defining the macro. There is no namespace reason (ignoring the block-scope namespace issues that would apply equally to *every* function called by tgmath.h macros) for using __clog10 here, since this is only for _GNU_SOURCE so clog10 is always visible when this macro definition is used. Furthermore, __clog10f128 is not exported, so supporting _Float128 in tgmath.h implies using clog10 not __clog10 there. (__clog10 and clog10 aren't used in libstdc++ either, although that library would have a good case for using the __clog10 reserved-namespace export: the standard C++ library includes log10 of a complex number.) This patch duly changes the header to use clog10, and enables tests of the macro for complex arguments. Tested for x86_64. * math/tgmath.h [__USE_GNU] (log10): Use clog10 not __clog10. * math/gen-tgmath-tests.py (Tests.add_all_tests): Test log10 for complex arguments.
* Fix tgmath.h totalorder, totalordermag return type (bug 21687).Joseph Myers2017-06-281-2/+2
| | | | | | | | | | | | | | | | | | | The tgmath.h totalorder and totalordermag macros wrongly return a floating-point type. They should return int, like the underlying functions. This patch fixes them accordingly, updating tests including enabling tests of those functions from gen-tgmath-tests.py. Tested for x86_64. [BZ #21687] * math/tgmath.h (__TGMATH_BINARY_REAL_RET_ONLY): New macro. (totalorder): Use it. (totalordermag): Likewise. * math/gen-tgmath-tests.py (Tests.add_all_tests): Enable tests of totalorder and totalordermag. * math/test-tgmath.c (F(compile_test)): Do not call totalorder or totalordermag in arguments of calls to those functions. (NCALLS): Change to 134.
* Add more thorough generated tgmath.h test.Joseph Myers2017-06-281-0/+608
This patch adds a more thorough test of tgmath.h macros, verifying both the return type and the function called for all the cases of valid argument types. (Cases with current problems - I've just filed four bugs - are disabled or omitted pending fixing those problems.) The test uses a Python generator (works with both Python 2 and 3) to generate a C file which is then built and run as a test in the usual way (and that C file includes its own dummy definitions of libm functions similar to existing tgmath.h tests). The motivation is to make it easier to add tests of tgmath.h for _Float128 when adding tgmath.h support for that type; the _FloatN / _FloatNx support is present in the script, but disabled until the tgmath.h support is written. Tested for x86_64, and for arm to check things in the long double = double case. (In that case, it's OK to call either double or long double functions when the selected type is double or long double, as long as the return type of the macro is exactly correct.) * math/gen-tgmath-tests.py: New file. * math/Makefile [PYTHON] (tests): Add test-tgmath3. [PYTHON] (generated): Add test-tgmath3.c. [PYTHON] (CFLAGS-test-tgmath3.c): New variable. [PYTHON] ($(objpfx)test-tgmath3.c): New rule.