Macaulay2 Engine
Loading...
Searching...
No Matches
gmp-util.h File Reference

Inline helpers that move GMP / MPFR / MPFI limbs from malloc-managed storage into the bdwgc heap. More...

Go to the source code of this file.

Classes

struct  CC_struct
 Immutable view of a complex number as a pair of mpfr_srcptr real and imaginary parts. More...
struct  CCmutable_struct
 Mutable view of a complex number as a pair of mpfr_ptr real and imaginary parts. More...
struct  CCi_struct
 Immutable view of a complex interval as a pair of mpfi_srcptr real and imaginary parts. More...
struct  CCimutable_struct
 Mutable view of a complex interval as a pair of mpfi_ptr real and imaginary parts. More...

Functions

void mpz_reallocate_limbs (mpz_ptr _z)
gmp_QQ moveTo_gmpQQ (mpq_ptr z)
void mpfr_reallocate_limbs (mpfr_ptr _z)
void mpfi_reallocate_limbs (mpfi_ptr _z)
mpfr_srcptr moveTo_gmpRR (mpfr_ptr _z)
mpfi_srcptr moveTo_gmpRRi (mpfi_ptr _z)
gmp_CC moveTo_gmpCC (gmp_CCmutable _z)
gmp_CCi moveTo_gmpCCi (gmp_CCimutable _z)

Detailed Description

Inline helpers that move GMP / MPFR / MPFI limbs from malloc-managed storage into the bdwgc heap.

Note
AI-generated documentation. Verify against the source before relying on it.

Declares the small family of mpz_reallocate_limbs / mpfr_reallocate_limbs / mpfi_reallocate_limbs rewriters and the typed moveTo_gmpQQ / moveTo_gmpRR / moveTo_gmpRRi / moveTo_gmpCC / moveTo_gmpCCi wrappers (integer values go through mpz_reallocate_limbs directly) that the engine uses to launder every GMP-allocated number through getmem_atomic before handing it back to the interpreter. The pattern is the same in every case: allocate a fresh atomic GC buffer of the right limb size, memcpy the existing limbs into it, mpz_clear / mpfr_clear the original malloc-backed payload, and rewire the multiprecision struct to point at the new GC-managed storage.

Without this laundering the engine would interleave two memory regimes inside the same value and the bdwgc collector would be unable to see the limbs — so any rational, real, or complex number crossing the engine-to-interpreter boundary gets passed through a moveTo_* helper first. The CC_struct / CCi_struct typedefs at the bottom carry the complex (and complex-interval) layouts the helpers operate on.

See also
m2-mem.h
engine-includes.hpp

Definition in file gmp-util.h.