summaryrefslogtreecommitdiff
path: root/tests/make_png/murmur3.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/make_png/murmur3.c')
-rw-r--r--tests/make_png/murmur3.c89
1 files changed, 42 insertions, 47 deletions
diff --git a/tests/make_png/murmur3.c b/tests/make_png/murmur3.c
index 484ebfd03..6698c09d5 100644
--- a/tests/make_png/murmur3.c
+++ b/tests/make_png/murmur3.c
@@ -1,45 +1,40 @@
-//-----------------------------------------------------------------------------
-// Note - The x86 and x64 versions do _not_ produce the same results, as the
-// algorithms are optimized for their respective platforms. You can still
-// compile and run any of them on any platform, but your performance with the
-// non-native version will be less than optimal.
+/*------------------------------------------------------------------*/
+/* Note - The x86 and x64 versions do _not_ produce the same */
+/* results, as the algorithms are optimized for their respective */
+/* platforms. You can still compile and run any of them on any */
+/* platform, but your performance with the non-native version */
+/* will be less than optimal. */
#include "murmur3.h"
-//-----------------------------------------------------------------------------
-// Platform-specific functions and macros
+/*------------------------------------------------------------------*/
+/* Platform-specific functions and macros */
-#ifdef __GNUC__
-#define FORCE_INLINE __attribute__((always_inline)) inline
-#else
-#define FORCE_INLINE inline
-#endif
-
-static FORCE_INLINE uint32_t rotl32 ( uint32_t x, int8_t r )
+static uint32_t rotl32 ( uint32_t x, int8_t r )
{
return (x << r) | (x >> (32 - r));
}
-static FORCE_INLINE uint64_t rotl64 ( uint64_t x, int8_t r )
+static 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 ROTL32(x,y) rotl32(x,y)
+#define ROTL64(x,y) rotl64(x,y)
#define BIG_CONSTANT(x) (x##LLU)
-//-----------------------------------------------------------------------------
-// Block read - if your platform needs to do endian-swapping or can only
-// handle aligned reads, do the conversion here
+/*------------------------------------------------------------------*/
+/* Block read - if your platform needs to do endian-swapping or can */
+/* only handle aligned reads, do the conversion here */
#define getblock(p, i) (p[i])
-//-----------------------------------------------------------------------------
-// Finalization mix - force all bits of a hash block to avalanche
+/*------------------------------------------------------------------*/
+/* Finalization mix - force all bits of a hash block to avalanche */
-static FORCE_INLINE uint32_t fmix32 ( uint32_t h )
+static uint32_t fmix32 ( uint32_t h )
{
h ^= h >> 16;
h *= 0x85ebca6b;
@@ -50,9 +45,9 @@ static FORCE_INLINE uint32_t fmix32 ( uint32_t h )
return h;
}
-//----------
+/*----------*/
-static FORCE_INLINE uint64_t fmix64 ( uint64_t k )
+static uint64_t fmix64 ( uint64_t k )
{
k ^= k >> 33;
k *= BIG_CONSTANT(0xff51afd7ed558ccd);
@@ -63,7 +58,7 @@ static FORCE_INLINE uint64_t fmix64 ( uint64_t k )
return k;
}
-//-----------------------------------------------------------------------------
+/*------------------------------------------------------------------*/
void MurmurHash3_x86_32 ( const void * key, int len,
uint32_t seed, void * out )
@@ -77,8 +72,8 @@ void MurmurHash3_x86_32 ( const void * key, int len,
uint32_t c1 = 0xcc9e2d51;
uint32_t c2 = 0x1b873593;
- //----------
- // body
+ /*----------*/
+ /* body */
const uint32_t * blocks = (const uint32_t *)(data + nblocks*4);
@@ -95,8 +90,8 @@ void MurmurHash3_x86_32 ( const void * key, int len,
h1 = h1*5+0xe6546b64;
}
- //----------
- // tail
+ /*----------*/
+ /* tail */
const uint8_t * tail = (const uint8_t*)(data + nblocks*4);
@@ -110,8 +105,8 @@ void MurmurHash3_x86_32 ( const void * key, int len,
k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
};
- //----------
- // finalization
+ /*----------*/
+ /* finalization */
h1 ^= len;
@@ -120,7 +115,7 @@ void MurmurHash3_x86_32 ( const void * key, int len,
*(uint32_t*)out = h1;
}
-//-----------------------------------------------------------------------------
+/*------------------------------------------------------------------*/
void MurmurHash3_x86_128 ( const void * key, const int len,
uint32_t seed, void * out )
@@ -139,8 +134,8 @@ void MurmurHash3_x86_128 ( const void * key, const int len,
uint32_t c3 = 0x38b34ae5;
uint32_t c4 = 0xa1e38b93;
- //----------
- // body
+ /*----------*/
+ /* body */
const uint32_t * blocks = (const uint32_t *)(data + nblocks*16);
@@ -168,8 +163,8 @@ void MurmurHash3_x86_128 ( const void * key, const int len,
h4 = ROTL32(h4,13); h4 += h1; h4 = h4*5+0x32ac3b17;
}
- //----------
- // tail
+ /*----------*/
+ /* tail */
const uint8_t * tail = (const uint8_t*)(data + nblocks*16);
@@ -204,8 +199,8 @@ void MurmurHash3_x86_128 ( const void * key, const int len,
k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
};
- //----------
- // finalization
+ /*----------*/
+ /* finalization */
h1 ^= len; h2 ^= len; h3 ^= len; h4 ^= len;
@@ -226,7 +221,7 @@ void MurmurHash3_x86_128 ( const void * key, const int len,
((uint32_t*)out)[3] = h4;
}
-//-----------------------------------------------------------------------------
+/*------------------------------------------------------------------*/
void MurmurHash3_x64_128 ( const void * key, const int len,
const uint32_t seed, void * out )
@@ -241,8 +236,8 @@ void MurmurHash3_x64_128 ( const void * key, const int len,
uint64_t c1 = BIG_CONSTANT(0x87c37b91114253d5);
uint64_t c2 = BIG_CONSTANT(0x4cf5ad432745937f);
- //----------
- // body
+ /*----------*/
+ /* body */
const uint64_t * blocks = (const uint64_t *)(data);
@@ -260,8 +255,8 @@ void MurmurHash3_x64_128 ( const void * key, const int len,
h2 = ROTL64(h2,31); h2 += h1; h2 = h2*5+0x38495ab5;
}
- //----------
- // tail
+ /*----------*/
+ /* tail */
const uint8_t * tail = (const uint8_t*)(data + nblocks*16);
@@ -290,8 +285,8 @@ void MurmurHash3_x64_128 ( const void * key, const int len,
k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1;
};
- //----------
- // finalization
+ /*----------*/
+ /* finalization*/
h1 ^= len; h2 ^= len;
@@ -308,5 +303,5 @@ void MurmurHash3_x64_128 ( const void * key, const int len,
((uint64_t*)out)[1] = h2;
}
-//-----------------------------------------------------------------------------
+/*------------------------------------------------------------------*/