From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 5CC4A1F463 for ; Tue, 17 Dec 2019 21:48:45 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=IFS6Idp7mNVpDtmHpfj3f8e5MVawhtw Uyc5dLheNCWiqAxDOZrklqHHVS+WeZ2W/n6GcQh1PaxGj7FBhHUhG73E5Qo5dT6p 68XhjBgZnm+LMwVFPDtvRGs5wYkG8N07TxUUR6B6OrKokj0WHO39uPzMObc1dxVD h+hk41YIm1E4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=xrtSw4rVaeYdgXAErvuBvBiMfS4=; b=iAtNk quXLKFfXZpdplRTGFPoI/b9OD21VhnzlQAG81exqgV2ByJgSZRhhI7bBcmuuFwzD 8+AVjFqQ6qzoRivOfSTNDIH1MWO9TOFMBSoU/MAmOPjhl37EHatA+PMQC/6NdG0l fRnllsCi6FgTMlPSxXoZGGxx8kvFnOTUly3b3Q= 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 Received: (qmail 110480 invoked by uid 89); 17 Dec 2019 21:47:47 -0000 Authentication-Results: sourceware.org; auth=none 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== 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. --- 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