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>
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.
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:
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:
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:
@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:
-# 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,
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
+])
+
+])