This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC v2 05/20] sysdeps/nanosleep: Use clock_nanosleep_time64 if avaliable


On Tue, Jun 25, 2019 at 1:59 AM Arnd Bergmann <arnd@arndb.de> wrote:
>
> On Tue, Jun 25, 2019 at 2:11 AM Alistair Francis
> <alistair.francis@wdc.com> wrote:
>
> > index f14ae565af..c2d6e2f766 100644
> > --- a/sysdeps/unix/sysv/linux/nanosleep.c
> > +++ b/sysdeps/unix/sysv/linux/nanosleep.c
> > @@ -25,7 +25,19 @@ int
> >  __nanosleep (const struct timespec *requested_time,
> >              struct timespec *remaining)
> >  {
> > +
> > +#ifdef __ASSUME_TIME64_SYSCALLS
> > +  return SYSCALL_CANCEL (clock_nanosleep_time64, CLOCK_REALTIME, 0,
> > +                         requested_time, remaining);
> > +#else
> > +# ifdef __NR_clock_nanosleep_time64
> > +  long int ret = SYSCALL_CANCEL (clock_nanosleep_time64, CLOCK_REALTIME, 0,
> > +                                 requested_time, remaining);
> > +  if (ret == 0 || errno != ENOSYS)
> > +    return ret;
> > +# endif
> >    return SYSCALL_CANCEL (nanosleep, requested_time, remaining);
> > +#endif
> >  }
>
> There has to be a type conversion in here somewhere: If timespec
> uses 32-bit time_t (on all existing 32-bit architectures), you must not
> pass it into __NR_clock_nanosleep_time64, while on builds with
> a 64-bit timespec you must not call nanosleep() without conversion.
>
> I suppose you need something like an internal __nanosleep64 (like
> your function above, but with the conversion added to the fallback
> path) and an internal __nanosleep32 (not calling clock_nanosleep_time64
> or doing conversion). Architectures that have always had a 64-bit time_t
> don't need the latter of course.

Argh, this is a little messy but I think I have something working.

Alistair

>
> No idea how that fits into the rest of the glibc implementation.
>
>         Arnd


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]