From patchwork Tue Dec 17 21:47:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 36925 Received: (qmail 110558 invoked by alias); 17 Dec 2019 21:47:47 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 110480 invoked by uid 89); 17 Dec 2019 21:47:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=consolidate, Consolidate X-HELO: mail-pl1-f195.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=31A2C6VnVSuXF7lIk8i3xpCvP5CNKJdQz45WdnEsO2A=; b=pxnjT+D3nRMtKrg/D+vIhTLnk9ESZIDhqoKfIleNLIPyPuOOib1ap2tDZ50N5JChlm N1r57kqWIUiVm+aYzAxiDHkqmhhkGPZD63jqXnreshfqLhFGEEdd8Mutr7fEeR7qYu/R yEJAi6FJQ/2VkUOPggKIt/0NsbpoBzlBcNPudW7gSi0MLHvSXecR3wkafoe5ldoG2QdY OOKHK/xQLOO1ytAz0+UNZWLNN8dux1sFbiR0HG4bNSo9Yowl0dXWJ9rL5Zkrk1C0khRO rO+oQ7bQ+245C0sAyBred9qyyFdj4IXQWm8tr/TSTOyg7Olmmu31CMgk/0WyRFUfMrrw I+Qg== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 07/16] linux: Consolidate time implementation Date: Tue, 17 Dec 2019 18:47:19 -0300 Message-Id: <20191217214728.2886-7-adhemerval.zanella@linaro.org> In-Reply-To: <20191217214728.2886-1-adhemerval.zanella@linaro.org> References: <20191217214728.2886-1-adhemerval.zanella@linaro.org> The IFUNC bypass to vDSO is used when USE_IFUNC_TIME is set. Currently powerpc and x86 defines it. Otherwise the generic implementation is used, which calls clock_gettime. Checked on powerpc64le-linux-gnu, powerpc64-linux-gnu, powerpc-linux-gnu-power4, x86_64-linux-gnu, and i686-linux-gnu. Reviewed-by: Siddhesh Poyarekar --- sysdeps/unix/sysv/linux/powerpc/time.c | 32 +--------------- sysdeps/unix/sysv/linux/time.c | 51 ++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/x86/time.c | 27 +------------- 3 files changed, 55 insertions(+), 55 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/time.c diff --git a/sysdeps/unix/sysv/linux/powerpc/time.c b/sysdeps/unix/sysv/linux/powerpc/time.c index f2b4c76be8..3622ef48f6 100644 --- a/sysdeps/unix/sysv/linux/powerpc/time.c +++ b/sysdeps/unix/sysv/linux/powerpc/time.c @@ -16,33 +16,5 @@ License along with the GNU C Library; if not, see . */ -#include -#include -#include - -static time_t -time_vsyscall (time_t *t) -{ - return INLINE_VSYSCALL (time, 1, t); -} - -#ifdef SHARED -# include -# include - -# define INIT_ARCH() \ - void *vdso_time = get_vdso_symbol (HAVE_TIME_VSYSCALL); - -/* If the vDSO is not available we fall back to the syscall. */ -libc_ifunc (time, - vdso_time - ? VDSO_IFUNC_RET (vdso_time) - : (void *) time_vsyscall); - -#else -time_t -time (time_t *t) -{ - return time_vsyscall (t); -} -#endif /* !SHARED */ +#define USE_IFUNC_TIME +#include diff --git a/sysdeps/unix/sysv/linux/time.c b/sysdeps/unix/sysv/linux/time.c new file mode 100644 index 0000000000..0598958c9c --- /dev/null +++ b/sysdeps/unix/sysv/linux/time.c @@ -0,0 +1,51 @@ +/* time -- Get number of seconds since Epoch. Linux version. + Copyright (C) 2019 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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* Some architecture might optimize the time by setting the plt direct + to vDSO symbol by using a IFUNC. */ +#ifdef USE_IFUNC_TIME +# include +# include +# include + +#ifdef SHARED +# include + +static time_t +time_syscall (time_t *t) +{ + return INLINE_SYSCALL_CALL (time, t); +} + +# undef INIT_ARCH +# define INIT_ARCH() \ + void *vdso_time = get_vdso_symbol (HAVE_TIME_VSYSCALL); +libc_ifunc (time, + vdso_time ? VDSO_IFUNC_RET (vdso_time) + : (void *) time_syscall); + +# else +time_t +time (time_t *t) +{ + return INLINE_VSYSCALL (time, 1, t); +} +# endif /* !SHARED */ +#else /* USE_IFUNC_TIME */ +# include