1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 20:00:19 +02:00

Allow compilation with GMP < 5.0.0.

* libguile/numbers.c (VARARG_MPZ_ITERATOR)[!HAVE_DECL_MPZ_INITS]: New
  macro.
  (mpz_inits, mpz_clears)[!HAVE_DECL_MPZ_INITS]: New functions.
* configure.ac: Check for the declaration of `mpz_inits'.
This commit is contained in:
Ludovic Courtès 2013-03-28 22:16:07 +01:00
parent 06589f5c22
commit 07b390d582
2 changed files with 38 additions and 1 deletions

View file

@ -872,6 +872,14 @@ if test "x$HAVE_LIBGMP" != "xyes"; then
AC_MSG_ERROR([GNU MP 4.1 or greater not found, see README]) AC_MSG_ERROR([GNU MP 4.1 or greater not found, see README])
fi fi
dnl `mpz_inits' and `mpz_clears' appeared in GMP 5.0.0.
save_CPPFLAGS="$CPPFLAGS"
if test "x$LIBGMP_PREFIX" != "x"; then
CPPFLAGS="-I$LIBGMP_PREFIX $CPPFLAGS"
fi
AC_CHECK_DECLS([mpz_inits], [], [], [[#include <gmp.h>]])
CPPFLAGS="$save_CPPFLAGS"
dnl GNU libunistring is checked for by Gnulib's `libunistring' module. dnl GNU libunistring is checked for by Gnulib's `libunistring' module.
if test "x$LTLIBUNISTRING" = "x"; then if test "x$LTLIBUNISTRING" = "x"; then
AC_MSG_ERROR([GNU libunistring is required, please install it.]) AC_MSG_ERROR([GNU libunistring is required, please install it.])

View file

@ -1,4 +1,6 @@
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. /* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
* 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012,
* 2013 Free Software Foundation, Inc.
* *
* Portions Copyright 1990, 1991, 1992, 1993 by AT&T Bell Laboratories * Portions Copyright 1990, 1991, 1992, 1993 by AT&T Bell Laboratories
* and Bellcore. See scm_divide. * and Bellcore. See scm_divide.
@ -56,6 +58,8 @@
#include <complex.h> #include <complex.h>
#endif #endif
#include <stdarg.h>
#include "libguile/_scm.h" #include "libguile/_scm.h"
#include "libguile/feature.h" #include "libguile/feature.h"
#include "libguile/ports.h" #include "libguile/ports.h"
@ -96,6 +100,31 @@ typedef scm_t_signed_bits scm_t_inum;
#define DOUBLE_IS_POSITIVE_INFINITY(x) (isinf(x) && ((x) > 0)) #define DOUBLE_IS_POSITIVE_INFINITY(x) (isinf(x) && ((x) > 0))
#define DOUBLE_IS_NEGATIVE_INFINITY(x) (isinf(x) && ((x) < 0)) #define DOUBLE_IS_NEGATIVE_INFINITY(x) (isinf(x) && ((x) < 0))
#if ! HAVE_DECL_MPZ_INITS
/* GMP < 5.0.0 lacks `mpz_inits' and `mpz_clears'. Provide them. */
#define VARARG_MPZ_ITERATOR(func) \
static void \
func ## s (mpz_t x, ...) \
{ \
va_list ap; \
\
va_start (ap, x); \
while (x != NULL) \
{ \
func (x); \
x = va_arg (ap, mpz_ptr); \
} \
va_end (ap); \
}
VARARG_MPZ_ITERATOR (mpz_init)
VARARG_MPZ_ITERATOR (mpz_clear)
#endif
/* /*