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