summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr67043.c
blob: 36aa68673f15ef1e768830ec1ce98fe7f0da0713 (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
30
31
32
/* { dg-do compile } */
/* { dg-options "-O3 -fcompare-debug -w" } */

extern void rt_mutex_owner (void);
extern void rt_mutex_deadlock_account_lock (int);
extern void signal_pending (void);
__typeof__ (int *) a;
int b;

int
try_to_take_rt_mutex (int p1) {
  rt_mutex_owner ();
  if (b)
    return 0;
  rt_mutex_deadlock_account_lock (p1);
  return 1;
}

void
__rt_mutex_slowlock (int p1) {
  int c;
  for (;;) {
    c = ({
      asm ("" : "=r"(a));
      a;
    });
    if (try_to_take_rt_mutex (c))
      break;
    if (__builtin_expect (p1 == 0, 0))
      signal_pending ();
  }
}