summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHelge Deller <deller@gmx.de>2014-04-04 12:34:06 +0200
committerHelge Deller <deller@gmx.de>2014-04-04 12:34:06 +0200
commite8b4221ea02ac427fd454b85c77bafc9a980bc32 (patch)
tree7d1125f22f9e62f4d6d520006d0b62b9af1b0fe5
parent9bdbb1aa998a0259be270ec4abaa2ebec87c37fe (diff)
downloadpalo-e8b4221ea02ac427fd454b85c77bafc9a980bc32.tar.gz
Provide endianess byteswapping functions for HP-UX.
-rw-r--r--lib/common.h24
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/common.h b/lib/common.h
index 1ac0130..159eea2 100644
--- a/lib/common.h
+++ b/lib/common.h
@@ -10,17 +10,33 @@
#define __KERNEL_STRICT_NAMES /* fixes build on SUSE 10 (kernel 2.6.1[2|3]) */
-#include <sys/cdefs.h> /* useful macros */
+#if !(defined(__hpux__) || defined(__hpux))
+# include <sys/cdefs.h> /* useful macros */
+# include <byteswap.h>
+#endif
+
#include <stdarg.h>
-#include <byteswap.h>
+
+/* Swap bytes in 32 bit value. */
+#define __palo_bswap_constant_32(x) \
+ ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
+ (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
+
#if defined(__linux__)
# include <asm/byteorder.h>
-#else
+#elif defined(__hpux__) || defined(__hpux)
+/* HP-UX is always big endian */
+# define __be64_to_cpu(x) (x)
+# define __be32_to_cpu(x) (x)
+# define __be16_to_cpu(x) (x)
+# define __le32_to_cpu(x) __palo_bswap_constant_32(x)
+# define __le16_to_cpu(x) le16toh(x)
+# define __cpu_to_be32(x) (x)
+#else /* BSD and similiar */
# include <endian.h>
# define __be64_to_cpu(x) be64toh(x)
# define __be32_to_cpu(x) be32toh(x)
# define __be16_to_cpu(x) be16toh(x)
-# define __le64_to_cpu(x) le64toh(x)
# define __le32_to_cpu(x) le32toh(x)
# define __le16_to_cpu(x) le16toh(x)
# define __cpu_to_be32(x) htobe32(x)