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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 737 jeremybenn
/* { dg-do run } */
2
/* { dg-options "-pthread" } */
3
/* { dg-skip-if "PR libitm/51822" { *-*-* } } */
4
/* Tests static constructors inside of transactional code.  */
5
 
6
#include 
7
#include 
8
 
9
int f(int x) __attribute__((noinline,transaction_safe));
10
int f(int x)
11
{
12
  static int y = x;
13
  return y*x;
14
}
15
 
16
static void *thread (void *)
17
{
18
  int bar;
19
  __transaction_atomic { bar = f(10); }
20
  if (bar != 100)
21
    abort();
22
  return 0;
23
}
24
 
25
int main()
26
{
27
  int bar;
28
 
29
  // First, initialize y in another thread.
30
  pthread_t pt;
31
  pthread_create(&pt, NULL, thread, NULL);
32
  pthread_join(pt, NULL);
33
 
34
  // Now y should already be initialized.
35
  __transaction_atomic { bar = f(20); }
36
  if (bar != 200)
37
    abort();
38
 
39
  return 0;
40
}

powered by: WebSVN 2.1.0

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