view test_csp1.c @ 18:bec7f99b60b5

remove goto exit
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Sun, 24 Jan 2016 06:03:01 +0900
parents f442aa72b246
children 586096c45873
line wrap: on
line source

#include<stdio.h>
#include<stdlib.h>


void* freturn ();
void function (double a, float b, int c);
int main (int argc, char **argv);


__code cs_goto(int a, int b, int c, int d){
  __code (*csp)(int, int, int, int);
  csp = freturn();
  printf("csp = %p.\n", csp);

#ifdef INDIRECT
  goto csp(b+a, d+b, a+c, c+d);
#else
  goto cs0(b+a, d+b, a+c, c+d);
#endif
}

__code cs_end(int a){
  printf("cs_exit : a=%d.\n", a);
  exit(a);
  goto cs_end(a);
}

__code cs0(int a, int b, int c, int d){
  printf("cs_cs0  : a=%d, b=%d, c=%d, d=%d.\n", a, b, c, d);
  goto cs_end( (int)(20*a + 30*b + 40*c + 50*d) );
}


void* freturn(){
  return cs0;
}

void function(double a, float b, int c){

  printf("function:\n");
  printf("a=%lf, b=%f, c=%d\n", a, b, c);
  goto cs_goto(10, 20, 30, 40);
}

int main(int argc, char **argv){
  function(10.01, 20.02, 30);
  return 0;
}