]> xenbits.xensource.com Git - xen.git/commitdiff
autoconf: check endian.h include path
authorRoger Pau Monne <roger.pau@citrix.com>
Thu, 4 Feb 2021 09:38:33 +0000 (10:38 +0100)
committerIan Jackson <iwj@xenproject.org>
Wed, 10 Feb 2021 11:10:55 +0000 (11:10 +0000)
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>
m4/header.m4 [new file with mode: 0644]
tools/configure.ac
tools/libs/guest/xg_dom_decompress_unsafe_lzo1x.c
tools/libs/guest/xg_dom_decompress_unsafe_xz.c
tools/libs/guest/xg_dom_decompress_unsafe_zstd.c
tools/xenstore/include/xenstore_state.h

diff --git a/m4/header.m4 b/m4/header.m4
new file mode 100644 (file)
index 0000000..81d1d65
--- /dev/null
@@ -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])
+])
+])
index 5b328700e0250411e705275e3c64a9631bf20668..3a3e7b4b2baa29e2af7db4cc2e46c474e0c6bb2a 100644 (file)
@@ -74,6 +74,7 @@ m4_include([../m4/ax_compare_version.m4])
 m4_include([../m4/paths.m4])
 m4_include([../m4/systemd.m4])
 m4_include([../m4/golang.m4])
+m4_include([../m4/header.m4])
 
 AX_XEN_EXPAND_CONFIG()
 
@@ -517,4 +518,6 @@ AC_ARG_ENABLE([pvshim],
 ])
 AC_SUBST(pvshim)
 
+AX_FIND_HEADER([INCLUDE_ENDIAN_H], [endian.h sys/endian.h])
+
 AC_OUTPUT()
index a4f8ebd42de76aa09198b7d2090dff700840d568..e58c1b95ed17c043cff7d26f6e6ad18aeb48b68b 100644 (file)
@@ -1,7 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <inttypes.h>
-#include <endian.h>
+#include INCLUDE_ENDIAN_H
 #include <stdint.h>
 
 #include "xg_private.h"
index ff6824b38d03c6192d532de71634918b4da31db9..fc481987411150fef734177cc87ad4dc5e918ddf 100644 (file)
@@ -1,5 +1,5 @@
 #include <stdio.h>
-#include <endian.h>
+#include INCLUDE_ENDIAN_H
 #include <stdlib.h>
 #include <stddef.h>
 #include <stdint.h>
index 52558d2ffc5bdc2e57b5a2f49ce1d87146a42333..01eafaaaa69d62ecf21048220f53be911c25d965 100644 (file)
@@ -1,5 +1,5 @@
 #include <stdio.h>
-#include <endian.h>
+#include INCLUDE_ENDIAN_H
 #include <stdlib.h>
 #include <stddef.h>
 #include <stdint.h>
index f7e4da2b2cd6f45ecb5abb9e0b354b6d8613d9f6..ae0d053c8ffc07c1e0491da647bcc40728d127f3 100644 (file)
 #ifndef XENSTORE_STATE_H
 #define XENSTORE_STATE_H
 
-#if defined(__FreeBSD__) || defined(__NetBSD__)
-#include <sys/endian.h>
-#else
-#include <endian.h>
-#endif
+#include INCLUDE_ENDIAN_H
 #include <sys/types.h>
 
 #ifndef htobe32