[libFuzzer] move the mutators to public interface so that custom mutators may reuse...
[oota-llvm.git] / lib / Fuzzer / FuzzerInterface.cpp
1 //===- FuzzerInterface.cpp - Mutate a test input --------------------------===//
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 // Parts of public interface for libFuzzer.
10 //===----------------------------------------------------------------------===//
11
12
13 #include "FuzzerInterface.h"
14 #include "FuzzerInternal.h"
15
16 namespace fuzzer {
17
18 void FuzzerRandomLibc::ResetSeed(int seed) { srand(seed); }
19
20 size_t FuzzerRandomLibc::Rand() { return rand(); }
21
22 UserSuppliedFuzzer::UserSuppliedFuzzer()
23     : OwnRand(true), Rand(new FuzzerRandomLibc(0)) {}
24
25 UserSuppliedFuzzer::UserSuppliedFuzzer(FuzzerRandomBase *Rand) : Rand(Rand) {}
26
27 UserSuppliedFuzzer::~UserSuppliedFuzzer() {
28   if (OwnRand)
29     delete Rand;
30 }
31
32 }  // namespace fuzzer.