#include "zbxalgo.h"
#include "algodefs.h"
#include "zbxstr.h"
typedef unsigned char uchar;
zbx_hash_t zbx_hash_modfnv(const void *data, size_t len, zbx_hash_t seed)
{
const uchar *p = (const uchar *)data;
zbx_hash_t hash;
hash = 2166136261u ^ seed;
while (len-- >= 1)
{
hash = (hash ^ *(p++)) * 16777619u;
}
hash += hash << 13;
hash ^= hash >> 7;
hash += hash << 3;
hash ^= hash >> 17;
hash += hash << 5;
return hash;
}
zbx_hash_t zbx_hash_splittable64(const void *data)
{
zbx_uint64_t value = *(const zbx_uint64_t *)data;
value ^= value >> 30;
value *= __UINT64_C(0xbf58476d1ce4e5b9);
value ^= value >> 27;
value *= __UINT64_C(0x94d049bb133111eb);
value ^= value >> 31;
return (zbx_hash_t)value ^ (value >> 32);
}
zbx_hash_t zbx_default_ptr_hash_func(const void *data)
{
return ZBX_DEFAULT_PTR_HASH_ALGO(data, ZBX_PTR_SIZE, ZBX_DEFAULT_HASH_SEED);
}
zbx_hash_t zbx_default_string_hash_func(const void *data)
{
return ZBX_DEFAULT_STRING_HASH_ALGO(data, strlen((const char *)data), ZBX_DEFAULT_HASH_SEED);
}
zbx_hash_t zbx_default_string_ptr_hash_func(const void *data)
{
return zbx_default_string_hash_func(*((const char * const *)data));
}
zbx_hash_t zbx_default_uint64_pair_hash_func(const void *data)
{
const zbx_uint64_pair_t *pair = (const zbx_uint64_pair_t *)data;
zbx_hash_t hash;
hash = ZBX_DEFAULT_UINT64_HASH_FUNC(&pair->first);
hash = ZBX_DEFAULT_UINT64_HASH_ALGO(&pair->second, sizeof(pair->second), hash);
return hash;
}