summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-04-10 18:15:51 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-04-10 18:15:51 +0000
commit74d2f617f20f3dcd7b160e569bdcbd7ba12312c9 (patch)
treeb86c4646c8e7dcb098e0622ceb143895d12db877 /llvm
parent5522d815eb014b97bd734968848016eee4cffa37 (diff)
downloadbcm5719-llvm-74d2f617f20f3dcd7b160e569bdcbd7ba12312c9.tar.gz
bcm5719-llvm-74d2f617f20f3dcd7b160e569bdcbd7ba12312c9.zip
Remember if lseek works in this FD.
It will be used in clang in a sec. llvm-svn: 234619
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Support/raw_ostream.h4
-rw-r--r--llvm/lib/Support/raw_ostream.cpp3
2 files changed, 6 insertions, 1 deletions
diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h
index 6b0bde73db6..c378fa95763 100644
--- a/llvm/include/llvm/Support/raw_ostream.h
+++ b/llvm/include/llvm/Support/raw_ostream.h
@@ -333,6 +333,8 @@ class raw_fd_ostream : public raw_ostream {
uint64_t pos;
+ bool SupportsSeeking;
+
/// See raw_ostream::write_impl.
void write_impl(const char *Ptr, size_t Size) override;
@@ -370,6 +372,8 @@ public:
/// fsync.
void close();
+ bool supportsSeeking() { return SupportsSeeking; }
+
/// Flushes the stream and repositions the underlying file descriptor position
/// to the offset specified from the beginning of the file.
uint64_t seek(uint64_t off);
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index b7e9ba616d5..199f0a6185b 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/lib/Support/raw_ostream.cpp
@@ -525,7 +525,8 @@ raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered)
// Get the starting position.
off_t loc = ::lseek(FD, 0, SEEK_CUR);
- if (loc == (off_t)-1)
+ SupportsSeeking = loc != (off_t)-1;
+ if (!SupportsSeeking)
pos = 0;
else
pos = static_cast<uint64_t>(loc);
OpenPOWER on IntegriCloud