summaryrefslogtreecommitdiff
path: root/cv.h
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-08-16 14:57:47 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-08-17 12:33:37 -0700
commitbad4ae388d7276039782b23915670f267acaff1d (patch)
tree5ffcb707b471358f918fd2da2bf6ad8f528a89a4 /cv.h
parent656b40dad946c5783030da9c7bd125c68dcfbb80 (diff)
downloadperl-bad4ae388d7276039782b23915670f267acaff1d.tar.gz
[perl #96126] Allocate CvFILE more simply
See the thread starting at: http://www.nntp.perl.org/group/perl.perl5.porters/2011/07/msg175161.html Instead of assuming that only Perl subs have mallocked CvFILEs and only under threads, resulting in various hackery to borrow parts of the SvPVX buffer where that assumption proves wrong, we can simply add another flag (DYNFILE) to indicate whether CvFILE is mallocked, instead of trying to use the ISXSUB flag for two purposes. This simplifies the code greatly, eliminating bug #96126 in the pro- cess (which had to do with sv_dup not knowing about the hackery that this commit removes). I removed that comment from cv_ckproto_len about CONSTSUBs doubling up the buffer field, as it is no longer relevant. But I still left the code as it is, since it’s better to do an explicit length check.
Diffstat (limited to 'cv.h')
-rw-r--r--cv.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/cv.h b/cv.h
index b2fe16d888..f47d171908 100644
--- a/cv.h
+++ b/cv.h
@@ -51,9 +51,11 @@ For more information, see L<perlguts>.
#define CvGV_set(cv,gv) Perl_cvgv_set(aTHX_ cv, gv)
#define CvFILE(sv) ((XPVCV*)MUTABLE_PTR(SvANY(sv)))->xcv_file
#ifdef USE_ITHREADS
-# define CvFILE_set_from_cop(sv, cop) (CvFILE(sv) = savepv(CopFILE(cop)))
+# define CvFILE_set_from_cop(sv, cop) \
+ (CvFILE(sv) = savepv(CopFILE(cop)), CvDYNFILE_on(sv))
#else
-# define CvFILE_set_from_cop(sv, cop) (CvFILE(sv) = CopFILE(cop))
+# define CvFILE_set_from_cop(sv, cop) \
+ (CvFILE(sv) = CopFILE(cop), CvDYNFILE_off(sv))
#endif
#define CvFILEGV(sv) (gv_fetchfile(CvFILE(sv)))
#if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
@@ -83,6 +85,7 @@ For more information, see L<perlguts>.
#define CVf_NODEBUG 0x0200 /* no DB::sub indirection for this CV
(esp. useful for special XSUBs) */
#define CVf_CVGV_RC 0x0400 /* CvGV is reference counted */
+#define CVf_DYNFILE 0x1000 /* The filename isn't static */
/* This symbol for optimised communication between toke.c and op.c: */
#define CVf_BUILTIN_ATTRS (CVf_METHOD|CVf_LVALUE)
@@ -140,6 +143,10 @@ For more information, see L<perlguts>.
#define CvCVGV_RC_on(cv) (CvFLAGS(cv) |= CVf_CVGV_RC)
#define CvCVGV_RC_off(cv) (CvFLAGS(cv) &= ~CVf_CVGV_RC)
+#define CvDYNFILE(cv) (CvFLAGS(cv) & CVf_DYNFILE)
+#define CvDYNFILE_on(cv) (CvFLAGS(cv) |= CVf_DYNFILE)
+#define CvDYNFILE_off(cv) (CvFLAGS(cv) &= ~CVf_DYNFILE)
+
/* Flags for newXS_flags */
#define XS_DYNAMIC_FILENAME 0x01 /* The filename isn't static */