#define PL_Gfold_locale (my_vars->Gfold_locale)
#define PL_hexdigit (my_vars->Ghexdigit)
#define PL_Ghexdigit (my_vars->Ghexdigit)
+#define PL_hints_mutex (my_vars->Ghints_mutex)
+#define PL_Ghints_mutex (my_vars->Ghints_mutex)
#define PL_malloc_mutex (my_vars->Gmalloc_mutex)
#define PL_Gmalloc_mutex (my_vars->Gmalloc_mutex)
#define PL_mmap_page_size (my_vars->Gmmap_page_size)
#define PL_Gdollarzero_mutex PL_dollarzero_mutex
#define PL_Gfold_locale PL_fold_locale
#define PL_Ghexdigit PL_hexdigit
+#define PL_Ghints_mutex PL_hints_mutex
#define PL_Gmalloc_mutex PL_malloc_mutex
#define PL_Gmmap_page_size PL_mmap_page_size
#define PL_Gmy_ctx_mutex PL_my_ctx_mutex
}
while (chain) {
- const U32 hash = HEK_HASH(chain->refcounted_he_he.hent_hek);
+ const U32 hash = HEK_HASH(chain->refcounted_he_hek);
HE **oentry = &((HvARRAY(hv))[hash & max]);
HE *entry = *oentry;
assert (!entry);
entry = new_HE();
- HeKEY_hek(entry) = share_hek_hek(chain->refcounted_he_he.hent_hek);
+ HeKEY_hek(entry) = share_hek_hek(chain->refcounted_he_hek);
- HeVAL(entry) = chain->refcounted_he_he.he_valu.hent_val;
+ HeVAL(entry) = chain->refcounted_he_val;
if (HeVAL(entry) == &PL_sv_placeholder)
placeholders++;
SvREFCNT_inc_void_NN(HeVAL(entry));
HvTOTALKEYS(hv)++;
next_please:
- chain = (struct refcounted_he *) chain->refcounted_he_he.hent_next;
+ chain = chain->refcounted_he_next;
}
if (placeholders) {
Newx(he, 1, struct refcounted_he);
- he->refcounted_he_he.hent_next = (HE *)parent;
- he->refcounted_he_he.he_valu.hent_val = value;
- he->refcounted_he_he.hent_hek
+ he->refcounted_he_next = parent;
+ he->refcounted_he_val = value;
+ he->refcounted_he_hek
= share_hek(p, SvUTF8(key) ? -(I32)len : len, hash);
he->refcounted_he_refcnt = 1;
if (--he->refcounted_he_refcnt)
return;
- unshare_hek_or_pvn (he->refcounted_he_he.hent_hek, 0, 0, 0);
- SvREFCNT_dec(he->refcounted_he_he.he_valu.hent_val);
+ unshare_hek_or_pvn (he->refcounted_he_hek, 0, 0, 0);
+ SvREFCNT_dec(he->refcounted_he_val);
copy = he;
- he = (struct refcounted_he *) he->refcounted_he_he.hent_next;
+ he = he->refcounted_he_next;
Safefree(copy);
}
}
Newx(copy, 1, struct refcounted_he);
ptr_table_store(PL_ptr_table, he, copy);
- copy->refcounted_he_he.hent_next
- = (HE *)Perl_refcounted_he_dup(aTHX_
- (struct refcounted_he *)
- he->refcounted_he_he.hent_next,
- param);
- copy->refcounted_he_he.he_valu.hent_val
- = SvREFCNT_inc(sv_dup(he->refcounted_he_he.he_valu.hent_val, param));
- copy->refcounted_he_he.hent_hek
- = hek_dup(he->refcounted_he_he.hent_hek, param);
+ copy->refcounted_he_next
+ = Perl_refcounted_he_dup(aTHX_ he->refcounted_he_next, param);
+ copy->refcounted_he_val
+ = SvREFCNT_inc(sv_dup(he->refcounted_he_val, param));
+ copy->refcounted_he_hek = hek_dup(he->refcounted_he_hek, param);
copy->refcounted_he_refcnt = he->refcounted_he_refcnt;
return copy;
}
return NULL;
Newx(copy, 1, struct refcounted_he);
- copy->refcounted_he_he.hent_next
- = (HE *)Perl_refcounted_he_copy(aTHX_
- (struct refcounted_he *)
- he->refcounted_he_he.hent_next);
- copy->refcounted_he_he.he_valu.hent_val
- = newSVsv(he->refcounted_he_he.he_valu.hent_val);
- hek = he->refcounted_he_he.hent_hek;
- copy->refcounted_he_he.hent_hek
+ copy->refcounted_he_next
+ = Perl_refcounted_he_copy(aTHX_ he->refcounted_he_next);
+ copy->refcounted_he_val = newSVsv(he->refcounted_he_val);
+ hek = he->refcounted_he_hek;
+ copy->refcounted_he_hek
= share_hek(HEK_KEY(hek),
HEK_UTF8(hek) ? -(I32)HEK_LEN(hek) : HEK_LEN(hek),
HEK_HASH(hek));
struct hek shared_he_hek;
};
-struct refcounted_he {
- struct he refcounted_he_he;
- U32 refcounted_he_refcnt;
-};
-
/* Subject to change.
Don't access this directly.
*/
->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
+
+struct refcounted_he {
+ struct refcounted_he *refcounted_he_next; /* next entry in chain */
+ HEK *refcounted_he_hek; /* hint key */
+ SV *refcounted_he_val; /* hint value */
+ U32 refcounted_he_refcnt; /* reference count */
+};
+
+# 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