diff --git a/llvm/lib/Bytecode/Reader/ReaderWrappers.cpp b/llvm/lib/Bytecode/Reader/ReaderWrappers.cpp
index c799567a4a6c62a7a7fe71a6df74ef19b4dec496..9b8491327fa41a1287798c3854fa4c2793b387ce 100644
--- a/llvm/lib/Bytecode/Reader/ReaderWrappers.cpp
+++ b/llvm/lib/Bytecode/Reader/ReaderWrappers.cpp
@@ -20,6 +20,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/System/MappedFile.h"
 #include <cerrno>
+#include <iostream>
 using namespace llvm;
 
 //===----------------------------------------------------------------------===//
@@ -41,10 +42,6 @@ namespace {
   };
 }
 
-static std::string ErrnoMessage (int savedErrNum, std::string descr) {
-   return ::strerror(savedErrNum) + std::string(", while trying to ") + descr;
-}
-
 BytecodeFileReader::BytecodeFileReader(const std::string &Filename,
                                        llvm::BytecodeHandler* H ) 
   : BytecodeReader(H)
@@ -133,14 +130,14 @@ namespace {
 BytecodeStdinReader::BytecodeStdinReader( BytecodeHandler* H ) 
   : BytecodeReader(H)
 {
-  int BlockSize;
-  unsigned char Buffer[4096*4];
+  char Buffer[4096*4];
 
   // Read in all of the data from stdin, we cannot mmap stdin...
-  while ((BlockSize = ::read(0 /*stdin*/, Buffer, 4096*4))) {
-    if (BlockSize == -1)
-      throw ErrnoMessage(errno, "read from standard input");
-    
+  while (std::cin.good()) {
+    std::cin.read(Buffer, 4096*4);
+    int BlockSize = std::cin.gcount();
+    if (0 >= BlockSize)
+      break;
     FileData.insert(FileData.end(), Buffer, Buffer+BlockSize);
   }