public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] nptl: Refactor thrd_sleep in terms of clock_nanosleep
@ 2019-11-06 17:47 Adhemerval Zanella
  0 siblings, 0 replies; only message in thread
From: Adhemerval Zanella @ 2019-11-06 17:47 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=807edded258e888dbfa0d19ca967d6e42882d069

commit 807edded258e888dbfa0d19ca967d6e42882d069
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Tue Nov 5 21:52:48 2019 +0000

    nptl: Refactor thrd_sleep in terms of clock_nanosleep
    
    Checked on x86_64-linux-gnu and powerpc64le-linux-gnu.
    
    Reviewed-by: Florian Weimer <fweimer@redhat.com>

Diff:
---
 nptl/thrd_sleep.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/nptl/thrd_sleep.c b/nptl/thrd_sleep.c
index 2e185dd..3f5e307 100644
--- a/nptl/thrd_sleep.c
+++ b/nptl/thrd_sleep.c
@@ -24,16 +24,13 @@
 int
 thrd_sleep (const struct timespec* time_point, struct timespec* remaining)
 {
-  INTERNAL_SYSCALL_DECL (err);
-  int ret = INTERNAL_SYSCALL_CANCEL (nanosleep, err, time_point, remaining);
-  if (INTERNAL_SYSCALL_ERROR_P (ret, err))
-    {
-      /* C11 states thrd_sleep function returns -1 if it has been interrupted
-	 by a signal, or a negative value if it fails.  */
-      ret = INTERNAL_SYSCALL_ERRNO (ret, err);
-      if (ret == EINTR)
-	return -1;
-      return -2;
-    }
-  return 0;
+  int ret = __clock_nanosleep (CLOCK_REALTIME, 0, time_point, remaining);
+  /* C11 states thrd_sleep function returns -1 if it has been interrupted
+     by a signal, or a negative value if it fails.  */
+  switch (ret)
+  {
+     case 0:      return 0;
+     case EINTR:  return -1;
+     default:     return -2;
+  }
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-11-06 17:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-06 17:47 [glibc] nptl: Refactor thrd_sleep in terms of clock_nanosleep Adhemerval Zanella

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