diff options
| author | Corey Richardson <corey@octayn.net> | 2014-08-15 01:47:28 -0400 |
|---|---|---|
| committer | Corey Richardson <corey@octayn.net> | 2014-08-20 21:02:24 -0400 |
| commit | 21bd17fcc12ac277ac34c0a92010070f0a861ae1 (patch) | |
| tree | febd8dbb212ff60fd3e3e47ee64c5cb274de18b3 | |
| parent | cf5d28083dc25ae9a395b7e55e98af9c621574dc (diff) | |
| download | rust-21bd17fcc12ac277ac34c0a92010070f0a861ae1.tar.gz rust-21bd17fcc12ac277ac34c0a92010070f0a861ae1.zip | |
Stage #[repr(packed)] in std::rt
| -rw-r--r-- | src/libgreen/context.rs | 12 | ||||
| -rw-r--r-- | src/libgreen/stack.rs | 3 | ||||
| -rw-r--r-- | src/libstd/rt/backtrace.rs | 33 |
3 files changed, 40 insertions, 8 deletions
diff --git a/src/libgreen/context.rs b/src/libgreen/context.rs index dfed121b3ce..64537ea12d9 100644 --- a/src/libgreen/context.rs +++ b/src/libgreen/context.rs @@ -166,16 +166,16 @@ fn new_regs() -> Box<Registers> { #[cfg(target_arch = "x86")] fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint, - procedure: raw::Procedure, sp: *mut libc::uintptr_t) { - + procedure: raw::Procedure, sp: *mut uint) { + let sp = sp as *mut uint; // x86 has interesting stack alignment requirements, so do some alignment // plus some offsetting to figure out what the actual stack should be. let sp = align_down(sp); let sp = mut_offset(sp, -4); - unsafe { *mut_offset(sp, 2) = procedure.env as libc::uintptr_t }; - unsafe { *mut_offset(sp, 1) = procedure.code as libc::uintptr_t }; - unsafe { *mut_offset(sp, 0) = arg as libc::uintptr_t }; + unsafe { *mut_offset(sp, 2) = procedure.env as uint }; + unsafe { *mut_offset(sp, 1) = procedure.code as uint }; + unsafe { *mut_offset(sp, 0) = arg as uint }; let sp = mut_offset(sp, -1); unsafe { *sp = 0 }; // The final return address @@ -316,7 +316,7 @@ fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint, } fn align_down(sp: *mut uint) -> *mut uint { - let sp = (sp as libc::uintptr_t) & !(16 - 1); + let sp = (sp as uint) & !(16 - 1); sp as *mut uint } diff --git a/src/libgreen/stack.rs b/src/libgreen/stack.rs index eea5105de8c..4673e7b3ba2 100644 --- a/src/libgreen/stack.rs +++ b/src/libgreen/stack.rs @@ -68,7 +68,8 @@ impl Stack { // FIXME: Using the FFI to call a C macro. Slow stk.valgrind_id = unsafe { - rust_valgrind_stack_register(stk.start() as *const libc::uintptr_t, stk.end() as *const libc::uintptr_t) + rust_valgrind_stack_register(stk.start() as *const libc::uintptr_t, + stk.end() as *const libc::uintptr_t) }; return stk; } diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs index 5ef1286500c..1b005f49b88 100644 --- a/src/libstd/rt/backtrace.rs +++ b/src/libstd/rt/backtrace.rs @@ -701,7 +701,8 @@ mod imp { static IMAGE_FILE_MACHINE_IA64: libc::DWORD = 0x0200; static IMAGE_FILE_MACHINE_AMD64: libc::DWORD = 0x8664; - #[repr(packed)] + #[cfg(stage0)] + #[packed] struct SYMBOL_INFO { SizeOfStruct: libc::c_ulong, TypeIndex: libc::c_ulong, @@ -723,6 +724,30 @@ mod imp { Name: [libc::c_char, ..MAX_SYM_NAME], } + #[cfg(not(stage0))] + #[repr(C, packed)] + struct SYMBOL_INFO { + SizeOfStruct: libc::c_ulong, + TypeIndex: libc::c_ulong, + Reserved: [u64, ..2], + Index: libc::c_ulong, + Size: libc::c_ulong, + ModBase: u64, + Flags: libc::c_ulong, + Value: u64, + Address: u64, + Register: libc::c_ulong, + Scope: libc::c_ulong, + Tag: libc::c_ulong, + NameLen: libc::c_ulong, + MaxNameLen: libc::c_ulong, + // note that windows has this as 1, but it basically just means that + // the name is inline at the end of the struct. For us, we just bump + // the struct size up to MAX_SYM_NAME. + Name: [libc::c_char, ..MAX_SYM_NAME], + } + + #[repr(C)] enum ADDRESS_MODE { AddrMode1616, @@ -772,6 +797,7 @@ mod imp { static MAXIMUM_SUPPORTED_EXTENSION: uint = 512; + #[repr(C)] pub struct CONTEXT { ContextFlags: libc::DWORD, Dr0: libc::DWORD, @@ -800,6 +826,7 @@ mod imp { ExtendedRegisters: [u8, ..MAXIMUM_SUPPORTED_EXTENSION], } + #[repr(C)] pub struct FLOATING_SAVE_AREA { ControlWord: libc::DWORD, StatusWord: libc::DWORD, @@ -829,6 +856,7 @@ mod imp { use libc::{c_longlong, c_ulonglong}; use libc::types::os::arch::extra::{WORD, DWORD, DWORDLONG}; + #[repr(C)] pub struct CONTEXT { P1Home: DWORDLONG, P2Home: DWORDLONG, @@ -886,11 +914,13 @@ mod imp { LastExceptionFromRip: DWORDLONG, } + #[repr(C)] pub struct M128A { Low: c_ulonglong, High: c_longlong } + #[repr(C)] pub struct FLOATING_SAVE_AREA { _Dummy: [u8, ..512] // FIXME: Fill this out } @@ -907,6 +937,7 @@ mod imp { } } + #[repr(C)] struct Cleanup { handle: libc::HANDLE, SymCleanup: SymCleanupFn, |
