diff options
| author | bors <bors@rust-lang.org> | 2013-10-17 22:06:22 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-10-17 22:06:22 -0700 |
| commit | 0e4d1fc8cae42e15e00f71d9f439b01bb25a86ae (patch) | |
| tree | 4cdbd44d59d33f6bb828bbde15fe36559906730d /src/libstd | |
| parent | 737413d72a714e55ff53e591e8190b490c194a53 (diff) | |
| parent | 82f5f65076e604ec70a6e09cdbe8dddb8b3b7c44 (diff) | |
| download | rust-0e4d1fc8cae42e15e00f71d9f439b01bb25a86ae.tar.gz rust-0e4d1fc8cae42e15e00f71d9f439b01bb25a86ae.zip | |
auto merge of #9922 : alexcrichton/rust/less-sys, r=thestinger
More progress on #2240
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/managed.rs | 7 | ||||
| -rw-r--r-- | src/libstd/sys.rs | 10 |
2 files changed, 7 insertions, 10 deletions
diff --git a/src/libstd/managed.rs b/src/libstd/managed.rs index 57230b2fd24..a27c8aa4a76 100644 --- a/src/libstd/managed.rs +++ b/src/libstd/managed.rs @@ -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 { diff --git a/src/libstd/sys.rs b/src/libstd/sys.rs index 0299ca0b49a..0f38671bfc2 100644 --- a/src/libstd/sys.rs +++ b/src/libstd/sys.rs @@ -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; |
