+#define __PACKAGE__ "re::engine::Plugin"
+#define __PACKAGE_LEN__ (sizeof(__PACKAGE__)-1)
+
+#define REP_HAS_PERL(R, V, S) (PERL_REVISION > (R) || (PERL_REVISION == (R) && (PERL_VERSION > (V) || (PERL_VERSION == (V) && (PERL_SUBVERSION >= (S))))))
+
+#ifndef REP_WORKAROUND_REQUIRE_PROPAGATION
+# define REP_WORKAROUND_REQUIRE_PROPAGATION !REP_HAS_PERL(5, 10, 1)
+#endif
+
+/* ... Thread safety and multiplicity ...................................... */
+
+/* Safe unless stated otherwise in Makefile.PL */
+#ifndef REP_FORKSAFE
+# define REP_FORKSAFE 1
+#endif
+
+#ifndef REP_MULTIPLICITY
+# if defined(MULTIPLICITY) || defined(PERL_IMPLICIT_CONTEXT)
+# define REP_MULTIPLICITY 1
+# else
+# define REP_MULTIPLICITY 0
+# endif
+#endif
+#if REP_MULTIPLICITY && !defined(tTHX)
+# define tTHX PerlInterpreter*
+#endif
+
+#if REP_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 REP_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 REP_THREADSAFE 0
+# undef dMY_CXT
+# define dMY_CXT dNOOP
+# undef MY_CXT
+# define MY_CXT rep_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
+
+/* --- Helpers ------------------------------------------------------------- */
+
+/* ... Thread-safe hints ................................................... */
+
+typedef struct {
+ SV *comp;
+ SV *exec;
+#if REP_WORKAROUND_REQUIRE_PROPAGATION
+ IV require_tag;
+#endif
+} rep_hint_t;
+
+#if REP_THREADSAFE
+
+#define PTABLE_VAL_FREE(V) { \
+ rep_hint_t *h = (V); \
+ SvREFCNT_dec(h->comp); \
+ SvREFCNT_dec(h->exec); \
+ PerlMemShared_free(h); \
+}