# HG changeset patch # User Shohei KOKUBO # Date 1427904352 -32400 # Node ID 14c604cfa7118a15cfe1311c996ec76f40451f38 # Parent 714d0ce1efd7dbe28a6e4ff8a0ae623b82872b06 modify directories diff -r 714d0ce1efd7 -r 14c604cfa711 src/CMakeLists.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/CMakeLists.txt Thu Apr 02 01:05:52 2015 +0900 @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 2.8) + +# set compiler +set(CMAKE_C_COMPILER $ENV{CbC_Clang}/clang) + +# compile option +add_definitions("-Wall -g -O0") + +include_directories(include) + +add_subdirectory(allocate) +#add_subdirectory(list) diff -r 714d0ce1efd7 -r 14c604cfa711 src/allocate/CMakeLists.txt --- a/src/allocate/CMakeLists.txt Wed Apr 01 22:56:51 2015 +0900 +++ b/src/allocate/CMakeLists.txt Thu Apr 02 01:05:52 2015 +0900 @@ -1,10 +1,5 @@ cmake_minimum_required(VERSION 2.8) -# compile option -add_definitions("-Wall -g -O0") -#add_library(allocate_lib STATIC allocate.c) add_executable(allocate allocate_test.c ) -#target_link_libraries(allocate allocate_lib) -set(CMAKE_C_COMPILER $ENV{CbC_Clang}/clang) diff -r 714d0ce1efd7 -r 14c604cfa711 src/allocate/allocate.c --- a/src/allocate/allocate.c Wed Apr 01 22:56:51 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -#include - -#include "allocate.h" - -__code allocate(Context* context, int size, int num, __code (*next)()) { - goto meta_allocate(context, size, num, next); -} - -__code meta_allocate(Context* context, int size, int num, __code (*next)()) { - context->next = next; - void* ds = context->ds; - context->ds += size*num; - ((mdata*)context->mds)->ds = ds; - ((mdata*)context->mds)->size = size; - context->mds = (mdata*)context->mds+1; - goto context->next(context, (data1*)ds, 0); -} diff -r 714d0ce1efd7 -r 14c604cfa711 src/allocate/allocate.h --- a/src/allocate/allocate.h Wed Apr 01 22:56:51 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -typedef struct DataSegment1 { - int i; // 4 byte - char c[10]; // 10 byte - // padding 2 byte -} data1; - -typedef struct DataSegment2 { - int x; // 4 byte - int y; // 4 byte - int z; // 4 byte -} data2; - -typedef struct metaDataSegment { - size_t size; // 8 byte - void* ds; // 8 byte -} mdata; - -typedef struct Context_st { - void* ds; - void* mds; - void* ds_heap; - void* mds_heap; - __code (*next)(); -} Context; - -__code start_code(); -__code meta_start_code(); -__code code1(); -__code meta_code1(); -__code allocate(); -__code meta_allocate(); -__code code2(); -__code meta_code2(); -__code exit_code(); diff -r 714d0ce1efd7 -r 14c604cfa711 src/allocate/allocate_test.c --- a/src/allocate/allocate_test.c Wed Apr 01 22:56:51 2015 +0900 +++ b/src/allocate/allocate_test.c Thu Apr 02 01:05:52 2015 +0900 @@ -1,6 +1,7 @@ #include #include +#include "allocate_test.h" #include "allocate.h" #ifdef CLANG @@ -26,19 +27,19 @@ goto allocate(context, (int)sizeof(data1), NUM, code2); } -__code allocate(Context* context, int size, int num, __code (*next)()) { - goto meta_allocate(context, size, num, next); -} +/* __code allocate(Context* context, int size, int num, __code (*next)()) { */ +/* goto meta_allocate(context, size, num, next); */ +/* } */ -__code meta_allocate(Context* context, int size, int num, __code (*next)()) { - context->next = next; - void* ds = context->ds; - context->ds += size*num; - ((mdata*)context->mds)->ds = ds; - ((mdata*)context->mds)->size = size; - context->mds = (mdata*)context->mds+1; - goto context->next(context, (data1*)ds, 0); -} +/* __code meta_allocate(Context* context, int size, int num, __code (*next)()) { */ +/* context->next = next; */ +/* void* ds = context->ds; */ +/* context->ds += size*num; */ +/* ((mdata*)context->mds)->ds = ds; */ +/* ((mdata*)context->mds)->size = size; */ +/* context->mds = (mdata*)context->mds+1; */ +/* goto context->next(context, (data1*)ds, 0); */ +/* } */ __code code2(Context* context, data1* out, int loop) { out->i = loop; diff -r 714d0ce1efd7 -r 14c604cfa711 src/allocate/allocate_test.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/allocate/allocate_test.h Thu Apr 02 01:05:52 2015 +0900 @@ -0,0 +1,32 @@ +typedef struct DataSegment1 { + int i; // 4 byte + char c[10]; // 10 byte + // padding 2 byte +} data1; + +typedef struct DataSegment2 { + int x; // 4 byte + int y; // 4 byte + int z; // 4 byte +} data2; + +typedef struct metaDataSegment { + size_t size; // 8 byte + void* ds; // 8 byte +} mdata; + +typedef struct Context_st { + void* ds; + void* mds; + void* ds_heap; + void* mds_heap; + __code (*next)(); +} Context; + +__code start_code(); +__code meta_start_code(); +__code code1(); +__code meta_code1(); +__code code2(); +__code meta_code2(); +__code exit_code();