]> git.lizzy.rs Git - rust.git/commitdiff
Fixed Win64 build
authorVadim Chugunov <vadimcn@gmail.com>
Wed, 19 Mar 2014 07:42:02 +0000 (00:42 -0700)
committerVadim Chugunov <vadimcn@gmail.com>
Wed, 23 Apr 2014 01:08:06 +0000 (18:08 -0700)
src/libgreen/macros.rs
src/librustuv/macros.rs
src/libstd/io/stdio.rs
src/libstd/rt/backtrace.rs
src/libstd/rt/mod.rs
src/libstd/rt/util.rs
src/libstd/unstable/mutex.rs

index d1d7a9e0c98da8c54fc5e09ebf8eb98d22baffee..34e29b06f76ccb2a16939a838b730dbf5c0791fe 100644 (file)
@@ -52,20 +52,9 @@ macro_rules! rtabort (
 
 pub fn dumb_println(args: &fmt::Arguments) {
     use std::io;
-    use libc;
+    use std::rt;
 
-    struct Stderr;
-    impl io::Writer for Stderr {
-        fn write(&mut self, data: &[u8]) -> io::IoResult<()> {
-            unsafe {
-                libc::write(libc::STDERR_FILENO,
-                            data.as_ptr() as *libc::c_void,
-                            data.len() as libc::size_t);
-            }
-            Ok(()) // just ignore the result
-        }
-    }
-    let mut w = Stderr;
+    let mut w = rt::Stderr;
     let _ = fmt::writeln(&mut w as &mut io::Writer, args);
 }
 
index df41adfafbece95382607dc298f661697d9f7077..8e827703cb2b8985de8a3b685ea6915dc86227cf 100644 (file)
@@ -29,19 +29,8 @@ macro_rules! uvdebug (
 
 pub fn dumb_println(args: &fmt::Arguments) {
     use std::io;
-    use libc;
+    use std::rt;
 
-    struct Stderr;
-    impl io::Writer for Stderr {
-        fn write(&mut self, data: &[u8]) -> io::IoResult<()> {
-            let _ = unsafe {
-                libc::write(libc::STDERR_FILENO,
-                            data.as_ptr() as *libc::c_void,
-                            data.len() as libc::size_t)
-            };
-            Ok(()) // just ignore the errors
-        }
-    }
-    let mut w = Stderr;
+    let mut w = rt::Stderr;
     let _ = fmt::writeln(&mut w as &mut io::Writer, args);
 }
index 96439439e7aefb9ca3ac2015d47ca3c34181a2fe..afef21e7c688f7c4e0eb73a9f67ee5fba2a08ce3 100644 (file)
@@ -27,7 +27,6 @@
 
 */
 
-use container::Container;
 use fmt;
 use io::{Reader, Writer, IoResult, IoError, OtherIoError,
          standard_error, EndOfFile, LineBufferedWriter, BufferedReader};
 use option::{Option, Some, None};
 use prelude::drop;
 use result::{Ok, Err};
+use rt;
 use rt::local::Local;
 use rt::rtio::{DontClose, IoFactory, LocalIo, RtioFileStream, RtioTTY};
 use rt::task::Task;
 use str::StrSlice;
-use slice::ImmutableVector;
 
 // And so begins the tale of acquiring a uv handle to a stdio stream on all
 // platforms in all situations. Our story begins by splitting the world into two
@@ -236,18 +235,7 @@ fn with_task_stdout(f: |&mut Writer| -> IoResult<()> ) {
         }
 
         None => {
-            struct Stdout;
-            impl Writer for Stdout {
-                fn write(&mut self, data: &[u8]) -> IoResult<()> {
-                    unsafe {
-                        libc::write(libc::STDOUT_FILENO,
-                                    data.as_ptr() as *libc::c_void,
-                                    data.len() as libc::size_t);
-                    }
-                    Ok(()) // just ignore the results
-                }
-            }
-            let mut io = Stdout;
+            let mut io = rt::Stdout;
             f(&mut io as &mut Writer)
         }
     };
index c3bf7a6d12a67bee1f69db6e58153d8765b4a6fe..85699cdfebc02a97691d06b764f06af333d64b56 100644 (file)
@@ -665,6 +665,89 @@ pub fn init_frame(frame: &mut super::STACKFRAME64,
         }
     }
 
