Skip to content

Commit 2f4e604

Browse files
author
kcc
committed
[libFuzzer] replace slow std::mt19937 with a much faster std::minstd_rand; second attempt after failed r352732, this time with a fix for cmake
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/fuzzer@353782 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 278174f commit 2f4e604

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

FuzzerRandom.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
#include <random>
1515

1616
namespace fuzzer {
17-
class Random : public std::mt19937 {
17+
class Random : public std::minstd_rand {
1818
public:
19-
Random(unsigned int seed) : std::mt19937(seed) {}
20-
result_type operator()() { return this->std::mt19937::operator()(); }
19+
Random(unsigned int seed) : std::minstd_rand(seed) {}
20+
result_type operator()() { return this->std::minstd_rand::operator()(); }
2121
size_t Rand() { return this->operator()(); }
2222
size_t RandBool() { return Rand() % 2; }
2323
size_t SkewTowardsLast(size_t n) {

tests/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ if(COMPILER_RT_DEFAULT_TARGET_ARCH IN_LIST FUZZER_SUPPORTED_ARCH)
4646
FOLDER "Compiler-RT Runtime tests")
4747

4848
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND COMPILER_RT_LIBCXX_PATH)
49-
set(LIBFUZZER_TEST_RUNTIME_DEPS libcxx_fuzzer_${arch}-build)
49+
file(GLOB libfuzzer_headers ../*.h)
50+
set(LIBFUZZER_TEST_RUNTIME_DEPS libcxx_fuzzer_${arch}-build ${libfuzzer_headers})
5051
set(LIBFUZZER_TEST_RUNTIME_CFLAGS -isystem ${LIBCXX_${arch}_PREFIX}/include/c++/v1)
5152
set(LIBFUZZER_TEST_RUNTIME_LINK_FLAGS ${LIBCXX_${arch}_PREFIX}/lib/libc++.a)
5253
endif()

0 commit comments

Comments
 (0)