view test_env.c @ 2:35d6eabeadb0

modify Makefile. we can use makefile to compile outside CbC examples. (some examples are not compilable...)
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Wed, 22 Oct 2014 02:06:29 +0900
parents bacef8675607
children
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);
}

__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;
  
  printf("f0: fp = 0x%x\n", __builtin_frame_address(0));
  void __return_func(int retval_, void *fp){
    retval = retval_;
    goto exit0;
  }
  
  printf("f1: fp = 0x%x\n", __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;
}