56 lines
1.1 KiB
C
56 lines
1.1 KiB
C
// vim:fileencoding=utf-8:foldmethod=marker
|
|
|
|
#ifndef HASHER_H
|
|
#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 WpU128 {
|
|
u64 value[2];
|
|
} WpU128;
|
|
|
|
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;
|
|
WpHasherCtx ctx;
|
|
} WpHasher;
|
|
|
|
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
|
|
#endif // !WP_PLATFORM_CPP
|
|
|
|
#endif // !HASHER_H
|