S
satya manapragada
Hi all,
I am fairly new to embedding perl into c. I am trying to rewrite an
application. which has following code. This code used to work fine with
perl 5.0005 on BeOS, but when started to compile against perl 5.8.4 on
Linux, initially it complained unsatisfied variable my_perl variable so
i added "#include <XSUB.h> " header which solved it. But know when I
run it i get Segmentation fault.
here is code
#include <EXTERN.h>
#include <perl.h>
#include <XSUB.h>
..........
..........
..........
GetBool(
char *inChan,
bool *outVal,
int16 inIdx,
unsigned int *inRef)
{
unsigned int retVal = 0;
unsigned int tempRef = 0;
int count;
char kindStr[8];
dSP ;
printf("Hello World \n");
ENTER ;
SAVETMPS ;
PUSHMARK(SP) ;
XPUSHs(sv_2mortal(newSViv(eCallType_GetBool)));
XPUSHs(sv_2mortal(newSViv(inChan)));
XPUSHs(sv_2mortal(newSVpv(kindStr, 0)));
XPUSHs(sv_2mortal(newSViv(inIdx)));
XPUSHs(sv_2mortal(newSViv(*inRef)));
PUTBACK ;
count = perl_call_pv((char *)Name(), G_ARRAY | G_EVAL);
SPAGAIN ;
if (count == 3) { // if we don't return 3, then we disregard whatever
this function did.
// return bool, ref, and callback (reversed om stack)
retVal = POPl;
*inRef = POPl;
*outVal = POPl ? true : false;
}
PUTBACK ;
FREETMPS ;
LEAVE ;
return retVal;
}
.............
.............
.............
(gdb) continue
Continuing.
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1232290896 (LWP 24333)]
0xb7ec38b6 in LOF_Script::GetBool (this=0x8824120, inChan=0xb2e29d8,
outVal=0xb68cba2b, inIdx=0, inRef=0xcf4ce70)
at Function/Output/LOF_Script.cpp:85
85 dSP ;
any suggestion.
thanks
Gopi Manapragada
I am fairly new to embedding perl into c. I am trying to rewrite an
application. which has following code. This code used to work fine with
perl 5.0005 on BeOS, but when started to compile against perl 5.8.4 on
Linux, initially it complained unsatisfied variable my_perl variable so
i added "#include <XSUB.h> " header which solved it. But know when I
run it i get Segmentation fault.
here is code
#include <EXTERN.h>
#include <perl.h>
#include <XSUB.h>
..........
..........
..........
GetBool(
char *inChan,
bool *outVal,
int16 inIdx,
unsigned int *inRef)
{
unsigned int retVal = 0;
unsigned int tempRef = 0;
int count;
char kindStr[8];
dSP ;
printf("Hello World \n");
ENTER ;
SAVETMPS ;
PUSHMARK(SP) ;
XPUSHs(sv_2mortal(newSViv(eCallType_GetBool)));
XPUSHs(sv_2mortal(newSViv(inChan)));
XPUSHs(sv_2mortal(newSVpv(kindStr, 0)));
XPUSHs(sv_2mortal(newSViv(inIdx)));
XPUSHs(sv_2mortal(newSViv(*inRef)));
PUTBACK ;
count = perl_call_pv((char *)Name(), G_ARRAY | G_EVAL);
SPAGAIN ;
if (count == 3) { // if we don't return 3, then we disregard whatever
this function did.
// return bool, ref, and callback (reversed om stack)
retVal = POPl;
*inRef = POPl;
*outVal = POPl ? true : false;
}
PUTBACK ;
FREETMPS ;
LEAVE ;
return retVal;
}
.............
.............
.............
(gdb) continue
Continuing.
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1232290896 (LWP 24333)]
0xb7ec38b6 in LOF_Script::GetBool (this=0x8824120, inChan=0xb2e29d8,
outVal=0xb68cba2b, inIdx=0, inRef=0xcf4ce70)
at Function/Output/LOF_Script.cpp:85
85 dSP ;
any suggestion.
thanks
Gopi Manapragada