summaryrefslogtreecommitdiff
path: root/adk/include/byteswap.h
diff options
context:
space:
mode:
Diffstat (limited to 'adk/include/byteswap.h')
-rw-r--r--adk/include/byteswap.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/adk/include/byteswap.h b/adk/include/byteswap.h
new file mode 100644
index 000000000..f557cd468
--- /dev/null
+++ b/adk/include/byteswap.h
@@ -0,0 +1,18 @@
+#if defined(__linux__) || defined(__CYGWIN__)
+#include_next <byteswap.h>
+#else
+static inline unsigned short bswap_16(unsigned short val)
+{
+ return ((val & 0xff) << 8) | ((val >> 8) & 0xff);
+}
+static inline unsigned long bswap_32(unsigned long val)
+{
+ return bswap_16((unsigned short)val) << 16 |
+ bswap_16((unsigned short)(val >> 16));
+}
+static inline unsigned long long bswap_64(unsigned long long val)
+{
+ return ((((unsigned long long)bswap_32(val)) << 32) |
+ (((unsigned long long)bswap_32(val >> 32)) & 0xffffffffULL));
+}
+#endif