cancel.c 926 B

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