summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hv.h41
-rw-r--r--sv.h2
2 files changed, 43 insertions, 0 deletions
diff --git a/hv.h b/hv.h
index 49703632b8..a9de8caef1 100644
--- a/hv.h
+++ b/hv.h
@@ -32,6 +32,23 @@ struct xpvhv {
char *xhv_name; /* name, if a symbol table */
};
+#define PERL_HASH(hash,str,len) \
+ STMT_START { \
+ register char *s_PeRlHaSh = str; \
+ register I32 i_PeRlHaSh = len; \
+ register U32 hash_PeRlHaSh = 0; \
+ while (i_PeRlHaSh--) \
+ hash_PeRlHaSh = hash_PeRlHaSh * 33 + *s_PeRlHaSh++; \
+ (hash) = hash_PeRlHaSh; \
+ } STMT_END
+
+
+/* these hash entry flags ride on hent_klen */
+
+#define HEf_LAZYDEL -1 /* entry must be deleted during next iter step */
+#define HEf_SVKEY -2 /* hent_key is a SV* (only for magic/tied HVs) */
+
+
#define Nullhv Null(HV*)
#define HvARRAY(hv) ((HE**)((XPVHV*) SvANY(hv))->xhv_array)
#define HvFILL(hv) ((XPVHV*) SvANY(hv))->xhv_fill
@@ -42,6 +59,10 @@ struct xpvhv {
#define HvPMROOT(hv) ((XPVHV*) SvANY(hv))->xhv_pmroot
#define HvNAME(hv) ((XPVHV*) SvANY(hv))->xhv_name
+#define HvSHAREKEYS(hv) (SvFLAGS(hv) & SVphv_SHAREKEYS)
+#define HvSHAREKEYS_on(hv) (SvFLAGS(hv) |= SVphv_SHAREKEYS)
+#define HvSHAREKEYS_off(hv) (SvFLAGS(hv) &= ~SVphv_SHAREKEYS)
+
#ifdef OVERLOAD
/* Maybe amagical: */
@@ -58,3 +79,23 @@ struct xpvhv {
*/
#endif /* OVERLOAD */
+
+#define Nullhe Null(HE*)
+#define HeNEXT(he) (he)->hent_next
+#define HeKEY(he) (he)->hent_key
+#define HeKLEN(he) (he)->hent_klen
+#define HeVAL(he) (he)->hent_val
+#define HeHASH(he) (he)->hent_hash
+#define HePV(he) ((he)->hent_klen == HEf_SVKEY) ? \
+ SvPV((SV*)((he)->hent_key),na) : \
+ (he)->hent_key))
+#define HeSVKEY(he) (((he)->hent_key && \
+ (he)->hent_klen == HEf_SVKEY) ? \
+ (SV*)((he)->hent_key) : Nullsv)
+
+#define HeSVKEY_force(he) ((he)->hent_key ? \
+ (((he)->hent_klen == HEf_SVKEY) ? \
+ (SV*)((he)->hent_key) : \
+ sv_2mortal(newSVpv((he)->hent_key, \
+ (he)->hent_klen))) : \
+ &sv_undef)
diff --git a/sv.h b/sv.h
index c586de4e02..5b3a72a4ad 100644
--- a/sv.h
+++ b/sv.h
@@ -129,6 +129,8 @@ struct io {
#define SVpbm_CASEFOLD 0x40000000
#define SVpbm_TAIL 0x20000000
+#define SVphv_SHAREKEYS 0x20000000 /* keys live on shared string table */
+
#ifdef OVERLOAD
#define SVpgv_AM 0x40000000
/* #define SVpgv_badAM 0x20000000 */