testing hash

This commit is contained in:
2026-07-02 15:19:31 +03:00
parent ab619909d9
commit 4a1e0bb078
33 changed files with 2356 additions and 0 deletions
Submodule hash_testing/src/cityhash added at f5dc54147f
+46
View File
@@ -0,0 +1,46 @@
#include "hash.h"
#include <stddef.h>
#define JOAAT_SEED 0x9e3779b9u
uint32_t joaat_hash_bytes(const void *data, size_t len)
{
uint32_t hash = JOAAT_SEED;
const unsigned char *p = (const unsigned char *)data;
while (len-- > 0) {
hash += *p++;
hash += (hash << 10);
hash ^= (hash >> 6);
}
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
return hash;
}
uint32_t joaat_hash(const char *str)
{
uint32_t hash = JOAAT_SEED;
const unsigned char *p = (const unsigned char *)str;
while (*p) {
hash += *p++;
hash += (hash << 10);
hash ^= (hash >> 6);
}
hash += (hash << 3);
hash ^= (hash >> 11);
hash += (hash << 15);
return hash;
}
unsigned int hash(const char *str)
{
return (unsigned int)joaat_hash(str);
}
+21
View File
@@ -0,0 +1,21 @@
#ifndef ARSV_JOAAT_HASH_H
#define ARSV_JOAAT_HASH_H
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
uint32_t joaat_hash(const char *str);
uint32_t joaat_hash_bytes(const void *data, size_t len);
/* Compatibility wrapper matching the original set.c function name. */
unsigned int hash(const char *str);
#ifdef __cplusplus
}
#endif
#endif /* ARSV_JOAAT_HASH_H */
Submodule hash_testing/src/xxHash added at e573d4d2aa