view test_csp1.c @ 8:37a10fd62ea9

add programs for prototype generation checking
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Sat, 21 Feb 2015 21:19:46 +0900
parents 35d6eabeadb0
children f442aa72b246
line wrap: on
line source

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


__code cs_end (int a);
__code cs0 (int a, int b, int c, int d);
void* freturn ();
__code cs_goto (int a, int b, int c, int d);
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;
}