dropref-2.c 646 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* { dg-xfail-run-if "unsupported" { *-*-* } } */
  2. #include <stdlib.h>
  3. #include <libitm.h>
  4. /* Test that _ITM_dropReferences() forces a commit of given chunk. */
  5. unsigned char pp[100];
  6. int main()
  7. {
  8. int i;
  9. for(i=0; i < 100; ++i)
  10. pp[i]=0x22;
  11. __transaction_atomic {
  12. for(i=0; i < 100; ++i)
  13. pp[i]=0x33;
  14. /* This should write-through pp[0..49]... */
  15. _ITM_dropReferences (pp, 50);
  16. /* ...while this should revert everything but pp[0..49]. */
  17. __transaction_cancel;
  18. }
  19. for(i=0; i < 50; ++i)
  20. if (pp[i] != 0x33)
  21. abort();
  22. for(i=50; i < 100; ++i)
  23. if (pp[i] != 0x22)
  24. abort();
  25. return 0;
  26. }