From ce15c4940c36b96d2614651782e7b2f69b8adb36 Mon Sep 17 00:00:00 2001
From: Anders Roxell <anders.roxell@linaro.org>
Date: Sat, 15 Nov 2025 18:31:02 +0100
Subject: [PATCH 5/5] selftests: vdso: Add clock_getres_time64 syscall test
 coverage

Add testing for the 64-bit clock_getres_time64 syscall on 32-bit
systems. This syscall is critical for y2038 safety as it uses 64-bit
time values.

Wrap the existing SYS_clock_getres syscall test in #ifdef
SYS_clock_getres to support architectures that only provide the time64
variant. Move the sys_ts variable declaration inside the #ifdef block
since it's only used there.

The clock_getres_time64 test is conditionally compiled with #ifdef
SYS_clock_getres_time64 and prints resolution values for comparison with
the existing vDSO and 32-bit syscall results.

This complements the existing clock_getres tests and ensures 64-bit time
support on 32-bit ARM architectures.

Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
 tools/testing/selftests/vDSO/vdso_test_abi.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/vDSO/vdso_test_abi.c b/tools/testing/selftests/vDSO/vdso_test_abi.c
index c7b056c9838b..6f53e51beab0 100644
--- a/tools/testing/selftests/vDSO/vdso_test_abi.c
+++ b/tools/testing/selftests/vDSO/vdso_test_abi.c
@@ -173,7 +173,7 @@ static void vdso_test_clock_getres(clockid_t clk_id)
 		return;
 	}
 
-	struct __kernel_old_timespec ts, sys_ts;
+	struct __kernel_old_timespec ts;
 	long ret = VDSO_CALL(vdso_clock_getres, 2, clk_id, &ts);
 
 	if (ret == 0) {
@@ -183,6 +183,9 @@ static void vdso_test_clock_getres(clockid_t clk_id)
 		clock_getres_fail++;
 	}
 
+#ifdef SYS_clock_getres
+	/* most architectures still provide the old clock_getres */
+	struct __kernel_old_timespec sys_ts;
 	ret = syscall(SYS_clock_getres, clk_id, &sys_ts);
 
 	ksft_print_msg("The clock_getres resolution is %ld %ld\n",
@@ -190,6 +193,15 @@ static void vdso_test_clock_getres(clockid_t clk_id)
 
 	if ((sys_ts.tv_sec != ts.tv_sec) || (sys_ts.tv_nsec != ts.tv_nsec))
 		clock_getres_fail++;
+#endif
+
+#ifdef SYS_clock_getres_time64
+	struct __kernel_timespec sys_ts64;
+	ret = syscall(SYS_clock_getres_time64, clk_id, &sys_ts64);
+	ksft_print_msg("The clock_getres_time64 resolution is %lld %lld\n",
+			(long long)sys_ts64.tv_sec, (long long)sys_ts64.tv_nsec);
+
+#endif
 
 	if (clock_getres_fail > 0) {
 		ksft_test_result_fail("%s %s\n", name[3],
-- 
2.51.0

