Updated to fedora-glibc-20080612T1619
[glibc.git] / elf / tst-tls7.c
blob1edc2b63568ee821d245dcf151367d82b429af3d
1 #include <dlfcn.h>
2 #include <stdio.h>
3 #include <stdlib.h>
5 #include <link.h>
6 #include <tls.h>
9 #define TEST_FUNCTION do_test ()
10 static int
11 do_test (void)
13 static const char modname[] = "tst-tlsmod3.so";
14 int result = 0;
15 int (*fp) (void);
16 void *h;
17 int i;
18 int modid = -1;
20 for (i = 0; i < 10; ++i)
22 h = dlopen (modname, RTLD_LAZY);
23 if (h == NULL)
25 printf ("cannot open '%s': %s\n", modname, dlerror ());
26 exit (1);
29 /* Dirty test code here: we peek into a private data structure.
30 We make sure that the module gets assigned the same ID every
31 time. The value of the first round is used. */
32 if (modid == -1)
33 modid = ((struct link_map *) h)->l_tls_modid;
34 else if (((struct link_map *) h)->l_tls_modid != (size_t) modid)
36 printf ("round %d: modid now %zu, initially %d\n",
37 i, ((struct link_map *) h)->l_tls_modid, modid);
38 result = 1;
41 fp = dlsym (h, "in_dso2");
42 if (fp == NULL)
44 printf ("cannot get symbol 'in_dso2': %s\n", dlerror ());
45 exit (1);
48 result |= fp ();
50 dlclose (h);
53 return result;
57 #include "../test-skeleton.c"