summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/fuzzer/FuzzerRandom.h
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2019-02-12 00:12:33 +0000
committerKostya Serebryany <kcc@google.com>2019-02-12 00:12:33 +0000
commit63f48717b58d76523fdbfdba6fa1e2c10ae9e3da (patch)
tree4d83c194d8dd5d507aac81d062664802b4df0929 /compiler-rt/lib/fuzzer/FuzzerRandom.h
parent9ebc9dbd3c7d8ce5fb35d3d166279b39808dac0b (diff)
downloadbcm5719-llvm-63f48717b58d76523fdbfdba6fa1e2c10ae9e3da.tar.gz
bcm5719-llvm-63f48717b58d76523fdbfdba6fa1e2c10ae9e3da.zip
[libFuzzer] extend the -fork=1 functionality. Still not fully usable, but good enough for the first unit test
llvm-svn: 353775
Diffstat (limited to 'compiler-rt/lib/fuzzer/FuzzerRandom.h')
-rw-r--r--compiler-rt/lib/fuzzer/FuzzerRandom.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerRandom.h b/compiler-rt/lib/fuzzer/FuzzerRandom.h
index f475797871c..af8e1a4eb71 100644
--- a/compiler-rt/lib/fuzzer/FuzzerRandom.h
+++ b/compiler-rt/lib/fuzzer/FuzzerRandom.h
@@ -20,6 +20,11 @@ class Random : public std::mt19937 {
result_type operator()() { return this->std::mt19937::operator()(); }
size_t Rand() { return this->operator()(); }
size_t RandBool() { return Rand() % 2; }
+ size_t SkewTowardsLast(size_t n) {
+ size_t T = this->operator()(n * n);
+ size_t Res = sqrt(T);
+ return Res;
+ }
size_t operator()(size_t n) { return n ? Rand() % n : 0; }
intptr_t operator()(intptr_t From, intptr_t To) {
assert(From < To);
OpenPOWER on IntegriCloud