Move sys::refcount to managed::refcount

More progress on #2240
This commit is contained in:
Alex Crichton 2013-10-17 21:13:56 -07:00
parent d8d1b8f8be
commit 82f5f65076
4 changed files with 20 additions and 23 deletions

View file

@ -17,6 +17,13 @@ use ptr::to_unsafe_ptr;
pub static RC_MANAGED_UNIQUE : uint = (-2) as uint;
pub static RC_IMMORTAL : uint = 0x77777777;
/// Returns the refcount of a shared box (as just before calling this)
#[inline]
pub fn refcount<T>(t: @T) -> uint {
use unstable::raw::Repr;
unsafe { (*t.repr()).ref_count }
}
/// Determine if two shared boxes point to the same object
#[inline]
pub fn ptr_eq<T>(a: @T, b: @T) -> bool {

View file

@ -13,22 +13,12 @@
#[allow(missing_doc)];
use c_str::ToCStr;
use cast;
use libc::size_t;
use libc;
use repr;
use rt::task;
use str;
/// Returns the refcount of a shared box (as just before calling this)
#[inline]
pub fn refcount<T>(t: @T) -> uint {
unsafe {
let ref_ptr: *uint = cast::transmute_copy(&t);
*ref_ptr - 1
}
}
pub fn log_str<T>(t: &T) -> ~str {
use rt::io;
use rt::io::Decorator;