summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Fuzzer/FuzzerInterface.h
diff options
context:
space:
mode:
authorIvan Krasin <krasin@chromium.org>2016-01-22 01:32:34 +0000
committerIvan Krasin <krasin@chromium.org>2016-01-22 01:32:34 +0000
commitb008fd4d895591013dad05bdeb2276085689b774 (patch)
treee7b50a74f9ec2fea0a7a4cb24872f138abbc3a22 /llvm/lib/Fuzzer/FuzzerInterface.h
parent1423921a24866af65dd7ffaf69bca20babe72786 (diff)
downloadbcm5719-llvm-b008fd4d895591013dad05bdeb2276085689b774.tar.gz
bcm5719-llvm-b008fd4d895591013dad05bdeb2276085689b774.zip
Use std::piecewise_constant_distribution instead of ad-hoc binary search.
Summary: Fix the issue with the most recently discovered unit receiving much less attention. Note: I had to change the seed for one test to make it pass. Alternatively, the number of runs could be increased. I believe that the average time of 'foo' discovery is not increased, just seed=1 was particularly convenient for the previous PRNG scheme used. Reviewers: aizatsky, kcc Subscribers: llvm-commits, kcc Differential Revision: http://reviews.llvm.org/D16419 llvm-svn: 258473
Diffstat (limited to 'llvm/lib/Fuzzer/FuzzerInterface.h')
-rw-r--r--llvm/lib/Fuzzer/FuzzerInterface.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Fuzzer/FuzzerInterface.h b/llvm/lib/Fuzzer/FuzzerInterface.h
index 64b8f868f65..5cf0361e1e6 100644
--- a/llvm/lib/Fuzzer/FuzzerInterface.h
+++ b/llvm/lib/Fuzzer/FuzzerInterface.h
@@ -66,6 +66,18 @@ class FuzzerRandomBase {
// Return a random number in range [0,n).
size_t operator()(size_t n) { return n ? Rand() % n : 0; }
bool RandBool() { return Rand() % 2; }
+
+ // The methods below is to satisfy UniformRandomNumberGenerator:
+ // http://en.cppreference.com/w/cpp/concept/UniformRandomNumberGenerator\
+
+ // Returns a random number between 0 and RAND_MAX inclusive.
+ double operator()() { return operator()(RAND_MAX); }
+
+ // Returns the smallest value that operator() may return.
+ double min() { return 0; }
+
+ // Returns the largest value that operator() may return.
+ double max() { return RAND_MAX; }
};
// Using libc's stand/rand.
OpenPOWER on IntegriCloud