aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/tm/nested-2.C
blob: c6d5d98ba7a86000b2f90c72e62719ed79576a20 (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
// { dg-do compile }
// { dg-options "-fgnu-tm -O" }

typedef unsigned long int uint64_t;
extern int *hash_indx;

typedef struct
{
  uint64_t exit_atomicsec_time;
} ent_ex_times;
class HashTree
{
public:
   __attribute__((transaction_safe))
   void *operator new(__SIZE_TYPE__);
   __attribute__((transaction_safe))
   int add_element();
private:
   HashTree **Hash_table;
   int Count;
};


__attribute__((transaction_safe))
int HashTree::add_element()
{
 ent_ex_times enter_exit_times_inside;
 int val = hash_indx[5];
 int tt;
 if (Hash_table[val] == __null)
 {
  __transaction_atomic {
    Hash_table[val] = new HashTree;
  }
 }
 __transaction_atomic {
 tt = Count++;
 enter_exit_times_inside.exit_atomicsec_time = 5;
 }
 return tt;
}