about summary refs log tree commit diff
path: root/include
Commit message (Collapse)AuthorAgeFilesLines
* Rename __LONG_DOUBLE_USES_FLOAT128 to __LDOUBLE_REDIRECTS_TO_FLOAT128_ABIPaul E. Murphy2020-04-307-13/+13
| | | | | | | | | | | | | | | Improve the commentary to aid future developers who will stumble upon this novel, yet not always perfect, mechanism to support alternative formats for long double. Likewise, rename __LONG_DOUBLE_USES_FLOAT128 to __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI now that development work has settled down. The command used was git grep -l __LONG_DOUBLE_USES_FLOAT128 ':!./ChangeLog*' | \ xargs sed -i 's/__LONG_DOUBLE_USES_FLOAT128/__LDOUBLE_REDIRECTS_TO_FLOAT128_ABI/g' Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
* ldbl-128ibm-compat: workaround GCC 9 C++ PR90731Paul E. Murphy2020-04-305-0/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC 9 has a bug (PR90731) whereby __typeof does not correctly copy exception specifiers[1]. Surprisingly, this can be quieted by declaring "#pragma system_header", or if the headers are installed in a system directory. Work around this by using the pragma for any gcc version between 9.0 and 9.2 to ensure tests continue to compile. [1] Example error from g++ 9.2.1: In file included from ../include/sys/cdefs.h:3, from ../include/features.h:465, from ../bits/libc-header-start.h:33, from ../math/math.h:27, from ../include/math.h:7, from test-math-isinff.cc:21: ../libio/bits/stdio-ldbl.h:25:20: error: declaration of ‘int sprintf(char*, const char*, ...)’ has a different exception specifier 25 | __LDBL_REDIR_DECL (sprintf) | ^~~~~~~ ../misc/sys/cdefs.h:461:26: note: in definition of macro ‘__LDBL_REDIR_DECL’ 461 | extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128")); | ^~~~ In file included from ../include/stdio.h:5, from test-math-isinff.cc:22: ../libio/stdio.h:334:12: note: from previous declaration ‘int sprintf(char*, const char*, ...) throw ()’ 334 | extern int sprintf (char *__restrict __s, | ^~~~~~~ Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
* Use 2020 as copyright year.Carlos O'Donell2020-04-271-1/+1
| | | | | Use the year 2020 for files added by commit: 92954ffa5a5662fbfde14febd7e5dcc358c85470
* localedef: Add verbose messages for failure paths.Carlos O'Donell2020-04-261-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | During testing of localedef running in a minimal container there were several error cases which were hard to diagnose since they appeared as strerror (errno) values printed by the higher level functions. This change adds three new verbose messages for potential failure paths. The new messages give the user the opportunity to use -v and display additional information about why localedef might be failing. I found these messages useful myself while writing a localedef container test for --no-hard-links. Since the changes cleanup the code that handle codeset normalization we add tst-localedef-path-norm which contains many sub-tests to verify the correct expected normalization of codeset strings both when installing to default paths (the only time normalization is enabled) and installing to absolute paths. During the refactoring I created at least one buffer-overflow which valgrind caught, but these tests did not catch because the exec in the container had a very clean heap with zero-initialized memory. However, between valgrind and the tests the results are clean. The new tst-localedef-path-norm passes without regression on x86_64. Change-Id: I28b9f680711ff00252a2cb15625b774cc58ecb9d
* Linux: Remove <sys/sysctl.h> and the sysctl functionFlorian Weimer2020-04-151-3/+0
| | | | | | | | | | | | | | | Linux 5.5 remove the system call in commit 61a47c1ad3a4dc6882f01ebdc88138ac62d0df03 ("Linux: Remove <sys/sysctl.h>"). Therefore, the compat function is just a stub that sets ENOSYS. Due to SHLIB_COMPAT, new ports will not add the sysctl function anymore automatically. x32 already lacks the sysctl function, so an empty sysctl.c file is used to suppress it. Otherwise, a new compat symbol would be added. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* y2038: linux: Provide __mq_timedreceive_time64 implementationLukasz Majewski2020-04-061-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch provides new __mq_timedreceive_time64 explicit 64 bit function for receiving messages with absolute timeout. Moreover, a 32 bit version - __mq_timedreceive has been refactored to internally use __mq_timedreceive_time64. The __mq_timedreceive is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary conversion to 64 bit struct __timespec64 from struct timespec. The new mq_timedsend_time64 syscall available from Linux 5.1+ has been used, when applicable. As this wrapper function is also used internally in the glibc, to e.g. provide mq_receive implementation, an explicit check for abs_timeout being NULL has been added due to conversions between struct timespec and struct __timespec64. Before this change the Linux kernel handled this NULL pointer. Build tests: - ./src/scripts/build-many-glibcs.py glibcs 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 Linux kernel, headers and minimal kernel version for glibc build test matrix: - Linux v5.1 (with mq_timedreceive_time64) and glibc built 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 mq_timedreceive_time64 syscall. - Linux v4.19 (no mq_timedreceive_time64 support) with default minimal kernel version for contemporary glibc (3.2.0) This kernel doesn't support mq_timedreceive_time64 syscall, so the fallback to mq_timedreceive is tested. Above tests were performed with Y2038 redirection applied as well as without (so the __TIMESIZE != 64 execution path is checked as well). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* y2038: linux: Provide __mq_timedsend_time64 implementationLukasz Majewski2020-04-061-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch provides new __mq_timedsend_time64 explicit 64 bit function for sending messages with absolute timeout. Moreover, a 32 bit version - __mq_timedsend has been refactored to internally use __mq_timedsend_time64. The __mq_timedsend is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary conversion to 64 bit struct __timespec64 from struct timespec. The new __mq_timedsend_time64 syscall available from Linux 5.1+ has been used, when applicable. As this wrapper function is also used internally in the glibc, to e.g. provide mq_send implementation, an explicit check for abs_timeout being NULL has been added due to conversions between struct timespec and struct __timespec64. Before this change the Linux kernel handled this NULL pointer. Build tests: - ./src/scripts/build-many-glibcs.py glibcs 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 Linux kernel, headers and minimal kernel version for glibc build test matrix: - Linux v5.1 (with mq_timedsend_time64) and glibc built with v5.1 as a 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 mq_timedsend_time64 syscall. - Linux v4.19 (no mq_timedsend_time64 support) with default minimal kernel version for contemporary glibc (3.2.0) This kernel doesn't support mq_timedsend_time64 syscall, so the fallback to mq_timedsend is tested. Above tests were performed with Y2038 redirection applied as well as without (so the __TIMESIZE != 64 execution path is checked as well). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* y2038: include: Move struct __timespec64 definition to a separate fileLukasz Majewski2020-04-062-23/+28
| | | | | | | | | | | | | | The struct __timespec64's definition has been moved from ./include/time.h to ./include/struct___timespec64.h. This change would prevent from polluting other glibc namespaces (when headers are modified to support 64 bit time on architectures with __WORDSIZE==32). Now it is possible to just include definition of this particular structure when needed. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* linux: Use long time_t for wait4/getrusageAlistair Francis2020-04-021-0/+11
| | | | | | | | | | | | | | The Linux kernel expects rusage to use a 32-bit time_t, even on archs with a 64-bit time_t (like RV32). To address this let's convert rusage to/from 32-bit and 64-bit to ensure the kernel always gets a 32-bit time_t. While we are converting these functions let's also convert them to be the y2038 safe versions. This means there is a *64 function that is called by a backwards compatible wrapper. Reviewed-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* resource: Add a __rusage64 structAlistair Francis2020-04-021-0/+110
| | | | | | | Add a __rusage64 struct which always uses a 64-bit time_t. Reviewed-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* linux: Use long time_t __getitimer/__setitimerAlistair Francis2020-04-021-0/+15
| | | | | | | | | | | | | | The Linux kernel expects itimerval to use a 32-bit time_t, even on archs with a 64-bit time_t (like RV32). To address this let's convert itimerval to/from 32-bit and 64-bit to ensure the kernel always gets a 32-bit time_t. While we are converting these functions let's also convert them to be the y2038 safe versions. This means there is a *64 function that is called by a backwards compatible wrapper. Tested-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* time: Add a __itimerval64 structAlistair Francis2020-03-271-0/+7
| | | | | | | Add a __itimerval64 which always uses a 64-bit time_t. Reviewed-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* time: Add a timeval with a 32-bit tv_sec and tv_usecAlistair Francis2020-03-271-0/+45
| | | | | | | | | On y2038 safe 32-bit systems the Linux kernel expects itimerval to use a 32-bit time_t, even though the other time_t's are 64-bit. To address this let's add a __timeval32 struct to be used internally. Reviewed-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* ldbl-128ibm-compat: PLT redirects for using ldbl redirects internallyPaul E. Murphy2020-03-256-23/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tweak the PLT bypass magic when building glibc with long double redirects. This is made more difficult by the fact we only get one chance to redirect functions. This happens via the public headers. There are roughly three classes of redirect we need to attend to today: 1. Simple redirects, redirected via cdef macro overrides and and new libc_hidden_ldbl_proto macro. 2. Internal usage of internal API, e.g __snprintf, which has no direct analogue. This is bypassed directly on case-by- case basis. 3. Double redirects, e.g sscanf and related. These require a heavier handed approach of macro renaming to existing symbols. Most simple redirects are handled via 1. Ideally, the libc_* macro would live in libc-symbols.h, but in practice the macros needed for it to do anything useful live in cdefs.h, so they are defined in the local override. Notably, the internal name of the asprintf generated for ieee ldbl redirects is renamed to work with internal prefixed usage. This resolves the local plt usage introduced when building glibc with ldbl == ieee128 on ppc64le. Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
* y2038: linux: Provide __futimesat64 implementationLukasz Majewski2020-03-091-0/+4
| | | | | | | | | This conversion patch for supporting 64 bit time for futimesat only differs from the work performed for futimes (when providing __futimes64) with passing also the file name (and path) to utimensat. All the design and conversion decisions are exactly the same as for futimens conversion.
* y2038: linux: Provide __lutimes64 implementationLukasz Majewski2020-03-091-0/+3
| | | | | | | | | | | This conversion patch for supporting 64 bit time for lutimes mostly differs from the work performed for futimes (when providing __futimes64) with adding the AT_SYMLINK_NOFOLLOW flag to utimensat. It also supports passing file name instead of file descriptor number, but this is not relevant for utimensat used to implement it. All the design and conversion decisions are exactly the same as for futimens conversion.
* y2038: linux: Provide __futimes64 implementationLukasz Majewski2020-03-091-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch provides new __futimes64 explicit 64 bit function for setting file's 64 bit attributes for access and modification time (by specifying file descriptor number). Internally, the __utimensat64_helper function is used. This patch is necessary for having architectures with __WORDSIZE == 32 Y2038 safe. Moreover, a 32 bit version - __futimes has been refactored to internally use __futimes64. The __futimes is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary conversion of struct timeval to 64 bit struct __timeval64. The check if struct timevals' usec fields are in the range between 0 and 1000000 has been removed as Linux kernel performs it internally in the implementation of utimensat (the conversion between struct __timeval64 and __timespec64 is not relevant for this particular check). Last but not least, checks for tvp{64} not being NULL have been preserved from the original code as some legacy user space programs may rely on it. Build tests: ./src/scripts/build-many-glibcs.py glibcs 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 Above tests were performed with Y2038 redirection applied as well as without to test the proper usage of both __futimes64 and __futimes.
* y2038: linux: Provide __utime64 implementationLukasz Majewski2020-03-031-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch replaces auto generated wrapper (as described in sysdeps/unix/sysv/linux/syscalls.list) for utime with one which adds extra support for setting file's access and modification 64 bit time on machines with __TIMESIZE != 64. Internally, the __utimensat_time64 helper function is used. This patch is necessary for having architectures with __WORDSIZE == 32 && __TIMESIZE != 64 Y2038 safe. Moreover, a 32 bit version - __utime has been refactored to internally use __utime64. The __utime is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary conversion between struct utimbuf and struct __utimbuf64. Build tests: ./src/scripts/build-many-glibcs.py glibcs 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 Above tests were performed with Y2038 redirection applied as well as without to test proper usage of both __utime64 and __utime. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* y2038: linux: Provide __utimes64 implementationLukasz Majewski2020-03-031-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch provides new __utimes64 explicit 64 bit function for setting file's 64 bit attributes for access and modification time. Internally, the __utimensat64_helper function is used. This patch is necessary for having architectures with __WORDSIZE == 32 Y2038 safe. Moreover, a 32 bit version - __utimes has been refactored to internally use __utimes64. The __utimes is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary conversion of struct timeval to 64 bit struct __timeval64. Build tests: ./src/scripts/build-many-glibcs.py glibcs 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 Above tests were performed with Y2038 redirection applied as well as without to test proper usage of both __utimes64 and __utimes. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* y2038: Introduce struct __utimbuf64 - new internal glibc typeLukasz Majewski2020-03-031-0/+12
| | | | | | | | | | | This type is a glibc's "internal" type to store file's access and modification times in __time64_t rather than __time_t, which makes it Y2038-proof. Build tests: ./src/scripts/build-many-glibcs.py glibcs Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
* ldbl-128ibm-compat: Redirect long double functions to f128/ieee128 functionsTulio Magno Quites Machado Filho2020-02-281-3/+6
| | | | | | | | | | | | | | | | Modify the headers to redirect long double functions to global __*f128 symbols or to __*ieee128 otherwise. Most of the functions in math.h benefit from the infrastructure already available for __LDBL_COMPAT. The only exceptions are nexttowardf and nexttoward that need especial treatment. Both math/bits/mathcalls-helper-functions.h and math/bits/mathcalls.h were modified in order to provide alternative redirection destinations that are essential to support functions that should not be redirected to the same name pattern of the rest of the functions, i.e.: __fpclassify, __signbit, __iseqsig, __issignaling, isinf, finite and isnan, which will be redirected to __*f128 instead of __*ieee128 used for the rest.
* nss_nis: Use NSS_DECLARE_MODULE_FUNCTIONSFlorian Weimer2020-02-252-1/+30
| | | | | This commit removes the minor optimization based on strong aliases because it loses type safety.
* csu: Use ELF constructor instead of _init in libc.soFlorian Weimer2020-02-251-1/+1
| | | | | | | | On !ELF_INITFINI architectures, _init is no longer called by the dynamic linker. We can use an ELF constructor instead because the constructor order does not matter. (The other constructors are used to set up libio vtable bypasses and do not depend on this initialization routine.)
* Add hidden prototypes for __sched_getparam, __sched_getschedulerFlorian Weimer2020-02-201-0/+2
| | | | | | This will enable them to be used in libc.so without PLTs. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* y2038: linux: Provide __gettimeofday64 implementationLukasz Majewski2020-02-181-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the glibc the gettimeofday can use vDSO (on power and x86 the USE_IFUNC_GETTIMEOFDAY is defined), gettimeofday syscall or 'default' ___gettimeofday() from ./time/gettime.c (as a fallback). In this patch the last function (___gettimeofday) has been refactored and moved to ./sysdeps/unix/sysv/linux/gettimeofday.c to be Linux specific. The new __gettimeofday64 explicit 64 bit function for getting 64 bit time from the kernel (by internally calling __clock_gettime64) has been introduced. Moreover, a 32 bit version - __gettimeofday has been refactored to internally use __gettimeofday64. The __gettimeofday is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary check for time_t potential overflow and conversion of struct __timeval64 to 32 bit struct timespec. The iFUNC vDSO direct call optimization has been removed from both i686 and powerpc32 (USE_IFUNC_GETTIMEOFDAY is not defined for those architectures anymore). The Linux kernel does not provide a y2038 safe implementation of gettimeofday neither it plans to provide it in the future, clock_gettime64 should be used instead. Keeping support for this optimization would require to handle another build permutation (!__ASSUME_TIME64_SYSCALLS && USE_IFUNC_GETTIMEOFDAY) which adds more complexity and has limited use (since the idea is to eventually have a y2038 safe glibc build). Build tests: ./src/scripts/build-many-glibcs.py glibcs 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 Above tests were performed with Y2038 redirection applied as well as without to test proper usage of both __gettimeofday64 and __gettimeofday. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> [Including some commit message improvement]
* Move implementation of <file_change_detection.h> into a C fileFlorian Weimer2020-02-181-90/+20
| | | | | | | | | | | file_change_detection_for_stat partially initialize struct file_change_detection in some cases, when the size member alone determines the outcome of all comparisons. This results in maybe-uninitialized compiler warnings in case of sufficiently aggressive inlining. Once the implementation is moved into a separate C file, this kind of inlining is no longer possible, so the compiler warnings are gone.
* ld.so: Do not export free/calloc/malloc/realloc functions [BZ #25486]Florian Weimer2020-02-155-3/+99
| | | | | | | | | | | | | | | | | | | Exporting functions and relying on symbol interposition from libc.so makes the choice of implementation dependent on DT_NEEDED order, which is not what some compiler drivers expect. This commit replaces one magic mechanism (symbol interposition) with another one (preprocessor-/compiler-based redirection). This makes the hand-over from the minimal malloc to the full malloc more explicit. Removing the ABI symbols is backwards-compatible because libc.so is always in scope, and the dynamic loader will find the malloc-related symbols there since commit f0b2132b35248c1f4a80f62a2c38cddcc802aa8c ("ld.so: Support moving versioned symbols between sonames [BZ #24741]"). Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Remove weak declaration of free from <inline-hashtab.h>Florian Weimer2020-02-151-8/+3
| | | | | | | | elf/dl-minimal.c provides a definition of free, so the function pointer is always non-null, even before the final relocation of the loader. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* io: Implement lchmod using fchmodat [BZ #14578]Florian Weimer2020-02-121-0/+1
|
* Add internal <file_change_detection.h> header fileFlorian Weimer2020-02-121-0/+140
| | | | | | | | | | | The code started out with bits form resolv/resolv_conf.c, but it was enhanced to deal with directories and FIFOs in a more predictable manner. A test case is included as well. This will be used to implement the /etc/resolv.conf change detection. This currently lives in a header file only. Once there are multiple users, the implementations should be moved into C files.
* y2038: linux: Provide __settimeofday64 implementationLukasz Majewski2020-02-071-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch provides new __settimeofday64 explicit 64 bit function for setting 64 bit time in the kernel (by internally calling __clock_settime64). Moreover, a 32 bit version - __settimeofday has been refactored to internally use __settimeofday64. The __settimeofday is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary conversion of struct timeval to 64 bit struct __timespec64. Internally the settimeofday uses __settimeofday64. This patch is necessary for having architectures with __WORDSIZE == 32 Y2038 safe. Build tests: ./src/scripts/build-many-glibcs.py glibcs 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 Above tests were performed with Y2038 redirection applied as well as without to test proper usage of both __settimeofday64 and __settimeofday. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* y2038: Provide conversion helpers for struct __timeval64Lukasz Majewski2020-02-071-0/+49
| | | | | | | | | | | | Those functions allow easy conversion between Y2038 safe, glibc internal struct __timeval64 and other time related data structures (like struct timeval or struct __timespec64). Build tests: ./src/scripts/build-many-glibcs.py glibcs Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* y2038: Introduce struct __timeval64 - new internal glibc typeLukasz Majewski2020-02-071-0/+14
| | | | | | | | | | | | | | This type is a glibc's "internal" type similar to struct timeval but whose tv_sec field is a __time64_t rather than a time_t, which makes it Y2038-proof. This struct is NOT supposed to be passed to the kernel - instead it shall be converted to struct __timespec64 and clock_[sg]ettime syscalls shall be used (which are now Y2038 safe). Build tests: ./src/scripts/build-many-glibcs.py glibcs Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* y2038: linux: Provide __timespec_get64 implementationLukasz Majewski2020-02-051-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch provides new instance of Linux specific timespec_get.c file placed in ./sysdeps/unix/sysv/linux/. When compared to this file version from ./time directory, it provides __timespec_get64 explicit 64 bit function for getting 64 bit time in the struct __timespec64 (for compilation using C11 standard). Moreover, a 32 bit version - __timespec_get internally uses __timespec_get64. The __timespec_get is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary conversion to 32 bit struct timespec. Internally the timespec_get uses __clock_gettime64. This patch is necessary for having architectures with __WORDSIZE == 32 Y2038 safe. Build tests: ./src/scripts/build-many-glibcs.py glibcs 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 Above tests were performed with Y2038 redirection applied as well as without to test proper usage of both __timespec_get64 and __timespec_get. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* rt: avoid PLT setup in timer_[sg]ettimeAndreas Schwab2020-02-031-2/+2
| | | | | | | | | | The functions __timer_gettime64 and __timer_settime64 live in librt, not libc. Use proper hidden aliases so that the callers do not need to set up the PLT register. Fixes commits cae1635a70 ("y2038: linux: Provide __timer_settime64 implementation") and 562cdc19c7 ("y2038: linux: Provide __timer_gettime64 implementation").
* y2038: linux: Provide __sched_rr_get_interval64 implementationLukasz Majewski2020-02-021-0/+7
| | | | | | | | | | | | | | | | | | | | | | This patch replaces auto generated wrapper (as described in sysdeps/unix/sysv/linux/syscalls.list) for sched_rr_get_interval with one which adds extra support for reading 64 bit time values on machines with __TIMESIZE != 64. There is no functional change for architectures already supporting 64 bit time ABI. The sched_rr_get_interval declaration in ./include/sched.h is not followed by corresponding libc_hidden_proto(), so it has been assumed that newly introduced syscall wrapper doesn't require libc_hidden_def() (which has been added by template used with auto generation script). Moreover, the code for building sched_rr_gi.c file is already placed in ./posix/Makefiles, so there was no need to add it elsewhere. Performed tests and validation are the same as for timer_gettime() conversion (sysdeps/unix/sysv/linux/timer_gettime.c). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* y2038: linux: Provide __timerfd_settime64 implementationLukasz Majewski2020-02-021-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch replaces auto generated wrapper (as described in sysdeps/unix/sysv/linux/syscalls.list) for timerfd_settime with one which adds extra support for reading and writing from Linux kernel 64 bit time values on machines with __TIMESIZE != 64. There is no functional change for archs already supporting 64 bit time ABI. This patch is conceptually identical to timer_settime conversion already done in sysdeps/unix/sysv/linux/timer_settime.c. Please refer to corresponding commit message for detailed description of introduced functions and the testing procedure. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> --- Changes for v4: - Update date from 2019 to 2020 Changes for v3: - Add missing libc_hidden_def() Changes for v2: - Remove "Contributed by" from the file header - Remove early check for (fd < 0) in __timerfd_settime64 as the fd correctness check is already done in Linux kernel - Add single descriptive comment line to provide concise explanation of the code
* y2038: linux: Provide __timerfd_gettime64 implementationLukasz Majewski2020-02-021-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch replaces auto generated wrapper (as described in sysdeps/unix/sysv/linux/syscalls.list) for timerfd_gettime with one which adds extra support for reading 64 bit time values on machines with __TIMESIZE != 64. There is no functional change for architectures already supporting 64 bit time ABI. This patch is conceptually identical to timer_gettime conversion already done in sysdeps/unix/sysv/linux/timer_gettime.c. Please refer to corresponding commit message for detailed description of introduced functions and the testing procedure. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> --- Changes for v4: - Update date from 2019 to 2020 Changes for v3: - Add missing libc_hidden_def() Changes for v2: - Remove "Contributed by" from the file header - Remove early check for (fd < 0) in __timerfd_gettime64 as the fd correctness check is already done in Linux kernel - Add single descriptive comment line to provide concise explanation of the code
* Update version numbers for 2.31 releaseSiddhesh Poyarekar2020-02-011-1/+1
|
* Update copyright dates with scripts/update-copyrights.Joseph Myers2020-01-0133-33/+33
|
* Do not redirect calls to __GI_* symbols, when redirecting to *ieee128Tulio Magno Quites Machado Filho2019-12-272-2/+12
| | | | | | | | | | | | | | | | | | | | | | On platforms where long double has IEEE binary128 format as a third option (initially, only powerpc64le), many exported functions are redirected to their __*ieee128 equivalents. This redirection is provided by installed headers such as stdio-ldbl.h, and is supposed to work correctly with user code. However, during the build of glibc, similar redirections are employed, in internal headers, such as include/stdio.h, in order to avoid extra PLT entries. These redirections conflict with the redirections to __*ieee128, and must be avoided during the build. This patch protects the second redirections with a test for __LONG_DOUBLE_USES_FLOAT128, a new macro that is defined to 1 when functions that deal with long double typed values reuses the _Float128 implementation (this is currently only true for powerpc64le). Tested for powerpc64le, x86_64, and with build-many-glibcs.py. Co-authored-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com> Reviewed-by: Florian Weimer <fweimer@redhat.com>
* Implement waitpid in terms of wait4Adhemerval Zanella2019-12-191-0/+1
| | | | | | This also consolidate all waitpid implementations. Checked on x86_64-linux-gnu.
* hurd: Fix local PLTSamuel Thibault2019-12-131-0/+10
| | | | | | | | | | * include/sys/random.h (__getrandom): Add hidden prototype. * stdlib/getrandom.c (getrandom): Rename to hidden definition __getrandom. Add weak alias. * sysdeps/mach/hurd/getrandom.c (getrandom): Likewise. * sysdeps/unix/sysv/linux/getrandom.c (getrandom): Likewise. * sysdeps/mach/hurd/getentropy.c (getentropy): Use __getrandom instead of getrandom.
* dlopen: Rework handling of pending NODELETE statusFlorian Weimer2019-12-131-20/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit a2e8aa0d9ea648068d8be52dd7b15f1b6a008e23 ("Block signals during the initial part of dlopen") was deemed necessary because of read-modify-write operations like the one in add_dependency in elf/dl-lookup.c. In the old code, we check for any kind of NODELETE status and bail out: /* Redo the NODELETE check, as when dl_load_lock wasn't held yet this could have changed. */ if (map->l_nodelete != link_map_nodelete_inactive) goto out; And then set pending status (during relocation): if (flags & DL_LOOKUP_FOR_RELOCATE) map->l_nodelete = link_map_nodelete_pending; else map->l_nodelete = link_map_nodelete_active; If a signal arrives during relocation and the signal handler, through lazy binding, adds a global scope dependency on the same map, it will set map->l_nodelete to link_map_nodelete_active. This will be overwritten with link_map_nodelete_pending by the dlopen relocation code. To avoid such problems in relation to the l_nodelete member, this commit introduces two flags for active NODELETE status (irrevocable) and pending NODELETE status (revocable until activate_nodelete is invoked). As a result, NODELETE processing in dlopen does not introduce further reasons why lazy binding from signal handlers is unsafe during dlopen, and a subsequent commit can remove signal blocking from dlopen. This does not address pre-existing issues (unrelated to the NODELETE changes) which make lazy binding in a signal handler during dlopen unsafe, such as the use of malloc in both cases. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* nptl: Add more missing placeholder abi symbol from nanosleep moveAdhemerval Zanella2019-12-091-0/+36
| | | | | | | | | | | | | | | | | | | | This patch adds the missing __libpthread_version_placeholder for GLIBC_2.2.6 version from the nanosleep implementation move from libpthread to libc (79a547b162). It also fixes the wrong compat symbol definitions added by changing back the version used on vfork check and remove the __libpthread_version_placeholder added on some ABI (4f4bb489e0dd). The __libpthread_version_placeholder is also refactored to make it simpler to add new compat_symbols by adding a new macro compat_symbol_unique which uses the compiler extension __COUNTER__ to generate unique strong alias to be used with compat_symbol. Checked with a updated-abi on the all affected abis of the nanosleep move. Change-Id: I347a4dbdc931bb42b359456932dd1e17aa4d4078
* y2038: linux: Provide __timer_settime64 implementationLukasz Majewski2019-12-051-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch provides new __timer_settime64 explicit 64 bit function for setting flags, interval and value of specified timer. Moreover, a 32 bit version - __timer_settime has been refactored to internally use __timer_settime64. The __timer_settime is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary conversion to 64 bit struct __timespec64 from struct timespec (and opposite when old_value pointer is provided). The new __timer_settime64 syscall available from Linux 5.1+ has been used, when applicable. The original INLINE_SYSCALL() macro has been replaced with INLINE_SYSCALL_CALL() to avoid explicit passing the number of arguments. 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 timer_settime64) 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 timer_settime64 syscall. - Linux v4.19 (no timer_settime64 support) with default minimal kernel version for contemporary glibc (3.2.0) This kernel doesn't support timer_settime64 syscall, so the fallback to timer_settime 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. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* y2038: linux: Provide __timer_gettime64 implementationLukasz Majewski2019-12-051-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch provides new __timer_gettime64 explicit 64 bit function for reading status of specified timer. To be more precise - the remaining time and interval set with timer_settime. Moreover, a 32 bit version - __timer_gettime has been refactored to internally use __timer_gettime64. The __timer_gettime is now supposed to be used on systems still supporting 32 bit time (__TIMESIZE != 64) - hence the necessary conversion from 64 bit struct __timespec64 to struct timespec. The new __timer_gettime64 syscall available from Linux 5.1+ has been used, when applicable. The original INLINE_SYSCALL() macro has been replaced with INLINE_SYSCALL_CALL() to avoid explicit passing the number of arguments. 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 timer_gettime64) 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 timer_gettime64 syscall. - Linux v4.19 (no timer_gettime64 support) with default minimal kernel version for contemporary glibc (3.2.0) This kernel doesn't support timer_gettime64 syscall, so the fallback to timer_gettime 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. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* time: Introduce glibc's internal struct __itimerspec64Lukasz Majewski2019-12-051-0/+11
| | | | | | | | | | This change provides the glibc's internal struct itimerspec representation, which is explicitly supporting 64 bit time (by using struct __timespec64). Such representation is necessary to provide correct time after Y2038 (time_t overflow) on devices with __TIMESIZE == 32. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* sysdeps/clock_gettime: Use clock_gettime64 if avaliableAlistair Francis2019-12-041-0/+3
| | | | | | | | With the clock_gettime64 call we prefer to use vDSO. There is no call to clock_gettime64 on glibc with older headers and kernel 5.1+ if it doesn't support vDSO. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* ldbl-128ibm-compat: Add strfmon_l with IEEE long double formatRajalakshmi Srinivasaraghavan2019-12-031-0/+1
| | | | | | | | | | | | Similarly to what has been done for printf-like functions, more specifically to the internal implementation in __vfprintf_internal, this patch extends __vstrfmon_l_internal to deal with long double values with binary128 format (as a third format option and reusing the float128 implementation). Tested for powerpc64le, powerpc64, x86_64, and with build-many-glibcs. Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>