localedata: Months updated from CLDR - Bengali scripts [BZ #21217]
[glibc.git] / sysdeps / powerpc / tst-tlsopt-powerpc.c
blob8ae928a3f4c70c597c1adcd750cbee34573b5ece
1 /* glibc test for __tls_get_addr optimization. */
2 #include <stdio.h>
4 #include "../../elf/tls-macros.h"
5 #include "dl-tls.h"
7 /* common 'int' variable in TLS. */
8 COMMON_INT_DEF(foo);
11 static int
12 do_test (void)
14 int result = 0;
16 /* Get variable using general dynamic model. */
17 int *ap = TLS_GD (foo);
18 if (*ap != 0)
20 printf ("foo = %d\n", *ap);
21 result = 1;
24 tls_index *tls_arg;
25 #ifdef __powerpc64__
26 register unsigned long thread_pointer __asm__ ("r13");
27 asm ("addi %0,2,foo@got@tlsgd" : "=r" (tls_arg));
28 #else
29 register unsigned long thread_pointer __asm__ ("r2");
30 asm ("bcl 20,31,1f\n1:\t"
31 "mflr %0\n\t"
32 "addis %0,%0,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t"
33 "addi %0,%0,_GLOBAL_OFFSET_TABLE_-1b@l\n\t"
34 "addi %0,%0,foo@got@tlsgd" : "=b" (tls_arg));
35 #endif
37 if (tls_arg->ti_module != 0)
39 printf ("tls_index not optimized, binutils too old?\n");
40 result = 1;
42 else if (tls_arg->ti_offset + thread_pointer != (unsigned long) ap)
44 printf ("tls_index->ti_offset wrong value\n");
45 result = 1;
48 return result;
51 #include <support/test-driver.c>