Skip to content
Snippets Groups Projects
Commit 949fb1d0 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

linux: use futex_time64 where applicable

This adds support for 32-bit RISC-V, which only supports 64-bit time_t,
and thus lacks a plain futex system call. This also adds (future)
support for building with a 64-bit time_t ABI on a 32-bit platform.
parent 535509c9
No related branches found
No related tags found
1 merge request!1310linux: use futex_time64 where applicable
Pipeline #184979 passed with stage
in 18 minutes and 22 seconds
......@@ -53,7 +53,27 @@ unsigned long vlc_thread_id(void)
static int sys_futex(void *addr, int op, unsigned val,
const struct timespec *to, void *addr2, int val3)
{
return syscall(__NR_futex, addr, op, val, to, addr2, val3);
/* The futex Linux kernel system call exists in two variants:
* - the original one for use with long time_t, which suffers from the
* year 2038 problem on 32-bit architectures,
* - the "time64" one for use with 64-bit time_t, which lacks backward
* binary compatibility with 32-bit long time_t on 32-bit architectures.
*/
static_assert (sizeof (time_t) == sizeof (long) || sizeof (time_t) == 8,
"Unrecognised time_t type definition");
#if !defined (__NR_futex)
/* Recent 32-bit platforms (e.g. riscv32) only support 64-bit time_t. */
static_assert (sizeof (time_t) == 8, "Expected 64-bit time_t");
const long num = __NR_futex_time64;
#elif !defined (__NR_futex_time64)
static_assert (sizeof (time_t) == sizeof (long), "Expected long time_t");
const long num = __NR_futex;
#else
const long num = sizeof (time_t) == sizeof (long)
? __NR_futex : __NR_futex_time64;
#endif
return syscall(num, addr, op, val, to, addr2, val3);
}
static int vlc_futex_wake(void *addr, int nr)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment