Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Version PMC

4 views
Skip to first unread message

Leopold Toetsch

unread,
Sep 15, 2006, 2:30:31 PM9/15/06
to perl6-i...@perl.org
Hi,
Today I played a bit with calculating the 44th Mersenne prime, which is of
course using BigInt's. I discovered that my installed GMP 4.1.1 segfaulted
during multiplication (it was *not* a parrot problem ;). I compiled &
installed a recent GMP version and all went fine.

But: below [1] is the test code, to implement a diagnostic about a maybe
problematic GMP version. I'd like to code it like this:

.local pmc cl, v, need
cl = getclass 'BigInt'
v = cl.'version'() # return a .Version PMC
need = new .Version, '4.1.4'
if v < need goto warn
...

So the idea is:
- fill version.pmc with some initializers
- assume version =~ / (major(\.minor(\.patch)*))?.* /x at least for now
- provide compare functions that do arithmetic compares on subcomponents from
left to right.

Comments welcome,
leo

[1] s. also t/pmc/bigint.t
.sub main :main
.local pmc b, ar
.local string v
.local int ma, mi, pa
b = new .BigInt
v = b.'version'()
ar = split '.', v
ma = ar[0]
mi = ar[1]
pa = ar[2]
if ma >= 4 goto ge_4
warn:
print 'GMP version '
print v
print " is buggy with huge digit multiply - please upgrade\n"
end
ge_4:
if mi >= 2 goto ok
if mi == 0 goto warn
# test 4.1.x
if pa >= 4 goto ok
goto warn
end
ok:
.end

0 new messages