[RFC v2 05/20] sysdeps/nanosleep: Use clock_nanosleep_time64 if avaliable
Arnd Bergmann
arnd@arndb.de
Tue Jun 25 08:59:00 GMT 2019
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.
No idea how that fits into the rest of the glibc implementation.
Arnd
More information about the Libc-alpha
mailing list