edits
[cdsspec-compiler.git] / output / chase-lev-deque-bugfix / main.c
1 #include <stdlib.h>
2 #include <assert.h>
3 #include <stdio.h>
4 #include <threads.h>
5 #include <stdatomic.h>
6
7 #include "model-assert.h"
8
9 #include "deque.h"
10
11 Deque *q;
12 int a;
13 int b;
14 int c;
15
16 static void task(void * param) {
17         a=steal(q);
18         if (a == ABORT) {
19                 printf("Steal NULL\n");
20         } else {
21                 printf("Steal %d\n", a);
22         }
23 }
24
25 int user_main(int argc, char **argv)
26 {
27         __sequential_init();
28         
29         thrd_t t;
30         q=create();
31         thrd_create(&t, task, 0);
32         push(q, 1);
33         printf("Push 1\n");
34         push(q, 2);
35         printf("Push 2\n");
36         push(q, 4);
37         printf("Push 4\n");
38         b=take(q);
39         if (b == EMPTY) {
40                 printf("Take NULL\n");
41         } else {
42                 printf("Take %d\n", b);
43         }
44         c=take(q);
45         if (c == EMPTY) {
46                 printf("Take NULL\n");
47         } else {
48                 printf("Take %d\n", c);
49         }
50         thrd_join(t);
51
52         
53         return 0;
54 }
55