From cd1e8d2c9d8585f3e63c4d57efacfe18275fe132 Mon Sep 17 00:00:00 2001 From: Chris Lattner <sabre@nondot.org> Date: Mon, 3 Sep 2007 18:24:56 +0000 Subject: [PATCH] Add #ifdefs to make the source portable to windows. Patch contributed by Hartmut Kaiser! llvm-svn: 41684 --- clang/Basic/SourceManager.cpp | 10 +++++++++- clang/Driver/PrintPreprocessedOutput.cpp | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/clang/Basic/SourceManager.cpp b/clang/Basic/SourceManager.cpp index 96da7634511c..569c864dde7f 100644 --- a/clang/Basic/SourceManager.cpp +++ b/clang/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/clang/Driver/PrintPreprocessedOutput.cpp b/clang/Driver/PrintPreprocessedOutput.cpp index 3eb11b719cf8..1cfadb35aa3d 100644 --- a/clang/Driver/PrintPreprocessedOutput.cpp +++ b/clang/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)