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

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 nits. 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 -------------*- C++ -*-===//
jvoung (off chromium) 2015/06/01 17:26:35 no need for -*- C++ -*-
Karl 2015/06/01 22:40:54 Done.
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.
jvoung (off chromium) 2015/06/01 17:26:35 //===---------------------------------------------
Karl 2015/06/01 22:40:55 Done.
11
12 #include "llvm/Bitcode/NaCl/NaClRandNumGen.h"
13
14 #include <vector>
15 #include <algorithm>
16
17 namespace naclfuzz {
18
19 // Put destructor in .cpp file go guarantee vtable construction.
jvoung (off chromium) 2015/06/01 17:26:35 "go guarantee" -> "to guarantee"
Karl 2015/06/01 22:40:54 Done.
20 RandomNumberGenerator::~RandomNumberGenerator() {}
21
22 DefaultRandomNumberGenerator::DefaultRandomNumberGenerator(std::string Seed)
23 : Seed(Seed) {
24 setSeed(0);
jvoung (off chromium) 2015/06/01 17:26:35 How about call the method saltSeed() (can salt be
Karl 2015/06/01 22:40:54 Changed to saltSeed.
25 }
26
27 uint64_t DefaultRandomNumberGenerator::operator()() {
28 return Generator();
29 }
30
31 void DefaultRandomNumberGenerator::setSeed(uint64_t Salt) {
32 // Combine seed and salt and pass to generator.
33 std::vector<uint32_t> Data;
34 Data.reserve(Seed.size() + 2);
35 Data.push_back(static_cast<uint32_t>(Salt));
36 Data.push_back(static_cast<uint32_t>(Salt >> 32));
37 std::copy(Seed.begin(), Seed.end(), Data.end());
38 std::seed_seq SeedSeq(Data.begin(), Data.end());
39 Generator.seed(SeedSeq);
40 }
41
42 } // end of namespace nacl
jvoung (off chromium) 2015/06/01 17:26:35 naclfuzz
Karl 2015/06/01 22:40:55 Done.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698