Do not rely on LLVMMCJITMemoryManagerRef being available.
The c binding to the memory manager objects only appeared
on llvm-3.4.
The change is based on an initial patch of Brian Paul.
Reviewed-by: Brian Paul <brianp@vmware.com>
Tested-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Signed-off-by: Mathias Froehlich <Mathias.Froehlich@web.de>
#endif
+#if HAVE_LLVM <= 0x0303
+/* We won't actually use LLVMMCJITMemoryManagerRef, just create a dummy
+ * typedef to simplify things elsewhere.
+ */
+typedef void *LLVMMCJITMemoryManagerRef;
+#endif
+
+
/**
* Redefine these LLVM entrypoints as invalid macros to make sure we
* don't accidentally use them. We need to use the functions which
assert(!gallivm->engine);
lp_free_generated_code(gallivm->code);
gallivm->code = NULL;
-#if HAVE_LLVM < 0x0306
- LLVMDisposeMCJITMemoryManager(gallivm->memorymgr);
+ lp_free_memory_manager(gallivm->memorymgr);
gallivm->memorymgr = NULL;
-#endif
}
return 0;
#endif
}
+
+extern "C"
+void
+lp_free_memory_manager(LLVMMCJITMemoryManagerRef memorymgr)
+{
+#if HAVE_LLVM < 0x0306
+ delete reinterpret_cast<llvm::JITMemoryManager*>(memorymgr);
+#endif
+}
extern LLVMMCJITMemoryManagerRef
lp_get_default_memory_manager();
+extern void
+lp_free_memory_manager(LLVMMCJITMemoryManagerRef memorymgr);
+
#ifdef __cplusplus
}
#endif