edits
[cdsspec-compiler.git] / output / chase-lev-deque-bugfix / testcase2.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 int x;
16
17 static void task(void * param) {
18         a=steal(q);
19         if (a == ABORT) {
20                 printf("Steal NULL\n");
21         } else {
22                 printf("Steal %d\n", a);
23         }
24         
25 }
26
27 int user_main(int argc, char **argv)
28 {
29         __sequential_init();
30         
31         thrd_t t;
32         q=create();
33         push(q, 1);
34         printf("Push 1\n");
35         push(q, 2);
36         printf("Push 2\n");
37         push(q, 4);
38         printf("Push 4\n");
39         push(q, 5);
40         printf("Push 5\n");
41         thrd_create(&t, task, 0);
42
43         b=take(q);
44         if (b == EMPTY) {
45                 printf("Take NULL\n");
46         } else {
47                 printf("Take %d\n", b);
48         }
49         c=take(q);
50         if (c == EMPTY) {
51                 printf("Take NULL\n");
52         } else {
53                 printf("Take %d\n", c);
54         }
55         thrd_join(t);
56
57         
58         return 0;
59 }
60