-static void lt_ck_restore(pTHX_ OPCODE type, lt_ck_t *old_ck_p) {
-#define lt_ck_restore(T, OCP) lt_ck_restore(aTHX_ (T), (OCP))
- LT_CHECK_LOCK;
- if (*old_ck_p) {
- PL_check[type] = *old_ck_p;
- *old_ck_p = 0;
- }
- LT_CHECK_UNLOCK;
-}
-
-/* --- Helpers ------------------------------------------------------------- */
-
-/* ... Check if the module is loaded ....................................... */
-
-static I32 lt_loaded = 0;
-
-#if LT_THREADSAFE
-
-#define PTABLE_NAME ptable_loaded
-#define PTABLE_NEED_DELETE 1
-#define PTABLE_NEED_WALK 0
-
-#include "ptable.h"
-
-#define ptable_loaded_store(T, K, V) ptable_loaded_store(aPTBLMS_ (T), (K), (V))
-#define ptable_loaded_delete(T, K) ptable_loaded_delete(aPTBLMS_ (T), (K))
-#define ptable_loaded_free(T) ptable_loaded_free(aPTBLMS_ (T))
-
-static ptable *lt_loaded_cxts = NULL;
-
-#ifdef DEBUGGING
-
-static int lt_is_loaded(pTHX_ void *cxt) {
-#define lt_is_loaded(C) lt_is_loaded(aTHX_ (C))
- int res = 0;
-
- LT_LOADED_LOCK;
- if (lt_loaded_cxts && ptable_fetch(lt_loaded_cxts, cxt))
- res = 1;
- LT_LOADED_UNLOCK;
-
- return res;
-}
-
-#endif /* DEBUGGING */
-
-static int lt_set_loaded_locked(pTHX_ void *cxt) {
-#define lt_set_loaded_locked(C) lt_set_loaded_locked(aTHX_ (C))
- int global_setup = 0;
-
- if (lt_loaded <= 0) {
- LT_ASSERT(lt_loaded == 0);
- LT_ASSERT(!lt_loaded_cxts);
- lt_loaded_cxts = ptable_new();
- global_setup = 1;
- }
- ++lt_loaded;
- LT_ASSERT(lt_loaded_cxts);
- ptable_loaded_store(lt_loaded_cxts, cxt, cxt);
-
- return global_setup;
-}
-
-static int lt_clear_loaded_locked(pTHX_ void *cxt) {
-#define lt_clear_loaded_locked(C) lt_clear_loaded_locked(aTHX_ (C))
- int global_teardown = 0;
-
- if (lt_loaded > 1) {
- LT_ASSERT(lt_loaded_cxts);
- ptable_loaded_delete(lt_loaded_cxts, cxt);
- --lt_loaded;
- } else if (lt_loaded_cxts) {
- LT_ASSERT(lt_loaded == 1);
- ptable_loaded_free(lt_loaded_cxts);
- lt_loaded_cxts = NULL;
- lt_loaded = 0;
- global_teardown = 1;
- }
-
- return global_teardown;
-}
-
-#else
-
-#define lt_is_loaded(C) (lt_loaded > 0)
-#define lt_set_loaded_locked(C) ((lt_loaded++ <= 0) ? 1 : 0)
-#define lt_clear_loaded_locked(C) ((--lt_loaded <= 0) ? 1 : 0)
-
-#endif
-
-/* ... Thread-safe hints ................................................... */
-
-#if LT_WORKAROUND_REQUIRE_PROPAGATION
-
-typedef struct {
- 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 PTABLE_NEED_DELETE 0
-#define PTABLE_NEED_WALK 1
-
-#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_NEED_DELETE 0
-#define PTABLE_NEED_WALK 0
-
-#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 {
- peep_t old_peep;
- ptable *seen; /* It really is a ptable_seen */
-#if LT_THREADSAFE
- ptable *tbl; /* It really is a ptable_hints */
- tTHX owner;
-#endif
- SV *default_meth;
-} my_cxt_t;