Skip to contentSkip to conversation

selftests: futex: define SYS_futex on 32-bit architectures with 64-bit time_t

PATCH Superseded Ben Zong-You Xie 3 participants 3 messages Jun 27, 2025 – Jul 6, 2025

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 selftests: futex: define SYS_futex on 32-bit architectures with 64-bit time_t

glibc does not define SYS_futex for 32-bit architectures using 64-bit time_t e.g. riscv32, therefore this test fails to compile since it does not find SYS_futex in C library headers. Define SYS_futex as SYS_futex_time64 in this situation to ensure successful compilation and compatibility.

---
Changes since v1:
- Fix the SOB chain

v1 : https://lore.kernel.org/all/[email protected]/

---
 tools/testing/selftests/futex/include/futextest.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
tools/testing/selftests/futex/include/futextest.h +11 -0
index ddbcfc9b7bac..7a5fd1d5355e 100644
@@ -47,6 +47,17 @@ typedef volatile u_int32_t futex_t;
 					 FUTEX_PRIVATE_FLAG)
 #endif
 
+/*
+ * SYS_futex is expected from system C library, in glibc some 32-bit
+ * architectures (e.g. RV32) are using 64-bit time_t, therefore it doesn't have
+ * SYS_futex defined but just SYS_futex_time64. Define SYS_futex as
+ * SYS_futex_time64 in this situation to ensure the compilation and the
+ * compatibility.
+ */
+#if !defined(SYS_futex) && defined(SYS_futex_time64)
+#define SYS_futex SYS_futex_time64
+#endif
+
 /**
  * futex() - SYS_futex syscall wrapper
  * @uaddr:	address of first futex

--
2.34.1

Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Ben Zong-You Xie

glibc does not define SYS_futex for 32-bit architectures using 64-bit time_t e.g. riscv32, therefore this test fails to compile since it does not find SYS_futex in C library headers. Define SYS_futex as SYS_futex_time64 in this situation to ensure successful compilation and compatibility.

Quoted 33 lines

---
Changes since v1:
- Fix the SOB chain

v1 : https://lore.kernel.org/all/[email protected]/

---
 tools/testing/selftests/futex/include/futextest.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
tools/testing/selftests/futex/include/futextest.h +11 -1
index ddbcfc9b7bac..7a5fd1d5355e 100644
@@ -47,6 +47,17 @@ typedef volatile u_int32_t futex_t;
 					 FUTEX_PRIVATE_FLAG)
 #endif
 
+/*
+ * SYS_futex is expected from system C library, in glibc some 32-bit
+ * architectures (e.g. RV32) are using 64-bit time_t, therefore it doesn't have
+ * SYS_futex defined but just SYS_futex_time64. Define SYS_futex as
+ * SYS_futex_time64 in this situation to ensure the compilation and the
+ * compatibility.
+ */
+#if !defined(SYS_futex) && defined(SYS_futex_time64)
+#define SYS_futex SYS_futex_time64
+#endif
+
 /**
  * futex() - SYS_futex syscall wrapper
  * @uaddr:	address of first futex
--

2.34.1

#2 lore raw
In reply to Ben Zong-You Xie
Quoted 1 line · Ben Zong-You Xie

glibc does not define SYS_futex for 32-bit architectures using 64-bit

Kinda. The kernel does not provide sys_futex() on 32-bit architectures, which do not support 32-bit time representations. As a consequence glibc obviously cannot define SYS_futex either.

Quoted 9 lines

time_t e.g. riscv32, therefore this test fails to compile since it does not find SYS_futex in C library headers. Define SYS_futex as SYS_futex_time64 in this situation to ensure successful compilation and compatibility.

---
Changes since v1:
- Fix the SOB chain

Mostly.

If Cynthia authored the patch, then this still lacks a 'From: Cynthia...' at the top of the change log so she can be identified as the author. Otherwise tooling will attribute autorship to you.

Thanks,

tglx