This commit is contained in:
@@ -13,9 +13,9 @@ struct SplitMix64State {
|
||||
u64 seed;
|
||||
};
|
||||
|
||||
wp_intern u64 split_mix_64(SplitMix64State *state);
|
||||
wp_intern void seed_os_generator(u64 seed);
|
||||
wp_intern u64 generate_random_number(void);
|
||||
wp_intern u64 splitMix64(SplitMix64State *state);
|
||||
wp_intern void seedOsGenerator(u64 seed);
|
||||
wp_intern u64 genRandomNumber(void);
|
||||
|
||||
WpXor256State wpPrngXorshiftInit(void) {
|
||||
return wpPrngXorshiftInitWithSeed(0);
|
||||
@@ -25,16 +25,16 @@ WpXor256State wpPrngXorshiftInitWithSeed(u64 seed) {
|
||||
wp_persist b8 seeded = false;
|
||||
if (!seeded) {
|
||||
seeded = true;
|
||||
seed_os_generator(seed);
|
||||
seedOsGenerator(seed);
|
||||
}
|
||||
|
||||
SplitMix64State sm64 = {.seed = generate_random_number()};
|
||||
SplitMix64State sm64 = {.seed = genRandomNumber()};
|
||||
|
||||
return (WpXor256State){
|
||||
.x = split_mix_64(&sm64),
|
||||
.y = split_mix_64(&sm64),
|
||||
.z = split_mix_64(&sm64),
|
||||
.w = split_mix_64(&sm64),
|
||||
.x = splitMix64(&sm64),
|
||||
.y = splitMix64(&sm64),
|
||||
.z = splitMix64(&sm64),
|
||||
.w = splitMix64(&sm64),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ u64 wpPrngXorshift256pChoice(WpXor256State *state, u64 available_choices) {
|
||||
return wpPrngXorshift256p(state) % available_choices;
|
||||
}
|
||||
|
||||
wp_intern u64 split_mix_64(SplitMix64State *state) {
|
||||
wp_intern u64 splitMix64(SplitMix64State *state) {
|
||||
state->seed += 0x9E3779B97f4A7C15;
|
||||
|
||||
u64 result = state->seed;
|
||||
@@ -115,7 +115,7 @@ wp_intern u64 split_mix_64(SplitMix64State *state) {
|
||||
|
||||
#if defined(WP_PLATFORM_C) && WP_PLATFORM_C_VERSION >= WP_PLATFORM_C11_VERSION
|
||||
#ifdef WP_PLATFORM_POSIX
|
||||
wp_intern void seed_os_generator(u64 seed) {
|
||||
wp_intern void seedOsGenerator(u64 seed) {
|
||||
if (seed == 0) {
|
||||
struct timespec ts = {0};
|
||||
int result = clock_gettime(CLOCK_MONOTONIC_RAW, &ts);
|
||||
@@ -126,11 +126,11 @@ wp_intern void seed_os_generator(u64 seed) {
|
||||
srand48(seed);
|
||||
}
|
||||
|
||||
wp_intern u64 generate_random_number(void) {
|
||||
wp_intern u64 genRandomNumber(void) {
|
||||
return lrand48();
|
||||
}
|
||||
#else
|
||||
wp_intern void seed_os_generator(u64 seed) {
|
||||
wp_intern void seedOsGenerator(u64 seed) {
|
||||
if (seed == 0) {
|
||||
struct timespec ts = {0};
|
||||
int result = timespec_get(&ts, TIME_UTC);
|
||||
@@ -141,7 +141,7 @@ wp_intern void seed_os_generator(u64 seed) {
|
||||
srand(seed);
|
||||
}
|
||||
|
||||
wp_intern u64 generate_random_number(void) {
|
||||
wp_intern u64 genRandomNumber(void) {
|
||||
i32 n1 = rand();
|
||||
i32 n2 = rand();
|
||||
|
||||
@@ -149,7 +149,7 @@ wp_intern u64 generate_random_number(void) {
|
||||
}
|
||||
#endif // !WP_PLATFORM_POSIX
|
||||
#else
|
||||
wp_intern void seed_os_generator(u64 seed) {
|
||||
wp_intern void seedOsGenerator(u64 seed) {
|
||||
if (seed == 0) {
|
||||
time_t result = time(NULL);
|
||||
wpRuntimeAssert(result != (time_t)(-1), "Invalid seed value");
|
||||
@@ -159,7 +159,7 @@ wp_intern void seed_os_generator(u64 seed) {
|
||||
srand(seed);
|
||||
}
|
||||
|
||||
wp_intern u64 generate_random_number(void) {
|
||||
wp_intern u64 genRandomNumber(void) {
|
||||
i32 n1 = rand();
|
||||
i32 n2 = rand();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user