From patchwork Thu Sep 5 20:56:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 173185 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp1238820ilq; Thu, 5 Sep 2019 13:57:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzewyE2xaTiDCLXfU2xADcDCxBHnFSFwTT49+HgKBwS5ya/S6VGo7iUpXPB4NZ1la2iO9n3 X-Received: by 2002:a63:2b84:: with SMTP id r126mr5113352pgr.308.1567717075167; Thu, 05 Sep 2019 13:57:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567717075; cv=none; d=google.com; s=arc-20160816; b=q8q67m1fhh3ubWOVm3qWSlfWZDj8vI76vB789piM8Z9ayVsHaGoyqae3TSzugGW27P JLxNe5gaax8AQEx0PtJgNhO8GHM2Qx3yrogeVvE9sTlrcTVPHeLIHhz1WJMkdoeLOKSs lgZpP4O5CKYlGTh04mJMaiJgCjFnD7pY2Pk2K0pd4yvg1P+hOoHYhiU/IgXcYd/b4wGM 5Z54S9XZl+WAPX88oLzQxd6QRZieUPq+cigYn6n030Vysm2TvT5HFKsK+YgLwjfL+kuC jF/9SQkPZoKyRVaG0fu5XlkObVwFv+aeGfK3UgL8I6XwHwO54ri9ubWRnY1xwAf9x0Xw UHlQ== 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=MWQuXfMf3IWTXs8matr+lGt67d/nvAusyTdZyVJFT8o=; b=LLz1l4eYs1PBYISaqkhSrVpreEcE5Oyp6316nEzwiOx6ROkZ16so4mxv1bkznVmyX1 j/Vgk8sPeYX1CPSpgvCFPh/XnKCzm3ZaSljHv49Kz6pa+pspF5cphvPd0HztRaXGiNmM Z5ktqXtp6vxiDOvG9VO63QMYowVDzhZXR+aIss2hZ6BreYJ4jd7LEQD+4hbKEGv/7Xp1 uBJHOPhLUy3McvHMRY2kfe9HvUq9eXHTTkvoCoPgkmZ2zDtZcIDBTiX7sZKcypbCgw4j 9+UL9ePApyzL9KLnuDK/8XOGT2b9Tdl3U74MUb1JhNeweKsXf/2VT2IKX9gXXGJLxq7R dgrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=yVPTgnsz; dkim=pass header.i=@linaro.org header.s=google header.b=a5J40TiB; spf=pass (google.com: domain of libc-alpha-return-105070-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105070-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 b9si3127826plz.140.2019.09.05.13.57.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Sep 2019 13:57:55 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105070-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=yVPTgnsz; dkim=pass header.i=@linaro.org header.s=google header.b=a5J40TiB; spf=pass (google.com: domain of libc-alpha-return-105070-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105070-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=JLm3Ov+jXxnw/EZ+wGP4h4Khq0RaeHx wtskJsl2hIAeQkMKxc9UCY2YWvqUPrHkvWc0miLFo9mT8Tvo/TCC08q/rjvDYTuC T+eA8VCGdWoqfVxruK7Mh4Vg1c1fxJjYEUDNQRgboehoZKbkUCubf963pE/bIFhE LUGwbt9fO8r8= 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=EJCqriYsbr/8oST/OE+TWeB5Cno=; b=yVPTg nsz+BLM62JVZ6rZgVvcddro2/kGeraXt+HXkN2B8NTqfkIjtQDMXvURHNoHINjV+ p5scERt5Sp0BC1xowY+86uoEulJY6ZHaIs7jgt6fUjt4ACbQK9CN78hPRf+Dyqof izqRX1jQ+TL8f2kx6VxzQKuqYjBHQ2ZZ+JL5RQ= Received: (qmail 117720 invoked by alias); 5 Sep 2019 20:56:41 -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 117651 invoked by uid 89); 5 Sep 2019 20:56:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.1 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=H*RU:209.85.160.196, HX-Spam-Relays-External:209.85.160.196 X-HELO: mail-qt1-f196.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=MWQuXfMf3IWTXs8matr+lGt67d/nvAusyTdZyVJFT8o=; b=a5J40TiB79uImJIioqez3S1jVGtx6bjCVrUX2V+eLiEbBlbdJp6heIBK5wh2VTEQsj 41iVOUHoqwi4ZivFUolHJJ4KoCdSadPlNh/zH57wK4fN7YWQ84IYF+46alqKZw6D34N+ idAhzYVaj7DalDQnDq1gBRBU0aRKWoF6nLh0ycDTiJnV8ybosNPaulYqIpNn17KgP61G QKwCNbAFPeqov1Q9NmXH/6Suz0vcqTU/zWiUMMIzdypFh+xkPgxRPdGmF6+qag2t6FCu odrMjBkyFHoN1xiOgxYa3Z5VqWrISn5SxflzypcKYSBGiSV754lq9ATPWqNUFgZudL+d F5oQ== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 8/8] linux: Consolidate gettimeofday implementation Date: Thu, 5 Sep 2019 17:56:20 -0300 Message-Id: <20190905205620.4646-8-adhemerval.zanella@linaro.org> In-Reply-To: <20190905205620.4646-1-adhemerval.zanella@linaro.org> References: <20190905205620.4646-1-adhemerval.zanella@linaro.org> Changes from previous version: - Update due powerpc64 fixes. -- 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 | 58 ------------- sysdeps/unix/sysv/linux/aarch64/sysdep.h | 1 + sysdeps/unix/sysv/linux/gettimeofday.c | 51 +++++++++-- sysdeps/unix/sysv/linux/i386/gettimeofday.c | 35 -------- sysdeps/unix/sysv/linux/i386/sysdep.h | 1 + .../unix/sysv/linux/powerpc/gettimeofday.c | 84 ------------------- 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, 48 insertions(+), 247 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 9499a11fda..0000000000 --- a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c +++ /dev/null @@ -1,58 +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..833e97ca7d 100644 --- a/sysdeps/unix/sysv/linux/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/gettimeofday.c @@ -16,24 +16,61 @@ 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 +# undef INIT_ARCH +# define INIT_ARCH() \ + void *vdso_gettimeofday = get_vdso_symbol (HAVE_GETTIMEOFDAY_VSYSCALL) + +libc_ifunc_redirected (__redirect___gettimeofday, __gettimeofday, + vdso_gettimeofday + ? VDSO_IFUNC_RET (vdso_gettimeofday) + : (void *) 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 e046594d40..0000000000 --- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c +++ /dev/null @@ -1,84 +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_IFUNC_RET (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 084b6525ca..743eb67557 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"