1 #include <stdlib.h>
2 #include <libitm.h>
3 
4 unsigned char pp[100];
5 
cancel1()6 void __attribute((transaction_may_cancel_outer,noinline)) cancel1()
7 {
8   __transaction_cancel [[outer]];
9 }
10 
11 int a, b;
12 
main()13 int main()
14 {
15   a = b = 0;
16 
17   __transaction_atomic {
18     a = 1;
19     __transaction_atomic {
20       b = 1;
21       __transaction_cancel;
22     }
23   }
24   if (a != 1 || b != 0)
25     abort();
26   if (_ITM_inTransaction() != outsideTransaction)
27     abort();
28 
29   __transaction_atomic [[outer]] {
30     a = 2;
31     __transaction_atomic {
32       b = 2;
33       __transaction_cancel [[outer]];
34     }
35   }
36   if (a != 1 || b != 0)
37     abort();
38   if (_ITM_inTransaction() != outsideTransaction)
39     abort();
40 
41   __transaction_atomic [[outer]] {
42     a = 2;
43     __transaction_atomic {
44       b = 2;
45       __transaction_cancel [[outer]];
46       cancel1();
47     }
48   }
49   if (a != 1 || b != 0)
50     abort();
51   if (_ITM_inTransaction() != outsideTransaction)
52     abort();
53 
54   return 0;
55 }
56