aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/c-c++-common/tm/20111206.c
blob: 74a551966f26864f26e52ad89f978516b83d2844 (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
/* { dg-do compile } */
/* { dg-options "-fgnu-tm -O2" } */
/* This test case triggered block sharing between the two transactions.  */

void func1 (void) __attribute__ ((transaction_callable, used));
long func2 (void) __attribute__ ((transaction_callable, used));
unsigned long rand (void);

void client_run (void)
{
  long types[100];
  long i;

  for (i = 0; i < 100; i++)
    {
      long action = rand ();

      switch (action)
	{
	case 0:
	  {
	    __transaction_relaxed
	    {
	      long bill = func2 ();
	      if (bill >= 0)
		{
		  func1 ();
		}
	    }
	    break;
	  }

	case 1:
	  {
	    long n;
	    __transaction_relaxed
	    {
	      for (n = 0; n < 100; n++)
		{
		  long t = types[n];
		  switch (t)
		    {
		    case 0:
		      func1 ();
		      break;
		    }
		}
	    }
	    break;
	  }
	}
    }
}