]> git.ipfire.org Git - thirdparty/glibc.git/blame - elf/tst-tls3.c
alloc_buffer: Return unqualified pointer type in alloc_buffer_next
[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
16static int
17do_test (void)
2e36cb48 18{
2e36cb48
UD
19 int result = 0;
20 int *ap, *bp, *cp;
21
22
23 /* Set the variable using the local exec model. */
24 puts ("set baz to 3 (LE)");
25 ap = TLS_LE (baz);
26 *ap = 3;
27
28
29 /* Get variables using initial exec model. */
30 puts ("set variables foo and bar (IE)");
31 ap = TLS_IE (foo);
32 *ap = 1;
33 bp = TLS_IE (bar);
34 *bp = 2;
35
36
37 /* Get variables using local dynamic model. */
38 fputs ("get sum of foo, bar (GD) and baz (LD)", stdout);
39 ap = TLS_GD (foo);
40 bp = TLS_GD (bar);
41 cp = TLS_LD (baz);
42 printf (" = %d\n", *ap + *bp + *cp);
43 result |= *ap + *bp + *cp != 6;
44 if (*ap != 1)
45 {
46 printf ("foo = %d\n", *ap);
47 result = 1;
48 }
49 if (*bp != 2)
50 {
51 printf ("bar = %d\n", *bp);
52 result = 1;
53 }
54 if (*cp != 3)
55 {
56 printf ("baz = %d\n", *cp);
57 result = 1;
58 }
59
60
61 result |= in_dso ();
62
63 return result;
2e36cb48 64}
aed283dd
UD
65
66
36fe25fd 67#include <support/test-driver.c>