Last change
on this file was 2036, checked in by bird, 20 years ago |
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1.2 KB
|
Line | |
---|
1 | #include <dlfcn.h>
|
---|
2 | #include <stdio.h>
|
---|
3 | #include <stdlib.h>
|
---|
4 |
|
---|
5 | #include <link.h>
|
---|
6 | #include <tls.h>
|
---|
7 |
|
---|
8 |
|
---|
9 | #define TEST_FUNCTION do_test ()
|
---|
10 | static int
|
---|
11 | do_test (void)
|
---|
12 | {
|
---|
13 | #ifdef USE_TLS
|
---|
14 | static const char modname[] = "tst-tlsmod3.so";
|
---|
15 | int result = 0;
|
---|
16 | int (*fp) (void);
|
---|
17 | void *h;
|
---|
18 | int i;
|
---|
19 | int modid = -1;
|
---|
20 |
|
---|
21 | for (i = 0; i < 10; ++i)
|
---|
22 | {
|
---|
23 | h = dlopen (modname, RTLD_LAZY);
|
---|
24 | if (h == NULL)
|
---|
25 | {
|
---|
26 | printf ("cannot open '%s': %s\n", modname, dlerror ());
|
---|
27 | exit (1);
|
---|
28 | }
|
---|
29 |
|
---|
30 | /* Dirty test code here: we peek into a private data structure.
|
---|
31 | We make sure that the module gets assigned the same ID every
|
---|
32 | time. The value of the first round is used. */
|
---|
33 | if (modid == -1)
|
---|
34 | modid = ((struct link_map *) h)->l_tls_modid;
|
---|
35 | else if (((struct link_map *) h)->l_tls_modid != (size_t) modid)
|
---|
36 | {
|
---|
37 | printf ("round %d: modid now %zu, initially %d\n",
|
---|
38 | i, ((struct link_map *) h)->l_tls_modid, modid);
|
---|
39 | result = 1;
|
---|
40 | }
|
---|
41 |
|
---|
42 | fp = dlsym (h, "in_dso2");
|
---|
43 | if (fp == NULL)
|
---|
44 | {
|
---|
45 | printf ("cannot get symbol 'in_dso2': %s\n", dlerror ());
|
---|
46 | exit (1);
|
---|
47 | }
|
---|
48 |
|
---|
49 | result |= fp ();
|
---|
50 |
|
---|
51 | dlclose (h);
|
---|
52 | }
|
---|
53 |
|
---|
54 | return result;
|
---|
55 | #else
|
---|
56 | return 0;
|
---|
57 | #endif
|
---|
58 | }
|
---|
59 |
|
---|
60 |
|
---|
61 | #include "../test-skeleton.c"
|
---|
Note:
See
TracBrowser
for help on using the repository browser.