changes
[cdsspec-compiler.git] / benchmark / 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         a=steal(q);
19         if (a == ABORT) {
20                 printf("Steal NULL\n");
21         } else {
22                 printf("Steal %d\n", a);
23         }
24 }
25
26 int user_main(int argc, char **argv)
27 {
28         /**
29                 @Begin
30                 @Entry_point
31                 @End
32         */
33         thrd_t t;
34         q=create();
35         thrd_create(&t, task, 0);
36         push(q, 1);
37         printf("Push 1\n");
38         push(q, 2);
39         printf("Push 2\n");
40         push(q, 4);
41         printf("Push 4\n");
42         b=take(q);
43         if (b == EMPTY) {
44                 printf("Take NULL\n");
45         } else {
46                 printf("Take %d\n", b);
47         }
48         c=take(q);
49         if (c == EMPTY) {
50                 printf("Take NULL\n");
51         } else {
52                 printf("Take %d\n", c);
53         }
54         thrd_join(t);
55 /*
56         bool correct=true;
57         if (a!=1 && a!=2 && a!=4 && a!= EMPTY)
58                 correct=false;
59         if (b!=1 && b!=2 && b!=4 && b!= EMPTY)
60                 correct=false;
61         if (c!=1 && c!=2 && c!=4 && a!= EMPTY)
62                 correct=false;
63         if (a!=EMPTY && b!=EMPTY && c!=EMPTY && (a+b+c)!=7)
64                 correct=false;
65         if (!correct)
66                 printf("a=%d b=%d c=%d\n",a,b,c);
67                 */
68         //MODEL_ASSERT(correct);
69
70         return 0;
71 }