From patchwork Tue Jul 7 15:08:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 39934 X-Patchwork-Delegate: l.majewski@majess.pl Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B0E913857034; Tue, 7 Jul 2020 15:08:50 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by sourceware.org (Postfix) with ESMTPS id CA480385702B for ; Tue, 7 Jul 2020 15:08:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CA480385702B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4B1QnB02szz1rx8j; Tue, 7 Jul 2020 17:08:46 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4B1Qn961SGz1r576; Tue, 7 Jul 2020 17:08:45 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id poh07d_3nCZM; Tue, 7 Jul 2020 17:08:44 +0200 (CEST) X-Auth-Info: 0Ncn+pWvOHuArXnmFzjzHfQOOknrn1hUo4CrYbORHos= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 7 Jul 2020 17:08:44 +0200 (CEST) From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Subject: [RFC 01/10] doc: Fix wording and formatting in ./support/README Date: Tue, 7 Jul 2020 17:08:18 +0200 Message-Id: <20200707150827.20899-2-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200707150827.20899-1-lukma@denx.de> References: <20200707150827.20899-1-lukma@denx.de> MIME-Version: 1.0 X-Spam-Status: No, score=-20.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Weimer , GNU C Library , Andreas Schwab , Stepan Golosunov , Alistair Francis Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" --- support/README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/support/README b/support/README index ae2c41caa8..bbd3d588f2 100644 --- a/support/README +++ b/support/README @@ -4,8 +4,8 @@ not) and tests. # Error-checking wrappers -These wrappers test for error return codes an terminate the process on -error. They are declared in these header files: +These wrappers test for error return codes and terminate the process on +error. They are declared in these header files: * support.h * xsignal.h From patchwork Tue Jul 7 15:08:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 39936 X-Patchwork-Delegate: l.majewski@majess.pl Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6F47E38618A5; Tue, 7 Jul 2020 15:08:52 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [IPv6:2001:a60:0:28:0:1:25:1]) by sourceware.org (Postfix) with ESMTPS id 15F0C3857C7C for ; Tue, 7 Jul 2020 15:08:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 15F0C3857C7C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4B1QnC6Bktz1rxML; Tue, 7 Jul 2020 17:08:47 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4B1QnC4m09z1r573; Tue, 7 Jul 2020 17:08:47 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id bYZIfWKCDimz; Tue, 7 Jul 2020 17:08:46 +0200 (CEST) X-Auth-Info: bYlyA0qe42hurUcMuRo0isPx+J1UfdvWnHCKVABzx9A= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 7 Jul 2020 17:08:46 +0200 (CEST) From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Subject: [RFC 02/10] y2038: Convert timespec_* from posix-timer.h to be Y2038 safe Date: Tue, 7 Jul 2020 17:08:19 +0200 Message-Id: <20200707150827.20899-3-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200707150827.20899-1-lukma@denx.de> References: <20200707150827.20899-1-lukma@denx.de> MIME-Version: 1.0 X-Spam-Status: No, score=-20.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Weimer , GNU C Library , Andreas Schwab , Stepan Golosunov , Alistair Francis Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Static inline functions - timespec_compare, timespec_sum and timespec_diff - from ./sysdeps/pthread/posix-timer.h have been converted to support 64 bit time on ports with __WORDSIZE == 32 && __TIMESIZE != 64. The change was focused on using struct __timespec64. Tested with glibc/glibc-many-build --keep failed glibcs --- sysdeps/pthread/posix-timer.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sysdeps/pthread/posix-timer.h b/sysdeps/pthread/posix-timer.h index 81fc8a2394..86bb123b7a 100644 --- a/sysdeps/pthread/posix-timer.h +++ b/sysdeps/pthread/posix-timer.h @@ -115,7 +115,8 @@ timer_delref (struct timer_node *timer) /* Timespec helper routines. */ static inline int __attribute ((always_inline)) -timespec_compare (const struct timespec *left, const struct timespec *right) +timespec_compare (const struct __timespec64 *left, + const struct __timespec64 *right) { if (left->tv_sec < right->tv_sec) return -1; @@ -131,8 +132,8 @@ timespec_compare (const struct timespec *left, const struct timespec *right) } static inline void -timespec_add (struct timespec *sum, const struct timespec *left, - const struct timespec *right) +timespec_add (struct __timespec64 *sum, const struct __timespec64 *left, + const struct __timespec64 *right) { sum->tv_sec = left->tv_sec + right->tv_sec; sum->tv_nsec = left->tv_nsec + right->tv_nsec; @@ -145,8 +146,8 @@ timespec_add (struct timespec *sum, const struct timespec *left, } static inline void -timespec_sub (struct timespec *diff, const struct timespec *left, - const struct timespec *right) +timespec_sub (struct __timespec64 *diff, const struct __timespec64 *left, + const struct __timespec64 *right) { diff->tv_sec = left->tv_sec - right->tv_sec; diff->tv_nsec = left->tv_nsec - right->tv_nsec; From patchwork Tue Jul 7 15:08:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 39938 X-Patchwork-Delegate: l.majewski@majess.pl Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2E74138618F9; Tue, 7 Jul 2020 15:08:56 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by sourceware.org (Postfix) with ESMTPS id B227A38618D4 for ; Tue, 7 Jul 2020 15:08:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B227A38618D4 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4B1QnF6SMNz1qskn; Tue, 7 Jul 2020 17:08:49 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4B1QnF5v9nz1r573; Tue, 7 Jul 2020 17:08:49 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 6LOpc5eDy-nA; Tue, 7 Jul 2020 17:08:48 +0200 (CEST) X-Auth-Info: 4pD5ejFFO4CrCt21esZvn46abUz47k5fGpZrKNXEd/Y= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 7 Jul 2020 17:08:47 +0200 (CEST) From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Subject: [RFC 03/10] y2038: Convert __lll_futex* functions to use futex_time64 when available Date: Tue, 7 Jul 2020 17:08:20 +0200 Message-Id: <20200707150827.20899-4-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200707150827.20899-1-lukma@denx.de> References: <20200707150827.20899-1-lukma@denx.de> MIME-Version: 1.0 X-Spam-Status: No, score=-20.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Weimer , GNU C Library , Andreas Schwab , Stepan Golosunov , Alistair Francis Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" As the 'futex' syscall is wrapped with a C preprocessor macros, it was necessary to provide new set of those to replace call it with Y2038 safe 'futex_time64' syscall. The current code expand wrapper's arguments as __VA_ARGS__ when more than three arguments are passed. For the conversion it was necessary to also have 'timeout' explicitly passed, and hence the introduction of lll_futex_syscall_time64_4 and lll_futex_syscall_time64 functions. The former expects exactly 4 arguments - timeout is the last one. Signed-off-by: Lukasz Majewski --- sysdeps/nptl/lowlevellock-futex.h | 80 ++++++++++++++++++++++++++++--- sysdeps/nptl/lowlevellock.h | 2 +- 2 files changed, 75 insertions(+), 7 deletions(-) diff --git a/sysdeps/nptl/lowlevellock-futex.h b/sysdeps/nptl/lowlevellock-futex.h index 2209ca76a1..a686773db4 100644 --- a/sysdeps/nptl/lowlevellock-futex.h +++ b/sysdeps/nptl/lowlevellock-futex.h @@ -65,14 +65,82 @@ (((fl) | FUTEX_PRIVATE_FLAG) ^ (private)) # endif -# define lll_futex_syscall(nargs, futexp, op, ...) \ +# define __lll_futex_syscall(nargs, futexp, op, ...) \ ({ \ - long int __ret = INTERNAL_SYSCALL (futex, nargs, futexp, op, \ + long int __ret = INTERNAL_SYSCALL (futex, nargs, futexp, op, \ __VA_ARGS__); \ (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (__ret)) \ ? -INTERNAL_SYSCALL_ERRNO (__ret) : 0); \ }) +# define __lll_futex_syscall64(nargs, futexp, op, ...) \ + ({ \ + long int __ret = INTERNAL_SYSCALL (futex_time64, nargs, futexp, op, \ + __VA_ARGS__); \ + (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (__ret)) \ + ? -INTERNAL_SYSCALL_ERRNO (__ret) : 0); \ + }) + +# ifdef __ASSUME_TIME64_SYSCALLS +# ifndef __NR_futex_time64 +# define __NR_futex_time64 __NR_futex +# endif +# define lll_futex_syscall(nargs, futexp, op, ...) \ + __lll_futex_syscall64(nargs, futexp, op, __VA_ARGS__) +# define lll_futex_syscall_time64_4(nargs, futexp, op, val, timeout)\ + __lll_futex_syscall64(nargs, futexp, op, val, timeout) +# define lll_futex_syscall_time64(nargs, futexp, op, val, timeout, ...)\ + __lll_futex_syscall64(nargs, futexp, op, val, timeout, __VA_ARGS__) +# else +inline static long int +__lll_futex_syscall_time_check (long int __ret, const struct __timespec64 *t) +{ + if (! (__ret == 0 || errno != ENOSYS)) + if (t != NULL && ! in_time_t_range (t->tv_sec)) + __ret = ({ errno = (EOVERFLOW); -1l; }); + return __ret; +} +# define lll_futex_syscall(nargs, futexp, op, ...) \ + ({ \ + long int __ret = \ + __lll_futex_syscall64(nargs, futexp, op, __VA_ARGS__); \ + if (! (__ret == 0 || errno != ENOSYS)) \ + __ret = \ + __lll_futex_syscall(nargs, futexp, op, __VA_ARGS__); \ + __ret; \ + }) + +# define lll_futex_syscall_time64(nargs, futexp, op, val, timeout, ...)\ + ({ \ + struct timespec __ts32; \ + if (timeout != NULL) \ + __ts32 = valid_timespec64_to_timespec (*((struct __timespec64*) timeout)); \ + long int __ret = \ + __lll_futex_syscall64(nargs, futexp, op, val, timeout,\ + __VA_ARGS__); \ + __ret = __lll_futex_syscall_time_check (__ret, timeout); \ + if (__ret != 0) \ + __ret = __lll_futex_syscall(nargs, futexp, op, val, \ + timeout != NULL ? &__ts32 : NULL, \ + __VA_ARGS__); \ + __ret; \ + }) + +# define lll_futex_syscall_time64_4(nargs, futexp, op, val, timeout)\ + ({ \ + struct timespec __ts32; \ + if (timeout != NULL) \ + __ts32 = valid_timespec64_to_timespec (*((struct __timespec64*) timeout)); \ + long int __ret = \ + __lll_futex_syscall64(nargs, futexp, op, val, timeout); \ + __ret = __lll_futex_syscall_time_check (__ret, timeout); \ + if (__ret != 0) \ + __ret = __lll_futex_syscall(nargs, futexp, op, val, \ + timeout != NULL ? &__ts32 : NULL); \ + __ret; \ + }) + +# endif /* For most of these macros, the return value is never really used. Nevertheless, the protocol is that each one returns a negated errno code for failure or zero for success. (Note that the corresponding @@ -85,7 +153,7 @@ lll_futex_timed_wait (futexp, val, NULL, private) # define lll_futex_timed_wait(futexp, val, timeout, private) \ - lll_futex_syscall (4, futexp, \ + lll_futex_syscall_time64_4 (4, futexp, \ __lll_private_flag (FUTEX_WAIT, private), \ val, timeout) @@ -107,7 +175,7 @@ const int op = \ __lll_private_flag (FUTEX_WAIT_BITSET | clockbit, private); \ \ - __ret = lll_futex_syscall (6, futexp, op, val, \ + __ret = lll_futex_syscall_time64 (6, futexp, op, val, \ timeout, NULL /* Unused. */, \ FUTEX_BITSET_MATCH_ANY); \ } \ @@ -118,7 +186,7 @@ /* Wake up up to NR waiters on FUTEXP. */ # define lll_futex_wake(futexp, nr, private) \ - lll_futex_syscall (4, futexp, \ + lll_futex_syscall_time64_4 (4, futexp, \ __lll_private_flag (FUTEX_WAKE, private), nr, 0) /* Wake up up to NR_WAKE waiters on FUTEXP. Move up to NR_MOVE of the @@ -159,7 +227,7 @@ /* Like lll_futex_wait_requeue_pi, but with a timeout. */ # define lll_futex_timed_wait_requeue_pi(futexp, val, timeout, clockbit, \ mutex, private) \ - lll_futex_syscall (5, futexp, \ + lll_futex_syscall_time64 (5, futexp, \ __lll_private_flag (FUTEX_WAIT_REQUEUE_PI \ | (clockbit), private), \ val, timeout, mutex) diff --git a/sysdeps/nptl/lowlevellock.h b/sysdeps/nptl/lowlevellock.h index 68b3be8819..864152e609 100644 --- a/sysdeps/nptl/lowlevellock.h +++ b/sysdeps/nptl/lowlevellock.h @@ -123,7 +123,7 @@ extern void __lll_lock_wait (int *futex, int private) attribute_hidden; extern int __lll_clocklock_wait (int *futex, int val, clockid_t, - const struct timespec *, + const struct __timespec64 *, int private) attribute_hidden; #define lll_timedwait(futex, val, clockid, abstime, private) \ From patchwork Tue Jul 7 15:08:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 39937 X-Patchwork-Delegate: l.majewski@majess.pl Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CA92D3861024; Tue, 7 Jul 2020 15:08:54 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [IPv6:2001:a60:0:28:0:1:25:1]) by sourceware.org (Postfix) with ESMTPS id 96F4B3861024 for ; Tue, 7 Jul 2020 15:08:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 96F4B3861024 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4B1QnH5Ll7z1rxMS; Tue, 7 Jul 2020 17:08:51 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4B1QnH47hKz1r576; Tue, 7 Jul 2020 17:08:51 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id pVsHJMjTmWKl; Tue, 7 Jul 2020 17:08:50 +0200 (CEST) X-Auth-Info: KRC90JcSnmyrpyTgJ/yIfQcwryK2qoI+rcI4syYZRfk= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 7 Jul 2020 17:08:49 +0200 (CEST) From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Subject: [RFC 04/10] y2038: Replace struct timespec with __timespec64 in futex-internal.h Date: Tue, 7 Jul 2020 17:08:21 +0200 Message-Id: <20200707150827.20899-5-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200707150827.20899-1-lukma@denx.de> References: <20200707150827.20899-1-lukma@denx.de> MIME-Version: 1.0 X-Spam-Status: No, score=-20.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Weimer , GNU C Library , Andreas Schwab , Stepan Golosunov , Alistair Francis Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This patch set replaces all occurences of struct timespec with __timespec64 in futex-internal.h header. --- sysdeps/nptl/futex-internal.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sysdeps/nptl/futex-internal.h b/sysdeps/nptl/futex-internal.h index d622122ddc..e23a954e73 100644 --- a/sysdeps/nptl/futex-internal.h +++ b/sysdeps/nptl/futex-internal.h @@ -211,7 +211,7 @@ futex_wait_cancelable (unsigned int *futex_word, unsigned int expected, */ static __always_inline int futex_reltimed_wait (unsigned int* futex_word, unsigned int expected, - const struct timespec* reltime, int private) + const struct __timespec64* reltime, int private) { int err = lll_futex_timed_wait (futex_word, expected, reltime, private); switch (err) @@ -237,7 +237,7 @@ futex_reltimed_wait (unsigned int* futex_word, unsigned int expected, static __always_inline int futex_reltimed_wait_cancelable (unsigned int* futex_word, unsigned int expected, - const struct timespec* reltime, int private) + const struct __timespec64* reltime, int private) { int oldtype; oldtype = LIBC_CANCEL_ASYNC (); @@ -275,7 +275,7 @@ futex_abstimed_supported_clockid (clockid_t clockid) static __always_inline int futex_abstimed_wait (unsigned int* futex_word, unsigned int expected, clockid_t clockid, - const struct timespec* abstime, int private) + const struct __timespec64* abstime, int private) { /* Work around the fact that the kernel rejects negative timeout values despite them being valid. */ @@ -309,7 +309,7 @@ static __always_inline int futex_abstimed_wait_cancelable (unsigned int* futex_word, unsigned int expected, clockid_t clockid, - const struct timespec* abstime, int private) + const struct __timespec64* abstime, int private) { /* Work around the fact that the kernel rejects negative timeout values despite them being valid. */ @@ -406,7 +406,7 @@ futex_wake (unsigned int* futex_word, int processes_to_wake, int private) - ETIMEDOUT if the ABSTIME expires. */ static __always_inline int -futex_lock_pi (unsigned int *futex_word, const struct timespec *abstime, +futex_lock_pi (unsigned int *futex_word, const struct __timespec64 *abstime, int private) { int err = lll_futex_timed_lock_pi (futex_word, abstime, private); From patchwork Tue Jul 7 15:08:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 39939 X-Patchwork-Delegate: l.majewski@majess.pl Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F3C03386190B; Tue, 7 Jul 2020 15:08:59 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by sourceware.org (Postfix) with ESMTPS id D31FF3861899 for ; Tue, 7 Jul 2020 15:08:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D31FF3861899 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4B1QnL6qmsz1qskc; Tue, 7 Jul 2020 17:08:54 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4B1QnL5kxlz1r573; Tue, 7 Jul 2020 17:08:54 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id U36dFG6TRHp7; Tue, 7 Jul 2020 17:08:51 +0200 (CEST) X-Auth-Info: 7W3TF87l8UI9BwwZmN15zaerxWMCGun9J/FPtoSxNBQ= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 7 Jul 2020 17:08:51 +0200 (CEST) From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Subject: [RFC 05/10] y2038: Convert pthread_* functions to support 64 bit time Date: Tue, 7 Jul 2020 17:08:22 +0200 Message-Id: <20200707150827.20899-6-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200707150827.20899-1-lukma@denx.de> References: <20200707150827.20899-1-lukma@denx.de> MIME-Version: 1.0 X-Spam-Status: No, score=-20.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Weimer , GNU C Library , Andreas Schwab , Stepan Golosunov , Alistair Francis Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Following function are converted to support 64 bit abstime parameter on archs with __TIMESIZE != 64 and __WORDSIZE == 32: pthread_cond_timedwait pthread_cond_clockwait pthread_mutex_clocklock pthread_mutex_timedlock pthread_clockjoin_np pthread_timedjoin_np pthread_rwlock_clockrdlock pthread_rwlock_clockwrlock pthread_rwlock_timedrdlock pthread_rwlock_timedwrlock --- nptl/pthreadP.h | 53 ++++++++++++++++++++++++++++++- nptl/pthread_clockjoin.c | 22 +++++++++++-- nptl/pthread_cond_wait.c | 46 +++++++++++++++++++++++---- nptl/pthread_join_common.c | 11 ++++--- nptl/pthread_mutex_timedlock.c | 39 ++++++++++++++++++----- nptl/pthread_rwlock_clockrdlock.c | 21 ++++++++++-- nptl/pthread_rwlock_clockwrlock.c | 21 ++++++++++-- nptl/pthread_rwlock_common.c | 4 +-- nptl/pthread_rwlock_timedrdlock.c | 21 ++++++++++-- nptl/pthread_rwlock_timedwrlock.c | 21 ++++++++++-- nptl/pthread_timedjoin.c | 20 ++++++++++-- 11 files changed, 245 insertions(+), 34 deletions(-) diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index 6f94d6be31..cab4adf4a1 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -458,6 +458,57 @@ extern int __pthread_cond_init (pthread_cond_t *cond, libc_hidden_proto (__pthread_cond_init) extern int __pthread_cond_signal (pthread_cond_t *cond); extern int __pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex); + +#if __TIMESIZE == 64 +# define __pthread_cond_timedwait64 __pthread_cond_timedwait +# define __pthread_cond_clockwait64 __pthread_cond_clockwait +# define __pthread_mutex_clocklock64 __pthread_mutex_clocklock +# define __pthread_mutex_timedlock64 __pthread_mutex_timedlock +# define __pthread_clockjoin_np64 __pthread_clockjoin_np +# define __pthread_timedjoin_np64 __pthread_timedjoin_np +# define __pthread_rwlock_clockrdlock64 __pthread_rwlock_clockrdlock +# define __pthread_rwlock_clockwrlock64 __pthread_rwlock_clockwrlock +# define __pthread_rwlock_timedrdlock64 __pthread_rwlock_timedrdlock +# define __pthread_rwlock_timedwrlock64 __pthread_rwlock_timedwrlock +#else +extern int __pthread_cond_timedwait64 (pthread_cond_t *cond, + pthread_mutex_t *mutex, + const struct __timespec64 *abstime); +libc_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); +libc_hidden_proto (__pthread_cond_clockwait64) +extern int __pthread_mutex_clocklock64 (pthread_mutex_t *mutex, + clockid_t clockid, + const struct __timespec64 *abstime); +libc_hidden_proto (__pthread_mutex_clocklock64) +extern int __pthread_mutex_timedlock64 (pthread_mutex_t *mutex, + const struct __timespec64 *abstime); +libc_hidden_proto (__pthread_mutex_timedlock64) +extern int __pthread_clockjoin_np64 (pthread_t threadid, void **thread_return, + clockid_t clockid, + const struct __timespec64 *abstime); +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_rwlock_clockrdlock64 (pthread_rwlock_t *rwlock, + clockid_t clockid, + const struct __timespec64 *abstime); +libc_hidden_proto (__pthread_rwlock_clockrdlock64) +extern int __pthread_rwlock_clockwrlock64 (pthread_rwlock_t *rwlock, + clockid_t clockid, + const struct __timespec64 *abstime); +libc_hidden_proto (__pthread_rwlock_clockwrlock64) +extern int __pthread_rwlock_timedrdlock64 (pthread_rwlock_t *rwlock, + const struct __timespec64 *abstime); +libc_hidden_proto (__pthread_rwlock_timedrdlock64) +extern int __pthread_rwlock_timedwrlock64 (pthread_rwlock_t *rwlock, + const struct __timespec64 *abstime); +libc_hidden_proto (__pthread_rwlock_timedwrlock64) +#endif extern int __pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime); @@ -488,7 +539,7 @@ extern int __pthread_enable_asynccancel (void) attribute_hidden; extern void __pthread_disable_asynccancel (int oldtype) attribute_hidden; extern void __pthread_testcancel (void); extern int __pthread_clockjoin_ex (pthread_t, void **, clockid_t, - const struct timespec *, bool) + const struct __timespec64 *, bool) attribute_hidden; extern int __pthread_sigmask (int, const sigset_t *, sigset_t *); libc_hidden_proto (__pthread_sigmask); diff --git a/nptl/pthread_clockjoin.c b/nptl/pthread_clockjoin.c index a3e7f37e3b..c3a92e5e0b 100644 --- a/nptl/pthread_clockjoin.c +++ b/nptl/pthread_clockjoin.c @@ -16,14 +16,32 @@ License along with the GNU C Library; if not, see . */ +#include #include "pthreadP.h" +int +__pthread_clockjoin_np64 (pthread_t threadid, void **thread_return, + clockid_t clockid, + const struct __timespec64 *abstime) +{ + return __pthread_clockjoin_ex (threadid, thread_return, + clockid, abstime, true); +} + +#if __TIMESIZE != 64 +libc_hidden_def (__pthread_clockjoin_np64) + int __pthread_clockjoin_np (pthread_t threadid, void **thread_return, clockid_t clockid, const struct timespec *abstime) { - return __pthread_clockjoin_ex (threadid, thread_return, - clockid, abstime, true); + struct __timespec64 ts64; + if (abstime != NULL) + ts64 = valid_timespec_to_timespec64 (*abstime); + + return __pthread_clockjoin_np64 (threadid, thread_return, + clockid, abstime != NULL ? &ts64 : NULL); } +#endif weak_alias (__pthread_clockjoin_np, pthread_clockjoin_np) diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c index 85ddbc1011..69b18b1316 100644 --- a/nptl/pthread_cond_wait.c +++ b/nptl/pthread_cond_wait.c @@ -379,7 +379,7 @@ __condvar_cleanup_waiting (void *arg) static __always_inline int __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex, clockid_t clockid, - const struct timespec *abstime) + const struct __timespec64 *abstime) { const int maxspin = 0; int err; @@ -640,8 +640,8 @@ __pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex) /* See __pthread_cond_wait_common. */ int -__pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex, - const struct timespec *abstime) +__pthread_cond_timedwait64 (pthread_cond_t *cond, pthread_mutex_t *mutex, + const struct __timespec64 *abstime) { /* Check parameter validity. This should also tell the compiler that it can assume that abstime is not NULL. */ @@ -655,6 +655,23 @@ __pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex, ? CLOCK_MONOTONIC : CLOCK_REALTIME; return __pthread_cond_wait_common (cond, mutex, clockid, abstime); } + +#if __TIMESIZE != 64 +libc_hidden_def (__pthread_cond_timedwait64) + +int +__pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex, + const struct timespec *abstime) +{ + struct __timespec64 ts64; + if (abstime != NULL) + ts64 = valid_timespec_to_timespec64 (*abstime); + + return __pthread_cond_timedwait64 (cond, mutex, + abstime != NULL ? &ts64 : NULL); +} +#endif + versioned_symbol (libpthread, __pthread_cond_wait, pthread_cond_wait, GLIBC_2_3_2); versioned_symbol (libpthread, __pthread_cond_timedwait, pthread_cond_timedwait, @@ -662,9 +679,9 @@ versioned_symbol (libpthread, __pthread_cond_timedwait, pthread_cond_timedwait, /* See __pthread_cond_wait_common. */ int -__pthread_cond_clockwait (pthread_cond_t *cond, pthread_mutex_t *mutex, - clockid_t clockid, - const struct timespec *abstime) +__pthread_cond_clockwait64 (pthread_cond_t *cond, pthread_mutex_t *mutex, + clockid_t clockid, + const struct __timespec64 *abstime) { /* Check parameter validity. This should also tell the compiler that it can assume that abstime is not NULL. */ @@ -676,4 +693,21 @@ __pthread_cond_clockwait (pthread_cond_t *cond, pthread_mutex_t *mutex, return __pthread_cond_wait_common (cond, mutex, clockid, abstime); } + +#if __TIMESIZE != 64 +libc_hidden_def (__pthread_cond_clockwait64) + +int +__pthread_cond_clockwait (pthread_cond_t *cond, pthread_mutex_t *mutex, + clockid_t clockid, + const struct timespec *abstime) +{ + struct __timespec64 ts64; + if (abstime != NULL) + ts64 = valid_timespec_to_timespec64 (*abstime); + + return __pthread_cond_clockwait64(cond, mutex, clockid, + abstime != NULL ? &ts64 : NULL); +} +#endif weak_alias (__pthread_cond_clockwait, pthread_cond_clockwait); diff --git a/nptl/pthread_join_common.c b/nptl/pthread_join_common.c index a96ceafde4..38a078fd23 100644 --- a/nptl/pthread_join_common.c +++ b/nptl/pthread_join_common.c @@ -37,7 +37,8 @@ cleanup (void *arg) afterwards. The kernel up to version 3.16.3 does not use the private futex operations for futex wake-up when the clone terminates. */ static int -clockwait_tid (pid_t *tidp, clockid_t clockid, const struct timespec *abstime) +clockwait_tid (pid_t *tidp, clockid_t clockid, + const struct __timespec64 *abstime) { pid_t tid; @@ -47,11 +48,11 @@ clockwait_tid (pid_t *tidp, clockid_t clockid, const struct timespec *abstime) /* Repeat until thread terminated. */ while ((tid = *tidp) != 0) { - struct timespec rt; + struct __timespec64 rt; /* Get the current time. This can only fail if clockid is invalid. */ - if (__glibc_unlikely (__clock_gettime (clockid, &rt))) + if (__glibc_unlikely (__clock_gettime64 (clockid, &rt))) return EINVAL; /* Compute relative timeout. */ @@ -80,8 +81,8 @@ clockwait_tid (pid_t *tidp, clockid_t clockid, const struct timespec *abstime) int __pthread_clockjoin_ex (pthread_t threadid, void **thread_return, - clockid_t clockid, - const struct timespec *abstime, bool block) + clockid_t clockid, + const struct __timespec64 *abstime, bool block) { struct pthread *pd = (struct pthread *) threadid; diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c index 8ae814b984..2438c61aa4 100644 --- a/nptl/pthread_mutex_timedlock.c +++ b/nptl/pthread_mutex_timedlock.c @@ -45,7 +45,7 @@ int __pthread_mutex_clocklock_common (pthread_mutex_t *mutex, clockid_t clockid, - const struct timespec *abstime) + const struct __timespec64 *abstime) { int oldval; pid_t id = THREAD_GETMEM (THREAD_SELF, tid); @@ -543,10 +543,10 @@ __pthread_mutex_clocklock_common (pthread_mutex_t *mutex, goto failpp; } - struct timespec rt; + struct __timespec64 rt; /* Get the current time. */ - __clock_gettime (CLOCK_REALTIME, &rt); + __clock_gettime64 (CLOCK_REALTIME, &rt); /* Compute relative timeout. */ rt.tv_sec = abstime->tv_sec - rt.tv_sec; @@ -599,9 +599,9 @@ __pthread_mutex_clocklock_common (pthread_mutex_t *mutex, } int -__pthread_mutex_clocklock (pthread_mutex_t *mutex, - clockid_t clockid, - const struct timespec *abstime) +__pthread_mutex_clocklock64 (pthread_mutex_t *mutex, + clockid_t clockid, + const struct __timespec64 *abstime) { if (__glibc_unlikely (!lll_futex_supported_clockid (clockid))) return EINVAL; @@ -609,13 +609,36 @@ __pthread_mutex_clocklock (pthread_mutex_t *mutex, LIBC_PROBE (mutex_clocklock_entry, 3, mutex, clockid, abstime); return __pthread_mutex_clocklock_common (mutex, clockid, abstime); } + +#if __TIMESIZE != 64 +libc_hidden_def (__pthread_mutex_clocklock64) +int +__pthread_mutex_clocklock (pthread_mutex_t *mutex, + clockid_t clockid, + const struct timespec *abstime) +{ + struct __timespec64 ts64 = valid_timespec_to_timespec64 (*abstime); + return __pthread_mutex_clocklock64 (mutex, clockid, &ts64); +} +#endif weak_alias (__pthread_mutex_clocklock, pthread_mutex_clocklock) int -__pthread_mutex_timedlock (pthread_mutex_t *mutex, - const struct timespec *abstime) +__pthread_mutex_timedlock64 (pthread_mutex_t *mutex, + const struct __timespec64 *abstime) { LIBC_PROBE (mutex_timedlock_entry, 2, mutex, abstime); return __pthread_mutex_clocklock_common (mutex, CLOCK_REALTIME, abstime); } + +#if __TIMESIZE != 64 +libc_hidden_def (__pthread_mutex_timedlock64) +int +__pthread_mutex_timedlock (pthread_mutex_t *mutex, + const struct timespec *abstime) +{ + struct __timespec64 ts64 = valid_timespec_to_timespec64 (*abstime); + return __pthread_mutex_timedlock64 (mutex, &ts64); +} +#endif weak_alias (__pthread_mutex_timedlock, pthread_mutex_timedlock) diff --git a/nptl/pthread_rwlock_clockrdlock.c b/nptl/pthread_rwlock_clockrdlock.c index 4cedfd1dcd..bb0a0b0d16 100644 --- a/nptl/pthread_rwlock_clockrdlock.c +++ b/nptl/pthread_rwlock_clockrdlock.c @@ -21,8 +21,25 @@ /* See pthread_rwlock_common.c. */ int -pthread_rwlock_clockrdlock (pthread_rwlock_t *rwlock, clockid_t clockid, - const struct timespec *abstime) +__pthread_rwlock_clockrdlock64 (pthread_rwlock_t *rwlock, clockid_t clockid, + const struct __timespec64 *abstime) { return __pthread_rwlock_rdlock_full (rwlock, clockid, abstime); } + +#if __TIMESIZE != 64 +libc_hidden_def (__pthread_rwlock_clockrdlock64) + +int +__pthread_rwlock_clockrdlock (pthread_rwlock_t *rwlock, clockid_t clockid, + const struct timespec *abstime) +{ + struct __timespec64 ts64; + if (abstime != NULL) + ts64 = valid_timespec_to_timespec64 (*abstime); + + return __pthread_rwlock_clockrdlock64 (rwlock, clockid, + abstime != NULL ? &ts64 : NULL); +} +#endif +weak_alias (__pthread_rwlock_clockrdlock, pthread_rwlock_clockrdlock) diff --git a/nptl/pthread_rwlock_clockwrlock.c b/nptl/pthread_rwlock_clockwrlock.c index 7a954cf529..742fa04dbc 100644 --- a/nptl/pthread_rwlock_clockwrlock.c +++ b/nptl/pthread_rwlock_clockwrlock.c @@ -21,8 +21,25 @@ /* See pthread_rwlock_common.c. */ int -pthread_rwlock_clockwrlock (pthread_rwlock_t *rwlock, clockid_t clockid, - const struct timespec *abstime) +__pthread_rwlock_clockwrlock64 (pthread_rwlock_t *rwlock, clockid_t clockid, + const struct __timespec64 *abstime) { return __pthread_rwlock_wrlock_full (rwlock, clockid, abstime); } + +#if __TIMESIZE != 64 +libc_hidden_def (__pthread_rwlock_clockwrlock64) + +int +__pthread_rwlock_clockwrlock (pthread_rwlock_t *rwlock, clockid_t clockid, + const struct timespec *abstime) +{ + struct __timespec64 ts64; + if (abstime != NULL) + ts64 = valid_timespec_to_timespec64 (*abstime); + + return __pthread_rwlock_clockwrlock64 (rwlock, clockid, + abstime != NULL ? &ts64 : NULL); +} +#endif +weak_alias (__pthread_rwlock_clockwrlock, pthread_rwlock_clockwrlock) diff --git a/nptl/pthread_rwlock_common.c b/nptl/pthread_rwlock_common.c index 3fbc66ded2..438cf2f74c 100644 --- a/nptl/pthread_rwlock_common.c +++ b/nptl/pthread_rwlock_common.c @@ -280,7 +280,7 @@ __pthread_rwlock_rdunlock (pthread_rwlock_t *rwlock) static __always_inline int __pthread_rwlock_rdlock_full (pthread_rwlock_t *rwlock, clockid_t clockid, - const struct timespec *abstime) + const struct __timespec64 *abstime) { unsigned int r; @@ -587,7 +587,7 @@ __pthread_rwlock_wrunlock (pthread_rwlock_t *rwlock) static __always_inline int __pthread_rwlock_wrlock_full (pthread_rwlock_t *rwlock, clockid_t clockid, - const struct timespec *abstime) + const struct __timespec64 *abstime) { /* Make sure any passed in clockid and timeout value are valid. Note that the previous implementation assumed that this check *must* not be diff --git a/nptl/pthread_rwlock_timedrdlock.c b/nptl/pthread_rwlock_timedrdlock.c index c5d8aee909..7e808439a6 100644 --- a/nptl/pthread_rwlock_timedrdlock.c +++ b/nptl/pthread_rwlock_timedrdlock.c @@ -20,8 +20,25 @@ /* See pthread_rwlock_common.c. */ int -pthread_rwlock_timedrdlock (pthread_rwlock_t *rwlock, - const struct timespec *abstime) +__pthread_rwlock_timedrdlock64 (pthread_rwlock_t *rwlock, + const struct __timespec64 *abstime) { return __pthread_rwlock_rdlock_full (rwlock, CLOCK_REALTIME, abstime); } + +#if __TIMESIZE != 64 +libc_hidden_def (__pthread_rwlock_timedrdlock64) + +int +__pthread_rwlock_timedrdlock (pthread_rwlock_t *rwlock, + const struct timespec *abstime) +{ + struct __timespec64 ts64; + if (abstime != NULL) + ts64 = valid_timespec_to_timespec64 (*abstime); + + return __pthread_rwlock_timedrdlock64 (rwlock, + abstime != NULL ? &ts64 : NULL); +} +#endif +weak_alias (__pthread_rwlock_timedrdlock, pthread_rwlock_timedrdlock) diff --git a/nptl/pthread_rwlock_timedwrlock.c b/nptl/pthread_rwlock_timedwrlock.c index ccee8b77d9..8160c18819 100644 --- a/nptl/pthread_rwlock_timedwrlock.c +++ b/nptl/pthread_rwlock_timedwrlock.c @@ -20,8 +20,25 @@ /* See pthread_rwlock_common.c. */ int -pthread_rwlock_timedwrlock (pthread_rwlock_t *rwlock, - const struct timespec *abstime) +__pthread_rwlock_timedwrlock64 (pthread_rwlock_t *rwlock, + const struct __timespec64 *abstime) { return __pthread_rwlock_wrlock_full (rwlock, CLOCK_REALTIME, abstime); } + +#if __TIMESIZE != 64 +libc_hidden_def (__pthread_rwlock_timedwrlock64) + +int +__pthread_rwlock_timedwrlock (pthread_rwlock_t *rwlock, + const struct timespec *abstime) +{ + struct __timespec64 ts64; + if (abstime != NULL) + ts64 = valid_timespec_to_timespec64 (*abstime); + + return __pthread_rwlock_timedwrlock64 (rwlock, + abstime != NULL ? &ts64 : NULL); +} +#endif +weak_alias (__pthread_rwlock_timedwrlock, pthread_rwlock_timedwrlock) diff --git a/nptl/pthread_timedjoin.c b/nptl/pthread_timedjoin.c index dd7038dcf7..a6c2bbae53 100644 --- a/nptl/pthread_timedjoin.c +++ b/nptl/pthread_timedjoin.c @@ -19,10 +19,26 @@ #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; + if (abstime != NULL) + ts64 = valid_timespec_to_timespec64 (*abstime); + + return __pthread_timedjoin_np64 (threadid, thread_return, + abstime != NULL ? &ts64 : NULL); +} +#endif weak_alias (__pthread_timedjoin_np, pthread_timedjoin_np) From patchwork Tue Jul 7 15:08:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 39940 X-Patchwork-Delegate: l.majewski@majess.pl Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 55712386190E; Tue, 7 Jul 2020 15:09:00 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by sourceware.org (Postfix) with ESMTPS id 89EF9385EC56 for ; Tue, 7 Jul 2020 15:08:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 89EF9385EC56 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4B1QnP3vkHz1rxb9; Tue, 7 Jul 2020 17:08:57 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4B1QnP2r1vz1r574; Tue, 7 Jul 2020 17:08:57 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id hi3TMsBUOc2G; Tue, 7 Jul 2020 17:08:55 +0200 (CEST) X-Auth-Info: WYt8PdfF6aO3NXLkKS2yCCCfUy+O2iHGRq1e6uRDk/Y= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 7 Jul 2020 17:08:55 +0200 (CEST) From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Subject: [RFC 06/10] y2038: Convert sem_{timed|clock}wait to support 64 bit timeout Date: Tue, 7 Jul 2020 17:08:23 +0200 Message-Id: <20200707150827.20899-7-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200707150827.20899-1-lukma@denx.de> References: <20200707150827.20899-1-lukma@denx.de> MIME-Version: 1.0 X-Spam-Status: No, score=-20.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Weimer , GNU C Library , Andreas Schwab , Stepan Golosunov , Alistair Francis Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The conversion was to: - Replace struct timespec with struct __timespec64 - Provide aliases to __sem_* functions - Introduce Y2038 safe versions of __sem_timedwait64 and __sem_clockwait64 --- nptl/sem_clockwait.c | 21 +++++++++++++++++++-- nptl/sem_timedwait.c | 18 +++++++++++++++++- nptl/sem_waitcommon.c | 4 ++-- nptl/semaphoreP.h | 12 ++++++++++++ 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/nptl/sem_clockwait.c b/nptl/sem_clockwait.c index b9bae75183..86ce18ee2b 100644 --- a/nptl/sem_clockwait.c +++ b/nptl/sem_clockwait.c @@ -20,10 +20,11 @@ #include #include "sem_waitcommon.c" +#include "semaphoreP.h" int -sem_clockwait (sem_t *sem, clockid_t clockid, - const struct timespec *abstime) +__sem_clockwait64 (sem_t *sem, clockid_t clockid, + const struct __timespec64 *abstime) { /* Check that supplied clockid is one we support, even if we don't end up waiting. */ @@ -44,3 +45,19 @@ sem_clockwait (sem_t *sem, clockid_t clockid, else return __new_sem_wait_slow ((struct new_sem *) sem, clockid, abstime); } + +#if __TIMESIZE != 64 +libc_hidden_def (__sem_timedwait64) + +int +__sem_clockwait (sem_t *sem, clockid_t clockid, + const struct timespec *abstime) +{ + struct __timespec64 ts64; + if (abstime != NULL) + ts64 = valid_timespec_to_timespec64 (*abstime); + + return __sem_clockwait64 (sem, clockid, abstime != NULL ? &ts64 : NULL); +} +#endif +weak_alias (__sem_clockwait, sem_clockwait) diff --git a/nptl/sem_timedwait.c b/nptl/sem_timedwait.c index 99c11bf20e..0ffb56ec67 100644 --- a/nptl/sem_timedwait.c +++ b/nptl/sem_timedwait.c @@ -19,11 +19,12 @@ #include #include "sem_waitcommon.c" +#include "semaphoreP.h" /* This is in a separate file because because sem_timedwait is only provided if __USE_XOPEN2K is defined. */ int -sem_timedwait (sem_t *sem, const struct timespec *abstime) +__sem_timedwait64 (sem_t *sem, const struct __timespec64 *abstime) { if (! valid_nanoseconds (abstime->tv_nsec)) { @@ -40,3 +41,18 @@ sem_timedwait (sem_t *sem, const struct timespec *abstime) return __new_sem_wait_slow ((struct new_sem *) sem, CLOCK_REALTIME, abstime); } + +#if __TIMESIZE != 64 +libc_hidden_def (__sem_timedwait64) + +int +__sem_timedwait (sem_t *sem, const struct timespec *abstime) +{ + struct __timespec64 ts64; + if (abstime != NULL) + ts64 = valid_timespec_to_timespec64 (*abstime); + + return __sem_timedwait64 (sem, abstime != NULL ? &ts64 : NULL); +} +#endif +weak_alias (__sem_timedwait, sem_timedwait) diff --git a/nptl/sem_waitcommon.c b/nptl/sem_waitcommon.c index 5a6d2643ee..7fdc084d53 100644 --- a/nptl/sem_waitcommon.c +++ b/nptl/sem_waitcommon.c @@ -104,7 +104,7 @@ __sem_wait_cleanup (void *arg) static int __attribute__ ((noinline)) do_futex_wait (struct new_sem *sem, clockid_t clockid, - const struct timespec *abstime) + const struct __timespec64 *abstime) { int err; @@ -163,7 +163,7 @@ __new_sem_wait_fast (struct new_sem *sem, int definitive_result) static int __attribute__ ((noinline)) __new_sem_wait_slow (struct new_sem *sem, clockid_t clockid, - const struct timespec *abstime) + const struct __timespec64 *abstime) { int err = 0; diff --git a/nptl/semaphoreP.h b/nptl/semaphoreP.h index e7e1c9763f..9023ea5573 100644 --- a/nptl/semaphoreP.h +++ b/nptl/semaphoreP.h @@ -17,6 +17,7 @@ . */ #include +#include #include "pthreadP.h" #define SEM_SHM_PREFIX "sem." @@ -52,3 +53,14 @@ extern int __new_sem_wait (sem_t *sem); extern int __old_sem_wait (sem_t *sem); extern int __new_sem_trywait (sem_t *sem); extern int __new_sem_getvalue (sem_t *sem, int *sval); + +#if __TIMESIZE == 64 +# define __sem_timedwait64 __sem_timedwait +# define __sem_clockwait64 __sem_clockwait +#else +extern int __sem_timedwait64 (sem_t *sem, const struct __timespec64 *abstime); +libc_hidden_proto (__sem_timedwait64) +extern int __sem_clockwait64 (sem_t *sem, clockid_t clockid, + const struct __timespec64 *abstime); +libc_hidden_proto (__sem_clockwait64) +#endif From patchwork Tue Jul 7 15:08:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 39941 X-Patchwork-Delegate: l.majewski@majess.pl Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B02993861899; Tue, 7 Jul 2020 15:09:02 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by sourceware.org (Postfix) with ESMTPS id 454D93861919 for ; Tue, 7 Jul 2020 15:09:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 454D93861919 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4B1QnR2b8Qz1rxbc; Tue, 7 Jul 2020 17:08:59 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4B1QnR1GNGz1r574; Tue, 7 Jul 2020 17:08:59 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id rYrDP8DtHJNr; Tue, 7 Jul 2020 17:08:57 +0200 (CEST) X-Auth-Info: yP6oDefHa2zUb6uovc1ejLcZIXVN/qhiCv9vt3Zb1+M= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 7 Jul 2020 17:08:57 +0200 (CEST) From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Subject: [RFC 07/10] y2038: Convert __lll_clocklock_wait function to support 64 bit time Date: Tue, 7 Jul 2020 17:08:24 +0200 Message-Id: <20200707150827.20899-8-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200707150827.20899-1-lukma@denx.de> References: <20200707150827.20899-1-lukma@denx.de> MIME-Version: 1.0 X-Spam-Status: No, score=-20.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Weimer , GNU C Library , Andreas Schwab , Stepan Golosunov , Alistair Francis Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Prepare the internal __lll_clocklock_wait function to support 64 bit time on architectures, with __TIMESIZE != 64 and __WORDSIZE == 32 by replacing struct timespec with struct __timespec64 and __clock_gettime with __clock_gettime64. --- nptl/lll_timedlock_wait.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nptl/lll_timedlock_wait.c b/nptl/lll_timedlock_wait.c index eabdca70c8..82cd76e557 100644 --- a/nptl/lll_timedlock_wait.c +++ b/nptl/lll_timedlock_wait.c @@ -26,9 +26,9 @@ int __lll_clocklock_wait (int *futex, int val, clockid_t clockid, - const struct timespec *abstime, int private) + const struct __timespec64 *abstime, int private) { - struct timespec ts, *tsp = NULL; + struct __timespec64 ts, *tsp = NULL; if (abstime != NULL) { @@ -37,7 +37,7 @@ __lll_clocklock_wait (int *futex, int val, clockid_t clockid, return EINVAL; /* Get the current time. This can only fail if clockid is not valid. */ - if (__glibc_unlikely (__clock_gettime (clockid, &ts) != 0)) + if (__glibc_unlikely (__clock_gettime64 (clockid, &ts) != 0)) return EINVAL; /* Compute relative timeout. */ From patchwork Tue Jul 7 15:08:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 39942 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 855CB386195C; Tue, 7 Jul 2020 15:09:05 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by sourceware.org (Postfix) with ESMTPS id 20C06386192B for ; Tue, 7 Jul 2020 15:09:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 20C06386192B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4B1QnV1gP4z1qskq; Tue, 7 Jul 2020 17:09:02 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4B1QnV1F6bz1r573; Tue, 7 Jul 2020 17:09:02 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id bFwMsGMsjW9X; Tue, 7 Jul 2020 17:08:59 +0200 (CEST) X-Auth-Info: PgIjgJVg75Xc2+eeyz24mhZrkbprBQG8GHIRoM9C5TU= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 7 Jul 2020 17:08:59 +0200 (CEST) From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Subject: [RFC 08/10] y2038: Convert aio_suspend to support 64 bit timeout Date: Tue, 7 Jul 2020 17:08:25 +0200 Message-Id: <20200707150827.20899-9-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200707150827.20899-1-lukma@denx.de> References: <20200707150827.20899-1-lukma@denx.de> MIME-Version: 1.0 X-Spam-Status: No, score=-19.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Weimer , GNU C Library , Andreas Schwab , Stepan Golosunov , Alistair Francis Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This patch converts aio_suspend function to support 64 bit timeout. This function internally uses futex syscall. --- sysdeps/nptl/aio_misc.h | 11 ++++++++++- sysdeps/pthread/aio_suspend.c | 36 ++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/sysdeps/nptl/aio_misc.h b/sysdeps/nptl/aio_misc.h index 3f195f4794..5f0ed58217 100644 --- a/sysdeps/nptl/aio_misc.h +++ b/sysdeps/nptl/aio_misc.h @@ -23,6 +23,7 @@ #include #include #include +#include #define DONT_NEED_AIO_MISC_COND 1 @@ -49,7 +50,7 @@ (unsigned int *) futexaddr, oldval, timeout, FUTEX_PRIVATE); \ else \ status = futex_reltimed_wait ((unsigned int *) futexaddr, \ - oldval, timeout, FUTEX_PRIVATE); \ + oldval, timeout, FUTEX_PRIVATE); \ if (status != EAGAIN) \ break; \ \ @@ -69,3 +70,11 @@ } while (0) #include_next + +#if __TIMESIZE == 64 +# define __aio_suspend64 __aio_suspend +#else +extern int __aio_suspend64 (const struct aiocb *const list[], int nent, + const struct __timespec64 *timeout); +libc_hidden_proto (__aio_suspend64) +#endif diff --git a/sysdeps/pthread/aio_suspend.c b/sysdeps/pthread/aio_suspend.c index ad03f13558..71e0dbceb1 100644 --- a/sysdeps/pthread/aio_suspend.c +++ b/sysdeps/pthread/aio_suspend.c @@ -94,7 +94,7 @@ cleanup (void *arg) #ifdef DONT_NEED_AIO_MISC_COND static int __attribute__ ((noinline)) -do_aio_misc_wait (unsigned int *cntr, const struct timespec *timeout) +do_aio_misc_wait (unsigned int *cntr, const struct __timespec64 *timeout) { int result = 0; @@ -104,9 +104,9 @@ do_aio_misc_wait (unsigned int *cntr, const struct timespec *timeout) } #endif -int -aio_suspend (const struct aiocb *const list[], int nent, - const struct timespec *timeout) +static int +__aio_suspend_common (const struct aiocb *const list[], int nent, + const struct __timespec64 *timeout) { if (__glibc_unlikely (nent < 0)) { @@ -183,10 +183,10 @@ aio_suspend (const struct aiocb *const list[], int nent, { /* We have to convert the relative timeout value into an absolute time value with pthread_cond_timedwait expects. */ - struct timespec now; - struct timespec abstime; + struct __timespec64 now; + struct __timespec64 abstime; - __clock_gettime (CLOCK_REALTIME, &now); + __clock_gettime64 (CLOCK_REALTIME, &now); abstime.tv_nsec = timeout->tv_nsec + now.tv_nsec; abstime.tv_sec = timeout->tv_sec + now.tv_sec; if (abstime.tv_nsec >= 1000000000) @@ -250,4 +250,26 @@ aio_suspend (const struct aiocb *const list[], int nent, return result; } +int +__aio_suspend64 (const struct aiocb *const list[], int nent, + const struct __timespec64 *timeout) +{ + return __aio_suspend_common (list, nent, timeout); +} + +#if __TIMESIZE != 64 +libc_hidden_def (__aio_suspend64) + +int +__aio_suspend (const struct aiocb *const list[], int nent, + const struct timespec *timeout) +{ + struct __timespec64 ts64; + if (timeout != NULL) + ts64 = valid_timespec_to_timespec64 (*timeout); + + return __aio_suspend64 (list, nent, timeout != NULL ? &ts64 : NULL); +} +#endif +weak_alias (__aio_suspend, aio_suspend) weak_alias (aio_suspend, aio_suspend64) From patchwork Tue Jul 7 15:08:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 39943 X-Patchwork-Delegate: l.majewski@majess.pl Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D9BBE3861960; Tue, 7 Jul 2020 15:09:06 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) by sourceware.org (Postfix) with ESMTPS id DF998386192B for ; Tue, 7 Jul 2020 15:09:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DF998386192B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4B1QnW74kYz1qskn; Tue, 7 Jul 2020 17:09:03 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4B1QnW6kKBz1r574; Tue, 7 Jul 2020 17:09:03 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id 3Lk7_hq1sHsH; Tue, 7 Jul 2020 17:09:02 +0200 (CEST) X-Auth-Info: dhkyYLRfOYL65zOMwAtDRSvqFNrSvigfpb6Ro1K9cl8= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 7 Jul 2020 17:09:02 +0200 (CEST) From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Subject: [RFC 09/10] y2038: Convert gai_suspend to support 64 bit timeout Date: Tue, 7 Jul 2020 17:08:26 +0200 Message-Id: <20200707150827.20899-10-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200707150827.20899-1-lukma@denx.de> References: <20200707150827.20899-1-lukma@denx.de> MIME-Version: 1.0 X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Weimer , GNU C Library , Andreas Schwab , Stepan Golosunov , Alistair Francis Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This patch converts gai_suspend to support 64 bit timeout. It uses internally futex syscall to achieve this goal. --- resolv/gai_misc.h | 7 +++++++ resolv/gai_suspend.c | 33 ++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/resolv/gai_misc.h b/resolv/gai_misc.h index 008d6a4ad6..4ac2a24859 100644 --- a/resolv/gai_misc.h +++ b/resolv/gai_misc.h @@ -97,4 +97,11 @@ extern int __gai_notify_only (struct sigevent *sigev, pid_t caller_pid) /* Send the signal. */ extern int __gai_sigqueue (int sig, const union sigval val, pid_t caller_pid); +# if __TIMESIZE == 64 +# define __gai_suspend64 __gai_suspend +# else +extern int __gai_suspend64 (const struct gaicb *const list[], int ent, + const struct __timespec64 *timeout); +libc_hidden_proto (__gai_suspend64) +# endif #endif /* gai_misc.h */ diff --git a/resolv/gai_suspend.c b/resolv/gai_suspend.c index 734f9b4500..79b183681d 100644 --- a/resolv/gai_suspend.c +++ b/resolv/gai_suspend.c @@ -26,8 +26,8 @@ int -gai_suspend (const struct gaicb *const list[], int ent, - const struct timespec *timeout) +__gai_suspend_common (const struct gaicb *const list[], int ent, + const struct __timespec64 *timeout) { struct waitlist waitlist[ent]; struct requestlist *requestlist[ent]; @@ -91,10 +91,10 @@ gai_suspend (const struct gaicb *const list[], int ent, { /* We have to convert the relative timeout value into an absolute time value with pthread_cond_timedwait expects. */ - struct timespec now; - struct timespec abstime; + struct __timespec64 now; + struct __timespec64 abstime; - __clock_gettime (CLOCK_REALTIME, &now); + __clock_gettime64 (CLOCK_REALTIME, &now); abstime.tv_nsec = timeout->tv_nsec + now.tv_nsec; abstime.tv_sec = timeout->tv_sec + now.tv_sec; if (abstime.tv_nsec >= 1000000000) @@ -155,3 +155,26 @@ gai_suspend (const struct gaicb *const list[], int ent, return result; } + +int +__gai_suspend64 (const struct gaicb *const list[], int ent, + const struct __timespec64 *timeout) +{ + return __gai_suspend_common (list, ent, timeout); +} + +#if __TIMESIZE != 64 +libc_hidden_def (__gai_suspend64) + +int +__gai_suspend (const struct gaicb *const list[], int ent, + const struct timespec *timeout) +{ + struct __timespec64 ts64; + if (timeout != NULL) + ts64 = valid_timespec_to_timespec64 (*timeout); + + return __gai_suspend64 (list, ent, timeout != NULL ? &ts64 : NULL); +} +#endif +weak_alias (__gai_suspend, gai_suspend) From patchwork Tue Jul 7 15:08:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 39944 X-Patchwork-Delegate: l.majewski@majess.pl Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 433BD3861959; Tue, 7 Jul 2020 15:09:09 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-out.m-online.net (mail-out.m-online.net [IPv6:2001:a60:0:28:0:1:25:1]) by sourceware.org (Postfix) with ESMTPS id 786BA3861959 for ; Tue, 7 Jul 2020 15:09:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 786BA3861959 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=lukma@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4B1QnY4pLwz1rxbC; Tue, 7 Jul 2020 17:09:05 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4B1QnY4V44z1r573; Tue, 7 Jul 2020 17:09:05 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id eKLKI4qhu4Jr; Tue, 7 Jul 2020 17:09:04 +0200 (CEST) X-Auth-Info: 47tq1Cb4FieKSOXE/j/QLxarnLvXeJ3QVYztKAYT98o= Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 7 Jul 2020 17:09:04 +0200 (CEST) From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Subject: [RFC 10/10] y2038: x86: Fix __lll_clocklock_elision to support 64 bit time Date: Tue, 7 Jul 2020 17:08:27 +0200 Message-Id: <20200707150827.20899-11-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200707150827.20899-1-lukma@denx.de> References: <20200707150827.20899-1-lukma@denx.de> MIME-Version: 1.0 X-Spam-Status: No, score=-19.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Weimer , GNU C Library , Andreas Schwab , Stepan Golosunov , Alistair Francis Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Adjust x86 specific code to use 64 bit struct __timespec64. --- sysdeps/unix/sysv/linux/x86/elision-timed.c | 2 +- sysdeps/unix/sysv/linux/x86/lowlevellock.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sysdeps/unix/sysv/linux/x86/elision-timed.c b/sysdeps/unix/sysv/linux/x86/elision-timed.c index 87e5c788c6..ac4d5f7858 100644 --- a/sysdeps/unix/sysv/linux/x86/elision-timed.c +++ b/sysdeps/unix/sysv/linux/x86/elision-timed.c @@ -20,7 +20,7 @@ #include #include "lowlevellock.h" #define __lll_lock_elision __lll_clocklock_elision -#define EXTRAARG clockid_t clockid, const struct timespec *t, +#define EXTRAARG clockid_t clockid, const struct __timespec64 *t, #undef LLL_LOCK #define LLL_LOCK(a, b) lll_clocklock (a, clockid, t, b) #include "elision-lock.c" diff --git a/sysdeps/unix/sysv/linux/x86/lowlevellock.h b/sysdeps/unix/sysv/linux/x86/lowlevellock.h index 27d62c9301..d0ea71b105 100644 --- a/sysdeps/unix/sysv/linux/x86/lowlevellock.h +++ b/sysdeps/unix/sysv/linux/x86/lowlevellock.h @@ -84,7 +84,7 @@ __lll_cas_lock (int *futex) extern int __lll_clocklock_elision (int *futex, short *adapt_count, clockid_t clockid, - const struct timespec *timeout, + const struct __timespec64 *timeout, int private) attribute_hidden; #define lll_clocklock_elision(futex, adapt_count, clockid, timeout, private) \