From a512e041120e9012e69afa2f5c3adc196ec4999a Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 14 Sep 2016 19:36:14 -0500 Subject: [PATCH] sys_types: avoid glibc 2.25 warnings about major() glibc 2.25 is deprecating the namespace pollution of injecting major(), minor(), and makedev() into the compilation environment, with a warning that insists that users include 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 --- ChangeLog | 8 +++++++ doc/glibc-functions/gnu_dev_major.texi | 4 ++++ doc/glibc-functions/gnu_dev_makedev.texi | 4 ++++ doc/glibc-functions/gnu_dev_minor.texi | 4 ++++ doc/posix-headers/sys_types.texi | 6 ++++++ m4/sys_types_h.m4 | 27 +++++++++++++++++++++++- 6 files changed, 52 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1362beae4a..8d0b408bb6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2016-09-15 Eric Blake + 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. diff --git a/doc/glibc-functions/gnu_dev_major.texi b/doc/glibc-functions/gnu_dev_major.texi index f7a2cfdee4..3a8530089e 100644 --- a/doc/glibc-functions/gnu_dev_major.texi +++ b/doc/glibc-functions/gnu_dev_major.texi @@ -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: diff --git a/doc/glibc-functions/gnu_dev_makedev.texi b/doc/glibc-functions/gnu_dev_makedev.texi index febd7f841c..27386985f8 100644 --- a/doc/glibc-functions/gnu_dev_makedev.texi +++ b/doc/glibc-functions/gnu_dev_makedev.texi @@ -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: diff --git a/doc/glibc-functions/gnu_dev_minor.texi b/doc/glibc-functions/gnu_dev_minor.texi index a3dbefe344..b4c789cffa 100644 --- a/doc/glibc-functions/gnu_dev_minor.texi +++ b/doc/glibc-functions/gnu_dev_minor.texi @@ -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: diff --git a/doc/posix-headers/sys_types.texi b/doc/posix-headers/sys_types.texi index 29bb9ae589..cf44beaf33 100644 --- a/doc/posix-headers/sys_types.texi +++ b/doc/posix-headers/sys_types.texi @@ -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: diff --git a/m4/sys_types_h.m4 b/m4/sys_types_h.m4 index b0aabb4786..159b005b3d 100644 --- a/m4/sys_types_h.m4 +++ b/m4/sys_types_h.m4 @@ -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 + +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 + .])]) +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 + .])]) +fi +]) + +]) -- 2.39.5