From: Andrei Borzenkov <arvidjaar@gmail.com>
To: grub-devel@gnu.org
Subject: Re: [PATCH] build: Use AC_HEADER_MAJOR to find device macros
Date: Sun, 17 Apr 2016 20:33:52 +0300 [thread overview]
Message-ID: <5713C900.8070007@gmail.com> (raw)
In-Reply-To: <CAJ0EP42MozJ=MBOPiht_bN78AF3xaK1=X9JZUhykGZYiw_ZSeg@mail.gmail.com>
17.04.2016 18:28, Mike Gilbert пишет:
> On Sun, Apr 17, 2016 at 1:53 AM, Andrei Borzenkov <arvidjaar@gmail.com> wrote:
>> 17.04.2016 00:34, Mike Gilbert пишет:
>>> 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
> <sys/sysmacros.h> 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
>
Then your commit message is misleading. It is not found in 3 places, it
is found in 2 places, one of which is pulled in by default currently.
> 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.
I'm fine with it actually (it should not break anything) but could you
please clean up commit message, mention that problem will be caused by
removal of sys/sysmacros.h default inclusion in glibc and add reference
to above discussion. Given release cycle of grub it probably make sense
to include it in 2.02.
>
>>> 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 limits.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 <sys/param.h>
>>> diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devmapper/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 <limits.h>
>>> #endif
>>>
>>> +#if defined(MAJOR_IN_MKDEV)
>>> +#include <sys/mkdev.h>
>>> +#elif defined(MAJOR_IN_SYSMACROS)
>>> +#include <sys/sysmacros.h>
>>> +#endif
>>> +
>>> #include <libdevmapper.h>
>>>
>>> #include <grub/types.h>
>>> diff --git a/grub-core/osdep/devmapper/hostdisk.c b/grub-core/osdep/devmapper/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 <errno.h>
>>> #include <limits.h>
>>>
>>> +#if defined(MAJOR_IN_MKDEV)
>>> +#include <sys/mkdev.h>
>>> +#elif defined(MAJOR_IN_SYSMACROS)
>>> +#include <sys/sysmacros.h>
>>> +#endif
>>>
>>> #ifdef HAVE_DEVICE_MAPPER
>>> # include <libdevmapper.h>
>>> diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c
>>> index 10480b6..09e7e6e 100644
>>> --- a/grub-core/osdep/linux/getroot.c
>>> +++ b/grub-core/osdep/linux/getroot.c
>>> @@ -35,6 +35,12 @@
>>> #include <limits.h>
>>> #endif
>>>
>>> +#if defined(MAJOR_IN_MKDEV)
>>> +#include <sys/mkdev.h>
>>> +#elif defined(MAJOR_IN_SYSMACROS)
>>> +#include <sys/sysmacros.h>
>>> +#endif
>>> +
>>> #include <grub/types.h>
>>> #include <sys/ioctl.h> /* ioctl */
>>> #include <sys/mount.h>
>>> diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.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 <sys/types.h>
>>> -#if defined(HAVE_SYS_MKDEV_H)
>>> +#if defined(MAJOR_IN_MKDEV)
>>> #include <sys/mkdev.h>
>>> +#elif defined(MAJOR_IN_SYSMACROS)
>>> +#include <sys/sysmacros.h>
>>> #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.
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>
next prev parent reply other threads:[~2016-04-17 17:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-16 21:34 [PATCH] build: Use AC_HEADER_MAJOR to find device macros Mike Gilbert
2016-04-17 5:53 ` Andrei Borzenkov
2016-04-17 15:28 ` Mike Gilbert
2016-04-17 17:33 ` Andrei Borzenkov [this message]
2016-04-17 18:27 ` [PATCH v2] " Mike Gilbert
2016-04-18 6:11 ` Vladimir 'phcoder' Serbinenko
2016-04-18 15:32 ` Mike Gilbert
2016-04-19 18:27 ` [PATCH v3] " Mike Gilbert
2016-04-24 5:13 ` Andrei Borzenkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5713C900.8070007@gmail.com \
--to=arvidjaar@gmail.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.