-
-static void indirect_ptable_clone(pTHX_ ptable_ent *ent, void *ud_) {
- indirect_ptable_clone_ud *ud = ud_;
- indirect_hint_t *h1 = ent->val;
- indirect_hint_t *h2;
-
-#if I_HINT_STRUCT
-
- h2 = PerlMemShared_malloc(sizeof *h2);
- h2->code = indirect_dup_inc(h1->code, ud);
-#if I_WORKAROUND_REQUIRE_PROPAGATION
- h2->require_tag = PTR2IV(indirect_dup_inc(INT2PTR(SV *, h1->require_tag), ud));
-#endif
-
-#else /* I_HINT_STRUCT */
-
- h2 = indirect_dup_inc(h1, ud);
-
-#endif /* !I_HINT_STRUCT */
-
- ptable_hints_store(ud->tbl, ent->key, h2);
-}
-
-static void indirect_thread_cleanup(pTHX_ void *ud) {
- dMY_CXT;
-
- indirect_clear_loaded(&MY_CXT);
-
- SvREFCNT_dec(MY_CXT.global_code);
- MY_CXT.global_code = NULL;
-
- ptable_free(MY_CXT.map);
- MY_CXT.map = NULL;
-
- ptable_hints_free(MY_CXT.tbl);
- MY_CXT.tbl = NULL;
-}
-
-static int indirect_endav_free(pTHX_ SV *sv, MAGIC *mg) {
- SAVEDESTRUCTOR_X(indirect_thread_cleanup, NULL);
-
- return 0;
-}
-
-static MGVTBL indirect_endav_vtbl = {
- 0,
- 0,
- 0,
- 0,
- indirect_endav_free
-#if MGf_COPY
- , 0
-#endif
-#if MGf_DUP
- , 0
-#endif
-#if MGf_LOCAL
- , 0
-#endif
-};
-
-#endif /* I_THREADSAFE */
-
-#if I_WORKAROUND_REQUIRE_PROPAGATION
-static IV indirect_require_tag(pTHX) {
-#define indirect_require_tag() indirect_require_tag(aTHX)
- const CV *cv, *outside;
-
- cv = PL_compcv;
-
- if (!cv) {
- /* If for some reason the pragma is operational at run-time, try to discover
- * the current cv in use. */
- const PERL_SI *si;
-
- for (si = PL_curstackinfo; si; si = si->si_prev) {
- I32 cxix;
-
- for (cxix = si->si_cxix; cxix >= 0; --cxix) {
- const PERL_CONTEXT *cx = si->si_cxstack + cxix;
-
- switch (CxTYPE(cx)) {
- case CXt_SUB:
- case CXt_FORMAT:
- /* The propagation workaround is only needed up to 5.10.0 and at that
- * time format and sub contexts were still identical. And even later the
- * cv members offsets should have been kept the same. */
- cv = cx->blk_sub.cv;
- goto get_enclosing_cv;
- case CXt_EVAL:
- cv = cx->blk_eval.cv;
- goto get_enclosing_cv;
- default:
- break;
- }