X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/796b6530911f5ebd6a26275873610304e63d5d19..6f8848d55c2ea11b7ed7f8cf1afb2d6a28c76e4d:/sv.h?ds=sidebyside diff --git a/sv.h b/sv.h index 7c67d8f..bfda6bf 100644 --- a/sv.h +++ b/sv.h @@ -467,7 +467,7 @@ perform the upgrade if necessary. See C>. /* PVHV */ #define SVphv_HASKFLAGS 0x80000000 /* keys have flag byte after hash */ /* PVGV when SVpbm_VALID is true */ -#define SVpbm_TAIL 0x80000000 +#define SVpbm_TAIL 0x80000000 /* string has a fake "\n" appended */ /* RV upwards. However, SVf_ROK and SVp_IOK are exclusive */ #define SVprv_WEAKREF 0x80000000 /* Weak reference */ /* pad name vars only */ @@ -838,7 +838,7 @@ Set the current length of the string which is in the SV. See C> and C>. =for apidoc Am|void|SvLEN_set|SV* sv|STRLEN len -Set the actual length of the string which is in the SV. See C>. +Set the size of the string buffer for the SV. See C>. =cut */ @@ -949,7 +949,7 @@ in gv.h: */ #define SvOOK(sv) (SvFLAGS(sv) & SVf_OOK) #define SvOOK_on(sv) (SvFLAGS(sv) |= SVf_OOK) -#define SvOOK_off(sv) ((void)(SvOOK(sv) && sv_backoff(sv))) +#define SvOOK_off(sv) ((void)(SvOOK(sv) && (sv_backoff(sv),0))) #define SvFAKE(sv) (SvFLAGS(sv) & SVf_FAKE) #define SvFAKE_on(sv) (SvFLAGS(sv) |= SVf_FAKE) @@ -1051,7 +1051,7 @@ For example, if your scalar is a reference and you want to modify the C slot, you can't just do C, as that will leak the referent. This is used internally by various sv-modifying functions, such as -C, C and C, C and C. One case that this does not handle is a gv without SvFAKE set. After @@ -1473,10 +1473,9 @@ attention to precisely which outputs are influenced by which inputs. #define SvTAINT(sv) \ STMT_START { \ - if (UNLIKELY(TAINTING_get)) { \ - if (UNLIKELY(TAINT_get)) \ - SvTAINTED_on(sv); \ - } \ + assert(TAINTING_get || !TAINT_get); \ + if (UNLIKELY(TAINT_get)) \ + SvTAINTED_on(sv); \ } STMT_END /* @@ -1575,13 +1574,13 @@ Returns a boolean indicating whether Perl would evaluate the SV as true or false. See C> for a defined/undefined test. Does not handle 'get' magic. =for apidoc Am|char*|SvPVutf8_force|SV* sv|STRLEN len -Like C, but converts C to utf8 first if necessary. +Like C, but converts C to UTF-8 first if necessary. =for apidoc Am|char*|SvPVutf8|SV* sv|STRLEN len -Like C, but converts C to utf8 first if necessary. +Like C, but converts C to UTF-8 first if necessary. =for apidoc Am|char*|SvPVutf8_nolen|SV* sv -Like C, but converts C to utf8 first if necessary. +Like C, but converts C to UTF-8 first if necessary. =for apidoc Am|char*|SvPVbyte_force|SV* sv|STRLEN len Like C, but converts C to byte representation first if necessary. @@ -1593,12 +1592,12 @@ Like C, but converts C to byte representation first if necessary. Like C, but converts C to byte representation first if necessary. =for apidoc Am|char*|SvPVutf8x_force|SV* sv|STRLEN len -Like C, but converts C to utf8 first if necessary. +Like C, but converts C to UTF-8 first if necessary. Guarantees to evaluate C only once; use the more efficient C otherwise. =for apidoc Am|char*|SvPVutf8x|SV* sv|STRLEN len -Like C, but converts C to utf8 first if necessary. +Like C, but converts C to UTF-8 first if necessary. Guarantees to evaluate C only once; use the more efficient C otherwise. @@ -2261,5 +2260,39 @@ Evaluates C more than once. Sets C to 0 if C is false. #define SV_CONSTS_COUNT 35 /* + * Bodyless IVs and NVs! + * + * Since 5.9.2, we can avoid allocating a body for SVt_IV-type SVs. + * Since the larger IV-holding variants of SVs store their integer + * values in their respective bodies, the family of SvIV() accessor + * macros would naively have to branch on the SV type to find the + * integer value either in the HEAD or BODY. In order to avoid this + * expensive branch, a clever soul has deployed a great hack: + * We set up the SvANY pointer such that instead of pointing to a + * real body, it points into the memory before the location of the + * head. We compute this pointer such that the location of + * the integer member of the hypothetical body struct happens to + * be the same as the location of the integer member of the bodyless + * SV head. This now means that the SvIV() family of accessors can + * always read from the (hypothetical or real) body via SvANY. + * + * Since the 5.21 dev series, we employ the same trick for NVs + * if the architecture can support it (NVSIZE <= IVSIZE). + */ + +/* The following two macros compute the necessary offsets for the above + * trick and store them in SvANY for SvIV() (and friends) to use. */ + +#ifdef PERL_CORE +# define SET_SVANY_FOR_BODYLESS_IV(sv) \ + SvANY(sv) = (XPVIV*)((char*)&(sv->sv_u.svu_iv) \ + - STRUCT_OFFSET(XPVIV, xiv_iv)) + +# define SET_SVANY_FOR_BODYLESS_NV(sv) \ + SvANY(sv) = (XPVNV*)((char*)&(sv->sv_u.svu_nv) \ + - STRUCT_OFFSET(XPVNV, xnv_u.xnv_nv)) +#endif + +/* * ex: set ts=8 sts=4 sw=4 et: */