This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: explaination of trampoline
- From: Paolo Bonzini <paolo dot bonzini at lu dot unisi dot ch>
- To: kernel coder <lhrkernelcoder at gmail dot com>, GCC Development <gcc at gcc dot gnu dot org>
- Date: Wed, 27 Sep 2006 13:56:55 +0200
- Subject: Re: explaination of trampoline
- References: <f69849430609270339g4f97dc35nd155836790e433b2@mail.gmail.com>
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