about summary refs log tree commit diff
path: root/sysdeps
Commit message (Collapse)AuthorAgeFilesLines
* sysdeps/posix/getaddrinfo: Return early on invalid address familyTim Rühsen2019-11-261-22/+18
| | | | Check address family before expensive function call (__check_pf).
* sysdeps/posix: Simplify if expression in getaddrinfoTim Rühsen2019-11-261-1/+1
| | | | Small code cleanup for better readability.
* arm: Fix armv7 selection after 'Split BE/LE abilist'Adhemerval Zanella2019-11-255-0/+5
| | | | | | | | | | | | It adds the missing Implies for armv7, armv6, armv6t2 after the commit 1673ba87fefe019c. Without the Implies a build with the compiler targeting the aforementioned architecture does not select the arch-specific optimization including the ifunc selectors. I checked with a build against armv5, armv6, armv6t2, armv7, and armv7-neon for both LE and BE. For armv6 and armv7 I also checked that both sysdeps selection and the resulting implementation built is the expected ones.
* ldbl-128ibm-compat: Add wide character scanning functionsGabriel F. T. Gomes2019-11-2211-1/+248
| | | | | | | | | | | | | Similarly to what was done for regular character scanning functions, this patch uses the new mode mask, SCANF_LDBL_USES_FLOAT128, in the 'mode' argument of the wide characters scanning function, __vfwscanf_internal (which is also extended to support scanning floating-point values with IEEE binary128, by redirecting calls to __wcstold_internal to __wcstof128_internal). Tested for powerpc64le. Reviewed-By: Paul E. Murphy <murphyp@linux.ibm.com>
* ldbl-128ibm-compat: Add regular character scanning functionsGabriel F. T. Gomes2019-11-2213-3/+421
| | | | | | | | | | | | | | | | | | | The 'mode' argument to __vfscanf_internal allows the selection of the long double format for all long double arguments requested by the format string. Currently, there are two possibilities: long double with the same format as double or long double as something else. The 'something else' format varies between architectures, and on powerpc64le, it means IBM Extended Precision format. In preparation for the third option of long double format on powerpc64le, this patch uses the new mode mask, SCANF_LDBL_USES_FLOAT128, which tells __vfscanf_internal to call __strtof128_internal, instead of __strtold_internal, and save the output into a _Float128 variable. Tested for powerpc64le. Reviewed-By: Paul E. Murphy <murphyp@linux.ibm.com>
* ldbl-128ibm-compat: Test positional argumentsGabriel F. T. Gomes2019-11-224-4/+38
| | | | | | | | | | | | | The format string can request positional parameters, instead of relying on the order in which they appear as arguments. Since this has an effect on how the type of each argument is determined, this patch extends the test cases to use positional parameters with mixed double and long double types, to verify that the IEEE long double implementations of *printf work correctly in this scenario. Tested for powerpc64le. Reviewed-By: Paul E. Murphy <murphyp@linux.ibm.com>
* ldbl-128ibm-compat: Test double valuesGabriel F. T. Gomes2019-11-224-110/+117
| | | | | | | | | | | | A single format string can take double and long double parameters at the same time. Internally, these parameters are routed to the same function, which correctly reads them and calls the underlying functions responsible for the actual conversion to string. This patch adds a new case to test this scenario. Tested for powerpc64le. Reviewed-By: Paul E. Murphy <murphyp@linux.ibm.com>
* ldbl-128ibm-compat: Add wide character, fortified printing functionsGabriel F. T. Gomes2019-11-2213-1/+357
| | | | | | | | | | | | | | | | | Similarly to what was done for the regular character, fortified printing functions, this patch combines the mode masks PRINTF_LDBL_USES_FLOAT128 and PRINTF_FORTIFY to provide wide character versions of fortified printf functions. It also adds two flavors of test cases: one that explicitly calls the fortified functions, and another that reuses the non-fortified test, but defining _FORTIFY_SOURCE as 2. The first guarantees that the implementations are actually being tested (independently of what's in bits/wchar2.h), whereas the second guarantees that the redirections calls the correct function in the IBM and IEEE long double cases. Tested for powerpc64le. Reviewed-By: Paul E. Murphy <murphyp@linux.ibm.com>
* ldbl-128ibm-compat: Add regular character, fortified printing functionsGabriel F. T. Gomes2019-11-2219-0/+649
| | | | | | | | | | | | | | | | | | | | | | | | | | Since the introduction of internal functions with explicit flags for the printf family of functions, the 'mode' parameter can be used to select which format long double parameters have (with the mode flags: PRINTF_LDBL_IS_DBL and PRINTF_LDBL_USES_FLOAT128), as well as to select whether to check for overflows (mode flag: PRINTF_FORTIFY). This patch combines PRINTF_LDBL_USES_FLOAT128 and PRINTF_FORTIFY to provide the IEEE binary128 version of printf-like function for platforms where long double can take this format, in addition to the double format and to some non-ieee format (currently, this means powerpc64le). There are two flavors of test cases provided with this patch: one that explicitly calls the fortified functions, for instance __asprintf_chk, and another that reuses the non-fortified test, but defining _FORTIFY_SOURCE as 2. The first guarantees that the implementations are actually being tested (in bits/stdio2.h, vprintf gets redirected to __vfprintf_chk, which would leave __vprintf_chk untested), whereas the second guarantees that the redirections calls the correct function in the IBM and IEEE long double cases. Tested for powerpc64le. Reviewed-By: Paul E. Murphy <murphyp@linux.ibm.com>
* ldbl-128ibm-compat: Add wide character printing functionsGabriel F. T. Gomes2019-11-2211-1/+321
| | | | | | | | | | | | | | | Similarly to what was done for regular character printing functions, this patch uses the new mode mask, PRINTF_LDBL_USES_FLOAT128, in the 'mode' argument of the wide characters printing function, __vfwprintf_internal (which is also extended to support printing floating-point values with IEEE binary128, by saving floating-point values into variables of type __float128 and adjusting the parameters to __printf_fp and __printf_fphex as if it was a call from a wide-character version of strfromf128 (even though such version does not exist)). Tested for powerpc64le. Reviewed-By: Paul E. Murphy <murphyp@linux.ibm.com>
* ldbl-128ibm-compat: Add regular character printing functionsGabriel F. T. Gomes2019-11-2217-1/+603
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 'mode' argument to __vfprintf_internal allows the selection of the long double format for all long double arguments requested by the format string. Currently, there are two possibilities: long double with the same format as double or long double as something else. The 'something else' format varies between architectures, and on powerpc64le, it means IBM Extended Precision format. In preparation for the third option of long double format on powerpc64le, this patch uses the new mode mask, PRINTF_LDBL_USES_FLOAT128, which tells __vfprintf_internal to save the floating-point values into variables of type __float128 and adjusts the parameters to __printf_fp and __printf_fphex as if it was a call from strfromf128. Many files from the stdio-common, wcsmbs, argp, misc, and libio directories will have IEEE binary128 counterparts. Setting the correct compiler options to these files (original and counterparts) would produce a large amount of repetitive Makefile rules. To avoid this repetition, this patch adds a Makefile routine that iterates over the files adding or removing the appropriate flags. Tested for powerpc64le. Reviewed-By: Florian Weimer <fweimer@redhat.com> Reviewed-By: Joseph Myers <joseph@codesourcery.com> Reviewed-By: Paul E. Murphy <murphyp@linux.ibm.com>
* misc: Set generic pselect as ENOSYSAdhemerval Zanella2019-11-222-33/+77
| | | | | | | | | | | | | | | | | | The generic pselect implementation has the very specific race condition that motived the creation of the pselect syscall (no atomicity in signal mask set/reset). Using it as generic implementation is counterproductive Also currently only microblaze uses it as fallback when used on kernel prior 3.15. This patch moves the generic implementation to a microblaze specific one, sets the generic internal as a ENOSYS, and cleanups the Linux generic implementation. The microblaze implementation mimics the previous Linux generic one, where it either uses pselect6 directly if __ASSUME_PSELECT or a first try pselect6 then the fallback otherwise. Checked on x86_64-linux-gnu and microblaze-linux-gnu.
* Remove duplicate inline implementation of issignalingfPaul A. Clarke2019-11-222-11/+2
| | | | | | | | | | | | | | | | | | | | Very recent commit 854e91bf6b4221f424ffa13b9ef50f35623b7b74 enabled inline of issignalingf() in general (__issignalingf in include/math.h). There is another implementation for an inline use of issignalingf (issignalingf_inline in sysdeps/ieee754/flt-32/math_config.h) which could instead make use of the new enablement. Replace the use of issignalingf_inline with __issignaling. Using issignaling (instead of __issignalingf) will allow future enhancements to the type-generic implementation, issignaling, to be automatically adopted. The implementations are slightly different, and compile to slightly different code, but I measured no significant performance difference. The second implementation was brought to my attention by: Suggested-by: Joseph Myers <joseph@codesourcery.com> Reviewed-by: Joseph Myers <joseph@codesourcery.com>
* Don't use a custom wrapper macro around __has_include (bug 25189).Emilio Cobos Álvarez2019-11-211-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | This causes issues when using clang with -frewrite-includes to e.g., submit the translation unit to a distributed compiler. In my case, I was building Firefox using sccache. See [1] for a reduced test-case since I initially thought this was a clang bug, and [2] for more context. Apparently doing this is invalid C++ per [cpp.cond], which mentions [3]: > The #ifdef and #ifndef directives, and the defined conditional > inclusion operator, shall treat __has_include and __has_cpp_attribute > as if they were the names of defined macros. The identifiers > __has_include and __has_cpp_attribute shall not appear in any context > not mentioned in this subclause. [1]: https://bugs.llvm.org/show_bug.cgi?id=43982 [2]: https://bugs.llvm.org/show_bug.cgi?id=37990 [3]: http://eel.is/c++draft/cpp.cond#7.sentence-2 Change-Id: Id4b8ee19176a9e4624b533087ba870c418f27e60
* Enable inlining issignalingf within glibcPaul A. Clarke2019-11-211-29/+0
| | | | | | | | | issignalingf is a very small function used in some areas where better performance (and smaller code) might be helpful. Create inline implementation for issignalingf. Reviewed-by: Joseph Myers <joseph@codesourcery.com>
* Introduce DL_LOOKUP_FOR_RELOCATE flag for _dl_lookup_symbol_xFlorian Weimer2019-11-211-0/+3
| | | | | | | | | | This will allow changes in dependency processing during non-lazy binding, for more precise processing of NODELETE objects: During initial relocation in dlopen, the fate of NODELETE objects is still unclear, so objects which are depended upon by NODELETE objects cannot immediately be marked as NODELETE. Change-Id: Ic7b94a3f7c4719a00ca8e6018088567824da0658
* rtld: Check __libc_enable_secure before honoring LD_PREFER_MAP_32BIT_EXEC ↵Marcin Kościelnicki2019-11-211-1/+2
| | | | | | | | (CVE-2019-19126) [BZ #25204] The problem was introduced in glibc 2.23, in commit b9eb92ab05204df772eb4929eccd018637c9f3e9 ("Add Prefer_MAP_32BIT_EXEC to map executable pages with MAP_32BIT").
* Enhance _dl_catch_exception to allow disabling exception handlingFlorian Weimer2019-11-161-1/+3
| | | | | | | | | | | | In some cases, it is necessary to introduce noexcept regions where raised dynamic loader exceptions (e.g., from lazy binding) are fatal, despite being nested in a code region with an active exception handler. This change enhances _dl_catch_exception with to provide such a capability. The existing function is reused, so that it is not necessary to introduce yet another function with a similar purpose. Change-Id: Iec1bf642ff95a349fdde8040e9baf851ac7b8904
* hurd: Suppress GCC 10 -Warray-bounds warning in init-first.c [BZ #25097]Florian Weimer2019-11-161-0/+9
| | | | | | | The trampoline code should really be rewritten in assembler because this is all very undefined at the C level. Change-Id: Ided58244ca0ee48892519faac5ac222a4e02dec4
* linux: Add comment on affinity set sizes to tst-skeleton-affinity.cFlorian Weimer2019-11-151-0/+5
| | | | Change-Id: Ic6ec48f75f3a0576d3121befd04531382c92afb4
* Avoid zero-length array at the end of struct link_map [BZ #25097]Florian Weimer2019-11-151-4/+13
| | | | | | | | | | | | l_audit ends up as an internal array with _rtld_global, and GCC 10 warns about this. This commit does not change the layout of _rtld_global, so it is suitable for backporting. Future changes could allocate more of the audit state dynamically and remove it from always-allocated data structures, to optimize the common case of inactive auditing. Change-Id: Ic911100730f9124d4ea977ead8e13cee64b84d45
* Introduce link_map_audit_state accessor functionFlorian Weimer2019-11-151-1/+7
| | | | | | | | | | | | To improve GCC 10 compatibility, it is necessary to remove the l_audit zero-length array from the end of struct link_map. In preparation of that, this commit introduces an accessor function for the audit state, so that it is possible to change the representation of the audit state without adjusting the code that accesses it. Tested on x86_64-linux-gnu. Built on i686-gnu. Change-Id: Id815673c29950fc011ae5301d7cde12624f658df
* nios2: Work around backend bug triggered by csu/libc-tls.c (GCC PR 92499)Florian Weimer2019-11-141-0/+9
| | | | Change-Id: If5df5b05d15f0418af821a9ac8cc0fad53437b10
* aarch64: Increase small and medium cases for __memcpy_genericKrzysztof Koch2019-11-121-35/+47
| | | | | | | | | | | | | | | | | | | | | | | | Increase the upper bound on medium cases from 96 to 128 bytes. Now, up to 128 bytes are copied unrolled. Increase the upper bound on small cases from 16 to 32 bytes so that copies of 17-32 bytes are not impacted by the larger medium case. Benchmarking: The attached figures show relative timing difference with respect to 'memcpy_generic', which is the existing implementation. 'memcpy_med_128' denotes the the version of memcpy_generic with only the medium case enlarged. The 'memcpy_med_128_small_32' numbers are for the version of memcpy_generic submitted in this patch, which has both medium and small cases enlarged. The figures were generated using the script from: https://www.sourceware.org/ml/libc-alpha/2019-10/msg00563.html Depending on the platform, the performance improvement in the bench-memcpy-random.c benchmark ranges from 6% to 20% between the original and final version of memcpy.S Tested against GLIBC testsuite and randomized tests.
* slotinfo in struct dtv_slotinfo_list should be flexible array [BZ #25097]Florian Weimer2019-11-121-1/+1
| | | | | | | | | GCC 10 will warn about subscribing inner length zero arrays. Use a GCC extension in csu/libc-tls.c to allocate space for the static_slotinfo variable. Adjust nptl_db so that the type description machinery does not attempt to determine the size of the flexible array member slotinfo. Change-Id: I51be146a7857186a4ede0bb40b332509487bdde8
* Fix clock_nanosleep when interrupted by a signalAdhemerval Zanella2019-11-111-9/+7
| | | | | | | | | | | This patch fixes the time64 support (added by 2e44b10b42d) where it misses the remaining argument updated if __NR_clock_nanosleep returns EINTR. Checked on i686-linux-gnu on 4.15 kernel (no time64 support) and on 5.3 kernel (with time64 support). Reviewed-by: Alistair Francis <alistair23@gmail.com>
* y2038: linux: Provide __ppoll64 implementationLukasz Majewski2019-11-111-4/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch provides new __ppoll64 explicit 64 bit function for handling polling events (with struct timespec specified timeout) for a set of file descriptors. Moreover, a 32 bit version - __ppoll has been refactored to internally use __ppoll64. The __ppoll is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary conversion to 64 bit struct __timespec64. The new ppoll_time64 syscall available from Linux 5.1+ has been used, when applicable. The Linux kernel checks if passed tv_nsec value overflows, so there is no need to repeat it in the glibc. When ppoll syscall on systems supporting 32 bit time ABI is used, the check is performed if passed data (which may have 64 bit tv_sec) fits into 32 bit range. Build tests: - The code has been tested on x86_64/x86 (native compilation): make PARALLELMFLAGS="-j8" && make check PARALLELMFLAGS="-j8" && \\ make xcheck PARALLELMFLAGS="-j8" - The glibc has been build tested (make PARALLELMFLAGS="-j8") for x86 (i386), x86_64-x32, and armv7 Run-time tests: - Run specific tests on ARM/x86 32bit systems (qemu): https://github.com/lmajewski/meta-y2038 and run tests: https://github.com/lmajewski/y2038-tests/commits/master - Use of cross-test-ssh.sh for ARM (armv7): make PARALLELMFLAGS="-j8" test-wrapper='./cross-test-ssh.sh root@192.168.7.2' xcheck Linux kernel, headers and minimal kernel version for glibc build test matrix: - Linux v5.1 (with ppoll_time64) and glibc build with v5.1 as minimal kernel version (--enable-kernel="5.1.0") The __ASSUME_TIME64_SYSCALLS flag defined. - Linux v5.1 and default minimal kernel version The __ASSUME_TIME64_SYSCALLS not defined, but kernel supports ppoll_time64 syscall. - Linux v4.19 (no ppoll_time64 support) with default minimal kernel version for contemporary glibc This kernel doesn't support ppoll_time64 syscall, so the fallback to ppoll is tested. Above tests were performed with Y2038 redirection applied as well as without (so the __TIMESIZE != 64 execution path is checked as well). No regressions were observed.
* linux: Reduce stack size for nptl/tst-thread-affinity-pthreadFlorian Weimer2019-11-111-1/+4
| | | | | | | | And related tests. These tests create a thread for each core, so they may fail due to address space limitations with the default stack size. Change-Id: Ieef44a7731f58d3b7d6638cce4ccd31126647551
* sysdeps/clock_nanosleep: Use clock_nanosleep_time64 if avaliableAlistair Francis2019-11-081-4/+57
| | | | | | The clock_nanosleep syscall is not supported on newer 32-bit platforms (such as RV32). To fix this issue let's use clock_nanosleep_time64 if it is avaliable.
* Remove hppa pthreadP.hAdhemerval Zanella2019-11-081-16/+0
| | | | | | | | | It just contains duplicated defitions provided by other generic nptl headers. Checked with run-built-tests=no against hppa-linux-gnu. Change-Id: I95f55d5b7b7ae528c81cd2394d57ce92398189bf
* nptl: Add missing placeholder abi symbol from nanosleep moveAdhemerval Zanella2019-11-079-0/+9
| | | | | | Adds the __libpthread_version_placeholder symbol with the same version of nanosleep/__nanosleep that was removed by 79a547b162657b3f and that is not provided by other symbols.
* hurd: Remove lingering references to the time functionFlorian Weimer2019-11-071-2/+2
| | | | | | | | They cause a check-localplt failure after commit f9a7554009cf38f39. Fixes: f9a7554009cf38f390e74fcabc5b49f974f72382 Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Change-Id: I37bc20f3449b9e358f32879ed231720c969965b4
* Refactor nanosleep in terms of clock_nanosleepAdhemerval Zanella2019-11-064-132/+47
| | | | | | | | | | | | | The generic version is straightforward. For Hurd, its nanosleep implementation is moved to clock_nanosleep with adjustments from generic unix implementation. The generic clock_nanosleep unix version is also removed since it calls nanosleep. Checked on x86_64-linux-gnu and powerpc64le-linux-gnu. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* nptl: Move nanosleep implementation to libcAdhemerval Zanella2019-11-0627-54/+0
| | | | | | | | | Checked on x86_64-linux-gnu and powerpc64le-linux-gnu. I also checked the libpthread.so .gnu.version_d entries for every ABI affected and all of them contains the required versions (including for architectures which exports __nanosleep with a different version). Reviewed-by: Florian Weimer <fweimer@redhat.com>
* S390: Fp comparison are now raising FE_INVALID with gcc 10.Stefan Liebler2019-11-061-5/+7
| | | | | | | The s390 gcc bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77918 "S390: Floating point comparisons don't raise invalid for unordered operands." is fixed with gcc 10. Thus we conditionally set FIX_COMPARE_INVALID to 0 or 1.
* linux: pselect: Remove CALL_PSELECT6 macroLukasz Majewski2019-11-051-9/+2
| | | | | | | | Nothing defines CALL_PSELECT6 in the current tree, so remove it. Tested with: - make PARALLELMFLAGS="-j8" && make xcheck PARALLELMFLAGS="-j8" (x86_64) - scripts/build-many-glibcs.py
* nptl: Fix niggles with pthread_clockjoin_npMike Crowe2019-11-042-1/+12
| | | | | | | | | | | | | | | | | | | Joseph Myers spotted[1] that 69ca4b54c151cec42ccca5e05790efc1a8206b47 added pthread_clockjoin_np to sysdeps/nptl/pthread.h but not to its hppa-specific equivalent sysdeps/unix/sysv/linux/hppa/pthread.h. Rafal Luzynski spotted[2] typos in the NEWS entry and manual updates too. Florian Weimer spotted[3] that the clockid parameter was not using a reserved identifier in pthread.h. [1] https://sourceware.org/ml/libc-alpha/2019-11/msg00016.html [2] https://sourceware.org/ml/libc-alpha/2019-11/msg00019.html [3] https://sourceware.org/ml/libc-alpha/2019-11/msg00022.html Reviewed-by: Joseph Myers <joseph@codesourcery.com> Reviewed-by: Rafal Luzynski <digitalfreak@lingonborough.com> Reviewed-by: Florian Weimer <fw@deneb.enyo.de>
* hppa: Align __clone stack argument to 8 bytes (Bug 25066)John David Anglin2019-11-031-2/+7
| | | | | | | | | The hppa architecture requires strict alignment for loads and stores. As a result, the minimum stack alignment that will work is 8 bytes. This patch adjusts __clone() to align the stack argument passed to it. It also adjusts slightly some formatting. This fixes the nptl/tst-tls1 test.
* y2038: linux: Provide __futimens64 implementationLukasz Majewski2019-11-021-3/+19
| | | | | | | | | | | | | | | | | | | This patch provides new __futimens64 explicit 64 bit function for setting access and modification time of file (by using its file descriptor). Moreover, a 32 bit version - __futimens has been refactored to internally use __futimens64. The __futimens is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary conversions to 64 bit struct __timespec64. When pointer to struct __timespec64 is NULL - the file access and modification time is set to the current one (by the kernel) and no conversions from struct timespec to __timespec64 are performed. The __futimens64 reuses __utimensat64_helper defined for __utimensat64. The test procedure for __futimens64 is the same as for __utimensat64 conversion patch.
* y2038: linux: Provide __utimensat64 implementationLukasz Majewski2019-11-021-4/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch provides new __utimensat64 explicit 64 bit function for setting access and modification time of a file. Moreover, a 32 bit version - __utimensat has been refactored to internally use __utimensat64. The __utimensat is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary conversions to 64 bit struct __timespec64. When pointer to struct __timespec64 is NULL - the file access and modification time is set to the current one and no conversions from struct timespec to __timespec64 are performed. The new utimensat_time64 syscall available from Linux 5.1+ has been used, when applicable. The new helper function - __utimensat64_helper - has been introduced to facilitate code re-usage on function providing futimens syscall handling. The Linux kernel checks if passed tv_nsec value overflows, so there is no need to repeat it in glibc. When utimensat syscall on systems supporting 32 bit time ABI is used, the check is performed if passed data (which may have 64 bit tv_sec) fits into 32 bit range. Build tests: - The code has been tested on x86_64/x86 (native compilation): make PARALLELMFLAGS="-j8" && make xcheck PARALLELMFLAGS="-j8" - The glibc has been build tested (make PARALLELMFLAGS="-j8") for x86 (i386), x86_64-x32, and armv7 Run-time tests: - Run specific tests on ARM/x86 32bit systems (qemu): https://github.com/lmajewski/meta-y2038 and run tests: https://github.com/lmajewski/y2038-tests/commits/master - Use of cross-test-ssh.sh for ARM (armv7): make PARALLELMFLAGS="-j8" test-wrapper='./cross-test-ssh.sh root@192.168.7.2' xcheck Linux kernel, headers and minimal kernel version for glibc build test matrix: - Linux v5.1 (with utimensat_time64) and glibc build with v5.1 as minimal kernel version (--enable-kernel="5.1.0") The __ASSUME_TIME64_SYSCALLS flag defined. - Linux v5.1 and default minimal kernel version The __ASSUME_TIME64_SYSCALLS not defined, but kernel supports utimensat_time64 syscall. - Linux v4.19 (no utimensat_time64 support) with default minimal kernel version for contemporary glibc This kernel doesn't support utimensat_time64 syscall, so the fallback to utimensat is tested. The above tests were performed with Y2038 redirection applied as well as without (so the __TIMESIZE != 64 execution path is checked as well). No regressions were observed.
* nptl: Add pthread_clockjoin_npMike Crowe2019-11-0128-0/+38
| | | | | | | | | | | Introduce pthread_clockjoin_np as a version of pthread_timedjoin_np that accepts a clockid_t parameter to indicate which clock the timeout should be measured against. This mirrors the recently-added POSIX-proposed "clock" wait functions. Checked on x86_64-linux-gnu. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Refactor adjtimex based on clock_adjtimeAdhemerval Zanella2019-10-312-2/+2
| | | | | | Checked on x86_64-linux-gnu. Reviewed-by: Florian Weimer <fweimer@redhat.com>
* Refactor PI mutexes internal definitionsAdhemerval Zanella2019-10-312-0/+95
| | | | | | | | | | This patch adds the generic futex_lock_pi and futex_unlock_pi to wrap around the syscall machinery required to issue the syscall calls. It simplifies a bit the futex code required to implement PI mutexes. No function changes, checked on x86_64-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Remove pause and nanosleep not cancel wrappersAdhemerval Zanella2019-10-315-76/+2
| | | | | | Since they are not used any longer. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* nptl: Replace non cancellable pause/nanosleep with futexAdhemerval Zanella2019-10-314-47/+33
| | | | | | | | | | | | | | | | | | | | | | | | To help y2038 work avoid duplicate all the logic of nanosleep on non cancellable version, the patch replace it with a new futex operation, lll_timedwait. The changes are: - Add a expected value for __lll_clocklock_wait, so it can be used to wait for generic values. - Remove its internal atomic operation and move the logic to __lll_clocklock. It makes __lll_clocklock_wait even more generic and __lll_clocklock slight faster on fast-path (since it won't require a function call anymore). - Add lll_timedwait, which uses __lll_clocklock_wait, to replace both __pause_nocancel and __nanosleep_nocancel. It also allows remove the sparc32 __lll_clocklock_wait implementation (since it is similar to the generic one). Checked on x86_64-linux-gnu, sparcv9-linux-gnu, and i686-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Consolidate lowlevellock-futex.hAdhemerval Zanella2019-10-312-205/+128
| | | | | | | | | | NPTL is already Linux specific, there is no need to parametrize low level lock futex operations and add a sysdep Linux specific implementation. This patch moves the relevant Linux code to nptl one. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Consolidate futex-internal.hAdhemerval Zanella2019-10-312-270/+196
| | | | | | | | | | NPTL is already Linux specific, there is no need to parametrize futex operations and add a sysdep Linux specific implementation. This patch moves the relevant Linux code to nptl one. Checked on x86_64-linux-gnu and i686-linux-gnu. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Make second argument of gettimeofday as 'void *'Zack Weinberg2019-10-303-6/+6
| | | | | | | | | | | | | Also make the public prototype of gettimeofday declare its second argument with type "void *" unconditionally, consistent with POSIX. It is also consistent with POSIX. Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu. Co-authored-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Lukasz Majewski <lukma@denx.de>
* Use clock_gettime to implement gettimeofday.Adhemerval Zanella2019-10-3013-297/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consolidate generic gettimeofday implementation to use clock_gettime. Linux ports that still provide gettimeofday through vDSO are not changed. Remove sysdeps/unix/clock_gettime.c, which implemented clock_gettime using gettimeofday; new OS ports must provide a real implementation of clock_gettime. Rename sysdeps/mach/gettimeofday.c to sysdeps/mach/clock_gettime.c and convert into an implementation of clock_gettime. It only supports CLOCK_REALTIME; Mach does not appear to have any support for monotonic clocks. It uses __host_get_time, which provides at best microsecond resolution. Hurd is currently using sysdeps/posix/clock_getres.c for clock_getres; its output for CLOCK_REALTIME is based on sysconf (_SC_CLK_TCK), and I do not know whether that gives the correct result. Unlike settimeofday, there are no known uses of gettimeofday's vestigial "get time zone" feature that are not bugs. (The per-process timezone support in localtime and friends is unrelated, and the programs that set the kernel's offset between the hardware clock and UTC do not need to read it back.) Therefore, this feature is dummied out. Henceforth, if gettimeofday's "struct timezone" argument is not NULL, it will write zeroes to both fields. Any program that is actually looking at this data will thus think it is running in UTC, which is probably more correct than whatever it was doing before. [__]gettimeofday no longer has any internal callers, so we can now remove its internal prototype and PLT bypass aliases. The __gettimeofday@GLIBC_2.0 export remains, in case it is used by any third-party code. It also allows to simplify the arch-specific implementation on x86 and powerpc to remove the hack to disable the internal route to non iFUNC variant for internal symbol. This patch also fixes a missing optimization on aarch64, powerpc, and x86 where the code used on static build do not use the vDSO. Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu. Co-authored-by: Zack Weinberg <zackw@panix.com> Reviewed-by: Lukasz Majewski <lukma@denx.de>
* Use clock_gettime to implement timespec_get.Zack Weinberg2019-10-302-78/+0
| | | | | | | | | | | | | | | | | | | | | timespec_get is the same function as clock_gettime, with an obnoxious coating of NIH painted on it by the ISO C committee. In addition to the rename, it takes its arguments in a different order, it returns 0 on *failure* or a positive number on *success*, and it requires that all of its TIME_* constants be positive. This last means we cannot directly reuse the existing CLOCK_* constants for it, because those have been allocated starting with CLOCK_REALTIME = 0 on all existing platforms. This patch simply promotes the sysdeps/posix implementation to universal, and removes the Linux-specific implementation, whose apparent reason for existing was to cut out one function call's worth of overhead. Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, powerpc64-linux-gnu, powerpc-linux-gnu, and aarch64-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>