Limit dg-xfail-run-if for *-*-hpux11.[012]* to -O0
[official-gcc.git] / libphobos / testsuite / libphobos.thread / external_threads.d
blob9c98a3fa13d172df008d6edc5d1120461c824f78
1 import core.sys.posix.pthread;
2 import core.memory;
3 import core.thread;
5 extern (C) void rt_moduleTlsCtor();
6 extern (C) void rt_moduleTlsDtor();
8 extern(C)
9 void* entry_point1(void*)
11 // try collecting - GC must ignore this call because this thread
12 // is not registered in runtime
13 GC.collect();
14 return null;
17 extern(C)
18 void* entry_point2(void*)
20 // This thread gets registered in druntime, does some work and gets
21 // unregistered to be cleaned up manually
22 thread_attachThis();
23 rt_moduleTlsCtor();
25 auto x = new int[10];
27 rt_moduleTlsDtor();
28 thread_detachThis();
29 return null;
32 void main()
34 // allocate some garbage
35 auto x = new int[1000];
38 pthread_t thread;
39 auto status = pthread_create(&thread, null, &entry_point1, null);
40 assert(status == 0);
41 pthread_join(thread, null);
45 pthread_t thread;
46 auto status = pthread_create(&thread, null, &entry_point2, null);
47 assert(status == 0);
48 pthread_join(thread, null);