@@ -15,6 +15,7 @@ use std::rt::stack;
1515use std:: raw;
1616#[ cfg( target_arch = "x86_64" ) ]
1717use std:: simd;
18+ use libc;
1819
1920// FIXME #7761: Registers is boxed so that it is 16-byte aligned, for storing
2021// SSE regs. It would be marginally better not to do this. In C++ we
@@ -69,7 +70,7 @@ impl Context {
6970 // overflow). Additionally, their coroutine stacks are listed as being
7071 // zero-length, so that's how we detect what's what here.
7172 let stack_base: * const uint = stack. start ( ) ;
72- let bounds = if sp as uint == stack_base as uint {
73+ let bounds = if sp as libc :: uintptr_t == stack_base as libc :: uintptr_t {
7374 None
7475 } else {
7576 Some ( ( stack_base as uint , sp as uint ) )
@@ -166,7 +167,7 @@ fn new_regs() -> Box<Registers> {
166167#[ cfg( target_arch = "x86" ) ]
167168fn initialize_call_frame ( regs : & mut Registers , fptr : InitFn , arg : uint ,
168169 procedure : raw:: Procedure , sp : * mut uint ) {
169-
170+ let sp = sp as * mut uint ;
170171 // x86 has interesting stack alignment requirements, so do some alignment
171172 // plus some offsetting to figure out what the actual stack should be.
172173 let sp = align_down ( sp) ;
@@ -188,13 +189,15 @@ fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint,
188189// windows requires saving more registers (both general and XMM), so the windows
189190// register context must be larger.
190191#[ cfg( windows, target_arch = "x86_64" ) ]
192+ #[ repr( C ) ]
191193struct Registers {
192- gpr : [ uint , ..14 ] ,
194+ gpr : [ libc :: uintptr_t , ..14 ] ,
193195 _xmm : [ simd:: u32x4 , ..10 ]
194196}
195197#[ cfg( not( windows) , target_arch = "x86_64" ) ]
198+ #[ repr( C ) ]
196199struct Registers {
197- gpr : [ uint , ..10 ] ,
200+ gpr : [ libc :: uintptr_t , ..10 ] ,
198201 _xmm : [ simd:: u32x4 , ..6 ]
199202}
200203
@@ -234,30 +237,30 @@ fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint,
234237 unsafe { * sp = 0 ; }
235238
236239 rtdebug ! ( "creating call frame" ) ;
237- rtdebug ! ( "fptr {:#x}" , fptr as uint ) ;
240+ rtdebug ! ( "fptr {:#x}" , fptr as libc :: uintptr_t ) ;
238241 rtdebug ! ( "arg {:#x}" , arg) ;
239242 rtdebug ! ( "sp {}" , sp) ;
240243
241244 // These registers are frobbed by rust_bootstrap_green_task into the right
242245 // location so we can invoke the "real init function", `fptr`.
243- regs. gpr [ RUSTRT_R12 ] = arg as uint ;
244- regs. gpr [ RUSTRT_R13 ] = procedure. code as uint ;
245- regs. gpr [ RUSTRT_R14 ] = procedure. env as uint ;
246- regs. gpr [ RUSTRT_R15 ] = fptr as uint ;
246+ regs. gpr [ RUSTRT_R12 ] = arg as libc :: uintptr_t ;
247+ regs. gpr [ RUSTRT_R13 ] = procedure. code as libc :: uintptr_t ;
248+ regs. gpr [ RUSTRT_R14 ] = procedure. env as libc :: uintptr_t ;
249+ regs. gpr [ RUSTRT_R15 ] = fptr as libc :: uintptr_t ;
247250
248251 // These registers are picked up by the regular context switch paths. These
249252 // will put us in "mostly the right context" except for frobbing all the
250253 // arguments to the right place. We have the small trampoline code inside of
251254 // rust_bootstrap_green_task to do that.
252- regs. gpr [ RUSTRT_RSP ] = sp as uint ;
253- regs. gpr [ RUSTRT_IP ] = rust_bootstrap_green_task as uint ;
255+ regs. gpr [ RUSTRT_RSP ] = sp as libc :: uintptr_t ;
256+ regs. gpr [ RUSTRT_IP ] = rust_bootstrap_green_task as libc :: uintptr_t ;
254257
255258 // Last base pointer on the stack should be 0
256259 regs. gpr [ RUSTRT_RBP ] = 0 ;
257260}
258261
259262#[ cfg( target_arch = "arm" ) ]
260- type Registers = [ uint , ..32 ] ;
263+ type Registers = [ libc :: uintptr_t , ..32 ] ;
261264
262265#[ cfg( target_arch = "arm" ) ]
263266fn new_regs ( ) -> Box < Registers > { box { [ 0 , .. 32 ] } }
@@ -277,17 +280,17 @@ fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint,
277280 // ARM uses the same technique as x86_64 to have a landing pad for the start
278281 // of all new green tasks. Neither r1/r2 are saved on a context switch, so
279282 // the shim will copy r3/r4 into r1/r2 and then execute the function in r5
280- regs[ 0 ] = arg as uint ; // r0
281- regs[ 3 ] = procedure. code as uint ; // r3
282- regs[ 4 ] = procedure. env as uint ; // r4
283- regs[ 5 ] = fptr as uint ; // r5
284- regs[ 13 ] = sp as uint ; // #52 sp, r13
285- regs[ 14 ] = rust_bootstrap_green_task as uint ; // #56 pc, r14 --> lr
283+ regs[ 0 ] = arg as libc :: uintptr_t ; // r0
284+ regs[ 3 ] = procedure. code as libc :: uintptr_t ; // r3
285+ regs[ 4 ] = procedure. env as libc :: uintptr_t ; // r4
286+ regs[ 5 ] = fptr as libc :: uintptr_t ; // r5
287+ regs[ 13 ] = sp as libc :: uintptr_t ; // #52 sp, r13
288+ regs[ 14 ] = rust_bootstrap_green_task as libc :: uintptr_t ; // #56 pc, r14 --> lr
286289}
287290
288291#[ cfg( target_arch = "mips" ) ]
289292#[ cfg( target_arch = "mipsel" ) ]
290- type Registers = [ uint , ..32 ] ;
293+ type Registers = [ libc :: uintptr_t , ..32 ] ;
291294
292295#[ cfg( target_arch = "mips" ) ]
293296#[ cfg( target_arch = "mipsel" ) ]
@@ -304,12 +307,12 @@ fn initialize_call_frame(regs: &mut Registers, fptr: InitFn, arg: uint,
304307 // The final return address. 0 indicates the bottom of the stack
305308 unsafe { * sp = 0 ; }
306309
307- regs[ 4 ] = arg as uint ;
308- regs[ 5 ] = procedure. code as uint ;
309- regs[ 6 ] = procedure. env as uint ;
310- regs[ 29 ] = sp as uint ;
311- regs[ 25 ] = fptr as uint ;
312- regs[ 31 ] = fptr as uint ;
310+ regs[ 4 ] = arg as libc :: uintptr_t ;
311+ regs[ 5 ] = procedure. code as libc :: uintptr_t ;
312+ regs[ 6 ] = procedure. env as libc :: uintptr_t ;
313+ regs[ 29 ] = sp as libc :: uintptr_t ;
314+ regs[ 25 ] = fptr as libc :: uintptr_t ;
315+ regs[ 31 ] = fptr as libc :: uintptr_t ;
313316}
314317
315318fn align_down ( sp : * mut uint ) -> * mut uint {
0 commit comments