guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] 01/02: Don't expose mini-gmp to users


From: Andy Wingo
Subject: [Guile-commits] 01/02: Don't expose mini-gmp to users
Date: Mon, 8 Mar 2021 16:29:06 -0500 (EST)

wingo pushed a commit to branch master
in repository guile.

commit f46477f6f5218b7974d35c1ce304e53f10e1ebcf
Author: Andy Wingo <wingo@pobox.com>
AuthorDate: Mon Mar 8 22:12:37 2021 +0100

    Don't expose mini-gmp to users
    
    * libguile.h: Don't import anything GMP-related.
    * libguile/numbers.h: Import GMP here instead.  If we are using
    mini-GMP, only import it when building Guile.
    (scm_to_mpz, scm_from_mpz): Don't define when mini-gmp is enabled.
---
 libguile.h         | 15 +++------------
 libguile/numbers.h | 25 +++++++++++++++++++++++--
 2 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/libguile.h b/libguile.h
index 14ea1d1..45117af 100644
--- a/libguile.h
+++ b/libguile.h
@@ -1,7 +1,7 @@
 #ifndef SCM_LIBGUILE_H
 #define SCM_LIBGUILE_H
 
-/* Copyright 1995-1998,2000-2004,2006,2008-2014,2018,2020
+/* Copyright 1995-1998,2000-2004,2006,2008-2014,2018,2020-2021
      Free Software Foundation, Inc.
 
    This file is part of Guile.
@@ -25,18 +25,9 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
+
 #include "libguile/scm.h"
-#ifdef __cplusplus
-}
-#endif
-#if SCM_ENABLE_MINI_GMP
-#include "libguile/mini-gmp.h"
-#else
-#include <gmp.h>
-#endif
-#ifdef __cplusplus
-extern "C" {
-#endif
+
 #include "libguile/alist.h"
 #include "libguile/array-handle.h"
 #include "libguile/array-map.h"
diff --git a/libguile/numbers.h b/libguile/numbers.h
index 7fe8071..df5c911 100644
--- a/libguile/numbers.h
+++ b/libguile/numbers.h
@@ -1,7 +1,7 @@
 #ifndef SCM_NUMBERS_H
 #define SCM_NUMBERS_H
 
-/* Copyright 1995-1996,1998,2000-2006,2008-2011,2013-2014,2016-2018
+/* Copyright 1995-1996,1998,2000-2006,2008-2011,2013-2014,2016-2018,2021
      Free Software Foundation, Inc.
 
    This file is part of Guile.
@@ -22,13 +22,26 @@
 
 
 
-#include "libguile/scm.h"
+#include "libguile/scmconfig.h"
+
+/* gmp.h needs to be included with C++ linkage, if including Guile
+   headers from a C++ compiler.  */
+#ifdef __cplusplus
+extern "C++" {
+#endif
+
 #if SCM_ENABLE_MINI_GMP
+#ifdef BUILDING_LIBGUILE
 #include "libguile/mini-gmp.h"
+#endif
 #else
 #include <gmp.h>
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #include "libguile/error.h"
 #include "libguile/gc.h"
 #include "libguile/print.h"
@@ -156,7 +169,10 @@ typedef long scm_t_inum;
 #define SCM_COMPLEX_IMAG(x) (((scm_t_complex *) SCM2PTR (x))->imag)
 
 /* 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
+
 #define SCM_BIGP(x) (SCM_HAS_TYP16 (x, scm_tc16_big))
 
 #define SCM_NUMBERP(x) (SCM_I_INUMP(x) || SCM_NUMP(x))
@@ -401,8 +417,13 @@ SCM_API SCM          scm_from_int64  (int64_t x);
 SCM_API uint64_t     scm_to_uint64   (SCM x);
 SCM_API SCM          scm_from_uint64 (uint64_t x);
 
+#if defined BUILDING_LIBGUILE && SCM_ENABLE_MINI_GMP
+SCM_INTERNAL void scm_to_mpz (SCM x, mpz_t rop);
+SCM_INTERNAL SCM  scm_from_mpz (mpz_t rop);
+#elif !SCM_ENABLE_MINI_GMP
 SCM_API void scm_to_mpz (SCM x, mpz_t rop);
 SCM_API SCM  scm_from_mpz (mpz_t rop);
+#endif
 
 
 /* The conversion functions for other types are aliased to the



reply via email to

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