add _DEFAULT_SOURCE wherever _BSD_SOURCE was used
[libc-test] / src / functional / tls_init_dlopen.c
1 #include <string.h>
2 #include <dlfcn.h>
3 #include "test.h"
4
5 int main()
6 {
7         void *h;
8         char *(*f)(void);
9         char *s;
10
11         h = dlopen("src/functional/tls_init_dso.so", RTLD_NOW|RTLD_GLOBAL);
12         if (!h)
13                 t_error("dlopen failed: %s\n", dlerror());
14         f = dlsym(h, "gettls");
15         if (!f)
16                 t_error("dlsym failed: %s\n", dlerror());
17         s = f();
18         if (!s)
19                 t_error("tls was not initialized at dlopen\n");
20         if (strcmp(s, "foobar")!=0)
21                 t_error("tls was not initialized correctly at dlopen (got \"%s\", want \"foobar\"\n", s);
22
23         return t_status;
24 }