[llvm] r234619 - Remember if lseek works in this FD.
Rafael Espindola
rafael.espindola at gmail.com
Fri Apr 10 11:15:52 PDT 2015
Author: rafael
Date: Fri Apr 10 13:15:51 2015
New Revision: 234619
URL: http://llvm.org/viewvc/llvm-project?rev=234619&view=rev
Log:
Remember if lseek works in this FD.
It will be used in clang in a sec.
Modified:
llvm/trunk/include/llvm/Support/raw_ostream.h
llvm/trunk/lib/Support/raw_ostream.cpp
Modified: llvm/trunk/include/llvm/Support/raw_ostream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/raw_ostream.h?rev=234619&r1=234618&r2=234619&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/raw_ostream.h (original)
+++ llvm/trunk/include/llvm/Support/raw_ostream.h Fri Apr 10 13:15:51 2015
@@ -333,6 +333,8 @@ class raw_fd_ostream : public raw_ostrea
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);
Modified: llvm/trunk/lib/Support/raw_ostream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=234619&r1=234618&r2=234619&view=diff
==============================================================================
--- llvm/trunk/lib/Support/raw_ostream.cpp (original)
+++ llvm/trunk/lib/Support/raw_ostream.cpp Fri Apr 10 13:15:51 2015
@@ -525,7 +525,8 @@ raw_fd_ostream::raw_fd_ostream(int fd, b
// 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);
More information about the llvm-commits
mailing list