# define MY_CXT_CLONE NOOP
#endif
+#if defined(OP_CHECK_MUTEX_LOCK) && defined(OP_CHECK_MUTEX_UNLOCK)
+# define SO_CHECK_MUTEX_LOCK OP_CHECK_MUTEX_LOCK
+# define SO_CHECK_MUTEX_UNLOCK OP_CHECK_MUTEX_UNLOCK
+#else
+# define SO_CHECK_MUTEX_LOCK OP_REFCNT_LOCK
+# define SO_CHECK_MUTEX_UNLOCK OP_REFCNT_UNLOCK
+#endif
+
+typedef OP *(*so_ck_t)(pTHX_ OP *);
+
+#ifdef wrap_op_checker
+
+# define so_ck_replace(T, NC, OCP) wrap_op_checker((T), (NC), (OCP))
+
+#else
+
+STATIC void so_ck_replace(pTHX_ OPCODE type, so_ck_t new_ck, so_ck_t *old_ck_p){
+#define so_ck_replace(T, NC, OCP) so_ck_replace(aTHX_ (T), (NC), (OCP))
+ SO_CHECK_MUTEX_LOCK;
+ if (!*old_ck_p) {
+ *old_ck_p = PL_check[type];
+ PL_check[type] = new_ck;
+ }
+ SO_CHECK_MUTEX_UNLOCK;
+}
+
+#endif
+
+STATIC void so_ck_restore(pTHX_ OPCODE type, so_ck_t *old_ck_p) {
+#define so_ck_restore(T, OCP) so_ck_restore(aTHX_ (T), (OCP))
+ SO_CHECK_MUTEX_LOCK;
+ if (*old_ck_p) {
+ PL_check[type] = *old_ck_p;
+ *old_ck_p = 0;
+ }
+ SO_CHECK_MUTEX_UNLOCK;
+}
+
/* --- Global data --------------------------------------------------------- */
#define MY_CXT_KEY __PACKAGE__ "::_guts" XS_VERSION
MY_CXT.owner = aTHX;
#endif /* SO_THREADSAFE */
- so_old_ck_entersub = PL_check[OP_ENTERSUB];
- PL_check[OP_ENTERSUB] = so_ck_entersub;
- so_old_ck_refgen = PL_check[OP_REFGEN];
- PL_check[OP_REFGEN] = so_ck_refgen;
- so_old_ck_gelem = PL_check[OP_GELEM];
- PL_check[OP_GELEM] = so_ck_gelem;
+ so_ck_replace(OP_ENTERSUB, so_ck_entersub, &so_old_ck_entersub);
+ so_ck_replace(OP_REFGEN, so_ck_refgen, &so_old_ck_refgen);
+ so_ck_replace(OP_GELEM, so_ck_gelem, &so_old_ck_gelem);
}
#if SO_THREADSAFE