X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/d2f13c598f9812cd520097e22d819d1b9f7b0cb6..5d487c263b0c0c7fb6c50dee3540f1838c4ab067:/sv.h diff --git a/sv.h b/sv.h index ed25383..fc67ed9 100644 --- a/sv.h +++ b/sv.h @@ -117,10 +117,10 @@ struct STRUCT_SV { /* struct sv { */ _SV_HEAD(void*); _SV_HEAD_UNION; #ifdef DEBUG_LEAKING_SCALARS - unsigned sv_debug_optype:9; /* the type of OP that allocated us */ - unsigned sv_debug_inpad:1; /* was allocated in a pad for an OP */ - unsigned sv_debug_cloned:1; /* was cloned for an ithread */ - unsigned sv_debug_line:16; /* the line where we were allocated */ + 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 */ char * sv_debug_file; /* the file where we were allocated */ #endif }; @@ -221,7 +221,7 @@ perform the upgrade if necessary. See C. #define SvFLAGS(sv) (sv)->sv_flags #define SvREFCNT(sv) (sv)->sv_refcnt -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) && !defined(PERL_GCC_PEDANTIC) +#if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) # define SvREFCNT_inc(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ @@ -264,7 +264,7 @@ perform the upgrade if necessary. See C. #define SvREFCNT_inc_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #define SvREFCNT_inc_simple_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) && !defined(PERL_GCC_PEDANTIC) +#if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) # define SvREFCNT_dec(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ @@ -328,18 +328,18 @@ perform the upgrade if necessary. See C. 3: For PVCV, whether CvUNIQUE(cv) refers to an eval or once only [CvEVAL(cv), CvSPECIAL(cv)] - 4: Whether the regexp pointer is in - fact an offset [SvREPADTMP(sv)] - 5: On a pad name SV, that slot in the + 4: On a pad name SV, that slot in the frame AV is a REFCNT'ed reference to a lexical from "outside". */ -#define SVphv_REHASH SVf_FAKE /* 6: On a PVHV, hash values are being +#define SVphv_REHASH SVf_FAKE /* 5: On a PVHV, hash values are being recalculated */ #define SVf_OOK 0x02000000 /* has valid offset value. For a PVHV this means that a hv_aux struct is present after the main array */ #define SVf_BREAK 0x04000000 /* refcnt is artificially low - used by - SV's in final arena cleanup */ + SVs in final arena cleanup. + Set in S_regtry on PL_reg_curpm, so that + perl_destruct will skip it. */ #define SVf_READONLY 0x08000000 /* may not be modified */ @@ -532,38 +532,48 @@ typedef struct { IV xfm_lines; } xpvfm_allocated; +#define _XPVIO_TAIL \ + PerlIO * xio_ifp; /* ifp and ofp are normally the same */ \ + PerlIO * xio_ofp; /* but sockets need separate streams */ \ + /* 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 \ + * following union trick (as suggested by Gurusamy Sarathy). \ + * For further information see Geir Johansen's problem report \ + * titled [ID 20000612.002] Perl problem on Cray system \ + * The any pointer (known as IoANY()) will also be a good place \ + * to hang any IO disciplines to. \ + */ \ + union { \ + DIR * xiou_dirp; /* for opendir, readdir, etc */ \ + void * xiou_any; /* for alignment */ \ + } xio_dirpu; \ + IV xio_lines; /* $. */ \ + IV xio_page; /* $% */ \ + IV xio_page_len; /* $= */ \ + IV xio_lines_left; /* $- */ \ + char * xio_top_name; /* $^ */ \ + GV * xio_top_gv; /* $^ */ \ + char * xio_fmt_name; /* $~ */ \ + GV * xio_fmt_gv; /* $~ */ \ + char * xio_bottom_name;/* $^B */ \ + GV * xio_bottom_gv; /* $^B */ \ + char xio_type; \ + U8 xio_flags + + struct xpvio { _XPV_HEAD; _XPVMG_HEAD; - - PerlIO * xio_ifp; /* ifp and ofp are normally the same */ - PerlIO * xio_ofp; /* but sockets need separate streams */ - /* 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 following - * union trick (as suggested by Gurusamy Sarathy). - * For further information see Geir Johansen's problem report titled - [ID 20000612.002] Perl problem on Cray system - * The any pointer (known as IoANY()) will also be a good place - * to hang any IO disciplines to. - */ - union { - DIR * xiou_dirp; /* for opendir, readdir, etc */ - void * xiou_any; /* for alignment */ - } xio_dirpu; - IV xio_lines; /* $. */ - IV xio_page; /* $% */ - IV xio_page_len; /* $= */ - IV xio_lines_left; /* $- */ - char * xio_top_name; /* $^ */ - GV * xio_top_gv; /* $^ */ - char * xio_fmt_name; /* $~ */ - GV * xio_fmt_gv; /* $~ */ - char * xio_bottom_name;/* $^B */ - GV * xio_bottom_gv; /* $^B */ - char xio_type; - U8 xio_flags; + _XPVIO_TAIL; }; + +typedef struct { + _XPV_ALLOCATED_HEAD; + _XPVMG_HEAD; + _XPVIO_TAIL; +} xpvio_allocated; + #define xio_dirp xio_dirpu.xiou_dirp #define xio_any xio_dirpu.xiou_any @@ -988,14 +998,6 @@ the scalar's value cannot change unless written to. #define SvTAIL_off(sv) (SvFLAGS(sv) &= ~SVpbm_TAIL) -#ifdef USE_ITHREADS -/* The following uses the FAKE flag to show that a regex pointer is infact - its own offset in the regexpad for ithreads */ -#define SvREPADTMP(sv) (SvFLAGS(sv) & SVf_FAKE) -#define SvREPADTMP_on(sv) (SvFLAGS(sv) |= SVf_FAKE) -#define SvREPADTMP_off(sv) (SvFLAGS(sv) &= ~SVf_FAKE) -#endif - #define SvPAD_TYPED(sv) \ ((SvFLAGS(sv) & (SVpad_NAME|SVpad_TYPED)) == (SVpad_NAME|SVpad_TYPED)) @@ -1111,6 +1113,7 @@ the scalar's value cannot change unless written to. assert(SvTYPE(_svi) != SVt_PVHV); \ assert(SvTYPE(_svi) != SVt_PVCV); \ assert(SvTYPE(_svi) != SVt_PVFM); \ + assert(SvTYPE(_svi) != SVt_PVIO); \ assert(!isGV_with_GP(_svi)); \ &(((XPVNV*) SvANY(_svi))->xnv_u.xnv_nv); \ })) @@ -1185,6 +1188,7 @@ the scalar's value cannot change unless written to. STMT_START { assert(SvTYPE(sv) == SVt_NV || SvTYPE(sv) >= SVt_PVNV); \ assert(SvTYPE(sv) != SVt_PVAV); assert(SvTYPE(sv) != SVt_PVHV); \ assert(SvTYPE(sv) != SVt_PVCV); assert(SvTYPE(sv) != SVt_PVFM); \ + assert(SvTYPE(sv) != SVt_PVIO); \ assert(!isGV_with_GP(sv)); \ (((XPVNV*)SvANY(sv))->xnv_u.xnv_nv = (val)); } STMT_END #define SvPV_set(sv, val) \ @@ -1693,6 +1697,8 @@ Like C but doesn't process magic. #define SV_COW_SHARED_HASH_KEYS 512 /* This one is only enabled for PERL_OLD_COPY_ON_WRITE */ #define SV_COW_OTHER_PVS 1024 +/* Make sv_2pv_flags return NULL if something is undefined. */ +#define SV_UNDEF_RETURNS_NULL 2048 /* The core is safe for this COW optimisation. XS code on CPAN may not be. So only default to doing the COW setup if we're in the core.