diff options
author | dim <dim@FreeBSD.org> | 2016-01-06 20:01:02 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2016-01-06 20:01:02 +0000 |
commit | ff2ba393a56d9d99dcb76ceada542233db28af9a (patch) | |
tree | ea70b740d40cffe568a990c7aecd1acb5f83f786 /lib/Support/raw_ostream.cpp | |
parent | 7c35321d839f2c4d0fc8510bfbd8954b07908b76 (diff) | |
download | FreeBSD-src-ff2ba393a56d9d99dcb76ceada542233db28af9a.zip FreeBSD-src-ff2ba393a56d9d99dcb76ceada542233db28af9a.tar.gz |
Vendor import of llvm trunk r256945:
https://llvm.org/svn/llvm-project/llvm/trunk@256945
Diffstat (limited to 'lib/Support/raw_ostream.cpp')
-rw-r--r-- | lib/Support/raw_ostream.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp index 57c7ac3..57162dc 100644 --- a/lib/Support/raw_ostream.cpp +++ b/lib/Support/raw_ostream.cpp @@ -57,6 +57,10 @@ #endif #endif +#ifdef LLVM_ON_WIN32 +#include "Windows/WindowsSupport.h" +#endif + using namespace llvm; raw_ostream::~raw_ostream() { @@ -567,8 +571,21 @@ void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) { assert(FD >= 0 && "File already closed."); pos += Size; +#ifndef LLVM_ON_WIN32 + bool ShouldWriteInChunks = false; +#else + // Writing a large size of output to Windows console returns ENOMEM. It seems + // that, prior to Windows 8, WriteFile() is redirecting to WriteConsole(), and + // the latter has a size limit (66000 bytes or less, depending on heap usage). + bool ShouldWriteInChunks = !!::_isatty(FD) && !IsWindows8OrGreater(); +#endif + do { - ssize_t ret = ::write(FD, Ptr, Size); + size_t ChunkSize = Size; + if (ChunkSize > 32767 && ShouldWriteInChunks) + ChunkSize = 32767; + + ssize_t ret = ::write(FD, Ptr, ChunkSize); if (ret < 0) { // If it's a recoverable error, swallow it and retry the write. |