deque: fix bugs in assertion code and move up 3 variables...
[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
7 #include "deque.h"
8
9 Deque *q;
10 int a;
11 int b;
12 int c;
13
14 static void task(void * param) {
15         a=steal(q);
16 }
17
18 int user_main(int argc, char **argv)
19 {
20         thrd_t t;
21         q=create();
22         thrd_create(&t, task, 0);
23         push(q, 1);
24         push(q, 2);
25         push(q, 4);
26         b=take(q);
27         c=take(q);
28         thrd_join(t);
29         bool correct=true;
30         if (a!=1 && a!=2 && a!=4 && a!= EMPTY)
31                 correct=false;
32         if (b!=1 && b!=2 && b!=4 && b!= EMPTY)
33                 correct=false;
34         if (c!=1 && c!=2 && c!=4 && a!= EMPTY)
35                 correct=false;
36         if (a!=EMPTY && b!=EMPTY && c!=EMPTY && (a+b+c)!=7)
37                 correct=false;
38         if (!correct)
39                 printf("a=%d b=%d c=%d\n",a,b,c);
40         return 0;
41 }