From 1d0bba8224686d054378bcc4e853798d56fdfecf Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 28 Nov 2016 18:25:47 -0700 Subject: [PATCH] Move stdout/err flush into sys --- src/libstd/io/stdio.rs | 6 ------ src/libstd/sys/redox/stdio.rs | 2 +- src/libstd/sys/unix/stdio.rs | 13 ++++++++++++- src/libstd/sys/windows/stdio.rs | 13 ++++++++++++- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index f6ee0be47fad..6419a9ff683d 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -81,16 +81,10 @@ impl Read for StdinRaw { } impl Write for StdoutRaw { fn write(&mut self, buf: &[u8]) -> io::Result { self.0.write(buf) } - #[cfg(not(target_os = "redox"))] - fn flush(&mut self) -> io::Result<()> { Ok(()) } - #[cfg(target_os = "redox")] fn flush(&mut self) -> io::Result<()> { self.0.flush() } } impl Write for StderrRaw { fn write(&mut self, buf: &[u8]) -> io::Result { self.0.write(buf) } - #[cfg(not(target_os = "redox"))] - fn flush(&mut self) -> io::Result<()> { Ok(()) } - #[cfg(target_os = "redox")] fn flush(&mut self) -> io::Result<()> { self.0.flush() } } diff --git a/src/libstd/sys/redox/stdio.rs b/src/libstd/sys/redox/stdio.rs index 1fe7e33a35ec..aa8329bc2838 100644 --- a/src/libstd/sys/redox/stdio.rs +++ b/src/libstd/sys/redox/stdio.rs @@ -73,7 +73,7 @@ impl io::Write for Stderr { } fn flush(&mut self) -> io::Result<()> { - cvt(syscall::fsync(2)).and(Ok(())) + Stderr::flush(self) } } diff --git a/src/libstd/sys/unix/stdio.rs b/src/libstd/sys/unix/stdio.rs index 273341b1918d..1002c60d3033 100644 --- a/src/libstd/sys/unix/stdio.rs +++ b/src/libstd/sys/unix/stdio.rs @@ -43,6 +43,10 @@ impl Stdout { fd.into_raw(); ret } + + pub fn flush(&self) -> io::Result<()> { + Ok(()) + } } impl Stderr { @@ -54,6 +58,10 @@ impl Stderr { fd.into_raw(); ret } + + pub fn flush(&self) -> io::Result<()> { + Ok(()) + } } // FIXME: right now this raw stderr handle is used in a few places because @@ -63,7 +71,10 @@ impl io::Write for Stderr { fn write(&mut self, data: &[u8]) -> io::Result { Stderr::write(self, data) } - fn flush(&mut self) -> io::Result<()> { Ok(()) } + + fn flush(&mut self) -> io::Result<()> { + Stderr::flush(self) + } } pub const EBADF_ERR: i32 = ::libc::EBADF as i32; diff --git a/src/libstd/sys/windows/stdio.rs b/src/libstd/sys/windows/stdio.rs index 72788776dedd..0d58da29323e 100644 --- a/src/libstd/sys/windows/stdio.rs +++ b/src/libstd/sys/windows/stdio.rs @@ -156,6 +156,10 @@ impl Stdout { pub fn write(&self, data: &[u8]) -> io::Result { write(&self.0, data) } + + pub fn flush(&self) -> io::Result<()> { + Ok(()) + } } impl Stderr { @@ -166,6 +170,10 @@ impl Stderr { pub fn write(&self, data: &[u8]) -> io::Result { write(&self.0, data) } + + pub fn flush(&self) -> io::Result<()> { + Ok(()) + } } // FIXME: right now this raw stderr handle is used in a few places because @@ -175,7 +183,10 @@ impl io::Write for Stderr { fn write(&mut self, data: &[u8]) -> io::Result { Stderr::write(self, data) } - fn flush(&mut self) -> io::Result<()> { Ok(()) } + + fn flush(&mut self) -> io::Result<()> { + Stderr::flush(self) + } } impl NoClose {