Skip to content

Commit f686e5e

Browse files
committed
Fixed Win64 build
1 parent 6619134 commit f686e5e

File tree

7 files changed

+105
-44
lines changed

7 files changed

+105
-44
lines changed

src/libgreen/macros.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,9 @@ macro_rules! rtabort (
5252

5353
pub fn dumb_println(args: &fmt::Arguments) {
5454
use std::io;
55-
use libc;
55+
use std::rt;
5656

57-
struct Stderr;
58-
impl io::Writer for Stderr {
59-
fn write(&mut self, data: &[u8]) -> io::IoResult<()> {
60-
unsafe {
61-
libc::write(libc::STDERR_FILENO,
62-
data.as_ptr() as *libc::c_void,
63-
data.len() as libc::size_t);
64-
}
65-
Ok(()) // just ignore the result
66-
}
67-
}
68-
let mut w = Stderr;
57+
let mut w = rt::Stderr;
6958
let _ = fmt::writeln(&mut w as &mut io::Writer, args);
7059
}
7160

src/librustuv/macros.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,8 @@ macro_rules! uvdebug (
2929

3030
pub fn dumb_println(args: &fmt::Arguments) {
3131
use std::io;
32-
use libc;
32+
use std::rt;
3333

34-
struct Stderr;
35-
impl io::Writer for Stderr {
36-
fn write(&mut self, data: &[u8]) -> io::IoResult<()> {
37-
let _ = unsafe {
38-
libc::write(libc::STDERR_FILENO,
39-
data.as_ptr() as *libc::c_void,
40-
data.len() as libc::size_t)
41-
};
42-
Ok(()) // just ignore the errors
43-
}
44-
}
45-
let mut w = Stderr;
34+
let mut w = rt::Stderr;
4635
let _ = fmt::writeln(&mut w as &mut io::Writer, args);
4736
}

src/libstd/io/stdio.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ out.write(bytes!("Hello, world!"));
2727
2828
*/
2929

30-
use container::Container;
3130
use fmt;
3231
use io::{Reader, Writer, IoResult, IoError, OtherIoError,
3332
standard_error, EndOfFile, LineBufferedWriter, BufferedReader};
@@ -37,11 +36,11 @@ use mem::replace;
3736
use option::{Option, Some, None};
3837
use prelude::drop;
3938
use result::{Ok, Err};
39+
use rt;
4040
use rt::local::Local;
4141
use rt::rtio::{DontClose, IoFactory, LocalIo, RtioFileStream, RtioTTY};
4242
use rt::task::Task;
4343
use str::StrSlice;
44-
use slice::ImmutableVector;
4544

4645
// And so begins the tale of acquiring a uv handle to a stdio stream on all
4746
// 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<()> ) {
236235
}
237236

238237
None => {
239-
struct Stdout;
240-
impl Writer for Stdout {
241-
fn write(&mut self, data: &[u8]) -> IoResult<()> {
242-
unsafe {
243-
libc::write(libc::STDOUT_FILENO,
244-
data.as_ptr() as *libc::c_void,
245-
data.len() as libc::size_t);
246-
}
247-
Ok(()) // just ignore the results
248-
}
249-
}
250-
let mut io = Stdout;
238+
let mut io = rt::Stdout;
251239
f(&mut io as &mut Writer)
252240
}
253241
};

src/libstd/rt/backtrace.rs

+83
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,89 @@ mod imp {
665665
}
666666
}
667667

