Mercurial > hg > Members > Moririn
changeset 10:88a4a95f5485
create list
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 02 Apr 2015 02:31:13 +0900 |
parents | 14c604cfa711 |
children | a4f351b66544 |
files | src/CMakeLists.txt src/allocate/CMakeLists.txt src/allocate/allocate.c src/allocate/allocate_test.c src/allocate/allocate_test.h src/allocate/prototype.h |
diffstat | 6 files changed, 68 insertions(+), 104 deletions(-) [+] |
line wrap: on
line diff
--- a/src/CMakeLists.txt Thu Apr 02 01:05:52 2015 +0900 +++ b/src/CMakeLists.txt Thu Apr 02 02:31:13 2015 +0900 @@ -9,4 +9,4 @@ include_directories(include) add_subdirectory(allocate) -#add_subdirectory(list) +add_subdirectory(list)
--- a/src/allocate/CMakeLists.txt Thu Apr 02 01:05:52 2015 +0900 +++ b/src/allocate/CMakeLists.txt Thu Apr 02 02:31:13 2015 +0900 @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.8) add_executable(allocate - allocate_test.c + allocate.c )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/allocate/allocate.c Thu Apr 02 02:31:13 2015 +0900 @@ -0,0 +1,45 @@ +#include <stdio.h> +#include <stdlib.h> + +#include "prototype.h" + +#include "context.h" +#include "allocate.h" +#include "origin_cs.h" + +#ifdef CLANG +#define _CbC_retrun __return +#define _CbC_environment __environment +#endif + +#define NUM 100 + +__code code1(Context* context) { + goto meta_code1(context); +} + +__code meta_code1(Context* context) { + goto allocate(context, (int)sizeof(data1), NUM, code2); +} + +__code code2(Context* context, data1* out, int loop) { + out->i = loop; + if (loop == NUM) { + goto meta_code2(context); + } + printf("%d\n",out->i); + goto code2(context, out+1, loop+1); +} + +__code meta_code2(Context* context) { + goto exit_code(context); +} + +int main() { + Context* context = (Context*)malloc(sizeof(Context)); + context->ds_heap = malloc(sizeof(data1)*1024); + context->mds_heap = malloc(sizeof(mdata)*1024); + context->ds = context->ds_heap; + context->mds = context->mds_heap; + goto start_code(context, code1); +}
--- a/src/allocate/allocate_test.c Thu Apr 02 01:05:52 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - -#include "allocate_test.h" -#include "allocate.h" - -#ifdef CLANG -#define _CbC_retrun __return -#define _CbC_environment __environment -#endif - -#define NUM 100 - -__code start_code(Context* context) { - goto meta_start_code(context); -} - -__code meta_start_code(Context* context) { - goto code1(context); -} - -__code code1(Context* context) { - goto meta_code1(context); -} - -__code meta_code1(Context* context) { - 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 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; - if (loop == NUM) { - goto meta_code2(context); - } - printf("%d\n",out->i); - goto code2(context, out+1, loop+1); -} - -__code meta_code2(Context* context) { - goto exit_code(context); -} - -__code exit_code(Context* context) { - free(context->ds_heap); - free(context->mds_heap); - goto exit(0); -} - -int main() { - Context* context = (Context*)malloc(sizeof(Context)); - context->ds_heap = malloc(sizeof(data1)*1024); - context->mds_heap = malloc(sizeof(mdata)*1024); - context->ds = context->ds_heap; - context->mds = context->mds_heap; - goto start_code(context); -}
--- a/src/allocate/allocate_test.h Thu Apr 02 01:05:52 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +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 code2(); -__code meta_code2(); -__code exit_code();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/allocate/prototype.h Thu Apr 02 02:31:13 2015 +0900 @@ -0,0 +1,21 @@ +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; + +__code code1(); +__code meta_code1(); +__code code2(); +__code meta_code2();