explaination of trampoline
Paolo Bonzini
paolo.bonzini@lu.unisi.ch
Wed Sep 27 12:16:00 GMT 2006
> The c code for which i'm observing the effect is as follows.
>
> int foo(int (*f)()){
> (*f)();
> }
> main(){
> int g(){printf("hello");}
> foo(g);
> }
This one does not need a trampoline, because there would not be any
difference if int g() was not a nested function -- g() has no static
chain argument. Try this one instead:
int foo(int (*f)()){
(*f)();
}
main(int argc, char **argv){
int g(){printf("hello, argc=%d\n", argc);}
foo(g);
}
You will see trampolines in all their beauty.
Paolo
More information about the Gcc
mailing list