aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2018-06-10 10:47:12 +0200
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2018-10-24 12:53:11 +0200
commit94811042d73239d35b9d4bf7592c62ccc65ce633 (patch)
tree29f75d34340865645dba40df50e4ecfd6f0eafce
parenteaf0f523fb03866d27d2175b7b280a825b91a8c1 (diff)
downloadglibc-94811042d73239d35b9d4bf7592c62ccc65ce633.zip
glibc-94811042d73239d35b9d4bf7592c62ccc65ce633.tar.gz
glibc-94811042d73239d35b9d4bf7592c62ccc65ce633.tar.bz2
Y2038: provide kernel support indication
Introduce __ASSUME_KERNEL_Y2038_SUPPORT which means that the underlying kernel *always* implements 64-bit-time Y2038-proof syscalls. If __ASSUME_KERNEL_Y2038_SUPPORT is not defined, glibc must check dynamically whether the underlying kernel provides these syscalls or not, and must fallback to 32-bit-time syscalls if not. Introduce function __y2038_get_kernel_support(), which returns true if the underlying kernel supports 64-bit-time syscalls. Also introduce function __y2038_set_kernel_support(), which allows an implementation to notify glibc of the absence of 64-bit-time syscalls (ENOSYS) so that they are not needlessly tried again. * misc/Makefile: Add module y2038-support. * misc/Versions: (__y2038_get_kernel_support): Add to GLIBC_PRIVATE. * misc/Versions: (__y2038_set_kernel_support): Likewise. * misc/y2038-support.c: New file. * misc/y2038-support.h: Likewise. * sysdeps/unix/sysv/linux/kernel-features.h (__ASSUME_KERNEL_Y2038_SUPPORT): Add. * sysdeps/unix/sysv/linux/y2038-support.c: New file. * sysdeps/unix/sysv/linux/y2038-support.h: New file.
-rw-r--r--misc/Makefile2
-rw-r--r--misc/Versions4
-rw-r--r--misc/y2038-support.c40
-rw-r--r--misc/y2038-support.h33
-rw-r--r--sysdeps/unix/sysv/linux/kernel-features.h14
-rw-r--r--sysdeps/unix/sysv/linux/y2038-support.c46
-rw-r--r--sysdeps/unix/sysv/linux/y2038-support.h34
7 files changed, 172 insertions, 1 deletions
diff --git a/misc/Makefile b/misc/Makefile
index 30e0673..7ced1ea 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -71,7 +71,7 @@ routines := brk sbrk sstk ioctl \
fgetxattr flistxattr fremovexattr fsetxattr getxattr \
listxattr lgetxattr llistxattr lremovexattr lsetxattr \
removexattr setxattr getauxval ifunc-impl-list makedev \
- allocate_once
+ allocate_once y2038-support
generated += tst-error1.mtrace tst-error1-mem.out \
tst-allocate_once.mtrace tst-allocate_once-mem.out
diff --git a/misc/Versions b/misc/Versions
index 900e4ff..48285d8 100644
--- a/misc/Versions
+++ b/misc/Versions
@@ -158,6 +158,8 @@ libc {
GLIBC_2.26 {
preadv2; preadv64v2; pwritev2; pwritev64v2;
}
+ GLIBC_2.29 {
+ }
GLIBC_PRIVATE {
__madvise;
__mktemp;
@@ -166,5 +168,7 @@ libc {
__mmap; __munmap; __mprotect;
__sched_get_priority_min; __sched_get_priority_max;
__libc_allocate_once_slow;
+ __y2038_get_kernel_support;
+ __y2038_set_kernel_support;
}
}
diff --git a/misc/y2038-support.c b/misc/y2038-support.c
new file mode 100644
index 0000000..64f8036
--- /dev/null
+++ b/misc/y2038-support.c
@@ -0,0 +1,40 @@
+/* y2038 general kernel support indication.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdbool.h>
+
+#ifndef __ASSUME_KERNEL_Y2038_SUPPORT
+
+/* By default glibc assumes the underlying kernel does not support Y2038. */
+bool
+__default_y2038_get_kernel_support (void)
+{
+ return false;
+}
+weak_alias (__default_y2038_get_kernel_support, __y2038_get_kernel_support)
+
+/* By default glibc just ignores Y2038 support indication setting. */
+void
+__default_y2038_set_kernel_support (bool support __attribute__ ((unused)))
+{
+ /* Do nothing. */
+}
+weak_alias (__default_y2038_set_kernel_support, __y2038_set_kernel_support)
+
+#endif
diff --git a/misc/y2038-support.h b/misc/y2038-support.h
new file mode 100644
index 0000000..aad387b
--- /dev/null
+++ b/misc/y2038-support.h
@@ -0,0 +1,33 @@
+/* y2038 general kernel support indication.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdbool.h>
+
+/* If we do not assume that the kernel provides 64-bit-time syscalls,
+ * then we need a dynamic way to remember whether it does or not. */
+
+#ifndef __ASSUME_KERNEL_Y2038_SUPPORT
+
+/* Dynamically check whether actual kernel supports Y2038 or not. */
+extern bool __y2038_get_kernel_support (void);
+
+/* Dynamically set whether actual kernel supports Y2038 or not. */
+extern void __y2038_set_kernel_support (bool support);
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h
index 5543d92..b47755b 100644
--- a/sysdeps/unix/sysv/linux/kernel-features.h
+++ b/sysdeps/unix/sysv/linux/kernel-features.h
@@ -154,3 +154,17 @@
*/
#define __ASSUME_CLONE_DEFAULT 1
+
+/* Support for Y2038-proof times.
+
+ If defined, the underlying kernel always provides a set of syscalls
+ (__NR_* names and numbers) which can handle times beyond Y2038.
+
+ If undefined, whether the underlying kernel provides this set or not
+ must be checked dynamically.
+
+ Definition is commented out until Y2038 syscalls are merged in the
+ kernel.
+ */
+
+/* #define __ASSUME_KERNEL_Y2038_SUPPORT 1 */
diff --git a/sysdeps/unix/sysv/linux/y2038-support.c b/sysdeps/unix/sysv/linux/y2038-support.c
new file mode 100644
index 0000000..adbcd8f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/y2038-support.c
@@ -0,0 +1,46 @@
+/* y2038 Linux kernel support indication.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef __ASSUME_KERNEL_Y2038_SUPPORT
+
+#include <stdbool.h>
+
+/* By default the underlying Linux kernel is assumed not to support Y2038.
+ * Any Linux architecture may (test and) claim Y2038 kernel support by
+ * setting __y2038_linux_support.
+ */
+bool __y2038_linux_support = false;
+
+/* For Linux, Y2038 kernel support is determined by __y2038_linux_support. */
+
+bool
+__linux_y2038_get_kernel_support (void)
+{
+ return __y2038_linux_support;
+}
+strong_alias (__linux_y2038_get_kernel_support, __y2038_get_kernel_support)
+
+void
+__linux_y2038_set_kernel_support (bool support)
+{
+ __y2038_linux_support = support;
+}
+strong_alias (__linux_y2038_set_kernel_support, __y2038_set_kernel_support)
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/y2038-support.h b/sysdeps/unix/sysv/linux/y2038-support.h
new file mode 100644
index 0000000..b8b6b8e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/y2038-support.h
@@ -0,0 +1,34 @@
+/* y2038 Linux kernel support indication.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef __ASSUME_KERNEL_Y2038_SUPPORT
+
+#include <stdbool.h>
+
+/* Indicates Y2038 support.
+ * Can be read directly from within libc linux-related files.
+ * Can be written non-zero to indicate support or lack thereof.
+ * Other libraries (e.g. librt) cannot access this variable and must
+ * call __y2038_get_kernel_support() and __y2038_set_kernel_support(). */
+extern bool __y2038_linux_support;
+
+#endif
+
+/* As a fallback, provide generic Y2038 support indication. */
+#include <misc/y2038-support.h>