do merge...push right code
[model-checker-benchmarks.git] / chase-lev-deque / main.c
1 #include <stdlib.h>
2 #include <assert.h>
3 #include <stdio.h>
4 #include <threads.h>
5 #include <stdatomic.h>
6 #include <stdio.h>
7
8 #include "model-assert.h"
9
10 #include "deque.h"
11
12 Deque *q;
13 int a;
14 int b;
15 int c;
16
17 static void task(void * param) {
18         a=steal(q);
19 }
20
21 int user_main(int argc, char **argv)
22 {
23         thrd_t t;
24         q=create();
25         thrd_create(&t, task, 0);
26         push(q, 1);
27         push(q, 2);
28         push(q, 4);
29         b=take(q);
30         c=take(q);
31         thrd_join(t);
32
33         bool correct=true;
34         if (a!=1 && a!=2 && a!=4 && a!= EMPTY)
35                 correct=false;
36         if (b!=1 && b!=2 && b!=4 && b!= EMPTY)
37                 correct=false;
38         if (c!=1 && c!=2 && c!=4 && a!= EMPTY)
39                 correct=false;
40         if (a!=EMPTY && b!=EMPTY && c!=EMPTY && (a+b+c)!=7)
41                 correct=false;
42         if (!correct)
43                 printf("a=%d b=%d c=%d\n",a,b,c);
44
45         return 0;
46 }