xref: /freebsd/contrib/llvm-project/compiler-rt/lib/fuzzer/FuzzerDefs.h (revision 349cc55c9796c4596a5b9904cd3281af295f878f)
1 //===- FuzzerDefs.h - Internal header for the Fuzzer ------------*- C++ -* ===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 // Basic definitions.
9 //===----------------------------------------------------------------------===//
10 
11 #ifndef LLVM_FUZZER_DEFS_H
12 #define LLVM_FUZZER_DEFS_H
13 
14 #include <cassert>
15 #include <cstddef>
16 #include <cstdint>
17 #include <cstring>
18 #include <memory>
19 #include <set>
20 #include <string>
21 #include <vector>
22 
23 
24 namespace fuzzer {
25 
Min(T a,T b)26 template <class T> T Min(T a, T b) { return a < b ? a : b; }
Max(T a,T b)27 template <class T> T Max(T a, T b) { return a > b ? a : b; }
28 
29 class Random;
30 class Dictionary;
31 class DictionaryEntry;
32 class MutationDispatcher;
33 struct FuzzingOptions;
34 class InputCorpus;
35 struct InputInfo;
36 struct ExternalFunctions;
37 
38 // Global interface to functions that may or may not be available.
39 extern ExternalFunctions *EF;
40 
41 typedef std::vector<uint8_t> Unit;
42 typedef std::vector<Unit> UnitVector;
43 typedef int (*UserCallback)(const uint8_t *Data, size_t Size);
44 
45 int FuzzerDriver(int *argc, char ***argv, UserCallback Callback);
46 
47 uint8_t *ExtraCountersBegin();
48 uint8_t *ExtraCountersEnd();
49 void ClearExtraCounters();
50 
51 extern bool RunningUserCallback;
52 
53 }  // namespace fuzzer
54 
55 #endif  // LLVM_FUZZER_DEFS_H
56