This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Refactor porting/diag.t and improve output format
[perl5.git] / sv.h
diff --git a/sv.h b/sv.h
index adadab3..a49954d 100644 (file)
--- a/sv.h
+++ b/sv.h
@@ -106,6 +106,7 @@ typedef struct hek HEK;
        SV**    svu_array;              \
        HE**    svu_hash;               \
        GP*     svu_gp;                 \
+       PerlIO *svu_fp;                 \
     }  sv_u
 
 
@@ -115,10 +116,10 @@ struct STRUCT_SV {                /* struct sv { */
 #ifdef DEBUG_LEAKING_SCALARS
     PERL_BITFIELD32 sv_debug_optype:9; /* the type of OP that allocated us */
     PERL_BITFIELD32 sv_debug_inpad:1;  /* was allocated in a pad for an OP */
-    PERL_BITFIELD32 sv_debug_cloned:1; /* was cloned for an ithread */
     PERL_BITFIELD32 sv_debug_line:16;  /* the line where we were allocated */
     U32                    sv_debug_serial;    /* serial number of sv allocation   */
-    char *     sv_debug_file;          /* the file where we were allocated */
+    char *         sv_debug_file;      /* the file where we were allocated */
+    SV *           sv_debug_parent;    /* what we were cloned from (ithreads)*/
 #endif
 };
 
@@ -509,8 +510,8 @@ struct xpvfm {
 struct xpvio {
     _XPV_HEAD;
     union _xivu xiv_u;
-    PerlIO *   xio_ifp;        /* ifp and ofp are normally the same */
-    PerlIO *   xio_ofp;        /* but sockets need separate streams */
+    /* ifp and ofp are normally the same, but sockets need separate streams */
+    PerlIO *   xio_ofp;
     /* Cray addresses everything by word boundaries (64 bits) and
      * code and data pointers cannot be mixed (which is exactly what
      * Perl_filter_add() tries to do with the dirp), hence the
@@ -1054,6 +1055,8 @@ the scalar's value cannot change unless written to.
            assert(SvTYPE(_svcur) != SVt_PVAV);                         \
            assert(SvTYPE(_svcur) != SVt_PVHV);                         \
            assert(!isGV_with_GP(_svcur));                              \
+           assert(!(SvTYPE(_svcur) == SVt_PVIO                         \
+                    && !(IoFLAGS(_svcur) & IOf_FAKE_DIRP)));           \
            &(((XPV*) MUTABLE_PTR(SvANY(_svcur)))->xpv_cur);            \
         }))
 #    define SvIVX(sv)                                                  \
@@ -1100,6 +1103,8 @@ the scalar's value cannot change unless written to.
            assert(SvTYPE(_svrv) != SVt_PVCV);                          \
            assert(SvTYPE(_svrv) != SVt_PVFM);                          \
            assert(!isGV_with_GP(_svrv));                               \
+           assert(!(SvTYPE(_svrv) == SVt_PVIO                          \
+                    && !(IoFLAGS(_svrv) & IOf_FAKE_DIRP)));            \
            &((_svrv)->sv_u.svu_rv);                                    \
         }))
 #    define SvRV_const(sv)                                             \
@@ -1110,6 +1115,8 @@ the scalar's value cannot change unless written to.
            assert(SvTYPE(_svrv) != SVt_PVCV);                          \
            assert(SvTYPE(_svrv) != SVt_PVFM);                          \
            assert(!isGV_with_GP(_svrv));                               \
+           assert(!(SvTYPE(_svrv) == SVt_PVIO                          \
+                    && !(IoFLAGS(_svrv) & IOf_FAKE_DIRP)));            \
            (_svrv)->sv_u.svu_rv;                                       \
         })
 #    define SvMAGIC(sv)                                                        \
@@ -1185,6 +1192,8 @@ the scalar's value cannot change unless written to.
                assert(SvTYPE(sv) != SVt_PVAV);         \
                assert(SvTYPE(sv) != SVt_PVHV);         \
                assert(!isGV_with_GP(sv));              \
+               assert(!(SvTYPE(sv) == SVt_PVIO         \
+                    && !(IoFLAGS(sv) & IOf_FAKE_DIRP))); \
                ((sv)->sv_u.svu_pv = (val)); } STMT_END
 #define SvUV_set(sv, val) \
        STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \
@@ -1200,6 +1209,8 @@ the scalar's value cannot change unless written to.
                assert(SvTYPE(sv) != SVt_PVCV);         \
                assert(SvTYPE(sv) != SVt_PVFM);         \
                assert(!isGV_with_GP(sv));              \
+               assert(!(SvTYPE(sv) == SVt_PVIO         \
+                    && !(IoFLAGS(sv) & IOf_FAKE_DIRP))); \
                 ((sv)->sv_u.svu_rv = (val)); } STMT_END
 #define SvMAGIC_set(sv, val) \
         STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \
@@ -1212,12 +1223,16 @@ the scalar's value cannot change unless written to.
                assert(SvTYPE(sv) != SVt_PVAV);         \
                assert(SvTYPE(sv) != SVt_PVHV);         \
                assert(!isGV_with_GP(sv));              \
+               assert(!(SvTYPE(sv) == SVt_PVIO         \
+                    && !(IoFLAGS(sv) & IOf_FAKE_DIRP))); \
                (((XPV*)  SvANY(sv))->xpv_cur = (val)); } STMT_END
 #define SvLEN_set(sv, val) \
        STMT_START { assert(SvTYPE(sv) >= SVt_PV); \
                assert(SvTYPE(sv) != SVt_PVAV); \
                assert(SvTYPE(sv) != SVt_PVHV); \
                assert(!isGV_with_GP(sv));      \
+               assert(!(SvTYPE(sv) == SVt_PVIO         \
+                    && !(IoFLAGS(sv) & IOf_FAKE_DIRP))); \
                (((XPV*)  SvANY(sv))->xpv_len = (val)); } STMT_END
 #define SvEND_set(sv, val) \
        STMT_START { assert(SvTYPE(sv) >= SVt_PV); \
@@ -1311,7 +1326,7 @@ the scalar's value cannot change unless written to.
 #define LvTARGOFF(sv)  ((XPVLV*)  SvANY(sv))->xlv_targoff
 #define LvTARGLEN(sv)  ((XPVLV*)  SvANY(sv))->xlv_targlen
 
-#define IoIFP(sv)      ((XPVIO*)  SvANY(sv))->xio_ifp
+#define IoIFP(sv)      (sv)->sv_u.svu_fp
 #define IoOFP(sv)      ((XPVIO*)  SvANY(sv))->xio_ofp
 #define IoDIRP(sv)     ((XPVIO*)  SvANY(sv))->xio_dirp
 #define IoANY(sv)      ((XPVIO*)  SvANY(sv))->xio_any