From patchwork Wed Aug 28 15:32:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zack Weinberg X-Patchwork-Id: 34310 Received: (qmail 14864 invoked by alias); 28 Aug 2019 15:32:54 -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 14776 invoked by uid 89); 28 Aug 2019 15:32:54 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mailbackend.panix.com From: Zack Weinberg To: libc-alpha@sourceware.org Cc: Joseph Myers , Florian Weimer , Lukasz Majewski , Alistair Francis , Stepan Golosunov , Arnd Bergmann , Adhemerval Zanella , Samuel Thibault Subject: [PATCH v2 08/10] Use clock_gettime to implement gettimeofday. Date: Wed, 28 Aug 2019 11:32:34 -0400 Message-Id: <20190828153236.18229-9-zackw@panix.com> In-Reply-To: <20190828153236.18229-1-zackw@panix.com> References: <20190828153236.18229-1-zackw@panix.com> MIME-Version: 1.0 Remove sysdeps/unix/clock_gettime.c, which implemented clock_gettime using gettimeofday; new OS ports must provide a real implementation of clock_gettime. Rename sysdeps/mach/gettimeofday.c to sysdeps/mach/clock_gettime.c and convert into an implementation of clock_gettime. It only supports CLOCK_REALTIME; Mach does not appear to have any support for monotonic clocks. It uses __host_get_time, which provides at best microsecond resolution. Hurd is currently using sysdeps/posix/clock_getres.c for clock_getres; its output for CLOCK_REALTIME is based on sysconf (_SC_CLK_TCK), and I do not know whether that gives the correct result. Most Linux ports supplied a vDSO symbol for gettimeofday, and some wrapped that with an ifunc, so this patch deletes a lot of code. For ease of future edits to the many copies of _libc_vdso_platform_setup, the variable "p" in each is now declared separately from any use of it. Unlike settimeofday, there are no known uses of gettimeofday's vestigial "get time zone" feature that are not bugs. (The per-process timezone support in localtime and friends is unrelated, and the programs that set the kernel's offset between the hardware clock and UTC do not need to read it back.) Therefore, this feature is dummied out. Henceforth, if gettimeofday's "struct timezone" argument is not NULL, it will write zeroes to both fields. Any program that is actually looking at this data will thus think it is running in UTC, which is probably more correct than whatever it was doing before. [__]gettimeofday no longer has any internal callers, so we can now remove its internal prototype and PLT bypass aliases. The __gettimeofday@GLIBC_2.0 export remains, in case it is used by any third-party code. * time/gettimeofday.c: No longer a stub implementation. Call __clock_gettime. If tz argument is not NULL, clear the object it points to. Remove libc_hidden_* for __gettimeofday and gettimeofday. Optionally override the default symbol version for gettimeofday and __gettimeofday. * include/sys/time.h: Remove internal prototype and libc_hidden_proto for __gettimeofday, and libc_hidden_proto for gettimeofday. * sysdeps/unix/sysv/linux/alpha/gettimeofday.c: Switch to including time/gettimeofday.c. * sysdeps/unix/sysv/linux/alpha/osf_gettimeofday.c (gettimeofday@GLIBC_2.0): Use __clock_gettime instead of __gettimeofday. If tz argument is not NULL, clear the object it points to. * sysdeps/unix/sysv/linux/aarch64/init-first.c * sysdeps/unix/sysv/linux/arm/init-first.c * sysdeps/unix/sysv/linux/mips/init-first.c * sysdeps/unix/sysv/linux/powerpc/init-first.c * sysdeps/unix/sysv/linux/riscv/init-first.c * sysdeps/unix/sysv/linux/s390/init-first.c * sysdeps/unix/sysv/linux/sparc/init-first.c: Do not define nor initialize VDSO_SYMBOL(gettimeofday). * sysdeps/unix/sysv/linux/aarch64/libc-vdso.h * sysdeps/unix/sysv/linux/arm/libc-vdso.h * sysdeps/unix/sysv/linux/mips/libc-vdso.h * sysdeps/unix/sysv/linux/powerpc/libc-vdso.h * sysdeps/unix/sysv/linux/riscv/libc-vdso.h * sysdeps/unix/sysv/linux/s390/libc-vdso.h * sysdeps/unix/sysv/linux/sparc/libc-vdso.h: Do not declare VDSO_SYMBOL(gettimeofday). * sysdeps/unix/syscalls.list: Remove entry for gettimeofday. * sysdeps/unix/sysv/linux/alpha/syscalls.list: Remove entries for gettimeofday and osf_gettimeofday. * sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list: Remove entry for gettimeofday. * sysdeps/posix/gettimeofday.c * sysdeps/unix/clock_gettime.c * sysdeps/unix/sysv/linux/aarch64/gettimeofday.c * sysdeps/unix/sysv/linux/gettimeofday.c * sysdeps/unix/sysv/linux/i386/gettimeofday.c * sysdeps/unix/sysv/linux/powerpc/gettimeofday.c * sysdeps/unix/sysv/linux/x86/gettimeofday.c: Delete file. * sysdeps/mach/gettimeofday.c: Rename to sysdeps/mach/clock_gettime.c and convert into an implementation of clock_gettime. --- include/sys/time.h | 4 - sysdeps/{unix => mach}/clock_gettime.c | 37 ++++---- sysdeps/mach/gettimeofday.c | 43 ---------- sysdeps/posix/gettimeofday.c | 67 --------------- sysdeps/unix/syscalls.list | 1 - .../unix/sysv/linux/aarch64/gettimeofday.c | 71 ---------------- sysdeps/unix/sysv/linux/aarch64/init-first.c | 7 +- sysdeps/unix/sysv/linux/aarch64/libc-vdso.h | 2 - .../sysv/linux/{i386 => alpha}/gettimeofday.c | 25 ++---- .../unix/sysv/linux/alpha/osf_gettimeofday.c | 11 ++- sysdeps/unix/sysv/linux/alpha/syscalls.list | 1 - sysdeps/unix/sysv/linux/arm/init-first.c | 7 +- sysdeps/unix/sysv/linux/arm/libc-vdso.h | 2 - sysdeps/unix/sysv/linux/gettimeofday.c | 49 ----------- sysdeps/unix/sysv/linux/mips/init-first.c | 7 +- sysdeps/unix/sysv/linux/mips/libc-vdso.h | 2 - .../unix/sysv/linux/powerpc/gettimeofday.c | 85 ------------------- sysdeps/unix/sysv/linux/powerpc/init-first.c | 8 +- sysdeps/unix/sysv/linux/powerpc/libc-vdso.h | 2 - sysdeps/unix/sysv/linux/riscv/init-first.c | 10 +-- sysdeps/unix/sysv/linux/riscv/libc-vdso.h | 2 - sysdeps/unix/sysv/linux/s390/init-first.c | 9 +- sysdeps/unix/sysv/linux/s390/libc-vdso.h | 3 - sysdeps/unix/sysv/linux/sparc/init-first.c | 8 +- sysdeps/unix/sysv/linux/sparc/libc-vdso.h | 2 - sysdeps/unix/sysv/linux/x86/gettimeofday.c | 61 ------------- .../unix/sysv/linux/x86_64/x32/syscalls.list | 1 - time/gettimeofday.c | 32 ++++--- 28 files changed, 67 insertions(+), 492 deletions(-) rename sysdeps/{unix => mach}/clock_gettime.c (65%) delete mode 100644 sysdeps/mach/gettimeofday.c delete mode 100644 sysdeps/posix/gettimeofday.c delete mode 100644 sysdeps/unix/sysv/linux/aarch64/gettimeofday.c rename sysdeps/unix/sysv/linux/{i386 => alpha}/gettimeofday.c (58%) delete mode 100644 sysdeps/unix/sysv/linux/gettimeofday.c delete mode 100644 sysdeps/unix/sysv/linux/powerpc/gettimeofday.c delete mode 100644 sysdeps/unix/sysv/linux/x86/gettimeofday.c diff --git a/include/sys/time.h b/include/sys/time.h index a57752e8c7..4a91622096 100644 --- a/include/sys/time.h +++ b/include/sys/time.h @@ -20,10 +20,6 @@ # include