From f866e9e5eca336e54fe6a9595c2513fe15169d8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Mon, 4 Sep 2000 18:04:34 +0200 Subject: [PATCH] Improved definition of __MPN(). Should now support gmp 3.x. Fixes [Bug 150]. Rev: src/modules/Gmp/configure.in:1.17 Rev: src/modules/Gmp/gmp_machine.h.in:1.5 Rev: src/modules/Gmp/my_gmp.h:1.8 --- src/modules/Gmp/configure.in | 55 +++++++++++++++++++++++++------- src/modules/Gmp/gmp_machine.h.in | 5 ++- src/modules/Gmp/my_gmp.h | 15 +++++---- 3 files changed, 55 insertions(+), 20 deletions(-) diff --git a/src/modules/Gmp/configure.in b/src/modules/Gmp/configure.in index e41807fe1d..f417d070b3 100644 --- a/src/modules/Gmp/configure.in +++ b/src/modules/Gmp/configure.in @@ -1,4 +1,4 @@ -# $Id: configure.in,v 1.16 2000/09/04 13:50:22 grubba Exp $ +# $Id: configure.in,v 1.17 2000/09/04 16:04:33 grubba Exp $ AC_INIT(mpz_glue.c) AC_CONFIG_HEADER(gmp_machine.h) AC_ARG_WITH(gmp, [ --with(out)-gmp Support bignums],[],[with_gmp=yes]) @@ -49,7 +49,40 @@ define([AC_CHECK_GMP], done=no AC_CHECK_HEADERS($2,[ - AC_MSG_CHECKING(working $1) + # This test is needed since the __MPN macro + # is broken on many versions of gmp, since + # many ANSI compilers only define __STDC__ + # in strict ansi mode. Some of the affected + # compilers also don't allow redefining + # __STDC__. + AC_MSG_CHECKING(prefix for __MPN in $2) + define(PIKE_PREFIX_NAME,[pike_cv_$1___MPN_prefix]) + AC_CACHE_VAL(PIKE_PREFIX_NAME, [ + AC_EGREP_CPP([__gmpn_.*PiKe], [ +#include <$2> +__MPN(PiKe) + ], [ + PIKE_PREFIX_NAME="__gmpn_" + ], [ + AC_EGREP_CPP([__mpn_.*PiKe], [ +#include <$2> +__MPN(PiKe) + ], [ + PIKE_PREFIX_NAME="__mpn_" + ], [ + PIKE_PREFIX_NAME="no" + ]) + ]) + ]) + if test "x[$]PIKE_PREFIX_NAME" = "xno"; then + AC_MSG_RESULT(warning -- prefix not found) + else + AC_MSG_RESULT([$]PIKE_PREFIX_NAME) + AC_DEFINE(PIKE_MPN_PREFIX, [$]PIKE_PREFIX_NAME) + fi + undefine(PIKE_PREFIX_NAME) + + AC_MSG_CHECKING(working <$2>) AC_CACHE_VAL(pike_cv_working_$1,[ OLDLIBS="${LIBS-}" LIBS="${LIBS-} -l$1" @@ -57,11 +90,10 @@ define([AC_CHECK_GMP], #include <stdio.h> /* Kludge for some compilers only defining __STDC__ in strict mode. */ -#ifndef __STDC__ -#ifdef HAVE_ANSI_CONCAT -#define __STDC__ 0 -#endif -#endif /* __STDC__ */ +#if !defined(__STDC__) && defined(HAVE_ANSI_CONCAT) && defined(PIKE_MPN_PREFIX) +#define PIKE_MPN_CONCAT(x,y) x##y +#define __MPN(x) PIKE_MPN_CONCAT(PIKE_MPN_PREFIX,x) +#endif /* !__STDC__ && HAVE_ANSI_CONCAT && PIKE_MPN_PREFIX */ #include <$2> int main(int argc, char **argv) @@ -84,11 +116,10 @@ int main(int argc, char **argv) #include <stdio.h> /* Kludge for some compilers only defining __STDC__ in strict mode. */ -#ifndef __STDC__ -#ifdef HAVE_ANSI_CONCAT -#define __STDC__ 0 -#endif -#endif /* __STDC__ */ +#if !defined(__STDC__) && defined(HAVE_ANSI_CONCAT) && defined(PIKE_MPN_PREFIX) +#define PIKE_MPN_CONCAT(x,y) x##y +#define __MPN(x) PIKE_MPN_CONCAT(PIKE_MPN_PREFIX,x) +#endif /* !__STDC__ && HAVE_ANSI_CONCAT && PIKE_MPN_PREFIX */ #include <$2> diff --git a/src/modules/Gmp/gmp_machine.h.in b/src/modules/Gmp/gmp_machine.h.in index 6d0f6d6aa9..cc6a90e3ca 100644 --- a/src/modules/Gmp/gmp_machine.h.in +++ b/src/modules/Gmp/gmp_machine.h.in @@ -1,7 +1,10 @@ -/* $Id: gmp_machine.h.in,v 1.4 2000/04/25 15:07:13 marcus Exp $ */ +/* $Id: gmp_machine.h.in,v 1.5 2000/09/04 16:04:33 grubba Exp $ */ #ifndef GMP_MACHINE_H #define GMP_MACHINE_H +/* Define this to the prefix used by __MPN() (usually __mpn_ or __gmpn_). */ +#undef PIKE_MPN_PREFIX + /* Define this if you have <gmp2/gmp.h> */ #undef HAVE_GMP2_GMP_H diff --git a/src/modules/Gmp/my_gmp.h b/src/modules/Gmp/my_gmp.h index a2837cae05..f158154d06 100644 --- a/src/modules/Gmp/my_gmp.h +++ b/src/modules/Gmp/my_gmp.h @@ -1,4 +1,4 @@ -/* $Id: my_gmp.h,v 1.7 2000/09/04 13:50:23 grubba Exp $ +/* $Id: my_gmp.h,v 1.8 2000/09/04 16:04:34 grubba Exp $ * * These functions or something similar will hopefully be included * with Gmp-2.1 . @@ -7,12 +7,13 @@ #ifndef MY_GMP_H_INCLUDED #define MY_GMP_H_INCLUDED -/* Kludge for some compilers only defining __STDC__ in strict mode. */ -#ifndef __STDC__ -#ifdef HAVE_ANSI_CONCAT -#define __STDC__ 0 -#endif -#endif /* __STDC__ */ +/* Kludge for some compilers only defining __STDC__ in strict mode, + * which leads to <gmp.h> using the wrong token concat method. + */ +#if !defined(__STDC__) && defined(HAVE_ANSI_CONCAT) && defined(PIKE_MPN_PREFIX) +#define PIKE_MPN_CONCAT(x,y) x##y +#define __MPN(x) PIKE_MPN_CONCAT(PIKE_MPN_PREFIX,x) +#endif /* !__STDC__ && HAVE_ANSI_CONCAT && PIKE_MPN_PREFIX */ #undef _PROTO #define _PROTO(x) x -- GitLab