Skip to content
Snippets Groups Projects
Commit f866e9e5 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

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
parent 55d23256
No related branches found
No related tags found
No related merge requests found
# $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_INIT(mpz_glue.c)
AC_CONFIG_HEADER(gmp_machine.h) AC_CONFIG_HEADER(gmp_machine.h)
AC_ARG_WITH(gmp, [ --with(out)-gmp Support bignums],[],[with_gmp=yes]) AC_ARG_WITH(gmp, [ --with(out)-gmp Support bignums],[],[with_gmp=yes])
...@@ -49,7 +49,40 @@ define([AC_CHECK_GMP], ...@@ -49,7 +49,40 @@ define([AC_CHECK_GMP],
done=no done=no
AC_CHECK_HEADERS($2,[ 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,[ AC_CACHE_VAL(pike_cv_working_$1,[
OLDLIBS="${LIBS-}" OLDLIBS="${LIBS-}"
LIBS="${LIBS-} -l$1" LIBS="${LIBS-} -l$1"
...@@ -57,11 +90,10 @@ define([AC_CHECK_GMP], ...@@ -57,11 +90,10 @@ define([AC_CHECK_GMP],
#include <stdio.h> #include <stdio.h>
/* Kludge for some compilers only defining __STDC__ in strict mode. */ /* Kludge for some compilers only defining __STDC__ in strict mode. */
#ifndef __STDC__ #if !defined(__STDC__) && defined(HAVE_ANSI_CONCAT) && defined(PIKE_MPN_PREFIX)
#ifdef HAVE_ANSI_CONCAT #define PIKE_MPN_CONCAT(x,y) x##y
#define __STDC__ 0 #define __MPN(x) PIKE_MPN_CONCAT(PIKE_MPN_PREFIX,x)
#endif #endif /* !__STDC__ && HAVE_ANSI_CONCAT && PIKE_MPN_PREFIX */
#endif /* __STDC__ */
#include <$2> #include <$2>
int main(int argc, char **argv) int main(int argc, char **argv)
...@@ -84,11 +116,10 @@ int main(int argc, char **argv) ...@@ -84,11 +116,10 @@ int main(int argc, char **argv)
#include <stdio.h> #include <stdio.h>
/* Kludge for some compilers only defining __STDC__ in strict mode. */ /* Kludge for some compilers only defining __STDC__ in strict mode. */
#ifndef __STDC__ #if !defined(__STDC__) && defined(HAVE_ANSI_CONCAT) && defined(PIKE_MPN_PREFIX)
#ifdef HAVE_ANSI_CONCAT #define PIKE_MPN_CONCAT(x,y) x##y
#define __STDC__ 0 #define __MPN(x) PIKE_MPN_CONCAT(PIKE_MPN_PREFIX,x)
#endif #endif /* !__STDC__ && HAVE_ANSI_CONCAT && PIKE_MPN_PREFIX */
#endif /* __STDC__ */
#include <$2> #include <$2>
......
/* $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 #ifndef GMP_MACHINE_H
#define 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> */ /* Define this if you have <gmp2/gmp.h> */
#undef HAVE_GMP2_GMP_H #undef HAVE_GMP2_GMP_H
......
/* $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 * These functions or something similar will hopefully be included
* with Gmp-2.1 . * with Gmp-2.1 .
...@@ -7,12 +7,13 @@ ...@@ -7,12 +7,13 @@
#ifndef MY_GMP_H_INCLUDED #ifndef MY_GMP_H_INCLUDED
#define MY_GMP_H_INCLUDED #define MY_GMP_H_INCLUDED
/* Kludge for some compilers only defining __STDC__ in strict mode. */ /* Kludge for some compilers only defining __STDC__ in strict mode,
#ifndef __STDC__ * which leads to <gmp.h> using the wrong token concat method.
#ifdef HAVE_ANSI_CONCAT */
#define __STDC__ 0 #if !defined(__STDC__) && defined(HAVE_ANSI_CONCAT) && defined(PIKE_MPN_PREFIX)
#endif #define PIKE_MPN_CONCAT(x,y) x##y
#endif /* __STDC__ */ #define __MPN(x) PIKE_MPN_CONCAT(PIKE_MPN_PREFIX,x)
#endif /* !__STDC__ && HAVE_ANSI_CONCAT && PIKE_MPN_PREFIX */
#undef _PROTO #undef _PROTO
#define _PROTO(x) x #define _PROTO(x) x
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment