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 | /* glibc test for TLS in ld.so. */
|
---|
2 | #include <stdio.h>
|
---|
3 |
|
---|
4 | #include <tls.h>
|
---|
5 |
|
---|
6 | #ifdef USE_TLS
|
---|
7 | # include "tls-macros.h"
|
---|
8 |
|
---|
9 |
|
---|
10 | /* One define int variable, two externs. */
|
---|
11 | COMMON_INT_DECL(foo);
|
---|
12 | VAR_INT_DECL(bar);
|
---|
13 | VAR_INT_DEF(baz);
|
---|
14 | #endif
|
---|
15 |
|
---|
16 |
|
---|
17 | extern int in_dso (void);
|
---|
18 |
|
---|
19 |
|
---|
20 | #define TEST_FUNCTION do_test ()
|
---|
21 | static int
|
---|
22 | do_test (void)
|
---|
23 | {
|
---|
24 | #ifdef USE_TLS
|
---|
25 | int result = 0;
|
---|
26 | int *ap, *bp, *cp;
|
---|
27 |
|
---|
28 |
|
---|
29 | /* Set the variable using the local exec model. */
|
---|
30 | puts ("set baz to 3 (LE)");
|
---|
31 | ap = TLS_LE (baz);
|
---|
32 | *ap = 3;
|
---|
33 |
|
---|
34 |
|
---|
35 | /* Get variables using initial exec model. */
|
---|
36 | puts ("set variables foo and bar (IE)");
|
---|
37 | ap = TLS_IE (foo);
|
---|
38 | *ap = 1;
|
---|
39 | bp = TLS_IE (bar);
|
---|
40 | *bp = 2;
|
---|
41 |
|
---|
42 |
|
---|
43 | /* Get variables using local dynamic model. */
|
---|
44 | fputs ("get sum of foo, bar (GD) and baz (LD)", stdout);
|
---|
45 | ap = TLS_GD (foo);
|
---|
46 | bp = TLS_GD (bar);
|
---|
47 | cp = TLS_LD (baz);
|
---|
48 | printf (" = %d\n", *ap + *bp + *cp);
|
---|
49 | result |= *ap + *bp + *cp != 6;
|
---|
50 | if (*ap != 1)
|
---|
51 | {
|
---|
52 | printf ("foo = %d\n", *ap);
|
---|
53 | result = 1;
|
---|
54 | }
|
---|
55 | if (*bp != 2)
|
---|
56 | {
|
---|
57 | printf ("bar = %d\n", *bp);
|
---|
58 | result = 1;
|
---|
59 | }
|
---|
60 | if (*cp != 3)
|
---|
61 | {
|
---|
62 | printf ("baz = %d\n", *cp);
|
---|
63 | result = 1;
|
---|
64 | }
|
---|
65 |
|
---|
66 |
|
---|
67 | result |= in_dso ();
|
---|
68 |
|
---|
69 | return result;
|
---|
70 | #else
|
---|
71 | return 0;
|
---|
72 | #endif
|
---|
73 | }
|
---|
74 |
|
---|
75 |
|
---|
76 | #include "../test-skeleton.c"
|
---|
Note:
See
TracBrowser
for help on using the repository browser.