view CbC-examples/test_env.c @ 60:bd49c42ec43e

remove unnecessary files
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 15 Feb 2010 17:39:45 +0900
parents 4c6926a2b9bc
children 5d30d517ebed
line wrap: on
line source


typedef void (*RET_FUNC)(int, void *);

int main(int argc, char **argv)
{
	int r;
	r = f();
	printf("%d\n", r);
}

//void z(RET_FUNC ret, void *fp)
__code z(RET_FUNC ret, void *fp)
{
	printf("z: fp=0x%x\n", __builtin_frame_address(0));
	ret(5, fp);
}
__code i(RET_FUNC ret, void *fp)
{
	printf("i: fp=0x%x\n", __builtin_frame_address(0));
	goto z(ret, fp);
}
__code h(RET_FUNC ret, void *fp)
{
	printf("h: fp=0x%x\n", __builtin_frame_address(0));
	goto i(ret, fp);
}
__code g(RET_FUNC ret, void *fp)
{
	printf("g: fp=0x%x\n", __builtin_frame_address(0));
	goto h(ret, fp);
}

int f()
{
	__label__ exit0;
	int retval;
	//void (*ret)(int retval_, void *fp);

	/*
	ret = ({
			void __return_func(int retval_, void *fp){
				retval = retval_;
				goto exit0;
			}
			__return_func;
		});
		*/
	printf("f0: fp = 0x%x\n", __builtin_frame_address(0));
	void __return_func(int retval_, void *fp){
		retval = retval_;
		goto exit0;
	}
	//ret = __return_func;

	printf("f1: fp = 0x%x\n", __builtin_frame_address(0));

	//g(__return_func, __builtin_frame_address(0));
	goto g(__return_func, __builtin_frame_address(0));

	printf("bad\n");

exit0:
	printf("f2: fp = 0x%x\n", __builtin_frame_address(0));
	return retval;
}