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