about summary refs log tree commit diff
path: root/nptl
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-11-05 21:52:48 +0000
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-11-06 14:47:05 -0300
commit807edded258e888dbfa0d19ca967d6e42882d069 (patch)
treec2fada662dc56552435db37c3efb13529c2ccc74 /nptl
parent3537ecb49cf7177274607004c562d6f9ecc99474 (diff)
downloadglibc-807edded258e888dbfa0d19ca967d6e42882d069.tar.gz
glibc-807edded258e888dbfa0d19ca967d6e42882d069.tar.xz
glibc-807edded258e888dbfa0d19ca967d6e42882d069.zip
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>
Diffstat (limited to 'nptl')
-rw-r--r--nptl/thrd_sleep.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/nptl/thrd_sleep.c b/nptl/thrd_sleep.c
index 2e185dd748..3f5e307d56 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;
+  }
 }