xref: /openbsd-src/gnu/llvm/compiler-rt/lib/fuzzer/FuzzerDefs.h (revision 810390e339a5425391477d5d41c78d7cab2424ac)
13cab2bb3Spatrick //===- FuzzerDefs.h - Internal header for the Fuzzer ------------*- C++ -* ===//
23cab2bb3Spatrick //
33cab2bb3Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
43cab2bb3Spatrick // See https://llvm.org/LICENSE.txt for license information.
53cab2bb3Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
63cab2bb3Spatrick //
73cab2bb3Spatrick //===----------------------------------------------------------------------===//
83cab2bb3Spatrick // Basic definitions.
93cab2bb3Spatrick //===----------------------------------------------------------------------===//
103cab2bb3Spatrick 
113cab2bb3Spatrick #ifndef LLVM_FUZZER_DEFS_H
123cab2bb3Spatrick #define LLVM_FUZZER_DEFS_H
133cab2bb3Spatrick 
143cab2bb3Spatrick #include <cassert>
153cab2bb3Spatrick #include <cstddef>
163cab2bb3Spatrick #include <cstdint>
173cab2bb3Spatrick #include <cstring>
183cab2bb3Spatrick #include <memory>
193cab2bb3Spatrick #include <set>
203cab2bb3Spatrick #include <string>
213cab2bb3Spatrick #include <vector>
223cab2bb3Spatrick 
233cab2bb3Spatrick 
243cab2bb3Spatrick namespace fuzzer {
253cab2bb3Spatrick 
Min(T a,T b)263cab2bb3Spatrick template <class T> T Min(T a, T b) { return a < b ? a : b; }
Max(T a,T b)273cab2bb3Spatrick template <class T> T Max(T a, T b) { return a > b ? a : b; }
283cab2bb3Spatrick 
293cab2bb3Spatrick class Random;
303cab2bb3Spatrick class Dictionary;
313cab2bb3Spatrick class DictionaryEntry;
323cab2bb3Spatrick class MutationDispatcher;
333cab2bb3Spatrick struct FuzzingOptions;
343cab2bb3Spatrick class InputCorpus;
353cab2bb3Spatrick struct InputInfo;
363cab2bb3Spatrick struct ExternalFunctions;
373cab2bb3Spatrick 
383cab2bb3Spatrick // Global interface to functions that may or may not be available.
393cab2bb3Spatrick extern ExternalFunctions *EF;
403cab2bb3Spatrick 
41*810390e3Srobert typedef std::vector<uint8_t> Unit;
42*810390e3Srobert typedef std::vector<Unit> UnitVector;
433cab2bb3Spatrick typedef int (*UserCallback)(const uint8_t *Data, size_t Size);
443cab2bb3Spatrick 
453cab2bb3Spatrick int FuzzerDriver(int *argc, char ***argv, UserCallback Callback);
463cab2bb3Spatrick 
473cab2bb3Spatrick uint8_t *ExtraCountersBegin();
483cab2bb3Spatrick uint8_t *ExtraCountersEnd();
493cab2bb3Spatrick void ClearExtraCounters();
503cab2bb3Spatrick 
513cab2bb3Spatrick extern bool RunningUserCallback;
523cab2bb3Spatrick 
533cab2bb3Spatrick }  // namespace fuzzer
543cab2bb3Spatrick 
553cab2bb3Spatrick #endif  // LLVM_FUZZER_DEFS_H
56