From 685bf97467ceb612061926d442534ce552b78d3e Mon Sep 17 00:00:00 2001 From: Linus Probert Date: Fri, 22 Feb 2019 00:27:19 +0100 Subject: [PATCH] Makes the custom random generator deterministic across platforms TIL that the generators are implemented according to spec but the distributions are custom. Since this is C I think we can manage without distributions. This still needs a test. --- bh_random/src/bh_random.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bh_random/src/bh_random.cpp b/bh_random/src/bh_random.cpp index 4934584..af8c602 100644 --- a/bh_random/src/bh_random.cpp +++ b/bh_random/src/bh_random.cpp @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#include #include #include extern "C" { @@ -24,7 +25,6 @@ extern "C" { static std::mt19937 generator; static std::mt19937 map_generator; -static std::uniform_int_distribution distribution(0, INT_MAX); extern "C" void bh_srand(unsigned int seed) @@ -36,7 +36,7 @@ bh_srand(unsigned int seed) extern "C" unsigned int bh_rand(void) { - return distribution(generator); + return generator(); } extern "C" void @@ -49,5 +49,5 @@ bh_map_srand(unsigned int seed) extern "C" unsigned int bh_map_rand(void) { - return distribution(map_generator); + return map_generator(); }