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)