22 #ifdef HAVE_GETTIMEOFDAY 28 #include <sys/types.h> 36 static const uint32 a0 = 0xE66D;
37 static const uint32 a1 = 0xDEEC;
38 static const uint32 a2 = 0x5;
40 static const uint32 b0 = 0xB;
44 #define LO(x) ((x) & 0xFFFFU) 45 #define HI(x) ((x) >> 16) 74 char *grass_random_seed =
getenv(
"GRASS_RANDOM_SEED");
75 if(!grass_random_seed) grass_random_seed =
getenv(
"SOURCE_DATE_EPOCH");
76 if(grass_random_seed) {
77 seed = strtoull(grass_random_seed,
NULL, 10);
79 seed = (
unsigned long) getpid();
81 #ifdef HAVE_GETTIMEOFDAY 84 if (gettimeofday(&tv,
NULL) < 0)
86 seed += (
unsigned long) tv.tv_sec;
87 seed += (
unsigned long) tv.tv_usec;
91 time_t
t = time(
NULL);
92 seed += (
unsigned long) t;
101 static void G__next(
void)
149 return (
long) (
int32) r;
167 r /= 281474976710656.0;
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_srand48(long seedval)
Seed the pseudo-random number generator.
long G_mrand48(void)
Generate an integer in the range [-2^31, 2^31)
long G_lrand48(void)
Generate an integer in the range [0, 2^31)
long G_srand48_auto(void)
Seed the pseudo-random number generator from the time and PID.
double G_drand48(void)
Generate a floating-point value in the range [0,1)