Mercurial > hg > CbC > old > akasha
changeset 6:3f00d95339a7
Use llrb in akasha
author | Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 15 Mar 2016 11:45:17 +0900 |
parents | 82a81eaff050 |
children | 24ae2641fec5 |
files | src/CMakeLists.txt src/insert_verification/CMakeLists.txt src/insert_verification/akashaCS.c src/insert_verification/akashaLLRBContext.c src/insert_verification/include/akashaCS.h src/insert_verification/include/akashaLLRBContext.h src/insert_verification/main.c |
diffstat | 7 files changed, 43 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/src/CMakeLists.txt Mon Mar 14 22:31:39 2016 +0900 +++ b/src/CMakeLists.txt Tue Mar 15 11:45:17 2016 +0900 @@ -5,7 +5,7 @@ # set compiler set(CMAKE_C_COMPILER $ENV{CBC_COMPILER}) -add_definitions("-Wall -g -O0") +add_definitions("-Wall -g -O0 --save-temps") include_directories(include)
--- a/src/insert_verification/CMakeLists.txt Mon Mar 14 22:31:39 2016 +0900 +++ b/src/insert_verification/CMakeLists.txt Tue Mar 15 11:45:17 2016 +0900 @@ -5,16 +5,16 @@ include_directories(include) include_directories($ENV{GEARS_PATH}/src/include) -include_directories(${llrb_path}) +include_directories(${llrb_path}/include) + add_executable(insert_verification main.c akashaCS.c akashaLLRBContext.c - ${llrb_path}/allocate.c # TODO: create file in akasha - ${llrb_path}/compare.c # TODO: create file in akasha - ${llrb_path}/stack.c # TODO: create file in akasha - ${llrb_path}/llrb.c + ${llrb_path}/allocate.c + ${llrb_path}/compare.c + ${llrb_path}/stack.c )
--- a/src/insert_verification/akashaCS.c Mon Mar 14 22:31:39 2016 +0900 +++ b/src/insert_verification/akashaCS.c Tue Mar 15 11:45:17 2016 +0900 @@ -5,11 +5,14 @@ goto (context->code[next])(context); } -__code start_code(struct Context* context, enum Code next) { +__code startCode(enum Code next) { + struct Context* context = (struct Context*)malloc(sizeof(struct Context)); + initLLRBContext(context); + goto meta(context, next); } -__code exit_code(struct Context* context) { +__code exitCode(struct Context* context) { free(context->code); free(context->data); free(context->heapStart);
--- a/src/insert_verification/akashaLLRBContext.c Mon Mar 14 22:31:39 2016 +0900 +++ b/src/insert_verification/akashaLLRBContext.c Tue Mar 15 11:45:17 2016 +0900 @@ -2,6 +2,9 @@ #include "akashaLLRBContext.h" +extern __code insertOnce_stub(struct Context*); + +/* definitions from llrb */ extern __code meta(struct Context*); extern __code put_stub(struct Context*); extern __code replaceNode_stub(struct Context*); @@ -35,16 +38,19 @@ extern __code deleteCase4_stub(struct Context*); extern __code deleteCase5_stub(struct Context*); extern __code deleteCase6_stub(struct Context*); -extern __code exit_code(struct Context*); +extern __code exitCode(struct Context*); -__code initLLRBContext(struct Context* context, int num) { +__code initLLRBContext(struct Context* context) { context->heapLimit = sizeof(union Data)*ALLOCATE_SIZE; - context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE); - context->data = malloc(sizeof(union Data*)*ALLOCATE_SIZE); + context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE); + context->data = malloc(sizeof(union Data*)*ALLOCATE_SIZE); context->heapStart = malloc(context->heapLimit); context->codeNum = Exit; + context->code[InsertOnce] = insertOnce_stub; + + /* definitions from llrb */ context->code[Put] = put_stub; context->code[Replace] = replaceNode_stub; context->code[Insert] = insertNode_stub; @@ -58,7 +64,7 @@ context->code[InsertCase4_2] = insert4_2_stub; context->code[InsertCase5] = insert5_stub; context->code[StackClear] = stackClear_stub; - context->code[Exit] = exit_code; + context->code[Exit] = exitCode; context->heap = context->heapStart;
--- a/src/insert_verification/include/akashaCS.h Mon Mar 14 22:31:39 2016 +0900 +++ b/src/insert_verification/include/akashaCS.h Tue Mar 15 11:45:17 2016 +0900 @@ -1,3 +1,3 @@ -extern __code start_code(struct Context* context, enum Code next); -extern __code exit_code(struct Context* context); +extern __code startCode(enum Code next); +extern __code exitCode(struct Context* context); extern __code meta(struct Context* context, enum Code next);
--- a/src/insert_verification/include/akashaLLRBContext.h Mon Mar 14 22:31:39 2016 +0900 +++ b/src/insert_verification/include/akashaLLRBContext.h Tue Mar 15 11:45:17 2016 +0900 @@ -4,6 +4,9 @@ #define ALLOCATE_SIZE 1000 enum Code { + InsertOnce, + + /* definitions from llrb */ Allocator, Put, Replace,
--- a/src/insert_verification/main.c Mon Mar 14 22:31:39 2016 +0900 +++ b/src/insert_verification/main.c Tue Mar 15 11:45:17 2016 +0900 @@ -1,16 +1,23 @@ #include <stdio.h> -struct Context; -struct Tree; -struct Node; -struct Allocate; +#include "llrbContext.h" +#include "origin_cs.h" + +__code insertOnce_stub(struct Context* context) { + goto insertOnce(context, &context->data[Node]->node); +} -extern __code put(struct Context*, struct Tree*, struct Node*, struct Allocate*); -__code hello() { - printf("access to llrb library: %p\n", put); +__code insertOnce(struct Context* context, struct Node* node) { + + // print_tree(context->data[Tree]->tree.root, 0); + // puts(""); + context->next = Exit; + node->key = rand()%100+1; + node->value = 100; + + goto meta(context, Put); } int main(int argc, char const* argv[]) { - - goto hello(); + goto startCode(InsertOnce); }