summaryrefslogtreecommitdiffstats
path: root/clib/misc.h
diff options
context:
space:
mode:
authorAdriana Kobylak <anoo@us.ibm.com>2015-02-18 16:14:28 -0600
committerAdriana Kobylak <anoo@us.ibm.com>2015-02-18 16:14:28 -0600
commit76ce4aadee1a7a890001affed54a0fb1110b1793 (patch)
tree14a358904909e8fe0f631d414333c26de81e5042 /clib/misc.h
parentaa8354ef7ee6606fe32453e3eedce9af8038230a (diff)
downloadffs-76ce4aadee1a7a890001affed54a0fb1110b1793.tar.gz
ffs-76ce4aadee1a7a890001affed54a0fb1110b1793.zip
Support to compile in 64bit for Ubuntu Little Endian
Diffstat (limited to 'clib/misc.h')
-rw-r--r--clib/misc.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/clib/misc.h b/clib/misc.h
index ddec6d0..edb5da5 100644
--- a/clib/misc.h
+++ b/clib/misc.h
@@ -49,6 +49,51 @@
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#ifndef be16toh
+#include <byteswap.h>
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define be16toh(x) __bswap_16(x)
+#define htobe16(x) __bswap_16(x)
+#define le16toh(x) (x)
+#define htole16(x) (x)
+#else
+#define be16toh(x) (x)
+#define htobe16(x) (x)
+#define le16toh(x) __bswap_16(x)
+#define htole16(x) __bswap_16(x)
+#endif
+#endif
+
+#ifndef be32toh
+#include <byteswap.h>
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define be32toh(x) __bswap_32(x)
+#define htobe32(x) __bswap_32(x)
+#define le32toh(x) (x)
+#define htole32(x) (x)
+#else
+#define be32toh(x) (x)
+#define htobe32(x) (x)
+#define le32toh(x) __bswap_32(x)
+#define htole32(x) __bswap_32(x)
+#endif
+#endif
+
+#ifndef be64toh
+#include <byteswap.h>
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define be64toh(x) __bswap_64(x)
+#define htobe64(x) __bswap_64(x)
+#define le64toh(x) (x)
+#define htole64(x) (x)
+#else
+#define be64toh(x) (x)
+#define htobe64(x) (x)
+#define le64toh(x) __bswap_64(x)
+#define htole64(x) __bswap_64(x)
+#endif
+#endif
+
#ifndef gettid
#define gettid() ({ \
pid_t __tid = (pid_t)syscall(SYS_gettid); \
OpenPOWER on IntegriCloud