J
Jeff
Hello,
I'm having a problem passing a function parameter to a perl callback
function being call from C w/ a cloned interpreter. The reason for the
cloned interpreter is that the perl callback function is being called
from a different thread, and perl does not currently support multiple
threads concurrently calling into the same interpreter.
The below function works perfectly if I do not clone the interpreter.
But when I clone the interpreter, the function parameter passed on the
stack does not make its way to the function. When the perl function
attempts to use this varaible, it's always 0.
Is there a special step I need to take to setup the function parameter
on the stack w/ a cloned interpreter? I've tried passing a reference
to the variable, and this also does not work.
Any insight would be greatly appreciated.
Thanks,
Jeff
static void PerlCallBack(void *clientdata)
{
//clone perl interpreter and set it as context
perl_clone((PerlInterpreter*)Perl_get_context(),
CLONEf_CLONE_HOST|CLONEf_KEEP_PTR_TABLE);
PUSHMARK(SP) ;
//push integer, 2, onto stack as parameter for test purposes
XPUSHs(sv_2mortal(newSViv(2)));
PUTBACK ;
//call perl function passed via clientdata
perl_call_sv((SV*) clientdata, G_DISCARD) ;
LEAVE;
}
I'm having a problem passing a function parameter to a perl callback
function being call from C w/ a cloned interpreter. The reason for the
cloned interpreter is that the perl callback function is being called
from a different thread, and perl does not currently support multiple
threads concurrently calling into the same interpreter.
The below function works perfectly if I do not clone the interpreter.
But when I clone the interpreter, the function parameter passed on the
stack does not make its way to the function. When the perl function
attempts to use this varaible, it's always 0.
Is there a special step I need to take to setup the function parameter
on the stack w/ a cloned interpreter? I've tried passing a reference
to the variable, and this also does not work.
Any insight would be greatly appreciated.
Thanks,
Jeff
static void PerlCallBack(void *clientdata)
{
//clone perl interpreter and set it as context
perl_clone((PerlInterpreter*)Perl_get_context(),
CLONEf_CLONE_HOST|CLONEf_KEEP_PTR_TABLE);
PUSHMARK(SP) ;
//push integer, 2, onto stack as parameter for test purposes
XPUSHs(sv_2mortal(newSViv(2)));
PUTBACK ;
//call perl function passed via clientdata
perl_call_sv((SV*) clientdata, G_DISCARD) ;
LEAVE;
}