Re: Math::Prime::FastSieve v0.12
[email protected] ("Sisyphus")
| Newsgroups | perl.inline |
|---|---|
| Message-ID | <354FE47251704F628BFD784ACE3BF1E8@desktop2> |
----- Original Message -----
From: "David Oswald"
> I've also taken Dana's suggestion and used unsigned longs internally
> (and longs as parameters). This allows Perl's built with long support
> to handle (theoretically) sieves up to 9.2e18. ( 2^64 / 2 --- if we
> were passing unsigned longs as params it would be 2^64, but
> Inline::CPP's typemap doesn't yet support unsigned longs, so we pass
> longs).
IINM you can easily pass an unsigned long to a function that takes a long as
its parameter:
################################
use warnings;
use Inline Config =>
BUILD_NOISY => 1;
use Inline CPP => <<'EOCPP';
void bar(long x) {
unsigned long ul = x;
printf("%u", ul);
}
EOCPP
my $x = 4294967233;
bar($x); # prints 4294967233 for me
# on 5.14.0 and 5.6.2
################################
Is the typemapping of unsigned long that occurs in the perl typemap
unsuitable for Inline::CPP ? ... or is it just that not all versions of perl
provided typemapping of 'unsigned long' ?
If it's the latter, you could just supply your own typemap with the M::P::FS
source, for those versions of perl that don't typemap 'unsigned long'. The
typemap you provide would have a copy'n'paste of the 'unsigned long'
typemapping from one of the later perl typemaps.
At least, that approach worked with Inline::C.
Cheers,
Rob