Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libmudflap / testsuite / libmudflap.cth / pass37-frag.c
blob877803c1ea028489384c8fdbf08e04bf9e9fb070
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <pthread.h>
4 #include <sched.h>
6 static void *
7 func (void *p)
9 int *counter = (int *) p;
10 unsigned i;
12 for (i=0; i<100; i++)
14 (*counter) ++;
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;
23 sched_yield (); /* sleep (1); */
26 return (NULL);
30 int main ()
32 int rc;
33 unsigned i;
34 enum foo { NT=10 };
35 pthread_t threads[NT];
36 int counts[NT];
39 for (i=0; i<NT; i++)
41 counts[i] = 0;
42 rc = pthread_create (& threads[i], NULL, func, (void *) & counts[i]);
43 if (rc) abort();
46 for (i=0; i<NT; i++)
48 rc = pthread_join (threads[i], NULL);
49 if (rc) abort();
50 printf ("%d%s", counts[i], (i==NT-1) ? "\n" : " ");
53 return 0;
56 /* { dg-output "100 100 100 100 100 100 100 100 100 100" } */
57 /* { dg-repetitions 20 } */
58 /* { dg-timeout 10 } */