autoconf: check endian.h include path

Introduce an autoconf macro to check for the include path of certain
headers that can be different between OSes.

Use such macro to find the correct path for the endian.h header, and
modify the users of endian.h to use the output of such check.

Suggested-by: Ian Jackson <iwj@xenproject.org>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Ian Jackson <iwj@xenproject.org>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
This commit is contained in:
Roger Pau Monne authored and Ian Jackson committed 2021-02-10 11:10:55 +00:00
1 parent 687121f8a0
commit c9b0242ad4
6 files changed
+20 -8

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
AC_DEFUN([AX_FIND_HEADER], [
ax_found=0
m4_foreach_w([header], $2, [
AS_IF([test "$ax_found" = "0"], [
AC_CHECK_HEADER(header, [
AC_DEFINE($1, [<header>], [Header path for $1])
ax_found=1])
])
])
AS_IF([test "$ax_found" = "0"], [
AC_MSG_ERROR([No header found from list $2])
])
])
+3
View File
@@ -74,6 +74,7 @@ m4_include([../m4/ax_compare_version.m4])
m4_include([../m4/paths.m4]) m4_include([../m4/paths.m4])
m4_include([../m4/systemd.m4]) m4_include([../m4/systemd.m4])
m4_include([../m4/golang.m4]) m4_include([../m4/golang.m4])
m4_include([../m4/header.m4])
AX_XEN_EXPAND_CONFIG() AX_XEN_EXPAND_CONFIG()
@@ -517,4 +518,6 @@ AC_ARG_ENABLE([pvshim],
]) ])
AC_SUBST(pvshim) AC_SUBST(pvshim)
AX_FIND_HEADER([INCLUDE_ENDIAN_H], [endian.h sys/endian.h])
AC_OUTPUT() AC_OUTPUT()
@@ -1,7 +1,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <inttypes.h> #include <inttypes.h>
#include <endian.h> #include INCLUDE_ENDIAN_H
#include <stdint.h> #include <stdint.h>
#include "xg_private.h" #include "xg_private.h"
@@ -1,5 +1,5 @@
#include <stdio.h> #include <stdio.h>
#include <endian.h> #include INCLUDE_ENDIAN_H
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
@@ -1,5 +1,5 @@
#include <stdio.h> #include <stdio.h>
#include <endian.h> #include INCLUDE_ENDIAN_H
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
+1 -5
View File
@@ -21,11 +21,7 @@
#ifndef XENSTORE_STATE_H #ifndef XENSTORE_STATE_H
#define XENSTORE_STATE_H #define XENSTORE_STATE_H
#if defined(__FreeBSD__) || defined(__NetBSD__) #include INCLUDE_ENDIAN_H
#include <sys/endian.h>
#else
#include <endian.h>
#endif
#include <sys/types.h> #include <sys/types.h>
#ifndef htobe32 #ifndef htobe32
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.