about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-01-02 15:39:12 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2020-01-03 10:02:05 -0300
commitb03688bfbb072f42970747bc2e6362c24b4b7ee8 (patch)
tree46604ee4bf56a8f38206b049b8e57817c6c00ea6 /sysdeps
parent220622dde5704c95a100c2792a280f18f3deba73 (diff)
downloadglibc-b03688bfbb072f42970747bc2e6362c24b4b7ee8.tar.gz
glibc-b03688bfbb072f42970747bc2e6362c24b4b7ee8.tar.xz
glibc-b03688bfbb072f42970747bc2e6362c24b4b7ee8.zip
Linux: Fix clock_nanosleep time64 check
The result of INTERNAL_SYSCALL_CANCEL should be checked with
macros INTERNAL_SYSCALL_ERROR_P and INTERNAL_SYSCALL_ERRNO instead
of comparing the result directly.

Checked on powerpc-linux-gnu.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/unix/sysv/linux/clock_nanosleep.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c b/sysdeps/unix/sysv/linux/clock_nanosleep.c
index 993c3cc8a6..728137aa56 100644
--- a/sysdeps/unix/sysv/linux/clock_nanosleep.c
+++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c
@@ -52,9 +52,10 @@ __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec
   r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep_time64, err, clock_id,
                                flags, req, rem);
 
-  if (r != -ENOSYS)
-    return (INTERNAL_SYSCALL_ERROR_P (r, err)
-            ? INTERNAL_SYSCALL_ERRNO (r, err) : 0);
+  if (! INTERNAL_SYSCALL_ERROR_P (r, err))
+    return 0;
+  if (INTERNAL_SYSCALL_ERRNO (r, err) != ENOSYS)
+    return INTERNAL_SYSCALL_ERRNO (r, err);
 # endif /* __NR_clock_nanosleep_time64 */
 
   if (! in_time_t_range (req->tv_sec))
@@ -65,11 +66,14 @@ __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec
 
   struct timespec tr32;
   struct timespec ts32 = valid_timespec64_to_timespec (*req);
-  r =  INTERNAL_SYSCALL_CANCEL (clock_nanosleep, err, clock_id, flags,
-                                &ts32, &tr32);
-
-  if (r == -EINTR && rem != NULL && (flags & TIMER_ABSTIME) == 0)
-    *rem = valid_timespec_to_timespec64 (tr32);
+  r = INTERNAL_SYSCALL_CANCEL (clock_nanosleep, err, clock_id, flags,
+                               &ts32, &tr32);
+  if (INTERNAL_SYSCALL_ERROR_P (r, err))
+    {
+      if (INTERNAL_SYSCALL_ERRNO (r, err) == EINTR && rem != NULL
+	  && (flags & TIMER_ABSTIME) == 0)
+	*rem = valid_timespec_to_timespec64 (tr32);
+    }
 #endif /* __ASSUME_TIME64_SYSCALLS */
 
   return (INTERNAL_SYSCALL_ERROR_P (r, err)