about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2012-10-05 17:19:50 -0700
committerTim Chevalier <chevalier@alum.wellesley.edu>2012-10-05 21:03:40 -0700
commit05999290e23ad5f57bdfbfd56bde694a627c342e (patch)
tree4c46f6dd9fd367e445413743bd0f7bc7722c42b1 /src/libstd
parent688a920045627a3afa8ef46ee9d62b253ccfa243 (diff)
Finally removing all uses of by-mut-ref
The code for the mode itself is still there.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/arena.rs115
-rw-r--r--src/libstd/time.rs33
2 files changed, 4 insertions, 144 deletions
diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs
index 69478b3e731..6a2ac88f714 100644
--- a/src/libstd/arena.rs
+++ b/src/libstd/arena.rs
@@ -31,10 +31,6 @@ use libc::size_t;
 
 #[abi = "rust-intrinsic"]
 extern mod rusti {
-    #[cfg(stage0)]
-    fn move_val_init<T>(&dst: T, -src: T);
-    #[cfg(stage1)]
-    #[cfg(stage2)]
     fn move_val_init<T>(dst: &mut T, -src: T);
     fn needs_drop<T>() -> bool;
 }
@@ -132,117 +128,6 @@ unsafe fn un_bitpack_tydesc_ptr(p: uint) -> (*TypeDesc, bool) {
     (reinterpret_cast(&(p & !1)), p & 1 == 1)
 }
 
