[cfe-commits] r41684 - in /cfe/trunk: Basic/SourceManager.cpp Driver/PrintPreprocessedOutput.cpp
Chris Lattner
sabre at nondot.org
Mon Sep 3 11:24:56 PDT 2007
Author: lattner
Date: Mon Sep 3 13:24:56 2007
New Revision: 41684
URL: http://llvm.org/viewvc/llvm-project?rev=41684&view=rev
Log:
Add #ifdefs to make the source portable to windows. Patch contributed
by Hartmut Kaiser!
Modified:
cfe/trunk/Basic/SourceManager.cpp
cfe/trunk/Driver/PrintPreprocessedOutput.cpp
Modified: cfe/trunk/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/SourceManager.cpp?rev=41684&r1=41683&r2=41684&view=diff
==============================================================================
--- cfe/trunk/Basic/SourceManager.cpp (original)
+++ cfe/trunk/Basic/SourceManager.cpp Mon Sep 3 13:24:56 2007
@@ -41,8 +41,12 @@
// 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 @@
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;
Modified: cfe/trunk/Driver/PrintPreprocessedOutput.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/PrintPreprocessedOutput.cpp?rev=41684&r1=41683&r2=41684&view=diff
==============================================================================
--- cfe/trunk/Driver/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/Driver/PrintPreprocessedOutput.cpp Mon Sep 3 13:24:56 2007
@@ -73,7 +73,9 @@
}
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)
More information about the cfe-commits
mailing list