changeset 127:4c56639505ff

fix function.c and add CbC-example Makefile
author mir3636
date Wed, 11 Apr 2018 18:46:58 +0900
parents 5d30d517ebed
children fe568345ddd5
files CbC-examples/Makefile CbC-examples/bug.c CbC-examples/normal.c CbC-examples/normal2.c CbC-examples/parallel_check/c-int-double.c CbC-examples/parallel_check/c-int.c CbC-examples/parallel_check/c-struct.c CbC-examples/quicksort/quicksort_c.c CbC-examples/return_check/test_return.c CbC-examples/return_check/typedeffed.c CbC-examples/return_check/variable_return_type.c CbC-examples/test01.c CbC-examples/test03.c CbC-examples/test04.c CbC-examples/test_array.c CbC-examples/test_call.c CbC-examples/test_nest.c CbC-examples/test_return.c CbC-examples/test_struct.c CbC-examples/test_tailcall1.c CbC-examples/tmp2.c gcc/calls.c gcc/function.c
diffstat 23 files changed, 18 insertions(+), 1170 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CbC-examples/Makefile	Wed Apr 11 18:46:58 2018 +0900
@@ -0,0 +1,9 @@
+TEST = arg.exe conv1.exe fact-a.exe goto.exe loto6.exe stack1.exe test02.exe test05.exe test1.exe test2.exe test_cs.exe test_csp1.exe test_env.exe test_func2code.exe test_para2.exe test_para3.exe test_para4.exe test_para.exe test_tree.exe tmp1.exe tmp2.exe tmp4.exe tmpa.exe too-long-argument.exe
+
+.SUFFIXES: .exe
+
+.c.exe : 
+	${CBC_COMPILER} $(CFLAGS) -o $@ $<
+
+test : $(TEST)
+	for exe in ${TEST}; do; ./$${exe} ; done
--- a/CbC-examples/bug.c	Sun Apr 08 20:55:21 2018 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-extern int printf(const char*, ...);
-
-typedef void (*atexit_callback)(void);
-typedef void (*cxa_atexit_callback)(void *);
-struct one_atexit_routine 
-{
-  int callback;
-};
-
-
-static int
-atexit_common (const struct one_atexit_routine *r, const void *dso)
-
-
-{
-    return 0;
-}
-
-int main(){
-    printf("hello\n");
-}
--- a/CbC-examples/normal.c	Sun Apr 08 20:55:21 2018 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-#include<stdio.h>
-#include<stdlib.h>
-
-//size_t size;
-int size;
-typedef int test_int;
-
-test_int ti;
-
-void end(){
-	exit(0);
-}
-
-int main(int argc, char **argv){
-	size=0;
-	ti=10;
-
-	printf("main: ");
-	printf("normal:%d\n", argc);
-
-	size = 10;
-	printf("size = %d\n", size);
-	printf("  ti = %d\n",   ti);
-	end();
-}
-
--- a/CbC-examples/normal2.c	Sun Apr 08 20:55:21 2018 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-//#include<stdio.h>
-//#include<stdlib.h>
-extern int printf(const char*, ...);
-extern void exit(int);
-
-struct abc {
-	int a;
-	double b;
-	char c;
-	double *d;
-};
-
-struct def {
-	int d;
-	struct abc e;
-	struct abc *f;
-};
-
-void print_abc(struct abc a){
-	printf("\tstruct abc:\n");
-	printf("\ta=%d, b=%lf, c=%d, d=%p\n", a.a, a.b, a.c, a.d);
-}
-void print_def(struct def b){
-	printf("\tstruct def:\n");
-	printf("\ta=%d, b=%p\n", b.d, b.f);
-	print_abc(b.e);
-}
-
-void cs_exit(int a){
-	printf("cs_exit : a=%d.\n", a);
-	exit(a);
-}
-
-void cs0(struct abc a, struct def b, int c){
-	printf("cs0     :\n");
-	print_abc(a);
-	print_def(b);
-	return cs_exit( c*a.a+b.e.c );
-}
-
-
-void cs_goto(int c, struct abc a, struct def b){
-	printf("cs_return :\n");
-	print_abc(a);
-	print_def(b);
-	return cs0(a, b, c);
-}
-
-int main(int argc, char **argv){
-	struct abc A;
-	struct def B;
-	//int a=10, b=20, c=30, d=40, e=50, f=60, g=70;
-	A.a = 10, A.b = 20.02, A.c = '\0', A.d = 0;
-	B.d = 30, B.f = &A;
-	B.e.a = 50, B.e.b = 60.06, B.e.c = '\1', B.e.d = 0;
-
-	printf("main    :\n");
-	print_abc(A);
-	print_def(B);
-	//printf("20*%d + 30*%d + 40*%d + 50*%d  =\n", a, b, c, d);
-	cs_goto(100, A, B);
-	return 0;
-}
-
-
-
-
--- a/CbC-examples/parallel_check/c-int-double.c	Sun Apr 08 20:55:21 2018 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-#include<stdio.h>
-#include<math.h>
-
-#define dprint(f, args...) \
-	printf("in %s env=%p: "f, __FUNCTION__, __builtin_frame_address(1), ## args)
-
-int
-test(int a)
-{
-	return (int)pow(a, 2.0);
-}
-
-int
-callee(double a, double b, double c, int d)
-{
-	dprint("a=%d,b=%d,c=%d,d=%d\n", a,b,c,d);
-	return a+b+c+d;
-}
-
-int
-caller(int a, double b, double c, double d)
-{
-	int x;
-	double y,z,w;
-	//x = test(a);
-	//y = test(b);
-	//z = test(c);
-	//w = test(d);
-	x=a, y=b;
-	z=c, w=d;
-
-	return callee(y,z,w,x);
-	//return callee(b,c,d, a);
-}
-
-int
-main (int argc, char **argv)
-{
-	int r;
-	r = caller(11,22,33,44);
-	//r = caller(11,22,33,44, 55,66,77,88);
-	printf("r = %d\n", r);
-}
-
-
-
--- a/CbC-examples/parallel_check/c-int.c	Sun Apr 08 20:55:21 2018 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-#include<stdio.h>
-#define dprint(f, args...) \
-	printf("in %s env=%p: "f, __FUNCTION__, __builtin_frame_address(1), ## args)
-
-void
-callee(int a, int b, int c, int d)
-{
-	int r;
-	dprint("a=%d,b=%d,c=%d,d=%d\n", a,b,c,d);
-	r = a+b+c+d;
-	printf("r = %d\n", r);
-	return;
-}
-
-void
-caller1(int a, int b, int c, int d)
-{
-	int x,y,z,w;
-	x=a, y=b;
-	z=c, w=d;
-
-	callee(x,y,z,w);
-	return;
-}
-
-void
-caller2(int a, int b, int c, int d)
-{
-	int x,y,z,w;
-	x=a, y=b;
-	z=c, w=d;
-
-	callee(y,z,w,x);
-	return;
-}
-
-void
-caller3(int a, int b, int c, int d)
-{
-	callee(b,c,d,a);
-	return;
-}
-
-void
-caller4(int a, int b, int c, int d)
-{
-	callee(a+b,b+c,c+d,d+a);
-	return;
-}
-
-void
-caller5(int a, int b, int c, int d)
-{
-	int x,y,z,w;
-	x = a+b;
-	y = b+c;
-	z = c+d;
-	w = d+a;
-
-	callee(x,y,z,w);
-	return;
-}
-
-int
-main (int argc, char **argv)
-{
-	int r;
-	caller5(11,22,33,44);
-	//r = caller(11,22,33,44, 55,66,77,88);
-}
-
--- a/CbC-examples/parallel_check/c-struct.c	Sun Apr 08 20:55:21 2018 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-#include<stdio.h>
-#include<math.h>
-
-#define dprint(f, args...) \
-	printf("in %s env=%p: "f, __FUNCTION__, __builtin_frame_address(1), ## args)
-
-typedef struct {
-	int a;
-	double b;
-	char *c;
-} STRUCT;
-
-int
-test(int a)
-{
-	return (int)pow(a, 2.0);
-}
-
-
-int
-callee(int a, STRUCT s, int b)
-	/*  |-|----|-|  */
-{
-	dprint("a=%d,b=%d\n", a,b);
-	dprint("s.a=%d,s.b=%lf,s.c=%s\n", s.a, s.b, s.c);
-	return a+b+ s.a;
-}
-
-int
-caller(STRUCT s, int a, double b)
-	/*  |----|-|--|  */
-{
-	STRUCT s0;// = {44, 55.5, "aiueo2"};
-	//int a0 = 55;
-	//a0 = a;
-	s0 = s;
-
-	return callee(10, s0, 20);
-}
-
-int
-main (int argc, char **argv)
-{
-	int r;
-	STRUCT s = { 33, 44.4, "aiueo" };
-
-	r = caller(s, 11, 22.2);
-	//r = caller(11,22,33,44, 55,66,77,88);
-	printf("r = %d\n", r);
-}
-
--- a/CbC-examples/quicksort/quicksort_c.c	Sun Apr 08 20:55:21 2018 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,183 +0,0 @@
-#include<stdio.h>
-#include<stdlib.h>
-#include<unistd.h>
-#include<assert.h>
-
-static inline void
-SWAP (int *a, int *b)
-{
-	int tmp;
-	tmp = *a;
-	*a = *b;
-	*b = tmp;
-}
-
-static inline int
-mid_point(int a, int b, int c)
-{
-	if (a < b) {
-		if (b < c)
-			return b;
-		else if (a < c)
-			return c;
-		else 
-			return a;
-	} else {
-		if (a < c)
-			return a;
-		else if (b < c)
-			return c;
-		else 
-			return b;
-	}
-}
-
-void
-selectsort(int *v, int s0, int e0)
-{
-	int i,j;
-	int m;
-	int size = e0-s0+1;
-	v += s0;
-	for (i=0; i<size; i++) {
-		m = i;
-		for (j=i+1; j<size; j++) {
-			if (v[m] > v[j])
-				m = j;
-		}
-		if (m!=i)
-			SWAP(&v[i],&v[m]);
-	}
-	return;
-}
-
-void
-quicksort(int *v, int s0, int e0)
-{
-	int p;
-	int s=s0, e=e0;
-#if 0
-	if (e<=s) return;
-	if (e-s<5) {
-		selectsort(v,s0,e0);
-		return;
-	}
-#else
-	if (e<=s) return;
-#endif
-
-	//p = (v[s]+v[(s+e)/2]+v[e])/3;
-	p = mid_point(v[s],v[e],v[(s+e)/2]);
-
-	while (1) {
-		 while (v[s]<p) s++;
-		 while (p<v[e]) e--;
-
-		 if (!(s<e)) break;
-		 SWAP(&v[s], &v[e]);
-		 s++; e--;
-	}
-	assert(e+1==s || s==e);
-
-	quicksort(v, s0, e);
-	quicksort(v, e+1, e0);
-	return;
-}
-
-static void
-print_array(int *v, int size)
-{
-	int i;
-	printf("[");
-	for (i=0; i<size; i++) {
-		printf("%s%4d", (i%10==0)? "\n  ":" ", v[i]);
-	}
-	printf("]\n");
-}
-
-static int
-check_sort(int *v, int size)
-{
-	int i;
-	for (i=0; i<size-1; i++) {
-		if (v[i] > v[i+1])
-			return 0;
-	}
-	return 1;
-}
-
-void
-random_initialize(int *v, int size, int min, int max)
-{
-	int i;
-	int diff = max-min+1;
-
-	for (i=0; i<size; i++) {
-		v[i] = min+random()%diff;
-	}
-	return;
-}
-
-int
-start_sort(int size)
-{
-	int *target;
-
-	target = (int*)malloc(sizeof(int)*size);
-	if (!target) {
-		perror("malloc");
-		exit(1);
-	}
-
-	random_initialize(target, size, 0, 1);
-
-	//print_array(target, size);
-	quicksort(target, 0, size-1);
-	//selectsort(target, 0, size-1);
-	//print_array(target, size);
-	return check_sort(target, size);
-}
-
-int
-main(int argc, char **argv)
-{
-	//unsigned int seed= -1074072728;
-	unsigned int seed;
-	int size=101;
-	int loop=1;
-	int opt, i;
-
-	while ((opt = getopt(argc, argv, "t:s:n:")) != -1) {
-		switch (opt) {
-			case 'n':
-				size = atoi(optarg);
-				break;
-			case 't':
-				loop = atoi(optarg);
-				break;
-			case 's':
-				seed = atoi(optarg);
-				break;
-			default:
-				fprintf(stderr, "Usage: %s [-t times] [-n sizeofarray] [-s seed]\n", argv[0]);
-				exit(1);
-		}
-	}
-
-	printf("start seed = %u\n", seed);
-	printf("sort size = %d\n", size);
-	for (i=0; i<loop; i++) {
-		srandom(seed+i);
-		int b = start_sort(size);
-		if (b) {
-			printf("seed = %d+%u, success\n", i, seed);
-		} else {
-			fprintf(stderr, "sorting failure!  seed=%u+%d\n", seed,i);
-			exit(1);
-		}
-	}
-	exit(0);
-}
-
-
-
--- a/CbC-examples/return_check/test_return.c	Sun Apr 08 20:55:21 2018 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-#include<stdio.h>
-
-#if 0
-typedef float testtype;
-testtype good = 33.3f;
-testtype bad = 0.0f;
-void print_testtype(testtype t)
-{
-	printf("return value = %2.3f  good=%2.3f,bad=%2.3f\n", t,good,bad);
-}
-#elif 1
-typedef char testtype;
-testtype good = 33;
-testtype bad  = 0;
-void print_testtype(testtype t)
-{
-	printf("return value = %d, good=%d,bad=%d\n", t,good,bad);
-}
-#elif 0
-typedef double testtype;
-testtype good = 333.3;
-testtype bad  = 0.00;
-void print_testtype(testtype t)
-{
-	printf("return value = %3.3lf, good=%3.3lf,bad=%3.3lf\n", t,good,bad);
-}
-#elif 0
-typedef
-struct {
-	int a;
-	float b;
-	int c[4];
-} testtype;
-testtype good = {33, 33.3, {4,4,4,4}};
-testtype bad  = {0, 00.0, {0,0,0,0}};
-void print_testtype(testtype t)
-{
-	printf( "return value = {\n"
-			"	a = %d\n"
-			"	b = %2.3f\n"
-			"	c = { %d, %d, %d, %d }"
-			"}\n", t.a, t.b,
-			t.c[0],t.c[1],t.c[2],t.c[3]);
-}
-#else
-typedef int testtype;
-testtype good = 33;
-testtype bad = 0;
-void print_testtype(testtype t)
-{
-	printf("return value = %d,  good=%d,bad=%d\n", t,good,bad);
-}
-#endif
-
-typedef void (*RET_FUNC)(testtype, void *);
-
-void g(RET_FUNC func)
-{
-	func(good, NULL);
-}
-
-testtype f_cbc()
-{
-	//__label__ _cbc_exit0;
-	//int retval;
-	void *ret;
-
-	ret = _CbC_return;
-
-	printf("f0: fp = %p\n", __builtin_frame_address(0));
-	printf("__return_func = %p\n", ret);
-	g(ret);
-
-	printf("not good\n");
-	return bad;
-//_cbc_exit0:
-	//printf("f1: fp = 0x%x\n", __builtin_frame_address(0));
-	//return retval;
-}
-
-int main(int argc, char **argv)
-{
-	testtype t;
-	printf("main before: fp = %p\n", __builtin_frame_address(0));
-	t = f_cbc();
-	print_testtype(t);
-	printf("main after: fp = %p\n", __builtin_frame_address(0));
-}
-
--- a/CbC-examples/return_check/typedeffed.c	Sun Apr 08 20:55:21 2018 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-#include<stdio.h>
-
-#if 0
-typedef float testtype;
-testtype good = 33.3f;
-testtype bad = 0.0f;
-void print_testtype(testtype t)
-{
-	printf("return value = %2.3f  good=%2.3f,bad=%2.3f\n", t,good,bad);
-}
-#elif 1
-typedef char testtype;
-testtype good = 33;
-testtype bad  = 0;
-void print_testtype(testtype t)
-{
-	printf("return value = %d, good=%d,bad=%d\n", t,good,bad);
-}
-#elif 0
-typedef double testtype;
-testtype good = 333.3;
-testtype bad  = 0.00;
-void print_testtype(testtype t)
-{
-	printf("return value = %3.3lf, good=%3.3lf,bad=%3.3lf\n", t,good,bad);
-}
-#elif 0
-typedef
-struct {
-	int a;
-	float b;
-	int c[4];
-} testtype;
-testtype good = {33, 33.3, {4,4,4,4}};
-testtype bad  = {0, 00.0, {0,0,0,0}};
-void print_testtype(testtype t)
-{
-	printf( "return value = {\n"
-			"	a = %d\n"
-			"	b = %2.3f\n"
-			"	c = { %d, %d, %d, %d }"
-			"}\n", t.a, t.b,
-			t.c[0],t.c[1],t.c[2],t.c[3]);
-}
-#else
-typedef int testtype;
-testtype good = 33;
-testtype bad = 0;
-void print_testtype(testtype t)
-{
-	printf("return value = %d,  good=%d,bad=%d\n", t,good,bad);
-}
-#endif
-
-typedef void (*RET_FUNC)(testtype, void *);
-
-void g(RET_FUNC func)
-{
-	func(good, NULL);
-}
-
-testtype f_cbc()
-{
-	//__label__ _cbc_exit0;
-	//int retval;
-	void *ret;
-
-	ret = _CbC_return;
-
-	printf("f0: fp = %p\n", __builtin_frame_address(0));
-	printf("__return_func = %p\n", ret);
-	g(ret);
-
-	printf("not good\n");
-	return bad;
-//_cbc_exit0:
-	//printf("f1: fp = 0x%x\n", __builtin_frame_address(0));
-	//return retval;
-}
-
-int main(int argc, char **argv)
-{
-	testtype t;
-	printf("main before: fp = %p\n", __builtin_frame_address(0));
-	t = f_cbc();
-	print_testtype(t);
-	printf("main after: fp = %p\n", __builtin_frame_address(0));
-}
-
--- a/CbC-examples/return_check/variable_return_type.c	Sun Apr 08 20:55:21 2018 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,196 +0,0 @@
-#include<stdio.h>
-#include<assert.h>
-
-#define dprint(f, args...) \
-	fprintf(stdout, "in %s\t: "f, __FUNCTION__, ## args)
-
-
-/* for integer.  */
-int goodint = 33;
-int badint = 0;
-typedef void (*RETINT_FUNC)(int, void *);
-void g_int(RETINT_FUNC func)
-{
-	func(goodint, NULL);
-}
-int f_int()
-{
-	void *ret;
-
-	ret = _CbC_return;
-
-	dprint("fp = %p\n", __builtin_frame_address(0));
-	dprint("__return_func = %p\n", ret);
-	g_int(ret);
-	//goto g(ret);
-
-	dprint("not good\n");
-	return badint;
-}
-
-
-/* for double.  */
-double gooddouble = 333.3;
-double baddouble  = 0.00;
-typedef void (*RETDOUBLE_FUNC)(double, void *);
-void g_double(RETDOUBLE_FUNC func)
-{
-	func(gooddouble, NULL);
-}
-double f_double()
-{
-	void *ret;
-	ret = _CbC_return;
-
-	dprint("fp = %p\n", __builtin_frame_address(0));
-	dprint("__return_func = %p\n", ret);
-	g_double(ret);
-	//goto g_double(ret);
-
-	dprint("not good\n");
-	return baddouble;
-}
-
-/* for float.  */
-float goodfloat = 33.3f;
-float badfloat = 0.0f;
-typedef void (*RETFLOAT_FUNC)(float, void *);
-void g_float(RETFLOAT_FUNC func)
-{
-	func(goodfloat, NULL);
-}
-float f_float()
-{
-	void *ret;
-	ret = _CbC_return;
-
-	dprint("fp = %p\n", __builtin_frame_address(0));
-	dprint("__return_func = %p\n", ret);
-	g_float(ret);
-	//goto g_float(ret);
-
-	dprint("not good\n");
-	return badfloat;
-}
-
-/* for char.  */
-char goodchar = 33;
-char badchar  = 0;
-typedef void (*RETCHAR_FUNC)(char, void *);
-void g_char(RETCHAR_FUNC func)
-{
-	func(goodchar, NULL);
-}
-char f_char()
-{
-	void *ret;
-
-	ret = _CbC_return;
-
-	dprint("fp = %p\n", __builtin_frame_address(0));
-	dprint("__return_func = %p\n", ret);
-	g_char(ret);
-	//goto g(ret);
-
-	dprint("not good\n");
-	return badchar;
-}
-
-
-/* for struct.  */
-struct ifid {
-	int a;
-	float b;
-	int c[4];
-	double d;
-};
-struct ifid goodstruct = {33, 33.3, {4,4,4,4}, 333.333};
-struct ifid badstruct  = {0, 00.0, {0,0,0,0}, 0.0};
-typedef void (*RETSTRUCT_FUNC)(struct ifid, void *);
-void g_struct(RETSTRUCT_FUNC func)
-{
-	func(goodstruct, NULL);
-}
-struct ifid f_struct()
-{
-	void *ret;
-
-	ret = _CbC_return;
-
-	dprint("fp = %p\n", __builtin_frame_address(0));
-	dprint("__return_func = %p\n", ret);
-	g_struct(ret);
-	//goto g(ret);
-
-	dprint("not good\n");
-	return badstruct;
-}
-
-int main(int argc, char **argv)
-{
-	void *bptr;
-	int rint;
-	float rfloat;
-	double rdouble;
-	char rchar;
-	struct ifid rstruct;
-
-	bptr = __builtin_frame_address(0);
-
-	dprint("before int: fp = %p\n", __builtin_frame_address(0));
-	rint = f_int();
-	dprint("f_int = %d,  good=%d,bad=%d\n", rint,goodint,badint);
-
-	dprint("before float: fp = %p\n", __builtin_frame_address(0));
-	rfloat = f_float();
-	dprint("f_float = %3.3f, good=%3.3f,bad=%3.3f\n", rfloat,goodfloat,badfloat);
-	assert(bptr==__builtin_frame_address(0));
-
-	dprint("before double: fp = %p\n", __builtin_frame_address(0));
-	rdouble = f_double();
-	dprint("f_double = %3.3lf, good=%3.3lf,bad=%3.3lf\n", rdouble,gooddouble,baddouble);
-	assert(bptr==__builtin_frame_address(0));
-
-	dprint("before char: fp = %p\n", __builtin_frame_address(0));
-	rchar = f_char();
-	dprint("f_char = %d,  good=%d,bad=%d\n", rchar,goodchar,badchar);
-	assert(bptr==__builtin_frame_address(0));
-
-	dprint("before struct: fp = %p\n", __builtin_frame_address(0));
-	rstruct = f_struct();
-	dprint( "return value = {\n"
-			"	a = %d\n"
-			"	b = %2.3f\n"
-			"	c = { %d, %d, %d, %d }\n"
-			"	d = %3.3f\n"
-			"}\n", rstruct.a, rstruct.b,
-			rstruct.c[0],rstruct.c[1],rstruct.c[2],rstruct.c[3], rstruct.d);
-
-
-
-	dprint("end: fp = %p\n", __builtin_frame_address(0));
-
-	if (bptr!=__builtin_frame_address(0)) {
-		dprint("CbC_return failure!\n");
-		return 1;
-	}
-	if ( rint!=goodint 
-		|| rchar!=goodchar
-		|| (rfloat < goodfloat-0.01 || goodfloat+0.01 < rfloat)
-		|| (rdouble < gooddouble-0.01 || gooddouble+0.01 < rdouble)
-		|| rstruct.a!=goodstruct.a
-		|| (rstruct.b < goodstruct.b-0.01 || goodstruct.b+0.01 < rstruct.b)
-		|| (rstruct.d < goodstruct.d-0.01 || goodstruct.d+0.01 < rstruct.d)
-		|| rstruct.c[0]!=goodstruct.c[0]
-		|| rstruct.c[1]!=goodstruct.c[1]
-		|| rstruct.c[2]!=goodstruct.c[2]
-		|| rstruct.c[3]!=goodstruct.c[3] ) {
-		dprint("CbC_return failure!\n");
-		return 1;
-	}
-
-
-	dprint("CbC_return successful!\n");
-	return 0;
-}
-
--- a/CbC-examples/test01.c	Sun Apr 08 20:55:21 2018 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-#include<stdio.h>
-int test_goto2(int a,int b,int c,int d,int e,int f,int g,int h,int i,int j,int k);
-
-int test_code(void){
-	printf("\t\ttest_code: return 10\n");
-	return 10;
-}
-
-int test_goto(int a){
-	printf("\ttest_goto: a = %d\n", a);
-	//return test_code();
-	return test_code();
-}
-
-int main(int argc, char **argv){
-	int ret;
-	printf("test code\n");
-	ret = test_goto(20);
-	printf("main: ret = %d\n", ret);
-
-	return test_goto2(10,20,30,40,50,60,70,80,90,100);
-	return 0;
-}
-
-int test_code2(int a,int b,int c,int d,int e,int f,int g,int h,int i,int j,int k){
-	printf("\t\ttest_code: return 10\n");
-	printf("a=%d,b=%d,c=%d,d=%d,e=%d,f=%d,g=%d,h=%d,i=%d,j=%d,k=%d\n",a,b,c,d,e,f,g,h,i,j,k );
-	return a+b+c+d+e+f+g+h+i+j+k;
-}
-
-int test_goto2(int a,int b,int c,int d,int e,int f,int g,int h,int i,int j,int k){
-	printf("\ttest_goto: a = %d\n", a);
-	//return test_code();
-	return test_code2(a,b,c,d,e,f,g,h,i,j,k);
-}
--- a/CbC-examples/test03.c	Sun Apr 08 20:55:21 2018 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-
-extern void test02() ;
-extern void test03() ;
-
-extern int data;
-
-extern void
-test01() {
-    test02();
-}
-
-extern void
-test02() {
-    test03();
-}
-
-extern void
-test03() {
-    data = 3;
-}
-
-int
-main()
-{
-    test01();
-}
--- a/CbC-examples/test04.c	Sun Apr 08 20:55:21 2018 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-extern int printf(const char*, ...);
-
-int test01(int a, double b, int *c){
-    return a+b- *c;
-}
-
-int test(int *a, double b){
-    int c;
-    c = *a*b + 10;
-    printf("a = %x, *a = %d, b = %d\n", a, *a, b);
-    *a = test01( *a+b, 0.02, &c);
-    return *a+b;
-}
-
-
-int test02(int a, int b){
-    int i,sum=0;
-    i = a;
-    while ( i <= b ) {
-	sum += i;
-	i++;
-    }
-    return sum - a*b;
-}
-
-int main(int argc, char **argv){
-    int a=10;
-
-    printf("= %d\n", test02(0, 10));
-    test( &a, 10.1);
-    return 0;
-}
-
-
--- a/CbC-examples/test_array.c	Sun Apr 08 20:55:21 2018 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-//#include<stdio.h>
-extern int printf(const char*, ...);
-void print_array(int *, int);
-
-int main(int argc, char **argv){
-	int array[10] = {10, 2, 3, 0, 7, 5};
-	array[1] += array[2]+array[4];
-	print_array(array, 10);
-	return 0;
-}
-
-void print_array(int *a, int size){
-	while( size-->0 ){
-		printf(" %7d", *a++);
-	}
-	printf("\n");
-}
-
--- a/CbC-examples/test_call.c	Sun Apr 08 20:55:21 2018 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-extern int printf(const char*, ...);
-
-int test(int a){
-	printf("a = %d\n", a);
-	return 10*a;
-}
-
-int main(){
-	test(10);
-	return 0;
-}
-
-
--- a/CbC-examples/test_nest.c	Sun Apr 08 20:55:21 2018 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-
-int printf(char *, ...);
-typedef void (*RET_FUNC)(int, void *);
-
-void g(RET_FUNC func)
-{
-	func(33, 0);
-}
-
-int f()
-{
-	void *ret;
-	ret = ({
-		__label__ exit0;
-		int retval;
-		void __return_func(int retval_, void *fp){
-			retval = retval_;
-			goto exit0;
-		}
-		if (0) {
-		  exit0:
-			printf("f2: fp = 0x%x\n", __builtin_frame_address(0));
-			return retval;
-		}
-		__return_func;
-	});
-
-	//g(__return_func, __builtin_frame_address(0));
-	printf("f0: fp = 0x%x\n", __builtin_frame_address(0));
-	printf("__return_func = %x\n", ret);
-	g(ret);
-
-	printf("not good\n");
-	return 0;
-
-//exit0:
-	//printf("f2: fp = 0x%x\n", __builtin_frame_address(0));
-	//return retval;
-}
-
-int main(int argc, char **argv)
-{
-	int t;
-	printf("main before: fp = 0x%x\n", __builtin_frame_address(0));
-	t = f();
-	printf("f = %d\n", t);
-	printf("main after: fp = 0x%x\n", __builtin_frame_address(0));
-}
-
-
--- a/CbC-examples/test_return.c	Sun Apr 08 20:55:21 2018 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-#include<stdio.h>
-
-#if 0
-typedef float testtype;
-testtype good = 33.3f;
-testtype bad = 0.0f;
-void print_testtype(testtype t)
-{
-	printf("return value = %2.3f  good=%2.3f,bad=%2.3f\n", t,good,bad);
-}
-#elif 1
-typedef char testtype;
-testtype good = 33;
-testtype bad  = 0;
-void print_testtype(testtype t)
-{
-	printf("return value = %d, good=%d,bad=%d\n", t,good,bad);
-}
-#elif 0
-typedef double testtype;
-testtype good = 333.3;
-testtype bad  = 0.00;
-void print_testtype(testtype t)
-{
-	printf("return value = %3.3lf, good=%3.3lf,bad=%3.3lf\n", t,good,bad);
-}
-#elif 0
-typedef
-struct {
-	int a;
-	float b;
-	int c[4];
-} testtype;
-testtype good = {33, 33.3, {4,4,4,4}};
-testtype bad  = {0, 00.0, {0,0,0,0}};
-void print_testtype(testtype t)
-{
-	printf( "return value = {\n"
-			"	a = %d\n"
-			"	b = %2.3f\n"
-			"	c = { %d, %d, %d, %d }"
-			"}\n", t.a, t.b,
-			t.c[0],t.c[1],t.c[2],t.c[3]);
-}
-#else
-typedef int testtype;
-testtype good = 33;
-testtype bad = 0;
-void print_testtype(testtype t)
-{
-	printf("return value = %d,  good=%d,bad=%d\n", t,good,bad);
-}
-#endif
-
-typedef void (*RET_FUNC)(testtype, void *);
-
-void g(RET_FUNC func)
-{
-	func(good, NULL);
-}
-
-testtype f_cbc()
-{
-	//__label__ _cbc_exit0;
-	//int retval;
-	void *ret;
-
-	ret = _CbC_return;
-
-	printf("f0: fp = %p\n", __builtin_frame_address(0));
-	printf("__return_func = %p\n", ret);
-	g(ret);
-
-	printf("not good\n");
-	return bad;
-//_cbc_exit0:
-	//printf("f1: fp = 0x%x\n", __builtin_frame_address(0));
-	//return retval;
-}
-
-int main(int argc, char **argv)
-{
-	testtype t;
-	printf("main before: fp = %p\n", __builtin_frame_address(0));
-	t = f_cbc();
-	print_testtype(t);
-	printf("main after: fp = %p\n", __builtin_frame_address(0));
-}
-
--- a/CbC-examples/test_struct.c	Sun Apr 08 20:55:21 2018 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-extern int printf(const char*, ...);
-
-void tset01( struct aaa B, int size);
-
-struct aaa{
-	int a;      // 4
-	char b;     // 1
-	int c;      // 4
-	double d;   // 8
-	char e[10]; //10
-};              //27  --> 32
-
-int main(int argc, char **argv){
-	struct aaa A;
-	A.a = 10;
-	A.b = 'A';
-	A.c = 20;
-	A.d = 1.11;
-	A.e[0] = 'A', A.e[1] = 'Z';
-
-	printf("sizeof aaa = %d\n", sizeof(struct aaa));
-	tset01( A, 10);
-	return 0;
-}
-
-void tset01( struct aaa B, int size){
-	printf("B.a = %d\n", B.a);
-	printf("B.b = %d\n", B.b);
-	printf("B.c = %d\n", B.c);
-	printf("B.d = %lf\n", B.d);
-	B.e[9] = '\0';
-	printf("B.e = %s\n", B.e);
-	printf("size = %d\n", size);
-}
--- a/CbC-examples/test_tailcall1.c	Sun Apr 08 20:55:21 2018 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-#include<stdio.h>
-
-
-void B(int a, int b, int c){
-    printf("B: a=%d, b=%d, c=%d\n", a, b, c);
-    return ;
-}
-
-void* freturn(){
-	return B;
-}
-void A(int a, int b, int c, int d){
-    void (*fp)(int, int, int);
-    fp = freturn();
-
-    printf("A: a=%d, b=%d, c=%d, d=%d\n", a, b, c, d);
-    return fp(a, b, c+d);
-    //return B(a, b, c+d);
-}
-
-int main(int argc, char **argv){
-    printf("main: \n");
-    //fp = B;
-    A(10, 20, 30, 40);
-    return 0;
-}
-
-
--- a/CbC-examples/tmp2.c	Sun Apr 08 20:55:21 2018 +0900
+++ b/CbC-examples/tmp2.c	Wed Apr 11 18:46:58 2018 +0900
@@ -24,7 +24,7 @@
 char *av[];
 {
     fprintf(stdout,"#0021:2: %s\n",av[0]);
-    goto code0(av,__CbC_return,__CbC_environment);
+    goto code0(av,_CbC_return,_CbC_environment);
 }
 
 __code code0(av,ret,retenv)
--- a/gcc/calls.c	Sun Apr 08 20:55:21 2018 +0900
+++ b/gcc/calls.c	Wed Apr 11 18:46:58 2018 +0900
@@ -3375,7 +3375,8 @@
 
 #ifndef noCbC
   if ( fntype
-       && CbC_IS_CbC_GOTO (exp) // it's better? than CALL_EXPR_TAILCALL()
+       //&& CbC_IS_CbC_GOTO (exp) // it's better? than CALL_EXPR_TAILCALL()
+       && CALL_EXPR_TAILCALL(exp)
        && CbC_IS_CODE_SEGMENT (TREE_TYPE (current_function_decl))
      )
     {
--- a/gcc/function.c	Sun Apr 08 20:55:21 2018 +0900
+++ b/gcc/function.c	Wed Apr 11 18:46:58 2018 +0900
@@ -3668,6 +3668,10 @@
       }
 }
 
+#ifndef noCbC
+#include "c/cbc-tree.h"
+#endif
+
 /* Assign RTL expressions to the function's parameters.  This may involve
    copying them into registers and using those registers as the DECL_RTL.  */
 
@@ -3874,8 +3878,8 @@
     }
 
 #ifndef noCbC
-  //  if (CbC_IS_CODE_SEGMENT(TREE_TYPE(fndecl)) )
-  //    all.stack_args_size.constant = CbC_STACK_SIZE;
+    if (CbC_IS_CODE_SEGMENT(TREE_TYPE(fndecl)) )
+      all.stack_args_size.constant = CbC_PRETENDED_STACK_SIZE;
 #endif
 
   /* We have aligned all the args, so add space for the pretend args.  */