Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

div_2exp_gmp

fibonacci

get_str_gmp

gmp_copy

gmp_tstbit

intify

is_perfect_power

is_perfect_square

jacobi

legendre

mmod_gmp

mod_2exp_gmp

mul_2exp_gmp

new_from_scalar

new_from_scalar_with_base

op_add

op_bool

op_div

op_eq

op_mod

op_mul

op_numify

op_pow

op_spaceship

op_stringify

op_sub

powm_gmp

probab_prime

sizeinbase_gmp

stringify

uintify