Skip to contentSkip to conversation

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

PATCH Applied Ben Zong-You Xie 2 participants 2 messages Jul 10, 2025 – Jul 22, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

From: Cynthia Huang <[email protected]>

Linux kernel does not provide sys_futex() on some 32-bit architectures that do not support 32-bit time representations, such as riscv32. As a result, glibc cannot define SYS_futex, causing compilation failures in tests that rely on this syscall. Define SYS_futex as SYS_futex_time64 in such cases to ensure successful compilation and compatibility.

---
Changes since v2:
- Refine the commit message suggested by tglx
- Attribute the authorship to Cynthia
- Add the Reviewed-by tag from Muhammad

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

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

merge bot Applied
#1 lore raw

[tip: locking/futex] selftests/futex: Define SYS_futex on 32-bit architectures with 64-bit time_t

The following commit has been merged into the locking/futex branch of tip:

The following commit has been merged into the locking/futex branch of tip:

Commit-ID:     04850819c65c8242072818655d4341e70ae998b5
Gitweb:        https://git.kernel.org/tip/04850819c65c8242072818655d4341e70ae998b5
Author:        Cynthia Huang <[email protected]>
AuthorDate:    Thu, 10 Jul 2025 18:36:30 +08:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Tue, 22 Jul 2025 11:18:43 +02:00

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

The kernel does not provide sys_futex() on 32-bit architectures that do not support 32-bit time representations, such as riscv32.

As a result, glibc cannot define SYS_futex, causing compilation failures in tests that rely on this syscall. Define SYS_futex as SYS_futex_time64 in such cases to ensure successful compilation and compatibility.

---
 tools/testing/selftests/futex/include/futextest.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
tools/testing/selftests/futex/include/futextest.h +11 -0
index ddbcfc9..7a5fd1d 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