<html><head></head><body bgcolor="#FFFFFF"><div>Thanks, will fix shortly.<br><br><div> - Daniel</div><div><br></div></div><div><br>On Nov 6, 2012, at 0:42, Alexey Samsonov <<a href="mailto:samsonov@google.com">samsonov@google.com</a>> wrote:<br>
<br></div><div></div><blockquote type="cite"><div><div style="font-family:arial,helvetica,sans-serif;font-size:10pt">This change breaks our Windows buildbot:<div><br></div><div><pre><span class="stdout" style="font-family:'Courier New',courier,monotype">1>Compiling...
1>MemoryBuffer.cpp
1>..\..\..\llvm\lib\Support\MemoryBuffer.cpp(324) : error C2065: 'S_IFIFO' : undeclared identifier</span></pre><br><div class="gmail_quote">On Tue, Nov 6, 2012 at 1:55 AM, Daniel Dunbar <span dir="ltr"><<a href="mailto:daniel@zuster.org" target="_blank">daniel@zuster.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ddunbar<br>
Date: Mon Nov  5 15:55:40 2012<br>
New Revision: 167407<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=167407&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=167407&view=rev</a><br>
Log:<br>
MemoryBuffer: Support reading named pipes in getFile().<br>
<br>
 - We only support this when the client didn't claim to know the file size.<br>
<br>
Modified:<br>
    llvm/trunk/lib/Support/MemoryBuffer.cpp<br>
<br>
Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=167407&r1=167406&r2=167407&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=167407&r1=167406&r2=167407&view=diff</a><br>


==============================================================================<br>
--- llvm/trunk/lib/Support/MemoryBuffer.cpp (original)<br>
+++ llvm/trunk/lib/Support/MemoryBuffer.cpp Mon Nov  5 15:55:40 2012<br>
@@ -201,6 +201,27 @@<br>
 };<br>
 }<br>
<br>
+static error_code getMemoryBufferForStream(int FD,<br>
+                                           StringRef BufferName,<br>
+                                           OwningPtr<MemoryBuffer> &result) {<br>
+  const ssize_t ChunkSize = 4096*4;<br>
+  SmallString<ChunkSize> Buffer;<br>
+  ssize_t ReadBytes;<br>
+  // Read into Buffer until we hit EOF.<br>
+  do {<br>
+    Buffer.reserve(Buffer.size() + ChunkSize);<br>
+    ReadBytes = read(FD, Buffer.end(), ChunkSize);<br>
+    if (ReadBytes == -1) {<br>
+      if (errno == EINTR) continue;<br>
+      return error_code(errno, posix_category());<br>
+    }<br>
+    Buffer.set_size(Buffer.size() + ReadBytes);<br>
+  } while (ReadBytes != 0);<br>
+<br>
+  result.reset(MemoryBuffer::getMemBufferCopy(Buffer, BufferName));<br>
+  return error_code::success();<br>
+}<br>
+<br>
 error_code MemoryBuffer::getFile(StringRef Filename,<br>
                                  OwningPtr<MemoryBuffer> &result,<br>
                                  int64_t FileSize,<br>
@@ -297,6 +318,13 @@<br>
       if (fstat(FD, &FileInfo) == -1) {<br>
         return error_code(errno, posix_category());<br>
       }<br>
+<br>
+      // If this is a named pipe, we can't trust the size. Create the memory<br>
+      // buffer by copying off the stream.<br>
+      if (FileInfo.st_mode & S_IFIFO) {<br>
+        return getMemoryBufferForStream(FD, Filename, result);<br>
+      }<br>
+<br>
       FileSize = FileInfo.st_size;<br>
     }<br>
     MapSize = FileSize;<br>
@@ -370,20 +398,5 @@<br>
   // fallback if it fails.<br>
   sys::Program::ChangeStdinToBinary();<br>
<br>
-  const ssize_t ChunkSize = 4096*4;<br>
-  SmallString<ChunkSize> Buffer;<br>
-  ssize_t ReadBytes;<br>
-  // Read into Buffer until we hit EOF.<br>
-  do {<br>
-    Buffer.reserve(Buffer.size() + ChunkSize);<br>
-    ReadBytes = read(0, Buffer.end(), ChunkSize);<br>
-    if (ReadBytes == -1) {<br>
-      if (errno == EINTR) continue;<br>
-      return error_code(errno, posix_category());<br>
-    }<br>
-    Buffer.set_size(Buffer.size() + ReadBytes);<br>
-  } while (ReadBytes != 0);<br>
-<br>
-  result.reset(getMemBufferCopy(Buffer, "<stdin>"));<br>
-  return error_code::success();<br>
+  return getMemoryBufferForStream(0, "<stdin>", result);<br>
 }<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Alexey Samsonov, MSK</div><br>
</div></div>
</div></blockquote></body></html>