public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: Joseph Myers <joseph@codesourcery.com>,
	Paul Eggert <eggert@cs.ucla.edu>,
	Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: Alistair Francis <alistair23@gmail.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Alistair Francis <alistair.francis@wdc.com>,
	GNU C Library <libc-alpha@sourceware.org>,
	Florian Weimer <fweimer@redhat.com>,
	Carlos O'Donell <carlos@redhat.com>,
	Stepan Golosunov <stepan@golosunov.pp.ru>,
	Andreas Schwab <schwab@suse.de>, Zack Weinberg <zackw@panix.com>,
	Lukasz Majewski <lukma@denx.de>
Subject: [RFC 09/10] y2038: Convert gai_suspend to support 64 bit timeout
Date: Tue,  7 Jul 2020 17:08:26 +0200	[thread overview]
Message-ID: <20200707150827.20899-10-lukma@denx.de> (raw)
In-Reply-To: <20200707150827.20899-1-lukma@denx.de>

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)
-- 
2.20.1


  parent reply	other threads:[~2020-07-07 15:09 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07 15:08 [RFC 00/10] y2038: nptl: futex: Provide support for futex_time64 Lukasz Majewski
2020-07-07 15:08 ` [RFC 01/10] doc: Fix wording and formatting in ./support/README Lukasz Majewski
2020-07-07 15:11   ` Florian Weimer
2020-07-07 15:08 ` [RFC 02/10] y2038: Convert timespec_* from posix-timer.h to be Y2038 safe Lukasz Majewski
2020-07-07 15:08 ` [RFC 03/10] y2038: Convert __lll_futex* functions to use futex_time64 when available Lukasz Majewski
2020-07-12 13:43   ` Lukasz Majewski
2020-07-13 21:08     ` Joseph Myers
2020-07-14  7:23       ` Lukasz Majewski
2020-07-07 15:08 ` [RFC 04/10] y2038: Replace struct timespec with __timespec64 in futex-internal.h Lukasz Majewski
2020-07-07 15:08 ` [RFC 05/10] y2038: Convert pthread_* functions to support 64 bit time Lukasz Majewski
2020-07-07 15:08 ` [RFC 06/10] y2038: Convert sem_{timed|clock}wait to support 64 bit timeout Lukasz Majewski
2020-07-07 15:08 ` [RFC 07/10] y2038: Convert __lll_clocklock_wait function to support 64 bit time Lukasz Majewski
2020-07-07 15:08 ` [RFC 08/10] y2038: Convert aio_suspend to support 64 bit timeout Lukasz Majewski
2020-07-07 15:08 ` Lukasz Majewski [this message]
2020-07-07 15:08 ` [RFC 10/10] y2038: x86: Fix __lll_clocklock_elision to support 64 bit time Lukasz Majewski
2020-07-12 13:42 ` [RFC 00/10] y2038: nptl: futex: Provide support for futex_time64 Lukasz Majewski
2020-07-13 17:15 ` Adhemerval Zanella
2020-07-14  7:56   ` Lukasz Majewski
2020-07-14 15:10     ` Adhemerval Zanella
2020-07-15  8:47       ` Lukasz Majewski
2020-07-16 19:02         ` Adhemerval Zanella
2020-07-17  7:27           ` Lukasz Majewski
2020-07-17  8:11             ` Arnd Bergmann
2020-07-17 10:17               ` Lukasz Majewski
2020-07-17 15:04               ` Adhemerval Zanella
2020-07-17 16:41                 ` Lukasz Majewski
2020-07-17 17:18                 ` Joseph Myers
2020-07-17 14:32             ` Joseph Myers
2020-07-17 15:04             ` Adhemerval Zanella
2020-07-17 16:42               ` Lukasz Majewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200707150827.20899-10-lukma@denx.de \
    --to=lukma@denx.de \
    --cc=adhemerval.zanella@linaro.org \
    --cc=alistair.francis@wdc.com \
    --cc=alistair23@gmail.com \
    --cc=arnd@arndb.de \
    --cc=carlos@redhat.com \
    --cc=eggert@cs.ucla.edu \
    --cc=fweimer@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@suse.de \
    --cc=stepan@golosunov.pp.ru \
    --cc=zackw@panix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).