Skip to contentSkip to conversation

build: Use AC_HEADER_MAJOR to find device macros

PATCH Superseded Mike Gilbert 3 participants 9 messages Apr 16, 2016 – Apr 24, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 build: Use AC_HEADER_MAJOR to find device macros

Depending on the OS/libc, device macros may be found in 3 places:

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 ++++++
 grub-core/osdep/unix/getroot.c       | 4 +++-
 5 files changed, 22 insertions(+), 2 deletions(-)
configure.ac +2 -1
index 57e1713..9ddfc53 100644
@@ -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>
grub-core/osdep/devmapper/getroot.c +6 -0
index 05eda50..72e5582 100644
@@ -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>
grub-core/osdep/devmapper/hostdisk.c +5 -0
index 19c1101..a697bcb 100644
@@ -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>
grub-core/osdep/linux/getroot.c +6 -0
index 10480b6..09e7e6e 100644
@@ -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>
grub-core/osdep/unix/getroot.c +3 -1
index 1079a91..4bf37b0 100644
@@ -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
 
 #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
Signature · 1 line
2.8.1
#1 lore raw

17.04.2016 00:34, Mike Gilbert пишет:

Quoted 2 lines

Depending on the OS/libc, device macros may be found in 3 places:

Mentioning OS and libc versions that have problem would be helpful.

Quoted 4 lines

sys/types.h
sys/mkdev.h
sys/sysmacros.h

Quoted 8 lines

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?

Quoted 72 lines
 grub-core/osdep/unix/getroot.c       | 4 +++-
 5 files changed, 22 insertions(+), 2 deletions(-)
configure.ac +2 -1
index 57e1713..9ddfc53 100644
@@ -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>
grub-core/osdep/devmapper/getroot.c +6 -0
index 05eda50..72e5582 100644
@@ -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>
grub-core/osdep/devmapper/hostdisk.c +5 -0
index 19c1101..a697bcb 100644
@@ -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>
grub-core/osdep/linux/getroot.c +6 -0
index 10480b6..09e7e6e 100644
@@ -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>
grub-core/osdep/unix/getroot.c +0 -0
index 1079a91..4bf37b0 100644

grub-core/osdep/unix/getroot.c line 59

Quoted 10 lines
grub-core/osdep/unix/getroot.c +3 -1
@@ -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 :)

Quoted 2 lines
grub-core/osdep/unix/getroot.c +0 -0
 #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
#2 lore raw
Quoted 6 lines · Andrei Borzenkov

17.04.2016 00:34, Mike Gilbert пишет:

Quoted 2 lines

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?

Quoted 13 lines
Quoted 4 lines

sys/types.h
sys/mkdev.h
sys/sysmacros.h

Quoted 8 lines

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 ++++++
Quoted 3 lines

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

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.

Quoted 74 lines
Quoted 74 lines
 grub-core/osdep/unix/getroot.c       | 4 +++-
 5 files changed, 22 insertions(+), 2 deletions(-)
configure.ac +2 -1
index 57e1713..9ddfc53 100644
@@ -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>
grub-core/osdep/devmapper/getroot.c +6 -0
index 05eda50..72e5582 100644
@@ -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>
grub-core/osdep/devmapper/hostdisk.c +5 -0
index 19c1101..a697bcb 100644
@@ -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>
grub-core/osdep/linux/getroot.c +6 -0
index 10480b6..09e7e6e 100644
@@ -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>
grub-core/osdep/unix/getroot.c +0 -0
index 1079a91..4bf37b0 100644
@@ -51,8 +51,10 @@
 #endif
 
Quoted 14 lines

grub-core/osdep/unix/getroot.c line 59

Quoted 8 lines
grub-core/osdep/unix/getroot.c +3 -1
 #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.

#3 lore raw

17.04.2016 18:28, Mike Gilbert пишет:

Quoted 34 lines · Andrei Borzenkov
Quoted 6 lines

17.04.2016 00:34, Mike Gilbert пишет:

Quoted 2 lines

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?

Quoted 13 lines
Quoted 4 lines

sys/types.h
sys/mkdev.h
sys/sysmacros.h

Quoted 8 lines

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 ++++++
Quoted 3 lines

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.

Quoted 4 lines

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.

Quoted 5 lines

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.

Quoted 97 lines
Quoted 75 lines
Quoted 75 lines
 grub-core/osdep/unix/getroot.c       | 4 +++-
 5 files changed, 22 insertions(+), 2 deletions(-)
configure.ac +2 -1
index 57e1713..9ddfc53 100644
@@ -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>
grub-core/osdep/devmapper/getroot.c +6 -0
index 05eda50..72e5582 100644
@@ -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>
grub-core/osdep/devmapper/hostdisk.c +5 -0
index 19c1101..a697bcb 100644
@@ -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>
grub-core/osdep/linux/getroot.c +6 -0
index 10480b6..09e7e6e 100644
@@ -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>
grub-core/osdep/unix/getroot.c +0 -0
index 1079a91..4bf37b0 100644
@@ -51,8 +51,10 @@
 #endif
 
Quoted 14 lines

grub-core/osdep/unix/getroot.c line 59

Quoted 8 lines
grub-core/osdep/unix/getroot.c +3 -1
 #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
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#4 lore raw

PATCH v2 1/1 build: Use AC_HEADER_MAJOR to find device macros

Depending on the OS/libc, device macros are defined in different headers.

sys/mkdev.h - BSD, Sun
sys/sysmacros.h - glibc (Linux)

glibc currently pulls sys/sysmacros.h into sys/types.h, but this may change in a future release.

