mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-23 12:40:38 +00:00
1a1c8bea2d
This fixes linking problems on OSX. Unfortunately it turns out we need to use an instance of the ``fuzzer::ExternalFunctions`` object in several places so this commit also replaces all instances with a single global instance. It also turns out initializing a global ``fuzzer::ExternalFunctions`` before main is entered (i.e. letting the object be initialised by the global initializers) is not safe (on OSX the call to ``Printf()`` in the CTOR crashes if it is called from a global initializer) so we instead have a global ``fuzzer::ExternalFunctions*`` and initialize it inside ``FuzzerDriver()``. Multiple unit tests depend also depend on the ``fuzzer::ExternalFunctions*`` global so a ``main()`` function has been added that initializes it before running any tests. Differential Revision: http://reviews.llvm.org/D20943 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272072 91177308-0d34-0410-b5e6-96231b3b80d8
34 lines
1.0 KiB
C++
34 lines
1.0 KiB
C++
//===- FuzzerExtFunctions.h - Interface to external functions ---*- C++ -* ===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
// Defines an interface to (possibly optional) functions.
|
|
//===----------------------------------------------------------------------===//
|
|
#ifndef LLVM_FUZZER_EXT_FUNCTIONS_H
|
|
#define LLVM_FUZZER_EXT_FUNCTIONS_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
namespace fuzzer {
|
|
|
|
struct ExternalFunctions {
|
|
// Initialize function pointers. Functions that are not available will be set
|
|
// to nullptr. Do not call this constructor before ``main()`` has been
|
|
// entered.
|
|
ExternalFunctions();
|
|
|
|
#define EXT_FUNC(NAME, RETURN_TYPE, FUNC_SIG, WARN) \
|
|
RETURN_TYPE(*NAME) FUNC_SIG = nullptr
|
|
|
|
#include "FuzzerExtFunctions.def"
|
|
|
|
#undef EXT_FUNC
|
|
};
|
|
} // namespace fuzzer
|
|
#endif
|