| 1 |
/* PR target/58595 */ |
| 2 |
/* { dg-do run } */ |
| 3 |
/* { dg-options "-O2" } */ |
| 4 |
/* { dg-additional-options "-fpic" { target fpic } } */ |
| 5 |
/* { dg-add-options tls } */ |
| 6 |
/* { dg-require-effective-target tls_runtime } */ |
| 7 |
/* { dg-require-effective-target sync_int_long } */ |
| 8 |
|
| 9 |
struct S { unsigned long a, b; }; |
| 10 |
__thread struct S s; |
| 11 |
void bar (unsigned long *); |
| 12 |
|
| 13 |
__attribute__((noinline)) void |
| 14 |
foo (void) |
| 15 |
{ |
| 16 |
int i; |
| 17 |
for (i = 0; i < 10; i++) |
| 18 |
__sync_fetch_and_add (&s.b, 1L); |
| 19 |
} |
| 20 |
|
| 21 |
int |
| 22 |
main () |
| 23 |
{ |
| 24 |
s.b = 12; |
| 25 |
foo (); |
| 26 |
if (s.b != 22) |
| 27 |
__builtin_abort (); |
| 28 |
return 0; |
| 29 |
} |