Unbreak non-x86 builds
[sbcl.git] / tools-for-build / os-provides-dladdr-test.c
blob17817b4bffb2167846537615ef41ea94680189bd
1 /* test to build and run so that we know if we have dladdr
2 */
4 /* bloody FSF dlcfn.h won't give us dladdr without this */
5 #define _GNU_SOURCE
7 #include <stdlib.h>
8 #include <dlfcn.h>
10 #ifdef __NetBSD__
11 #include <sys/param.h>
12 #endif
14 int main ()
16 #if defined(__NetBSD_Version__) && __NetBSD_Version__ < 700000001
17 /* dladdr(3) is broken on some NetBSD versions before 7.0 */
18 return 1;
19 #else
20 void * handle = dlopen((void*)0, RTLD_GLOBAL | RTLD_NOW);
21 void * addr = dlsym(handle, "printf");
22 Dl_info * info = (Dl_info*) malloc(sizeof(Dl_info));
23 if (dladdr(addr, info) == 0) {
24 return 1;
25 } else {
26 return 104;
28 #endif