Change 34647 by [EMAIL PROTECTED] on 2008/10/29 21:57:34

        Add MUTABLE_CV(), and eliminate (CV *) casts in *.c. 

Affected files ...

... //depot/perl/gv.c#401 edit
... //depot/perl/handy.h#154 edit
... //depot/perl/mg.c#534 edit
... //depot/perl/op.c#1013 edit
... //depot/perl/pad.c#124 edit
... //depot/perl/perl.c#880 edit
... //depot/perl/pp.c#634 edit
... //depot/perl/pp_ctl.c#701 edit
... //depot/perl/pp_hot.c#581 edit
... //depot/perl/pp_sort.c#81 edit
... //depot/perl/pp_sys.c#564 edit
... //depot/perl/sv.c#1565 edit
... //depot/perl/toke.c#830 edit
... //depot/perl/xsutils.c#58 edit

Differences ...

==== //depot/perl/gv.c#401 (text) ====
Index: perl/gv.c
--- perl/gv.c#400~34629~        2008-10-28 15:14:26.000000000 -0700
+++ perl/gv.c   2008-10-29 14:57:34.000000000 -0700
@@ -1764,10 +1764,10 @@
            if (i < DESTROY_amg)
                have_ovl = 1;
        } else if (gv) {                /* Autoloaded... */
-           cv = (CV*)gv;
+           cv = MUTABLE_CV(gv);
            filled = 1;
        }
