From 1e272a6b52d663e0b4db8f42162c4461405b7f84 Mon Sep 17 00:00:00 2001
From: Salvatore Sanfilippo <antirez@gmail.com>
Date: Sun, 19 Feb 2017 14:01:58 +0000
Subject: [PATCH] ARM: Fix 64 bit unaligned access in MurmurHash64A().

---
 src/config.h      | 6 ++++++
 src/hyperloglog.c | 4 ++++
 2 files changed, 10 insertions(+)

diff --git a/src/config.h b/src/config.h
index 9fd53626..354f8f5e 100644
--- a/src/config.h
+++ b/src/config.h
@@ -206,4 +206,10 @@ void setproctitle(const char *fmt, ...);
 #endif
 #endif
 
+/* Make sure we can test for ARM just checking for __arm__, since sometimes
+ * __arm is defined but __arm__ is not. */
+#if defined(__arm) && !defined(__arm__)
+#define __arm__
+#endif
+
 #endif
diff --git a/src/hyperloglog.c b/src/hyperloglog.c
index 0800bf59..7de5786f 100644
--- a/src/hyperloglog.c
+++ b/src/hyperloglog.c
@@ -401,7 +401,11 @@ uint64_t MurmurHash64A (const void * key, int len, unsigned int seed) {
         uint64_t k;
 
 #if (BYTE_ORDER == LITTLE_ENDIAN)
+	#ifdef __arm__
+	memcpy(&k,data,sizeof(uint64_t));
+	#else
         k = *((uint64_t*)data);
+	#endif
 #else
         k = (uint64_t) data[0];
         k |= (uint64_t) data[1] << 8;