AC_MSG_WARN([dlopen() not found - disabling plugin support]))
dnl libffi is optional; used to call external functions from the interpreter
-AC_CHECK_LIB(ffi,ffi_call,[have_libffi=1],
- AC_MSG_WARN([libffi not found - disabling external calls from interpreter]))
+AC_SEARCH_LIBS(ffi_call,ffi,AC_DEFINE([HAVE_FFI_CALL],[1],
+ [Define if libffi is available on this platform.]),
+ AC_MSG_WARN([libffi not found - disabling external calls from interpreter]))
dnl mallinfo is optional; the code can compile (minus features) without it
AC_SEARCH_LIBS(mallinfo,malloc,AC_DEFINE([HAVE_MALLINFO],[1],
AC_SUBST(HAVE_PTHREAD, 0)
fi
-dnl Once we know we have libffi, try to find ffi.h.
-if test -n "$have_libffi" ; then
- AC_CHECK_HEADERS([ffi.h ffi/ffi.h], [AC_SUBST(HAVE_FFI, 1)])
-fi
+dnl Try to find ffi.h.
+AC_CHECK_HEADERS([ffi.h ffi/ffi.h])
dnl===-----------------------------------------------------------------------===
dnl===
#include <cmath>
#include <cstring>
-#ifdef HAVE_FFI
+#ifdef HAVE_FFI_CALL
#ifdef HAVE_FFI_H
#include <ffi.h>
+#define USE_LIBFFI
#elif HAVE_FFI_FFI_H
#include <ffi/ffi.h>
-#else
-#error "Not sure where configure found ffi.h!"
+#define USE_LIBFFI
#endif
#endif
static ManagedStatic<std::map<const Function *, ExFunc> > ExportedFunctions;
static std::map<std::string, ExFunc> FuncNames;
-#ifdef HAVE_FFI
+#ifdef USE_LIBFFI
typedef void (*RawFunc)(void);
static ManagedStatic<std::map<const Function *, RawFunc> > RawFunctions;
#endif
return FnPtr;
}
-#ifdef HAVE_FFI
+#ifdef USE_LIBFFI
static ffi_type *ffiTypeFor(const Type *Ty) {
switch (Ty->getTypeID()) {
case Type::VoidTyID: return &ffi_type_void;
return false;
}
-#endif // HAVE_FFI
+#endif // USE_LIBFFI
GenericValue Interpreter::callExternalFunction(Function *F,
const std::vector<GenericValue> &ArgVals) {
: FI->second)
return Fn(F->getFunctionType(), ArgVals);
-#ifdef HAVE_FFI
+#ifdef USE_LIBFFI
std::map<const Function *, RawFunc>::iterator RF = RawFunctions->find(F);
RawFunc RawFn;
if (RF == RawFunctions->end()) {
GenericValue Result;
if (RawFn != 0 && ffiInvoke(RawFn, F, ArgVals, getTargetData(), Result))
return Result;
-#endif // HAVE_FFI
+#endif // USE_LIBFFI
cerr << "Tried to execute an unknown external function: "
<< F->getType()->getDescription() << " " << F->getName() << "\n";