This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user