]> git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/static-terminators.dtest/base.c
dyld-732.8.tar.gz
[apple/dyld.git] / testing / test-cases / static-terminators.dtest / base.c
1 #include <stddef.h>
2 #include <stdio.h>
3 #include <stdbool.h>
4
5 static bool mainCalled = false;
6 static bool libCalled = false;
7 static bool libCalledBeforeMain = false;
8
9 void mainTerminated()
10 {
11 mainCalled = true;
12 }
13
14 void libDynamicTerminated()
15 {
16 libCalled = true;
17 if ( !mainCalled )
18 libCalledBeforeMain = true;
19 }
20
21
22 static __attribute__((destructor))
23 void myTerm()
24 {
25 if ( !mainCalled )
26 printf("[FAIL] static-terminators, main's terminator not called\n");
27 else if ( !libCalled )
28 printf("[FAIL] static-terminators, libDynamic's terminator not called\n");
29 else if ( !libCalledBeforeMain )
30 printf("[FAIL] static-terminators, libDynamic's terminator called out of order\n");
31 else
32 printf("[PASS] static-terminators\n");
33 }
34