notx.c 720 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* These tests all check whether initialization happens properly even if no
  2. transaction has been used in the current thread yet. */
  3. /* { dg-options "-pthread" } */
  4. #include <stdlib.h>
  5. #include <pthread.h>
  6. #include <libitm.h>
  7. static void *test1 (void *dummy __attribute__((unused)))
  8. {
  9. if (_ITM_inTransaction() != outsideTransaction)
  10. abort();
  11. return NULL;
  12. }
  13. static void *test2 (void *dummy __attribute__((unused)))
  14. {
  15. if (_ITM_getTransactionId() != _ITM_noTransactionId)
  16. abort();
  17. return NULL;
  18. }
  19. int main()
  20. {
  21. pthread_t thread;
  22. pthread_create(&thread, NULL, test1, NULL);
  23. pthread_join(thread, NULL);
  24. pthread_create(&thread, NULL, test2, NULL);
  25. pthread_join(thread, NULL);
  26. return 0;
  27. }