This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
add Intel C++ Compiler for Win32 support
[perl5.git] / cv.h
diff --git a/cv.h b/cv.h
index 3d44a73..234e030 100644 (file)
--- a/cv.h
+++ b/cv.h
@@ -49,7 +49,7 @@ See L<perlguts/Autoloading with XSUBs>.
 #define CvROOT(sv)     ((XPVCV*)MUTABLE_PTR(SvANY(sv)))->xcv_root_u.xcv_root
 #define CvXSUB(sv)     ((XPVCV*)MUTABLE_PTR(SvANY(sv)))->xcv_root_u.xcv_xsub
 #define CvXSUBANY(sv)  ((XPVCV*)MUTABLE_PTR(SvANY(sv)))->xcv_start_u.xcv_xsubany
-#define CvGV(sv)       S_CvGV((CV *)(sv))
+#define CvGV(sv)       S_CvGV((const CV *)(sv))
 #define CvGV_set(cv,gv)        Perl_cvgv_set(aTHX_ cv, gv)
 #define CvFILE(sv)     ((XPVCV*)MUTABLE_PTR(SvANY(sv)))->xcv_file
 #ifdef USE_ITHREADS
@@ -189,7 +189,7 @@ See L<perlguts/Autoloading with XSUBs>.
 #define XS_DYNAMIC_FILENAME    0x01    /* The filename isn't static  */
 
 PERL_STATIC_INLINE GV *
-S_CvGV(CV *sv)
+S_CvGV(const CV *sv)
 {
     return CvNAMED(sv)
        ? 0
@@ -202,6 +202,15 @@ CvNAME_HEK(CV *sv)
        ? ((XPVCV*)MUTABLE_PTR(SvANY(sv)))->xcv_gv_u.xcv_hek
        : 0;
 }
+/* This lowers the refernce count of the previous value, but does *not*
+   increment the reference count of the new value. */
+#define CvNAME_HEK_set(cv, hek) ( \
+       CvNAME_HEK((CV *)(cv))                                           \
+           ? unshare_hek(SvANY((CV *)(cv))->xcv_gv_u.xcv_hek)    \
+           : (void)0,                                             \
+       ((XPVCV*)MUTABLE_PTR(SvANY(cv)))->xcv_gv_u.xcv_hek = (hek), \
+       CvNAMED_on(cv)                                               \
+    )
 
 /*
 =head1 CV reference counts and CvOUTSIDE