-#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 I_THREADSAFE
-/* We must use preexistent global mutexes or we will never be able to destroy
- * them. */
-# if I_HAS_PERL(5, 9, 3)
-# define I_LOADED_LOCK MUTEX_LOCK(&PL_my_ctx_mutex)
-# define I_LOADED_UNLOCK MUTEX_UNLOCK(&PL_my_ctx_mutex)
-# else
-# define I_LOADED_LOCK OP_REFCNT_LOCK
-# define I_LOADED_UNLOCK OP_REFCNT_UNLOCK
-# endif
-#else
-# define I_LOADED_LOCK NOOP
-# define I_LOADED_UNLOCK NOOP
-#endif
-
-#if defined(OP_CHECK_MUTEX_LOCK) && defined(OP_CHECK_MUTEX_UNLOCK)
-# define I_CHECK_LOCK OP_CHECK_MUTEX_LOCK
-# define I_CHECK_UNLOCK OP_CHECK_MUTEX_UNLOCK
-#elif I_HAS_PERL(5, 9, 3)
-# define I_CHECK_LOCK OP_REFCNT_LOCK
-# define I_CHECK_UNLOCK OP_REFCNT_UNLOCK
-#else
-/* Before perl 5.9.3, indirect_ck_*() calls are already protected by the
- * I_LOADED mutex, which falls back to the OP_REFCNT mutex. Make sure we don't
- * lock it twice. */
-# define I_CHECK_LOCK NOOP
-# define I_CHECK_UNLOCK NOOP
-#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_LOCK;
- if (!*old_ck_p) {
- *old_ck_p = PL_check[type];
- PL_check[type] = new_ck;
- }
- I_CHECK_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_LOCK;
- if (*old_ck_p) {
- PL_check[type] = *old_ck_p;
- *old_ck_p = 0;
- }
- I_CHECK_UNLOCK;
-}
-
-/* --- Helpers ------------------------------------------------------------- */
-
-/* ... Check if the module is loaded ....................................... */
-
-static I32 indirect_loaded = 0;
-
-#if I_THREADSAFE
-
-#define PTABLE_NAME ptable_loaded
-#define PTABLE_VAL_FREE(V) NOOP
-
-#include "ptable.h"