diff --git a/src/lib/sys.rs b/src/lib/sys.rs index 84da28f7253..3d858413375 100644 --- a/src/lib/sys.rs +++ b/src/lib/sys.rs @@ -3,5 +3,6 @@ fn size_of[T]() -> uint; fn align_of[T]() -> uint; fn refcount[T](@T t) -> uint; + fn gc(); } diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 71aa644b144..eb84355f169 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -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) { diff --git a/src/test/run-pass/mlist-cycle.rs b/src/test/run-pass/mlist-cycle.rs index 2a371317541..313455f8e68 100644 --- a/src/test/run-pass/mlist-cycle.rs +++ b/src/test/run-pass/mlist-cycle.rs @@ -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()); }