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

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/uapi/linux/input.h?h=v6.5.6#n28
[2]
https://lore.kernel.org/lkml/1a528414-f193-4ac0-a911-af426bb48d64@app.fastmail.com/
[3]
https://sourceware.org/git/?p=glibc.git;a=blob;f=posix/bits/types.h;hb=glibc-2.37#l220
[4]
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/ioctl.c;hb=glibc-2.37#l48
-- 
Antonios Salios
Software Engineer

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

Geschäftsführung
Lukas Jünger
Dr.-Ing. Jan Henrik Weinstock


More information about the Libc-help mailing list