# define aMY_CXT_
#endif
+#if defined(OP_CHECK_MUTEX_LOCK) && defined(OP_CHECK_MUTEX_UNLOCK)
+# define LT_CHECK_MUTEX_LOCK OP_CHECK_MUTEX_LOCK
+# define LT_CHECK_MUTEX_UNLOCK OP_CHECK_MUTEX_UNLOCK
+#else
+# define LT_CHECK_MUTEX_LOCK OP_REFCNT_LOCK
+# define LT_CHECK_MUTEX_UNLOCK OP_REFCNT_UNLOCK
+#endif
+
+typedef OP *(*lt_ck_t)(pTHX_ OP *);
+
+#ifdef wrap_op_checker
+
+# define lt_ck_replace(T, NC, OCP) wrap_op_checker((T), (NC), (OCP))
+
+#else
+
+STATIC void lt_ck_replace(pTHX_ OPCODE type, lt_ck_t new_ck, lt_ck_t *old_ck_p){
+#define lt_ck_replace(T, NC, OCP) lt_ck_replace(aTHX_ (T), (NC), (OCP))
+ LT_CHECK_MUTEX_LOCK;
+ if (!*old_ck_p) {
+ *old_ck_p = PL_check[type];
+ PL_check[type] = new_ck;
+ }
+ LT_CHECK_MUTEX_UNLOCK;
+}
+
+#endif
+
+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_MUTEX_LOCK;
+ if (*old_ck_p) {
+ PL_check[type] = *old_ck_p;
+ *old_ck_p = 0;
+ }
+ LT_CHECK_MUTEX_UNLOCK;
+}
+
/* --- Helpers ------------------------------------------------------------- */
/* ... Thread-safe hints ................................................... */
SvREFCNT_dec(MY_CXT.default_meth);
}
- PL_check[OP_PADANY] = MEMBER_TO_FPTR(lt_old_ck_padany);
- lt_old_ck_padany = 0;
- PL_check[OP_PADSV] = MEMBER_TO_FPTR(lt_old_ck_padsv);
- lt_old_ck_padsv = 0;
+ lt_ck_restore(OP_PADANY, <_old_ck_padany);
+ lt_ck_restore(OP_PADSV, <_old_ck_padsv);
#if LT_HAS_RPEEP
PL_rpeepp = lt_old_peep;
SvREADONLY_on(MY_CXT.default_meth);
}
- lt_old_ck_padany = PL_check[OP_PADANY];
- PL_check[OP_PADANY] = MEMBER_TO_FPTR(lt_ck_padany);
- lt_old_ck_padsv = PL_check[OP_PADSV];
- PL_check[OP_PADSV] = MEMBER_TO_FPTR(lt_ck_padsv);
+ lt_ck_replace(OP_PADANY, lt_ck_padany, <_old_ck_padany);
+ lt_ck_replace(OP_PADSV, lt_ck_padsv, <_old_ck_padsv);
#if LT_HAS_RPEEP
lt_old_peep = PL_rpeepp;