Compare commits

...
7 Commits
Author SHA1 Message Date
abdelrahman fc4f3f49d2 Updated WpUuid API
Release / release (push) Successful in 12s
2026-11-16 21:32:20 +00:00
abdelrahman 45e58a23f6 Rename debug macro
Release / release (push) Successful in 12s
2026-11-11 01:48:12 +00:00
abdelrahman 5687cb512c Fix MSVC build issues
Release / release (push) Successful in 16s
2026-10-29 02:15:17 +00:00
abdelrahman 188cfae0d7 Update README
Release / release (push) Successful in 1s
2026-10-29 00:14:49 +00:00
abdelrahman 741566fafd Add containers for b32
Release / release (push) Successful in 4s
2026-10-24 01:06:48 +01:00
abdelrahman 9bec020f04 Add b32 alias
Release / release (push) Successful in 4s
2026-10-11 21:33:50 +01:00
abdelrahman fe5f13d8ce Make wpLogMakeLogger compile time constant
Release / release (push) Successful in 4s
2026-10-05 01:28:21 +01:00
32 changed files with 201 additions and 93 deletions

No files matched your search

+36
View File
@@ -7,6 +7,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [3.5.0] - 2026-11-16
### Changed
- `WpUuid` API
## [3.4.0] - 2026-11-11
### Changed
- `WP_DEBUG_ASSERT` macro to `WP_DEBUG_BUILD`
## [3.3.1] - 2026-10-29
### Fixed
- MSVC build issues
## [3.3.0] - 2026-10-24
### Added
- Containers for `b32`
## [3.2.0] - 2026-10-11
### Added
- `b32` alias for a 4-byte boolean
## [3.1.0] - 2026-10-05
### Changed
- `wpLogMakeLogger` to be compile time constant
## [3.0.0] - 2026-09-30
### Added
+2 -2
View File
@@ -34,9 +34,9 @@ override HEADER_INSTALL_CMD := scripts/header_install.sh
ifeq ($(origin BUILD_FLAGS), undefined)
ifeq ($(BUILD_TYPE),Debug)
BUILD_FLAGS += -g -fsanitize=address,undefined -DWP_DEBUG_ASSERT
BUILD_FLAGS += -g -fsanitize=address,undefined -DWP_DEBUG_BUILD
else ifeq ($(BUILD_TYPE),RelWithDebInfo)
BUILD_FLAGS += -g -O2 -fsanitize=address,undefined -DWP_DEBUG_ASSERT
BUILD_FLAGS += -g -O2 -fsanitize=address,undefined -DWP_DEBUG_BUILD
else ifeq ($(BUILD_TYPE),Release)
BUILD_FLAGS += -O3
else
+14
View File
@@ -3,3 +3,17 @@
**Wizard Apprentice Standard Library** (`wapp`) is a lightweight collection of reusable utilities for **C and C++** projects.
For more information about the library and how to use it, check the [wiki](https://git.thewizardapprentice.com/abdelrahman/wizapp-stdlib/wiki).
## Building
Linux/macOS
```console
./build
```
Windows
```console
./build.ps1
```
+1 -1
View File
@@ -1 +1 @@
3.0.0
3.5.0
+3 -1
View File
@@ -205,7 +205,9 @@ void arrayRemoveSwapEnd(WpArray array, u64 index, u64 item_size) {
u64 last_item_index = header->count - 1;
if (index < last_item_index) {
// NOTE (Abdelrahman): Extract into a variable to get rid of MSVC Spectre mitigation warnings
b8 is_last_item = index == last_item_index;
if (!is_last_item) {
void *cur_item = arrayGetItemWithOffset(array, header->item_size * index);
void *last_item = arrayGetItemWithOffset(array, header->item_size * last_item_index);
+1
View File
@@ -30,6 +30,7 @@ typedef u16 *WpU16Array;
typedef u32 *WpU32Array;
typedef u64 *WpU64Array;
typedef b8 *WpB8Array;
typedef b32 *WpB32Array;
typedef i8 *WpI8Array;
typedef i16 *WpI16Array;
typedef i32 *WpI32Array;
+2
View File
@@ -46,6 +46,7 @@ typedef WpDblList WpU16List;
typedef WpDblList WpU32List;
typedef WpDblList WpU64List;
typedef WpDblList WpB8List;
typedef WpDblList WpB32List;
typedef WpDblList WpI8List;
typedef WpDblList WpI16List;
typedef WpDblList WpI32List;
@@ -67,6 +68,7 @@ typedef WpDblNode WpU16Node;
typedef WpDblNode WpU32Node;
typedef WpDblNode WpU64Node;
typedef WpDblNode WpB8Node;
typedef WpDblNode WpB32Node;
typedef WpDblNode WpI8Node;
typedef WpDblNode WpI16Node;
typedef WpDblNode WpI32Node;
+2
View File
@@ -5,6 +5,7 @@
#include "../../stream/stream.h"
#include "../../../common/aliases/aliases.h"
#include "../../../common/misc/misc_utils.h"
#ifdef WP_PLATFORM_CPP
BEGIN_C_LINKAGE
@@ -30,6 +31,7 @@ typedef struct WpSiphashCtx {
typedef struct WpHasherCtx {
WpHasherCtxType type;
u8 padding[4];
union {
WpSiphashCtx siphash;
void *user;
+1 -1
View File
@@ -29,7 +29,7 @@ WpHasher wpX64Mur3HasherWithSeed(u32 seed) {
WpU128 wpX64Mur3GetHash128(WpU8Stream *bytes, WpHasherCtx ctx) {
validateMur3HasherCtx(&ctx);
const i32 nblocks = (bytes->count * bytes->item_size) / 16;
const i32 nblocks = (const i32)((bytes->count * bytes->item_size) / 16);
u64 h1 = ctx.murmur3;
u64 h2 = ctx.murmur3;
+30 -6
View File
@@ -119,12 +119,20 @@ void hashTableGrow(const WpAllocator *allocator, WpHashTable *table, u64 key_siz
table->buckets = buckets;
table->bucket_mask = mask;
for (u64 i = 0; i < wpArrayCount(old_keys); ++i) {
void *key = arrayGet(old_keys, i, key_size);
void *value = table->has_values ? arrayGet(old_values, i, value_size) : NULL;
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
// MSVC Spectre mitigation warnings
u64 count = wpArrayCount(old_keys);
u64 index = 0;
b8 running = true;
while (running) {
void *key = arrayGet(old_keys, index, key_size);
void *value = table->has_values ? arrayGet(old_values, index, value_size) : NULL;
u64 hash = hashTableCalcHash(table, key, key_size);
WpHashBucketRef ref = hashTableBucketRef(table, hash);
hashTableInsert(table, key, value, ref, key_size, value_size);
++index;
running = index < count;
}
}
@@ -132,7 +140,9 @@ WpHashLookupResult hashTableLookup(WpHashTable *table, void *key, WpHashBucketRe
hashTableValidate(table, key_size, 0);
wpDebugAssert(key != NULL, "`key` should not be NULL");
while (true) {
u64 initial_bucket_index = ref.bucket_index;
b8 running = true;
while (running) {
WpHashBucket *bucket = &table->buckets[ref.bucket_index];
if (ref.dist_and_tag == bucket->dist_and_tag) {
@@ -152,7 +162,16 @@ WpHashLookupResult hashTableLookup(WpHashTable *table, void *key, WpHashBucketRe
ref.dist_and_tag = hashTableDistInc(ref.dist_and_tag);
ref.bucket_index = hashTableNextBucket(table, ref.bucket_index);
// Break if we loop back to the start bucket index
running = ref.bucket_index != initial_bucket_index;
}
return (WpHashLookupResult){
.ref.dist_and_tag = ref.dist_and_tag,
.ref.bucket_index = ref.bucket_index,
.found = false,
};
}
void hashTableUpdate(WpHashTable *table, void *value, WpHashBucketRef ref, u64 value_size) {
@@ -172,7 +191,10 @@ void hashTableInsert(WpHashTable *table, void *key, void *value, WpHashBucketRef
wpDebugAssert(key != NULL, "`key` should not be NULL");
u64 index = wpArrayCount(table->keys);
while (true) {
// NOTE (Abdelrahman): Extract into a variable to satisfy MSVC
b8 running = true;
while (running) {
WpHashBucket *bucket = &table->buckets[ref.bucket_index];
if (bucket->dist_and_tag == 0) {
@@ -202,7 +224,9 @@ void hashTableRemove(WpHashTable *table, WpHashBucketRef ref, u64 key_size, u64
u64 last_item_index = wpArrayCount(table->keys) - 1;
if (bucket->item_index < last_item_index) {
// NOTE (Abdelrahman): Extract into a variable to get rid of MSVC Spectre mitigation warnings
b8 is_last_item = bucket->item_index == last_item_index;
if (!is_last_item) {
// Update the bucket for the last item before swapping
u64 hash = hashTableCalcHash(table, arrayGet(table->keys, last_item_index, key_size), key_size);
+5 -2
View File
@@ -25,6 +25,7 @@
#include "../../stream/stream.h"
#include "../../../common/aliases/aliases.h"
#include "../../../common/platform/platform.h"
#include "../../../common/misc/misc_utils.h"
#ifdef WP_PLATFORM_CPP
BEGIN_C_LINKAGE
@@ -56,7 +57,7 @@ typedef struct WpHashTable {
u64 magic;
u64 bucket_mask;
f32 load_factor;
b8 has_values;
b32 has_values;
} WpHashTable;
typedef struct WpHashBucketRef {
@@ -66,7 +67,9 @@ typedef struct WpHashBucketRef {
typedef struct WpHashLookupResult {
WpHashBucketRef ref;
b8 found;
b32 found;
wpMiscUtilsReservePadding(sizeof(WpHashBucketRef) + sizeof(b32));
} WpHashLookupResult;
void hashTableAlloc(const WpAllocator *allocator, WpHashTable *table,
+1
View File
@@ -94,6 +94,7 @@ b8 wpMemAllocatorOpSupported(const WpAllocator *allocator, WpMemOp op) {
return allocator->temp_begin != NULL;
case WP_MEM_OP_TEMP_END:
return allocator->temp_end != NULL;
case COUNT_MEM_OPS:
default:
break;
}
+1
View File
@@ -29,6 +29,7 @@ typedef WpQueue WpU16Queue;
typedef WpQueue WpU32Queue;
typedef WpQueue WpU64Queue;
typedef WpQueue WpB8Queue;
typedef WpQueue WpB32Queue;
typedef WpQueue WpI8Queue;
typedef WpQueue WpI16Queue;
typedef WpQueue WpI32Queue;
+1
View File
@@ -27,6 +27,7 @@ typedef WpStream WpU16Stream;
typedef WpStream WpU32Stream;
typedef WpStream WpU64Stream;
typedef WpStream WpB8Stream;
typedef WpStream WpB32Stream;
typedef WpStream WpI8Stream;
typedef WpStream WpI16Stream;
typedef WpStream WpI32Stream;
+1
View File
@@ -34,6 +34,7 @@ typedef uint64_t u64;
#define wpU64Const UINT64_C
typedef uint8_t b8;
typedef uint32_t b32;
#ifndef WP_PLATFORM_CPP
+1 -1
View File
@@ -21,7 +21,7 @@ BEGIN_C_LINKAGE
#define wpRuntimeAssert(EXPR, MSG)
#endif
#ifdef WP_DEBUG_ASSERT
#ifdef WP_DEBUG_BUILD
#define wpDebugAssert(EXPR, MSG) wpRuntimeAssert(EXPR, MSG)
#else
#define wpDebugAssert(EXPR, MSG)
+20 -10
View File
@@ -3,6 +3,7 @@
#include "log.h"
#include "../base/strings/str8/str8.h"
#include "../common/aliases/aliases.h"
#include "../common/platform/platform.h"
#include "../common/assert/assert.h"
#include "../common/misc/misc_utils.h"
#include "../os/file/file.h"
@@ -11,9 +12,9 @@
#define MIN_LOG_MSG_LENGTH 128
#define TIME_BUF_CAPACITY 70
wp_intern WpStr8RO L_BRACKET = wpStr8LitRo("[");
wp_intern WpStr8RO R_BRACKET_SPACE = wpStr8LitRo("] ");
wp_intern WpStr8RO R_BRACKET_NEWLINE = wpStr8LitRo("]\n");
wp_intern WpStr8RO L_BRACKET = wpStr8LitRoInitialiserList("[");
wp_intern WpStr8RO R_BRACKET_SPACE = wpStr8LitRoInitialiserList("] ");
wp_intern WpStr8RO R_BRACKET_NEWLINE = wpStr8LitRoInitialiserList("]\n");
typedef struct LogConfig {
WpFile *outlog;
@@ -48,10 +49,6 @@ void wpLogConfigure(WpFile *outlog, WpFile *errlog, WpLogLevel level) {
LOG_CONFIG.level = level;
}
WpLogger wpLogMakeLogger(WpStr8 name) {
return (WpLogger){ .name = name };
}
void wpLogDebug(const WpLogger *logger, WpStr8 msg) {
wpDebugAssert(logger != NULL, "`logger` should not be NULL");
if (LOG_CONFIG.level < WP_LOG_LEVEL_DEBUG) { return; }
@@ -105,14 +102,20 @@ wp_intern void getCurrentTimeString(WpStr8 *dst) {
char buf[TIME_BUF_CAPACITY];
time_t now = time(NULL);
struct tm utc;
#ifdef WP_PLATFORM_WINDOWS
gmtime_s(&utc, &now);
#else
gmtime_r(&now, &utc);
#endif
strftime(buf, sizeof(buf), "%FT%TZ ", &utc);
wpStr8CopyCstrCapped(dst, buf);
}
wp_intern void writeLogLine(WpFile *fp, const WpLogger *logger, WpStr8 msg, WpLogLevel level) {
WpStr8 padding = wpStr8Buf(MIN_LOG_MSG_LENGTH);
u32 padding_size = msg.size < MIN_LOG_MSG_LENGTH ? MIN_LOG_MSG_LENGTH - msg.size + 1 : 0;
u32 padding_size = (u32)(msg.size < MIN_LOG_MSG_LENGTH ? MIN_LOG_MSG_LENGTH - msg.size + 1 : 0);
wpStr8Format(&padding, "%-*s", padding_size, " ");
WpStr8 time_str = wpStr8Buf(TIME_BUF_CAPACITY);
@@ -131,7 +134,14 @@ wp_intern void writeLogLine(WpFile *fp, const WpLogger *logger, WpStr8 msg, WpLo
&R_BRACKET_NEWLINE
);
for (u64 i = 0; i < wpArrayCount(strings); ++i) {
wpFileWriteStr8(strings[i], fp);
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
// MSVC Spectre mitigation warnings
u64 count = wpArrayCount(strings);
u64 index = 0;
b8 running = true;
while (running) {
wpFileWriteStr8(strings[index], fp);
++index;
running = index < count;
}
}
+7 -1
View File
@@ -3,6 +3,7 @@
#ifndef LOG_H
#define LOG_H
#include "../common/platform/platform.h"
#include "../os/file/file.h"
#include "../base/strings/str8/str8.h"
@@ -25,9 +26,14 @@ typedef struct WpLogger {
WpStr8 name;
} WpLogger;
#ifdef WP_PLATFORM_CPP
#define wpLogMakeLogger(NAME) (WpLogger{NAME})
#else
#define wpLogMakeLogger(NAME) ((WpLogger){ .name = NAME })
#endif
void wpLogSetLevel(WpLogLevel level);
void wpLogConfigure(WpFile *outlog, WpFile *errlog, WpLogLevel level);
WpLogger wpLogMakeLogger(WpStr8 name);
void wpLogDebug(const WpLogger *logger, WpStr8 msg);
void wpLogInfo(const WpLogger *logger, WpStr8 msg);
void wpLogWarning(const WpLogger *logger, WpStr8 msg);
+1 -1
View File
@@ -41,7 +41,7 @@
// --- Assert ---
#define WAPP_NO_RUNTIME_ASSERT WP_NO_RUNTIME_ASSERT
#define WAPP_DEBUG_ASSERT WP_DEBUG_ASSERT
#define WAPP_DEBUG_ASSERT WP_DEBUG_BUILD
// --- CPath ---
+1 -1
View File
@@ -67,7 +67,7 @@ wp_intern void seedOsGenerator(u64 seed) {
seed = (u64)ts.tv_nsec;
}
srand(seed);
srand((u32)seed);
}
wp_intern u64 genRandomNumber(void) {
+4 -1
View File
@@ -13,7 +13,10 @@ WpXor256State wpPrngXorshiftInit(void) {
WpXor256State wpPrngXorshiftInitWithSeed(u64 seed) {
WpSplitmix64State sm64;
if (seed > 0) {
// NOTE (Abdelrahman): Extract into a variable to get rid of MSVC Spectre mitigation warnings
b8 seed_not_zero = seed > 0;
if (seed_not_zero) {
sm64 = wpPrngSplitmix64InitWithSeed(seed);
} else {
sm64 = wpPrngSplitmix64Init();
+24 -29
View File
@@ -8,36 +8,19 @@
#include <inttypes.h>
#define UUID_STR_FORMAT ("%.8" PRIx64 "-%.4" PRIx64 "-%.4" PRIx64 "-%.4" PRIx64 "-%.12" PRIx64)
#define UUID_HEX_FORMAT ("%.16" PRIx64 "%.16" PRIx64)
typedef struct UUID4 UUID4;
struct UUID4 {
u64 high;
u64 low;
};
wp_intern UUID4 genUuid4(void);
wp_intern void uuid4ToUuid(const UUID4* uuid4, WpUuid *uuid);
WpUuid *wpUuidInitUuid4(WpUuid *uuid) {
wpDebugAssert(uuid != NULL, "`uuid` should not be NULL");
UUID4 uuid4 = genUuid4();
uuid4ToUuid(&uuid4, uuid);
return uuid;
}
wp_intern UUID4 genUuid4(void) {
WpUuid wpUuidGenUuid4(void) {
wp_persist WpXor256State state = {0};
wp_persist b8 initialised = false;
wp_persist b8 initialised = false;
if (!initialised) {
initialised = true;
state = wpPrngXorshiftInit();
}
UUID4 uuid = (UUID4){
.high = wpPrngXorshift256(&state),
WpUuid uuid = {
.high = wpPrngXorshift256(&state),
.low = wpPrngXorshift256(&state),
};
@@ -47,12 +30,24 @@ wp_intern UUID4 genUuid4(void) {
return uuid;
}
wp_intern void uuid4ToUuid(const UUID4* uuid4, WpUuid *uuid) {
u64 group1 = uuid4->high >> 32;
u64 group2 = (uuid4->high << 32) >> 48;
u64 group3 = (uuid4->high << 48) >> 48;
u64 group4 = uuid4->low >> 48;
u64 group5 = (uuid4->low << 16) >> 16;
void wpUuidToStr8(const WpUuid *uuid, WpStr8 *buf) {
wpDebugAssert(uuid != NULL, "`uuid` should not be NULL");
wpRuntimeAssert(buf != NULL && buf->capacity >= WP_UUID_STR_BUF_LENGTH,
"String buffer is NULL or doesn't have sufficient capacity");
wpStr8Format(&(uuid->uuid), UUID_STR_FORMAT, group1, group2, group3, group4, group5);
u64 group1 = uuid->high >> 32;
u64 group2 = (uuid->high << 32) >> 48;
u64 group3 = (uuid->high << 48) >> 48;
u64 group4 = uuid->low >> 48;
u64 group5 = (uuid->low << 16) >> 16;
wpStr8Format(buf, UUID_STR_FORMAT, group1, group2, group3, group4, group5);
}
void wpUuidToHex(const WpUuid *uuid, WpStr8 *buf) {
wpDebugAssert(uuid != NULL, "`uuid` should not be NULL");
wpRuntimeAssert(buf != NULL && buf->capacity >= WP_UUID_HEX_BUF_LENGTH,
"String buffer is NULL or doesn't have sufficient capacity");
wpStr8Format(buf, UUID_HEX_FORMAT, uuid->high, uuid->low);
}
+9 -29
View File
@@ -11,37 +11,17 @@
BEGIN_C_LINKAGE
#endif // !WP_PLATFORM_CPP
#define WP_UUID_BUF_LENGTH 48
#define WP_UUID_SPEC WP_STR8_SPEC
#define wpUuidVarg(WpUuid) wpStr8Varg((WpUuid).uuid)
#define WP_UUID_STR_BUF_LENGTH 36
#define WP_UUID_HEX_BUF_LENGTH 32
typedef struct WpUuid WpUuid;
struct WpUuid {
WpStr8 uuid;
};
typedef struct WpUuid {
u64 high;
u64 low;
} WpUuid;
// TODO (Abdelrahman): Update UUID implementation to work properly with C++ and tests for validation
#ifdef WP_PLATFORM_CPP
#define wpUuidGenUuid4() ([&](){ \
wp_persist WpUuid uuid = wpUuidCreate(); \
return *(wpUuidInitUuid4(&uuid)); \
}())
#else
#define wpUuidGenUuid4() *(wpUuidInitUuid4(&wpUuidCreate()))
#endif
/* Low level UUID API */
#ifdef WP_PLATFORM_CPP
#define wpUuidCreate() ([&](){ return WpUuid{wpStr8Buf(WP_UUID_BUF_LENGTH)}; }())
#else
#define wpUuidCreate() ((WpUuid){.uuid = wpStr8Buf(WP_UUID_BUF_LENGTH)})
#endif
// Just returns the same pointer that was passed in with the UUID initialised.
// Fails when passed a NULL pointer.
WpUuid *wpUuidInitUuid4(WpUuid *uuid);
WpUuid wpUuidGenUuid4(void);
void wpUuidToStr8(const WpUuid *uuid, WpStr8 *buf);
void wpUuidToHex(const WpUuid *uuid, WpStr8 *buf);
#ifdef WP_PLATFORM_CPP
END_C_LINKAGE
+5
View File
@@ -7,8 +7,13 @@
// compile and run any of them on any platform, but your performance with the
// non-native version will be less than optimal.
#include "wapp.h"
#include "MurmurHash3.h"
#ifdef WP_PLATFORM_WINDOWS
#pragma warning(disable:5045)
#endif
//-----------------------------------------------------------------------------
// Platform-specific functions and macros
+5
View File
@@ -7,8 +7,13 @@
// compile and run any of them on any platform, but your performance with the
// non-native version will be less than optimal.
#include "wapp.h"
#include "MurmurHash3.h"
#ifdef WP_PLATFORM_WINDOWS
#pragma warning(disable:5045)
#endif
//-----------------------------------------------------------------------------
// Platform-specific functions and macros
+1 -1
View File
@@ -102,7 +102,7 @@ int siphash(const void *in, const size_t inlen, const void *k, uint8_t *out,
uint64_t m;
int i;
const unsigned char *end = ni + inlen - (inlen % sizeof(uint64_t));
const int left = inlen & 7;
const int left = (const int)(inlen & 7);
uint64_t b = ((uint64_t)inlen) << 56;
v3 ^= k1;
v2 ^= k0;
+3 -3
View File
@@ -22,19 +22,19 @@ WpTestFuncResult test_murmur3(void) {
// Sring hash
WpU128 mur_hash = hasher.func(&str_bytes, hasher.ctx);
MurmurHash3_x64_128(str_bytes.data, str_bytes.count * str_bytes.item_size, hasher.ctx.murmur3, (void *)hash);
MurmurHash3_x64_128(str_bytes.data, (i32)(str_bytes.count * str_bytes.item_size), hasher.ctx.murmur3, (void *)hash);
result = result && mur_hash.value[0] == hash[0] && mur_hash.value[1] == hash[1];
// Array hash
mur_hash = hasher.func(&arr_bytes, hasher.ctx);
MurmurHash3_x64_128(arr_bytes.data, arr_bytes.count * arr_bytes.item_size, hasher.ctx.murmur3, (void *)hash);
MurmurHash3_x64_128(arr_bytes.data, (i32)(arr_bytes.count * arr_bytes.item_size), hasher.ctx.murmur3, (void *)hash);
result = result && mur_hash.value[0] == hash[0] && mur_hash.value[1] == hash[1];
// Number hash
mur_hash = hasher.func(&num_bytes, hasher.ctx);
MurmurHash3_x64_128(num_bytes.data, num_bytes.count * num_bytes.item_size, hasher.ctx.murmur3, (void *)hash);
MurmurHash3_x64_128(num_bytes.data, (i32)(num_bytes.count * num_bytes.item_size), hasher.ctx.murmur3, (void *)hash);
result = result && mur_hash.value[0] == hash[0] && mur_hash.value[1] == hash[1];
+3 -3
View File
@@ -22,19 +22,19 @@ WpTestFuncResult test_murmur3(void) {
// Sring hash
WpU128 mur_hash = hasher.func(&str_bytes, hasher.ctx);
MurmurHash3_x64_128(str_bytes.data, str_bytes.count * str_bytes.item_size, hasher.ctx.murmur3, (void *)hash);
MurmurHash3_x64_128(str_bytes.data, (i32)(str_bytes.count * str_bytes.item_size), hasher.ctx.murmur3, (void *)hash);
result = result && mur_hash.value[0] == hash[0] && mur_hash.value[1] == hash[1];
// Array hash
mur_hash = hasher.func(&arr_bytes, hasher.ctx);
MurmurHash3_x64_128(arr_bytes.data, arr_bytes.count * arr_bytes.item_size, hasher.ctx.murmur3, (void *)hash);
MurmurHash3_x64_128(arr_bytes.data, (i32)(arr_bytes.count * arr_bytes.item_size), hasher.ctx.murmur3, (void *)hash);
result = result && mur_hash.value[0] == hash[0] && mur_hash.value[1] == hash[1];
// Number hash
mur_hash = hasher.func(&num_bytes, hasher.ctx);
MurmurHash3_x64_128(num_bytes.data, num_bytes.count * num_bytes.item_size, hasher.ctx.murmur3, (void *)hash);
MurmurHash3_x64_128(num_bytes.data, (i32)(num_bytes.count * num_bytes.item_size), hasher.ctx.murmur3, (void *)hash);
result = result && mur_hash.value[0] == hash[0] && mur_hash.value[1] == hash[1];
+4
View File
@@ -3,6 +3,10 @@
#include "wapp.h"
#include "test_hashmap.h"
#ifdef WP_PLATFORM_WINDOWS
#pragma warning(disable:5045)
#endif
wp_persist inline WpU8Stream encoder(void *data);
wp_persist inline b8 key_eq(void *a, void *b);
+4
View File
@@ -3,6 +3,10 @@
#include "wapp.h"
#include "test_hashmap.h"
#ifdef WP_PLATFORM_WINDOWS
#pragma warning(disable:5045)
#endif
wp_persist inline WpU8Stream encoder(void *data);
wp_persist inline b8 key_eq(void *a, void *b);
+4
View File
@@ -3,6 +3,10 @@
#include "wapp.h"
#include "test_hashset.h"
#ifdef WP_PLATFORM_WINDOWS
#pragma warning(disable:5045)
#endif
wp_persist inline WpU8Stream encoder(void *data);
wp_persist inline b8 key_eq(void *a, void *b);
+4
View File
@@ -3,6 +3,10 @@
#include "wapp.h"
#include "test_hashset.h"
#ifdef WP_PLATFORM_WINDOWS
#pragma warning(disable:5045)
#endif
wp_persist inline WpU8Stream encoder(void *data);
wp_persist inline b8 key_eq(void *a, void *b);