[llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710)
[llvm-project.git] / llvm / bindings / ocaml / bitwriter / bitwriter_ocaml.c
blob8812f52c18214f681ba507cd3c83b0993a76cfb5
1 /*===-- bitwriter_ocaml.c - LLVM OCaml Glue ---------------------*- C++ -*-===*\
2 |* *|
3 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4 |* Exceptions. *|
5 |* See https://llvm.org/LICENSE.txt for license information. *|
6 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
7 |* *|
8 |*===----------------------------------------------------------------------===*|
9 |* *|
10 |* This file glues LLVM's OCaml interface to its C interface. These functions *|
11 |* are by and large transparent wrappers to the corresponding C functions. *|
12 |* *|
13 |* Note that these functions intentionally take liberties with the CAMLparamX *|
14 |* macros, since most of the parameters are not GC heap objects. *|
15 |* *|
16 \*===----------------------------------------------------------------------===*/
18 #include "caml/alloc.h"
19 #include "caml/memory.h"
20 #include "caml/mlvalues.h"
21 #include "llvm_ocaml.h"
22 #include "llvm-c/BitWriter.h"
23 #include "llvm-c/Core.h"
25 /* Llvm.llmodule -> string -> bool */
26 value llvm_write_bitcode_file(value M, value Path) {
27 int Result = LLVMWriteBitcodeToFile(Module_val(M), String_val(Path));
28 return Val_bool(Result == 0);
31 /* ?unbuffered:bool -> Llvm.llmodule -> Unix.file_descr -> bool */
32 value llvm_write_bitcode_to_fd(value U, value M, value FD) {
33 int Unbuffered;
34 int Result;
36 if (U == Val_int(0)) {
37 Unbuffered = 0;
38 } else {
39 Unbuffered = Bool_val(Field(U, 0));
42 Result = LLVMWriteBitcodeToFD(Module_val(M), Int_val(FD), 0, Unbuffered);
43 return Val_bool(Result == 0);
46 /* Llvm.llmodule -> Llvm.llmemorybuffer */
47 value llvm_write_bitcode_to_memory_buffer(value M) {
48 return to_val(LLVMWriteBitcodeToMemoryBuffer(Module_val(M)));