https://sourceware.org/ml/libc-alpha/2015-11/msg00253.html

---
 configure.ac                         | 3 ++-
 grub-core/osdep/devmapper/getroot.c  | 6 ++++++
 grub-core/osdep/devmapper/hostdisk.c | 5 +++++
 grub-core/osdep/linux/getroot.c      | 6 ++++++
 grub-core/osdep/unix/getroot.c       | 4 +++-
 5 files changed, 22 insertions(+), 2 deletions(-)
configure.ac +2 -1
index 57e1713..9ddfc53 100644
@@ -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>
grub-core/osdep/devmapper/getroot.c +6 -0
index 05eda50..72e5582 100644
@@ -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>
grub-core/osdep/devmapper/hostdisk.c +5 -0
index 19c1101..a697bcb 100644
@@ -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>
grub-core/osdep/linux/getroot.c +6 -0
index 10480b6..09e7e6e 100644
@@ -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>
grub-core/osdep/unix/getroot.c +3 -1
index 1079a91..4bf37b0 100644
@@ -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
 
 #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
Signature · 1 line
2.8.1
#5 lore raw

Looks good to me. If Andrei is fine with it, I'll let him commit

Quoted 112 lines · Mike Gilbert

Depending on the OS/libc, device macros are defined in different headers.

sys/mkdev.h - BSD, Sun
sys/sysmacros.h - glibc (Linux)

glibc currently pulls sys/sysmacros.h into sys/types.h, but this may change in a future release.

https://sourceware.org/ml/libc-alpha/2015-11/msg00253.html

---
 configure.ac                         | 3 ++-
 grub-core/osdep/devmapper/getroot.c  | 6 ++++++
 grub-core/osdep/devmapper/hostdisk.c | 5 +++++
 grub-core/osdep/linux/getroot.c      | 6 ++++++
 grub-core/osdep/unix/getroot.c       | 4 +++-
 5 files changed, 22 insertions(+), 2 deletions(-)
configure.ac +2 -1
index 57e1713..9ddfc53 100644
@@ -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>

grub-core/osdep/devmapper/getroot.c +6 -0
index 05eda50..72e5582 100644
@@ -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>
grub-core/osdep/devmapper/hostdisk.c +5 -0
index 19c1101..a697bcb 100644
@@ -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>
grub-core/osdep/linux/getroot.c +6 -0
index 10480b6..09e7e6e 100644
@@ -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>
grub-core/osdep/unix/getroot.c +3 -2
index 1079a91..4bf37b0 100644
@@ -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
 
 #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
--

2.8.1

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#7 lore raw

PATCH v3 1/1 build: Use AC_HEADER_MAJOR to find device macros

Depending on the OS/libc, device macros are defined in different headers. This change ensures we include the right one.

sys/types.h - BSD
sys/mkdev.h - Sun
sys/sysmacros.h - glibc (Linux)

glibc currently pulls sys/sysmacros.h into sys/types.h, but this may change in a future release.

https://sourceware.org/ml/libc-alpha/2015-11/msg00253.html

---
 configure.ac                         | 3 ++-
 grub-core/osdep/devmapper/getroot.c  | 6 ++++++
 grub-core/osdep/devmapper/hostdisk.c | 5 +++++
 grub-core/osdep/linux/getroot.c      | 6 ++++++
 grub-core/osdep/unix/getroot.c       | 4 +++-
 5 files changed, 22 insertions(+), 2 deletions(-)
configure.ac +2 -1
index 57e1713..9ddfc53 100644
@@ -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>
grub-core/osdep/devmapper/getroot.c +6 -0
index 05eda50..72e5582 100644
@@ -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>
grub-core/osdep/devmapper/hostdisk.c +5 -0
index 19c1101..a697bcb 100644
@@ -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>
grub-core/osdep/linux/getroot.c +6 -0
index 10480b6..09e7e6e 100644
@@ -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>
grub-core/osdep/unix/getroot.c +3 -1
index 1079a91..4bf37b0 100644
@@ -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
 
 #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)
Signature · 1 line
2.8.1
#8 lore raw

19.04.2016 21:27, Mike Gilbert пишет:

Quoted 11 lines

Depending on the OS/libc, device macros are defined in different headers. This change ensures we include the right one.

sys/types.h - BSD
sys/mkdev.h - Sun
sys/sysmacros.h - glibc (Linux)

glibc currently pulls sys/sysmacros.h into sys/types.h, but this may change in a future release.

https://sourceware.org/ml/libc-alpha/2015-11/msg00253.html

committed. Thanks!

Quoted 89 lines
---
 configure.ac                         | 3 ++-
 grub-core/osdep/devmapper/getroot.c  | 6 ++++++
 grub-core/osdep/devmapper/hostdisk.c | 5 +++++
 grub-core/osdep/linux/getroot.c      | 6 ++++++
 grub-core/osdep/unix/getroot.c       | 4 +++-
 5 files changed, 22 insertions(+), 2 deletions(-)
configure.ac +2 -1
index 57e1713..9ddfc53 100644
@@ -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>
grub-core/osdep/devmapper/getroot.c +6 -0
index 05eda50..72e5582 100644
@@ -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>
grub-core/osdep/devmapper/hostdisk.c +5 -0
index 19c1101..a697bcb 100644
@@ -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>
grub-core/osdep/linux/getroot.c +6 -0
index 10480b6..09e7e6e 100644
@@ -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>
grub-core/osdep/unix/getroot.c +3 -1
index 1079a91..4bf37b0 100644
@@ -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
 
 #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR)