[project @ 1998-06-05 14:37:45 by simonm]
authorsimonm <unknown>
Fri, 5 Jun 1998 14:37:46 +0000 (14:37 +0000)
committersimonm <unknown>
Fri, 5 Jun 1998 14:37:46 +0000 (14:37 +0000)
Initial revision

12 files changed:
ghc/rts/gmp/Makefile.in [new file with mode: 0644]
ghc/rts/gmp/PROJECTS [new file with mode: 0644]
ghc/rts/gmp/SPEED [new file with mode: 0644]
ghc/rts/gmp/config.guess [new file with mode: 0644]
ghc/rts/gmp/config.sub [new file with mode: 0644]
ghc/rts/gmp/configure [new file with mode: 0644]
ghc/rts/gmp/configure.in [new file with mode: 0644]
ghc/rts/gmp/cre-mparam.c [new file with mode: 0644]
ghc/rts/gmp/extract-double.c [new file with mode: 0644]
ghc/rts/gmp/gmp-impl.h [new file with mode: 0644]
ghc/rts/gmp/gmp.h [new file with mode: 0644]
ghc/rts/gmp/insert-double.c [new file with mode: 0644]

diff --git a/ghc/rts/gmp/Makefile.in b/ghc/rts/gmp/Makefile.in
new file mode 100644 (file)
index 0000000..d8e7be9
--- /dev/null
@@ -0,0 +1,196 @@
+# Top Makefile for GNU MP
+# Copyright (C) 1991, 1993, 1994, 1996 Free Software Foundation, Inc.
+
+# This file is part of the GNU MP Library.
+
+# The GNU MP Library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Library General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+
+# The GNU MP Library is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+# License for more details.
+
+# You should have received a copy of the GNU Library General Public License
+# along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+# MA 02111-1307, USA.
+
+srcdir = .
+
+prefix = /usr/local
+
+exec_prefix = $(prefix)
+libdir = $(exec_prefix)/lib
+infodir = $(prefix)/info
+includedir = $(prefix)/include
+
+CC = gcc
+LOCAL_CC = $(CC)
+CFLAGS = -O
+XCFLAGS = 
+AR = ar
+AR_FLAGS = rc
+RANLIB_TEST = [ -f /usr/bin/ranlib -o -f /bin/ranlib ]
+RANLIB = ranlib
+SHELL = /bin/sh
+INSTALL = $(srcdir)/install.sh -c
+INSTALL_PROGRAM = $(INSTALL)
+INSTALL_DATA = $(INSTALL)
+MAKEINFO = makeinfo
+MAKEINFOFLAGS =
+TEXI2DVI = texi2dvi
+LN = ln -s
+
+#### host and target specific makefile fragments come in here.
+###
+
+SRCS = memory.c mp_set_fns.c mp_clz_tab.c version.c stack-alloc.c mp_bpl.c \
+  extract-double.c insert-double.c
+OBJS = memory.o mp_set_fns.o mp_clz_tab.o version.o stack-alloc.o mp_bpl.o \
+  extract-double.o insert-double.o
+FILES = gmp.h mp.h gmp-impl.h longlong.h urandom.h move-if-change \
+ mkinstalldirs INSTALL COPYING.LIB ChangeLog Makefile.in \
+ NEWS README SPEED TODO config.guess config.sub configure configure.in \
+ gmp.info* gmp.texi texinfo.tex $(SRCS)
+
+INCLUDES = -I. -Impn -I$(srcdir)
+FLAGS_TO_PASS = "CC=$(CC)" "CFLAGS=$(CFLAGS)" "XCFLAGS=$(XCFLAGS)"
+
+all: libgmp.a
+
+.c.o:
+       $(CC) -c $(INCLUDES) $(CFLAGS) $(XCFLAGS) $<
+
+libgmp.a: mpn/libmpn.a mpz/libmpz.a $(OBJS)
+       rm -rf tmpdir
+       mkdir tmpdir
+       for i in mpn mpz; \
+         do \
+           mkdir tmpdir/$$i; \
+           ( cd tmpdir/$$i; $(AR) x ../../$$i/lib$$i.a ); \
+         done
+       cp $(OBJS) tmpdir
+       cd tmpdir; $(AR) $(AR_FLAGS) $@ *.o */*.o
+       if $(RANLIB_TEST) ; then $(RANLIB) tmpdir/$@; else true; fi
+       mv tmpdir/$@ .
+       rm -rf tmpdir
+
+libmp.a: mpn/libmpn.a mpbsd/libmpbsd.a $(OBJS)
+       rm -rf tmpdir
+       mkdir tmpdir
+       for i in mpn mpbsd; \
+         do \
+           mkdir tmpdir/$$i; \
+           ( cd tmpdir/$$i; $(AR) x ../../$$i/lib$$i.a ); \
+         done
+       cp $(OBJS) tmpdir
+       cd tmpdir; $(AR) $(AR_FLAGS) $@ *.o */*.o
+       if $(RANLIB_TEST) ; then $(RANLIB) tmpdir/$@; else true; fi
+       mv tmpdir/$@ .
+       rm -rf tmpdir
+
+mpn/libmpn.a: force
+       cd mpn; $(MAKE) $(FLAGS_TO_PASS) libmpn.a
+mpz/libmpz.a: force
+       cd mpz; $(MAKE) $(FLAGS_TO_PASS) libmpz.a
+
+check: libgmp.a
+       cd mpz/tests; $(MAKE) $(FLAGS_TO_PASS) check
+
+doc: gmp.dvi gmp.info
+
+info: $(srcdir)/gmp.info
+$(srcdir)/gmp.info: $(srcdir)/gmp.texi
+       cd $(srcdir); $(MAKEINFO) gmp.texi
+
+dvi: gmp.dvi
+gmp.dvi: $(srcdir)/gmp.texi
+       rm -f tmp.texi
+       $(LN) $(srcdir)/gmp.texi tmp.texi
+       TEXINPUTS=.:$(srcdir) $(TEXI2DVI) tmp.texi
+       rm -f tmp.texi
+       mv tmp.dvi gmp.dvi
+       rm -f tmp.*
+
+ps: gmp.ps
+gmp.ps: gmp.dvi
+       dvips gmp.dvi -o gmp.ps
+
+html: gmp_toc.html
+gmp_toc.html: $(srcdir)/gmp.texi
+       texi2html -acc -split_chapter $(srcdir)/gmp.texi
+
+# The semicolon is to prevent the install.sh -> install default rule
+# from doing anything.  Having it run true helps avoid problems and
+# noise from versions of make which don't like to have null commands.
+install: install-normal ; @true
+
+install-strip: install-normal
+install-normal: installdirs libgmp.a
+       $(INSTALL_DATA) libgmp.a $(libdir)/libgmp.a
+       -chmod a-x $(libdir)/libgmp.a
+#      $(INSTALL_DATA) $(srcdir)/gmp.h $(includedir)/gmp.h
+#      -chmod a-x $(includedir)/gmp.h
+install-bsdmp: installdirs libmp.a gmp.info install-info-files
+       $(INSTALL_DATA) libmp.a $(libdir)/libmp.a
+       -chmod a-x $(libdir)/libmp.a
+       $(INSTALL_DATA) $(srcdir)/mp.h $(includedir)/mp.h
+       -chmod a-x $(includedir)/mp.h
+install-info-files: installdirs $(srcdir)/gmp.info
+       cd $(srcdir); for f in gmp.info*; \
+       do $(INSTALL_DATA) $$f $(infodir)/$$f; done
+       -chmod a-x $(infodir)/gmp.info*
+       # Attempt to edit the info directory node
+       if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
+         install-info --dir-file=$(infodir)/dir $(infodir)/gmp.info; \
+         else true; fi
+
+installdirs: $(srcdir)/mkinstalldirs
+       $(srcdir)/mkinstalldirs $(includedir) $(libdir) $(infodir)
+
+uninstall:
+       rm -f $(libdir)/libgmp.a
+       rm -f $(includedir)/gmp.h
+       rm -f $(libdir)/libmp.a
+       rm -f $(includedir)/mp.h
+       rm -f $(infodir)/gmp.info*
+
+clean mostlyclean:
+       rm -f *.o libgmp.a libmp.a gmp.dvi gmp.ps tmp.* tmp-*
+       rm -f gmp.?? gmp.??s gmp.log gmp.toc gmp.*aux gmp*.html
+       -cd mpn; $(MAKE) $@
+       -cd mpz; $(MAKE) $@
+distclean: clean
+       rm -f Makefile config.status
+       -cd mpn; $(MAKE) $@
+       -cd mpz; $(MAKE) $@
+maintainer-clean: distclean
+       rm -f $(srcdir)/gmp.info*
+
+TAGS: force
+       cd $(srcdir); etags *.[ch] mp*/*.c mpn/generic/*.c >TAGS
+
+dist:
+       @echo "sorry, not supported target"
+       @exit 1
+
+Makefile: $(srcdir)/Makefile.in $(host_makefile_frag) $(target_makefile_frag)
+       $(SHELL) ./config.status
+
+H = $(srcdir)/gmp.h $(srcdir)/gmp-impl.h mpn/gmp-mparam.h
+
+extract-double.o: $(srcdir)/extract-double.c $(H)
+insert-double.o: $(srcdir)/insert-double.c $(H)
+memory.o: $(srcdir)/memory.c $(H)
+mp_bpl.o: $(srcdir)/mp_bpl.c
+mp_clz_tab.o: $(srcdir)/mp_clz_tab.c
+mp_set_fns.o: $(srcdir)/mp_set_fns.c $(H)
+stack-alloc.o: $(srcdir)/stack-alloc.c $(srcdir)/stack-alloc.h
+version.o: $(srcdir)/version.c
+
+force:
+.PNONY: check install install-bsdmp install-info-files install-strip uninstall
+.PHONY: doc clean distclean maintainer-clean force info dvi
diff --git a/ghc/rts/gmp/PROJECTS b/ghc/rts/gmp/PROJECTS
new file mode 100644 (file)
index 0000000..75016bd
--- /dev/null
@@ -0,0 +1,270 @@
+IDEAS ABOUT THINGS TO WORK ON
+
+* mpq_cmp: Maybe the most sensible thing to do would be to multiply the, say,
+  4 most significant limbs of each operand and compare them.  If that is not
+  sufficient, do the same for 8 limbs, etc.
+
+* Write mpi, the Multiple Precision Interval Arithmetic layer.
+
+* Write `mpX_eval' that take lambda-like expressions and a list of operands.
+
+* As a general rule, recognize special operand values in mpz and mpf, and
+  use shortcuts for speed.  Examples: Recognize (small or all) 2^n in
+  multiplication and division.  Recognize small bases in mpz_pow_ui.
+
+* Implement lazy allocation?  mpz->d == 0 would mean no allocation made yet.
+
+* Maybe store one-limb numbers according to Per Bothner's idea:
+    struct {
+      mp_ptr d;
+      union {
+       mp_limb val;    /* if (d == NULL).  */
+        mp_size size;   /* Length of data array, if (d != NULL).  */
+      } u;
+    };
+  Problem: We can't normalize to that format unless we free the space
+  pointed to by d, and therefore small values will not be stored in a
+  canonical way.
+
+* Document complexity of all functions.
+
+* Add predicate functions mpz_fits_signedlong_p, mpz_fits_unsignedlong_p,
+  mpz_fits_signedint_p, etc.
+
+  mpz_floor (mpz, mpq), mpz_trunc (mpz, mpq), mpz_round (mpz, mpq).
+
+* Better random number generators.  There should be fast (like mpz_random),
+  very good (mpz_veryrandom), and special purpose (like mpz_random2).  Sizes
+  in *bits*, not in limbs.
+
+* It'd be possible to have an interface "s = add(a,b)" with automatic GC.
+  If the mpz_xinit routine remembers the address of the variable we could
+  walk-and-mark the list of remembered variables, and free the space
+  occupied by the remembered variables that didn't get marked.  Fairly
+  standard.
+
+* Improve speed for non-gcc compilers by defining umul_ppmm, udiv_qrnnd,
+  etc, to call __umul_ppmm, __udiv_qrnnd.  A typical definition for
+  umul_ppmm would be
+  #define umul_ppmm(ph,pl,m0,m1) \
+    {unsigned long __ph; (pl) = __umul_ppmm (&__ph, (m0), (m1)); (ph) = __ph;}
+  In order to maintain just one version of longlong.h (gmp and gcc), this
+  has to be done outside of longlong.h.
+
+Bennet Yee at CMU proposes:
+* mpz_{put,get}_raw for memory oriented I/O like other *_raw functions.
+* A function mpfatal that is called for exceptions.  Let the user override
+  a default definition.
+
+* Make all computation mpz_* functions return a signed int indicating if the
+  result was zero, positive, or negative?
+
+* Implement mpz_cmpabs, mpz_xor, mpz_to_double, mpz_to_si, mpz_lcm, mpz_dpb,
+  mpz_ldb, various bit string operations.  Also mpz_@_si for most @??
+
+* Add macros for looping efficiently over a number's limbs:
+       MPZ_LOOP_OVER_LIMBS_INCREASING(num,limb)
+         { user code manipulating limb}
+       MPZ_LOOP_OVER_LIMBS_DECREASING(num,limb)
+         { user code manipulating limb}
+
+Brian Beuning proposes:
+   1. An array of small primes
+   3. A function to factor a mpz_t.  [How do we return the factors?  Maybe
+      we just return one arbitrary factor?  In the latter case, we have to
+      use a data structure that records the state of the factoring routine.]
+   4. A routine to look for "small" divisors of an mpz_t
+   5. A 'multiply mod n' routine based on Montgomery's algorithm.
+
+Dough Lea proposes:
+   1. A way to find out if an integer fits into a signed int, and if so, a
+      way to convert it out.
+   2. Similarly for double precision float conversion.
+   3. A function to convert the ratio of two integers to a double.  This
+      can be useful for mixed mode operations with integers, rationals, and
+      doubles.
+
+Elliptic curve method description in the Chapter `Algorithms in Number
+Theory' in the Handbook of Theoretical Computer Science, Elsevier,
+Amsterdam, 1990.  Also in Carl Pomerance's lecture notes on Cryptology and
+Computational Number Theory, 1990.
+
+* Harald Kirsh suggests:
+  mpq_set_str (MP_RAT *r, char *numerator, char *denominator).
+
+* New function: mpq_get_ifstr (int_str, frac_str, base,
+  precision_in_som_way, rational_number).  Convert RATIONAL_NUMBER to a
+  string in BASE and put the integer part in INT_STR and the fraction part
+  in FRAC_STR.  (This function would do a division of the numerator and the
+  denominator.)
+
+* Should mpz_powm* handle negative exponents?
+
+* udiv_qrnnd: If the denominator is normalized, the n0 argument has very
+  little effect on the quotient.  Maybe we can assume it is 0, and
+  compensate at a later stage?
+
+* Better sqrt: First calculate the reciprocal square root, then multiply by
+  the operand to get the square root.  The reciprocal square root can be
+  obtained through Newton-Raphson without division.  To compute sqrt(A), the
+  iteration is,
+
+                                   2
+                  x   = x  (3 - A x )/2.
+                   i+1   i         i
+
+  The final result can be computed without division using,
+
+                    sqrt(A) = A x .
+                                 n
+
+* Newton-Raphson using multiplication: We get twice as many correct digits
+  in each iteration.  So if we square x(k) as part of the iteration, the
+  result will have the leading digits in common with the entire result from
+  iteration k-1.  A _mpn_mul_lowpart could help us take advantage of this.
+
+* Peter Montgomery: If 0 <= a, b < p < 2^31 and I want a modular product
+  a*b modulo p and the long long type is unavailable, then I can write
+
+         typedef   signed long slong;
+         typedef unsigned long ulong;
+         slong a, b, p, quot, rem;
+
+         quot = (slong) (0.5 + (double)a * (double)b / (double)p);
+         rem =  (slong)((ulong)a * (ulong)b - (ulong)p * (ulong)quot);
+         if (rem < 0} {rem += p; quot--;}
+
+* Speed modulo arithmetic, using Montgomery's method or my pre-inversion
+  method.  In either case, special arithmetic calls would be needed,
+  mpz_mmmul, mpz_mmadd, mpz_mmsub, plus some kind of initialization
+  functions.  Better yet: Write a new mpr layer.
+
+* mpz_powm* should not use division to reduce the result in the loop, but
+  instead pre-compute the reciprocal of the MOD argument and do reduced_val
+  = val-val*reciprocal(MOD)*MOD, or use Montgomery's method.
+
+* mpz_mod_2expplussi -- to reduce a bignum modulo (2**n)+s
+
+* It would be a quite important feature never to allocate more memory than
+  really necessary for a result.  Sometimes we can achieve this cheaply, by
+  deferring reallocation until the result size is known.
+
+* New macro in longlong.h: shift_rhl that extracts a word by shifting two
+  words as a unit.  (Supported by i386, i860, HP-PA, POWER, 29k.)  Useful
+  for shifting multiple precision numbers.
+
+* The installation procedure should make a test run of multiplication to
+  decide the threshold values for algorithm switching between the available
+  methods.
+
+* Fast output conversion of x to base B:
+    1. Find n, such that (B^n > x).
+    2. Set y to (x*2^m)/(B^n), where m large enough to make 2^n ~~ B^n
+    3. Multiply the low half of y by B^(n/2), and recursively convert the
+       result.  Truncate the low half of y and convert that recursively.
+  Complexity: O(M(n)log(n))+O(D(n))!
+
+* Improve division using Newton-Raphson.  Check out "Newton Iteration and
+  Integer Division" by Stephen Tate in "Synthesis of Parallel Algorithms",
+  Morgan Kaufmann, 1993 ("beware of some errors"...)
+
+* Improve implementation of Karatsuba's algorithm.  For most operand sizes,
+  we can reduce the number of operations by splitting differently.
+
+* Faster multiplication: The best approach is to first implement Toom-Cook.
+  People report that it beats Karatsuba's algorithm already at about 100
+  limbs.  FFT would probably never beat a well-written Toom-Cook (not even for
+  millions of bits).
+
+FFT:
+{
+  * Multiplication could be done with Montgomery's method combined with
+    the "three primes" method described in Lipson.  Maybe this would be
+    faster than to Nussbaumer's method with 3 (simple) moduli?
+
+  * Maybe the modular tricks below are not needed: We are using very
+    special numbers, Fermat numbers with a small base and a large exponent,
+    and maybe it's possible to just subtract and add?
+
+  * Modify Nussbaumer's convolution algorithm, to use 3 words for each
+    coefficient, calculating in 3 relatively prime moduli (e.g.
+    0xffffffff, 0x100000000, and 0x7fff on a 32-bit computer).  Both all
+    operations and CRR would be very fast with such numbers.
+
+  * Optimize the Schoenhage-Stassen multiplication algorithm.  Take advantage
+    of the real valued input to save half of the operations and half of the
+    memory.  Use recursive FFT with large base cases, since recursive FFT has
+    better memory locality.  A normal FFT get 100% cache misses for large
+    enough operands.
+
+  * In the 3-prime convolution method, it might sometimes be a win to use 2,
+    3, or 5 primes.  Imagine that using 3 primes would require a transform
+    length of 2^n.  But 2 primes might still sometimes give us correct
+    results with that same transform length, or 5 primes might allow us to
+    decrease the transform size to 2^(n-1).
+
+  To optimize floating-point based complex FFT we have to think of:
+
+  1. The normal implementation accesses all input exactly once for each of
+     the log(n) passes.  This means that we will get 0% cache hit when n >
+     our cache.  Remedy: Reorganize computation to compute partial passes,
+     maybe similar to a standard recursive FFT implementation.  Use a large
+     `base case' to make any extra overhead of this organization negligible.
+
+  2. Use base-4, base-8 and base-16 FFT instead of just radix-2.  This can
+     reduce the number of operations by 2x.
+
+  3. Inputs are real-valued.  According to Knuth's "Seminumerical
+     Algorithms", exercise 4.6.4-14, we can save half the memory and half
+     the operations if we take advantage of that.
+
+  4. Maybe make it possible to write the innermost loop in assembly, since
+     that could win us another 2x speedup.  (If we write our FFT to avoid
+     cache-miss (see #1 above) it might be logical to write the `base case'
+     in assembly.)
+
+  5. Avoid multiplication by 1, i, -1, -i.  Similarly, optimize
+     multiplication by (+-\/2 +- i\/2).
+
+  6. Put as many bits as possible in each double (but don't waste time if
+     that doesn't make the transform size become smaller).
+
+  7. For n > some large number, we will get accuracy problems because of the
+     limited precision of our floating point arithmetic.  This can easily be
+     solved by using the Karatsuba trick a few times until our operands
+     become small enough.
+
+  8. Precompute the roots-of-unity and store them in a vector.
+}
+
+* When a division result is going to be just one limb, (i.e. nsize-dsize is
+  small) normalization could be done in the division loop.
+
+* Never allocate temporary space for a source param that overlaps with a
+  destination param needing reallocation.  Instead malloc a new block for
+  the destination (and free the source before returning to the caller).
+
+* Parallel addition.  Since each processors have to tell it is ready to the
+  next processor, we can use simplified synchronization, and actually write
+  it in C:  For each processor (apart from the least significant):
+
+       while (*svar != my_number)
+         ;
+       *svar = my_number + 1;
+
+  The least significant processor does this:
+
+       *svar = my_number + 1;  /* i.e., *svar = 1 */
+
+  Before starting the addition, one processor has to store 0 in *svar.
+
+  Other things to think about for parallel addition: To avoid false
+  (cache-line) sharing, allocate blocks on cache-line boundaries.
+
+\f
+Local Variables:
+mode: text
+fill-column: 77
+fill-prefix: "  "
+version-control: never
+End:
diff --git a/ghc/rts/gmp/SPEED b/ghc/rts/gmp/SPEED
new file mode 100644 (file)
index 0000000..e888e17
--- /dev/null
@@ -0,0 +1,156 @@
+==============================================================================
+Cycle counts and throughput for low-level routines in GNU MP as currently
+implemented.
+
+A range means that the timing is data-dependent.  The slower number of such
+an interval is usually the best performance estimate.
+
+The throughput value, measured in Gb/s (gigabits per second) has a meaning
+only for comparison between CPUs.
+
+A star before a line means that all values on that line are estimates.  A
+star before a number means that that number is an estimate.  A `p' before a
+number means that the code is not complete, but the timing is believed to be
+accurate.
+
+           |   mpn_lshift      mpn_add_n       mpn_mul_1       mpn_addmul_1
+           |   mpn_rshift      mpn_sub_n                       mpn_submul_1
+------------+-----------------------------------------------------------------
+DEC/Alpha   |
+EV4        |   4.75 cycles/64b 7.75 cycles/64b 42 cycles/64b   42 cycles/64b
+  200MHz    |  2.7 Gb/s        1.65 Gb/s       20 Gb/s         20 Gb/s
+EV5 old code|  4.0 cycles/64b  5.5 cycles/64b  18 cycles/64b   18 cycles/64b
+  267MHz    |  4.27 Gb/s       3.10 Gb/s       61 Gb/s         61 Gb/s
+  417MHz    |  6.67 Gb/s       4.85 Gb/s       95 Gb/s         95 Gb/s
+EV5 tuned   |  3.25 cycles/64b 4.75 cycles/64b
+  267MHz    |  5.25 Gb/s       3.59 Gb/s               as above
+  417MHz    |  8.21 Gb/s       5.61 Gb/s
+------------+-----------------------------------------------------------------
+Sun/SPARC   |
+SPARC v7    |  14.0 cycles/32b 8.5 cycles/32b  37-54 cycl/32b  37-54 cycl/32b
+SuperSPARC  |  3 cycles/32b    2.5 cycles/32b  8.2 cycles/32b  10.8 cycles/32b
+  50MHz            |   0.53 Gb/s       0.64 Gb/s       6.2 Gb/s        4.7 Gb/s
+**SuperSPARC|          tuned addmul and submul will take:      9.25 cycles/32b
+MicroSPARC2 |  ?               6.65 cycles/32b 30 cycles/32b   31.5 cycles/32b
+  110MHz    |  ?               0.53 Gb/s       3.75 Gb/s       3.58 Gb/s
+SuperSPARC2 |  ?               ?               ?               ?
+Ultra/32 (4)|  2.5 cycles/32b  6.5 cycles/32b  13-27 cyc/32b   16-30 cyc/32b
+  182MHz    |  2.33 Gb/s       0.896 Gb/s      14.3-6.9 Gb/s
+Ultra/64 (5)|  2.5 cycles/64b  10 cycles/64b   40-70 cyc/64b   46-76 cyc/64b
+  182MHz    |  4.66 Gb/s       1.16 Gb/s       18.6-11 Gb/s
+HalSPARC64  |  ?               ?               ?               ?
+------------+-----------------------------------------------------------------
+SGI/MIPS    |
+R3000      |   6 cycles/32b    9.25 cycles/32b 16 cycles/32b   16 cycles/32b
+  40MHz     |  0.21 Gb/s       0.14 Gb/s       2.56 Gb/s       2.56 Gb/s
+R4400/32    |  8.6 cycles/32b  10 cycles/32b   16-18           19-21
+  200MHz    |  0.74 Gb/s       0.64 Gb/s       13-11 Gb/s      11-9.6 Gb/s
+*R4400/64   |  8.6 cycles/64b  10 cycles/64b   22 cycles/64b   22 cycles/64b
+  *200MHz   |  1.48 Gb/s       1.28 Gb/s       37 Gb/s         37 Gb/s
+R4600/32    |  6 cycles/64b    9.25 cycles/32b 15 cycles/32b   19 cycles/32b
+  134MHz    |  0.71 Gb/s       0.46 Gb/s       9.1 Gb/s        7.2 Gb/s
+R4600/64    |  6 cycles/64b    9.25 cycles/64b ?               ?
+  134MHz    |  1.4 Gb/s        0.93 Gb/s       ?               ?
+R8000/64    |  3 cycles/64b    4.6 cycles/64b  8 cycles/64b    8 cycles/64b
+  75MHz            |   1.6 Gb/s        1.0 Gb/s        38 Gb/s         38 Gb/s
+*R10000/64  |  2 cycles/64b    3 cycles/64b    11 cycles/64b   11 cycles/64b
+  *200MHz   |  6.4 Gb/s        4.27 Gb/s       74 Gb/s         74 Gb/s
+  *250MHz   |  8.0 Gb/s        5.33 Gb/s       93 Gb/s         93 Gb/s
+------------+-----------------------------------------------------------------
+Motorola    |
+MC68020     |  ?               24 cycles/32b   62 cycles/32b   70 cycles/32b
+MC68040     |  ?               6 cycles/32b    24 cycles/32b   25 cycles/32b
+MC88100            |   >5 cycles/32b   4.6 cycles/32b  16/21 cyc/32b   p 18/23 cyc/32b
+MC88110  wt |  ?               3.75 cycles/32b 6 cycles/32b    8.5 cyc/32b
+*MC88110 wb |  ?               2.25 cycles/32b 4 cycles/32b    5 cycles/32b
+------------+-----------------------------------------------------------------
+HP/PA-RISC  |
+PA7000     |   4 cycles/32b    5 cycles/32b    9 cycles/32b    11 cycles/32b
+  67MHz            |   0.53 Gb/s       0.43 Gb/s       7.6 Gb/s        6.2 Gb/s
+PA7100     |   3.25 cycles/32b 4.25 cycles/32b 7 cycles/32b    8 cycles/32b
+  99MHz            |   0.97 Gb/s       0.75 Gb/s       14 Gb/s         12.8 Gb/s
+PA7100LC    |  ?               ?               ?               ?
+PA7200  (3) |  3 cycles/32b    4 cycles/32b    7 cycles/32b    6.5 cycles/32b
+  100MHz    |  1.07 Gb/s       0.80            14 Gb/s         15.8 Gb/s
+PA7300LC    |  ?               ?               ?               ?
+*PA8000            |   3 cycles/64b    4 cycles/64b    7 cycles/64b    6.5 cycles/64b
+  180MHz    |  3.84 Gb/s       2.88 Gb/s       105 Gb/s        113 Gb/s
+------------+-----------------------------------------------------------------
+Intel/x86   |
+386DX      |   20 cycles/32b   17 cycles/32b   41-70 cycl/32b  50-79 cycl/32b
+  16.7MHz   |  0.027 Gb/s      0.031 Gb/s      0.42-0.24 Gb/s  0.34-0.22 Gb/s
+486DX      |   ?               ?               ?               ?
+486DX4     |   9.5 cycles/32b  9.25 cycles/32b 17-23 cycl/32b  20-26 cycl/32b
+  100MHz    |  0.34 Gb/s       0.35 Gb/s       6.0-4.5 Gb/s    5.1-3.9 Gb/s
+Pentium     |  2/6 cycles/32b  2.5 cycles/32b  13 cycles/32b   14 cycles/32b
+  167MHz    |  2.7/0.89 Gb/s   2.1 Gb/s        13.1 Gb/s       12.2 Gb/s
+Pentium Pro |  2.5 cycles/32b  3.5 cycles/32b  6 cycles/32b    9 cycles/32b
+  200MHz    |  2.6 Gb/s        1.8 Gb/s        34 Gb/s         23 Gb/s
+------------+-----------------------------------------------------------------
+IBM/POWER   |
+RIOS 1     |   3 cycles/32b    4 cycles/32b    11.5-12.5 c/32b 14.5/15.5 c/32b
+RIOS 2     |   2 cycles/32b    2 cycles/32b    7 cycles/32b    8.5 cycles/32b
+------------+-----------------------------------------------------------------
+PowerPC            |
+PPC601  (1) |  3 cycles/32b    6 cycles/32b    11-16 cycl/32b  14-19 cycl/32b
+PPC601  (2) |  5 cycles/32b    6 cycles/32b    13-22 cycl/32b  16-25 cycl/32b
+  67MHz (2) |  0.43 Gb/s       0.36 Gb/s       5.3-3.0 Gb/s    4.3-2.7 Gb/s
+PPC603     |   ?               ?               ?               ?
+*PPC604            |   2               3               2               3
+  *167MHz   |                                                  57 Gb/s
+PPC620     |   ?               ?               ?               ?
+------------+-----------------------------------------------------------------
+Tege       |
+Model 1            |   2 cycles/64b    3 cycles/64b    2 cycles/64b    3 cycles/64b
+  250MHz    |  8 Gb/s          5.3 Gb/s        500 Gb/s        340 Gb/s
+  500MHz    |  16 Gb/s         11 Gb/s         1000 Gb/s       680 Gb/s
+____________|_________________________________________________________________
+(1) Using POWER and PowerPC instructions
+(2) Using only PowerPC instructions
+(3) Actual timing for shift/add/sub depends on code alignment.  PA7000 code
+    is smaller and therefore often faster on this CPU.
+(4) Multiplication routines modified for bogus UltraSPARC early-out
+    optimization.  Smaller operand is put in rs1, not rs2 as it should
+    according to the SPARC architecture manuals.
+(5) Preliminary timings, since there is no stable 64-bit environment.
+(6) Use mulu.d at least for mpn_lshift.  With mak/extu/or, we can only get
+    to 2 cycles/32b.
+
+=============================================================================
+Estimated theoretical asymptotic cycle counts for low-level routines:
+
+           |   mpn_lshift      mpn_add_n       mpn_mul_1       mpn_addmul_1
+           |   mpn_rshift      mpn_sub_n                       mpn_submul_1
+------------+-----------------------------------------------------------------
+DEC/Alpha   |
+EV4        |   3 cycles/64b    5 cycles/64b    42 cycles/64b   42 cycles/64b
+EV5        |   3 cycles/64b    4 cycles/64b    18 cycles/64b   18 cycles/64b
+------------+-----------------------------------------------------------------
+Sun/SPARC   |
+SuperSPARC  |  2.5 cycles/32b  2 cycles/32b    8 cycles/32b    9 cycles/32b
+------------+-----------------------------------------------------------------
+SGI/MIPS    |
+R4400/32    |  5 cycles/64b    8 cycles/64b    16 cycles/64b   16 cycles/64b
+R4400/64    |  5 cycles/64b    8 cycles/64b    22 cycles/64b   22 cycles/64b
+R4600      |
+------------+-----------------------------------------------------------------
+HP/PA-RISC  |
+PA7100     |   3 cycles/32b    4 cycles/32b    6.5 cycles/32b  7.5 cycles/32b
+PA7100LC    |
+------------+-----------------------------------------------------------------
+Motorola    |
+MC88110            |   1.5 cyc/32b (6) 1.5 cycle/32b   1.5 cycles/32b  2.25 cycles/32b
+------------+-----------------------------------------------------------------
+Intel/x86   |
+486DX4     |
+Pentium P5x |  5 cycles/32b    2 cycles/32b    11.5 cycles/32b 13 cycles/32b
+Pentium Pro |  2 cycles/32b    3 cycles/32b    4 cycles/32b    6 cycles/32b
+------------+-----------------------------------------------------------------
+IBM/POWER   |
+RIOS 1     |   3 cycles/32b    4 cycles/32b
+RIOS 2     |   1.5 cycles/32b  2 cycles/32b    4.5 cycles/32b  5.5 cycles/32b
+------------+-----------------------------------------------------------------
+PowerPC            |
+PPC601  (1) |  3 cycles/32b    ?4 cycles/32b
+PPC601  (2) |  4 cycles/32b    ?4 cycles/32b
+____________|_________________________________________________________________
diff --git a/ghc/rts/gmp/config.guess b/ghc/rts/gmp/config.guess
new file mode 100644 (file)
index 0000000..afd200a
--- /dev/null
@@ -0,0 +1,592 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright (C) 1992, 93, 94, 95, 1996 Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Written by Per Bothner <bothner@cygnus.com>.
+# The master version of this file is at the FSF in /home/gd/gnu/lib.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub.  If it succeeds, it prints the system name on stdout, and
+# exits with 0.  Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit system type (host/target name).
+#
+# Only a few systems have been added to this list; please add others
+# (but try to keep the structure clean).
+#
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 8/24/94.)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+       PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    alpha:OSF1:[VX]*:*)
+       # After 1.2, OSF1 uses "V1.3" for uname -r.
+       # After 4.x, OSF1 uses "X4.x" for uname -r.
+       echo alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VX]//'`
+       exit 0 ;;
+    alpha:OSF1:*:*)
+       # 1.2 uses "1.2" for uname -r.
+       echo alpha-dec-osf${UNAME_RELEASE}
+        exit 0 ;;
+    21064:Windows_NT:50:3)
+       echo alpha-dec-winnt3.5
+       exit 0 ;;
+    Amiga*:UNIX_System_V:4.0:*)
+       echo m68k-cbm-sysv4
+       exit 0;;
+    amiga:NetBSD:*:*)
+      echo m68k-cbm-netbsd${UNAME_RELEASE}
+      exit 0 ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+       echo arm-acorn-riscix${UNAME_RELEASE}
+       exit 0;;
+    Pyramid*:OSx*:*:*)
+       if test "`(/bin/universe) 2>/dev/null`" = att ; then
+               echo pyramid-pyramid-sysv3
+       else
+               echo pyramid-pyramid-bsd
+       fi
+       exit 0 ;;
+    sun4*:SunOS:5.*:*)
+       echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit 0 ;;
+    i86pc:SunOS:5.*:*)
+       echo i386-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit 0 ;;
+    sun4*:SunOS:6*:*)
+       # According to config.sub, this is the proper way to canonicalize
+       # SunOS6.  Hard to guess exactly what SunOS6 will be like, but
+       # it's likely to be more like Solaris than SunOS4.
+       echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit 0 ;;
+    sun4*:SunOS:*:*)
+       case "`/usr/bin/arch -k`" in
+           Series*|S4*)
+               UNAME_RELEASE=`uname -v`
+               ;;
+       esac
+       # Japanese Language versions have a version number like `4.1.3-JL'.
+       echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+       exit 0 ;;
+    sun3*:SunOS:*:*)
+       echo m68k-sun-sunos${UNAME_RELEASE}
+       exit 0 ;;
+    atari*:NetBSD:*:*)
+       echo m68k-atari-netbsd${UNAME_RELEASE}
+       exit 0 ;;
+    sun3*:NetBSD:*:*)
+       echo m68k-sun-netbsd${UNAME_RELEASE}
+       exit 0 ;;
+    mac68k:NetBSD:*:*)
+       echo m68k-apple-netbsd${UNAME_RELEASE}
+       exit 0 ;;
+    RISC*:ULTRIX:*:*)
+       echo mips-dec-ultrix${UNAME_RELEASE}
+       exit 0 ;;
+    VAX*:ULTRIX*:*:*)
+       echo vax-dec-ultrix${UNAME_RELEASE}
+       exit 0 ;;
+    mips:*:4*:UMIPS)
+       echo mips-mips-riscos4sysv
+       exit 0 ;;
+    mips:*:5*:RISCos)
+       echo mips-mips-riscos${UNAME_RELEASE}
+       exit 0 ;;
+    Night_Hawk:Power_UNIX:*:*)
+       echo powerpc-harris-powerunix
+       exit 0 ;;
+    m88k:CX/UX:7*:*)
+       echo m88k-harris-cxux7
+       exit 0 ;;
+    m88k:*:4*:R4*)
+       echo m88k-motorola-sysv4
+       exit 0 ;;
+    m88k:*:3*:R3*)
+       echo m88k-motorola-sysv3
+       exit 0 ;;
+    AViiON:dgux:*:*)
+        # DG/UX returns AViiON for all architectures
+        UNAME_PROCESSOR=`uname -p`
+        if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88100 ] ; then
+       if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
+            -o ${TARGET_BINARY_INTERFACE}x = x ] ; then
+               echo m88k-dg-dgux${UNAME_RELEASE}
+       else
+               echo m88k-dg-dguxbcs${UNAME_RELEASE}
+       fi
+        else echo i586-dg-dgux${UNAME_RELEASE}
+        fi
+       exit 0 ;;
+    M88*:DolphinOS:*:*)        # DolphinOS (SVR3)
+       echo m88k-dolphin-sysv3
+       exit 0 ;;
+    M88*:*:R3*:*)
+       # Delta 88k system running SVR3
+       echo m88k-motorola-sysv3
+       exit 0 ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+       echo m88k-tektronix-sysv3
+       exit 0 ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+       echo m68k-tektronix-bsd
+       exit 0 ;;
+    *:IRIX*:*:*)
+       echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+       exit 0 ;;
+   ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+       echo romp-ibm-aix      # uname -m gives an 8 hex-code CPU id
+       exit 0 ;;              # Note that: echo "'`uname -s`'" gives 'AIX '
+    i[34]86:AIX:*:*)
+       echo i386-ibm-aix
+       exit 0 ;;
+    *:AIX:2:3)
+       if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+               sed 's/^                //' << EOF >dummy.c
+               #include <sys/systemcfg.h>
+
+               main()
+                       {
+                       if (!__power_pc())
+                               exit(1);
+                       puts("powerpc-ibm-aix3.2.5");
+                       exit(0);
+                       }
+EOF
+               ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
+               rm -f dummy.c dummy
+               echo rs6000-ibm-aix3.2.5
+       elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+               echo rs6000-ibm-aix3.2.4
+       else
+               echo rs6000-ibm-aix3.2
+       fi
+       exit 0 ;;
+    *:AIX:*:4)
+       if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then
+               IBM_ARCH=rs6000
+       else
+               IBM_ARCH=powerpc
+       fi
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=4.${UNAME_RELEASE}
+       fi
+       echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+       exit 0 ;;
+    *:AIX:*:*)
+       echo rs6000-ibm-aix
+       exit 0 ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+       echo romp-ibm-bsd4.4
+       exit 0 ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC NetBSD and
+       echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to 
+       exit 0 ;;                           # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+       echo rs6000-bull-bosx
+       exit 0 ;;
+    DPX/2?00:B.O.S.:*:*)
+       echo m68k-bull-sysv3
+       exit 0 ;;
+    9000/[34]??:4.3bsd:1.*:*)
+       echo m68k-hp-bsd
+       exit 0 ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+       echo m68k-hp-bsd4.4
+       exit 0 ;;
+    9000/[3478]??:HP-UX:*:*)
+       case "${UNAME_MACHINE}" in
+           9000/31? )            HP_ARCH=m68000 ;;
+           9000/[34]?? )         HP_ARCH=m68k ;;
+           9000/7?? | 9000/8?[679] ) HP_ARCH=hppa1.1 ;;
+           9000/8?? )            HP_ARCH=hppa1.0 ;;
+       esac
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+       exit 0 ;;
+    3050*:HI-UX:*:*)
+       sed 's/^        //' << EOF >dummy.c
+       #include <unistd.h>
+       int
+       main ()
+       {
+         long cpu = sysconf (_SC_CPU_VERSION);
+         /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+            true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
+            results, however.  */
+         if (CPU_IS_PA_RISC (cpu))
+           {
+             switch (cpu)
+               {
+                 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+                 default: puts ("hppa-hitachi-hiuxwe2"); break;
+               }
+           }
+         else if (CPU_IS_HP_MC68K (cpu))
+           puts ("m68k-hitachi-hiuxwe2");
+         else puts ("unknown-hitachi-hiuxwe2");
+         exit (0);
+       }
+EOF
+       ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
+       rm -f dummy.c dummy
+       echo unknown-hitachi-hiuxwe2
+       exit 0 ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+       echo hppa1.1-hp-bsd
+       exit 0 ;;
+    9000/8??:4.3bsd:*:*)
+       echo hppa1.0-hp-bsd
+       exit 0 ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+       echo hppa1.1-hp-osf
+       exit 0 ;;
+    hp8??:OSF1:*:*)
+       echo hppa1.0-hp-osf
+       exit 0 ;;
+    parisc*:Lites*:*:*)
+       echo hppa1.1-hp-lites
+       exit 0 ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+       echo c1-convex-bsd
+        exit 0 ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+        exit 0 ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+       echo c34-convex-bsd
+        exit 0 ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+       echo c38-convex-bsd
+        exit 0 ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+       echo c4-convex-bsd
+        exit 0 ;;
+    CRAY*X-MP:*:*:*)
+       echo xmp-cray-unicos
+        exit 0 ;;
+    CRAY*Y-MP:*:*:*)
+       echo ymp-cray-unicos${UNAME_RELEASE}
+       exit 0 ;;
+    CRAY*C90:*:*:*)
+       echo c90-cray-unicos${UNAME_RELEASE}
+       exit 0 ;;
+    CRAY-2:*:*:*)
+       echo cray2-cray-unicos
+        exit 0 ;;
+    hp3[0-9][05]:NetBSD:*:*)
+       echo m68k-hp-netbsd${UNAME_RELEASE}
+       exit 0 ;;
+    i[34]86:BSD/386:*:* | *:BSD/OS:*:*)
+       echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+       exit 0 ;;
+    *:FreeBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+       exit 0 ;;
+    *:NetBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+       exit 0 ;;
+    i*:CYGWIN*:*)
+       echo i386-unknown-cygwin32
+       exit 0 ;;
+    p*:CYGWIN*:*)
+       echo powerpcle-unknown-cygwin32
+       exit 0 ;;
+    *:GNU:*:*)
+       echo `echo ${UNAME_MACHINE}|sed -e 's,/.*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+       exit 0 ;;
+    *:Linux:*:*)
+       # The BFD linker knows what the default object file format is, so
+       # first see if it will tell us.
+       ld_help_string=`ld --help 2>&1`
+       if echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf_i[345]86"; then
+         echo "${UNAME_MACHINE}-unknown-linux" ; exit 0
+       elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i[345]86linux"; then
+         echo "${UNAME_MACHINE}-unknown-linuxaout" ; exit 0
+       elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i[345]86coff"; then
+         echo "${UNAME_MACHINE}-unknown-linuxcoff" ; exit 0
+       elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68kelf"; then
+         echo "${UNAME_MACHINE}-unknown-linux" ; exit 0
+       elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68klinux"; then
+         echo "${UNAME_MACHINE}-unknown-linuxaout" ; exit 0
+       elif test "${UNAME_MACHINE}" = "alpha" ; then
+         echo alpha-unknown-linux ; exit 0
+       else
+         # Either a pre-BFD a.out linker (linuxoldld) or one that does not give us
+         # useful --help.  Gcc wants to distinguish between linuxoldld and linuxaout.
+         test ! -d /usr/lib/ldscripts/. \
+           && echo "${UNAME_MACHINE}-unknown-linuxoldld" && exit 0
+         # Determine whether the default compiler is a.out or elf
+         cat >dummy.c <<EOF
+main(argc, argv)
+int argc;
+char *argv[];
+{
+#ifdef __ELF__
+  printf ("%s-unknown-linux\n", argv[1]);
+#else
+  printf ("%s-unknown-linuxaout\n", argv[1]);
+#endif
+  return 0;
+}
+EOF
+         ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
+         rm -f dummy.c dummy
+       fi ;;
+# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.  earlier versions
+# are messed up and put the nodename in both sysname and nodename.
+    i[34]86:DYNIX/ptx:4*:*)
+       echo i386-sequent-sysv4
+       exit 0 ;;
+    i[34]86:*:4.*:* | i[34]86:SYSTEM_V:4.*:*)
+       if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+               echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
+       else
+               echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}
+       fi
+       exit 0 ;;
+    i[34]86:*:3.2:*)
+       if test -f /usr/options/cb.name; then
+               UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+               echo ${UNAME_MACHINE}-unknown-isc$UNAME_REL
+       elif /bin/uname -X 2>/dev/null >/dev/null ; then
+               UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
+               (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
+               (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
+                       && UNAME_MACHINE=i586
+               echo ${UNAME_MACHINE}-unknown-sco$UNAME_REL
+       else
+               echo ${UNAME_MACHINE}-unknown-sysv32
+       fi
+       exit 0 ;;
+    Intel:Mach:3*:*)
+       echo i386-unknown-mach3
+       exit 0 ;;
+    paragon:*:*:*)
+       echo i860-intel-osf1
+       exit 0 ;;
+    i860:*:4.*:*) # i860-SVR4
+       if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+         echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+       else # Add other i860-SVR4 vendors below as they are discovered.
+         echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+       fi
+       exit 0 ;;
+    mini*:CTIX:SYS*5:*)
+       # "miniframe"
+       echo m68010-convergent-sysv
+       exit 0 ;;
+    M680[234]0:*:R3V[567]*:*)
+       test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
+    3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0)
+        uname -p 2>/dev/null | grep 86 >/dev/null \
+          && echo i486-ncr-sysv4.3 && exit 0 ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+        uname -p 2>/dev/null | grep 86 >/dev/null \
+          && echo i486-ncr-sysv4 && exit 0 ;;
+    m680[234]0:LynxOS:2.[23]*:*)
+       echo m68k-lynx-lynxos${UNAME_RELEASE}
+       exit 0 ;;
+    mc68030:UNIX_System_V:4.*:*)
+       echo m68k-atari-sysv4
+       exit 0 ;;
+    i[34]86:LynxOS:2.[23]*:*)
+       echo i386-lynx-lynxos${UNAME_RELEASE}
+       exit 0 ;;
+    TSUNAMI:LynxOS:2.[23]*:*)
+       echo sparc-lynx-lynxos${UNAME_RELEASE}
+       exit 0 ;;
+    rs6000:LynxOS:2.[23]*:*)
+       echo rs6000-lynx-lynxos${UNAME_RELEASE}
+       exit 0 ;;
+    RM*:SINIX-*:*:*)
+       echo mips-sni-sysv4
+       exit 0 ;;
+    *:SINIX-*:*:*)
+       if uname -p 2>/dev/null >/dev/null ; then
+               UNAME_MACHINE=`(uname -p) 2>/dev/null`
+               echo ${UNAME_MACHINE}-sni-sysv4
+       else
+               echo ns32k-sni-sysv
+       fi
+       exit 0 ;;
+    mc68*:A/UX:*:*)
+       echo m68k-apple-aux${UNAME_RELEASE}
+       exit 0 ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+cat >dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+          "4"
+#else
+         ""
+#endif
+         ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  printf ("%s-next-nextstep%s\n", __ARCHITECTURE__,  version==2 ? "2" : "3");
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-unknown-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+       printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+       printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+#if !defined (ultrix)
+  printf ("vax-dec-bsd\n"); exit (0);
+#else
+  printf ("vax-dec-ultrix\n"); exit (0);
+#endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0
+rm -f dummy.c dummy
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+       echo c1-convex-bsd
+       exit 0 ;;
+    c2*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+       exit 0 ;;
+    c34*)
+       echo c34-convex-bsd
+       exit 0 ;;
+    c38*)
+       echo c38-convex-bsd
+       exit 0 ;;
+    c4*)
+       echo c4-convex-bsd
+       exit 0 ;;
+    esac
+fi
+
+#echo '(Unable to guess system type)' 1>&2
+
+exit 1
diff --git a/ghc/rts/gmp/config.sub b/ghc/rts/gmp/config.sub
new file mode 100644 (file)
index 0000000..997f9db
--- /dev/null
@@ -0,0 +1,1094 @@
+#! /bin/sh
+# Configuration validation subroutine script, version 1.1.
+#   Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine.  It does not imply ALL GNU software can. 
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support.  The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+#      CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+if [ x$1 = x ]
+then
+       echo Configuration name missing. 1>&2
+       echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
+       echo "or     $0 ALIAS" 1>&2
+       echo where ALIAS is a recognized configuration type. 1>&2
+       exit 1
+fi
+
+# First pass through any local machine types.
+case $1 in
+       *local*)
+               echo $1
+               exit 0
+               ;;
+       *)
+       ;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS (if any).
+basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+if [ $basic_machine != $1 ]
+then os=`echo $1 | sed 's/.*-/-/'`
+else os=; fi
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work.  We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+       -sun*os*)
+               # Prevent following clause from handling this invalid input.
+               ;;
+       -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+       -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+       -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+       -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+       -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+       -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp )
+               os=
+               basic_machine=$1
+               ;;
+       -sim | -cisco | -oki | -wec | -winbond )        # CYGNUS LOCAL
+               os=
+               basic_machine=$1
+               ;;
+       -apple*)                                        # CYGNUS LOCAL
+               os=
+               basic_machine=$1
+               ;;
+       -scout)                                         # CYGNUS LOCAL
+               ;;
+       -wrs)                                           # CYGNUS LOCAL
+               os=vxworks
+               basic_machine=$1
+               ;;
+       -hiux*)
+               os=-hiuxwe2
+               ;;
+       -sco4)
+               os=-sco3.2v4
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'`
+               ;;
+       -sco3.2.[4-9]*)
+               os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'`
+               ;;
+       -sco3.2v[4-9]*)
+               # Don't forget version if it is 3.2v4 or newer.
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'`
+               ;;
+       -sco*)
+               os=-sco3.2v2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'`
+               ;;
+       -isc)
+               os=-isc2.2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'`
+               ;;
+       -clix*)
+               basic_machine=clipper-intergraph
+               ;;
+       -isc*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-unknown/'`
+               ;;
+       -lynx*)
+               os=-lynxos
+               ;;
+       -ptx*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+               ;;
+       -windowsnt*)
+               os=`echo $os | sed -e 's/windowsnt/winnt/'`
+               ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+       # Recognize the basic CPU types without company name.
+       # Some are omitted here because they have special meanings below.
+       tahoe | i[345]86 | i860 | m68k | m68000 | m88k | ns32k | arm | armeb \
+               | armel | pyramid \
+               | tron | a29k | 580 | i960 | h8300 | hppa1.0 | hppa1.1 \
+               | alpha | we32k | ns16k | clipper | sparclite | i370 | sh \
+               | powerpc | powerpcle | sparc64 | 1750a | dsp16xx | mips64 | mipsel \
+               | pdp11 | mips64el | mips64orion | mips64orionel \
+               | sparc | sparc8 | supersparc | microsparc | ultrasparc)
+               basic_machine=$basic_machine-unknown
+               ;;
+       m88110 | m680[012346]0 | m683?2 | m68360 | z8k | v70 | h8500 | w65) # CYGNUS LOCAL
+               basic_machine=$basic_machine-unknown
+               ;;
+       mips64vr4300 | mips64vr4300el) # CYGNUS LOCAL jsmith
+               basic_machine=$basic_machine-unknown
+               ;;
+       # Object if more than one company name word.
+       *-*-*)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+       # Recognize the basic CPU types with company name.
+       vax-* | tahoe-* | i[3456]86-* | i860-* | m68k-* | m68000-* | m88k-* \
+             | sparc-* | ns32k-* | fx80-* | arm-* | arme[lb]-* | c[123]* \
+             | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* | power-* \
+             | none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \
+             | hppa1.0-* | hppa1.1-* | alpha-* | we32k-* | cydra-* | ns16k-* \
+             | pn-* | np1-* | xps100-* | clipper-* | orion-* | sparclite-* \
+             | pdp11-* | sh-* | powerpc-* | powerpcle-* | sparc64-* \
+             | mips64-* | mipsel-* | mips64el-* | mips64orion-* \
+             | mips64orionel-* | sparc8-* | supersparc-* | microsparc-* | ultrasparc-*)
+               ;;
+       m88110-* | m680[012346]0-* | m683?2-* | m68360-* | z8k-* | h8500-*) # CYGNUS LOCAL
+               ;;
+       mips64vr4300-* | mips64vr4300el-*) # CYGNUS LOCAL jsmith
+               ;;
+       # Recognize the various machine names and aliases which stand
+       # for a CPU type and a company and sometimes even an OS.
+       386bsd)                                         # CYGNUS LOCAL
+               basic_machine=i386-unknown
+               os=-bsd
+               ;;
+       3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+               basic_machine=m68000-att
+               ;;
+       3b*)
+               basic_machine=we32k-att
+               ;;
+       a29khif)                                        # CYGNUS LOCAL
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       adobe68k)                                       # CYGNUS LOCAL
+               basic_machine=m68010-adobe
+               os=-scout
+               ;;
+       alliant | fx80)
+               basic_machine=fx80-alliant
+               ;;
+       altos | altos3068)
+               basic_machine=m68k-altos
+               ;;
+       am29k)
+               basic_machine=a29k-none
+               os=-bsd
+               ;;
+       amdahl)
+               basic_machine=580-amdahl
+               os=-sysv
+               ;;
+       amiga | amiga-*)
+               basic_machine=m68k-cbm
+               ;;
+       amigados)
+               basic_machine=m68k-cbm
+               os=-amigados
+               ;;
+       amigaunix | amix)
+               basic_machine=m68k-cbm
+               os=-sysv4
+               ;;
+       apollo68)
+               basic_machine=m68k-apollo
+               os=-sysv
+               ;;
+       apollo68bsd)                                    # CYGNUS LOCAL
+               basic_machine=m68k-apollo
+               os=-bsd
+               ;;
+       arm | armel | armeb)
+               basic_machine=arm-arm
+               os=-aout
+               ;;
+       balance)
+               basic_machine=ns32k-sequent
+               os=-dynix
+               ;;
+       [ctj]90-cray)
+               basic_machine=c90-cray
+               os=-unicos
+               ;;
+       convex-c1)
+               basic_machine=c1-convex
+               os=-bsd
+               ;;
+       convex-c2)
+               basic_machine=c2-convex
+               os=-bsd
+               ;;
+       convex-c32)
+               basic_machine=c32-convex
+               os=-bsd
+               ;;
+       convex-c34)
+               basic_machine=c34-convex
+               os=-bsd
+               ;;
+       convex-c38)
+               basic_machine=c38-convex
+               os=-bsd
+               ;;
+       cray | ymp)
+               basic_machine=ymp-cray
+               os=-unicos
+               ;;
+       cray2)
+               basic_machine=cray2-cray
+               os=-unicos
+               ;;
+       crds | unos)
+               basic_machine=m68k-crds
+               ;;
+       da30 | da30-*)
+               basic_machine=m68k-da30
+               ;;
+       decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+               basic_machine=mips-dec
+               ;;
+       delta | 3300 | motorola-3300 | motorola-delta \
+             | 3300-motorola | delta-motorola)
+               basic_machine=m68k-motorola
+               ;;
+       delta88)
+               basic_machine=m88k-motorola
+               os=-sysv3
+               ;;
+       dpx20 | dpx20-*)
+               basic_machine=rs6000-bull
+               os=-bosx
+               ;;
+       dpx2* | dpx2*-bull)
+               basic_machine=m68k-bull
+               os=-sysv3
+               ;;
+       ebmon29k)
+               basic_machine=a29k-amd
+               os=-ebmon
+               ;;
+       elxsi)
+               basic_machine=elxsi-elxsi
+               os=-bsd
+               ;;
+       encore | umax | mmax)
+               basic_machine=ns32k-encore
+               ;;
+       es1800 | OSE68k | ose68k | ose | OSE)           # CYGNUS LOCAL
+               basic_machine=m68k-ericsson
+               os=-ose
+               ;;
+       fx2800)
+               basic_machine=i860-alliant
+               ;;
+       genix)
+               basic_machine=ns32k-ns
+               ;;
+       gmicro)
+               basic_machine=tron-gmicro
+               os=-sysv
+               ;;
+       h3050r* | hiux*)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       h8300hms)
+               basic_machine=h8300-hitachi
+               os=-hms
+               ;;
+       h8300xray)                                      # CYGNUS LOCAL
+               basic_machine=h8300-hitachi
+               os=-xray
+               ;;
+       h8500hms)                                       # CYGNUS LOCAL
+               basic_machine=h8500-hitachi
+               os=-hms
+               ;;
+       harris)
+               basic_machine=m88k-harris
+               os=-sysv3
+               ;;
+       hp300-*)
+               basic_machine=m68k-hp
+               ;;
+       hp300bsd)
+               basic_machine=m68k-hp
+               os=-bsd
+               ;;
+       hp300hpux)
+               basic_machine=m68k-hp
+               os=-hpux
+               ;;
+        w89k-*)                                                # CYGNUS LOCAL
+                basic_machine=hppa1.1-winbond
+                os=-proelf
+                ;;
+        op50n-*)                                       # CYGNUS LOCAL
+                basic_machine=hppa1.1-oki
+                os=-proelf
+                ;;
+        op60c-*)                                       # CYGNUS LOCAL
+                basic_machine=hppa1.1-oki
+                os=-proelf
+                ;;
+        hppro)                                         # CYGNUS LOCAL
+                basic_machine=hppa1.1-hp
+                os=-proelf
+                ;;
+       hp9k2[0-9][0-9] | hp9k31[0-9])
+               basic_machine=m68000-hp
+               ;;
+       hp9k3[2-9][0-9])
+               basic_machine=m68k-hp
+               ;;
+       hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7)
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[0-9][0-9] | hp8[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hppaosf)                                        # CYGNUS LOCAL
+               basic_machine=hppa1.1-hp
+               os=-osf
+               ;;
+       i370-ibm* | ibm*)
+               basic_machine=i370-ibm
+               os=-mvs
+               ;;
+# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
+       i[3456]86v32)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'`
+               os=-sysv32
+               ;;
+       i[3456]86v4*)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'`
+               os=-sysv4
+               ;;
+       i[3456]86v)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'`
+               os=-sysv
+               ;;
+       i[3456]86sol2)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-unknown/'`
+               os=-solaris2
+               ;;
+       i386mach)                                       # CYGNUS LOCAL
+               basic_machine=i386-mach
+               os=-mach
+               ;;
+       i386-vsta | vsta)                               # CYGNUS LOCAL
+               basic_machine=i386-unknown
+               os=-vsta
+               ;;
+       i386-go32 | go32)                               # CYGNUS LOCAL
+               basic_machine=i386-unknown
+               os=-go32
+               ;;
+       iris | iris4d)
+               basic_machine=mips-sgi
+               case $os in
+                   -irix*)
+                       ;;
+                   *)
+                       os=-irix4
+                       ;;
+               esac
+               ;;
+       isi68 | isi)
+               basic_machine=m68k-isi
+               os=-sysv
+               ;;
+       m88k-omron*)
+               basic_machine=m88k-omron
+               ;;
+       magnum | m3230)
+               basic_machine=mips-mips
+               os=-sysv
+               ;;
+       merlin)
+               basic_machine=ns32k-utek
+               os=-sysv
+               ;;
+       miniframe)
+               basic_machine=m68000-convergent
+               ;;
+       mips3*-*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+               ;;
+       mips3*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+               ;;
+       monitor)                                        # CYGNUS LOCAL
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       msdos)                                          # CYGNUS LOCAL
+               basic_machine=i386-unknown      
+               os=-msdos
+               ;;
+       ncr3000)
+               basic_machine=i486-ncr
+               os=-sysv4
+               ;;
+       netbsd386)
+               basic_machine=i386-unknown              # CYGNUS LOCAL
+               os=-netbsd
+               ;;
+       news | news700 | news800 | news900)
+               basic_machine=m68k-sony
+               os=-newsos
+               ;;
+       news1000)
+               basic_machine=m68030-sony
+               os=-newsos
+               ;;
+       news-3600 | risc-news)
+               basic_machine=mips-sony
+               os=-newsos
+               ;;
+       necv70)                                         # CYGNUS LOCAL
+               basic_machine=v70-nec
+               os=-sysv
+               ;;
+       next | m*-next )
+               basic_machine=m68k-next
+               case $os in
+                   -nextstep* )
+                       ;;
+                   -ns2*)
+                     os=-nextstep2
+                       ;;
+                   *)
+                     os=-nextstep3
+                       ;;
+               esac
+               ;;
+       nh3000)
+               basic_machine=m68k-harris
+               os=-cxux
+               ;;
+       nh[45]000)
+               basic_machine=m88k-harris
+               os=-cxux
+               ;;
+       nindy960)
+               basic_machine=i960-intel
+               os=-nindy
+               ;;
+       np1)
+               basic_machine=np1-gould
+               ;;
+       OSE68000 | ose68000)                            # CYGNUS LOCAL
+               basic_machine=m68000-ericsson
+               os=-ose
+               ;;
+       os68k)                                          # CYGNUS LOCAL
+               basic_machine=m68k-none
+               os=-os68k
+               ;;
+       pa-hitachi)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       paragon)
+               basic_machine=i860-intel
+               os=-osf
+               ;;
+       pbd)
+               basic_machine=sparc-tti
+               ;;
+       pbb)
+               basic_machine=m68k-tti
+               ;;
+        pc532 | pc532-*)
+               basic_machine=ns32k-pc532
+               ;;
+       pentium | p5)
+               basic_machine=i586-intel
+               ;;
+       pentiumpro | p6)
+               basic_machine=i686-intel
+               ;;
+       pentium-* | p5-*)
+               basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentiumpro-* | p6-*)
+               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       k5)
+               # We don't have specific support for AMD's K5 yet, so just call it a Pentium
+               basic_machine=i586-amd
+               ;;
+       nexgen)
+               # We don't have specific support for Nexgen yet, so just call it a Pentium
+               basic_machine=i586-nexgen
+               ;;
+       pn)
+               basic_machine=pn-gould
+               ;;
+       power)  basic_machine=rs6000-ibm
+               ;;
+       ppc)    basic_machine=powerpc-unknown
+               ;;
+       ppc-*)  basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppcle | powerpclittle | ppc-le | powerpc-little)
+               basic_machine=powerpcle-unknown
+               ;;
+       ppcle-* | powerpclittle-*)
+               basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ps2)
+               basic_machine=i386-ibm
+               ;;
+       rom68k)                                         # CYGNUS LOCAL
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       rm[46]00)
+               basic_machine=mips-siemens
+               ;;
+       rtpc | rtpc-*)
+               basic_machine=romp-ibm
+               ;;
+       sa29200)                                        # CYGNUS LOCAL
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       sequent)
+               basic_machine=i386-sequent
+               ;;
+       sh)
+               basic_machine=sh-hitachi
+               os=-hms
+               ;;
+       sparclite-wrs)                                  # CYGNUS LOCAL
+               basic_machine=sparclite-wrs
+               os=-vxworks
+               ;;
+       sparcfrw)                                       # CYGNUS LOCAL
+               basic_machine=sparcfrw-sun
+               os=-sunos4
+               ;;
+       sparcfrwcompat)                                 # CYGNUS LOCAL
+               basic_machine=sparcfrwcompat-sun
+               os=-sunos4
+               ;;
+       sparclitefrw)                                   # CYGNUS LOCAL
+               basic_machine=sparclitefrw-fujitsu
+               ;;
+       sparclitefrwcompat)                             # CYGNUS LOCAL
+               basic_machine=sparclitefrwcompat-fujitsu
+               ;;
+       sps7)
+               basic_machine=m68k-bull
+               os=-sysv2
+               ;;
+       spur)
+               basic_machine=spur-unknown
+               ;;
+       st2000)                                         # CYGNUS LOCAL
+               basic_machine=m68k-tandem
+               ;;
+       stratus)                                        # CYGNUS LOCAL
+               basic_machine=i860-stratus
+               os=-sysv4
+               ;;
+       sun2)
+               basic_machine=m68000-sun
+               ;;
+       sun2os3)
+               basic_machine=m68000-sun
+               os=-sunos3
+               ;;
+       sun2os4)
+               basic_machine=m68000-sun
+               os=-sunos4
+               ;;
+       sun3os3)
+               basic_machine=m68k-sun
+               os=-sunos3
+               ;;
+       sun3os4)
+               basic_machine=m68k-sun
+               os=-sunos4
+               ;;
+       sun4os3)
+               basic_machine=sparc-sun
+               os=-sunos3
+               ;;
+       sun4os4)
+               basic_machine=sparc-sun
+               os=-sunos4
+               ;;
+       sun4sol2)
+               basic_machine=sparc-sun
+               os=-solaris2
+               ;;
+       sun3 | sun3-*)
+               basic_machine=m68k-sun
+               ;;
+       sun4)
+               basic_machine=sparc-sun
+               ;;
+       sun386 | sun386i | roadrunner)
+               basic_machine=i386-sun
+               ;;
+       symmetry)
+               basic_machine=i386-sequent
+               os=-dynix
+               ;;
+       tower | tower-32)
+               basic_machine=m68k-ncr
+               ;;
+       udi29k)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       ultra3)
+               basic_machine=a29k-nyu
+               os=-sym1
+               ;;
+       v810 | necv810)                                 # CYGNUS LOCAL
+               basic_machine=v810-nec
+               os=-none
+               ;;
+       vaxv)
+               basic_machine=vax-dec
+               os=-sysv
+               ;;
+       vms)
+               basic_machine=vax-dec
+               os=-vms
+               ;;
+       vxworks960)
+               basic_machine=i960-wrs
+               os=-vxworks
+               ;;
+       vxworks68)
+               basic_machine=m68k-wrs
+               os=-vxworks
+               ;;
+        vxworks29k)                                    # CYGNUS LOCAL
+                basic_machine=a29k-wrs
+                os=-vxworks
+                ;;
+       w65*)                                           # CYGNUS LOCAL
+               basic_machine=w65-wdc
+               os=-none
+               ;;
+       xmp)
+               basic_machine=xmp-cray
+               os=-unicos
+               ;;
+        xps | xps100)
+               basic_machine=xps100-honeywell
+               ;;
+       z8k-*-coff)                                     # CYGNUS LOCAL
+               basic_machine=z8k-unknown
+               os=-sim
+               ;;
+       none)
+               basic_machine=none-none
+               os=-none
+               ;;
+
+# Here we handle the default manufacturer of certain CPU types.  It is in
+# some cases the only manufacturer, in others, it is the most popular.
+       w89k)                                           # CYGNUS LOCAL
+               basic_machine=hppa1.1-winbond
+               ;;
+       op50n)                                          # CYGNUS LOCAL
+               basic_machine=hppa1.1-oki
+               ;;
+       op60c)                                          # CYGNUS LOCAL
+               basic_machine=hppa1.1-oki
+               ;;
+       mips)
+               basic_machine=mips-mips
+               ;;
+       romp)
+               basic_machine=romp-ibm
+               ;;
+       rs6000)
+               basic_machine=rs6000-ibm
+               ;;
+       vax)
+               basic_machine=vax-dec
+               ;;
+       pdp11)
+               basic_machine=pdp11-dec
+               ;;
+       we32k)
+               basic_machine=we32k-att
+               ;;
+       sparc)
+               basic_machine=sparc-sun
+               ;;
+        cydra)
+               basic_machine=cydra-cydrome
+               ;;
+       orion)
+               basic_machine=orion-highlevel
+               ;;
+       orion105)
+               basic_machine=clipper-highlevel
+               ;;
+       mac | mpw | mac-mpw)                            # CYGNUS LOCAL
+               basic_machine=m68k-apple
+               ;;
+       pmac | pmac-mpw)                                # CYGNUS LOCAL
+               basic_machine=powerpc-apple
+               ;;
+       *)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+       *-digital*)
+               basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+               ;;
+       *-commodore*)
+               basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+               ;;
+       *)
+               ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+       # -solaris* is a basic system type, with this one exception.
+       -solaris1 | -solaris1.*)
+               os=`echo $os | sed -e 's|solaris1|sunos4|'`
+               ;;
+       -solaris)
+               os=-solaris2
+               ;;
+       -unixware* | svr4*)
+               os=-sysv4
+               ;;
+       -gnu/linux*)
+               os=`echo $os | sed -e 's|gnu/linux|linux|'`
+               ;;
+       # First accept the basic system types.
+       # The portable systems comes first.
+       # Each alternative must end in a *, to match a version number.
+       # -sysv* is not here because it comes later, after sysvr4.
+       -gnu* | -bsd* | -mach* | -lites* | -minix* | -genix* | -ultrix* | -irix* \
+             | -vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[3456]* \
+             | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+             | -amigados* | -msdos* | -moss* | -newsos* | -unicos* | -aos* \
+             | -nindy* | -vxworks* | -ebmon* | -hms* | -mvs* | -clix* \
+             | -riscos* | -linux* | -uniplus* | -iris* | -rtu* | -xenix* \
+             | -hiux* | -386bsd* | -netbsd* | -freebsd* | -riscix*  | -lites* \
+             | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \
+             | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta | -udi \
+             | -eabi* | -ieee*)
+               ;;
+       # CYGNUS LOCAL
+       -go32 | -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+             | -windows* | -osx | -abug |  -netware* | -proelf | -os9* \
+             | -macos* | -mpw* | -magic* | -pe* | -win32)
+               ;;
+       -mac*)                                          # CYGNUS LOCAL
+               os=`echo $os | sed -e 's|mac|macos|'`
+               ;;
+       -sunos5*)
+               os=`echo $os | sed -e 's|sunos5|solaris2|'`
+               ;;
+       -sunos6*)
+               os=`echo $os | sed -e 's|sunos6|solaris3|'`
+               ;;
+       -osfrose*)
+               os=-osfrose
+               ;;
+       -osf*)
+               os=-osf
+               ;;
+       -utek*)
+               os=-bsd
+               ;;
+       -dynix*)
+               os=-bsd
+               ;;
+       -acis*)
+               os=-aos
+               ;;
+       -386bsd)                                        # CYGNUS LOCAL
+               os=-bsd
+               ;;
+       -ctix* | -uts*)
+               os=-sysv
+               ;;
+       # Preserve the version number of sinix5.
+       -sinix5.*)
+               os=`echo $os | sed -e 's|sinix|sysv|'`
+               ;;
+       -sinix*)
+               os=-sysv4
+               ;;
+       -triton*)
+               os=-sysv3
+               ;;
+       -oss*)
+               os=-sysv3
+               ;;
+       -svr4)
+               os=-sysv4
+               ;;
+       -svr3)
+               os=-sysv3
+               ;;
+       -sysvr4)
+               os=-sysv4
+               ;;
+       # This must come after -sysvr4.
+       -sysv*)
+               ;;
+       -ose*)                                          # CYGNUS LOCAL
+               os=-ose
+               ;;
+       -es1800*)                                       # CYGNUS LOCAL
+               os=-ose
+               ;;
+       -xenix)
+               os=-xenix
+               ;;
+       -none)
+               ;;
+       *)
+               # Get rid of the `-' at the beginning of $os.
+               os=`echo $os | sed 's/[^-]*-//'`
+               echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system.  Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+       *-acorn)
+               os=-riscix1.2
+               ;;
+        pdp11-*)
+               os=-none
+               ;;
+       *-dec | vax-*)
+               os=-ultrix4.2
+               ;;
+       m68*-apollo)
+               os=-domain
+               ;;
+       i386-sun)
+               os=-sunos4.0.2
+               ;;
+       m68000-sun)
+               os=-sunos3
+               # This also exists in the configure program, but was not the
+               # default.
+               # os=-sunos4
+               ;;
+       m68*-cisco)                                     # CYGNUS LOCAL
+               os=-aout
+               ;;
+       mips*-cisco)                                    # CYGNUS LOCAL
+               os=-elf
+               ;;
+       *-tti)  # must be before sparc entry or we get the wrong os.
+               os=-sysv3
+               ;;
+       sparc-* | *-sun)
+               os=-sunos4.1.1
+               ;;
+       *-ibm)
+               os=-aix
+               ;;
+       *-wec)                                          # CYGNUS LOCAL
+               os=-proelf
+               ;;
+       *-winbond)                                      # CYGNUS LOCAL
+               os=-proelf
+               ;;
+       *-oki)                                          # CYGNUS LOCAL
+               os=-proelf
+               ;;
+       *-hp)
+               os=-hpux
+               ;;
+       *-hitachi)
+               os=-hiux
+               ;;
+       i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+               os=-sysv
+               ;;
+       *-cbm)
+               os=-amigados
+               ;;
+       *-dg)
+               os=-dgux
+               ;;
+       *-dolphin)
+               os=-sysv3
+               ;;
+       m68k-ccur)
+               os=-rtu
+               ;;
+       m88k-omron*)
+               os=-luna
+               ;;
+       *-sequent)
+               os=-ptx
+               ;;
+       *-crds)
+               os=-unos
+               ;;
+       *-ns)
+               os=-genix
+               ;;
+       i370-*)
+               os=-mvs
+               ;;
+       *-next)
+               os=-nextstep3
+               ;;
+        *-gould)
+               os=-sysv
+               ;;
+        *-highlevel)
+               os=-bsd
+               ;;
+       *-encore)
+               os=-bsd
+               ;;
+        *-sgi)
+               os=-irix
+               ;;
+        *-siemens)
+               os=-sysv4
+               ;;
+       *-masscomp)
+               os=-rtu
+               ;;
+       *-rom68k)                                       # CYGNUS LOCAL
+               os=-coff
+               ;;
+       *-*bug)                                         # CYGNUS LOCAL
+               os=-coff
+               ;;
+       *-apple)                                        # CYGNUS LOCAL
+               os=-macos
+               ;;
+       *)
+               os=-none
+               ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer.  We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+       *-unknown)
+               case $os in
+                       -riscix*)
+                               vendor=acorn
+                               ;;
+                       -sunos*)
+                               vendor=sun
+                               ;;
+                       -bosx*)                         # CYGNUS LOCAL
+                               vendor=bull
+                               ;;
+                       -lynxos*)
+                               vendor=lynx
+                               ;;
+                       -aix*)
+                               vendor=ibm
+                               ;;
+                       -hpux*)
+                               vendor=hp
+                               ;;
+                       -hiux*)
+                               vendor=hitachi
+                               ;;
+                       -unos*)
+                               vendor=crds
+                               ;;
+                       -dgux*)
+                               vendor=dg
+                               ;;
+                       -luna*)
+                               vendor=omron
+                               ;;
+                       -genix*)
+                               vendor=ns
+                               ;;
+                       -mvs*)
+                               vendor=ibm
+                               ;;
+                       -ptx*)
+                               vendor=sequent
+                               ;;
+                       -vxworks*)
+                               vendor=wrs
+                               ;;
+                       -hms*)                          # CYGNUS LOCAL
+                               vendor=hitachi
+                               ;;
+                       -mpw* | -macos*)                # CYGNUS LOCAL
+                               vendor=apple
+                               ;;
+               esac
+               basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+               ;;
+esac
+
+echo $basic_machine$os
diff --git a/ghc/rts/gmp/configure b/ghc/rts/gmp/configure
new file mode 100644 (file)
index 0000000..ad1c839
--- /dev/null
@@ -0,0 +1,1263 @@
+#!/bin/sh
+
+### WARNING: this file contains embedded tabs.  Do not run untabify on this file.
+
+# Configuration script
+# Copyright (C) 1988, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# This file was originally written by K. Richard Pixley.
+
+#
+# Shell script to create proper links to machine-dependent files in
+# preparation for compilation.
+#
+# If configure succeeds, it leaves its status in config.status.
+# If configure fails after disturbing the status quo, 
+#       config.status is removed.
+#
+
+export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh $0 $argv; kill $$)
+
+remove=rm
+hard_link=ln
+symbolic_link='ln -s'
+
+#for Test
+#remove="echo rm"
+#hard_link="echo ln"
+#symbolic_link="echo ln -s"
+
+# clear some things potentially inherited from environment.
+
+Makefile=Makefile
+Makefile_in=Makefile.in
+arguments=
+build_alias=
+cache_file=
+cache_file_option=
+configdirs=
+exec_prefix=
+exec_prefixoption=
+fatal=
+floating_point=default
+gas=default
+host_alias=NOHOST
+host_makefile_frag=
+moveifchange=
+norecursion=
+other_options=
+package_makefile_frag=
+prefix=/usr/local
+progname=
+program_prefix=
+program_prefixoption=
+program_suffix=
+program_suffixoption=
+program_transform_name=
+program_transform_nameoption=
+redirect=">/dev/null"
+removing=
+site=
+site_makefile_frag=
+site_option=
+srcdir=
+srctrigger=
+subdirs=
+target_alias=NOTARGET
+target_makefile_frag=
+undefs=NOUNDEFS
+version="$Revision: 1.1 $"
+x11=default
+
+### we might need to use some other shell than /bin/sh for running subshells
+#
+config_shell=${CONFIG_SHELL-/bin/sh}
+
+NO_EDIT="This file was generated automatically by configure.  Do not edit."
+
+## this is a little touchy and won't always work, but...
+##
+## if the argv[0] starts with a slash then it is an absolute name that can (and
+## must) be used as is.
+##
+## otherwise, if argv[0] has no slash in it, we can assume that it is on the
+## path.  Since PATH might include "." we also add `pwd` to the end of PATH.
+##
+
+progname=$0
+# if PWD already has a value, it is probably wrong.
+if [ -n "$PWD" ]; then PWD=`pwd`; fi
+
+case "${progname}" in
+/*) ;;
+*/*) ;;
+*)
+        PATH=$PATH:${PWD=`pwd`} ; export PATH
+        ;;
+esac
+
+# Loop over all args
+
+while :
+do
+
+# Break out if there are no more args
+       case $# in
+       0)
+               break
+               ;;
+       esac
+
+# Get the first arg, and shuffle
+       option=$1
+       shift
+
+# Make all options have two hyphens
+       orig_option=$option     # Save original for error messages
+       case $option in
+       --*) ;;
+       -*) option=-$option ;;
+       esac
+               
+# Split out the argument for options that take them
+       case $option in
+       --*=*)
+               optarg=`echo $option | sed -e 's/^[^=]*=//'`
+               arguments="$arguments $option"
+               ;;
+# These options have mandatory values.  Since we didn't find an = sign,
+# the value must be in the next argument
+       --bu* | --cache* | --ex* | --ho* | --pre* | --program-p* | --program-s* | --program-t* | --si* | --sr* | --ta* | --tm* | --x-* | --bi* | --sb* | --li* | --da* | --sy* | --sh* | --lo* | --in* | --ol* | --ma*)
+               optarg=$1
+               shift
+               arguments="$arguments $option=$optarg"
+               ;;
+       --v)
+               arguments="$arguments -v"
+               ;;
+       --*)
+               arguments="$arguments $option"
+               ;;
+       esac
+
+# Now, process the options
+       case $option in
+
+       --build* | --bu*)
+               case "$build_alias" in
+               "") build_alias=$optarg ;;
+               *) echo '***' Can only configure for one build machine at a time.  1>&2
+                  fatal=yes
+                  ;;
+               esac
+               ;;
+       --cache*)
+               cache_file=$optarg
+               ;;
+       --disable-*)
+               enableopt=`echo ${option} | sed 's:^--disable-:enable_:;s:-:_:g'`
+               eval $enableopt=no
+               disableoptions="$disableoptions $option"
+               ;;
+       --enable-*)
+               case "$option" in
+               *=*)    ;;
+               *)      optarg=yes ;;
+               esac
+
+               enableopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
+               eval $enableopt="$optarg"
+               enableoptions="$enableoptions $option"
+               ;;
+       --exec-prefix* | --ex*)
+               exec_prefix=$optarg
+               exec_prefixoption="--exec-prefix=$optarg"
+               ;;
+       --gas | --g*)
+               gas=yes
+               ;;
+       --help | --he*)
+               fatal=yes
+               ;;
+       --host* | --ho*)
+               case $host_alias in
+               NOHOST) host_alias=$optarg ;;
+               *) echo '***' Can only configure for one host at a time.  1>&2
+                  fatal=yes
+                  ;;
+               esac
+               ;;
+       --nfp | --nf*)
+               floating_point=no
+               floating_pointoption="--nfp"
+               ;;
+       --norecursion | --no*)
+               norecursion=yes
+               ;;
+       --prefix* | --pre*)
+               prefix=$optarg
+               prefixoption="--prefix=$optarg"
+               ;;
+       --program-prefix* | --program-p*)
+               program_prefix=$optarg
+               program_prefixoption="--program-prefix=$optarg"
+               ;;
+       --program-suffix* | --program-s*)
+               program_suffix=$optarg
+               program_suffixoption="--program-suffix=$optarg"
+               ;;
+       --program-transform-name* | --program-t*)
+               # Double any backslashes or dollar signs in the argument
+               program_transform_name="${program_transform_name} -e `echo ${optarg} | sed -e 's/\\\\/\\\\\\\\/g' -e 's/\\\$/$$/g'`"
+               program_transform_nameoption="${program_transform_nameoption} --program-transform-name='$optarg'"
+               ;;
+       --rm)
+               removing=--rm
+               ;;
+       --silent | --sil* | --quiet | --q*)
+               redirect=">/dev/null"
+               verbose=--silent
+               ;;
+       --site* | --sit*)
+               site=$optarg
+               site_option="--site=$optarg"
+               ;;
+       --srcdir*/ | --sr*/)
+                # Remove trailing slashes.  Otherwise, when the file name gets
+                # bolted into an object file as debug info, it has two slashes
+                # in it.  Ordinarily this is ok, but emacs takes double slash
+                # to mean "forget the first part".
+               srcdir=`echo $optarg | sed -e 's:/$::'`
+               ;;
+       --srcdir* | --sr*)
+               srcdir=$optarg
+               ;;
+       --target* | --ta*)
+               case $target_alias in
+               NOTARGET) target_alias=$optarg ;;
+               *) echo '***' Can only configure for one target at a time.  1>&2
+                  fatal=yes
+                  ;;
+               esac
+               ;;
+       --tmpdir* | --tm*)
+               TMPDIR=$optarg
+               tmpdiroption="--tmpdir=$optarg"
+               ;;
+       --verbose | --v | --verb*)
+               redirect=
+               verbose=--verbose
+               ;;
+       --version | --V | --vers*)
+               echo "This is Cygnus Configure version" `echo ${version} | sed 's/[ $:]//g'`
+               exit 0
+               ;;
+       --with-*)
+               case "$option" in
+               *=*)    ;;
+               *)      optarg=yes ;;
+               esac
+
+               withopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
+               eval $withopt="$optarg"
+               withoptions="$withoptions $option"
+               ;;
+       --without-*)
+               withopt=`echo ${option} | sed 's:^--::;s:out::;s:-:_:g'`
+               eval $withopt=no
+               withoutoptions="$withoutoptions $option"
+               ;;
+       --x)    with_x=yes
+               withoptions="$withoptions --with-x"
+               ;;
+       --x-i* | --x-l*) other_options="$other_options $orig_option"
+               ;;
+       --bi* | --sb* | --li* | --da* | --sy* | --sh* | --lo* | --in* | --ol* | --ma*)
+               # These options were added to autoconf for emacs.
+               ;;
+       --*)
+               echo "configure: Unrecognized option: \"$orig_option\"; use --help for usage." >&2
+               exit 1
+               ;;
+       *)
+               case $undefs in
+               NOUNDEFS) undefs=$option ;;
+               *) echo '***' Can only configure for one host and one target at a time.  1>&2
+                  fatal=yes
+                  ;;
+               esac
+               ;;
+       esac
+done
+
+# process host and target
+
+# Do some error checking and defaulting for the host and target type.
+# The inputs are:
+#    configure --host=HOST --target=TARGET UNDEFS
+#
+# The rules are:
+# 1. You aren't allowed to specify --host, --target, and undefs at the
+#    same time.
+# 2. Host defaults to undefs.
+# 3. If undefs is not specified, then host defaults to the current host,
+#    as determined by config.guess.
+# 4. Target defaults to undefs.
+# 5. If undefs is not specified, then target defaults to host.
+
+case "${fatal}" in
+"")
+       # Make sure that host, target & undefs aren't all specified at the
+       # same time.
+       case $host_alias---$target_alias---$undefs in
+       NOHOST---*---* | *---NOTARGET---* | *---*---NOUNDEFS)
+               ;;
+       *) echo '***' Can only configure for one host and one target at a time.  1>&2
+          fatal=yes
+          break 2
+               ;;
+       esac
+
+       # Now, do defaulting for host.
+       case $host_alias in
+       NOHOST)
+               case $undefs in
+               NOUNDEFS)
+                       # Neither --host option nor undefs were present.
+                       # Call config.guess.
+                       guesssys=`echo ${progname} | sed 's/configure$/config.guess/'`
+                       if host_alias=`${guesssys}`
+                       then
+                               # If the string we are going to use for
+                               # the target is a prefix of the string
+                               # we just guessed for the host, then
+                               # assume we are running native, and force
+                               # the same string for both target and host.
+                               case $target_alias in
+                               NOTARGET) ;;
+                               *)
+                                       if expr $host_alias : $target_alias >/dev/null
+                                       then
+                                               host_alias=$target_alias
+                                       fi
+                                       ;;
+                               esac
+                               echo "Configuring for a ${host_alias} host." 1>&2
+                               arguments="--host=$host_alias $arguments"
+                       else
+                               echo 'Config.guess failed to determine the host type.  You need to specify one.' 1>&2
+                               fatal=yes
+                       fi
+                       ;;
+               *)
+                       host_alias=$undefs
+                       arguments="--host=$host_alias $arguments"
+                       undefs=NOUNDEFS
+                       ;;
+               esac
+       esac
+
+       # Do defaulting for target.  If --target option isn't present, default
+       # to undefs.  If undefs isn't present, default to host.
+       case $target_alias in
+       NOTARGET)
+               case $undefs in
+               NOUNDEFS)
+                       target_alias=$host_alias
+                       ;;
+               *)
+                       target_alias=$undefs
+                       arguments="--target=$target_alias $arguments"
+                       ;;
+               esac
+       esac
+       ;;
+*) ;;
+esac
+
+if [ -n "${fatal}" -o "${host_alias}" = "help" ] ; then
+       exec 1>&2
+       echo Usage: configure [OPTIONS] [HOST]
+       echo
+       echo Options: [defaults in brackets]
+       echo ' --prefix=MYDIR            install into MYDIR [/usr/local]'
+       echo ' --exec-prefix=MYDIR       install host-dependent files into MYDIR [/usr/local]'
+       echo ' --help                    print this message [normal config]'
+       echo ' --build=BUILD             configure for building on BUILD [BUILD=HOST]'
+       echo ' --host=HOST               configure for HOST [determined via config.guess]'
+       echo ' --norecursion             configure this directory only [recurse]'
+       echo ' --program-prefix=FOO      prepend FOO to installed program names [""]'
+       echo ' --program-suffix=FOO      append FOO to installed program names [""]'
+       echo ' --program-transform-name=P transform installed names by sed pattern P [""]'
+       echo ' --site=SITE               configure with site-specific makefile for SITE'
+       echo ' --srcdir=DIR              find the sources in DIR [. or ..]'
+       echo ' --target=TARGET   configure for TARGET [TARGET=HOST]'
+       echo ' --tmpdir=TMPDIR   create temporary files in TMPDIR [/tmp]'
+       echo ' --nfp                     configure for software floating point [hard float]'
+       echo ' --with-FOO, --with-FOO=BAR package FOO is available (parameter BAR)'
+       echo ' --without-FOO             package FOO is NOT available'
+       echo ' --enable-FOO, --enable-FOO=BAR include feature FOO (parameter BAR)'
+       echo ' --disable-FOO             do not include feature FOO'
+       echo
+       echo 'Where HOST and TARGET are something like "sparc-sunos", "mips-sgi-irix5", etc.'
+       echo
+       if [ -r config.status ] ; then
+               cat config.status
+       fi
+
+       exit 1
+fi
+
+configsub=`echo ${progname} | sed 's/configure$/config.sub/'`
+moveifchange=`echo ${progname} | sed 's/configure$/move-if-change/'`
+
+# this is a hack.  sun4 must always be a valid host alias or this will fail.
+if ${configsub} sun4 >/dev/null 2>&1 ; then
+        true
+else
+        echo '***' cannot find config.sub.  1>&2
+        exit 1
+fi
+
+touch config.junk
+if ${moveifchange} config.junk config.trash ; then
+        true
+else
+        echo '***' cannot find move-if-change.  1>&2
+        exit 1
+fi
+rm -f config.junk config.trash
+
+case "${srcdir}" in
+"")
+        if [ -r configure.in ] ; then
+                srcdir=.
+        else
+                if [ -r ${progname}.in ] ; then
+                        srcdir=`echo ${progname} | sed 's:/configure$::'`
+                else
+                        echo '***' "Can't find configure.in.  Try using --srcdir=some_dir"  1>&2
+                        exit 1
+                fi
+        fi
+        ;;
+*)
+       # Set srcdir to "." if that's what it is.
+       # This is important for multilib support.
+       if [ ! -d ${srcdir} ] ; then
+               echo "Invalid source directory ${srcdir}" >&2
+               exit 1
+       fi
+       pwd=`pwd`
+       srcpwd=`cd ${srcdir} ; pwd`
+       if [ "${pwd}" = "${srcpwd}" ] ; then
+               srcdir=.
+       fi
+esac
+
+### warn about some conflicting configurations.
+
+case "${srcdir}" in
+".") ;;
+*)
+        if [ -f ${srcdir}/config.status ] ; then
+                echo '***' Cannot configure here in \"${PWD=`pwd`}\" when \"${srcdir}\" is currently configured. 1>&2
+                exit 1
+        fi
+esac
+
+# default exec_prefix
+case "${exec_prefixoption}" in
+"") exec_prefix="\$(prefix)" ;;
+*) ;;
+esac
+
+### break up ${srcdir}/configure.in.
+case "`grep '^# per\-host:' ${srcdir}/configure.in`" in
+"")
+        echo '***' ${srcdir}/configure.in has no \"per-host:\" line. 1>&2
+       # Check for a directory that's been converted to use autoconf since
+       # it was last configured.
+       if grep AC_OUTPUT ${srcdir}/configure.in >/dev/null ; then
+         echo '***' Hmm, looks like this directory has been autoconfiscated. 1>&2
+         if [ -r ${srcdir}/configure ] ; then
+           echo '***' Running the local configure script. 1>&2
+           case "${cache_file}" in
+           "") cache_file_option= ;;
+           *)  cache_file_option="--cache-file=${cache_file}" ;;
+           esac
+           srcdiroption="--srcdir=${srcdir}"
+           case "${build_alias}" in
+           "") buildopt= ;;
+           *)  buildopt="--build=${build_alias}" ;;
+           esac
+           eval exec ${config_shell} ${srcdir}/configure ${verbose} \
+               ${buildopt} --host=${host_alias} --target=${target_alias} \
+               ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
+               ${srcdiroption} \
+               ${program_prefixoption} ${program_suffixoption} \
+               ${program_transform_nameoption} ${site_option} \
+               ${withoptions} ${withoutoptions} \
+               ${enableoptions} ${disableoptions} ${floating_pointoption} \
+               ${cache_file_option} ${removing} ${other_options} ${redirect}
+         else
+           echo '***' There is no configure script present though. 1>&2
+         fi
+       fi
+        exit 1
+        ;;
+*) ;;
+esac
+
+case "`grep '^# per\-target:' ${srcdir}/configure.in`" in
+"")
+        echo '***' ${srcdir}/configure.in has no \"per-target:\" line. 1>&2
+        exit 1
+        ;;
+*) ;;
+esac
+
+case "${TMPDIR}" in
+"") TMPDIR=/tmp ; export TMPDIR ;;
+*) ;;
+esac
+
+# keep this filename short for &%*%$*# 14 char file names
+tmpfile=${TMPDIR}/cONf$$
+# Note that under many versions of sh a trap handler for 0 will *override* any
+# exit status you explicitly specify!  At this point, the only non-error exit
+# is at the end of the script; these actions are duplicated there, minus
+# the "exit 1".  Don't use "exit 0" anywhere after this without resetting the
+# trap handler, or you'll lose.
+trap "rm -f Makefile.tem ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos; exit 1" 0 1 2 15
+
+# split ${srcdir}/configure.in into common, per-host, per-target,
+# and post-target parts.  Post-target is optional.
+sed -e '/^# per\-host:/,$d' ${srcdir}/configure.in > ${tmpfile}.com
+sed -e '1,/^# per\-host:/d' -e '/^# per\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.hst
+if grep '^# post-target:' ${srcdir}/configure.in >/dev/null ; then
+  sed -e '1,/^# per\-target:/d' -e '/^# post\-target:/,$d' ${srcdir}/configure.in > ${tmpfile}.tgt
+  sed -e '1,/^# post\-target:/d' ${srcdir}/configure.in > ${tmpfile}.pos
+else
+  sed -e '1,/^# per\-target:/d' ${srcdir}/configure.in > ${tmpfile}.tgt
+  echo >${tmpfile}.pos
+fi
+
+### do common part of configure.in
+
+. ${tmpfile}.com
+
+# some sanity checks on configure.in
+case "${srctrigger}" in
+"")
+        echo '***' srctrigger not set in ${PWD=`pwd`}/configure.in.  1>&2
+        exit 1
+        ;;
+*) ;;
+esac
+
+case "${build_alias}" in
+"")
+       if result=`${config_shell} ${configsub} ${host_alias}` ; then
+           build_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
+           build_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
+           build_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
+           build=${build_cpu}-${build_vendor}-${build_os}
+           build_alias=${host_alias}
+       fi
+       ;;
+*)
+       if result=`${config_shell} ${configsub} ${build_alias}` ; then
+           buildopt="--build=${build_alias}"
+           build_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
+           build_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
+           build_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
+           build=${build_cpu}-${build_vendor}-${build_os}
+       else
+           echo "Unrecognized build system name ${build_alias}." 1>&2
+           exit 1
+       fi
+       ;;
+esac
+
+if result=`${config_shell} ${configsub} ${host_alias}` ; then
+    true
+else
+    echo "Unrecognized host system name ${host_alias}." 1>&2
+    exit 1
+fi
+host_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
+host_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
+host_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
+host=${host_cpu}-${host_vendor}-${host_os}
+
+. ${tmpfile}.hst
+
+if result=`${config_shell} ${configsub} ${target_alias}` ; then
+    true
+else
+    echo "Unrecognized target system name ${target_alias}." 1>&2
+    exit 1
+fi
+target_cpu=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`
+target_vendor=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`
+target_os=`echo $result | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`
+target=${target_cpu}-${target_vendor}-${target_os}
+
+. ${tmpfile}.tgt
+
+# Find the source files, if location was not specified.
+case "${srcdir}" in
+"")
+        srcdirdefaulted=1
+        srcdir=.
+        if [ ! -r ${srctrigger} ] ; then
+                srcdir=..
+        fi
+        ;;
+*) ;;
+esac
+
+if [ ! -r ${srcdir}/${srctrigger} ] ; then
+        case "${srcdirdefaulted}" in
+        "") echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/${srcdir}" 1>&2 ;;
+        *)  echo '***' "${progname}: Can't find ${srcname} sources in ${PWD=`pwd`}/. or ${PWD=`pwd`}/.." 1>&2 ;;
+        esac
+
+        echo '***' \(At least ${srctrigger} is missing.\) 1>&2
+        exit 1
+fi
+
+# Some systems (e.g., one of the i386-aix systems the gas testers are
+# using) don't handle "\$" correctly, so don't use it here.
+tooldir='$(exec_prefix)'/${target_alias}
+
+if [ "${host_alias}" != "${target_alias}" ] ; then
+    if [ "${program_prefixoption}" = "" ] ; then
+        if [ "${program_suffixoption}" = "" ] ; then 
+            if [ "${program_transform_nameoption}" = "" ] ; then
+                program_prefix=${target_alias}- ;
+            fi
+        fi
+    fi
+fi
+
+# Merge program_prefix and program_suffix onto program_transform_name.
+# (program_suffix used to use $, but it's hard to preserve $ through both
+# make and sh.)
+if [ "${program_suffix}" != "" ] ; then
+    program_transform_name="-e s,\\\\(.*\\\\),\\\\1${program_suffix}, ${program_transform_name}"
+fi
+
+if [ "${program_prefix}" != "" ] ; then
+    program_transform_name="-e s,^,${program_prefix}, ${program_transform_name}"
+fi
+
+# If CC and CXX are not set in the environment, and the Makefile
+# exists, try to extract them from it.  This is to handle running
+# ./config.status by hand.
+if [ -z "${CC}" -a -r Makefile ]; then
+  sed -n -e ':loop
+/\\$/ N
+/\\$/ b loop
+s/\\\n//g
+/^CC[  ]*=/ s/CC[      ]*=[    ]*\(.*\)/\1/p' < Makefile > Makefile.cc
+  CC=`tail -1 Makefile.cc`
+  rm -f Makefile.cc
+fi
+
+if [ -z "${CXX}" -a -r Makefile ]; then
+  sed -n -e ':loop
+/\\$/ N
+/\\$/ b loop
+s/\\\n//g
+/^CXX[         ]*=/ s/CXX[     ]*=[    ]*\(.*\)/\1/p' < Makefile > Makefile.cc
+  CXX=`tail -1 Makefile.cc`
+  rm -f Makefile.cc
+fi
+
+if [ "${build}" != "${host}" ]; then
+  # If we are doing a Canadian Cross, in which the host and build systems
+  # are not the same, we set reasonable default values for the tools.
+
+  tools="AR AR_FOR_TARGET AS AS_FOR_TARGET BISON CC_FOR_BUILD"
+  tools="${tools} CC_FOR_TARGET CXX_FOR_TARGET"
+  tools="${tools} DLLTOOL DLLTOOL_FOR_TARGET HOST_PREFIX"
+  tools="${tools} HOST_PREFIX_1 LD LD_FOR_TARGET LEX MAKEINFO NM"
+  tools="${tools} NM_FOR_TARGET RANLIB RANLIB_FOR_TARGET"
+
+  for var in ${tools}; do
+    if [ -z "`eval 'echo $'"${var}"`" -a -r Makefile ]; then
+      sed -n -e ':loop
+/\\$/ N
+/\\$/ b loop
+s/\\\n//g
+/^'"${var}"'[  ]*=/ s/'"${var}"'[      ]*=[    ]*\(.*\)/\1/p' \
+       < Makefile > Makefile.v
+      t=`tail -1 Makefile.v`
+      if [ -n "${t}" ]; then
+       eval "${var}='${t}'"
+      fi
+      rm -f Makefile.v
+    fi
+  done
+
+  AR=${AR-${host_alias}-ar}
+  AR_FOR_TARGET=${AR_FOR_TARGET-${target_alias}-ar}
+  AS=${AS-${host_alias}-as}
+  AS_FOR_TARGET=${AS_FOR_TARGET-${target_alias}-as}
+  CC=${CC-${host_alias}-gcc}
+  CXX=${CXX-${host_alias}-gcc}
+  CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
+  CC_FOR_TARGET=${CC_FOR_TARGET-${target_alias}-gcc}
+  CXX_FOR_TARGET=${CXX_FOR_TARGET-${target_alias}-gcc}
+  DLLTOOL=${DLLTOOL-${host_alias}-dlltool}
+  DLLTOOL_FOR_TARGET=${DLLTOOL_FOR_TARGET-${target_alias}-dlltool}
+  HOST_PREFIX=${build_alias}-
+  HOST_PREFIX_1=${build_alias}-
+  LD=${LD-${host_alias}-ld}
+  LD_FOR_TARGET=${LD_FOR_TARGET-${target_alias}-ld}
+  MAKEINFO=${MAKEINFO-makeinfo}
+  NM=${NM-${host_alias}-nm}
+  NM_FOR_TARGET=${NM_FOR_TARGET-${target_alias}-nm}
+  RANLIB=${RANLIB-${host_alias}-ranlib}
+  RANLIB_FOR_TARGET=${RANLIB_FOR_TARGET-${target_alias}-ranlib}
+
+  if [ -z "${BISON}" ]; then
+    IFS="${IFS=        }"; save_ifs="$IFS"; IFS="${IFS}:"
+    for dir in $PATH; do
+      test -z "$dir" && dir=.
+      if test -f $dir/byacc; then
+       BISON=byacc
+       break
+      fi
+      if test -f $dir/bison; then
+       BISON=bison
+       break
+      fi
+      if test -f $dir/yacc; then
+       BISON=yacc
+       break
+      fi
+    done
+    IFS="$save_ifs"
+    BISON=${BISON-bison}
+  fi
+
+  if [ -z "${LEX}" ]; then
+    IFS="${IFS=        }"; save_ifs="$IFS"; IFS="${IFS}:"
+    for dir in $PATH; do
+      test -z "$dir" && dir=.
+      if test -f $dir/flex; then
+       LEX=flex
+       break
+      fi
+      if test -f $dir/lex; then
+       LEX=lex
+       break
+      fi
+    done
+    IFS="$save_ifs"
+    LEX=${LEX-flex}
+  fi
+
+  # Export variables which autoconf might try to set.
+  export AS
+  export AR
+  export CC_FOR_BUILD
+  export DLLTOOL
+  export LD
+  export NM
+  export RANLIB
+else
+  # If CC is still not set, try to get gcc.
+  if [ x$with_gcc != xno -a -z "${CC}" ]; then
+    IFS="${IFS=        }"; save_ifs="$IFS"; IFS="${IFS}:"
+    for dir in $PATH; do
+      test -z "$dir" && dir=.
+      if test -f $dir/gcc; then
+       CC="gcc -O2"
+       break
+      fi
+    done
+    IFS="$save_ifs"
+    CC=${CC-cc}
+  fi
+
+  CXX=${CXX-"gcc"}
+fi
+
+export CC
+export CXX
+
+case "$host" in
+       *go32*)
+           enable_gdbtk=no ;;
+esac
+
+# Determine whether gdb needs tk/tcl or not.
+if [ "$enable_gdbtk" != "no" ]; then
+       GDB_TK="all-tcl all-tk"
+else
+       GDB_TK=""
+fi
+
+for subdir in . ${subdirs} ; do
+
+    # ${subdir} is relative path from . to the directory we're currently
+    # configuring.
+    # ${invsubdir} is inverse of ${subdir), *with* trailing /, if needed.
+    invsubdir=`echo ${subdir}/ | sed -e 's|\./||g' -e 's|[^/]*/|../|g'`
+
+    ### figure out what to do with srcdir
+    case "${srcdir}" in
+        ".")  # no -srcdir option.  We're building in place.
+                makesrcdir=. ;;
+        /*) # absolute path
+                makesrcdir=`echo ${srcdir}/${subdir} | sed -e 's|/\.$||'`
+                ;;
+        *) # otherwise relative
+                case "${subdir}" in
+                .) makesrcdir=${srcdir} ;;
+                *) makesrcdir=${invsubdir}${srcdir}/${subdir} ;;
+                esac
+                ;;
+    esac
+
+    if [ "${subdir}/" != "./" ] ; then
+        Makefile=${subdir}/Makefile
+    fi
+
+    if [ ! -d ${subdir} ] ; then
+        if mkdir ${subdir} ; then
+                true
+        else
+                echo '***' "${progname}: could not make ${PWD=`pwd`}/${subdir}" 1>&2
+                exit 1
+        fi
+    fi
+
+    case "${removing}" in
+    "")
+        case "${subdir}" in
+        .) ;;
+        *) eval echo Building in ${subdir} ${redirect} ;;
+        esac
+
+        # FIXME Should this be done recursively ??? (Useful for e.g. gdbtest)
+        # Set up the list of links to be made.
+        # ${links} is the list of link names, and ${files} is the list of names to link to.
+
+        # Make the links.
+        configlinks="${links}"
+        if [ -r ${subdir}/config.status ] ; then
+                mv -f ${subdir}/config.status ${subdir}/config.back
+        fi
+        while [ -n "${files}" ] ; do
+                # set file to car of files, files to cdr of files
+                set ${files}; file=$1; shift; files=$*
+                set ${links}; link=$1; shift; links=$*
+
+                if [ ! -r ${srcdir}/${file} ] ; then
+                        echo '***' "${progname}: cannot create a link \"${link}\"," 1>&2
+                        echo '***' "since the file \"${srcdir}/${file}\" does not exist." 1>&2
+                        exit 1
+                fi
+
+                ${remove} -f ${link}
+               # Make a symlink if possible, otherwise try a hard link
+               if ${symbolic_link} ${srcdir}/${file} ${link} >/dev/null 2>&1 ; then
+                       true
+               else
+                       # We need to re-remove the file because Lynx leaves a 
+                       # very strange directory there when it fails an NFS symlink.
+                       ${remove} -r -f ${link}
+                       ${hard_link} ${srcdir}/${file} ${link}
+               fi
+                if [ ! -r ${link} ] ; then
+                        echo '***' "${progname}: unable to link \"${link}\" to \"${srcdir}/${file}\"." 1>&2
+                        exit 1
+                fi
+
+                echo "Linked \"${link}\" to \"${srcdir}/${file}\"."
+        done
+
+        # Create a .gdbinit file which runs the one in srcdir
+        # and tells GDB to look there for source files.
+
+        if [ -r ${srcdir}/${subdir}/.gdbinit ] ; then
+                case ${srcdir} in
+                .) ;;
+                *) cat > ${subdir}/.gdbinit <<EOF
+# ${NO_EDIT}
+dir ${makesrcdir}
+dir .
+source ${makesrcdir}/.gdbinit
+EOF
+                        ;;
+                esac
+        fi
+
+        # Install a makefile, and make it set VPATH
+        # if necessary so that the sources are found.
+        # Also change its value of srcdir.
+        # NOTE: Makefile generation constitutes the majority of the time in configure.  Hence, this section has
+        # been somewhat optimized and is perhaps a bit twisty.
+
+        # code is order so as to try to sed the smallest input files we know.
+
+        # the four makefile fragments MUST end up in the resulting Makefile in this order: 
+        # package, target, host, and site.  so do these separately because I don't trust the
+        #  order of sed -e expressions.
+
+        if [ -f ${srcdir}/${subdir}/${Makefile_in} ] ; then
+
+            # Conditionalize for this site from "Makefile.in" (or whatever it's called) into Makefile.tem
+            rm -f ${subdir}/Makefile.tem
+              case "${site}" in
+              "") cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem ;;
+              *)
+                      site_makefile_frag=${srcdir}/config/ms-${site}
+
+                      if [ -f ${site_makefile_frag} ] ; then
+                              sed -e "/^####/  r ${site_makefile_frag}" ${srcdir}/${subdir}/${Makefile_in} \
+                                      > ${subdir}/Makefile.tem
+                      else
+                              cp ${srcdir}/${subdir}/${Makefile_in} ${subdir}/Makefile.tem
+                              site_makefile_frag=
+                      fi
+                      ;;
+            esac
+            # working copy now in ${subdir}/Makefile.tem
+
+            # Conditionalize the makefile for this host.
+            rm -f ${Makefile}
+            case "${host_makefile_frag}" in
+              "") mv ${subdir}/Makefile.tem ${Makefile} ;;
+              *)
+                      if [ ! -f ${host_makefile_frag} ] ; then
+                              host_makefile_frag=${srcdir}/${host_makefile_frag}
+                      fi
+                      if [ -f ${host_makefile_frag} ] ; then
+                              sed -e "/^####/  r ${host_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
+                      else
+                              echo '***' Expected host makefile fragment \"${host_makefile_frag}\" 1>&2
+                              echo '***' is missing in ${PWD=`pwd`}. 1>&2
+                              mv ${subdir}/Makefile.tem ${Makefile}
+                      fi
+            esac
+            # working copy now in ${Makefile}
+
+            # Conditionalize the makefile for this target.
+            rm -f ${subdir}/Makefile.tem
+            case "${target_makefile_frag}" in
+              "") mv ${Makefile} ${subdir}/Makefile.tem ;;
+              *)
+                      if [ ! -f ${target_makefile_frag} ] ; then
+                              target_makefile_frag=${srcdir}/${target_makefile_frag}
+                      fi
+                      if [ -f ${target_makefile_frag} ] ; then
+                              sed -e "/^####/  r ${target_makefile_frag}" ${Makefile} > ${subdir}/Makefile.tem
+                      else
+                              mv ${Makefile} ${subdir}/Makefile.tem
+                              target_makefile_frag=
+                      fi
+                      ;;
+            esac
+            # real copy now in ${subdir}/Makefile.tem
+
+            # Conditionalize the makefile for this package.
+            rm -f ${Makefile}
+            case "${package_makefile_frag}" in
+              "") mv ${subdir}/Makefile.tem ${Makefile} ;;
+              *)
+                      if [ ! -f ${package_makefile_frag} ] ; then
+                              package_makefile_frag=${srcdir}/${package_makefile_frag}
+                      fi
+                      if [ -f ${package_makefile_frag} ] ; then
+                              sed -e "/^####/  r ${package_makefile_frag}" ${subdir}/Makefile.tem > ${Makefile}
+                             rm -f ${subdir}/Makefile.tem
+                      else
+                              echo '***' Expected package makefile fragment \"${package_makefile_frag}\" 1>&2
+                              echo '***' is missing in ${PWD=`pwd`}. 1>&2
+                              mv ${subdir}/Makefile.tem ${Makefile}
+                      fi
+            esac
+            # working copy now in ${Makefile}
+
+            mv ${Makefile} ${subdir}/Makefile.tem
+
+            # real copy now in ${subdir}/Makefile.tem
+
+            # prepend warning about editting, and a bunch of variables.
+            rm -f ${Makefile}
+            cat > ${Makefile} <<EOF
+# ${NO_EDIT}
+VPATH = ${makesrcdir}
+links = ${configlinks}
+host_alias = ${host_alias}
+host_cpu = ${host_cpu}
+host_vendor = ${host_vendor}
+host_os = ${host_os}
+host_canonical = ${host_cpu}-${host_vendor}-${host_os}
+target_alias = ${target_alias}
+target_cpu = ${target_cpu}
+target_vendor = ${target_vendor}
+target_os = ${target_os}
+target_canonical = ${target_cpu}-${target_vendor}-${target_os}
+EOF
+           case "${build}" in
+             "") ;;
+             *)  cat >> ${Makefile} << EOF
+build_alias = ${build_alias}
+build_cpu = ${build_cpu}
+build_vendor = ${build_vendor}
+build_os = ${build_os}
+build_canonical = ${build_cpu}-${build_vendor}-${build_os}
+EOF
+           esac
+
+            case "${package_makefile_frag}" in
+              "") ;;
+              /*) echo package_makefile_frag = ${package_makefile_frag} >>${Makefile} ;;
+              *)  echo package_makefile_frag = ${invsubdir}${package_makefile_frag} >>${Makefile} ;;
+            esac
+
+            case "${target_makefile_frag}" in
+              "") ;;
+              /*) echo target_makefile_frag = ${target_makefile_frag} >>${Makefile} ;;
+              *)  echo target_makefile_frag = ${invsubdir}${target_makefile_frag} >>${Makefile} ;;
+            esac
+
+            case "${host_makefile_frag}" in
+              "") ;;
+              /*) echo host_makefile_frag = ${host_makefile_frag} >>${Makefile} ;;
+              *)  echo host_makefile_frag = ${invsubdir}${host_makefile_frag} >>${Makefile} ;;
+            esac
+
+            if [ "${site_makefile_frag}" != "" ] ; then
+                echo site_makefile_frag = ${invsubdir}${site_makefile_frag} >>${Makefile}
+            fi 
+
+            # reset prefix, exec_prefix, srcdir, SUBDIRS, NONSUBDIRS,
+            # remove any form feeds.
+            if [ -z "${subdirs}" ]; then
+                rm -f ${subdir}/Makefile.tem2
+                sed -e "s:^SUBDIRS[    ]*=.*$:SUBDIRS = ${configdirs}:" \
+                    -e "s:^NONSUBDIRS[         ]*=.*$:NONSUBDIRS = ${noconfigdirs}:" \
+                    ${subdir}/Makefile.tem > ${subdir}/Makefile.tem2
+                rm -f ${subdir}/Makefile.tem
+                mv ${subdir}/Makefile.tem2 ${subdir}/Makefile.tem
+            fi
+            sed -e "s:^prefix[         ]*=.*$:prefix = ${prefix}:" \
+                    -e "s:^exec_prefix[        ]*=.*$:exec_prefix = ${exec_prefix}:" \
+                   -e "/^CC[   ]*=/{
+                       :loop1
+                       /\\\\$/ N
+                       /\\\\$/ b loop1
+                       s/\\\\\\n//g
+                       s%^CC[  ]*=.*$%CC = ${CC}%
+                       }" \
+                   -e "/^CXX[  ]*=/{
+                       :loop2
+                       /\\\\$/ N
+                       /\\\\$/ b loop2
+                       s/\\\\\\n//g
+                       s%^CXX[         ]*=.*$%CXX = ${CXX}%
+                       }" \
+                   -e "s:^SHELL[        ]*=.*$:SHELL = ${config_shell}:" \
+                   -e "s:^GDB_TK[       ]*=.*$:GDB_TK = ${GDB_TK}:" \
+                    -e "s:^srcdir[     ]*=.*$:srcdir = ${makesrcdir}:" \
+                    -e "s/\f//" \
+                    -e "s:^program_prefix[     ]*=.*$:program_prefix = ${program_prefix}:" \
+                    -e "s:^program_suffix[     ]*=.*$:program_suffix = ${program_suffix}:" \
+                    -e "s:^program_transform_name[     ]*=.*$:program_transform_name = ${program_transform_name}:" \
+                    -e "s:^tooldir[    ]*=.*$:tooldir = ${tooldir}:" \
+                    ${subdir}/Makefile.tem >> ${Makefile}
+
+           # If this is a Canadian Cross, preset the values of many more
+           # tools.
+           if [ "${build}" != "${host}" ]; then
+               for var in ${tools}; do
+                   val=`eval 'echo $'"${var}"`
+                   sed -e "/^${var}[   ]*=/{
+                          :loop1
+                          /\\\\$/ N
+                          /\\\\$/ b loop1
+                          s/\\\\\\n//g
+                          s%^${var}[   ]*=.*$%${var} = ${val}%
+                          }" ${Makefile} > ${Makefile}.tem
+                   mv -f ${Makefile}.tem ${Makefile}
+               done
+           fi
+
+            # final copy now in ${Makefile}
+
+        else
+           echo "No Makefile.in found in ${srcdir}/${subdir}, unable to configure" 1>&2
+        fi
+
+        rm -f ${subdir}/Makefile.tem
+
+        case "${host_makefile_frag}" in
+        "") using= ;;
+        *) using="and \"${host_makefile_frag}\"" ;;
+        esac
+
+        case "${target_makefile_frag}" in
+        "") ;;
+        *) using="${using} and \"${target_makefile_frag}\"" ;;
+        esac
+
+        case "${site_makefile_frag}" in
+        "") ;;
+        *) using="${using} and \"${site_makefile_frag}\"" ;;
+        esac
+
+        newusing=`echo "${using}" | sed 's/and/using/'`
+        using=${newusing}
+        echo "Created \"${Makefile}\" in" ${PWD=`pwd`} ${using}
+
+        . ${tmpfile}.pos
+
+        # describe the chosen configuration in config.status.
+        # Make that file a shellscript which will reestablish
+        # the same configuration.  Used in Makefiles to rebuild
+        # Makefiles.
+
+        case "${norecursion}" in
+        "") arguments="${arguments} --norecursion" ;;
+        *) ;;
+        esac
+
+        if [ ${subdir} = . ] ; then
+            echo "#!/bin/sh
+# ${NO_EDIT}
+# This directory was configured as follows:
+${progname}" ${arguments}  "
+# ${using}" > ${subdir}/config.new
+        else
+            echo "#!/bin/sh
+# ${NO_EDIT}
+# This directory was configured as follows:
+cd ${invsubdir}
+${progname}" ${arguments}  "
+# ${using}" > ${subdir}/config.new
+        fi
+        chmod a+x ${subdir}/config.new
+        if [ -r ${subdir}/config.back ] ; then
+                mv -f ${subdir}/config.back ${subdir}/config.status
+        fi
+        ${moveifchange} ${subdir}/config.new ${subdir}/config.status
+        ;;
+
+    *)  rm -f ${Makefile} ${subdir}/config.status ${links} ;;
+    esac
+done
+
+# If there are subdirectories, then recur. 
+if [ -z "${norecursion}" -a -n "${configdirs}" ] ; then 
+        for configdir in ${configdirs} ; do
+
+                if [ -d ${srcdir}/${configdir} ] ; then
+                        eval echo Configuring ${configdir}... ${redirect}
+                        case "${srcdir}" in
+                        ".") ;;
+                        *)
+                                if [ ! -d ./${configdir} ] ; then
+                                        if mkdir ./${configdir} ; then
+                                                true
+                                        else
+                                                echo '***' "${progname}: could not make ${PWD=`pwd`}/${configdir}" 1>&2
+                                                exit 1
+                                        fi
+                                fi
+                                ;;
+                        esac
+
+                        POPDIR=${PWD=`pwd`}
+                        cd ${configdir} 
+
+### figure out what to do with srcdir
+                        case "${srcdir}" in
+                        ".") newsrcdir=${srcdir} ;; # no -srcdir option.  We're building in place.
+                        /*) # absolute path
+                                newsrcdir=${srcdir}/${configdir}
+                                srcdiroption="--srcdir=${newsrcdir}"
+                                ;;
+                        *) # otherwise relative
+                                newsrcdir=../${srcdir}/${configdir}
+                                srcdiroption="--srcdir=${newsrcdir}"
+                                ;;
+                        esac
+
+                       # Handle --cache-file=../XXX
+                       case "${cache_file}" in
+                       "") # empty
+                               ;;
+                       /*) # absolute path
+                               cache_file_option="--cache-file=${cache_file}"
+                               ;;
+                       *) # relative path
+                               cache_file_option="--cache-file=../${cache_file}"
+                               ;;
+                       esac
+
+### check for guested configure, otherwise fix possibly relative progname
+                        if [ -f ${newsrcdir}/configure ] ; then
+                                recprog=${newsrcdir}/configure
+                        elif [ -f ${newsrcdir}/configure.in ] ; then
+                                case "${progname}" in
+                                /*)     recprog=${progname} ;;
+                                *)      recprog=../${progname} ;;
+                                esac
+                       else
+                               eval echo No configuration information in ${configdir} ${redirect}
+                               recprog=
+                        fi
+
+### The recursion line is here.
+                       if [ ! -z "${recprog}" ] ; then
+                               if eval ${config_shell} ${recprog} ${verbose} ${buildopt} --host=${host_alias} --target=${target_alias} \
+                                       ${prefixoption} ${tmpdiroption} ${exec_prefixoption} \
+                                       ${srcdiroption} ${program_prefixoption} ${program_suffixoption} ${program_transform_nameoption} ${site_option} ${withoptions} ${withoutoptions} ${enableoptions} ${disableoptions} ${floating_pointoption} ${cache_file_option} ${removing} ${other_options} ${redirect} ; then
+                                       true
+                               else
+                                       echo Configure in `pwd` failed, exiting. 1>&2
+                                       exit 1
+                               fi
+                       fi
+
+                        cd ${POPDIR}
+                fi
+        done
+fi
+
+# Perform the same cleanup as the trap handler, minus the "exit 1" of course,
+# and reset the trap handler.
+rm -f ${tmpfile}.com ${tmpfile}.tgt ${tmpfile}.hst ${tmpfile}.pos
+trap 0
+
+exit 0
+
+#
+# Local Variables:
+# fill-column: 131
+# End:
+#
+
+# end of configure
diff --git a/ghc/rts/gmp/configure.in b/ghc/rts/gmp/configure.in
new file mode 100644 (file)
index 0000000..42192b5
--- /dev/null
@@ -0,0 +1,35 @@
+# This file is a shell script fragment that supplies the information
+# necessary for a configure script to process the program in
+# this directory.  For more information, look at ../configure.
+
+configdirs="mpn mpz mpf mpq mpbsd"
+srctrigger=gmp-impl.h
+srcname="GNU Multi-Precision library"
+
+# per-host:
+
+# per-target:
+
+case "${target}" in
+  sparc8* | microsparc*)
+    if [ x$with_gcc != xno ]
+    then
+      target_makefile_frag=config/mt-sprc8-gcc
+    fi
+    ;;
+  supersparc*)
+    if [ x$with_gcc != xno ]
+    then
+      target_makefile_frag=config/mt-supspc-gcc
+    fi
+    ;;
+  m888110*)
+    if [ x$with_gcc != xno ]
+    then
+      target_makefile_frag=config/mt-m88110
+    fi
+    ;;
+  *-*-linux*)
+    target_makefile_frag=config/mt-linux ;;
+    
+esac
diff --git a/ghc/rts/gmp/cre-mparam.c b/ghc/rts/gmp/cre-mparam.c
new file mode 100644 (file)
index 0000000..2020c8a
--- /dev/null
@@ -0,0 +1,16 @@
+#include "gmp.h"
+
+main ()
+{
+printf ("/* gmp-mparam.h -- Compiler/machine parameter header file.\n\n");
+printf ("    *** CREATED BY A PROGRAM -- DO NOT EDIT ***\n\n");
+printf ("Copyright (C) 1996 Free Software Foundation, Inc.  */\n\n");
+
+printf ("#define BITS_PER_MP_LIMB %d\n", 8 * sizeof (mp_limb_t));
+printf ("#define BYTES_PER_MP_LIMB %d\n", sizeof (mp_limb_t));
+printf ("#define BITS_PER_LONGINT %d\n", 8 * sizeof (long));
+printf ("#define BITS_PER_INT %d\n", 8 * sizeof (int));
+printf ("#define BITS_PER_SHORTINT %d\n", 8 * sizeof (short));
+printf ("#define BITS_PER_CHAR 8\n");
+exit (0);
+}
diff --git a/ghc/rts/gmp/extract-double.c b/ghc/rts/gmp/extract-double.c
new file mode 100644 (file)
index 0000000..052b1a9
--- /dev/null
@@ -0,0 +1,160 @@
+/* __gmp_extract_double -- convert from double to array of mp_limb_t.
+
+Copyright (C) 1996 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU Library General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at your
+option) any later version.
+
+The GNU MP Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+License for more details.
+
+You should have received a copy of the GNU Library General Public License
+along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+
+#ifdef XDEBUG
+#undef _GMP_IEEE_FLOATS
+#endif
+
+#ifndef _GMP_IEEE_FLOATS
+#define _GMP_IEEE_FLOATS 0
+#endif
+
+#define MP_BASE_AS_DOUBLE (2.0 * ((mp_limb_t) 1 << (BITS_PER_MP_LIMB - 1)))
+
+/* Extract a non-negative double in d.  */
+
+int
+#if __STDC__
+__gmp_extract_double (mp_ptr rp, double d)
+#else
+__gmp_extract_double (rp, d)
+     mp_ptr rp;
+     double d;
+#endif
+{
+  long exp;
+  unsigned sc;
+  mp_limb_t manh, manl;
+
+  /* BUGS
+
+     1. Should handle Inf and NaN in IEEE specific code.
+     2. Handle Inf and NaN also in default code, to avoid hangs.
+     3. Generalize to handle all BITS_PER_MP_LIMB >= 32.
+     4. This lits is incomplete and misspelled.
+   */
+
+  if (d == 0.0)
+    {
+      rp[0] = 0;
+      rp[1] = 0;
+#if BITS_PER_MP_LIMB == 32
+      rp[2] = 0;
+#endif
+      return 0;
+    }
+
+#if _GMP_IEEE_FLOATS
+  {
+    union ieee_double_extract x;
+    x.d = d;
+
+    exp = x.s.exp;
+    sc = (unsigned) (exp + 2) % BITS_PER_MP_LIMB;
+#if BITS_PER_MP_LIMB == 64
+    manl = (((mp_limb_t) 1 << 63)
+           | ((mp_limb_t) x.s.manh << 43) | ((mp_limb_t) x.s.manl << 11));
+#else
+    manh = ((mp_limb_t) 1 << 31) | (x.s.manh << 11) | (x.s.manl >> 21);
+    manl = x.s.manl << 11;
+#endif
+  }
+#else
+  {
+    /* Unknown (or known to be non-IEEE) double format.  */
+    exp = 0;
+    if (d >= 1.0)
+      {
+       if (d * 0.5 == d)
+         abort ();
+
+       while (d >= 32768.0)
+         {
+           d *= (1.0 / 65536.0);
+           exp += 16;
+         }
+       while (d >= 1.0)
+         {
+           d *= 0.5;
+           exp += 1;
+         }
+      }
+    else if (d < 0.5)
+      {
+       while (d < (1.0 / 65536.0))
+         {
+           d *=  65536.0;
+           exp -= 16;
+         }
+       while (d < 0.5)
+         {
+           d *= 2.0;
+           exp -= 1;
+         }
+      }
+
+    sc = (unsigned) exp % BITS_PER_MP_LIMB;
+
+    d *= MP_BASE_AS_DOUBLE;
+#if BITS_PER_MP_LIMB == 64
+    manl = d;
+#else
+    manh = d;
+    manl = (d - manh) * MP_BASE_AS_DOUBLE;
+#endif
+
+    exp += 1022;
+  }
+#endif
+
+  exp = (unsigned) (exp + 1) / BITS_PER_MP_LIMB - 1024 / BITS_PER_MP_LIMB + 1;
+
+#if BITS_PER_MP_LIMB == 64
+  if (sc != 0)
+    {
+      rp[1] = manl >> (BITS_PER_MP_LIMB - sc);
+      rp[0] = manl << sc;
+    }
+  else
+    {
+      rp[1] = manl;
+      rp[0] = 0;
+    }
+#else
+  if (sc != 0)
+    {
+      rp[2] = manh >> (BITS_PER_MP_LIMB - sc);
+      rp[1] = (manl >> (BITS_PER_MP_LIMB - sc)) | (manh << sc);
+      rp[0] = manl << sc;
+    }
+  else
+    {
+      rp[2] = manh;
+      rp[1] = manl;
+      rp[0] = 0;
+    }
+#endif
+
+  return exp;
+}
diff --git a/ghc/rts/gmp/gmp-impl.h b/ghc/rts/gmp/gmp-impl.h
new file mode 100644 (file)
index 0000000..7d56846
--- /dev/null
@@ -0,0 +1,367 @@
+/* Include file for internal GNU MP types and definitions.
+
+Copyright (C) 1991, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU Library General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at your
+option) any later version.
+
+The GNU MP Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+License for more details.
+
+You should have received a copy of the GNU Library General Public License
+along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+/* When using gcc, make sure to use its builtin alloca.  */
+#if ! defined (alloca) && defined (__GNUC__)
+#define alloca __builtin_alloca
+#define HAVE_ALLOCA
+#endif
+
+/* When using cc, do whatever necessary to allow use of alloca.  For many
+   machines, this means including alloca.h.  IBM's compilers need a #pragma
+   in "each module that needs to use alloca".  */
+#if ! defined (alloca)
+/* We need lots of variants for MIPS, to cover all versions and perversions
+   of OSes for MIPS.  */
+#if defined (__mips) || defined (MIPSEL) || defined (MIPSEB) \
+ || defined (_MIPSEL) || defined (_MIPSEB) || defined (__sgi) \
+ || defined (__alpha) || defined (__sparc) || defined (sparc) \
+ || defined (__ksr__)
+#include <alloca.h>
+#define HAVE_ALLOCA
+#endif
+#if defined (_IBMR2)
+#pragma alloca
+#define HAVE_ALLOCA
+#endif
+#if defined (__DECC)
+#define alloca(x) __ALLOCA(x)
+#define HAVE_ALLOCA
+#endif
+#endif
+
+#if ! defined (HAVE_ALLOCA) || USE_STACK_ALLOC
+#include "stack-alloc.h"
+#else
+#define TMP_DECL(m)
+#define TMP_ALLOC(x) alloca(x)
+#define TMP_MARK(m)
+#define TMP_FREE(m)
+#endif
+
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+#if ! defined (__GNUC__)
+#define inline                 /* Empty */
+#endif
+
+#define ABS(x) (x >= 0 ? x : -x)
+#define MIN(l,o) ((l) < (o) ? (l) : (o))
+#define MAX(h,i) ((h) > (i) ? (h) : (i))
+
+/* Field access macros.  */
+#define SIZ(x) ((x)->_mp_size)
+#define ABSIZ(x) ABS (SIZ (x))
+#define PTR(x) ((x)->_mp_d)
+#define EXP(x) ((x)->_mp_exp)
+#define PREC(x) ((x)->_mp_prec)
+#define ALLOC(x) ((x)->_mp_alloc)
+
+#include "gmp-mparam.h"
+/* #include "longlong.h" */
+
+#if defined (__STDC__)  || defined (__cplusplus)
+void *malloc (size_t);
+void *realloc (void *, size_t);
+void free (void *);
+
+extern void *  (*_mp_allocate_func) (size_t);
+extern void *  (*_mp_reallocate_func) (void *, size_t, size_t);
+extern void    (*_mp_free_func) (void *, size_t);
+
+void *_mp_default_allocate (size_t);
+void *_mp_default_reallocate (void *, size_t, size_t);
+void _mp_default_free (void *, size_t);
+
+#else
+
+#define const                  /* Empty */
+#define signed                 /* Empty */
+
+void *malloc ();
+void *realloc ();
+void free ();
+
+extern void *  (*_mp_allocate_func) ();
+extern void *  (*_mp_reallocate_func) ();
+extern void    (*_mp_free_func) ();
+
+void *_mp_default_allocate ();
+void *_mp_default_reallocate ();
+void _mp_default_free ();
+#endif
+
+/* Copy NLIMBS *limbs* from SRC to DST.  */
+#define MPN_COPY_INCR(DST, SRC, NLIMBS) \
+  do {                                                                 \
+    mp_size_t __i;                                                     \
+    for (__i = 0; __i < (NLIMBS); __i++)                               \
+      (DST)[__i] = (SRC)[__i];                                         \
+  } while (0)
+#define MPN_COPY_DECR(DST, SRC, NLIMBS) \
+  do {                                                                 \
+    mp_size_t __i;                                                     \
+    for (__i = (NLIMBS) - 1; __i >= 0; __i--)                          \
+      (DST)[__i] = (SRC)[__i];                                         \
+  } while (0)
+#define MPN_COPY MPN_COPY_INCR
+
+/* Zero NLIMBS *limbs* AT DST.  */
+#define MPN_ZERO(DST, NLIMBS) \
+  do {                                                                 \
+    mp_size_t __i;                                                     \
+    for (__i = 0; __i < (NLIMBS); __i++)                               \
+      (DST)[__i] = 0;                                                  \
+  } while (0)
+
+#define MPN_NORMALIZE(DST, NLIMBS) \
+  do {                                                                 \
+    while (NLIMBS > 0)                                                 \
+      {                                                                        \
+       if ((DST)[(NLIMBS) - 1] != 0)                                   \
+         break;                                                        \
+       NLIMBS--;                                                       \
+      }                                                                        \
+  } while (0)
+#define MPN_NORMALIZE_NOT_ZERO(DST, NLIMBS) \
+  do {                                                                 \
+    while (1)                                                          \
+      {                                                                        \
+       if ((DST)[(NLIMBS) - 1] != 0)                                   \
+         break;                                                        \
+       NLIMBS--;                                                       \
+      }                                                                        \
+  } while (0)
+
+/* Initialize the MP_INT X with space for NLIMBS limbs.
+   X should be a temporary variable, and it will be automatically
+   cleared out when the running function returns.
+   We use __x here to make it possible to accept both mpz_ptr and mpz_t
+   arguments.  */
+#define MPZ_TMP_INIT(X, NLIMBS) \
+  do {                                                                 \
+    mpz_ptr __x = (X);                                                 \
+    __x->_mp_alloc = (NLIMBS);                                         \
+    __x->_mp_d = (mp_ptr) TMP_ALLOC ((NLIMBS) * BYTES_PER_MP_LIMB);    \
+  } while (0)
+
+#define MPN_MUL_N_RECURSE(prodp, up, vp, size, tspace) \
+  do {                                                                 \
+    if ((size) < KARATSUBA_THRESHOLD)                                  \
+      impn_mul_n_basecase (prodp, up, vp, size);                       \
+    else                                                               \
+      impn_mul_n (prodp, up, vp, size, tspace);                        \
+  } while (0);
+#define MPN_SQR_N_RECURSE(prodp, up, size, tspace) \
+  do {                                                                 \
+    if ((size) < KARATSUBA_THRESHOLD)                                  \
+      impn_sqr_n_basecase (prodp, up, size);                           \
+    else                                                               \
+      impn_sqr_n (prodp, up, size, tspace);                            \
+  } while (0);
+
+/* Structure for conversion between internal binary format and
+   strings in base 2..36.  */
+struct bases
+{
+  /* Number of digits in the conversion base that always fits in an mp_limb_t.
+     For example, for base 10 on a machine where a mp_limb_t has 32 bits this
+     is 9, since 10**9 is the largest number that fits into a mp_limb_t.  */
+  int chars_per_limb;
+
+  /* log(2)/log(conversion_base) */
+  float chars_per_bit_exactly;
+
+  /* base**chars_per_limb, i.e. the biggest number that fits a word, built by
+     factors of base.  Exception: For 2, 4, 8, etc, big_base is log2(base),
+     i.e. the number of bits used to represent each digit in the base.  */
+  mp_limb_t big_base;
+
+  /* A BITS_PER_MP_LIMB bit approximation to 1/big_base, represented as a
+     fixed-point number.  Instead of dividing by big_base an application can
+     choose to multiply by big_base_inverted.  */
+  mp_limb_t big_base_inverted;
+};
+
+extern const struct bases __mp_bases[];
+extern mp_size_t __gmp_default_fp_limb_precision;
+
+/* Divide the two-limb number in (NH,,NL) by D, with DI being the largest
+   limb not larger than (2**(2*BITS_PER_MP_LIMB))/D - (2**BITS_PER_MP_LIMB).
+   If this would yield overflow, DI should be the largest possible number
+   (i.e., only ones).  For correct operation, the most significant bit of D
+   has to be set.  Put the quotient in Q and the remainder in R.  */
+#define udiv_qrnnd_preinv(q, r, nh, nl, d, di) \
+  do {                                                                 \
+    mp_limb_t _q, _ql, _r;                                             \
+    mp_limb_t _xh, _xl;                                                        \
+    umul_ppmm (_q, _ql, (nh), (di));                                   \
+    _q += (nh);                        /* DI is 2**BITS_PER_MP_LIMB too small */\
+    umul_ppmm (_xh, _xl, _q, (d));                                     \
+    sub_ddmmss (_xh, _r, (nh), (nl), _xh, _xl);                                \
+    if (_xh != 0)                                                      \
+      {                                                                        \
+       sub_ddmmss (_xh, _r, _xh, _r, 0, (d));                          \
+       _q += 1;                                                        \
+       if (_xh != 0)                                                   \
+         {                                                             \
+           sub_ddmmss (_xh, _r, _xh, _r, 0, (d));                      \
+           _q += 1;                                                    \
+         }                                                             \
+      }                                                                        \
+    if (_r >= (d))                                                     \
+      {                                                                        \
+       _r -= (d);                                                      \
+       _q += 1;                                                        \
+      }                                                                        \
+    (r) = _r;                                                          \
+    (q) = _q;                                                          \
+  } while (0)
+/* Like udiv_qrnnd_preinv, but for for any value D.  DNORM is D shifted left
+   so that its most significant bit is set.  LGUP is ceil(log2(D)).  */
+#define udiv_qrnnd_preinv2gen(q, r, nh, nl, d, di, dnorm, lgup) \
+  do {                                                                 \
+    mp_limb_t n2, n10, n1, nadj, q1;                                   \
+    mp_limb_t _xh, _xl;                                                        \
+    n2 = ((nh) << (BITS_PER_MP_LIMB - (lgup))) + ((nl) >> 1 >> (l - 1));\
+    n10 = (nl) << (BITS_PER_MP_LIMB - (lgup));                         \
+    n1 = ((mp_limb_signed_t) n10 >> (BITS_PER_MP_LIMB - 1));           \
+    nadj = n10 + (n1 & (dnorm));                                       \
+    umul_ppmm (_xh, _xl, di, n2 - n1);                                 \
+    add_ssaaaa (_xh, _xl, _xh, _xl, 0, nadj);                          \
+    q1 = ~(n2 + _xh);                                                  \
+    umul_ppmm (_xh, _xl, q1, d);                                       \
+    add_ssaaaa (_xh, _xl, _xh, _xl, nh, nl);                           \
+    _xh -= (d);                                                                \
+    (r) = _xl + ((d) & _xh);                                           \
+    (q) = _xh - q1;                                                    \
+  } while (0)
+/* Exactly like udiv_qrnnd_preinv, but branch-free.  It is not clear which
+   version to use.  */
+#define udiv_qrnnd_preinv2norm(q, r, nh, nl, d, di) \
+  do {                                                                 \
+    mp_limb_t n2, n10, n1, nadj, q1;                                   \
+    mp_limb_t _xh, _xl;                                                        \
+    n2 = (nh);                                                         \
+    n10 = (nl);                                                                \
+    n1 = ((mp_limb_signed_t) n10 >> (BITS_PER_MP_LIMB - 1));           \
+    nadj = n10 + (n1 & (d));                                           \
+    umul_ppmm (_xh, _xl, di, n2 - n1);                                 \
+    add_ssaaaa (_xh, _xl, _xh, _xl, 0, nadj);                          \
+    q1 = ~(n2 + _xh);                                                  \
+    umul_ppmm (_xh, _xl, q1, d);                                       \
+    add_ssaaaa (_xh, _xl, _xh, _xl, nh, nl);                           \
+    _xh -= (d);                                                                \
+    (r) = _xl + ((d) & _xh);                                           \
+    (q) = _xh - q1;                                                    \
+  } while (0)
+
+#if defined (__GNUC__)
+/* Define stuff for longlong.h.  */
+typedef unsigned int UQItype   __attribute__ ((mode (QI)));
+typedef         int SItype     __attribute__ ((mode (SI)));
+typedef unsigned int USItype   __attribute__ ((mode (SI)));
+typedef                 int DItype     __attribute__ ((mode (DI)));
+typedef unsigned int UDItype   __attribute__ ((mode (DI)));
+#else
+typedef unsigned char UQItype;
+typedef         long SItype;
+typedef unsigned long USItype;
+#endif
+
+typedef mp_limb_t UWtype;
+typedef unsigned int UHWtype;
+#define W_TYPE_SIZE BITS_PER_MP_LIMB
+
+/* Internal mpn calls */
+#define impn_mul_n_basecase    __MPN(impn_mul_n_basecase)
+#define impn_mul_n             __MPN(impn_mul_n)
+#define impn_sqr_n_basecase    __MPN(impn_sqr_n_basecase)
+#define impn_sqr_n             __MPN(impn_sqr_n)
+
+/* Define ieee_double_extract and _GMP_IEEE_FLOATS.  */
+
+#if defined (_LITTLE_ENDIAN) || defined (__LITTLE_ENDIAN__)            \
+ || defined (__alpha)                                                  \
+ || (defined (__arm__) && defined (__ARMWEL__))                                \
+ || defined (__clipper__)                                              \
+ || defined (__cris)                                                   \
+ || defined (__i386__)                                                 \
+ || defined (__i860__)                                                 \
+ || defined (__i960__)                                                 \
+ || defined (MIPSEL) || defined (_MIPSEL)                              \
+ || defined (__ns32000__)                                              \
+ || defined (__WINNT) || defined (_WIN32)
+#define _GMP_IEEE_FLOATS 1
+union ieee_double_extract
+{
+  struct
+    {
+      unsigned int manl:32;
+      unsigned int manh:20;
+      unsigned int exp:11;
+      unsigned int sig:1;
+    } s;
+  double d;
+};
+#else /* Need this as an #else since the tests aren't made exclusive.  */
+#if defined (_BIG_ENDIAN)                                              \
+ || defined (__a29k__) || defined (_AM29K)                             \
+ || defined (__arm__)                                                  \
+ || (defined (__convex__) && defined (_IEEE_FLOAT_))                   \
+ || defined (__i370__) || defined (__mvs__)                            \
+ || defined (__mc68000__) || defined (__mc68020__) || defined (__NeXT__)\
+    || defined(mc68020)                                                        \
+ || defined (__m88000__)                                               \
+ || defined (MIPSEB) || defined (_MIPSEB)                              \
+ || defined (__hppa)                                                   \
+ || defined (__pyr__)                                                  \
+ || defined (__ibm032__)                                               \
+ || defined (_IBMR2) || defined (_ARCH_PPC)                            \
+ || defined (__sh__)                                                   \
+ || defined (__sparc) || defined (sparc)                               \
+ || defined (__we32k__)
+#define _GMP_IEEE_FLOATS 1
+union ieee_double_extract
+{
+  struct
+    {
+      unsigned int sig:1;
+      unsigned int exp:11;
+      unsigned int manh:20;
+      unsigned int manl:32;
+    } s;
+  double d;
+};
+#endif
+#endif
+
+#define MP_BASE_AS_DOUBLE (2.0 * ((mp_limb_t) 1 << (BITS_PER_MP_LIMB - 1)))
+#if BITS_PER_MP_LIMB == 64
+#define LIMBS_PER_DOUBLE 2
+#else
+#define LIMBS_PER_DOUBLE 3
+#endif
+
+double __gmp_scale2 _PROTO ((double, int));
+int __gmp_extract_double _PROTO((mp_ptr, double));
diff --git a/ghc/rts/gmp/gmp.h b/ghc/rts/gmp/gmp.h
new file mode 100644 (file)
index 0000000..a1cc1ac
--- /dev/null
@@ -0,0 +1,632 @@
+/* gmp.h -- Definitions for GNU multiple precision functions.
+
+Copyright (C) 1991, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU Library General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at your
+option) any later version.
+
+The GNU MP Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+License for more details.
+
+You should have received a copy of the GNU Library General Public License
+along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+#ifndef __GMP_H__
+
+#ifndef __GNU_MP__
+#define __GNU_MP__ 2
+#define __need_size_t
+#include <stddef.h>
+#undef __need_size_t
+
+#if defined (__STDC__) || defined (__cplusplus)
+#define __gmp_const const
+#else
+#define __gmp_const
+#endif
+
+#if defined (__GNUC__)
+#define __gmp_inline __inline__
+#else
+#define __gmp_inline
+#endif
+
+#ifndef _EXTERN_INLINE
+#ifdef __GNUC__
+#define _EXTERN_INLINE extern __inline__
+#else
+#define _EXTERN_INLINE static
+#endif
+#endif
+
+#ifdef _SHORT_LIMB
+typedef unsigned int           mp_limb_t;
+typedef int                    mp_limb_signed_t;
+#else
+#ifdef _LONG_LONG_LIMB
+typedef unsigned long long int mp_limb_t;
+typedef long long int          mp_limb_signed_t;
+#else
+typedef unsigned long int      mp_limb_t;
+typedef long int               mp_limb_signed_t;
+#endif
+#endif
+
+typedef mp_limb_t *            mp_ptr;
+typedef __gmp_const mp_limb_t *        mp_srcptr;
+typedef long int               mp_size_t;
+typedef long int               mp_exp_t;
+
+#ifndef __MP_SMALL__
+typedef struct
+{
+  int _mp_alloc;               /* Number of *limbs* allocated and pointed
+                                  to by the D field.  */
+  int _mp_size;                        /* abs(SIZE) is the number of limbs
+                                  the last field points to.  If SIZE
+                                  is negative this is a negative
+                                  number.  */
+  mp_limb_t *_mp_d;            /* Pointer to the limbs.  */
+} __mpz_struct;
+#else
+typedef struct
+{
+  short int _mp_alloc;         /* Number of *limbs* allocated and pointed
+                                  to by the D field.  */
+  short int _mp_size;          /* abs(SIZE) is the number of limbs
+                                  the last field points to.  If SIZE
+                                  is negative this is a negative
+                                  number.  */
+  mp_limb_t *_mp_d;            /* Pointer to the limbs.  */
+} __mpz_struct;
+#endif
+#endif /* __GNU_MP__ */
+
+/* User-visible types.  */
+typedef __mpz_struct MP_INT;
+typedef __mpz_struct mpz_t[1];
+
+/* Structure for rational numbers.  Zero is represented as 0/any, i.e.
+   the denominator is ignored.  Negative numbers have the sign in
+   the numerator.  */
+typedef struct
+{
+  __mpz_struct _mp_num;
+  __mpz_struct _mp_den;
+#if 0
+  int _mp_num_alloc;           /* Number of limbs allocated
+                                  for the numerator.  */
+  int _mp_num_size;            /* The absolute value of this field is the
+                                  length of the numerator; the sign is the
+                                  sign of the entire rational number.  */
+  mp_ptr _mp_num;              /* Pointer to the numerator limbs.  */
+  int _mp_den_alloc;           /* Number of limbs allocated
+                                  for the denominator.  */
+  int _mp_den_size;            /* Length of the denominator.  (This field
+                                  should always be positive.) */
+  mp_ptr _mp_den;              /* Pointer to the denominator limbs.  */
+#endif
+} __mpq_struct;
+
+typedef __mpq_struct MP_RAT;
+typedef __mpq_struct mpq_t[1];
+
+typedef struct
+{
+  int _mp_prec;                        /* Max precision, in number of `mp_limb_t's.
+                                  Set by mpf_init and modified by
+                                  mpf_set_prec.  The area pointed to
+                                  by the `d' field contains `prec' + 1
+                                  limbs.  */
+  int _mp_size;                        /* abs(SIZE) is the number of limbs
+                                  the last field points to.  If SIZE
+                                  is negative this is a negative
+                                  number.  */
+  mp_exp_t _mp_exp;            /* Exponent, in the base of `mp_limb_t'.  */
+  mp_limb_t *_mp_d;            /* Pointer to the limbs.  */
+} __mpf_struct;
+
+/* typedef __mpf_struct MP_FLOAT; */
+typedef __mpf_struct mpf_t[1];
+
+/* Types for function declarations in gmp files.  */
+/* ??? Should not pollute user name space with these ??? */
+typedef __gmp_const __mpz_struct *mpz_srcptr;
+typedef __mpz_struct *mpz_ptr;
+typedef __gmp_const __mpf_struct *mpf_srcptr;
+typedef __mpf_struct *mpf_ptr;
+typedef __gmp_const __mpq_struct *mpq_srcptr;
+typedef __mpq_struct *mpq_ptr;
+
+#ifndef _PROTO
+#if defined (__STDC__) || defined (__cplusplus)
+#define _PROTO(x) x
+#else
+#define _PROTO(x) ()
+#endif
+#endif
+
+#ifndef __MPN
+#if defined (__STDC__) || defined (__cplusplus)
+#define __MPN(x) __mpn_##x
+#else
+#define __MPN(x) __mpn_/**/x
+#endif
+#endif
+
+#if defined (FILE) || defined (H_STDIO) || defined (_H_STDIO) \
+ || defined (_STDIO_H) || defined (_STDIO_H_) || defined (__STDIO_H__) \
+ || defined (_STDIO_INCLUDED)
+#define _GMP_H_HAVE_FILE 1
+#endif
+
+void mp_set_memory_functions _PROTO ((void *(*) (size_t),
+                                     void *(*) (void *, size_t, size_t),
+                                     void (*) (void *, size_t)));
+extern __gmp_const int mp_bits_per_limb;
+
+/**************** Integer (i.e. Z) routines.  ****************/
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+void *_mpz_realloc _PROTO ((mpz_ptr, mp_size_t));
+
+void mpz_abs _PROTO ((mpz_ptr, mpz_srcptr));
+void mpz_add _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+void mpz_add_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+void mpz_and _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+void mpz_array_init _PROTO ((mpz_ptr, mp_size_t, mp_size_t));
+void mpz_cdiv_q _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+unsigned long int mpz_cdiv_q_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+void mpz_cdiv_qr _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
+unsigned long int mpz_cdiv_qr_ui _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));
+void mpz_cdiv_r _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+unsigned long int mpz_cdiv_r_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+unsigned long int mpz_cdiv_ui _PROTO ((mpz_srcptr, unsigned long int));
+void mpz_clear _PROTO ((mpz_ptr));
+void mpz_clrbit _PROTO ((mpz_ptr, unsigned long int));
+int mpz_cmp _PROTO ((mpz_srcptr, mpz_srcptr));
+int mpz_cmp_si _PROTO ((mpz_srcptr, signed long int));
+int mpz_cmp_ui _PROTO ((mpz_srcptr, unsigned long int));
+void mpz_com _PROTO ((mpz_ptr, mpz_srcptr));
+void mpz_divexact _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+void mpz_fac_ui _PROTO ((mpz_ptr, unsigned long int));
+void mpz_fdiv_q _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+void mpz_fdiv_q_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+unsigned long int mpz_fdiv_q_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+void mpz_fdiv_qr _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
+unsigned long int mpz_fdiv_qr_ui _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));
+void mpz_fdiv_r _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+void mpz_fdiv_r_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+unsigned long int mpz_fdiv_r_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+unsigned long int mpz_fdiv_ui _PROTO ((mpz_srcptr, unsigned long int));
+void mpz_gcd _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+unsigned long int mpz_gcd_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+void mpz_gcdext _PROTO ((mpz_ptr, mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
+double mpz_get_d _PROTO ((mpz_srcptr));
+/* signed */ long int mpz_get_si _PROTO ((mpz_srcptr));
+char *mpz_get_str _PROTO ((char *, int, mpz_srcptr));
+unsigned long int mpz_get_ui _PROTO ((mpz_srcptr));
+mp_limb_t mpz_getlimbn _PROTO ((mpz_srcptr, mp_size_t));
+unsigned long int mpz_hamdist _PROTO ((mpz_srcptr, mpz_srcptr));
+void mpz_init _PROTO ((mpz_ptr));
+#ifdef _GMP_H_HAVE_FILE
+size_t mpz_inp_binary _PROTO ((mpz_ptr, FILE *));
+size_t mpz_inp_raw _PROTO ((mpz_ptr, FILE *));
+size_t mpz_inp_str _PROTO ((mpz_ptr, FILE *, int));
+#endif
+void mpz_init_set _PROTO ((mpz_ptr, mpz_srcptr));
+void mpz_init_set_d _PROTO ((mpz_ptr, double));
+void mpz_init_set_si _PROTO ((mpz_ptr, signed long int));
+int mpz_init_set_str _PROTO ((mpz_ptr, const char *, int));
+void mpz_init_set_ui _PROTO ((mpz_ptr, unsigned long int));
+int mpz_invert _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+void mpz_ior _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+int mpz_jacobi _PROTO ((mpz_srcptr, mpz_srcptr));
+int mpz_legendre _PROTO ((mpz_srcptr, mpz_srcptr));
+void mpz_mod _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+void mpz_mul _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+void mpz_mul_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+void mpz_mul_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+void mpz_neg _PROTO ((mpz_ptr, mpz_srcptr));
+#ifdef _GMP_H_HAVE_FILE
+size_t mpz_out_binary _PROTO ((FILE *, mpz_srcptr));
+size_t mpz_out_raw _PROTO ((FILE *, mpz_srcptr));
+size_t mpz_out_str _PROTO ((FILE *, int, mpz_srcptr));
+#endif
+int mpz_perfect_square_p _PROTO ((mpz_srcptr));
+unsigned long int mpz_popcount _PROTO ((mpz_srcptr));
+void mpz_pow_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+void mpz_powm _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr));
+void mpz_powm_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int, mpz_srcptr));
+int mpz_probab_prime_p _PROTO ((mpz_srcptr, int));
+void mpz_random _PROTO ((mpz_ptr, mp_size_t));
+void mpz_random2 _PROTO ((mpz_ptr, mp_size_t));
+unsigned long int mpz_scan0 _PROTO ((mpz_srcptr, unsigned long int));
+unsigned long int mpz_scan1 _PROTO ((mpz_srcptr, unsigned long int));
+void mpz_set _PROTO ((mpz_ptr, mpz_srcptr));
+void mpz_set_d _PROTO ((mpz_ptr, double));
+void mpz_set_f _PROTO ((mpz_ptr, mpf_srcptr));
+void mpz_set_q _PROTO ((mpz_ptr, mpq_srcptr));
+void mpz_set_si _PROTO ((mpz_ptr, signed long int));
+int mpz_set_str _PROTO ((mpz_ptr, const char *, int));
+void mpz_set_ui _PROTO ((mpz_ptr, unsigned long int));
+void mpz_setbit _PROTO ((mpz_ptr, unsigned long int));
+size_t mpz_size _PROTO ((mpz_srcptr));
+size_t mpz_sizeinbase _PROTO ((mpz_srcptr, int));
+void mpz_sqrt _PROTO ((mpz_ptr, mpz_srcptr));
+void mpz_sqrtrem _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr));
+void mpz_sub _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+void mpz_sub_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+void mpz_tdiv_q _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+void mpz_tdiv_q_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+void mpz_tdiv_q_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+void mpz_tdiv_qr _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr));
+void mpz_tdiv_qr_ui _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int));
+void mpz_tdiv_r _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr));
+void mpz_tdiv_r_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+void mpz_tdiv_r_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int));
+void mpz_ui_pow_ui _PROTO ((mpz_ptr, unsigned long int, unsigned long int));
+
+/**************** Rational (i.e. Q) routines.  ****************/
+
+void mpq_init _PROTO ((mpq_ptr));
+void mpq_clear _PROTO ((mpq_ptr));
+void mpq_set _PROTO ((mpq_ptr, mpq_srcptr));
+void mpq_set_ui _PROTO ((mpq_ptr, unsigned long int, unsigned long int));
+void mpq_set_si _PROTO ((mpq_ptr, signed long int, unsigned long int));
+void mpq_set_z _PROTO ((mpq_ptr, mpz_srcptr));
+void mpq_add _PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
+void mpq_sub _PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
+void mpq_mul _PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
+void mpq_div _PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr));
+void mpq_neg _PROTO ((mpq_ptr, mpq_srcptr));
+int mpq_cmp _PROTO ((mpq_srcptr, mpq_srcptr));
+int mpq_cmp_ui _PROTO ((mpq_srcptr, unsigned long int, unsigned long int));
+int mpq_equal _PROTO ((mpq_srcptr, mpq_srcptr));
+void mpq_inv _PROTO ((mpq_ptr, mpq_srcptr));
+void mpq_set_num _PROTO ((mpq_ptr, mpz_srcptr));
+void mpq_set_den _PROTO ((mpq_ptr, mpz_srcptr));
+void mpq_get_num _PROTO ((mpz_ptr, mpq_srcptr));
+void mpq_get_den _PROTO ((mpz_ptr, mpq_srcptr));
+double mpq_get_d _PROTO ((mpq_srcptr));
+void mpq_canonicalize _PROTO ((mpq_ptr));
+
+/**************** Float (i.e. F) routines.  ****************/
+
+void mpf_abs _PROTO ((mpf_ptr, mpf_srcptr));
+void mpf_add _PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
+void mpf_add_ui _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
+void mpf_clear _PROTO ((mpf_ptr));
+int mpf_cmp _PROTO ((mpf_srcptr, mpf_srcptr));
+int mpf_cmp_si _PROTO ((mpf_srcptr, signed long int));
+int mpf_cmp_ui _PROTO ((mpf_srcptr, unsigned long int));
+void mpf_div _PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
+void mpf_div_2exp _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
+void mpf_div_ui _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
+void mpf_dump _PROTO ((mpf_srcptr));
+int mpf_eq _PROTO ((mpf_srcptr, mpf_srcptr, unsigned long int));
+double mpf_get_d _PROTO ((mpf_srcptr));
+unsigned long int mpf_get_prec _PROTO ((mpf_srcptr));
+char *mpf_get_str _PROTO ((char *, mp_exp_t *, int, size_t, mpf_srcptr));
+void mpf_init _PROTO ((mpf_ptr));
+void mpf_init2 _PROTO ((mpf_ptr, unsigned long int));
+#ifdef _GMP_H_HAVE_FILE
+size_t mpf_inp_str _PROTO ((mpf_ptr, FILE *, int));
+#endif
+void mpf_init_set _PROTO ((mpf_ptr, mpf_srcptr));
+void mpf_init_set_d _PROTO ((mpf_ptr, double));
+void mpf_init_set_si _PROTO ((mpf_ptr, signed long int));
+int mpf_init_set_str _PROTO ((mpf_ptr, const char *, int));
+void mpf_init_set_ui _PROTO ((mpf_ptr, unsigned long int));
+void mpf_mul _PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
+void mpf_mul_2exp _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
+void mpf_mul_ui _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
+void mpf_neg _PROTO ((mpf_ptr, mpf_srcptr));
+#ifdef _GMP_H_HAVE_FILE
+size_t mpf_out_str _PROTO ((FILE *, int, size_t, mpf_srcptr));
+#endif
+void mpf_random2 _PROTO ((mpf_ptr, mp_size_t, mp_exp_t));
+void mpf_reldiff _PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
+void mpf_set _PROTO ((mpf_ptr, mpf_srcptr));
+void mpf_set_d _PROTO ((mpf_ptr, double));
+void mpf_set_default_prec _PROTO ((unsigned long int));
+void mpf_set_prec _PROTO ((mpf_ptr, unsigned long int));
+void mpf_set_prec_raw _PROTO ((mpf_ptr, unsigned long int));
+void mpf_set_q _PROTO ((mpf_ptr, mpq_srcptr));
+void mpf_set_si _PROTO ((mpf_ptr, signed long int));
+int mpf_set_str _PROTO ((mpf_ptr, const char *, int));
+void mpf_set_ui _PROTO ((mpf_ptr, unsigned long int));
+void mpf_set_z _PROTO ((mpf_ptr, mpz_srcptr));
+size_t mpf_size _PROTO ((mpf_srcptr));
+void mpf_sqrt _PROTO ((mpf_ptr, mpf_srcptr));
+void mpf_sqrt_ui _PROTO ((mpf_ptr, unsigned long int));
+void mpf_sub _PROTO ((mpf_ptr, mpf_srcptr, mpf_srcptr));
+void mpf_sub_ui _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int));
+void mpf_ui_div _PROTO ((mpf_ptr, unsigned long int, mpf_srcptr));
+void mpf_ui_sub _PROTO ((mpf_ptr, unsigned long int, mpf_srcptr));
+#if defined (__cplusplus)
+}
+#endif
+/************ Low level positive-integer (i.e. N) routines.  ************/
+
+/* This is ugly, but we need to make usr calls reach the prefixed function.  */
+#define mpn_add                        __MPN(add)
+#define mpn_add_1              __MPN(add_1)
+#define mpn_add_n              __MPN(add_n)
+#define mpn_addmul_1           __MPN(addmul_1)
+#define mpn_bdivmod            __MPN(bdivmod)
+#define mpn_cmp                        __MPN(cmp)
+#define mpn_divmod_1           __MPN(divmod_1)
+#define mpn_divrem             __MPN(divrem)
+#define mpn_divrem_1           __MPN(divrem_1)
+#define mpn_dump               __MPN(dump)
+#define mpn_gcd                        __MPN(gcd)
+#define mpn_gcd_1              __MPN(gcd_1)
+#define mpn_gcdext             __MPN(gcdext)
+#define mpn_get_str            __MPN(get_str)
+#define mpn_hamdist            __MPN(hamdist)
+#define mpn_lshift             __MPN(lshift)
+#define mpn_mod_1              __MPN(mod_1)
+#define mpn_mul                        __MPN(mul)
+#define mpn_mul_1              __MPN(mul_1)
+#define mpn_mul_n              __MPN(mul_n)
+#define mpn_perfect_square_p   __MPN(perfect_square_p)
+#define mpn_popcount           __MPN(popcount)
+#define mpn_preinv_mod_1       __MPN(preinv_mod_1)
+#define mpn_random2            __MPN(random2)
+#define mpn_rshift             __MPN(rshift)
+#define mpn_scan0              __MPN(scan0)
+#define mpn_scan1              __MPN(scan1)
+#define mpn_set_str            __MPN(set_str)
+#define mpn_sqrtrem            __MPN(sqrtrem)
+#define mpn_sub                        __MPN(sub)
+#define mpn_sub_1              __MPN(sub_1)
+#define mpn_sub_n              __MPN(sub_n)
+#define mpn_submul_1           __MPN(submul_1)
+#define mpn_udiv_w_sdiv                __MPN(udiv_w_sdiv)
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+mp_limb_t mpn_add _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr,mp_size_t));
+mp_limb_t mpn_add_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
+mp_limb_t mpn_add_n _PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
+mp_limb_t mpn_addmul_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
+mp_limb_t mpn_bdivmod _PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, unsigned long int));
+int mpn_cmp _PROTO ((mp_srcptr, mp_srcptr, mp_size_t));
+mp_limb_t mpn_divmod_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
+mp_limb_t mpn_divrem _PROTO ((mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr, mp_size_t));
+mp_limb_t mpn_divrem_1 _PROTO ((mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t));
+void mpn_dump _PROTO ((mp_srcptr, mp_size_t));
+mp_size_t mpn_gcd _PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t));
+mp_limb_t mpn_gcd_1 _PROTO ((mp_srcptr, mp_size_t, mp_limb_t));
+mp_size_t mpn_gcdext _PROTO ((mp_ptr, mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t));
+size_t mpn_get_str _PROTO ((unsigned char *, int, mp_ptr, mp_size_t));
+unsigned long int mpn_hamdist _PROTO ((mp_srcptr, mp_srcptr, mp_size_t));
+mp_limb_t mpn_lshift _PROTO ((mp_ptr, mp_srcptr, mp_size_t, unsigned int));
+mp_limb_t mpn_mod_1 _PROTO ((mp_srcptr, mp_size_t, mp_limb_t));
+mp_limb_t mpn_mul _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t));
+mp_limb_t mpn_mul_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
+void mpn_mul_n _PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
+int mpn_perfect_square_p _PROTO ((mp_srcptr, mp_size_t));
+unsigned long int mpn_popcount _PROTO ((mp_srcptr, mp_size_t));
+mp_limb_t mpn_preinv_mod_1 _PROTO ((mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t));
+void mpn_random2 _PROTO ((mp_ptr, mp_size_t));
+mp_limb_t mpn_rshift _PROTO ((mp_ptr, mp_srcptr, mp_size_t, unsigned int));
+unsigned long int mpn_scan0 _PROTO ((mp_srcptr, unsigned long int));
+unsigned long int mpn_scan1 _PROTO ((mp_srcptr, unsigned long int));
+mp_size_t mpn_set_str _PROTO ((mp_ptr, const unsigned char *, size_t, int));
+mp_size_t mpn_sqrtrem _PROTO ((mp_ptr, mp_ptr, mp_srcptr, mp_size_t));
+mp_limb_t mpn_sub _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr,mp_size_t));
+mp_limb_t mpn_sub_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
+mp_limb_t mpn_sub_n _PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
+mp_limb_t mpn_submul_1 _PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t));
+#if defined (__cplusplus)
+}
+#endif
+
+#if defined (__GNUC__) || defined (_FORCE_INLINES)
+_EXTERN_INLINE mp_limb_t
+#if defined (__STDC__) || defined (__cplusplus)
+mpn_add_1 (register mp_ptr res_ptr,
+          register mp_srcptr s1_ptr,
+          register mp_size_t s1_size,
+          register mp_limb_t s2_limb)
+#else
+mpn_add_1 (res_ptr, s1_ptr, s1_size, s2_limb)
+     register mp_ptr res_ptr;
+     register mp_srcptr s1_ptr;
+     register mp_size_t s1_size;
+     register mp_limb_t s2_limb;
+#endif
+{
+  register mp_limb_t x;
+
+  x = *s1_ptr++;
+  s2_limb = x + s2_limb;
+  *res_ptr++ = s2_limb;
+  if (s2_limb < x)
+    {
+      while (--s1_size != 0)
+       {
+         x = *s1_ptr++ + 1;
+         *res_ptr++ = x;
+         if (x != 0)
+           goto fin;
+       }
+
+      return 1;
+    }
+
+ fin:
+  if (res_ptr != s1_ptr)
+    {
+      mp_size_t i;
+      for (i = 0; i < s1_size - 1; i++)
+       res_ptr[i] = s1_ptr[i];
+    }
+  return 0;
+}
+
+_EXTERN_INLINE mp_limb_t
+#if defined (__STDC__) || defined (__cplusplus)
+mpn_add (register mp_ptr res_ptr,
+        register mp_srcptr s1_ptr,
+        register mp_size_t s1_size,
+        register mp_srcptr s2_ptr,
+        register mp_size_t s2_size)
+#else
+mpn_add (res_ptr, s1_ptr, s1_size, s2_ptr, s2_size)
+     register mp_ptr res_ptr;
+     register mp_srcptr s1_ptr;
+     register mp_size_t s1_size;
+     register mp_srcptr s2_ptr;
+     register mp_size_t s2_size;
+#endif
+{
+  mp_limb_t cy_limb = 0;
+
+  if (s2_size != 0)
+    cy_limb = mpn_add_n (res_ptr, s1_ptr, s2_ptr, s2_size);
+
+  if (s1_size - s2_size != 0)
+    cy_limb = mpn_add_1 (res_ptr + s2_size,
+                        s1_ptr + s2_size,
+                        s1_size - s2_size,
+                        cy_limb);
+  return cy_limb;
+}
+
+_EXTERN_INLINE mp_limb_t
+#if defined (__STDC__) || defined (__cplusplus)
+mpn_sub_1 (register mp_ptr res_ptr,
+          register mp_srcptr s1_ptr,
+          register mp_size_t s1_size,
+          register mp_limb_t s2_limb)
+#else
+mpn_sub_1 (res_ptr, s1_ptr, s1_size, s2_limb)
+     register mp_ptr res_ptr;
+     register mp_srcptr s1_ptr;
+     register mp_size_t s1_size;
+     register mp_limb_t s2_limb;
+#endif
+{
+  register mp_limb_t x;
+
+  x = *s1_ptr++;
+  s2_limb = x - s2_limb;
+  *res_ptr++ = s2_limb;
+  if (s2_limb > x)
+    {
+      while (--s1_size != 0)
+       {
+         x = *s1_ptr++;
+         *res_ptr++ = x - 1;
+         if (x != 0)
+           goto fin;
+       }
+
+      return 1;
+    }
+
+ fin:
+  if (res_ptr != s1_ptr)
+    {
+      mp_size_t i;
+      for (i = 0; i < s1_size - 1; i++)
+       res_ptr[i] = s1_ptr[i];
+    }
+  return 0;
+}
+
+_EXTERN_INLINE mp_limb_t
+#if defined (__STDC__) || defined (__cplusplus)
+mpn_sub (register mp_ptr res_ptr,
+        register mp_srcptr s1_ptr,
+        register mp_size_t s1_size,
+        register mp_srcptr s2_ptr,
+        register mp_size_t s2_size)
+#else
+mpn_sub (res_ptr, s1_ptr, s1_size, s2_ptr, s2_size)
+     register mp_ptr res_ptr;
+     register mp_srcptr s1_ptr;
+     register mp_size_t s1_size;
+     register mp_srcptr s2_ptr;
+     register mp_size_t s2_size;
+#endif
+{
+  mp_limb_t cy_limb = 0;
+
+  if (s2_size != 0)
+    cy_limb = mpn_sub_n (res_ptr, s1_ptr, s2_ptr, s2_size);
+
+  if (s1_size - s2_size != 0)
+    cy_limb = mpn_sub_1 (res_ptr + s2_size,
+                        s1_ptr + s2_size,
+                        s1_size - s2_size,
+                        cy_limb);
+  return cy_limb;
+}
+#endif /* __GNUC__ */
+
+/* Allow faster testing for negative, zero, and positive.  */
+#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)
+#define mpf_sgn(F) ((F)->_mp_size < 0 ? -1 : (F)->_mp_size > 0)
+#define mpq_sgn(Q) ((Q)->_mp_num._mp_size < 0 ? -1 : (Q)->_mp_num._mp_size > 0)
+
+/* Allow direct user access to numerator and denominator of a mpq_t object.  */
+#define mpq_numref(Q) (&((Q)->_mp_num))
+#define mpq_denref(Q) (&((Q)->_mp_den))
+
+/* When using GCC, optimize certain common comparisons.  */
+#if defined (__GNUC__)
+#define mpz_cmp_ui(Z,UI) \
+  (__builtin_constant_p (UI) && (UI) == 0                              \
+   ? mpz_sgn (Z) : mpz_cmp_ui (Z,UI))
+#define mpz_cmp_si(Z,UI) \
+  (__builtin_constant_p (UI) && (UI) == 0 ? mpz_sgn (Z)                        \
+   : __builtin_constant_p (UI) && (UI) > 0 ? mpz_cmp_ui (Z,UI)         \
+   : mpz_cmp_si (Z,UI))
+#define mpq_cmp_ui(Q,NUI,DUI) \
+  (__builtin_constant_p (NUI) && (NUI) == 0                            \
+   ? mpq_sgn (Q) : mpq_cmp_ui (Q,NUI,DUI))
+#endif
+
+#define mpn_divmod(qp,np,nsize,dp,dsize) mpn_divrem (qp,0,np,nsize,dp,dsize)
+#if 0
+#define mpn_divmod_1(qp,np,nsize,dlimb) mpn_divrem_1 (qp,0,np,nsize,dlimb)
+#endif
+
+/* Compatibility with GMP 1.  */
+#define mpz_mdiv       mpz_fdiv_q
+#define mpz_mdivmod    mpz_fdiv_qr
+#define mpz_mmod       mpz_fdiv_r
+#define mpz_mdiv_ui    mpz_fdiv_q_ui
+#define mpz_mdivmod_ui(q,r,n,d) \
+  ((r == 0) ? mpz_fdiv_q_ui (q,n,d) : mpz_fdiv_qr_ui (q,r,n,d))
+#define mpz_mmod_ui(r,n,d) \
+  ((r == 0) ? mpz_fdiv_ui (n,d) : mpz_fdiv_r_ui (r,n,d))
+
+/* Useful synonyms, but not quite compatible with GMP 1.  */
+#define mpz_div                mpz_fdiv_q
+#define mpz_divmod     mpz_fdiv_qr
+#define mpz_div_ui     mpz_fdiv_q_ui
+#define mpz_divmod_ui  mpz_fdiv_qr_ui
+#define mpz_mod_ui     mpz_fdiv_r_ui
+#define mpz_div_2exp   mpz_fdiv_q_2exp
+#define mpz_mod_2exp   mpz_fdiv_r_2exp
+
+#define __GNU_MP_VERSION 2
+#define __GNU_MP_VERSION_MINOR 0
+#define __GMP_H__
+#endif /* __GMP_H__ */
diff --git a/ghc/rts/gmp/insert-double.c b/ghc/rts/gmp/insert-double.c
new file mode 100644 (file)
index 0000000..1ce2571
--- /dev/null
@@ -0,0 +1,70 @@
+/* __gmp_insert_double -- convert from array of mp_limb_t to double.
+
+Copyright (C) 1996 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU Library General Public License as published by
+the Free Software Foundation; either version 2 of the License, or (at your
+option) any later version.
+
+The GNU MP Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+License for more details.
+
+You should have received a copy of the GNU Library General Public License
+along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
+the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+MA 02111-1307, USA. */
+
+#include "gmp.h"
+#include "gmp-impl.h"
+
+#ifdef XDEBUG
+#undef _GMP_IEEE_FLOATS
+#endif
+
+#ifndef _GMP_IEEE_FLOATS
+#define _GMP_IEEE_FLOATS 0
+#endif
+
+double
+#if __STDC__
+__gmp_scale2 (double d, int exp)
+#else
+__gmp_scale2 (d, exp)
+     double d;
+     int exp;
+#endif
+{
+#if _GMP_IEEE_FLOATS
+  {
+    union ieee_double_extract x;
+    x.d = d;
+    x.s.exp += exp;
+    return x.d;
+  }
+#else
+  {
+    double factor, r;
+
+    factor = 2.0;
+    if (exp < 0)
+      {
+       factor = 0.5;
+       exp = -exp;
+      }
+    r = d;
+    while (exp != 0)
+      {
+       if ((exp & 1) != 0)
+         r *= factor;
+       factor *= factor;
+       exp >>= 1;
+      }
+    return r;
+  }
+#endif
+}