aboutsummaryrefslogtreecommitdiff
path: root/src/common/int-util.h
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-01-08 16:40:02 -0800
committerRiccardo Spagni <ric@spagni.net>2017-01-08 16:40:02 -0800
commit2a996f492f933a6b7c27117904fecc447d0c2dc1 (patch)
tree2ee0ebfd45b1c35fd16f037693406bb7d0fa93e7 /src/common/int-util.h
parentMerge pull request #1509 (diff)
parentBuild wallet with Android NDK (diff)
downloadmonero-2a996f492f933a6b7c27117904fecc447d0c2dc1.tar.xz
Merge pull request #1510
80abc3bc Build wallet with Android NDK (MoroccanMalinois)
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))