m4-patches
[Top][All Lists]
Advanced

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

GMP


From: akim
Subject: GMP
Date: Tue, 18 Sep 2001 23:06:27 +0200
User-agent: Mutt/1.3.20i

Gary, I'd like your approval.  It works fine on my machine, which has
libgmp.  But maybe I'm wrong on the intentions: the TODO portions and
what I wrote are not exxactly the same.


Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * config/gmp.m4 (AM_WITH_GMP): Rename as...
        (AC_LIB_GMP): this.
        By default, use gmp.
        Massive revamping.
        * configure.in: Adjust.
        Use Automake conditionals for USE_GMP.
        Always compute sizeof (long long int).
        This was a bug BTW, as `eval' (not `mpeval') depends on it:
        before, it was used _only_ if mpeval was not activated.
        * modules/Makefile.am (pkglibexec2dir, +pkglibexec2_LTLIBRARIES)
        (mpeval_la_LIBADD): New macros.
        * modules/mpeval.c: No longer be conditioned by WITH_GMP.
        Indent.
        * tests/Makefile.am ($(srcdir)/$(TESTSUITE)): Create package.m4.
        * tests/atlocal.in, tests/builtins.at: Depend upon USE_GMP, not
        WITH_GMP.

Index: TODO
--- TODO Tue, 18 Sep 2001 20:57:18 +0200 akim
+++ TODO Tue, 18 Sep 2001 22:37:35 +0200 akim
@@ -26,7 +26,7 @@
       (GNU m4 1.4k, built with glibc 2.0.100 (itself built with Linux
       2.1.126 headers), and running on Linux 2.0.36pre15.)

-      --
+      --
       Joseph S. Myers
       address@hidden

@@ -69,12 +69,6 @@
        maintaining the string lengths, and avoiding strlen, strcpy,
        etc.).

-  + --with-gmp is surplus to requirements, mpeval should always be built --
-    either with libgmp if it is available, or else without it.  Whether
-    or not to use mpeval is then determined at runtime, if the user tries
-    to `load(`mpeval')'.
-
-
 * MODULE SPECIFIC ISSUES

   + Some way of linking a module statically is needed, for systems
@@ -97,3 +91,8 @@

   + The perl module should only be built if a suitable perl interpreter
     is found on the build machine.
+
+* OTHER TOOLS
+
+  + Automake 1.5 doesn't seem to like pkglibexec_LTLIBRARIES +=
+    See modules/Makefile.am.
Index: configure.in
--- configure.in Tue, 18 Sep 2001 20:57:18 +0200 akim
+++ configure.in Tue, 18 Sep 2001 22:17:05 +0200 akim
@@ -74,6 +74,7 @@
 AC_CHECK_HEADERS(limits.h locale.h memory.h string.h unistd.h errno.h)
 AC_HEADER_STDC
 AC_TYPE_SIZE_T
+AC_CHECK_SIZEOF(long long int)

 AC_CHECK_FUNCS(bzero calloc mkstemp mktemp strerror tmpfile)

@@ -122,8 +123,9 @@
 AC_FUNC_STRFTIME
 AC_CHECK_FUNCS(getcwd gethostname mktime uname)
 AC_CHECK_FUNCS(setenv unsetenv putenv clearenv)
-AM_WITH_GMP
-AC_SUBST([WITH_GMP], [$with_gmp])
+
+AC_LIB_GMP
+AM_CONDITIONAL([USE_GMP], [test "x$LIB_GMP" != xno])

 AM_WITH_DMALLOC
 if test "$USE_INCLUDED_LIBINTL" = yes; then
Index: config/gmp.m4
--- config/gmp.m4 Fri, 10 Aug 2001 14:01:13 +0200 akim
+++ config/gmp.m4 Tue, 18 Sep 2001 22:13:45 +0200 akim
@@ -16,36 +16,44 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 # 02111-1307  USA

-# serial 3
+# serial 4

