This commit is contained in:
@@ -41,7 +41,7 @@ typedef uptr *WpUptrArray;
|
||||
typedef iptr *WpIptrArray;
|
||||
typedef WpStr8 *WpStr8Array;
|
||||
|
||||
typedef enum {
|
||||
typedef enum WpArrayInitFlags {
|
||||
WP_ARRAY_INIT_NONE = 0,
|
||||
WP_ARRAY_INIT_FILLED = 1 << 1,
|
||||
} WpArrayInitFlags;
|
||||
|
||||
@@ -16,7 +16,7 @@ BEGIN_C_LINKAGE
|
||||
|
||||
typedef struct WpDblNode WpDblNode;
|
||||
|
||||
typedef struct {
|
||||
typedef struct WpDblNodeHeader {
|
||||
u64 magic;
|
||||
u64 item_size;
|
||||
WpDblNode *prev;
|
||||
@@ -28,7 +28,7 @@ struct WpDblNode {
|
||||
void *item;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
typedef struct WpDblList {
|
||||
u64 magic;
|
||||
u64 node_count;
|
||||
u64 item_size;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
// vim:fileencoding=utf-8:foldmethod=marker
|
||||
|
||||
#include "hasher.h"
|
||||
#include "../../../common/assert/assert.h"
|
||||
|
||||
WpU128Hash wpHasherGetHash128(const WpHasher *hasher, WpU8Stream *stream, void *hasher_data) {
|
||||
wpDebugAssert(hasher != NULL && stream != NULL, "hasher and stream shouldn't be NULL");
|
||||
|
||||
WpU128Hash output;
|
||||
switch (hasher->type) {
|
||||
case WP_HASH_TYPE_64: {
|
||||
output.hash[0] = hasher->hasher_64(stream, hasher_data);
|
||||
output.hash[1] = hasher->hasher_64(stream, hasher_data);
|
||||
} break;
|
||||
case WP_HASH_TYPE_128: {
|
||||
output = hasher->hasher_128(stream, hasher_data);
|
||||
} break;
|
||||
default: {
|
||||
wpRuntimeAssert(0, "Invalid hasher type");
|
||||
} break;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
u64 wpHasherGetHash64(const WpHasher *hasher, WpU8Stream *stream, void *hasher_data) {
|
||||
wpDebugAssert(hasher != NULL && stream != NULL, "hasher and stream shouldn't be NULL");
|
||||
|
||||
u64 output;
|
||||
switch (hasher->type) {
|
||||
case WP_HASH_TYPE_64: {
|
||||
output = hasher->hasher_64(stream, hasher_data);
|
||||
} break;
|
||||
case WP_HASH_TYPE_128: {
|
||||
WpU128Hash hash = hasher->hasher_128(stream, hasher_data);
|
||||
output = hash.hash[0] ^ hash.hash[1];
|
||||
} break;
|
||||
default: {
|
||||
wpRuntimeAssert(0, "Invalid hasher type");
|
||||
} break;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -9,11 +9,11 @@
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
typedef struct {
|
||||
typedef struct WpU128Hash {
|
||||
u64 hash[2];
|
||||
} WpU128Hash;
|
||||
|
||||
typedef enum {
|
||||
typedef enum WpHasherType {
|
||||
WP_HASH_TYPE_64,
|
||||
WP_HASH_TYPE_128,
|
||||
|
||||
@@ -23,7 +23,7 @@ typedef enum {
|
||||
typedef u64 (*WpHasher64) (WpU8Stream *stream, void *hasher_data);
|
||||
typedef WpU128Hash (*WpHasher128)(WpU8Stream *stream, void *hasher_data);
|
||||
|
||||
typedef struct {
|
||||
typedef struct WpHasher {
|
||||
WpHasherType type;
|
||||
union {
|
||||
WpHasher64 hasher_64;
|
||||
@@ -39,6 +39,9 @@ typedef struct {
|
||||
#define wpHasher128(HASHER) ((WpHasher){ .type = WP_HASH_TYPE_128, .hasher_128 = (HASHER) })
|
||||
#endif
|
||||
|
||||
WpU128Hash wpHasherGetHash128(const WpHasher *hasher, WpU8Stream *stream, void *hasher_data);
|
||||
u64 wpHasherGetHash64 (const WpHasher *hasher, WpU8Stream *stream, void *hasher_data);
|
||||
|
||||
#ifdef WP_PLATFORM_CPP
|
||||
END_C_LINKAGE
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
@@ -19,7 +19,7 @@ BEGIN_C_LINKAGE
|
||||
|
||||
#define WP_MUR3_HASHER_MAGIC wpU64Const(0x57504d4841534833)
|
||||
|
||||
typedef struct {
|
||||
typedef struct WpMur3HasherData {
|
||||
u64 magic;
|
||||
u32 seed;
|
||||
} WpMur3HasherData;
|
||||
|
||||
@@ -19,12 +19,12 @@ BEGIN_C_LINKAGE
|
||||
|
||||
#define WP_SIP_HASHER_MAGIC wpU64Const(0x5750534950485348)
|
||||
|
||||
typedef struct {
|
||||
typedef struct WpSipHasherKey {
|
||||
u64 lo;
|
||||
u64 hi;
|
||||
} WpSipHasherKey;
|
||||
|
||||
typedef struct {
|
||||
typedef struct WpSipHasherData {
|
||||
WpSipHasherKey key;
|
||||
u64 magic;
|
||||
u64 compression;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
typedef enum {
|
||||
typedef enum WpMemOp {
|
||||
WP_MEM_OP_ALLOC,
|
||||
WP_MEM_OP_ALLOC_ALIGNED,
|
||||
WP_MEM_OP_REALLOC,
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
typedef struct {
|
||||
typedef struct WpQueue {
|
||||
WpArray items;
|
||||
u64 front;
|
||||
u64 back;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
BEGIN_C_LINKAGE
|
||||
#endif // !WP_PLATFORM_CPP
|
||||
|
||||
typedef struct {
|
||||
typedef struct WpStream {
|
||||
void *data;
|
||||
u64 count;
|
||||
u64 position;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "wapp_base.h"
|
||||
#include "array/array.c"
|
||||
#include "dbl_list/dbl_list.c"
|
||||
#include "hash/hasher/hasher.c"
|
||||
#include "hash/hasher/murmur3.c"
|
||||
#include "hash/hasher/siphash.c"
|
||||
#include "queue/queue.c"
|
||||
|
||||
Reference in New Issue
Block a user