xref: /freebsd/contrib/llvm-project/compiler-rt/lib/fuzzer/FuzzerDefs.h (revision 349cc55c9796c4596a5b9904cd3281af295f878f)
10b57cec5SDimitry Andric //===- FuzzerDefs.h - Internal header for the Fuzzer ------------*- C++ -* ===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric // Basic definitions.
90b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
100b57cec5SDimitry Andric 
110b57cec5SDimitry Andric #ifndef LLVM_FUZZER_DEFS_H
120b57cec5SDimitry Andric #define LLVM_FUZZER_DEFS_H
130b57cec5SDimitry Andric 
140b57cec5SDimitry Andric #include <cassert>
150b57cec5SDimitry Andric #include <cstddef>
160b57cec5SDimitry Andric #include <cstdint>
170b57cec5SDimitry Andric #include <cstring>
1868d75effSDimitry Andric #include <memory>
1968d75effSDimitry Andric #include <set>
200b57cec5SDimitry Andric #include <string>
210b57cec5SDimitry Andric #include <vector>
2268d75effSDimitry Andric 
230b57cec5SDimitry Andric 
240b57cec5SDimitry Andric namespace fuzzer {
250b57cec5SDimitry Andric 
Min(T a,T b)260b57cec5SDimitry Andric template <class T> T Min(T a, T b) { return a < b ? a : b; }
Max(T a,T b)270b57cec5SDimitry Andric template <class T> T Max(T a, T b) { return a > b ? a : b; }
280b57cec5SDimitry Andric 
290b57cec5SDimitry Andric class Random;
300b57cec5SDimitry Andric class Dictionary;
310b57cec5SDimitry Andric class DictionaryEntry;
320b57cec5SDimitry Andric class MutationDispatcher;
330b57cec5SDimitry Andric struct FuzzingOptions;
340b57cec5SDimitry Andric class InputCorpus;
350b57cec5SDimitry Andric struct InputInfo;
360b57cec5SDimitry Andric struct ExternalFunctions;
370b57cec5SDimitry Andric 
380b57cec5SDimitry Andric // Global interface to functions that may or may not be available.
390b57cec5SDimitry Andric extern ExternalFunctions *EF;
400b57cec5SDimitry Andric 
41*349cc55cSDimitry Andric typedef std::vector<uint8_t> Unit;
42*349cc55cSDimitry Andric typedef std::vector<Unit> UnitVector;
430b57cec5SDimitry Andric typedef int (*UserCallback)(const uint8_t *Data, size_t Size);
440b57cec5SDimitry Andric 
450b57cec5SDimitry Andric int FuzzerDriver(int *argc, char ***argv, UserCallback Callback);
460b57cec5SDimitry Andric 
470b57cec5SDimitry Andric uint8_t *ExtraCountersBegin();
480b57cec5SDimitry Andric uint8_t *ExtraCountersEnd();
490b57cec5SDimitry Andric void ClearExtraCounters();
500b57cec5SDimitry Andric 
510b57cec5SDimitry Andric extern bool RunningUserCallback;
520b57cec5SDimitry Andric 
530b57cec5SDimitry Andric }  // namespace fuzzer
540b57cec5SDimitry Andric 
550b57cec5SDimitry Andric #endif  // LLVM_FUZZER_DEFS_H
56