Making perl a builtin command dtksh command on AIX 4.x

Making perl a builtin command dtksh command on AIX 4.x

Post by John L. All » Wed, 29 Oct 1997 04:00:00



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);

Quote:}

int main(int argc, char **argv, char **env)
{
b_b_perl(argc, argv, env);

Quote:}

extern void boot_DynaLoader _((CV* cv));

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
 
 
 

1. Need an AIX comand that is similar to Linix ipchains command or freeBSD ipfw command

I'm trying to find a command on IBM AIX that functions like the
ipchains command on Linux.  That is, it allows you to issue a rule
that tells all incoming TCP packets destined for port 80 to be
forwarded to port 10080.  Does
anyone know of a like command on AIX.  Thanks.

ex.

The Linux command is

ipchains -A input --destination-port 80 -p tcp -j REDIRECT 10080

2. Where is Xfig?

3. UNKNOWN AIX Command: What does the imfs command do?

4. Anonymous mail

5. diff among echo a>f; command<f; echo $a|command; command << $a; EOF

6. status on usage of NFS

7. Upgraded AIX, now @ symbol constantly appears at prompt and is making command line act funny.

8. OS5 & Specialix Multigraphics problem

9. AIX 4.1.3 - bosboot command failed in making mksysb - can I reboot?

10. Builtin commands true/false extension

11. check if a string is builtin command?

12. scope of variables assigned by read builtin command in bash

13. test command - builtin or not