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: 181918 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp6350276ile; Tue, 17 Dec 2019 13:48:52 -0800 (PST) X-Google-Smtp-Source: APXvYqx073LuB84fJh8rbfcRZv0xXLli6UG4Qc6Hz2IowoKSZtMtARZM9pEPRtzMQLbvdbgm/zsw X-Received: by 2002:a9d:6652:: with SMTP id q18mr40591588otm.321.1576619332623; Tue, 17 Dec 2019 13:48:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576619332; cv=none; d=google.com; s=arc-20160816; b=tS9pxbBHyQqMFp9R7nF/V3Je/guOkPOXHoY/Wsr6WWzkio9UQMwVMlFm0xu8KZ0BLv pokehrRZKBytaktykE+5usx9EbcZKwG+6t3kSrZUeNHjGl+scgZBqSmSCV+9foqB7i4u 4sBammhCCkLD3QL0OFd/SGzGBmyRz5Co4JpGhIuqivxYH7EaDWRz9ZgY6FGzNN1p7LQ9 r5ylupZuN0oWjH1yyEXmRFi1sqvNXQ1x4c4NQxh/OEwILGvILCZeRirHkue9phv29QB6 02JDNjsxBYrXhJz5aNLBzuuMoWrH6vlI0NjEv8WUobxPvEAlXTDdcxBxJlJGCli0Xq/w Jvzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=31A2C6VnVSuXF7lIk8i3xpCvP5CNKJdQz45WdnEsO2A=; b=y7fj7XqTKpm/zjRtMbFue1gwWsq3xOwFaBhHhoSV1CBuP1daeJo6e0KyV4J8hlzziv OOlYeyrhVJFudr36NVbXmOSk+TG8J7s4AgpBPpLKZGJdEp0PniJ5T3TUUfBgTYb8jCeq LZFrEHl/6m7URyLzf66nplWsSTcWrrALKM32bEcMinyLphkyakjfHZ+PerLx2cfEbog1 Q4noEZpw9H+7d+2wcfoT9tIakhwqqZHSb7/lQCm9qMG4J+faBuxN6zfehQ9C4NsPalP1 zegSW0cl+BCxHVbHoiAp/LiR8q2/hnAuPqn/WIO9V1RdtHvE47k7+MhGgECpKL2azERz frTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=sufD3b+9; dkim=pass header.i=@linaro.org header.s=google header.b=pxnjT+D3; spf=pass (google.com: domain of libc-alpha-return-108169-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-108169-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id x16si13053899otp.184.2019.12.17.13.48.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Dec 2019 13:48:52 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-108169-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=sufD3b+9; dkim=pass header.i=@linaro.org header.s=google header.b=pxnjT+D3; spf=pass (google.com: domain of libc-alpha-return-108169-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-108169-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=xS+93cqD5nkBAGGXOaqjCgRuY7a3na2 VnftD69O+nwKgUH2mTm0N6X/J4c9fGojQ97YEiJU3vliwfDcM9IOJNY6rhmsjTcY tOIxFcbq/vyohVfEeHqL9LRjwHic4NHJm55tnJvtvzASe6mezVwOlz+uTdCRmO/S uShFFhd5k/o8= 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=sufD3 b+9yM9qRSg+FfDYxMzoAd+dQEWXmCrO1P/YnrdnDbEFT++3BVAjOhpGqbBrRgKww 383eGr98FL+KrUD/oDBgpYT4QhiKMDFadQ18rGrZs7+hLM7I+v867C4eKtp0Wnz0 P5zI87cJlbiM8pd/Nse9Yhk4tDNGXFbgKqFF4E= 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. --- 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 -- 2.17.1 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