]> granicus.if.org Git - clang/commitdiff
Add #ifdefs to make the source portable to windows. Patch contributed
authorChris Lattner <sabre@nondot.org>
Mon, 3 Sep 2007 18:24:56 +0000 (18:24 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 3 Sep 2007 18:24:56 +0000 (18:24 +0000)
by Hartmut Kaiser!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41684 91177308-0d34-0410-b5e6-96231b3b80d8

Basic/SourceManager.cpp
Driver/PrintPreprocessedOutput.cpp

index 96da7634511cdeafd3ee0c9612debd11f819f20a..569c864dde7fd5314f73e65c00ea50a757daa002 100644 (file)
@@ -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;
index 3eb11b719cf89dc8bd0256158cffe951727ba421..1cfadb35aa3dcc6181aa476ade7c8e6b31df6941 100644 (file)
@@ -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)