From: Nicholas Clark Date: Wed, 26 Oct 2005 08:31:20 +0000 (+0000) Subject: Most platforms don't actually need PL_pidstatus, or the associated X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ca0c25f67f45e5dccb746852d8545d7ae29ed067;p=p5sagit%2Fp5-mst-13.2.git Most platforms don't actually need PL_pidstatus, or the associated .5K of code. p4raw-id: //depot/perl@25850 --- diff --git a/embed.fnc b/embed.fnc index f00f722..6ad77da 100644 --- a/embed.fnc +++ b/embed.fnc @@ -609,7 +609,9 @@ Apd |void |require_pv |NN const char* pv Apd |void |pack_cat |NN SV *cat|NN const char *pat|NN const char *patend \ |NN SV **beglist|NN SV **endlist|NN SV ***next_in_list|U32 flags Apd |void |packlist |NN SV *cat|NN const char *pat|NN const char *patend|NN SV **beglist|NN SV **endlist +#ifdef PERL_USES_PL_PIDSTATUS p |void |pidgone |Pid_t pid|int status +#endif Ap |void |pmflag |NN U32* pmfl|int ch p |OP* |pmruntime |NN OP* pm|NN OP* expr|bool isreg p |OP* |pmtrans |NN OP* o|NN OP* expr|NN OP* repl diff --git a/intrpvar.h b/intrpvar.h index b69999a..966c7b7 100644 --- a/intrpvar.h +++ b/intrpvar.h @@ -239,7 +239,9 @@ PERLVARI(Icop_seqmax, U32, 0) /* statement sequence number */ PERLVARI(Ievalseq, U32, 0) /* eval sequence number */ PERLVAR(Iorigenviron, char **) PERLVAR(Iorigalen, U32) +#ifdef PERL_USES_PL_PIDSTATUS PERLVAR(Ipidstatus, HV *) /* pid-to-status mappings for waitpid */ +#endif PERLVARI(Imaxo, int, MAXO) /* maximum number of ops */ PERLVAR(Iosname, char *) /* operating system */ diff --git a/makedef.pl b/makedef.pl index 8975d50..890f6b0 100644 --- a/makedef.pl +++ b/makedef.pl @@ -824,6 +824,12 @@ if ($define{'SPRINTF_RETURNS_STRLEN'}) { Perl_my_sprintf )]; } +unless ($define{'PERL_USES_PL_PIDSTATUS'}) { + skip_symbols [qw( + Perl_pidgone + PL_pidstatus + )]; +} unless ($define{'d_mmap'}) { skip_symbols [qw( diff --git a/perl.c b/perl.c index f9a71af..ec8fd4e 100644 --- a/perl.c +++ b/perl.c @@ -259,7 +259,9 @@ perl_construct(pTHXx) } PL_sighandlerp = (Sighandler_t) Perl_sighandler; +#ifdef PERL_USES_PL_PIDSTATUS PL_pidstatus = newHV(); +#endif } PL_rs = newSVpvn("\n", 1); @@ -952,8 +954,10 @@ perl_destruct(pTHXx) PL_subname = Nullsv; SvREFCNT_dec(PL_linestr); PL_linestr = Nullsv; +#ifdef PERL_USES_PL_PIDSTATUS SvREFCNT_dec(PL_pidstatus); PL_pidstatus = Nullhv; +#endif SvREFCNT_dec(PL_toptarget); PL_toptarget = Nullsv; SvREFCNT_dec(PL_bodytarget); @@ -1770,6 +1774,9 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) # ifdef PERL_USE_SAFE_PUTENV " PERL_USE_SAFE_PUTENV" # endif +#ifdef PERL_USES_PL_PIDSTATUS + " PERL_USES_PL_PIDSTATUS" +#endif # ifdef PL_OP_SLAB_ALLOC " PL_OP_SLAB_ALLOC" # endif diff --git a/perl.h b/perl.h index d6ccfa4..d302252 100644 --- a/perl.h +++ b/perl.h @@ -815,6 +815,10 @@ int usleep(unsigned int); #define PERL_DONT_CREATE_GVSV #endif +#if !defined(HAS_WAITPID) && !defined(HAS_WAIT4) || defined(HAS_WAITPID_RUNTIME) +#define PERL_USES_PL_PIDSTATUS +#endif + /* Cannot include embed.h here on Win32 as win32.h has not yet been included and defines some config variables e.g. HAVE_INTERP_INTERN */ diff --git a/pp_sys.c b/pp_sys.c index b907093..19a735a 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -4128,7 +4128,9 @@ PP(pp_fork) #ifdef THREADS_HAVE_PIDS PL_ppid = (IV)getppid(); #endif +#ifdef PERL_USES_PL_PIDSTATUS hv_clear(PL_pidstatus); /* no kids, so don't wait for 'em */ +#endif } PUSHi(childpid); RETURN; diff --git a/sv.c b/sv.c index fc89183..53ef6e0 100644 --- a/sv.c +++ b/sv.c @@ -11608,7 +11608,9 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, PL_evalseq = proto_perl->Ievalseq; PL_origenviron = proto_perl->Iorigenviron; /* XXX not quite right */ PL_origalen = proto_perl->Iorigalen; +#ifdef PERL_USES_PL_PIDSTATUS PL_pidstatus = newHV(); /* XXX flag for cloning? */ +#endif PL_osname = SAVEPV(proto_perl->Iosname); PL_sighandlerp = proto_perl->Isighandlerp; diff --git a/util.c b/util.c index 74facce..4079c44 100644 --- a/util.c +++ b/util.c @@ -2232,7 +2232,9 @@ Perl_my_popen(pTHX_ const char *cmd, const char *mode) PL_ppid = (IV)getppid(); #endif PL_forkprocess = 0; +#ifdef PERL_USES_PL_PIDSTATUS hv_clear(PL_pidstatus); /* we have no children */ +#endif return Nullfp; #undef THIS #undef THAT @@ -2635,7 +2637,7 @@ Perl_wait4pid(pTHX_ Pid_t pid, int *statusp, int flags) I32 result = 0; if (!pid) return -1; -#if !defined(HAS_WAITPID) && !defined(HAS_WAIT4) || defined(HAS_WAITPID_RUNTIME) +#ifdef PERL_USES_PL_PIDSTATUS { char spid[TYPE_CHARS(IV)]; @@ -2686,7 +2688,7 @@ Perl_wait4pid(pTHX_ Pid_t pid, int *statusp, int flags) result = wait4((pid==-1)?0:pid,statusp,flags,Null(struct rusage *)); goto finish; #endif -#if !defined(HAS_WAITPID) && !defined(HAS_WAIT4) || defined(HAS_WAITPID_RUNTIME) +#ifdef PERL_USES_PL_PIDSTATUS #if defined(HAS_WAITPID) && defined(HAS_WAITPID_RUNTIME) hard_way: #endif @@ -2711,6 +2713,7 @@ Perl_wait4pid(pTHX_ Pid_t pid, int *statusp, int flags) } #endif /* !DOSISH || OS2 || WIN32 || NETWARE */ +#ifdef PERL_USES_PL_PIDSTATUS void Perl_pidgone(pTHX_ Pid_t pid, int status) { @@ -2723,6 +2726,7 @@ Perl_pidgone(pTHX_ Pid_t pid, int status) SvIV_set(sv, status); return; } +#endif #if defined(atarist) || defined(OS2) || defined(EPOC) int pclose();