]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/thread-local-atexit.dtest/main.cpp
d86dcabda8983f844907f009ef56a0302772b7ca
2 // BUILD: $CXX main.cpp -std=c++11 -o $BUILD_DIR/thread-local-atexit.exe
4 // RUN: ./thread-local-atexit.exe
10 // We create an A and a B.
11 // While destroying B we create a C
12 // Given that tlv_finalize has "destroy in reverse order of construction", we
13 // must then immediately destroy C before we destroy A to maintain that invariant
44 if ( state
!= None
) {
45 printf("[FAIL] thread-local-atexit: should be in the 'None' state\n");
51 if ( state
!= ConstructedA
) {
52 printf("[FAIL] thread-local-atexit: should be in the 'ConstructedA' state\n");
59 // We construct C during B's destructor
60 if ( state
!= DestroyingB
) {
61 printf("[FAIL] thread-local-atexit: should be in the 'DestroyingB' state\n");
69 if ( state
!= ConstructedB
) {
70 printf("[FAIL] thread-local-atexit: should be in the 'ConstructedB' state\n");
74 static thread_local C c
;
75 if ( state
!= ConstructedC
) {
76 printf("[FAIL] thread-local-atexit: should be in the 'ConstructedC' state\n");
84 if ( state
!= DestroyedB
) {
85 printf("[FAIL] thread-local-atexit: should be in the 'DestroyedB' state\n");
91 // And finally destroy A
93 if ( state
!= DestroyedC
) {
94 printf("[FAIL] thread-local-atexit: should be in the 'DestroyedC' state\n");
98 printf("[PASS] thread-local-atexit\n");
101 static void* work(void* arg
)
110 printf("[BEGIN] thread-local-atexit\n");
113 if ( pthread_create(&worker
, NULL
, work
, NULL
) != 0 ) {
114 printf("[FAIL] thread-local-atexit, pthread_create\n");
119 pthread_join(worker
, &dummy
);