Re: Global restricted function pointer
- From: Willem <willem@xxxxxxxxxxxxxx>
- Date: Tue, 16 Jun 2009 11:11:45 +0000 (UTC)
Jacob Shamalini wrote:
) I have a trampoline variable into which I repeatedly load callbacks
) for execution, I'd like to be hopeful about it getting optimized into
) a register.
)
) More or less like this:
)
) void (*current_callback)();
)
) void run()
) {
) for(;;)
) current_callback(); // each callback loads a new callback as a
) side effect
) }
)
)
) I _can_ declare a global restricted object pointer, therefore I wonder
) if a function pointer might be legal.
I don't think 'restrict' does what you think it does.
And even if it did, you do *not* want it optimized into a register,
otherwise it could be calling the wrong function.
If you *want* it to be a register instead of a global pointer,
the following method could be useful:
void run()
{
void *(* cb)();
cb = init;
while (cb)
cb = cb();
}
I.E. each callback returns the next callback instead of
setting it in a global.
Note: the type definition of cb becomes quite tricky in this case,
so I decided to let the functions return void pointers which get
autoconverted to the correct function type by the assignment.
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
.
- Follow-Ups:
- Re: Global restricted function pointer
- From: Richard Harter
- Re: Global restricted function pointer
- From: Jacob Shamalini
- Re: Global restricted function pointer
- References:
- Global restricted function pointer
- From: Jacob Shamalini
- Re: Global restricted function pointer
- From: Igmar Palsenberg
- Re: Global restricted function pointer
- From: Jacob Shamalini
- Global restricted function pointer
- Prev by Date: Re: rtf file verification
- Next by Date: Re: Has CBFalconer died?
- Previous by thread: Re: Global restricted function pointer
- Next by thread: Re: Global restricted function pointer
- Index(es):
Relevant Pages
|