-       amt.table[i]=(CV*)SvREFCNT_inc_simple(cv);
+       amt.table[i]=MUTABLE_CV(SvREFCNT_inc_simple(cv));
     }
     if (filled) {
       AMT_AMAGIC_on(&amt);

==== //depot/perl/handy.h#154 (text) ====
Index: perl/handy.h
--- perl/handy.h#153~34619~     2008-10-28 11:30:54.000000000 -0700
+++ perl/handy.h        2008-10-29 14:57:34.000000000 -0700
@@ -55,6 +55,7 @@
 #endif
 
 #define MUTABLE_AV(p)  ((AV *)MUTABLE_PTR(p))
+#define MUTABLE_CV(p)  ((CV *)MUTABLE_PTR(p))
 #define MUTABLE_HV(p)  ((HV *)MUTABLE_PTR(p))
 #define MUTABLE_SV(p)  ((SV *)MUTABLE_PTR(p))
 

==== //depot/perl/mg.c#534 (text) ====
Index: perl/mg.c
--- perl/mg.c#533~34629~        2008-10-28 15:14:26.000000000 -0700
+++ perl/mg.c   2008-10-29 14:57:34.000000000 -0700
@@ -2916,7 +2916,7 @@
     if (flags & 16)
        PL_scopestack_ix += 1;
     /* sv_2cv is too complicated, try a simpler variant first: */
-    if (!SvROK(PL_psig_ptr[sig]) || !(cv = (CV*)SvRV(PL_psig_ptr[sig]))
+    if (!SvROK(PL_psig_ptr[sig]) || !(cv = MUTABLE_CV(SvRV(PL_psig_ptr[sig])))
        || SvTYPE(cv) != SVt_PVCV) {
        HV *st;
        cv = sv_2cv(PL_psig_ptr[sig], &st, &gv, GV_ADD);

==== //depot/perl/op.c#1013 (text) ====
Index: perl/op.c
--- perl/op.c#1012~34645~       2008-10-29 14:24:54.000000000 -0700
+++ perl/op.c   2008-10-29 14:57:34.000000000 -0700
@@ -5569,7 +5569,7 @@
            {
                Perl_warner(aTHX_ packWARN(WARN_PROTOTYPE), "Runaway 
prototype");
            }
-           cv_ckproto_len((CV*)gv, NULL, ps, ps_len);
+           cv_ckproto_len((const CV *)gv, NULL, ps, ps_len);
        }
        if (ps)
            sv_setpvn((SV*)gv, ps, ps_len);
@@ -6103,7 +6103,7 @@
     if (cv)                            /* must reuse cv if autoloaded */
        cv_undef(cv);
     else {
-       cv = (CV*)newSV_type(SVt_PVCV);
+       cv = MUTABLE_CV(newSV_type(SVt_PVCV));
        if (name) {
            GvCV(gv) = cv;
            GvCVGEN(gv) = 0;

==== //depot/perl/pad.c#124 (text) ====
Index: perl/pad.c
--- perl/pad.c#123~34629~       2008-10-28 15:14:26.000000000 -0700
+++ perl/pad.c  2008-10-29 14:57:34.000000000 -0700
@@ -285,7 +285,7 @@
            if (namesv && namesv != &PL_sv_undef
                && *SvPVX_const(namesv) == '&')
            {
-               CV * const innercv = (CV*)curpad[ix];
+               CV * const innercv = MUTABLE_CV(curpad[ix]);
                U32 inner_rc = SvREFCNT(innercv);
                assert(inner_rc);
                namepad[ix] = NULL;
@@ -511,10 +511,10 @@
 
     /* to avoid ref loops, we never have parent + child referencing each
      * other simultaneously */
-    if (CvOUTSIDE((CV*)sv)) {
-       assert(!CvWEAKOUTSIDE((CV*)sv));
-       CvWEAKOUTSIDE_on((CV*)sv);
-       SvREFCNT_dec(CvOUTSIDE((CV*)sv));
+    if (CvOUTSIDE((const CV *)sv)) {
+       assert(!CvWEAKOUTSIDE((const CV *)sv));
+       CvWEAKOUTSIDE_on(MUTABLE_CV(sv));
+       SvREFCNT_dec(CvOUTSIDE(MUTABLE_CV(sv)));
     }
     return ix;
 }
@@ -1486,7 +1486,7 @@
     ENTER;
     SAVESPTR(PL_compcv);
 
-    cv = PL_compcv = (CV*)newSV_type(SvTYPE(proto));
+    cv = PL_compcv = MUTABLE_CV(newSV_type(SvTYPE(proto)));
     CvFLAGS(cv) = CvFLAGS(proto) & ~(CVf_CLONE|CVf_WEAKOUTSIDE);
     CvCLONED_on(cv);
 
@@ -1502,7 +1502,7 @@
     CvROOT(cv)         = OpREFCNT_inc(CvROOT(proto));
     OP_REFCNT_UNLOCK;
     CvSTART(cv)                = CvSTART(proto);
-    CvOUTSIDE(cv)      = (CV*)SvREFCNT_inc_simple(outside);
+    CvOUTSIDE(cv)      = MUTABLE_CV(SvREFCNT_inc_simple(outside));
     CvOUTSIDE_SEQ(cv) = CvOUTSIDE_SEQ(proto);
 
     if (SvPOK(proto))
@@ -1620,7 +1620,7 @@
        if (namesv && namesv != &PL_sv_undef
            && *SvPVX_const(namesv) == '&')
        {
-           CV * const innercv = (CV*)curpad[ix];
+           CV * const innercv = MUTABLE_CV(curpad[ix]);
            assert(CvWEAKOUTSIDE(innercv));
            assert(CvOUTSIDE(innercv) == old_cv);
            CvOUTSIDE(innercv) = new_cv;

==== //depot/perl/perl.c#880 (text) ====
Index: perl/perl.c
--- perl/perl.c#879~34629~      2008-10-28 15:14:26.000000000 -0700
+++ perl/perl.c 2008-10-29 14:57:34.000000000 -0700
@@ -2100,7 +2100,7 @@
        }
     }
 
-    PL_main_cv = PL_compcv = (CV*)newSV_type(SVt_PVCV);
+    PL_main_cv = PL_compcv = MUTABLE_CV(newSV_type(SVt_PVCV));
     CvUNIQUE_on(PL_compcv);
 
     CvPADLIST(PL_compcv) = pad_new(0);
@@ -2649,7 +2649,7 @@
          && (PL_DBcv || (PL_DBcv = GvCV(PL_DBsub)))
           /* Try harder, since this may have been a sighandler, thus
            * curstash may be meaningless. */
-         && (SvTYPE(sv) != SVt_PVCV || CvSTASH((CV*)sv) != PL_debstash)
+         && (SvTYPE(sv) != SVt_PVCV || CvSTASH((const CV *)sv) != PL_debstash)
          && !(flags & G_NODEBUG))
        PL_op->op_private |= OPpENTERSUB_DB;
 
@@ -5114,7 +5114,7 @@
     PERL_ARGS_ASSERT_CALL_LIST;
 
     while (av_len(paramList) >= 0) {
-       cv = (CV*)av_shift(paramList);
+       cv = MUTABLE_CV(av_shift(paramList));
        if (PL_savebegin) {
            if (paramList == PL_beginav) {
                /* save PL_beginav for compiler */

==== //depot/perl/pp.c#634 (text) ====
Index: perl/pp.c
--- perl/pp.c#633~34646~        2008-10-29 14:36:17.000000000 -0700
+++ perl/pp.c   2008-10-29 14:57:34.000000000 -0700
@@ -376,7 +376,7 @@
     CV *cv = sv_2cv(TOPs, &stash_unused, &gv, flags);
     if (cv) {
        if (CvCLONE(cv))
-           cv = (CV*)sv_2mortal((SV*)cv_clone(cv));
+           cv = MUTABLE_CV(sv_2mortal((SV*)cv_clone(cv)));
        if ((PL_op->op_private & OPpLVAL_INTRO)) {
            if (gv && GvCV(gv) == cv && (gv = gv_autoload4(GvSTASH(gv), 
GvNAME(gv), GvNAMELEN(gv), FALSE)))
                cv = GvCV(gv);
@@ -385,10 +385,10 @@
        }
     }
     else if ((flags == (GV_ADD|GV_NOEXPAND)) && gv && SvROK(gv)) {
-       cv = (CV*)gv;
+       cv = MUTABLE_CV(gv);
     }    
     else
-       cv = (CV*)&PL_sv_undef;
+       cv = MUTABLE_CV(&PL_sv_undef);
     SETs((SV*)cv);
     RETURN;
 }
@@ -472,9 +472,9 @@
 PP(pp_anoncode)
 {
     dVAR; dSP;
-    CV* cv = (CV*)PAD_SV(PL_op->op_targ);
+    CV *cv = MUTABLE_CV(PAD_SV(PL_op->op_targ));
     if (CvCLONE(cv))
-       cv = (CV*)sv_2mortal((SV*)cv_clone(cv));
+       cv = MUTABLE_CV(sv_2mortal((SV*)cv_clone(cv)));
     EXTEND(SP,1);
     PUSHs((SV*)cv);
     RETURN;
@@ -811,14 +811,15 @@
     case SVt_PVCV:
        if (cv_const_sv((const CV *)sv) && ckWARN(WARN_MISC))
            Perl_warner(aTHX_ packWARN(WARN_MISC), "Constant subroutine %s 
undefined",
-                CvANON((CV*)sv) ? "(anonymous)" : GvENAME(CvGV((CV*)sv)));
+                CvANON((const CV *)sv) ? "(anonymous)"
+                       : GvENAME(CvGV((const CV *)sv)));
        /* FALLTHROUGH */
     case SVt_PVFM:
        {
            /* let user-undef'd sub keep its identity */
-           GV* const gv = CvGV((CV*)sv);
-           cv_undef((CV*)sv);
-           CvGV((CV*)sv) = gv;
+           GV* const gv = CvGV((const CV *)sv);
+           cv_undef(MUTABLE_CV(sv));
+           CvGV((const CV *)sv) = gv;
        }
        break;
     case SVt_PVGV:

==== //depot/perl/pp_ctl.c#701 (text) ====
Index: perl/pp_ctl.c
--- perl/pp_ctl.c#700~34629~    2008-10-28 15:14:26.000000000 -0700
+++ perl/pp_ctl.c       2008-10-29 14:57:34.000000000 -0700
@@ -2412,7 +2412,7 @@
        if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVCV) {
            I32 cxix;
            register PERL_CONTEXT *cx;
-           CV* cv = (CV*)SvRV(sv);
+           CV *cv = MUTABLE_CV(SvRV(sv));
            SV** mark;
            I32 items = 0;
            I32 oldsave;
@@ -2983,13 +2983,13 @@
     PUSHMARK(SP);
 
     SAVESPTR(PL_compcv);
-    PL_compcv = (CV*)newSV_type(SVt_PVCV);
+    PL_compcv = MUTABLE_CV(newSV_type(SVt_PVCV));
     CvEVAL_on(PL_compcv);
     assert(CxTYPE(&cxstack[cxstack_ix]) == CXt_EVAL);
     cxstack[cxstack_ix].blk_eval.cv = PL_compcv;
 
     CvOUTSIDE_SEQ(PL_compcv) = seq;
-    CvOUTSIDE(PL_compcv) = (CV*)SvREFCNT_inc_simple(outside);
+    CvOUTSIDE(PL_compcv) = MUTABLE_CV(SvREFCNT_inc_simple(outside));
 
     /* set up a scratch pad */
 

==== //depot/perl/pp_hot.c#581 (text) ====
Index: perl/pp_hot.c
--- perl/pp_hot.c#580~34629~    2008-10-28 15:14:26.000000000 -0700
+++ perl/pp_hot.c       2008-10-29 14:57:34.000000000 -0700
@@ -2714,7 +2714,7 @@
            SV * const * sp = &sv;              /* Used in tryAMAGICunDEREF 
macro. */
            tryAMAGICunDEREF(to_cv);
        }       
-       cv = (CV*)SvRV(sv);
+       cv = MUTABLE_CV(SvRV(sv));
        if (SvTYPE(cv) == SVt_PVCV)
            break;
        /* FALL THROUGH */
@@ -2723,7 +2723,7 @@
        DIE(aTHX_ "Not a CODE reference");
        /* This is the second most common case:  */
     case SVt_PVCV:
-       cv = (CV*)sv;
+       cv = MUTABLE_CV(sv);
        break;
     }
 

==== //depot/perl/pp_sort.c#81 (text) ====
Index: perl/pp_sort.c
--- perl/pp_sort.c#80~34585~    2008-10-25 05:23:01.000000000 -0700
+++ perl/pp_sort.c      2008-10-29 14:57:34.000000000 -0700
@@ -1813,7 +1813,7 @@
     dVAR; dSP;
     const I32 oldsaveix = PL_savestack_ix;
     const I32 oldscopeix = PL_scopestack_ix;
-    CV * const cv=(CV*)PL_sortcop;
+    CV * const cv=MUTABLE_CV(PL_sortcop);
     I32 result;
 
     PERL_ARGS_ASSERT_SORTCV_XSUB;

==== //depot/perl/pp_sys.c#564 (text) ====
Index: perl/pp_sys.c
--- perl/pp_sys.c#563~34629~    2008-10-28 15:14:26.000000000 -0700
+++ perl/pp_sys.c       2008-10-29 14:57:34.000000000 -0700
@@ -1306,7 +1306,7 @@
        DIE(aTHX_ "Not a format reference");
     }
     if (CvCLONE(cv))
-       cv = (CV*)sv_2mortal((SV*)cv_clone(cv));
+       cv = MUTABLE_CV(sv_2mortal((SV*)cv_clone(cv)));
 
     IoFLAGS(io) &= ~IOf_DIDTOP;
     return doform(cv,gv,PL_op->op_next);
@@ -1397,7 +1397,7 @@
                DIE(aTHX_ "Undefined top format called");
        }
        if (cv && CvCLONE(cv))
-           cv = (CV*)sv_2mortal((SV*)cv_clone(cv));
+           cv = MUTABLE_CV(sv_2mortal((SV*)cv_clone(cv)));
        return doform(cv, gv, PL_op);
     }
 

==== //depot/perl/sv.c#1565 (text) ====
Index: perl/sv.c
--- perl/sv.c#1564~34646~       2008-10-29 14:36:17.000000000 -0700
+++ perl/sv.c   2008-10-29 14:57:34.000000000 -0700
@@ -3502,7 +3502,7 @@
     common:
        if (intro) {
            if (stype == SVt_PVCV) {
-               /*if (GvCVGEN(dstr) && (GvCV(dstr) != (CV*)sref || 
GvCVGEN(dstr))) {*/
+               /*if (GvCVGEN(dstr) && (GvCV(dstr) != (const CV *)sref || 
GvCVGEN(dstr))) {*/
                if (GvCVGEN(dstr)) {
                    SvREFCNT_dec(GvCV(dstr));
                    GvCV(dstr) = NULL;
@@ -3514,14 +3514,14 @@
        else
            dref = *location;
        if (stype == SVt_PVCV && (*location != sref || GvCVGEN(dstr))) {
-           CV* const cv = (CV*)*location;
+           CV* const cv = MUTABLE_CV(*location);
            if (cv) {
                if (!GvCVGEN((GV*)dstr) &&
                    (CvROOT(cv) || CvXSUB(cv)))
                    {
                        /* Redefining a sub - warning is mandatory if
                           it was a const and its value changed. */
-                       if (CvCONST(cv) && CvCONST((CV*)sref)
+                       if (CvCONST(cv) && CvCONST((const CV *)sref)
                            && cv_const_sv(cv)
                            == cv_const_sv((const CV *)sref)) {
                            NOOP;
@@ -3534,7 +3534,7 @@
                        }
                        else if (ckWARN(WARN_REDEFINE)
                                 || (CvCONST(cv)
-                                    && (!CvCONST((CV*)sref)
+                                    && (!CvCONST((const CV *)sref)
                                         || sv_cmp(cv_const_sv(cv),
                                                   cv_const_sv((const CV *)
                                                               sref))))) {
@@ -5509,7 +5509,7 @@
        goto freescalar;
     case SVt_PVCV:
     case SVt_PVFM:
-       cv_undef((CV*)sv);
+       cv_undef(MUTABLE_CV(sv));
        goto freescalar;
     case SVt_PVHV:
        if (PL_last_swash_hv == (const HV *)sv) {
@@ -7945,7 +7945,7 @@
     case SVt_PVCV:
        *st = CvSTASH(sv);
        *gvp = NULL;
-       return (CV*)sv;
+       return MUTABLE_CV(sv);
     case SVt_PVHV:
     case SVt_PVAV:
        *st = NULL;
@@ -7968,7 +7968,7 @@
 
            sv = SvRV(sv);
            if (SvTYPE(sv) == SVt_PVCV) {
-               cv = (CV*)sv;
+               cv = MUTABLE_CV(sv);
                *gvp = NULL;
                *st = CvSTASH(cv);
                return cv;
@@ -10088,8 +10088,8 @@
 #define av_dup_inc(s,t)        (AV*)SvREFCNT_inc(sv_dup((const SV *)s,t))
 #define hv_dup(s,t)    MUTABLE_HV(sv_dup((const SV *)s,t))
 #define hv_dup_inc(s,t)        MUTABLE_HV(SvREFCNT_inc(sv_dup((const SV 
*)s,t)))
-#define cv_dup(s,t)    (CV*)sv_dup((SV*)s,t)
-#define cv_dup_inc(s,t)        (CV*)SvREFCNT_inc(sv_dup((const SV *)s,t))
+#define cv_dup(s,t)    MUTABLE_CV(sv_dup((SV*)s,t))
+#define cv_dup_inc(s,t)        MUTABLE_CV(SvREFCNT_inc(sv_dup((const SV 
*)s,t)))
 #define io_dup(s,t)    (IO*)sv_dup((SV*)s,t)
 #define io_dup_inc(s,t)        (IO*)SvREFCNT_inc(sv_dup((const SV *)s,t))
 #define gv_dup(s,t)    (GV*)sv_dup((SV*)s,t)

==== //depot/perl/toke.c#830 (text) ====
Index: perl/toke.c
--- perl/toke.c#829~34622~      2008-10-28 13:12:16.000000000 -0700
+++ perl/toke.c 2008-10-29 14:57:34.000000000 -0700
@@ -5442,7 +5442,7 @@
                    /* Real typeglob, so get the real subroutine: */
                           ? GvCVu(gv)
                    /* A proxy for a subroutine in this package? */
-                          : SvOK(gv) ? (CV *) gv : NULL)
+                          : SvOK(gv) ? MUTABLE_CV(gv) : NULL)
                    : NULL;
 
                /* See if it's the indirect object for a list operator. */
@@ -12565,12 +12565,12 @@
     save_item(PL_subname);
     SAVESPTR(PL_compcv);
 
-    PL_compcv = (CV*)newSV_type(is_format ? SVt_PVFM : SVt_PVCV);
+    PL_compcv = MUTABLE_CV(newSV_type(is_format ? SVt_PVFM : SVt_PVCV));
     CvFLAGS(PL_compcv) |= flags;
 
     PL_subline = CopLINE(PL_curcop);
     CvPADLIST(PL_compcv) = pad_new(padnew_SAVE|padnew_SAVESUB);
-    CvOUTSIDE(PL_compcv) = (CV*)SvREFCNT_inc_simple(outsidecv);
+    CvOUTSIDE(PL_compcv) = MUTABLE_CV(SvREFCNT_inc_simple(outsidecv));
     CvOUTSIDE_SEQ(PL_compcv) = PL_cop_seqmax;
 
     return oldsavestack_ix;

==== //depot/perl/xsutils.c#58 (text) ====
Index: perl/xsutils.c
--- perl/xsutils.c#57~34585~    2008-10-25 05:23:01.000000000 -0700
+++ perl/xsutils.c      2008-10-29 14:57:34.000000000 -0700
@@ -77,9 +77,9 @@
                case 'l':
                    if (memEQ(name, "lvalue", 6)) {
                        if (negated)
-                           CvFLAGS((CV*)sv) &= ~CVf_LVALUE;
+                           CvFLAGS(MUTABLE_CV(sv)) &= ~CVf_LVALUE;
                        else
-                           CvFLAGS((CV*)sv) |= CVf_LVALUE;
+                           CvFLAGS(MUTABLE_CV(sv)) |= CVf_LVALUE;
                        continue;
                    }
                    break;
@@ -87,18 +87,18 @@
                case 'k':
                    if (memEQ(name, "locked", 6)) {
                        if (negated)
-                           CvFLAGS((CV*)sv) &= ~CVf_LOCKED;
+                           CvFLAGS(MUTABLE_CV(sv)) &= ~CVf_LOCKED;
                        else
-                           CvFLAGS((CV*)sv) |= CVf_LOCKED;
+                           CvFLAGS(MUTABLE_CV(sv)) |= CVf_LOCKED;
                        continue;
                    }
                    break;
                case 'h':
                    if (memEQ(name, "method", 6)) {
                        if (negated)
-                           CvFLAGS((CV*)sv) &= ~CVf_METHOD;
+                           CvFLAGS(MUTABLE_CV(sv)) &= ~CVf_METHOD;
                        else
-                           CvFLAGS((CV*)sv) |= CVf_METHOD;
+                           CvFLAGS(MUTABLE_CV(sv)) |= CVf_METHOD;
                        continue;
                    }
                    break;
@@ -203,7 +203,7 @@
 
     switch (SvTYPE(sv)) {
     case SVt_PVCV:
-       cvflags = CvFLAGS((CV*)sv);
+       cvflags = CvFLAGS((const CV *)sv);
        if (cvflags & CVf_LOCKED)
            XPUSHs(newSVpvs_flags("locked", SVs_TEMP));
 #ifdef CVf_LVALUE
@@ -212,7 +212,7 @@
 #endif
        if (cvflags & CVf_METHOD)
            XPUSHs(newSVpvs_flags("method", SVs_TEMP));
-        if (GvUNIQUE(CvGV((CV*)sv)))
+        if (GvUNIQUE(CvGV((const CV *)sv)))
            XPUSHs(newSVpvs_flags("unique", SVs_TEMP));
        break;
     case SVt_PVGV:
End of Patch.

Reply via email to