]> Savannah Git Hosting - gnulib.git/commitdiff
sys_types: avoid glibc 2.25 warnings about major()
authorEric Blake <eblake@redhat.com>
Thu, 15 Sep 2016 00:36:14 +0000 (19:36 -0500)
committerEric Blake <eblake@redhat.com>
Thu, 15 Sep 2016 17:40:24 +0000 (12:40 -0500)
glibc 2.25 is deprecating the namespace pollution of <sys/types.h>
injecting major(), minor(), and makedev() into the compilation
environment, with a warning that insists that users include
<sys/sysmacros.h> instead.  However, because the expansion of
AC_HEADER_MAJOR didn't bother checking sys/sysmacros.h until
after probing whether sys/types.h pollutes the namespace, it was
not defining MAJOR_IN_SYSMACROS, with the result that code
compiled with -Werror chokes on the deprecation warnings because
it was not including sysmacros.h.

Backport the autoconf fix (see autoconf commit e17a30e98), so that
gnulib projects avoid the warnings even when using older autoconf.

* m4/sys_types_h.m4 (AC_HEADER_MAJOR): Replace broken version in
older autoconf.
* doc/posix-headers/sys_types.texi (sys/types.h): Document fix.
* doc/glibc-functions/gnu_dev_major.texi (gnu_dev_major): Likewise.
* doc/glibc-functions/gnu_dev_makedev.texi (gnu_dev_makedev): Likewise.
* doc/glibc-functions/gnu_dev_minor.texi (gnu_dev_minor): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
doc/glibc-functions/gnu_dev_major.texi
doc/glibc-functions/gnu_dev_makedev.texi
doc/glibc-functions/gnu_dev_minor.texi
doc/posix-headers/sys_types.texi
m4/sys_types_h.m4

index 1362beae4a181baeff047ad80e661ad036ee4143..8d0b408bb66fbdaf4f4a7d4bd42ae41da2d0b2aa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2016-09-15  Eric Blake  <eblake@redhat.com>
 
+       sys_types: avoid glibc 2.25 warnings about major()
+       * m4/sys_types_h.m4 (AC_HEADER_MAJOR): Replace broken version in
+       older autoconf.
+       * doc/posix-headers/sys_types.texi (sys/types.h): Document fix.
+       * doc/glibc-functions/gnu_dev_major.texi (gnu_dev_major): Likewise.
+       * doc/glibc-functions/gnu_dev_makedev.texi (gnu_dev_makedev): Likewise.
+       * doc/glibc-functions/gnu_dev_minor.texi (gnu_dev_minor): Likewise.
+
        mountlist: include sysmacros.h for glibc
        * m4/mountlist.m4 (gl_PREREQ_MOUTLIST_EXTRA): Include
        AC_HEADER_MAJOR.
index f7a2cfdee4c82b7a86cea91090471b8e930a21c1..3a8530089e68574cfc0d6433b48112b70482cebf 100644 (file)
@@ -6,6 +6,10 @@ Gnulib module: ---
 
 Portability problems fixed by Gnulib:
 @itemize
+The @code{AC_HEADER_MAJOR} macro in Autoconf 2.69 and earlier fails to
+set @code{MAJOR_IN_SYSMACROS} when it detects namespace pollution in
+@file{sys/types.h}; which in turn provokes deprecation warnings in
+glibc 2.25.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index febd7f841c81916e148a3e932a9eff570c3b39d0..27386985f8e960234a98700acbda515c992ee420 100644 (file)
@@ -6,6 +6,10 @@ Gnulib module: ---
 
 Portability problems fixed by Gnulib:
 @itemize
+The @code{AC_HEADER_MAJOR} macro in Autoconf 2.69 and earlier fails to
+set @code{MAJOR_IN_SYSMACROS} when it detects namespace pollution in
+@file{sys/types.h}; which in turn provokes deprecation warnings in
+glibc 2.25.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index a3dbefe344bce768b375b53bd28116022ebf6e2f..b4c789cffa0db2a0f57bd9e6ac2f0169961f108b 100644 (file)
@@ -6,6 +6,10 @@ Gnulib module: ---
 
 Portability problems fixed by Gnulib:
 @itemize
+The @code{AC_HEADER_MAJOR} macro in Autoconf 2.69 and earlier fails to
+set @code{MAJOR_IN_SYSMACROS} when it detects namespace pollution in
+@file{sys/types.h}; which in turn provokes deprecation warnings in
+glibc 2.25.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index 29bb9ae58904592c8b5938a88ede8d50af971b5d..cf44beaf33d55da5f03d29a6293c3ca19aa6ff5b 100644 (file)
@@ -19,6 +19,12 @@ MSVC 9.
 @item
 The type @code{mode_t} is not defined on some platforms:
 MSVC 9.
+@item
+Some systems leak definitions of @code{major}, @code{minor}, and
+@code{makedev} through this header; however, when
+@file{sys/sysmacros.h} exists, that file should also be included to
+avoid deprecation warnings from the versions in this header:
+glibc 2.25.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index b0aabb4786228ca39fa7685398442264c4434ccf..159b005b3d426f1a8a065aaa4e5a1433dea46d87 100644 (file)
@@ -1,4 +1,4 @@
-# sys_types_h.m4 serial 5
+# sys_types_h.m4 serial 6
 dnl Copyright (C) 2011-2016 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -22,3 +22,28 @@ AC_DEFUN_ONCE([gl_SYS_TYPES_H],
 AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS],
 [
 ])
+
+# This works around a buggy version in autoconf <= 2.69.
+# See <https://lists.gnu.org/archive/html/autoconf/2016-08/msg00014.html>
+
+m4_version_prereq([2.70], [], [
+
+# This is taken from the following Autoconf patch:
+# http://git.sv.gnu.org/cgit/autoconf.git/commit/?id=e17a30e98
+
+m4_undefine([AC_HEADER_MAJOR])
+AC_DEFUN([AC_HEADER_MAJOR],
+[AC_CHECK_HEADERS_ONCE([sys/types.h])
+AC_CHECK_HEADER([sys/mkdev.h],
+  [AC_DEFINE([MAJOR_IN_MKDEV], [1],
+    [Define to 1 if `major', `minor', and `makedev' are declared in
+     <mkdev.h>.])])
+if test $ac_cv_header_sys_mkdev_h = no; then
+  AC_CHECK_HEADER([sys/sysmacros.h],
+    [AC_DEFINE([MAJOR_IN_SYSMACROS], [1],
+      [Define to 1 if `major', `minor', and `makedev' are declared in
+       <sysmacros.h>.])])
+fi
+])
+
+])