aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix
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 /sysdeps/unix
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.
Diffstat (limited to 'sysdeps/unix')
-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
3 files changed, 94 insertions, 0 deletions
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>