///
bool Error;
- /// Controls whether the stream should attempt to use atomic writes, when
- /// possible.
- bool UseAtomicWrites;
-
uint64_t pos;
bool SupportsSeeking;
/// to the offset specified from the beginning of the file.
uint64_t seek(uint64_t off);
- /// Set the stream to attempt to use atomic writes for individual output
- /// routines where possible.
- ///
- /// Note that because raw_ostream's are typically buffered, this flag is only
- /// sensible when used on unbuffered streams which will flush their output
- /// immediately.
- void SetUseAtomicWrites(bool Value) {
- UseAtomicWrites = Value;
- }
-
raw_ostream &changeColor(enum Colors colors, bool bold=false,
bool bg=false) override;
raw_ostream &resetColor() override;
/// closes the file when the stream is destroyed.
raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered)
: raw_pwrite_stream(unbuffered), FD(fd), ShouldClose(shouldClose),
- Error(false), UseAtomicWrites(false) {
+ Error(false) {
if (FD < 0 ) {
ShouldClose = false;
return;
pos += Size;
do {
- ssize_t ret;
-
- // Check whether we should attempt to use atomic writes.
- if (LLVM_LIKELY(!UseAtomicWrites)) {
- ret = ::write(FD, Ptr, Size);
- } else {
- // Use ::writev() where available.
-#if defined(HAVE_WRITEV)
- const void *Addr = static_cast<const void *>(Ptr);
- struct iovec IOV = {const_cast<void *>(Addr), Size };
- ret = ::writev(FD, &IOV, 1);
-#else
- ret = ::write(FD, Ptr, Size);
-#endif
- }
+ ssize_t ret = ::write(FD, Ptr, Size);
if (ret < 0) {
// If it's a recoverable error, swallow it and retry the write.