From patchwork Tue Dec 1 09:44:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 41238 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 9767C393D039; Tue, 1 Dec 2020 09:45:28 +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 878A5393D01E for ; Tue, 1 Dec 2020 09:45:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 878A5393D01E 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 4Clcf95bn6z1rxwF; Tue, 1 Dec 2020 10:45:21 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4Clcf94KXqz1qtZG; Tue, 1 Dec 2020 10:45:21 +0100 (CET) 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 K6KoxUjxifMc; Tue, 1 Dec 2020 10:45:18 +0100 (CET) X-Auth-Info: CZugALXgco2NSNz6uRLaLhDa53QwHMkAnPJ/FGy++Ow= Received: from localhost.localdomain (89-64-5-98.dynamic.chello.pl [89.64.5.98]) (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, 1 Dec 2020 10:45:18 +0100 (CET) From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Subject: [PATCH 1/2] symbols: Add defines for libanl's libanl_hidden_{def|proto} Date: Tue, 1 Dec 2020 10:44:36 +0100 Message-Id: <20201201094437.23804-1-lukma@denx.de> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 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" The __gai_suspend_time64, which supports 64 bit time on ports with __WORDSIZE == 32 && __TIMESIZE != 64, shall be exported from libanl (the same library from which original gai_suspend is exported). Up till now there were no defines for this library. This commit adds them. --- include/libc-symbols.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/libc-symbols.h b/include/libc-symbols.h index b8103b98bb..154a73b5e5 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -879,6 +879,14 @@ for linking") # define libutil_hidden_data_ver(local, name) #endif +#if IS_IN (libanl) +# define libanl_hidden_proto(name, attrs...) hidden_proto (name, ##attrs) +# define libanl_hidden_def(name) hidden_def (name) +#else +# define libanl_hidden_proto(name, attrs...) +# define libanl_hidden_def(name) +#endif + /* Get some dirty hacks. */ #include From patchwork Tue Dec 1 09:44:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 41239 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 EEC653944800; Tue, 1 Dec 2020 09:45:28 +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 87A4F393D024 for ; Tue, 1 Dec 2020 09:45:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 87A4F393D024 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 4ClcfC4Rt6z1rxwf; Tue, 1 Dec 2020 10:45:23 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4ClcfC36Sjz1qtZF; Tue, 1 Dec 2020 10:45:23 +0100 (CET) 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 rG2V-lPQBh7K; Tue, 1 Dec 2020 10:45:21 +0100 (CET) X-Auth-Info: DU0PQsjmKB6FlKeinSBWesS5NPO01i0BehMyKT2urfs= Received: from localhost.localdomain (89-64-5-98.dynamic.chello.pl [89.64.5.98]) (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, 1 Dec 2020 10:45:21 +0100 (CET) From: Lukasz Majewski To: Joseph Myers , Paul Eggert , Adhemerval Zanella Subject: [PATCH 2/2] y2038: Convert gai_suspend to support 64 bit time Date: Tue, 1 Dec 2020 10:44:37 +0100 Message-Id: <20201201094437.23804-2-lukma@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201201094437.23804-1-lukma@denx.de> References: <20201201094437.23804-1-lukma@denx.de> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 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 change uses (in gai_misc.h): - __futex_abstimed_wait64 (instead of futex_reltimed_wait) - __futex_abstimed_wait_cancellable64 (instead of futex_reltimed_wait_cancellable) from ./sysdeps/nptl/futex-helpers.h The gai_suspend() accepts relative timeout, which then is converted to absolute one. The i686-gnu port (HURD) do not define DONT_NEED_GAI_MISC_COND and as it doesn't (yet) support 64 bit time it uses not converted pthread_cond_timedwait(). The __gai_suspend() is supposed to be run on ports with __TIMESIZE !=64 and __WORDSIZE==32. It internally utilizes __gai_suspend_time64() and hence the conversion from 32 bit struct timespec to 64 bit one is required. For ports supporting 64 bit time the __gai_suspend_time64() will be used either via alias (to __gai_suspend when __TIMESIZE==64) or redirection (when -D_TIME_BITS=64 is passed). Build tests: ./src/scripts/build-many-glibcs.py glibcs Reviewed-by: Adhemerval Zanella Reviewed-by: Alistair Francis --- include/netdb.h | 7 +++++ resolv/gai_suspend.c | 61 ++++++++++++++++++++++++----------------- sysdeps/nptl/gai_misc.h | 11 +++++--- 3 files changed, 50 insertions(+), 29 deletions(-) diff --git a/include/netdb.h b/include/netdb.h index 49d63c1338..645b85dc62 100644 --- a/include/netdb.h +++ b/include/netdb.h @@ -194,6 +194,13 @@ extern int ruserpass (const char *host, const char **aname, const char **apass); libc_hidden_proto (ruserpass) +# if __TIMESIZE == 64 +# define __gai_suspend_time64 __gai_suspend +# else +extern int __gai_suspend_time64 (const struct gaicb *const list[], int ent, + const struct __timespec64 *timeout); +libanl_hidden_proto (__gai_suspend_time64) +# endif /* The following definition has been removed from the public header since we don't want people to use them. */ diff --git a/resolv/gai_suspend.c b/resolv/gai_suspend.c index 734f9b4500..d75abeb7e3 100644 --- a/resolv/gai_suspend.c +++ b/resolv/gai_suspend.c @@ -24,10 +24,9 @@ #include - int -gai_suspend (const struct gaicb *const list[], int ent, - const struct timespec *timeout) +__gai_suspend_time64 (const struct gaicb *const list[], int ent, + const struct __timespec64 *timeout) { struct waitlist waitlist[ent]; struct requestlist *requestlist[ent]; @@ -63,6 +62,19 @@ gai_suspend (const struct gaicb *const list[], int ent, } } + struct __timespec64 ts; + if (timeout != NULL) + { + __clock_gettime64 (CLOCK_MONOTONIC, &ts); + ts.tv_sec += timeout->tv_sec; + ts.tv_nsec += timeout->tv_nsec; + if (ts.tv_nsec >= 1000000000) + { + ts.tv_nsec -= 1000000000; + ts.tv_sec++; + } + } + if (none) { if (cnt < ent) @@ -83,29 +95,11 @@ gai_suspend (const struct gaicb *const list[], int ent, #ifdef DONT_NEED_GAI_MISC_COND result = 0; - GAI_MISC_WAIT (result, cntr, timeout, 1); + GAI_MISC_WAIT (result, cntr, timeout == NULL ? NULL : &ts, 1); #else - if (timeout == NULL) - result = pthread_cond_wait (&cond, &__gai_requests_mutex); - else - { - /* We have to convert the relative timeout value into an - absolute time value with pthread_cond_timedwait expects. */ - struct timespec now; - struct timespec abstime; - - __clock_gettime (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) - { - abstime.tv_nsec -= 1000000000; - abstime.tv_sec += 1; - } - - result = pthread_cond_timedwait (&cond, &__gai_requests_mutex, - &abstime); - } + struct timespec ts32 = valid_timespec64_to_timespec (ts); + result = pthread_cond_timedwait (&cond, &__gai_requests_mutex, + timeout == NULL ? NULL : &ts32); #endif /* Now remove the entry in the waiting list for all requests @@ -155,3 +149,20 @@ gai_suspend (const struct gaicb *const list[], int ent, return result; } + +#if __TIMESIZE != 64 +libanl_hidden_def (__gai_suspend_time64) + +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_suspend_time64 (list, ent, timeout != NULL ? &ts64 : NULL); +} +#endif +weak_alias (__gai_suspend, gai_suspend) diff --git a/sysdeps/nptl/gai_misc.h b/sysdeps/nptl/gai_misc.h index c1d5e2e6f0..c72a863974 100644 --- a/sysdeps/nptl/gai_misc.h +++ b/sysdeps/nptl/gai_misc.h @@ -46,11 +46,12 @@ do \ { \ if (cancel) \ - status = futex_reltimed_wait_cancelable ( \ - (unsigned int *) futexaddr, oldval, timeout, FUTEX_PRIVATE); \ + status = __futex_abstimed_wait_cancelable64 ( \ + (unsigned int *) futexaddr, oldval, CLOCK_MONOTONIC, timeout, \ + FUTEX_PRIVATE); \ else \ - status = futex_reltimed_wait ((unsigned int *) futexaddr, \ - oldval, timeout, FUTEX_PRIVATE); \ + status = __futex_abstimed_wait64 ((unsigned int *) futexaddr, \ + oldval, CLOCK_REALTIME, timeout, FUTEX_PRIVATE); \ if (status != EAGAIN) \ break; \ \ @@ -62,6 +63,8 @@ result = EINTR; \ else if (status == ETIMEDOUT) \ result = EAGAIN; \ + else if (status == EOVERFLOW) \ + result = EOVERFLOW; \ else \ assert (status == 0 || status == EAGAIN); \ \