Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / libmudflap / testsuite / libmudflap.cth / pass39-frag.c
blobcd3eb5abdafb61b03733c9c1a3a7663c03ee1feb
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <pthread.h>
4 #include <sched.h>
5 #include <assert.h>
7 static void *
8 func (void *p)
10 int *counter = (int *) p;
11 unsigned i;
12 enum { numarrays = 100, numels = 17 };
13 char *arrays [numarrays];
15 for (i=0; i<numarrays; i++)
17 (*counter) ++;
18 unsigned x = i % numels;
19 arrays[i] = calloc (numels, sizeof(arrays[i][0]));
20 assert (arrays[i] != NULL);
21 arrays[i][x] = i;
22 free (arrays[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;
55 /* { dg-output "100 100 100 100 100 100 100 100 100 100" } */
56 /* { dg-repetitions 20 } */
57 /* { dg-timeout 10 } */