File tree Expand file tree Collapse file tree 6 files changed +12
-31
lines changed Expand file tree Collapse file tree 6 files changed +12
-31
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,6 @@ type rust_cond_lock = *libc::c_void;
20
20
21
21
#[ abi = "cdecl" ]
22
22
native mod rustrt {
23
- pure fn refcount ( t : * ( ) ) -> libc:: intptr_t ;
24
23
fn unsupervise ( ) ;
25
24
pure fn shape_log_str ( t : * sys:: type_desc , data : * ( ) ) -> str ;
26
25
@@ -71,10 +70,11 @@ pure fn pref_align_of<T>() -> uint {
71
70
unchecked { rusti : : pref_align_of :: < T > ( ) }
72
71
}
73
72
74
- #[ doc = "Returns the refcount of a shared box" ]
75
- pure fn refcount < T > ( t : @T ) -> uint {
73
+ #[ doc = "Returns the refcount of a shared box (as just before calling this) " ]
74
+ pure fn refcount < T > ( + t : @T ) -> uint {
76
75
unsafe {
77
- ret rustrt:: refcount ( unsafe :: reinterpret_cast ( t) ) as uint ;
76
+ let ref_ptr: * uint = unsafe :: reinterpret_cast ( t) ;
77
+ * ref_ptr - 1
78
78
}
79
79
}
80
80
Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ export debug_box;
8
8
export debug_tag;
9
9
export debug_fn;
10
10
export ptr_cast;
11
- export refcount;
12
11
export breakpoint;
13
12
14
13
#[ abi = "cdecl" ]
@@ -48,11 +47,6 @@ unsafe fn ptr_cast<T, U>(x: @T) -> @U {
48
47
reinterpret_cast ( x) ) )
49
48
}
50
49
51
- fn refcount < T > ( a : @T ) -> uint unsafe {
52
- let p: * uint = unsafe :: reinterpret_cast ( a) ;
53
- ret * p;
54
- }
55
-
56
50
#[ doc = "Triggers a debugger breakpoint" ]
57
51
fn breakpoint ( ) {
58
52
rustrt:: rust_dbg_breakpoint ( ) ;
Original file line number Diff line number Diff line change @@ -127,13 +127,6 @@ rust_env_pairs() {
127
127
}
128
128
#endif
129
129
130
- extern " C" CDECL intptr_t
131
- refcount (intptr_t *v) {
132
- // Passed-in value has refcount 1 too high
133
- // because it was ref'ed while making the call.
134
- return (*v) - 1 ;
135
- }
136
-
137
130
extern " C" CDECL void
138
131
unsupervise () {
139
132
rust_task *task = rust_get_current_task ();
Original file line number Diff line number Diff line change @@ -29,7 +29,6 @@ rand_new
29
29
rand_new_seeded
30
30
rand_next
31
31
rand_seed
32
- refcount
33
32
rust_get_sched_id
34
33
rust_new_sched
35
34
rust_new_task_in_sched
Original file line number Diff line number Diff line change 1
1
2
2
3
3
// -*- rust -*-
4
- use std;
5
-
6
- import std:: dbg;
4
+ import core:: sys;
7
5
8
6
enum t { make_t( @int ) , clam, }
9
7
10
8
fn foo ( s : @int ) {
11
- let count = dbg :: refcount ( s) ;
9
+ let count = sys :: refcount ( s) ;
12
10
let x: t = make_t ( s) ; // ref up
13
11
14
12
alt x {
@@ -18,17 +16,17 @@ fn foo(s: @int) {
18
16
}
19
17
_ { #debug( "?" ) ; fail; }
20
18
}
21
- log ( debug, dbg :: refcount ( s) ) ;
22
- assert ( dbg :: refcount ( s) == count + 1 u) ;
19
+ log ( debug, sys :: refcount ( s) ) ;
20
+ assert ( sys :: refcount ( s) == count + 1 u) ;
23
21
}
24
22
25
23
fn main ( ) {
26
24
let s: @int = @0 ; // ref up
27
25
28
- let count = dbg :: refcount ( s) ;
26
+ let count = sys :: refcount ( s) ;
29
27
30
28
foo ( s) ; // ref up then down
31
29
32
- log ( debug, dbg :: refcount ( s) ) ;
33
- assert ( dbg :: refcount ( s) == count) ;
30
+ log ( debug, sys :: refcount ( s) ) ;
31
+ assert ( sys :: refcount ( s) == count) ;
34
32
}
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ native mod rustrt {
11
11
fn unsupervise ( ) ;
12
12
fn last_os_error ( ) -> str ;
13
13
fn rust_getcwd ( ) -> str ;
14
- fn refcount ( box : @int ) ;
15
14
fn get_task_id ( ) ;
16
15
fn sched_threads ( ) ;
17
16
fn rust_get_task ( ) ;
@@ -20,7 +19,6 @@ native mod rustrt {
20
19
fn calllink01 ( ) { rustrt:: unsupervise ( ) ; }
21
20
fn calllink02 ( ) { rustrt:: last_os_error ( ) ; }
22
21
fn calllink03 ( ) { rustrt:: rust_getcwd ( ) ; }
23
- fn calllink04 ( ) { rustrt:: refcount ( @0 ) ; }
24
22
fn calllink08 ( ) { rustrt:: get_task_id ( ) ; }
25
23
fn calllink09 ( ) { rustrt:: sched_threads ( ) ; }
26
24
fn calllink10 ( ) { rustrt:: rust_get_task ( ) ; }
@@ -52,7 +50,6 @@ fn main() {
52
50
calllink01,
53
51
calllink02,
54
52
calllink03,
55
- calllink04,
56
53
calllink08,
57
54
calllink09,
58
55
calllink10
@@ -63,4 +60,4 @@ fn main() {
63
60
let frame_backoff = rng. next( ) % 10u32 + 1u32 ;
64
61
task:: try { || runtest( f, frame_backoff) } ;
65
62
}
66
- }
63
+ }
You can’t perform that action at this time.
0 commit comments