18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Fast user context implementation of clock_gettime, gettimeofday, and time. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright 2006 Andi Kleen, SUSE Labs. 68c2ecf20Sopenharmony_ci * Copyright 2019 ARM Limited 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * 32 Bit compat layer by Stefani Seibold <stefani@seibold.net> 98c2ecf20Sopenharmony_ci * sponsored by Rohde & Schwarz GmbH & Co. KG Munich/Germany 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci#include <linux/time.h> 128c2ecf20Sopenharmony_ci#include <linux/kernel.h> 138c2ecf20Sopenharmony_ci#include <linux/types.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include "../../../../lib/vdso/gettimeofday.c" 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ciextern int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz); 188c2ecf20Sopenharmony_ciextern __kernel_old_time_t __vdso_time(__kernel_old_time_t *t); 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ciint __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) 218c2ecf20Sopenharmony_ci{ 228c2ecf20Sopenharmony_ci return __cvdso_gettimeofday(tv, tz); 238c2ecf20Sopenharmony_ci} 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ciint gettimeofday(struct __kernel_old_timeval *, struct timezone *) 268c2ecf20Sopenharmony_ci __attribute__((weak, alias("__vdso_gettimeofday"))); 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci__kernel_old_time_t __vdso_time(__kernel_old_time_t *t) 298c2ecf20Sopenharmony_ci{ 308c2ecf20Sopenharmony_ci return __cvdso_time(t); 318c2ecf20Sopenharmony_ci} 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci__kernel_old_time_t time(__kernel_old_time_t *t) __attribute__((weak, alias("__vdso_time"))); 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#if defined(CONFIG_X86_64) && !defined(BUILD_VDSO32_64) 378c2ecf20Sopenharmony_ci/* both 64-bit and x32 use these */ 388c2ecf20Sopenharmony_ciextern int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts); 398c2ecf20Sopenharmony_ciextern int __vdso_clock_getres(clockid_t clock, struct __kernel_timespec *res); 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ciint __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts) 428c2ecf20Sopenharmony_ci{ 438c2ecf20Sopenharmony_ci return __cvdso_clock_gettime(clock, ts); 448c2ecf20Sopenharmony_ci} 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ciint clock_gettime(clockid_t, struct __kernel_timespec *) 478c2ecf20Sopenharmony_ci __attribute__((weak, alias("__vdso_clock_gettime"))); 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ciint __vdso_clock_getres(clockid_t clock, 508c2ecf20Sopenharmony_ci struct __kernel_timespec *res) 518c2ecf20Sopenharmony_ci{ 528c2ecf20Sopenharmony_ci return __cvdso_clock_getres(clock, res); 538c2ecf20Sopenharmony_ci} 548c2ecf20Sopenharmony_ciint clock_getres(clockid_t, struct __kernel_timespec *) 558c2ecf20Sopenharmony_ci __attribute__((weak, alias("__vdso_clock_getres"))); 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci#else 588c2ecf20Sopenharmony_ci/* i386 only */ 598c2ecf20Sopenharmony_ciextern int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts); 608c2ecf20Sopenharmony_ciextern int __vdso_clock_getres(clockid_t clock, struct old_timespec32 *res); 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ciint __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) 638c2ecf20Sopenharmony_ci{ 648c2ecf20Sopenharmony_ci return __cvdso_clock_gettime32(clock, ts); 658c2ecf20Sopenharmony_ci} 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ciint clock_gettime(clockid_t, struct old_timespec32 *) 688c2ecf20Sopenharmony_ci __attribute__((weak, alias("__vdso_clock_gettime"))); 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ciint __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts) 718c2ecf20Sopenharmony_ci{ 728c2ecf20Sopenharmony_ci return __cvdso_clock_gettime(clock, ts); 738c2ecf20Sopenharmony_ci} 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ciint clock_gettime64(clockid_t, struct __kernel_timespec *) 768c2ecf20Sopenharmony_ci __attribute__((weak, alias("__vdso_clock_gettime64"))); 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ciint __vdso_clock_getres(clockid_t clock, struct old_timespec32 *res) 798c2ecf20Sopenharmony_ci{ 808c2ecf20Sopenharmony_ci return __cvdso_clock_getres_time32(clock, res); 818c2ecf20Sopenharmony_ci} 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ciint clock_getres(clockid_t, struct old_timespec32 *) 848c2ecf20Sopenharmony_ci __attribute__((weak, alias("__vdso_clock_getres"))); 858c2ecf20Sopenharmony_ci#endif 86