OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libitm/] [testsuite/] [libitm.c/] [txrelease.c] - Blame information for rev 737

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 737 jeremybenn
/* This test triggers execution of the code that releases per-thread
2
   transaction data when a thread exists, potentially repeatedly. However,
3
   we currently cannot check whether the data has indeed been released.  */
4
 
5
/* { dg-options "-pthread" } */
6
 
7
#include <stddef.h>
8
#include <stdlib.h>
9
#include <pthread.h>
10
 
11
static int round = 0;
12
static pthread_key_t key;
13
 
14
static void
15
thread_exit_handler(void *dummy __attribute__((unused)))
16
{
17
  if (round == 0)
18
    abort();
19
  if (round == 1)
20
    {
21
      // ??? It would be good if we could check here that the transaction has
22
      // indeed been released.
23
      __transaction_atomic { round++; }
24
      if (pthread_setspecific(key, &round))
25
        abort();
26
    }
27
  // ??? It would be good if we could check here that the transaction has
28
  // indeed been released (again).
29
}
30
 
31
static void *thread (void *dummy __attribute__((unused)))
32
{
33
  if (pthread_key_create(&key, thread_exit_handler))
34
    abort();
35
  if (pthread_setspecific(key, &round))
36
    abort();
37
  __transaction_atomic { round++; }
38
  return NULL;
39
}
40
 
41
int main()
42
{
43
  pthread_t pt;
44
  pthread_create(&pt, NULL, thread, NULL);
45
  pthread_join(pt, NULL);
46
  if (round != 2)
47
    abort();
48
  return 0;
49
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.