[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH for-4.15] autoconf: check endian.h include path


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Thu, 4 Feb 2021 10:38:33 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FV6zQhox0t6WyZyOKRZdDZ0EWUIr6LMm4rPKFCDSIKM=; b=n+fzV0BVz7IC3oN3tThlirNiJmpu9L5svKWwjSCNBTSQN6CIWicGpYbobeIbeA9CGfIvHd7aSGh8D2VrnBuoZkkriyit78jyUGdnfN4B8uO2EWlvCSYxk/wvVC80cJmnWgdrC1hvMy+bwuRBNBZNFvrFfPLHq1XhQ77faye+WN4Y+uhjkgS8Z2ysihu6X5eAxtNIsp6Qr/CteGDgbyU+tZNyJpeGpsYKv417lzb09ErS3FCno9LS4vZKKy+Aj5GwKhn9x/MAqqU+bEEGXhezReiwMleOnk3MadcNfNReaTO96/cKWD5QX0Pb2MpEaq958AXKmaEciK+8DsyEhXBgrw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HuxQMCOGmGnOwZ9GB+ixpIeXiWythgscUS8+JrjI0tNqi9wTCE9Z+ZnpJ5GSJ9DiQZTx3FOpW0kI4iSD0V7v2//rZiW/VtsPsbQFurMj8WLctw6uOdD3TYDd9UUgAUe6j75KMsvqBd9LYLPh2lt6B5Rlo8Ybd3SH2xOaCBdKpZdZQli+eeyNgoReKqvo1Q85xQHsYMkRJQhwu4So2ZKFyWljZgti11OA+guXT47NQS768wRYrb8MevojOkc5zbmdGttM5cHztolO/Q2IngjPUWcW0wNFskQgpag65TqXeS3FVQS+780DSaLuEsmBuWtJAockkQA5ggvQAqjKMLTBxg==
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Thu, 04 Feb 2021 09:38:58 +0000
  • Ironport-sdr: 8zP6IfrSXrZYzz3HL98vzNgx/6VEsJaiUkYtTih5juwE8rMg57+mSWE0OfAgTS2Qc+Dw+fC3Xe QOX4nQQl9dzqyILAxFWgOAOokQIq4LYR5NDSfR1NM+scDJFdT9aZ5zKvQFOLY8/nIdDk84lfJl 9BBu6+Pyn+BNz+SpaHS8sDCaQ3Me8G9iFMM0xj4vTHHWSqUrenXJbzaPP6hNZXR2LL18Co5iI7 wZYWeIsco06qa5a1fOnnJUS/unrTfD8WigdykABXSNnPzLS3QkCuCSY/vhJ6GWrrsS3N1LQl5l t1Y=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxxxxxxxxx>
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Please re-run autogen after applying.

The biggest risk for this would be some kind of configure or build
failure, and we should be able to catch it in either osstest or the
gitlab build tests.
---
 m4/header.m4                                      | 13 +++++++++++++
 tools/configure.ac                                |  3 +++
 tools/libs/guest/xg_dom_decompress_unsafe_lzo1x.c |  2 +-
 tools/libs/guest/xg_dom_decompress_unsafe_xz.c    |  2 +-
 tools/libs/guest/xg_dom_decompress_unsafe_zstd.c  |  2 +-
 tools/xenstore/include/xenstore_state.h           |  6 +-----
 6 files changed, 20 insertions(+), 8 deletions(-)
 create mode 100644 m4/header.m4

diff --git a/m4/header.m4 b/m4/header.m4
new file mode 100644
index 0000000000..81d1d65194
--- /dev/null
+++ b/m4/header.m4
@@ -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])
+])
+])
diff --git a/tools/configure.ac b/tools/configure.ac
index 5b328700e0..3a3e7b4b2b 100644
--- a/tools/configure.ac
+++ b/tools/configure.ac
@@ -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()
diff --git a/tools/libs/guest/xg_dom_decompress_unsafe_lzo1x.c 
b/tools/libs/guest/xg_dom_decompress_unsafe_lzo1x.c
index a4f8ebd42d..e58c1b95ed 100644
--- a/tools/libs/guest/xg_dom_decompress_unsafe_lzo1x.c
+++ b/tools/libs/guest/xg_dom_decompress_unsafe_lzo1x.c
@@ -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"
diff --git a/tools/libs/guest/xg_dom_decompress_unsafe_xz.c 
b/tools/libs/guest/xg_dom_decompress_unsafe_xz.c
index ff6824b38d..fc48198741 100644
--- a/tools/libs/guest/xg_dom_decompress_unsafe_xz.c
+++ b/tools/libs/guest/xg_dom_decompress_unsafe_xz.c
@@ -1,5 +1,5 @@
 #include <stdio.h>
-#include <endian.h>
+#include INCLUDE_ENDIAN_H
 #include <stdlib.h>
 #include <stddef.h>
 #include <stdint.h>
diff --git a/tools/libs/guest/xg_dom_decompress_unsafe_zstd.c 
b/tools/libs/guest/xg_dom_decompress_unsafe_zstd.c
index 52558d2ffc..01eafaaaa6 100644
--- a/tools/libs/guest/xg_dom_decompress_unsafe_zstd.c
+++ b/tools/libs/guest/xg_dom_decompress_unsafe_zstd.c
@@ -1,5 +1,5 @@
 #include <stdio.h>
-#include <endian.h>
+#include INCLUDE_ENDIAN_H
 #include <stdlib.h>
 #include <stddef.h>
 #include <stdint.h>
diff --git a/tools/xenstore/include/xenstore_state.h 
b/tools/xenstore/include/xenstore_state.h
index f7e4da2b2c..ae0d053c8f 100644
--- a/tools/xenstore/include/xenstore_state.h
+++ b/tools/xenstore/include/xenstore_state.h
@@ -21,11 +21,7 @@
 #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
-- 
2.29.2




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.