annotate src/list/list.c @ 58:4283b87ddbf4

Add stub to synchronizedQueues
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Tue, 16 Jun 2015 15:59:48 +0900
parents 2ff693c5563c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <stdlib.h>
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <stdio.h>
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
34
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
4 #include "listContext.h"
13
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 #include "allocate.h"
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 #include "origin_cs.h"
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
34
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
9 extern __code initListContext(struct Context* context);
13
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
58
4283b87ddbf4 Add stub to synchronizedQueues
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 55
diff changeset
11 __code code1(struct Context* context, struct Allocate* allocate) {
55
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
12 allocate->size = sizeof(struct Element);
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
13 allocate->next = Code2;
34
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
14 goto meta(context, Allocator);
13
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 }
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
55
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
17 __code code1_stub(struct Context* context) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
18 goto code1(context, &context->data[Allocate]->allocate);
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
19 }
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
20
34
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
21 __code meta(struct Context* context, enum Code next) {
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
22 goto (context->code[next])(context);
13
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 }
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
55
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
25 __code code2(struct Context* context, struct Allocate* allocate, struct Element* element) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
26 allocate->after_append = Code3;
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
27 element ->value = 10;
34
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
28 goto meta(context, Append);
13
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 }
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30
55
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
31 __code code2_stub(struct Context* context) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
32 goto code2(context, &context->data[Allocate]->allocate, &context->data[context->dataNum]->element);
13
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 }
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34
55
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
35
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
36 __code append(struct Context* context, struct Allocate* allocate, struct List* list, struct Element* element) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
37 if(list->head) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
38 list->tail->next = element;
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
39 } else {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
40 list->head = element;
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
41 }
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
42 list->tail = element;
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
43 list->tail->next = 0;
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
44 goto meta(context, allocate->after_append);
13
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 }
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47
55
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
48 __code append_stub(struct Context* context) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
49 goto append(context,&context->data[Allocate]->allocate, &context->data[List]->list, &context->data[context->dataNum]->element);
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
50 }
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
51
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
52 __code code3(struct Context* context, struct Allocate *allocate) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
53 allocate->size = sizeof(struct Element);
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
54 allocate->next = Code4;
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
55 goto meta(context, Allocator);
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
56 }
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
57
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
58 __code code3_stub(struct Context* context) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
59 goto code3(context, &context->data[Allocate]->allocate);
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
60 }
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
61
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
62 __code code4(struct Context* context, struct Allocate* allocate, struct Element* element) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
63 allocate->after_append = Code5;
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
64 element ->value = 100;
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
65 goto meta(context, Append);
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
66 }
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
67
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
68 __code code4_stub(struct Context* context) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
69 goto code4(context, &context->data[Allocate]->allocate, &context->data[context->dataNum]->element);
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
70 }
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
71
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
72 __code meta_traverse(struct Context* context, struct List* list, enum Code next) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
73 printf("current value in list is %d\n", list->current->value);
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
74 if (list->current->next) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
75 list->current = list->current->next;
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
76 goto meta_traverse(context, list, next);
34
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
77 }
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
78 goto (context->code[next])(context);
13
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 }
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80
55
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
81 __code traverse(struct Context* context, struct Allocate* allocate, struct List* list) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
82 list->current = list->head;
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
83 goto meta_traverse(context, list, allocate->after_traverse);
13
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 }
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85
55
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
86 __code traverse_stub(struct Context* context) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
87 goto traverse(context, &context->data[Allocate]->allocate, &context->data[List]->list);
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
88 }
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
89
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
90 __code code5(struct Context* context, struct Allocate* allocate) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
91 allocate->after_traverse = Code6;
34
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
92 goto meta(context, Traverse);
13
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 }
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
94
55
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
95 __code code5_stub(struct Context* context) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
96 goto code5(context, &context->data[Allocate]->allocate);
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
97 }
34
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
98
55
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
99 __code code6(struct Context* context, struct Allocate* allocate) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
100 allocate->after_delete = Code7;
34
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
101 goto meta(context, Delete);
13
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
102 }
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
103
55
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
104 __code code6_stub(struct Context* context) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
105 goto code6(context, &context->data[Allocate]->allocate);
13
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
106 }
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
107
55
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
108 __code delete(struct Context* context, struct Allocate* allocate, struct List* list) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
109 list->head = (list->head->next) ? list->head->next : 0;
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
110 goto meta(context, allocate->after_delete);
13
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 }
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
112
55
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
113 __code delete_stub(struct Context* context) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
114 goto delete(context, &context->data[Allocate]->allocate, &context->data[List]->list);
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
115 }
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
116
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
117 __code code7(struct Context* context, struct Allocate* allocate) {
34
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
118 printf("after delete\n");
55
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
119 allocate->after_traverse = Exit;
34
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
120 goto meta(context, Traverse);
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
121 }
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
122
55
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
123 __code code7_stub(struct Context* context) {
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
124 goto code7(context, &context->data[Allocate]->allocate);
2ff693c5563c Add stub to list
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 35
diff changeset
125 }
34
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
126
13
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 int main() {
34
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
128 struct Context* context = (struct Context*)malloc(sizeof(struct Context));
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
129 initListContext(context);
c3314208d7b9 Add listContext files
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
130 goto start_code(context, Code1);
13
a765eb7f3b7c implement delete, traverse
Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp>
parents:
diff changeset
131 }