summaryrefslogtreecommitdiff
path: root/MurmurHash3.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'MurmurHash3.cpp')
-rw-r--r--MurmurHash3.cpp39
1 files changed, 39 insertions, 0 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