aboutsummaryrefslogtreecommitdiffstats
path: root/bindings/ocaml/irreader/irreader_ocaml.c
diff options
context:
space:
mode:
Diffstat (limited to 'bindings/ocaml/irreader/irreader_ocaml.c')
-rw-r--r--bindings/ocaml/irreader/irreader_ocaml.c30
1 files changed, 3 insertions, 27 deletions
diff --git a/bindings/ocaml/irreader/irreader_ocaml.c b/bindings/ocaml/irreader/irreader_ocaml.c
index 30c10c7..ce593db 100644
--- a/bindings/ocaml/irreader/irreader_ocaml.c
+++ b/bindings/ocaml/irreader/irreader_ocaml.c
@@ -16,33 +16,9 @@
#include "caml/alloc.h"
#include "caml/fail.h"
#include "caml/memory.h"
+#include "caml/callback.h"
-/* Can't use the recommended caml_named_value mechanism for backwards
- compatibility reasons. This is largely equivalent. */
-static value llvm_irreader_error_exn;
-
-CAMLprim value llvm_register_irreader_exns(value Error) {
- llvm_irreader_error_exn = Field(Error, 0);
- register_global_root(&llvm_irreader_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
-}
-
-
-/*===-- Modules -----------------------------------------------------------===*/
+void llvm_raise(value Prototype, char *Message);
/* Llvm.llcontext -> Llvm.llmemorybuffer -> Llvm.llmodule */
CAMLprim value llvm_parse_ir(LLVMContextRef C,
@@ -53,7 +29,7 @@ CAMLprim value llvm_parse_ir(LLVMContextRef C,
char *Message;
if (LLVMParseIRInContext(C, MemBuf, &M, &Message))
- llvm_raise(llvm_irreader_error_exn, Message);
+ llvm_raise(*caml_named_value("Llvm_irreader.Error"), Message);
CAMLreturn((value) M);
}