-#if I_MULTIPLICITY && !defined(tTHX)
-# define tTHX PerlInterpreter*
-#endif
-
-#if I_MULTIPLICITY && defined(USE_ITHREADS) && defined(dMY_CXT) && defined(MY_CXT) && defined(START_MY_CXT) && defined(MY_CXT_INIT) && (defined(MY_CXT_CLONE) || defined(dMY_CXT_SV))
-# define I_THREADSAFE 1
-# ifndef MY_CXT_CLONE
-# define MY_CXT_CLONE \
- dMY_CXT_SV; \
- my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1)); \
- Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t); \
- sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
-# endif
-#else
-# define I_THREADSAFE 0
-# undef dMY_CXT
-# define dMY_CXT dNOOP
-# undef MY_CXT
-# define MY_CXT indirect_globaldata
-# undef START_MY_CXT
-# define START_MY_CXT STATIC my_cxt_t MY_CXT;
-# undef MY_CXT_INIT
-# define MY_CXT_INIT NOOP
-# undef MY_CXT_CLONE
-# define MY_CXT_CLONE NOOP
-#endif
-
-#if defined(OP_CHECK_MUTEX_LOCK) && defined(OP_CHECK_MUTEX_UNLOCK)
-# define I_CHECK_MUTEX_LOCK OP_CHECK_MUTEX_LOCK
-# define I_CHECK_MUTEX_UNLOCK OP_CHECK_MUTEX_UNLOCK
-#else
-# define I_CHECK_MUTEX_LOCK OP_REFCNT_LOCK
-# define I_CHECK_MUTEX_UNLOCK OP_REFCNT_UNLOCK
-#endif
-
-typedef OP *(*indirect_ck_t)(pTHX_ OP *);
-
-#ifdef wrap_op_checker
-
-# define indirect_ck_replace(T, NC, OCP) wrap_op_checker((T), (NC), (OCP))
-
-#else
-
-STATIC void indirect_ck_replace(pTHX_ OPCODE type, indirect_ck_t new_ck, indirect_ck_t *old_ck_p) {
-#define indirect_ck_replace(T, NC, OCP) indirect_ck_replace(aTHX_ (T), (NC), (OCP))
- I_CHECK_MUTEX_LOCK;
- if (!*old_ck_p) {
- *old_ck_p = PL_check[type];
- PL_check[type] = new_ck;
- }
- I_CHECK_MUTEX_UNLOCK;
-}
-
-#endif
-
-STATIC void indirect_ck_restore(pTHX_ OPCODE type, indirect_ck_t *old_ck_p) {
-#define indirect_ck_restore(T, OCP) indirect_ck_restore(aTHX_ (T), (OCP))
- I_CHECK_MUTEX_LOCK;
- if (*old_ck_p) {
- PL_check[type] = *old_ck_p;
- *old_ck_p = 0;
- }
- I_CHECK_MUTEX_UNLOCK;
-}
-
-/* --- Helpers ------------------------------------------------------------- */
-
-/* ... Thread-safe hints ................................................... */
-
-#if I_WORKAROUND_REQUIRE_PROPAGATION
-
-typedef struct {
- SV *code;
- IV require_tag;
-} indirect_hint_t;
-
-#define I_HINT_STRUCT 1
-
-#define I_HINT_CODE(H) ((H)->code)
-
-#define I_HINT_FREE(H) { \
- indirect_hint_t *h = (H); \
- SvREFCNT_dec(h->code); \
- PerlMemShared_free(h); \
-}
-
-#else /* I_WORKAROUND_REQUIRE_PROPAGATION */
-
-typedef SV indirect_hint_t;
-
-#define I_HINT_STRUCT 0
-
-#define I_HINT_CODE(H) (H)
-
-#define I_HINT_FREE(H) SvREFCNT_dec(H);
-
-#endif /* !I_WORKAROUND_REQUIRE_PROPAGATION */
-
-#if I_THREADSAFE
-
-#define PTABLE_NAME ptable_hints
-#define PTABLE_VAL_FREE(V) I_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 /* I_THREADSAFE */
-
-/* Define the op->str ptable here because we need to be able to clean it during
- * thread cleanup. */
-
-typedef struct {
- char *buf;
- STRLEN pos;
- STRLEN size;
- STRLEN len;
- line_t line;
-} indirect_op_info_t;
-
-#define PTABLE_NAME ptable
-#define PTABLE_VAL_FREE(V) if (V) { Safefree(((indirect_op_info_t *) (V))->buf); Safefree(V); }
-
-#define pPTBL pTHX
-#define pPTBL_ pTHX_
-#define aPTBL aTHX
-#define aPTBL_ aTHX_
-
-#include "ptable.h"
-
-#define ptable_store(T, K, V) ptable_store(aTHX_ (T), (K), (V))
-#define ptable_delete(T, K) ptable_delete(aTHX_ (T), (K))
-#define ptable_clear(T) ptable_clear(aTHX_ (T))
-#define ptable_free(T) ptable_free(aTHX_ (T))
-
-#define MY_CXT_KEY __PACKAGE__ "::_guts" XS_VERSION
-
-typedef struct {
-#if I_THREADSAFE
- ptable *tbl; /* It really is a ptable_hints */
- tTHX owner;
-#endif
- ptable *map;
- SV *global_code;
-} my_cxt_t;