Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arch: vdso: consolidate gettime prototypes

The VDSO functions are defined as globals in the kernel sources but intended
to be called from userspace, so there is no need to declare them in a kernel
side header.

Without a prototype, this now causes warnings such as

arch/mips/vdso/vgettimeofday.c:14:5: error: no previous prototype for '__vdso_clock_gettime' [-Werror=missing-prototypes]
arch/mips/vdso/vgettimeofday.c:28:5: error: no previous prototype for '__vdso_gettimeofday' [-Werror=missing-prototypes]
arch/mips/vdso/vgettimeofday.c:36:5: error: no previous prototype for '__vdso_clock_getres' [-Werror=missing-prototypes]
arch/mips/vdso/vgettimeofday.c:42:5: error: no previous prototype for '__vdso_clock_gettime64' [-Werror=missing-prototypes]
arch/sparc/vdso/vclock_gettime.c:254:1: error: no previous prototype for '__vdso_clock_gettime' [-Werror=missing-prototypes]
arch/sparc/vdso/vclock_gettime.c:282:1: error: no previous prototype for '__vdso_clock_gettime_stick' [-Werror=missing-prototypes]
arch/sparc/vdso/vclock_gettime.c:307:1: error: no previous prototype for '__vdso_gettimeofday' [-Werror=missing-prototypes]
arch/sparc/vdso/vclock_gettime.c:343:1: error: no previous prototype for '__vdso_gettimeofday_stick' [-Werror=missing-prototypes]

Most architectures have already added workarounds for these by adding
declarations somewhere, but since these are all compatible, we should
really just have one copy, with an #ifdef check for the 32-bit vs
64-bit variant and use that everywhere.

Unfortunately, the sparc an um versions are currently incompatible
since they never added support for __vdso_clock_gettime64() in 32-bit
userland. For the moment, I'm leaving this one out, as I can't
easily test it and it requires a larger rework.

