# HG changeset patch # User Shohei KOKUBO # Date 1427896611 -32400 # Node ID 714d0ce1efd7dbe28a6e4ff8a0ae623b82872b06 # Parent ad48a076a8e580d5f598d267e0357cf410b2981e change configuring directory diff -r ad48a076a8e5 -r 714d0ce1efd7 src/CMakeLists.txt --- a/src/CMakeLists.txt Tue Mar 24 17:55:43 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -cmake_minimum_required(VERSION 2.8) -add_definitions("-Wall -g -O0") -add_executable(allocate allocate.c) -set(CMAKE_C_COMPILER /Users/e105744/Desktop/CbC_llvm/Release+Asserts/bin/clang) diff -r ad48a076a8e5 -r 714d0ce1efd7 src/Makefile --- a/src/Makefile Tue Mar 24 17:55:43 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,167 +0,0 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.1 - -# Default target executed when no arguments are given to make. -default_target: all -.PHONY : default_target - -# Allow only one "make -f Makefile2" at a time, but pass parallelism. -.NOTPARALLEL: -.PHONY : .NOTPARALLEL - -#============================================================================= -# Special targets provided by cmake. - -# Disable implicit rules so canonical targets will work. -.SUFFIXES: - -# Remove some rules from gmake that .SUFFIXES does not remove. -SUFFIXES = - -.SUFFIXES: .hpux_make_needs_suffix_list - -# Suppress display of executed commands. -$(VERBOSE).SILENT: - -# A target that is always out of date. -cmake_force: -.PHONY : cmake_force - -#============================================================================= -# Set environment variables for the build. - -# The shell in which to execute make rules. -SHELL = /bin/sh - -# The CMake executable. -CMAKE_COMMAND = /usr/local/Cellar/cmake/3.1.3/bin/cmake - -# The command to remove a file. -RM = /usr/local/Cellar/cmake/3.1.3/bin/cmake -E remove -f - -# Escaping for special characters. -EQUALS = = - -# The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /Users/e105744/Desktop/Gears/src - -# The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /Users/e105744/Desktop/Gears/src - -#============================================================================= -# Targets provided globally by CMake. - -# Special rule for the target edit_cache -edit_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..." - /usr/local/Cellar/cmake/3.1.3/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) -.PHONY : edit_cache - -# Special rule for the target edit_cache -edit_cache/fast: edit_cache -.PHONY : edit_cache/fast - -# Special rule for the target rebuild_cache -rebuild_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." - /usr/local/Cellar/cmake/3.1.3/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) -.PHONY : rebuild_cache - -# Special rule for the target rebuild_cache -rebuild_cache/fast: rebuild_cache -.PHONY : rebuild_cache/fast - -# The main all target -all: cmake_check_build_system - $(CMAKE_COMMAND) -E cmake_progress_start /Users/e105744/Desktop/Gears/src/CMakeFiles /Users/e105744/Desktop/Gears/src/CMakeFiles/progress.marks - $(MAKE) -f CMakeFiles/Makefile2 all - $(CMAKE_COMMAND) -E cmake_progress_start /Users/e105744/Desktop/Gears/src/CMakeFiles 0 -.PHONY : all - -# The main clean target -clean: - $(MAKE) -f CMakeFiles/Makefile2 clean -.PHONY : clean - -# The main clean target -clean/fast: clean -.PHONY : clean/fast - -# Prepare targets for installation. -preinstall: all - $(MAKE) -f CMakeFiles/Makefile2 preinstall -.PHONY : preinstall - -# Prepare targets for installation. -preinstall/fast: - $(MAKE) -f CMakeFiles/Makefile2 preinstall -.PHONY : preinstall/fast - -# clear depends -depend: - $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 -.PHONY : depend - -#============================================================================= -# Target rules for targets named allocate - -# Build rule for target. -allocate: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 allocate -.PHONY : allocate - -# fast build rule for target. -allocate/fast: - $(MAKE) -f CMakeFiles/allocate.dir/build.make CMakeFiles/allocate.dir/build -.PHONY : allocate/fast - -allocate.o: allocate.c.o -.PHONY : allocate.o - -# target to build an object file -allocate.c.o: - $(MAKE) -f CMakeFiles/allocate.dir/build.make CMakeFiles/allocate.dir/allocate.c.o -.PHONY : allocate.c.o - -allocate.i: allocate.c.i -.PHONY : allocate.i - -# target to preprocess a source file -allocate.c.i: - $(MAKE) -f CMakeFiles/allocate.dir/build.make CMakeFiles/allocate.dir/allocate.c.i -.PHONY : allocate.c.i - -allocate.s: allocate.c.s -.PHONY : allocate.s - -# target to generate assembly for a file -allocate.c.s: - $(MAKE) -f CMakeFiles/allocate.dir/build.make CMakeFiles/allocate.dir/allocate.c.s -.PHONY : allocate.c.s - -# Help Target -help: - @echo "The following are some of the valid targets for this Makefile:" - @echo "... all (the default if no target is provided)" - @echo "... clean" - @echo "... depend" - @echo "... edit_cache" - @echo "... rebuild_cache" - @echo "... allocate" - @echo "... allocate.o" - @echo "... allocate.i" - @echo "... allocate.s" -.PHONY : help - - - -#============================================================================= -# Special targets to cleanup operation of make. - -# Special rule to run CMake to check the build system integrity. -# No rule that depends on this can have commands that come from listfiles -# because they might be regenerated. -cmake_check_build_system: - $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 -.PHONY : cmake_check_build_system - diff -r ad48a076a8e5 -r 714d0ce1efd7 src/allocate.c --- a/src/allocate.c Tue Mar 24 17:55:43 2015 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -#include -#include - -#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)(Context*, data1*, int)) { - context->continuer = next; - goto meta_allocate(context, size, num); -} - -__code meta_allocate(Context* context, int size, int num) { - 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->continuer(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); -} diff -r ad48a076a8e5 -r 714d0ce1efd7 src/allocate.h --- a/src/allocate.h Tue Mar 24 17:55:43 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 (*continuer)(); -} Context; - -__code start_code(); -__code meta_start_code(); -__code code1(); -__code meta_code1(); -__code allocate(); -__code meta_allocate(); -__code code2(Context*, data1*, int); -__code meta_code2(); -__code exit_code(); diff -r ad48a076a8e5 -r 714d0ce1efd7 src/allocate/CMakeLists.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/allocate/CMakeLists.txt Wed Apr 01 22:56:51 2015 +0900 @@ -0,0 +1,10 @@ +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 ad48a076a8e5 -r 714d0ce1efd7 src/allocate/allocate.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/allocate/allocate.c Wed Apr 01 22:56:51 2015 +0900 @@ -0,0 +1,17 @@ +#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 ad48a076a8e5 -r 714d0ce1efd7 src/allocate/allocate.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/allocate/allocate.h Wed Apr 01 22:56:51 2015 +0900 @@ -0,0 +1,34 @@ +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 ad48a076a8e5 -r 714d0ce1efd7 src/allocate/allocate_test.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/allocate/allocate_test.c Wed Apr 01 22:56:51 2015 +0900 @@ -0,0 +1,69 @@ +#include +#include + +#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); +}