/* MurmurHash3 was written by Austin Appleby, and is placed in the public
domain. The author hereby disclaims copyright to this source code.
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.
Adapted for Dovecot by Aki Tuomi <aki.tuomi@dovecot.fi> 2017-11-27
*/
#include "lib.h"
#include "murmurhash3.h"
//-----------------------------------------------------------------------------
// Block read - if your platform needs to do endian-swapping or can only
// handle aligned reads, do the conversion here
{
return p[i];
}
//-----------------------------------------------------------------------------
// Finalization mix - force all bits of a hash block to avalanche
{
h ^= h >> 16;
h *= 0x85ebca6b;
h ^= h >> 13;
h *= 0xc2b2ae35;
h ^= h >> 16;
return h;
}
//----------
{
//----------
// body
{
}
//----------
// tail
switch(len & 3)
{
/* fall through */
/* fall through */
};
//----------
// finalization
}
//-----------------------------------------------------------------------------
#ifdef _LP64
{
return p[i];
}
{
k ^= k >> 33;
k *= BIG_CONSTANT(0xff51afd7ed558ccd);
k ^= k >> 33;
k *= BIG_CONSTANT(0xc4ceb9fe1a85ec53);
k ^= k >> 33;
return k;
}
{
//----------
// body
{
}
//----------
// tail
switch(len & 15)
{
/* fall through */
/* fall through */
/* fall through */
/* fall through */
/* fall through */
/* fall through */
/* fall through */
/* fall through */
/* fall through */
/* fall through */
/* fall through */
/* fall through */
/* fall through */
/* fall through */
};
//----------
// finalization
}
#else
{
//----------
// body
{
}
//----------
// tail
switch(len & 15)
{
/* fall through */
/* fall through */
/* fall through */
/* fall through */
/* fall through */
/* fall through */
/* fall through */
/* fall through */
/* fall through */
/* fall through */
/* fall through */
/* fall through */
/* fall through */
/* fall through */
};
//----------
// finalization
}
#endif