Add callable gc method exposed to user code, use it in mlist-cycle.rs test (still not quite working; some memory corruption in the recursive tag constructors, not the GC)

This commit is contained in:
Graydon Hoare 2010-06-25 23:57:30 -07:00
parent 9236ad2846
commit 7ea416f4c3
3 changed files with 10 additions and 0 deletions

View File

@ -3,5 +3,6 @@ native "rust" mod rustrt {
fn size_of[T]() -> uint;
fn align_of[T]() -> uint;
fn refcount[T](@T t) -> uint;
fn gc();
}

View File

@ -81,6 +81,11 @@ refcount(rust_task *task, type_desc *t, size_t *v) {
return (*v) - 1;
}
extern "C" CDECL void
gc(rust_task *task) {
task->gc(1);
}
extern "C" CDECL rust_vec*
vec_alloc(rust_task *task, type_desc *t, size_t n_elts)
{

View File

@ -1,5 +1,7 @@
// -*- rust -*-
use std;
type cell = tup(mutable @list);
type list = tag(link(@cell), nil());
@ -7,4 +9,6 @@ fn main() {
let @cell first = tup(@nil());
let @cell second = tup(@link(first));
first._0 = link(second);
std.sys.rustrt.gc();
let @cell third = tup(@nil());
}