| 1 |
/* testsuite/gcc.target/arm/pr48183.c */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-require-effective-target arm_arch_v7a_arm_ok } */ |
| 4 |
/* { dg-skip-if "-mslow-flash-data and -mword-relocations incompatible" { *-*-* } { "-mslow-flash-data" } } */ |
| 5 |
/* { dg-skip-if "-mpure-code and -mword-relocations incompatible" { *-*-* } { "-mpure-code" } } */ |
| 6 |
/* { dg-options "-O2 -mword-relocations -std=c17" } */ |
| 7 |
/* { dg-add-options arm_arch_v7a_arm } */ |
| 8 |
/* { dg-final { scan-assembler-not "\[\\t \]+movw" } } */ |
| 9 |
|
| 10 |
int a, d, f; |
| 11 |
long b; |
| 12 |
struct ww_class { |
| 13 |
int stamp; |
| 14 |
} c; |
| 15 |
struct stress { |
| 16 |
int locks; |
| 17 |
int nlocks; |
| 18 |
}; |
| 19 |
void *e; |
| 20 |
int atomic_add_return_relaxed(int *p1) { |
| 21 |
__builtin_prefetch(p1); |
| 22 |
return a; |
| 23 |
} |
| 24 |
void atomic_long_inc_return_relaxed(int *p1) { |
| 25 |
int *v = p1; |
| 26 |
atomic_add_return_relaxed(v); |
| 27 |
} |
| 28 |
void ww_acquire_init(struct ww_class *p1) { |
| 29 |
atomic_long_inc_return_relaxed(&p1->stamp); |
| 30 |
} |
| 31 |
void ww_mutex_lock(); |
| 32 |
int *get_random_order(); |
| 33 |
void stress_inorder_work() { |
| 34 |
struct stress *g = e; |
| 35 |
int h = g->nlocks; |
| 36 |
int *i = &g->locks, *j = get_random_order(); |
| 37 |
do { |
| 38 |
int n; |
| 39 |
ww_acquire_init(&c); |
| 40 |
retry: |
| 41 |
for (n = 0; n < h; n++) |
| 42 |
ww_mutex_lock(i[j[n]]); |
| 43 |
f = n; |
| 44 |
if (d) |
| 45 |
goto retry; |
| 46 |
} while (b); |
| 47 |
} |
| 48 |
|