projects
/
oota-llvm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[X86][Haswell][SchedModel] Add architecture specific scheduling models.
[oota-llvm.git]
/
lib
/
Support
/
DataStream.cpp
diff --git
a/lib/Support/DataStream.cpp
b/lib/Support/DataStream.cpp
index fa8edc729c95c2384478f0d0f03e442ae8dd6cfc..32653de5194383549de9bb6b88b427383cca9f1f 100644
(file)
--- a/
lib/Support/DataStream.cpp
+++ b/
lib/Support/DataStream.cpp
@@
-1,4
+1,4
@@
-//===--- llvm/Support/DataStream.cpp - Lazy streamed
Data
---===//
+//===--- llvm/Support/DataStream.cpp - Lazy streamed
data --------------
---===//
//
// The LLVM Compiler Infrastructure
//
//
// The LLVM Compiler Infrastructure
//
@@
-14,21
+14,23
@@
//
//===----------------------------------------------------------------------===//
//
//===----------------------------------------------------------------------===//
-#define DEBUG_TYPE "Data-stream"
-#include "llvm/ADT/Statistic.h"
#include "llvm/Support/DataStream.h"
#include "llvm/Support/DataStream.h"
-#include "llvm/Support/system_error.h"
-#include <string>
+#include "llvm/ADT/Statistic.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Program.h"
#include <cerrno>
#include <cstdio>
#include <cerrno>
#include <cstdio>
+#include <string>
+#include <system_error>
#if !defined(_MSC_VER) && !defined(__MINGW32__)
#include <unistd.h>
#else
#include <io.h>
#endif
#if !defined(_MSC_VER) && !defined(__MINGW32__)
#include <unistd.h>
#else
#include <io.h>
#endif
-#include <fcntl.h>
using namespace llvm;
using namespace llvm;
+#define DEBUG_TYPE "Data-stream"
+
// Interface goals:
// * StreamableMemoryObject doesn't care about complexities like using
// threads/async callbacks to actually overlap download+compile
// Interface goals:
// * StreamableMemoryObject doesn't care about complexities like using
// threads/async callbacks to actually overlap download+compile
@@
-48,8
+50,6
@@
DataStreamer::~DataStreamer() {}
namespace {
namespace {
-const static error_code success;
-
// Very simple stream backed by a file. Mostly useful for stdin and debugging;
// actual file access is probably still best done with mmap.
class DataFileStreamer : public DataStreamer {
// Very simple stream backed by a file. Mostly useful for stdin and debugging;
// actual file access is probably still best done with mmap.
class DataFileStreamer : public DataStreamer {
@@
-59,22
+59,19
@@
public:
virtual ~DataFileStreamer() {
close(Fd);
}
virtual ~DataFileStreamer() {
close(Fd);
}
-
virtual size_t GetBytes(unsigned char *buf, size_t len)
{
+
size_t GetBytes(unsigned char *buf, size_t len) override
{
NumStreamFetches++;
return read(Fd, buf, len);
}
NumStreamFetches++;
return read(Fd, buf, len);
}
- error_code OpenFile(const std::string &Filename) {
- int OpenFlags = O_RDONLY;
-#ifdef O_BINARY
- OpenFlags |= O_BINARY; // Open input file in binary mode on win32.
-#endif
- if (Filename == "-")
+ std::error_code OpenFile(const std::string &Filename) {
+ if (Filename == "-") {
Fd = 0;
Fd = 0;
- else
- Fd = ::open(Filename.c_str(), OpenFlags);
- if (Fd == -1) return error_code(errno, posix_category());
- return success;
+ sys::ChangeStdinToBinary();
+ return std::error_code();
+ }
+
+ return sys::fs::openFileForRead(Filename, Fd);
}
};
}
};
@@
-84,11
+81,10
@@
namespace llvm {
DataStreamer *getDataFileStreamer(const std::string &Filename,
std::string *StrError) {
DataFileStreamer *s = new DataFileStreamer();
DataStreamer *getDataFileStreamer(const std::string &Filename,
std::string *StrError) {
DataFileStreamer *s = new DataFileStreamer();
- error_code e = s->OpenFile(Filename);
- if (e != success) {
+ if (std::error_code e = s->OpenFile(Filename)) {
*StrError = std::string("Could not open ") + Filename + ": " +
e.message() + "\n";
*StrError = std::string("Could not open ") + Filename + ": " +
e.message() + "\n";
- return
NULL
;
+ return
nullptr
;
}
return s;
}
}
return s;
}