Include <gmp.h> in numbers.h, not in
authorMarius Vollmer <mvo@zagadka.de>
Tue, 21 Sep 2004 00:42:30 +0000 (00:42 +0000)
committerMarius Vollmer <mvo@zagadka.de>
Tue, 21 Sep 2004 00:42:30 +0000 (00:42 +0000)
numbers.c.
(scm_to_mpz, scm_from_mpz): New.
Thanks to Andreas Vögele!

libguile/numbers.c
libguile/numbers.h

index e14a93e..2c9a7ea 100644 (file)
@@ -50,7 +50,6 @@
 #include <math.h>
 #include <ctype.h>
 #include <string.h>
-#include <gmp.h>
 
 #include "libguile/_scm.h"
 #include "libguile/feature.h"
@@ -5680,6 +5679,23 @@ scm_is_unsigned_integer (SCM val, scm_t_uintmax min, scm_t_uintmax max)
 
 #endif
 
+void
+scm_to_mpz (SCM val, mpz_t rop)
+{
+  if (SCM_I_INUMP (val))
+    mpz_set_si (rop, SCM_I_INUM (val));
+  else if (SCM_BIGP (val))
+    mpz_set (rop, SCM_I_BIG_MPZ (val));
+  else
+    scm_wrong_type_arg_msg (NULL, 0, val, "exact integer");
+}
+
+SCM
+scm_from_mpz (mpz_t val)
+{
+  return scm_i_mpz2num (val);
+}
+
 int
 scm_is_real (SCM val)
 {
index 4e39a2c..f663e9e 100644 (file)
@@ -22,6 +22,8 @@
 
 \f
 
+#include <gmp.h>
+
 #include "libguile/__scm.h"
 #include "libguile/print.h"
 
@@ -323,6 +325,10 @@ SCM_API SCM          scm_from_uint64 (scm_t_uint64 x);
 
 #endif
 
+SCM_API void scm_to_mpz (SCM x, mpz_t rop);
+SCM_API SCM  scm_from_mpz (mpz_t rop);
+
+
 /* The conversion functions for other types are aliased to the
    appropriate ones from above.  We pick the right one based on the
    size of the type.