+    #[cfg(target_arch = "x86_64")]
+    mod arch {
+        use libc::{c_longlong, c_ulonglong};
+        use libc::types::os::arch::extra::{WORD, DWORD, DWORDLONG};
+
+        pub struct CONTEXT {
+            P1Home: DWORDLONG,
+            P2Home: DWORDLONG,
+            P3Home: DWORDLONG,
+            P4Home: DWORDLONG,
+            P5Home: DWORDLONG,
+            P6Home: DWORDLONG,
+
+            ContextFlags: DWORD,
+            MxCsr: DWORD,
+
+            SegCs: WORD,
+            SegDs: WORD,
+            SegEs: WORD,
+            SegFs: WORD,
+            SegGs: WORD,
+            SegSs: WORD,
+            EFlags: DWORD,
+
+            Dr0: DWORDLONG,
+            Dr1: DWORDLONG,
+            Dr2: DWORDLONG,
+            Dr3: DWORDLONG,
+            Dr6: DWORDLONG,
+            Dr7: DWORDLONG,
+
+            Rax: DWORDLONG,
+            Rcx: DWORDLONG,
+            Rdx: DWORDLONG,
+            Rbx: DWORDLONG,
+            Rsp: DWORDLONG,
+            Rbp: DWORDLONG,
+            Rsi: DWORDLONG,
+            Rdi: DWORDLONG,
+            R8:  DWORDLONG,
+            R9:  DWORDLONG,
+            R10: DWORDLONG,
+            R11: DWORDLONG,
+            R12: DWORDLONG,
+            R13: DWORDLONG,
+            R14: DWORDLONG,
+            R15: DWORDLONG,
+
+            Rip: DWORDLONG,
+
+            FltSave: FLOATING_SAVE_AREA,
+
+            VectorRegister: [M128A, .. 26],
+            VectorControl: DWORDLONG,
+
+            DebugControl: DWORDLONG,
+            LastBranchToRip: DWORDLONG,
+            LastBranchFromRip: DWORDLONG,
+            LastExceptionToRip: DWORDLONG,
+            LastExceptionFromRip: DWORDLONG,
+        }
+
+        pub struct M128A {
+            Low:  c_ulonglong,
+            High: c_longlong
+        }
+
+        pub struct FLOATING_SAVE_AREA {
+            _Dummy: [u8, ..512] // FIXME: Fill this out
+        }
+
+        pub fn init_frame(frame: &mut super::STACKFRAME64,
+                          ctx: &CONTEXT) -> DWORD {
+            frame.AddrPC.Offset = ctx.Rip as u64;
+            frame.AddrPC.Mode = super::AddrModeFlat;
+            frame.AddrStack.Offset = ctx.Rsp as u64;
+            frame.AddrStack.Mode = super::AddrModeFlat;
+            frame.AddrFrame.Offset = ctx.Rbp as u64;
+            frame.AddrFrame.Mode = super::AddrModeFlat;
+            super::IMAGE_FILE_MACHINE_AMD64
+        }
+    }
+
     struct Cleanup {
         handle: libc::HANDLE,
         SymCleanup: SymCleanupFn,
index f4a4fd9ab2e9b34072e814b66b16a4da15f6b3b0..a61443d335acb7db046de3b002297cba55bafd91 100644 (file)
@@ -71,6 +71,8 @@
 // Export unwinding facilities used by the failure macros
 pub use self::unwind::{begin_unwind, begin_unwind_raw, begin_unwind_fmt};
 
+pub use self::util::{Stdio, Stdout, Stderr};
+
 // FIXME: these probably shouldn't be public...
 #[doc(hidden)]
 pub mod shouldnt_be_public {
index 4c208a64ddfcc147e5774bd49fd6c39ec75be47a..84284ca1faf52690f5d854e1664b740e2bd24a2d 100644 (file)
@@ -71,14 +71,22 @@ pub fn default_sched_threads() -> uint {
     }
 }
 
-pub struct Stderr;
+pub struct Stdio(libc::c_int);
 
-impl io::Writer for Stderr {
+pub static Stdout: Stdio = Stdio(libc::STDOUT_FILENO);
+pub static Stderr: Stdio = Stdio(libc::STDERR_FILENO);
+
+impl io::Writer for Stdio {
     fn write(&mut self, data: &[u8]) -> IoResult<()> {
+        #[cfg(unix)]
+        type WriteLen = libc::size_t;
+        #[cfg(windows)]
+        type WriteLen = libc::c_uint;
         unsafe {
-            libc::write(libc::STDERR_FILENO,
+            let Stdio(fd) = *self;
+            libc::write(fd,
                         data.as_ptr() as *libc::c_void,
-                        data.len() as libc::size_t);
+                        data.len() as WriteLen);
         }
         Ok(()) // yes, we're lying
     }
index c2db8ad9586ee4a90a83237cfd7efe7ebf00aa53..8faedcbd9edf97606ba835ba05aabfc53b68941e 100644 (file)
@@ -444,6 +444,8 @@ mod imp {
     static SPIN_COUNT: DWORD = 4000;
     #[cfg(target_arch = "x86")]
     static CRIT_SECTION_SIZE: uint = 24;
+    #[cfg(target_arch = "x86_64")]
+    static CRIT_SECTION_SIZE: uint = 40;
 
     pub struct Mutex {
         // pointers for the lock/cond handles, atomically updated