1 import core
.thread
, core
.memory
, core
.atomic
;
4 shared uint gctor
, gdtor
, tctor
, tdtor
;
5 shared static this() { if (atomicOp
!"+="(gctor
, 1) != 1) assert(0); }
6 shared static ~this() { if (atomicOp
!"+="(gdtor
, 1) != 1) assert(0); }
7 static this() { atomicOp
!"+="(tctor
, 1); }
8 static ~this() { atomicOp
!"+="(tdtor
, 1); }
11 __gshared Object root
;
12 void alloc() { root
= new Object(); }
13 void access() { assert(root
.toString() !is null); } // vtbl call will fail if finalized
14 void free() { root
= null; }
17 void tls_alloc() { tls_root
= new Object(); }
18 void tls_access() { assert(tls_root
.toString() !is null); } // vtbl call will fail if finalized
19 void tls_free() { tls_root
= null; }
21 void stack(alias func
)()
23 // allocate some extra stack space to not keep references to GC memory on the scanned stack
24 ubyte[1024] buf
= void;
43 extern(C
) int runTests()
47 assert(atomicLoad
!(MemoryOrder
.acq
)(gctor
) == 1);
48 assert(atomicLoad
!(MemoryOrder
.acq
)(gdtor
) == 0);
49 assert(atomicLoad
!(MemoryOrder
.acq
)(tctor
) >= 1);
50 assert(atomicLoad
!(MemoryOrder
.acq
)(tdtor
) >= 0);
51 // test some runtime functionality
53 new Thread(&testGC
).start
.join
;
62 // Provide a way to initialize D from C programs that are D agnostic.
63 import core
.runtime
: rt_init
, rt_term
;
65 extern(C
) int plugin_init()
70 extern(C
) int plugin_term()