aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/libitm/testsuite/libitm.c/notx.c
blob: 7ca6580452bef5e9a5c110942e3a3915aec34591 (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
/* These tests all check whether initialization happens properly even if no
   transaction has been used in the current thread yet.  */

/* { dg-options "-pthread" } */

#include <stdlib.h>
#include <pthread.h>
#include <libitm.h>

static void *test1 (void *dummy __attribute__((unused)))
{
  if (_ITM_inTransaction() != outsideTransaction)
    abort();
  return NULL;
}

static void *test2 (void *dummy __attribute__((unused)))
{
  if (_ITM_getTransactionId() != _ITM_noTransactionId)
    abort();
  return NULL;
}


int main()
{
  pthread_t thread;

  pthread_create(&thread, NULL, test1, NULL);
  pthread_join(thread, NULL);

  pthread_create(&thread, NULL, test2, NULL);
  pthread_join(thread, NULL);

  return 0;
}