summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraappleby@google.com <aappleby@google.com@77a7d1d3-4c08-bdc2-d393-d5859734b01a>2011-04-08 19:46:54 +0000
committeraappleby@google.com <aappleby@google.com@77a7d1d3-4c08-bdc2-d393-d5859734b01a>2011-04-08 19:46:54 +0000
commit7af0ee099b7f8d3a5b628791951ffb9680082583 (patch)
treeae9d1d5da56e0cfc10817e47d005aa46de81fcde
parent58dd8869da8c95f5c26ec70a6cdd243a7647c8fc (diff)
downloadsrc-7af0ee099b7f8d3a5b628791951ffb9680082583.tar.gz
gcc complains about multiply defined symbols, move rotl macros back to source file
git-svn-id: http://smhasher.googlecode.com/svn/trunk@127 77a7d1d3-4c08-bdc2-d393-d5859734b01a
-rw-r--r--MurmurHash3.cpp39
-rw-r--r--MurmurHash3.h28
2 files changed, 40 insertions, 27 deletions
diff --git a/MurmurHash3.cpp b/MurmurHash3.cpp
index 95d2e26..8ce4688 100644
--- a/MurmurHash3.cpp
+++ b/MurmurHash3.cpp
@@ -10,6 +10,45 @@
#include "MurmurHash3.h"
//-----------------------------------------------------------------------------
+// Platform-specific functions and macros
+
+// Microsoft Visual Studio
+
+#if defined(_MSC_VER)
+
+#define FORCE_INLINE __forceinline
+
+#include <stdlib.h>
+
+#define ROTL32(x,y) _rotl(x,y)
+#define ROTL64(x,y) _rotl64(x,y)
+
+#define BIG_CONSTANT(x) (x)
+
+// Other compilers
+
+#else // defined(_MSC_VER)
+
+#define FORCE_INLINE __attribute__((always_inline))
+
+inline uint32_t rotl32 ( uint32_t x, int8_t r )
+{
+ return (x << r) | (x >> (32 - r));
+}
+
+inline uint64_t rotl64 ( uint64_t x, int8_t r )
+{
+ return (x << r) | (x >> (64 - r));
+}
+
+#define ROTL32(x,y) rotl32(x,y)
+#define ROTL64(x,y) rotl64(x,y)
+
+#define BIG_CONSTANT(x) (x##LLU)
+
+#endif // !defined(_MSC_VER)
+
+//-----------------------------------------------------------------------------
// Block read - if your platform needs to do endian-swapping or can only
// handle aligned reads, do the conversion here
diff --git a/MurmurHash3.h b/MurmurHash3.h
index a2f26e9..9c8425c 100644
--- a/MurmurHash3.h
+++ b/MurmurHash3.h
@@ -21,38 +21,12 @@ typedef unsigned char uint8_t;
typedef unsigned long uint32_t;
typedef unsigned __int64 uint64_t;
-#define FORCE_INLINE __forceinline
-
-#include <stdlib.h>
-
-#define ROTL32(x,y) _rotl(x,y)
-#define ROTL64(x,y) _rotl64(x,y)
-
-#define BIG_CONSTANT(x) (x)
-
// Other compilers
#else // defined(_MSC_VER)
#include <stdint.h>
-#define FORCE_INLINE __attribute__((always_inline))
-
-inline uint32_t rotl32 ( uint32_t x, int8_t r )
-{
- return (x << r) | (x >> (32 - r));
-}
-
-inline uint64_t rotl64 ( uint64_t x, int8_t r )
-{
- return (x << r) | (x >> (64 - r));
-}
-
-#define ROTL32(x,y) rotl32(x,y)
-#define ROTL64(x,y) rotl64(x,y)
-
-#define BIG_CONSTANT(x) (x##LLU)
-
#endif // !defined(_MSC_VER)
//-----------------------------------------------------------------------------
@@ -65,4 +39,4 @@ void MurmurHash3_x64_128 ( const void * key, int len, uint32_t seed, void * out
//-----------------------------------------------------------------------------
-#endif // _MURMURHASH3_H_ \ No newline at end of file
+#endif // _MURMURHASH3_H_