summaryrefslogtreecommitdiff
path: root/lib/System/Win32/Program.inc
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-06-07 23:18:34 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-06-07 23:18:34 +0000
commit32f5553c03dc97912b0aa77583a23972e1a882e1 (patch)
tree1e7c40368d2b3994ed0b9b4f297996a0eba21ac2 /lib/System/Win32/Program.inc
parent2991b01b183abb12ae7e29544e427f794d64b14c (diff)
downloadllvm-32f5553c03dc97912b0aa77583a23972e1a882e1.tar.gz
llvm-32f5553c03dc97912b0aa77583a23972e1a882e1.tar.bz2
llvm-32f5553c03dc97912b0aa77583a23972e1a882e1.tar.xz
For 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28722 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Win32/Program.inc')
-rw-r--r--lib/System/Win32/Program.inc14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/System/Win32/Program.inc b/lib/System/Win32/Program.inc
index 95f56b231f..c29adf0bd1 100644
--- a/lib/System/Win32/Program.inc
+++ b/lib/System/Win32/Program.inc
@@ -12,8 +12,10 @@
//===----------------------------------------------------------------------===//
#include "Win32.h"
+#include <cstdio>
#include <malloc.h>
#include <io.h>
+#include <fcntl.h>
//===----------------------------------------------------------------------===//
//=== WARNING: Implementation here must contain only Win32 specific code
@@ -218,4 +220,16 @@ Program::ExecuteAndWait(const Path& path,
return status;
}
+void Program::ChangeStdinToBinary(){
+ int result = _setmode( _fileno(stdin), _O_BINARY );
+ if( result == -1 )
+ throw std::string("Cannot set input mode on stdin to binary.");
+}
+
+void Program::ChangeStdoutToBinary(){
+ int result = _setmode( _fileno(stdout), _O_BINARY );
+ if( result == -1 )
+ throw std::string("Cannot set output mode on stdout to binary.");
+}
+
}