[PATCH] OCaml bindings: fix ABI incompatibility

Peter Zotov whitequark at whitequark.org
Sat Oct 12 12:06:32 PDT 2013


Hi sylvestre.ledru,

OCaml's type unit is not compatible with C's type void.

http://llvm-reviews.chandlerc.com/D1929

Files:
  bindings/ocaml/llvm/llvm.ml
  bindings/ocaml/llvm/llvm_ocaml.c

Index: bindings/ocaml/llvm/llvm.ml
===================================================================
--- bindings/ocaml/llvm/llvm.ml
+++ bindings/ocaml/llvm/llvm.ml
@@ -379,7 +379,7 @@
 external set_value_name : string -> llvalue -> unit = "llvm_set_value_name"
 external dump_value : llvalue -> unit = "llvm_dump_value"
 external replace_all_uses_with : llvalue -> llvalue -> unit
-                               = "LLVMReplaceAllUsesWith"
+                               = "llvm_replace_all_uses_with"
 
 (*--... Operations on uses .................................................--*)
 external use_begin : llvalue -> lluse option = "llvm_use_begin"
Index: bindings/ocaml/llvm/llvm_ocaml.c
===================================================================
--- bindings/ocaml/llvm/llvm_ocaml.c
+++ bindings/ocaml/llvm/llvm_ocaml.c
@@ -501,6 +501,13 @@
   return Val_unit;
 }
 
+/* llvalue -> llvalue -> unit */
+CAMLprim value llvm_replace_all_uses_with(LLVMValueRef OldVal, 
+                                          LLVMValueRef NewVal) {
+  LLVMReplaceAllUsesWith(OldVal, NewVal);
+  return Val_unit;
+}
+
 /*--... Operations on users ................................................--*/
 
 /* llvalue -> int -> llvalue */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1929.1.patch
Type: text/x-patch
Size: 1233 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131012/b1dedc22/attachment.bin>


More information about the llvm-commits mailing list