Well, I confirmed that what I was trying to do is definitely possible. By adding the following code to the external application, somewhat simulating what the original function was doing:
void interruptTest(void(*function)(void)){ isrFunctions[1] = function; isrFunctions[1](); }
...and then simplifying my code to use this new function:
use warnings; use strict; use Inline ('C' => 'DATA', libs => '-lwiringPi'); # direct call callback(); # extern call testing(); sub p_callback { print "in perl callback\n"; } __DATA__ __C__ #include <stdlib.h> #include <stdio.h> #include <wiringPi.h> void testing(); void callback(); void callback(){ dSP; PUSHMARK(SP); PUTBACK; call_pv("p_callback", G_DISCARD|G_NOARGS); FREETMPS; LEAVE; } void testing(){ interruptTest(&callback); }
I get no segfaults, and the perl callback is called in both instances (internal and external). So its not that the external code doesn't know how to process the callback, it has to be something to do with what's happening in the original function I was sending it into. There's forking happening, and then the callback is executed when an interrupt happens, so I'll keep playing.
In reply to Re: XS: Passing an external library's function a Perl XS callback
by stevieb
in thread SOLVED: XS: Passing an external library's function a Perl XS callback
by stevieb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |