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(-)
@@ -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 */
@@ -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)