1.0.28.44: better MACHINE-VERSION answers on BSD'ish platforms
[sbcl.git] / tools-for-build / os-provides-dladdr-test.c
1 /* test to build and run so that we know if we have dladdr
2  */
3
4 #include <stdlib.h>
5
6 /* bloody FSF dlcfn.h won't give us dladdr without this */
7 #define _GNU_SOURCE
8
9 #include <dlfcn.h>
10
11 int main ()
12 {
13    void * handle = dlopen((void*)0, RTLD_GLOBAL | RTLD_NOW);
14    void * addr = dlsym(handle, "printf");
15    Dl_info * info = (Dl_info*) malloc(sizeof(Dl_info));
16    dladdr(addr, info);
17    if (strcmp(info->dli_sname, "printf")) {
18        return 1;
19    } else {
20        return 104;
21    }
22 }