X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=hv.h;h=bd157f8b11103ca0c8bc67d18884b1b7bbeaffe1;hb=b2a156bd8e464af88881c77344280160fd844dcf;hp=79035e27669392e98290048adbb69c4a29104be9;hpb=69ecfd1277806cc4f0867436789903927289b9b2;p=p5sagit%2Fp5-mst-13.2.git diff --git a/hv.h b/hv.h index 79035e2..bd157f8 100644 --- a/hv.h +++ b/hv.h @@ -283,19 +283,6 @@ C. #define HvREHASH_on(hv) (SvFLAGS(hv) |= SVphv_REHASH) #define HvREHASH_off(hv) (SvFLAGS(hv) &= ~SVphv_REHASH) -/* Maybe amagical: */ -/* #define HV_AMAGICmb(hv) (SvFLAGS(hv) & (SVpgv_badAM | SVpgv_AM)) */ - -#define HV_AMAGIC(hv) (SvFLAGS(hv) & SVpgv_AM) -#define HV_AMAGIC_on(hv) (SvFLAGS(hv) |= SVpgv_AM) -#define HV_AMAGIC_off(hv) (SvFLAGS(hv) &= ~SVpgv_AM) - -/* -#define HV_AMAGICbad(hv) (SvFLAGS(hv) & SVpgv_badAM) -#define HV_badAMAGIC_on(hv) (SvFLAGS(hv) |= SVpgv_badAM) -#define HV_badAMAGIC_off(hv) (SvFLAGS(hv) &= ~SVpgv_badAM) -*/ - #define Nullhe Null(HE*) #define HeNEXT(he) (he)->hent_next #define HeKEY_hek(he) (he)->hent_hek @@ -336,6 +323,7 @@ C. #define HVhek_UTF8 0x01 /* Key is utf8 encoded. */ #define HVhek_WASUTF8 0x02 /* Key is bytes here, but was supplied as utf8. */ #define HVhek_REHASH 0x04 /* This key is in an hv using a custom HASH . */ +#define HVhek_UNSHARED 0x08 /* This key isn't a shared hash key. */ #define HVhek_FREEKEY 0x100 /* Internal flag to say key is malloc()ed. */ #define HVhek_PLACEHOLD 0x200 /* Internal flag to create placeholder. * (may change, but Storable is a core module) */ @@ -346,10 +334,11 @@ C. into all keys as hv_iternext has no access to the hash flags. At this point Storable's tests get upset, because sometimes hashes are "keyed" and sometimes not, depending on the order of data insertion, and whether - it triggered rehashing. So currently HVhek_REHAS is exempt. + it triggered rehashing. So currently HVhek_REHASH is exempt. + Similarly UNSHARED */ -#define HVhek_ENABLEHVKFLAGS (HVhek_MASK - HVhek_REHASH) +#define HVhek_ENABLEHVKFLAGS (HVhek_MASK & ~(HVhek_REHASH|HVhek_UNSHARED)) #define HEK_UTF8(hek) (HEK_FLAGS(hek) & HVhek_UTF8) #define HEK_UTF8_on(hek) (HEK_FLAGS(hek) |= HVhek_UTF8) @@ -391,6 +380,60 @@ C. ->shared_he_he.he_valu.hent_refcount), \ hek) +/* This refcounted he structure is used for storing the hints used for lexical + pragmas. Without threads, it's basically struct he + refcount. + With threads, life gets more complex as the structure needs to be shared + between threads (because it hangs from OPs, which are shared), hence the + alternate definition and mutex. */ + +#ifdef PERL_CORE + +/* Gosh. This really isn't a good name any longer. */ +struct refcounted_he { + struct refcounted_he *refcounted_he_next; /* next entry in chain */ +#ifdef USE_ITHREADS + U32 refcounted_he_hash; + U32 refcounted_he_keylen; +#else + HEK *refcounted_he_hek; /* hint key */ +#endif + U32 refcounted_he_refcnt; /* reference count */ + union { + IV refcounted_he_u_iv; + UV refcounted_he_u_uv; + STRLEN refcounted_he_u_len; + } refcounted_he_val; + /* First byte is flags. Then NUL-terminated value. Then for ithreads, + non-NUL terminated key. */ + char refcounted_he_data[1]; +}; + +/* Flag bits are HVhek_UTF8, HVhek_WASUTF8, then */ +#define HVrhek_undef 0x00 /* Value is undef. */ +#define HVrhek_PV 0x10 /* Value is a string. */ +#define HVrhek_IV 0x20 /* Value is IV/UV. */ +#define HVrhek_delete 0x30 /* Value is placeholder - signifies delete. */ +#define HVrhek_typemask 0x30 +#define HVrhek_UTF8 0x40 /* string value is utf8. */ +#define HVrhek_UV 0x40 /* integer value is UV. */ + +# ifdef USE_ITHREADS +# define HINTS_REFCNT_LOCK MUTEX_LOCK(&PL_hints_mutex) +# define HINTS_REFCNT_UNLOCK MUTEX_UNLOCK(&PL_hints_mutex) +# else +# define HINTS_REFCNT_LOCK NOOP +# define HINTS_REFCNT_UNLOCK NOOP +# endif +#endif + +#ifdef USE_ITHREADS +# define HINTS_REFCNT_INIT MUTEX_INIT(&PL_hints_mutex) +# define HINTS_REFCNT_TERM MUTEX_DESTROY(&PL_hints_mutex) +#else +# define HINTS_REFCNT_INIT NOOP +# define HINTS_REFCNT_TERM NOOP +#endif + /* * Local variables: * c-indentation-style: bsd