summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common/clock_gettime.c
diff options
context:
space:
mode:
authorDmitry Chestnykh <dm.chestnykh@gmail.com>2024-04-15 15:31:58 +0300
committerWaldemar Brodkorb <wbx@openadk.org>2024-04-18 14:52:06 +0200
commit3a36a3100af2ee1cca69345af83228757e8c55fe (patch)
tree6ec6990dba241b65a925eb581ef59bcb3a74e843 /libc/sysdeps/linux/common/clock_gettime.c
parent0694e42c9c9789bd87fba7e6639b21d2f28e09d4 (diff)
Fix vDSO support for all supported architectures.
- Cleanup dl-vdso.c code. - Pass `void *` as first arg to `load_vdso()`, using 32-bit type is completely wrong on 64bit architectures. - Split libc code and vDSO-related code. Move arch-specific implementations into separate files. The performance improvement is for example 50-60 times on ARMv7 and about 4 times on x86_64. Signed-off-by: Dmitry Chestnykh <dm.chestnykh@gmail.com>
Diffstat (limited to 'libc/sysdeps/linux/common/clock_gettime.c')
-rw-r--r--libc/sysdeps/linux/common/clock_gettime.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/libc/sysdeps/linux/common/clock_gettime.c b/libc/sysdeps/linux/common/clock_gettime.c
index 4d787b9b7..b924d860b 100644
--- a/libc/sysdeps/linux/common/clock_gettime.c
+++ b/libc/sysdeps/linux/common/clock_gettime.c
@@ -11,10 +11,14 @@
#include <sys/syscall.h>
#include <time.h>
+#ifdef __VDSO_SUPPORT__
+#include "ldso.h"
+#endif
+
#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_gettime64)
#include "internal/time64_helpers.h"
-int clock_gettime(clockid_t clock_id, struct timespec *tp)
+int __libc_clock_gettime(clockid_t clock_id, struct timespec *tp)
{
struct __ts64_struct __ts64;
int __ret = INLINE_SYSCALL(clock_gettime64, 2, clock_id, &__ts64);
@@ -26,11 +30,14 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
return __ret;
}
#elif defined(__NR_clock_gettime)
-_syscall2(int, clock_gettime, clockid_t, clock_id, struct timespec*, tp)
+int __libc_clock_gettime(clockid_t clock_id, struct timespec *tp)
+{
+ return INLINE_SYSCALL(clock_gettime, 2, clock_id, tp);
+}
#else
# include <sys/time.h>
-int clock_gettime(clockid_t clock_id, struct timespec* tp)
+int __libc_clock_gettime(clockid_t clock_id, struct timespec* tp)
{
struct timeval tv;
int retval = -1;
@@ -53,3 +60,12 @@ int clock_gettime(clockid_t clock_id, struct timespec* tp)
return retval;
}
#endif
+
+int clock_gettime(clockid_t clock_id, struct timespec *tp)
+{
+#if defined(__VDSO_SUPPORT__) && defined(ARCH_VDSO_CLOCK_GETTIME)
+ return ARCH_VDSO_CLOCK_GETTIME(clock_id, tp);
+#else
+ return __libc_clock_gettime(clock_id, tp);
+#endif
+}