Mercurial > hg > CbC > CbC_examples
view test_csp1.c @ 5:90e6146d24cd
fix stack1.c
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 22 Oct 2014 19:02:57 +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; }