]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Linux: Deprecate <sys/sysctl.h> and sysctl
authorFlorian Weimer <fweimer@redhat.com>
Wed, 12 Jun 2019 12:32:08 +0000 (14:32 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Wed, 12 Jun 2019 12:32:08 +0000 (14:32 +0200)
Now that there are no internal users of __sysctl left, it is possible
to add an unconditional deprecation warning to <sys/sysctl.h>.

To avoid a test failure due this warning in check-install-headers,
skip the test for sys/sysctl.h.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
ChangeLog
NEWS
include/sys/sysctl.h
scripts/check-installed-headers.sh
sysdeps/unix/sysv/linux/sys/sysctl.h
sysdeps/unix/sysv/linux/sysctl.c

index b2aa19a58db2e5b3cb1e103ec38b7135493d7246..865fcec63de2e4510792f55a3cf1ed3faa1377a1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2019-06-12  Florian Weimer  <fweimer@redhat.com>
+
+       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 <linux/sysctl.h>
+       directly, to avoid the deprecation warning.  Do not include
+       <string.h>.
+       (__sysctl): Remove hidden alias.
+
 2019-06-12  Florian Weimer  <fweimer@redhat.com>
 
        Linux: Use kernel headers for statx definitions if available.
diff --git a/NEWS b/NEWS
index 00f9e855a29fcad50a9b12bc1134bcbcb07a6c9a..8a2fecef4758cb6505bbcd22fda818b1d335e8a4 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -61,6 +61,11 @@ Deprecated and removed features, and other changes affecting compatibility:
 * On 32-bit Arm, support for the port-based I/O emulation and the <sys/io.h>
   header have been removed.
 
+* The Linux-specific <sys/sysctl.h> header and the sysctl function have been
+  deprecated and will be removed from a future version of glibc.
+  Application should directly access /proc instead.  For obtaining random
+  bits, the getentropy function can be used.
+
 Changes to build and runtime requirements:
 
 * GCC 6.2 or later is required to build the GNU C Library.
index 2a15e91354d0174d928b15b6d9d2b92308212795..fa102aa22672d4d03857f745553445678025b3f9 100644 (file)
@@ -1,13 +1,3 @@
 #ifndef _SYS_SYSCTL_H
 #include_next <sys/sysctl.h>
-
-# 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 */
index e4f37d33f89a95c6e6c45afb15e27c446c3c0c1b..ef6ed94a2e82a478f7387f90c2babb7c765f4149 100644 (file)
@@ -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" <<EOF
-#if defined __x86_64__ && defined __ILP32__
-# error "is x32"
-#endif
-EOF
-                    if $cc_cmd -fsyntax-only "$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)
index 0f6e71ba7e4bcff367ad971b6b48dba869a126d6..be34555668a585e475a0911ab1d4c346587cbd63 100644 (file)
@@ -18,6 +18,8 @@
 #ifndef        _SYS_SYSCTL_H
 #define        _SYS_SYSCTL_H   1
 
+#warning "The <sys/sysctl.h> header is deprecated and will be removed."
+
 #include <features.h>
 #define __need_size_t
 #include <stddef.h>
@@ -66,7 +68,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
 
index 33afdd918be3bbc441c7007e5edd99336d1a8a4e..0f18c69abec9536bde5e2211ab819473615be96d 100644 (file)
@@ -17,8 +17,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
-#include <string.h>    /* For the real memset prototype.  */
-#include <sys/sysctl.h>
+#include <linux/sysctl.h>
 
 #include <sysdep.h>
 #include <sys/syscall.h>
@@ -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)