summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/FuzzerInterface.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerInterface.h')
-rw-r--r--llvm/lib/Fuzzer/FuzzerInterface.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerInterface.h b/llvm/lib/Fuzzer/FuzzerInterface.h
index b64dff8fe43..64b8f868f65 100644
--- a/llvm/lib/Fuzzer/FuzzerInterface.h
+++ b/llvm/lib/Fuzzer/FuzzerInterface.h
@@ -68,14 +68,27 @@ class FuzzerRandomBase {
bool RandBool() { return Rand() % 2; }
};
+// Using libc's stand/rand.
class FuzzerRandomLibc : public FuzzerRandomBase {
public:
FuzzerRandomLibc(unsigned int seed) { ResetSeed(seed); }
void ResetSeed(unsigned int seed) override;
- ~FuzzerRandomLibc() override {}
+ ~FuzzerRandomLibc() override {};
size_t Rand() override;
};
+// Using std::mt19937
+class FuzzerRandom_mt19937 : public FuzzerRandomBase {
+ public:
+ FuzzerRandom_mt19937(unsigned int seed) { ResetSeed(seed); }
+ void ResetSeed(unsigned int seed) override;
+ ~FuzzerRandom_mt19937() override;
+ size_t Rand() override;
+ private:
+ struct Impl;
+ Impl *R = nullptr;
+};
+
// For backward compatibility only, deprecated.
size_t Mutate(uint8_t *Data, size_t Size, size_t MaxSize,
FuzzerRandomBase &Rand);
OpenPOWER on IntegriCloud