Mercurial > hg > Members > nobuyasu > CbC
changeset 5:8bf48c0cb198
add cbc program CbC/loop
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 03 Jun 2012 14:22:49 +0900 |
parents | 6695c97470f3 |
children | 636a4f0cd8f4 |
files | DPP/Makefile DPP/dpp.cbc DPP/tableau.cbc loop/print.c loop/print.cbc loop/while.cbc |
diffstat | 6 files changed, 76 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/DPP/Makefile Sat Feb 04 12:41:59 2012 +0900 +++ b/DPP/Makefile Sun Jun 03 14:22:49 2012 +0900 @@ -1,8 +1,10 @@ CC=cbc-gcc-4.6.0 +#CC=~/hg/CbC/build-CbC-4.5/INSTALL_DIR/bin/cbc-gcc-4.5.0 #MCC=mcc TARGET=dpp dpp2 tableau tableau2 tableau3 #MCCFLAGS=-s -CFLAGS=-I. -g -Wall +#CFLAGS=-I. -g -Wall +CFLAGS=-O3 -Wall .SUFFIXES: .cbc .c .o
--- a/DPP/dpp.cbc Sat Feb 04 12:41:59 2012 +0900 +++ b/DPP/dpp.cbc Sun Jun 03 14:22:49 2012 +0900 @@ -3,7 +3,7 @@ ** Author : Atsuki Shimoji ** Note : This is a single running program. */ - +#include <stdio.h> #include "dpp.h" code putdown_lfork(PhilsPtr self)
--- a/DPP/tableau.cbc Sat Feb 04 12:41:59 2012 +0900 +++ b/DPP/tableau.cbc Sun Jun 03 14:22:49 2012 +0900 @@ -181,6 +181,7 @@ { self->right = phils_list; self->right_fork = phils_list->left_fork; + self->right->left = self; //printf("init all\n"); goto create_queue(1, self, 0, 0, task_entry0);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/loop/print.c Sun Jun 03 14:22:49 2012 +0900 @@ -0,0 +1,4 @@ +void func(void (*p)() ) { p(); } +#include <stdio.h> +void print() { printf("Hello\n");} +int main() { func(print); return 0;}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/loop/print.cbc Sun Jun 03 14:22:49 2012 +0900 @@ -0,0 +1,15 @@ +__code print(__rectype *p); + +__code func(__rectype *p) { + p(print); +} + +#include <stdio.h> +__code print(__rectype *p) { + printf("Hello\n"); +} + +int main() { + goto func(print); + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/loop/while.cbc Sun Jun 03 14:22:49 2012 +0900 @@ -0,0 +1,52 @@ +#define __environment _CbC_environment +#define __return _CbC_return + +#include <stdio.h> +#include <stdlib.h> + + +__code csa(__rectype *p, int total, int count); + + +__code print(__rectype *p, int total, int count) { + printf("function print()\n"); + printf("total = %d\ncount = %d\n",total,count); + exit(0); +} + +__code cs_end(__rectype *p, int total, int count){ + printf("cs_end: loop end\n"); + goto p(csa, total, count); +} + + +__code while_cond(__rectype *p, int total, int count) { + printf("while_cond\n"); + if ( count <= 100) { + goto cs_while(p, total, count); + } else { + goto cs_end(p, total, count); + } + +} + +__code cs_while(__rectype *p, int total, int count) { + printf("cswhile: \n"); + total += count; + count ++; + goto while_cond(p, total, count); +} + +__code csa(__rectype *p, int total, int count) { + goto cs_while(print, 0, 0); +} + +void func() { + goto csa(print, 0, 0); +} + +int main() +{ + func(); + return 0; +}