aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tls/pr58595.c
blob: e7827d79d77ea26e57ad97834c1f69d98ec34b4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* PR target/58595 */
/* { dg-do run } */
/* { dg-options "-O2" } */
/* { dg-additional-options "-fpic" { target fpic } } */
/* { dg-add-options tls } */
/* { dg-require-effective-target tls_runtime } */
/* { dg-require-effective-target sync_int_long } */

struct S { unsigned long a, b; };
__thread struct S s;
void bar (unsigned long *);

__attribute__((noinline)) void
foo (void)
{
  int i;
  for (i = 0; i < 10; i++)
    __sync_fetch_and_add (&s.b, 1L);
}

int
main ()
{
  s.b = 12;
  foo ();
  if (s.b != 22)
    __builtin_abort ();
  return 0;
}