about summary refs log tree commit diff
Commit message (Collapse)AuthorAgeFilesLines
* Bug 20729: Include libc-internal.h where required.Carlos O'Donell2016-10-314-1/+13
| | | | | | | | | The original fix for bug 20729 failed to include libc-internal.h in the files that needed them and this caused build failures on machines that don't implicitly include this header. This commit fixes that by following the consensus rule that a header, if needed, should always be directly included.
* hurd: Fix spurious port deallocationBrent W. Baccala2016-10-312-1/+7
| | | | | * sysdeps/mach/hurd/dl-sysdep.c (__mmap): Do not deallocate memobj_wr when it is MACH_PORT_NULL.
* Properly initialize glob structure with GLOB_BRACE|GLOB_DOOFFS (bug 20707)Andreas Schwab2016-10-313-39/+50
|
* Bug 20729: Fix building with -Os.Carlos O'Donell2016-10-298-1/+91
| | | | | | | | | | This commit adds a new DIAG_IGNORE_Os_NEEDS_COMMENT which is only enabled when compiling with -Os. This allows developers working on -Os enabled builds to mark false-positive warnings without impacting the warnings emitted at -O2. Then using the new DIAG_IGNORE_Os_NEEDS_COMMENT we fix 6 warnings generated with GCC 5 to get -Os builds working again.
* Add include/crypt.h.Carlos O'Donell2016-10-283-1/+8
| | | | To support tests that include crypt.h we add a wrapper.
* Fix warning caused by unused-result in bug-atexit3-lib.ccGabriel F T Gomes2016-10-282-2/+16
| | | | | | | | | The test case dlfcn/bug-atexit3-lib.cc calls write and doesn't check the result. When building with GCC 6.2, this generates a warning in 'make check', which is treated as an error. This patch replaces the call to write with a call to write_message. Tested for powerpc64le.
* Add SNAN, SNANF, SNANL macros.Joseph Myers2016-10-288-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | TS 18661-1 defines SNAN macros for signaling NaN values, suitable for use in static initializers. This patch adds them to glibc's <math.h> (provided you are building with GCC 3.3 or later; no attempt is made to provide any kind of nonconforming fallback for older compilers without the __builtin_nans functions). Tested for x86_64 and x86. * math/math.h [__GLIBC_USE (IEC_60559_BFP_EXT) && __GNUC_PREREQ (3, 3)] (SNANF): New macro. [__GLIBC_USE (IEC_60559_BFP_EXT) && __GNUC_PREREQ (3, 3)] (SNAN): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT) && __GNUC_PREREQ (3, 3)] (SNANL): Likewise. * manual/arith.texi (Infinity and NaN): Document SNANF, SNAN and SNANL. * math/test-double.h (snan_value_MACRO): New macro. * math/test-float.h (snan_value_MACRO): Likewise. * math/test-ldouble.h (snan_value_MACRO): Likewise. * math/libm-test.inc (issignaling_test_data): Add tests of snan_value_MACRO.
* Document a behavior of an elided pthread_rwlock_unlockTulio Magno Quites Machado Filho2016-10-283-0/+13
| | | | | Explain that pthread_rwlock_unlock may crash if called on a lock not held by the current thread.
* powerpc: Fix TOC stub on powerpc64 clone()Tulio Magno Quites Machado Filho2016-10-282-1/+7
| | | | | | | Use a function call to _exit() so that the linker can create a TOC stub instead of just a branch. Tested on powerpc64.
* malloc: Update comments about chunk layoutFlorian Weimer2016-10-282-10/+35
|
* crypt: Use internal names for the SHA-2 block functionsFlorian Weimer2016-10-287-30/+42
| | | | | These functions are externally visible with a static libcrypt library.
* Fix building tst-linkall-static.Carlos O'Donell2016-10-282-0/+3
| | | | | The crypt/ directory is not added as part of the sysdep directories. Add it when building tst-linkall-static to include crypt.h.
* Add missing include for stdlib.h.Carlos O'Donell2016-10-282-0/+5
| | | | | | | | | | The test math/test-nan-overflow uses malloc without including stdlib.h. On -Os builds for i486 the header inclusion order is altered enough that the test fails to build because of the warning which is turned into an error. The obvious fix is to include stdlib.h since malloc is being used directly.
* Check IFUNC definition in unrelocated shared library [BZ #20019]H.J. Lu2016-10-283-2/+41
| | | | | | | | | | | | Calling an IFUNC function defined in unrelocated shared library may lead to segfault. This patch issues an error message to request relinking the shared library if it references IFUNC function defined in the unrelocated shared library. [BZ #20019] * sysdeps/i386/dl-machine.h (elf_machine_rel): Check IFUNC definition in unrelocated shared library. * sysdeps/x86_64/dl-machine.h (elf_machine_rela): Likewise.
* i386: Support CFLAGS which imply -fno-omit-frame-pointer [BZ #20729]Florian Weimer2016-10-282-12/+59
|
* Add test for linking against most static librariesFlorian Weimer2016-10-283-1/+63
|
* sysmalloc: Initialize previous size field of mmaped chunksFlorian Weimer2016-10-282-0/+6
| | | | | With different encodings of the header, the previous zero initialization may be insufficient and produce an invalid encoding.
* malloc: Use accessors for chunk metadata accessFlorian Weimer2016-10-284-70/+127
| | | | | This change allows us to change the encoding of these struct members in a centralized fashion.
* Make strtod raise "inexact" exceptions (bug 19380).Joseph Myers2016-10-285-18/+57
| | | | | | | | | | | | | | | | | | | | | | | The strtod function should raise the "inexact" exception when its result is inexact, but fails to do so except in the case of underflow or overflow. This patch fixes it to do so for all inexact results. tst-strtod-round is extended to test for this exception; the generator is fixed to properly mark inexact results as such in the case where the inexactness is from the mpfr_subnormalize step. Tested for x86_64, x86 and powerpc. [BZ #19380] * stdlib/strtod_l.c (round_and_return): Force "inexact" exception for inexact results. * stdlib/gen-tst-strtod-round.c (string_to_fp): Return indication of inexact result where mpfr_subnormalize is the only inexact step. * stdlib/tst-strtod-round-data.h: Regenerated. * stdlib/tst-strtod-round-skeleton.c [!FE_INEXACT] (FE_INEXACT): Define to 0. (GEN_ONE_TEST): Test inexact exceptions raised are as expected.
* Fix a sparc header conformtest failure.David S. Miller2016-10-272-0/+6
| | | | * sysdeps/unix/sysv/linux/sparc/sys/user.h: Include stddef.h
* Static inline functions for mallopt helpersSiddhesh Poyarekar2016-10-272-34/+105
| | | | | | | | | | | | | | | Make mallopt helper functions for each mallopt parameter so that it can be called consistently in other areas, like setting tunables. * malloc/malloc.c (do_set_mallopt_check): New function. (do_set_mmap_threshold): Likewise. (do_set_mmaps_max): Likewise. (do_set_top_pad): Likewise. (do_set_perturb_byte): Likewise. (do_set_trim_threshold): Likewise. (do_set_arena_max): Likewise. (do_set_arena_test): Likewise. (__libc_mallopt): Use them.
* Add canonicalize, canonicalizef, canonicalizel.Joseph Myers2016-10-2649-26/+518
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TS 18661-1 defines canonicalize functions to produce a canonical version of a floating-point representation. This patch implements these functions for glibc. As with the iscanonical macro, these functions are oriented to the decimal floating-point case, where some values have both canonical and noncanonical representations. However, the functions have a return value that says whether they succeeded in storing a canonical result; thus, they can fail for the case of an invalid representation (while still not making any particular choice from among multiple equally canonical valid representations of the same value). Since no floating-point formats in glibc actually have noncanonical valid representations, a type-generic implementation of these functions can be used that expects iscanonical to return 0 only for invalid representations. Now that iscanonical is used within libm.so, libm_hidden_proto / libm_hidden_def are added for __iscanonicall. The definition of these functions is intended to correspond to a convertFormat operation to the same floating-point format. Thus, they convert signaling NaNs to quiet NaNs, raising the "invalid" exception. Such a conversion "should" produce "the canonical version of that signaling NaN made quiet". libm-test.inc is made to check NaN payloads for the output of these functions, a new feature (at some point manipulation functions such as fabs and copysign should have tests added that verify payload preservation for them). As however some architectures may not follow the recommended practice of preserving NaN payloads when converting a signaling NaN to quiet, a new math-tests.h macro SNAN_TESTS_PRESERVE_PAYLOAD is added, and defined to 0 for non-NAN2008 MIPS; any other architectures seeing test failures for lack of payload preservation in this case should also define this macro to 0. (If any cases arise where the sign isn't preserved either, those should have a similar macro added.) The ldbl-96 and ldbl-128ibm tests of iscanonical are renamed and adapted to test canonicalizel as well on the same representations. Tested for x86_64, x86, mips64 and powerpc. * math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (canonicalize): New declaration. * math/Versions (canonicalize): New libm symbol at version GLIBC_2.25. (canonicalizef): Likewise. (canonicalizel): Likewise. * math/Makefile (gen-libm-calls): Add s_canonicalizeF. * math/s_canonicalize_template.c: New file. * math/libm-test.inc: Update comment on functions tested and testing of NaN payloads. (TEST_NAN_PAYLOAD): New macro. (NO_TEST_INLINE): Update value. (XFAIL_TEST): Likewise. (ERRNO_UNCHANGED): Likewise. (ERRNO_EDOM): Likewise. (ERRNO_ERANGE): Likewise. (IGNORE_RESULT): Likewise. (NON_FINITE): Likewise. (TEST_SNAN): Likewise. (NO_TEST_MATHVEC): Likewise. (TEST_NAN_PAYLOAD_CANONICALIZE): New macro. (check_float_internal): Check NaN payloads if TEST_NAN_PAYLOAD. (struct test_Ffp_b1_data): New type. (RUN_TEST_Ffp_b1): New macro. (RUN_TEST_LOOP_Ffp_b1): Likewise. (canonicalize_test_data): New array. (canonicalize_test): New function. (main): Call canonicalize_test. * manual/arith.texi (FP Bit Twiddling): Document canonicalize, canonicalizef and canonicalizel. * manual/libm-err-tab.pl: Update comment on interfaces without ulps tabulated. * sysdeps/ieee754/ldbl-opt/nldbl-canonicalize.c: New file. * sysdeps/ieee754/ldbl-opt/s_canonicalizel.c: Likewise. * sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add canonicalize. (CFLAGS-nldbl-canonicalize.c): New variable. * sysdeps/ieee754/ldbl-128ibm/test-iscanonical-ldbl-128ibm.c: Move to ... * sysdeps/ieee754/ldbl-128ibm/test-canonical-ldbl-128ibm.c: ... here. (do_test): Also test canonicalizel. * sysdeps/ieee754/ldbl-128ibm/Makefile (tests): Change test-iscanonical-ldbl-128ibm to test-canonical-ldbl-128ibm. * sysdeps/ieee754/ldbl-128ibm/include/bits/iscanonical.h: New file. * sysdeps/ieee754/ldbl-128ibm/s_iscanonicall.c (__iscanonicall): Use libm_hidden_def. * sysdeps/ieee754/ldbl-96/test-iscanonical-ldbl-96.c: Move to ... * sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c: ... here. (do_test): Also test canonicalizel. * sysdeps/ieee754/ldbl-96/Makefile (tests): Change test-iscanonical-ldbl-96 to test-canonical-ldbl-96. * sysdeps/ieee754/ldbl-96/include/bits/iscanonical.h: New file. * sysdeps/ieee754/ldbl-96/s_iscanonicall.c (__iscanonicall): Use libm_hidden_def. * sysdeps/generic/math-tests.h (SNAN_TESTS_PRESERVE_PAYLOAD): New macro. * sysdeps/mips/math-tests.h [__mips_hard_float && !__mips_nan2008] (SNAN_TESTS_PRESERVE_PAYLOAD): Likewise. * sysdeps/nacl/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/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.
* Add getpayloadl to libnldbl.Joseph Myers2016-10-263-1/+35
| | | | | | | | | | | | This patch adds getpayloadl to libnldbl, missed in my patch that originally implemented getpayload functions. Tested for powerpc. * sysdeps/ieee754/ldbl-opt/nldbl-getpayload.c: New file. * sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add getpayload. (CFLAGS-nldbl-getpayload.c): New variable.
* Use read_int in vfscanfGabriel F. T. Gomes2016-10-262-8/+10
| | | | | | | | | The function read_int, from printf-parse.h, parses an integer from a string while avoiding overflows. It is used by other functions, such as vfprintf, to avoid undefined behavior. The function vfscanf (_IO_vfwscanf) parses an integer from the format string, and can use read_int.
* malloc: Remove malloc_get_state, malloc_set_state [BZ #19473]Florian Weimer2016-10-267-100/+504
| | | | | | | | | | | | After the removal of __malloc_initialize_hook, newly compiled Emacs binaries are no longer able to use these interfaces. malloc_get_state is only used during the Emacs build process, so we provide a stub implementation only. Existing Emacs binaries will not call this stub function, but still reference the symbol. The rewritten tst-mallocstate test constructs a dumped heap which should approximates what existing Emacs binaries pass to glibc malloc.
* iconv: Avoid writable data and relocations in ISO646Florian Weimer2016-10-262-40/+50
|
* iconv: Avoid writable data and relocations in IBM charsetsFlorian Weimer2016-10-269-154/+171
| | | | | | The IBM930, IBM933, IBM935 and IBM939 converters defined lookup tables which were not constant. They also contained an unnecessary pointer indirection.
* Remove redundant definitions of M_ARENA_* macrosSiddhesh Poyarekar2016-10-262-5/+2
| | | | | | | | | The M_ARENA_MAX and M_ARENA_TEST macros are defined in malloc.c as well as malloc.h, and the former is unnecessary. This patch removes the duplicate. Tested on x86_64 to verify that the generated code remains unchanged barring changed line numbers to __malloc_assert. * malloc/malloc.c (M_ARENA_TEST, M_ARENA_MAX): Remove.
* Remove references to sbrk to grow/shrink arenasSiddhesh Poyarekar2016-10-262-7/+8
| | | | | | | | | | | | | | | | The manual incorrectly references sbrk as the method used to grow and shrink heaps and the fact that M_TRIM_THRESHOLD and M_TOP_PAD control that behavior. In reality, a heap may be grown or shrunk through multiple methods depending on whether it is the main arena (in which case sbrk is correct) or not (in which case, there are a number of strategies including allocating an additional heap to grow an arena and/or 'mprotect' a region to make it available for allocation). Remove references to sbrk so that it covers the behavior more accurately. * manual/memory.texi (M_TOP_PAD): Remove reference to sbrk. (M_TRIM_THRESHOLD): Likewise.
* Document the M_ARENA_* mallopt parametersSiddhesh Poyarekar2016-10-263-62/+70
| | | | | | | | | | | The M_ARENA_* mallopt parameters are in wide use in production to control the number of arenas that a long lived process creates and hence there is no point in stating that this interface is non-public. Document this interface and remove the obsolete comment. * manual/memory.texi (M_ARENA_TEST): Add documentation. (M_ARENA_MAX): Likewise. * malloc/malloc.c: Remove obsolete comment.
* Add note on MALLOC_MMAP_* environment variablesSiddhesh Poyarekar2016-10-262-0/+41
| | | | | | | | | The mallopt parameters manual does not mention the environment variables that can be used to set these parameters at program startup. Mention those environment variables for completeness. * manual/memory.texi: Add environment variable alternatives to setting mallopt parameters.
* Fix atomic_fetch_xor_release.Carlos O'Donell2016-10-262-8/+17
| | | | | | | | | | | | | | | | | | No code uses atomic_fetch_xor_release except for the upcoming conditional variable rewrite. Therefore there is no user visible bug here. The use of atomic_compare_and_exchange_bool_rel is removed (since it doesn't exist anymore), and is replaced by atomic_compare_exchange_weak_release. We use weak_release because it provides better performance in the loop (the weak semantic) and because the xor is release MO (the release semantic). We don't reload expected in the loop because atomic_compare_and_exchange_weak_release does this for us as part of the CAS failure. It is otherwise a fairly plain conversion that fixes building the new condvar for 32-bit x86. Passes all regression tests for x86.
* Add tests for strfrom functionsRajalakshmi Srinivasaraghavan2016-10-255-1/+310
|
* Refactor strtod testsRajalakshmi Srinivasaraghavan2016-10-256-22/+27
| | | | This patch changes strtod* tests to use strfrom* functions.
* Add strfromd, strfromf, and strfroml functionsGabriel F. T. Gomes2016-10-2542-1/+434
| | | | | | | ISO/IEC TS 18661-1 adds several functions in the strfrom family to stdlib. This patch adds strfromd, strfromf, and strfroml. This is being done in preparation for the new floating-point type, float128. The added functions convert a floating-point value into a string, with configurable format.
* Fix cmpli usage in power6 memset.Joseph Myers2016-10-253-2/+9
| | | | | | | | | | | | | | | | | | | | | | | Building glibc for powerpc64 with recent (2.27.51.20161012) binutils, with multi-arch enabled, I get the error: ../sysdeps/powerpc/powerpc64/power6/memset.S: Assembler messages: ../sysdeps/powerpc/powerpc64/power6/memset.S:254: Error: operand out of range (5 is not between 0 and 1) ../sysdeps/powerpc/powerpc64/power6/memset.S:254: Error: operand out of range (128 is not between 0 and 31) ../sysdeps/powerpc/powerpc64/power6/memset.S:254: Error: missing operand Indeed, cmpli is documented as a four-operand instruction, and looking at nearby code it seems likely cmpldi was intended. This patch fixes this powerpc64 code accordingly, and makes a corresponding change to the powerpc32 code. Tested for powerpc, powerpc64 and powerpc64le by Tulio Magno Quites Machado Filho * sysdeps/powerpc/powerpc32/power6/memset.S (memset): Use cmplwi instead of cmpli. * sysdeps/powerpc/powerpc64/power6/memset.S (memset): Use cmpldi instead of cmpli.
* * sysdeps/unix/sysv/linux/fxstat.c: Remove useless cast.Yury Norov2016-10-247-6/+15
| | | | | | | | * sysdeps/unix/sysv/linux/lxstat.c: Likewise. * sysdeps/unix/sysv/linux/xstat.c: Likewise. * sysdeps/unix/sysv/linux/i386/fxstat.c: Likewise. * sysdeps/unix/sysv/linux/i386/lxstat.c: Likewise. * sysdeps/unix/sysv/linux/i386/xstat.c: Likewise.
* Fix Linux sh4 pread/pwrite argument passingAdhemerval Zanella2016-10-2411-100/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Although conceptually correct for p{read,write}{64} offset argument passing, sh4 implementation does not generate the correct expected code. The __ALIGNMENT_ARG redefinition is incorrect for two reasons: 1. the kernel-features.h header is included multiple times (since it contains no guards) and 2. the value it redefines is also incorrect (should be '0, ' instead of empty definition). This patch fixes it by adding another macro, SYSCALL_LL_PRW{64}, meant to be used to pass the offset argument on p{read,write}64. It is basically the already define SYSCALL_LL{64} plus __ALIGNMENT_ARG unless __ASSUME_PRW_DUMMY_ARG is define. In this case an empty dummy argument is used regardless how __ALIGNMENT_ARG is defined (sh4 case). Checked on x86_64, i686, aarch64, armhf, and powerpc64le (basically a sanity check). Also, John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> and James Clarke <jrtc27@jrtc27.com> help me check on a debian sh4 bootstrap using 2.24 plus this patch to verify it also corrected fixed the regression issue. I also verified the generated object for a 2.24 build and master with this patch for sh4 and both look identical. * sysdeps/unix/sysv/linux/pread.c (__libc_pread): Use SYSCALL_LL_PRW. * sysdeps/unix/sysv/linux/pwrite.c (__libc_pwrite): Likewise. * sysdeps/unix/sysv/linux/pread64.c (__libc_pread64): Use SYSCALL_LL64_PRW. * sysdeps/unix/sysv/linux/pwrite64.c (__libc_pwrite64): Likewise. * sysdeps/unix/sysv/linux/sh/kernel-features.h: Define __ASSUME_PRW_DUMMY_ARG. * sysdeps/unix/sysv/linux/sh/pread.c: Remove file. * sysdeps/unix/sysv/linux/sh/pread64.c: Likewise. * sysdeps/unix/sysv/linux/sh/pwrite.c: Likewise. * sysdeps/unix/sysv/linux/sh/pwrite64.c: Likewise. * sysdeps/unix/sysv/linux/sysdep.h: Define SYSCALL_LL_PRW and SYSCALL_LL_PRW64 based on __ASSUME_PRW_DUMMY_ARG.
* Fix -Wformat-length warning in tst-setgetname.cSteve Ellcey2016-10-242-1/+5
| | | | * sysdeps/unix/sysv/linux/tst-setgetname.c: Increase buffer size.
* math.h: Wrap C++ bits in extern "C++"Florian Weimer2016-10-222-2/+8
| | | | | | | It is still common to include system header files in an extern "C" block. This means that exiting <math.h>'s own extern "C" block is not sufficient to get back to C++ mode. Use an extern "C++" wrapper instead.
* Use -fno-builtin for sqrt benchmark.Joseph Myers2016-10-212-0/+5
| | | | | | | | | | | This patch makes the sqrt benchmark use -fno-builtin, as already done for benchmarks of ffs and ffsll, so that it actually benchmarks the glibc function as (presumably) intended even in the presence of the compiler inlining sqrt. Tested for x86_64 and also used for benchmarking my ARM sqrt patch. * benchtests/Makefile (CFLAGS-bench-sqrt.c): New variable.
* powerpc: Cleanup fenv_private.hPaul Murphy2016-10-212-103/+95
| | | | | | | | | | | | | | | | | | | | | | | | Some of the masks are wrong, and the naming is confusing. There are two basic cases we really care about: 1. Stacking a new rounding mode when running certain sections of code, and pausing exception handling. 2. Likewise, but discarding any exceptions which occur while running under the new rounding mode. libc_feholdexcept_setround_ppc_ctx has been removed as it basically does the same thing as libc_feholdsetround_ppc_ctx but also clearing any sticky bits. The restore behavior is what differentiates these two cases as the SET_RESTORE_ROUND{,_NOEX} macros will either merge or discard all exceptions occurring during scope of their usage. Likewise, there are a number of routines to swap, replace, or merge FP environments. This change reduces much of the common and sometimes wrong code. Tested on ppc64le, with results before and after.
* math: Define iszero as a function template for C++ [BZ #20715]Florian Weimer2016-10-214-6/+116
| | | | | This increases compatibility with C++ code which is forced to compile with _GNU_SOURCE.
* Use VSQRT instruction for ARM sqrt (bug 20660).Joseph Myers2016-10-203-0/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes ARM sqrt and sqrtf use the VSQRT VFP square root instruction when available, instead of much larger generic code for computing square roots. Now, GCC will normally inline sqrt calls except for negative arguments where errno needs to be set, and because the benchtests fail to use -fno-builtin that means no significant difference in benchmark results for sqrt (note, however, there are lots of __ieee754_sqrt calls internally in libm, which are *not* inlined - although some architectures define __ieee754_sqrt in their math_private.h for that purpose, ARM doesn't - so improving out-of-line sqrt performance is still relevant to those other functions, if not for most ordinary direct users of sqrt). With the benchtests changed to use -fno-builtin for sqrt tests, typical performance results before the change are ("max" is wildly varying in any case): "duration": 9.88358e+09, "iterations": 4.8783e+07, "max": 457.764, "min": 183.105, "mean": 202.603 and after it are: "duration": 9.45663e+09, "iterations": 2.24385e+08, "max": 274.659, "min": 30.517, "mean": 42.1447 Tested for ARM (hard-float and soft-float). [BZ #20660] * sysdeps/arm/e_sqrt.c: New file. * sysdeps/arm/e_sqrtf.c: Likewise.
* Stop powerpc copysignl raising "invalid" for sNaN argument (bug 20718).Joseph Myers2016-10-193-9/+30
| | | | | | | | | | | | | | | | | | | | | | The powerpc (hard-float) implementations of copysignl, both 32-bit and 64-bit, raise spurious "invalid" exceptions when the first argument is a signaling NaN. copysign functions should never raise exceptions even for signaling NaNs. The problem is the use of an fcmpu instruction to test the sign of the high part of the long double argument. This patch fixes the functions to use fsel instead (as used for fabsl following my fixes for a similar bug there), or to examine the integer representation for older 32-bit processors without fsel. Tested for powerpc64 and powerpc32 (configurations with and without fsel used). [BZ #20718] * sysdeps/powerpc/powerpc32/fpu/s_copysignl.S (__copysignl): Do not use floating-point comparisons to test sign. * sysdeps/powerpc/powerpc64/fpu/s_copysignl.S (__copysignl): Likewise.
* Add getpayload, getpayloadf, getpayloadl.Joseph Myers2016-10-1942-7/+491
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TS 18661-1 defines functions for manipulating the payloads of NaNs. This patch implements the getpayload functions for glibc; these extract the NaN payload (from an argument passed as a pointer, for which corresponding libm-test support is added) and return it in the same floating-point type. The return value of these functions is unspecified for non-NaN arguments; the patch does the simplest thing to implement, which is that the functions do not check whether the argument is a NaN and just treat the relevant bits of the representation as a payload regardless. A conversion from integer to floating-point is used to produce the required return value, except in the ldbl-128 case; as 128-bit integers are not supported for all configurations using ldbl-128, the code constructs the required floating-point representation of the return value directly instead. Tested for x86_64, x86, mips64 and powerpc. * math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (getpayload): New declaration. * math/Versions (getpayload): New libm symbol at version GLIBC_2.25. (getpayloadf): Likewise. (getpayloadl): Likewise. * math/Makefile (libm-calls): Add s_getpayloadF. * math/libm-test.inc: Include <nan-high-order-bit.h>. (struct test_f_f_data): Add comment. (RUN_TEST_fp_f): New macro. (RUN_TEST_LOOP_fp_f): Likewise. (getpayload_test_data): New array. (getpayload_test): New function. (main): Call getpayload_test. * math/gen-libm-test.pl (parse_args): Handle 'p' in argument descriptor. * manual/arith.texi (FP Bit Twiddling): Document getpayload, getpayloadf and getpayloadl. * manual/libm-err-tab.pl: Update comment on interfaces without ulps tabulated. * sysdeps/ieee754/dbl-64/s_getpayload.c: New file. * sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c: Likewise. * sysdeps/ieee754/flt-32/s_getpayloadf.c: Likewise. * sysdeps/ieee754/ldbl-128/s_getpayloadl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/s_getpayloadl.c: Likewise. * sysdeps/ieee754/ldbl-96/s_getpayloadl.c: Likewise. * sysdeps/nacl/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/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.
* Fix Linux fallocate tests for EOPNOTSUPPAdhemerval Zanella2016-10-183-2/+17
| | | | | | | | | | | | | | The fallocate syscall might fail on Linux due missing support from underlying filesystem (for instance some NFS versions). This patch adds this check for fallocate tests. It also moves tst-fallocate{64} to 'io' folder (since it is on fallocate{64} is built). Checked on x86_64. * sysdeps/unix/sysv/linux/Makefile [$(subdir) = math] (tests): Move tst-fallocate{64}. * sysdeps/unix/sysv/linux/tst-fallocate-common.c: Check for EOPNOTSUPP on syscall return.
* Bug 20689: Fix FMA and AVX2 detection on IntelCarlos O'Donell2016-10-172-10/+20
| | | | | | | | | | | | | | | | | | | | In the Intel Architecture Instruction Set Extensions Programming reference the recommended way to test for FMA in section '2.2.1 Detection of FMA' is: "Application Software must identify that hardware supports AVX as explained in ... after that it must also detect support for FMA..." We don't do that in glibc. We use osxsave to detect the use of xgetbv, and after that we check for AVX and FMA orthogonally. It is conceivable that you could have the AVX bit clear and the FMA bit in an undefined state. This commit fixes FMA and AVX2 detection to depend on usable AVX as required by the recommended Intel sequences. v1: https://www.sourceware.org/ml/libc-alpha/2016-10/msg00241.html v2: https://www.sourceware.org/ml/libc-alpha/2016-10/msg00265.html
* Define HIGH_ORDER_BIT_IS_SET_FOR_SNAN to 0 or 1.Joseph Myers2016-10-1723-36/+167
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch moves the HIGH_ORDER_BIT_IS_SET_FOR_SNAN macro from being defined or undefined to the preferred convention of always being defined, to either 0 or 1, so allowing typo-proof tests with #if. The macro is moved from math_private.h to a new header nan-high-order-bit.h to make it easy for all architectures to define, either through the sysdeps/generic version of the header or through providing their own version of the header, without needing #ifndef in the generic math_private.h to give a default definition. The move also allows the macro to be used without needing math_private.h to be included; the immediate motivation of this patch is to allow tests to access this information (to know what kinds of NaNs 0 is a valid payload for) without needing to include math_private.h. Existing C level rather than preprocessor conditionals at all, but this patch does not make such a change). Tested for x86_64 and x86 (testsuite); also verified for x86_64, x86, mips64 and powerpc that installed stripped shared libraries are unchanged by the patch. * sysdeps/generic/nan-high-order-bit.h: New file. * sysdeps/hppa/nan-high-order-bit.h: Likewise. * sysdeps/mips/nan-high-order-bit.h: Likewise. * sysdeps/hppa/math_private.h: Remove file. * sysdeps/mips/math_private.h (HIGH_ORDER_BIT_IS_SET_FOR_SNAN): Do not define here. * sysdeps/ieee754/dbl-64/s_issignaling.c: Include <nan-high-order-bit.h>. [HIGH_ORDER_BIT_IS_SET_FOR_SNAN]: Test with #if not #ifdef. * sysdeps/ieee754/dbl-64/s_totalorder.c: Include <nan-high-order-bit.h>. [HIGH_ORDER_BIT_IS_SET_FOR_SNAN]: Test with #if not #ifdef. * sysdeps/ieee754/dbl-64/s_totalordermag.c: Include <nan-high-order-bit.h>. [HIGH_ORDER_BIT_IS_SET_FOR_SNAN]: Test with #if not #ifdef. * sysdeps/ieee754/dbl-64/wordsize-64/s_issignaling.c: Include <nan-high-order-bit.h>. [HIGH_ORDER_BIT_IS_SET_FOR_SNAN]: Test with #if not #ifdef. * sysdeps/ieee754/dbl-64/wordsize-64/s_totalorder.c: Include <nan-high-order-bit.h>. [HIGH_ORDER_BIT_IS_SET_FOR_SNAN]: Test with #if not #ifdef. * sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c: Include <nan-high-order-bit.h>. [HIGH_ORDER_BIT_IS_SET_FOR_SNAN]: Test with #if not #ifdef. * sysdeps/ieee754/flt-32/s_issignalingf.c: Include <nan-high-order-bit.h>. [HIGH_ORDER_BIT_IS_SET_FOR_SNAN]: Test with #if not #ifdef. * sysdeps/ieee754/flt-32/s_totalorderf.c: Include <nan-high-order-bit.h>. [HIGH_ORDER_BIT_IS_SET_FOR_SNAN]: Test with #if not #ifdef. * sysdeps/ieee754/flt-32/s_totalordermagf.c: Include <nan-high-order-bit.h>. [HIGH_ORDER_BIT_IS_SET_FOR_SNAN]: Test with #if not #ifdef. * sysdeps/ieee754/ldbl-128/s_issignalingl.c: Include <nan-high-order-bit.h>. [HIGH_ORDER_BIT_IS_SET_FOR_SNAN]: Test with #if not #ifdef. * sysdeps/ieee754/ldbl-128/s_totalorderl.c: Include <nan-high-order-bit.h>. [HIGH_ORDER_BIT_IS_SET_FOR_SNAN]: Test with #if not #ifdef. * sysdeps/ieee754/ldbl-128/s_totalordermagl.c: Include <nan-high-order-bit.h>. [HIGH_ORDER_BIT_IS_SET_FOR_SNAN]: Test with #if not #ifdef. * sysdeps/ieee754/ldbl-128ibm/s_issignalingl.c: Include <nan-high-order-bit.h>. [HIGH_ORDER_BIT_IS_SET_FOR_SNAN]: Test with #if not #ifdef. * sysdeps/ieee754/ldbl-128ibm/s_totalorderl.c: Include <nan-high-order-bit.h>. [HIGH_ORDER_BIT_IS_SET_FOR_SNAN]: Test with #if not #ifdef. * sysdeps/ieee754/ldbl-128ibm/s_totalordermagl.c: Include <nan-high-order-bit.h>. [HIGH_ORDER_BIT_IS_SET_FOR_SNAN]: Test with #if not #ifdef. * sysdeps/ieee754/ldbl-96/s_issignalingl.c: Include <nan-high-order-bit.h>. [HIGH_ORDER_BIT_IS_SET_FOR_SNAN]: Test with #if not #ifdef. * sysdeps/ieee754/ldbl-96/s_totalorderl.c: Include <nan-high-order-bit.h>. [HIGH_ORDER_BIT_IS_SET_FOR_SNAN]: Test with #if not #ifdef. * sysdeps/ieee754/ldbl-96/s_totalordermagl.c: Include <nan-high-order-bit.h>. [HIGH_ORDER_BIT_IS_SET_FOR_SNAN]: Test with #if not #ifdef.
* S390: Fix fp comparison not raising FE_INVALID.Stefan Liebler2016-10-172-0/+40
| | | | | | | As gcc is using unordered comparison instructions which do not raise invalid exception if any operand is quiet NAN, FIX_COMPARE_INVALID is defined to 1. Thus iseqsig is calling feraiseexcept as workaround.