Reviewed-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+30 -38
-5
arch/arm/include/asm/vdso.h
··· 24 24 25 25 #endif /* CONFIG_VDSO */ 26 26 27 - int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts); 28 - int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts); 29 - int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz); 30 - int __vdso_clock_getres(clockid_t clock_id, struct old_timespec32 *res); 31 - 32 27 #endif /* __ASSEMBLY__ */ 33 28 34 29 #endif /* __KERNEL__ */
+1
arch/arm/vdso/vgettimeofday.c
··· 8 8 #include <linux/types.h> 9 9 #include <asm/vdso.h> 10 10 #include <asm/unwind.h> 11 + #include <vdso/gettime.h> 11 12 12 13 int __vdso_clock_gettime(clockid_t clock, 13 14 struct old_timespec32 *ts)
+1
arch/arm64/kernel/vdso32/vgettimeofday.c
··· 5 5 * Copyright (C) 2018 ARM Limited 6 6 * 7 7 */ 8 + #include <vdso/gettime.h> 8 9 9 10 int __vdso_clock_gettime(clockid_t clock, 10 11 struct old_timespec32 *ts)
+1 -10
arch/csky/kernel/vdso/vgettimeofday.c
··· 2 2 3 3 #include <linux/time.h> 4 4 #include <linux/types.h> 5 + #include <vdso/gettime.h> 5 6 6 7 extern 7 - int __vdso_clock_gettime(clockid_t clock, 8 - struct old_timespec32 *ts); 9 8 int __vdso_clock_gettime(clockid_t clock, 10 9 struct old_timespec32 *ts) 11 10 { ··· 12 13 } 13 14 14 15 int __vdso_clock_gettime64(clockid_t clock, 15 - struct __kernel_timespec *ts); 16 - int __vdso_clock_gettime64(clockid_t clock, 17 16 struct __kernel_timespec *ts) 18 17 { 19 18 return __cvdso_clock_gettime(clock, ts); 20 19 } 21 20 22 - extern 23 - int __vdso_gettimeofday(struct __kernel_old_timeval *tv, 24 - struct timezone *tz); 25 21 int __vdso_gettimeofday(struct __kernel_old_timeval *tv, 26 22 struct timezone *tz) 27 23 { 28 24 return __cvdso_gettimeofday(tv, tz); 29 25 } 30 26 31 - extern 32 - int __vdso_clock_getres(clockid_t clock_id, 33 - struct old_timespec32 *res); 34 27 int __vdso_clock_getres(clockid_t clock_id, 35 28 struct old_timespec32 *res) 36 29 {
+1 -6
arch/loongarch/vdso/vgettimeofday.c
··· 5 5 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited 6 6 */ 7 7 #include <linux/types.h> 8 + #include <vdso/gettime.h> 8 9 9 - extern 10 - int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts); 11 10 int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts) 12 11 { 13 12 return __cvdso_clock_gettime(clock, ts); 14 13 } 15 14 16 - extern 17 - int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz); 18 15 int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) 19 16 { 20 17 return __cvdso_gettimeofday(tv, tz); 21 18 } 22 19 23 - extern 24 - int __vdso_clock_getres(clockid_t clock_id, struct __kernel_timespec *res); 25 20 int __vdso_clock_getres(clockid_t clock_id, struct __kernel_timespec *res) 26 21 { 27 22 return __cvdso_clock_getres(clock_id, res);
+1
arch/mips/vdso/vgettimeofday.c
··· 9 9 */ 10 10 #include <linux/time.h> 11 11 #include <linux/types.h> 12 + #include <vdso/gettime.h> 12 13 13 14 #if _MIPS_SIM != _MIPS_SIM_ABI64 14 15 int __vdso_clock_gettime(clockid_t clock,
+1 -6
arch/riscv/kernel/vdso/vgettimeofday.c
··· 8 8 9 9 #include <linux/time.h> 10 10 #include <linux/types.h> 11 + #include <vdso/gettime.h> 11 12 12 - extern 13 - int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts); 14 13 int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts) 15 14 { 16 15 return __cvdso_clock_gettime(clock, ts); 17 16 } 18 17 19 - extern 20 - int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz); 21 18 int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) 22 19 { 23 20 return __cvdso_gettimeofday(tv, tz); 24 21 } 25 22 26 - extern 27 - int __vdso_clock_getres(clockid_t clock_id, struct __kernel_timespec *res); 28 23 int __vdso_clock_getres(clockid_t clock_id, struct __kernel_timespec *res) 29 24 { 30 25 return __cvdso_clock_getres(clock_id, res);
+1 -9
arch/x86/entry/vdso/vclock_gettime.c
··· 11 11 #include <linux/time.h> 12 12 #include <linux/kernel.h> 13 13 #include <linux/types.h> 14 + #include <vdso/gettime.h> 14 15 15 16 #include "../../../../lib/vdso/gettimeofday.c" 16 - 17 - extern int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz); 18 - extern __kernel_old_time_t __vdso_time(__kernel_old_time_t *t); 19 17 20 18 int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) 21 19 { ··· 33 35 34 36 #if defined(CONFIG_X86_64) && !defined(BUILD_VDSO32_64) 35 37 /* both 64-bit and x32 use these */ 36 - extern int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts); 37 - extern int __vdso_clock_getres(clockid_t clock, struct __kernel_timespec *res); 38 - 39 38 int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts) 40 39 { 41 40 return __cvdso_clock_gettime(clock, ts); ··· 51 56 52 57 #else 53 58 /* i386 only */ 54 - extern int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts); 55 - extern int __vdso_clock_getres(clockid_t clock, struct old_timespec32 *res); 56 - 57 59 int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) 58 60 { 59 61 return __cvdso_clock_gettime32(clock, ts);
-2
arch/x86/include/asm/vdso/gettimeofday.h
··· 337 337 } 338 338 #define vdso_calc_delta vdso_calc_delta 339 339 340 - int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts); 341 - 342 340 #endif /* !__ASSEMBLY__ */ 343 341 344 342 #endif /* __ASM_VDSO_GETTIMEOFDAY_H */
+23
include/vdso/gettime.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _VDSO_GETTIME_H 3 + #define _VDSO_GETTIME_H 4 + 5 + #include <linux/types.h> 6 + 7 + struct __kernel_timespec; 8 + struct timezone; 9 + 10 + #if !defined(CONFIG_64BIT) || defined(BUILD_VDSO32_64) 11 + struct old_timespec32; 12 + int __vdso_clock_getres(clockid_t clock, struct old_timespec32 *res); 13 + int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts); 14 + #else 15 + int __vdso_clock_getres(clockid_t clock, struct __kernel_timespec *res); 16 + int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts); 17 + #endif 18 + 19 + __kernel_old_time_t __vdso_time(__kernel_old_time_t *t); 20 + int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz); 21 + int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts); 22 + 23 + #endif