fixed commutativity rule
[cdsspec-compiler.git] / benchmark / 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         /**
36                 @Begin
37                 @Entry_point
38                 @End
39         */
40         thrd_t t;
41         q=create();
42         thrd_create(&t, task, 0);
43         push(q, 1);
44         printf("Push 1\n");
45         push(q, 2);
46         printf("Push 2\n");
47         push(q, 4);
48         printf("Push 4\n");
49         b=take(q);
50         if (b == EMPTY) {
51                 printf("Take NULL\n");
52         } else {
53                 printf("Take %d\n", b);
54         }
55         c=take(q);
56         if (c == EMPTY) {
57                 printf("Take NULL\n");
58         } else {
59                 printf("Take %d\n", c);
60         }
61         thrd_join(t);
62 /*
63         bool correct=true;
64         if (a!=1 && a!=2 && a!=4 && a!= EMPTY)
65                 correct=false;
66         if (b!=1 && b!=2 && b!=4 && b!= EMPTY)
67                 correct=false;
68         if (c!=1 && c!=2 && c!=4 && a!= EMPTY)
69                 correct=false;
70         if (a!=EMPTY && b!=EMPTY && c!=EMPTY && (a+b+c)!=7)
71                 correct=false;
72         if (!correct)
73                 printf("a=%d b=%d c=%d\n",a,b,c);
74                 */
75         //MODEL_ASSERT(correct);
76
77         return 0;
78 }