-// tjc: Can get rid of the duplication post-snapshot
-#[cfg(stage0)]
-// The duplication between the POD and non-POD functions is annoying.
-impl &Arena {
-    // Functions for the POD part of the arena
-    fn alloc_pod_grow(n_bytes: uint, align: uint) -> *u8 {
-        // Allocate a new chunk.
-        let chunk_size = at_vec::capacity(self.pod_head.data);
-        let new_min_chunk_size = uint::max(n_bytes, chunk_size);
-        self.chunks = @Cons(copy self.pod_head, self.chunks);
-        self.pod_head =
-            chunk(uint::next_power_of_two(new_min_chunk_size + 1u), true);
-
-        return self.alloc_pod_inner(n_bytes, align);
-    }
-
-    #[inline(always)]
-    fn alloc_pod_inner(n_bytes: uint, align: uint) -> *u8 {
-        let head = &mut self.pod_head;
-
-        let start = round_up_to(head.fill, align);
-        let end = start + n_bytes;
-        if end > at_vec::capacity(head.data) {
-            return self.alloc_pod_grow(n_bytes, align);
-        }
-        head.fill = end;
-
-        //debug!("idx = %u, size = %u, align = %u, fill = %u",
-        //       start, n_bytes, align, head.fill);
-
-        unsafe {
-            ptr::offset(vec::raw::to_ptr(head.data), start)
-        }
-    }
-
-    #[inline(always)]
-    fn alloc_pod<T>(op: fn() -> T) -> &self/T {
-        unsafe {
-            let tydesc = sys::get_type_desc::<T>();
-            let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align);
-            let ptr: *mut T = reinterpret_cast(&ptr);
-            rusti::move_val_init(*ptr, op());
-            return reinterpret_cast(&ptr);
-        }
-    }
-
-    // Functions for the non-POD part of the arena
-    fn alloc_nonpod_grow(n_bytes: uint, align: uint) -> (*u8, *u8) {
-        // Allocate a new chunk.
-        let chunk_size = at_vec::capacity(self.head.data);
-        let new_min_chunk_size = uint::max(n_bytes, chunk_size);
-        self.chunks = @Cons(copy self.head, self.chunks);
-        self.head =
-            chunk(uint::next_power_of_two(new_min_chunk_size + 1u), false);
-
-        return self.alloc_nonpod_inner(n_bytes, align);
-    }
-
-    #[inline(always)]
-    fn alloc_nonpod_inner(n_bytes: uint, align: uint) -> (*u8, *u8) {
-        let head = &mut self.head;
-
-        let tydesc_start = head.fill;
-        let after_tydesc = head.fill + sys::size_of::<*TypeDesc>();
-        let start = round_up_to(after_tydesc, align);
-        let end = start + n_bytes;
-        if end > at_vec::capacity(head.data) {
-            return self.alloc_nonpod_grow(n_bytes, align);
-        }
-        head.fill = round_up_to(end, sys::pref_align_of::<*TypeDesc>());
-
-        //debug!("idx = %u, size = %u, align = %u, fill = %u",
-        //       start, n_bytes, align, head.fill);
-
-        unsafe {
-            let buf = vec::raw::to_ptr(head.data);
-            return (ptr::offset(buf, tydesc_start), ptr::offset(buf, start));
-        }
-    }
-
-    #[inline(always)]
-    fn alloc_nonpod<T>(op: fn() -> T) -> &self/T {
-        unsafe {
-            let tydesc = sys::get_type_desc::<T>();
-            let (ty_ptr, ptr) =
-                self.alloc_nonpod_inner((*tydesc).size, (*tydesc).align);
-            let ty_ptr: *mut uint = reinterpret_cast(&ty_ptr);
-            let ptr: *mut T = reinterpret_cast(&ptr);
-            // Write in our tydesc along with a bit indicating that it
-            // has *not* been initialized yet.
-            *ty_ptr = reinterpret_cast(&tydesc);
-            // Actually initialize it
-            rusti::move_val_init(*ptr, op());
-            // Now that we are done, update the tydesc to indicate that
-            // the object is there.
-            *ty_ptr = bitpack_tydesc_ptr(tydesc, true);
-
-            return reinterpret_cast(&ptr);
-        }
-    }
-
-    // The external interface
-    #[inline(always)]
-    fn alloc<T>(op: fn() -> T) -> &self/T {
-        if !rusti::needs_drop::<T>() {
-            self.alloc_pod(op)
-        } else { self.alloc_nonpod(op) }
-    }
-}
-#[cfg(stage1)]
-#[cfg(stage2)]
 impl &Arena {
     // Functions for the POD part of the arena
     fn alloc_pod_grow(n_bytes: uint, align: uint) -> *u8 {
diff --git a/src/libstd/time.rs b/src/libstd/time.rs
index 8fa1e0cf3f0..65872a013ab 100644
--- a/src/libstd/time.rs
+++ b/src/libstd/time.rs
@@ -8,24 +8,16 @@ use result::{Result, Ok, Err};
 #[abi = "cdecl"]
 extern mod rustrt {
     #[legacy_exports]
-    #[cfg(stage0)]
-    fn get_time(&sec: i64, &nsec: i32);
-    #[cfg(stage1)]
-    #[cfg(stage2)]
     fn get_time(sec: &mut i64, nsec: &mut i32);
 
-    #[cfg(stage0)]
-    fn precise_time_ns(&ns: u64);
-    #[cfg(stage1)]
-    #[cfg(stage2)]
     fn precise_time_ns(ns: &mut u64);
 
     fn rust_tzset();
     // FIXME: The i64 values can be passed by-val when #2064 is fixed.
     fn rust_gmtime(&&sec: i64, &&nsec: i32, &&result: Tm);
     fn rust_localtime(&&sec: i64, &&nsec: i32, &&result: Tm);
-    fn rust_timegm(&&tm: Tm, &sec: i64);
-    fn rust_mktime(&&tm: Tm, &sec: i64);
+    fn rust_timegm(&&tm: Tm, sec: &mut i64);
+    fn rust_mktime(&&tm: Tm, sec: &mut i64);
 }
 
 /// A record specifying a time value in seconds and nanoseconds.
@@ -42,15 +34,6 @@ impl Timespec : Eq {
  * Returns the current time as a `timespec` containing the seconds and
  * nanoseconds since 1970-01-01T00:00:00Z.
  */
-#[cfg(stage0)]
-pub fn get_time() -> Timespec {
-    let mut sec = 0i64;
-    let mut nsec = 0i32;
-    rustrt::get_time(sec, nsec);
-    return {sec: sec, nsec: nsec};
-}
-#[cfg(stage1)]
-#[cfg(stage2)]
 pub fn get_time() -> Timespec {
     let mut sec = 0i64;
     let mut nsec = 0i32;
@@ -63,14 +46,6 @@ pub fn get_time() -> Timespec {
  * Returns the current value of a high-resolution performance counter
  * in nanoseconds since an unspecified epoch.
  */
-#[cfg(stage0)]
-pub fn precise_time_ns() -> u64 {
-    let mut ns = 0u64;
-    rustrt::precise_time_ns(ns);
-    ns
-}
-#[cfg(stage1)]
-#[cfg(stage2)]
 pub fn precise_time_ns() -> u64 {
     let mut ns = 0u64;
     rustrt::precise_time_ns(&mut ns);
@@ -790,9 +765,9 @@ impl Tm {
     fn to_timespec() -> Timespec {
         let mut sec = 0i64;
         if self.tm_gmtoff == 0_i32 {
-            rustrt::rust_timegm(self, sec);
+            rustrt::rust_timegm(self, &mut sec);
         } else {
-            rustrt::rust_mktime(self, sec);
+            rustrt::rust_mktime(self, &mut sec);
         }
         { sec: sec, nsec: self.tm_nsec }
     }