unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org
Subject: Re: [PATCH v6 1/3] sysdeps/clock_nanosleep: Use clock_nanosleep_time64 if avaliable
Date: Mon, 11 Nov 2019 10:50:35 -0300	[thread overview]
Message-ID: <c2a8fe69-f155-15f0-0ba2-78b5439e8253@linaro.org> (raw)
In-Reply-To: <87imnroccz.fsf@igel.home>



On 10/11/2019 14:44, Andreas Schwab wrote:
> On Nov 10 2019, Alistair Francis wrote:
> 
>> On Sun, Nov 10, 2019 at 1:00 AM Andreas Schwab <schwab@linux-m68k.org> wrote:
>>>
>>> This breaks rt/tst-timer on i586 and powerpc and armv7l.
>>
>> I don't understand how. I tested it on ARMv7. Do you have any more
>> details on why it is failing?
> 
> I don't know, it just hangs.
> 
>> Also is this on a 5.1+ or earlier kernel/headers?
> 
> All the latest.
> 
> https://build.opensuse.org/package/show/home:Andreas_Schwab:glibc/glibc
> 
> Andreas.
> 

It is because clock_nanosspe requires to handle EINTR as a possible return
value and update the remaining argument accordingly:

diff --git a/sysdeps/unix/sysv/linux/clock_nanosleep.c b/sysdeps/unix/sysv/linux/clock_nanosleep.c
index 60c61ee277..fc47c58ee7 100644
--- a/sysdeps/unix/sysv/linux/clock_nanosleep.c
+++ b/sysdeps/unix/sysv/linux/clock_nanosleep.c
@@ -52,13 +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 == 0 || errno != ENOSYS)
-    {
-      return (INTERNAL_SYSCALL_ERROR_P (r, err)
-              ? INTERNAL_SYSCALL_ERRNO (r, err) : 0);
-    }
+  if (r != -ENOSYS)
+    return (INTERNAL_SYSCALL_ERROR_P (r, err)
+            ? INTERNAL_SYSCALL_ERRNO (r, err) : 0);
 # endif /* __NR_clock_nanosleep_time64 */
-  struct timespec ts32, tr32;
 
   if (! in_time_t_range (req->tv_sec))
     {
@@ -66,11 +63,12 @@ __clock_nanosleep_time64 (clockid_t clock_id, int flags, const struct __timespec
       return -1;
     }
 
-  ts32 = valid_timespec64_to_timespec (*req);
+  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 == 0 && rem != NULL)
+  if (r == -EINTR && rem != NULL && (flags & TIMER_ABSTIME) == 0)
     *rem = valid_timespec_to_timespec64 (tr32);
 #endif /* __ASSUME_TIME64_SYSCALLS */
 
@@ -89,7 +87,7 @@ __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
   treq64 = valid_timespec_to_timespec64 (*req);
   r = __clock_nanosleep_time64 (clock_id, flags, &treq64, &trem64);
 
-  if (r == 0 && rem != NULL)
+  if (r == EINTR && rem != NULL && (flags & TIMER_ABSTIME) == 0)
     *rem = valid_timespec64_to_timespec (trem64);
 
   return r;




      reply	other threads:[~2019-11-11 13:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-08 17:03 [PATCH v6 1/3] sysdeps/clock_nanosleep: Use clock_nanosleep_time64 if avaliable Alistair Francis
2019-11-08 17:03 ` [PATCH v6 2/3] time: Define time64 thrd_sleep Alistair Francis
2019-11-08 18:58   ` Adhemerval Zanella
2019-11-08 21:17     ` Alistair Francis
2019-11-08 17:03 ` [PATCH v6 3/3] time: Define time64 nanosleep Alistair Francis
2019-11-08 18:59   ` Adhemerval Zanella
2019-11-08 19:01 ` [PATCH v6 1/3] sysdeps/clock_nanosleep: Use clock_nanosleep_time64 if avaliable Adhemerval Zanella
2019-11-08 20:52   ` Alistair Francis
2019-11-10  9:00 ` Andreas Schwab
2019-11-10 16:44   ` Alistair Francis
2019-11-10 17:44     ` Andreas Schwab
2019-11-11 13:50       ` Adhemerval Zanella [this message]

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

  List information: https://www.gnu.org/software/libc/involved.html

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

  git send-email \
    --in-reply-to=c2a8fe69-f155-15f0-0ba2-78b5439e8253@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    /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).