summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/bindings/ocaml/linker/linker_ocaml.c
diff options
context:
space:
mode:
authorpascal <pascal@openbsd.org>2016-09-03 22:46:54 +0000
committerpascal <pascal@openbsd.org>2016-09-03 22:46:54 +0000
commitb5500b9ca0102f1ccaf32f0e77e96d0739aded9b (patch)
treee1b7ebb5a0231f9e6d8d3f6f719582cebd64dc98 /gnu/llvm/bindings/ocaml/linker/linker_ocaml.c
parentclarify purpose of src/gnu/ directory. (diff)
downloadwireguard-openbsd-b5500b9ca0102f1ccaf32f0e77e96d0739aded9b.tar.xz
wireguard-openbsd-b5500b9ca0102f1ccaf32f0e77e96d0739aded9b.zip
Use the space freed up by sparc and zaurus to import LLVM.
ok hackroom@
Diffstat (limited to 'gnu/llvm/bindings/ocaml/linker/linker_ocaml.c')
-rw-r--r--gnu/llvm/bindings/ocaml/linker/linker_ocaml.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/gnu/llvm/bindings/ocaml/linker/linker_ocaml.c b/gnu/llvm/bindings/ocaml/linker/linker_ocaml.c
new file mode 100644
index 00000000000..498a5f0c845
--- /dev/null
+++ b/gnu/llvm/bindings/ocaml/linker/linker_ocaml.c
@@ -0,0 +1,32 @@
+/*===-- linker_ocaml.c - LLVM OCaml Glue ------------------------*- C++ -*-===*\
+|* *|
+|* The LLVM Compiler Infrastructure *|
+|* *|
+|* This file is distributed under the University of Illinois Open Source *|
+|* License. See LICENSE.TXT for details. *|
+|* *|
+|*===----------------------------------------------------------------------===*|
+|* *|
+|* This file glues LLVM's OCaml interface to its C interface. These functions *|
+|* are by and large transparent wrappers to the corresponding C functions. *|
+|* *|
+|* Note that these functions intentionally take liberties with the CAMLparamX *|
+|* macros, since most of the parameters are not GC heap objects. *|
+|* *|
+\*===----------------------------------------------------------------------===*/
+
+#include "llvm-c/Linker.h"
+#include "caml/alloc.h"
+#include "caml/memory.h"
+#include "caml/fail.h"
+#include "caml/callback.h"
+
+void llvm_raise(value Prototype, char *Message);
+
+/* llmodule -> llmodule -> unit */
+CAMLprim value llvm_link_modules(LLVMModuleRef Dst, LLVMModuleRef Src) {
+ if (LLVMLinkModules2(Dst, Src))
+ llvm_raise(*caml_named_value("Llvm_linker.Error"), "Linking failed");
+
+ return Val_unit;
+}