diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-06-05 14:41:25 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-06-05 20:30:08 -0700 |
commit | a60c099b83a336be6df44b89eb468b0cdfe351ca (patch) | |
tree | 31b610b9c6dc7110440b05b7bb23187f5d694755 /ext | |
parent | ee39f343efffd64e53e2d8282afa1cb99a1b7dcd (diff) | |
download | perl-a60c099b83a336be6df44b89eb468b0cdfe351ca.tar.gz |
Change B::COP::stashlen to stashoff
This was brought up in ticket #78742.
The stashlen method has never been in a stable release, and no longer
exists, as of d4d03940c, since it is dependent on a define that
d4d03940c removed.
So this commit removes stashlen from B.xs and adds stashoff in its
place, since this is what B::C needs.
It also adds a few basic tests for the stash and stashpv methods.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/B/B.pm | 2 | ||||
-rw-r--r-- | ext/B/B.xs | 19 | ||||
-rw-r--r-- | ext/B/t/b.t | 8 |
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(); |