Fix -Wundef warning for HAVE_OBSTACK
[glibc.git] / elf / tst-tls7.c
blob23a16e44897d6f17f9cdfb32b6b63d429b144d6f
1 #include <dlfcn.h>
2 #include <stdio.h>
3 #include <stdlib.h>
5 #include <link.h>
8 #define TEST_FUNCTION do_test ()
9 static int
10 do_test (void)
12 static const char modname[] = "tst-tlsmod3.so";
13 int result = 0;
14 int (*fp) (void);
15 void *h;
16 int i;
17 int modid = -1;
19 for (i = 0; i < 10; ++i)
21 h = dlopen (modname, RTLD_LAZY);
22 if (h == NULL)
24 printf ("cannot open '%s': %s\n", modname, dlerror ());
25 exit (1);
28 /* Dirty test code here: we peek into a private data structure.
29 We make sure that the module gets assigned the same ID every
30 time. The value of the first round is used. */
31 if (modid == -1)
32 modid = ((struct link_map *) h)->l_tls_modid;
33 else if (((struct link_map *) h)->l_tls_modid != (size_t) modid)
35 printf ("round %d: modid now %zu, initially %d\n",
36 i, ((struct link_map *) h)->l_tls_modid, modid);
37 result = 1;
40 fp = dlsym (h, "in_dso2");
41 if (fp == NULL)
43 printf ("cannot get symbol 'in_dso2': %s\n", dlerror ());
44 exit (1);
47 result |= fp ();
49 dlclose (h);
52 return result;
56 #include "../test-skeleton.c"