Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: lib/Bitcode/NaCl/TestUtils/NaClRandNumGen.cpp

Issue 1156103003: Initial implementation of a record-level bitcode fuzzer. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@fuzz
Patch Set: Fix issues in last patch. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 //===- NaClRandNumGen.cpp - Random number generator -----------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file provides a default implementation of a random number generator.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/Bitcode/NaCl/NaClRandNumGen.h"
15
16 #include <vector>
17 #include <algorithm>
18
19 namespace naclfuzz {
20
21 // Put destructor in .cpp file guarantee vtable construction.
22 RandomNumberGenerator::~RandomNumberGenerator() {}
23
24 DefaultRandomNumberGenerator::DefaultRandomNumberGenerator(llvm::StringRef Seed)
25 : Seed(Seed) {
26 saltSeed(0);
27 }
28
29 uint64_t DefaultRandomNumberGenerator::operator()() {
30 return Generator();
31 }
32
33 void DefaultRandomNumberGenerator::saltSeed(uint64_t Salt) {
34 // Combine seed and salt and pass to generator.
35 std::vector<uint32_t> Data;
36 Data.reserve(Seed.size() + 2);
37 Data.push_back(static_cast<uint32_t>(Salt));
38 Data.push_back(static_cast<uint32_t>(Salt >> 32));
39 std::copy(Seed.begin(), Seed.end(), Data.end());
40 std::seed_seq SeedSeq(Data.begin(), Data.end());
41 Generator.seed(SeedSeq);
42 }
43
44 } // end of namespace naclfuzz
OLDNEW
« no previous file with comments | « lib/Bitcode/NaCl/TestUtils/NaClFuzz.cpp ('k') | lib/Bitcode/NaCl/TestUtils/NaClSimpleRecordFuzzer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698