fix: dont shadow stdlib rand
This commit is contained in:
+3
-3
@@ -4,7 +4,7 @@ static unsigned long long mcg_state = 0xcafef00dd15ea5e5u; // Must be odd
|
||||
static unsigned long long const multiplier = 6364136223846793005u;
|
||||
|
||||
// https://en.wikipedia.org/wiki/Permuted_congruential_generator
|
||||
static unsigned long rand(void) {
|
||||
static unsigned long fast_rand(void) {
|
||||
unsigned long long x = mcg_state;
|
||||
unsigned count = (unsigned)(x >> 61);
|
||||
|
||||
@@ -15,9 +15,9 @@ static unsigned long rand(void) {
|
||||
|
||||
void rand_set_seed(unsigned long long seed) {
|
||||
mcg_state = 2 * seed + 1;
|
||||
(void)rand();
|
||||
(void)fast_rand();
|
||||
}
|
||||
|
||||
unsigned int rand_uint(const unsigned int max) {
|
||||
return max == 0 ? 0 : (unsigned int)(rand() % max);
|
||||
return max == 0 ? 0 : (unsigned int)(fast_rand() % max);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user