]> git.lizzy.rs Git - rust.git/commitdiff
update vec libs to use c-stack-cdecl calling convention
authorNiko Matsakis <niko@alum.mit.edu>
Tue, 18 Oct 2011 04:15:50 +0000 (21:15 -0700)
committerBrian Anderson <banderson@mozilla.com>
Mon, 24 Oct 2011 23:06:16 +0000 (16:06 -0700)
src/lib/sys.rs
src/lib/vec.rs

index 40209f9e54eb2cf159fc0c414d29eb3ff645d7f9..979b29fee9a2f912ab035e68ec00d31b35f9d475 100644 (file)
@@ -2,6 +2,10 @@
 //export rustrt;
 //export size_of;
 
+tag type_desc {
+    type_desc(@type_desc);
+}
+
 native "rust" mod rustrt {
     // Explicitly re-export native stuff we want to be made
     // available outside this crate. Otherwise it's
     fn refcount<T>(t: @T) -> uint;
     fn do_gc();
     fn unsupervise();
+    fn get_type_desc<T>() -> *type_desc;
+}
+
+fn get_type_desc<T>() -> *type_desc {
+    ret rustrt::get_type_desc::<T>();
 }
 
 fn last_os_error() -> str {
index af3e31fafed47c30eaa7d6522b6bb52c66070a43..d98f4376d16eca11c8b5410391c44626061a917d 100644 (file)
@@ -2,20 +2,27 @@
 
 import option::{some, none};
 import uint::next_power_of_two;
-import ptr::addr_of;
+import ptr::{addr_of, null};
 
 native "rust-intrinsic" mod rusti {
     fn vec_len<T>(&&v: [mutable? T]) -> uint;
 }
 
-native "rust" mod rustrt {
-    fn vec_reserve_shared<T>(&v: [mutable? T], n: uint);
-    fn vec_from_buf_shared<T>(ptr: *T, count: uint) -> [T];
+native "c-stack-cdecl" mod rustrt {
+    fn vec_reserve_shared<T>(dummy: *util::void,
+                             t: *sys::type_desc,
+                             &v: [mutable? T],
+                             n: uint);
+    fn vec_from_buf_shared<T>(dummy: *util::void,
+                              t: *sys::type_desc,
+                              ptr: *T,
+                              count: uint) -> [T];
 }
 
 /// Reserves space for `n` elements in the given vector.
 fn reserve<@T>(&v: [mutable? T], n: uint) {
-    rustrt::vec_reserve_shared(v, n);
+    log_err("reserve: v=", ptr::addr_of(v), " n=", n);
+    rustrt::vec_reserve_shared(null(), sys::get_type_desc::<T>(), v, n);
 }
 
 pure fn len<T>(v: [mutable? T]) -> uint { unchecked { rusti::vec_len(v) } }
@@ -352,7 +359,8 @@ mod unsafe {
     type vec_repr = {mutable fill: uint, mutable alloc: uint, data: u8};
 
     unsafe fn from_buf<@T>(ptr: *T, elts: uint) -> [T] {
-        ret rustrt::vec_from_buf_shared(ptr, elts);
+        ret rustrt::vec_from_buf_shared(null(), sys::get_type_desc::<T>(),
+                                        ptr, elts);
     }
 
     unsafe fn set_len<@T>(&v: [T], new_len: uint) {