668+
#[cfg(target_arch = "x86_64")]
669+
mod arch {
670+
use libc::{c_longlong, c_ulonglong};
671+
use libc::types::os::arch::extra::{WORD, DWORD, DWORDLONG};
672+
673+
pub struct CONTEXT {
674+
P1Home: DWORDLONG,
675+
P2Home: DWORDLONG,
676+
P3Home: DWORDLONG,
677+
P4Home: DWORDLONG,
678+
P5Home: DWORDLONG,
679+
P6Home: DWORDLONG,
680+
681+
ContextFlags: DWORD,
682+
MxCsr: DWORD,
683+
684+
SegCs: WORD,
685+
SegDs: WORD,
686+
SegEs: WORD,
687+
SegFs: WORD,
688+
SegGs: WORD,
689+
SegSs: WORD,
690+
EFlags: DWORD,
691+
692+
Dr0: DWORDLONG,
693+
Dr1: DWORDLONG,
694+
Dr2: DWORDLONG,
695+
Dr3: DWORDLONG,
696+
Dr6: DWORDLONG,
697+
Dr7: DWORDLONG,
698+
699+
Rax: DWORDLONG,
700+
Rcx: DWORDLONG,
701+
Rdx: DWORDLONG,
702+
Rbx: DWORDLONG,
703+
Rsp: DWORDLONG,
704+
Rbp: DWORDLONG,
705+
Rsi: DWORDLONG,
706+
Rdi: DWORDLONG,
707+
R8: DWORDLONG,
708+
R9: DWORDLONG,
709+
R10: DWORDLONG,
710+
R11: DWORDLONG,
711+
R12: DWORDLONG,
712+
R13: DWORDLONG,
713+
R14: DWORDLONG,
714+
R15: DWORDLONG,
715+
716+
Rip: DWORDLONG,
717+
718+
FltSave: FLOATING_SAVE_AREA,
719+
720+
VectorRegister: [M128A, .. 26],
721+
VectorControl: DWORDLONG,
722+
723+
DebugControl: DWORDLONG,
724+
LastBranchToRip: DWORDLONG,
725+
LastBranchFromRip: DWORDLONG,
726+
LastExceptionToRip: DWORDLONG,
727+
LastExceptionFromRip: DWORDLONG,
728+
}
729+
730+
pub struct M128A {
731+
Low: c_ulonglong,
732+
High: c_longlong
733+
}
734+
735+
pub struct FLOATING_SAVE_AREA {
736+
_Dummy: [u8, ..512] // FIXME: Fill this out
737+
}
738+
739+
pub fn init_frame(frame: &mut super::STACKFRAME64,
740+
ctx: &CONTEXT) -> DWORD {
741+
frame.AddrPC.Offset = ctx.Rip as u64;
742+
frame.AddrPC.Mode = super::AddrModeFlat;
743+
frame.AddrStack.Offset = ctx.Rsp as u64;
744+
frame.AddrStack.Mode = super::AddrModeFlat;
745+
frame.AddrFrame.Offset = ctx.Rbp as u64;
746+
frame.AddrFrame.Mode = super::AddrModeFlat;
747+
super::IMAGE_FILE_MACHINE_AMD64
748+
}
749+
}
750+
668751
struct Cleanup {
669752
handle: libc::HANDLE,
670753
SymCleanup: SymCleanupFn,

src/libstd/rt/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ pub use self::util::default_sched_threads;
7171
// Export unwinding facilities used by the failure macros
7272
pub use self::unwind::{begin_unwind, begin_unwind_raw, begin_unwind_fmt};
7373

74+
pub use self::util::{Stdio, Stdout, Stderr};
75+
7476
// FIXME: these probably shouldn't be public...
7577
#[doc(hidden)]
7678
pub mod shouldnt_be_public {

src/libstd/rt/util.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,22 @@ pub fn default_sched_threads() -> uint {
7171
}
7272
}
7373

74-
pub struct Stderr;
74+
pub struct Stdio(libc::c_int);
7575

76-
impl io::Writer for Stderr {
76+
pub static Stdout: Stdio = Stdio(libc::STDOUT_FILENO);
77+
pub static Stderr: Stdio = Stdio(libc::STDERR_FILENO);
78+
79+
impl io::Writer for Stdio {
7780
fn write(&mut self, data: &[u8]) -> IoResult<()> {
81+
#[cfg(unix)]
82+
type WriteLen = libc::size_t;
83+
#[cfg(windows)]
84+
type WriteLen = libc::c_uint;
7885
unsafe {
79-
libc::write(libc::STDERR_FILENO,
86+
let Stdio(fd) = *self;
87+
libc::write(fd,
8088
data.as_ptr() as *libc::c_void,
81-
data.len() as libc::size_t);
89+
data.len() as WriteLen);
8290
}
8391
Ok(()) // yes, we're lying
8492
}

src/libstd/unstable/mutex.rs

+2
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@ mod imp {
444444
static SPIN_COUNT: DWORD = 4000;
445445
#[cfg(target_arch = "x86")]
446446
static CRIT_SECTION_SIZE: uint = 24;
447+
#[cfg(target_arch = "x86_64")]
448+
static CRIT_SECTION_SIZE: uint = 40;
447449

448450
pub struct Mutex {
449451
// pointers for the lock/cond handles, atomically updated

0 commit comments

Comments
 (0)