]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/thread-local-atexit.dtest/main.cpp
2 // BUILD: $CXX main.cpp -std=c++11 -o $BUILD_DIR/thread-local-atexit.exe
4 // RUN: ./thread-local-atexit.exe
10 #include "test_support.h"
12 // We create an A and a B.
13 // While destroying B we create a C
14 // Given that tlv_finalize has "destroy in reverse order of construction", we
15 // must then immediately destroy C before we destroy A to maintain that invariant
46 if ( state
!= None
) {
47 FAIL("Should be in the 'None' state");
53 if ( state
!= ConstructedA
) {
54 FAIL("Should be in the 'ConstructedA' state");
60 // We construct C during B's destructor
61 if ( state
!= DestroyingB
) {
62 FAIL("Should be in the 'DestroyingB' state");
69 if ( state
!= ConstructedB
) {
70 FAIL("Should be in the 'ConstructedB' state");
73 static thread_local C c
;
74 if ( state
!= ConstructedC
) {
75 FAIL("Should be in the 'ConstructedC' state");
82 if ( state
!= DestroyedB
) {
83 FAIL("Should be in the 'DestroyedB' state");
88 // And finally destroy A
90 if ( state
!= DestroyedC
) {
91 FAIL("Should be in the 'DestroyedC' state");
97 static void* work(void* arg
)
105 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
107 if ( pthread_create(&worker
, NULL
, work
, NULL
) != 0 ) {
108 FAIL("pthread_create");
112 pthread_join(worker
, &dummy
);