-AC_DEFUN([AM_WITH_GMP],
-  [AC_MSG_CHECKING(if extended and fractional arithmetic is wanted)
-  AC_ARG_WITH(gmp,
-  [  --with-gmp              use gmp for extended and fractional arithmetic],
-  [use_gmp=$withval], [use_gmp=no])
-  AC_MSG_RESULT($use_gmp)
+m4_define([_AC_LIB_GMP],
+[AC_ARG_WITH(gmp,
+[  --without-gmp           don't use GNU multiple precision arithmetic 
library],
+[use_gmp=$withval], [use_gmp=yes])

-  if test "$use_gmp" = yes; then
-    LIBS="$LIBS -lgmp"
-    AC_CHECK_HEADER([gmp.h],
-      [AC_CACHE_CHECK([for mpq_init in libgmp], ac_cv_func_mpq_init_libgmp,
-        [AC_TRY_LINK([#include <gmp.h>],
-           [mpq_t x; (void)mpq_init(x)],
-           ac_cv_func_mpq_init_libgmp=yes,
-           ac_cv_func_mpq_init_libgmp=no)])],
-         ac_cv_func_mpq_init_libgmp=no)
+case $use_gmp:$GMP_LIB:$ac_cv_header_gmp_h in
+  *::yes)
+    AC_MSG_WARN([gmp library not found or does not appear to work
+                 but `gmp.h' is present])
+    ac_cv_using_lib_gmp=no
+    ;;
+  *:-lgmp:no)
+    AC_MSG_WARN([gmp works but `gmp.h' is missing])
+    ac_cv_using_lib_gmp=no
+    ;;
+  yes:*:yes)
+    ac_cv_using_lib_gmp=yes
+    ;;
+  no:*)
+    ac_cv_using_lib_gmp=no
+    ;;
+esac

-    if test "$ac_cv_func_mpq_init_libgmp$ac_cv_header_gmp_h" = yesyes; then
-      AC_DEFINE(WITH_GMP, 1,
-      [Define to 1 if the GNU multiple precision library should be used.])
-    else
-      LIBS=`echo $LIBS | sed -e 's/-lgmp//'`
-      AC_MSG_WARN([gmp library not found or does not appear to work])
-      use_gmp=no
-    fi
-  fi
+if test "$ac_cv_using_lib_gmp" = yes; then
+  AC_DEFINE(WITH_GMP, 1,
+    [Define to 1 if the GNU multiple precision library should be used.])
+fi
+])# _AC_LIB_GMP

-  if test "$use_gmp" != yes; then
-    AC_CHECK_SIZEOF(long long int, 0)
-  fi
-  ])
+AC_DEFUN([AC_LIB_GMP],
+[AC_CHECK_HEADERS([gmp.h])
+AC_CHECK_LIB([gmp], [mpq_init], [GMP_LIB=-lgmp])
+AC_SUBST([GMP_LIB])dnl
+
+AC_CACHE_CHECK([if using GNU multiple precision arithmetic library],
+                [ac_cv_using_lib_gmp],
+                [_AC_LIB_GMP])
+AC_SUBST([USE_GMP], [$ac_cv_using_lib_gmp])dnl
+])# AC_LIB_GMP
Index: modules/Makefile.am
--- modules/Makefile.am Tue, 18 Sep 2001 20:57:18 +0200 akim
+++ modules/Makefile.am Tue, 18 Sep 2001 22:36:05 +0200 akim
@@ -33,9 +33,16 @@
 LDFLAGS = -no-undefined

 pkglibexec_LTLIBRARIES = gnu.la load.la m4.la \
-                         mpeval.la traditional.la perl.la \
+                         traditional.la perl.la \
                          modtest.la shadow.la stdlib.la time.la

+## Aaaarg.  Automake 1.5 doesn't seem to like
+## pkglibexec_LTLIBRARIES += mpeval.la
+pkglibexec2dir = $(pkglibexecdir)
+if USE_GMP
+pkglibexec2_LTLIBRARIES = mpeval.la
+endif
+
 gnu_la_SOURCES = gnu.c
 EXTRA_gnu_la_SOURCES = format.c
 gnu_la_LDFLAGS = -module
@@ -48,6 +55,7 @@

 mpeval_la_SOURCES = mpeval.c
 mpeval_la_LDFLAGS = -module
