Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^16: supporting quads on 32 bit Perl

by salva (Abbot)
on Jun 03, 2012 at 18:33 UTC ( #974176=note: print w/replies, xml ) Need Help??

in reply to Re^15: supporting quads on 32 bit Perl
in thread supporting quads on 32 bit Perl

ok, I have uploaded version 0.20. Let's see how it does at the ActiveState PPM builders this time.

In any case, if you find any other problem with the module, don't hesitate to report it.

Replies are listed 'Best First'.
Re^17: supporting quads on 32 bit Perl
by bulk88 (Priest) on Jun 04, 2012 at 03:53 UTC
    I got a strange croak from Int64. I'm not sure who to blame. I'm leaning on Test::More is to blame.
    use strict; use warnings; use Math::Int64 qw( hex_to_int64 ); use Test::More; my $normalnum = 0; is($normalnum, hex_to_int64("0x8000200030004000"), "some test");
    sub _unoverload { my $self = shift; my $type = shift; $self->_try(sub { require overload; }, die_on_fail => 1); foreach my $thing (@_) { if( $self->_is_object($$thing) ) { if( my $string_meth = overload::Method( $$thing, $type ) ) + { >>>>>>>>>>>>>>> $$thing = $$thing->$string_meth(); } } } return; }
    which was called from
    sub _unoverload_str { my $self = shift; return $self->_unoverload( q[""], @_ ); }
    which was called from Test::Builder::cmp_ok which was called from Test::Builder::is_eq which was called from Test::More::is. When I put a breakpoint right before Int64's _string XSUB is called in _unoverload, the command line says
    # Failed test 'some test' not ok 1 - some test # at C:\Documents and Settings\Owner\Desktop\ line 7.
    If I run the whole script the output is
    C:\Documents and Settings\Owner\Desktop>perl not ok 1 - some test # Failed test 'some test' # at line 7. Usage: Math::Int64::_string(self, other, rev) at C:/perl512/lib/Test/B line 876. # Tests were run but no plan was declared and done_testing() was not s +een. C:\Documents and Settings\Owner\Desktop>
    In XS, in Math::Int64::_string, from Test::Builder::_unoverload, items variable was 1. That will cause the croak obviously.
      Yes, this is an error in Test::More calling some overload method directly with an incorrect number of arguments.

      I have changed Math::Int64 to support it anyway and also solved a problem with MS compiler not being able to handle uint64 to double conversions.

      Version 0.22 is now available from CPAN.

        0.22 from CPAN will not compile. All the errors follow the same format.
        Int64.xs(974) : error C2275: 'int64_t' : illegal use of this type as a +n expressi on Int64.xs(22) : see declaration of 'int64_t'
        Given this XS code
        SV *mi64_right(self, other, rev = &PL_sv_no) SV *self SV *other SV *rev CODE: int64_t a; uint64_t b; if (SvTRUE(rev)) { a = SvI64(aTHX_ other); b = SvU64x(self); } else { a = SvI64x(self); b = SvU64(aTHX_ other); }
        which produces this C code
        XS(XS_Math__Int64__right); /* prototype to pass -Wmissing-prototypes * +/ XS(XS_Math__Int64__right) { #ifdef dVAR dVAR; dXSARGS; #else dXSARGS; #endif if (items < 2 || items > 3) croak_xs_usage(cv, "self, other, rev = &PL_sv_no"); { SV * self = ST(0); SV * other = ST(1); SV * rev; SV * RETVAL; if (items < 3) rev = &PL_sv_no; else { rev = ST(2); } #line 974 "Int64.xs" int64_t a; uint64_t b; if (SvTRUE(rev)) { a = SvI64(aTHX_ other); b = SvU64x(self); } else { a = SvI64x(self); b = SvU64(aTHX_ other); }
        The error is obvious. You need to use PREINIT. Never rely on typemap entries being 1 liners and initialization not being deferred by XSPP. You can open new blocks, create new C autos, and run 1/4 page of code from a typemap entry. You can even run perl code to generate the type entry in the XS sub. For example to get accept a reference and its target.
        T_REFANDSV ".(unshift(@line, ( 'PREINIT:', ' SV * '.$var.'Ref;', 'INPUT:')),''). "${\$var}Ref = $arg; if (SvROK(${\$var}Ref)) $var = (SV*)SvRV(${\$var}Ref); else Perl_croak(aTHX_ \"%s: %s is not a reference\", ${$ALIAS?\q[GvNAME(CvGV(cv))]:\qq[\"$pname\"]}, \"$var\");

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://974176]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2018-04-26 08:31 GMT
Find Nodes?
    Voting Booth?