1/* 2TEST_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 5END 6*/ 7 8#include "test.h" 9#include <dlfcn.h> 10 11int state1 = 0; 12int *state2_p; 13 14OBJC_ROOT_CLASS 15@interface One @end 16@implementation One 17+(void)load 18{ 19 state1 = 111; 20 21 // Re-entrant +load doesn't get to complete until we do 22 void *dlh = dlopen("libload-reentrant2.dylib", RTLD_LAZY); 23 testassert(dlh); 24 state2_p = (int *)dlsym(dlh, "state2"); 25 testassert(state2_p); 26 testassert(*state2_p == 0); 27 28 state1 = 1; 29} 30@end 31 32int main() 33{ 34 testassert(state1 == 1 && state2_p && *state2_p == 2); 35 succeed(__FILE__); 36} 37