-#include <string.h>
-#include <assert.h>
-
-/* Force the LLVM interpreter and JIT to be linked in. */
-void llvm_initialize(void) {
- LLVMLinkInInterpreter();
- LLVMLinkInJIT();
-}
-
-/* unit -> bool */
-CAMLprim value llvm_initialize_native_target(value Unit) {
- return Val_bool(LLVMInitializeNativeTarget());
-}
-
-/* Can't use the recommended caml_named_value mechanism for backwards
- compatibility reasons. This is largely equivalent. */
-static value llvm_ee_error_exn;
-
-CAMLprim value llvm_register_ee_exns(value Error) {
- llvm_ee_error_exn = Field(Error, 0);
- register_global_root(&llvm_ee_error_exn);
- return Val_unit;
-}
-
-static void llvm_raise(value Prototype, char *Message) {
- CAMLparam1(Prototype);
- CAMLlocal1(CamlMessage);
-
- CamlMessage = copy_string(Message);
- LLVMDisposeMessage(Message);
-
- raise_with_arg(Prototype, CamlMessage);
- abort(); /* NOTREACHED */
-#ifdef CAMLnoreturn
- CAMLnoreturn; /* Silences warnings, but is missing in some versions. */
-#endif
-}