about summary refs log tree commit diff
path: root/sysdeps
Commit message (Collapse)AuthorAgeFilesLines
* hurd: Fix includability of <hurd/signal.h> in all standardsSamuel Thibault2018-03-058-0/+40
| | | | | | | | | | | | | * bits/sigaction.h: Add include guard. * sysdeps/unix/sysv/linux/alpha/bits/sigaction.h: Likewise. * sysdeps/unix/sysv/linux/bits/sigaction.h: Likewise. * sysdeps/unix/sysv/linux/hppa/bits/sigaction.h: Likewise. * sysdeps/unix/sysv/linux/ia64/bits/sigaction.h: Likewise. * sysdeps/unix/sysv/linux/mips/bits/sigaction.h: Likewise. * sysdeps/unix/sysv/linux/s390/bits/sigaction.h: Likewise. * sysdeps/unix/sysv/linux/sparc/bits/sigaction.h: Likewise. * sysdeps/unix/sysv/linux/tile/bits/sigaction.h: Likewise. * hurd/hurd/signal.h: Include <bits/sigaction.h>.
* Fix s390 -Os iconv build.Joseph Myers2018-03-051-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Building glibc for s390 with -Os (32-bit only, with GCC 7) fails with: In file included from ../sysdeps/s390/multiarch/8bit-generic.c:370:0, from ebcdic-at-de.c:28: ../iconv/loop.c: In function '__to_generic_vx': ../iconv/loop.c:264:22: error: 'ch' may be used uninitialized in this function [-Werror=maybe-uninitialized] if (((Character) >> 7) == (0xe0000 >> 7)) \ ^~ In file included from ebcdic-at-de.c:28:0: ../sysdeps/s390/multiarch/8bit-generic.c:340:15: note: 'ch' was declared here uint32_t ch; \ ^ ../iconv/loop.c:325:7: note: in expansion of macro 'BODY' BODY ^~~~ It's fairly easy to see, looking at the (long) expansion of the BODY macro, that this is a false positive and the relevant variable 'ch' is always initialized before use, in one of two possible places. As such, disabling the warning for -Os with the DIAG_* macros is the natural approach to fix this build failure. However, because of the location at which the warning is reported, the disabling needs to go in iconv/loop.c, around the definition of UNICODE_TAG_HANDLER (not inside the definition), as that macro definition is where the uninitialized use is reported, whereas the code that needs to be reasoned about to see that the warning is a false positive is in the definition of BODY elsewhere. Thus, the patch adds such disabling in iconv/loop.c, with a comment pointing to the s390-specific code and a comment in the s390-specific code pointing to the generic file to alert people to the possible need to update one place when changing the other. It would be possible if desired to use #ifdef __s390__ around the disabling, though in general we try to avoid that sort of thing in generic files. (Or some extremely specialized macros for "disable -Wmaybe-uninitialized in this particular place" could be specified, defined to 0 in a lot of different files that include iconv/loop.c and to 1 in that particular s390 file.) Tested that this fixed -Os compilation for s390-linux-gnu with build-many-glibcs.py. * iconv/loop.c (UNICODE_TAG_HANDLER): Disable -Wmaybe-uninitialized for -Os. * sysdeps/s390/multiarch/8bit-generic.c (BODY): Add comment about this disabling.
* Define _DIRENT_MATCHES_DIRENT64 regardlessAdhemerval Zanella2018-03-051-0/+2
| | | | | | | | | | | | | | | | | | | | | | This patch defines _DIRENT_MATCHES_DIRENT64 to either 0 or 1 and adjust its usage from checking its definition to its value. Checked on a build for major Linux abis. * bits/dirent.h (__INO_T_MATCHES_INO64_T): Define regardless whether __INO_T_MATCHES_INO64_T is defined. * sysdeps/unix/sysv/linux/bits/dirent.h: Likewise. * dirent/alphasort.c: Check _DIRENT_MATCHES_DIRENT64 value instead of definition. * dirent/alphasort64.c: Likewise. * dirent/scandir.c: Likewise. * dirent/scandir64-tail.c: Likewise. * dirent/scandir64.c: Likewise. * dirent/scandirat.c: Likewise. * dirent/scandirat64.c: Likewise. * dirent/versionsort.c: Likewise. * dirent/versionsort64.c: Likewise. * include/dirent.h: Likewise.
* nptl: Fix tst-cancel4 sendto testsAdhemerval Zanella2018-03-052-14/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that send might be implemented calling sendto syscall on Linux, I am seeing some issue in some kernel configurations where tst-cancel4 sendto do not block as expected. The socket used to force the syscall blocking is used with default system configuration for buffer sending size, which might not be suffice to force blocking. This patch fixes it by explicit setting buffer socket lower than the buffer size used. It also enables sendto cancellation tests to work in both ways (since internally send is implemented routing to sendto on Linux kernel). The patch also removes unrequired make rules on some archictures for send/recv. The generic nptl Makefile already set the compiler flags required on some architectures for correct unwinding and libc object are not strictly required to support unwind (since pthread_cancel requires linking against libpthread). Checked on aarch64-linux-gnu and x86_64-linux-gnu. I also did a sniff test with tst-cancel{4,5} on a simulated mips64-linux-gnu. * nptl/tst-cancel4-common.h (set_socket_buffer): New function. * nptl/tst-cancel4-common.c (do_test): Call set_socket_buffer for socketpair endpoint. * nptl/tst-cancel4.c (tf_send): Call set_socket_buffer and use WRITE_BUFFER_SIZE as buffer size for sending socket. (tf_sendto): Use SOCK_STREAM instead of SOCK_DGRAM and fix an issue on system where send is implemented with sendto syscall. * sysdeps/unix/sysv/linux/mips/mips64/Makefile [$(subdir) = socket] (CFLAGS-recv.c, CFLAGS-send.c): Remove rules. [$(subdir) = nptl] (CFLAGS-recv.c, CFLAGS-send.c): Likewise. * sysdeps/unix/sysv/linux/riscv/rv64/Makefile: Remove file.
* i386: Fix i386 sigaction sa_restorer initialization (BZ#21269)Adhemerval Zanella2018-03-053-1/+238
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes the i386 sa_restorer field initialization for sigaction syscall for kernel with vDSO. As described in bug report, i386 Linux (and compat on x86_64) interprets SA_RESTORER clear with nonzero sa_restorer as a request for stack switching if the SS segment is 'funny'. This means that anything that tries to mix glibc's signal handling with segmentation (for instance through modify_ldt syscall) is randomly broken depending on what values lands in sa_restorer. The testcase added is based on Linux test tools/testing/selftests/x86/ldt_gdt.c, more specifically in do_multicpu_tests function. The main changes are: - C11 atomics instead of plain access. - Remove x86_64 support which simplifies the syscall handling and fallbacks. - Replicate only the test required to trigger the issue. Checked on i686-linux-gnu. [BZ #21269] * sysdeps/unix/sysv/linux/i386/Makefile (tests): Add tst-bz21269. * sysdeps/unix/sysv/linux/i386/sigaction.c (SET_SA_RESTORER): Clear sa_restorer for vDSO case. * sysdeps/unix/sysv/linux/i386/tst-bz21269.c: New file.
* hurd: Add futimens supportSamuel Thibault2018-03-041-0/+50
| | | | * sysdeps/mach/hurd/futimens.c: New file.
* Separate out error_t definitionSamuel Thibault2018-03-043-16/+29
| | | | | | | | | | | | | | | | | | so interfaces needing it can get it. * stdlib/errno.h (error_t): Move definition to... * bits/types/error_t.h: ... new header. * stdlib/Makefile (headers): Add bits/types/error_t.h. * sysdeps/mach/hurd/bits/errno.h (error_t): Move definition to... * sysdeps/mach/hurd/bits/types/error_t.h: ... new header. * sysdeps/mach/hurd/errnos.awk (error_t): Likewise. * hurd/hurd.h: Include <bits/types/error_t.h> * hurd/hurd/fd.h: Include <bits/types/error_t.h> * hurd/hurd/id.h: Include <errno.h> and <bits/types/error_t.h> * hurd/hurd/lookup.h: Include <errno.h> and <bits/types/error_t.h> * hurd/hurd/resource.h: Include <bits/types/error_t.h> * hurd/hurd/signal.h: Include <bits/types/error_t.h> * hurd/hurd/sigpreempt.h: Include <bits/types/error_t.h>
* hurd: Add missing includeSamuel Thibault2018-03-041-0/+1
| | | | * sysdeps/mach/hurd/dl-sysdep.c: Include <mach/machine/vm_param.h>.
* hurd: Move mach/param.h to bits/mach/param.hSamuel Thibault2018-03-042-2/+2
| | | | | | | | * mach/Makefile (headers): Move mach/param.h to bits/mach/param.h. * sysdeps/mach/i386/mach/param.h: Move file to ... * sysdeps/mach/i386/bits/mach/param.h: ... here. Update path in #error. * sysdeps/mach/hurd/bits/param.h: Include <bits/mach/param.h> instead of <mach/param.h>.
* Fix powerpc ifunc-sel.h build for -Os.Joseph Myers2018-03-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Compiling the testsuite for powerpc (multi-arch configurations) with -Os with GCC 7 fails with: In file included from ifuncmod1.c:7:0, from ifuncdep1.c:3: ../sysdeps/powerpc/ifunc-sel.h: In function 'ifunc_sel': ../sysdeps/powerpc/ifunc-sel.h:12:3: error: asm operand 2 probably doesn't match constraints [-Werror] __asm__ ("mflr 12\n\t" ^~~~~~~ ../sysdeps/powerpc/ifunc-sel.h:12:3: error: asm operand 3 probably doesn't match constraints [-Werror] ../sysdeps/powerpc/ifunc-sel.h:12:3: error: asm operand 4 probably doesn't match constraints [-Werror] ../sysdeps/powerpc/ifunc-sel.h:12:3: error: impossible constraint in 'asm' The "i" constraints on function pointers require the function call to be inlined so the compiler can see the constant function pointer arguments passed to the asm. This patch marks the relevant functions as always_inline accordingly. Tested that this fixes the -Os testsuite build for powerpc-linux-gnu-power4, powerpc64-linux-gnu, powerpc64le-linux-gnu with build-many-glibcs.py. * sysdeps/powerpc/ifunc-sel.h (ifunc_sel): Make always_inline. (ifunc_one): Likewise.
* nptl: Move pthread_atfork to libc_nonshared.aFlorian Weimer2018-03-011-2/+1
| | | | | | | | | | | | | libpthread_nonshared.a is unused after this, so remove it from the build. There is no ABI impact because pthread_atfork was implemented using __register_atfork in libc even before this change. pthread_atfork has to be a weak alias because pthread_* names are not reserved in libc. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Fix i386 fenv_private.h float128 for 32-bit --with-fpmath=sse (bug 22902).Joseph Myers2018-02-281-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed in bug 22902, the i386 fenv_private.h implementation has problems for float128 for the case of 32-bit glibc built with libgcc from GCC configured using --with-fpmath=sse. The optimized floating-point state handling in fenv_private.h needs to know which floating-point state - x87 or SSE - is used for each floating-point type, so that only one state needs updating / testing for libm code using that state internally. On 32-bit x86, the x87 rounding mode is always used for float128, but the x87 exception flags are only used when libgcc is built using x87 floating-point arithmetic; if libgcc is built for SSE arithmetic, the SSE exception flags are used. The choice of arithmetic with which libgcc is built is independent of that with which glibc is built. Thus, since glibc cannot tell the choice used in libgcc, the default implementations of libc_feholdexcept_setroundf128 and libc_feupdateenv_testf128 (which use the <fenv.h> functions, thus using both x87 and SSE state on processors that have both) need to be used; this patch updates the code accordingly. Tested for 32-bit x86; HJ reports testing in the --with-fpmath=sse case. [BZ #22902] * sysdeps/i386/fpu/fenv_private.h [!__x86_64__] (libc_feholdexcept_setroundf128): New macro. [!__x86_64__] (libc_feupdateenv_testf128): Likewise.
* Use libc_hidden_* for strtoumax (bug 15105).Joseph Myers2018-02-282-0/+2
| | | | | | | | | | | | | | | | | | | On sparc, localplt test failures appear when building with -Os because of a call to strtoumax from sysdeps/unix/sysv/linux/sparc/sparc64/get_clockfreq.c, and strtoumax is not inlined when building with -Os. This patch fixes those failures by using libc_hidden_proto and libc_hidden_def for strtoumax. Tested with build-many-glibcs.py for sparc64-linux-gnu-disable-multi-arch, sparc64-linux-gnu, sparcv9-linux-gnu-disable-multi-arch, sparcv9-linux-gnu that this fixes that test failure with -Os. [BZ #15105] * sysdeps/wordsize-32/strtoumax.c (strtoumax): Use libc_hidden_def. * sysdeps/wordsize-64/strtoumax.c (strtoumax): Likewise. * include/inttypes.h: New file.
* hurd: fix timer_routines.c buildSamuel Thibault2018-02-271-1/+1
| | | | | * sysdeps/pthread/timer_routines.c: Include <timer_routines.h> instead of <internaltypes.h>.
* hurd: fix gai_misc buildSamuel Thibault2018-02-271-0/+67
| | | | * sysdeps/mach/hurd/gai_misc.h: New file.
* hurd: fix timer_routines.c buildSamuel Thibault2018-02-271-0/+3
| | | | | * sysdeps/pthread/timer_routines.c: [!defined DELAYTIMER_MAX] (DELAYTIMER_MAX): Define to INT_MAX.
* Move NPTL-specific code to NPTL-specific headerSamuel Thibault2018-02-272-26/+52
| | | | | | | * sysdeps/pthread/timer_routines.c: Include <timer_routines.h> instead of <nptl/pthreadP.h> (thread_attr_compare): Move function to... * sysdeps/nptl/timer_routines.h: ... new header.
* linux/powerpc: sync sys/ptrace.h with Linux 4.15 [BZ #22433, #22807]Dmitry V. Levin2018-02-261-0/+62
| | | | | | | | | | | Tested with strace. * sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h (__ptrace_request): Add PTRACE_GETREGS, PTRACE_SETREGS, PTRACE_GETFPREGS, PTRACE_SETFPREGS, PTRACE_GETVRREGS, PTRACE_SETVRREGS, PTRACE_GETEVRREGS, PTRACE_SETEVRREGS, PTRACE_GETREGS64, PTRACE_SETREGS64, PTRACE_GET_DEBUGREG, PTRACE_SET_DEBUGREG, PTRACE_GETVSRREGS, PTRACE_SETVSRREGS, and PTRACE_SINGLEBLOCK.
* powerpc: Undefine Linux ptrace macros that conflict with __ptrace_requestTulio Magno Quites Machado Filho2018-02-261-0/+43
| | | | | | | | | | | Linux ptrace headers define macros whose tokens conflict with the constants of enum __ptrace_request causing build errors when asm/ptrace.h or linux/ptrace.h are included before sys/ptrace.h. * sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h: Undefine Linux macros used in __ptrace_request. Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
* Define GEN_AS_CONST_HEADERS when generating header files [BZ #22792]H.J. Lu2018-02-232-2/+8
| | | | | | | | | | | | | | | | | | | | | Glibc build generates header files to define constants from special .sym files. If a .sym file includes the same header file which it generates, it leads to circular dependency which may lead to build hang on a many-core machine. Define GEN_AS_CONST_HEADERS when generating header files to avoid circular dependency. <tcb-offsets.h> is needed for i686 and it isn't needed for x86-64 at least since glibc 2.23. Tested on i686 and x86-64. [BZ #22792] * Makerules ($(common-objpfx)%.h): Pass -DGEN_AS_CONST_HEADERS to $(CC). * sysdeps/unix/sysv/linux/i386/lowlevellock.h: Include <tcb-offsets.h> only if GEN_AS_CONST_HEADERS isn't defined. * sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Don't include <tcb-offsets.h>.
* Update sparc ulpsAdhemerval Zanella2018-02-221-0/+2
| | | | * sysdeps/sparc/fpu/libm-test-ulps: Update.
* Refactor atfork handlersAdhemerval Zanella2018-02-223-108/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current implementation (sysdeps/nptl/fork.c) replicates the atfork handlers list backward to invoke the child handlers after fork/clone syscall. The internal atfork handlers is implemented as a single-linked list so a lock-free algorithm can be used, trading fork mulithread call performance for some code complexity and dynamic stack allocation (since the backwards list should not fail). This patch refactor it to use a dynarary instead of a linked list. It simplifies the external variables need to be exported and also the internal atfork handler member definition. The downside is a serialization of fork call in multithread, since to operate on the dynarray the internal lock should be used. However as noted by Florian, it already acquires external locks for malloc and libio so it is already hitting some lock contention. Besides, posix_spawn should be faster and more scalable to run external programs in multithread environments. Checked on x86_64-linux-gnu. * nptl/Makefile (routines): Remove unregister-atfork. * nptl/register-atfork.c (fork_handler_pool): Remove variable. (fork_handler_alloc): Remove function. (fork_handlers, fork_handler_init): New variables. (__fork_lock): Rename to atfork_lock. (__register_atfork, __unregister_atfork, libc_freeres_fn): Rewrite to use a dynamic array to add/remove atfork handlers. * sysdeps/nptl/fork.c (__libc_fork): Likewise. * sysdeps/nptl/fork.h (__fork_lock, __fork_handlers, __linkin_atfork): Remove declaration. (fork_handler): Remove next, refcntr, and need_signal member. (__run_fork_handler_type): New enum. (__run_fork_handlers): New prototype. * sysdeps/nptl/libc-lockP.h (__libc_atfork): Remove declaration.
* Rename nptl-signals.h to internal-signals.hAdhemerval Zanella2018-02-224-14/+13
| | | | | | | | | | | | | | | | | | | | | | | This patch renames the nptl-signals.h header to internal-signals.h. On Linux the definitions and functions are not only NPTL related, but used for other POSIX definitions as well (for instance SIGTIMER for posix times, SIGSETXID for id functions, and signal block/restore helpers) and since generic functions will be places and used in generic implementation it makes more sense to decouple it from NPTL. Checked on x86_64-linux-gnu. * sysdeps/nptl/nptl-signals.h: Move to ... * sysdeps/generic/internal-signals.h: ... here. Adjust internal comments. * sysdeps/unix/sysv/linux/internal-signals.h: Add include guards. (__nptl_is_internal_signal): Rename to __is_internal_signal. (__nptl_clear_internal_signals): Rename to __clear_internal_signals. * sysdeps/unix/sysv/linux/raise.c: Adjust nptl-signal.h to include-signals.h rename. * nptl/pthreadP.h: Likewise. * sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Call __is_internal_signal instead of __nptl_is_internal_signal.
* RISC-V: fmax/fmin: Handle signalling NaNs correctly.Andrew Waterman2018-02-224-8/+36
| | | | | | | | | RISC-V's fmax(sNAN,4) returns 4 but glibc expects it to return qNAN. * sysdeps/riscv/rvd/s_fmax.c (__fmax): Handle sNaNs correctly. * sysdeps/riscv/rvd/s_fmin.c (__fmin): Likewise. * sysdeps/riscv/rvf/s_fmaxf.c (__fmaxf): Likewise. * sysdeps/riscv/rvf/s_fminf.c (__fminf): Likewise.
* RISC-V: Do not initialize $gp in TLS macros.DJ Delorie2018-02-221-17/+3
| | | | | RISC-V TLS doesn't require GP to be initialized, and doing so breaks TLS in a shared object.
* aarch64/strcmp: fix misaligned loop jump targetSiddhesh Poyarekar2018-02-221-1/+1
| | | | | | | | | I accidentally set the loop jump back label as misaligned8 instead of do_misaligned. The typo is harmless but it's always nice to not have to unnecessarily execute those two instructions. * sysdeps/aarch64/strcmp.S (do_misaligned): Jump back to do_misaligned, not misaligned8.
* IFUNC for Cavium ThunderX2Steve Ellcey2018-02-226-10/+56
| | | | | | | | | | | | | | | | | * sysdeps/aarch64/multiarch/Makefile (sysdep_routines): Add memcpy_thunderx2. * sysdeps/aarch64/multiarch/ifunc-impl-list.c (MAX_IFUNC): Increment to 4. (__libc_ifunc_impl_list): Add __memcpy_thunderx2. * sysdeps/aarch64/multiarch/memcpy.c (libc_ifunc): Add IS_THUNDERX2 and IS_THUNDERX2PA checks. * sysdeps/aarch64/multiarch/memcpy_thunderx.S (USE_THUNDERX2): Use macro to set name appropriately. (memcpy): Use USE_THUNDERX2 macro to modify prefetches. * sysdeps/aarch64/multiarch/memcpy_thunderx2.S: New file. * sysdeps/unix/sysv/linux/aarch64/cpu-features.h (IS_THUNDERX2PA): New macro. (IS_THUNDERX2): New macro.
* S390: Regenerate ULPs.Stefan Liebler2018-02-221-6/+6
| | | | | | | | | | After regenerating ULPs from scratch in commit 8e7196c8759287a3e4c882e3c7cf32ddc322df8a, I've missed to test it with multiple gcc versions. Hence, here is a further update. ChangeLog: * sysdeps/s390/fpu/libm-test-ulps: Regenerated.
* hurd: Add sysdep-cancel.hSamuel Thibault2018-02-211-0/+9
|
* Mechanically remove _IO_ name aliases for types and constants.Zack Weinberg2018-02-214-7/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch mechanically removes all remaining uses, and the definitions, of the following libio name aliases: name replaced with ---- ------------- _IO_FILE FILE _IO_fpos_t __fpos_t _IO_fpos64_t __fpos64_t _IO_size_t size_t _IO_ssize_t ssize_t or __ssize_t _IO_off_t off_t _IO_off64_t off64_t _IO_pid_t pid_t _IO_uid_t uid_t _IO_wint_t wint_t _IO_va_list va_list or __gnuc_va_list _IO_BUFSIZ BUFSIZ _IO_cookie_io_functions_t cookie_io_functions_t __io_read_fn cookie_read_function_t __io_write_fn cookie_write_function_t __io_seek_fn cookie_seek_function_t __io_close_fn cookie_close_function_t I used __fpos_t and __fpos64_t instead of fpos_t and fpos64_t because the definitions of fpos_t and fpos64_t depend on the largefile mode. I used __ssize_t and __gnuc_va_list in a handful of headers where namespace cleanliness might be relevant even though they're internal-use-only. In all other cases, I used the public-namespace name. There are a tiny handful of places where I left a use of 'struct _IO_FILE' alone, because it was being used together with 'struct _IO_FILE_plus' or 'struct _IO_FILE_complete' in the same arithmetic expression. Because this patch was almost entirely done with search and replace, I may have introduced indentation botches. I did proofread the diff, but I may have missed something. The ChangeLog below calls out all of the places where this was not a pure search-and-replace change. Installed stripped libraries and executables are unchanged by this patch, except that some assertions in vfscanf.c change line numbers. * libio/libio.h (_IO_FILE): Delete; all uses changed to FILE. (_IO_fpos_t): Delete; all uses changed to __fpos_t. (_IO_fpos64_t): Delete; all uses changed to __fpos64_t. (_IO_size_t): Delete; all uses changed to size_t. (_IO_ssize_t): Delete; all uses changed to ssize_t or __ssize_t. (_IO_off_t): Delete; all uses changed to off_t. (_IO_off64_t): Delete; all uses changed to off64_t. (_IO_pid_t): Delete; all uses changed to pid_t. (_IO_uid_t): Delete; all uses changed to uid_t. (_IO_wint_t): Delete; all uses changed to wint_t. (_IO_va_list): Delete; all uses changed to va_list or __gnuc_va_list. (_IO_BUFSIZ): Delete; all uses changed to BUFSIZ. (_IO_cookie_io_functions_t): Delete; all uses changed to cookie_io_functions_t. (__io_read_fn): Delete; all uses changed to cookie_read_function_t. (__io_write_fn): Delete; all uses changed to cookie_write_function_t. (__io_seek_fn): Delete; all uses changed to cookie_seek_function_t. (__io_close_fn): Delete: all uses changed to cookie_close_function_t. * libio/iofopncook.c: Remove unnecessary forward declarations. * libio/iolibio.h: Correct outdated commentary. * malloc/malloc.c (__malloc_stats): Remove unnecessary casts. * stdio-common/fxprintf.c (__fxprintf_nocancel): Remove unnecessary casts. * stdio-common/getline.c: Use _IO_getdelim directly. Don't redefine ssize_t. * stdio-common/printf_fp.c, stdio_common/printf_fphex.c * stdio-common/printf_size.c: Don't redefine size_t or FILE. Remove outdated comments. * stdio-common/vfscanf.c: Don't redefine va_list.
* elf: Remove ad-hoc restrictions on dlopen callers [BZ #22787]Florian Weimer2018-02-212-12/+0
| | | | | | | | | | | | | | | | | | | | | | This looks like a post-exploitation hardening measure: If an attacker is able to redirect execution flow, they could use that to load a DSO which contains additional code (or perhaps make the stack executable). However, the checks are not in the correct place to be effective: If they are performed before the critical operation, an attacker with sufficient control over execution flow could simply jump directly to the code which performs the operation, bypassing the check. The check would have to be executed unconditionally after the operation and terminate the process in case a caller violation was detected. Furthermore, in _dl_check_caller, there was a fallback reading global writable data (GL(dl_rtld_map).l_map_start and GL(dl_rtld_map).l_text_end), which could conceivably be targeted by an attacker to disable the check, too. Other critical functions (such as system) remain completely unprotected, so the value of these additional checks does not appear that large. Therefore this commit removes this functionality.
* hurd: fix buildSamuel Thibault2018-02-211-0/+2
| | | | * sysdeps/mach/hurd/dl-sysdep.c (_dl_random): New variable.
* hurd: Fix build on missing __ptsname_internal functionSamuel Thibault2018-02-171-4/+19
| | | | | | | * sysdeps/mach/hurd/ptsname.c: Include <sys/stat.h>. (__ptsname_r): Move implementation to... (__ptsname_internal): ... new function. Add filling the STP structure.
* hurd: Define EXEC_PAGESIZESamuel Thibault2018-02-172-0/+27
| | | | | | * mach/Makefile (headers): Add mach/param.h. * sysdeps/mach/hurd/bits/param.h: Include <mach/param.h>. * sysdeps/mach/i386/mach/param.h: New file, defines EXEC_PAGESIZE
* Fix ulps for pow on hppa.John David Anglin2018-02-171-0/+2
| | | | | * sysdeps/hppa/fpu/libm-test-ulps (pow): Increase double and idouble to 1 ULP.
* Fix hppa local PLT entries for sigprocmask (bug 18124).Joseph Myers2018-02-153-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When adding/updating localplt.data for various architectures to get the compilation tests passing everywhere, I generally made it reflect the existing state of what local PLT entries were actually seen, rather than an ideal state with as few as possible such entries, mainly for functions that are intended to be interposable. This patch eliminates some local PLT entries for hppa by using __sigprocmask instead of sigprocmask in getcontext and setcontext. The specific case of sigprocmask called by setcontext is the third of four items in bug 18124 (the other three have already been fixed for 2.26 or earlier releases). Note that hppa-specific localplt.data entries for __sigsetjmp, _IO_funlockfile and __errno_location remain, but the causes / fixes are less immediately obvious from source inspection. Tested (compilation tests only) with build-many-glibcs.py for hppa-linux-gnu. [BZ #18124] * sysdeps/hppa/bsd-setjmp.S: Include <sysdep.h>. (setjmp): Use HIDDEN_JUMPTARGET with __sigsetjmp. * sysdeps/unix/sysv/linux/hppa/getcontext.S (__getcontext): Call __sigprocmask instead of sigprocmask. * sysdeps/unix/sysv/linux/hppa/setcontext.S (__setcontext): Likewise. * sysdeps/unix/sysv/linux/hppa/localplt.data: Remove entries for __sigsetjmp and sigprocmask.
* Use libc_hidden_* for __cmsg_nxthdr (bug 15105).Joseph Myers2018-02-151-0/+1
| | | | | | | | | | | | | | | | | | Among other localplt test failures when building with -Os, there are libc.so PLT references for __cmsg_nxthdr. This is a simple case of a function that is inlined for -O2 but not for -Os; this patch adds libc_hidden_proto / libc_hidden_def for it to avoid a localplt failure even when it is not inlined. Tested for x86_64 (both that it removes this particular localplt failure for -Os - but other such failures remain so the bug can't yet be closed - and that the testsuite continues to pass without -Os). [BZ #15105] * include/sys/socket.h [!_ISOMAC] (__cmsg_nxthdr): Use libc_hidden_proto. * sysdeps/unix/sysv/linux/cmsg_nxthdr.c (__cmsg_nxthdr): Use libc_hidden_def.
* Fix -Os feof_unlocked linknamespace, localplt issues (bug 15105, bug 19463).Joseph Myers2018-02-152-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Continuing the fixes for linknamespace and localplt test failures with -Os that arise from functions not being inlined in that case, this patch fixes such failures for feof_unlocked. The usual approach is followed of adding __feof_unlocked (inlined when feof_unlocked is), making calls use it when required for namespace reasons, and using libc_hidden_proto / libc_hidden_weak for the feof_unlocked weak alias when only localplt but not namespace issues are involved. In the case of getaddrinfo.c, use of __feof_unlocked needs to be conditional since that code is also used in nscd (where __feof_unlocked is not available). Tested for x86_64 (both without -Os to make sure that case continues to work, and with -Os to make sure all the relevant linknamespace and localplt test failures are resolved). Because of other such failures that remain after this patch, neither of the bugs can yet be closed. [BZ #15105] [BZ #19463] * libio/feof_u.c (feof_unlocked): Rename to __feof_unlocked and define as weak alias of __feof_unlocked. Use libc_hidden_weak. * include/stdio.h (feof_unlocked): Use libc_hidden_proto. (__feof_unlocked): New declaration, and inline function if [__USE_EXTERN_INLINES]. * iconv/gconv_conf.c (read_conf_file): Call __feof_unlocked instead of feof_unlocked. * intl/localealias.c [_LIBC] (FEOF): Likewise. * nss/nsswitch.c (nss_parse_file): Likewise. * sysdeps/unix/sysv/linux/readonly-area.c (__readonly_area): Likewise. * time/getdate.c (__getdate_r): Likewise. * sysdeps/posix/getaddrinfo.c [IS_IN (libc)] (feof_unlocked): Define as macro to call __feof_unlocked.
* [AArch64] Fix include.Wilco Dijkstra2018-02-151-1/+1
| | | | | | Fix include to use <>. * sysdeps/aarch64/fpu/fpu_control.h: Use <> in include.
* Remove mplog and mpexpWilco Dijkstra2018-02-1520-341/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Remove the now unused mplog and mpexp files. * math/Makefile: Remove mpexp.c and mplog.c * sysdeps/i386/fpu/mpexp.c: Delete file. * sysdeps/i386/fpu/mplog.c: Likewise. * sysdeps/ia64/fpu/mpexp.c: Likewise. * sysdeps/ia64/fpu/mplog.c: Likewise. * sysdeps/ieee754/dbl-64/e_exp.c: Remove mention of mpexp and mplog. * sysdeps/ieee754/dbl-64/mpa.h (__pow_mp): Remove unused function. * sysdeps/ieee754/dbl-64/mpexp.c: Delete file. * sysdeps/ieee754/dbl-64/mplog.c: Likewise. * sysdeps/m68k/m680x0/fpu/mpexp.c: Likewise. * sysdeps/m68k/m680x0/fpu/mplog.c: Likewise. * sysdeps/x86_64/fpu/multiarch/Makefile: Remove mpexp* and mplog*. * sysdeps/x86_64/fpu/multiarch/e_log-avx.c: Remove unused defines. * sysdeps/x86_64/fpu/multiarch/e_log-fma.c: Likewise. * sysdeps/x86_64/fpu/multiarch/e_log-fma4.c: Likewise. * sysdeps/x86_64/fpu/multiarch/mpexp-avx.c: Delete file. * sysdeps/x86_64/fpu/multiarch/mpexp-fma.c: Likewise. * sysdeps/x86_64/fpu/multiarch/mpexp-fma4.c: Likewise. * sysdeps/x86_64/fpu/multiarch/mplog-avx.c: Likewise. * sysdeps/x86_64/fpu/multiarch/mplog-fma.c: Likewise. * sysdeps/x86_64/fpu/multiarch/mplog-fma4.c: Likewise.
* S390: Regenerate ULPs.Stefan Liebler2018-02-151-68/+20
| | | | | | | | Regenerated ulps file from scratch due to recent pow changes. ChangeLog: * sysdeps/s390/fpu/libm-test-ulps: Regenerated.
* Update SH libm-tests-ulpsAdhemerval Zanella2018-02-141-48/+445
| | | | | | * sysdeps/sh/libm-test-ulps: Update. Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* powerpc: Update pow() ULPsTulio Magno Quites Machado Filho2018-02-121-0/+2
| | | | | | | * sysdeps/powerpc/fpu/libm-test-ulps (pow): Increase double and idouble to 1 ULP. Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
* Remove slow paths from expSzabolcs Nagy2018-02-1215-174/+21
| | | | | | | | | | | | | | | | | | | | | | | | | Remove the __slowexp code, so exp is no longer correctly rounded. The result is computed to about 70 bits precision so the worst case ulp error is about 0.500007 in nearest rounding mode. * manual/probes.texi: Remove slowexp probes. * math/Makefile: Remove slowexp. * sysdeps/generic/math_private.h (__slowexp): Remove. * sysdeps/ieee754/dbl-64/e_exp.c (__ieee754_exp): Remove __slowexp and document error bounds. * sysdeps/i386/fpu/slowexp.c: Remove. * sysdeps/ia64/fpu/slowexp.c: Remove. * sysdeps/ieee754/dbl-64/slowexp.c: Remove. * sysdeps/ieee754/dbl-64/uexp.h (err_0): Remove. * sysdeps/m68k/m680x0/fpu/slowexp.c: Remove. * sysdeps/powerpc/power4/fpu/Makefile (CPPFLAGS-slowexp.c): Remove. * sysdeps/x86_64/fpu/multiarch/Makefile: Remove slowexp-fma. * sysdeps/x86_64/fpu/multiarch/e_exp-avx.c (__slowexp): Remove. * sysdeps/x86_64/fpu/multiarch/e_exp-fma.c (__slowexp): Remove. * sysdeps/x86_64/fpu/multiarch/e_exp-fma4.c (__slowexp): Remove. * sysdeps/x86_64/fpu/multiarch/slowexp-avx.c: Remove. * sysdeps/x86_64/fpu/multiarch/slowexp-fma.c: Remove. * sysdeps/x86_64/fpu/multiarch/slowexp-fma4.c: Remove.
* Remove slow paths from powWilco Dijkstra2018-02-1222-503/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the slow paths from pow. Like several other double precision math functions, pow is exactly rounded. This is not required from math functions and causes major overheads as it requires multiple fallbacks using higher precision arithmetic if a result is close to 0.5ULP. Ridiculous slowdowns of up to 100000x have been reported when the highest precision path triggers. All GLIBC math tests pass on AArch64 and x64 (with ULP of pow set to 1). The worst case error is ~0.506ULP. A simple test over a few hundred million values shows pow is 10% faster on average. This fixes BZ #13932. [BZ #13932] * sysdeps/ieee754/dbl-64/uexp.h (err_1): Remove. * benchtests/pow-inputs: Update comment for slow path cases. * manual/probes.texi (slowpow_p10): Delete removed probe. (slowpow_p10): Likewise. * math/Makefile: Remove halfulp.c and slowpow.c. * sysdeps/aarch64/libm-test-ulps: Set ULP of pow to 1. * sysdeps/generic/math_private.h (__exp1): Remove error argument. (__halfulp): Remove. (__slowpow): Remove. * sysdeps/i386/fpu/halfulp.c: Delete file. * sysdeps/i386/fpu/slowpow.c: Likewise. * sysdeps/ia64/fpu/halfulp.c: Likewise. * sysdeps/ia64/fpu/slowpow.c: Likewise. * sysdeps/ieee754/dbl-64/e_exp.c (__exp1): Remove error argument, improve comments and add error analysis. * sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Add error analysis. (power1): Remove function: (log1): Remove error argument, add error analysis. (my_log2): Remove function. * sysdeps/ieee754/dbl-64/halfulp.c: Delete file. * sysdeps/ieee754/dbl-64/slowpow.c: Likewise. * sysdeps/m68k/m680x0/fpu/halfulp.c: Likewise. * sysdeps/m68k/m680x0/fpu/slowpow.c: Likewise. * sysdeps/powerpc/power4/fpu/Makefile: Remove CPPFLAGS-slowpow.c. * sysdeps/x86_64/fpu/libm-test-ulps: Set ULP of pow to 1. * sysdeps/x86_64/fpu/multiarch/Makefile: Remove slowpow-fma.c, slowpow-fma4.c, halfulp-fma.c, halfulp-fma4.c. * sysdeps/x86_64/fpu/multiarch/e_pow-fma.c (__slowpow): Remove define. * sysdeps/x86_64/fpu/multiarch/e_pow-fma4.c (__slowpow): Likewise. * sysdeps/x86_64/fpu/multiarch/halfulp-fma.c: Delete file. * sysdeps/x86_64/fpu/multiarch/halfulp-fma4.c: Likewise. * sysdeps/x86_64/fpu/multiarch/slowpow-fma.c: Likewise. * sysdeps/x86_64/fpu/multiarch/slowpow-fma4.c: Likewise.
* linux/aarch64: sync sys/ptrace.h with Linux 4.15 [BZ #22433]Dmitry V. Levin2018-02-101-8/+0
| | | | | | | | | | | Remove compat-specific constants that were never exported by kernel headers under these names. Before linux commit v3.7-rc1~16^2~1 they were exported with COMPAT_ prefix, and since that commit they are not exported at all. * sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h (__ptrace_request): Remove arm-specific PTRACE_GET_THREAD_AREA, PTRACE_GETHBPREGS, and PTRACE_SETHBPREGS.
* [AArch64] Fix testsuite error due to fpsr/fscr changeWilco Dijkstra2018-02-101-0/+2
| | | | | | Add features.h include for __GNUC_PREREQ. * sysdeps/aarch64/fpu/fpu_control.h: Add features.h to fix build error.
* Add narrowing add functions.Joseph Myers2018-02-1050-1/+889
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the narrowing add functions from TS 18661-1 to glibc's libm: fadd, faddl, daddl, f32addf64, f32addf32x, f32xaddf64 for all configurations; f32addf64x, f32addf128, f64addf64x, f64addf128, f32xaddf64x, f32xaddf128, f64xaddf128 for configurations with _Float64x and _Float128; __nldbl_daddl for ldbl-opt. As discussed for the build infrastructure patch, tgmath.h support is deliberately deferred, and FP_FAST_* macros are not applicable without optimized function implementations. Function implementations are added for all relevant pairs of formats (including certain cases of a format and itself where more than one type has that format). The main implementations use round-to-odd, or a trivial computation in the case where both formats are the same or where the wider format is IBM long double (in which case we don't attempt to be correctly rounding). The sysdeps/ieee754/soft-fp implementations use soft-fp, and are used automatically for configurations without exceptions and rounding modes by virtue of existing Implies files. As previously discussed, optimized versions for particular architectures are possible, but not included. i386 gets a special version of f32xaddf64 to avoid problems with double rounding (similar to the existing fdim version), since this function must round just once without an intermediate rounding to long double. (No such special version is needed for any other function, because the nontrivial functions use round-to-odd, which does the intermediate computation with the rounding mode set to round-to-zero, and double rounding is OK except in round-to-nearest mode, so is OK for that intermediate round-to-zero computation.) mul and div will need slightly different special versions for i386 (using round-to-odd on long double instead of precision control) because of the possibility of inexact intermediate results in the subnormal range for double. To reduce duplication among the different function implementations, math-narrow.h gets macros CHECK_NARROW_ADD, NARROW_ADD_ROUND_TO_ODD and NARROW_ADD_TRIVIAL. In the trivial cases and for any architecture-specific optimized implementations, the overhead of the errno setting might be significant, but I think that's best handled through compiler built-in functions rather than providing separate no-errno versions in glibc (and likewise there are no __*_finite entry points for these function provided, __*_finite effectively being no-errno versions at present in most cases). Tested for x86_64 and x86, with both GCC 6 and GCC 7. Tested for mips64 (all three ABIs, both hard and soft float) and powerpc with GCC 7. Tested with build-many-glibcs.py with both GCC 6 and GCC 7. * math/Makefile (libm-narrow-fns): Add add. (libm-test-funcs-narrow): Likewise. * math/Versions (GLIBC_2.28): Add narrowing add functions. * math/bits/mathcalls-narrow.h (add): Use __MATHCALL_NARROW . * math/gen-auto-libm-tests.c (test_functions): Add add. * math/math-narrow.h (CHECK_NARROW_ADD): New macro. (NARROW_ADD_ROUND_TO_ODD): Likewise. (NARROW_ADD_TRIVIAL): Likewise. * sysdeps/ieee754/float128/float128_private.h (__faddl): New macro. (__daddl): Likewise. * sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add fadd and dadd. (CFLAGS-nldbl-dadd.c): New variable. (CFLAGS-nldbl-fadd.c): Likewise. * sysdeps/ieee754/ldbl-opt/Versions (GLIBC_2.28): Add __nldbl_daddl. * sysdeps/ieee754/ldbl-opt/nldbl-compat.h (__nldbl_daddl): New prototype. * manual/arith.texi (Misc FP Arithmetic): Document fadd, faddl, daddl, fMaddfN, fMaddfNx, fMxaddfN and fMxaddfNx. * math/auto-libm-test-in: Add tests of add. * math/auto-libm-test-out-narrow-add: New generated file. * math/libm-test-narrow-add.inc: New file. * sysdeps/i386/fpu/s_f32xaddf64.c: Likewise. * sysdeps/ieee754/dbl-64/s_f32xaddf64.c: Likewise. * sysdeps/ieee754/dbl-64/s_fadd.c: Likewise. * sysdeps/ieee754/float128/s_f32addf128.c: Likewise. * sysdeps/ieee754/float128/s_f64addf128.c: Likewise. * sysdeps/ieee754/float128/s_f64xaddf128.c: Likewise. * sysdeps/ieee754/ldbl-128/s_daddl.c: Likewise. * sysdeps/ieee754/ldbl-128/s_f64xaddf128.c: Likewise. * sysdeps/ieee754/ldbl-128/s_faddl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/s_daddl.c: Likewise. * sysdeps/ieee754/ldbl-128ibm/s_faddl.c: Likewise. * sysdeps/ieee754/ldbl-96/s_daddl.c: Likewise. * sysdeps/ieee754/ldbl-96/s_faddl.c: Likewise. * sysdeps/ieee754/ldbl-opt/nldbl-dadd.c: Likewise. * sysdeps/ieee754/ldbl-opt/nldbl-fadd.c: Likewise. * sysdeps/ieee754/soft-fp/s_daddl.c: Likewise. * sysdeps/ieee754/soft-fp/s_fadd.c: Likewise. * sysdeps/ieee754/soft-fp/s_faddl.c: Likewise. * sysdeps/powerpc/fpu/libm-test-ulps: Update. * sysdeps/mach/hurd/i386/libm.abilist: Likewise. * 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/riscv/rv64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx32/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/tile/tilegx64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.
* Fix narrowing function tests build for powerpc64le.Joseph Myers2018-02-101-0/+6
| | | | | | | | | | | | | | | | | | | | Testing narrowing functions with build-many-glibcs.py showed up a further testsuite fix needed to enable building such functions for powerpc64le: tests test-<narrower-type>-float128-<function> (and likewise for float64x) needed the same special handling for powerpc64le as test-float128-* and test-float64x-*. This patch adds that special handling. Tested with build-many-glibcs.py for powerpc64le in conjunction with the main patch adding narrowing add functions. * sysdeps/powerpc/powerpc64le/Makefile [$(subdir) = math] (f128-pairs): New variable. [$(subdir) = math] ($(foreach suf,$(all-object-suffixes),$(foreach pair,$(f128-pairs),$(objpfx)test-$(pair)%$(suf)))): Add -mfloat128 to CFLAGS. [$(subdir) = math] ($(foreach pair,$(f128-pairs),test-$(pair)%)): Also make tests add $(f128-loader-link) to gnulib-tests.
* [RISC-V] Fix parsing flags in ELF64 files.DJ Delorie2018-02-091-1/+2
| | | | | | | | | | | | | | When ldconfig reads Elf64 files to determine the ABI, it used the Elf32 type, so read the wrong location, and stored the wrong ABI type in the cache, making the cache useless. This patch uses an Elf64 type for Elf64 objects instead. Note that pre-patch caches might need to be manually removed and regenerated to get the correct ABIs stored. [BZ #22827] * sysdeps/unix/sysv/linux/riscv/readelflib.c (process_elf_file): Use 64-bit ELF type for 64-bit ELF objects.