]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/librbd/fsx: musl libc doesn't implement random_r. Use c++11 std::mt19937 generat... 6332/head
authorJohn Coyle <dx9err@gmail.com>
Tue, 8 Dec 2015 21:40:23 +0000 (16:40 -0500)
committerJohn Coyle <dx9err@gmail.com>
Wed, 9 Dec 2015 00:50:42 +0000 (19:50 -0500)
Signed-off-by: John Coyle <dx9err@gmail.com>
src/test/librbd/fsx.cc

index 275f0034fcecc5494b2bd0271dd28fa857a358dc..6f72f307e4cf5028cc1ca21af880209c07c96097 100644 (file)
@@ -38,6 +38,7 @@
 #include <errno.h>
 #include <math.h>
 #include <fcntl.h>
+#include <random>
 
 #include "include/intarith.h"
 #include "include/krbd.h"
@@ -231,22 +232,12 @@ simple_err(const char *msg, int err)
 /*
  * random
  */
+std::mt19937 random_generator;
 
-#define RND_STATE_LEN  256
-char   rnd_state[RND_STATE_LEN];
-struct random_data rnd_data;
-
-int32_t
+uint_fast32_t
 get_random(void)
 {
-       int32_t val;
-
-       if (random_r(&rnd_data, &val) < 0) {
-               prterr("random_r");
-               exit(1);
-       }
-
-       return val;
+       return random_generator();
 }
 
 /*
@@ -2206,14 +2197,7 @@ main(int argc, char **argv)
        signal(SIGUSR1, cleanup);
        signal(SIGUSR2, cleanup);
 
-       if (initstate_r(seed, rnd_state, RND_STATE_LEN, &rnd_data) < 0) {
-               prterr("initstate_r");
-               exit(1);
-       }
-       if (setstate_r(rnd_state, &rnd_data) < 0) {
-               prterr("setstate_r");
-               exit(1);
-       }
+       random_generator.seed(seed);
 
        ret = create_image();
        if (ret < 0) {