about summary refs log tree commit diff
path: root/src/libterm
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-11-02 16:23:22 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-11-09 22:55:50 -0800
commit3d28b8b98e6e4f55ef4ecd8babf0a050f48a3d11 (patch)
tree343087c9e62da65e2780db851682280697064c5b /src/libterm
parentc8a29c2092cec369a751051a2bfed093522ff6e8 (diff)
downloadrust-3d28b8b98e6e4f55ef4ecd8babf0a050f48a3d11.tar.gz
rust-3d28b8b98e6e4f55ef4ecd8babf0a050f48a3d11.zip
std: Migrate to the new libc
* Delete `sys::unix::{c, sync}` as these are now all folded into libc itself
* Update all references to use `libc` as a result.
* Update all references to the new flat namespace.
* Moves all windows bindings into sys::c
Diffstat (limited to 'src/libterm')
-rw-r--r--src/libterm/win.rs21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/libterm/win.rs b/src/libterm/win.rs
index 66ef5e86617..28ddc567938 100644
--- a/src/libterm/win.rs
+++ b/src/libterm/win.rs
@@ -30,12 +30,17 @@ pub struct WinConsole<T> {
     background: color::Color,
 }
 
+type WORD = u16;
+type DWORD = u32;
+type BOOL = i32;
+type HANDLE = *mut u8;
+
 #[allow(non_snake_case)]
 #[repr(C)]
 struct CONSOLE_SCREEN_BUFFER_INFO {
     dwSize: [libc::c_short; 2],
     dwCursorPosition: [libc::c_short; 2],
-    wAttributes: libc::WORD,
+    wAttributes: WORD,
     srWindow: [libc::c_short; 4],
     dwMaximumWindowSize: [libc::c_short; 2],
 }
@@ -43,10 +48,10 @@ struct CONSOLE_SCREEN_BUFFER_INFO {
 #[allow(non_snake_case)]
 #[link(name = "kernel32")]
 extern "system" {
-    fn SetConsoleTextAttribute(handle: libc::HANDLE, attr: libc::WORD) -> libc::BOOL;
-    fn GetStdHandle(which: libc::DWORD) -> libc::HANDLE;
-    fn GetConsoleScreenBufferInfo(handle: libc::HANDLE,
-                                  info: *mut CONSOLE_SCREEN_BUFFER_INFO) -> libc::BOOL;
+    fn SetConsoleTextAttribute(handle: HANDLE, attr: WORD) -> BOOL;
+    fn GetStdHandle(which: DWORD) -> HANDLE;
+    fn GetConsoleScreenBufferInfo(handle: HANDLE,
+                                  info: *mut CONSOLE_SCREEN_BUFFER_INFO) -> BOOL;
 }
 
 fn color_to_bits(color: color::Color) -> u16 {
@@ -90,7 +95,7 @@ fn bits_to_color(bits: u16) -> color::Color {
 impl<T: Write+Send+'static> WinConsole<T> {
     fn apply(&mut self) {
         let _unused = self.buf.flush();
-        let mut accum: libc::WORD = 0;
+        let mut accum: WORD = 0;
         accum |= color_to_bits(self.foreground);
         accum |= color_to_bits(self.background) << 4;
 
@@ -104,7 +109,7 @@ impl<T: Write+Send+'static> WinConsole<T> {
             // terminal! Admittedly, this is fragile, since stderr could be
             // redirected to a different console. This is good enough for
             // rustc though. See #13400.
-            let out = GetStdHandle(-11i32 as libc::DWORD);
+            let out = GetStdHandle(-11i32 as DWORD);
             SetConsoleTextAttribute(out, accum);
         }
     }
@@ -116,7 +121,7 @@ impl<T: Write+Send+'static> WinConsole<T> {
         let bg;
         unsafe {
             let mut buffer_info = ::std::mem::uninitialized();
-            if GetConsoleScreenBufferInfo(GetStdHandle(-11i32 as libc::DWORD),
+            if GetConsoleScreenBufferInfo(GetStdHandle(-11i32 as DWORD),
                                           &mut buffer_info) != 0 {
                 fg = bits_to_color(buffer_info.wAttributes);
                 bg = bits_to_color(buffer_info.wAttributes >> 4);