Skip to contentSkip to conversation

selftests: timers: Fix clock_adjtime for newer 32-bit arches

PATCH In review Khem Raj 3 participants 4 messages Sep 18, 2024 – Sep 19, 2024

Subsystems (3)
lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 selftests: timers: Fix clock_adjtime for newer 32-bit arches

Newer 32-bit architectures e.g. riscv32 are using 64-bit time_t from get go, they have not wired __NR_clock_adjtime at all valid-adjtimex testcase fails to compile on such architectures. if this condition is found then use 64-bit adjtime syscall

Cc John Stultz <[email protected]>
Cc Shuah Khan <[email protected]>
---
 tools/testing/selftests/timers/valid-adjtimex.c | 4 ++++
 1 file changed, 4 insertions(+)
tools/testing/selftests/timers/valid-adjtimex.c +4 -0
index d500884801d8..ff4ff8b1d127 100644
@@ -39,7 +39,11 @@
 #include <sys/syscall.h>
 int clock_adjtime(clockid_t id, struct timex *tx)
 {
+#if !defined(__NR_clock_adjtime) && defined(__NR_clock_adjtime64)
+	return syscall(__NR_clock_adjtime64, id, tx);
+#else
 	return syscall(__NR_clock_adjtime, id, tx);
+#endif
 }
 
 
maintainer
#1 lore raw
Quoted 6 lines · Khem Raj

Newer 32-bit architectures e.g. riscv32 are using 64-bit time_t from get go, they have not wired __NR_clock_adjtime at all valid-adjtimex testcase fails to compile on such architectures. if this condition is found then use 64-bit adjtime syscall

No major objections here. Though I'm feeling a little forgetful as to why the test is calling the syscall directly instead of going through libc.
I suspect it's likely due to the test being written prior to the libc implementation being common?

So I wonder if a better fix would be just to drop the local clock_adjtime implementation here, as I'm sure the libc has similar logic to what's being added here?

thanks
-john

maintainer
#2 lore raw
Quoted 14 lines · John Stultz
Quoted 6 lines · Khem Raj

Newer 32-bit architectures e.g. riscv32 are using 64-bit time_t from get go, they have not wired __NR_clock_adjtime at all valid-adjtimex testcase fails to compile on such architectures. if this condition is found then use 64-bit adjtime syscall

No major objections here. Though I'm feeling a little forgetful as to why the test is calling the syscall directly instead of going through libc.
I suspect it's likely due to the test being written prior to the libc implementation being common?

Quoted 4 lines

So I wonder if a better fix would be just to drop the local clock_adjtime implementation here, as I'm sure the libc has similar logic to what's being added here?

The proposed solution works better than adding local clock_adjtime implementation here.

thanks,
-- Shuah

author
#3 lore raw
Quoted 16 lines · Shuah Khan
Quoted 14 lines · John Stultz
Quoted 6 lines · Khem Raj

Newer 32-bit architectures e.g. riscv32 are using 64-bit time_t from get go, they have not wired __NR_clock_adjtime at all valid-adjtimex testcase fails to compile on such architectures. if this condition is found then use 64-bit adjtime syscall

No major objections here. Though I'm feeling a little forgetful as to why the test is calling the syscall directly instead of going through libc.
I suspect it's likely due to the test being written prior to the libc implementation being common?

Quoted 7 lines
Quoted 4 lines

So I wonder if a better fix would be just to drop the local clock_adjtime implementation here, as I'm sure the libc has similar logic to what's being added here?

The proposed solution works better than adding local clock_adjtime implementation here.

Thanks, I will prepare and test a v2 by removing the local copy of clock_adjtime.

Quoted 4 lines

thanks,
-- Shuah