about summary refs log tree commit diff
path: root/sysdeps
Commit message (Collapse)AuthorAgeFilesLines
* sparc: Remove optimized math routines which cause testsuite failures.David S. Miller2017-02-0327-721/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | famx{,f}/fmin{,f} and 32-bit lrint cause math testsuite failures either because they generate incorrect results or they fail to signal the proper exceptions. * sysdeps/sparc/sparc64/fpu/multiarch/s_fmax-vis3.S: Remove file. * sysdeps/sparc/sparc64/fpu/multiarch/s_fmax.S: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_fmaxf-vis3.S: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_fmaxf.S: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_fmin-vis3.S: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_fmin.S: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_fminf-vis3.S: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/s_fminf.S: Likewise. * sysdeps/sparc/sparc64/fpu/multiarch/Makefile (libm-sysdep_routines): Update. * sysdeps/sparc/sparc32/sparcv9/fpu/s_fmax.S: Remove file. * sysdeps/sparc/sparc32/sparcv9/fpu/s_fmaxf.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/s_fmin.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/s_fminf.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/s_lrint.S: Likewise. * sysdeps/sparc/sparc64/fpu/s_fmax.S: Likewise. * sysdeps/sparc/sparc64/fpu/s_fmaxf.S: Likewise. * sysdeps/sparc/sparc64/fpu/s_fmin.S: Likewise. * sysdeps/sparc/sparc64/fpu/s_fminf.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fmax-vis3.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fmax.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fmaxf-vis3.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fmaxf.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fmin-vis3.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fmin.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fminf-vis3.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fminf.S: Likewise. * sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile (libm-sysdep_routines): Update.
* Allow IFUNC relocation against unrelocated shared libraryH.J. Lu2017-02-022-2/+2
| | | | | | | | | | | | | | | | | IFUNC relocation against definition in unrelocated shared library will lead to segfault when the IFUNC function is called. This patch allows such IFUNC relocations with a warning. This isn't a real fix for https://sourceware.org/bugzilla/show_bug.cgi?id=21041 It simply allows the program to load. The program will segfault when longjmp is called. * sysdeps/i386/dl-machine.h (elf_machine_rel): Replace _dl_fatal_printf with _dl_error_printf for IFUNC relocation against unrelocated shared library. * sysdeps/x86_64/dl-machine.h (elf_machine_rela): Likewise.
* Drop GLIBC_TUNABLES for setxid programs when tunables is disabled (bz #21073)Siddhesh Poyarekar2017-02-021-0/+7
| | | | | | | | | | | | | A setxid program that uses a glibc with tunables disabled may pass on GLIBC_TUNABLES as is to its child processes. If the child process ends up using a different glibc that has tunables enabled, it will end up getting access to unsafe tunables. To fix this, remove GLIBC_TUNABLES from the environment for setxid process. * sysdeps/generic/unsecvars.h: Add GLIBC_TUNABLES. * elf/tst-env-setuid-tunables.c (test_child_tunables)[!HAVE_TUNABLES]: Verify that GLIBC_TUNABLES is removed in a setgid process.
* alpha: Use saturating arithmetic in memchrRichard Henderson2017-02-011-1/+4
|
* m68k: fix 64bit atomic opsAndreas Schwab2017-02-011-6/+8
|
* Add ipc_priv.h header for Nios II to set __IPC_64 to zero.Chung-Lin Tang2017-01-311-0/+21
|
* Add VZEROUPPER to memset-vec-unaligned-erms.S [BZ #21081]H.J. Lu2017-01-301-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | Since memset-vec-unaligned-erms.S has VDUP_TO_VEC0_AND_SET_RETURN at function entry, memset optimized for AVX2 and AVX512 will always use ymm/zmm register. VZEROUPPER should be placed before ret in L(stosb): movq %rdx, %rcx movzbl %sil, %eax movq %rdi, %rdx rep stosb movq %rdx, %rax ret since it can be reached from L(stosb_more_2x_vec): cmpq $REP_STOSB_THRESHOLD, %rdx ja L(stosb) [BZ #21081] * sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S (L(stosb)): Add VZEROUPPER before ret.
* Bug 20116: Fix use after free in pthread_create()Carlos O'Donell2017-01-282-15/+11
| | | | | | | | | | | | | | | | | | The commit documents the ownership rules around 'struct pthread' and when a thread can read or write to the descriptor. With those ownership rules in place it becomes obvious that pd->stopped_start should not be touched in several of the paths during thread startup, particularly so for detached threads. In the case of detached threads, between the time the thread is created by the OS kernel and the creating thread checks pd->stopped_start, the detached thread might have already exited and the memory for pd unmapped. As a regression test we add a simple test which exercises this exact case by quickly creating detached threads with large enough stacks to ensure the thread stack cache is bypassed and the stacks are unmapped. Before the fix the testcase segfaults, after the fix it works correctly and completes without issue. For a detailed discussion see: https://www.sourceware.org/ml/libc-alpha/2017-01/msg00505.html
* Bug 21053: sh: Reduce namespace pollution from sys/ucontext.hJames Clarke2017-01-243-68/+66
| | | | | | | | | | | | | | | | | | | | | | | The problem is basically that sys/ucontext.h is defining R0..R15 which happens to conflict with some packages like Firefox when trying to build on SH. The very same problem existed on arm back then [1] and it was fixed by renaming R0..R15 to REG_R0..REG_R15. This patch imploy a similar strategy for SH. Checked on sh4-linux-gnu with run-built-tests=no and I also got reports that it fixes Firefox build on Debian sh4. * sysdeps/unix/sysv/linux/sh/sh3/ucontext_i.sym: Use new REG_R* constants instead of the old R* ones. * sysdeps/unix/sysv/linux/sh/sh4/ucontext_i.sym: Likewise. * sysdeps/unix/sysv/linux/sh/sys/ucontext.h (NGPREG): Rename... (NGREG): ... to this, to fit in with other architectures. (gpregset_t): Use new NGREG macro. [__USE_GNU]: Remove condition; all architectures other than tile are unconditional. (R*): Rename to REG_R*.
* Remove very old libm-test-ulps entries.Joseph Myers2017-01-205-208/+0
| | | | | | | | | | | | | | | | | | | | | | I noticed that some libm-test-ulps files still had long-obsolete entries for *_tonearest functions, which will no longer be used since functions with FE_TONEAREST explicitly set aren't tested separately from those functions with it as the default rounding mode any more. This patch removes those obsolete entries. However, as they are a sign of libm-test-ulps not having been regenerated from scratch for a long time, I strongly advise people testing on those platforms to remove / truncate the libm-test-ulps file, run "make regen-ulps" and commit the regenerated-from-scratch file. (Ideally any failures of libm tests still present after regeneration would be investigated / fixed - there are several open "math" bugs spread across these platforms - but simply regenerating from scratch improves things.) * sysdeps/hppa/fpu/libm-test-ulps: Remove *_tonearest entries. * sysdeps/ia64/fpu/libm-test-ulps: Likewise. * sysdeps/m68k/m680x0/fpu/libm-test-ulps: Likewise. * sysdeps/microblaze/libm-test-ulps: Likewise. * sysdeps/sh/libm-test-ulps: Likewise.
* powerpc: Fix adapt_count update in __lll_unlock_elisionTulio Magno Quites Machado Filho2017-01-201-1/+1
| | | | | Commit e9a96ea1aca4ebaa7c86e8b83b766f118d689d0f had an error that prevents adapt_count from being updated in __lll_unlock_elision.
* S390: Adjust lock elision code after review.Stefan Liebler2017-01-204-43/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch adjusts s390 specific lock elision code after review of the following patches: -S390: Use own tbegin macro instead of __builtin_tbegin. (8bfc4a2ab4bebdf86c151665aae8a266e2f18fb4) -S390: Use new __libc_tbegin_retry macro in elision-lock.c. (53c5c3d5ac238901c13f28a73ba05b0678094e80) -S390: Optimize lock-elision by decrementing adapt_count at unlock. (dd037fb3df286b7c2d0b0c6f8d02a2dd8a8e8a08) The futex value is not tested before starting a transaction, __glibc_likely is used instead of __builtin_expect and comments are adjusted. ChangeLog: * sysdeps/unix/sysv/linux/s390/htm.h: Adjust comments. * sysdeps/unix/sysv/linux/s390/elision-unlock.c: Likewise. * sysdeps/unix/sysv/linux/s390/elision-lock.c: Adjust comments. (__lll_lock_elision): Do not test futex before starting a transaction. Use __glibc_likely instead of __builtin_expect. * sysdeps/unix/sysv/linux/s390/elision-trylock.c: Adjust comments. (__lll_trylock_elision): Do not test futex before starting a transaction. Use __glibc_likely instead of __builtin_expect.
* Restore clock_* librt exports for MicroBlaze (bug 21061).Joseph Myers2017-01-191-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | MicroBlaze had clock_* functions exported from librt in glibc 2.18 and 2.19, as confirmed in <https://sourceware.org/ml/libc-alpha/2017-01/msg00369.html>, and they then disappeared in 2.20, presumably as a result of the fix <https://sourceware.org/ml/libc-alpha/2014-02/msg00598.html> for a Versions.def bug that had resulted in their unintended inclusion in 2.18 (followed by removal of the Versions.def mechanism that allowed such bugs). As they were released in that library, they should be considered part of the GLIBC_2.18 ABI and so restored for the sake of any binaries that expect them in that library. This patch restores them by adding a MicroBlaze version of clock-compat.c that overrides SHLIB_COMPAT. Tested (compilation only) with build-many-glibcs.py (where this fixes the librt ABI test failure; elf/check-execstack still fails and still needs architecture maintainer attention to fix it or XFAIL it with an appropriate explanatory comment). [BZ #21061] * sysdeps/unix/sysv/linux/microblaze/clock-compat.c: New file.
* Fix ARM fpu_control.h for assemblers requiring VFP insn names (bug 21047).Joseph Myers2017-01-191-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bug 21047 reports that the clang assembler disallows the ARM implementations of _FPU_GETCW and _FPU_SETCW. These are deliberately written the way they are, using generic coprocessor instructions (from the days when VFP was just one possible coprocessor for ARM) that have the right encodings, to handle the case of the instructions being used runtime-conditionally inside glibc, where use of these macros is not meant to result in either the assembler requiring VFP to be enabled at assembly time or in it marking the object as using VFP. However, more recent ARM ARM versions have restricted the definitions of the coprocessor instructions and reportedly the clang assembler follows that in disallowing those names for VFP instructions. In the non-__SOFTFP__ case - which in fact is the only case where these macro definitions can be used outside the build of glibc itself - using VFP instruction names is of course fine, since we know that VFP is enabled for that compilation. Thus, this patch uses the current VFP names for these instructions in that case to improve compatibility for this header file. Tested for hard-float and soft-float builds of glibc, including that installed stripped shared libraries are unchanged by the patch. [BZ #21047] * sysdeps/arm/fpu_control.h [!__SOFTFP__] (_FPU_GETCW): Use VFP name for instruction. [!__SOFTFP__] (_FPU_SETCW): Likewise.
* Make soft-float powerpc swapcontext restore the signal mask (bug 21045).Joseph Myers2017-01-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | The soft-float powerpc version of swapcontext does not restore the signal mask, resulting in stdlib/tst-setcontext2 failing: after getcontext after setcontext after swapcontext FAIL: SIGUSR2 is blocked after swapcontext. This patch fixes this by adjusting the arguments passed to __sigprocmask so that it restores the saved signal mask as well as saving the existing one. (For hard-float, this code is only used for a compat symbol, not for the current version of swapcontext.) Tested for soft-float powerpc. [BZ #21045] * sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S (__CONTEXT_FUNC_NAME): Pass address of signal mask to be restored to __sigprocmask.
* tile: Check for pointer add overflow in memchrChris Metcalf2017-01-162-0/+8
| | | | | | | | | | | | As was done in b224637928e9, check for large size causing an overflow in the loop that walks over the array. Branching out of line here is the fastest approach for handling this problem, since tile can bundle the instructions to compute the branch test in parallel with doing the required memchr loop setup computation. Unfortunately, the existing saturated ops (e.g. tilegx addxsc) are all signed saturing ops, so don't help with unsigned saturation.
* tile: pass __IPC_64 as zero for SysV IPC callsChris Metcalf2017-01-161-0/+21
| | | | | | | | In 1e5834c38a22 ("Refactor Linux ipc_priv header") a different approach to passing __IPC_64 as zero was created. The tile architecture also needs to pass __IPC_64 as zero since it does not set CONFIG_ARCH_WANT_IPC_PARSE_VERSION in the kernel. So create a minimal ipc_priv.h that specifies __IPC_64 as zero.
* Clear list of acquired robust mutexes in the child process after forking.Torvald Riegel2017-01-131-6/+14
| | | | | | | | | | | | | | Robust mutexes acquired at the time of a call to fork() do not remain acquired by the forked child process. We have to clear the list of acquired robust mutexes before registering this list with the kernel; otherwise, if some of the robust mutexes are process-shared, the parent process can alter the child's robust mutex list, which can lead to deadlocks or even modification of memory that may not be occupied by a mutex anymore. [BZ #19402] * sysdeps/nptl/fork.c (__libc_fork): Clear list of acquired robust mutexes.
* robust mutexes: Fix broken x86 assembly by removing itTorvald Riegel2017-01-136-780/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lll_robust_unlock on i386 and x86_64 first sets the futex word to FUTEX_WAITERS|0 before calling __lll_unlock_wake, which will set the futex word to 0. If the thread is killed between these steps, then the futex word will be FUTEX_WAITERS|0, and the kernel (at least current upstream) will not set it to FUTEX_OWNER_DIED|FUTEX_WAITERS because 0 is not equal to the TID of the crashed thread. The lll_robust_lock assembly code on i386 and x86_64 is not prepared to deal with this case because the fastpath tries to only CAS 0 to TID and not FUTEX_WAITERS|0 to TID; the slowpath simply waits until it can CAS 0 to TID or the futex_word has the FUTEX_OWNER_DIED bit set. This issue is fixed by removing the custom x86 assembly code and using the generic C code instead. However, instead of adding more duplicate code to the custom x86 lowlevellock.h, the code of the lll_robust* functions is inlined into the single call sites that exist for each of these functions in the pthread_mutex_* functions. The robust mutex paths in the latter have been slightly reorganized to make them simpler. This patch is meant to be easy to backport, so C11-style atomics are not used. [BZ #20985] * nptl/Makefile: Adapt. * nptl/pthread_mutex_cond_lock.c (LLL_ROBUST_MUTEX_LOCK): Remove. (LLL_ROBUST_MUTEX_LOCK_MODIFIER): New. * nptl/pthread_mutex_lock.c (LLL_ROBUST_MUTEX_LOCK): Remove. (LLL_ROBUST_MUTEX_LOCK_MODIFIER): New. (__pthread_mutex_lock_full): Inline lll_robust* functions and adapt. * nptl/pthread_mutex_timedlock.c (pthread_mutex_timedlock): Inline lll_robust* functions and adapt. * nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_full): Likewise. * sysdeps/nptl/lowlevellock.h (__lll_robust_lock_wait, __lll_robust_lock, lll_robust_cond_lock, __lll_robust_timedlock_wait, __lll_robust_timedlock, __lll_robust_unlock): Remove. * sysdeps/unix/sysv/linux/i386/lowlevellock.h (lll_robust_lock, lll_robust_cond_lock, lll_robust_timedlock, lll_robust_unlock): Remove. * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (lll_robust_lock, lll_robust_cond_lock, lll_robust_timedlock, lll_robust_unlock): Remove. * sysdeps/unix/sysv/linux/sparc/lowlevellock.h (__lll_robust_lock_wait, __lll_robust_lock, lll_robust_cond_lock, __lll_robust_timedlock_wait, __lll_robust_timedlock, __lll_robust_unlock): Remove. * nptl/lowlevelrobustlock.c: Remove file. * nptl/lowlevelrobustlock.sym: Likewise. * sysdeps/unix/sysv/linux/i386/lowlevelrobustlock.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S: Likewise.
* powerpc: Regenerate ULPsTulio Magno Quites Machado Filho2017-01-131-14/+14
| | | | | | | After this update, math/test-ildouble, math/test-ldouble and math/test-ldouble-finite pass on hard float, POWER < 7 builds. Tested on powerpc, powerpc64 and powerpc64le.
* Fix MIPS o32 posix_fadvise.Joseph Myers2017-01-121-0/+4
| | | | | | | | | | | | | | | | | | | | | | | The posix_fadvise consolidation broke posix_fadvise for MIPS o32, so resulting in posix/tst-posix_fadvise failing. MIPS o32 (and the other ABIs) has only the posix_fadvise64 syscall, which acts like posix_fadvise64_64 (in the o32 case, because of the alignment argument it's actually a 7-argument syscall). The generic posix_fadvise implementation presumes that if __NR_fadvise64 is defined, it's for the case where a single len argument is passed to the syscall rather than two syscall arguments in the case of a 32-bit system. The generic posix_fadvise64 works fine for this case (defining __NR_fadvise64_64 to __NR_fadvise64 as needed). ARM has a posix_fadvise.c that uses __posix_fadvise64_l64 in posix_fadvise, and that approach also works for MIPS o32, so this patch makes MIPS o32 include the ARM file. Tested for MIPS o32. * sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise.c: New file.
* New pthread rwlock that is more scalable.Torvald Riegel2017-01-1015-147/+147
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This replaces the pthread rwlock with a new implementation that uses a more scalable algorithm (primarily through not using a critical section anymore to make state changes). The fast path for rdlock acquisition and release is now basically a single atomic read-modify write or CAS and a few branches. See nptl/pthread_rwlock_common.c for details. * nptl/DESIGN-rwlock.txt: Remove. * nptl/lowlevelrwlock.sym: Remove. * nptl/Makefile: Add new tests. * nptl/pthread_rwlock_common.c: New file. Contains the new rwlock. * nptl/pthreadP.h (PTHREAD_RWLOCK_PREFER_READER_P): Remove. (PTHREAD_RWLOCK_WRPHASE, PTHREAD_RWLOCK_WRLOCKED, PTHREAD_RWLOCK_RWAITING, PTHREAD_RWLOCK_READER_SHIFT, PTHREAD_RWLOCK_READER_OVERFLOW, PTHREAD_RWLOCK_WRHANDOVER, PTHREAD_RWLOCK_FUTEX_USED): New. * nptl/pthread_rwlock_init.c (__pthread_rwlock_init): Adapt to new implementation. * nptl/pthread_rwlock_rdlock.c (__pthread_rwlock_rdlock_slow): Remove. (__pthread_rwlock_rdlock): Adapt. * nptl/pthread_rwlock_timedrdlock.c (pthread_rwlock_timedrdlock): Adapt. * nptl/pthread_rwlock_timedwrlock.c (pthread_rwlock_timedwrlock): Adapt. * nptl/pthread_rwlock_trywrlock.c (pthread_rwlock_trywrlock): Adapt. * nptl/pthread_rwlock_tryrdlock.c (pthread_rwlock_tryrdlock): Adapt. * nptl/pthread_rwlock_unlock.c (pthread_rwlock_unlock): Adapt. * nptl/pthread_rwlock_wrlock.c (__pthread_rwlock_wrlock_slow): Remove. (__pthread_rwlock_wrlock): Adapt. * nptl/tst-rwlock10.c: Adapt. * nptl/tst-rwlock11.c: Adapt. * nptl/tst-rwlock17.c: New file. * nptl/tst-rwlock18.c: New file. * nptl/tst-rwlock19.c: New file. * nptl/tst-rwlock2b.c: New file. * nptl/tst-rwlock8.c: Adapt. * nptl/tst-rwlock9.c: Adapt. * sysdeps/aarch64/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt. * sysdeps/arm/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt. * sysdeps/hppa/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt. * sysdeps/ia64/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt. * sysdeps/m68k/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt. * sysdeps/microblaze/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt. * sysdeps/mips/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt. * sysdeps/nios2/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt. * sysdeps/s390/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt. * sysdeps/sh/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt. * sysdeps/sparc/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt. * sysdeps/tile/nptl/bits/pthreadtypes.h (pthread_rwlock_t): Adapt. * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h (pthread_rwlock_t): Adapt. * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h (pthread_rwlock_t): Adapt. * sysdeps/x86/bits/pthreadtypes.h (pthread_rwlock_t): Adapt. * nptl/nptl-printers.py (): Adapt. * nptl/nptl_lock_constants.pysym: Adapt. * nptl/test-rwlock-printers.py: Adapt. * nptl/test-rwlockattr-printers.c: Adapt. * nptl/test-rwlockattr-printers.py: Adapt.
* Update MicroBlaze localplt.data.Joseph Myers2017-01-091-1/+2
| | | | | | | | | | | | | This patch updates the MicroBlaze localplt.data based on the results of a build with build-many-glibcs.py. This is simply an empirical update; quite possibly the port could be optimized to remove more local PLT entry usage. Tested (compilation tests) with build-many-glibcs.py. * sysdeps/unix/sysv/linux/microblaze/localplt.data (__pread64): Add libc.so PLT entry. (__tls_get_addr): Make ld.so PLT entry optional.
* Fix MIPS n64 readahead (bug 21026).Joseph Myers2017-01-051-0/+2
| | | | | | | | | | | | | | | | As noted in bug 20126, MIPS n64 uses an incorrect implementation of readahead intended for 32-bit systems. This patch adds a syscalls.list entry to fix this. An updated version of the consolidation patch <https://sourceware.org/ml/libc-alpha/2016-09/msg00527.html> could remove this syscalls.list entry again. Tested with compilation (only) for mips64; the nature of the syscall doesn't allow for a glibc test to detect this issue. [BZ #21026] * sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list (readahead): New syscall entry.
* Move wrappers to libm-compat-calls-autoGabriel F. T. Gomes2017-01-04123-61/+59
| | | | | | | | | | This commit moves one step towards the deprecation of wrappers that use _LIB_VERSION / matherr / __kernel_standard functionality, by adding the suffix '_compat' to their filenames and adjusting Makefiles and #includes accordingly. New template wrappers that do not use such functionality will be added by future patches and will be first used by the float128 wrappers.
* Fix MicroBlaze bits/setjmp.h for C++.Joseph Myers2017-01-041-1/+1
| | | | | | | | | | | | | | | For MicroBlaze, setjmp/check-installed-headers-cxx fails with: ../setjmp/setjmp.h:34:8: error: '__jmp_buf_tag' has a field '__jmp_buf_tag::__jmpbuf' whose type depends on the type '<unnamed struct>' which has no linkage [-Werror=subobject-linkage] This patch fixes this in the same way as for some other architectures: the struct used for the internal __jmp_buf type is given the tag __jmp_buf_internal_tag. Tested (compilation tests) with build-many-glibcs.py. * sysdeps/microblaze/bits/setjmp.h (__jmp_buf): Give struct tag __jmp_buf_internal_tag.
* Make MIPS soft-fp preserve NaN payloads for NAN2008.Joseph Myers2017-01-042-2/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | This corresponds to a patch applied to libgcc. In glibc it doesn't actually affect much (only fma, I think). The MIPS sfp-machine.h files have an _FP_CHOOSENAN implementation which emulates hardware semantics of not preserving signaling NaN payloads for an operation with two NaN arguments (although that doesn't suffice to avoid sNaN payload preservation in any case with just one NaN argument). However, those are only hardware semantics in the legacy NaN case; in the NAN2008 case, the architecture documentation says hardware preserves payloads in such cases. Furthermore, this implementation assumes legacy NaN semantics, so in the NAN2008 case the implementation actually has the effect of preserving sNaN payloads but not preserving qNaN payloads, when both should be preserved. This patch fixes the code just to copy from the first argument. Tested for mips64 soft-float. * sysdeps/mips/mips32/sfp-machine.h (_FP_CHOOSENAN): Always preserve NaN payload if [__mips_nan2008]. * sysdeps/mips/mips64/sfp-machine.h (_FP_CHOOSENAN): Likewise.
* Fix MicroBlaze __backtrace get_frame_size namespace (bug 21022).Joseph Myers2017-01-041-1/+1
| | | | | | | | | | | | Many linknamespace tests fail for MicroBlaze because __backtrace (as brought in by libc_fatal.c) uses an inline function get_frame_size which is not declared static. This patch fixes it to be declared static. Tested (compilation tests) with build-many-glibcs.py. [BZ #21022] * sysdeps/microblaze/backtrace.c (get_frame_size): Make static.
* Update i386 libm-test-ulps.Joseph Myers2017-01-031-4/+4
| | | | | | | | | | When testing changes to i386 libm functions (that are shadowed for i686 builds by i686 versions) recently, I saw that the plain i386 libm-test-ulps (as opposed to the i686 multiarch version) needed updating for tests that had been added since it was last updated. This patch updates it accordingly. * sysdeps/i386/fpu/libm-test-ulps: Update.
* Remove duplicate strcat implementationsAdhemerval Zanella2017-01-035-62/+3
| | | | | | | | | | | | | | | | | Since commit 6e46de42fe16 default strcat implementation is essentially the same for specialized ia64 and powerpc ones. This patch removes the redundant implementation and adjust powerpc64 ifunc code to use the default one. Checked on powerpc32-linux-gnu (default and power4) and ia64-linux build and on powerpc64le-linux-gnu. * sysdeps/ia64/strcat.c: Remove file. * sysdeps/powerpc/strcat.c: Likewise. * sysdeps/powerpc/powerpc64/multiarch/strcat-power7.c: Use default C implementation. * sysdeps/powerpc/powerpc64/multiarch/strcat-power8.c: Likewise. * sysdeps/powerpc/powerpc64/multiarch/strcat-ppc64.c: Likewise.
* powerpc: Fix write-after-destroy in lock elision [BZ #20822]Tulio Magno Quites Machado Filho2017-01-033-12/+20
| | | | | | The update of *adapt_count after the release of the lock causes a race condition when thread A unlocks, thread B continues and destroys the mutex, and thread A writes to *adapt_count.
* Fix x86 strncat optimized implementation for large sizesAdhemerval Zanella2017-01-032-0/+4
| | | | | | | | | | | | | | | | | | | | | | Similar to BZ#19387, BZ#21014, and BZ#20971, both x86 sse2 strncat optimized assembly implementations do not handle the size overflow correctly. The x86_64 one is in fact an issue with strcpy-sse2-unaligned, but that is triggered also with strncat optimized implementation. This patch uses a similar strategy used on 3daef2c8ee4df2, where saturared math is used for overflow case. Checked on x86_64-linux-gnu and i686-linux-gnu. It fixes BZ #19390. [BZ #19390] * string/test-strncat.c (test_main): Add tests with SIZE_MAX as maximum string size. * sysdeps/i386/i686/multiarch/strcat-sse2.S (STRCAT): Avoid overflow in pointer addition. * sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S (STRCPY): Likewise.
* Fix MIPS n32 lseek, lseek64 (bug 21019).Joseph Myers2017-01-022-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The lseek consolidation broke lseek64 for MIPS n32, so resulting in io/test-lfs failing with an incorrect return from ftello64. This configuration uses the lseek syscall with a 64-bit return value; as the C syscall macros return long, they cannot be used in this case and so an assembly implementation is needed; accordingly, this patch adds lseek64 back to syscalls.list for this configuration. lseek was also broken, truncating the result without checking for overflow. lseek however was already broken before the consolidation; it aliased lseek64 so would return an out-of-range value, resulting in architecturally undefined behavior in the caller if it tried to use a non-sign-extended value with a 32-bit instruction. This patch adds a custom lseek implementation in C for n32, which calls __lseek64 to get the 64-bit value then checks for overflow. Because the prior lseek breakage did not show in test results, and the lseek64 breakage showed only indirectly through tests of ftello64, test coverage was clearly inadequate. This patch extends io/test-lfs.c to test the lseek64 return value (at a point where it has already seeked over 2GB into a file), and then to test the lseek return value (with the latter's expectations depending on whether off_t is smaller than off64_t). Tested for mips64 n32. Also tested test-lfs for x86_64 and x86, where as expected it passes. [BZ #21019] * sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list (lseek64): New syscall entry. * sysdeps/unix/sysv/linux/mips/mips64/n32/lseek.c: New file. * io/test-lfs.c (do_test): Test offset returned from lseek64 and lseek.
* Correct MIPS math-tests.h condition for sNaN payload preservation.Joseph Myers2017-01-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | Testing for MIPS soft float shows that the issue with NaN payload preservation applies to soft float as well as hard float: the sfp-machine.h emulates hardware non-preservation semantics, although only for the case of two NaN arguments. This patch duly changes the MIPS math-tests.h to expect such non-preservation for soft float as well as hard float. The issue in the NAN2008 case for which I posted <https://gcc.gnu.org/ml/gcc-patches/2017-01/msg00034.html>, of sNaN payloads being preserved but qNaN payloads not being preserved, is not currently an issue for glibc tests because we don't have any tests that check for qNaN payloads being preserved by arithmetic, so a simple __mips_nan2008 conditional suffices without needing compiler version checks in the __mips_nan2008 case. Tested for mips64 soft float. * sysdeps/mips/math-tests.h (SNAN_TESTS_PRESERVE_PAYLOAD): Do not condition on [__mips_hard_float].
* Fix i686 memchr for large input sizesAdhemerval Zanella2017-01-022-3/+15
| | | | | | | | | | | | | | | | | | | Similar to BZ#19387 and BZ#20971, both i686 memchr optimized assembly implementations (memchr-sse2-bsf and memchr-sse2) do not handle the size overflow correctly. It is shown by the new tests added by commit 3daef2c8ee4df29, where both implementation fails with size as SIZE_MAX. This patch uses a similar strategy used on 3daef2c8ee4df2, where saturared math is used for overflow case. Checked on i686-linux-gnu. [BZ #21014] * sysdeps/i386/i686/multiarch/memchr-sse2-bsf.S (MEMCHR): Avoid overflow in pointer addition. * sysdeps/i386/i686/multiarch/memchr-sse2.S (MEMCHR): Likewise.
* Fix pthread_cond_t on sparc for new condvar.Torvald Riegel2017-01-021-8/+21
| | | | | * sysdeps/sparc/nptl/bits/pthreadtypes.h (pthread_cond_t): Adapt to new condvar.
* Update copyright dates not handled by scripts/update-copyrights.Joseph Myers2017-01-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I've updated copyright dates in glibc for 2017. This is the patch for the changes not generated by scripts/update-copyrights and subsequent build / regeneration of generated files. Please remember to include 2017 in the dates for any new files added in future (which means updating any existing uncommitted patches you have that add new files to use the new copyright dates in them). * NEWS: Update copyright dates. * catgets/gencat.c (print_version): Likewise. * csu/version.c (banner): Likewise. * debug/catchsegv.sh: Likewise. * debug/pcprofiledump.c (print_version): Likewise. * debug/xtrace.sh (do_version): Likewise. * elf/ldconfig.c (print_version): Likewise. * elf/ldd.bash.in: Likewise. * elf/pldd.c (print_version): Likewise. * elf/sotruss.sh: Likewise. * elf/sprof.c (print_version): Likewise. * iconv/iconv_prog.c (print_version): Likewise. * iconv/iconvconfig.c (print_version): Likewise. * locale/programs/locale.c (print_version): Likewise. * locale/programs/localedef.c (print_version): Likewise. * login/programs/pt_chown.c (print_version): Likewise. * malloc/memusage.sh (do_version): Likewise. * malloc/memusagestat.c (print_version): Likewise. * malloc/mtrace.pl: Likewise. * manual/libc.texinfo: Likewise. * nptl/version.c (banner): Likewise. * nscd/nscd.c (print_version): Likewise. * nss/getent.c (print_version): Likewise. * nss/makedb.c (print_version): Likewise. * posix/getconf.c (main): Likewise. * scripts/test-installation.pl: Likewise. * sysdeps/unix/sysv/linux/lddlibc4.c (main): Likewise.
* Update copyright dates with scripts/update-copyrights.Joseph Myers2017-01-015345-5345/+5345
|
* Add framework for tunablesSiddhesh Poyarekar2016-12-311-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The tunables framework allows us to uniformly manage and expose global variables inside glibc as switches to users. tunables/README has instructions for glibc developers to add new tunables. Tunables support can be enabled by passing the --enable-tunables configure flag to the configure script. This patch only adds a framework and does not pose any limitations on how tunable values are read from the user. It also adds environment variables used in malloc behaviour tweaking to the tunables framework as a PoC of the compatibility interface. * manual/install.texi: Add --enable-tunables option. * INSTALL: Regenerate. * README.tunables: New file. * Makeconfig (CPPFLAGS): Define TOP_NAMESPACE. (before-compile): Generate dl-tunable-list.h early. * config.h.in: Add HAVE_TUNABLES. * config.make.in: Add have-tunables. * configure.ac: Add --enable-tunables option. * configure: Regenerate. * csu/init-first.c (__libc_init_first): Move __libc_init_secure earlier... * csu/init-first.c (LIBC_START_MAIN):... to here. Include dl-tunables.h, libc-internal.h. (LIBC_START_MAIN) [!SHARED]: Initialize tunables for static binaries. * elf/Makefile (dl-routines): Add dl-tunables. * elf/Versions (ld): Add __tunable_set_val to GLIBC_PRIVATE namespace. * elf/dl-support (_dl_nondynamic_init): Unset MALLOC_CHECK_ only when !HAVE_TUNABLES. * elf/rtld.c (process_envvars): Likewise. * elf/dl-sysdep.c [HAVE_TUNABLES]: Include dl-tunables.h (_dl_sysdep_start): Call __tunables_init. * elf/dl-tunable-types.h: New file. * elf/dl-tunables.c: New file. * elf/dl-tunables.h: New file. * elf/dl-tunables.list: New file. * malloc/tst-malloc-usable-static.c: New test case. * malloc/Makefile (tests-static): Add it. * malloc/arena.c [HAVE_TUNABLES]: Include dl-tunables.h. Define TUNABLE_NAMESPACE. (DL_TUNABLE_CALLBACK (set_mallopt_check)): New function. (DL_TUNABLE_CALLBACK_FNDECL): New macro. Use it to define callback functions. (ptmalloc_init): Set tunable values. * scripts/gen-tunables.awk: New file. * sysdeps/mach/hurd/dl-sysdep.c: Include dl-tunables.h. (_dl_sysdep_start): Call __tunables_init.
* resolv: Deprecate the "inet6" option and RES_USE_INET6 [BZ #19582]Florian Weimer2016-12-311-7/+9
|
* New condvar implementation that provides stronger ordering guarantees.Torvald Riegel2016-12-3127-3791/+323
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a new implementation for condition variables, required after http://austingroupbugs.net/view.php?id=609 to fix bug 13165. In essence, we need to be stricter in which waiters a signal or broadcast is required to wake up; this couldn't be solved using the old algorithm. ISO C++ made a similar clarification, so this also fixes a bug in current libstdc++, for example. We can't use the old algorithm anymore because futexes do not guarantee to wake in FIFO order. Thus, when we wake, we can't simply let any waiter grab a signal, but we need to ensure that one of the waiters happening before the signal is woken up. This is something the previous algorithm violated (see bug 13165). There's another issue specific to condvars: ABA issues on the underlying futexes. Unlike mutexes that have just three states, or semaphores that have no tokens or a limited number of them, the state of a condvar is the *order* of the waiters. A waiter on a semaphore can grab a token whenever one is available; a condvar waiter must only consume a signal if it is eligible to do so as determined by the relative order of the waiter and the signal. Therefore, this new algorithm maintains two groups of waiters: Those eligible to consume signals (G1), and those that have to wait until previous waiters have consumed signals (G2). Once G1 is empty, G2 becomes the new G1. 64b counters are used to avoid ABA issues. This condvar doesn't yet use a requeue optimization (ie, on a broadcast, waking just one thread and requeueing all others on the futex of the mutex supplied by the program). I don't think doing the requeue is necessarily the right approach (but I haven't done real measurements yet): * If a program expects to wake many threads at the same time and make that scalable, a condvar isn't great anyway because of how it requires waiters to operate mutually exclusive (due to the mutex usage). Thus, a thundering herd problem is a scalability problem with or without the optimization. Using something like a semaphore might be more appropriate in such a case. * The scalability problem is actually at the mutex side; the condvar could help (and it tries to with the requeue optimization), but it should be the mutex who decides how that is done, and whether it is done at all. * Forcing all but one waiter into the kernel-side wait queue of the mutex prevents/avoids the use of lock elision on the mutex. Thus, it prevents the only cure against the underlying scalability problem inherent to condvars. * If condvars use short critical sections (ie, hold the mutex just to check a binary flag or such), which they should do ideally, then forcing all those waiter to proceed serially with kernel-based hand-off (ie, futex ops in the mutex' contended state, via the futex wait queues) will be less efficient than just letting a scalable mutex implementation take care of it. Our current mutex impl doesn't employ spinning at all, but if critical sections are short, spinning can be much better. * Doing the requeue stuff requires all waiters to always drive the mutex into the contended state. This leads to each waiter having to call futex_wake after lock release, even if this wouldn't be necessary. [BZ #13165] * nptl/pthread_cond_broadcast.c (__pthread_cond_broadcast): Rewrite to use new algorithm. * nptl/pthread_cond_destroy.c (__pthread_cond_destroy): Likewise. * nptl/pthread_cond_init.c (__pthread_cond_init): Likewise. * nptl/pthread_cond_signal.c (__pthread_cond_signal): Likewise. * nptl/pthread_cond_wait.c (__pthread_cond_wait): Likewise. (__pthread_cond_timedwait): Move here from pthread_cond_timedwait.c. (__condvar_confirm_wakeup, __condvar_cancel_waiting, __condvar_cleanup_waiting, __condvar_dec_grefs, __pthread_cond_wait_common): New. (__condvar_cleanup): Remove. * npt/pthread_condattr_getclock.c (pthread_condattr_getclock): Adapt. * npt/pthread_condattr_setclock.c (pthread_condattr_setclock): Likewise. * npt/pthread_condattr_getpshared.c (pthread_condattr_getpshared): Likewise. * npt/pthread_condattr_init.c (pthread_condattr_init): Likewise. * nptl/tst-cond1.c: Add comment. * nptl/tst-cond20.c (do_test): Adapt. * nptl/tst-cond22.c (do_test): Likewise. * sysdeps/aarch64/nptl/bits/pthreadtypes.h (pthread_cond_t): Adapt structure. * sysdeps/arm/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/ia64/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/m68k/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/microblaze/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/mips/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/nios2/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/s390/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/sh/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/tile/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/x86/bits/pthreadtypes.h (pthread_cond_t): Likewise. * sysdeps/nptl/internaltypes.h (COND_NWAITERS_SHIFT): Remove. (COND_CLOCK_BITS): Adapt. * sysdeps/nptl/pthread.h (PTHREAD_COND_INITIALIZER): Adapt. * nptl/pthreadP.h (__PTHREAD_COND_CLOCK_MONOTONIC_MASK, __PTHREAD_COND_SHARED_MASK): New. * nptl/nptl-printers.py (CLOCK_IDS): Remove. (ConditionVariablePrinter, ConditionVariableAttributesPrinter): Adapt. * nptl/nptl_lock_constants.pysym: Adapt. * nptl/test-cond-printers.py: Adapt. * sysdeps/unix/sysv/linux/hppa/internaltypes.h (cond_compat_clear, cond_compat_check_and_clear): Adapt. * sysdeps/unix/sysv/linux/hppa/pthread_cond_timedwait.c: Remove file ... * sysdeps/unix/sysv/linux/hppa/pthread_cond_wait.c (__pthread_cond_timedwait): ... and move here. * nptl/DESIGN-condvar.txt: Remove file. * nptl/lowlevelcond.sym: Likewise. * nptl/pthread_cond_timedwait.c: Likewise. * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S: Likewise. * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S: Likewise. * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise. * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise. * sysdeps/unix/sysv/linux/i386/i586/pthread_cond_broadcast.S: Likewise. * sysdeps/unix/sysv/linux/i386/i586/pthread_cond_signal.S: Likewise. * sysdeps/unix/sysv/linux/i386/i586/pthread_cond_timedwait.S: Likewise. * sysdeps/unix/sysv/linux/i386/i586/pthread_cond_wait.S: Likewise. * sysdeps/unix/sysv/linux/i386/i686/pthread_cond_broadcast.S: Likewise. * sysdeps/unix/sysv/linux/i386/i686/pthread_cond_signal.S: Likewise. * sysdeps/unix/sysv/linux/i386/i686/pthread_cond_timedwait.S: Likewise. * sysdeps/unix/sysv/linux/i386/i686/pthread_cond_wait.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise. * sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.
* Add fromfp functions.Joseph Myers2016-12-3158-1/+1011
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TS 18661-1 defines fromfp functions (fromfp, fromfpx, ufromfp, ufromfpx, and float and long double variants) to convert from floating-point to an integer type with any signedness and any given width up to that of intmax_t, in any of the five IEEE rounding modes (the usual four for binary floating point, plus rounding to nearest with ties rounding away from zero), with control of whether in-range non-integer values should result in the "inexact" exception being raised. This patch implements these functions for glibc. These implementations are (apart from raising exceptions) pure integer implementations; it's entirely possible optimized versions could be devised for some architectures. A common math/fromfp.h header provides various common helper code that can readily be shared between the implementations for different types. For each type, the bulk of the implementation is also shared between the four functions, with wrappers that define UNSIGNED and INEXACT macros appropriately before including the main implementation. As the functions return intmax_t and uintmax_t without math.h being allowed to expose those typedef names, they are declared using __intmax_t and __uintmax_t as obtained from <bits/types.h>. The FP_INT_* rounding direction macros are defined as ascending integers in the order the names are listed in the TS; I see no significant value in allowing architectures to vary the values of them. The libm-test machinery is duly adapted to handle unsigned int arguments, and intmax_t and uintmax_t results. Because each test input is generally tested for four functions, five rounding modes and several different widths, the libm-test.inc additions are very large. Thus, the diffs in the body of this message exclude the libm-test.inc changes, with the full patch being attached gzipped. The bulk of the new tests were generated (expanded from a test input plus rounding results and information about where it lies in the relevant interval between integers, to libm-test tests for all relevant combinations of function, rounding direction and width) by a script that's included in the patch as math/gen-fromfp-tests.py (input data math/gen-fromfp-tests-inputs); as an ad hoc script that's not really expected to be rerun, it's not very polished, but it's at least plausibly useful for adding any further tests for these functions in future. I may split the libm-test tests up by function in future (so both libm-test.inc and auto-libm-test-out are split into separate files, and the tests for each function are also built and run separately), but not for 2.25. For no obvious reason, adding tgmath tests for the new functions resulted in -Wuninitialized errors from test-tgmath.c about the variable i being used uninitialized. Those errors were correct - the variable is read by the frexp version in test-tgmath.c (where real frexp would write through that pointer instead of reading it) - but I don't know why this patch would result in the pre-existing issue being newly detected. The patch initializes the variable to avoid those errors. With these changes, glibc 2.25 should have all the library features from TS 18661-1 other than the functions that round result to narrower type (and constant rounding directions, but I'm considering those mainly a compiler feature not a library one). Tested for x86_64, x86, mips64 and powerpc. * math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)] (fromfp): New declaration. [__GLIBC_USE (IEC_60559_BFP_EXT)] (fromfpx): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfp): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfpx): Likewise. * math/tgmath.h (__TGMATH_TERNARY_FIRST_REAL_RET_ONLY): New macro. [__GLIBC_USE (IEC_60559_BFP_EXT)] (fromfp): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfp): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT)] (fromfpx): Likewise. [__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfpx): Likewise. * math/math.h: Include <bits/types.h>. [__GLIBC_USE (IEC_60559_BFP_EXT)] (FP_INT_UPWARD): New enum constant and macro. (FP_INT_DOWNWARD): Likewise. (FP_INT_TOWARDZERO): Likewise. (FP_INT_TONEARESTFROMZERO): Likewise. (FP_INT_TONEAREST): Likewise. * math/Versions (fromfp): New libm symbol at version GLIBC_2.25. (fromfpf): Likewise. (fromfpl): Likewise. (ufromfp): Likewise. (ufromfpf): Likewise. (ufromfpl): Likewise. (fromfpx): Likewise. (fromfpxf): Likewise. (fromfpxl): Likewise. (ufromfpx): Likewise. (ufromfpxf): Likewise. (ufromfpxl): Likewise. * math/Makefile (libm-calls): Add s_fromfpF, s_ufromfpF, s_fromfpxF and s_ufromfpxF. * math/gen-fromfp-tests.py: New file. * math/gen-fromfp-tests-inputs: Likewise. * math/libm-test.inc: Include <stdint.h> (check_intmax_t): New function. (check_uintmax_t): Likewise. (struct test_fiu_M_data): New type. (struct test_fiu_U_data): Likewise. (RUN_TEST_fiu_M): New macro. (RUN_TEST_LOOP_fiu_M): Likewise. (RUN_TEST_fiu_U): Likewise. (RUN_TEST_LOOP_fiu_U): Likewise. (fromfp_test_data): New array. (fromfp_test): New function. (fromfpx_test_data): New array. (fromfpx_test): New function. (ufromfp_test_data): New array. (ufromfp_test): New function. (ufromfpx_test_data): New array. (ufromfpx_test): New function. (main): Call fromfp_test, fromfpx_test, ufromfp_test and ufromfpx_test. * math/gen-libm-test.pl (parse_args): Handle u, M and U descriptor characters. * math/test-tgmath-ret.c: Include <stdint.h>. (rm): New variable. (width): Likewise. (CHECK_RET_CONST_TYPE): Take extra arguments and pass them to called function. (CHECK_RET_CONST_FLOAT): Take extra arguments and pass them to CHECK_RET_CONST_TYPE. (CHECK_RET_CONST_DOUBLE): Likewise. (CHECK_RET_CONST_LDOUBLE): Likewise. (CHECK_RET_CONST): Take extra arguments and pass them to calls macros. (fromfp): New CHECK_RET_CONST call. (ufromfp): Likewise. (fromfpx): Likewise. (ufromfpx): Likewise. (do_test): Call check_return_fromfp, check_return_ufromfp, check_return_fromfpx and check_return_ufromfpx. * math/test-tgmath.c: Include <stdint.h> (NCALLS): Increase to 138. (F(compile_test)): Initialize i. Call fromfp functions. (F(fromfp)): New function. (F(fromfpx)): Likewise. (F(ufromfp)): Likewise. (F(ufromfpx)): Likewise. * manual/arith.texi (Rounding Functions): Document FP_INT_UPWARD, FP_INT_DOWNWARD, FP_INT_TOWARDZERO, FP_INT_TONEARESTFROMZERO, FP_INT_TONEAREST, fromfp, fromfpf, fromfpl, ufromfp, ufromfpf, ufromfpl, fromfpx, fromfpxf, fromfpxl, ufromfpx, ufromfpxf and ufromfpxl. * manual/libm-err-tab.pl (@all_functions): Add fromfp, fromfpx, ufromfp and ufromfpx. * math/fromfp.h: New file. * sysdeps/ieee754/dbl-64/s_fromfp.c: Likewise. * sysdeps/ieee754/dbl-64/s_fromfp_main.c: Likewise. * sysdeps/ieee754/dbl-64/s_fromfpx.c: Likewise. * sysdeps/ieee754/dbl-64/s_ufromfp.c: Likewise. * sysdeps/ieee754/dbl-64/s_ufromfpx.c: Likewise. * sysdeps/ieee754/flt-32/s_fromfpf.c: Likewise. * sysdeps/ieee754/flt-32/s_fromfpf_main.c: Likewise. * sysdeps/ieee754/flt-32/s_fromfpxf.c: Likewise. * sysdeps/ieee754/flt-32/s_ufromfpf.c: Likewise. * sysdeps/ieee754/flt-32/s_ufromfpxf.c: Likewise. * sysdeps/ieee754/ldbl-128/s_fromfpl.c: Likewise. * sysdeps/ieee754/ldbl-128/s_fromfpl_main.c: Likewise. * sysdeps/ieee754/ldbl-128/s_fromfpxl.c: Likewise. * sysdeps/ieee754/ldbl-128/s_ufromfpl.c: Likewise. * sysdeps/ieee754/ldbl-128/s_ufromfpxl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/s_fromfpl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/s_fromfpl_main.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/s_fromfpxl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/s_ufromfpl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/s_ufromfpxl.c: Likewise. * sysdeps/ieee754/ldbl-96/s_fromfpl.c: Likewise. * sysdeps/ieee754/ldbl-96/s_fromfpl_main.c: Likewise. * sysdeps/ieee754/ldbl-96/s_fromfpxl.c: Likewise. * sysdeps/ieee754/ldbl-96/s_ufromfpl.c: Likewise. * sysdeps/ieee754/ldbl-96/s_ufromfpxl.c: Likewise. * sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add fromfp, ufromfp, fromfpx and ufromfpx. (CFLAGS-nldbl-fromfp.c): New variable. (CFLAGS-nldbl-fromfpx.c): Likewise. (CFLAGS-nldbl-ufromfp.c): Likewise. (CFLAGS-nldbl-ufromfpx.c): Likewise. * sysdeps/ieee754/ldbl-opt/nldbl-compat.h: Include <stdint.h>. * sysdeps/ieee754/ldbl-opt/nldbl-fromfp.c: New file. * sysdeps/ieee754/ldbl-opt/nldbl-fromfpx.c: Likewise. * sysdeps/ieee754/ldbl-opt/nldbl-ufromfp.c: Likewise. * sysdeps/ieee754/ldbl-opt/nldbl-ufromfpx.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.
* Define __intmax_t, __uintmax_t in bits/types.h.Joseph Myers2016-12-301-9/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | TS 18661-1 defines *fromfp* functions, which are declared in math.h and whose return types are intmax_t and uintmax_t, without allowing math.h to define those typedefs. (This is similar to e.g. ISO C declaring vprintf in stdio.h without allowing that header to define va_list.) Thus, math.h needs to access those typedefs under internal names. This patch accordingly arranges for bits/types.h (which defines only internal names, not public *_t typedefs) to define __intmax_t and __uintmax_t. stdint.h is made to use bits/types.h and define intmax_t and uintmax_t using __intmax_t and __uintmax_t, to avoid duplication of information. (It would be reasonable to define more of the types in stdint.h - and in sys/types.h, where it duplicates such types - using information already available in bits/types.h.) The idea is that the subsequent addition of fromfp functions would then make math.h include bits/types.h and use __intmax_t and __uintmax_t as the return types of those functions. Tested for x86_64 and x86 (testsuite, and that installed stripped shared libraries are unchanged by the patch). * bits/types.h (__intmax_t): New typedef. (__uintmax_t): Likewise. * sysdeps/generic/stdint.h: Include <bits/types.h>. (intmax_t): Define using __intmax_t. (uintmax_t): Define using __uintmax_t.
* Use shmget syscall for linux implementationAdhemerval Zanella2016-12-2810-35/+7
| | | | | | | | | | | | | | | | | | | | | this patch add a direct call to shmget syscall if it is supported by kernel features. Checked on x86_64, i686, powerpc64le, aarch64, and armhf. * sysdeps/unix/sysv/linux/alpha/syscalls.list (shmget): Remove. * sysdeps/unix/sysv/linux/arm/syscalls.list (shmget): Likewise. * sysdeps/unix/sysv/linux/generic/syscalls.list (shmget): Likewise. * sysdeps/unix/sysv/linux/hppa/syscalls.list (shmget): Likewise. * sysdeps/unix/sysv/linux/ia64/syscalls.list (shmget): Likewise. * sysdeps/unix/sysv/linux/microblaze/syscalls.list (shmget): Likewise. * sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (shmget): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (shmget): Likewise. * sysdeps/unix/sysv/linux/x86_64/syscalls.list (shmget): Likewise. * sysdeps/unix/sysv/linux/shmget.c (shmget): Use shmget syscall if it is defined.
* Use shmdt syscall for linux implementationAdhemerval Zanella2016-12-2810-14/+7
| | | | | | | | | | | | | | | | | | | | | this patch add a direct call to shmdt syscall if it is supported by kernel features. hecked on x86_64, i686, powerpc64le, aarch64, and armhf. * sysdeps/unix/sysv/linux/alpha/syscalls.list (shmdt): Remove. * sysdeps/unix/sysv/linux/arm/syscalls.list (shmdt): Likewise. * sysdeps/unix/sysv/linux/generic/syscalls.list (shmdt): Likewise. * sysdeps/unix/sysv/linux/hppa/syscalls.list (shmdt): Likewise. * sysdeps/unix/sysv/linux/ia64/syscalls.list (shmdt): Likewise. * sysdeps/unix/sysv/linux/microblaze/syscalls.list (shmdt): Likewise. * sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (shmdt): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (shmdt): Likewise. * sysdeps/unix/sysv/linux/x86_64/syscalls.list (shmdt): Likewise. * sysdeps/unix/sysv/linux/shmdt.c (shmdt): Use shmdt syscall if it is defined.
* Consolidate Linux shmctl implementationAdhemerval Zanella2016-12-2812-89/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch consolidates the shmctl Linux implementation in only one default file, sysdeps/unix/sysv/linux/shmctl.c. If tries to use the direct syscall if it is supported, otherwise will use the old ipc multiplex mechanism. The patch also simplify header inclusion and reorganize internal compat symbol to be built only if old ipc is defined. Checked on x86_64, i686, powerpc64le, aarch64, and armhf. * sysdeps/unix/sysv/linux/alpha/Makefile (sysdeps_routines): Remove oldshmctl. * sysdeps/unix/sysv/linux/alpha/syscalls.list (shmctl): Remove. * sysdeps/unix/sysv/linux/arm/syscalls.list (shmctl): Likewise. * sysdeps/unix/sysv/linux/generic/syscalls.list (shmctl): Likewise. * sysdeps/unix/sysv/linux/hppa/syscalls.list (shmctl): Likewise. * sysdeps/unix/sysv/linux/ia64/syscalls.list (shmctl): Likewise. * sysdeps/unix/sysv/linux/microblaze/syscalls.list (shmctl): Likewise. * sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (shmctl): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (shmctl): Likewise. * sysdeps/unix/sysv/linux/x86_64/syscalls.list (shmctl): Likewise. * sysdeps/unix/sysv/linux/alpha/shmctl.c: Remove file. * sysdeps/unix/sysv/linux/arm/shmctl.c: Likewise. * sysdeps/unix/sysv/linux/microblaze/shmctl.c: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/shmctl.c: Use default implementation. * sysdeps/unix/sysv/linux/shmctl.c (__new_shmctl): Use shmctl syscall if it is defined.
* Use shmat syscall for Linux implementationAdhemerval Zanella2016-12-2811-22/+15
| | | | | | | | | | | | | | | | | | | | | | | This patch add a direct call to shmat syscall if it is supported by kernel features. Checked on x86_64, i686, powerpc64le, aarch64, and armhf. * sysdeps/unix/sysv/linux/alpha/syscalls.list (shmat): Remove. * sysdeps/unix/sysv/linux/arm/syscalls.list (shmat): Likewise. * sysdeps/unix/sysv/linux/generic/syscalls.list (shmat): Likewise. * sysdeps/unix/sysv/linux/hppa/syscalls.list (shmat): Likewise. * sysdeps/unix/sysv/linux/ia64/syscalls.list (shmat): Likewise. * sysdeps/unix/sysv/linux/microblaze/syscalls.list (shmat): Likewise. * sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (shmat): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (shmat): Likewise. * sysdeps/unix/sysv/linux/x86_64/syscalls.list (shmat): Likewise. * sysdeps/unix/sysv/linux/alpha/kernel-features.h (__NR_shmat): Define to __NR_osf_shmat. * sysdeps/unix/sysv/linux/shmat.c (shmat): Use shmat syscall if it is defined.
* Consolidate Linux semtimedop implementationAdhemerval Zanella2016-12-2811-88/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch consolidates the semtimedop Linux implementation in only one default file, sysdeps/unix/sysv/linux/semtimedop.c. If tries to use the direct syscall if it is supported, otherwise will use the old ipc multiplex mechanism. Checked on x86_64, i686, powerpc64le, aarch64, and armhf. * sysdeps/unix/sysv/linux/alpha/syscalls.list (semtimedop): Remove. * sysdeps/unix/sysv/linux/arm/syscalls.list (semtimedop): Likewise. * sysdeps/unix/sysv/linux/generic/syscalls.list (semtimedop): Likewise. * sysdeps/unix/sysv/linux/hppa/syscalls.list (semtimedop): Likewise. * sysdeps/unix/sysv/linux/ia64/syscalls.list (semtimedop): Likewise. * sysdeps/unix/sysv/linux/microblaze/syscalls.list (semtimedop): Likewise. * sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (semtimedop): Likewise. * sysdeps/unix/sysv/linux/x86_64/syscalls.list (semtimedop): Likewise. * sysdeps/unix/sysv/linux/m68k/semtimedop.S: Remove file. * sysdeps/unix/sysv/linux/s390/semtimedop.c: Reorganize headers and add a comment about s390 syscall difference from default one. * sysdeps/unix/sysv/linux/semtimedop.c (semtimedop): Use semtimedop syscall if it is defined.
* Use semop syscall for Linux implementationAdhemerval Zanella2016-12-2810-13/+6
| | | | | | | | | | | | | | | | | | | | | This patch add a direct call to semop syscall if it is supported by kernel headers. Checked on x86_64, i686, powerpc64le, aarch64, and armhf. * sysdeps/unix/sysv/linux/alpha/syscalls.list (semop): Remove. * sysdeps/unix/sysv/linux/arm/syscalls.list (semop): Likewise. * sysdeps/unix/sysv/linux/generic/syscalls.list (semop): Likewise. * sysdeps/unix/sysv/linux/hppa/syscalls.list (semop): Likewise. * sysdeps/unix/sysv/linux/ia64/syscalls.list (semop): Likewise. * sysdeps/unix/sysv/linux/microblaze/syscalls.list (semop): Likewise. * sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (semop): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (semop): Likewise. * sysdeps/unix/sysv/linux/x86_64/syscalls.list (semop): Likewise. * sysdeps/unix/sysv/linux/semop.c (semop): Use semop syscall if it is defined.
* Use semget syscall for Linux implementationAdhemerval Zanella2016-12-2810-14/+6
| | | | | | | | | | | | | | | | | | | | | This patch add a direct call to semget syscall if it is supported by kernel features. hecked on x86_64, i686, powerpc64le, aarch64, and armhf. * sysdeps/unix/sysv/linux/alpha/syscalls.list (semget): Remove. * sysdeps/unix/sysv/linux/arm/syscalls.list (semget): Likewise. * sysdeps/unix/sysv/linux/generic/syscalls.list (semget): Likewise. * sysdeps/unix/sysv/linux/hppa/syscalls.list (semget): Likewise. * sysdeps/unix/sysv/linux/ia64/syscalls.list (semget): Likewise. * sysdeps/unix/sysv/linux/microblaze/syscalls.list (semget): Likewise. * sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (semget): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (semget): Likewise. * sysdeps/unix/sysv/linux/x86_64/syscalls.list (semget): Likewise. * sysdeps/unix/sysv/linux/semget.c (semget): Use semget syscall if it is defined.