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.
This commit is contained in:
parent
cc375bba4e
commit
685bf97467
|
@ -16,6 +16,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <random>
|
||||
#include <climits>
|
||||
extern "C" {
|
||||
|
@ -24,7 +25,6 @@ extern "C" {
|
|||
|
||||
static std::mt19937 generator;
|
||||
static std::mt19937 map_generator;
|
||||
static std::uniform_int_distribution<int> 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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue