GMP Module (perl)

Sisyphus kalinabears@iinet.net.au
Fri, 25 Jul 2003 09:43:34 +1000


----- Original Message -----
From: "Sisyphus" <kalinabears@iinet.net.au>
To: "Kevin Ryde" <user42@zip.com.au>
Cc: "GMP" <gmp-discuss@swox.com>
Sent: Thursday, July 24, 2003 11:58 AM
Subject: Re: GMP Module (perl)


>
> ----- Original Message -----
> From: "Kevin Ryde" <user42@zip.com.au>
> To: "Sisyphus" <kalinabears@iinet.net.au>
> Cc: "GMP" <gmp-discuss@swox.com>
> Sent: Thursday, July 24, 2003 11:25 AM
> Subject: Re: GMP Module (perl)
>
>
> > "Sisyphus" <kalinabears@iinet.net.au> writes:
> > >
> > > GMP.xs: In function `XS_GMP__Mpz_overload_add':
> > > GMP.xs:1229: initializer element is not constant
> > > GMP.xs:1229: (near initialization for `table[0].op')
> >
> > Hmm, yep, DLL imported functions don't work in initializers.  It'd be
> > nice if gcc could do something to help that, since of course it's a
> > fairly general problem.
> >
>
> Faik, they may have. The version of gcc that I'm using is getting a bit
old.
> I'll check with the gcc mailing list to see if more recent versions
address
> this problem.
>

Haven't heard back from them yet, on that.

> > You might get more joy from a static build of gmp, or maybe it'd work
> > to compile the generated GMP.c as C++ instead of C.
> >
>
> The second option sounds like one that should be fairly trivial to
> implement. I don't know how to do that (off the top of my head) in a perl
> build, but I should be able to work that out without too much difficulty.
>

That turns out to be fairly straightforward (and successful).
The only additional step necessary was to change this code:
static void
class_or_croak (SV *sv, classconst char *class)
{
  if (! sv_derived_from (sv, class))
    croak("not type %s", class);
}

g++ didn't like having a variable named 'class', as I'm sure everyone here
would know, so I changed it to 'cclass'. (Of course, someone else had to
tell me to change it, I'm ashamed to admit.)

Nice work, Kevin. (I believe you wrote the module.) It's nicer, imo, to use
than Math::GMP, and additionally provides access to a greater range of GMP
functions. Have you considered placing it on cpan ? I'm not sure how the
perl people would feel about the 'GMP' namespace, and the 'Math::GMP'
namespace is already taken ........

Cheers,
Rob