psss / rpms / libguestfs

Forked from rpms/libguestfs 5 years ago
Clone
Blob Blame History Raw
From 1fe7310e8564915508158f68e9d2f3187f7bdfbe Mon Sep 17 00:00:00 2001
From: Richard W.M. Jones <rjones@redhat.com>
Date: Fri, 8 Mar 2013 20:16:04 +0000
Subject: [PATCH 02/38] RHEL 5: inspect: Add macro for be32toh if one is not defined in the header files.

---
 configure.ac       |    1 +
 src/inspect-apps.c |   12 ++++++++++++
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 9d73c67..7a6df55 100644
--- a/configure.ac
+++ b/configure.ac
@@ -279,6 +279,7 @@ AC_CHECK_HEADERS([\
 
 dnl Functions.
 AC_CHECK_FUNCS([\
+    be32toh \
     fsync \
     futimens \
     getxattr \
diff --git a/src/inspect-apps.c b/src/inspect-apps.c
index 135adf7..747985e 100644
--- a/src/inspect-apps.c
+++ b/src/inspect-apps.c
@@ -32,6 +32,18 @@
 #include <endian.h>
 #endif
 
+/* be32toh is usually a macro definend in <endian.h>, but it might be
+ * a function in some system so check both, and if neither is defined
+ * then define be32toh for RHEL 5.
+ */
+#if !defined(HAVE_BE32TOH) && !defined(be32toh)
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define be32toh(x) __bswap_32 (x)
+#else
+#define be32toh(x) (x)
+#endif
+#endif
+
 #include <pcre.h>
 
 #include "xstrtol.h"
-- 
1.7.4.1