From patchwork Fri Jun 7 12:01:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 33046 Received: (qmail 89646 invoked by alias); 7 Jun 2019 12:01:47 -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 89638 invoked by uid 89); 7 Jun 2019 12:01:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.redhat.com From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH] Linux: Deprecate and sysctl Date: Fri, 07 Jun 2019 14:01:42 +0200 Message-ID: <874l51hae1.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Now that there are no internal users of __sysctl left, it is possible to add an unconditional deprecation warning to . To avoid a test failure due this warning in check-install-headers, skip the test for sys/sysctl.h. 2019-06-07 Florian Weimer Linux: Deprecate sysctl. * include/sysctl.h (__sysctl): Remove declaration. * scripts/check-installed-headers.sh (sys/sysctl.h): Disable check. * sysdeps/unix/sysv/linux/sys/sysctl.h: Add deprecation warning. (sysctl): Add deprecation attribute. * sysdeps/unix/sysv/linux/sysctl.c: Include directly, to avoid the deprecation warning. Do not include . (__sysctl): Remove hidden alias. Reviewed-by: Adhemerval Zanella Reviewed-by: Adhemerval Zanella diff --git a/NEWS b/NEWS index 00f9e855a2..fffff79576 100644 --- a/NEWS +++ b/NEWS @@ -61,6 +61,9 @@ Deprecated and removed features, and other changes affecting compatibility: * On 32-bit Arm, support for the port-based I/O emulation and the header have been removed. +* The Linux-specific header and the sysctl function have been + deprecated and will be removed from a future version of glibc. + Changes to build and runtime requirements: * GCC 6.2 or later is required to build the GNU C Library. diff --git a/include/sys/sysctl.h b/include/sys/sysctl.h index 2a15e91354..fa102aa226 100644 --- a/include/sys/sysctl.h +++ b/include/sys/sysctl.h @@ -1,13 +1,3 @@ #ifndef _SYS_SYSCTL_H #include_next - -# ifndef _ISOMAC - -/* Read or write system parameters (Linux, FreeBSD specific). */ -extern int __sysctl (int *__name, int __nlen, void *__oldval, - size_t *__oldlenp, void *__newval, size_t __newlen); -libc_hidden_proto (__sysctl) - - -# endif /* !_ISOMAC */ #endif /* _SYS_SYSCTL_H */ diff --git a/scripts/check-installed-headers.sh b/scripts/check-installed-headers.sh index e4f37d33f8..ef6ed94a2e 100644 --- a/scripts/check-installed-headers.sh +++ b/scripts/check-installed-headers.sh @@ -53,7 +53,6 @@ trap "rm -f '$cih_test_c'" 0 failed=0 is_x86_64=unknown -is_x32=unknown for header in "$@"; do # Skip various headers for which this test gets a false failure. case "$header" in @@ -75,27 +74,10 @@ for header in "$@"; do (finclude/*) continue;; - # sys/sysctl.h is unsupported for x32. + # sys/sysctl.h produces a deprecation warning and therefore + # fails compilation with -Werror. (sys/sysctl.h) - case "$is_x32" in - (yes) continue;; - (no) ;; - (unknown) - cat >"$cih_test_c" < /dev/null 2>&1 - then - is_x32=no - else - is_x32=yes - continue - fi - ;; - esac - ;; + continue;; # sys/vm86.h is "unsupported on x86-64" and errors out on that target. (sys/vm86.h) diff --git a/sysdeps/unix/sysv/linux/sys/sysctl.h b/sysdeps/unix/sysv/linux/sys/sysctl.h index 0f6e71ba7e..15ee9642ab 100644 --- a/sysdeps/unix/sysv/linux/sys/sysctl.h +++ b/sysdeps/unix/sysv/linux/sys/sysctl.h @@ -18,6 +18,9 @@ #ifndef _SYS_SYSCTL_H #define _SYS_SYSCTL_H 1 +#warning "The header is deprecated and will be removed." +#warning "Directly access the /proc file system instead." + #include #define __need_size_t #include @@ -66,7 +69,8 @@ __BEGIN_DECLS /* Read or write system parameters. */ extern int sysctl (int *__name, int __nlen, void *__oldval, - size_t *__oldlenp, void *__newval, size_t __newlen) __THROW; + size_t *__oldlenp, void *__newval, size_t __newlen) __THROW + __attribute_deprecated__; __END_DECLS diff --git a/sysdeps/unix/sysv/linux/sysctl.c b/sysdeps/unix/sysv/linux/sysctl.c index 33afdd918b..0f18c69abe 100644 --- a/sysdeps/unix/sysv/linux/sysctl.c +++ b/sysdeps/unix/sysv/linux/sysctl.c @@ -17,8 +17,7 @@ . */ #include -#include /* For the real memset prototype. */ -#include +#include #include #include @@ -39,5 +38,4 @@ __sysctl (int *name, int nlen, void *oldval, size_t *oldlenp, return INLINE_SYSCALL (_sysctl, 1, &args); } -libc_hidden_def (__sysctl) weak_alias (__sysctl, sysctl)