Rename PRNG

This commit is contained in:
2026-06-26 15:49:10 +01:00
parent e4c1068281
commit cdca775681
3 changed files with 15 additions and 15 deletions
+5 -5
View File
@@ -17,7 +17,7 @@ wp_intern u64 split_mix_64(SplitMix64State *state);
wp_intern void seed_os_generator(void);
wp_intern u64 generate_random_number(void);
XOR256State wapp_prng_xorshift_init_state(void) {
WpXor256State wpPrngXorshiftInit(void) {
wp_persist b8 seeded = false;
if (!seeded) {
seeded = true;
@@ -26,7 +26,7 @@ XOR256State wapp_prng_xorshift_init_state(void) {
SplitMix64State sm64 = {.seed = generate_random_number()};
return (XOR256State){
return (WpXor256State){
.x = split_mix_64(&sm64),
.y = split_mix_64(&sm64),
.z = split_mix_64(&sm64),
@@ -34,7 +34,7 @@ XOR256State wapp_prng_xorshift_init_state(void) {
};
}
u64 wapp_prng_xorshift_256(XOR256State *state) {
u64 wpPrngXorshift256(WpXor256State *state) {
u64 t = state->x ^ (state->x << 11);
state->x = state->y;
@@ -45,7 +45,7 @@ u64 wapp_prng_xorshift_256(XOR256State *state) {
return state->w;
}
u64 wapp_prng_xorshift_256ss(XOR256State *state) {
u64 wpPrngXorshift256ss(WpXor256State *state) {
const u64 result = rol64(state->z * 5, 7) * 9;
const u64 t = state->z << 17;
@@ -60,7 +60,7 @@ u64 wapp_prng_xorshift_256ss(XOR256State *state) {
return result;
}
u64 wapp_prng_xorshift_256p(XOR256State *state) {
u64 wpPrngXorshift256p(WpXor256State *state) {
const u64 result = state->w + state->x;
const u64 t = state->z << 17;
+6 -6
View File
@@ -10,18 +10,18 @@
BEGIN_C_LINKAGE
#endif // !WP_PLATFORM_CPP
typedef struct XOR256State XOR256State;
struct XOR256State {
typedef struct WpXor256State WpXor256State;
struct WpXor256State {
u64 x;
u64 y;
u64 z;
u64 w;
};
XOR256State wapp_prng_xorshift_init_state(void);
u64 wapp_prng_xorshift_256(XOR256State *state);
u64 wapp_prng_xorshift_256ss(XOR256State *state);
u64 wapp_prng_xorshift_256p(XOR256State *state);
WpXor256State wpPrngXorshiftInit(void);
u64 wpPrngXorshift256(WpXor256State *state);
u64 wpPrngXorshift256ss(WpXor256State *state);
u64 wpPrngXorshift256p(WpXor256State *state);
#ifdef WP_PLATFORM_CPP
END_C_LINKAGE
+4 -4
View File
@@ -28,17 +28,17 @@ WpUuid *wpUuidInitUuid4(WpUuid *uuid) {
}
wp_intern UUID4 generate_uuid4(void) {
wp_persist XOR256State state = {0};
wp_persist WpXor256State state = {0};
wp_persist b8 initialised = false;
if (!initialised) {
initialised = true;
state = wapp_prng_xorshift_init_state();
state = wpPrngXorshiftInit();
}
UUID4 uuid = (UUID4){
.high = wapp_prng_xorshift_256(&state),
.low = wapp_prng_xorshift_256(&state),
.high = wpPrngXorshift256(&state),
.low = wpPrngXorshift256(&state),
};
uuid.high = (uuid.high & 0xffffffffffff0fff) | 0x0000000000004000;