Ok, I'm trying to make perl5.004_04 be a builtin function in dtksh on AIX414.
[ No, no, please keep reading! Especially AIX 4.x system gurus! ]
Mainly as an interesting experiment, but with a view toward speeding
up perl access. I'm getting segfaults whenever dynamically loaded
modules like POSIX are use'd. The segfault occurs in boot_POSIX.
And yes, I think I'm using the xs_init() function properly. My
"by-the-book" substitute perlmain.c is appended below.
[ AIX users please try this at home. ]
After copying perl.exp from $Config{archlibexp}/CORE to $PWD,
I link myperl with
cc -o myperl b_perl.c -bE:funcs_perl.exp \
`perl -MExtUtils::Embed -e ccopts -e ldopts`
The funcs_perl.exp file contains the single line ``b_b_perl'', which
is use to tell dtksh that b_perl can be used as a builtin (the first
b_ is required by dtksh).
Now, the resulting myperl can be run at the command line and functions
just like perl, with ``use POSIX; print strftime "%D", localtime'' working
fine, ie., no problems with dynamic loading.
To make b_perl a dtksh builtin, you do this (under dtksh, of course)
builtin -f myperl
builtin b_perl
after that, stuff like ``b_perl -le 'print 1..99''' works fine,
but ``use POSIX'' segfaults in boot_POSIX, and ``use MD5'' segfaults
in boot_MD5.
Is there enything inherent in the way these extensions are constructed
that would prevent them from working when dynamically loaded from perl
if perl itself is dynamically loaded (which dtksh is doing when it
processes the ``builtin -f myperl''. I'm not positive, but I think
dtksh is using the load() system call.)?
Any ideas much appreciated.
John.
----- b_perl.c -----
#include <EXTERN.h> /* from the Perl distribution */
#include <perl.h> /* from the Perl distribution */
static void xs_init _((void));
static PerlInterpreter *my_perl; /*** The Perl interpreter ***/
int b_b_perl(int argc, char **argv, char **env)
{
my_perl = perl_alloc();
perl_construct(my_perl);
perl_parse(my_perl, xs_init, argc, argv, (char **)NULL);
perl_run(my_perl);
perl_destruct(my_perl);
perl_free(my_perl);
int main(int argc, char **argv, char **env)Quote:}
{
b_b_perl(argc, argv, env);
extern void boot_DynaLoader _((CV* cv));Quote:}
static void
xs_init()
{
char *file = __FILE__;
dXSUB_SYS;
newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
-------------------Quote:}
--
~\Allen/~Fax: 516-575-7428 <Universe>: 1e22 stars = 22 solar masses per sec