From patchwork Wed Sep 19 07:13:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Albert ARIBAUD X-Patchwork-Id: 29457 Received: (qmail 34741 invoked by alias); 19 Sep 2018 07:13:12 -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 34349 invoked by uid 89); 19 Sep 2018 07:13:11 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=thereof, misc X-HELO: smtp3-g21.free.fr From: "Albert ARIBAUD (3ADEV)" To: libc-alpha@sourceware.org Cc: "Albert ARIBAUD (3ADEV)" Subject: [PATCH] Y2038: provide kernel support indication Date: Wed, 19 Sep 2018 09:13:03 +0200 Message-Id: <20180919071303.26636-1-albert.aribaud@3adev.fr> * New function __y2038_get_kernel_support() returns: * 0 if the underlying kernel does not support Y2038 at all * > 0 if the underlying kernel has some support for Y2038 * < 0 if the underlying kernel support for Y2038 is broken * New function __y2038_set_kernel_support() allows indicating a kernel's Y2038 support (or support failure) * Default implementation (covering non-Linux kernels) always returns 0 (no support). --- 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. misc/Makefile | 2 +- misc/Versions | 4 +++ misc/y2038-support.c | 32 ++++++++++++++++++++ misc/y2038-support.h | 36 ++++++++++++++++++++++ sysdeps/unix/sysv/linux/y2038-support.c | 40 +++++++++++++++++++++++++ sysdeps/unix/sysv/linux/y2038-support.h | 30 +++++++++++++++++++ 6 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 misc/y2038-support.c create mode 100644 misc/y2038-support.h create mode 100644 sysdeps/unix/sysv/linux/y2038-support.c create mode 100644 sysdeps/unix/sysv/linux/y2038-support.h diff --git a/misc/Makefile b/misc/Makefile index 9a87e81ae5..dd64bf256f 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 900e4ffb79..e242bf7218 100644 --- a/misc/Versions +++ b/misc/Versions @@ -158,6 +158,10 @@ libc { GLIBC_2.26 { preadv2; preadv64v2; pwritev2; pwritev64v2; } + GLIBC_2.29 { + __y2038_get_kernel_support; + __y2038_set_kernel_support; + } GLIBC_PRIVATE { __madvise; __mktemp; diff --git a/misc/y2038-support.c b/misc/y2038-support.c new file mode 100644 index 0000000000..e401cb1112 --- /dev/null +++ b/misc/y2038-support.c @@ -0,0 +1,32 @@ +/* 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 + . */ + +/* By default glibc assumes the underlying kernel does not support Y2038 */ +int __default_y2038_get_kernel_support (void) +{ + return 0; +} +weak_alias (__default_y2038_get_kernel_support, __y2038_get_kernel_support) + +/* By default glibc just ignores Y2038 support indication setting */ +int __default_y2038_set_kernel_support (int new with __attribute__ ((unused))) +{ + return 0; +} +weak_alias (__default_y2038_set_kernel_support, __y2038_set_kernel_support) diff --git a/misc/y2038-support.h b/misc/y2038-support.h new file mode 100644 index 0000000000..ec7891b63b --- /dev/null +++ b/misc/y2038-support.h @@ -0,0 +1,36 @@ +/* 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 + . */ + +/* Get Y2038 kernel support. + * 0 means no suppport + * > 0 means (some) support + * < 0 means support is broken + */ +extern int __y2038_get_kernel_support (void); + +/* Set Y2038 support. + * 0 means no suppport + * > 0 means (some) support + * < 0 means support is broken + * Architectures should call this with new > 0 as soon as they know that + * their underlying kernel has Y2038 support. + * Implementations should call this with new < 0 as soon as they detect + * that a Y2038 kernel support failure occurred. + * As a courtesy, the previous support indication is returned. */ +extern int __y2038_set_kernel_support (int new); diff --git a/sysdeps/unix/sysv/linux/y2038-support.c b/sysdeps/unix/sysv/linux/y2038-support.c new file mode 100644 index 0000000000..f325efc7d8 --- /dev/null +++ b/sysdeps/unix/sysv/linux/y2038-support.c @@ -0,0 +1,40 @@ +/* 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 + . */ + +/* By default the underlying Linux kernel is assumed not to support Y2038. + * Any Linux architecture may claim Y2038 kernel support by setting + * __y2038_linux_support. + */ +int __y2038_linux_support = 0; + +/* For Linux, Y2038 kernel support is determined by __y2038_linux_support */ + +int __linux_y2038_get_kernel_support (void) +{ + return __y2038_linux_support; +} +strong_alias (__linux_y2038_get_kernel_support, __y2038_get_kernel_support) + +int __linux_y2038_set_kernel_support (int new) +{ + int previous = __y2038_linux_support; + __y2038_linux_support = new; + return previous; +} +strong_alias (__linux_y2038_set_kernel_support, __y2038_set_kernel_support) diff --git a/sysdeps/unix/sysv/linux/y2038-support.h b/sysdeps/unix/sysv/linux/y2038-support.h new file mode 100644 index 0000000000..7dcbe0b313 --- /dev/null +++ b/sysdeps/unix/sysv/linux/y2038-support.h @@ -0,0 +1,30 @@ +/* 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 + . */ + +/* Indicates Y2038 support. + * 0 means no suppport + * > 0 means (some) support + * < 0 means support is broken + * Can be read directly from within libc linux-related files. + * Can be written non-zero to indicate support or lack thereof. + */ +extern int __y2038_linux_support; + +/* As a fallback, provide generic Y2038 support indication */ +#include