Peta::FFI::GMP
pperl-specific module built into the interpreter. Runtime: PP.
Peta::FFI::GMP — Pre-baked libgmp bindings (Layer 1)
Uses dlopen("libgmp.so.10") at registration time. If libgmp is not
installed, use Peta::FFI::GMP (or use Math::GMP) dies with a helpful message.
GMP integers (mpz_t) are heap-allocated via libc malloc/free and stored as raw pointers (Box::into_raw cast to i64) inside blessed Perl refs of class “Math::GMP”. This exactly mirrors what the XS module does.
Object lifecycle: new() → malloc(sizeof(mpz_t)) + mpz_init_set_str → bless as Math::GMP DESTROY() → mpz_clear + free
All arithmetic ops return new blessed objects (matching XS behaviour).
Functions
_gmp_lib_version
add_ui_gmp
band
bdiv
bfac
bgcd
bior
blcm
blshift
bmodinv
bmulf
bnok
broot
brootrem
brshift
bsqrt
bsqrtrem
bxor
destroy
mpz_clear + free; called via DESTROY