From fcf5ba5be2ccbce693bf8902dacc5c46961d2162 Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Thu, 4 Jan 2018 09:23:59 +0300 Subject: [PATCH] Ticket #3857: avoid glibc 2.25 warnings about major(), minor(), and makedev(). See gnulib a512e041120e9012e69afa2f5c3adc196ec4999a: 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. Signed-off-by: Andrew Borodin --- acinclude.m4 | 2 ++ configure.ac | 2 ++ m4.include/sys_types_h.m4 | 60 +++++++++++++++++++++++++++++++++++++++ m4.include/windows-stat-inodes.m4 | 19 +++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 m4.include/sys_types_h.m4 create mode 100644 m4.include/windows-stat-inodes.m4 diff --git a/acinclude.m4 b/acinclude.m4 index 3e4231a1c..d7f27a62a 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -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]) diff --git a/configure.ac b/configure.ac index 5541393d6..65618d5e7 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/m4.include/sys_types_h.m4 b/m4.include/sys_types_h.m4 new file mode 100644 index 000000000..2debfb0d5 --- /dev/null +++ b/m4.include/sys_types_h.m4 @@ -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 + +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 + .])]) +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 +]) + +]) diff --git a/m4.include/windows-stat-inodes.m4 b/m4.include/windows-stat-inodes.m4 new file mode 100644 index 000000000..936900a27 --- /dev/null +++ b/m4.include/windows-stat-inodes.m4 @@ -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 +]) -- 2.11.4.GIT