return o;
}
+/* --- Global setup/teardown ------------------------------------------------ */
+
static U32 indirect_initialized = 0;
-static void indirect_teardown(pTHX_ void *root) {
+static void indirect_global_teardown(pTHX_ void *root) {
if (!indirect_initialized)
return;
return;
#endif
- {
- dMY_CXT;
- ptable_free(MY_CXT.map);
- MY_CXT.map = NULL;
-#if I_THREADSAFE
- ptable_hints_free(MY_CXT.tbl);
- MY_CXT.tbl = NULL;
-#endif
- }
-
indirect_ck_restore(OP_CONST, &indirect_old_ck_const);
indirect_ck_restore(OP_RV2SV, &indirect_old_ck_rv2sv);
indirect_ck_restore(OP_PADANY, &indirect_old_ck_padany);
indirect_ck_restore(OP_ENTERSUB, &indirect_old_ck_entersub);
indirect_initialized = 0;
+
+ return;
}
-static void indirect_setup(pTHX) {
-#define indirect_setup() indirect_setup(aTHX)
+static void indirect_global_setup(pTHX) {
+#define indirect_global_setup() indirect_global_setup(aTHX)
+ HV *stash;
+
if (indirect_initialized)
return;
- {
- MY_CXT_INIT;
-#if I_THREADSAFE
- MY_CXT.tbl = ptable_new();
- MY_CXT.owner = aTHX;
-#endif
- MY_CXT.map = ptable_new();
- MY_CXT.global_code = NULL;
- }
+ PERL_HASH(indirect_hash, __PACKAGE__, __PACKAGE_LEN__);
+
+ stash = gv_stashpvn(__PACKAGE__, __PACKAGE_LEN__, 1);
+ newCONSTSUB(stash, "I_THREADSAFE", newSVuv(I_THREADSAFE));
+ newCONSTSUB(stash, "I_FORKSAFE", newSVuv(I_FORKSAFE));
indirect_ck_replace(OP_CONST, indirect_ck_const, &indirect_old_ck_const);
indirect_ck_replace(OP_RV2SV, indirect_ck_rv2sv, &indirect_old_ck_rv2sv);
&indirect_old_ck_entersub);
#if I_MULTIPLICITY
- call_atexit(indirect_teardown, aTHX);
+ call_atexit(indirect_global_teardown, aTHX);
#else
- call_atexit(indirect_teardown, NULL);
+ call_atexit(indirect_global_teardown, NULL);
#endif
indirect_initialized = 1;
+
+ return;
+}
+
+/* --- Interpreter setup/teardown ------------------------------------------ */
+
+static void indirect_local_teardown(pTHX_ void *param) {
+ dMY_CXT;
+
+ ptable_free(MY_CXT.map);
+ MY_CXT.map = NULL;
+
+#if I_THREADSAFE
+ ptable_hints_free(MY_CXT.tbl);
+ MY_CXT.tbl = NULL;
+#endif
+
+ return;
}
-static U32 indirect_booted = 0;
+static void indirect_local_setup(pTHX) {
+#define indirect_local_setup() indirect_local_setup(aTHX)
+ MY_CXT_INIT;
+
+#if I_THREADSAFE
+ MY_CXT.tbl = ptable_new();
+ MY_CXT.owner = aTHX;
+#endif
+
+ MY_CXT.map = ptable_new();
+ MY_CXT.global_code = NULL;
+
+ call_atexit(indirect_local_teardown, NULL);
+
+ return;
+}
/* --- XS ------------------------------------------------------------------ */
BOOT:
{
- if (!indirect_booted++) {
- HV *stash;
-
- PERL_HASH(indirect_hash, __PACKAGE__, __PACKAGE_LEN__);
-
- stash = gv_stashpvn(__PACKAGE__, __PACKAGE_LEN__, 1);
- newCONSTSUB(stash, "I_THREADSAFE", newSVuv(I_THREADSAFE));
- newCONSTSUB(stash, "I_FORKSAFE", newSVuv(I_FORKSAFE));
- }
-
- indirect_setup();
+ indirect_global_setup();
+ indirect_local_setup();
}
#if I_THREADSAFE