about summary refs log tree commit diff
path: root/misc/subr.c
diff options
context:
space:
mode:
Diffstat (limited to 'misc/subr.c')
-rw-r--r--misc/subr.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/misc/subr.c b/misc/subr.c
index f894812..77e3a06 100644
--- a/misc/subr.c
+++ b/misc/subr.c
@@ -5,6 +5,7 @@
 #include <fcntl.h>
 #include <inttypes.h>
 #include <limits.h>
+#include <math.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -139,3 +140,9 @@ round_to_page(size_t size)
         size += psize - rem;
     return size;
 }
+
+long
+rand_between(long min, long max)
+{
+    return min + (long)rint((double)random() * (max - min) / RAND_MAX);
+}