Add #ifdefs to make the source portable to windows. Patch contributed

by Hartmut Kaiser!

llvm-svn: 41684
This commit is contained in:
Chris Lattner 2007-09-03 18:24:56 +00:00
parent 4d37b81df9
commit cd1e8d2c9d
2 changed files with 12 additions and 2 deletions

View File

@ -41,8 +41,12 @@ SourceManager::~SourceManager() {
// FIXME: REMOVE THESE // FIXME: REMOVE THESE
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#if !defined(_MSC_VER)
#include <sys/uio.h> #include <sys/uio.h>
#include <sys/fcntl.h> #include <sys/fcntl.h>
#else
#include <io.h>
#endif
#include <cerrno> #include <cerrno>
static const MemoryBuffer *ReadFileFast(const FileEntry *FileEnt) { static const MemoryBuffer *ReadFileFast(const FileEntry *FileEnt) {
@ -61,8 +65,12 @@ static const MemoryBuffer *ReadFileFast(const FileEntry *FileEnt) {
MemoryBuffer *SB = MemoryBuffer::getNewUninitMemBuffer(FileEnt->getSize(), MemoryBuffer *SB = MemoryBuffer::getNewUninitMemBuffer(FileEnt->getSize(),
FileEnt->getName()); FileEnt->getName());
char *BufPtr = const_cast<char*>(SB->getBufferStart()); 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); int FD = ::open(FileEnt->getName(), O_RDONLY);
#endif
if (FD == -1) { if (FD == -1) {
delete SB; delete SB;
return 0; return 0;

View File

@ -73,7 +73,9 @@ static void CleanupOutputBuffer() {
} }
static void OutputChar(char c) { static void OutputChar(char c) {
#ifdef USE_STDIO #if defined(_MSC_VER)
putchar(c);
#elif defined(USE_STDIO)
putchar_unlocked(c); putchar_unlocked(c);
#else #else
if (OutBufCur >= OutBufEnd) if (OutBufCur >= OutBufEnd)