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