From 323592fdc92a0021319419f210a6052542856654 Mon Sep 17 00:00:00 2001 From: Lukasz Majewski Date: Tue, 11 Aug 2020 10:49:03 +0200 Subject: y2038: nptl: Convert pthread_cond_{clock|timed}wait to support 64 bit time The pthread_cond_clockwait and pthread_cond_timedwait have been converted to support 64 bit time. This change introduces new futex_abstimed_wait_cancelable64 function in ./sysdeps/nptl/futex-helpers.c, which uses futex_time64 where possible and tries to replace low-level preprocessor macros from lowlevellock-futex.h The pthread_cond_{clock|timed}wait only accepts absolute time. Moreover, there is no need to check for NULL passed as *abstime pointer as __pthread_cond_wait_common() always passes non-NULL struct __timespec64 pointer to futex_abstimed_wait_cancellable64(). For systems with __TIMESIZE != 64 && __WORDSIZE == 32: - Conversions between 64 bit time to 32 bit are necessary - Redirection to __pthread_cond_{clock|timed}wait64 will provide support for 64 bit time The futex_abstimed_wait_cancelable64 function has been put into a separate file on the purpose - to avoid issues apparent on the m68k architecture related to small number of available registers (there is not enough registers to put all necessary arguments in them if the above function would be added to futex-internal.h with __always_inline attribute). In fact - new function - namely __futex_abstimed_wait_cancellable32 is used to reduce number of needed registers (as some in-register values are stored on the stack when function call is made). 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 __pthread_cond_{clock|timed}wait64 and __pthread_cond_{clock|timed}wait. Reviewed-by: Adhemerval Zanella --- nptl/pthreadP.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'nptl/pthreadP.h') diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index 99713c8447..9bb44c8535 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -462,6 +462,8 @@ extern int __pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex); #if __TIMESIZE == 64 # define __pthread_clockjoin_np64 __pthread_clockjoin_np # define __pthread_timedjoin_np64 __pthread_timedjoin_np +# define __pthread_cond_timedwait64 __pthread_cond_timedwait +# define __pthread_cond_clockwait64 __pthread_cond_clockwait #else extern int __pthread_clockjoin_np64 (pthread_t threadid, void **thread_return, clockid_t clockid, @@ -470,6 +472,15 @@ libc_hidden_proto (__pthread_clockjoin_np64) extern int __pthread_timedjoin_np64 (pthread_t threadid, void **thread_return, const struct __timespec64 *abstime); libc_hidden_proto (__pthread_timedjoin_np64) +extern int __pthread_cond_timedwait64 (pthread_cond_t *cond, + pthread_mutex_t *mutex, + const struct __timespec64 *abstime); +libpthread_hidden_proto (__pthread_cond_timedwait64) +extern int __pthread_cond_clockwait64 (pthread_cond_t *cond, + pthread_mutex_t *mutex, + clockid_t clockid, + const struct __timespec64 *abstime); +libpthread_hidden_proto (__pthread_cond_clockwait64) #endif extern int __pthread_cond_timedwait (pthread_cond_t *cond, -- cgit 1.4.1