+mpeval_la_LIBADD = -lgmp

 traditional_la_SOURCES = traditional.c
 traditional_la_LDFLAGS = -module
Index: modules/mpeval.c
--- modules/mpeval.c Thu, 30 Aug 2001 15:53:29 +0200 akim
+++ modules/mpeval.c Tue, 18 Sep 2001 22:50:49 +0200 akim
@@ -24,45 +24,43 @@
 #include <m4module.h>
 #include "m4private.h"

-#if WITH_GMP
-#  include "gmp.h"
+#include <gmp.h>

-#  define numb_set(ans,i) mpq_set(ans,i)
-#  define numb_set_si(ans,i) mpq_set_si(*(ans),(long)i,(unsigned long)1)
+#define numb_set(ans,i) mpq_set(ans,i)
+#define numb_set_si(ans,i) mpq_set_si(*(ans),(long)i,(unsigned long)1)

-#  define numb_init(x) mpq_init((x))
-#  define numb_fini(x) mpq_clear((x))
+#define numb_init(x) mpq_init((x))
+#define numb_fini(x) mpq_clear((x))

-#  define numb_zerop(x)     (mpq_cmp(x,numb_ZERO) == 0)
-#  define numb_positivep(x) (mpq_cmp(x,numb_ZERO) >  0)
-#  define numb_negativep(x) (mpq_cmp(x,numb_ZERO) <  0)
-
-#  define numb_eq(x,y) numb_set(x,mpq_cmp(x,y)==0? numb_ONE: numb_ZERO)
-#  define numb_ne(x,y) numb_set(x,mpq_cmp(x,y)!=0? numb_ONE: numb_ZERO)
-#  define numb_lt(x,y) numb_set(x,mpq_cmp(x,y)< 0? numb_ONE: numb_ZERO)
-#  define numb_le(x,y) numb_set(x,mpq_cmp(x,y)<=0? numb_ONE: numb_ZERO)
-#  define numb_gt(x,y) numb_set(x,mpq_cmp(x,y)> 0? numb_ONE: numb_ZERO)
-#  define numb_ge(x,y) numb_set(x,mpq_cmp(x,y)>=0? numb_ONE: numb_ZERO)
-
-#  define numb_lnot(x)   numb_set(x,numb_zerop(x)? numb_ONE: numb_ZERO)
-#  define numb_lior(x,y) numb_set(x,numb_zerop(x)? y: numb_ONE)
-#  define numb_land(x,y) numb_set(x,numb_zerop(x)? numb_ZERO: y)
-
-#  define reduce1(f1,x) \
-{ number T; mpq_init(T); f1(T,x);   mpq_set(x,T); mpq_clear(T); }
-#  define reduce2(f2,x,y) \
-{ number T; mpq_init(T); f2(T,(x),(y)); mpq_set((x),T); mpq_clear(T); }
-
-#  define numb_plus(x,y)  reduce2(mpq_add,x,y)
-#  define numb_minus(x,y) reduce2(mpq_sub,x,y)
-#  define numb_negate(x)  reduce1(mpq_neg,x)
-
-#  define numb_times(x,y) reduce2(mpq_mul,x,y)
-#  define numb_ratio(x,y) reduce2(mpq_div,x,y)
-#  define numb_invert(x)  reduce1(mpq_inv,x)
+#define numb_zerop(x)     (mpq_cmp(x,numb_ZERO) == 0)
+#define numb_positivep(x) (mpq_cmp(x,numb_ZERO) >  0)
+#define numb_negativep(x) (mpq_cmp(x,numb_ZERO) <  0)
+
+#define numb_eq(x,y) numb_set(x,mpq_cmp(x,y)==0? numb_ONE: numb_ZERO)
+#define numb_ne(x,y) numb_set(x,mpq_cmp(x,y)!=0? numb_ONE: numb_ZERO)
+#define numb_lt(x,y) numb_set(x,mpq_cmp(x,y)< 0? numb_ONE: numb_ZERO)
+#define numb_le(x,y) numb_set(x,mpq_cmp(x,y)<=0? numb_ONE: numb_ZERO)
+#define numb_gt(x,y) numb_set(x,mpq_cmp(x,y)> 0? numb_ONE: numb_ZERO)
+#define numb_ge(x,y) numb_set(x,mpq_cmp(x,y)>=0? numb_ONE: numb_ZERO)
+
+#define numb_lnot(x)   numb_set(x,numb_zerop(x)? numb_ONE: numb_ZERO)
+#define numb_lior(x,y) numb_set(x,numb_zerop(x)? y: numb_ONE)
+#define numb_land(x,y) numb_set(x,numb_zerop(x)? numb_ZERO: y)
+
+#define reduce1(f1,x) \
+  { number T; mpq_init(T); f1(T,x);   mpq_set(x,T); mpq_clear(T); }
+#define reduce2(f2,x,y) \
+  { number T; mpq_init(T); f2(T,(x),(y)); mpq_set((x),T); mpq_clear(T); }
+
+#define numb_plus(x,y)  reduce2(mpq_add,x,y)
+#define numb_minus(x,y) reduce2(mpq_sub,x,y)
+#define numb_negate(x)  reduce1(mpq_neg,x)
+
+#define numb_times(x,y) reduce2(mpq_mul,x,y)
+#define numb_ratio(x,y) reduce2(mpq_div,x,y)
+#define numb_invert(x)  reduce1(mpq_inv,x)

