]> git.ipfire.org Git - thirdparty/glibc.git/blame - elf/tst-tls3.c
Add page tests to string/test-strnlen.
[thirdparty/glibc.git] / elf / tst-tls3.c
CommitLineData
2e36cb48
UD
1/* glibc test for TLS in ld.so. */
2#include <stdio.h>
3
11bf311e 4#include "tls-macros.h"
100e184f
UD
5
6
2e36cb48
UD
7/* One define int variable, two externs. */
8COMMON_INT_DECL(foo);
9VAR_INT_DECL(bar);
10VAR_INT_DEF(baz);
11
12
13extern int in_dso (void);
14
15
aed283dd
UD
16#define TEST_FUNCTION do_test ()
17static int
18do_test (void)
2e36cb48 19{
2e36cb48
UD
20 int result = 0;
21 int *ap, *bp, *cp;
22
23
24 /* Set the variable using the local exec model. */
25 puts ("set baz to 3 (LE)");
26 ap = TLS_LE (baz);
27 *ap = 3;
28
29
30 /* Get variables using initial exec model. */
31 puts ("set variables foo and bar (IE)");
32 ap = TLS_IE (foo);
33 *ap = 1;
34 bp = TLS_IE (bar);
35 *bp = 2;
36
37
38 /* Get variables using local dynamic model. */
39 fputs ("get sum of foo, bar (GD) and baz (LD)", stdout);
40 ap = TLS_GD (foo);
41 bp = TLS_GD (bar);
42 cp = TLS_LD (baz);
43 printf (" = %d\n", *ap + *bp + *cp);
44 result |= *ap + *bp + *cp != 6;
45 if (*ap != 1)
46 {
47 printf ("foo = %d\n", *ap);
48 result = 1;
49 }
50 if (*bp != 2)
51 {
52 printf ("bar = %d\n", *bp);
53 result = 1;
54 }
55 if (*cp != 3)
56 {
57 printf ("baz = %d\n", *cp);
58 result = 1;
59 }
60
61
62 result |= in_dso ();
63
64 return result;
2e36cb48 65}
aed283dd
UD
66
67
68#include "../test-skeleton.c"