summaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/cilk-plus/CK/steal_check.c
blob: 6b41c7faf041485000dbcb10c7dbcd1ebe7f891c (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* { dg-do run  { target { i?86-*-* x86_64-*-* } } } */
/* { dg-options "-fcilkplus" } */
/* { dg-additional-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */

#ifdef __cplusplus
extern "C" {
#endif

extern int __cilkrts_set_param (const char *, const char *);

#ifdef __cplusplus
}
#endif


void foo(volatile int *);

void main2(void);

int main(void)
{
  /* Ensure more than one worker.  */
  if (__cilkrts_set_param("nworkers", "2") != 0)
    __builtin_abort();

  main2();
  return 0;
}


void main2(void)
{
  int some_var = 0;

  _Cilk_spawn foo(&some_var);

  some_var=1;
  some_var=5;
  some_var=3;
  some_var=4;

  _Cilk_sync; 
  return;
}

void foo(volatile int *some_other_var)
{
  while (*some_other_var == 0)
  {
   ;
  }
}