6 #include <cdsannotate.h>
7 #include <specannotation.h>
8 #include <model_memory.h>
17 atomic_size_t top, bottom;
18 atomic_uintptr_t array;
21 #define EMPTY 0xffffffff
22 #define ABORT 0xfffffffe
24 /* All other user-defined structs */
25 static IntegerList * __deque;
26 /* All other user-defined functions */
27 inline static bool succ ( int res ) {
28 return res != EMPTY && res != ABORT ;
31 /* Definition of interface info struct: Steal */
32 typedef struct Steal_info {
36 /* End of info struct definition: Steal */
38 /* ID function of interface: Steal */
39 inline static call_id_t Steal_id(void *info, thread_id_t __TID__) {
40 Steal_info* theInfo = (Steal_info*)info;
41 int __RET__ = theInfo->__RET__;
42 Deque * q = theInfo->q;
44 call_id_t __ID__ = succ ( __RET__ ) ? __RET__ : DEFAULT_CALL_ID;
47 /* End of ID function: Steal */
49 /* Check action function of interface: Steal */
50 inline static bool Steal_check_action(void *info, call_id_t __ID__, thread_id_t __TID__) {
52 Steal_info* theInfo = (Steal_info*)info;
53 int __RET__ = theInfo->__RET__;
54 Deque * q = theInfo->q;
57 if ( succ ( __RET__ ) ) {
58 elem = front ( __deque ) ;
59 pop_front ( __deque ) ;
61 check_passed = succ ( __RET__ ) ? __RET__ == elem : true;
66 /* End of check action function: Steal */
68 /* Definition of interface info struct: Take */
69 typedef struct Take_info {
73 /* End of info struct definition: Take */
75 /* ID function of interface: Take */
76 inline static call_id_t Take_id(void *info, thread_id_t __TID__) {
77 Take_info* theInfo = (Take_info*)info;
78 int __RET__ = theInfo->__RET__;
79 Deque * q = theInfo->q;
81 call_id_t __ID__ = succ ( __RET__ ) ? __RET__ : DEFAULT_CALL_ID;
84 /* End of ID function: Take */
86 /* Check action function of interface: Take */
87 inline static bool Take_check_action(void *info, call_id_t __ID__, thread_id_t __TID__) {
89 Take_info* theInfo = (Take_info*)info;
90 int __RET__ = theInfo->__RET__;
91 Deque * q = theInfo->q;
94 if ( succ ( __RET__ ) ) {
95 elem = back ( __deque ) ;
96 pop_back ( __deque ) ;
98 check_passed = succ ( __RET__ ) ? __RET__ == elem : true;
103 /* End of check action function: Take */
105 /* Definition of interface info struct: Push */
106 typedef struct Push_info {
110 /* End of info struct definition: Push */
112 /* ID function of interface: Push */
113 inline static call_id_t Push_id(void *info, thread_id_t __TID__) {
114 Push_info* theInfo = (Push_info*)info;
115 Deque * q = theInfo->q;
118 call_id_t __ID__ = x;
121 /* End of ID function: Push */
123 /* Check action function of interface: Push */
124 inline static bool Push_check_action(void *info, call_id_t __ID__, thread_id_t __TID__) {
126 Push_info* theInfo = (Push_info*)info;
127 Deque * q = theInfo->q;
130 push_back ( __deque , x ) ;
133 /* End of check action function: Push */
135 #define INTERFACE_SIZE 3
136 static void** func_ptr_table;
137 static hb_rule** hb_rule_table;
138 static commutativity_rule** commutativity_rule_table;
139 inline static bool CommutativityCondition0(void *info1, void *info2) {
140 Push_info *_info1 = (Push_info*) info1;
141 Steal_info *_info2 = (Steal_info*) info2;
144 inline static bool CommutativityCondition1(void *info1, void *info2) {
145 Take_info *_info1 = (Take_info*) info1;
146 Steal_info *_info2 = (Steal_info*) info2;
150 /* Initialization of sequential varialbes */
151 static void __SPEC_INIT__() {
152 __deque = createIntegerList ( ) ;
155 /* Cleanup routine of sequential variables */
156 static bool __SPEC_CLEANUP__() {
157 if ( __deque ) destroyIntegerList ( __deque ) ;
161 /* Define function for sequential code initialization */
162 inline static void __sequential_init() {
163 /* Init func_ptr_table */
164 func_ptr_table = (void**) malloc(sizeof(void*) * 3 * 2);
165 func_ptr_table[2 * 2] = (void*) &Steal_id;
166 func_ptr_table[2 * 2 + 1] = (void*) &Steal_check_action;
167 func_ptr_table[2 * 0] = (void*) &Take_id;
168 func_ptr_table[2 * 0 + 1] = (void*) &Take_check_action;
169 func_ptr_table[2 * 1] = (void*) &Push_id;
170 func_ptr_table[2 * 1 + 1] = (void*) &Push_check_action;
171 /* Push(true) -> Steal(true) */
172 struct hb_rule *hbConditionInit0 = (struct hb_rule*) malloc(sizeof(struct hb_rule));
173 hbConditionInit0->interface_num_before = 1; // Push
174 hbConditionInit0->hb_condition_num_before = 0; //
175 hbConditionInit0->interface_num_after = 2; // Steal
176 hbConditionInit0->hb_condition_num_after = 0; //
177 /* Init hb_rule_table */
178 hb_rule_table = (hb_rule**) malloc(sizeof(hb_rule*) * 1);
179 #define HB_RULE_TABLE_SIZE 1
180 hb_rule_table[0] = hbConditionInit0;
181 /* Init commutativity_rule_table */
182 commutativity_rule_table = (commutativity_rule**) malloc(sizeof(commutativity_rule*) * 2);
183 commutativity_rule* rule;
184 rule = (commutativity_rule*) malloc (sizeof(commutativity_rule));
185 rule->interface_num_before = 1;
186 rule->interface_num_after = 2;
188 rule->condition = CommutativityCondition0;
189 commutativity_rule_table[0] = rule;
190 rule = (commutativity_rule*) malloc (sizeof(commutativity_rule));
191 rule->interface_num_before = 0;
192 rule->interface_num_after = 2;
194 rule->condition = CommutativityCondition1;
195 commutativity_rule_table[1] = rule;
196 /* Pass init info, including function table info & HB rules & Commutativity Rules */
197 struct anno_init *anno_init = (struct anno_init*) malloc(sizeof(struct anno_init));
198 anno_init->init_func = (void_func_t) __SPEC_INIT__;
199 anno_init->cleanup_func = (cleanup_func_t) __SPEC_CLEANUP__;
200 anno_init->func_table = func_ptr_table;
201 anno_init->func_table_size = INTERFACE_SIZE;
202 anno_init->hb_rule_table = hb_rule_table;
203 anno_init->hb_rule_table_size = HB_RULE_TABLE_SIZE;
204 anno_init->commutativity_rule_table = commutativity_rule_table;
205 anno_init->commutativity_rule_table_size = 2;
206 struct spec_annotation *init = (struct spec_annotation*) malloc(sizeof(struct spec_annotation));
208 init->annotation = anno_init;
209 cdsannotate(SPEC_ANALYSIS, init);
213 /* End of Global construct generation in class */
218 void resize(Deque *q);
220 int __wrapper__take(Deque * q);
222 int __wrapper__take(Deque * q) ;
224 void __wrapper__push(Deque * q, int x);
226 void __wrapper__push(Deque * q, int x) ;
228 int __wrapper__steal(Deque * q);
230 int __wrapper__steal(Deque * q) ;