summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuc Verhaegen <libv@skynet.be>2010-03-27 16:56:06 +0100
committerLuc Verhaegen <libv@skynet.be>2010-03-27 16:56:06 +0100
commit9e43c3a677f2418b60e8a2f3a6e2f9b0040f17b6 (patch)
treec3892658b038c4265f6f1a6d21cc0354ba1ef8bd
parent2057a5f88b6e39537ff151cac01fe2d5000d5bc3 (diff)
Add leXXtoh() compat macros.
Apparently debian lenny doesn't come with these in its libc :) Reported by Maciej Pijanka.
-rw-r--r--ami_slab.c11
-rw-r--r--bios_extract.h11
-rw-r--r--lh5_extract.c11
3 files changed, 33 insertions, 0 deletions
diff --git a/ami_slab.c b/ami_slab.c
index 4a47651..6ed6e0e 100644
--- a/ami_slab.c
+++ b/ami_slab.c
@@ -25,6 +25,17 @@
#include <sys/stat.h>
#include <sys/mman.h>
+#if !defined(le32toh) || !defined(le16toh)
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define le32toh(x) (x)
+#define le16toh(x) (x)
+#else
+#include <byteswap.h>
+#define le32toh(x) bswap_32(x)
+#define le16toh(x) bswap_16(x)
+#endif
+#endif
+
struct slabentry {
uint32_t destaddr;
uint32_t length_flag;
diff --git a/bios_extract.h b/bios_extract.h
index 4d38e62..a39a747 100644
--- a/bios_extract.h
+++ b/bios_extract.h
@@ -23,6 +23,17 @@
#define FALSE 0
#define TRUE 1
+#if !defined(le32toh) || !defined(le16toh)
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define le32toh(x) (x)
+#define le16toh(x) (x)
+#else
+#include <byteswap.h>
+#define le32toh(x) bswap_32(x)
+#define le16toh(x) bswap_16(x)
+#endif
+#endif
+
/* bios_extract.c */
unsigned char *MMapOutputFile(char *filename, int size);
diff --git a/lh5_extract.c b/lh5_extract.c
index b3e2d98..0df2c3d 100644
--- a/lh5_extract.c
+++ b/lh5_extract.c
@@ -36,6 +36,17 @@
#include "lh5_extract.h"
+#if !defined(le32toh) || !defined(le16toh)
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define le32toh(x) (x)
+#define le16toh(x) (x)
+#else
+#include <byteswap.h>
+#define le32toh(x) bswap_32(x)
+#define le16toh(x) bswap_16(x)
+#endif
+#endif
+
/*
*
* LHA header parsing.