C and Ocaml bindings for ExecutionEngine (i.e., the JIT compiler).
[oota-llvm.git] / bindings / ocaml / bitreader / bitreader_ocaml.c
index 87477f6312d24b9e4f00c825b27f968af9f74a58..980ed2abbfc075f1cdd34d2f3b532c208ac33416 100644 (file)
@@ -14,9 +14,8 @@
 
 #include "llvm-c/BitReader.h"
 #include "caml/alloc.h"
-#include "caml/mlvalues.h"
+#include "caml/fail.h"
 #include "caml/memory.h"
-#include <stdio.h>
 
 
 /* Can't use the recommended caml_named_value mechanism for backwards
@@ -29,7 +28,17 @@ CAMLprim value llvm_register_bitreader_exns(value Error) {
   return Val_unit;
 }
 
-void llvm_raise(value Prototype, char *Message);
+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 */
+  CAMLnoreturn;
+}
 
 
 /*===-- Modules -----------------------------------------------------------===*/