6 throw new Exception(null);
9 Exception
collectException(void delegate() dg
)
19 __gshared Object root
;
20 void alloc() { root
= new Object(); }
21 void access() { assert(root
.toString() !is null); } // vtbl call will fail if finalized
22 void free() { root
= null; }
25 void tls_alloc() { tls_root
= new Object(); }
26 void tls_access() { assert(tls_root
.toString() !is null); } // vtbl call will fail if finalized
27 void tls_free() { tls_root
= null; }
29 void stack(alias func
)()
31 // allocate some extra stack space to not keep references to GC memory on the scanned stack
32 ubyte[1024] buf
= void;
52 import core
.atomic
: atomicOp
;
53 shared uint shared_static_ctor
, shared_static_dtor
, static_ctor
, static_dtor
;
54 shared static this() { if (atomicOp
!"+="(shared_static_ctor
, 1) != 1) assert(0); }
55 shared static ~this() { if (atomicOp
!"+="(shared_static_dtor
, 1) != 1) assert(0); }
56 static this() { atomicOp
!"+="(static_ctor
, 1); }
57 static ~this() { atomicOp
!"+="(static_dtor
, 1); }
59 extern(C
) int runTests()
78 assert(collectException({throwException();}) !is null);
82 assert(shared_static_ctor
== 1);
83 assert(static_ctor
== 1);
86 assert(static_ctor
== 2);
87 assert(shared_static_ctor
== 1);
90 auto thr
= new Thread(&run
);
93 assert(static_dtor
== 1);
96 foreach (m
; ModuleInfo
)
97 if (m
.name
== "lib") passed
= true;
101 // Provide a way to initialize D from C programs that are D agnostic.
102 import core
.runtime
: rt_init
, rt_term
;
104 extern(C
) int lib_init()
109 extern(C
) int lib_term()
114 shared size_t
* _finalizeCounter
;
121 atomicOp
!"+="(*_finalizeCounter
, 1);
125 class MyFinalizerBig
: MyFinalizer
127 ubyte[4096] _big
= void;
130 extern(C
) void setFinalizeCounter(shared(size_t
)* p
)
132 _finalizeCounter
= p
;