1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-24 12:20:20 +02:00

Bignums avoid both custom GMP allocator and finalizers

* libguile/deprecated.c (make_bignum): Move here from numbers.c, to
support scm_i_long2big etc.
(scm_i_big2dbl):
(scm_i_long2big):
(scm_i_ulong2big):
(scm_i_clonebig):
(scm_i_normbig): Deprecate.
(scm_install_gmp_memory_functions): Deprecate, happily!  SCM bignums now
have digits allocated inline with the bignum itself, so they are
completely transparent to the GC already.  The price is that if GMP ever
allocates digits via the MPZ API, those digits then have to be copied
back into managed memory.  But we avoid having to install finalizers and
we avoid having to muck with GMP's allocator.
* libguile/numbers.c (scm_from_mpz): Use scm_integer_from_mpz.
(scm_init_numbers): Never muck with GMP's allocators.
* doc/ref/guile-invoke.texi (Environment Variables): Remove note about
GUILE_INSTALL_GMP_MEMORY_FUNCTIONS.
* meta/build-env.in: No need to set GUILE_INSTALL_GMP_MEMORY_FUNCTIONS.
This commit is contained in:
Andy Wingo 2022-01-07 14:01:52 +01:00
parent a0765f564a
commit aa5455ea98
6 changed files with 113 additions and 201 deletions

View file

@ -1,7 +1,7 @@
#ifndef SCM_DEPRECATED_H
#define SCM_DEPRECATED_H
/* Copyright 2003-2007,2009-2018,2020,2021
/* Copyright 2003-2007,2009-2018,2020-2022
Free Software Foundation, Inc.
This file is part of Guile.
@ -146,6 +146,19 @@ SCM_DEPRECATED SCM scm_copy_tree (SCM obj);
SCM_DEPRECATED SCM scm_dynamic_unlink (SCM obj);
/* Each bignum is just an mpz_t stored in a double cell starting at word 1. */
#if defined BUILDING_LIBGUILE || SCM_ENABLE_MINI_GMP == 0
#define SCM_I_BIG_MPZ(x) (*((mpz_t *) (SCM_CELL_OBJECT_LOC((x),1))))
#endif
SCM_DEPRECATED int scm_install_gmp_memory_functions;
SCM_DEPRECATED SCM scm_i_normbig (SCM x);
SCM_DEPRECATED double scm_i_big2dbl (SCM b);
SCM_DEPRECATED SCM scm_i_long2big (long n);
SCM_DEPRECATED SCM scm_i_ulong2big (unsigned long n);
SCM_DEPRECATED SCM scm_i_clonebig (SCM src_big, int same_sign_p);
void scm_i_init_deprecated (void);
#endif