-#  define numb_decr(n) numb_minus(n,numb_ONE)
-#endif /* WITH_GMP */
+#define numb_decr(n) numb_minus(n,numb_ONE)

 /* Rename exported symbols for dlpreload()ing.  */
 #define m4_builtin_table       mpeval_LTX_m4_builtin_table
@@ -95,12 +93,11 @@
 };


-#if WITH_GMP
 /* A table for mapping m4 symbol names to simple expansion text. */
 m4_macro m4_macro_table[] =
 {
-  /* name                      text */
-  { "__gmp__",                 "" },
+  /* name                      text */
+  { "__gmp__",                 "" },
   { 0, 0 },
 };

@@ -108,31 +105,30 @@
 /* number should be at least 32 bits.  */
 typedef mpq_t number;

-extern boolean m4_mp_evaluate  (struct obstack *obs, const char *,
-                                const int radix, int min);
-static void numb_initialise    (void);
-static void numb_obstack       (struct obstack *obs, const number value,
-                                const int radix, int min);
-static void mpq2mpz            (mpz_t z, const number q,
-                                const char *noisily);
-static void mpz2mpq            (number q, const mpz_t z);
-static void numb_divide                (number *x, const number *y);
-static void numb_modulo                (number *x, const number *y);
-static void numb_and           (number *x, const number *y);
-static void numb_ior           (number *x, const number *y);
-static void numb_eor           (number *x, const number *y);
-static void numb_not           (number *x);
-static void numb_lshift                (number *x, const number *y);
-static void numb_rshift                (number *x, const number *y);
+extern boolean m4_mp_evaluate (struct obstack *obs, const char *,
+                              const int radix, int min);
+static void numb_initialise (void);
+static void numb_obstack (struct obstack *obs, const number value,
+                         const int radix, int min);
+static void mpq2mpz (mpz_t z, const number q, const char *noisily);
+static void mpz2mpq (number q, const mpz_t z);
+static void numb_divide (number *x, const number *y);
+static void numb_modulo (number *x, const number *y);
+static void numb_and (number *x, const number *y);
+static void numb_ior (number *x, const number *y);
+static void numb_eor (number *x, const number *y);
+static void numb_not (number *x);
+static void numb_lshift (number *x, const number *y);
+static void numb_rshift (number *x, const number *y);
+


-
 /**
  * mpeval(EXPRESSION)
  **/
 M4BUILTIN_HANDLER (mpeval)
 {
-  m4_do_eval(obs, argc, argv, m4_mp_evaluate);
+  m4_do_eval (obs, argc, argv, m4_mp_evaluate);
 }


@@ -147,11 +143,11 @@
   if (numb_initialised)
     return;

