]> git.saurik.com Git - apple/objc4.git/blob - test/load-reentrant.m
objc4-493.9.tar.gz
[apple/objc4.git] / test / load-reentrant.m
1 /*
2 TEST_BUILD
3 $C{COMPILE} $DIR/load-reentrant.m -o load-reentrant.out
4 $C{COMPILE} $DIR/load-reentrant2.m -o libload-reentrant2.dylib -bundle -bundle_loader load-reentrant.out
5 END
6 */
7
8 #include "test.h"
9 #include <dlfcn.h>
10
11 int state1 = 0;
12 int *state2_p;
13
14 @interface One @end
15 @implementation One
16 +(void)load
17 {
18 state1 = 111;
19
20 // Re-entrant +load doesn't get to complete until we do
21 void *dlh = dlopen("libload-reentrant2.dylib", RTLD_LAZY);
22 testassert(dlh);
23 state2_p = (int *)dlsym(dlh, "state2");
24 testassert(state2_p);
25 testassert(*state2_p == 0);
26
27 state1 = 1;
28 }
29 @end
30
31 int main()
32 {
33 testassert(state1 == 1 && state2_p && *state2_p == 2);
34 succeed(__FILE__);
35 }