[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] branch master updated: Allow users to force gmp to use l

From: Andy Wingo
Subject: [Guile-commits] branch master updated: Allow users to force gmp to use libgc
Date: Mon, 26 Apr 2021 16:58:26 -0400

This is an automated email from the git hooks/post-receive script.

wingo pushed a commit to branch master
in repository guile.

The following commit(s) were added to refs/heads/master by this push:
     new 534dd35  Allow users to force gmp to use libgc
534dd35 is described below

commit 534dd35a3c3e842d8547e83c38e5b67e99af89b5
Author: Andy Wingo <>
AuthorDate: Mon Apr 26 22:26:31 2021 +0200

    Allow users to force gmp to use libgc
    * doc/ref/guile-invoke.texi (Environment Variables): Document
    * libguile/numbers.c (scm_init_numbers): Use environment variable.
 doc/ref/guile-invoke.texi | 13 +++++++++++++
 libguile/numbers.c        |  9 +++++++++
 2 files changed, 22 insertions(+)

diff --git a/doc/ref/guile-invoke.texi b/doc/ref/guile-invoke.texi
index ee5f23e..92208d5 100644
--- a/doc/ref/guile-invoke.texi
+++ b/doc/ref/guile-invoke.texi
@@ -424,6 +424,19 @@ Guile uses the environment variable @env{HOME}, the name 
of your home
 directory, to locate various files, such as @file{.guile} or
+Guile uses the GNU multi-precision (GMP) library to implement its bigint
+support.  It can use an included minimal version of GMP, or the system
+version, which may be more optimal.  If Guile is the sole user of GMP in
+the process, Guile can tell GMP to allocate its digits using
+garbage-collected memory.  This can be significantly faster.  However
+this approach is unsafe if there are other libraries loaded that use
+libgmp, such as the GnuTLS library.  The default is for Guile to do the
+fastest safe thing: use the garbage collector for GMP when using the
+included ``mini-GMP'', but not otherwise.  Set this variable to nonzero
+to force GMP to use garbage-collected memory, even when using system GC.
 Guile has a just-in-time (JIT) code generator that makes running Guile
diff --git a/libguile/numbers.c b/libguile/numbers.c
index 0aa18e5..a4c8308 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -10412,6 +10412,15 @@ SCM_PRIMITIVE_GENERIC (scm_sqrt, "sqrt", 1, 0, 0,
 scm_init_numbers ()
+  /* Give the user the chance to force the use of libgc to manage gmp
+     digits, if we know there are no external GMP users in this process.
+     Can be an important optimization for those who link external GMP,
+     before we switch to the MPN API.  */
+    scm_install_gmp_memory_functions
+      = scm_getenv_int ("GUILE_INSTALL_GMP_MEMORY_FUNCTIONS",
+                        scm_install_gmp_memory_functions);
   if (scm_install_gmp_memory_functions)
     mp_set_memory_functions (custom_gmp_malloc,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]