view pointer_longjump.c @ 6:509523ee1e27

add struct_longjump.c
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Sun, 24 Nov 2013 01:10:16 +0900
parents 4e7858590985
children
line wrap: on
line source

#include <stdio.h>
#include <setjmp.h>

__code code1(int n,__code(*__return)(int,void *,int *),void *__environment,int *__ret_p){
  printf("code1 : code entry1\n");
  goto __return(n,__environment,__ret_p);
}

__code return1 (int n,void* env,int* __ret_p){
  printf("return1 : __return entry\n");
  *__ret_p = n;
  longjmp(*(jmp_buf*)env,1);
}

int main1 (){
  __code (*__return)();
  void *__environment;
  int  *__ret_p;
  jmp_buf j_buf;
  int retval;
  __ret_p = &retval;
  __environment = &j_buf;
  printf("main1 : main1 entry\n");
  if (setjmp(__environment)){
    printf("main1 : main1 return\n");
    return retval;
  }
  __return = return1;
  goto code1(30,__return,__environment,__ret_p);
  return 0;
}

int main (){
  int n;
  n = main1();
  printf("returned\n");
  printf("return = %d\n",n);
  return 1;
}