Mercurial > hg > GearsTemplate
changeset 203:25db17f32ac2
replace Stack for stack
author | ikkun |
---|---|
date | Mon, 19 Dec 2016 22:23:37 +0900 |
parents | 42dbe54332a0 |
children | 57a88b2ae3b3 |
files | src/parallel_execution/CMakeLists.txt src/parallel_execution/queue.c src/parallel_execution/test/queue_test.c |
diffstat | 3 files changed, 63 insertions(+), 67 deletions(-) [+] |
line wrap: on
line diff
--- a/src/parallel_execution/CMakeLists.txt Mon Dec 19 19:42:49 2016 +0900 +++ b/src/parallel_execution/CMakeLists.txt Mon Dec 19 22:23:37 2016 +0900 @@ -38,4 +38,4 @@ test/queue_test SOURCES test/queue_test.c queue.c -} +)
--- a/src/parallel_execution/queue.c Mon Dec 19 19:42:49 2016 +0900 +++ b/src/parallel_execution/queue.c Mon Dec 19 22:23:37 2016 +0900 @@ -3,8 +3,8 @@ #include <stdio.h> union Data* createSingleLinkedQueue(struct Context* context) { - struct Queue* queue = &ALLOCATE(context, Queue)->queue; - struct SingleLinkedQueue* singleLinkedQueue = &ALLOCATE(context, SingleLinkedQueue)->singleLinkedQueue; + struct Queue* queue = &ALLOCATE(context, Queue)->Queue; + struct SingleLinkedQueue* singleLinkedQueue = &ALLOCATE(context, SingleLinkedQueue)->SingleLinkedQueue; queue->queue = (union Data*)singleLinkedQueue; singleLinkedQueue->top = NULL; singleLinkedQueue->last = NULL; @@ -16,12 +16,12 @@ } void printQueue1(union Data* data) { - struct Node* node = &data->element.data->node; + struct Node* node = &data->Element.data->node; if (node == NULL) { printf("NULL"); } else { printf("key = %d ,", node->key); - printQueue1((union Data*)data->element.next); + printQueue1((union Data*)data->Element.next); } } @@ -36,7 +36,7 @@ } __code clearSingleLinkedQueue_stub(struct Context* context) { - goto clearSingleLinkedQueue(context, (struct SingleLinkedQueue *)context->data[D_Queue]->queue.queue->queue.queue, context->data[D_Queue]->queue.next); + goto clearSingleLinkedQueue(context, (struct SingleLinkedQueue *)context->data[D_Queue]->Queue.queue->Queue.queue, context->data[D_Queue]->Queue.next); } __code putSingleLinkedQueue(struct Context* context, struct SingleLinkedQueue* queue, struct Element* element, union Data* data, enum Code next) { @@ -54,12 +54,12 @@ } __code putSingleLinkedQueue_stub(struct Context* context) { - struct Element* element = &ALLOCATE(context, Element)->element; + struct Element* element = &ALLOCATE(context, Element)->Element; goto putSingleLinkedQueue(context, - (struct SingleLinkedQueue *)context->data[D_Queue]->queue.queue->queue.queue, + (struct SingleLinkedQueue *)context->data[D_Queue]->Queue.queue->Queue.queue, element, - context->data[D_Queue]->queue.data, - context->data[D_Queue]->queue.next); + context->data[D_Queue]->Queue.data, + context->data[D_Queue]->Queue.next); } __code takeSingleLinkedQueue(struct Context* context, struct SingleLinkedQueue* queue, union Data** data, enum Code next) { @@ -74,9 +74,9 @@ __code takeSingleLinkedQueue_stub(struct Context* context) { goto takeSingleLinkedQueue(context, - (struct SingleLinkedQueue *)context->data[D_Queue]->queue.queue->queue.queue, - &context->data[D_Queue]->queue.data, - context->data[D_Queue]->queue.next); + (struct SingleLinkedQueue *)context->data[D_Queue]->Queue.queue->Queue.queue, + &context->data[D_Queue]->Queue.data, + context->data[D_Queue]->Queue.next); } __code isEmptySingleLinkedQueue(struct Context* context, struct SingleLinkedQueue* queue, enum Code next,enum Code whenEmpty) { @@ -88,14 +88,14 @@ __code isEmptySingleLinkedQueue_stub(struct Context* context) { goto isEmptySingleLinkedQueue(context, - (struct SingleLinkedQueue *)context->data[D_Queue]->queue.queue->queue.queue, - context->data[D_Queue]->queue.next, - context->data[D_Queue]->queue.whenEmpty); + (struct SingleLinkedQueue *)context->data[D_Queue]->Queue.queue->Queue.queue, + context->data[D_Queue]->Queue.next, + context->data[D_Queue]->Queue.whenEmpty); } union Data* createSynchronizedQueue(struct Context* context) { - struct Queue* queue = &ALLOCATE(context, Queue)->queue; - struct SingleLinkedQueue* singleLinkedQueue = &ALLOCATE(context, SingleLinkedQueue)->singleLinkedQueue; + struct Queue* queue = &ALLOCATE(context, Queue)->Queue; + struct SingleLinkedQueue* singleLinkedQueue = &ALLOCATE(context, SingleLinkedQueue)->SingleLinkedQueue; queue->queue = (union Data*)singleLinkedQueue; singleLinkedQueue->top = NULL; singleLinkedQueue->last = NULL; @@ -106,7 +106,7 @@ return (union Data*)(queue); } -__code clearSynchornizedQueue(struct Context* context, struct SingleLinkedQueue* queue,enum Code next) { +__code clearSynchronizedQueue(struct Context* context, struct SingleLinkedQueue* queue,enum Code next) { struct Element* top = queue->top; if (__sync_bool_compare_and_swap(&queue->top, top, NULL)) { goto meta(context, next); @@ -115,8 +115,8 @@ } } -__code clearSynchornizedQueue_stub(struct Context* context) { - goto clearSingleLinkedQueue(context, (struct SingleLinkedQueue *)context->data[D_Queue]->queue.queue->queue.queue, context->data[D_Queue]->queue.next); +__code clearSynchronizedQueue_stub(struct Context* context) { + goto clearSingleLinkedQueue(context, (struct SingleLinkedQueue *)context->data[D_Queue]->Queue.queue->Queue.queue, context->data[D_Queue]->Queue.next); } __code putSynchronizedQueue(struct Context* context, struct SingleLinkedQueue* queue, struct Element* element, union Data* data, enum Code next) { @@ -140,12 +140,12 @@ } __code putSynchronizedQueue_stub(struct Context* context) { - struct Element* element = &ALLOCATE(context, Element)->element; + struct Element* element = &ALLOCATE(context, Element)->Element; goto putSynchronizedQueue(context, - (struct SingleLinkedQueue *)context->data[D_Queue]->queue.queue->queue.queue, + (struct SingleLinkedQueue *)context->data[D_Queue]->Queue.queue->Queue.queue, element, - context->data[D_Queue]->queue.data, - context->data[D_Queue]->queue.next); + context->data[D_Queue]->Queue.data, + context->data[D_Queue]->Queue.next); } __code takeSynchronizedQueue(struct Context* context, struct SingleLinkedQueue* queue, union Data** data, enum Code next) { @@ -164,9 +164,9 @@ __code takeSynchronizedQueue_stub(struct Context* context) { goto takeSynchronizedQueue(context, - (struct SingleLinkedQueue *)context->data[D_Queue]->queue.queue->queue.queue, - &context->data[D_Queue]->queue.data, - context->data[D_Queue]->queue.next); + (struct SingleLinkedQueue *)context->data[D_Queue]->Queue.queue->Queue.queue, + &context->data[D_Queue]->Queue.data, + context->data[D_Queue]->Queue.next); } __code isEmptySynchronizedQueue(struct Context* context, struct SingleLinkedQueue* queue, enum Code next,enum Code whenEmpty) { @@ -178,7 +178,7 @@ __code isEmptySynchronizedQueue_stub(struct Context* context) { goto isEmptySynchronizedQueue(context, - (struct SingleLinkedQueue *)context->data[D_Queue]->queue.queue->queue.queue, - context->data[D_Queue]->queue.next, - context->data[D_Queue]->queue.whenEmpty); + (struct SingleLinkedQueue *)context->data[D_Queue]->Queue.queue->Queue.queue, + context->data[D_Queue]->Queue.next, + context->data[D_Queue]->Queue.whenEmpty); }
--- a/src/parallel_execution/test/queue_test.c Mon Dec 19 19:42:49 2016 +0900 +++ b/src/parallel_execution/test/queue_test.c Mon Dec 19 22:23:37 2016 +0900 @@ -4,66 +4,62 @@ #include <assert.h> -__code queue_test1(struct Context* context, struct Task* task, struct Queue* queue) { - task->code = C_QueueTest1; - queue->next = C_QueueTest2; +__code queueTest1(struct Context* context, struct Task* task, struct Queue* queue) { + task->code = C_queueTest1; + queue->next = C_queueTest2; queue->data = (union Data*)task; - goto meta(context, queue->queue->queue.put); + goto meta(context, queue->queue->Queue.put); } -__code queue_test1_stub(struct Context* context) { +__code queueTest1_stub(struct Context* context) { Task* task = &ALLOCATE(context, Task)->Task; - struct Queue* queue = &(createSingleLinkedQueue(context)->queue); - assert(queue->queue->singleLinkedQueue.top == NULL); - assert(queue->queue->singleLinkedQueue.last == NULL); - context->data[D_Queue]->queue.queue = (union Data*)queue; - goto queue_test1(context, + struct Queue* queue = &(createSingleLinkedQueue(context)->Queue); + assert(queue->queue->SingleLinkedQueue.top == NULL); + assert(queue->queue->SingleLinkedQueue.last == NULL); + context->data[D_Queue]->Queue.queue = (union Data*)queue; + goto queueTest1(context, task, - &context->data[D_Queue]->queue); + &context->data[D_Queue]->Queue); } -__code queue_test2(struct Context* context, struct Task* task, struct Queue* queue) { - task->code = C_QueueTest2; - queue->next = C_QueueTest3; +__code queueTest2(struct Context* context, struct Task* task, struct Queue* queue) { + task->code = C_queueTest2; + queue->next = C_queueTest3; queue->data = (union Data*)task; - goto meta(context, queue->queue->queue.put); + goto meta(context, queue->queue->Queue.put); } -__code queue_test2_stub(struct Context* context) { - assert(((struct Task)context->data[D_Queue]->queue.queue->queue.queue->singleLinkedQueue.top->data)->code == C_QueueTest1) - assert(((struct Task)context->data[D_Queue]->queue.queue->queue.queue->singleLinkedQueue.top->data)->code == C_QueueTest1) +__code queueTest2_stub(struct Context* context) { Task* task = &ALLOCATE(context, Task)->Task; - goto queue_test2(context, + goto queueTest2(context, task, - &context->data[D_Queue]->queue->queue); + &context->data[D_Queue]->Queue.queue); } -__code queue_test3(struct Context* context, struct Queue* queue) { - queue->next = C_QueueTest4; - goto meta(context, queue->queue->take) +__code queueTest3(struct Context* context, struct Queue* queue) { + queue->next = C_queueTest4; + goto meta(context, queue->queue->Queue.take); } -__code queue_test3_stub(struct Context* context) { - assert(((struct Task)context->data[D_Queue]->queue.queue->queue.queue->singleLinkedQueue.top->data)->code == C_QueueTest2) - assert(((struct Task)context->data[D_Queue]->queue.queue->queue.queue->singleLinkedQueue.top->data)->code == C_QueueTest1) - goto queue_test3(context, - &context->data[D_Queue]->queue); +__code queueTest3_stub(struct Context* context) { + goto queueTest3(context, + &context->data[D_Queue]->Queue); } -__code queue_test4(struct Context* context) { - goto meta(context, Exit); +__code queueTest4(struct Context* context, struct Queue* queue) { + goto meta(context, C_queueTest4 /*Exit*/ ); } -__code queue_test4_stub(struct Context* context) { - assert(((struct Task)context->data[D_Queue]->queue.queue.data)->code == C_QueueTest1) - assert(((struct Task)context->data[D_Queue]->queue.queue.last->data)->code == C_QueueTest2) - goto queue_test4(context, - &context->data[D_Queue]->queue->queue); +__code queueTest4_stub(struct Context* context) { +// assert(((struct Task)context->data[D_Queue]->queue.queue.data)->code == C_queueTest1) +// assert(((struct Task)context->data[D_Queue]->queue.queue.last->data)->code == C_queueTest2) + goto queueTest4(context, + &context->data[D_Queue]->Queue.queue); } int main(int argc, char const* argv[]) { struct Context* main_context = NEW(struct Context); initContext(main_context); - main_context->next = C_QueueTest1; + main_context->next = C_queueTest1; goto start_code(main_context); }