From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1arock-0001LQ-ME for mharc-grub-devel@gnu.org; Sun, 17 Apr 2016 11:28:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aroch-0001F2-Vs for grub-devel@gnu.org; Sun, 17 Apr 2016 11:28:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aroce-0003Vu-QE for grub-devel@gnu.org; Sun, 17 Apr 2016 11:28:31 -0400 Received: from smtp.gentoo.org ([140.211.166.183]:42260) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aroce-0003V7-I0 for grub-devel@gnu.org; Sun, 17 Apr 2016 11:28:28 -0400 Received: from mail-ig0-f176.google.com (mail-ig0-f176.google.com [209.85.213.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: floppym) by smtp.gentoo.org (Postfix) with ESMTPSA id 575A73405D5 for ; Sun, 17 Apr 2016 15:28:26 +0000 (UTC) Received: by mail-ig0-f176.google.com with SMTP id gy3so54788546igb.0 for ; Sun, 17 Apr 2016 08:28:26 -0700 (PDT) X-Gm-Message-State: AOPr4FXXS9fmGX2kiwkwzQEnGS/mZ43hwqP9NdlZE/GGrJS7+GJpgx5HoT1Tncy85gEQIUjSfUBqo5X+travFA== X-Received: by 10.50.108.49 with SMTP id hh17mr15179949igb.31.1460906904269; Sun, 17 Apr 2016 08:28:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.79.8.196 with HTTP; Sun, 17 Apr 2016 08:28:04 -0700 (PDT) In-Reply-To: <571324C3.7080605@gmail.com> References: <1460842498-23914-1-git-send-email-floppym@gentoo.org> <571324C3.7080605@gmail.com> From: Mike Gilbert Date: Sun, 17 Apr 2016 11:28:04 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] build: Use AC_HEADER_MAJOR to find device macros To: The development of GNU GRUB Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 140.211.166.183 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Apr 2016 15:28:33 -0000 On Sun, Apr 17, 2016 at 1:53 AM, Andrei Borzenkov wro= te: > 17.04.2016 00:34, Mike Gilbert =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >> Depending on the OS/libc, device macros may be found in 3 places: >> > > Mentioning OS and libc versions that have problem would be helpful. > I am really only familiar with glibc, though I believe BSD and Sun use sys/mkdev.h? >> sys/types.h >> sys/mkdev.h >> sys/sysmacros.h >> >> glibc currenctly defines the major/minor/makedev macros in sys/sysmacros= .h >> and includes this from sys/types.h. Based on mailing list discussion, >> this may be removed from sys/types.h in a future glibc release. >> --- >> configure.ac | 3 ++- >> grub-core/osdep/devmapper/getroot.c | 6 ++++++ >> grub-core/osdep/devmapper/hostdisk.c | 5 +++++ >> grub-core/osdep/linux/getroot.c | 6 ++++++ > > All those files are linux only. Do you mean there are some linux flavors > that have these definitions in non-standard place? Could you name them? > As I mentioned, in a future release, glibc may remove #include from sys/types.h. This would provide preventing naming conflicts in programs that have variables named like "major" and indirectly include sys/types.h. This is currently up for discussion upstream. https://sourceware.org/ml/libc-alpha/2015-11/msg00253.html https://sourceware.org/ml/libc-alpha/2015-12/msg00612.html If you would prefer to wait until a commit lands in glibc, I understand. We have been doing some testing in Gentoo to see how many things will break (it's a lot!). I just thought I would submit this now since the check is fairly harmless and would future-proof the code either way. >> grub-core/osdep/unix/getroot.c | 4 +++- >> 5 files changed, 22 insertions(+), 2 deletions(-) >> >> diff --git a/configure.ac b/configure.ac >> index 57e1713..9ddfc53 100644 >> --- a/configure.ac >> +++ b/configure.ac >> @@ -388,7 +388,8 @@ fi >> >> # Check for functions and headers. >> AC_CHECK_FUNCS(posix_memalign memalign getextmntent) >> -AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h limit= s.h) >> +AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h) >> +AC_HEADER_MAJOR >> >> AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default >> #include >> diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devma= pper/getroot.c >> index 05eda50..72e5582 100644 >> --- a/grub-core/osdep/devmapper/getroot.c >> +++ b/grub-core/osdep/devmapper/getroot.c >> @@ -40,6 +40,12 @@ >> #include >> #endif >> >> +#if defined(MAJOR_IN_MKDEV) >> +#include >> +#elif defined(MAJOR_IN_SYSMACROS) >> +#include >> +#endif >> + >> #include >> >> #include >> diff --git a/grub-core/osdep/devmapper/hostdisk.c b/grub-core/osdep/devm= apper/hostdisk.c >> index 19c1101..a697bcb 100644 >> --- a/grub-core/osdep/devmapper/hostdisk.c >> +++ b/grub-core/osdep/devmapper/hostdisk.c >> @@ -24,6 +24,11 @@ >> #include >> #include >> >> +#if defined(MAJOR_IN_MKDEV) >> +#include >> +#elif defined(MAJOR_IN_SYSMACROS) >> +#include >> +#endif >> >> #ifdef HAVE_DEVICE_MAPPER >> # include >> diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/get= root.c >> index 10480b6..09e7e6e 100644 >> --- a/grub-core/osdep/linux/getroot.c >> +++ b/grub-core/osdep/linux/getroot.c >> @@ -35,6 +35,12 @@ >> #include >> #endif >> >> +#if defined(MAJOR_IN_MKDEV) >> +#include >> +#elif defined(MAJOR_IN_SYSMACROS) >> +#include >> +#endif >> + >> #include >> #include /* ioctl */ >> #include >> diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getro= ot.c >> index 1079a91..4bf37b0 100644 >> --- a/grub-core/osdep/unix/getroot.c >> +++ b/grub-core/osdep/unix/getroot.c >> @@ -51,8 +51,10 @@ >> #endif >> >> #include >> -#if defined(HAVE_SYS_MKDEV_H) >> +#if defined(MAJOR_IN_MKDEV) >> #include >> +#elif defined(MAJOR_IN_SYSMACROS) >> +#include >> #endif >> > > The names are really misleading. All that this macro checks for is > whether these headers are present, so it is entirely equivalent to > AC_CHECK_HEADERS([sys/mkdev.h sys/sysmacros.h]). Which returns us to the > question which systems have sys/sysmacros.h :) > The macro has existed for over 20 years. I can't say why it was named that = way.