dougm 2002/06/15 18:07:21 Added: src/modules/perl modperl_perl_pp.c modperl_perl_pp.h Log: new module where any PL_ppaddr modifications are done Revision Changes Path 1.1 modperl-2.0/src/modules/perl/modperl_perl_pp.c Index: modperl_perl_pp.c =================================================================== #include "mod_perl.h" static enum opcode MP_pp_map[] = { #ifdef MP_REFGEN_FIXUP OP_SREFGEN, #endif }; typedef OP * MP_FUNC_T(modperl_pp_t)(pTHX); static modperl_pp_t MP_PERL_ppaddr[MP_OP_max]; #ifdef MP_REFGEN_FIXUP /* * nasty workaround for bug fixed in bleedperl (11536 + 11553) * XXX: when 5.8.0 is released + stable, we will require 5.8.0 * if ithreads are enabled. */ static OP *modperl_pp_srefgen(pTHX) { dSP; OP *o; SV *sv = *SP; if (SvPADTMP(sv) && IS_PADGV(sv)) { /* prevent S_refto from making a copy of the GV, * tricking it to SvREFCNT_inc and point to this one instead. */ SvPADTMP_off(sv); } else { sv = Nullsv; } /* o = Perl_pp_srefgen(aTHX) */ o = MP_PERL_ppaddr[MP_OP_SREFGEN](aTHX); if (sv) { /* restore original flags */ SvPADTMP_on(sv); } return o; } #endif /* MP_REFGEN_FIXUP */ static modperl_pp_t MP_ppaddr[] = { #ifdef MP_REFGEN_FIXUP MEMBER_TO_FPTR(modperl_pp_srefgen), #endif }; void modperl_perl_pp_set(modperl_perl_opcode_e idx) { int pl_idx = MP_pp_map[idx]; /* save original */ MP_PERL_ppaddr[idx] = PL_ppaddr[pl_idx]; /* replace with our own */ PL_ppaddr[pl_idx] = MP_ppaddr[idx]; } void modperl_perl_pp_set_all(void) { int i; for (i=0; i<MP_OP_max; i++) { modperl_perl_pp_set(i); } } void modperl_perl_pp_unset(modperl_perl_opcode_e idx) { int pl_idx = MP_pp_map[idx]; /* restore original */ PL_ppaddr[pl_idx] = MP_PERL_ppaddr[idx]; } void modperl_perl_pp_unset_all(void) { int i; for (i=0; i<MP_OP_max; i++) { modperl_perl_pp_unset(i); } } 1.1 modperl-2.0/src/modules/perl/modperl_perl_pp.h Index: modperl_perl_pp.h =================================================================== #ifndef MODPERL_PERL_PP_H #define MODPERL_PERL_PP_H #if defined(USE_ITHREADS) && defined(MP_PERL_5_6_x) # define MP_REFGEN_FIXUP #endif typedef enum { #ifdef MP_REFGEN_FIXUP MP_OP_SREFGEN, #endif MP_OP_max } modperl_perl_opcode_e; void modperl_perl_pp_set(modperl_perl_opcode_e idx); void modperl_perl_pp_set_all(void); void modperl_perl_pp_unset(modperl_perl_opcode_e idx); void modperl_perl_pp_unset_all(void); #endif /* MODPERL_PERL_PP_H */