New functions xvasprintf() and strlcpy() and macro va_copy().
[sliver-openvswitch.git] / lib / random.c
index 55507e0..f4fab4c 100644 (file)
@@ -31,6 +31,7 @@
  * derivatives without specific, written prior permission.
  */
 
+#include <config.h>
 #include "random.h"
 
 #include <errno.h>
@@ -47,7 +48,7 @@ random_init(void)
         struct timeval tv;
         inited = true;
         if (gettimeofday(&tv, NULL) < 0) {
-            fatal(errno, "gettimeofday");
+            ofp_fatal(errno, "gettimeofday");
         }
         srand(tv.tv_sec ^ tv.tv_usec);
     }
@@ -70,3 +71,9 @@ random_uint32(void)
     random_bytes(&x, sizeof x);
     return x;
 }
+
+int
+random_range(int max) 
+{
+    return random_uint32() % max;
+}