* real if the array needs to be modified in some way. Functions that
* modify fake AVs check both flags to call av_reify() as appropriate.
*
- * Note that the Perl stack has neither flag set. (Thus, items that go
- * on the stack are never refcounted.)
+ * Note that the Perl stack and @DB::args have neither flag set. (Thus,
+ * items that go on the stack are never refcounted.)
*
* These internal details are subject to change any time. AV
* manipulations external to perl should not care about any of this.
} STMT_END
#endif /* USE_THREADS */
-#ifdef USE_ITHREADS
- /* junk in @_ spells trouble when cloning CVs, so don't leave any */
-# define CLEAR_ARGARRAY() av_clear(cx->blk_sub.argarray)
-#else
-# define CLEAR_ARGARRAY() NOOP
-#endif /* USE_ITHREADS */
-
+/* junk in @_ spells trouble when cloning CVs and in pp_caller(), so don't
+ * leave any (a fast av_clear(ary), basically) */
+#define CLEAR_ARGARRAY(ary) \
+ STMT_START { \
+ AvMAX(ary) += AvARRAY(ary) - AvALLOC(ary); \
+ SvPVX(ary) = (char*)AvALLOC(ary); \
+ AvFILLp(ary) = -1; \
+ } STMT_END
#define POPSUB(cx,sv) \
STMT_START { \
PL_curpad[0] = (SV*)cx->blk_sub.argarray; \
} \
else { \
- CLEAR_ARGARRAY(); \
+ CLEAR_ARGARRAY(cx->blk_sub.argarray); \
} \
} \
sv = (SV*)cx->blk_sub.cv; \
SV *sv;
PerlLIO_dup2(PerlIO_fileno(fp), fd);
- FDPID_LOCK;
+ MUTEX_LOCK(&PL_fdpid_mutex);
sv = *av_fetch(PL_fdpid,PerlIO_fileno(fp),TRUE);
(void)SvUPGRADE(sv, SVt_IV);
pid = SvIVX(sv);
SvIVX(sv) = 0;
sv = *av_fetch(PL_fdpid,fd,TRUE);
- FDPID_UNLOCK;
+ MUTEX_UNLOCK(&PL_fdpid_mutex);
(void)SvUPGRADE(sv, SVt_IV);
SvIVX(sv) = pid;
if (!was_fdopen)
int main() { return(0); }
EOF
workshoplibs=`cc -### try.c -lsunmath -o try 2>&1|grep " -Y "|sed 's%.* -Y "P,\(.*\)".*%\1%'|tr ':' '\n'|grep '/SUNWspro/'`
- . ./workshoplibpth.cbu
+ . ./UU/workshoplibpth.cbu
;;
esac
PL_dbargs = GvAV(gv_AVadd(tmpgv = gv_fetchpv("DB::args", TRUE,
SVt_PVAV)));
GvMULTI_on(tmpgv);
- AvREAL_off(PL_dbargs); /* XXX Should be REIFY */
+ AvREAL_off(PL_dbargs); /* XXX should be REIFY (see av.h) */
}
if (AvMAX(PL_dbargs) < AvFILLp(ary) + off)
#define SvGROW(sv,len) (SvLEN(sv) < (len) ? sv_grow(sv,len) : SvPVX(sv))
#define Sv_Grow sv_grow
-#ifdef USE_THREADS
-# define FDPID_LOCK MUTEX_LOCK(&PL_fdpid_mutex)
-# define FDPID_UNLOCK MUTEX_UNLOCK(&PL_fdpid_mutex)
-#else
-# define FDPID_LOCK
-# define FDPID_UNLOCK
-#endif
bar
B 2
bar
+########
+sub n { 0 }
+sub f { my $x = shift; d(); }
+f(n());
+f();
+
+sub d {
+ my $i = 0; my @a;
+ while (do { { package DB; @a = caller($i++) } } ) {
+ @a = @DB::args;
+ for (@a) { print "$_\n"; $_ = '' }
+ }
+}
+EXPECT
+0
PerlLIO_close(p[This]);
p[This] = p[that];
}
- FDPID_LOCK;
+ MUTEX_LOCK(&PL_fdpid_mutex);
sv = *av_fetch(PL_fdpid,p[This],TRUE);
- FDPID_UNLOCK;
+ MUTEX_UNLOCK(&PL_fdpid_mutex);
(void)SvUPGRADE(sv,SVt_IV);
SvIVX(sv) = pid;
PL_forkprocess = pid;
int saved_win32_errno;
#endif
- FDPID_LOCK;
+ MUTEX_LOCK(&PL_fdpid_mutex);
svp = av_fetch(PL_fdpid,PerlIO_fileno(ptr),TRUE);
- FDPID_UNLOCK;
+ MUTEX_UNLOCK(&PL_fdpid_mutex);
pid = SvIVX(*svp);
SvREFCNT_dec(*svp);
*svp = &PL_sv_undef;
/* be used by my_pclose */
/*---------------------------------------------*/
close(fd);
- FDPID_LOCK;
+ MUTEX_LOCK(&PL_fdpid_mutex);
p_sv = av_fetch(PL_fdpid,fd,TRUE);
fd = (int) SvIVX(*p_sv);
SvREFCNT_dec(*p_sv);
*p_sv = &PL_sv_undef;
sv = *av_fetch(PL_fdpid,fd,TRUE);
- FDPID_UNLOCK;
+ MUTEX_UNLOCK(&PL_fdpid_mutex);
(void) SvUPGRADE(sv, SVt_IV);
SvIVX(sv) = pid;
status = 0;
pid = spawn_cmd(cmd, Perl_stdin_fd, Perl_stdout_fd);
if (pid >= 0)
{
- FDPID_LOCK;
+ MUTEX_LOCK(&PL_fdpid_mutex);
sv = *av_fetch(PL_fdpid,pFd[this],TRUE);
- FDPID_UNLOCK;
+ MUTEX_UNLOCK(&PL_fdpid_mutex);
(void) SvUPGRADE(sv, SVt_IV);
SvIVX(sv) = pid;
fd = PerlIO_fdopen(pFd[this], mode);
}
else
{
- FDPID_LOCK;
+ MUTEX_LOCK(&PL_fdpid_mutex);
sv = *av_fetch(PL_fdpid,pFd[that],TRUE);
- FDPID_UNLOCK;
+ MUTEX_UNLOCK(&PL_fdpid_mutex);
(void) SvUPGRADE(sv, SVt_IV);
SvIVX(sv) = pFd[this];
fd = PerlIO_fdopen(pFd[this], mode);
SV **sv;
FILE *other;
- FDPID_LOCK;
+ MUTEX_LOCK(&PL_fdpid_mutex);
sv = av_fetch(PL_fdpid,PerlIO_fileno(fp),TRUE);
- FDPID_UNLOCK;
+ MUTEX_UNLOCK(&PL_fdpid_mutex);
pid = (int) SvIVX(*sv);
SvREFCNT_dec(*sv);
*sv = &PL_sv_undef;
/* close saved handle */
win32_close(oldfd);
- FDPID_LOCK;
+ MUTEX_LOCK(&PL_fdpid_mutex);
sv_setiv(*av_fetch(w32_fdpid, p[parent], TRUE), childpid);
- FDPID_UNLOCK;
+ MUTEX_UNLOCK(&PL_fdpid_mutex);
/* set process id so that it can be returned by perl's open() */
PL_forkprocess = childpid;
int childpid, status;
SV *sv;
- FDPID_LOCK;
+ MUTEX_LOCK(&PL_fdpid_mutex);
sv = *av_fetch(w32_fdpid, win32_fileno(pf), TRUE);
- FDPID_UNLOCK;
+ MUTEX_UNLOCK(&PL_fdpid_mutex);
if (SvIOK(sv))
childpid = SvIVX(sv);
else