-  numb_init(numb_ZERO);
-  numb_set_si(&numb_ZERO,0);
+  numb_init (numb_ZERO);
+  numb_set_si (&numb_ZERO, 0);

-  numb_init(numb_ONE);
-  numb_set_si(&numb_ONE,1);
+  numb_init (numb_ONE);
+  numb_set_si (&numb_ONE, 1);

   numb_initialised = 1;
 }
@@ -163,10 +159,10 @@
   const char *s;

   mpz_t i;
-  mpz_init(i);
+  mpz_init (i);

-  mpq_get_num(i,value);
-  s = mpz_get_str((char *)0, radix, i);
+  mpq_get_num (i, value);
+  s = mpz_get_str ((char *) 0, radix, i);

   if (*s == '-')
     {
@@ -179,14 +175,15 @@

   obstack_grow (obs, s, strlen (s));

-  mpq_get_den(i,value);
-  if (mpz_cmp_si(i,(long)1)!=0) {
-    obstack_1grow (obs, ':');
-    s = mpz_get_str((char *)0, radix, i);
-    obstack_grow (obs, s, strlen (s));
-  }
+  mpq_get_den (i, value);
+  if (mpz_cmp_si (i, (long) 1) != 0)
+    {
+      obstack_1grow (obs, ':');
+      s = mpz_get_str ((char *) 0, radix, i);
+      obstack_grow (obs, s, strlen (s));
+    }

-  mpz_clear(i);
+  mpz_clear (i);
 }

 #define NOISY ""
