Mercurial > hg > Members > innparusu > Gears
changeset 17:1eb599acffe4
modify allocate
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 21 Apr 2015 02:28:57 +0900 |
parents | 481760d44d87 |
children | ec4e7a81bddf |
files | src/CMakeLists.txt src/allocate/allocate.c src/allocate/allocateContext.c src/allocate/allocateContext.h src/include/allocate.h |
diffstat | 5 files changed, 13 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/CMakeLists.txt Tue Apr 14 03:47:15 2015 +0900 +++ b/src/CMakeLists.txt Tue Apr 21 02:28:57 2015 +0900 @@ -1,5 +1,8 @@ cmake_minimum_required(VERSION 2.8) +# output compile log +set(CMAKE_VERBOSE_MAKEFILE 1) + # set compiler set(CMAKE_C_COMPILER $ENV{CbC_Clang}/clang)
--- a/src/allocate/allocate.c Tue Apr 14 03:47:15 2015 +0900 +++ b/src/allocate/allocate.c Tue Apr 21 02:28:57 2015 +0900 @@ -12,6 +12,7 @@ #endif #define NUM 100 +#define ALLOCATE_SIZE 1024 extern __code initAllocateContext(struct Context* context); /* @@ -56,10 +57,9 @@ int main() { struct Context* context = (struct Context*)malloc(sizeof(struct Context)); - context->code = malloc(sizeof(__code*)*1024); - context->data = malloc(sizeof(union Data**)*1024); - for (int i=0;i<1024;i++) - context->data[i] = malloc(sizeof(union Data*)); + context->code = malloc(sizeof(__code*)*ALLOCATE_SIZE); + context->data = malloc(sizeof(union Data**)*ALLOCATE_SIZE); + context->heap = malloc(sizeof(union Data*)*ALLOCATE_SIZE); initAllocateContext(context); goto start_code(context, Code1); }
--- a/src/allocate/allocateContext.c Tue Apr 14 03:47:15 2015 +0900 +++ b/src/allocate/allocateContext.c Tue Apr 21 02:28:57 2015 +0900 @@ -7,12 +7,14 @@ extern __code exit_code(struct Context*); __code initAllocateContext(struct Context* context) { - context->codeSize = 3; context->code[Code1] = code1; context->code[Code2] = code2; context->code[Code3] = code3; context->code[Allocate] = allocate; context->code[Exit] = exit_code; + context->dataSize = 0; + context->data[context->dataSize] = context->heap; + context->dataSize++; }
--- a/src/allocate/allocateContext.h Tue Apr 14 03:47:15 2015 +0900 +++ b/src/allocate/allocateContext.h Tue Apr 21 02:28:57 2015 +0900 @@ -11,6 +11,7 @@ struct Context { int codeSize; __code (**code) (struct Context *); + void* heap; int dataSize; union Data **data; };
--- a/src/include/allocate.h Tue Apr 14 03:47:15 2015 +0900 +++ b/src/include/allocate.h Tue Apr 21 02:28:57 2015 +0900 @@ -7,6 +7,8 @@ } __code meta_allocate(struct Context* context) { + context->data[context->dataSize] = context->heap; + context->heap += sizeof(union Data); context->dataSize++; goto (context->code[context->data[context->dataSize-1]->allocate.next])(context); }