[RFC PATCH 2/4] support: test futex_time64 syscall instead of time32 one
Arnd Bergmann
arnd@kernel.org
Tue Nov 10 14:51:44 GMT 2026
From: Arnd Bergmann <arnd@arndb.de>
The old futex syscall is optional and can be disabled in the kernel
for 32-bit ABIs to force the use of time64 syscalls, which breaks the
support_mutex_pi_monotonic() detection: Even on __TIMESIZE=64 architectures
that always use the time64 syscalls, it may report false when __NR_futex
is defined but turned off.
Flip the detection and default to futex_time64 with a fallback to
futex for architectures that only have futex (64-bit ones plus x32).
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
support/support_mutex_pi_monotonic.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/support/support_mutex_pi_monotonic.c b/support/support_mutex_pi_monotonic.c
index cbcbd05165d4..8efcd7bd62b9 100644
--- a/support/support_mutex_pi_monotonic.c
+++ b/support/support_mutex_pi_monotonic.c
@@ -24,11 +24,16 @@ bool
support_mutex_pi_monotonic (void)
{
#ifdef __linux__
-# ifndef __NR_futex
-# define __NR_futex __NR_futex_time64
+ int r = 0;
+# if defined(__ASSUME_TIME64_SYSCALLS) && defined(__NR_futex_time64)
+ r = syscall (__NR_futex_time64, &(unsigned int){0}, 13 /* FUTEX_LOCK_PI2 */,
+ 0, NULL);
# endif
- int r = syscall (__NR_futex, &(unsigned int){0}, 13 /* FUTEX_LOCK_PI2 */,
+# ifdef __NR_futex
+ if (r != 0)
+ r = syscall (__NR_futex, &(unsigned int){0}, 13 /* FUTEX_LOCK_PI2 */,
0, NULL);
+# endif
return r == 0;
#else
return false;
--
2.53.0
More information about the Libc-alpha
mailing list