summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/FuzzerInterface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerInterface.cpp')
-rw-r--r--llvm/lib/Fuzzer/FuzzerInterface.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerInterface.cpp b/llvm/lib/Fuzzer/FuzzerInterface.cpp
index 76623ecf7d4..149ec66e5d5 100644
--- a/llvm/lib/Fuzzer/FuzzerInterface.cpp
+++ b/llvm/lib/Fuzzer/FuzzerInterface.cpp
@@ -12,6 +12,7 @@
#include "FuzzerInterface.h"
#include "FuzzerInternal.h"
+#include <random>
namespace fuzzer {
@@ -19,6 +20,19 @@ void FuzzerRandomLibc::ResetSeed(unsigned int seed) { srand(seed); }
size_t FuzzerRandomLibc::Rand() { return rand(); }
+struct FuzzerRandom_mt19937::Impl : public std::mt19937 {
+ Impl(unsigned seed) : std::mt19937(seed) {}
+};
+
+void FuzzerRandom_mt19937::ResetSeed(unsigned int seed) {
+ delete R;
+ R = new Impl(seed);
+}
+
+FuzzerRandom_mt19937::~FuzzerRandom_mt19937() { delete R; }
+
+size_t FuzzerRandom_mt19937::Rand() { return (*R)(); }
+
UserSuppliedFuzzer::UserSuppliedFuzzer(FuzzerRandomBase *Rand)
: Rand(Rand), MD(new MutationDispatcher(*Rand)) {}
OpenPOWER on IntegriCloud