1 //===-- BitWriter.cpp -----------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Gordon Henriksen and is distributed under the
6 // University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm-c/BitWriter.h"
11 #include "llvm/Bitcode/ReaderWriter.h"
17 /*===-- Operations on modules ---------------------------------------------===*/
19 int LLVMWriteBitcodeToFile(LLVMModuleRef M, const char *Path) {
20 std::ofstream OS(Path);
23 WriteBitcodeToFile(unwrap(M), OS);
32 #include <ext/stdio_filebuf.h>
34 // FIXME: Control this with configure? Provide some portable abstraction in
35 // libSystem? As is, the user will just get a linker error if they use this on
36 // non-GCC. Some C++ stdlibs even have ofstream::ofstream(int fd).
37 int LLVMWriteBitcodeToFileHandle(LLVMModuleRef M, int FileHandle) {
38 __gnu_cxx::stdio_filebuf<char> Buffer(FileHandle, std::ios_base::out);
39 std::ostream OS(&Buffer, std::ios::out | std::ios::trunc | std::ios::binary);
42 WriteBitcodeToFile(unwrap(M), OS);