]> git.lizzy.rs Git - rust.git/commitdiff
std: Move a plattform-specific constant to sys::stdio
authorBrian Anderson <banderson@mozilla.com>
Fri, 30 Sep 2016 21:01:53 +0000 (21:01 +0000)
committerBrian Anderson <banderson@mozilla.com>
Tue, 1 Nov 2016 17:08:24 +0000 (17:08 +0000)
src/libstd/io/mod.rs
src/libstd/io/stdio.rs
src/libstd/sys/common/io.rs
src/libstd/sys/unix/stdio.rs
src/libstd/sys/windows/stdio.rs
src/tools/tidy/src/pal.rs

index 37c3f70d54dda7df4236b5adf418f8ffa0d11cbc..193f396c0d4ab3a3d6a0fb0bbab3401effba48a9 100644 (file)
 mod util;
 mod stdio;
 
-const DEFAULT_BUF_SIZE: usize = 8 * 1024;
+const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE;
 
 // A few methods below (read_to_string, read_line) will append data into a
 // `String` buffer, but we need to be pretty careful when doing this. The
index c24ee8ff303c875530d976f01708a7d8e75cd3d9..1777b79ea1b59b422ed23c5f35e3ac0db1c7d241 100644 (file)
@@ -214,15 +214,7 @@ fn stdin_init() -> Arc<Mutex<BufReader<Maybe<StdinRaw>>>> {
             _ => Maybe::Fake
         };
 
-        // The default buffer capacity is 64k, but apparently windows
-        // doesn't like 64k reads on stdin. See #13304 for details, but the
-        // idea is that on windows we use a slightly smaller buffer that's
-        // been seen to be acceptable.
-        Arc::new(Mutex::new(if cfg!(windows) {
-            BufReader::with_capacity(8 * 1024, stdin)
-        } else {
-            BufReader::new(stdin)
-        }))
+        Arc::new(Mutex::new(BufReader::with_capacity(stdio::STDIN_BUF_SIZE, stdin)))
     }
 }
 
index 0483725dd83bc22631aec0f0bc15a988e7ddd8f2..23daeeb5187b7f75551ed3ea4612cdf194c715a4 100644 (file)
@@ -12,6 +12,8 @@
 use io::Read;
 use slice::from_raw_parts_mut;
 
+pub const DEFAULT_BUF_SIZE: usize = 8 * 1024;
+
 // Provides read_to_end functionality over an uninitialized buffer.
 // This function is unsafe because it calls the underlying
 // read function with a slice into uninitialized memory. The default
index 947ba2cc75232a72fdb8f0b6440c87445f55b837..273341b1918d1c0e6c42200b0b97b238fd9ff3d1 100644 (file)
@@ -67,3 +67,4 @@ fn flush(&mut self) -> io::Result<()> { Ok(()) }
 }
 
 pub const EBADF_ERR: i32 = ::libc::EBADF as i32;
+pub const STDIN_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE;
index 5f097d2631d9558c5e1129109aa19a85b898c71e..72788776dedd6ebdf4f60143e9774334c6860cc1 100644 (file)
@@ -207,3 +207,8 @@ fn invalid_encoding() -> io::Error {
 }
 
 pub const EBADF_ERR: i32 = ::sys::c::ERROR_INVALID_HANDLE as i32;
+// The default buffer capacity is 64k, but apparently windows
+// doesn't like 64k reads on stdin. See #13304 for details, but the
+// idea is that on windows we use a slightly smaller buffer that's
+// been seen to be acceptable.
+pub const STDIN_BUF_SIZE: usize = 8 * 1024;
index 80a2d22691b8b4880eb865b4e92bee2fb7c55f51..6ce5f7ee7fe274672cc3f10d24e5ceac579418ed 100644 (file)
@@ -66,7 +66,6 @@
     "src/libstd/lib.rs", // This could probably be done within the sys directory
     "src/libstd/rtdeps.rs", // Until rustbuild replaces make
     "src/libstd/path.rs",
-    "src/libstd/io/stdio.rs",
     "src/libstd/num/f32.rs",
     "src/libstd/num/f64.rs",
     "src/libstd/sys/common/mod.rs",