[llvm-commits] CVS: llvm/lib/Bytecode/Writer/Writer.cpp

Reid Spencer reid at x10sys.com
Wed Jun 7 16:18:49 PDT 2006

Changes in directory llvm/lib/Bytecode/Writer:

Writer.cpp updated: 1.121 -> 1.122
Log message:

For PR787: http://llvm.cs.uiuc.edu/PR787 :
Provide new llvm::sys::Program facilities for converting the stdout and
stdin to binary mode. There is no standard way to do this and the available
mechanisms are platform specific. Adjust the bytecode reader and writer to
use these methods when their input is stdin or output is stdout. THis avoids
the problem with \n writing CRLF to a bytecode file on windows.

Patch Contributed by Michael Smith.

Diffs of the changes:  (+6 -0)

 Writer.cpp |    6 ++++++
 1 files changed, 6 insertions(+)

Index: llvm/lib/Bytecode/Writer/Writer.cpp
diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.121 llvm/lib/Bytecode/Writer/Writer.cpp:1.122
--- llvm/lib/Bytecode/Writer/Writer.cpp:1.121	Fri May 26 13:42:34 2006
+++ llvm/lib/Bytecode/Writer/Writer.cpp	Wed Jun  7 18:18:33 2006
@@ -29,6 +29,7 @@
 #include "llvm/Support/GetElementPtrTypeIterator.h"
 #include "llvm/Support/Compressor.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/System/Program.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/Statistic.h"
 #include <cstring>
@@ -1217,6 +1218,11 @@
                                bool compress ) {
   assert(M && "You can't write a null module!!");
+  // Make sure that std::cout is put into binary mode for systems
+  // that care.
+  if (&Out == std::cout)
+    sys::Program::ChangeStdoutToBinary();
   // Create a vector of unsigned char for the bytecode output. We
   // reserve 256KBytes of space in the vector so that we avoid doing
   // lots of little allocations. 256KBytes is sufficient for a large

More information about the llvm-commits mailing list