Skip to content

Commit 1d0bba8

Browse files
committed
Move stdout/err flush into sys
1 parent 2ec2132 commit 1d0bba8

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

src/libstd/io/stdio.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,10 @@ impl Read for StdinRaw {
8181
}
8282
impl Write for StdoutRaw {
8383
fn write(&mut self, buf: &[u8]) -> io::Result<usize> { self.0.write(buf) }
84-
#[cfg(not(target_os = "redox"))]
85-
fn flush(&mut self) -> io::Result<()> { Ok(()) }
86-
#[cfg(target_os = "redox")]
8784
fn flush(&mut self) -> io::Result<()> { self.0.flush() }
8885
}
8986
impl Write for StderrRaw {
9087
fn write(&mut self, buf: &[u8]) -> io::Result<usize> { self.0.write(buf) }
91-
#[cfg(not(target_os = "redox"))]
92-
fn flush(&mut self) -> io::Result<()> { Ok(()) }
93-
#[cfg(target_os = "redox")]
9488
fn flush(&mut self) -> io::Result<()> { self.0.flush() }
9589
}
9690

src/libstd/sys/redox/stdio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl io::Write for Stderr {
7373
}
7474

7575
fn flush(&mut self) -> io::Result<()> {
76-
cvt(syscall::fsync(2)).and(Ok(()))
76+
Stderr::flush(self)
7777
}
7878
}
7979

src/libstd/sys/unix/stdio.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ impl Stdout {
4343
fd.into_raw();
4444
ret
4545
}
46+
47+
pub fn flush(&self) -> io::Result<()> {
48+
Ok(())
49+
}
4650
}
4751

4852
impl Stderr {
@@ -54,6 +58,10 @@ impl Stderr {
5458
fd.into_raw();
5559
ret
5660
}
61+
62+
pub fn flush(&self) -> io::Result<()> {
63+
Ok(())
64+
}
5765
}
5866

5967
// FIXME: right now this raw stderr handle is used in a few places because
@@ -63,7 +71,10 @@ impl io::Write for Stderr {
6371
fn write(&mut self, data: &[u8]) -> io::Result<usize> {
6472
Stderr::write(self, data)
6573
}
66-
fn flush(&mut self) -> io::Result<()> { Ok(()) }
74+
75+
fn flush(&mut self) -> io::Result<()> {
76+
Stderr::flush(self)
77+
}
6778
}
6879

6980
pub const EBADF_ERR: i32 = ::libc::EBADF as i32;

src/libstd/sys/windows/stdio.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ impl Stdout {
156156
pub fn write(&self, data: &[u8]) -> io::Result<usize> {
157157
write(&self.0, data)
158158
}
159+
160+
pub fn flush(&self) -> io::Result<()> {
161+
Ok(())
162+
}
159163
}
160164

161165
impl Stderr {
@@ -166,6 +170,10 @@ impl Stderr {
166170
pub fn write(&self, data: &[u8]) -> io::Result<usize> {
167171
write(&self.0, data)
168172
}
173+
174+
pub fn flush(&self) -> io::Result<()> {
175+
Ok(())
176+
}
169177
}
170178

171179
// FIXME: right now this raw stderr handle is used in a few places because
@@ -175,7 +183,10 @@ impl io::Write for Stderr {
175183
fn write(&mut self, data: &[u8]) -> io::Result<usize> {
176184
Stderr::write(self, data)
177185
}
178-
fn flush(&mut self) -> io::Result<()> { Ok(()) }
186+
187+
fn flush(&mut self) -> io::Result<()> {
188+
Stderr::flush(self)
189+
}
179190
}
180191

181192
impl NoClose {

0 commit comments

Comments
 (0)