@@ -22,24 +22,25 @@ export spawn;
22
22
export spawn_notify;
23
23
export spawn_joinable;
24
24
25
- native "rust" mod rustrt {
26
- fn task_sleep ( time_in_us : uint ) ;
27
- fn task_yield ( ) ;
28
- fn task_join ( t : task_id ) -> int ;
29
- fn pin_task ( ) ;
30
- fn unpin_task ( ) ;
31
- fn get_task_id ( ) -> task_id ;
25
+ native "rust" mod rustrt { // C Stack?
26
+ fn task_sleep ( time_in_us : uint ) ; // No
27
+ fn task_yield ( ) ; // No
28
+ fn start_task ( id : task_id , closure : * u8 ) ; // No
29
+ fn task_join ( t : task_id ) -> int ; // Refactor
30
+ }
32
31
33
- type rust_chan ;
32
+ native "c-stack-cdecl" mod rustrt2 = "rustrt" {
33
+ fn pin_task ( ) ; // Yes
34
+ fn unpin_task ( ) ; // Yes
35
+ fn get_task_id ( ) -> task_id ; // Yes
34
36
35
- fn set_min_stack ( stack_size : uint ) ;
37
+ fn set_min_stack ( stack_size : uint ) ; // Yes
36
38
37
39
fn new_task ( ) -> task_id ;
38
40
fn drop_task ( task : * rust_task ) ;
39
41
fn get_task_pointer ( id : task_id ) -> * rust_task ;
40
42
41
- fn migrate_alloc ( alloc : * u8 , target : task_id ) ;
42
- fn start_task ( id : task_id , closure : * u8 ) ;
43
+ fn migrate_alloc ( alloc : * u8 , target : task_id ) ; // Yes
43
44
}
44
45
45
46
type rust_task =
@@ -48,13 +49,13 @@ type rust_task =
48
49
mutable notify_chan: comm:: chan<task_notification>,
49
50
mutable stack_ptr: * u8} ;
50
51
51
- resource rust_task_ptr ( task: * rust_task) { rustrt :: drop_task ( task) ; }
52
+ resource rust_task_ptr ( task: * rust_task) { rustrt2 :: drop_task ( task) ; }
52
53
53
54
type task = int ;
54
55
type task_id = task ;
55
56
type joinable_task = ( task_id , comm:: port < task_notification > ) ;
56
57
57
- fn get_task_id ( ) -> task_id { rustrt :: get_task_id ( ) }
58
+ fn get_task_id ( ) -> task_id { rustrt2 :: get_task_id ( ) }
58
59
59
60
/**
60
61
* Hints the scheduler to yield this task for a specified ammount of time.
@@ -86,11 +87,11 @@ fn join_id(t: task_id) -> task_result {
86
87
87
88
fn unsupervise ( ) { ret sys:: unsupervise ( ) ; }
88
89
89
- fn pin ( ) { rustrt :: pin_task ( ) ; }
90
+ fn pin ( ) { rustrt2 :: pin_task ( ) ; }
90
91
91
- fn unpin ( ) { rustrt :: unpin_task ( ) ; }
92
+ fn unpin ( ) { rustrt2 :: unpin_task ( ) ; }
92
93
93
- fn set_min_stack ( stack_size : uint ) { rustrt :: set_min_stack ( stack_size) ; }
94
+ fn set_min_stack ( stack_size : uint ) { rustrt2 :: set_min_stack ( stack_size) ; }
94
95
95
96
fn spawn < ~T > ( -data : T , f : fn ( T ) ) -> task {
96
97
spawn_inner2 ( data, f, none)
@@ -138,12 +139,12 @@ fn spawn_inner2<~T>(-data: T, f: fn(T),
138
139
fn unsafe_spawn_inner( -thunk : fn @( ) ,
139
140
notify : option < comm:: chan < task_notification > > ) ->
140
141
task_id unsafe {
141
- let id = rustrt :: new_task ( ) ;
142
+ let id = rustrt2 :: new_task ( ) ;
142
143
143
144
let raw_thunk: { code : u32 , env : u32 } = cast ( thunk) ;
144
145
145
146
// set up the task pointer
146
- let task_ptr <- rust_task_ptr ( rustrt :: get_task_pointer ( id ) ) ;
147
+ let task_ptr <- rust_task_ptr ( rustrt2 :: get_task_pointer ( id ) ) ;
147
148
148
149
assert ( ptr:: null ( ) != ( * * task_ptr) . stack_ptr ) ;
149
150
@@ -167,7 +168,7 @@ fn unsafe_spawn_inner(-thunk: fn@(),
167
168
}
168
169
169
170
// give the thunk environment's allocation to the new task
170
- rustrt :: migrate_alloc ( cast ( raw_thunk . env) , id ) ;
171
+ rustrt2 :: migrate_alloc ( cast ( raw_thunk . env) , id ) ;
171
172
rustrt:: start_task ( id , cast ( thunkfn ) ) ;
172
173
// don't cleanup the thunk in this task
173
174
unsafe :: leak ( thunk ) ;
0 commit comments