Ticket #3857: avoid glibc 2.25 warnings about major(), minor(), and makedev().

See gnulib a512e041120e9012e69afa2f5c3adc196ec4999a:

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.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2018-01-04 09:23:59 +03:00
parent d94a568cbf
commit fcf5ba5be2
4 changed files with 83 additions and 0 deletions

View File

@ -9,6 +9,8 @@ m4_include([m4.include/ls-mntd-fs.m4])
m4_include([m4.include/fstypename.m4])
m4_include([m4.include/fsusage.m4])
m4_include([m4.include/mountlist.m4])
m4_include([m4.include/windows-stat-inodes.m4])
m4_include([m4.include/sys_types_h.m4])
m4_include([m4.include/mc-get-fs-info.m4])
m4_include([m4.include/mc-with-x.m4])
m4_include([m4.include/mc-use-termcap.m4])

View File

@ -160,6 +160,8 @@ AC_CHECK_HEADERS([string.h memory.h limits.h malloc.h \
utime.h sys/statfs.h sys/vfs.h \
sys/select.h sys/ioctl.h stropts.h arpa/inet.h \
sys/socket.h])
dnl This macro is redefined in m4.include/sys_types_h.m4
dnl to work around a buggy version in autoconf <= 2.69.
AC_HEADER_MAJOR

60
m4.include/sys_types_h.m4 Normal file
View File

@ -0,0 +1,60 @@
# sys_types_h.m4 serial 9
dnl Copyright (C) 2011-2018 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN_ONCE([gl_SYS_TYPES_H],
[
dnl Use sane struct stat types in OpenVMS 8.2 and later.
AC_DEFINE([_USE_STD_STAT], 1, [For standard stat data types on VMS.])
AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS])
gl_NEXT_HEADERS([sys/types.h])
dnl Ensure the type pid_t gets defined.
AC_REQUIRE([AC_TYPE_PID_T])
dnl Ensure the type mode_t gets defined.
AC_REQUIRE([AC_TYPE_MODE_T])
dnl Whether to override the 'off_t' type.
AC_REQUIRE([gl_TYPE_OFF_T])
dnl Whether to override the 'dev_t' and 'ino_t' types.
m4_ifdef([gl_WINDOWS_STAT_INODES], [
AC_REQUIRE([gl_WINDOWS_STAT_INODES])
], [
WINDOWS_STAT_INODES=0
])
AC_SUBST([WINDOWS_STAT_INODES])
])
AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS],
[
])
# This works around a buggy version in autoconf <= 2.69.
# See <https://lists.gnu.org/r/autoconf/2016-08/msg00014.html>
m4_version_prereq([2.70], [], [
# This is taken from the following Autoconf patch:
# https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=e17a30e987d7ee695fb4294a82d987ec3dc9b974
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
])
])

View File

@ -0,0 +1,19 @@
# windows-stat-inodes.m4 serial 1
dnl Copyright (C) 2017-2018 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl Enable inode identification in 'struct stat' on native Windows platforms.
dnl Set WINDOWS_STAT_INODES to
dnl - 0 -> keep the default (dev_t = 32-bit, ino_t = 16-bit),
dnl - 1 -> override types normally (dev_t = 32-bit, ino_t = 64-bit),
dnl - 2 -> override types in an extended way (dev_t = 64-bit, ino_t = 128-bit).
AC_DEFUN([gl_WINDOWS_STAT_INODES],
[
AC_REQUIRE([AC_CANONICAL_HOST])
case "$host_os" in
mingw*) WINDOWS_STAT_INODES=1 ;;
*) WINDOWS_STAT_INODES=0 ;;
esac
])