64 bit time_t on riscv32

Antonios Salios antonios@mwa.re
Mon Jan 15 12:52:52 GMT 2024

Hi all!

I'm having trouble with timestamps that are sent by the Linux evdev
interface to userspace applications (such as evtest).
I am using a virtualized riscv32 environment built by Buildroot with
glibc 2.37.

The kernel and userspace do not agree on how to define the timestamps.
The values should be 32-bit, so the kernel uses custom 32-bit __sec &
__usec variables instead of a timeval struct.
Userspace, on the other hand, wants to use a timeval struct, that uses
64-bit time_t on rv32.
The struct in question (input_event) can be found here [1].

According to a kernel maintainer, the __USE_TIME_BITS64 macro should be
set on architectures that use 64-bit time [2], otherwise the kernel
headers will not be able to pick the correct definition. 

When I define __USE_TIME_BITS64 manually, the compiler (gcc 13.2) does
not recognize the __time64_t type: `unknown type name '__time64_t'`.
This is fixed by also defining __LIBC [3], although I'm not sure why
this is necessary.
However, the preprocessor will then pick the correct definition of the
input_event struct.

But now the linker cannot find the reference to __ioctl_time64 (and
__select64) because it is only defined (as an alias) when __TIMESIZE !=
64 [4], which is not the case on rv32.

What am I missing?

Kind regards

Antonios Salios
Software Engineer

MachineWare GmbH | www.machineware.de
Hühnermarkt 19, 52062 Aachen, Germany
Amtsgericht Aachen HRB25734

Lukas Jünger
Dr.-Ing. Jan Henrik Weinstock

More information about the Libc-help mailing list