Select Git revision
remote_exception.py
perlmod.c 20.14 KiB
/* $Id: perlmod.c,v 1.14 2000/03/23 21:48:38 leif Exp $ */
#include "builtin_functions.h"
#include "global.h"
#include "svalue.h"
#include "array.h"
#include "stralloc.h"
#include "interpret.h"
#include "module_support.h"
#include "threads.h"
#include "mapping.h"
#include "perl_machine.h"
/* this is just for debugging */
#define _sv_2mortal(x) (x)
#ifdef HAVE_PERL
#include <EXTERN.h>
#include <perl.h>
/* Do not redefine my malloc macro you stupid Perl! */
#include "dmalloc.h"
static int num_perl_interpreters=0;
DEFINE_MUTEX(perl_running);
#ifdef MULTIPLICITY
#endif
struct perlmod_storage
{
char **argv;
char **env;
char *env_block;
struct array *argv_strings;
int constructed, parsed;
int array_size_limit;
PerlInterpreter *my_perl;
};
#define THIS ((struct perlmod_storage *)(fp->current_storage))
#define PERL THIS->my_perl
/* since both Perl and Pike likes to use "sp" as a stack pointer,
* let's define some Pike macros as functions...
*/
static void _push_int(INT32 i) { push_int(i);}
static void _push_float(float f) { push_float(f);}
static void _push_string(struct pike_string *s) { push_string(s);}
static void _push_array(struct array *a) { push_array(a);}
static void _pop_n_elems(int n) { pop_n_elems(n);}
static struct svalue *_pikesp() { return Pike_sp;}
static void _pike_pop() { --sp;}
#undef sp
#ifndef BLOCKING
#define MT_PERMIT THREADS_ALLOW(); mt_lock(&perl_running);
#define MT_FORBID mt_unlock(&perl_running); THREADS_DISALLOW();
#endif
/* utility function: push a zero_type zero */
static void _push_zerotype()
{ push_int(0);
Pike_sp[-1].subtype = 1;
}
static SV * _pikev2sv(struct svalue *s)