about summary refs log tree commit diff
path: root/nptl/pthread_timedjoin.c
diff options
context:
space:
mode:
authorLukasz Majewski <lukma@denx.de>2020-07-20 15:50:12 +0200
committerLukasz Majewski <lukma@denx.de>2020-08-13 14:16:34 +0200
commit4a14cb87cad30bb15bb906e579089109874f3071 (patch)
tree4a5cdc2249d5c749985f5da2833e8e5a337d2573 /nptl/pthread_timedjoin.c
parent12b2fd0ef9f51642ad00646c1a2e3490e25f4a00 (diff)
downloadglibc-4a14cb87cad30bb15bb906e579089109874f3071.tar.gz
glibc-4a14cb87cad30bb15bb906e579089109874f3071.tar.xz
glibc-4a14cb87cad30bb15bb906e579089109874f3071.zip
y2038: nptl: Convert pthread_{clock|timed}join_np to support 64 bit time
The pthread_clockjoin_np and pthread_timedjoin_np have been converted to
support 64 bit time.

This change introduces new futex_timed_wait_cancel64 function in
./sysdeps/nptl/futex-internal.h, which uses futex_time64 where possible
and tries to replace low-level preprocessor macros from
lowlevellock-futex.h
The pthread_{timed|clock}join_np only accept absolute time. Moreover,
there is no need to check for NULL passed as *abstime pointer as
clockwait_tid() always passes struct __timespec64.

For systems with __TIMESIZE != 64 && __WORDSIZE == 32:
- Conversions between 64 bit time to 32 bit are necessary
- Redirection to __pthread_{clock|timed}join_np64 will provide support
  for 64 bit time

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_{timed|clock}join_np64 and
__pthread_{timed|clock}join_np.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Diffstat (limited to 'nptl/pthread_timedjoin.c')
-rw-r--r--nptl/pthread_timedjoin.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/nptl/pthread_timedjoin.c b/nptl/pthread_timedjoin.c
index dd7038dcf7..6164ae7060 100644
--- a/nptl/pthread_timedjoin.c
+++ b/nptl/pthread_timedjoin.c
@@ -16,13 +16,27 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#include <time.h>
 #include "pthreadP.h"
 
 int
-__pthread_timedjoin_np (pthread_t threadid, void **thread_return,
-			const struct timespec *abstime)
+__pthread_timedjoin_np64 (pthread_t threadid, void **thread_return,
+                          const struct __timespec64 *abstime)
 {
   return __pthread_clockjoin_ex (threadid, thread_return,
                                  CLOCK_REALTIME, abstime, true);
 }
+
+#if __TIMESIZE != 64
+libc_hidden_def (__pthread_timedjoin_np64)
+
+int
+__pthread_timedjoin_np (pthread_t threadid, void **thread_return,
+                        const struct timespec *abstime)
+{
+  struct __timespec64 ts64 = valid_timespec_to_timespec64 (*abstime);
+
+  return __pthread_timedjoin_np64 (threadid, thread_return, &ts64);
+}
+#endif
 weak_alias (__pthread_timedjoin_np, pthread_timedjoin_np)