Skip to content

Commit 7ea416f

Browse files
committed
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)
1 parent 9236ad2 commit 7ea416f

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/lib/sys.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ native "rust" mod rustrt {
33
fn size_of[T]() -> uint;
44
fn align_of[T]() -> uint;
55
fn refcount[T](@T t) -> uint;
6+
fn gc();
67
}
78

src/rt/rust_builtin.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ refcount(rust_task *task, type_desc *t, size_t *v) {
8181
return (*v) - 1;
8282
}
8383

84+
extern "C" CDECL void
85+
gc(rust_task *task) {
86+
task->gc(1);
87+
}
88+
8489
extern "C" CDECL rust_vec*
8590
vec_alloc(rust_task *task, type_desc *t, size_t n_elts)
8691
{

src/test/run-pass/mlist-cycle.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
// -*- rust -*-
22

3+
use std;
4+
35
type cell = tup(mutable @list);
46
type list = tag(link(@cell), nil());
57

68
fn main() {
79
let @cell first = tup(@nil());
810
let @cell second = tup(@link(first));
911
first._0 = link(second);
12+
std.sys.rustrt.gc();
13+
let @cell third = tup(@nil());
1014
}

0 commit comments

Comments
 (0)