diff options
author | Ulrich Drepper <drepper@gmail.com> | 2011-08-21 13:52:28 -0400 |
---|---|---|
committer | Ulrich Drepper <drepper@gmail.com> | 2011-08-21 13:52:28 -0400 |
commit | 91b392a4bab0c2dc90e7e3ff914dec20b97adca8 (patch) | |
tree | c59ef82aa0fcbbcaaa2e6f0c6a99670e51da112b /sysdeps/unix/sysv/linux/x86_64 | |
parent | e315850c088ad13a160132a6fcec9d7564dd3c08 (diff) | |
download | glibc-91b392a4bab0c2dc90e7e3ff914dec20b97adca8.tar.gz glibc-91b392a4bab0c2dc90e7e3ff914dec20b97adca8.tar.xz glibc-91b392a4bab0c2dc90e7e3ff914dec20b97adca8.zip |
Use ifuncs for time and gettimeofday on x86-64
Diffstat (limited to 'sysdeps/unix/sysv/linux/x86_64')
-rw-r--r-- | sysdeps/unix/sysv/linux/x86_64/bits/libc-vdso.h | 5 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/x86_64/gettimeofday.c (renamed from sysdeps/unix/sysv/linux/x86_64/gettimeofday.S) | 48 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/x86_64/init-first.c | 24 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/x86_64/time.c (renamed from sysdeps/unix/sysv/linux/x86_64/time.S) | 40 |
4 files changed, 47 insertions, 70 deletions
diff --git a/sysdeps/unix/sysv/linux/x86_64/bits/libc-vdso.h b/sysdeps/unix/sysv/linux/x86_64/bits/libc-vdso.h index d7123c9bb5..f9bf84e5b9 100644 --- a/sysdeps/unix/sysv/linux/x86_64/bits/libc-vdso.h +++ b/sysdeps/unix/sysv/linux/x86_64/bits/libc-vdso.h @@ -1,5 +1,5 @@ /* Resolve function pointers to VDSO functions. - Copyright (C) 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 2005, 2007, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -25,9 +25,6 @@ #ifdef SHARED -extern long int (*__vdso_gettimeofday) (struct timeval *, void *) - attribute_hidden; - extern long int (*__vdso_clock_gettime) (clockid_t, struct timespec *); #endif diff --git a/sysdeps/unix/sysv/linux/x86_64/gettimeofday.S b/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c index f618e738b1..1a773d6412 100644 --- a/sysdeps/unix/sysv/linux/x86_64/gettimeofday.S +++ b/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2007, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,34 +16,34 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <sysdep.h> -#define _ERRNO_H 1 -#include <bits/errno.h> +#include <dl-vdso.h> -/* For the calculation see asm/vsyscall.h. */ -#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000 + +#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000ul -ENTRY (__gettimeofday) - /* Align stack. */ - sub $0x8, %rsp - cfi_adjust_cfa_offset(8) #ifdef SHARED - movq __vdso_gettimeofday(%rip), %rax - PTR_DEMANGLE (%rax) +void *gettimeofday_ifunc (void) __asm__ ("__gettimeofday"); + +void * +gettimeofday_ifunc (void) +{ + PREPARE_VERSION (linux26, "LINUX_2.6", 61765110); + + /* If the vDSO is not available we fall back on the old vsyscall. */ + return (_dl_vdso_vsym ("gettimeofday", &linux26) + ?: (void *) VSYSCALL_ADDR_vgettimeofday); +} +__asm (".type __gettimeofday, %gnu_indirect_function"); #else - movq $VSYSCALL_ADDR_vgettimeofday, %rax -#endif - callq *%rax - /* Check error return. */ - cmpl $-4095, %eax - jae SYSCALL_ERROR_LABEL +# include <sys/time.h> -L(pseudo_end): - add $0x8, %rsp - cfi_adjust_cfa_offset(-8) - ret -PSEUDO_END(__gettimeofday) +int +__gettimeofday (struct timeval *tv, struct timezone *tz) +{ + return ((int (*) (struct timeval *, struct timezone *)) VSYSCALL_ADDR_vgettimeofday) (tv, tz); +} +#endif -strong_alias (__gettimeofday, __gettimeofday_internal) weak_alias (__gettimeofday, gettimeofday) +strong_alias (__gettimeofday, __gettimeofday_internal) diff --git a/sysdeps/unix/sysv/linux/x86_64/init-first.c b/sysdeps/unix/sysv/linux/x86_64/init-first.c index e676f623e1..25cf08bd77 100644 --- a/sysdeps/unix/sysv/linux/x86_64/init-first.c +++ b/sysdeps/unix/sysv/linux/x86_64/init-first.c @@ -20,15 +20,11 @@ # include <dl-vdso.h> # include <bits/libc-vdso.h> -long int (*__vdso_gettimeofday) (struct timeval *, void *) attribute_hidden; - long int (*__vdso_clock_gettime) (clockid_t, struct timespec *) __attribute__ ((nocommon)); strong_alias (__vdso_clock_gettime, __GI___vdso_clock_gettime attribute_hidden) -long int (*__vdso_getcpu) (unsigned *, unsigned *, void *); - -long int (*__vdso_time) (time_t *) attribute_hidden; +long int (*__vdso_getcpu) (unsigned *, unsigned *, void *) attribute_hidden; static inline void @@ -36,15 +32,7 @@ _libc_vdso_platform_setup (void) { PREPARE_VERSION (linux26, "LINUX_2.6", 61765110); - void *p = _dl_vdso_vsym ("gettimeofday", &linux26); - /* If the vDSO is not available we fall back on the old vsyscall. */ -#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000ul - if (p == NULL) - p = (void *) VSYSCALL_ADDR_vgettimeofday; - PTR_MANGLE (p); - __vdso_gettimeofday = p; - - p = _dl_vdso_vsym ("clock_gettime", &linux26); + void *p = _dl_vdso_vsym ("clock_gettime", &linux26); PTR_MANGLE (p); __GI___vdso_clock_gettime = p; @@ -55,14 +43,6 @@ _libc_vdso_platform_setup (void) p = (void *) VSYSCALL_ADDR_vgetcpu; PTR_MANGLE (p); __vdso_getcpu = p; - - p = _dl_vdso_vsym ("time", &linux26); - /* If the vDSO is not available we fall back on the old vsyscall. */ -#define VSYSCALL_ADDR_vtime 0xffffffffff600400 - if (p == NULL) - p = (void *) VSYSCALL_ADDR_vtime; - PTR_MANGLE (p); - __vdso_time = p; } # define VDSO_SETUP _libc_vdso_platform_setup diff --git a/sysdeps/unix/sysv/linux/x86_64/time.S b/sysdeps/unix/sysv/linux/x86_64/time.c index 66d7498cef..698d56156c 100644 --- a/sysdeps/unix/sysv/linux/x86_64/time.S +++ b/sysdeps/unix/sysv/linux/x86_64/time.c @@ -16,32 +16,32 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <sysdep.h> -#define _ERRNO_H 1 -#include <bits/errno.h> +#include <dl-vdso.h> + -/* For the calculation see asm/vsyscall.h. */ #define VSYSCALL_ADDR_vtime 0xffffffffff600400 -/* Return the current time as a `time_t' and also put it in *T if T is - not NULL. Time is represented as seconds from Jan 1 00:00:00 1970. */ +#ifdef SHARED +void *time_ifunc (void) __asm__ ("time"); -ENTRY (time) - /* Align stack. */ - sub $0x8, %rsp - cfi_adjust_cfa_offset(8) +void * +time_ifunc (void) +{ + PREPARE_VERSION (linux26, "LINUX_2.6", 61765110); -#ifdef SHARED - movq __vdso_time(%rip), %rax - PTR_DEMANGLE (%rax) + /* If the vDSO is not available we fall back on the old vsyscall. */ + return _dl_vdso_vsym ("time", &linux26) ?: (void *) VSYSCALL_ADDR_vtime; +} +__asm (".type time, %gnu_indirect_function"); #else - movq $VSYSCALL_ADDR_vtime, %rax +# include <time.h> + +time_t +time (time_t *t) +{ + return ((time_t (*) (time_t *)) VSYSCALL_ADDR_vtime) (t); +} #endif - callq *%rax - add $0x8, %rsp - cfi_adjust_cfa_offset(-8) - ret -PSEUDO_END_NOERRNO(time) -libc_hidden_def (time) +strong_alias (time, __GI_time) |