Restructure hasher implementation
Release / release (push) Successful in 3s

This commit is contained in:
Abdelrahman Said
2026-09-23 00:02:37 +01:00
parent 9881c0ac9a
commit c215486442
9 changed files with 175 additions and 144 deletions
+33 -8
View File
@@ -4,24 +4,49 @@
#define HASHER_H
#include "../../stream/stream.h"
#include "../../../common/aliases/aliases.h"
#ifdef WP_PLATFORM_CPP
BEGIN_C_LINKAGE
#endif // !WP_PLATFORM_CPP
typedef struct WpU128Hash {
u64 hash[2];
} WpU128Hash;
typedef struct WpU128 {
u64 value[2];
} WpU128;
typedef WpU128Hash (*WpHashFunc)(WpU8Stream *stream, void *hasher_data);
typedef enum WpHasherCtxType {
WP_HASHER_CTX_MURMUR3,
WP_HASHER_CTX_SIPHASH,
WP_HASHER_CTX_USER_DEFINED,
COUNT_HASHER_CTX,
} WpHasherCtxType;
typedef struct WpSiphashCtx {
WpU128 key;
u64 compression;
u64 finalisation;
} WpSiphashCtx;
typedef struct WpHasherCtx {
WpHasherCtxType type;
union {
WpSiphashCtx siphash;
void *user;
u32 murmur3;
};
} WpHasherCtx;
typedef WpU128 (*WpHashFunc)(WpU8Stream *stream, WpHasherCtx ctx);
typedef struct WpHasher {
WpHashFunc func;
void *data;
WpHashFunc func;
WpHasherCtx ctx;
} WpHasher;
WpU128Hash wpHasherGetHash128(const WpHasher *hasher, WpU8Stream *stream);
u64 wpHasherGetHash64 (const WpHasher *hasher, WpU8Stream *stream);
WpHasher wpCustomHasher(WpHashFunc func, void *ctx);
WpU128 wpHasherGetHash128(const WpHasher *hasher, WpU8Stream *stream);
u64 wpHasherGetHash64(const WpHasher *hasher, WpU8Stream *stream);
#ifdef WP_PLATFORM_CPP
END_C_LINKAGE