[PATCH] arm64: vdso32: Define BUILD_VDSO32_64 to correct prototypes

From: Nathan Chancellor
Date: Tue Nov 28 2023 - 11:53:08 EST


After commit 42874e4eb35b ("arch: vdso: consolidate gettime
prototypes"), there are a couple of errors when building the 32-bit
compat vDSO for arm64:

arch/arm64/kernel/vdso32/vgettimeofday.c:10:5: error: conflicting types for '__vdso_clock_gettime'; have 'int(clockid_t, struct old_timespec32 *)' {aka 'int(int, struct old_timespec32 *)'}
10 | int __vdso_clock_gettime(clockid_t clock,
| ^~~~~~~~~~~~~~~~~~~~
In file included from arch/arm64/kernel/vdso32/vgettimeofday.c:8:
include/vdso/gettime.h:16:5: note: previous declaration of '__vdso_clock_gettime' with type 'int(clockid_t, struct __kernel_timespec *)' {aka 'int(int, struct __kernel_timespec *)'}
16 | int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts);
| ^~~~~~~~~~~~~~~~~~~~
arch/arm64/kernel/vdso32/vgettimeofday.c:28:5: error: conflicting types for '__vdso_clock_getres'; have 'int(clockid_t, struct old_timespec32 *)' {aka 'int(int, struct old_timespec32 *)'}
28 | int __vdso_clock_getres(clockid_t clock_id,
| ^~~~~~~~~~~~~~~~~~~
include/vdso/gettime.h:15:5: note: previous declaration of '__vdso_clock_getres' with type 'int(clockid_t, struct __kernel_timespec *)' {aka 'int(int, struct __kernel_timespec *)'}
15 | int __vdso_clock_getres(clockid_t clock, struct __kernel_timespec *res);
| ^~~~~~~~~~~~~~~~~~~

The type of the second parameter in __vdso_clock_getres() and
__vdso_clock_gettime() changes based on whether compiling for 32-bit vs.
64-bit, which is controlled by CONFIG_64BIT or the preprocessor macro
BUILD_VDSO32_64, which denotes a 32-bit vDSO is being built for a 64-bit
architecture. Since this situation is the latter case, define
BUILD_VDSO32_64 before the inclusion of include/vdso/gettime.h to clear
up the warning

Fixes: 42874e4eb35b ("arch: vdso: consolidate gettime prototypes")
Reported-by: Naresh Kamboju <naresh.kamboju@xxxxxxxxxx>
Closes: https://lore.kernel.org/CA+G9fYtV6X=c3JVTTAX89_=wc+uqLpzggnsbGSx-98m_5yd5yw@xxxxxxxxxxxxxx/
Reported-by: Mark Brown <broonie@xxxxxxxxxx>
Closes: https://lore.kernel.org/ZWCRWArzbTYUjvon@xxxxxxxxxxxxxxxxxxxxxxxx/
Signed-off-by: Nathan Chancellor <nathan@xxxxxxxxxx>
---
arch/arm64/kernel/vdso32/vgettimeofday.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/arch/arm64/kernel/vdso32/vgettimeofday.c b/arch/arm64/kernel/vdso32/vgettimeofday.c
index e23c7f4ef26b..29b4d8f61e39 100644
--- a/arch/arm64/kernel/vdso32/vgettimeofday.c
+++ b/arch/arm64/kernel/vdso32/vgettimeofday.c
@@ -5,6 +5,7 @@
* Copyright (C) 2018 ARM Limited
*
*/
+#define BUILD_VDSO32_64
#include <vdso/gettime.h>

int __vdso_clock_gettime(clockid_t clock,

---
base-commit: ca8e45c8048a2c9503c74751d25414601f730580
change-id: 20231128-arm64-vdso32-missing-prototypes-error-e0d30a1ce52f

Best regards,
--
Nathan Chancellor <nathan@xxxxxxxxxx>