summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-10-29 17:54:48 +0000
committerRichard Jones <rjones@redhat.com>2010-02-19 14:46:28 +0000
commit770d1ecad2d3e46cd467b9bc3c024210ae2d8d46 (patch)
tree16b3cefe87b9923f5626951cb3e069b2f242ac23
parent5e765cda4ddece4f20ebc57f0154fdf14035cd9d (diff)
RHEL 5: Detect endianness functions and supply them.
-rw-r--r--configure.ac2
-rw-r--r--hivex/hivex.c31
-rw-r--r--hivex/hivexget.c2
-rw-r--r--hivex/hivexml.c2
4 files changed, 35 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 5dbea37..f748617 100644
--- a/configure.ac
+++ b/configure.ac
@@ -123,7 +123,7 @@ dnl Check sizeof long.
AC_CHECK_SIZEOF([long])
dnl Headers.
-dnl AC_CHECK_HEADERS([])
+AC_CHECK_HEADERS([endian.h byteswap.h])
dnl Check for pod2man and pod2text.
AC_CHECK_PROG([POD2MAN],[pod2man],[pod2man],[no])
diff --git a/hivex/hivex.c b/hivex/hivex.c
index 16be753..85d6c7b 100644
--- a/hivex/hivex.c
+++ b/hivex/hivex.c
@@ -18,11 +18,12 @@
* See file LICENSE for the full license.
*/
+#include <config.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
-#include <endian.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
@@ -30,6 +31,34 @@
#include <sys/mman.h>
#include <sys/stat.h>
#include <assert.h>
+#ifdef HAVE_ENDIAN_H
+#include <endian.h>
+#endif
+#ifdef HAVE_BYTESWAP_H
+#include <byteswap.h>
+#endif
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#ifndef be32toh
+#define be32toh(x) __bswap_32 (x)
+#endif
+#ifndef be64toh
+#define be64toh(x) __bswap_64 (x)
+#endif
+#ifndef le32toh
+#define le32toh(x) (x)
+#endif
+#else
+#ifndef be32toh
+#define be32toh(x) (x)
+#endif
+#ifndef be64toh
+#define be64toh(x) (x)
+#endif
+#ifndef le32toh
+#define le32toh(x) __bswap_32 (x)
+#endif
+#endif
#include "hivex.h"
diff --git a/hivex/hivexget.c b/hivex/hivexget.c
index 9bb6bbb..04c854f 100644
--- a/hivex/hivexget.c
+++ b/hivex/hivexget.c
@@ -16,6 +16,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include <config.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/hivex/hivexml.c b/hivex/hivexml.c
index af3de9e..9dd394e 100644
--- a/hivex/hivexml.c
+++ b/hivex/hivexml.c
@@ -16,6 +16,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include <config.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>