From patchwork Wed May 29 12:22:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 32893 Received: (qmail 107631 invoked by alias); 29 May 2019 12:22:21 -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 107526 invoked by uid 89); 29 May 2019 12:22:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=equally, moreover X-HELO: mail-out.m-online.net From: Lukasz Majewski To: libc-alpha@sourceware.org Cc: Stepan Golosunov , Arnd Bergmann , Paul Eggert , Joseph Myers , Lukasz Majewski Subject: [PATCH v6] y2038: Introduce __ASSUME_TIME64_SYSCALLS define Date: Wed, 29 May 2019 14:22:00 +0200 Message-Id: <20190529122200.19883-1-lukma@denx.de> This define indicates if the Linux kernel provides 64 bit time syscalls on systems where: 1. __WORDSIZE == 64 - the 64 bit time is supported by already available set of syscalls. 2. __WORDSIZE == 32 - the new set of syscalls has been added to v5.1 kernel to provide 64 bit time ABI. List of new syscalls added to v5.1. kernel (they accept data based on struct timespec and timeval with 64 bit tv_sec): clock_gettime64 clock_settime64 clock_adjtime64 clock_getres_time64 clock_nanosleep_time64 timer_gettime64 timer_settime64 timerfd_gettime64 timerfd_settime64 utimensat_time64 pselect6_time64 ppoll_time64 io_pgetevents_time64 recvmmsg_time64 mq_timedsend_time64 mq_timedreceive_time64 semtimedop_time64 rt_sigtimedwait_time64 futex_time64 sched_rr_get_interval_time64 3. __WORDSIZE == 32 && _SYSCALL_WORDSIZE == 64 - a special case for machine with ILP32 data model, but already supporting 64 bit time (the 'x32' architecture to be precise). Different syscalls with different numbers can be used to achieve the goal (for example either __NR_clock_settime or __NR_clock_settime64) if they provide exactly equivalent interface. Ones which doesn't (like semtimedop_time64) would require special handling. In other words the __ASSUME_TIME64_SYSCALLS does not indicate the presence of particular syscalls, but the generic ability which they provide (64 bit time support). Moreover, this flag will be removed one day when glibc's minimal supported kernel version passes 5.1, as one would be sure that it provides 64 bit time ABI. * sysdeps/unix/sysv/linux/kernel-features.h: (__ASSUME_TIME64_SYSCALLS): Define. --- Changes for v6: - Change the logical meaning of __ASSUME_TIME64_SYSCALLS - now it indicates if the system supports the 64 bit time ABI (if for both __WORDSIZE==64 and __WORDSIZE==32 systems equally functional syscalls are provided). - Update commit description Changes for v5: - Rewrite the in-code comment (x32 description more precise) - Change patch description (for x32) Changes for v4: - Exclude this patch from the clock_settime64 patch series - Rewrite the in-code comment - Change patch description Changes for v3: - Provide more detailed and verbose description - Change name to __ASSUME_TIME64_SYSCALLS - Undefine __ASSUME_TIME64_SYSCALLS on x32 Changes for v2: - New patch --- sysdeps/unix/sysv/linux/kernel-features.h | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index bc5c959f58..fd5958cb64 100644 --- a/sysdeps/unix/sysv/linux/kernel-features.h +++ b/sysdeps/unix/sysv/linux/kernel-features.h @@ -143,3 +143,40 @@ */ #define __ASSUME_CLONE_DEFAULT 1 + +/* This flag indicates support for Linux kernel syscalls, which are able + to handle 64 bit time ABI. It is defined for architectures with both + intrinsic 64 bit time support as well as ones gaining it with new + syscalls added to Linux kernel version 5.1. + + To be more specific - this flag focuses on higer level of abstraction, + which indicates the system's ability to support 64 bit time. + + In the other words we do not focus on particular syscalls, but on the + ability which is provided by them. + + As an example - the syscall to set clock (clock_settime) - if the + __ASSUME_TIME64_SYSCALLS is defined, it indicates that 64 bit time can + be set in the system. + + On systems with __WORDSIZE == 64 the __NR_clock_settime syscall is used + to achieve this goal. Contrary, systems with __WORDSIZE == 32 do use + new __NR_clock_settime64 syscall available from Linux version 5.1. + + The __ASSUME_TIME64_SYSCALLS is defined for: + + 1. Systems with intrinsic 64 bit time support (__WORDSIZE == 64). + + 2. For x32 architecture, which is a special case in respect to 64 bit + time support (it has __WORDSIZE==32 but __TIMESIZE==64) + + 3. Systems with __WORDSIZE==32, which gain 64 bit time support + with new set of syscalls added to Linux kernel 5.1. */ + +#include +#if (__WORDSIZE == 64 \ + || (__WORDSIZE == 32 \ + && (__LINUX_KERNEL_VERSION >= 0x050100 \ + || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64)))) +# define __ASSUME_TIME64_SYSCALLS 1 +#endif