This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH v6] y2038: Introduce __ASSUME_TIME64_SYSCALLS define
- From: Lukasz Majewski <lukma at denx dot de>
- To: libc-alpha at sourceware dot org
- Cc: Stepan Golosunov <stepan at golosunov dot pp dot ru>, Arnd Bergmann <arnd at arndb dot de>, Paul Eggert <eggert at cs dot ucla dot edu>, Joseph Myers <joseph at codesourcery dot com>, Lukasz Majewski <lukma at denx dot de>
- Date: Wed, 29 May 2019 14:22:00 +0200
- Subject: [PATCH v6] y2038: Introduce __ASSUME_TIME64_SYSCALLS define
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 <bits/wordsize.h>
+#if (__WORDSIZE == 64 \
+ || (__WORDSIZE == 32 \
+ && (__LINUX_KERNEL_VERSION >= 0x050100 \
+ || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64))))
+# define __ASSUME_TIME64_SYSCALLS 1
+#endif
--
2.11.0