Philippe M. Chiasson wrote:
I've just tried building against a 64bitint perl-5.8.4, and there were quite a few
places were we were making assumptions that sizeof(int) == sizeof(pointer).
This patches tries to use INT2PTR and PTR2(IV|UV) where appropriate. This patch
passes all tests ok on perl-5.8.4 with and without 64bitint.
The INT2PTR is confusing, since it passes the type first and then the int :(
INT2PTR(PTR_TBL_t *, SvIV(sv));
But looks good (it's a perl macro after all).
I guess it isn't 100% clear, true, so how about adding:
#define MP_INT2PTR(int, type) INT2PTR(type, int)
However what this part of the patch has to do with the above comment?
> Index: xs/typemap > =================================================================== > --- xs/typemap (revision 126447) > +++ xs/typemap (working copy) > @@ -17,6 +17,9 @@ > T_VPTR > sv_setiv($arg, PTR2IV($var)); > > +T_UVPTR > + sv_setuv($arg, PTR2UV($var)); > +
> +T_UVPTR > + $var = INT2PTR($type, SvUV(SvROK($arg) ? SvRV($arg) : $arg)) > +
> Index: lib/ModPerl/WrapXS.pm > =================================================================== > --- lib/ModPerl/WrapXS.pm (revision 126447) > +++ lib/ModPerl/WrapXS.pm (working copy) > @@ -620,6 +620,7 @@ > 'apr_time_t' => 'T_APR_TIME', > 'APR::Table' => 'T_HASHOBJ', > 'APR::Pool' => 'T_POOLOBJ', > + 'apr_size_t *' => 'T_UVPTR', > ); > > sub write_typemap {
I don't see us using 'apr_size_t *' anywhere... in any case should probably be a separate commit :)
It's autogenerated, but a good example will be in WrapXS/APR/Socket/
apr_status_t
apr_socket_recvfrom(from, sock, flags, buf, len)
APR::SockAddr from
APR::Socket sock
apr_int32_t flags
char * buf
apr_size_t * lenFor instance, and there are a few more just in that one, apr_socket_sendto(), apr_socket_recvfrom(). The other one is apr_password_get().
All these take an apr_size_t * as argument, and previously, we were just letting default typemap entries do the job. but that's no good, if 64bit ints is on. You end up with generated code like this:
apr_size_t *len = (apr_size_t *)SvUV(ST(4));
and really, it should be
apr_size_t *len = INT2PTR(SvUV(ST(4)), apr_size_t *);
I've stumbled on all these just by trying to build against a 64bitint perl and fixing things until all built with no warnings. Then all test passed ;-)
-------------------------------------------------------------------------------- Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5 http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5
signature.asc
Description: OpenPGP digital signature
