edits
[cdsspec-compiler.git] / output / 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         __sequential_init();
35         
36         thrd_t t;
37         q=create();
38         thrd_create(&t, task, 0);
39         push(q, 1);
40         printf("Push 1\n");
41         push(q, 2);
42         printf("Push 2\n");
43         push(q, 4);
44         printf("Push 4\n");
45         b=take(q);
46         if (b == EMPTY) {
47                 printf("Take NULL\n");
48         } else {
49                 printf("Take %d\n", b);
50         }
51         c=take(q);
52         if (c == EMPTY) {
53                 printf("Take NULL\n");
54         } else {
55                 printf("Take %d\n", c);
56         }
57         thrd_join(t);
58
59         
60         return 0;
61 }
62