- SV *code;
- IV require_tag;
-} lt_hint_t;
-
-#define LT_HINT_STRUCT 1
-
-#define LT_HINT_CODE(H) ((H)->code)
-
-#define LT_HINT_FREE(H) { \
- lt_hint_t *h = (H); \
- SvREFCNT_dec(h->code); \
- PerlMemShared_free(h); \
-}
-
-#else /* LT_WORKAROUND_REQUIRE_PROPAGATION */
-
-typedef SV lt_hint_t;
-
-#define LT_HINT_STRUCT 0
-
-#define LT_HINT_CODE(H) (H)
-
-#define LT_HINT_FREE(H) SvREFCNT_dec(H);
-
-#endif /* !LT_WORKAROUND_REQUIRE_PROPAGATION */
-
-#if LT_THREADSAFE
-
-#define PTABLE_NAME ptable_hints
-#define PTABLE_VAL_FREE(V) LT_HINT_FREE(V)
-
-#define pPTBL pTHX
-#define pPTBL_ pTHX_
-#define aPTBL aTHX
-#define aPTBL_ aTHX_
-
-#include "ptable.h"
-
-#define ptable_hints_store(T, K, V) ptable_hints_store(aTHX_ (T), (K), (V))
-#define ptable_hints_free(T) ptable_hints_free(aTHX_ (T))
-
-#endif /* LT_THREADSAFE */
-
-/* ... "Seen" pointer table ................................................ */
-
-#define PTABLE_NAME ptable_seen
-#define PTABLE_VAL_FREE(V) NOOP
-
-#include "ptable.h"
-
-/* PerlMemShared_free() needs the [ap]PTBLMS_? default values */
-#define ptable_seen_store(T, K, V) ptable_seen_store(aPTBLMS_ (T), (K), (V))
-#define ptable_seen_clear(T) ptable_seen_clear(aPTBLMS_ (T))
-#define ptable_seen_free(T) ptable_seen_free(aPTBLMS_ (T))
-
-/* ... Global data ......................................................... */
-
-#define MY_CXT_KEY __PACKAGE__ "::_guts" XS_VERSION
-
-typedef struct {
-#if LT_THREADSAFE
- ptable *tbl; /* It really is a ptable_hints */
- tTHX owner;
-#endif
- ptable *seen; /* It really is a ptable_seen */
- SV *default_meth;
-} my_cxt_t;
-
-START_MY_CXT
-
-/* ... Cloning global data ................................................. */
-
-#if LT_THREADSAFE
-
-typedef struct {
- ptable *tbl;
-#if LT_HAS_PERL(5, 13, 2)
- CLONE_PARAMS *params;
-#else
- CLONE_PARAMS params;
-#endif
-} lt_ptable_clone_ud;
-
-#if LT_HAS_PERL(5, 13, 2)
-# define lt_ptable_clone_ud_init(U, T, O) \
- (U).tbl = (T); \
- (U).params = Perl_clone_params_new((O), aTHX)
-# define lt_ptable_clone_ud_deinit(U) Perl_clone_params_del((U).params)
-# define lt_dup_inc(S, U) SvREFCNT_inc(sv_dup((S), (U)->params))
-#else
-# define lt_ptable_clone_ud_init(U, T, O) \
- (U).tbl = (T); \
- (U).params.stashes = newAV(); \
- (U).params.flags = 0; \
- (U).params.proto_perl = (O)
-# define lt_ptable_clone_ud_deinit(U) SvREFCNT_dec((U).params.stashes)
-# define lt_dup_inc(S, U) SvREFCNT_inc(sv_dup((S), &((U)->params)))
-#endif
-
-STATIC void lt_ptable_clone(pTHX_ ptable_ent *ent, void *ud_) {
- lt_ptable_clone_ud *ud = ud_;
- lt_hint_t *h1 = ent->val;
- lt_hint_t *h2;
-
-#if LT_HINT_STRUCT
-
- h2 = PerlMemShared_malloc(sizeof *h2);
- h2->code = lt_dup_inc(h1->code, ud);
-#if LT_WORKAROUND_REQUIRE_PROPAGATION
- h2->require_tag = PTR2IV(lt_dup_inc(INT2PTR(SV *, h1->require_tag), ud));
-#endif
-
-#else /* LT_HINT_STRUCT */
-
- h2 = lt_dup_inc(h1, ud);
-
-#endif /* !LT_HINT_STRUCT */
-
- ptable_hints_store(ud->tbl, ent->key, h2);
-}
-
-STATIC void lt_thread_cleanup(pTHX_ void *ud) {
- dMY_CXT;
-
- ptable_hints_free(MY_CXT.tbl);
- MY_CXT.tbl = NULL;
- ptable_seen_free(MY_CXT.seen);
- MY_CXT.seen = NULL;
- SvREFCNT_dec(MY_CXT.default_meth);
- MY_CXT.default_meth = NULL;
-}
-
-STATIC int lt_endav_free(pTHX_ SV *sv, MAGIC *mg) {
- SAVEDESTRUCTOR_X(lt_thread_cleanup, NULL);
-
- return 0;
-}
-
-STATIC MGVTBL lt_endav_vtbl = {
- 0,
- 0,
- 0,
- 0,
- lt_endav_free
-#if MGf_COPY
- , 0
-#endif
-#if MGf_DUP
- , 0
-#endif
-#if MGf_LOCAL
- , 0
-#endif
-};