]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dlopen-in-init3.dtest/bar.c
6 #include "test_support.h"
8 static void* bazHandle
= NULL
;
9 static void* bazSymbol
= NULL
;
10 static int barInited
= 0;
11 static int bazInited
= 0;
13 __attribute__((constructor
))
14 static void myinit(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
16 bazHandle
= dlopen(RUN_DIR
"/libbaz.dylib", 0);
17 if ( bazHandle
== NULL
) {
18 FAIL("dlopen libbaz.dylib: %s", dlerror());
20 bazSymbol
= dlsym(RTLD_DEFAULT
, "bazIsInited");
21 if ( bazSymbol
== NULL
) {
22 FAIL("dlsym libbaz.dylib");
24 bazInited
= ((int(*)())bazSymbol
)();
28 if ( barInited
== 0 ) {
29 FAIL("Didn't init bar");
31 if ( bazHandle
== NULL
) {
32 FAIL("bazHandle not inited");
34 if ( bazSymbol
== NULL
) {
35 FAIL("bazSymbol not inited");
37 if ( bazInited
== 0 ) {
38 FAIL("didn't init bar");