aboutsummaryrefslogtreecommitdiff
path: root/src/common/int-util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/int-util.h')
-rw-r--r--src/common/int-util.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/common/int-util.h b/src/common/int-util.h
index e9eddee9c..9ac20e582 100644
--- a/src/common/int-util.h
+++ b/src/common/int-util.h
@@ -36,6 +36,10 @@
#include <string.h>
#include <sys/param.h>
+#if defined(__ANDROID__)
+#include <byteswap.h>
+#endif
+
#if defined(_MSC_VER)
#include <stdlib.h>
@@ -138,16 +142,24 @@ static inline uint32_t ident32(uint32_t x) { return x; }
static inline uint64_t ident64(uint64_t x) { return x; }
#ifndef __OpenBSD__
+# if defined(__ANDROID__) && defined(__swap32) && !defined(swap32)
+# define swap32 __swap32
+# elif !defined(swap32)
static inline uint32_t swap32(uint32_t x) {
x = ((x & 0x00ff00ff) << 8) | ((x & 0xff00ff00) >> 8);
return (x << 16) | (x >> 16);
}
+# endif
+# if defined(__ANDROID__) && defined(__swap64) && !defined(swap64)
+# define swap64 __swap64
+# elif !defined(swap64)
static inline uint64_t swap64(uint64_t x) {
x = ((x & 0x00ff00ff00ff00ff) << 8) | ((x & 0xff00ff00ff00ff00) >> 8);
x = ((x & 0x0000ffff0000ffff) << 16) | ((x & 0xffff0000ffff0000) >> 16);
return (x << 32) | (x >> 32);
}
-#endif
+# endif
+#endif /* __OpenBSD__ */
#if defined(__GNUC__)
#define UNUSED __attribute__((unused))