summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/B/B.pm2
-rw-r--r--ext/B/B.xs19
-rw-r--r--ext/B/t/b.t8
3 files changed, 16 insertions, 13 deletions
diff --git a/ext/B/B.pm b/ext/B/B.pm
index d7a5cdf256..1dcaf997b2 100644
--- a/ext/B/B.pm
+++ b/ext/B/B.pm
@@ -1213,7 +1213,7 @@ Only when perl was compiled with ithreads.
=item stashpv
-=item stashlen
+=item stashoff (threaded only)
=item file
diff --git a/ext/B/B.xs b/ext/B/B.xs
index 69fc6bb374..80bd0f9eb3 100644
--- a/ext/B/B.xs
+++ b/ext/B/B.xs
@@ -885,6 +885,7 @@ threadsv_names()
#ifdef USE_ITHREADS
#define COP_stashpv_ix char_pp | offsetof(struct cop, cop_stashpv)
+#define COP_stashoff_ix PADOFFSETp | offsetof(struct cop, cop_stashoff)
#define COP_file_ix char_pp | offsetof(struct cop, cop_file)
#else
#define COP_stash_ix SVp | offsetof(struct cop, cop_stash)
@@ -1163,11 +1164,16 @@ BOOT:
#ifdef USE_ITHREADS
cv = newXS("B::PMOP::pmoffset", XS_B__OP_next, __FILE__);
XSANY.any_i32 = PMOP_pmoffset_ix;
-# if PERL_VERSION >= 17 && defined(CopSTASH_len)
+# if PERL_VERSION >= 17
+# ifdef CopSTASH_len
cv = newXS("B::COP::stashpv", XS_B__OP_next, __FILE__);
XSANY.any_i32 = COP_stashpv_ix;
cv = newXS("B::COP::file", XS_B__OP_next, __FILE__);
XSANY.any_i32 = COP_file_ix;
+# else
+ cv = newXS("B::COP::stashoff", XS_B__OP_next, __FILE__);
+ XSANY.any_i32 = COP_stashoff_ix;
+# endif
# endif
#else
cv = newXS("B::COP::stash", XS_B__OP_next, __FILE__);
@@ -1229,9 +1235,6 @@ pv(o)
ST(0) = newSVpvn_flags(o->op_pv, strlen(o->op_pv), SVs_TEMP);
#define COP_label(o) CopLABEL(o)
-#ifdef CopSTASH_len
-#define COP_stashlen(o) CopSTASH_len(o)
-#endif
MODULE = B PACKAGE = B::COP PREFIX = COP_
@@ -1255,14 +1258,6 @@ COP_stash(o)
PUSHs(make_sv_object(aTHX_
ix ? (SV *)CopFILEGV(o) : (SV *)CopSTASH(o)));
-#ifdef CopSTASH_len
-
-U32
-COP_stashlen(o)
- B::COP o
-
-#endif
-
#endif
#if !defined(USE_ITHREADS) || (PERL_VERSION > 16 && !defined(CopSTASH_len))
diff --git a/ext/B/t/b.t b/ext/B/t/b.t
index 2534c279a1..d046885471 100644
--- a/ext/B/t/b.t
+++ b/ext/B/t/b.t
@@ -295,4 +295,12 @@ foo
can_ok $f, 'LINES';
}
+my $sub1 = sub {die};
+my $cop = B::svref_2object($sub1)->ROOT->first->first;
+is $cop->stash->object_2svref, \%main::, 'COP->stash';
+is $cop->stashpv, 'main', 'COP->stashpv';
+if ($Config::Config{useithreads}) {
+ like $cop->stashoff, qr/^[1-9]\d*\z/a, 'COP->stashoff'
+}
+
done_testing();