Skip to content

Commit af2d01e

Browse files
committed
Fix sys::refcount and remove dbg::refcount
1 parent ad82807 commit af2d01e

File tree

6 files changed

+12
-31
lines changed

6 files changed

+12
-31
lines changed

src/libcore/sys.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ type rust_cond_lock = *libc::c_void;
2020

2121
#[abi = "cdecl"]
2222
native mod rustrt {
23-
pure fn refcount(t: *()) -> libc::intptr_t;
2423
fn unsupervise();
2524
pure fn shape_log_str(t: *sys::type_desc, data: *()) -> str;
2625

@@ -71,10 +70,11 @@ pure fn pref_align_of<T>() -> uint {
7170
unchecked { rusti::pref_align_of::<T>() }
7271
}
7372

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 {
7675
unsafe {
77-
ret rustrt::refcount(unsafe::reinterpret_cast(t)) as uint;
76+
let ref_ptr: *uint = unsafe::reinterpret_cast(t);
77+
*ref_ptr - 1
7878
}
7979
}
8080

src/libstd/dbg.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export debug_box;
88
export debug_tag;
99
export debug_fn;
1010
export ptr_cast;
11-
export refcount;
1211
export breakpoint;
1312

1413
#[abi = "cdecl"]
@@ -48,11 +47,6 @@ unsafe fn ptr_cast<T, U>(x: @T) -> @U {
4847
reinterpret_cast(x)))
4948
}
5049

51-
fn refcount<T>(a: @T) -> uint unsafe {
52-
let p: *uint = unsafe::reinterpret_cast(a);
53-
ret *p;
54-
}
55-
5650
#[doc = "Triggers a debugger breakpoint"]
5751
fn breakpoint() {
5852
rustrt::rust_dbg_breakpoint();

src/rt/rust_builtin.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,6 @@ rust_env_pairs() {
127127
}
128128
#endif
129129

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-
137130
extern "C" CDECL void
138131
unsupervise() {
139132
rust_task *task = rust_get_current_task();

src/rt/rustrt.def.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ rand_new
2929
rand_new_seeded
3030
rand_next
3131
rand_seed
32-
refcount
3332
rust_get_sched_id
3433
rust_new_sched
3534
rust_new_task_in_sched

src/test/run-pass/alt-pattern-drop.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11

22

33
// -*- rust -*-
4-
use std;
5-
6-
import std::dbg;
4+
import core::sys;
75

86
enum t { make_t(@int), clam, }
97

108
fn foo(s: @int) {
11-
let count = dbg::refcount(s);
9+
let count = sys::refcount(s);
1210
let x: t = make_t(s); // ref up
1311

1412
alt x {
@@ -18,17 +16,17 @@ fn foo(s: @int) {
1816
}
1917
_ { #debug("?"); fail; }
2018
}
21-
log(debug, dbg::refcount(s));
22-
assert (dbg::refcount(s) == count + 1u);
19+
log(debug, sys::refcount(s));
20+
assert (sys::refcount(s) == count + 1u);
2321
}
2422

2523
fn main() {
2624
let s: @int = @0; // ref up
2725

28-
let count = dbg::refcount(s);
26+
let count = sys::refcount(s);
2927

3028
foo(s); // ref up then down
3129

32-
log(debug, dbg::refcount(s));
33-
assert (dbg::refcount(s) == count);
30+
log(debug, sys::refcount(s));
31+
assert (sys::refcount(s) == count);
3432
}

src/test/run-pass/morestack6.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ native mod rustrt {
1111
fn unsupervise();
1212
fn last_os_error() -> str;
1313
fn rust_getcwd() -> str;
14-
fn refcount(box: @int);
1514
fn get_task_id();
1615
fn sched_threads();
1716
fn rust_get_task();
@@ -20,7 +19,6 @@ native mod rustrt {
2019
fn calllink01() { rustrt::unsupervise(); }
2120
fn calllink02() { rustrt::last_os_error(); }
2221
fn calllink03() { rustrt::rust_getcwd(); }
23-
fn calllink04() { rustrt::refcount(@0); }
2422
fn calllink08() { rustrt::get_task_id(); }
2523
fn calllink09() { rustrt::sched_threads(); }
2624
fn calllink10() { rustrt::rust_get_task(); }
@@ -52,7 +50,6 @@ fn main() {
5250
calllink01,
5351
calllink02,
5452
calllink03,
55-
calllink04,
5653
calllink08,
5754
calllink09,
5855
calllink10
@@ -63,4 +60,4 @@ fn main() {
6360
let frame_backoff = rng.next() % 10u32 + 1u32;
6461
task::try {|| runtest(f, frame_backoff) };
6562
}
66-
}
63+
}

0 commit comments

Comments
 (0)