aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/c-c++-common/cilk-plus/CK/spawning_arg.c
blob: 95e6cab02c13de0af09a83bed3358398e9fe48ed (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
/* { dg-do run  { target { i?86-*-* x86_64-*-* } } } */
/* { dg-options "-fcilkplus" } */
/* { dg-additional-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */

void f0(volatile int *steal_flag)
{ 
  int i = 0;
  /* Wait for steal_flag to be set */
  while (!*steal_flag) 
    ;
}

int f1()
{

  volatile int steal_flag = 0;
  _Cilk_spawn f0(&steal_flag);
  steal_flag = 1;  // Indicate stolen
  _Cilk_sync; 
  return 0;
}

void f2(int q)
{
  q = 5;
}

void f3()
{
   _Cilk_spawn f2(f1());
}

int main()
{
  f3();
  return 0;
}