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 #include +#if !defined(_MSC_VER) #include #include +#else +#include +#endif #include 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(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)