From patchwork Wed Sep 19 07:27:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Albert ARIBAUD X-Patchwork-Id: 29458 Received: (qmail 86261 invoked by alias); 19 Sep 2018 07:27:09 -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 86249 invoked by uid 89); 19 Sep 2018 07:27:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=pad X-HELO: smtp3-g21.free.fr From: "Albert ARIBAUD (3ADEV)" To: libc-alpha@sourceware.org Cc: "Albert ARIBAUD (3ADEV)" Subject: [PATCH] Y2038: add struct __timespec64 Date: Wed, 19 Sep 2018 09:27:01 +0200 Message-Id: <20180919072701.27535-1-albert.aribaud@3adev.fr> * include/bits/types/struct_timespec64.h: Include time/bits/types/struct_timespec64.h * include/time.h (valid_timeval_to_timespec64): Add. * include/time.h (valid_timespec_to_timespec64): Likewise. * include/time.h (valid_timespec64_to_timespec): Likewise. * include/time.h (valid_timespec64_to_timeval): Likewise. * include/time.h (IS_VALID_NANOSECONDS): Likewise. * include/time.h (timespec_to_timespec64): Likewise. * include/time.h (timespec64_to_timespec): Likewise. * include/time.h (timespec64_to_timeval): Likewise. * io/fcntl.h: Include bits/types/struct_timespec64.h. * io/sys/poll.h: Likewise. * io/sys/stat.h: Likewise. * misc/sys/select.h: Likewise. * posix/sched.h: Likewise. * posix/netdb.h: Likewise. * rt/aio.h: Likewise. * rt/mqueue.h: Likewise. * signal/signal.h: Likewise. * sysdeps/nptl/pthread.h: Likewise. * sysdeps/pthread/semaphore.h: Likewise. * sysdeps/unix/sysv/linux/hppa/pthread.h: Likewise. * sysvipc/sys/sem.h: Likewise. * time/Makefile: Add bits/types/struct_timespec64.h * time/bits/types/struct_itimerspec.h: Include bits/types/struct_timespec64.h * time/bits/types/struct_itimerspec64.h: Add. * time/time.h: Include bits/types/struct_timespec64.h --- To be Y2038-proof, struct __timespec64 needs its tv_sec field to be a __time64_t rather than a __time_t. However, the question is which type should the tv_nsec field be. Keeping tv_nsec a long (32-bit) would be compatible with Posix requirements but would result in the GLIBC struct timespec being binary-incompatible with the Linux 64-bit struct timespec, which contains a 64-bit, not 32-bit, signed tv_nsec field. In order to maintain Posix compatibility yet simplify conversion between Posix and Linux struct timespec values, the Y2038-proof struct time stores its tv_nsec field as a 32-bit signed integer plus a padding which can serve as a 64-bit sign extension. This both meets Posix requirements and makes the GLIBC and Linux struct timespec binary compatible. Note that in the API (which is not modified here, and will be later alongside all Y2038-sensitive APIs), this padding is made 'invisible' by defining it as an anonymous bitfield, whereas the struct __timespec64 introduced here has a named field for the padding, allowing implementations to read and write it. Also, provide static inline functions and macros for checking and converting between 32-bit itimevals and timespecs to 64-bit timespecs. This patch is part of the Y2038 patch series, which is available at . Warning: this branch may be rebased on current master and/or updated based on feedback from the list at any time. include/bits/types/struct_timespec64.h | 1 + include/time.h | 82 ++++++++++++++++++++++++++ io/fcntl.h | 1 + io/sys/poll.h | 1 + io/sys/stat.h | 1 + misc/sys/select.h | 1 + posix/sched.h | 1 + resolv/netdb.h | 1 + rt/aio.h | 1 + rt/mqueue.h | 1 + signal/signal.h | 1 + sysdeps/nptl/pthread.h | 1 + sysdeps/pthread/semaphore.h | 1 + sysdeps/unix/sysv/linux/hppa/pthread.h | 1 + sysvipc/sys/sem.h | 1 + time/Makefile | 2 +- time/bits/types/struct_itimerspec.h | 1 + time/bits/types/struct_timespec64.h | 29 +++++++++ time/time.h | 1 + 19 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 include/bits/types/struct_timespec64.h create mode 100644 time/bits/types/struct_timespec64.h diff --git a/include/bits/types/struct_timespec64.h b/include/bits/types/struct_timespec64.h new file mode 100644 index 0000000000..42869680b8 --- /dev/null +++ b/include/bits/types/struct_timespec64.h @@ -0,0 +1 @@ +#include