@@ -197,8 +194,8 @@
 {
   if (noisily && mpz_cmp_si (mpq_denref (q), (long) 1) != 0)
     {
-      M4ERROR((warning_status, 0,
-              _("Loss of precision in eval: %s"), noisily));
+      M4ERROR ((warning_status, 0,
+               _("Loss of precision in eval: %s"), noisily));
     }

   mpz_div (z, mpq_numref (q), mpq_denref (q));
@@ -207,240 +204,233 @@
 static void
 mpz2mpq (number q, const mpz_t z)
 {
-  mpq_set_si  (q, (long) 0, (unsigned long) 1);
+  mpq_set_si (q, (long) 0, (unsigned long) 1);
   mpq_set_num (q, z);
 }

 static void
-numb_divide (number *x, const number *y)
+numb_divide (number * x, const number * y)
 {
-   mpq_t qres;
-   mpz_t zres;
+  mpq_t qres;
+  mpz_t zres;

-   mpq_init(qres);
-   mpq_div(qres,*x,*y);
+  mpq_init (qres);
+  mpq_div (qres, *x, *y);

-   mpz_init(zres);
-   mpz_div(zres,mpq_numref(qres),mpq_denref(qres));
-   mpq_clear(qres);
+  mpz_init (zres);
+  mpz_div (zres, mpq_numref (qres), mpq_denref (qres));
+  mpq_clear (qres);

-   mpz2mpq(*x,zres);
-   mpz_clear(zres);
+  mpz2mpq (*x, zres);
+  mpz_clear (zres);
 }

 static void
-numb_modulo (number *x, const number *y)
+numb_modulo (number * x, const number * y)
 {
-   mpz_t xx, yy, res;
+  mpz_t xx, yy, res;

   /* x should be integral */
   /* y should be integral */

-   mpz_init(xx);
-   mpq2mpz(xx,*x,NOISY);
+  mpz_init (xx);
+  mpq2mpz (xx, *x, NOISY);

-   mpz_init(yy);
-   mpq2mpz(yy,*y,NOISY);
+  mpz_init (yy);
+  mpq2mpz (yy, *y, NOISY);

-   mpz_init(res);
-   mpz_mod(res,xx,yy);
+  mpz_init (res);
+  mpz_mod (res, xx, yy);

-   mpz_clear(xx);
-   mpz_clear(yy);
+  mpz_clear (xx);
+  mpz_clear (yy);

-   mpz2mpq(*x,res);
-   mpz_clear(res);
+  mpz2mpq (*x, res);
+  mpz_clear (res);
 }

 static void
-numb_and(number *x, const number *y)
+numb_and (number * x, const number * y)
 {
-   mpz_t xx, yy, res;
+  mpz_t xx, yy, res;

   /* x should be integral */
   /* y should be integral */

-   mpz_init(xx);
-   mpq2mpz(xx,*x,NOISY);
+  mpz_init (xx);
+  mpq2mpz (xx, *x, NOISY);

-   mpz_init(yy);
-   mpq2mpz(yy,*y,NOISY);
+  mpz_init (yy);
+  mpq2mpz (yy, *y, NOISY);

-   mpz_init(res);
-   mpz_and(res,xx,yy);
+  mpz_init (res);
+  mpz_and (res, xx, yy);

-   mpz_clear(xx);
-   mpz_clear(yy);
+  mpz_clear (xx);
+  mpz_clear (yy);

-   mpz2mpq(*x,res);
-   mpz_clear(res);
+  mpz2mpq (*x, res);
+  mpz_clear (res);
 }

 static void
-numb_ior (number *x, const number *y)
+numb_ior (number * x, const number * y)
 {
-   mpz_t xx, yy, res;
+  mpz_t xx, yy, res;

   /* x should be integral */
   /* y should be integral */

-   mpz_init(xx);
-   mpq2mpz(xx,*x,NOISY);
+  mpz_init (xx);
+  mpq2mpz (xx, *x, NOISY);

-   mpz_init(yy);
-   mpq2mpz(yy,*y,NOISY);
+  mpz_init (yy);
+  mpq2mpz (yy, *y, NOISY);

-   mpz_init(res);
-   mpz_ior(res,xx,yy);
+  mpz_init (res);
+  mpz_ior (res, xx, yy);

-   mpz_clear(xx);
-   mpz_clear(yy);
+  mpz_clear (xx);
+  mpz_clear (yy);

-   mpz2mpq(*x,res);
-   mpz_clear(res);
+  mpz2mpq (*x, res);
+  mpz_clear (res);
 }

 static void
-numb_eor (number *x, const number *y)
+numb_eor (number * x, const number * y)
 {
-   mpz_t xx, yy, res;
+  mpz_t xx, yy, res;

   /* x should be integral */
   /* y should be integral */

-   mpz_init(xx);
-   mpq2mpz(xx,*x,NOISY);
+  mpz_init (xx);
+  mpq2mpz (xx, *x, NOISY);

-   mpz_init(yy);
-   mpq2mpz(yy,*y,NOISY);
+  mpz_init (yy);
+  mpq2mpz (yy, *y, NOISY);

-   mpz_init(res);
+  mpz_init (res);

 #if 0
-   mpz_xor(res,xx,yy);
-#else  /* 0 */
-   /* a^b = (a|b) & !(a&b) */
-   {
-     mpz_t and_ab, ior_ab, nand_ab;
-
-     mpz_init(ior_ab);
-     mpz_ior(ior_ab,xx,yy);
-
-     mpz_init(and_ab);
-     mpz_and(and_ab,xx,yy);
-
-     mpz_init(nand_ab);
-     mpz_com(nand_ab,and_ab);
-
-     mpz_and(res,ior_ab,nand_ab);
-
-     mpz_clear(and_ab);
-     mpz_clear(ior_ab);
-     mpz_clear(nand_ab);
-   }
+  mpz_xor (res, xx, yy);
+#else /* 0 */
+  /* a^b = (a|b) & !(a&b) */
+  {
+    mpz_t and_ab, ior_ab, nand_ab;
+
+    mpz_init (ior_ab);
+    mpz_ior (ior_ab, xx, yy);
+
+    mpz_init (and_ab);
+    mpz_and (and_ab, xx, yy);
+
+    mpz_init (nand_ab);
+    mpz_com (nand_ab, and_ab);
+
+    mpz_and (res, ior_ab, nand_ab);
+
+    mpz_clear (and_ab);
+    mpz_clear (ior_ab);
+    mpz_clear (nand_ab);
+  }
 #endif /* 0 */

-   mpz_clear(xx);
-   mpz_clear(yy);
+  mpz_clear (xx);
+  mpz_clear (yy);

-   mpz2mpq(*x,res);
-   mpz_clear(res);
+  mpz2mpq (*x, res);
+  mpz_clear (res);
 }

 static void
-numb_not (number *x)
+numb_not (number * x)
 {
-   mpz_t xx, res;
+  mpz_t xx, res;

   /* x should be integral */

-   mpz_init(xx);
-   mpq2mpz(xx,*x,NOISY);
+  mpz_init (xx);
+  mpq2mpz (xx, *x, NOISY);

-   mpz_init(res);
-   mpz_com(res,xx);
+  mpz_init (res);
+  mpz_com (res, xx);

-   mpz_clear(xx);
+  mpz_clear (xx);

-   mpz2mpq(*x,res);
-   mpz_clear(res);
+  mpz2mpq (*x, res);
+  mpz_clear (res);
 }

 static void
-numb_lshift (number *x, const number *y)
+numb_lshift (number * x, const number * y)
 {
-   mpz_t xx, yy, res;
+  mpz_t xx, yy, res;

   /* x should be integral */
   /* y should be integral */

-   mpz_init(xx);
-   mpq2mpz(xx,*x,NOISY);
+  mpz_init (xx);
+  mpq2mpz (xx, *x, NOISY);

-   mpz_init(yy);
-   mpq2mpz(yy,*y,NOISY);
+  mpz_init (yy);
+  mpq2mpz (yy, *y, NOISY);

-   mpz_init(res);
-   { /* bug: need to determine if y is too big or negative */
-     long int exp = mpz_get_si(yy);
-     if (exp >= 0) {
-       mpz_mul_2exp(res,xx,(unsigned)exp);
-     } else {
-       mpz_div_2exp(res,xx,(unsigned)-exp);
-     }
-   }
+  mpz_init (res);
+  {
+    /* bug: need to determine if y is too big or negative. */
+    long int exp = mpz_get_si (yy);
+    if (exp >= 0)
+      {
+       mpz_mul_2exp (res, xx, (unsigned) exp);
+      }
+    else
+      {
+       mpz_div_2exp (res, xx, (unsigned) -exp);
+      }
+  }

-   mpz_clear(xx);
-   mpz_clear(yy);
+  mpz_clear (xx);
+  mpz_clear (yy);

-   mpz2mpq(*x,res);
-   mpz_clear(res);
+  mpz2mpq (*x, res);
+  mpz_clear (res);
 }

 static void
-numb_rshift (number *x, const number *y)
+numb_rshift (number * x, const number * y)
 {
-   mpz_t xx, yy, res;
+  mpz_t xx, yy, res;

   /* x should be integral */
   /* y should be integral */

-   mpz_init(xx);
-   mpq2mpz(xx,*x,NOISY);
+  mpz_init (xx);
+  mpq2mpz (xx, *x, NOISY);

-   mpz_init(yy);
-   mpq2mpz(yy,*y,NOISY);
+  mpz_init (yy);
+  mpq2mpz (yy, *y, NOISY);

-   mpz_init(res);
-   { /* bug: need to determine if y is too big or negative */
-     long int exp = mpz_get_si(yy);
-     if (exp >= 0) {
-       mpz_div_2exp(res,xx,(unsigned)exp);
-     } else {
-       mpz_mul_2exp(res,xx,(unsigned)-exp);
-     }
-   }
+  mpz_init (res);
+  {                            /* bug: need to determine if y is too big or 
negative */
+    long int exp = mpz_get_si (yy);
+    if (exp >= 0)
+      {
+       mpz_div_2exp (res, xx, (unsigned) exp);
+      }
+    else
+      {
+       mpz_mul_2exp (res, xx, (unsigned) -exp);
+      }
+  }

-   mpz_clear(xx);
-   mpz_clear(yy);
+  mpz_clear (xx);
+  mpz_clear (yy);

-   mpz2mpq(*x,res);
-   mpz_clear(res);
+  mpz2mpq (*x, res);
+  mpz_clear (res);
 }

 #define m4_evaluate m4_mp_evaluate
 #include "evalparse.c"
-
-#else
-
-/**
- * mpeval()
- **/
-M4BUILTIN_HANDLER (mpeval)
-{
-  M4ERROR ((EXIT_FAILURE, 0,
-           _("%s support was not compiled in"), M4ARG(0)));
-  abort ();
-}
-
-#endif /* !WITH_GMP */
Index: tests/Makefile.am
--- tests/Makefile.am Tue, 18 Sep 2001 20:57:18 +0200 akim
+++ tests/Makefile.am Tue, 18 Sep 2001 22:41:29 +0200 akim
@@ -47,19 +47,7 @@ clean-local:
 # FIXME: Autom4te is not complete yet, and lacks a means to find
 # the lib files.
 AUTOM4TE = autom4te
-$(srcdir)/$(TESTSUITE): package.m4 $(TESTSUITE_AT)
-       $(AUTOM4TE) --language=autotest -I $(srcdir) testsuite.at -o 
address@hidden
-       mv address@hidden $@
-
-# Run the test suite on the *installed* tree.
-installcheck-local:
-       $(SHELL) $(srcdir)/$(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin
-
-## ------------ ##
-## package.m4.  ##
-## ------------ ##
-
-package.m4: $(top_srcdir)/configure.in
+$(srcdir)/$(TESTSUITE): $(TESTSUITE_AT)
        {                                       \
          echo '# Signature of the current package.'; \
          echo 'm4_define([PACKAGE_NAME],      address@hidden@])'; \
@@ -68,3 +56,9 @@ package.m4: $(top_srcdir)/configure.in
          echo 'm4_define([PACKAGE_STRING],    address@hidden@])'; \
          echo 'm4_define([PACKAGE_BUGREPORT], address@hidden@])'; \
        } >package.m4
+       $(AUTOM4TE) --language=autotest -I $(srcdir) testsuite.at -o 
address@hidden
+       mv address@hidden $@
+
+# Run the test suite on the *installed* tree.
+installcheck-local:
+       $(SHELL) $(srcdir)/$(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin
Index: tests/atlocal.in
--- tests/atlocal.in Mon, 03 Sep 2001 15:40:52 +0200 akim
+++ tests/atlocal.in Tue, 18 Sep 2001 22:31:48 +0200 akim
@@ -1,7 +1,7 @@
 # -*- shell-script -*-
-# @configure_generated@
+# @configure_input@
 # Configurable variable values for M4 test suite.
 # Copyright 2000, 2001 Free Software Foundation, Inc.

 # Some tests cannot be performed with all the configurations.
address@hidden@
address@hidden@
Index: tests/builtins.at
--- tests/builtins.at Tue, 18 Sep 2001 20:57:18 +0200 akim
+++ tests/builtins.at Tue, 18 Sep 2001 22:29:28 +0200 akim
@@ -19,20 +19,20 @@
 AT_BANNER([Torturing builtins.])


-## ------- ##
-## ddivert ##
-## ------- ##
+## ------ ##
+## divert ##
+## ------ ##

-AT_SETUP([ddivert])
+AT_SETUP([[divert]])

-AT_DATA([[ddivert.m4]],
+AT_DATA([[divert.m4]],
 [[divert(1)Text diverted a first time.
 divert(0)undivert(1)dnl
 divert(1)Text diverted a second time.
 divert(0)undivert(1)dnl
 ]])

-AT_CHECK_M4([ddivert.m4], 0,
+AT_CHECK_M4([divert.m4], 0,
 [[Text diverted a first time.
 Text diverted a second time.
 ]])
@@ -140,7 +140,7 @@ m4trace: -1- countdown(...) -> `0 ifelse
 AT_SETUP([gmp])

 # cannot perform test without --with-gmp
-AT_CHECK([test "$WITH_GMP" = yes || exit 77])
+AT_CHECK([test "$USE_GMP" = yes || exit 77])

 AT_DATA([[in]],
 [[divert(-1)















Aaaaaaaaaaaaaaaaaaaarg!  It's looks like my left CTRL key is dead !!!!



reply via email to

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