hppa: Remove custom lowlevellock.h.
[glibc.git] / elf / tst-tls2.c
blobd0b6d51402d486207420ec7be3d9e7bdde36a5c8
1 /* glibc test for TLS in ld.so. */
2 #include <stdio.h>
4 #include "tls-macros.h"
7 /* Two 'int' variables in TLS. */
8 VAR_INT_DEF(foo);
9 VAR_INT_DEF(bar);
12 #define TEST_FUNCTION do_test ()
13 static int
14 do_test (void)
16 int result = 0;
17 int *ap, *bp;
20 /* Set the variable using the local exec model. */
21 puts ("set bar to 1 (LE)");
22 ap = TLS_LE (bar);
23 *ap = 1;
26 /* Get variables using initial exec model. */
27 fputs ("get sum of foo and bar (IE)", stdout);
28 ap = TLS_IE (foo);
29 bp = TLS_IE (bar);
30 printf (" = %d\n", *ap + *bp);
31 result |= *ap + *bp != 1;
32 if (*ap != 0)
34 printf ("foo = %d\n", *ap);
35 result = 1;
37 if (*bp != 1)
39 printf ("bar = %d\n", *bp);
40 result = 1;
44 /* Get variables using local dynamic model. */
45 fputs ("get sum of foo and bar (LD)", stdout);
46 ap = TLS_LD (foo);
47 bp = TLS_LD (bar);
48 printf (" = %d\n", *ap + *bp);
49 result |= *ap + *bp != 1;
50 if (*ap != 0)
52 printf ("foo = %d\n", *ap);
53 result = 1;
55 if (*bp != 1)
57 printf ("bar = %d\n", *bp);
58 result = 1;
62 /* Get variables using generic dynamic model. */
63 fputs ("get sum of foo and bar (GD)", stdout);
64 ap = TLS_GD (foo);
65 bp = TLS_GD (bar);
66 printf (" = %d\n", *ap + *bp);
67 result |= *ap + *bp != 1;
68 if (*ap != 0)
70 printf ("foo = %d\n", *ap);
71 result = 1;
73 if (*bp != 1)
75 printf ("bar = %d\n", *bp);
76 result = 1;
79 return result;
83 #include "../test-skeleton.c"