have_seed = 1;
}
-double cdrand_d(void) {
+double cdrand_d() {
double r;
pthread_mutex_lock(&lock);
return (r);
}
+uint32_t cdrand_u() {
+ long r;
+
+ pthread_mutex_lock(&lock);
+ cdrand_seed();
+ r = jrand48(seed);
+ pthread_mutex_unlock(&lock);
+
+ return (uint32_t)r;
+}
+
long cdrand_range(long min, long max) {
long range;
long r;
*
* This function is thread- and reentrant-safe.
*/
-double cdrand_d(void);
+double cdrand_d();
+
+/**
+ * cdrand_u returns a random uint32_t value uniformly distributed in the range
+ * [0-2^32).
+ *
+ * This function is thread- and reentrant-safe.
+ */
+uint32_t cdrand_u();
/**
* Returns a random long between min and max, inclusively.