This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [RFC v4 02/24] sysdeps/nanosleep: Use clock_nanosleep_time64 if avaliable
14.08.2019 в 11:20:54 -0700 Alistair Francis написал:
> On Mon, Aug 12, 2019 at 10:22 AM Joseph Myers
> <joseph@codesourcery.com> wrote:
> > The pattern we have previously discussed for 64-bit time support is that
> > the code should (a) define the function (__thrd_sleep_time64, say) for
> > 64-bit time (which then only needs conversions in the reverse direction -
> > if the 64-bit syscall is not in fact available, but the 32-bit one is),
> > (b) if __TIMESIZE != 64, defines the 32-bit function as a thin wrapper
> > round that, (c) in the appropriate internal header, has a #define of the
>
> Doesn't having a thing wrapper around __thrd_sleep64() result in
> unnecessary conversions? When __NR_clock_nanosleep_time64 is not
> defined we will end up converting a 32-bit time_t to a 64-bit time_t
> just to convert it back to a 32-bit time_t.
The only purpose of handling __NR_clock_nanosleep_time64 being not
defined (when __ASSUME_TIME64_SYSCALLS is not defined too) is just to
avoid compilation failure with old kernel headers. There is no point
to optimize this case. And Florian proposed patches that remove it
altogether.
> It seems simpler to me to just keep the structure here and fix the
> 32-bit time_t when __ASSUME_TIME64_SYSCALLS is defined. That will
> probably result in a helper function for
> defined(__ASSUME_TIME64_SYSCALLS) ||
> __NR_clock_nanosleep_time64 as they are very similar.
If you add support for a 64-bit time version of a function on
__TIMESIZE==32 architectures, you'll end up with 2 functions. And it
is much simpler to have 32-bit-time one as a thin wrapper around
64-bit-time one. Code will be more tested this way.
And if you do not add such support it should be sufficient to do just
#ifdef __NR_nanosleep
int ret = INTERNAL_SYSCALL_CANCEL (nanosleep, err, time_point, remaining);
#else
int ret = INTERNAL_SYSCALL_CANCEL (clock_nanosleep, err, CLOCK_MONOTONIC,
0, time_point, remaining);
#endif
plus
#define __NR_clock_nanosleep __NR_clock_nanosleep64
in sysdep.h for rv32.
(I am not sure whether the #ifdef __NR_nanosleep part is needed.)