diff options
author | Peter Zotov <whitequark@whitequark.org> | 2014-10-30 08:29:29 +0000 |
---|---|---|
committer | Peter Zotov <whitequark@whitequark.org> | 2014-10-30 08:29:29 +0000 |
commit | 1b254f9a56b8647ea0101ee49ff00fd4a810b6d4 (patch) | |
tree | 7bcd4627f2d7870e9a9fcd7b82dcc7ece710bdd2 | |
parent | a2c5153edd2a4abb4a5a168e28b0be03bdf1f607 (diff) | |
download | bcm5719-llvm-1b254f9a56b8647ea0101ee49ff00fd4a810b6d4.tar.gz bcm5719-llvm-1b254f9a56b8647ea0101ee49ff00fd4a810b6d4.zip |
[OCaml] De-duplicate llvm_raise and llvm_string_of_message.
llvm-svn: 220898
-rw-r--r-- | llvm/bindings/ocaml/bitreader/bitreader_ocaml.c | 13 | ||||
-rw-r--r-- | llvm/bindings/ocaml/bitwriter/bitwriter_ocaml.c | 2 | ||||
-rw-r--r-- | llvm/bindings/ocaml/executionengine/executionengine_ocaml.c | 11 | ||||
-rw-r--r-- | llvm/bindings/ocaml/irreader/irreader_ocaml.c | 13 | ||||
-rw-r--r-- | llvm/bindings/ocaml/linker/linker_ocaml.c | 11 | ||||
-rw-r--r-- | llvm/bindings/ocaml/llvm/llvm_ocaml.c | 14 | ||||
-rw-r--r-- | llvm/bindings/ocaml/target/target_ocaml.c | 21 |
7 files changed, 14 insertions, 71 deletions
diff --git a/llvm/bindings/ocaml/bitreader/bitreader_ocaml.c b/llvm/bindings/ocaml/bitreader/bitreader_ocaml.c index eab3e1ae30e..15ebd5f635f 100644 --- a/llvm/bindings/ocaml/bitreader/bitreader_ocaml.c +++ b/llvm/bindings/ocaml/bitreader/bitreader_ocaml.c @@ -18,18 +18,7 @@ #include "caml/memory.h" #include "caml/callback.h" -static void llvm_raise(value Prototype, char *Message) { - CAMLparam1(Prototype); - CAMLlocal1(CamlMessage); - - CamlMessage = copy_string(Message); - LLVMDisposeMessage(Message); - - raise_with_arg(Prototype, CamlMessage); - CAMLnoreturn; -} - -/*===-- BitReader --------------------------------------------------------===*/ +void llvm_raise(value Prototype, char *Message); /* Llvm.llcontext -> Llvm.llmemorybuffer -> Llvm.llmodule */ CAMLprim LLVMModuleRef llvm_get_module(LLVMContextRef C, LLVMMemoryBufferRef MemBuf) { diff --git a/llvm/bindings/ocaml/bitwriter/bitwriter_ocaml.c b/llvm/bindings/ocaml/bitwriter/bitwriter_ocaml.c index f20fd59fd31..04fd61917dc 100644 --- a/llvm/bindings/ocaml/bitwriter/bitwriter_ocaml.c +++ b/llvm/bindings/ocaml/bitwriter/bitwriter_ocaml.c @@ -21,8 +21,6 @@ #include "caml/mlvalues.h" #include "caml/memory.h" -/*===-- BitWriter ---------------------------------------------------------===*/ - /* Llvm.llmodule -> string -> bool */ CAMLprim value llvm_write_bitcode_file(LLVMModuleRef M, value Path) { int Result = LLVMWriteBitcodeToFile(M, String_val(Path)); diff --git a/llvm/bindings/ocaml/executionengine/executionengine_ocaml.c b/llvm/bindings/ocaml/executionengine/executionengine_ocaml.c index a12cc0091ae..c647d23133c 100644 --- a/llvm/bindings/ocaml/executionengine/executionengine_ocaml.c +++ b/llvm/bindings/ocaml/executionengine/executionengine_ocaml.c @@ -25,16 +25,7 @@ #include "caml/memory.h" #include "caml/callback.h" -static void llvm_raise(value Prototype, char *Message) { - CAMLparam1(Prototype); - CAMLlocal1(CamlMessage); - - CamlMessage = copy_string(Message); - LLVMDisposeMessage(Message); - - raise_with_arg(Prototype, CamlMessage); - CAMLnoreturn; -} +void llvm_raise(value Prototype, char *Message); /*--... Operations on generic values .......................................--*/ diff --git a/llvm/bindings/ocaml/irreader/irreader_ocaml.c b/llvm/bindings/ocaml/irreader/irreader_ocaml.c index d9f7a50c52d..ce593db80a8 100644 --- a/llvm/bindings/ocaml/irreader/irreader_ocaml.c +++ b/llvm/bindings/ocaml/irreader/irreader_ocaml.c @@ -18,18 +18,7 @@ #include "caml/memory.h" #include "caml/callback.h" -static void llvm_raise(value Prototype, char *Message) { - CAMLparam1(Prototype); - CAMLlocal1(CamlMessage); - - CamlMessage = copy_string(Message); - LLVMDisposeMessage(Message); - - raise_with_arg(Prototype, CamlMessage); - CAMLnoreturn; -} - -/*===-- IRReader ----------------------------------------------------------===*/ +void llvm_raise(value Prototype, char *Message); /* Llvm.llcontext -> Llvm.llmemorybuffer -> Llvm.llmodule */ CAMLprim value llvm_parse_ir(LLVMContextRef C, diff --git a/llvm/bindings/ocaml/linker/linker_ocaml.c b/llvm/bindings/ocaml/linker/linker_ocaml.c index 553fbd91fe3..ade0fbb56d9 100644 --- a/llvm/bindings/ocaml/linker/linker_ocaml.c +++ b/llvm/bindings/ocaml/linker/linker_ocaml.c @@ -21,16 +21,7 @@ #include "caml/fail.h" #include "caml/callback.h" -static void llvm_raise(value Prototype, char *Message) { - CAMLparam1(Prototype); - CAMLlocal1(CamlMessage); - - CamlMessage = copy_string(Message); - LLVMDisposeMessage(Message); - - raise_with_arg(Prototype, CamlMessage); - CAMLnoreturn; -} +void llvm_raise(value Prototype, char *Message); /* llmodule -> llmodule -> Mode.t -> unit */ CAMLprim value llvm_link_modules(LLVMModuleRef Dst, LLVMModuleRef Src, value Mode) { diff --git a/llvm/bindings/ocaml/llvm/llvm_ocaml.c b/llvm/bindings/ocaml/llvm/llvm_ocaml.c index 4b146332c94..2348b6d1699 100644 --- a/llvm/bindings/ocaml/llvm/llvm_ocaml.c +++ b/llvm/bindings/ocaml/llvm/llvm_ocaml.c @@ -25,14 +25,16 @@ #include "caml/fail.h" #include "caml/callback.h" -static void llvm_raise(value Prototype, char *Message) { - CAMLparam1(Prototype); - CAMLlocal1(CamlMessage); - - CamlMessage = copy_string(Message); +value llvm_string_of_message(char* Message) { + value String = caml_copy_string(Message); LLVMDisposeMessage(Message); - raise_with_arg(Prototype, CamlMessage); + return String; +} + +void llvm_raise(value Prototype, char *Message) { + CAMLparam1(Prototype); + raise_with_arg(Prototype, llvm_string_of_message(Message)); CAMLnoreturn; } diff --git a/llvm/bindings/ocaml/target/target_ocaml.c b/llvm/bindings/ocaml/target/target_ocaml.c index efb5d9bd51e..8f77cb46f13 100644 --- a/llvm/bindings/ocaml/target/target_ocaml.c +++ b/llvm/bindings/ocaml/target/target_ocaml.c @@ -23,25 +23,8 @@ #include "caml/custom.h" #include "caml/callback.h" -/*===---- Exceptions ------------------------------------------------------===*/ - -static void llvm_raise(value Prototype, char *Message) { - CAMLparam1(Prototype); - CAMLlocal1(CamlMessage); - - CamlMessage = copy_string(Message); - LLVMDisposeMessage(Message); - - raise_with_arg(Prototype, CamlMessage); - CAMLnoreturn; -} - -static value llvm_string_of_message(char* Message) { - value String = caml_copy_string(Message); - LLVMDisposeMessage(Message); - - return String; -} +void llvm_raise(value Prototype, char *Message); +value llvm_string_of_message(char* Message); /*===---- Data Layout -----------------------------------------------------===*/ |