On Fri, 17 Jan 2003, Tassilo von Parseval wrote:

> Here the C function and how it's called from one of the two XSUBs below:
> 
>     int datify (FILETIME *wintime, int method) {
>         dXSARGS;
          ^^^^^^^^

>         time_t time = FileTimeToUnixTime(wintime, NULL);
>         struct tm *tstruct;
>         SP -= items;
          ^^^^^^^^^^^

>         if (method == 0)
>             tstruct = localtime(&time);
>         else    
>             tstruct = gmtime(&time);
>         
>         PUSHMARK(SP);
          ^^^^^^^^^

>         if (GIMME == G_ARRAY) {
>             EXTEND(SP, 9);
>             PUSHs(sv_2mortal(newSViv(tstruct->tm_sec)));
>             [...] /* nine values overall */
>             PUSHs(sv_2mortal(newSViv(tstruct->tm_isdst)));
>             PUTBACK;
              ^^^^^^^^^

>             return 9;
>         } else {
>             SV *str = newSVpvf("%s %s %2d %02d:%02d:%02d %d",
>                       dayname[tstruct->tm_wday],
>                       [...]
>                       tstruct->tm_year + 1900);                   
>             EXTEND(SP, 1);
>             PUSHs(sv_2mortal(str));
>             PUTBACK;
              ^^^^^^^^
>             return 1;
>         }
>     }
>     [...]

I can't address some of your points, but can tell you that in 5+ years of 
XS coding, I have never found it necessary to use any of the macros 
underlined above in an XS function called from perl.  The only time these 
are needed (AFAIK) is when calling back to a perl routine from C.

I suspect the fact you are calling a common C routine from two XS stubs is 
a red-herring.  I do this all the time without any need to worry about the 
Perl call stack.  Something else is going on.


Steve
 


Reply via email to