# HG changeset patch # User Shinji KONO # Date 1478731875 -32400 # Node ID cc071cf1ba853c87b4895281519c3084a208bb44 # Parent d529c024e5a506f7e2c0ba3577ee1adf59b89995 add stack clear interface diff -r d529c024e5a5 -r cc071cf1ba85 src/parallel_execution/context.c --- a/src/parallel_execution/context.c Thu Nov 10 07:33:10 2016 +0900 +++ b/src/parallel_execution/context.c Thu Nov 10 07:51:15 2016 +0900 @@ -59,8 +59,6 @@ extern __code putQueue3_stub(struct Context*); extern __code putQueue4_stub(struct Context*); extern __code getQueue_stub(struct Context*); -extern __code pushSingleLinkedStack_stub(struct Context*); -extern __code popSingleLinkedStack_stub(struct Context*); extern __code spawnTask_stub(struct Context*); extern __code twice_stub(struct Context*); extern __code start_time_stub(struct Context*); @@ -96,6 +94,7 @@ context->code[C_get] = get_stub; context->code[C_search] = search_stub; + context->code[C_clearSingleLinkedStack] = clearSingleLinkedStack_stub; context->code[C_pushSingleLinkedStack] = pushSingleLinkedStack_stub; context->code[C_popSingleLinkedStack] = popSingleLinkedStack_stub; context->code[C_pop2SingleLinkedStack] = pop2SingleLinkedStack_stub; diff -r d529c024e5a5 -r cc071cf1ba85 src/parallel_execution/context.h --- a/src/parallel_execution/context.h Thu Nov 10 07:33:10 2016 +0900 +++ b/src/parallel_execution/context.h Thu Nov 10 07:51:15 2016 +0900 @@ -90,6 +90,7 @@ PutQueue3, PutQueue4, GetQueue, + C_clearSingleLinkedStack, C_pushSingleLinkedStack, C_popSingleLinkedStack, C_pop2SingleLinkedStack, @@ -181,11 +182,13 @@ union Data* stack; union Data* data; union Data* data1; + enum Code whenEmpty; + + enum Code clear; enum Code push; enum Code pop; enum Code pop2; enum Code isEmpty; - enum Code whenEmpty; enum Code get; enum Code get2; enum Code next; diff -r d529c024e5a5 -r cc071cf1ba85 src/parallel_execution/rb_tree.c --- a/src/parallel_execution/rb_tree.c Thu Nov 10 07:33:10 2016 +0900 +++ b/src/parallel_execution/rb_tree.c Thu Nov 10 07:51:15 2016 +0900 @@ -304,16 +304,15 @@ parent); } -__code stackClear(struct Context* context, struct Traverse* traverse) { +__code stackClear(struct Context* context, struct Traverse* traverse,struct Stack *nodeStack) { traverse->current = 0; - struct SingleLinkedStack* nodeStack = (struct SingleLinkedStack*)traverse->nodeStack->stack; - nodeStack->top = NULL; - - goto meta(context, context->next); + nodeStack->stack = (union Data*)traverse->nodeStack; + nodeStack->next = context->next; + goto meta(context, traverse->nodeStack->clear); } __code stackClear_stub(struct Context* context) { - goto stackClear(context, &context->data[Traverse]->traverse); + goto stackClear(context, &context->data[Traverse]->traverse,&context->data[Stack]->stack); } diff -r d529c024e5a5 -r cc071cf1ba85 src/parallel_execution/stack.c --- a/src/parallel_execution/stack.c Thu Nov 10 07:33:10 2016 +0900 +++ b/src/parallel_execution/stack.c Thu Nov 10 07:51:15 2016 +0900 @@ -14,6 +14,7 @@ stack->get = C_getSingleLinkedStack; stack->get2 = C_get2SingleLinkedStack; stack->isEmpty = C_isEmptySingleLinkedStack; + stack->clear = C_clearSingleLinkedStack; return (union Data*)(stack); } @@ -32,6 +33,15 @@ printf("\n"); } +__code clearSingleLinkedStack(struct Context* context, struct SingleLinkedStack* stack,enum Code next) { + stack->top = NULL; + goto meta(context, next); +} + +__code clearSingleLinkedStack_stub(struct Context* context) { + goto clearSingleLinkedStack(context, (struct SingleLinkedStack *)context->data[Stack]->stack.stack->stack.stack, context->data[Stack]->stack.next); +} + __code pushSingleLinkedStack(struct Context* context, struct SingleLinkedStack* stack, struct Element* element, union Data* data, enum Code next) { element->next = stack->top; element->data = data; diff -r d529c024e5a5 -r cc071cf1ba85 src/parallel_execution/stack.h --- a/src/parallel_execution/stack.h Thu Nov 10 07:33:10 2016 +0900 +++ b/src/parallel_execution/stack.h Thu Nov 10 07:51:15 2016 +0900 @@ -6,3 +6,4 @@ extern __code getSingleLinkedStack_stub(struct Context* context) ; extern __code get2SingleLinkedStack_stub(struct Context* context) ; extern __code isEmptySingleLinkedStack_stub(struct Context* context) ; +extern __code clearSingleLinkedStack_stub(struct Context* context) ;