X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=sv.h;h=0a79b2adbef0251c7614978fbd538f454121961c;hb=741448370a0796f47e22ef979f14593fc7533404;hp=0085b368accebfc0857696e07bb508341bd4db65;hpb=c43294b8228352af5778f0b0d7935ff67661117e;p=p5sagit%2Fp5-mst-13.2.git diff --git a/sv.h b/sv.h index 0085b36..0a79b2a 100644 --- a/sv.h +++ b/sv.h @@ -1,6 +1,6 @@ /* sv.h * - * Copyright (c) 1991-2001, Larry Wall + * Copyright (c) 1991-2002, Larry Wall * * You may distribute under the terms of either the GNU General Public * License or the Artistic License, as specified in the README file. @@ -12,8 +12,10 @@ #endif /* +=head1 SV Flags + =for apidoc AmU||svtype -An enum of flags for Perl types. These are found in the file B +An enum of flags for Perl types. These are found in the file B in the C enum. Test these flags with the C macro. =for apidoc AmU||SVt_PV @@ -61,7 +63,7 @@ typedef enum { /* Using C's structural equivalence to help emulate C++ inheritance here... */ -struct STRUCT_SV { +struct STRUCT_SV { /* struct sv { */ void* sv_any; /* pointer to something */ U32 sv_refcnt; /* how many references to us */ U32 sv_flags; /* what we are */ @@ -98,6 +100,8 @@ struct io { }; /* +=head1 SV Manipulation Functions + =for apidoc Am|U32|SvREFCNT|SV* sv Returns the value of the object's reference count. @@ -121,7 +125,7 @@ perform the upgrade if necessary. See C. #define SvFLAGS(sv) (sv)->sv_flags #define SvREFCNT(sv) (sv)->sv_refcnt -#ifdef USE_THREADS +#ifdef USE_5005THREADS # if defined(VMS) # define ATOMIC_INC(count) __ATOMIC_INCREMENT_LONG(&count) @@ -146,7 +150,7 @@ perform the upgrade if necessary. See C. #else # define ATOMIC_INC(count) (++count) # define ATOMIC_DEC_AND_TEST(res, count) (res = (--count == 0)) -#endif /* USE_THREADS */ +#endif /* USE_5005THREADS */ #ifdef __GNUC__ # define SvREFCNT_inc(sv) \ @@ -157,7 +161,7 @@ perform the upgrade if necessary. See C. nsv; \ }) #else -# if defined(CRIPPLED_CC) || defined(USE_THREADS) +# if defined(CRIPPLED_CC) || defined(USE_5005THREADS) # if defined(VMS) && defined(__ALPHA) # define SvREFCNT_inc(sv) \ (PL_Sv=(SV*)(sv), (PL_Sv && __ATOMIC_INCREMENT_LONG(&(SvREFCNT(PL_Sv)))), (SV *)PL_Sv) @@ -338,20 +342,20 @@ struct xpvfm { HV * xcv_stash; OP * xcv_start; OP * xcv_root; - void (*xcv_xsub)(pTHXo_ CV*); + void (*xcv_xsub)(pTHX_ CV*); ANY xcv_xsubany; GV * xcv_gv; char * xcv_file; long xcv_depth; /* >= 2 indicates recursive call */ AV * xcv_padlist; CV * xcv_outside; -#ifdef USE_THREADS +#ifdef USE_5005THREADS perl_mutex *xcv_mutexp; /* protects xcv_owner */ struct perl_thread *xcv_owner; /* current owner thread */ -#endif /* USE_THREADS */ +#endif /* USE_5005THREADS */ cv_flags_t xcv_flags; - I32 xfm_lines; + IV xfm_lines; }; struct xpvio { @@ -378,10 +382,10 @@ struct xpvio { DIR * xiou_dirp; /* for opendir, readdir, etc */ void * xiou_any; /* for alignment */ } xio_dirpu; - long xio_lines; /* $. */ - long xio_page; /* $% */ - long xio_page_len; /* $= */ - long xio_lines_left; /* $- */ + 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; /* $~ */ @@ -454,7 +458,7 @@ Returns a boolean indicating whether the SV contains an unsigned integer. Returns a boolean indicating whether the SV contains an unsigned integer. =for apidoc Am|void|SvIOK_notUV|SV* sv -Returns a boolean indicating whether the SV contains an signed integer. +Returns a boolean indicating whether the SV contains a signed integer. =for apidoc Am|bool|SvNOK|SV* sv Returns a boolean indicating whether the SV contains a double. @@ -646,7 +650,7 @@ and leaves the UTF8 status as it was. #define SvAMAGIC_on(sv) (SvFLAGS(sv) |= SVf_AMAGIC) #define SvAMAGIC_off(sv) (SvFLAGS(sv) &= ~SVf_AMAGIC) -#define SvGAMAGIC(sv) (SvFLAGS(sv) & (SVs_GMG|SVf_AMAGIC)) +#define SvGAMAGIC(sv) (SvFLAGS(sv) & (SVs_GMG|SVf_AMAGIC)) /* #define Gv_AMG(stash) \ @@ -703,6 +707,14 @@ and leaves the UTF8 status as it was. #define SvVALID_on(sv) (SvFLAGS(sv) |= SVpbm_VALID) #define SvVALID_off(sv) (SvFLAGS(sv) &= ~SVpbm_VALID) +#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 SvRV(sv) ((XRV*) SvANY(sv))->xrv_rv #define SvRVx(sv) SvRV(sv) @@ -847,7 +859,7 @@ version which guarantees to evaluate sv only once. =for apidoc Am|IV|SvIVx|SV* sv Coerces the given SV to an integer and returns it. Guarantees to evaluate -sv only once. Use the more efficent C otherwise. +sv only once. Use the more efficient C otherwise. =for apidoc Am|NV|SvNV|SV* sv Coerce the given SV to a double and return it. See C for a version @@ -855,7 +867,7 @@ which guarantees to evaluate sv only once. =for apidoc Am|NV|SvNVx|SV* sv Coerces the given SV to a double and returns it. Guarantees to evaluate -sv only once. Use the more efficent C otherwise. +sv only once. Use the more efficient C otherwise. =for apidoc Am|UV|SvUV|SV* sv Coerces the given SV to an unsigned integer and returns it. See C @@ -863,20 +875,20 @@ for a version which guarantees to evaluate sv only once. =for apidoc Am|UV|SvUVx|SV* sv Coerces the given SV to an unsigned integer and returns it. Guarantees to -evaluate sv only once. Use the more efficent C otherwise. +evaluate sv only once. Use the more efficient C otherwise. =for apidoc Am|bool|SvTRUE|SV* sv Returns a boolean indicating whether Perl would evaluate the SV as true or false, defined or undefined. Does not handle 'get' magic. =for apidoc Am|char*|SvPVutf8_force|SV* sv|STRLEN len -Like C, but converts sv to uft8 first if necessary. +Like C, but converts sv to utf8 first if necessary. =for apidoc Am|char*|SvPVutf8|SV* sv|STRLEN len -Like C, but converts sv to uft8 first if necessary. +Like C, but converts sv to utf8 first if necessary. -=for apidoc Am|char*|SvPVutf8_nolen|SV* sv|STRLEN len -Like C, but converts sv to uft8 first if necessary. +=for apidoc Am|char*|SvPVutf8_nolen|SV* sv +Like C, but converts sv to utf8 first if necessary. =for apidoc Am|char*|SvPVbyte_force|SV* sv|STRLEN len Like C, but converts sv to byte representation first if necessary. @@ -884,27 +896,27 @@ Like C, but converts sv to byte representation first if necessary. =for apidoc Am|char*|SvPVbyte|SV* sv|STRLEN len Like C, but converts sv to byte representation first if necessary. -=for apidoc Am|char*|SvPVbyte_nolen|SV* sv|STRLEN len +=for apidoc Am|char*|SvPVbyte_nolen|SV* sv Like C, but converts sv to byte representation first if necessary. =for apidoc Am|char*|SvPVutf8x_force|SV* sv|STRLEN len -Like C, but converts sv to uft8 first if necessary. -Guarantees to evalute sv only once; use the more efficient C +Like C, but converts sv to utf8 first if necessary. +Guarantees to evaluate sv only once; use the more efficient C otherwise. =for apidoc Am|char*|SvPVutf8x|SV* sv|STRLEN len -Like C, but converts sv to uft8 first if necessary. -Guarantees to evalute sv only once; use the more efficient C +Like C, but converts sv to utf8 first if necessary. +Guarantees to evaluate sv only once; use the more efficient C otherwise. =for apidoc Am|char*|SvPVbytex_force|SV* sv|STRLEN len Like C, but converts sv to byte representation first if necessary. -Guarantees to evalute sv only once; use the more efficient C +Guarantees to evaluate sv only once; use the more efficient C otherwise. =for apidoc Am|char*|SvPVbytex|SV* sv|STRLEN len Like C, but converts sv to byte representation first if necessary. -Guarantees to evalute sv only once; use the more efficient C +Guarantees to evaluate sv only once; use the more efficient C otherwise. @@ -914,6 +926,8 @@ otherwise. #define SvPV_force(sv, lp) sv_pvn_force(sv, &lp) #define SvPV(sv, lp) sv_pvn(sv, &lp) #define SvPV_nolen(sv) sv_pv(sv) +#define SvPV_nomg(sv, lp) sv_pvn_nomg(sv, &lp) +#define SvPV_force_flags(sv, lp, flags) sv_pvn_force_flags(sv, &lp, flags) #define SvPVutf8_force(sv, lp) sv_pvutf8n_force(sv, &lp) #define SvPVutf8(sv, lp) sv_pvutf8n(sv, &lp) @@ -941,6 +955,14 @@ otherwise. #define SvUV(sv) SvUVx(sv) #define SvTRUE(sv) SvTRUEx(sv) +/* flag values for sv_*_flags functions */ +#define SV_IMMEDIATE_UNREF 1 +#define SV_GMAGIC 2 + +#define sv_pvn_force_nomg(sv, lp) sv_pvn_force_flags(sv, lp, 0) +#define sv_utf8_upgrade_nomg(sv) sv_utf8_upgrade_flags(sv, 0) +#define sv_catpvn_nomg(dsv, sstr, slen) sv_catpvn_flags(dsv, sstr, slen, 0) + #ifndef CRIPPLED_CC /* redefine some things to more efficient inlined versions */ @@ -954,30 +976,15 @@ otherwise. #undef SvNV #define SvNV(sv) (SvNOK(sv) ? SvNVX(sv) : sv_2nv(sv)) -/* flag values for sv_*_flags functions */ -#define SV_IMMEDIATE_UNREF 1 -#define SV_GMAGIC 2 - -#define sv_setsv_macro(dsv, ssv) sv_setsv_flags(dsv, ssv, SV_GMAGIC) +#define sv_setsv(dsv, ssv) sv_setsv_flags(dsv, ssv, SV_GMAGIC) #define sv_setsv_nomg(dsv, ssv) sv_setsv_flags(dsv, ssv, 0) -#define sv_catsv_macro(dsv, ssv) sv_catsv_flags(dsv, ssv, SV_GMAGIC) +#define sv_catsv(dsv, ssv) sv_catsv_flags(dsv, ssv, SV_GMAGIC) #define sv_catsv_nomg(dsv, ssv) sv_catsv_flags(dsv, ssv, 0) -#define sv_catpvn_macro(dsv, sstr, slen) sv_catpvn_flags(dsv, sstr, slen, SV_GMAGIC) -#define sv_catpvn_nomg(dsv, sstr, slen) sv_catpvn_flags(dsv, sstr, slen, 0) -#define sv_2pv_macro(sv, lp) sv_2pv_flags(sv, lp, SV_GMAGIC) +#define sv_catpvn(dsv, sstr, slen) sv_catpvn_flags(dsv, sstr, slen, SV_GMAGIC) +#define sv_2pv(sv, lp) sv_2pv_flags(sv, lp, SV_GMAGIC) #define sv_2pv_nomg(sv, lp) sv_2pv_flags(sv, lp, 0) -#define sv_pvn_force_macro(sv, lp) sv_pvn_force_flags(sv, lp, SV_GMAGIC) -#define sv_pvn_force_nomg(sv, lp) sv_pvn_force_flags(sv, lp, 0) -#define sv_utf8_upgrade_macro(sv) sv_utf8_upgrade_flags(sv, SV_GMAGIC) -#define sv_utf8_upgrade_nomg(sv) sv_utf8_upgrade_flags(sv, 0) - -/* function style also available for bincompat */ -#define sv_setsv(dsv, ssv) sv_setsv_macro(dsv, ssv) -#define sv_catsv(dsv, ssv) sv_catsv_macro(dsv, ssv) -#define sv_catpvn(dsv, sstr, slen) sv_catpvn_macro(dsv, sstr, slen) -#define sv_2pv(sv, lp) sv_2pv_macro(sv, lp) -#define sv_pvn_force(sv, lp) sv_pvn_force_macro(sv, lp) -#define sv_utf8_upgrade(sv) sv_utf8_upgrade_macro(sv) +#define sv_pvn_force(sv, lp) sv_pvn_force_flags(sv, lp, SV_GMAGIC) +#define sv_utf8_upgrade(sv) sv_utf8_upgrade_flags(sv, SV_GMAGIC) #undef SvPV #define SvPV(sv, lp) SvPV_flags(sv, lp, SV_GMAGIC) @@ -1084,7 +1091,7 @@ otherwise. : sv_2bool(sv) ) # define SvTRUEx(sv) ({SV *nsv = (sv); SvTRUE(nsv); }) #else /* __GNUC__ */ -#ifndef USE_THREADS +#ifndef USE_5005THREADS /* These inlined macros use globals, which will require a thread * declaration in user code, so we avoid them under threads */ @@ -1118,7 +1125,7 @@ otherwise. ? SvNVX(sv) != 0.0 \ : sv_2bool(sv) ) # define SvTRUEx(sv) ((PL_Sv = (sv)), SvTRUE(PL_Sv)) -#endif /* !USE_THREADS */ +#endif /* !USE_5005THREADS */ #endif /* !__GNU__ */ #endif /* !CRIPPLED_CC */ @@ -1136,6 +1143,8 @@ incremented. /* the following macros update any magic values this sv is associated with */ /* +=head1 Magical Functions + =for apidoc Am|void|SvGETMAGIC|SV* sv Invokes C on an SV if it has 'get' magic. This macro evaluates its argument more than once. @@ -1158,15 +1167,33 @@ Like C, but does any set magic required afterwards. =for apidoc Am|void|SvSetMagicSV_nosteal|SV* dsv|SV* ssv Like C, but does any set magic required afterwards. +=for apidoc Am|void|SvSHARE|SV* sv +Arranges for sv to be shared between threads if a suitable module +has been loaded. + +=for apidoc Am|void|SvLOCK|SV* sv +Arranges for a mutual exclusion lock to be obtained on sv if a suitable module +has been loaded. + +=for apidoc Am|void|SvUNLOCK|SV* sv +Releases a mutual exclusion lock on sv if a suitable module +has been loaded. + +=head1 SV Manipulation Functions + =for apidoc Am|char *|SvGROW|SV* sv|STRLEN len Expands the character buffer in the SV so that it has room for the indicated number of bytes (remember to reserve space for an extra trailing -NUL character). Calls C to perform the expansion if necessary. +NUL character). Calls C to perform the expansion if necessary. Returns a pointer to the character buffer. =cut */ +#define SvSHARE(sv) CALL_FPTR(PL_sharehook)(aTHX_ sv) +#define SvLOCK(sv) CALL_FPTR(PL_lockhook)(aTHX_ sv) +#define SvUNLOCK(sv) CALL_FPTR(PL_unlockhook)(aTHX_ sv) + #define SvGETMAGIC(x) STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END #define SvSETMAGIC(x) STMT_START { if (SvSMAGICAL(x)) mg_set(x); } STMT_END @@ -1217,7 +1244,7 @@ Returns a pointer to the character buffer. #define CLONEf_KEEP_PTR_TABLE 2 #define CLONEf_CLONE_HOST 4 -typedef struct { +struct clone_params { AV* stashes; UV flags; -} clone_params; +};