edits
[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         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         /**
28                 @Begin
29                 @Entry_point
30                 @End
31         */
32         thrd_t t;
33         q=create();
34         thrd_create(&t, task, 0);
35         push(q, 1);
36         printf("Push 1\n");
37         push(q, 2);
38         printf("Push 2\n");
39         push(q, 4);
40         printf("Push 4\n");
41         b=take(q);
42         if (b == EMPTY) {
43                 printf("Take NULL\n");
44         } else {
45                 printf("Take %d\n", b);
46         }
47         c=take(q);
48         if (c == EMPTY) {
49                 printf("Take NULL\n");
50         } else {
51                 printf("Take %d\n", c);
52         }
53         thrd_join(t);
54 /*
55         bool correct=true;
56         if (a!=1 && a!=2 && a!=4 && a!= EMPTY)
57                 correct=false;
58         if (b!=1 && b!=2 && b!=4 && b!= EMPTY)
59                 correct=false;
60         if (c!=1 && c!=2 && c!=4 && a!= EMPTY)
61                 correct=false;
62         if (a!=EMPTY && b!=EMPTY && c!=EMPTY && (a+b+c)!=7)
63                 correct=false;
64         if (!correct)
65                 printf("a=%d b=%d c=%d\n",a,b,c);
66                 */
67         //MODEL_ASSERT(correct);
68
69         return 0;
70 }