From patchwork Fri Jun 14 15:29:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 166839 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2202928ilk; Fri, 14 Jun 2019 08:31:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7dFCOX8PS1LD3reNw7gB6wMMSk9bqASYj93G+ml9v8Uaij5EAJ9vfEoKm8woEHbLctotr X-Received: by 2002:a62:fccd:: with SMTP id e196mr27002834pfh.53.1560526284663; Fri, 14 Jun 2019 08:31:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560526284; cv=none; d=google.com; s=arc-20160816; b=hXGprD/WS00BEo/eSL1hMBt7lMm7YK7AE76iVjP1S978laOX4PEX/PykSEE2im1l1/ OOErhdGIELSpq+slwvEdaRpz3FlKZEf2RMeVQ3RKCAmz4ElfuUw53mbslx6qF952fkQf O7f8SVPHtHffvQqURJxofMvviI7NYdJi+IBTz5FLoehFiWhlARTkynFO8ZYTByeTS6SZ S28qwxB5qpLJHUEb7V4wkPM7mifInkSkyUGPPjVmpGqeSB6Qv+QU9Uw7Qgnw50KMEIYe bJIL9kVEjDSSA3AsGLyzMadypZ9EK8sqv1sKGVze9JXAiAeJqbmMDDv7cyYnKbelYJ3N EQ7w== 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=V8L5eKvYtMEJWUg+mj01H9rLBXOON/MM/T14+E1vSo4=; b=khLCtHpPqXBnNF+1k3zxSXch4UZO/hiTxLXKRmIwYevTUh1hiNneog0DCM9VXVuxui qrHsxsw9XV+jYOpjCczY9bovU/eSp0LT/IPcQsLGPLwF6wgTdCNnAqKI+mQOs3RzRG7C ANIlozNlckyGGqq4ZHO154IwOxTC/RrZa60VU+0GBIlySk4ZBHXfyQNsjB0QDB8O4peT YTtiWM1Q313MCabm6d2KaJA0S2RU/1NSJGYIfVH1hXHEUHH+cz0USHY3WEQIY7WCFt17 V0ckfqHuLONszTjmZqjekub2Ww4UWbuY+a99rmLB9FiHQLPrKaezlBuZsXn9go+l+jeU suCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=AzBxCdBm; dkim=pass header.i=@linaro.org header.s=google header.b=RWmMSzw1; spf=pass (google.com: domain of libc-alpha-return-102745-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-102745-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 g129si2702311pfb.181.2019.06.14.08.31.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jun 2019 08:31:24 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-102745-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=AzBxCdBm; dkim=pass header.i=@linaro.org header.s=google header.b=RWmMSzw1; spf=pass (google.com: domain of libc-alpha-return-102745-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-102745-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=N+ndxlL8O3LrZlE/MVmGIVB9UbSFYHy Brjns0vIc84nucBNRx8tI/vUXpce6ji7pwk8tHsZsohDJFFYdnDsNskbHAA1uBTp KiOPpsCTy1WA4yBTYNVwZxtIzUhm0+ltTSAnCeCNVkmPqNEMCMIF6NI16MWLn7N8 hM8RAeX+ZXLs= 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=d2MAcsIS/A116oSj2WNLqA3tQSc=; b=AzBxC dBm00zGSrx3ppO3vSER5+i/YgF+h+ZzT5Cl3RGbfTAWYekog2ww2z9YYuMHMCToG P08GTu1gHBdO/TNctGu+ytVY7x/T3/7AA2f67z8EBmyS/LHAFpksYvbNvUo4xl2Q f+yEHEsDcwuuCIFuLaPhDsYtLwhXfGxRZXR7vk= Received: (qmail 118604 invoked by alias); 14 Jun 2019 15:29:33 -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 118479 invoked by uid 89); 14 Jun 2019 15:29:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.6 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, RCVD_IN_JMF_BR, SPF_PASS autolearn=ham version=3.3.1 spammy=2018-2019, 20182019, 1624 X-HELO: mail-vs1-f66.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=V8L5eKvYtMEJWUg+mj01H9rLBXOON/MM/T14+E1vSo4=; b=RWmMSzw1FpXklYaVnnU6Lq/diLe5LDH7yCa9iWZRQXezaUDxmoaOK1jv8CGSZqASIp EnhTsD8e1I4XLlXz7BKL/vzorTizgANn6rbTp7BbYQMs8ajm/gn4HWtOELZP6yf4Aw+D j+EKSsCXZ/YZe72YwfFdJQ8OphUfsJpUK9Nz2FEI+dLpM1CUIdZtYKZnoAymIOUuHQR1 9Wj0Mixn14lPRQNzAFqchtfTx8161KcMIpLqvAPWjPc1ob//9p9kBwjqO2BLPxjBkqtz UqKCvr3dn+rJ8/E+YYcDk3rRdTuHHl9SxvzM+Fan1jcgnOeUStFbFY3/ebj4iiGcbPfX +Upw== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 12/12] linux: Consolidate gettimeofday implementation Date: Fri, 14 Jun 2019 12:29:08 -0300 Message-Id: <20190614152908.8101-12-adhemerval.zanella@linaro.org> In-Reply-To: <20190614152908.8101-1-adhemerval.zanella@linaro.org> References: <20190614152908.8101-1-adhemerval.zanella@linaro.org> The gettimeofday syscall has currently 3 possible implementations: 1. Wire-up __NR_gettimeofday with a VDSO implementation accessed directly through IFUNC (aarch64, x86, and powerpc*). 2. vDSO gettimeofday (arm, mips*, riscv*, s390, and sparc). 3. Wire-up __NR_gettimeofday (alpha, hppa, ia64, m68k, microblaze, nios, sh4). This patch consolidates all implementation on Linux generic sysdeps/unix/sysv/linux/gettimeofday.c. To simplify the code, some changes are made: * The wire-up with vDSO implementation may route external calls directly to vDSO through IFUNC. To enable it the architecture need to explicit define USE_GETTIMEOFDAY_VSYSCALL_IFUNC. * Also, powerpc and x86 tries to route internal time usages to IFUNC mechanism, which is problematic since powerpc32 and i686 does not really support it. Instead, all internal calls are routed to a default internal symbol which in turn calls INTERNAL_VSYSCALL. * Static linking also uses the fallback mechanism which calls INTERNAL_VSYSCALL, so vDSO is used for this case as well. The generic implementation issues a syscall as default, calls the vDSO if the architecture defines HAVE_GETTIMEOFDAY_VSYSCALL, and route the external calls to iFUNC if the architecture also defines USE_GETTIMEOFDAY_VSYSCALL_IFUNC. Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu, powerpc64-linux-gnu, powerpc64le-linux-gnu, and aarch64-linux-gnu. * sysdeps/unix/sysv/linux/aarch64/gettimeofday.c: Remove file. * sysdeps/unix/sysv/linux/i386/gettimeofday.c: Likewise. * sysdeps/unix/sysv/linux/powerpc/gettimeofday.c: Likewise. * sysdeps/unix/sysv/linux/x86/gettimeofday.c: Likewise. * sysdeps/unix/sysv/linux/aarch64/sysdep.h (USE_GETTIMEOFDAY_VSYSCALL_IFUNC): Define. * sysdeps/unix/sysv/linux/i386/sysdep.h (USE_GETTIMEOFDAY_VSYSCALL_IFUNC): Likewise. * sysdeps/unix/sysv/linux/x86_64/sysdep.h (USE_GETTIMEOFDAY_VSYSCALL_IFUNC): Likewise. * sysdeps/unix/sysv/linux/powerpc/sysdep.h (USE_GETTIMEOFDAY_VSYSCALL_IFUNC): Likewise. * sysdeps/unix/sysv/linux/gettimeofday.c (gettimeofday): Handle all possible Linux implementations (wire-up syscall, vDSO implementation, and iFUNC). (gettimeofday_syscall): New function. --- .../unix/sysv/linux/aarch64/gettimeofday.c | 59 ------------- sysdeps/unix/sysv/linux/aarch64/sysdep.h | 1 + sysdeps/unix/sysv/linux/gettimeofday.c | 47 ++++++++-- sysdeps/unix/sysv/linux/i386/gettimeofday.c | 35 -------- sysdeps/unix/sysv/linux/i386/sysdep.h | 1 + .../unix/sysv/linux/powerpc/gettimeofday.c | 85 ------------------- sysdeps/unix/sysv/linux/powerpc/sysdep.h | 1 + sysdeps/unix/sysv/linux/x86/gettimeofday.c | 63 -------------- sysdeps/unix/sysv/linux/x86_64/sysdep.h | 1 + 9 files changed, 44 insertions(+), 249 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/aarch64/gettimeofday.c delete mode 100644 sysdeps/unix/sysv/linux/i386/gettimeofday.c delete mode 100644 sysdeps/unix/sysv/linux/powerpc/gettimeofday.c delete mode 100644 sysdeps/unix/sysv/linux/x86/gettimeofday.c -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c deleted file mode 100644 index 2474a2c575..0000000000 --- a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2018-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 - . */ - -/* Get the current time of day and timezone information, - putting it into *tv and *tz. If tz is null, *tz is not filled. - Returns 0 on success, -1 on errors. */ - -#include - -#ifdef SHARED - -# include -# include - -/* Used as a fallback in the ifunc resolver if VDSO is not available - and for libc.so internal __gettimeofday calls. */ - -static int -__gettimeofday_vsyscall (struct timeval *tv, struct timezone *tz) -{ - return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); -} - -# define INIT_ARCH() - -libc_ifunc_hidden (__gettimeofday, __gettimeofday, - (get_vdso_symbol ("__vdso_gettimeofday") - ?: __gettimeofday_vsyscall)) -libc_hidden_def (__gettimeofday) - -#else - -# include -int -__gettimeofday (struct timeval *tv, struct timezone *tz) -{ - return INLINE_SYSCALL (gettimeofday, 2, tv, tz); -} -libc_hidden_def (__gettimeofday) - -#endif - -weak_alias (__gettimeofday, gettimeofday) -libc_hidden_weak (gettimeofday) diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h index d57f7232e2..526741ed82 100644 --- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h +++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h @@ -163,6 +163,7 @@ # define HAVE_CLOCK_GETRES_VSYSCALL "__kernel_clock_getres" # define HAVE_CLOCK_GETTIME_VSYSCALL "__kernel_clock_gettime" # define HAVE_GETTIMEOFDAY_VSYSCALL "__kernel_gettimeofday" +# define USE_GETTIMEOFDAY_VSYSCALL_IFUNC 1 /* Previously AArch64 used the generic version without the libc_hidden_def which lead in a non existent __send symbol in libc.so. */ diff --git a/sysdeps/unix/sysv/linux/gettimeofday.c b/sysdeps/unix/sysv/linux/gettimeofday.c index a74f03825a..ed46723803 100644 --- a/sysdeps/unix/sysv/linux/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/gettimeofday.c @@ -16,24 +16,57 @@ License along with the GNU C Library; if not, see . */ -#include -#include +/* Currently we have 3 possible gettimeofday implementations, which is also + selected in the order: + + 1. Wire-up __NR_gettimeofday with a vDSO implementation (currently aarch64, + x86, and powerpc). + + 2. vDSO gettimeofday (arm, mips*, riscv*, s390, and sparc). + 3. Wire-up __NR_gettimeofday (alpha, hppa, ia64, m68k, microblaze, + nios, sh4). */ + +#define __gettimeofday __redirect___gettimeofday +#include #undef __gettimeofday +#include #ifdef HAVE_GETTIMEOFDAY_VSYSCALL # define HAVE_VSYSCALL #endif #include +#include + +/* Get the current time of day and timezone information, putting it into *tv + and *tz. If tz is null, *tz is not filled. Returns 0 on success, -1 on + errors. */ +static int +gettimeofday_syscall (struct timeval *tv, struct timezone *tz) +{ + return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); +} + +#if HAVE_IFUNC && defined USE_GETTIMEOFDAY_VSYSCALL_IFUNC +/* Route externals calls direct to vDSO and static and internal calls to + fallback implementation (which also might call the vDSO). */ +# ifdef SHARED +# define INIT_ARCH() +libc_ifunc_redirected (__redirect___gettimeofday, __gettimeofday, + get_vdso_symbol (HAVE_GETTIMEOFDAY_VSYSCALL) + ?: gettimeofday_syscall); +libc_hidden_def_redir (gettimeofday_syscall, __gettimeofday) +# else +strong_alias (gettimeofday_syscall, __gettimeofday) +# endif /* SHARED */ +#else -/* Get the current time of day and timezone information, - putting it into *tv and *tz. If tz is null, *tz is not filled. - Returns 0 on success, -1 on errors. */ int __gettimeofday (struct timeval *tv, struct timezone *tz) { - return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); + return gettimeofday_syscall (tv, tz); } -libc_hidden_def (__gettimeofday) +libc_hidden_def_redir (__gettimeofday, __gettimeofday) +#endif weak_alias (__gettimeofday, gettimeofday) libc_hidden_weak (gettimeofday) diff --git a/sysdeps/unix/sysv/linux/i386/gettimeofday.c b/sysdeps/unix/sysv/linux/i386/gettimeofday.c deleted file mode 100644 index 185450ece6..0000000000 --- a/sysdeps/unix/sysv/linux/i386/gettimeofday.c +++ /dev/null @@ -1,35 +0,0 @@ -/* gettimeofday - get the time. Linux/i386 version. - Copyright (C) 2015-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 - . */ - -#ifdef SHARED -# define __gettimeofday __redirect___gettimeofday -#endif - -#include - -#ifdef SHARED -# undef __gettimeofday -# define __gettimeofday_type __redirect___gettimeofday - -# undef libc_hidden_def -# define libc_hidden_def(name) \ - __hidden_ver1 (__gettimeofday_syscall, __GI___gettimeofday, \ - __gettimeofday_syscall); -#endif - -#include diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h index 4f79f25989..076e4393d3 100644 --- a/sysdeps/unix/sysv/linux/i386/sysdep.h +++ b/sysdeps/unix/sysv/linux/i386/sysdep.h @@ -315,6 +315,7 @@ struct libc_do_syscall_args /* List of system calls which are supported as vsyscalls. */ # define HAVE_CLOCK_GETTIME_VSYSCALL "__vdso_clock_gettime" # define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday" +# define USE_GETTIMEOFDAY_VSYSCALL_IFUNC 1 # define HAVE_TIME_VSYSCALL "__vdso_time" # define USE_TIME_VSYSCALL_IFUNC 1 diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c deleted file mode 100644 index 7a4e3cca0c..0000000000 --- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c +++ /dev/null @@ -1,85 +0,0 @@ -/* Copyright (C) 2005-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 - . */ - -#if defined SHARED && !defined __powerpc64__ -# define __gettimeofday __redirect___gettimeofday -#else -# define __redirect___gettimeofday __gettimeofday -#endif - -#include - -#ifdef SHARED - -# include -# include -# include - -# ifndef __powerpc64__ -# undef __gettimeofday - -int -__gettimeofday_vsyscall (struct timeval *tv, struct timezone *tz) -{ - return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); -} - -/* __GI___gettimeofday is defined as hidden and for ppc32 it enables the - compiler make a local call (symbol@local) for internal GLIBC usage. It - means the PLT won't be used and the ifunc resolver will be called directly. - For ppc64 a call to a function in another translation unit might use a - different toc pointer thus disallowing direct branchess and making internal - ifuncs calls safe. */ -# undef libc_hidden_def -# define libc_hidden_def(name) \ - __hidden_ver1 (__gettimeofday_vsyscall, __GI___gettimeofday, \ - __gettimeofday_vsyscall); - -# endif /* !__powerpc64__ */ - -static int -__gettimeofday_syscall (struct timeval *tv, struct timezone *tz) -{ - return INLINE_SYSCALL (gettimeofday, 2, tv, tz); -} - -# define INIT_ARCH() \ - void *vdso_gettimeofday = get_vdso_symbol (HAVE_GETTIMEOFDAY_VSYSCALL) - - -/* If the vDSO is not available we fall back syscall. */ -libc_ifunc_hidden (__redirect___gettimeofday, __gettimeofday, - vdso_gettimeofday - ? vdso_gettimeofday - : (void *) __gettimeofday_syscall); -libc_hidden_def (__gettimeofday) - -#else - -# include -# include - -int -__gettimeofday (struct timeval *tv, struct timezone *tz) -{ - return INLINE_SYSCALL (gettimeofday, 2, tv, tz); -} -libc_hidden_def (__gettimeofday) - -#endif -weak_alias (__gettimeofday, gettimeofday) -libc_hidden_weak (gettimeofday) diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h index 44bfa3f1b6..754832d580 100644 --- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h +++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h @@ -26,6 +26,7 @@ #define HAVE_TIME_VSYSCALL "__kernel_time" #define USE_TIME_VSYSCALL_IFUNC 1 #define HAVE_GETTIMEOFDAY_VSYSCALL "__kernel_gettimeofday" +#define USE_GETTIMEOFDAY_VSYSCALL_IFUNC 1 #define HAVE_GET_TBFREQ "__kernel_get_tbfreq" #if defined(__PPC64__) || defined(__powerpc64__) diff --git a/sysdeps/unix/sysv/linux/x86/gettimeofday.c b/sysdeps/unix/sysv/linux/x86/gettimeofday.c deleted file mode 100644 index 3ceab633e5..0000000000 --- a/sysdeps/unix/sysv/linux/x86/gettimeofday.c +++ /dev/null @@ -1,63 +0,0 @@ -/* gettimeofday - get the time. Linux/x86 version. - Copyright (C) 2015-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 - . */ - -#include - -#ifdef SHARED - -# include -# include -# include -# include - -static int -__gettimeofday_syscall (struct timeval *tv, struct timezone *tz) -{ - return INLINE_SYSCALL (gettimeofday, 2, tv, tz); -} - -# ifndef __gettimeofday_type -/* The i386 gettimeofday.c includes this file with a defined - __gettimeofday_type macro. For x86_64 we have to define it to __gettimeofday - as the internal symbol is the ifunc'ed one. */ -# define __gettimeofday_type __gettimeofday -# endif - -# define INIT_ARCH() - -/* If the vDSO is not available we fall back to syscall. */ -libc_ifunc_hidden (__gettimeofday_type, __gettimeofday, - (get_vdso_symbol ("__vdso_gettimeofday") - ?: __gettimeofday_syscall)); -libc_hidden_def (__gettimeofday) - -#else - -# include -# include - -int -__gettimeofday (struct timeval *tv, struct timezone *tz) -{ - return INLINE_SYSCALL (gettimeofday, 2, tv, tz); -} -libc_hidden_def (__gettimeofday) - -#endif -weak_alias (__gettimeofday, gettimeofday) -libc_hidden_weak (gettimeofday) diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h index c64fbd1e26..4ea9c4fa31 100644 --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h @@ -376,6 +376,7 @@ /* List of system calls which are supported as vsyscalls. */ # define HAVE_CLOCK_GETTIME_VSYSCALL "__vdso_clock_gettime" # define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday" +# define USE_GETTIMEOFDAY_VSYSCALL_IFUNC 1 # define HAVE_TIME_VSYSCALL "__vdso_time" # define USE_TIME_VSYSCALL_IFUNC 1 # define HAVE_GETCPU_VSYSCALL "__vdso_getcpu"