[RFC PATCH 3/4] linux: consistently use time64 syscalls if available

Arnd Bergmann arnd@arndb.de
Wed Nov 11 13:04:35 GMT 2026


On Wed, Nov 11, 2026, at 13:09, Adhemerval Zanella Netto wrote:
> On 10/11/26 11:51, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>

>> --- a/sysdeps/unix/sysv/linux/poll.c
>> +++ b/sysdeps/unix/sysv/linux/poll.c
>> @@ -27,6 +27,18 @@ __poll (struct pollfd *fds, nfds_t nfds, int timeout)
>>  {
>>  #ifdef __NR_poll
>>    return SYSCALL_CANCEL (poll, fds, nfds, timeout);
>> +#elif defined(__ASSUME_TIME64_SYSCALLS) && defined(__NR_ppoll_time64)
>> +  struct __timespec64 timeout_ts;
>> +  struct __timespec64 *timeout_ts_p = NULL;
>> +
>> +  if (timeout >= 0)
>> +    {
>> +      timeout_ts.tv_sec = timeout / 1000;
>> +      timeout_ts.tv_nsec = (timeout % 1000) * 1000000;
>> +      timeout_ts_p = &timeout_ts;
>> +    }
>> +
>> +  return SYSCALL_CANCEL (ppoll_time64, fds, nfds, timeout_ts_p, NULL, 0);
>
> The could avoid duplicating the timeout conversion by using the usual:
>
>   #ifndef __NR_ppoll_time64
>   # define __NR_ppoll_time64 __NR_ppoll
>   #endif
>
> It is fine either way.

I don't think that would work here, since we need both cases
depending on the expected kernel ABI version.

 - on __ASSUME_TIME64_SYSCALLS (building for new kernel versions)
   we want __NR_ppoll_time64 and need to convert to __timespec64
 - when building for older 32-bit kernels, the #ifndef is false
   because both __NR_ppoll_time64 and __NR_ppoll are defined,
   but we want to use __NR_ppoll with the time32 timespec.

> Missing ')'. More importantly, tst-clone3.c and i386/tst-bz21269.c are 
> regular tests
> and do not include <kernel-features.h>, so __ASSUME_TIME64_SYSCALLS is 
> never defined there.

Is it ok to include that header here it then, or does this need to
try call both syscalls?

> The clone3 needs Linux 5.3, so when tst-clone3* reach futex_wait, futex_time64
> always exists.

Ok

   Arnd


More information about the Libc-alpha mailing list