]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen-in-init2.dtest/foo.c
6 #include "test_support.h"
8 extern int bazInited();
10 static void* barHandle
= NULL
;
11 static void* barSymbol
= NULL
;
12 static int fooInited
= 0;
13 static int barInited
= 0;
15 __attribute__((constructor
))
16 static void myinit(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
18 barHandle
= dlopen(RUN_DIR
"/libbar.dylib", 0);
19 if ( barHandle
== NULL
) {
20 FAIL("dlopen libbar.dylib: %s", dlerror());
22 barSymbol
= dlsym(RTLD_DEFAULT
, "barIsInited");
23 if ( barSymbol
== NULL
) {
24 FAIL("dlsym libbar.dylib");
26 barInited
= ((int(*)())barSymbol
)();
30 if ( fooInited
== 0 ) {
31 FAIL("Didn't init foo");
33 if ( barHandle
== NULL
) {
34 FAIL("barHandle not inited");
36 if ( barSymbol
== NULL
) {
37 FAIL("barSymbol not inited");
39 if ( barInited
== 0 ) {
40 FAIL("Didn't init bar");
42 if ( bazInited() == 0 ) {
43 FAIL("Didn't init baz");