From patchwork Wed Aug 28 15:32:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zack Weinberg X-Patchwork-Id: 1154551 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-104811-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=panix.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="sgj7uVYF"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 46JV9r595Rz9sNF for ; Thu, 29 Aug 2019 01:32:48 +1000 (AEST) 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:cc:subject:date:message-id :mime-version:content-transfer-encoding; q=dns; s=default; b=xCa SsH13z4n/kHeQpL2wxsVkD+HFv3Kt+uUednBvd7WY+x39Vc0p4x2bvcrOrWy9oBC q4a/xuQqGY9opIURBdZZWBhE3LiQYcrWK5CephljylMMVRzGhASGBy42Z8RKZlJm BBTqQt/6A21Br7s2R6KhFnZCIoEdNdhg3ficDkLE= 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:cc:subject:date:message-id :mime-version:content-transfer-encoding; s=default; bh=MVFSwX+qM fJ2Q0N4/0wFNIXTp1s=; b=sgj7uVYFcfnieprehrWKinTrMMWF9tjUsE67RWLLe +m8yJ3QEdH90lTH+qJ2svWd4KybxRiQXDXlrfV0jaBeWaNcRKPjytX1/B+yK1TUl b2pgEGJhQi6KHSpwIIuRTYNAFANqA0ylsQd6dTl9iQnnuUcSI4TllnXPe8cKUzUt vE= Received: (qmail 13242 invoked by alias); 28 Aug 2019 15:32: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 13229 invoked by uid 89); 28 Aug 2019 15:32:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, SPF_PASS autolearn=ham version=3.3.1 spammy=withdraw, ease, patchset, consequences 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 00/10] Y2038 preparation: use clock_[gs]ettime to implement the other time-getting and -setting functions. Date: Wed, 28 Aug 2019 11:32:26 -0400 Message-Id: <20190828153236.18229-1-zackw@panix.com> MIME-Version: 1.0 This patchset aims to make the Y2038 project a little easier by implementing the other time-getting and time-setting functions (time, ftime, stime, gettimeofday, and settimeofday) in terms of clock_gettime and clock_settime. Internal uses of (__)gettimeofday are also all changed to __clock_gettime. Internal uses of time() are mostly left alone, since time() is easier and clearer when you don't care about sub-second resolution and don't need a struct timespec for some other reason. The user-visible consequences of this patchset are: - The obsolete functions ftime and stime are no longer available to new binaries. The header is no longer installed. - gettimeofday and ftime now always report a crude time zone corresponding to UTC. - settimeofday will fail with EINVAL when both of its arguments are non-null. - Programs that call gettimeofday with a non-null tzp argument will receive compile-time warnings (with GCC and when optimizing). - On Linux, the (v)syscalls time and gettimeofday are no longer used under any circumstances. See the final patch in the series for edits to NEWS describing these changes in more detail. This patchset also includes a partial revision of manual/time.tex.i clock_gettime and clock_settime are now documented, and the obsolescent status of stime, settimeofday, and gettimeofday is clearer. I only documented CLOCK_REALTIME and CLOCK_MONOTONIC, because most of the other clock constants are either extremely Linux-specific or they have to do with measuring CPU time, and I didn't touch the measuring-CPU-time part of time.texi. (That part also deserves a rewrite, but I don't know enough about the topic and this patchset is already long enough.) This patchset has a structural dependency on the patch "Linux/Alpha: don't use timeval32 system calls." I think that patch needs to be reviewed and discussed separately since it has implications for how we implement 32-bit time_t compatibility in general. Some but not all of the patches in this set could be re-done to avoid the dependency, but I don't think there's much point. Each individual patch in this series has been tested with build-many-glibcs targeting alpha-linux-gnu, i686-gnu, and x86_64-linux-gnu-enable-obsolete. The complete patch series has been tested with a full build-many-glibcs run and a full "make xcheck" run in the x86_64-linux-gnu-enable-obsolete configuration. Changes since v1: - Demote ftime and stime to compat symbols. - Also use clock_gettime to implement timespec_get. - Better implementation of warnings for gettimeofday with non-null tzp argument. - Patch series reorganized for ease of review and to ensure all intermediate stages work correctly on all supported platforms. In particular, gettimeofday and settimeofday have fully operational implementations on the Hurd at all stages of the series. - I believe all previous review comments have been addressed. Zack Weinberg (10): Change most internal uses of __gettimeofday to __clock_gettime. Finish move of clock_* functions to libc. Use clock_settime to implement stime; withdraw stime. Use clock_settime to implement settimeofday. Use clock_gettime to implement time. Use clock_gettime to implement ftime; withdraw ftime. Use clock_gettime to implement timespec_get. Use clock_gettime to implement gettimeofday. Warn when gettimeofday is called with non-null tzp argument. Revise the documentation of simple calendar time. NEWS | 62 +- conform/Makefile | 9 + debug/warning-nop.c | 9 + include/sys/time.h | 7 +- include/time.h | 4 +- inet/deadline.c | 8 +- login/logout.c | 9 +- login/logwtmp.c | 7 +- manual/filesys.texi | 2 +- manual/llio.texi | 10 +- manual/threads.texi | 2 +- manual/time.texi | 1071 ++++++++++------- nis/nis_call.c | 4 +- nptl/pthread_join_common.c | 7 +- nptl/pthread_mutex_timedlock.c | 7 +- nscd/nscd_helper.c | 24 +- resolv/gai_misc.c | 6 +- resolv/gai_suspend.c | 6 +- resolv/res_send.c | 7 +- rt/Makefile | 15 +- rt/Versions | 16 - rt/clock-compat.c | 63 - sunrpc/auth_des.c | 19 +- sunrpc/auth_unix.c | 9 +- sunrpc/create_xid.c | 6 +- sunrpc/svcauth_des.c | 7 +- support/support_test_main.c | 23 +- sysdeps/generic/memusage.h | 16 +- sysdeps/mach/clock_gettime.c | 51 + sysdeps/mach/gettimeofday.c | 43 - .../hurd/{settimeofday.c => clock_settime.c} | 36 +- sysdeps/mach/hurd/getitimer.c | 6 +- sysdeps/mach/hurd/i386/libc.abilist | 5 + sysdeps/mach/hurd/i386/librt.abilist | 5 - sysdeps/mach/hurd/setitimer.c | 8 +- sysdeps/mach/hurd/times.c | 7 +- sysdeps/mach/nanosleep.c | 36 +- sysdeps/mach/usleep.c | 5 - sysdeps/posix/clock_getres.c | 11 +- sysdeps/posix/gettimeofday.c | 67 -- sysdeps/posix/tempname.c | 9 +- sysdeps/posix/time.c | 40 - sysdeps/posix/timespec_get.c | 38 - sysdeps/pthread/aio_misc.c | 6 +- sysdeps/pthread/aio_suspend.c | 6 +- sysdeps/unix/bsd/ftime.c | 40 - sysdeps/unix/clock_gettime.c | 64 - sysdeps/unix/clock_nanosleep.c | 10 +- sysdeps/unix/clock_settime.c | 54 - sysdeps/unix/make-syscalls.sh | 2 +- sysdeps/unix/syscalls.list | 2 - .../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 - .../linux/{time.c => alpha/gettimeofday.c} | 31 +- sysdeps/unix/sysv/linux/alpha/libc.abilist | 5 + sysdeps/unix/sysv/linux/alpha/librt.abilist | 5 - .../unix/sysv/linux/alpha/osf_gettimeofday.c | 11 +- .../unix/sysv/linux/alpha/osf_settimeofday.c | 16 +- sysdeps/unix/sysv/linux/alpha/settimeofday.c | 22 + sysdeps/unix/sysv/linux/alpha/syscalls.list | 2 - sysdeps/unix/sysv/linux/arm/init-first.c | 7 +- sysdeps/unix/sysv/linux/arm/libc-vdso.h | 2 - sysdeps/unix/sysv/linux/arm/libc.abilist | 5 + sysdeps/unix/sysv/linux/arm/librt.abilist | 5 - sysdeps/unix/sysv/linux/clock_getcpuclockid.c | 10 +- sysdeps/unix/sysv/linux/clock_getres.c | 11 +- sysdeps/unix/sysv/linux/clock_gettime.c | 11 +- sysdeps/unix/sysv/linux/clock_nanosleep.c | 10 +- sysdeps/unix/sysv/linux/clock_settime.c | 11 +- sysdeps/unix/sysv/linux/ftime.c | 3 - sysdeps/unix/sysv/linux/gettimeofday.c | 49 - sysdeps/unix/sysv/linux/hppa/libc.abilist | 5 + sysdeps/unix/sysv/linux/hppa/librt.abilist | 5 - sysdeps/unix/sysv/linux/i386/gettimeofday.c | 35 - sysdeps/unix/sysv/linux/i386/libc.abilist | 5 + sysdeps/unix/sysv/linux/i386/librt.abilist | 5 - sysdeps/unix/sysv/linux/i386/time.c | 34 - sysdeps/unix/sysv/linux/ia64/libc.abilist | 5 + sysdeps/unix/sysv/linux/ia64/librt.abilist | 5 - .../sysv/linux/m68k/coldfire/libc.abilist | 5 + .../sysv/linux/m68k/coldfire/librt.abilist | 5 - .../unix/sysv/linux/m68k/m680x0/libc.abilist | 5 + .../unix/sysv/linux/m68k/m680x0/librt.abilist | 5 - .../unix/sysv/linux/microblaze/librt.abilist | 5 - sysdeps/unix/sysv/linux/mips/init-first.c | 7 +- sysdeps/unix/sysv/linux/mips/libc-vdso.h | 2 - .../sysv/linux/mips/mips32/fpu/libc.abilist | 5 + .../unix/sysv/linux/mips/mips32/librt.abilist | 5 - .../sysv/linux/mips/mips32/nofpu/libc.abilist | 5 + .../unix/sysv/linux/mips/mips64/librt.abilist | 5 - .../sysv/linux/mips/mips64/n32/libc.abilist | 5 + .../sysv/linux/mips/mips64/n64/libc.abilist | 5 + sysdeps/unix/sysv/linux/powerpc/Versions | 1 - .../unix/sysv/linux/powerpc/gettimeofday.c | 85 -- sysdeps/unix/sysv/linux/powerpc/init-first.c | 13 +- sysdeps/unix/sysv/linux/powerpc/libc-vdso.h | 2 - .../linux/powerpc/powerpc32/fpu/libc.abilist | 5 + .../linux/powerpc/powerpc32/librt.abilist | 5 - .../powerpc/powerpc32/nofpu/libc.abilist | 5 + .../linux/powerpc/powerpc64/be/libc.abilist | 5 + .../linux/powerpc/powerpc64/be/librt.abilist | 5 - sysdeps/unix/sysv/linux/powerpc/time.c | 84 -- 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 - .../unix/sysv/linux/s390/s390-32/libc.abilist | 5 + .../sysv/linux/s390/s390-32/librt.abilist | 5 - .../unix/sysv/linux/s390/s390-64/libc.abilist | 5 + .../sysv/linux/s390/s390-64/librt.abilist | 5 - .../{stime.c => sysv/linux/settimezone.c} | 30 +- sysdeps/unix/sysv/linux/sh/libc.abilist | 5 + sysdeps/unix/sysv/linux/sh/librt.abilist | 5 - sysdeps/unix/sysv/linux/sparc/init-first.c | 8 +- sysdeps/unix/sysv/linux/sparc/libc-vdso.h | 2 - .../sysv/linux/sparc/sparc32/libc.abilist | 5 + .../sysv/linux/sparc/sparc32/librt.abilist | 5 - .../sysv/linux/sparc/sparc64/libc.abilist | 5 + .../sysv/linux/sparc/sparc64/librt.abilist | 5 - sysdeps/unix/sysv/linux/sparc/sparc64/time.c | 1 - sysdeps/unix/sysv/linux/syscalls.list | 1 - sysdeps/unix/sysv/linux/timespec_get.c | 46 - sysdeps/unix/sysv/linux/x86/gettimeofday.c | 61 - sysdeps/unix/sysv/linux/x86/time.c | 59 - .../unix/sysv/linux/x86_64/64/libc.abilist | 5 + .../unix/sysv/linux/x86_64/64/librt.abilist | 5 - .../unix/sysv/linux/x86_64/x32/libc.abilist | 5 + .../unix/sysv/linux/x86_64/x32/librt.abilist | 5 - .../unix/sysv/linux/x86_64/x32/syscalls.list | 2 - time/Makefile | 20 +- time/Versions | 13 + {rt => time}/clock_getcpuclockid.c | 9 +- time/clock_getres.c | 39 + {rt => time}/clock_gettime.c | 11 +- {rt => time}/clock_nanosleep.c | 11 +- {rt => time}/clock_settime.c | 12 +- time/ftime.c | 40 +- time/gettimeofday.c | 32 +- time/settimeofday.c | 24 +- rt/clock_getres.c => time/settimezone.c | 12 +- time/stime.c | 25 +- time/sys/time.h | 47 +- time/sys/timeb.h | 43 - time/time.c | 12 +- time/time.h | 6 - time/timespec_get.c | 14 +- {rt => time}/tst-clock.c | 0 {rt => time}/tst-clock2.c | 0 {rt => time}/tst-clock_nanosleep.c | 0 {rt => time}/tst-cpuclock1.c | 0 time/tst-ftime.c | 58 - time/{tst-ftime_l.c => tst-strftime_l.c} | 0 153 files changed, 1376 insertions(+), 2011 deletions(-) delete mode 100644 rt/clock-compat.c create mode 100644 sysdeps/mach/clock_gettime.c delete mode 100644 sysdeps/mach/gettimeofday.c rename sysdeps/mach/hurd/{settimeofday.c => clock_settime.c} (60%) delete mode 100644 sysdeps/posix/gettimeofday.c delete mode 100644 sysdeps/posix/time.c delete mode 100644 sysdeps/posix/timespec_get.c delete mode 100644 sysdeps/unix/bsd/ftime.c delete mode 100644 sysdeps/unix/clock_gettime.c delete mode 100644 sysdeps/unix/clock_settime.c delete mode 100644 sysdeps/unix/sysv/linux/aarch64/gettimeofday.c rename sysdeps/unix/sysv/linux/{time.c => alpha/gettimeofday.c} (64%) create mode 100644 sysdeps/unix/sysv/linux/alpha/settimeofday.c delete mode 100644 sysdeps/unix/sysv/linux/ftime.c delete mode 100644 sysdeps/unix/sysv/linux/gettimeofday.c delete mode 100644 sysdeps/unix/sysv/linux/i386/gettimeofday.c delete mode 100644 sysdeps/unix/sysv/linux/i386/time.c delete mode 100644 sysdeps/unix/sysv/linux/powerpc/gettimeofday.c delete mode 100644 sysdeps/unix/sysv/linux/powerpc/time.c rename sysdeps/unix/{stime.c => sysv/linux/settimezone.c} (64%) delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/time.c delete mode 100644 sysdeps/unix/sysv/linux/timespec_get.c delete mode 100644 sysdeps/unix/sysv/linux/x86/gettimeofday.c delete mode 100644 sysdeps/unix/sysv/linux/x86/time.c rename {rt => time}/clock_getcpuclockid.c (75%) create mode 100644 time/clock_getres.c rename {rt => time}/clock_gettime.c (74%) rename {rt => time}/clock_nanosleep.c (76%) rename {rt => time}/clock_settime.c (71%) rename rt/clock_getres.c => time/settimezone.c (73%) delete mode 100644 time/sys/timeb.h rename {rt => time}/tst-clock.c (100%) rename {rt => time}/tst-clock2.c (100%) rename {rt => time}/tst-clock_nanosleep.c (100%) rename {rt => time}/tst-cpuclock1.c (100%) delete mode 100644 time/tst-ftime.c rename time/{tst-ftime_l.c => tst-strftime_l.c} (100%)