Debian Codegraph @

extra_tests/cffi_tests/embedding/thread1-test.c

raw symbols SCIP
1 /* Generated by pypy/tool/import_cffi.py */
2 #include <stdio.h>
3 #include <assert.h>
4 #include "thread-test.h"
5
6 #define NTHREADS 10
7
8
9 extern int add1(int, int);
10
11 static sem_t done;
12
13
14 static void *start_routine(void *arg)
15 {
16 int x, status;
17 x = add1(40, 2);
18 assert(x == 42);
19
20 status = sem_post(&done);
21 assert(status == 0);
22
23 return arg;
24 }
25
26 int main(void)
27 {
28 pthread_t th;
29 int i, status = sem_init(&done, 0, 0);
30 assert(status == 0);
31
32 printf("starting\n");
33 fflush(stdout);
34 for (i = 0; i < NTHREADS; i++) {
35 status = pthread_create(&th, NULL, start_routine, NULL);
36 assert(status == 0);
37 }
38 for (i = 0; i < NTHREADS; i++) {
39 status = sem_wait(&done);
40 assert(status == 0);
41 }
42 printf("done\n");
43 return 0;
44 }