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] - Rev 689

Compare with Previous | Blame | View Log

/* { dg-do compile } */
/* { dg-options "-fgnu-tm -O" } */
 
extern void usleep (int) __attribute__((transaction_pure));
extern int rand(void) __attribute__((pure, transaction_pure));
extern int printf (const char *, ...);
extern void *malloc (__SIZE_TYPE__) __attribute__((malloc));
extern void xyzzy (void * (*)(void *));
 
typedef struct
{
  int id;
} parm;
 
int gvar;
 
void *hello(void *arg)
{
  parm *p=(parm *)arg;
  int tmp = p->id;
  int tmp3;
  printf ("Thread reads %d.\n", tmp);
  __transaction_atomic
    {
      int tmp2 = gvar;
      usleep ((int) (10.0*rand()/(10+1.0))/100);
      gvar = tmp + tmp2;
      tmp3 = gvar;
    }
  printf("tmp3 = %d\n", tmp3);
  return 0;
}
 
int
main()
{
  int i, n = rand();
 
  for (i=0; i<n; i++)
    xyzzy (hello);
 
  return 0;
}
 

Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

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