changes with lines of spec counted
[cdsspec-compiler.git] / benchmark / chase-lev-deque-bugfix / deque.h
index 0e2fb2b..837df89 100644 (file)
@@ -37,15 +37,15 @@ typedef struct {
         id_tag_t *tag;
         @InitVar:
             __deque = new_spec_list();
-                       model_print("init_list\n");
+                       //model_print("init_list\n");
             tag = new_id_tag(); // Beginning of available id
-               @Cleanup:
-                       if (__deque) {
+               //@Cleanup:
+                       //if (__deque) {
                                //free_spec_list(__deque);
-                               model_print("free_list\n");
-                       }
-                       if (tag)
-                               free_id_tag(tag);
+                               //model_print("free_list\n");
+                       //}
+                       //if (tag)
+                               //free_id_tag(tag);
         @DefineFunc:
             tag_elem_t* new_tag_elem(call_id_t id, int data) {
                 tag_elem_t *e = (tag_elem_t*) CMODEL_MALLOC(sizeof(tag_elem_t));
@@ -55,17 +55,19 @@ typedef struct {
             }
         @DefineFunc:
             call_id_t get_id(void *wrapper) {
-                               tag_elem_t *res = (tag_elem_t*) wrapper;
-                               if (res == NULL) {
+                               //tag_elem_t *res = (tag_elem_t*) wrapper;
+                               return res == NULL ? 0 : ((tag_elem_t*) wrapper)->id;
+                               //if (res == NULL) {
                                        //model_print("wrong id here\n");
-                                       return 0;
-                               }
-                return res->id;
+                                       //return 0;
+                               //}
+                //return res->id;
             }
         @DefineFunc:
             int get_data(void *wrapper) {
-                               tag_elem_t *res = (tag_elem_t*) wrapper;
-                return res->data;
+                               //tag_elem_t *res = (tag_elem_t*) wrapper;
+                //return res->data;
+                               return ((tag_elem_t*) wrapper)->data;
             }
     @Happens_before:
         Push -> Steal
@@ -85,14 +87,11 @@ void resize(Deque *q);
     @ID: __RET__ == EMPTY ? DEFAULT_CALL_ID : get_id(back(__deque))
     @Action:
         int _Old_Val = EMPTY;
-               if (__RET__ != EMPTY) {
-                       if (size(__deque) > 0) {
-                               _Old_Val = get_data(back(__deque));
-                       pop_back(__deque);
-                       }       
+               if (__RET__ != EMPTY && size(__deque) > 0) {
+                       _Old_Val = get_data(back(__deque));
+               pop_back(__deque);
                }
-    @Post_check:
-        _Old_Val == __RET__
+    @Post_check: _Old_Val == __RET__
     @End
 */
 int take(Deque *q);
@@ -102,9 +101,7 @@ int take(Deque *q);
     @Interface: Push 
     @Commit_point_set: Push_Update_Bottom 
     @ID: get_and_inc(tag);
-    @Action:
-        tag_elem_t *elem = new_tag_elem(__ID__, x);
-        push_back(__deque, elem);
+    @Action: push_back(__deque, new_tag_elem(__ID__, x));
     @End
 */
 void push(Deque *q, int x);
@@ -117,11 +114,9 @@ void push(Deque *q, int x);
     @ID: (__RET__ == EMPTY || __RET__ == ABORT) ? DEFAULT_CALL_ID : get_id(front(__deque))
     @Action:
         int _Old_Val = EMPTY;
-               if (__RET__ != EMPTY && __RET__ != ABORT) {
-                       if (size(__deque) > 0) {
-                               _Old_Val = get_data(front(__deque));
-                               pop_front(__deque);
-                       }
+               if (__RET__ != EMPTY && __RET__ != ABORT && size(__deque) > 0) {
+                       _Old_Val = get_data(front(__deque));
+                       pop_front(__deque);
                }
     @Post_check:
         _Old_Val == __RET__ || __RET__ == EMPTY || __RET__ == ABORT