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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [libmudflap/] [testsuite/] [libmudflap.cth/] [pass37-frag.c] - Blame information for rev 455

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

Line No. Rev Author Line
1 275 jeremybenn
#include <stdlib.h>
2
#include <stdio.h>
3
#include <pthread.h>
4
#include <sched.h>
5
 
6
static void *
7
func (void *p)
8
{
9
  int *counter = (int *) p;
10
  unsigned i;
11
 
12
  for (i=0; i<100; i++)
13
    {
14
      (*counter) ++;
15
      {
16
        int array[17];
17
        unsigned x = i % (sizeof(array)/sizeof(array[0]));
18
        /* VRP could prove that x is within [0,16], but until then, the
19
           following access will ensure that array[] is registered to
20
           libmudflap. */
21
        array[x] = i;
22
      }
23
      sched_yield (); /* sleep (1); */
24
    }
25
 
26
  return (NULL);
27
}
28
 
29
 
30
int main ()
31
{
32
  int rc;
33
  unsigned i;
34
  enum foo { NT=10 };
35
  pthread_t threads[NT];
36
  int counts[NT];
37
 
38
 
39
  for (i=0; i<NT; i++)
40
    {
41
      counts[i] = 0;
42
      rc = pthread_create (& threads[i], NULL, func, (void *) & counts[i]);
43
      if (rc) abort();
44
    }
45
 
46
  for (i=0; i<NT; i++)
47
    {
48
      rc = pthread_join (threads[i], NULL);
49
      if (rc) abort();
50
      printf ("%d%s", counts[i], (i==NT-1) ? "\n" : " ");
51
    }
52
 
53
  return 0;
54
}
55
 
56
/* { dg-output "100 100 100 100 100 100 100 100 100 100" } */
57
/* { dg-repetitions 20 } */
58
/* { dg-timeout 10 } */

powered by: WebSVN 2.1.0

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