On Thu, 24 Jan 2008, Philippe M. Chiasson wrote:
[ ... ]
Following is a patch (probably will change some more before I am done) that
gets rid of this hacking attribute handling and passes it around with magic.
Great work! And thanks for the explanations :)
I've applied a modified version of this patch (attached)
to Win32 ActivePerl 5.10 (build 1002) with Apache/2.2.8;
there's some problems with the t/perl/ithreads*.t tests,
which I'll look at more carefully, but all the filter
tests now pass.
The changes I made to your original patch are:
- change the name of mp_code_attrs to modperl_code_attrs,
as the modperl_ prefix is used for the other functions
that go into mod_perl.so
- add modperl_code_attrs to ModPerl::FunctionTable,
so that it's added to modperl.def (Win32 needs this
to include the functions in mod_perl.so)
- add a (CV*) cast in MP_CODE_ATTRS in
src/modules/perl/mod_perl.h, to avoid a warning
when compiling Apache2::Filter
--
best regards,
Randy
Index: src/modules/perl/mod_perl.h
===================================================================
--- src/modules/perl/mod_perl.h (revision 615116)
+++ src/modules/perl/mod_perl.h (working copy)
@@ -141,7 +141,8 @@
/* betting on Perl*Handlers not using CvXSUBANY
* mod_perl reuses this field for handler attributes
*/
-#define MP_CODE_ATTRS(cv) (CvXSUBANY((CV*)cv).any_i32)
+U16 *modperl_code_attrs(pTHX_ CV *cv);
+#define MP_CODE_ATTRS(cv) (*modperl_code_attrs(aTHX_ (CV*)cv))
#define MgTypeExt(mg) (mg->mg_type == '~')
Index: src/modules/perl/modperl_mgv.c
===================================================================
--- src/modules/perl/modperl_mgv.c (revision 615116)
+++ src/modules/perl/modperl_mgv.c (working copy)
@@ -271,7 +271,7 @@
}
else {
if ((cv = get_cv(name, FALSE))) {
- handler->attrs = (U32)MP_CODE_ATTRS(cv);
+ handler->attrs = MP_CODE_ATTRS(cv);
handler->mgv_cv =
modperl_mgv_compile(aTHX_ p, HvNAME(GvSTASH(CvGV(cv))));
modperl_mgv_append(aTHX_ p, handler->mgv_cv, GvNAME(CvGV(cv)));
@@ -334,7 +334,7 @@
modperl_mgv_new_name(handler->mgv_obj, p, name);
}
- handler->attrs = (U32)MP_CODE_ATTRS(cv);
+ handler->attrs = MP_CODE_ATTRS(cv);
/* note: this is the real function after @ISA lookup */
handler->mgv_cv = modperl_mgv_compile(aTHX_ p, HvNAME(GvSTASH(gv)));
modperl_mgv_append(aTHX_ p, handler->mgv_cv, handler_name);
Index: src/modules/perl/modperl_types.h
===================================================================
--- src/modules/perl/modperl_types.h (revision 615116)
+++ src/modules/perl/modperl_types.h (working copy)
@@ -195,7 +195,7 @@
const char *name;
CV *cv;
U8 flags;
- U32 attrs;
+ U16 attrs;
modperl_handler_t *next;
};
Index: src/modules/perl/modperl_util.c
===================================================================
--- src/modules/perl/modperl_util.c (revision 615116)
+++ src/modules/perl/modperl_util.c (working copy)
@@ -899,3 +899,14 @@
}
return newRV_inc((SV *)*pnotes);
}
+
+U16 *modperl_code_attrs(pTHX_ CV *cv) {
+ MAGIC *mg;
+
+ if (!SvMAGICAL(cv)) {
+ sv_magic((SV*)cv, Nullsv, PERL_MAGIC_ext, NULL, -1);
+ }
+
+ mg = mg_find((SV*)cv, PERL_MAGIC_ext);
+ return &(mg->mg_private);
+}
Index: xs/Apache2/Filter/Apache2__Filter.h
===================================================================
--- xs/Apache2/Filter/Apache2__Filter.h (revision 615112)
+++ xs/Apache2/Filter/Apache2__Filter.h (working copy)
@@ -86,9 +86,9 @@
return len;
}
-static MP_INLINE U32 *modperl_filter_attributes(SV *package, SV *cvrv)
+static MP_INLINE U16 *modperl_filter_attributes(pTHX_ SV *package, SV *cvrv)
{
- return (U32 *)&MP_CODE_ATTRS(SvRV(cvrv));
+ return &MP_CODE_ATTRS(SvRV(cvrv));
}
#ifdef MP_TRACE
@@ -118,7 +118,7 @@
MP_STATIC XS(MPXS_modperl_filter_attributes)
{
dXSARGS;
- U32 *attrs = modperl_filter_attributes(ST(0), ST(1));
+ U16 *attrs = modperl_filter_attributes(aTHX_ ST(0), ST(1));
I32 i;
#ifdef MP_TRACE
HV *stash = gv_stashsv(ST(0), TRUE);
Index: xs/tables/current/ModPerl/FunctionTable.pm
===================================================================
--- xs/tables/current/ModPerl/FunctionTable.pm (revision 615431)
+++ xs/tables/current/ModPerl/FunctionTable.pm (working copy)
@@ -1239,6 +1239,20 @@
]
},
{
+ 'return_type' => 'U16 *',
+ 'name' => 'modperl_code_attrs',
+ 'args' => [
+ {
+ 'type' => 'PerlInterpreter *',
+ 'name' => 'my_perl'
+ },
+ {
+ 'type' => 'CV *',
+ 'name' => 'cv'
+ }
+ ]
+ },
+ {
'return_type' => 'int',
'name' => 'modperl_config_apply_PerlModule',
'args' => [
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]