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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [tm/] [opt-1.c] - Blame information for rev 774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* { dg-do compile } */
2
/* { dg-options "-fgnu-tm -O" } */
3
 
4
extern void usleep (int) __attribute__((transaction_pure));
5
extern int rand(void) __attribute__((pure, transaction_pure));
6
extern int printf (const char *, ...);
7
extern void *malloc (__SIZE_TYPE__) __attribute__((malloc));
8
extern void xyzzy (void * (*)(void *));
9
 
10
typedef struct
11
{
12
  int id;
13
} parm;
14
 
15
int gvar;
16
 
17
void *hello(void *arg)
18
{
19
  parm *p=(parm *)arg;
20
  int tmp = p->id;
21
  int tmp3;
22
  printf ("Thread reads %d.\n", tmp);
23
  __transaction_atomic
24
    {
25
      int tmp2 = gvar;
26
      usleep ((int) (10.0*rand()/(10+1.0))/100);
27
      gvar = tmp + tmp2;
28
      tmp3 = gvar;
29
    }
30
  printf("tmp3 = %d\n", tmp3);
31
  return 0;
32
}
33
 
34
int
35
main()
36
{
37
  int i, n = rand();
38
 
39
  for (i=0; i<n; i++)
40
    xyzzy (hello);
41
 
42
  return 0;
43
}

powered by: WebSVN 2.1.0

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