glib/gthread-posix: Conditionally use `futex` and/or `futex_time64` syscalls...
glib/gthread-posix: Conditionally use futex
and/or futex_time64
syscalls as necessary and use the correct struct timespec
definition
On some systems only futex_time64
exists (e.g. riscv32) while on
others only futex
exists (old Linux, 64 bit platforms), so it is
necessary to check for both and try calling both at runtime.
Additionally use the correct struct timespec
definition. There is not
necessarily any relation between the libc's definition and the kernel's.
Specifically, the libc headers might use 64-bit time_t
while the kernel
headers use 32-bit __kernel_old_time_t
on certain systems.
To get around this problem we
- check if
futex_time64
is available, which only exists on 32-bit platforms and always uses 64-bittime_t
. - otherwise (or if that returns
ENOSYS
), we call the normalfutex
syscall with thestruct timespec
used by the kernel, which uses__kernel_long_t
for both its fields. We use that instead of__kernel_old_time_t
because it is equivalent and available in the kernel headers for a longer time.
Edited by Sebastian Dröge