Hi,
I looked at the pingpong code and found how a thread is created and activated using THREADCONTROL system call. It uses C function pointers and typecasts them to L4_Word_t which are then passed to threadcontrol system call to run this function as thread.
I want to use a C++ function as the thread. But C++ member function pointer seem not to be as simple as C function pointers. Their size changes as well, with the compiler or compiler-options, because of inheritance. Is their any example code that does this?
Thanks.
Jayesh Salvi wrote:
Hi,
I looked at the pingpong code and found how a thread is created and activated using THREADCONTROL system call. It uses C function pointers and typecasts them to L4_Word_t which are then passed to threadcontrol system call to run this function as thread.
I want to use a C++ function as the thread. But C++ member function pointer seem not to be as simple as C function pointers. Their size changes as well, with the compiler or compiler-options, because of inheritance. Is their any example code that does this?
Hi, the typical way to deal with the like is to define a wrapper function an externalize it as a C function. The below example (taken from the fiasco source code) defines a C function sys_thread_ex_regs_wrapper which in turn calls sys_thread_ex_regs of class Thread.
extern "C" void sys_thread_ex_regs_wrapper() { Proc::sti(); current_thread()->sys_thread_ex_regs(); }
Marcus
l4-hackers@os.inf.tu-dresden.de