aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-09-03 18:24:56 +0000
committerChris Lattner <sabre@nondot.org>2007-09-03 18:24:56 +0000
commit6a4545ed8b9600860126c9e332831424c4729638 (patch)
treeb942f5a63d86ef50289c11063b0b1d77ca5729f1
parent0b6f0ee3a47f8607623b46f78a26049d11ecfca5 (diff)
Add #ifdefs to make the source portable to windows. Patch contributed
by Hartmut Kaiser! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41684 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Basic/SourceManager.cpp10
-rw-r--r--Driver/PrintPreprocessedOutput.cpp4
2 files changed, 12 insertions, 2 deletions
diff --git a/Basic/SourceManager.cpp b/Basic/SourceManager.cpp
index 96da763451..569c864dde 100644
--- a/Basic/SourceManager.cpp
+++ b/Basic/SourceManager.cpp
@@ -41,8 +41,12 @@ SourceManager::~SourceManager() {
// FIXME: REMOVE THESE
#include <unistd.h>
#include <sys/types.h>
+#if !defined(_MSC_VER)
#include <sys/uio.h>
#include <sys/fcntl.h>
+#else
+#include <io.h>
+#endif
#include <cerrno>
static const MemoryBuffer *ReadFileFast(const FileEntry *FileEnt) {
@@ -61,8 +65,12 @@ static const MemoryBuffer *ReadFileFast(const FileEntry *FileEnt) {
MemoryBuffer *SB = MemoryBuffer::getNewUninitMemBuffer(FileEnt->getSize(),
FileEnt->getName());
char *BufPtr = const_cast<char*>(SB->getBufferStart());
-
+
+#if defined(_WIN32) || defined(_WIN64)
+ int FD = ::open(FileEnt->getName(), O_RDONLY|O_BINARY);
+#else
int FD = ::open(FileEnt->getName(), O_RDONLY);
+#endif
if (FD == -1) {
delete SB;
return 0;
diff --git a/Driver/PrintPreprocessedOutput.cpp b/Driver/PrintPreprocessedOutput.cpp
index 3eb11b719c..1cfadb35aa 100644
--- a/Driver/PrintPreprocessedOutput.cpp
+++ b/Driver/PrintPreprocessedOutput.cpp
@@ -73,7 +73,9 @@ static void CleanupOutputBuffer() {
}
static void OutputChar(char c) {
-#ifdef USE_STDIO
+#if defined(_MSC_VER)
+ putchar(c);
+#elif defined(USE_STDIO)
putchar_unlocked(c);
#else
if (OutBufCur >= OutBufEnd)