| 1 |
#include "analyzer-decls.h" |
| 2 |
|
| 3 |
struct S { long long a[16]; } s; |
| 4 |
|
| 5 |
struct S |
| 6 |
test_atomic_load (void) |
| 7 |
{ |
| 8 |
struct S r; |
| 9 |
__atomic_load (&s, &r, __ATOMIC_RELAXED); |
| 10 |
__analyzer_eval (r.a[0] == s.a[0]); /* { dg-warning "TRUE" } */ |
| 11 |
__analyzer_eval (r.a[15] == s.a[15]); /* { dg-warning "TRUE" } */ |
| 12 |
return r; |
| 13 |
} |
| 14 |
|
| 15 |
void |
| 16 |
test_atomic_store (struct S x) |
| 17 |
{ |
| 18 |
__atomic_store (&s, &x, __ATOMIC_RELAXED); |
| 19 |
__analyzer_eval (s.a[0] == x.a[0]); /* { dg-warning "TRUE" } */ |
| 20 |
__analyzer_eval (s.a[15] == x.a[15]); /* { dg-warning "TRUE" } */ |
| 21 |
} |
| 22 |
|
| 23 |
struct S |
| 24 |
test_atomic_exchange (struct S x) |
| 25 |
{ |
| 26 |
struct S init_x, init_s; |
| 27 |
struct S r; |
| 28 |
|
| 29 |
/* Capture initial values of x and s for comparison below. */ |
| 30 |
__atomic_load (&x, &init_x, __ATOMIC_RELAXED); |
| 31 |
__atomic_load (&s, &init_s, __ATOMIC_RELAXED); |
| 32 |
|
| 33 |
__atomic_exchange (&s, &x, &r, __ATOMIC_RELAXED); |
| 34 |
|
| 35 |
__analyzer_eval (s.a[0] == init_x.a[0]); /* { dg-warning "TRUE" } */ |
| 36 |
__analyzer_eval (s.a[15] == init_x.a[15]); /* { dg-warning "TRUE" } */ |
| 37 |
__analyzer_eval (r.a[0] == init_s.a[0]); /* { dg-warning "TRUE" } */ |
| 38 |
__analyzer_eval (r.a[15] == init_s.a[15]); /* { dg-warning "TRUE" } */ |
| 39 |
|
| 40 |
return r; |
| 41 |
} |
| 42 |
|
| 43 |
int |
| 44 |
test_atomic_compare_exchange (struct S *e, struct S *d) |
| 45 |
{ |
| 46 |
return __atomic_compare_exchange (&s, e, d, 0, |
| 47 |
__ATOMIC_RELAXED, __ATOMIC_RELAXED); |
| 48 |
} |