develooper Front page | perl.perl5.porters | Postings from November 2014

commit "rename sTHX to PERL_MEMORY_DEBUG_HEADER_SIZE" broke my code

From:
bulk88
Date:
November 18, 2014 23:49
Subject:
commit "rename sTHX to PERL_MEMORY_DEBUG_HEADER_SIZE" broke my code
Message ID:
20141118234854.25601.qmail@lists-nntp.develooper.com
Today I found out in some darkpan code of mine, 
http://perl5.git.perl.org/perl.git/commitdiff/a78adc844d26a047e6547bbc893c9116171ba840 
  broke my code in 5.20.0. Since it isn't public API, i can't really 
complain. Fixed version below. This is part of some code that creates a 
high performance lock free function call free access from C to the IVs 
in "threads::shared" SVIVs. "usedSV" is either from the inner secret 
interpreter in threads::shared or in a process without threads::shared, 
a normal unshared SV *. "threads::shared" does export/have any API to 
get the secret inner THX so this hack works.

#ifdef PERL_TRACK_MEMPOOL
             tTHX origInterp = aTHX;
             struct perl_memory_debug_header * header;
#if (PERL_BCDVERSION < 0x5019008)
             header = (struct perl_memory_debug_header *)(((char 
*)SvPVX(usedSV)) - sTHX);
#else
             header = (struct perl_memory_debug_header *)(((char 
*)SvPVX(usedSV)) - PERL_MEMORY_DEBUG_HEADER_SIZE);
#endif
             PERL_SET_CONTEXT(aTHX = header->interpreter);
#endif
             mg = sv_magicext(usedSV, NULL, PERL_MAGIC_ext,  &freevtbl, 
&(((GFStrt *)&GlobalFlags)[i]), 0);
             ((GFStrt *)&GlobalFlags)[i].flagPtr = &(SvIVX(usedSV));
#ifdef PERL_TRACK_MEMPOOL
             PERL_SET_CONTEXT(aTHX = origInterp);
#endif



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About