X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=sv.h;h=fcf92975f4e4d19767c5b6a122b812bdf62c8380;hb=51dd5992be029393cb3f221313a1a6ec2a76c21a;hp=2651e434671c27078cd974d84315e9976e1f8a4c;hpb=12ca11f6c16e7b63e13bbf5bc251f214e8de5211;p=p5sagit%2Fp5-mst-13.2.git diff --git a/sv.h b/sv.h index 2651e43..fcf9297 100644 --- a/sv.h +++ b/sv.h @@ -70,17 +70,20 @@ struct io { #define SvANY(sv) (sv)->sv_any #define SvFLAGS(sv) (sv)->sv_flags - #define SvREFCNT(sv) (sv)->sv_refcnt -#ifdef CRIPPLED_CC -#define SvREFCNT_inc(sv) sv_newref((SV*)sv) -#define SvREFCNT_dec(sv) sv_free((SV*)sv) + +#ifdef __GNUC__ +# define SvREFCNT_inc(sv) ({SV* nsv=(SV*)(sv); if(nsv) ++SvREFCNT(nsv); nsv;}) #else -#define SvREFCNT_inc(sv) ((Sv = (SV*)(sv)), \ - (Sv && ++SvREFCNT(Sv)), (SV*)Sv) -#define SvREFCNT_dec(sv) sv_free((SV*)sv) +# if defined(CRIPPLED_CC) || defined(USE_THREADS) +# define SvREFCNT_inc(sv) sv_newref((SV*)sv) +# else +# define SvREFCNT_inc(sv) ((Sv=(SV*)(sv)), (Sv && ++SvREFCNT(Sv)), (SV*)Sv) +# endif #endif +#define SvREFCNT_dec(sv) sv_free((SV*)sv) + #define SVTYPEMASK 0xff #define SvTYPE(sv) ((sv)->sv_flags & SVTYPEMASK) @@ -131,10 +134,6 @@ struct io { #define SVphv_SHAREKEYS 0x20000000 /* keys live on shared string table */ #define SVphv_LAZYDEL 0x40000000 /* entry in xhv_eiter must be deleted */ -#ifdef USE_THREADS -#define SVp_SYNC 0x10000000 /* Synchronised CV or an SV lock */ -#endif /* USE_THREADS */ - struct xrv { SV * xrv_rv; /* pointer to another SV */ }; @@ -224,6 +223,8 @@ struct xpvbm { /* This structure much match XPVCV */ +typedef U16 cv_flags_t; + struct xpvfm { char * xpv_pv; /* pointer to malloced string */ STRLEN xpv_cur; /* length of xpv_pv as a C string */ @@ -244,11 +245,10 @@ struct xpvfm { AV * xcv_padlist; CV * xcv_outside; #ifdef USE_THREADS - perl_mutex *xcv_mutexp; - perl_cond * xcv_condp; /* signalled when owner leaves CV */ + perl_mutex *xcv_mutexp; /* protects xcv_owner */ struct thread *xcv_owner; /* current owner thread */ #endif /* USE_THREADS */ - U8 xcv_flags; + cv_flags_t xcv_flags; I32 xfm_lines; }; @@ -494,20 +494,19 @@ struct xpvio { #ifdef CRIPPLED_CC -IV SvIV _((SV* sv)); -UV SvUV _((SV* sv)); -double SvNV _((SV* sv)); #define SvPV_force(sv, lp) sv_pvn_force(sv, &lp) #define SvPV(sv, lp) sv_pvn(sv, &lp) -char *sv_pvn _((SV *, STRLEN *)); -I32 SvTRUE _((SV *)); - -#define SvIVx(sv) SvIV(sv) -#define SvUVx(sv) SvUV(sv) -#define SvNVx(sv) SvNV(sv) +#define SvIVx(sv) sv_iv(sv) +#define SvUVx(sv) sv_uv(sv) +#define SvNVx(sv) sv_nv(sv) #define SvPVx(sv, lp) sv_pvn(sv, &lp) #define SvPVx_force(sv, lp) sv_pvn_force(sv, &lp) -#define SvTRUEx(sv) SvTRUE(sv) +#define SvTRUEx(sv) sv_true(sv) + +#define SvIV(sv) SvIVx(sv) +#define SvNV(sv) SvNVx(sv) +#define SvUV(sv) SvIVx(sv) +#define SvTRUE(sv) SvTRUEx(sv) #else /* !CRIPPLED_CC */ @@ -547,20 +546,33 @@ I32 SvTRUE _((SV *)); ? SvNVX(sv) != 0.0 \ : sv_2bool(sv) ) -#define SvIVx(sv) ((Sv = (sv)), SvIV(Sv)) -#define SvUVx(sv) ((Sv = (sv)), SvUV(Sv)) -#define SvNVx(sv) ((Sv = (sv)), SvNV(Sv)) -#define SvPVx(sv, lp) ((Sv = (sv)), SvPV(Sv, lp)) +#ifdef __GNUC__ +# define SvIVx(sv) ({SV *nsv = (SV*)(sv); SvIV(nsv); }) +# define SvUVx(sv) ({SV *nsv = (SV*)(sv); SvUV(nsv); }) +# define SvNVx(sv) ({SV *nsv = (SV*)(sv); SvNV(nsv); }) +# define SvPVx(sv, lp) ({SV *nsv = (sv); SvPV(nsv, lp); }) +#else +# define SvIVx(sv) ((Sv = (sv)), SvIV(Sv)) +# define SvUVx(sv) ((Sv = (sv)), SvUV(Sv)) +# define SvNVx(sv) ((Sv = (sv)), SvNV(Sv)) +# define SvPVx(sv, lp) ((Sv = (sv)), SvPV(Sv, lp)) +#endif /* __GNUC__ */ + #define SvTRUEx(sv) ((Sv = (sv)), SvTRUE(Sv)) #endif /* CRIPPLED_CC */ #define newRV_inc(sv) newRV(sv) -#ifdef CRIPPLED_CC -SV *newRV_noinc _((SV *)); +#ifdef __GNUC__ +# undef newRV_noinc +# define newRV_noinc(sv) ({SV *nsv=newRV((sv)); --SvREFCNT(SvRV(nsv)); nsv;}) #else -#define newRV_noinc(sv) ((Sv = newRV(sv)), --SvREFCNT(SvRV(Sv)), Sv) -#endif +# if defined(CRIPPLED_CC) || defined(USE_THREADS) +# else +# undef newRV_noinc +# define newRV_noinc(sv) ((Sv = newRV(sv)), --SvREFCNT(SvRV(Sv)), Sv) +# endif +#endif /* __GNUC__ */ /* the following macro updates any magic values this sv is associated with */