10b57cec5SDimitry Andric//===- FuzzerExtFunctions.def - External functions --------------*- 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// This defines the external function pointers that
90b57cec5SDimitry Andric// ``fuzzer::ExternalFunctions`` should contain and try to initialize.  The
100b57cec5SDimitry Andric// EXT_FUNC macro must be defined at the point of inclusion. The signature of
110b57cec5SDimitry Andric// the macro is:
120b57cec5SDimitry Andric//
130b57cec5SDimitry Andric// EXT_FUNC(<name>, <return_type>, <function_signature>, <warn_if_missing>)
140b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
150b57cec5SDimitry Andric
160b57cec5SDimitry Andric// Optional user functions
170b57cec5SDimitry AndricEXT_FUNC(LLVMFuzzerInitialize, int, (int *argc, char ***argv), false);
180b57cec5SDimitry AndricEXT_FUNC(LLVMFuzzerCustomMutator, size_t,
190b57cec5SDimitry Andric         (uint8_t *Data, size_t Size, size_t MaxSize, unsigned int Seed),
200b57cec5SDimitry Andric         false);
210b57cec5SDimitry AndricEXT_FUNC(LLVMFuzzerCustomCrossOver, size_t,
220b57cec5SDimitry Andric         (const uint8_t *Data1, size_t Size1,
230b57cec5SDimitry Andric          const uint8_t *Data2, size_t Size2,
240b57cec5SDimitry Andric          uint8_t *Out, size_t MaxOutSize, unsigned int Seed),
250b57cec5SDimitry Andric         false);
260b57cec5SDimitry Andric
270b57cec5SDimitry Andric// Sanitizer functions
280b57cec5SDimitry AndricEXT_FUNC(__lsan_enable, void, (), false);
290b57cec5SDimitry AndricEXT_FUNC(__lsan_disable, void, (), false);
300b57cec5SDimitry AndricEXT_FUNC(__lsan_do_recoverable_leak_check, int, (), false);
310b57cec5SDimitry AndricEXT_FUNC(__sanitizer_acquire_crash_state, int, (), true);
320b57cec5SDimitry AndricEXT_FUNC(__sanitizer_install_malloc_and_free_hooks, int,
330b57cec5SDimitry Andric         (void (*malloc_hook)(const volatile void *, size_t),
340b57cec5SDimitry Andric          void (*free_hook)(const volatile void *)),
350b57cec5SDimitry Andric         false);
360b57cec5SDimitry AndricEXT_FUNC(__sanitizer_log_write, void, (const char *buf, size_t len), false);
370b57cec5SDimitry AndricEXT_FUNC(__sanitizer_purge_allocator, void, (), false);
380b57cec5SDimitry AndricEXT_FUNC(__sanitizer_print_memory_profile, void, (size_t, size_t), false);
390b57cec5SDimitry AndricEXT_FUNC(__sanitizer_print_stack_trace, void, (), true);
400b57cec5SDimitry AndricEXT_FUNC(__sanitizer_symbolize_pc, void,
410b57cec5SDimitry Andric         (void *, const char *fmt, char *out_buf, size_t out_buf_size), false);
420b57cec5SDimitry AndricEXT_FUNC(__sanitizer_get_module_and_offset_for_pc, int,
430b57cec5SDimitry Andric         (void *pc, char *module_path,
440b57cec5SDimitry Andric         size_t module_path_len,void **pc_offset), false);
450b57cec5SDimitry AndricEXT_FUNC(__sanitizer_set_death_callback, void, (void (*)(void)), true);
460b57cec5SDimitry AndricEXT_FUNC(__sanitizer_set_report_fd, void, (void*), false);
470b57cec5SDimitry AndricEXT_FUNC(__msan_scoped_disable_interceptor_checks, void, (), false);
480b57cec5SDimitry AndricEXT_FUNC(__msan_scoped_enable_interceptor_checks, void, (), false);
490b57cec5SDimitry AndricEXT_FUNC(__msan_unpoison, void, (const volatile void *, size_t size), false);
50EXT_FUNC(__msan_unpoison_param, void, (size_t n), false);
51