diff --git a/src/gmp/COPYING b/src/gmp/COPYING index a6d7d0188..5b6e7c66c 100644 --- a/src/gmp/COPYING +++ b/src/gmp/COPYING @@ -2,7 +2,7 @@ Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -313,7 +313,7 @@ Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: - Gnomovision version 69, Copyright (C) year name of author + Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. @@ -325,12 +325,16 @@ mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Hereny it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, +necessary. Here is a sample; alter the names: - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Section \ No newline at end of file + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/src/gmp/COPYING.LIB b/src/gmp/COPYING.LIB index c4792dd27..b1e3f5a26 100644 --- a/src/gmp/COPYING.LIB +++ b/src/gmp/COPYING.LIB @@ -1,6 +1,5 @@ - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -11,7 +10,7 @@ as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] - Preamble + Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public @@ -23,8 +22,7 @@ specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations -below. +strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that @@ -57,7 +55,7 @@ modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. -^L + Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a @@ -89,8 +87,7 @@ libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it -becomes +encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this @@ -114,8 +111,8 @@ modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. -^L - GNU LESSER GENERAL PUBLIC LICENSE + + GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other @@ -139,8 +136,7 @@ included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control -compilation +interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not @@ -150,7 +146,7 @@ such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. - + 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an @@ -220,7 +216,7 @@ instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. -^L + Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. @@ -271,7 +267,7 @@ Library will still fall under Section 6.) distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. -^L + 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work @@ -333,7 +329,7 @@ restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. -^L + 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined @@ -374,7 +370,7 @@ subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. -^L + 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or @@ -388,10 +384,9 @@ all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply, and the section as a whole is intended to apply in other -circumstances. +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any @@ -409,11 +404,11 @@ be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License -may add an explicit geographical distribution limitation excluding those -countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. @@ -427,7 +422,7 @@ conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. -^L + 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is @@ -437,7 +432,7 @@ decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - NO WARRANTY + NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. @@ -460,31 +455,28 @@ FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - END OF TERMS AND CONDITIONS -^L + END OF TERMS AND CONDITIONS + How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms -of the ordinary General Public License). +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). - To apply these terms, attach the following notices to the library. -It is safest to attach them to the start of each source file to most -effectively convey the exclusion of warranty; and each file should -have at least the "copyright" line and a pointer to where the full -notice is found. + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. - - + Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -493,19 +485,16 @@ does.> You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -Also add information on how to contact you by electronic and paper -mail. +Also add information on how to contact you by electronic and paper mail. -You should also get your employer (if you work as a programmer) or -your +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James -Random Hacker. + library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice diff --git a/src/gmp/ChangeLog b/src/gmp/ChangeLog index b919456d9..49f0f57c2 100644 --- a/src/gmp/ChangeLog +++ b/src/gmp/ChangeLog @@ -1,5 +1,5 @@ -Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999 2000, 2001, 2002 -Free Software Foundation, Inc. +Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999 2000, 2001, +2002, 2003, 2004 Free Software Foundation, Inc. . This file is part of the GNU MP Library. . @@ -19,6 +19,680 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +2004-09-22 Torbjorn Granlund + + * Version 4.1.4 released. + + * config.sub: Recognize viac3*. + +2004-09-21 Torbjorn Granlund + + * gmp.texi: Update cpu list. + + * configure.in: Merge x86_64 changes from HEAD. + * acinclude.m4 (X86_PATTERN): Add viac3. + +2004-09-20 Torbjorn Granlund + + * config.guess: Recognize AMD's hammer processors, return x86_64. + + * tests/mpz/t-mul.c (ref_mpn_mul): Fudge tmp allocation for toom3. + +2004-09-19 Torbjorn Granlund + + * tests/misc.c (tests_rand_start): Shift tv_usec for better seeding. + +2004-09-18 Torbjorn Granlund + + * tests/misc.c (tests_rand_start): Invoke fflush after printing seed. + + * tests/mpz/t-mul.c (main): Check environment for GMP_CHECK_FFT, run + extra FFT tests if set. + (ref_mpn_mul): Use library code for kara and toom, but skewded so that + we never use the same algorithm that we're testing. + (mul_kara): Delete. + (debug_mp): Print just one line of large numbers. + (ref_mpn_mul): Rework usage of tp temporary space. + +2004-09-17 Torbjorn Granlund + + * mpn/generic/mul_fft.c: Additional changes from Paul. + +2004-09-16 Torbjorn Granlund + + * gmp-h.in (__GNU_MP_VERSION_PATCHLEVEL): Bump to 4.1.4. + +2004-04-16 Paul Zimmermann + + * mpn/generic/mul_fft.c (mpn_mul_fft): Fix a bug in the choice of the + recursive fft parameters. + +2004-09-15 Torbjorn Granlund + + * configure.in: Add support for powerpc64 under GNU/Linux. + + * mpn/powerpc64/linux64.m4: New file. + + * mpn/powerpc64/mul_1.asm: Change cal => addi. + * mpn/powerpc64/addmul_1.asm: Likewise. + * mpn/powerpc64/submul_1.asm: Likewise. + * mpn/powerpc64/sqr_diagonal.asm: Likewise. + +2004-05-14 Kevin Ryde + + * mpf/sub.c: When one operand cancels high limbs of the other, strip + high zeros on the balance before truncating to destination precision. + Truncating first loses accuracy and can lead to a result 0 despite + operands being not equal. Reported by John Abbott. + Also, ensure exponent is zero when result is zero, for instance if + operands are exactly equal. + +2004-04-26 Kevin Ryde + + * Version 4.1.3 released. + +2004-04-26 Torbjorn Granlund + + * mpn/ia64/*.asm: Add Itanium2 cycle counts. + +2004-04-25 Kevin Ryde + + * mpfr/tests/tsqrt_ui.c: Disable this test, it fails on debian s390, + apparently due to sqrt() dodginess. Reported by Laurent Fousse. + +2004-04-24 Kevin Ryde + + * mpz/aorsmul.c, mpz/aorsmul_i.c, mpz/cfdiv_q_2exp.c, + mpz/cfdiv_r_2exp.c, mpq/aors.c, mpf/ceilfloor.c: Give REGPARM_ATTR() + on function definition too, as demanded by gcc 3.4. + +2004-04-22 Kevin Ryde + + * tests/rand/t-lc2exp.c (check_bigc1): New test. + + * fdl.texi: Tweak @appendixsubsec -> @appendixsec to match our + preference for this in an @appendix, and because texi2pdf doesn't + support @appendixsubsec directly within an @appendix. + + * mpfr/set_str.c: Patch from mpfr web page, supporting upper case + letters, as per mpf_set_str. + + * mpfr/out_str.c: Patch from mpfr web page, supporting NULL for FILE + stream argument. + + * mpfr/agm.c: Patch from mpfr web page, fixing division by zero if + mpfr_agm arguments are too close. + + * mpfr/exp_2.c: Patch from mpfr web page, fixing wrong result from + mpfr_exp for large argument. + + * mpfr/urandomb.c: Patch from mpfr web page, fixing seg fault if + random number is zero. + +2004-04-20 Kevin Ryde + + * macos/configure (what_objects): Only demand 9 object files, as for + instance occurs in the scanf directory. + (asm files): Transform labels L(foo) -> Lfoo. Take func name from + PROLOGUE to support empty "EPILOGUE()". Recognise and subsitute + register name "define()"s. + * macos/Makefile.in (CmnObjs): Add tal-notreent.o. + + * texinfo.tex: Update to 2004-04-07.08 from texinfo 4.7. + * gmp.texi (@copying): Don't put a line break in @ref within + @copying, recent texinfo.tex doesn't like that. + * mpfr/mpfr.texi (Assigning Floats): Balance parens in mpfr_set_si, + demanded by recent texinfo.tex. + +2004-04-16 Kevin Ryde + + * macos/configure, macos/Makefile.in: Add printf and scanf directories. + + * COPYING: Restore from FSF, end had somehow been truncated. + * COPYING.LIB: Update to version 2.1 from FSF. + * fdl.texi: Update to version 1.2 from FSF. + + * tests/mpz/t-gcd.c (check_data): New function, exercising K6 + gcd_finda bug. + + * randlc2x.c (gmp_randinit_lc_2exp): Mask _mp_c down to m2exp bits, as + assumed by randraw.c. + + * randraw.c (lc): In seedn==0 case, discard low m2exp/2 bits same as + general case. Fixes _gmp_rand returning more bits than requested. + +2004-04-16 Paul Zimmermann + + * mpn/generic/mul_fft.c (mpn_fft_add_modF): Reduce correctly to + ap[n]<=1 when c==3, as required by subsequent operations. + +2004-04-14 Kevin Ryde + + * mpfr/mpfr.texi: Use @ifnottex around @top, for the benefit of + makeinfo 4.6 --html. + + * randraw.c (lc): Zero out limbs to be produced, since seedn==0 and + small "a" cases may not do this. + + * gmp.texi (Reentrancy, Random State Initialization): Note + gmp_randinit use of gmp_errno is not thread safe. Reported by Vincent + Lefèvre. + + * gmp.texi (Random State Initialization): Add index entries for + gmp_errno and constants. + + * randraw.c (lc): Allow for small "a" possibly making tn less than + m2exp in limbs. + + * randsd.c: Allow negative seed value. + + * configure.in (--enable-mpbsd): Typo Berkley -> Berkeley in help msg. + +2004-04-12 Kevin Ryde + + * gmp.texi (ABI and ISA): Move @sp 1, for the benefit of makeinfo + --docbook in texinfo 4.6. + + * gmp.texi (References): Add URL for "GMP Square Root" paper. + + * demos/perl/GMP.xs (static_functable): New macro, use it for all + function tables, to support mingw DLL builds. + + * demos/perl/GMP.pm, Makefile.PL (VERSION): Set to '2.00'. + * demos/perl/GMP.pm (COPYRIGHT): New in the doc section. + + * demos/perl/sample.pl: Print the module and library versions in use. + +2004-04-09 Kevin Ryde + + * mpfrxx.h: Fix typo in assignments of mpfr_class from mpf_class. + Reported by Derrick Bass. + + * tests/cxx/t-locale.cc: Use instead of , the + latter not available in g++ 3.3, and use namespace std to support this. + + * longlong.h [powerpc]: Test CPU_FAMILY==PPC for VxWorks, not just for + PPC defined. Amend use of PPC for gcc 2.7.x similarly. Reported by + Mark Haigh. + + * configfsf.guess, configfsf.sub: Update to 2004-03-12. + + * configure.in (sparc64-*-*): Use -xarch=v8plus in cc flags, needed + for the mpn/sparc32/v9 assembler code. Reported by Nicholas Oxhøj. + + * tests/mpz/t-import.c, tests/mpz/t-export.c: Add for + memcmp and memset. + + * gmp.texi (Integer Logic and Bit Fiddling): Say ULONG_MAX as per + limits.h, instead of MAX_ULONG. + + * gmp-h.in (__GNU_MP_VERSION_PATCHLEVEL): Bump to 4.1.3. + + * Makefile.am (LIBGMP_LT_REVISION, LIBGMPXX_LT_REVISION, + LIBMP_LT_REVISION): Increment for new release. + + * mpfr/rnd_mode.c (mpfr_set_machine_rnd_mode): exit(0) if desired mode + not available, for the benefit of ARM systems without FE_TOWARDZERO. + + * gmp-impl.h (union ieee_double_extract): Add __s390__ for big endian. + +2004-04-07 Kevin Ryde + + * mpn/x86/k6/gcd_finda.asm: Correction jbe -> jb in initial setups. + Zero flag is wrong here, it relects only the high limb of the compare, + leading to n1>=n2 not satisfied and wrong results. cp[1]==0x7FFFFFFF + with cp[0]>=0x80000001 provokes this. + + * gmp.texi (BSD Compatible Functions): Note "pow" name clash under + the pow function description too. + (Language Bindings): Add XEmacs (betas at this stage). Reported by + Jerry James. + + * tests/refmpn.c (refmpn_mod2): Correction to ASSERTs, r==a is allowed. + +2004-03-31 Kevin Ryde + + * gmp.texi (Language Bindings): Add GOO, MLGMP and Numerix. + +2004-03-04 Kevin Ryde + + * gmp.texi (Reentrancy): Note C++ mpf_class constructors using + global default precision. + (C++ Interface Floats): Describe operator= copying the value, not the + precision, and what this can mean about copy constructor versus + default constructor plus assignment. + +2004-02-29 Kevin Ryde + + * gmp.texi (C++ Interface Integers): Note / and % rounding follows + C99 / and %. + +2004-02-22 Kevin Ryde + + * gmp-impl.h (USE_LEADING_REGPARM): Disable under prof or gprof, for + the benefit of freebsd where .mcount clobbers registers. Spotted by + Torbjorn. + * configure.in (WANT_PROFILING_PROF, WANT_PROFILING_GPROF): New + AC_DEFINEs. + +2004-01-24 Kevin Ryde + + * gmp.texi (Miscellaneous Float Functions): For mpf_random2, note + exponent is in limbs. + +2004-01-17 Kevin Ryde + + * gmp-h.in (_GMP_H_HAVE_FILE): Add _MSL_STDIO_H for Metrowerks. + Reported by Tomas Zahradnicky. + +2004-01-07 Kevin Ryde + + * mp-h.in: Use "! defined (__GMP_WITHIN_CONFIGURE)" in the same style + as gmp-h.in (though mp-h.in is not actually used during configure). + + * gmp-h.in, mp-h.in (__GMP_SHORT_LIMB): Renamed from _SHORT_LIMB, to + keep in our namespace. (Not actually used anywhere currently.) + Reported by Patrick Pelissier. + + * mp-h.in (__GMP_DECLSPEC_EXPORT, __GMP_DECLSPEC_IMPORT) [__GNUC__]: + Use __dllexport__ and __dllimport__ to keep out of application + namespace. Same previously done in gmp-h.in. + +2004-01-03 Kevin Ryde + + * gmp.texi (Single Limb Division): Correction to tex expression + for (1/2)x1. + +2003-12-31 Kevin Ryde + + * demos/perl/GMP.xs (scan0, scan1): Return ~0 for not-found. + * demos/perl/GMP.pm: Describe this, remove the note about ULONG_MAX + being the same as ~0 (which is not true in old perl). + * demos/perl/test.pl: Update tests. + * demos/perl/typemap (gmp_UV): New type. + + * demos/perl/test.pl (fits_slong_p): Comment out uv_max test, it won't + necessarily exceed a long. + + * demos/perl/GMP.pm: Add a remark about get_str to the bugs section. + +2003-12-23 Kevin Ryde + + * demos/perl/typemap (MPZ_ASSUME, MPQ_ASSUME, MPF_ASSUME): Remove + output rules, these are only meant for inputs. + (MPZ_MUTATE): Remove, not used since changes for magic. + + * demos/perl/GMP.xs (mpz_class_hv, mpq_class_hv, mpf_class_hv): New + variables, initialized in BOOT. + * demos/perl/GMP.xs, demos/perl/typemap: Use them and explicit + sv_bless, to save a gv_stashpv for every new object. + +2003-12-21 Kevin Ryde + + * gmp.texi (Integer Logic and Bit Fiddling): Say "bitwise" in + mpz_and, mpz_ior and mpz_xor, to avoid any confusion with what C means + by "logical". Reported by Rüdiger Schütz. + +2003-12-13 Kevin Ryde + + * gmp.texi (Miscellaneous Integer Functions): Note mpz_sizeinbase + can be used to locate the most significant bit. Reword a bit for + clarity. + + * tests/devel/try.c (mpn_divexact_by3_fun, mpn_modexact_1_odd_fun): + Correction to return values. + + * tests/t-constants.c (main), tests/mpz/t-jac.c (try_si_zi): + Correction to printfs. + +2003-12-10 Kevin Ryde + + * demos/perl/test.pl: Should be $] for perl version in old perl. + + * demos/perl/Makefile.PL: Don't install sample.pl and test2.pl. + + * demos/perl/GMP.xs (use_sv): Prefer PV over IV or NV to avoid any + rounding. + * demos/perl/test.pl: Exercise this. + + * demos/perl/GMP/Mpf.pm (overload_string): Corrections to $# usage. + * demos/perl/test.pl: Exercise this. + +2003-12-08 Kevin Ryde + + * demos/perl/GMP.pm: Correction to canonicalize example. + + * demos/perl/GMP.xs: New type check scheme, support magic scalars, + support UV when available. Remove some unused local variables. + (coerce_long): Check range of double. + (get_d_2exp): Remove stray printf. + + * demos/perl/test.pl: Exercise magic, rearrange to make it clearer + what's being tested. + +2003-12-07 Kevin Ryde + + * tests/misc/t-scanf.c (test_sscanf_eof_ok): New function. + (check_misc): Use it to suppress tests broken by libc. + And should be EOF rather than -1 in various places. + +2003-12-03 Kevin Ryde + + * mpn/x86/p6/aors_n.asm: New file, grabbing the K7 code. + Superiority of this reported by Patrick Pelissier. + + * mpz/export.c: Allow NULL for countp. + * gmp.texi (Integer Import and Export): Describe this. + Suggested by Jack Lloyd. + +2003-11-30 Kevin Ryde + + * gmp.texi (Debugging): Remove debauch, seems to have disappeared. + (Language Bindings): Corrections to URLs for CLN, Omni F77, Pike. + +2003-11-29 Kevin Ryde + + * gmp.texi (Build Options): Update texinfo manual html cross reference. + + * demos/perl/GMP/Mpf.pm (overload_string): Use $OFMT to avoid warnings + about $#. + + * demos/perl/GMP.xs (fits_slong_p): Use LONG_MAX+1 to avoid possible + rounding of 0x7F..FF in a double on 64-bit systems. + +2003-11-25 Kevin Ryde + + * gmp.texi (Language Bindings): Add Axiom. + +2003-11-15 Kevin Ryde + + * gmp.texi (Assigning Integers): Remove notes on possible change + to disallow whitespace, this would be an incompatible change and + really can't be made. + +2003-10-25 Kevin Ryde + + * gmp-h.in (mpn_divmod_1): Use __GMP_CAST, to avoid warnings in + applications using g++ -Wold-style-cast. + + * mpn/m68k/t-m68k-defs.pl: Don't use -> with hashes, to avoid + deprecation warnings from perl 5.8. + + * Makefile.am (CXX_OBJECTS): Remove $U, C++ files are not subject to + ansi2knr rules. + + * mpn/z8000/README: New file. + +2003-10-22 Kevin Ryde + + * gmp.texi (Notes for Particular Systems): Note m68k gcc -mshort + and PalmOS calling conventions not supported. Reported by Patrick + Pelissier. + +2003-10-18 Kevin Ryde + + * gmp.texi (C++ Formatted Input, C++ Formatted Output): Cross + reference class interface on overloading. + + * mpn/m68k/README: Add various ideas from doc/tasks.html. + + * mpn/m88k/README: New file. + +2003-10-12 Torbjorn Granlund + + * mpn/m68k/aors_n.asm (INPUT PARAMETERS): Fix typo. + * mpn/m68k/lshift.asm: Likewise. + * mpn/m68k/rshift.asm: Likewise. + + * mpn/m68k/README: Correct an URL; add some STATUS comments. + +2003-10-11 Kevin Ryde + + * mpn/x86/pentium4/sse2/diveby3.asm: Remove non-PIC RODATA memory + access for 0xAAAAAAAB constant. + +2003-10-09 Kevin Ryde + + * tests/devel/try.c (_SC_PAGESIZE): Define from _SC_PAGE_SIZE on + systems which use that, eg. hpux 9. + +2003-10-04 Kevin Ryde + + * tune/freq.c (freq_bsd_dmesg): Demand matching of MHz etc at end of + sscanf format string. In particular need this for freq_bsd_dmesg on + i486-pc-freebsd4.7 to avoid the 486 cpu being used for the frequency. + +2003-08-19 Kevin Ryde + + * longlong.h (add_ssaaaa, sub_ddmmss) [hppa 64]: Exclude for + _LONG_LONG_LIMB (ie. ABI=2.0n) since these forms are only for + ABI=2.0w. + + * demos/perl/GMP.xs, demos/perl/GMP.pm, demos/perl/test.pl: Add + get_d_2exp. + + * longlong.h (count_leading_zeros) [__mcpu32__]: Check __mcpu32__ to + avoid bfffo on GCC 3.4 in CPU32 mode. Reported by Bernardo Innocenti. + + * longlong.h (count_trailing_zeros) [x86_64]: Use "%q0" to force + 64-bit register destination. Pointed out by Torbjorn. + +2003-08-14 Kevin Ryde + + * gmp.texi (Reentrancy): Remove SCO ctype.h note, don't want to list + every system misfeature, and was quite possibly for non-threading mode + anyway. + (Karatsuba Multiplication): Correction to threshold increase/decrease + for a and b terms. Reported by Richard Brent and Paul Zimmermann. + +2002-08-05 Kevin Ryde + + From the development mainline: + * demos/perl/GMP.pm, demos/perl/GMP.xs, demos/perl/GMP/Mpz.pm, + demos/perl/test.pl: Add mpz_import and mpz_export. + +2003-07-31 Kevin Ryde + + * demos/perl/GMP.xs (class_or_croak): Rename "class" parameter to + avoid C++ keyword. + (coerce_ulong, coerce_long): Move croaks to stop g++ 3.3 complaining + about uninitialized variables. + + * config.guess: Remove $dummy.o files everywhere, in case vendor + compilers produce that even when not asked. + +2003-07-05 Kevin Ryde + + * configure.in (i786-*-*): Recognise as pentium4, per configfsf.sub. + +2003-06-28 Kevin Ryde + + * mpz/get_d_2exp.c, mpf/get_d_2exp.c: Avoid res==1.0 when floats round + upwards. + +2003-06-22 Kevin Ryde + + * gmpxx.h (mpz_class __gmp_binary_divides, __gmp_binary_modulus): Fix + long/mpz and long%mpz for dividend==LONG_MIN divisor==-LONG_MIN. + (mpz_class __gmp_binary_modulus): Fix mpz%long for negative dividend. + + * gmp-impl.h: Add __GMP_DECLSPEC to __gmp_fib_table + (for the benefit of tests/mpz/t-fib_ui.c). + +2003-06-15 Kevin Ryde + + * mpn/x86/k6/mode1o.asm: Remove a bogus ASSERT. + +2003-06-08 Kevin Ryde + + * mpn/x86/x86-defs.m4 (cmovCC, psadbw): Remove simulated versions. + (cmov_available_p, psadbw_available_p): Remove. + This trickery was only ever for development purposes on machines + without those instructions. Removing it simplifies gmp and in + particular avoids complications for fat binary builds. Development + can be done with a wrapper around "as" if really needed. + +2003-06-05 Torbjorn Granlund + + * mpn/pa64: Change ".level 2.0W" to ".level 2.0w" to please + picky GNU assembler. + +2003-05-19 Torbjorn Granlund + + * config.guess: Recognize viac3* processors. + * configure.in: Set up path for viac3* processors. + * acinclude.m4 (X86_PATTERN): Include viac3* processors. + +2003-05-18 Linus Nordberg + + * gmp.texi: Three changes merged from HEAD for publication on web site: + (Notes for Particular Systems): Correct libtool library directory on + Windows. Reported by Andreas Fabri. + (Build Options): Update Cygwin URL. + (References): Add Bertot, Magaud and Zimmermann on GMP Square Root. + +2003-04-24 Kevin Ryde + + * longlong.h (add_ssaaaa) [all]: Remove first "%" commutative in each, + since gcc only supports one per asm. + + * gmp.texi (Debugging): New valgrind is getting MMX/SSE. + (Low-level Functions): Note with mpn_hamdist what hamming distance is. + +2003-04-18 Kevin Ryde + + * configure.in (m68060-*-*): Fallback to gcc -m68000 when -m68060 not + available, and don't use mpn/m68k/mc68020 asm routines. (Avoids 32x32 + mul and 64/32 div which trap to the kernel on 68060. Advice by + Richard Zidlicky) + * mpn/m68k/README: Update notes on directory usage. + + * gmp.texi (Language Bindings): Add Guile. + +2003-04-12 Kevin Ryde + + * gmp-impl.h (mpn_copyi, mpn_copyd): Add __GMP_DECLSPEC. + +2003-04-06 Kevin Ryde + + * mpz/gcd_ui.c: Correction to return value on longlong limb systems, + limb might not fit a ulong. + * tests/mpz/t-gcd_ui.c: New file. + * tests/mpz/Makefile.am: Add it. + +2003-03-07 Kevin Ryde + + * Makefile.am: Put gmp.h and mp.h under $(exec_prefix)/include. + * gmp.texi (Build Options): Add notes on this. + Reported by Vincent Lefèvre. + +2003-02-20 Kevin Ryde + + * demos/factorize.c (factor_using_pollard_rho): Test k>0 to avoid + infinite loop if k=0 and gcd!=1 reveals a factor. Reported by John + Pongsajapan. + +2003-02-01 Kevin Ryde + + * gmp.texi (Low-level Functions): No overlap permitted by mpn_mul_n. + Reported by Jason Moxham. + (Formatted Input Strings): Correction to strtoul cross reference + formatting. + +2003-01-25 Kevin Ryde + + * config.guess (powerpc*-*-*): Remove $dummy.core file when mfpvr + fails on NetBSD. + (trap): Remove $dummy.core on abnormal termination too. + +2003-01-15 Kevin Ryde + + * gmp.texi (Notes for Particular Systems): Add hardware floating point + precision mode. + +2003-01-05 Kevin Ryde + + * configure.in (pentium4-*-*): Use "-march=pentium4 -mno-sse2" since + sse2 causes buggy code from gcc 3.2.1 and is only supported on new + enough kernels. + + * gmp-h.in (__GMP_CAST): New macro, clean to g++ -Wold-style-cast. + (GMP_NUMB_MASK, mpz_cmp_si, mpq_cmp_si, mpz_odd_p, mpn_divexact_by3, + mpn_divmod): Use it. Reported by Krzysztof Kozminski. + (mpz_odd_p): No need for the outermost cast to "int". + * tests/cxx/t-cast.cc: New file. + * tests/cxx/Makefile.am: Add it. + + * gmp-h.in (mpz_mdivmod_ui, mpz_mmod_ui): Add parens around "r". + +2003-01-03 Kevin Ryde + + * gmp.texi (Introduction to GMP): Mention release announcements + mailing list, and put home page and ftp before mailing lists. + +2002-12-24 Kevin Ryde + + * gmp.texi (Integer Import and Export): Clarify treatment of signs, + reported by Kent Boortz. + +2002-12-13 Pedro Gimeno + + * tests/rand/t-lc2exp.c (check_bigs): Test negative seeds. + +2002-12-07 Pedro Gimeno + + * tests/rand/t-lc2exp.c (check_bigm, check_bigs): New tests. + +2002-12-05 Torbjorn Granlund + + * mpn/pa64/sqr_diagonal.asm: Remove .entry, .proc, .procend. + * mpn/pa64/udiv_qrnnd.asm: Likewise. + +2002-12-05 Kevin Ryde + + * mpn/pa64/sub_n.asm: Remove space in "sub, db" which gas objects to. + * mpn/pa64/*.asm, tune/hppa2.asm: Use ".level 2.0" for 2.0n, since gas + doesn't like ".level 2.0N". + +2002-11-30 Torbjorn Granlund + + * mpn/ia64/popcount.asm: Properly restore register ar.lc. + + * gmp-impl.h: #undef MIN and MAX before #defining. + +2002-11-04 Kevin Ryde + + * demos/expr/expr-impl.h (stdarg.h): Test __DECC same as gmp.h. + +2002-09-18 Kevin Ryde + + * gmp.texi (Integer Comparisons): Remove mention of non-existant + mpz_cmpabs_si, reported by Conrad Curry. + +2002-09-07 Kevin Ryde + + * gmp-h.in, mp-h.in: Use #ifdef for tests, for the benefit of + applications using gcc -Wundef. + +2002-08-22 Kevin Ryde + + * config.guess (powerpc*-*-*): Use a { } construct to suppress SIGILL + message on AIX. + +2002-06-18 Kevin Ryde + + * tests/rand/t-lc2exp.c: New file. + * tests/rand/Makefile.am: Add it, and use tests/libtests.la. + +2002-06-15 Kevin Ryde + + * config.guess (CC_FOR_BUILD): Try c99, same as configfsf.guess. + +2002-06-14 Kevin Ryde + + * randlc2x.c: Allow for a<0 + * randraw.c (lc): Allow for a==0. + 2002-12-24 Kevin Ryde * Version 4.1.2 released. diff --git a/src/gmp/Makefile.am b/src/gmp/Makefile.am index 9a257bc27..a20514cfa 100644 --- a/src/gmp/Makefile.am +++ b/src/gmp/Makefile.am @@ -1,8 +1,8 @@ ## Process this file with automake to generate Makefile.in -# Copyright 1991, 1993, 1994, 1996, 1997, 1999, 2000, 2001, 2002 Free -# Software Foundation, Inc. +# Copyright 1991, 1993, 1994, 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004 +# Free Software Foundation, Inc. # # This file is part of the GNU MP Library. # @@ -47,6 +47,7 @@ # 4.1 6:0:3 3:2:0 4:4:1 # 4.1.1 6:1:3 3:3:0 4:5:1 # 4.1.2 6:2:3 3:4:0 4:6:1 +# 4.1.3 6:3:3 3:5:0 4:7:1 # # Starting at 3:0:0 is a slight abuse of the versioning system, but it # ensures we're past soname libgmp.so.2, which was used on Debian GNU/Linux @@ -54,15 +55,15 @@ # gmp 3 mean 3:0:0 is right. LIBGMP_LT_CURRENT = 6 -LIBGMP_LT_REVISION = 2 +LIBGMP_LT_REVISION = 3 LIBGMP_LT_AGE = 3 LIBGMPXX_LT_CURRENT = 3 -LIBGMPXX_LT_REVISION = 4 +LIBGMPXX_LT_REVISION = 5 LIBGMPXX_LT_AGE = 0 LIBMP_LT_CURRENT = 4 -LIBMP_LT_REVISION = 6 +LIBMP_LT_REVISION = 7 LIBMP_LT_AGE = 1 @@ -93,8 +94,19 @@ if WANT_MPFR MPFRXX_HEADERS_OPTION = mpfrxx.h endif endif + +# gmp.h and mp.h are architecture dependent, mainly since they encode the +# limb size used in libgmp. For that reason they belong under $exec_prefix +# not $prefix, strictly speaking. +# +# $exec_prefix/include is not in the default include path for gcc built to +# the same $prefix and $exec_prefix, which might mean gmp.h is not found, +# but anyone knowledgable enough to be playing with exec_prefix will be able +# to address that. +# +includeexecdir = $(exec_prefix)/include include_HEADERS = $(GMPXX_HEADERS_OPTION) $(MPFRXX_HEADERS_OPTION) -nodist_include_HEADERS = gmp.h $(MPBSD_HEADERS_OPTION) +nodist_includeexec_HEADERS = gmp.h $(MPBSD_HEADERS_OPTION) lib_LTLIBRARIES = libgmp.la $(GMPXX_LTLIBRARIES_OPTION) $(MPBSD_LTLIBRARIES_OPTION) EXTRA_DIST = doc macos \ @@ -209,10 +221,11 @@ SCANF_OBJECTS = \ scanf/scanf$U.lo scanf/sscanf$U.lo scanf/sscanffuns$U.lo \ scanf/vfscanf$U.lo scanf/vscanf$U.lo scanf/vsscanf$U.lo -CXX_OBJECTS = \ - cxx/isfuns$U.lo cxx/ismpf$U.lo cxx/ismpq$U.lo cxx/ismpz$U.lo \ - cxx/osdoprnti$U.lo cxx/osfuns$U.lo \ - cxx/osmpf$U.lo cxx/osmpq$U.lo cxx/osmpz$U.lo +# no $U for C++ files +CXX_OBJECTS = \ + cxx/isfuns.lo cxx/ismpf.lo cxx/ismpq.lo cxx/ismpz.lo \ + cxx/osdoprnti.lo cxx/osfuns.lo \ + cxx/osmpf.lo cxx/osmpq.lo cxx/osmpz.lo MPBSD_OBJECTS = mpbsd/add$U.lo mpbsd/tdiv_qr$U.lo mpbsd/set$U.lo \ mpbsd/powm$U.lo mpbsd/sub$U.lo mpbsd/cmp$U.lo mpbsd/mfree$U.lo \ diff --git a/src/gmp/Makefile.in b/src/gmp/Makefile.in index 545c76bab..ab873cefb 100644 --- a/src/gmp/Makefile.in +++ b/src/gmp/Makefile.in @@ -13,8 +13,8 @@ @SET_MAKE@ -# Copyright 1991, 1993, 1994, 1996, 1997, 1999, 2000, 2001, 2002 Free -# Software Foundation, Inc. +# Copyright 1991, 1993, 1994, 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004 +# Free Software Foundation, Inc. # # This file is part of the GNU MP Library. # @@ -58,6 +58,7 @@ # 4.1 6:0:3 3:2:0 4:4:1 # 4.1.1 6:1:3 3:3:0 4:5:1 # 4.1.2 6:2:3 3:4:0 4:6:1 +# 4.1.3 6:3:3 3:5:0 4:7:1 # # Starting at 3:0:0 is a slight abuse of the versioning system, but it # ensures we're past soname libgmp.so.2, which was used on Debian GNU/Linux @@ -168,15 +169,15 @@ mpn_objs_in_libgmp = @mpn_objs_in_libgmp@ mpn_objs_in_libmp = @mpn_objs_in_libmp@ LIBGMP_LT_CURRENT = 6 -LIBGMP_LT_REVISION = 2 +LIBGMP_LT_REVISION = 3 LIBGMP_LT_AGE = 3 LIBGMPXX_LT_CURRENT = 3 -LIBGMPXX_LT_REVISION = 4 +LIBGMPXX_LT_REVISION = 5 LIBGMPXX_LT_AGE = 0 LIBMP_LT_CURRENT = 4 -LIBMP_LT_REVISION = 6 +LIBMP_LT_REVISION = 7 LIBMP_LT_AGE = 1 AUTOMAKE_OPTIONS = gnu no-dependencies ansi2knr @@ -196,8 +197,19 @@ SUBDIRS = tests mpn mpz mpq mpf printf scanf cxx mpbsd $(MPFR_DIR) demos tune @WANT_CXX_TRUE@GMPXX_HEADERS_OPTION = gmpxx.h @WANT_CXX_TRUE@@WANT_MPFR_TRUE@MPFRXX_HEADERS_OPTION = mpfrxx.h + +# gmp.h and mp.h are architecture dependent, mainly since they encode the +# limb size used in libgmp. For that reason they belong under $exec_prefix +# not $prefix, strictly speaking. +# +# $exec_prefix/include is not in the default include path for gcc built to +# the same $prefix and $exec_prefix, which might mean gmp.h is not found, +# but anyone knowledgable enough to be playing with exec_prefix will be able +# to address that. +# +includeexecdir = $(exec_prefix)/include include_HEADERS = $(GMPXX_HEADERS_OPTION) $(MPFRXX_HEADERS_OPTION) -nodist_include_HEADERS = gmp.h $(MPBSD_HEADERS_OPTION) +nodist_includeexec_HEADERS = gmp.h $(MPBSD_HEADERS_OPTION) lib_LTLIBRARIES = libgmp.la $(GMPXX_LTLIBRARIES_OPTION) $(MPBSD_LTLIBRARIES_OPTION) EXTRA_DIST = doc macos \ @@ -317,10 +329,11 @@ SCANF_OBJECTS = \ scanf/vfscanf$U.lo scanf/vscanf$U.lo scanf/vsscanf$U.lo +# no $U for C++ files CXX_OBJECTS = \ - cxx/isfuns$U.lo cxx/ismpf$U.lo cxx/ismpq$U.lo cxx/ismpz$U.lo \ - cxx/osdoprnti$U.lo cxx/osfuns$U.lo \ - cxx/osmpf$U.lo cxx/osmpq$U.lo cxx/osmpz$U.lo + cxx/isfuns.lo cxx/ismpf.lo cxx/ismpq.lo cxx/ismpz.lo \ + cxx/osdoprnti.lo cxx/osfuns.lo \ + cxx/osmpf.lo cxx/osmpq.lo cxx/osmpz.lo MPBSD_OBJECTS = mpbsd/add$U.lo mpbsd/tdiv_qr$U.lo mpbsd/set$U.lo \ @@ -449,10 +462,10 @@ CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ CXXFLAGS = @CXXFLAGS@ DIST_SOURCES = $(libdummy_la_SOURCES) $(libgmp_la_SOURCES) \ $(libgmpxx_la_SOURCES) $(libmp_la_SOURCES) -#INFO_DEPS = gmp.info -#DVIS = gmp.dvi +INFO_DEPS = gmp.info +DVIS = gmp.dvi TEXINFOS = gmp.texi -HEADERS = $(include_HEADERS) $(nodist_include_HEADERS) +HEADERS = $(include_HEADERS) $(nodist_includeexec_HEADERS) RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \ @@ -755,22 +768,22 @@ uninstall-includeHEADERS: echo " rm -f $(DESTDIR)$(includedir)/$$f"; \ rm -f $(DESTDIR)$(includedir)/$$f; \ done -install-nodist_includeHEADERS: $(nodist_include_HEADERS) +install-nodist_includeexecHEADERS: $(nodist_includeexec_HEADERS) @$(NORMAL_INSTALL) - $(mkinstalldirs) $(DESTDIR)$(includedir) - @list='$(nodist_include_HEADERS)'; for p in $$list; do \ + $(mkinstalldirs) $(DESTDIR)$(includeexecdir) + @list='$(nodist_includeexec_HEADERS)'; for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ f="`echo $$p | sed -e 's|^.*/||'`"; \ - echo " $(INSTALL_HEADER) $$d$$p $(DESTDIR)$(includedir)/$$f"; \ - $(INSTALL_HEADER) $$d$$p $(DESTDIR)$(includedir)/$$f; \ + echo " $(INSTALL_HEADER) $$d$$p $(DESTDIR)$(includeexecdir)/$$f"; \ + $(INSTALL_HEADER) $$d$$p $(DESTDIR)$(includeexecdir)/$$f; \ done -uninstall-nodist_includeHEADERS: +uninstall-nodist_includeexecHEADERS: @$(NORMAL_UNINSTALL) - @list='$(nodist_include_HEADERS)'; for p in $$list; do \ + @list='$(nodist_includeexec_HEADERS)'; for p in $$list; do \ f="`echo $$p | sed -e 's|^.*/||'`"; \ - echo " rm -f $(DESTDIR)$(includedir)/$$f"; \ - rm -f $(DESTDIR)$(includedir)/$$f; \ + echo " rm -f $(DESTDIR)$(includeexecdir)/$$f"; \ + rm -f $(DESTDIR)$(includeexecdir)/$$f; \ done # This directory's subdirectories are mostly independent; you can cd @@ -954,7 +967,7 @@ all-am: Makefile $(INFO_DEPS) $(ANSI2KNR) $(LTLIBRARIES) $(HEADERS) \ config.h installdirs: installdirs-recursive installdirs-am: - $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(infodir) $(DESTDIR)$(includedir) $(DESTDIR)$(includedir) + $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(infodir) $(DESTDIR)$(includedir) $(DESTDIR)$(includeexecdir) install: install-recursive install-exec: install-exec-recursive @@ -1002,10 +1015,10 @@ info: info-recursive info-am: $(INFO_DEPS) -install-data-am: install-includeHEADERS install-info-am \ - install-nodist_includeHEADERS +install-data-am: install-includeHEADERS install-info-am -install-exec-am: install-libLTLIBRARIES +install-exec-am: install-libLTLIBRARIES \ + install-nodist_includeexecHEADERS install-info: install-info-recursive @@ -1047,7 +1060,7 @@ mostlyclean-am: mostlyclean-aminfo mostlyclean-compile \ mostlyclean-vti uninstall-am: uninstall-includeHEADERS uninstall-info-am \ - uninstall-libLTLIBRARIES uninstall-nodist_includeHEADERS + uninstall-libLTLIBRARIES uninstall-nodist_includeexecHEADERS uninstall-info: uninstall-info-recursive @@ -1061,17 +1074,17 @@ uninstall-info: uninstall-info-recursive install-exec install-exec-am install-exec-recursive \ install-includeHEADERS install-info install-info-am \ install-info-recursive install-libLTLIBRARIES install-man \ - install-nodist_includeHEADERS install-recursive install-strip \ - installcheck installcheck-am installdirs installdirs-am \ - installdirs-recursive maintainer-clean maintainer-clean-aminfo \ - maintainer-clean-generic maintainer-clean-recursive \ - maintainer-clean-vti mostlyclean mostlyclean-aminfo \ - mostlyclean-compile mostlyclean-generic mostlyclean-kr \ - mostlyclean-libtool mostlyclean-recursive mostlyclean-vti tags \ - tags-recursive uninstall uninstall-am uninstall-includeHEADERS \ - uninstall-info-am uninstall-info-recursive \ - uninstall-libLTLIBRARIES uninstall-nodist_includeHEADERS \ - uninstall-recursive + install-nodist_includeexecHEADERS install-recursive \ + install-strip installcheck installcheck-am installdirs \ + installdirs-am installdirs-recursive maintainer-clean \ + maintainer-clean-aminfo maintainer-clean-generic \ + maintainer-clean-recursive maintainer-clean-vti mostlyclean \ + mostlyclean-aminfo mostlyclean-compile mostlyclean-generic \ + mostlyclean-kr mostlyclean-libtool mostlyclean-recursive \ + mostlyclean-vti tags tags-recursive uninstall uninstall-am \ + uninstall-includeHEADERS uninstall-info-am \ + uninstall-info-recursive uninstall-libLTLIBRARIES \ + uninstall-nodist_includeexecHEADERS uninstall-recursive # Avoid: CVS - cvs directories diff --git a/src/gmp/NEWS b/src/gmp/NEWS index af9641d5b..055b9a3bc 100644 --- a/src/gmp/NEWS +++ b/src/gmp/NEWS @@ -1,4 +1,4 @@ -Copyright 1996, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +Copyright 1996, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -18,16 +18,37 @@ the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -Changes between MP version 4.1.1 and 4.1.2 +Changes between GMP version 4.1.3 and 4.1.4 + +* Bug fix to FFT multiplication code (crash for huge operands). +* Bug fix to mpf_sub (miscomputation). +* Support for powerpc64-gnu-linux. +* Better support for AMD64 in 32-bit mode. +* Upwardly binary compatible with 4.1.3, 4.1.2, 4.1.1, 4.1, 4.0.1, 4.0, + and 3.x versions. + +Changes between GMP version 4.1.2 and 4.1.3 + +* Bug fix for FFT multiplication code (miscomputation). +* Bug fix to K6 assembly code for gcd. +* Bug fix to IA-64 assembly code for population count. +* Portability improvements, most notably functional AMD64 support. +* mpz_export allows NULL for countp parameter. +* Many minor bug fixes. +* mpz_export allows NULL for countp parameter. +* Upwardly binary compatible with 4.1.2, 4.1.1, 4.1, 4.0.1, 4.0, and 3.x + versions. + +Changes between GMP version 4.1.1 and 4.1.2 * Bug fixes. -Changes between MP version 4.1 and 4.1.1 +Changes between GMP version 4.1 and 4.1.1 * Bug fixes. * New systems supported: NetBSD and OpenBSD sparc64. -Changes between MP version 4.0.1 and 4.1 +Changes between GMP version 4.0.1 and 4.1 * Bug fixes. * Speed improvements. @@ -50,11 +71,11 @@ Changes between MP version 4.0.1 and 4.1 * Nails-enabled Alpha 21264 assembly code, allowing up to 75% better performance. (Use --enable-nails=4 to enable it.) -Changes between MP version 4.0 and 4.0.1 +Changes between GMP version 4.0 and 4.0.1 * Bug fixes. -Changes between MP version 3.1.1 and 4.0 +Changes between GMP version 3.1.1 and 4.0 * Bug fixes. * Speed improvements. @@ -98,12 +119,12 @@ Changes between MP version 3.1.1 and 4.0 * New preliminary perl interface (see demos/perl). * Tuned algorithm thresholds for many more CPUs. -Changes between MP version 3.1 and 3.1.1 +Changes between GMP version 3.1 and 3.1.1 * Bug fixes for division (rare), mpf_get_str, FFT, and miscellaneous minor things. -Changes between MP version 3.0 and 3.1 +Changes between GMP version 3.0 and 3.1 * Bug fixes. * Improved `make check' running more tests. @@ -129,12 +150,12 @@ Changes between MP version 3.0 and 3.1 To try it, pass --enable-mpfr to configure. See the mpfr subdirectory for more information; it is not documented in the main GMP manual. -Changes between MP version 3.0 and 3.0.1 +Changes between GMP version 3.0 and 3.0.1 * Memory leaks in gmp_randinit and mpz_probab_prime_p fixed. * Documentation for gmp_randinit fixed. Misc documentation errors fixed. -Changes between MP version 2.0 and 3.0 +Changes between GMP version 2.0 and 3.0 * Source level compatibility with past releases (except mpn_gcd). * Bug fixes. @@ -166,11 +187,11 @@ Changes between MP version 2.0 and 3.0 * Better support for MIPS R4x000 and R5000 under Irix 6. * Improved support for SPARCv8 and SPARCv9 processors. -Changes between MP version 2.0 and 2.0.2 +Changes between GMP version 2.0 and 2.0.2 * Many bug fixes. -Changes between MP version 1.3.2 and 2.0 +Changes between GMP version 1.3.2 and 2.0 * Division routines in the mpz class have changed. There are three classes of functions, that rounds the quotient to -infinity, 0, and +infinity, diff --git a/src/gmp/acinclude.m4 b/src/gmp/acinclude.m4 index 450285e8d..70be732c9 100644 --- a/src/gmp/acinclude.m4 +++ b/src/gmp/acinclude.m4 @@ -22,7 +22,7 @@ dnl MA 02111-1307, USA. define(X86_PATTERN, -[[i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-*]]) +[[i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-* | viac3*-*-*]]) define(POWERPC64_PATTERN, [[powerpc64-*-* | powerpc64le-*-* | powerpc620-*-* | powerpc630-*-*]]) diff --git a/src/gmp/aclocal.m4 b/src/gmp/aclocal.m4 index a72eaa648..494fc2713 100644 --- a/src/gmp/aclocal.m4 +++ b/src/gmp/aclocal.m4 @@ -35,7 +35,7 @@ dnl MA 02111-1307, USA. define(X86_PATTERN, -[[i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-*]]) +[[i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-* | viac3*-*-*]]) define(POWERPC64_PATTERN, [[powerpc64-*-* | powerpc64le-*-* | powerpc620-*-* | powerpc630-*-*]]) diff --git a/src/gmp/config.guess b/src/gmp/config.guess index 042b6625c..268384835 100755 --- a/src/gmp/config.guess +++ b/src/gmp/config.guess @@ -3,7 +3,7 @@ # GMP config.guess wrapper. -# Copyright 2000, 2001, 2002 Free Software Foundation, Inc. +# Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc. # # This file is part of the GNU MP Library. # @@ -76,7 +76,7 @@ exact_cpu= dummy=dummy-$$ -trap 'rm -f $dummy.c $dummy.o $dummy ${dummy}1.s ${dummy}2.c ; exit 1' 1 2 15 +trap 'rm -f $dummy.c $dummy.o $dummy.core $dummy ${dummy}1.s ${dummy}2.c ; exit 1' 1 2 15 # Use $HOST_CC if defined. $CC may point to a cross-compiler if test x"$CC_FOR_BUILD" = x; then @@ -87,7 +87,7 @@ if test x"$CC_FOR_BUILD" = x; then CC_FOR_BUILD="$CC" else echo 'dummy(){}' >$dummy.c - for c in cc c89 gcc; do + for c in cc gcc c89 c99; do ($c $dummy.c -c) >/dev/null 2>&1 if test $? = 0; then CC_FOR_BUILD="$c"; break @@ -144,7 +144,7 @@ EOF 2-1307) exact_cpu=alphaev68 ;; esac fi - rm -f $dummy.s $dummy + rm -f $dummy.s $dummy.o $dummy ;; mips-*-irix[6789]*) @@ -251,7 +251,7 @@ EOF exact_cpu=m68020 fi fi - rm -f $dummy.s $dummy $dummy.core core + rm -f $dummy.s $dummy.o $dummy $dummy.core core fi if test -z "$exact_cpu"; then case "$guess_full" in @@ -313,13 +313,14 @@ main () } EOF if ($CC_FOR_BUILD $dummy.c -o $dummy) >/dev/null 2>&1; then - # use $SHELL -c to avoid a segv message when this program is run on AIX - x=`$SHELL -c ./$dummy 2>/dev/null` + # This style construct is needed on AIX 4.3 to suppress the SIGILL error + # from (*fun)(). Using $SHELL -c ./$dummy 2>/dev/null doesn't work. + { x=`./$dummy`; } 2>/dev/null if test -n "$x"; then exact_cpu=$x fi fi - rm -f $dummy.c $dummy + rm -f $dummy.c $dummy.o $dummy $dummy.core # Grep the linux kernel /proc/cpuinfo pseudo-file. # Anything unrecognised is ignored, since of course we mustn't spit out @@ -383,7 +384,7 @@ EOF exact_cpu=$x fi fi - rm -f $dummy.c $dummy + rm -f $dummy.c $dummy.o $dummy fi if test -z "$exact_cpu"; then @@ -422,7 +423,7 @@ EOF exact_cpu=$x fi fi - rm -f $dummy.c $dummy + rm -f $dummy.c $dummy.o $dummy fi ;; @@ -598,12 +599,27 @@ main () case 6: modelstr = "athlon"; break; + case 15: + /* We might want to return opteron, athlon64, or the CPU core name + hammer here instead of the architecture name x86_64. */ + modelstr = "x86_64"; + break; } } else if (strcmp (vendor_string, "CyrixInstead") == 0) { /* Should recognize Cyrix' processors too. */ } + else if (strcmp (vendor_string, "CentaurHauls") == 0) + { + switch (family) + { + case 6: + if (model < 9) modelstr = "viac3"; + else modelstr = "viac32"; + break; + } + } printf ("%s\n", modelstr); return 0; diff --git a/src/gmp/config.in b/src/gmp/config.in index bc074b839..f79f7d1da 100644 --- a/src/gmp/config.in +++ b/src/gmp/config.in @@ -465,6 +465,12 @@ MA 02111-1307, USA. */ /* ./configure --enable-fft option, to enable FFTs for multiplication */ #undef WANT_FFT +/* Define to 1 if --enable-profiling=gprof */ +#undef WANT_PROFILING_GPROF + +/* Define to 1 if --enable-profiling=prof */ +#undef WANT_PROFILING_PROF + /* --enable-alloca=yes */ #undef WANT_TMP_ALLOCA diff --git a/src/gmp/config.sub b/src/gmp/config.sub index 16d9864d6..a8b884734 100755 --- a/src/gmp/config.sub +++ b/src/gmp/config.sub @@ -85,7 +85,7 @@ given_full="$given_cpu$given_rest" # GMP extras and what to use for the config.sub test case "$given_cpu" in -pentium | pentiummmx | pentiumpro | pentium[234] | k[56] | k6[23] | athlon) +pentium | pentiummmx | pentiumpro | pentium[234] | k[56] | k6[23] | athlon | viac3*) test_cpu=i386 ;; power[12] | power2sc) test_cpu=power ;; diff --git a/src/gmp/configfsf.guess b/src/gmp/configfsf.guess index 0cd6c1a38..51fab4770 100755 --- a/src/gmp/configfsf.guess +++ b/src/gmp/configfsf.guess @@ -1,9 +1,9 @@ #! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002 Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. -timestamp='2002-08-19' +timestamp='2004-03-12' # 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 @@ -98,30 +98,32 @@ trap 'exit 1' 1 2 15 # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. -# This shell variable is my proudest work .. or something. --bje +# Portable tmp directory creation inspired by the Autoconf team. -set_cc_for_build='tmpdir=${TMPDIR-/tmp}/config-guess-$$ ; -(old=`umask` && umask 077 && mkdir $tmpdir && umask $old && unset old) - || (echo "$me: cannot create $tmpdir" >&2 && exit 1) ; -dummy=$tmpdir/dummy ; -files="$dummy.c $dummy.o $dummy.rel $dummy" ; -trap '"'"'rm -f $files; rmdir $tmpdir; exit 1'"'"' 1 2 15 ; +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do - if ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; then + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; - rm -f $files ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; -unset files' +esac ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) @@ -178,18 +180,35 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # The OS release - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit 0 ;; + amd64:OpenBSD:*:*) + echo x86_64-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; amiga:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; arc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; + cats:OpenBSD:*:*) + echo arm-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; hp300:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; @@ -208,6 +227,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in mvmeppc:OpenBSD:*:*) echo powerpc-unknown-openbsd${UNAME_RELEASE} exit 0 ;; + pegasos:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; pmax:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; @@ -223,71 +245,70 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:OpenBSD:*:*) echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} exit 0 ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit 0 ;; + macppc:MirBSD:*:*) + echo powerppc-unknown-mirbsd${UNAME_RELEASE} + exit 0 ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit 0 ;; alpha:OSF1:*:*) - if test $UNAME_RELEASE = "V4.0"; then + case $UNAME_RELEASE in + *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - fi + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - eval $set_cc_for_build - cat <$dummy.s - .data -\$Lformat: - .byte 37,100,45,37,120,10,0 # "%d-%x\n" - - .text - .globl main - .align 4 - .ent main -main: - .frame \$30,16,\$26,0 - ldgp \$29,0(\$27) - .prologue 1 - .long 0x47e03d80 # implver \$0 - lda \$2,-1 - .long 0x47e20c21 # amask \$2,\$1 - lda \$16,\$Lformat - mov \$0,\$17 - not \$1,\$18 - jsr \$26,printf - ldgp \$29,0(\$26) - mov 0,\$16 - jsr \$26,exit - .end main -EOF - $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null - if test "$?" = 0 ; then - case `$dummy` in - 0-0) - UNAME_MACHINE="alpha" - ;; - 1-0) - UNAME_MACHINE="alphaev5" - ;; - 1-1) - UNAME_MACHINE="alphaev56" - ;; - 1-101) - UNAME_MACHINE="alphapca56" - ;; - 2-303) - UNAME_MACHINE="alphaev6" - ;; - 2-307) - UNAME_MACHINE="alphaev67" - ;; - 2-1307) - UNAME_MACHINE="alphaev68" - ;; - 3-1307) - UNAME_MACHINE="alphaev7" - ;; - esac - fi - rm -f $dummy.s $dummy && rmdir $tmpdir - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit 0 ;; + Alpha*:OpenVMS:*:*) + echo alpha-hp-vms exit 0 ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? @@ -310,6 +331,9 @@ EOF *:OS/390:*:*) echo i370-ibm-openedition exit 0 ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; @@ -327,6 +351,9 @@ EOF NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit 0 ;; DRS?6000:UNIX_SV:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7 && exit 0 ;; @@ -399,6 +426,9 @@ EOF *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit 0 ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; @@ -437,16 +467,18 @@ EOF exit (-1); } EOF - $CC_FOR_BUILD $dummy.c -o $dummy \ + $CC_FOR_BUILD -o $dummy $dummy.c \ && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0 - rm -f $dummy.c $dummy && rmdir $tmpdir + && exit 0 echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit 0 ;; - Night_Hawk:*:*:PowerMAX_OS) + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit 0 ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit 0 ;; Night_Hawk:Power_UNIX:*:*) @@ -521,8 +553,7 @@ EOF exit(0); } EOF - $CC_FOR_BUILD $dummy.c -o $dummy && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0 - rm -f $dummy.c $dummy && rmdir $tmpdir + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 @@ -620,11 +651,21 @@ EOF exit (0); } EOF - (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null) && HP_ARCH=`$dummy` - if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi - rm -f $dummy.c $dummy && rmdir $tmpdir + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + # avoid double evaluation of $set_cc_for_build + test -n "$CC_FOR_BUILD" || eval $set_cc_for_build + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; ia64:HP-UX:*:*) @@ -658,8 +699,7 @@ EOF exit (0); } EOF - $CC_FOR_BUILD $dummy.c -o $dummy && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0 - rm -f $dummy.c $dummy && rmdir $tmpdir + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) @@ -717,21 +757,26 @@ EOF CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; - CRAY*T3D:*:*:*) - echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; + *:UNICOS/mp:*:*) + echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; @@ -753,8 +798,10 @@ EOF #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` - rm -f $dummy.c && rmdir $tmpdir - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC} + # GNU/KFreeBSD systems have a "k" prefix to indicate we are using + # FreeBSD's kernel, but not the complete OS. + case ${LIBC} in gnu) kernel_only='k' ;; esac + echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC} exit 0 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin @@ -765,14 +812,17 @@ EOF i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit 0 ;; - x86:Interix*:3*) - echo i386-pc-interix3 + x86:Interix*:[34]*) + echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' + exit 0 ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks exit 0 ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? - echo i386-pc-interix + echo i586-pc-interix exit 0 ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin @@ -784,17 +834,28 @@ EOF echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) + # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit 0 ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit 0 ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit 0 ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; @@ -815,8 +876,26 @@ EOF #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - rm -f $dummy.c && rmdir $tmpdir - test x"${CPU}" != x && echo "${CPU}-pc-linux-gnu" && exit 0 + test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu @@ -852,6 +931,9 @@ EOF s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit 0 ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; @@ -909,9 +991,11 @@ EOF LIBC=gnuaout #endif #endif + #ifdef __dietlibc__ + LIBC=dietlibc + #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` - rm -f $dummy.c && rmdir $tmpdir test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 ;; @@ -929,6 +1013,26 @@ EOF # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit 0 ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit 0 ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit 0 ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit 0 ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit 0 ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit 0 ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then @@ -963,9 +1067,6 @@ EOF echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit 0 ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about @@ -989,9 +1090,15 @@ EOF # "miniframe" echo m68010-convergent-sysv exit 0 ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit 0 ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit 0 ;; M68*:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0) + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` @@ -1008,9 +1115,6 @@ EOF mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; @@ -1092,7 +1196,11 @@ EOF echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Darwin:*:*) - echo `uname -p`-apple-darwin${UNAME_RELEASE} + case `uname -p` in + *86) UNAME_PROCESSOR=i686 ;; + powerpc) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit 0 ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` @@ -1105,7 +1213,7 @@ EOF *:QNX:*:4*) echo i386-pc-qnx exit 0 ;; - NSR-[GKLNPTVW]:NONSTOP_KERNEL:*:*) + NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit 0 ;; *:NonStop-UX:*:*) @@ -1128,11 +1236,6 @@ EOF fi echo ${UNAME_MACHINE}-unknown-plan9 exit 0 ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit 0 ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit 0 ;; @@ -1151,11 +1254,11 @@ EOF *:ITS:*:*) echo pdp10-unknown-its exit 0 ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} exit 0 ;; - i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; esac @@ -1277,8 +1380,7 @@ main () } EOF -$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0 -rm -f $dummy.c $dummy && rmdir $tmpdir +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 # Apollos put the system type in the environment. diff --git a/src/gmp/configfsf.sub b/src/gmp/configfsf.sub index 603384298..ba331039b 100755 --- a/src/gmp/configfsf.sub +++ b/src/gmp/configfsf.sub @@ -1,9 +1,9 @@ #! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002 Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. -timestamp='2002-08-20' +timestamp='2004-03-12' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -118,7 +118,8 @@ esac # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | freebsd*-gnu* | storm-chaos* | os2-emx* | windows32-* | rtmk-nova*) + nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ + kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; @@ -228,38 +229,42 @@ case $basic_machine in | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ - | ip2k \ - | m32r | m68000 | m68k | m88k | mcore \ + | ip2k | iq2000 \ + | m32r | m32rle | m68000 | m68k | m88k | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ - | mips64vr | mips64vrel \ + | mips64vr | mips64vrel \ | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ + | msp430 \ | ns16k | ns32k \ | openrisc | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ - | sh | sh[1234] | sh3e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ - | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ + | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv8 | sparcv9 | sparcv9b \ | strongarm \ - | tahoe | thumb | tic80 | tron \ + | tahoe | thumb | tic4x | tic80 | tron \ | v850 | v850e \ | we32k \ | x86 | xscale | xstormy16 | xtensa \ @@ -294,7 +299,7 @@ case $basic_machine in | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* \ | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c54x-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | clipper-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ @@ -302,34 +307,39 @@ case $basic_machine in | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ - | ip2k-* \ - | m32r-* \ + | ip2k-* | iq2000-* \ + | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | mcore-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ - | mips64vr-* | mips64vrel-* \ + | mips64vr-* | mips64vrel-* \ | mips64orion-* | mips64orionel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipstx39 | mipstx39el \ - | none-* | np1-* | ns16k-* | ns32k-* \ + | mipstx39-* | mipstx39el-* \ + | msp430-* \ + | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh3e-* | sh[34]eb-* | shbe-* \ + | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ - | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ @@ -353,6 +363,9 @@ case $basic_machine in basic_machine=a29k-amd os=-udi ;; + abacus) + basic_machine=abacus-unknown + ;; adobe68k) basic_machine=m68010-adobe os=-scout @@ -367,6 +380,12 @@ case $basic_machine in basic_machine=a29k-none os=-bsd ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; amdahl) basic_machine=580-amdahl os=-sysv @@ -426,12 +445,20 @@ case $basic_machine in basic_machine=j90-cray os=-unicos ;; + cr16c) + basic_machine=cr16c-unknown + os=-elf + ;; crds | unos) basic_machine=m68k-crds ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; da30 | da30-*) basic_machine=m68k-da30 ;; @@ -716,6 +743,10 @@ case $basic_machine in np1) basic_machine=np1-gould ;; + nv1) + basic_machine=nv1-cray + os=-unicosmp + ;; nsr-tandem) basic_machine=nsr-tandem ;; @@ -727,6 +758,10 @@ case $basic_machine in basic_machine=or32-unknown os=-coff ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose @@ -749,7 +784,7 @@ case $basic_machine in pbb) basic_machine=m68k-tti ;; - pc532 | pc532-*) + pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5 | k5 | k6 | nexgen | viac3) @@ -758,40 +793,46 @@ case $basic_machine in pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; - pentiumii | pentium2) + pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; + pentium4) + basic_machine=i786-pc + ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - pentiumii-* | pentium2-*) + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-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/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown - ;; + ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown - ;; + ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; @@ -828,6 +869,10 @@ case $basic_machine in sb1el) basic_machine=mipsisa64sb1el-unknown ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; sequent) basic_machine=i386-sequent ;; @@ -835,6 +880,9 @@ case $basic_machine in basic_machine=sh-hitachi os=-hms ;; + sh64) + basic_machine=sh64-unknown + ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks @@ -893,7 +941,7 @@ case $basic_machine in sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; - sv1) + sv1) basic_machine=sv1-cray os=-unicos ;; @@ -901,10 +949,6 @@ case $basic_machine in basic_machine=i386-sequent os=-dynix ;; - t3d) - basic_machine=alpha-cray - os=-unicos - ;; t3e) basic_machine=alphaev5-cray os=-unicos @@ -917,6 +961,14 @@ case $basic_machine in basic_machine=tic54x-unknown os=-coff ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; tx39) basic_machine=mipstx39-unknown ;; @@ -930,6 +982,10 @@ case $basic_machine in tower | tower-32) basic_machine=m68k-ncr ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; udi29k) basic_machine=a29k-amd os=-udi @@ -951,8 +1007,8 @@ case $basic_machine in os=-vms ;; vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; + basic_machine=f301-fujitsu + ;; vxworks960) basic_machine=i960-wrs os=-vxworks @@ -973,11 +1029,7 @@ case $basic_machine in basic_machine=hppa1.1-winbond os=-proelf ;; - windows32) - basic_machine=i386-pc - os=-windows32-msvcrt - ;; - xps | xps100) + xps | xps100) basic_machine=xps100-honeywell ;; ymp) @@ -1023,16 +1075,16 @@ case $basic_machine in we32k) basic_machine=we32k-att ;; - sh3 | sh4 | sh3eb | sh4eb | sh[1234]le | sh3ele) + sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sh64) basic_machine=sh64-unknown ;; - sparc | sparcv9 | sparcv9b) + sparc | sparcv8 | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; - cydra) + cydra) basic_machine=cydra-cydrome ;; orion) @@ -1047,10 +1099,6 @@ case $basic_machine in pmac | pmac-mpw) basic_machine=powerpc-apple ;; - c4x*) - basic_machine=c4x-none - os=-coff - ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; @@ -1106,18 +1154,20 @@ case $os in | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ - | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ + | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* | -powermax*) + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1129,8 +1179,10 @@ case $os in ;; esac ;; + -nto-qnx*) + ;; -nto*) - os=-nto-qnx + os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ @@ -1139,6 +1191,9 @@ case $os in -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; @@ -1151,6 +1206,9 @@ case $os in -opened*) os=-openedition ;; + -os400*) + os=-os400 + ;; -wince*) os=-wince ;; @@ -1172,6 +1230,9 @@ case $os in -atheos*) os=-atheos ;; + -syllable*) + os=-syllable + ;; -386bsd) os=-bsd ;; @@ -1182,7 +1243,7 @@ case $os in os=-rtmk-nova ;; -ns2 ) - os=-nextstep2 + os=-nextstep2 ;; -nsk*) os=-nsk @@ -1194,6 +1255,9 @@ case $os in -sinix*) os=-sysv4 ;; + -tpf*) + os=-tpf + ;; -triton*) os=-sysv3 ;; @@ -1221,8 +1285,14 @@ case $os in -xenix) os=-xenix ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos ;; -none) ;; @@ -1255,11 +1325,14 @@ case $basic_machine in arm*-semi) os=-aout ;; + c4x-* | tic4x-*) + os=-coff + ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; - pdp11-*) + pdp11-*) os=-none ;; *-dec | vax-*) @@ -1352,19 +1425,19 @@ case $basic_machine in *-next) os=-nextstep3 ;; - *-gould) + *-gould) os=-sysv ;; - *-highlevel) + *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; - *-sgi) + *-sgi) os=-irix ;; - *-siemens) + *-siemens) os=-sysv4 ;; *-masscomp) @@ -1433,9 +1506,15 @@ case $basic_machine in -mvs* | -opened*) vendor=ibm ;; + -os400*) + vendor=ibm + ;; -ptx*) vendor=sequent ;; + -tpf*) + vendor=ibm + ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; diff --git a/src/gmp/configure b/src/gmp/configure index e10629e29..f6e34f17d 100755 --- a/src/gmp/configure +++ b/src/gmp/configure @@ -1,9 +1,9 @@ #! /bin/sh -# From configure.in Revision: 1.425.2.17 . +# From configure.in Revision: 1.425.2.25 . # # # -# Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software +# Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software # Foundation, Inc. # # This file is part of the GNU MP Library. @@ -870,7 +870,7 @@ Optional Features: --enable-alloca how to get temp memory [default=reentrant] --enable-cxx enable C++ support [default=no] --enable-fft enable FFTs for multiplication [default=yes] - --enable-mpbsd build Berkley MP compatibility library + --enable-mpbsd build Berkeley MP compatibility library [default=no] --enable-mpfr build MPFR [default=no] --enable-nails use nails on limbs [default=no] @@ -958,7 +958,7 @@ Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. -Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software +Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -1580,7 +1580,7 @@ fi # Define the identity of the package. PACKAGE=gmp -VERSION=4.1.2 +VERSION=4.1.4 cat >>confdefs.h <>confdefs.h <<\EOF +#define WANT_PROFILING_PROF 1 +EOF + + ;; + gprof) + +cat >>confdefs.h <<\EOF +#define WANT_PROFILING_GPROF 1 +EOF + + ;; +esac + echo "define(,<\`$enable_profiling'>)" >> $gmp_tmpconfigm4 # -fomit-frame-pointer is incompatible with -pg, on x86s at least @@ -1818,7 +1835,7 @@ if test "${with_readline+set}" = set; then withval="$with_readline" case $withval in yes|no|detect) ;; -*) { { echo "$as_me:1821: error: bad value $withval for --with-readline, need yes/no/detect" >&5 +*) { { echo "$as_me:1838: error: bad value $withval for --with-readline, need yes/no/detect" >&5 echo "$as_me: error: bad value $withval for --with-readline, need yes/no/detect" >&2;} { (exit 1); exit 1; }; } ;; esac @@ -2195,7 +2212,7 @@ echo "include_mpn(\`m68k/m68k-defs.m4')" >> $gmp_tmpconfigm4i m68020-*-*) gcc_cflags_arch="-m68020" ;; m68030-*-*) gcc_cflags_arch="-m68030" ;; m68040-*-*) gcc_cflags_arch="-m68040" ;; - m68060-*-*) gcc_cflags_arch="-m68060 -m68040" ;; + m68060-*-*) gcc_cflags_arch="-m68060 -m68000" ;; m68360-*-*) gcc_cflags_arch="-mcpu32 -m68000" ;; *) gcc_cflags_arch="-m68000" ;; esac @@ -2204,9 +2221,9 @@ echo "include_mpn(\`m68k/m68k-defs.m4')" >> $gmp_tmpconfigm4i # tested. Will need to introduce an m68k/cpu32 if m68k/mc62020 ever uses # the bitfield instructions. case $host in - m680[2346]0-*-* | m68360-*-*) path="m68k/mc68020 m68k" - extra_functions="udiv umul" ;; - *) path="m68k" ;; + m680[234]0-*-* | m68360-*-*) path="m68k/mc68020 m68k" + extra_functions="udiv umul" ;; + *) path="m68k" ;; esac ;; @@ -2385,6 +2402,30 @@ EOF path_aix64="powerpc64" extra_functions_aix64="umul" ;; + *-*-linux*) + # On GNU/Linux, assume the processor is in 64-bit mode. Some + # environments have a gcc that is always in 64-bit mode, while + # others require -m64, hence the use of cflags_maybe. The + # sizeof-long-8 test checks the mode is right (for the no option + # case). + # + # -mpowerpc64 is not used, since it should be the default in + # 64-bit mode. (We need its effect for the various longlong.h + # asm macros to be right of course.) + # + # gcc64 was an early port of gcc to 64-bit mode, but should be + # obsolete before too long. We prefer plain gcc when it knows + # 64-bits. + # + abilist="64 $abilist" + cclist_64="gcc gcc64" + gcc_64_cflags_maybe="-m64" + gcc_64_cflags="-O3" + gcc_64_cflags_optlist="cpu" + path_64="powerpc64" + any_64_testlist="sizeof-long-8" + gmp_cv_asm_underscore=no # Kludge + ;; esac ;; esac @@ -2485,7 +2526,9 @@ echo "include_mpn(\`sparc32/sparc-defs.m4')" >> $gmp_tmpconfigm4i gcc_cflags="-g -O2 -Wa,-xarch=v8plus" gcc_cflags_cpu="-mcpu=ultrasparc -mcpu=v9 -mcpu=v8 -mv8" - cc_cflags="-xtarget=native -xarch=v8 -xO4" + # must have -xarch=v8plus here, to get the right assembler options + # for our mpn/sparc32/v9 code + cc_cflags="-xtarget=native -xarch=v8plus -xO4" case $host in *-*-solaris2.[7-9]) @@ -2528,7 +2571,7 @@ echo "include_mpn(\`sparc32/sparc-defs.m4')" >> $gmp_tmpconfigm4i ;; # AMD and Intel x86 configurations - i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-*) + i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-* | viac3*-*-* | x86_64-*-*) cat >>confdefs.h <<\EOF #define HAVE_HOST_CPU_FAMILY_x86 1 EOF @@ -2590,12 +2633,27 @@ echo "include_mpn(\`x86/x86-defs.m4')" >> $gmp_tmpconfigm4i gcc_cflags_cpu="-mcpu=athlon -mcpu=pentiumpro -mcpu=i486 -m486" gcc_cflags_arch="-march=athlon -march=pentiumpro -march=pentium -march=i486" ;; - pentium4-*-*) + pentium4-*-* | i786-*-*) # pentium4 is known to gcc 3.1 and up, not sure what cpu choice # would best suit previous versions, pentiumpro will get us cmov # from gcc 2.95.4 up, otherwise let's just try i486. gcc_cflags_cpu="-mcpu=pentium4 -mcpu=pentiumpro -mcpu=i486 -m486" - gcc_cflags_arch="-march=pentium4 -march=pentiumpro -march=pentium -march=i486" + gcc_cflags_arch="-march=pentium4~-mno-sse2 -march=pentiumpro -march=pentium -march=i486" + ;; + viac32-*-*) + # Not sure of the best fallbacks here for -mcpu. + # c3-2 has sse and mmx, so pentium3 is good for -march. + gcc_cflags_cpu="-mtune=c3-2 -mcpu=c3-2 -mcpu=i486 -m486" + gcc_cflags_arch="-march=c3-2 -march=pentium3 -march=pentiumpro -march=pentium" + ;; + viac3*-*-*) + # Not sure of the best fallbacks here. + gcc_cflags_cpu="-mtune=c3 -mcpu=c3 -mcpu=i486 -m486" + gcc_cflags_arch="-march=c3 -march=pentium-mmx -march=pentium" + ;; + x86_64-*-*) + gcc_cflags_cpu="-mtune=k8 -mcpu=athlon -mcpu=pentiumpro -mcpu=i486 -m486" + gcc_cflags_arch="-march=k8 -march=k8~-mno-sse2 -march=athlon -march=pentiumpro -march=pentium" ;; esac @@ -2608,8 +2666,25 @@ echo "include_mpn(\`x86/x86-defs.m4')" >> $gmp_tmpconfigm4i pentium3-*-*) path="x86/p6/p3mmx x86/p6/mmx x86/p6 x86";; k6[23]*-*-*) path="x86/k6/k62mmx x86/k6/mmx x86/k6 x86" ;; k6*-*-*) path="x86/k6/mmx x86/k6 x86" ;; - athlon-*-*) path="x86/k7/mmx x86/k7 x86" ;; - pentium4-*-*) path="x86/pentium4/sse2 x86/pentium4/mmx x86/pentium4 x86" ;; + # we don't have any specific 32-bit code for opteron (x86_64), the + # athlon code should be reasonable + athlon-*-* | x86_64-*-*) path="x86/k7/mmx x86/k7 x86" ;; + i786-*-* | pentium4-*-*) + path="x86/pentium4/sse2 x86/pentium4/mmx x86/pentium4 x86" ;; + # VIA/Centaur processors, sold as CyrixIII and C3. + viac32-*-*) path="x86/p6/p3mmx x86/p6/mmx x86/p6 x86";; + viac3*-*-*) path="x86/pentium/mmx x86/pentium x86";; + *) path="x86" ;; + esac + + case $host in + x86_64-*-*) + abilist="64 32" + path_64="x86-64" + cclist_64="gcc" + gcc_64_cflags="-O2 -m64" + gcc_64_cflags_optlist="cpu" + ;; esac ;; @@ -2647,13 +2722,13 @@ CFLAGS_or_unset=${CFLAGS-'(unset)'} CPPFLAGS_or_unset=${CPPFLAGS-'(unset)'} cat >&5 <&5 + { { echo "$as_me:2752: error: ABI=$ABI is not among the following valid choices: $abilist" >&5 echo "$as_me: error: ABI=$ABI is not among the following valid choices: $abilist" >&2;} { (exit 1); exit 1; }; } fi @@ -2764,15 +2839,15 @@ for abi in $abilist; do #endif EOF gmp_compile="$cc -c conftest.c >&5" -if { (eval echo "$as_me:2767: \"$gmp_compile\"") >&5 +if { (eval echo "$as_me:2842: \"$gmp_compile\"") >&5 (eval $gmp_compile) 2>&5 ac_status=$? - echo "$as_me:2770: \$? = $ac_status" >&5 + echo "$as_me:2845: \$? = $ac_status" >&5 (exit $ac_status); }; then rm -f conftest* - echo "$as_me:2773: checking whether $cc is gcc" >&5 + echo "$as_me:2848: checking whether $cc is gcc" >&5 echo $ECHO_N "checking whether $cc is gcc... $ECHO_C" >&6 - echo "$as_me:2775: result: yes" >&5 + echo "$as_me:2850: result: yes" >&5 echo "${ECHO_T}yes" >&6 ccbase=gcc else @@ -2786,14 +2861,14 @@ fi # then change $ccbase and make the default xlc flags available. if test $ccbase != xlc; then gmp_command="$cc 2>&1 | grep xlc >/dev/null" -if { (eval echo "$as_me:2789: \"$gmp_command\"") >&5 +if { (eval echo "$as_me:2864: \"$gmp_command\"") >&5 (eval $gmp_command) 2>&5 ac_status=$? - echo "$as_me:2792: \$? = $ac_status" >&5 + echo "$as_me:2867: \$? = $ac_status" >&5 (exit $ac_status); }; then - echo "$as_me:2794: checking whether $cc is xlc" >&5 + echo "$as_me:2869: checking whether $cc is xlc" >&5 echo $ECHO_N "checking whether $cc is xlc... $ECHO_C" >&6 - echo "$as_me:2796: result: yes" >&5 + echo "$as_me:2871: result: yes" >&5 echo "${ECHO_T}yes" >&6 ccbase=xlc else @@ -2820,7 +2895,7 @@ fi gprof) cflags="$cflags -pg" ;; esac - echo "$as_me:2823: checking compiler $cc $cflags $cppflags" >&5 + echo "$as_me:2898: checking compiler $cc $cflags $cppflags" >&5 echo $ECHO_N "checking compiler $cc $cflags $cppflags... $ECHO_C" >&6 cat >conftest.c <&5 +if { (eval echo "$as_me:2926: \"$gmp_compile\"") >&5 (eval $gmp_compile) 2>&5 ac_status=$? - echo "$as_me:2854: \$? = $ac_status" >&5 + echo "$as_me:2929: \$? = $ac_status" >&5 (exit $ac_status); }; then if test "$cross_compiling" = no; then if { ac_try='./a.out || ./a.exe || ./conftest' - { (eval echo "$as_me:2858: \"$ac_try\"") >&5 + { (eval echo "$as_me:2933: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:2861: \$? = $ac_status" >&5 + echo "$as_me:2936: \$? = $ac_status" >&5 (exit $ac_status); }; }; then gmp_prog_cc_works=yes fi @@ -2867,7 +2942,7 @@ if { (eval echo "$as_me:2851: \"$gmp_compile\"") >&5 fi fi rm -f conftest* a.out a.exe -echo "$as_me:2870: result: $gmp_prog_cc_works" >&5 +echo "$as_me:2945: result: $gmp_prog_cc_works" >&5 echo "${ECHO_T}$gmp_prog_cc_works" >&6 if test $gmp_prog_cc_works = yes; then : @@ -2882,7 +2957,7 @@ fi testlist_pass=yes for tst in $testlist; do case $tst in - hpc-hppa-2-0) echo "$as_me:2885: checking whether HP compiler $cc is good for 64-bits" >&5 + hpc-hppa-2-0) echo "$as_me:2960: checking whether HP compiler $cc is good for 64-bits" >&5 echo $ECHO_N "checking whether HP compiler $cc is good for 64-bits... $ECHO_C" >&6 # Bad compiler output: # ccom: HP92453-01 G.10.32.05 HP C Compiler @@ -2925,7 +3000,7 @@ fi gmp_hpc_64bit=$gmp_compare_ge fi -echo "$as_me:2928: result: $gmp_hpc_64bit" >&5 +echo "$as_me:3003: result: $gmp_hpc_64bit" >&5 echo "${ECHO_T}$gmp_hpc_64bit" >&6 if test $gmp_hpc_64bit = yes; then : @@ -2933,7 +3008,7 @@ else testlist_pass=no fi ;; - gcc-arm-umodsi) echo "$as_me:2936: checking whether ARM gcc unsigned division works" >&5 + gcc-arm-umodsi) echo "$as_me:3011: checking whether ARM gcc unsigned division works" >&5 echo $ECHO_N "checking whether ARM gcc unsigned division works... $ECHO_C" >&6 tmp_version=`$cc --version` echo "$tmp_version" >&5 @@ -2945,10 +3020,10 @@ case $tmp_version in : gmp_gcc_arm_umodsi_result=yes ;; esac -echo "$as_me:2948: result: $gmp_gcc_arm_umodsi_result" >&5 +echo "$as_me:3023: result: $gmp_gcc_arm_umodsi_result" >&5 echo "${ECHO_T}$gmp_gcc_arm_umodsi_result" >&6 ;; - gcc-mips-o32) echo "$as_me:2951: checking whether gcc supports o32" >&5 + gcc-mips-o32) echo "$as_me:3026: checking whether gcc supports o32" >&5 echo $ECHO_N "checking whether gcc supports o32... $ECHO_C" >&6 echo 'int x;' >conftest.c echo "$cc -mabi=32 -c conftest.c" >&5 @@ -2963,7 +3038,7 @@ else fi fi rm -f conftest.* -echo "$as_me:2966: result: $result" >&5 +echo "$as_me:3041: result: $result" >&5 echo "${ECHO_T}$result" >&6 if test $result = yes; then : @@ -3001,7 +3076,7 @@ done # C on MS-DOS systems). # if test $found_compiler = no && test -n "$path"; then - { { echo "$as_me:3004: error: could not find a working compiler" >&5 + { { echo "$as_me:3079: error: could not find a working compiler" >&5 echo "$as_me: error: could not find a working compiler" >&2;} { (exit 1); exit 1; }; } fi @@ -3042,17 +3117,17 @@ esac -no-cpp-precomp) # special check, avoiding a warning if test "$ccbase" = gcc; then - echo "$as_me:3045: checking compiler $cc $cflags -no-cpp-precomp" >&5 + echo "$as_me:3120: checking compiler $cc $cflags -no-cpp-precomp" >&5 echo $ECHO_N "checking compiler $cc $cflags -no-cpp-precomp... $ECHO_C" >&6 result=no cat >conftest.c <&5 + if { (eval echo "$as_me:3127: \"$gmp_compile\"") >&5 (eval $gmp_compile) 2>&5 ac_status=$? - echo "$as_me:3055: \$? = $ac_status" >&5 + echo "$as_me:3130: \$? = $ac_status" >&5 (exit $ac_status); }; then if grep "unrecognized option.*-no-cpp-precomp" conftest.out >/dev/null; then : ; else @@ -3061,7 +3136,7 @@ EOF fi cat conftest.out >&5 rm -f conftest* a.out - echo "$as_me:3064: result: $result" >&5 + echo "$as_me:3139: result: $result" >&5 echo "${ECHO_T}$result" >&6 if test "$result" = yes; then cflags="$cflags $flag" @@ -3075,17 +3150,17 @@ fi -Wa,-m*) case $host in alpha*-*-*) - echo "$as_me:3078: checking assembler $cc $cflags $flag" >&5 + echo "$as_me:3153: checking assembler $cc $cflags $flag" >&5 echo $ECHO_N "checking assembler $cc $cflags $flag... $ECHO_C" >&6 result=no cat >conftest.c <&5 +if { (eval echo "$as_me:3160: \"$gmp_compile\"") >&5 (eval $gmp_compile) 2>&5 ac_status=$? - echo "$as_me:3088: \$? = $ac_status" >&5 + echo "$as_me:3163: \$? = $ac_status" >&5 (exit $ac_status); }; then if grep "Unknown CPU identifier" conftest.out >/dev/null; then : ; else @@ -3094,7 +3169,7 @@ if { (eval echo "$as_me:3085: \"$gmp_compile\"") >&5 fi cat conftest.out >&5 rm -f conftest* -echo "$as_me:3097: result: $result" >&5 +echo "$as_me:3172: result: $result" >&5 echo "${ECHO_T}$result" >&6 if test "$result" = yes; then : @@ -3107,7 +3182,7 @@ fi ;; esac - echo "$as_me:3110: checking compiler $cc $cflags $cppflags $flag" >&5 + echo "$as_me:3185: checking compiler $cc $cflags $cppflags $flag" >&5 echo $ECHO_N "checking compiler $cc $cflags $cppflags $flag... $ECHO_C" >&6 cat >conftest.c <&5 +if { (eval echo "$as_me:3213: \"$gmp_compile\"") >&5 (eval $gmp_compile) 2>&5 ac_status=$? - echo "$as_me:3141: \$? = $ac_status" >&5 + echo "$as_me:3216: \$? = $ac_status" >&5 (exit $ac_status); }; then if test "$cross_compiling" = no; then if { ac_try='./a.out || ./a.exe || ./conftest' - { (eval echo "$as_me:3145: \"$ac_try\"") >&5 + { (eval echo "$as_me:3220: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3148: \$? = $ac_status" >&5 + echo "$as_me:3223: \$? = $ac_status" >&5 (exit $ac_status); }; }; then gmp_prog_cc_works=yes fi @@ -3154,7 +3229,7 @@ if { (eval echo "$as_me:3138: \"$gmp_compile\"") >&5 fi fi rm -f conftest* a.out a.exe -echo "$as_me:3157: result: $gmp_prog_cc_works" >&5 +echo "$as_me:3232: result: $gmp_prog_cc_works" >&5 echo "${ECHO_T}$gmp_prog_cc_works" >&6 if test $gmp_prog_cc_works = yes; then cflags="$cflags $flag" @@ -3250,7 +3325,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 -echo "$as_me:3253: checking for $ac_word" >&5 +echo "$as_me:3328: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -3265,7 +3340,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_CC="${ac_tool_prefix}gcc" -echo "$as_me:3268: found $ac_dir/$ac_word" >&5 +echo "$as_me:3343: found $ac_dir/$ac_word" >&5 break done @@ -3273,10 +3348,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:3276: result: $CC" >&5 + echo "$as_me:3351: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else - echo "$as_me:3279: result: no" >&5 + echo "$as_me:3354: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -3285,7 +3360,7 @@ if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -echo "$as_me:3288: checking for $ac_word" >&5 +echo "$as_me:3363: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -3300,7 +3375,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_CC="gcc" -echo "$as_me:3303: found $ac_dir/$ac_word" >&5 +echo "$as_me:3378: found $ac_dir/$ac_word" >&5 break done @@ -3308,10 +3383,10 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:3311: result: $ac_ct_CC" >&5 + echo "$as_me:3386: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else - echo "$as_me:3314: result: no" >&5 + echo "$as_me:3389: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -3324,7 +3399,7 @@ if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 -echo "$as_me:3327: checking for $ac_word" >&5 +echo "$as_me:3402: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -3339,7 +3414,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_CC="${ac_tool_prefix}cc" -echo "$as_me:3342: found $ac_dir/$ac_word" >&5 +echo "$as_me:3417: found $ac_dir/$ac_word" >&5 break done @@ -3347,10 +3422,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:3350: result: $CC" >&5 + echo "$as_me:3425: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else - echo "$as_me:3353: result: no" >&5 + echo "$as_me:3428: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -3359,7 +3434,7 @@ if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -echo "$as_me:3362: checking for $ac_word" >&5 +echo "$as_me:3437: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -3374,7 +3449,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_CC="cc" -echo "$as_me:3377: found $ac_dir/$ac_word" >&5 +echo "$as_me:3452: found $ac_dir/$ac_word" >&5 break done @@ -3382,10 +3457,10 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:3385: result: $ac_ct_CC" >&5 + echo "$as_me:3460: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else - echo "$as_me:3388: result: no" >&5 + echo "$as_me:3463: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -3398,7 +3473,7 @@ fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -echo "$as_me:3401: checking for $ac_word" >&5 +echo "$as_me:3476: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -3418,7 +3493,7 @@ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then continue fi ac_cv_prog_CC="cc" -echo "$as_me:3421: found $ac_dir/$ac_word" >&5 +echo "$as_me:3496: found $ac_dir/$ac_word" >&5 break done @@ -3440,10 +3515,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:3443: result: $CC" >&5 + echo "$as_me:3518: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else - echo "$as_me:3446: result: no" >&5 + echo "$as_me:3521: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -3454,7 +3529,7 @@ if test -z "$CC"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -echo "$as_me:3457: checking for $ac_word" >&5 +echo "$as_me:3532: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -3469,7 +3544,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_CC="$ac_tool_prefix$ac_prog" -echo "$as_me:3472: found $ac_dir/$ac_word" >&5 +echo "$as_me:3547: found $ac_dir/$ac_word" >&5 break done @@ -3477,10 +3552,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - echo "$as_me:3480: result: $CC" >&5 + echo "$as_me:3555: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else - echo "$as_me:3483: result: no" >&5 + echo "$as_me:3558: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -3493,7 +3568,7 @@ if test -z "$CC"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -echo "$as_me:3496: checking for $ac_word" >&5 +echo "$as_me:3571: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -3508,7 +3583,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_CC="$ac_prog" -echo "$as_me:3511: found $ac_dir/$ac_word" >&5 +echo "$as_me:3586: found $ac_dir/$ac_word" >&5 break done @@ -3516,10 +3591,10 @@ fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - echo "$as_me:3519: result: $ac_ct_CC" >&5 + echo "$as_me:3594: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else - echo "$as_me:3522: result: no" >&5 + echo "$as_me:3597: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -3531,32 +3606,32 @@ fi fi -test -z "$CC" && { { echo "$as_me:3534: error: no acceptable cc found in \$PATH" >&5 +test -z "$CC" && { { echo "$as_me:3609: error: no acceptable cc found in \$PATH" >&5 echo "$as_me: error: no acceptable cc found in \$PATH" >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. -echo "$as_me:3539:" \ +echo "$as_me:3614:" \ "checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` -{ (eval echo "$as_me:3542: \"$ac_compiler --version &5\"") >&5 +{ (eval echo "$as_me:3617: \"$ac_compiler --version &5\"") >&5 (eval $ac_compiler --version &5) 2>&5 ac_status=$? - echo "$as_me:3545: \$? = $ac_status" >&5 + echo "$as_me:3620: \$? = $ac_status" >&5 (exit $ac_status); } -{ (eval echo "$as_me:3547: \"$ac_compiler -v &5\"") >&5 +{ (eval echo "$as_me:3622: \"$ac_compiler -v &5\"") >&5 (eval $ac_compiler -v &5) 2>&5 ac_status=$? - echo "$as_me:3550: \$? = $ac_status" >&5 + echo "$as_me:3625: \$? = $ac_status" >&5 (exit $ac_status); } -{ (eval echo "$as_me:3552: \"$ac_compiler -V &5\"") >&5 +{ (eval echo "$as_me:3627: \"$ac_compiler -V &5\"") >&5 (eval $ac_compiler -V &5) 2>&5 ac_status=$? - echo "$as_me:3555: \$? = $ac_status" >&5 + echo "$as_me:3630: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF -#line 3559 "configure" +#line 3634 "configure" #include "confdefs.h" int @@ -3572,13 +3647,13 @@ ac_clean_files="$ac_clean_files a.out a.exe" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -echo "$as_me:3575: checking for C compiler default output" >&5 +echo "$as_me:3650: checking for C compiler default output" >&5 echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6 ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` -if { (eval echo "$as_me:3578: \"$ac_link_default\"") >&5 +if { (eval echo "$as_me:3653: \"$ac_link_default\"") >&5 (eval $ac_link_default) 2>&5 ac_status=$? - echo "$as_me:3581: \$? = $ac_status" >&5 + echo "$as_me:3656: \$? = $ac_status" >&5 (exit $ac_status); }; then # Find the output, starting from the most likely. This scheme is # not robust to junk in `.', hence go to wildcards (a.*) only as a last @@ -3601,34 +3676,34 @@ done else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 -{ { echo "$as_me:3604: error: C compiler cannot create executables" >&5 +{ { echo "$as_me:3679: error: C compiler cannot create executables" >&5 echo "$as_me: error: C compiler cannot create executables" >&2;} { (exit 77); exit 77; }; } fi ac_exeext=$ac_cv_exeext -echo "$as_me:3610: result: $ac_file" >&5 +echo "$as_me:3685: result: $ac_file" >&5 echo "${ECHO_T}$ac_file" >&6 # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -echo "$as_me:3615: checking whether the C compiler works" >&5 +echo "$as_me:3690: checking whether the C compiler works" >&5 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' - { (eval echo "$as_me:3621: \"$ac_try\"") >&5 + { (eval echo "$as_me:3696: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3624: \$? = $ac_status" >&5 + echo "$as_me:3699: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else - { { echo "$as_me:3631: error: cannot run C compiled programs. + { { echo "$as_me:3706: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'." >&5 echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'." >&2;} @@ -3636,24 +3711,24 @@ If you meant to cross compile, use \`--host'." >&2;} fi fi fi -echo "$as_me:3639: result: yes" >&5 +echo "$as_me:3714: result: yes" >&5 echo "${ECHO_T}yes" >&6 rm -f a.out a.exe conftest$ac_cv_exeext ac_clean_files=$ac_clean_files_save # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -echo "$as_me:3646: checking whether we are cross compiling" >&5 +echo "$as_me:3721: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 -echo "$as_me:3648: result: $cross_compiling" >&5 +echo "$as_me:3723: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6 -echo "$as_me:3651: checking for executable suffix" >&5 +echo "$as_me:3726: checking for executable suffix" >&5 echo $ECHO_N "checking for executable suffix... $ECHO_C" >&6 -if { (eval echo "$as_me:3653: \"$ac_link\"") >&5 +if { (eval echo "$as_me:3728: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:3656: \$? = $ac_status" >&5 + echo "$as_me:3731: \$? = $ac_status" >&5 (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will @@ -3669,25 +3744,25 @@ for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do esac done else - { { echo "$as_me:3672: error: cannot compute EXEEXT: cannot compile and link" >&5 + { { echo "$as_me:3747: error: cannot compute EXEEXT: cannot compile and link" >&5 echo "$as_me: error: cannot compute EXEEXT: cannot compile and link" >&2;} { (exit 1); exit 1; }; } fi rm -f conftest$ac_cv_exeext -echo "$as_me:3678: result: $ac_cv_exeext" >&5 +echo "$as_me:3753: result: $ac_cv_exeext" >&5 echo "${ECHO_T}$ac_cv_exeext" >&6 rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT -echo "$as_me:3684: checking for object suffix" >&5 +echo "$as_me:3759: checking for object suffix" >&5 echo $ECHO_N "checking for object suffix... $ECHO_C" >&6 if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 3690 "configure" +#line 3765 "configure" #include "confdefs.h" int @@ -3699,10 +3774,10 @@ main () } _ACEOF rm -f conftest.o conftest.obj -if { (eval echo "$as_me:3702: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3777: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3705: \$? = $ac_status" >&5 + echo "$as_me:3780: \$? = $ac_status" >&5 (exit $ac_status); }; then for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do case $ac_file in @@ -3714,24 +3789,24 @@ done else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 -{ { echo "$as_me:3717: error: cannot compute OBJEXT: cannot compile" >&5 +{ { echo "$as_me:3792: error: cannot compute OBJEXT: cannot compile" >&5 echo "$as_me: error: cannot compute OBJEXT: cannot compile" >&2;} { (exit 1); exit 1; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi -echo "$as_me:3724: result: $ac_cv_objext" >&5 +echo "$as_me:3799: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6 OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -echo "$as_me:3728: checking whether we are using the GNU C compiler" >&5 +echo "$as_me:3803: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 3734 "configure" +#line 3809 "configure" #include "confdefs.h" int @@ -3746,16 +3821,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3749: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3824: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3752: \$? = $ac_status" >&5 + echo "$as_me:3827: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3755: \"$ac_try\"") >&5 + { (eval echo "$as_me:3830: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3758: \$? = $ac_status" >&5 + echo "$as_me:3833: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_compiler_gnu=yes else @@ -3767,19 +3842,19 @@ rm -f conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -echo "$as_me:3770: result: $ac_cv_c_compiler_gnu" >&5 +echo "$as_me:3845: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS CFLAGS="-g" -echo "$as_me:3776: checking whether $CC accepts -g" >&5 +echo "$as_me:3851: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 3782 "configure" +#line 3857 "configure" #include "confdefs.h" int @@ -3791,16 +3866,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3794: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3869: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3797: \$? = $ac_status" >&5 + echo "$as_me:3872: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3800: \"$ac_try\"") >&5 + { (eval echo "$as_me:3875: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3803: \$? = $ac_status" >&5 + echo "$as_me:3878: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cc_g=yes else @@ -3810,7 +3885,7 @@ ac_cv_prog_cc_g=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:3813: result: $ac_cv_prog_cc_g" >&5 +echo "$as_me:3888: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS @@ -3837,16 +3912,16 @@ cat >conftest.$ac_ext <<_ACEOF #endif _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3840: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3915: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3843: \$? = $ac_status" >&5 + echo "$as_me:3918: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3846: \"$ac_try\"") >&5 + { (eval echo "$as_me:3921: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3849: \$? = $ac_status" >&5 + echo "$as_me:3924: \$? = $ac_status" >&5 (exit $ac_status); }; }; then for ac_declaration in \ ''\ @@ -3858,7 +3933,7 @@ if { (eval echo "$as_me:3840: \"$ac_compile\"") >&5 'void exit (int);' do cat >conftest.$ac_ext <<_ACEOF -#line 3861 "configure" +#line 3936 "configure" #include "confdefs.h" #include $ac_declaration @@ -3871,16 +3946,16 @@ exit (42); } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3874: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3949: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3877: \$? = $ac_status" >&5 + echo "$as_me:3952: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3880: \"$ac_try\"") >&5 + { (eval echo "$as_me:3955: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3883: \$? = $ac_status" >&5 + echo "$as_me:3958: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -3890,7 +3965,7 @@ continue fi rm -f conftest.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF -#line 3893 "configure" +#line 3968 "configure" #include "confdefs.h" $ac_declaration int @@ -3902,16 +3977,16 @@ exit (42); } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:3905: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:3980: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:3908: \$? = $ac_status" >&5 + echo "$as_me:3983: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:3911: \"$ac_try\"") >&5 + { (eval echo "$as_me:3986: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:3914: \$? = $ac_status" >&5 + echo "$as_me:3989: \$? = $ac_status" >&5 (exit $ac_status); }; }; then break else @@ -3946,7 +4021,7 @@ doit: @echo done END # If we don't find an include directive, just comment out the code. -echo "$as_me:3949: checking for style of include used by $am_make" >&5 +echo "$as_me:4024: checking for style of include used by $am_make" >&5 echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6 am__include='#' am__quote= @@ -3973,13 +4048,13 @@ if test "$am__include" = "#"; then fi fi -echo "$as_me:3976: result: $_am_result" >&5 +echo "$as_me:4051: result: $_am_result" >&5 echo "${ECHO_T}$_am_result" >&6 rm -f confinc confmf depcc="$CC" am_compiler_list= -echo "$as_me:3982: checking dependency style of $depcc" >&5 +echo "$as_me:4057: checking dependency style of $depcc" >&5 echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -4041,11 +4116,11 @@ else fi fi -echo "$as_me:4044: result: $am_cv_CC_dependencies_compiler_type" >&5 +echo "$as_me:4119: result: $am_cv_CC_dependencies_compiler_type" >&5 echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6 CCDEPMODE="depmode=$am_cv_CC_dependencies_compiler_type" -echo "$as_me:4048: checking for $CC option to accept ANSI C" >&5 +echo "$as_me:4123: checking for $CC option to accept ANSI C" >&5 echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 if test "${ac_cv_prog_cc_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -4053,7 +4128,7 @@ else ac_cv_prog_cc_stdc=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF -#line 4056 "configure" +#line 4131 "configure" #include "confdefs.h" #include #include @@ -4102,16 +4177,16 @@ for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIO do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext -if { (eval echo "$as_me:4105: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4180: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4108: \$? = $ac_status" >&5 + echo "$as_me:4183: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:4111: \"$ac_try\"") >&5 + { (eval echo "$as_me:4186: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4114: \$? = $ac_status" >&5 + echo "$as_me:4189: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cc_stdc=$ac_arg break @@ -4128,10 +4203,10 @@ fi case "x$ac_cv_prog_cc_stdc" in x|xno) - echo "$as_me:4131: result: none needed" >&5 + echo "$as_me:4206: result: none needed" >&5 echo "${ECHO_T}none needed" >&6 ;; *) - echo "$as_me:4134: result: $ac_cv_prog_cc_stdc" >&5 + echo "$as_me:4209: result: $ac_cv_prog_cc_stdc" >&5 echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 CC="$CC $ac_cv_prog_cc_stdc" ;; esac @@ -4141,7 +4216,7 @@ ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu -echo "$as_me:4144: checking how to run the C preprocessor" >&5 +echo "$as_me:4219: checking how to run the C preprocessor" >&5 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then @@ -4162,18 +4237,18 @@ do # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF -#line 4165 "configure" +#line 4240 "configure" #include "confdefs.h" #include Syntax error _ACEOF -if { (eval echo "$as_me:4170: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:4245: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:4176: \$? = $ac_status" >&5 + echo "$as_me:4251: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -4196,17 +4271,17 @@ rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF -#line 4199 "configure" +#line 4274 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:4203: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:4278: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:4209: \$? = $ac_status" >&5 + echo "$as_me:4284: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -4243,7 +4318,7 @@ fi else ac_cv_prog_CPP=$CPP fi -echo "$as_me:4246: result: $CPP" >&5 +echo "$as_me:4321: result: $CPP" >&5 echo "${ECHO_T}$CPP" >&6 ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes @@ -4253,18 +4328,18 @@ do # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF -#line 4256 "configure" +#line 4331 "configure" #include "confdefs.h" #include Syntax error _ACEOF -if { (eval echo "$as_me:4261: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:4336: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:4267: \$? = $ac_status" >&5 + echo "$as_me:4342: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -4287,17 +4362,17 @@ rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF -#line 4290 "configure" +#line 4365 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:4294: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:4369: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:4300: \$? = $ac_status" >&5 + echo "$as_me:4375: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -4325,7 +4400,7 @@ rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else - { { echo "$as_me:4328: error: C preprocessor \"$CPP\" fails sanity check" >&5 + { { echo "$as_me:4403: error: C preprocessor \"$CPP\" fails sanity check" >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&2;} { (exit 1); exit 1; }; } fi @@ -4341,7 +4416,7 @@ case $ac_cv_prog_cc_stdc in ;; *) cat >conftest.$ac_ext <<_ACEOF -#line 4344 "configure" +#line 4419 "configure" #include "confdefs.h" #define __GMP_WITHIN_CONFIGURE 1 /* ignore template stuff */ #define GMP_NAIL_BITS $GMP_NAIL_BITS @@ -4363,22 +4438,22 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:4366: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4441: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4369: \$? = $ac_status" >&5 + echo "$as_me:4444: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:4372: \"$ac_try\"") >&5 + { (eval echo "$as_me:4447: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4375: \$? = $ac_status" >&5 + echo "$as_me:4450: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 -{ echo "$as_me:4381: WARNING: gmp.h doesnt recognise compiler as ANSI, prototypes and \"const\" will be unavailable" >&5 +{ echo "$as_me:4456: WARNING: gmp.h doesnt recognise compiler as ANSI, prototypes and \"const\" will be unavailable" >&5 echo "$as_me: WARNING: gmp.h doesnt recognise compiler as ANSI, prototypes and \"const\" will be unavailable" >&2;} fi rm -f conftest.$ac_objext conftest.$ac_ext @@ -4399,7 +4474,7 @@ if test -n "$ac_tool_prefix"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -echo "$as_me:4402: checking for $ac_word" >&5 +echo "$as_me:4477: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -4414,7 +4489,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" -echo "$as_me:4417: found $ac_dir/$ac_word" >&5 +echo "$as_me:4492: found $ac_dir/$ac_word" >&5 break done @@ -4422,10 +4497,10 @@ fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then - echo "$as_me:4425: result: $CXX" >&5 + echo "$as_me:4500: result: $CXX" >&5 echo "${ECHO_T}$CXX" >&6 else - echo "$as_me:4428: result: no" >&5 + echo "$as_me:4503: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -4438,7 +4513,7 @@ if test -z "$CXX"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -echo "$as_me:4441: checking for $ac_word" >&5 +echo "$as_me:4516: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -4453,7 +4528,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_CXX="$ac_prog" -echo "$as_me:4456: found $ac_dir/$ac_word" >&5 +echo "$as_me:4531: found $ac_dir/$ac_word" >&5 break done @@ -4461,10 +4536,10 @@ fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then - echo "$as_me:4464: result: $ac_ct_CXX" >&5 + echo "$as_me:4539: result: $ac_ct_CXX" >&5 echo "${ECHO_T}$ac_ct_CXX" >&6 else - echo "$as_me:4467: result: no" >&5 + echo "$as_me:4542: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -4476,32 +4551,32 @@ test -n "$ac_ct_CXX" || ac_ct_CXX="g++" fi # Provide some information about the compiler. -echo "$as_me:4479:" \ +echo "$as_me:4554:" \ "checking for C++ compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` -{ (eval echo "$as_me:4482: \"$ac_compiler --version &5\"") >&5 +{ (eval echo "$as_me:4557: \"$ac_compiler --version &5\"") >&5 (eval $ac_compiler --version &5) 2>&5 ac_status=$? - echo "$as_me:4485: \$? = $ac_status" >&5 + echo "$as_me:4560: \$? = $ac_status" >&5 (exit $ac_status); } -{ (eval echo "$as_me:4487: \"$ac_compiler -v &5\"") >&5 +{ (eval echo "$as_me:4562: \"$ac_compiler -v &5\"") >&5 (eval $ac_compiler -v &5) 2>&5 ac_status=$? - echo "$as_me:4490: \$? = $ac_status" >&5 + echo "$as_me:4565: \$? = $ac_status" >&5 (exit $ac_status); } -{ (eval echo "$as_me:4492: \"$ac_compiler -V &5\"") >&5 +{ (eval echo "$as_me:4567: \"$ac_compiler -V &5\"") >&5 (eval $ac_compiler -V &5) 2>&5 ac_status=$? - echo "$as_me:4495: \$? = $ac_status" >&5 + echo "$as_me:4570: \$? = $ac_status" >&5 (exit $ac_status); } -echo "$as_me:4498: checking whether we are using the GNU C++ compiler" >&5 +echo "$as_me:4573: checking whether we are using the GNU C++ compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6 if test "${ac_cv_cxx_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 4504 "configure" +#line 4579 "configure" #include "confdefs.h" int @@ -4516,16 +4591,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:4519: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4594: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4522: \$? = $ac_status" >&5 + echo "$as_me:4597: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:4525: \"$ac_try\"") >&5 + { (eval echo "$as_me:4600: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4528: \$? = $ac_status" >&5 + echo "$as_me:4603: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_compiler_gnu=yes else @@ -4537,19 +4612,19 @@ rm -f conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi -echo "$as_me:4540: result: $ac_cv_cxx_compiler_gnu" >&5 +echo "$as_me:4615: result: $ac_cv_cxx_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6 GXX=`test $ac_compiler_gnu = yes && echo yes` ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS CXXFLAGS="-g" -echo "$as_me:4546: checking whether $CXX accepts -g" >&5 +echo "$as_me:4621: checking whether $CXX accepts -g" >&5 echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cxx_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 4552 "configure" +#line 4627 "configure" #include "confdefs.h" int @@ -4561,16 +4636,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:4564: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4639: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4567: \$? = $ac_status" >&5 + echo "$as_me:4642: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:4570: \"$ac_try\"") >&5 + { (eval echo "$as_me:4645: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4573: \$? = $ac_status" >&5 + echo "$as_me:4648: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cxx_g=yes else @@ -4580,7 +4655,7 @@ ac_cv_prog_cxx_g=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:4583: result: $ac_cv_prog_cxx_g" >&5 +echo "$as_me:4658: result: $ac_cv_prog_cxx_g" >&5 echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6 if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS @@ -4607,7 +4682,7 @@ for ac_declaration in \ 'void exit (int);' do cat >conftest.$ac_ext <<_ACEOF -#line 4610 "configure" +#line 4685 "configure" #include "confdefs.h" #include $ac_declaration @@ -4620,16 +4695,16 @@ exit (42); } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:4623: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4698: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4626: \$? = $ac_status" >&5 + echo "$as_me:4701: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:4629: \"$ac_try\"") >&5 + { (eval echo "$as_me:4704: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4632: \$? = $ac_status" >&5 + echo "$as_me:4707: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -4639,7 +4714,7 @@ continue fi rm -f conftest.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF -#line 4642 "configure" +#line 4717 "configure" #include "confdefs.h" $ac_declaration int @@ -4651,16 +4726,16 @@ exit (42); } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:4654: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:4729: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:4657: \$? = $ac_status" >&5 + echo "$as_me:4732: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:4660: \"$ac_try\"") >&5 + { (eval echo "$as_me:4735: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:4663: \$? = $ac_status" >&5 + echo "$as_me:4738: \$? = $ac_status" >&5 (exit $ac_status); }; }; then break else @@ -4684,7 +4759,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CXX" am_compiler_list= -echo "$as_me:4687: checking dependency style of $depcc" >&5 +echo "$as_me:4762: checking dependency style of $depcc" >&5 echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -4746,7 +4821,7 @@ else fi fi -echo "$as_me:4749: result: $am_cv_CXX_dependencies_compiler_type" >&5 +echo "$as_me:4824: result: $am_cv_CXX_dependencies_compiler_type" >&5 echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6 CXXDEPMODE="depmode=$am_cv_CXX_dependencies_compiler_type" @@ -4774,7 +4849,7 @@ CXXDEPMODE="depmode=$am_cv_CXX_dependencies_compiler_type" # for cxxflags_choice in $cxxflags_list; do eval CXXFLAGS=\"\$cxxflags_$cxxflags_choice\" - echo "$as_me:4777: checking C++ compiler $CXX $CXXFLAGS" >&5 + echo "$as_me:4852: checking C++ compiler $CXX $CXXFLAGS" >&5 echo $ECHO_N "checking C++ compiler $CXX $CXXFLAGS... $ECHO_C" >&6 cat >conftest.cc < @@ -4789,19 +4864,19 @@ main (void) EOF gmp_cxxcompile="$CXX $CXXFLAGS conftest.cc -o conftest >&5" -if { (eval echo "$as_me:4792: \"$gmp_cxxcompile\"") >&5 +if { (eval echo "$as_me:4867: \"$gmp_cxxcompile\"") >&5 (eval $gmp_cxxcompile) 2>&5 ac_status=$? - echo "$as_me:4795: \$? = $ac_status" >&5 + echo "$as_me:4870: \$? = $ac_status" >&5 (exit $ac_status); }; then rm -f conftest* - echo "$as_me:4798: result: yes" >&5 + echo "$as_me:4873: result: yes" >&5 echo "${ECHO_T}yes" >&6 want_cxx=yes break else rm -f conftest* - echo "$as_me:4804: result: no" >&5 + echo "$as_me:4879: result: no" >&5 echo "${ECHO_T}no" >&6 : fi @@ -4810,7 +4885,7 @@ fi # If --enable-cxx=yes but a C++ compiler can't be found, then abort. if test $want_cxx = no && test $enable_cxx = yes; then - { { echo "$as_me:4813: error: C++ compiler not available" >&5 + { { echo "$as_me:4888: error: C++ compiler not available" >&5 echo "$as_me: error: C++ compiler not available" >&2;} { (exit 1); exit 1; }; } fi @@ -4835,7 +4910,7 @@ ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -echo "$as_me:4838: checking how to run the C++ preprocessor" >&5 +echo "$as_me:4913: checking how to run the C++ preprocessor" >&5 echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6 if test -z "$CXXCPP"; then if test "${ac_cv_prog_CXXCPP+set}" = set; then @@ -4852,18 +4927,18 @@ do # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF -#line 4855 "configure" +#line 4930 "configure" #include "confdefs.h" #include Syntax error _ACEOF -if { (eval echo "$as_me:4860: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:4935: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:4866: \$? = $ac_status" >&5 + echo "$as_me:4941: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_cxx_preproc_warn_flag @@ -4886,17 +4961,17 @@ rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF -#line 4889 "configure" +#line 4964 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:4893: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:4968: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:4899: \$? = $ac_status" >&5 + echo "$as_me:4974: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_cxx_preproc_warn_flag @@ -4933,7 +5008,7 @@ fi else ac_cv_prog_CXXCPP=$CXXCPP fi -echo "$as_me:4936: result: $CXXCPP" >&5 +echo "$as_me:5011: result: $CXXCPP" >&5 echo "${ECHO_T}$CXXCPP" >&6 ac_preproc_ok=false for ac_cxx_preproc_warn_flag in '' yes @@ -4943,18 +5018,18 @@ do # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF -#line 4946 "configure" +#line 5021 "configure" #include "confdefs.h" #include Syntax error _ACEOF -if { (eval echo "$as_me:4951: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:5026: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:4957: \$? = $ac_status" >&5 + echo "$as_me:5032: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_cxx_preproc_warn_flag @@ -4977,17 +5052,17 @@ rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF -#line 4980 "configure" +#line 5055 "configure" #include "confdefs.h" #include _ACEOF -if { (eval echo "$as_me:4984: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:5059: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:4990: \$? = $ac_status" >&5 + echo "$as_me:5065: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_cxx_preproc_warn_flag @@ -5015,7 +5090,7 @@ rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else - { { echo "$as_me:5018: error: C++ preprocessor \"$CXXCPP\" fails sanity check" >&5 + { { echo "$as_me:5093: error: C++ preprocessor \"$CXXCPP\" fails sanity check" >&5 echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check" >&2;} { (exit 1); exit 1; }; } fi @@ -5032,7 +5107,7 @@ case $host_cpu in c90 | t90) cat >conftest.$ac_ext <<_ACEOF -#line 5035 "configure" +#line 5110 "configure" #include "confdefs.h" #ifdef _CRAYIEEE yes @@ -5068,7 +5143,7 @@ if test $GMP_NAIL_BITS != 0 && test -z "$MPN_PATH"; then fi cat >&5 <&5 +echo "$as_me:5168: checking for ${CC-cc} option to accept ANSI C" >&5 echo $ECHO_N "checking for ${CC-cc} option to accept ANSI C... $ECHO_C" >&6 if test "${am_cv_prog_cc_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -5108,7 +5183,7 @@ for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIO do CC="$ac_save_CC $ac_arg" cat >conftest.$ac_ext <<_ACEOF -#line 5111 "configure" +#line 5186 "configure" #include "confdefs.h" #include #include @@ -5150,16 +5225,16 @@ return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:5153: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:5228: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:5156: \$? = $ac_status" >&5 + echo "$as_me:5231: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:5159: \"$ac_try\"") >&5 + { (eval echo "$as_me:5234: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:5162: \$? = $ac_status" >&5 + echo "$as_me:5237: \$? = $ac_status" >&5 (exit $ac_status); }; }; then am_cv_prog_cc_stdc="$ac_arg"; break else @@ -5173,10 +5248,10 @@ CC="$ac_save_CC" fi if test -z "$am_cv_prog_cc_stdc"; then - echo "$as_me:5176: result: none needed" >&5 + echo "$as_me:5251: result: none needed" >&5 echo "${ECHO_T}none needed" >&6 else - echo "$as_me:5179: result: $am_cv_prog_cc_stdc" >&5 + echo "$as_me:5254: result: $am_cv_prog_cc_stdc" >&5 echo "${ECHO_T}$am_cv_prog_cc_stdc" >&6 fi case "x$am_cv_prog_cc_stdc" in @@ -5184,10 +5259,10 @@ case "x$am_cv_prog_cc_stdc" in *) CC="$CC $am_cv_prog_cc_stdc" ;; esac -echo "$as_me:5187: checking for function prototypes" >&5 +echo "$as_me:5262: checking for function prototypes" >&5 echo $ECHO_N "checking for function prototypes... $ECHO_C" >&6 if test "$am_cv_prog_cc_stdc" != no; then - echo "$as_me:5190: result: yes" >&5 + echo "$as_me:5265: result: yes" >&5 echo "${ECHO_T}yes" >&6 cat >>confdefs.h <<\EOF @@ -5196,18 +5271,18 @@ EOF U= ANSI2KNR= else - echo "$as_me:5199: result: no" >&5 + echo "$as_me:5274: result: no" >&5 echo "${ECHO_T}no" >&6 U=_ ANSI2KNR=./ansi2knr fi # Ensure some checks needed by ansi2knr itself. -echo "$as_me:5204: checking for ANSI C header files" >&5 +echo "$as_me:5279: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 5210 "configure" +#line 5285 "configure" #include "confdefs.h" #include #include @@ -5215,13 +5290,13 @@ else #include _ACEOF -if { (eval echo "$as_me:5218: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:5293: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:5224: \$? = $ac_status" >&5 + echo "$as_me:5299: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -5243,7 +5318,7 @@ rm -f conftest.err conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF -#line 5246 "configure" +#line 5321 "configure" #include "confdefs.h" #include @@ -5261,7 +5336,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF -#line 5264 "configure" +#line 5339 "configure" #include "confdefs.h" #include @@ -5282,7 +5357,7 @@ if test $ac_cv_header_stdc = yes; then : else cat >conftest.$ac_ext <<_ACEOF -#line 5285 "configure" +#line 5360 "configure" #include "confdefs.h" #include #if ((' ' & 0x0FF) == 0x020) @@ -5308,15 +5383,15 @@ main () } _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:5311: \"$ac_link\"") >&5 +if { (eval echo "$as_me:5386: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:5314: \$? = $ac_status" >&5 + echo "$as_me:5389: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:5316: \"$ac_try\"") >&5 + { (eval echo "$as_me:5391: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:5319: \$? = $ac_status" >&5 + echo "$as_me:5394: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -5329,7 +5404,7 @@ rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi -echo "$as_me:5332: result: $ac_cv_header_stdc" >&5 +echo "$as_me:5407: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6 if test $ac_cv_header_stdc = yes; then @@ -5342,23 +5417,23 @@ fi for ac_header in string.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -echo "$as_me:5345: checking for $ac_header" >&5 +echo "$as_me:5420: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 5351 "configure" +#line 5426 "configure" #include "confdefs.h" #include <$ac_header> _ACEOF -if { (eval echo "$as_me:5355: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:5430: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:5361: \$? = $ac_status" >&5 + echo "$as_me:5436: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -5377,7 +5452,7 @@ else fi rm -f conftest.err conftest.$ac_ext fi -echo "$as_me:5380: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "$as_me:5455: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <&5 +echo "$as_me:5469: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_AR+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -5406,7 +5481,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_AR="${ac_tool_prefix}ar" -echo "$as_me:5409: found $ac_dir/$ac_word" >&5 +echo "$as_me:5484: found $ac_dir/$ac_word" >&5 break done @@ -5414,10 +5489,10 @@ fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then - echo "$as_me:5417: result: $AR" >&5 + echo "$as_me:5492: result: $AR" >&5 echo "${ECHO_T}$AR" >&6 else - echo "$as_me:5420: result: no" >&5 + echo "$as_me:5495: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -5426,7 +5501,7 @@ if test -z "$ac_cv_prog_AR"; then ac_ct_AR=$AR # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 -echo "$as_me:5429: checking for $ac_word" >&5 +echo "$as_me:5504: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_AR+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -5441,7 +5516,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_AR="ar" -echo "$as_me:5444: found $ac_dir/$ac_word" >&5 +echo "$as_me:5519: found $ac_dir/$ac_word" >&5 break done @@ -5450,10 +5525,10 @@ fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then - echo "$as_me:5453: result: $ac_ct_AR" >&5 + echo "$as_me:5528: result: $ac_ct_AR" >&5 echo "${ECHO_T}$ac_ct_AR" >&6 else - echo "$as_me:5456: result: no" >&5 + echo "$as_me:5531: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -5466,10 +5541,10 @@ if test -z "$gmp_user_AR"; then eval arflags=\"\$ar${abi1}_flags\" test -n "$arflags" || eval arflags=\"\$ar${abi2}_flags\" if test -n "$arflags"; then - echo "$as_me:5469: checking for extra ar flags" >&5 + echo "$as_me:5544: checking for extra ar flags" >&5 echo $ECHO_N "checking for extra ar flags... $ECHO_C" >&6 AR="$AR $arflags" - echo "$as_me:5472: result: $arflags" >&5 + echo "$as_me:5547: result: $arflags" >&5 echo "${ECHO_T}$arflags" >&6 fi fi @@ -5478,7 +5553,7 @@ if test -z "$AR_FLAGS"; then fi gmp_user_NM=$NM -echo "$as_me:5481: checking for BSD-compatible nm" >&5 +echo "$as_me:5556: checking for BSD-compatible nm" >&5 echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6 if test "${lt_cv_path_NM+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -5513,7 +5588,7 @@ else test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm fi fi -echo "$as_me:5516: result: $lt_cv_path_NM" >&5 +echo "$as_me:5591: result: $lt_cv_path_NM" >&5 echo "${ECHO_T}$lt_cv_path_NM" >&6 NM="$lt_cv_path_NM" @@ -5529,7 +5604,7 @@ if test -z "$gmp_user_NM" && test -n "$ac_tool_prefix" && test "$NM" = nm; then gmp_save_ac_tool_prefix=$ac_tool_prefix ac_tool_prefix= NM= - echo "$as_me:5532: checking for BSD-compatible nm" >&5 + echo "$as_me:5607: checking for BSD-compatible nm" >&5 echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6 if test "${lt_cv_path_NM+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -5564,7 +5639,7 @@ else test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm fi fi -echo "$as_me:5567: result: $lt_cv_path_NM" >&5 +echo "$as_me:5642: result: $lt_cv_path_NM" >&5 echo "${ECHO_T}$lt_cv_path_NM" >&6 NM="$lt_cv_path_NM" @@ -5575,10 +5650,10 @@ if test -z "$gmp_user_NM"; then eval nmflags=\"\$nm${abi1}_flags\" test -n "$nmflags" || eval nmflags=\"\$nm${abi2}_flags\" if test -n "$nmflags"; then - echo "$as_me:5578: checking for extra nm flags" >&5 + echo "$as_me:5653: checking for extra nm flags" >&5 echo $ECHO_N "checking for extra nm flags... $ECHO_C" >&6 NM="$NM $nmflags" - echo "$as_me:5581: result: $nmflags" >&5 + echo "$as_me:5656: result: $nmflags" >&5 echo "${ECHO_T}$nmflags" >&6 fi fi @@ -5652,7 +5727,7 @@ case $host in fi # Don't allow both static and DLL. if test "$enable_shared" != no && test "$enable_static" != no; then - { { echo "$as_me:5655: error: cannot build both static and DLL, since gmp.h is different for each. + { { echo "$as_me:5730: error: cannot build both static and DLL, since gmp.h is different for each. Use \"--disable-static --enable-shared\" to build just a DLL." >&5 echo "$as_me: error: cannot build both static and DLL, since gmp.h is different for each. Use \"--disable-static --enable-shared\" to build just a DLL." >&2;} @@ -5676,7 +5751,7 @@ case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32*) if test "$cross_compiling" != no && test "$enable_shared" != no; then -echo "$as_me:5679: checking for HOST_CC build system compiler" >&5 +echo "$as_me:5754: checking for HOST_CC build system compiler" >&5 echo $ECHO_N "checking for HOST_CC build system compiler... $ECHO_C" >&6 if test "${gmp_cv_prog_host_cc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -5701,7 +5776,7 @@ EOF done rm -f conftest* if test -z "$gmp_cv_prog_host_cc"; then - { { echo "$as_me:5704: error: cannot find a build system compiler" >&5 + { { echo "$as_me:5779: error: cannot find a build system compiler" >&5 echo "$as_me: error: cannot find a build system compiler" >&2;} { (exit 1); exit 1; }; } fi @@ -5709,7 +5784,7 @@ echo "$as_me: error: cannot find a build system compiler" >&2;} fi fi -echo "$as_me:5712: result: $gmp_cv_prog_host_cc" >&5 +echo "$as_me:5787: result: $gmp_cv_prog_host_cc" >&5 echo "${ECHO_T}$gmp_cv_prog_host_cc" >&6 HOST_CC=$gmp_cv_prog_host_cc @@ -5829,7 +5904,7 @@ fi; ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. - echo "$as_me:5832: checking for ld used by GCC" >&5 + echo "$as_me:5907: checking for ld used by GCC" >&5 echo $ECHO_N "checking for ld used by GCC... $ECHO_C" >&6 case $host in *-*-mingw*) @@ -5859,10 +5934,10 @@ echo $ECHO_N "checking for ld used by GCC... $ECHO_C" >&6 ;; esac elif test "$with_gnu_ld" = yes; then - echo "$as_me:5862: checking for GNU ld" >&5 + echo "$as_me:5937: checking for GNU ld" >&5 echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6 else - echo "$as_me:5865: checking for non-GNU ld" >&5 + echo "$as_me:5940: checking for non-GNU ld" >&5 echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6 fi if test "${lt_cv_path_LD+set}" = set; then @@ -5893,16 +5968,16 @@ fi LD="$lt_cv_path_LD" if test -n "$LD"; then - echo "$as_me:5896: result: $LD" >&5 + echo "$as_me:5971: result: $LD" >&5 echo "${ECHO_T}$LD" >&6 else - echo "$as_me:5899: result: no" >&5 + echo "$as_me:5974: result: no" >&5 echo "${ECHO_T}no" >&6 fi -test -z "$LD" && { { echo "$as_me:5902: error: no acceptable ld found in \$PATH" >&5 +test -z "$LD" && { { echo "$as_me:5977: error: no acceptable ld found in \$PATH" >&5 echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} { (exit 1); exit 1; }; } -echo "$as_me:5905: checking if the linker ($LD) is GNU ld" >&5 +echo "$as_me:5980: checking if the linker ($LD) is GNU ld" >&5 echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6 if test "${lt_cv_prog_gnu_ld+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -5914,18 +5989,18 @@ else lt_cv_prog_gnu_ld=no fi fi -echo "$as_me:5917: result: $lt_cv_prog_gnu_ld" >&5 +echo "$as_me:5992: result: $lt_cv_prog_gnu_ld" >&5 echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6 with_gnu_ld=$lt_cv_prog_gnu_ld -echo "$as_me:5921: checking for $LD option to reload object files" >&5 +echo "$as_me:5996: checking for $LD option to reload object files" >&5 echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6 if test "${lt_cv_ld_reload_flag+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_ld_reload_flag='-r' fi -echo "$as_me:5928: result: $lt_cv_ld_reload_flag" >&5 +echo "$as_me:6003: result: $lt_cv_ld_reload_flag" >&5 echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6 reload_flag=$lt_cv_ld_reload_flag case $reload_flag in @@ -5934,18 +6009,18 @@ case $reload_flag in esac reload_cmds='$LD$reload_flag -o $output$reload_objs' -echo "$as_me:5937: checking whether ln -s works" >&5 +echo "$as_me:6012: checking whether ln -s works" >&5 echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6 LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then - echo "$as_me:5941: result: yes" >&5 + echo "$as_me:6016: result: yes" >&5 echo "${ECHO_T}yes" >&6 else - echo "$as_me:5944: result: no, using $LN_S" >&5 + echo "$as_me:6019: result: no, using $LN_S" >&5 echo "${ECHO_T}no, using $LN_S" >&6 fi -echo "$as_me:5948: checking how to recognise dependant libraries" >&5 +echo "$as_me:6023: checking how to recognise dependant libraries" >&5 echo $ECHO_N "checking how to recognise dependant libraries... $ECHO_C" >&6 if test "${lt_cv_deplibs_check_method+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -6132,7 +6207,7 @@ sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7* | sysv4*uw2*) esac fi -echo "$as_me:6135: result: $lt_cv_deplibs_check_method" >&5 +echo "$as_me:6210: result: $lt_cv_deplibs_check_method" >&5 echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6 file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method @@ -6158,10 +6233,10 @@ case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext - if { (eval echo "$as_me:6161: \"$ac_compile\"") >&5 + if { (eval echo "$as_me:6236: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:6164: \$? = $ac_status" >&5 + echo "$as_me:6239: \$? = $ac_status" >&5 (exit $ac_status); }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) @@ -6176,11 +6251,11 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 6179 "configure"' > conftest.$ac_ext - if { (eval echo "$as_me:6180: \"$ac_compile\"") >&5 + echo '#line 6254 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:6255: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:6183: \$? = $ac_status" >&5 + echo "$as_me:6258: \$? = $ac_status" >&5 (exit $ac_status); }; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) @@ -6201,7 +6276,7 @@ ia64-*-hpux*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" - echo "$as_me:6204: checking whether the C compiler needs -belf" >&5 + echo "$as_me:6279: checking whether the C compiler needs -belf" >&5 echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6 if test "${lt_cv_cc_needs_belf+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -6213,7 +6288,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu cat >conftest.$ac_ext <<_ACEOF -#line 6216 "configure" +#line 6291 "configure" #include "confdefs.h" int @@ -6225,16 +6300,16 @@ main () } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:6228: \"$ac_link\"") >&5 +if { (eval echo "$as_me:6303: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:6231: \$? = $ac_status" >&5 + echo "$as_me:6306: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:6234: \"$ac_try\"") >&5 + { (eval echo "$as_me:6309: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:6237: \$? = $ac_status" >&5 + echo "$as_me:6312: \$? = $ac_status" >&5 (exit $ac_status); }; }; then lt_cv_cc_needs_belf=yes else @@ -6250,7 +6325,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu fi -echo "$as_me:6253: result: $lt_cv_cc_needs_belf" >&5 +echo "$as_me:6328: result: $lt_cv_cc_needs_belf" >&5 echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6 if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf @@ -6261,7 +6336,7 @@ echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6 if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 -echo "$as_me:6264: checking for $ac_word" >&5 +echo "$as_me:6339: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_DLLTOOL+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -6276,7 +6351,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" -echo "$as_me:6279: found $ac_dir/$ac_word" >&5 +echo "$as_me:6354: found $ac_dir/$ac_word" >&5 break done @@ -6284,10 +6359,10 @@ fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then - echo "$as_me:6287: result: $DLLTOOL" >&5 + echo "$as_me:6362: result: $DLLTOOL" >&5 echo "${ECHO_T}$DLLTOOL" >&6 else - echo "$as_me:6290: result: no" >&5 + echo "$as_me:6365: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -6296,7 +6371,7 @@ if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 -echo "$as_me:6299: checking for $ac_word" >&5 +echo "$as_me:6374: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_DLLTOOL+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -6311,7 +6386,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_DLLTOOL="dlltool" -echo "$as_me:6314: found $ac_dir/$ac_word" >&5 +echo "$as_me:6389: found $ac_dir/$ac_word" >&5 break done @@ -6320,10 +6395,10 @@ fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then - echo "$as_me:6323: result: $ac_ct_DLLTOOL" >&5 + echo "$as_me:6398: result: $ac_ct_DLLTOOL" >&5 echo "${ECHO_T}$ac_ct_DLLTOOL" >&6 else - echo "$as_me:6326: result: no" >&5 + echo "$as_me:6401: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -6335,7 +6410,7 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. set dummy ${ac_tool_prefix}as; ac_word=$2 -echo "$as_me:6338: checking for $ac_word" >&5 +echo "$as_me:6413: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_AS+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -6350,7 +6425,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_AS="${ac_tool_prefix}as" -echo "$as_me:6353: found $ac_dir/$ac_word" >&5 +echo "$as_me:6428: found $ac_dir/$ac_word" >&5 break done @@ -6358,10 +6433,10 @@ fi fi AS=$ac_cv_prog_AS if test -n "$AS"; then - echo "$as_me:6361: result: $AS" >&5 + echo "$as_me:6436: result: $AS" >&5 echo "${ECHO_T}$AS" >&6 else - echo "$as_me:6364: result: no" >&5 + echo "$as_me:6439: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -6370,7 +6445,7 @@ if test -z "$ac_cv_prog_AS"; then ac_ct_AS=$AS # Extract the first word of "as", so it can be a program name with args. set dummy as; ac_word=$2 -echo "$as_me:6373: checking for $ac_word" >&5 +echo "$as_me:6448: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_AS+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -6385,7 +6460,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_AS="as" -echo "$as_me:6388: found $ac_dir/$ac_word" >&5 +echo "$as_me:6463: found $ac_dir/$ac_word" >&5 break done @@ -6394,10 +6469,10 @@ fi fi ac_ct_AS=$ac_cv_prog_ac_ct_AS if test -n "$ac_ct_AS"; then - echo "$as_me:6397: result: $ac_ct_AS" >&5 + echo "$as_me:6472: result: $ac_ct_AS" >&5 echo "${ECHO_T}$ac_ct_AS" >&6 else - echo "$as_me:6400: result: no" >&5 + echo "$as_me:6475: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -6409,7 +6484,7 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 -echo "$as_me:6412: checking for $ac_word" >&5 +echo "$as_me:6487: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_OBJDUMP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -6424,7 +6499,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" -echo "$as_me:6427: found $ac_dir/$ac_word" >&5 +echo "$as_me:6502: found $ac_dir/$ac_word" >&5 break done @@ -6432,10 +6507,10 @@ fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then - echo "$as_me:6435: result: $OBJDUMP" >&5 + echo "$as_me:6510: result: $OBJDUMP" >&5 echo "${ECHO_T}$OBJDUMP" >&6 else - echo "$as_me:6438: result: no" >&5 + echo "$as_me:6513: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -6444,7 +6519,7 @@ if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 -echo "$as_me:6447: checking for $ac_word" >&5 +echo "$as_me:6522: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -6459,7 +6534,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_OBJDUMP="objdump" -echo "$as_me:6462: found $ac_dir/$ac_word" >&5 +echo "$as_me:6537: found $ac_dir/$ac_word" >&5 break done @@ -6468,10 +6543,10 @@ fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then - echo "$as_me:6471: result: $ac_ct_OBJDUMP" >&5 + echo "$as_me:6546: result: $ac_ct_OBJDUMP" >&5 echo "${ECHO_T}$ac_ct_OBJDUMP" >&6 else - echo "$as_me:6474: result: no" >&5 + echo "$as_me:6549: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -6482,13 +6557,13 @@ fi # recent cygwin and mingw systems supply a stub DllMain which the user # can override, but on older systems we have to supply one - echo "$as_me:6485: checking if libtool should supply DllMain function" >&5 + echo "$as_me:6560: checking if libtool should supply DllMain function" >&5 echo $ECHO_N "checking if libtool should supply DllMain function... $ECHO_C" >&6 if test "${lt_cv_need_dllmain+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 6491 "configure" +#line 6566 "configure" #include "confdefs.h" int @@ -6501,16 +6576,16 @@ extern int __attribute__((__stdcall__)) DllMain(void*, int, void*); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:6504: \"$ac_link\"") >&5 +if { (eval echo "$as_me:6579: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:6507: \$? = $ac_status" >&5 + echo "$as_me:6582: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:6510: \"$ac_try\"") >&5 + { (eval echo "$as_me:6585: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:6513: \$? = $ac_status" >&5 + echo "$as_me:6588: \$? = $ac_status" >&5 (exit $ac_status); }; }; then lt_cv_need_dllmain=no else @@ -6520,7 +6595,7 @@ lt_cv_need_dllmain=yes fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:6523: result: $lt_cv_need_dllmain" >&5 +echo "$as_me:6598: result: $lt_cv_need_dllmain" >&5 echo "${ECHO_T}$lt_cv_need_dllmain" >&6 case $host/$CC in @@ -6529,13 +6604,13 @@ echo "${ECHO_T}$lt_cv_need_dllmain" >&6 # require "-mdll" SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -mdll" - echo "$as_me:6532: checking how to link DLLs" >&5 + echo "$as_me:6607: checking how to link DLLs" >&5 echo $ECHO_N "checking how to link DLLs... $ECHO_C" >&6 if test "${lt_cv_cc_dll_switch+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 6538 "configure" +#line 6613 "configure" #include "confdefs.h" int @@ -6547,16 +6622,16 @@ main () } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:6550: \"$ac_link\"") >&5 +if { (eval echo "$as_me:6625: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:6553: \$? = $ac_status" >&5 + echo "$as_me:6628: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:6556: \"$ac_try\"") >&5 + { (eval echo "$as_me:6631: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:6559: \$? = $ac_status" >&5 + echo "$as_me:6634: \$? = $ac_status" >&5 (exit $ac_status); }; }; then lt_cv_cc_dll_switch=-mdll else @@ -6566,7 +6641,7 @@ lt_cv_cc_dll_switch=-dll fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:6569: result: $lt_cv_cc_dll_switch" >&5 +echo "$as_me:6644: result: $lt_cv_cc_dll_switch" >&5 echo "${ECHO_T}$lt_cv_cc_dll_switch" >&6 CFLAGS="$SAVE_CFLAGS" ;; *-*-cygwin* | *-*-pw32*) @@ -6583,23 +6658,23 @@ need_locks="$enable_libtool_lock" for ac_header in dlfcn.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -echo "$as_me:6586: checking for $ac_header" >&5 +echo "$as_me:6661: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 6592 "configure" +#line 6667 "configure" #include "confdefs.h" #include <$ac_header> _ACEOF -if { (eval echo "$as_me:6596: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:6671: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:6602: \$? = $ac_status" >&5 + echo "$as_me:6677: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -6618,7 +6693,7 @@ else fi rm -f conftest.err conftest.$ac_ext fi -echo "$as_me:6621: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "$as_me:6696: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <&5 +echo "$as_me:6709: checking the maximum length of command line arguments" >&5 echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6 if test "${lt_cv_sys_max_cmd_len+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -6680,15 +6755,15 @@ else fi if test -n $lt_cv_sys_max_cmd_len ; then - echo "$as_me:6683: result: $lt_cv_sys_max_cmd_len" >&5 + echo "$as_me:6758: result: $lt_cv_sys_max_cmd_len" >&5 echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6 else - echo "$as_me:6686: result: none" >&5 + echo "$as_me:6761: result: none" >&5 echo "${ECHO_T}none" >&6 fi # Check for command to grab the raw symbol name followed by C symbol from nm. -echo "$as_me:6691: checking command to parse $NM output from $compiler object" >&5 +echo "$as_me:6766: checking command to parse $NM output from $compiler object" >&5 echo $ECHO_N "checking command to parse $NM output from $compiler object... $ECHO_C" >&6 if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -6773,17 +6848,17 @@ void nm_test_func(){} int main(){nm_test_var='a';nm_test_func();return(0);} EOF - if { (eval echo "$as_me:6776: \"$ac_compile\"") >&5 + if { (eval echo "$as_me:6851: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:6779: \$? = $ac_status" >&5 + echo "$as_me:6854: \$? = $ac_status" >&5 (exit $ac_status); }; then # Now try to grab the symbols. nlist=conftest.nm - if { (eval echo "$as_me:6783: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5 + if { (eval echo "$as_me:6858: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5 (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5 ac_status=$? - echo "$as_me:6786: \$? = $ac_status" >&5 + echo "$as_me:6861: \$? = $ac_status" >&5 (exit $ac_status); } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then @@ -6835,10 +6910,10 @@ EOF lt_save_CFLAGS="$CFLAGS" LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" - if { (eval echo "$as_me:6838: \"$ac_link\"") >&5 + if { (eval echo "$as_me:6913: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:6841: \$? = $ac_status" >&5 + echo "$as_me:6916: \$? = $ac_status" >&5 (exit $ac_status); } && test -s conftest${ac_exeext}; then pipe_works=yes fi @@ -6873,14 +6948,14 @@ if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then - echo "$as_me:6876: result: failed" >&5 + echo "$as_me:6951: result: failed" >&5 echo "${ECHO_T}failed" >&6 else - echo "$as_me:6879: result: ok" >&5 + echo "$as_me:6954: result: ok" >&5 echo "${ECHO_T}ok" >&6 fi -echo "$as_me:6883: checking for objdir" >&5 +echo "$as_me:6958: checking for objdir" >&5 echo $ECHO_N "checking for objdir... $ECHO_C" >&6 if test "${lt_cv_objdir+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -6895,7 +6970,7 @@ else fi rmdir .libs 2>/dev/null fi -echo "$as_me:6898: result: $lt_cv_objdir" >&5 +echo "$as_me:6973: result: $lt_cv_objdir" >&5 echo "${ECHO_T}$lt_cv_objdir" >&6 objdir=$lt_cv_objdir @@ -6943,7 +7018,7 @@ with_gnu_ld="$lt_cv_prog_gnu_ld" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -echo "$as_me:6946: checking for $ac_word" >&5 +echo "$as_me:7021: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_RANLIB+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -6958,7 +7033,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" -echo "$as_me:6961: found $ac_dir/$ac_word" >&5 +echo "$as_me:7036: found $ac_dir/$ac_word" >&5 break done @@ -6966,10 +7041,10 @@ fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then - echo "$as_me:6969: result: $RANLIB" >&5 + echo "$as_me:7044: result: $RANLIB" >&5 echo "${ECHO_T}$RANLIB" >&6 else - echo "$as_me:6972: result: no" >&5 + echo "$as_me:7047: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -6978,7 +7053,7 @@ if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 -echo "$as_me:6981: checking for $ac_word" >&5 +echo "$as_me:7056: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -6993,7 +7068,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_RANLIB="ranlib" -echo "$as_me:6996: found $ac_dir/$ac_word" >&5 +echo "$as_me:7071: found $ac_dir/$ac_word" >&5 break done @@ -7002,10 +7077,10 @@ fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then - echo "$as_me:7005: result: $ac_ct_RANLIB" >&5 + echo "$as_me:7080: result: $ac_ct_RANLIB" >&5 echo "${ECHO_T}$ac_ct_RANLIB" >&6 else - echo "$as_me:7008: result: no" >&5 + echo "$as_me:7083: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -7017,7 +7092,7 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 -echo "$as_me:7020: checking for $ac_word" >&5 +echo "$as_me:7095: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_STRIP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -7032,7 +7107,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_STRIP="${ac_tool_prefix}strip" -echo "$as_me:7035: found $ac_dir/$ac_word" >&5 +echo "$as_me:7110: found $ac_dir/$ac_word" >&5 break done @@ -7040,10 +7115,10 @@ fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then - echo "$as_me:7043: result: $STRIP" >&5 + echo "$as_me:7118: result: $STRIP" >&5 echo "${ECHO_T}$STRIP" >&6 else - echo "$as_me:7046: result: no" >&5 + echo "$as_me:7121: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -7052,7 +7127,7 @@ if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 -echo "$as_me:7055: checking for $ac_word" >&5 +echo "$as_me:7130: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -7067,7 +7142,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_ac_ct_STRIP="strip" -echo "$as_me:7070: found $ac_dir/$ac_word" >&5 +echo "$as_me:7145: found $ac_dir/$ac_word" >&5 break done @@ -7076,10 +7151,10 @@ fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then - echo "$as_me:7079: result: $ac_ct_STRIP" >&5 + echo "$as_me:7154: result: $ac_ct_STRIP" >&5 echo "${ECHO_T}$ac_ct_STRIP" >&6 else - echo "$as_me:7082: result: no" >&5 + echo "$as_me:7157: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -7128,7 +7203,7 @@ fi case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then - echo "$as_me:7131: checking for ${ac_tool_prefix}file" >&5 + echo "$as_me:7206: checking for ${ac_tool_prefix}file" >&5 echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6 if test "${lt_cv_path_MAGIC_CMD+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -7181,16 +7256,16 @@ fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then - echo "$as_me:7184: result: $MAGIC_CMD" >&5 + echo "$as_me:7259: result: $MAGIC_CMD" >&5 echo "${ECHO_T}$MAGIC_CMD" >&6 else - echo "$as_me:7187: result: no" >&5 + echo "$as_me:7262: result: no" >&5 echo "${ECHO_T}no" >&6 fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then - echo "$as_me:7193: checking for file" >&5 + echo "$as_me:7268: checking for file" >&5 echo $ECHO_N "checking for file... $ECHO_C" >&6 if test "${lt_cv_path_MAGIC_CMD+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -7243,10 +7318,10 @@ fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then - echo "$as_me:7246: result: $MAGIC_CMD" >&5 + echo "$as_me:7321: result: $MAGIC_CMD" >&5 echo "${ECHO_T}$MAGIC_CMD" >&6 else - echo "$as_me:7249: result: no" >&5 + echo "$as_me:7324: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -7319,11 +7394,11 @@ if test "$GCC" = no; then esac fi if test -n "$lt_prog_cc_shlib"; then - { echo "$as_me:7322: WARNING: \`$CC' requires \`$lt_prog_cc_shlib' to build shared libraries" >&5 + { echo "$as_me:7397: WARNING: \`$CC' requires \`$lt_prog_cc_shlib' to build shared libraries" >&5 echo "$as_me: WARNING: \`$CC' requires \`$lt_prog_cc_shlib' to build shared libraries" >&2;} if echo "$old_CC $old_CFLAGS " | egrep -e "[ ]$lt_prog_cc_shlib[ ]" >/dev/null; then : else - { echo "$as_me:7326: WARNING: add \`$lt_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&5 + { echo "$as_me:7401: WARNING: add \`$lt_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&5 echo "$as_me: WARNING: add \`$lt_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&2;} lt_cv_prog_cc_can_build_shared=no fi @@ -7332,7 +7407,7 @@ fi # # Check to make sure the static flag actually works. # -echo "$as_me:7335: checking if $compiler static flag $lt_prog_compiler_static works" >&5 +echo "$as_me:7410: checking if $compiler static flag $lt_prog_compiler_static works" >&5 echo $ECHO_N "checking if $compiler static flag $lt_prog_compiler_static works... $ECHO_C" >&6 if test "${lt_prog_compiler_static_works+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -7355,7 +7430,7 @@ else LDFLAGS="$save_LDFLAGS" fi -echo "$as_me:7358: result: $lt_prog_compiler_static_works" >&5 +echo "$as_me:7433: result: $lt_prog_compiler_static_works" >&5 echo "${ECHO_T}$lt_prog_compiler_static_works" >&6 if test x"$lt_prog_compiler_static_works" = xyes; then @@ -7369,7 +7444,7 @@ lt_prog_compiler_no_builtin_flag= if test "$GCC" = yes; then lt_prog_compiler_no_builtin_flag=' -fno-builtin' - echo "$as_me:7372: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 + echo "$as_me:7447: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6 if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -7394,7 +7469,7 @@ else CFLAGS="$save_CFLAGS" fi -echo "$as_me:7397: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +echo "$as_me:7472: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6 if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then @@ -7409,7 +7484,7 @@ lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= -echo "$as_me:7412: checking for $compiler option to produce PIC" >&5 +echo "$as_me:7487: checking for $compiler option to produce PIC" >&5 echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 if test "$GCC" = yes; then @@ -7562,14 +7637,14 @@ echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 esac fi -echo "$as_me:7565: result: $lt_prog_compiler_pic" >&5 +echo "$as_me:7640: result: $lt_prog_compiler_pic" >&5 echo "${ECHO_T}$lt_prog_compiler_pic" >&6 # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then - echo "$as_me:7572: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 + echo "$as_me:7647: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic works... $ECHO_C" >&6 if test "${lt_prog_compiler_pic_works+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -7594,7 +7669,7 @@ else CFLAGS="$save_CFLAGS" fi -echo "$as_me:7597: result: $lt_prog_compiler_pic_works" >&5 +echo "$as_me:7672: result: $lt_prog_compiler_pic_works" >&5 echo "${ECHO_T}$lt_prog_compiler_pic_works" >&6 if test x"$lt_prog_compiler_pic_works" = xyes; then @@ -7618,7 +7693,7 @@ case "$host_os" in ;; esac -echo "$as_me:7621: checking if $compiler supports -c -o file.$ac_objext" >&5 +echo "$as_me:7696: checking if $compiler supports -c -o file.$ac_objext" >&5 echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 if test "${lt_cv_prog_compiler_c_o+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -7659,13 +7734,13 @@ else $rm conftest* fi -echo "$as_me:7662: result: $lt_cv_prog_compiler_c_o" >&5 +echo "$as_me:7737: result: $lt_cv_prog_compiler_c_o" >&5 echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6 hard_links="nottested" if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user - echo "$as_me:7668: checking if we can lock with hard links" >&5 + echo "$as_me:7743: checking if we can lock with hard links" >&5 echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 hard_links=yes $rm conftest* @@ -7673,10 +7748,10 @@ echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no - echo "$as_me:7676: result: $hard_links" >&5 + echo "$as_me:7751: result: $hard_links" >&5 echo "${ECHO_T}$hard_links" >&6 if test "$hard_links" = no; then - { echo "$as_me:7679: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 + { echo "$as_me:7754: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi @@ -7684,7 +7759,7 @@ else need_locks=no fi -echo "$as_me:7687: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo "$as_me:7762: checking whether the $compiler linker ($LD) supports shared libraries" >&5 echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 runpath_var= @@ -8034,7 +8109,7 @@ EOF allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an empty executable. cat >conftest.$ac_ext <<_ACEOF -#line 8037 "configure" +#line 8112 "configure" #include "confdefs.h" int @@ -8046,16 +8121,16 @@ main () } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:8049: \"$ac_link\"") >&5 +if { (eval echo "$as_me:8124: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:8052: \$? = $ac_status" >&5 + echo "$as_me:8127: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:8055: \"$ac_try\"") >&5 + { (eval echo "$as_me:8130: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:8058: \$? = $ac_status" >&5 + echo "$as_me:8133: \$? = $ac_status" >&5 (exit $ac_status); }; }; then aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } @@ -8080,7 +8155,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi else # Determine the default libpath from the value encoded in an empty executable. cat >conftest.$ac_ext <<_ACEOF -#line 8083 "configure" +#line 8158 "configure" #include "confdefs.h" int @@ -8092,16 +8167,16 @@ main () } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:8095: \"$ac_link\"") >&5 +if { (eval echo "$as_me:8170: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:8098: \$? = $ac_status" >&5 + echo "$as_me:8173: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:8101: \"$ac_try\"") >&5 + { (eval echo "$as_me:8176: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:8104: \$? = $ac_status" >&5 + echo "$as_me:8179: \$? = $ac_status" >&5 (exit $ac_status); }; }; then aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } @@ -8468,7 +8543,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac fi -echo "$as_me:8471: result: $ld_shlibs" >&5 +echo "$as_me:8546: result: $ld_shlibs" >&5 echo "${ECHO_T}$ld_shlibs" >&6 test "$ld_shlibs" = no && can_build_shared=no @@ -8490,15 +8565,15 @@ if test "$enable_shared" = yes && test "$GCC" = yes; then # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. - echo "$as_me:8493: checking whether -lc should be explicitly linked in" >&5 + echo "$as_me:8568: checking whether -lc should be explicitly linked in" >&5 echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 $rm conftest* echo 'static int dummy;' > conftest.$ac_ext - if { (eval echo "$as_me:8498: \"$ac_compile\"") >&5 + if { (eval echo "$as_me:8573: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:8501: \$? = $ac_status" >&5 + echo "$as_me:8576: \$? = $ac_status" >&5 (exit $ac_status); } 2>conftest.err; then soname=conftest lib=conftest @@ -8512,10 +8587,10 @@ echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >& libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= - if { (eval echo "$as_me:8515: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + if { (eval echo "$as_me:8590: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? - echo "$as_me:8518: \$? = $ac_status" >&5 + echo "$as_me:8593: \$? = $ac_status" >&5 (exit $ac_status); } then archive_cmds_need_lc=no @@ -8527,13 +8602,13 @@ echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >& cat conftest.err 1>&5 fi $rm conftest* - echo "$as_me:8530: result: $archive_cmds_need_lc" >&5 + echo "$as_me:8605: result: $archive_cmds_need_lc" >&5 echo "${ECHO_T}$archive_cmds_need_lc" >&6 ;; esac fi -echo "$as_me:8536: checking how to hardcode library paths into programs" >&5 +echo "$as_me:8611: checking how to hardcode library paths into programs" >&5 echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 hardcode_action= if test -n "$hardcode_libdir_flag_spec" || \ @@ -8557,7 +8632,7 @@ else # directories. hardcode_action=unsupported fi -echo "$as_me:8560: result: $hardcode_action" >&5 +echo "$as_me:8635: result: $hardcode_action" >&5 echo "${ECHO_T}$hardcode_action" >&6 if test "$hardcode_action" = relink; then @@ -8571,19 +8646,19 @@ fi striplib= old_striplib= -echo "$as_me:8574: checking whether stripping libraries is possible" >&5 +echo "$as_me:8649: checking whether stripping libraries is possible" >&5 echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" - echo "$as_me:8579: result: yes" >&5 + echo "$as_me:8654: result: yes" >&5 echo "${ECHO_T}yes" >&6 else - echo "$as_me:8582: result: no" >&5 + echo "$as_me:8657: result: no" >&5 echo "${ECHO_T}no" >&6 fi -echo "$as_me:8586: checking dynamic linker characteristics" >&5 +echo "$as_me:8661: checking dynamic linker characteristics" >&5 echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 library_names_spec= libname_spec='lib$name' @@ -9022,7 +9097,7 @@ uts4*) dynamic_linker=no ;; esac -echo "$as_me:9025: result: $dynamic_linker" >&5 +echo "$as_me:9100: result: $dynamic_linker" >&5 echo "${ECHO_T}$dynamic_linker" >&6 test "$dynamic_linker" = no && can_build_shared=no @@ -9047,13 +9122,13 @@ else ;; *) - echo "$as_me:9050: checking for shl_load" >&5 + echo "$as_me:9125: checking for shl_load" >&5 echo $ECHO_N "checking for shl_load... $ECHO_C" >&6 if test "${ac_cv_func_shl_load+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 9056 "configure" +#line 9131 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char shl_load (); below. */ @@ -9084,16 +9159,16 @@ f = shl_load; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:9087: \"$ac_link\"") >&5 +if { (eval echo "$as_me:9162: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:9090: \$? = $ac_status" >&5 + echo "$as_me:9165: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:9093: \"$ac_try\"") >&5 + { (eval echo "$as_me:9168: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:9096: \$? = $ac_status" >&5 + echo "$as_me:9171: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_shl_load=yes else @@ -9103,12 +9178,12 @@ ac_cv_func_shl_load=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:9106: result: $ac_cv_func_shl_load" >&5 +echo "$as_me:9181: result: $ac_cv_func_shl_load" >&5 echo "${ECHO_T}$ac_cv_func_shl_load" >&6 if test $ac_cv_func_shl_load = yes; then lt_cv_dlopen="shl_load" else - echo "$as_me:9111: checking for shl_load in -ldld" >&5 + echo "$as_me:9186: checking for shl_load in -ldld" >&5 echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6 if test "${ac_cv_lib_dld_shl_load+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -9116,7 +9191,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 9119 "configure" +#line 9194 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -9135,16 +9210,16 @@ shl_load (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:9138: \"$ac_link\"") >&5 +if { (eval echo "$as_me:9213: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:9141: \$? = $ac_status" >&5 + echo "$as_me:9216: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:9144: \"$ac_try\"") >&5 + { (eval echo "$as_me:9219: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:9147: \$? = $ac_status" >&5 + echo "$as_me:9222: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dld_shl_load=yes else @@ -9155,18 +9230,18 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:9158: result: $ac_cv_lib_dld_shl_load" >&5 +echo "$as_me:9233: result: $ac_cv_lib_dld_shl_load" >&5 echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6 if test $ac_cv_lib_dld_shl_load = yes; then lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" else - echo "$as_me:9163: checking for dlopen" >&5 + echo "$as_me:9238: checking for dlopen" >&5 echo $ECHO_N "checking for dlopen... $ECHO_C" >&6 if test "${ac_cv_func_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 9169 "configure" +#line 9244 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char dlopen (); below. */ @@ -9197,16 +9272,16 @@ f = dlopen; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:9200: \"$ac_link\"") >&5 +if { (eval echo "$as_me:9275: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:9203: \$? = $ac_status" >&5 + echo "$as_me:9278: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:9206: \"$ac_try\"") >&5 + { (eval echo "$as_me:9281: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:9209: \$? = $ac_status" >&5 + echo "$as_me:9284: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_dlopen=yes else @@ -9216,12 +9291,12 @@ ac_cv_func_dlopen=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:9219: result: $ac_cv_func_dlopen" >&5 +echo "$as_me:9294: result: $ac_cv_func_dlopen" >&5 echo "${ECHO_T}$ac_cv_func_dlopen" >&6 if test $ac_cv_func_dlopen = yes; then lt_cv_dlopen="dlopen" else - echo "$as_me:9224: checking for dlopen in -ldl" >&5 + echo "$as_me:9299: checking for dlopen in -ldl" >&5 echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 if test "${ac_cv_lib_dl_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -9229,7 +9304,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 9232 "configure" +#line 9307 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -9248,16 +9323,16 @@ dlopen (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:9251: \"$ac_link\"") >&5 +if { (eval echo "$as_me:9326: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:9254: \$? = $ac_status" >&5 + echo "$as_me:9329: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:9257: \"$ac_try\"") >&5 + { (eval echo "$as_me:9332: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:9260: \$? = $ac_status" >&5 + echo "$as_me:9335: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dl_dlopen=yes else @@ -9268,12 +9343,12 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:9271: result: $ac_cv_lib_dl_dlopen" >&5 +echo "$as_me:9346: result: $ac_cv_lib_dl_dlopen" >&5 echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 if test $ac_cv_lib_dl_dlopen = yes; then lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else - echo "$as_me:9276: checking for dlopen in -lsvld" >&5 + echo "$as_me:9351: checking for dlopen in -lsvld" >&5 echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6 if test "${ac_cv_lib_svld_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -9281,7 +9356,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 9284 "configure" +#line 9359 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -9300,16 +9375,16 @@ dlopen (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:9303: \"$ac_link\"") >&5 +if { (eval echo "$as_me:9378: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:9306: \$? = $ac_status" >&5 + echo "$as_me:9381: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:9309: \"$ac_try\"") >&5 + { (eval echo "$as_me:9384: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:9312: \$? = $ac_status" >&5 + echo "$as_me:9387: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_svld_dlopen=yes else @@ -9320,12 +9395,12 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:9323: result: $ac_cv_lib_svld_dlopen" >&5 +echo "$as_me:9398: result: $ac_cv_lib_svld_dlopen" >&5 echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6 if test $ac_cv_lib_svld_dlopen = yes; then lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else - echo "$as_me:9328: checking for dld_link in -ldld" >&5 + echo "$as_me:9403: checking for dld_link in -ldld" >&5 echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6 if test "${ac_cv_lib_dld_dld_link+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -9333,7 +9408,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 9336 "configure" +#line 9411 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -9352,16 +9427,16 @@ dld_link (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:9355: \"$ac_link\"") >&5 +if { (eval echo "$as_me:9430: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:9358: \$? = $ac_status" >&5 + echo "$as_me:9433: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:9361: \"$ac_try\"") >&5 + { (eval echo "$as_me:9436: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:9364: \$? = $ac_status" >&5 + echo "$as_me:9439: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dld_dld_link=yes else @@ -9372,7 +9447,7 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:9375: result: $ac_cv_lib_dld_dld_link" >&5 +echo "$as_me:9450: result: $ac_cv_lib_dld_dld_link" >&5 echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6 if test $ac_cv_lib_dld_dld_link = yes; then lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" @@ -9408,7 +9483,7 @@ fi save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" - echo "$as_me:9411: checking whether a program can dlopen itself" >&5 + echo "$as_me:9486: checking whether a program can dlopen itself" >&5 echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6 if test "${lt_cv_dlopen_self+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -9419,7 +9494,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <&5 + if { (eval echo "$as_me:9558: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:9486: \$? = $ac_status" >&5 + echo "$as_me:9561: \$? = $ac_status" >&5 (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) 2>/dev/null lt_status=$? @@ -9500,12 +9575,12 @@ fi rm -fr conftest* fi -echo "$as_me:9503: result: $lt_cv_dlopen_self" >&5 +echo "$as_me:9578: result: $lt_cv_dlopen_self" >&5 echo "${ECHO_T}$lt_cv_dlopen_self" >&6 if test "x$lt_cv_dlopen_self" = xyes; then LDFLAGS="$LDFLAGS $link_static_flag" - echo "$as_me:9508: checking whether a statically linked program can dlopen itself" >&5 + echo "$as_me:9583: checking whether a statically linked program can dlopen itself" >&5 echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6 if test "${lt_cv_dlopen_self_static+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -9516,7 +9591,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <&5 + if { (eval echo "$as_me:9655: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:9583: \$? = $ac_status" >&5 + echo "$as_me:9658: \$? = $ac_status" >&5 (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) 2>/dev/null lt_status=$? @@ -9597,7 +9672,7 @@ fi rm -fr conftest* fi -echo "$as_me:9600: result: $lt_cv_dlopen_self_static" >&5 +echo "$as_me:9675: result: $lt_cv_dlopen_self_static" >&5 echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6 fi @@ -9619,12 +9694,12 @@ echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6 fi # Report which librarie types wil actually be built -echo "$as_me:9622: checking if libtool supports shared libraries" >&5 +echo "$as_me:9697: checking if libtool supports shared libraries" >&5 echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6 -echo "$as_me:9624: result: $can_build_shared" >&5 +echo "$as_me:9699: result: $can_build_shared" >&5 echo "${ECHO_T}$can_build_shared" >&6 -echo "$as_me:9627: checking whether to build shared libraries" >&5 +echo "$as_me:9702: checking whether to build shared libraries" >&5 echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6 test "$can_build_shared" = "no" && enable_shared=no @@ -9645,14 +9720,14 @@ aix4*) fi ;; esac -echo "$as_me:9648: result: $enable_shared" >&5 +echo "$as_me:9723: result: $enable_shared" >&5 echo "${ECHO_T}$enable_shared" >&6 -echo "$as_me:9651: checking whether to build static libraries" >&5 +echo "$as_me:9726: checking whether to build static libraries" >&5 echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6 # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes -echo "$as_me:9655: result: $enable_static" >&5 +echo "$as_me:9730: result: $enable_static" >&5 echo "${ECHO_T}$enable_static" >&6 # The else clause should only fire when bootstrapping the @@ -9732,7 +9807,7 @@ if test -f "$ltmain"; then cfgfile="${ofile}T" trap "$rm \"$cfgfile\"; exit 1" 1 2 15 $rm -f "$cfgfile" - { echo "$as_me:9735: creating $ofile" >&5 + { echo "$as_me:9810: creating $ofile" >&5 echo "$as_me: creating $ofile" >&6;} cat <<__EOF__ >> "$cfgfile" @@ -10290,17 +10365,17 @@ fi; if test -f "$ltmain" && test -n "$tagnames"; then if test ! -f "${ofile}"; then - { echo "$as_me:10293: WARNING: output file \`$ofile' does not exist" >&5 + { echo "$as_me:10368: WARNING: output file \`$ofile' does not exist" >&5 echo "$as_me: WARNING: output file \`$ofile' does not exist" >&2;} fi if test -z "$LTCC"; then eval "`$SHELL ${ofile} --config | grep '^LTCC='`" if test -z "$LTCC"; then - { echo "$as_me:10300: WARNING: output file \`$ofile' does not look like a libtool script" >&5 + { echo "$as_me:10375: WARNING: output file \`$ofile' does not look like a libtool script" >&5 echo "$as_me: WARNING: output file \`$ofile' does not look like a libtool script" >&2;} else - { echo "$as_me:10303: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&5 + { echo "$as_me:10378: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&5 echo "$as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&2;} fi fi @@ -10315,7 +10390,7 @@ echo "$as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&2;} # Check whether tagname contains only valid characters case `$echo "X$tagname" | $Xsed -e 's:[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]::g'` in "") ;; - *) { { echo "$as_me:10318: error: invalid tag name: $tagname" >&5 + *) { { echo "$as_me:10393: error: invalid tag name: $tagname" >&5 echo "$as_me: error: invalid tag name: $tagname" >&2;} { (exit 1); exit 1; }; } ;; @@ -10323,7 +10398,7 @@ echo "$as_me: error: invalid tag name: $tagname" >&2;} if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null then - { { echo "$as_me:10326: error: tag name \"$tagname\" already exists" >&5 + { { echo "$as_me:10401: error: tag name \"$tagname\" already exists" >&5 echo "$as_me: error: tag name \"$tagname\" already exists" >&2;} { (exit 1); exit 1; }; } fi @@ -10450,7 +10525,7 @@ else fi # PORTME: fill in a description of your system's C++ link characteristics -echo "$as_me:10453: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo "$as_me:10528: checking whether the $compiler linker ($LD) supports shared libraries" >&5 echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 ld_shlibs_CXX=yes case $host_os in @@ -10541,7 +10616,7 @@ case $host_os in allow_undefined_flag_CXX='-berok' # Determine the default libpath from the value encoded in an empty executable. cat >conftest.$ac_ext <<_ACEOF -#line 10544 "configure" +#line 10619 "configure" #include "confdefs.h" int @@ -10553,16 +10628,16 @@ main () } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:10556: \"$ac_link\"") >&5 +if { (eval echo "$as_me:10631: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:10559: \$? = $ac_status" >&5 + echo "$as_me:10634: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:10562: \"$ac_try\"") >&5 + { (eval echo "$as_me:10637: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:10565: \$? = $ac_status" >&5 + echo "$as_me:10640: \$? = $ac_status" >&5 (exit $ac_status); }; }; then aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } @@ -10588,7 +10663,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi else # Determine the default libpath from the value encoded in an empty executable. cat >conftest.$ac_ext <<_ACEOF -#line 10591 "configure" +#line 10666 "configure" #include "confdefs.h" int @@ -10600,16 +10675,16 @@ main () } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:10603: \"$ac_link\"") >&5 +if { (eval echo "$as_me:10678: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:10606: \$? = $ac_status" >&5 + echo "$as_me:10681: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:10609: \"$ac_try\"") >&5 + { (eval echo "$as_me:10684: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:10612: \$? = $ac_status" >&5 + echo "$as_me:10687: \$? = $ac_status" >&5 (exit $ac_status); }; }; then aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } @@ -11107,7 +11182,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi ld_shlibs_CXX=no ;; esac -echo "$as_me:11110: result: $ld_shlibs_CXX" >&5 +echo "$as_me:11185: result: $ld_shlibs_CXX" >&5 echo "${ECHO_T}$ld_shlibs_CXX" >&6 test "$ld_shlibs_CXX" = no && can_build_shared=no @@ -11123,10 +11198,10 @@ private: }; EOF -if { (eval echo "$as_me:11126: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:11201: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:11129: \$? = $ac_status" >&5 + echo "$as_me:11204: \$? = $ac_status" >&5 (exit $ac_status); }; then # Parse the compiler output and extract the necessary # objects, libraries and library flags. @@ -11226,7 +11301,7 @@ lt_prog_compiler_wl_CXX= lt_prog_compiler_pic_CXX= lt_prog_compiler_static_CXX= -echo "$as_me:11229: checking for $compiler option to produce PIC" >&5 +echo "$as_me:11304: checking for $compiler option to produce PIC" >&5 echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 # C++ specific cases for pic, static, wl, etc. @@ -11462,14 +11537,14 @@ echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 esac fi -echo "$as_me:11465: result: $lt_prog_compiler_pic_CXX" >&5 +echo "$as_me:11540: result: $lt_prog_compiler_pic_CXX" >&5 echo "${ECHO_T}$lt_prog_compiler_pic_CXX" >&6 # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic_CXX"; then - echo "$as_me:11472: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 + echo "$as_me:11547: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... $ECHO_C" >&6 if test "${lt_prog_compiler_pic_works_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -11494,7 +11569,7 @@ else CFLAGS="$save_CFLAGS" fi -echo "$as_me:11497: result: $lt_prog_compiler_pic_works_CXX" >&5 +echo "$as_me:11572: result: $lt_prog_compiler_pic_works_CXX" >&5 echo "${ECHO_T}$lt_prog_compiler_pic_works_CXX" >&6 if test x"$lt_prog_compiler_pic_works_CXX" = xyes; then @@ -11518,7 +11593,7 @@ case "$host_os" in ;; esac -echo "$as_me:11521: checking if $compiler supports -c -o file.$ac_objext" >&5 +echo "$as_me:11596: checking if $compiler supports -c -o file.$ac_objext" >&5 echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -11559,13 +11634,13 @@ else $rm conftest* fi -echo "$as_me:11562: result: $lt_cv_prog_compiler_c_o_CXX" >&5 +echo "$as_me:11637: result: $lt_cv_prog_compiler_c_o_CXX" >&5 echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6 hard_links="nottested" if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user - echo "$as_me:11568: checking if we can lock with hard links" >&5 + echo "$as_me:11643: checking if we can lock with hard links" >&5 echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 hard_links=yes $rm conftest* @@ -11573,10 +11648,10 @@ echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no - echo "$as_me:11576: result: $hard_links" >&5 + echo "$as_me:11651: result: $hard_links" >&5 echo "${ECHO_T}$hard_links" >&6 if test "$hard_links" = no; then - { echo "$as_me:11579: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 + { echo "$as_me:11654: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi @@ -11584,7 +11659,7 @@ else need_locks=no fi -echo "$as_me:11587: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo "$as_me:11662: checking whether the $compiler linker ($LD) supports shared libraries" >&5 echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols' @@ -11606,7 +11681,7 @@ echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared librar ;; esac -echo "$as_me:11609: result: $ld_shlibs_CXX" >&5 +echo "$as_me:11684: result: $ld_shlibs_CXX" >&5 echo "${ECHO_T}$ld_shlibs_CXX" >&6 test "$ld_shlibs_CXX" = no && can_build_shared=no @@ -11628,15 +11703,15 @@ if test "$enable_shared" = yes && test "$GCC" = yes; then # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. - echo "$as_me:11631: checking whether -lc should be explicitly linked in" >&5 + echo "$as_me:11706: checking whether -lc should be explicitly linked in" >&5 echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 $rm conftest* echo 'static int dummy;' > conftest.$ac_ext - if { (eval echo "$as_me:11636: \"$ac_compile\"") >&5 + if { (eval echo "$as_me:11711: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:11639: \$? = $ac_status" >&5 + echo "$as_me:11714: \$? = $ac_status" >&5 (exit $ac_status); } 2>conftest.err; then soname=conftest lib=conftest @@ -11650,10 +11725,10 @@ echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >& libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag_CXX allow_undefined_flag_CXX= - if { (eval echo "$as_me:11653: \"$archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + if { (eval echo "$as_me:11728: \"$archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 (eval $archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? - echo "$as_me:11656: \$? = $ac_status" >&5 + echo "$as_me:11731: \$? = $ac_status" >&5 (exit $ac_status); } then archive_cmds_need_lc_CXX=no @@ -11665,13 +11740,13 @@ echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >& cat conftest.err 1>&5 fi $rm conftest* - echo "$as_me:11668: result: $archive_cmds_need_lc_CXX" >&5 + echo "$as_me:11743: result: $archive_cmds_need_lc_CXX" >&5 echo "${ECHO_T}$archive_cmds_need_lc_CXX" >&6 ;; esac fi -echo "$as_me:11674: checking how to hardcode library paths into programs" >&5 +echo "$as_me:11749: checking how to hardcode library paths into programs" >&5 echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 hardcode_action_CXX= if test -n "$hardcode_libdir_flag_spec_CXX" || \ @@ -11695,7 +11770,7 @@ else # directories. hardcode_action_CXX=unsupported fi -echo "$as_me:11698: result: $hardcode_action_CXX" >&5 +echo "$as_me:11773: result: $hardcode_action_CXX" >&5 echo "${ECHO_T}$hardcode_action_CXX" >&6 if test "$hardcode_action_CXX" = relink; then @@ -11709,19 +11784,19 @@ fi striplib= old_striplib= -echo "$as_me:11712: checking whether stripping libraries is possible" >&5 +echo "$as_me:11787: checking whether stripping libraries is possible" >&5 echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" - echo "$as_me:11717: result: yes" >&5 + echo "$as_me:11792: result: yes" >&5 echo "${ECHO_T}yes" >&6 else - echo "$as_me:11720: result: no" >&5 + echo "$as_me:11795: result: no" >&5 echo "${ECHO_T}no" >&6 fi -echo "$as_me:11724: checking dynamic linker characteristics" >&5 +echo "$as_me:11799: checking dynamic linker characteristics" >&5 echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 library_names_spec= libname_spec='lib$name' @@ -12160,7 +12235,7 @@ uts4*) dynamic_linker=no ;; esac -echo "$as_me:12163: result: $dynamic_linker" >&5 +echo "$as_me:12238: result: $dynamic_linker" >&5 echo "${ECHO_T}$dynamic_linker" >&6 test "$dynamic_linker" = no && can_build_shared=no @@ -12185,13 +12260,13 @@ else ;; *) - echo "$as_me:12188: checking for shl_load" >&5 + echo "$as_me:12263: checking for shl_load" >&5 echo $ECHO_N "checking for shl_load... $ECHO_C" >&6 if test "${ac_cv_func_shl_load+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 12194 "configure" +#line 12269 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char shl_load (); below. */ @@ -12222,16 +12297,16 @@ f = shl_load; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:12225: \"$ac_link\"") >&5 +if { (eval echo "$as_me:12300: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:12228: \$? = $ac_status" >&5 + echo "$as_me:12303: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:12231: \"$ac_try\"") >&5 + { (eval echo "$as_me:12306: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:12234: \$? = $ac_status" >&5 + echo "$as_me:12309: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_shl_load=yes else @@ -12241,12 +12316,12 @@ ac_cv_func_shl_load=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:12244: result: $ac_cv_func_shl_load" >&5 +echo "$as_me:12319: result: $ac_cv_func_shl_load" >&5 echo "${ECHO_T}$ac_cv_func_shl_load" >&6 if test $ac_cv_func_shl_load = yes; then lt_cv_dlopen="shl_load" else - echo "$as_me:12249: checking for shl_load in -ldld" >&5 + echo "$as_me:12324: checking for shl_load in -ldld" >&5 echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6 if test "${ac_cv_lib_dld_shl_load+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -12254,7 +12329,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 12257 "configure" +#line 12332 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -12273,16 +12348,16 @@ shl_load (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:12276: \"$ac_link\"") >&5 +if { (eval echo "$as_me:12351: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:12279: \$? = $ac_status" >&5 + echo "$as_me:12354: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:12282: \"$ac_try\"") >&5 + { (eval echo "$as_me:12357: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:12285: \$? = $ac_status" >&5 + echo "$as_me:12360: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dld_shl_load=yes else @@ -12293,18 +12368,18 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:12296: result: $ac_cv_lib_dld_shl_load" >&5 +echo "$as_me:12371: result: $ac_cv_lib_dld_shl_load" >&5 echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6 if test $ac_cv_lib_dld_shl_load = yes; then lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" else - echo "$as_me:12301: checking for dlopen" >&5 + echo "$as_me:12376: checking for dlopen" >&5 echo $ECHO_N "checking for dlopen... $ECHO_C" >&6 if test "${ac_cv_func_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 12307 "configure" +#line 12382 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char dlopen (); below. */ @@ -12335,16 +12410,16 @@ f = dlopen; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:12338: \"$ac_link\"") >&5 +if { (eval echo "$as_me:12413: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:12341: \$? = $ac_status" >&5 + echo "$as_me:12416: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:12344: \"$ac_try\"") >&5 + { (eval echo "$as_me:12419: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:12347: \$? = $ac_status" >&5 + echo "$as_me:12422: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_dlopen=yes else @@ -12354,12 +12429,12 @@ ac_cv_func_dlopen=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:12357: result: $ac_cv_func_dlopen" >&5 +echo "$as_me:12432: result: $ac_cv_func_dlopen" >&5 echo "${ECHO_T}$ac_cv_func_dlopen" >&6 if test $ac_cv_func_dlopen = yes; then lt_cv_dlopen="dlopen" else - echo "$as_me:12362: checking for dlopen in -ldl" >&5 + echo "$as_me:12437: checking for dlopen in -ldl" >&5 echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 if test "${ac_cv_lib_dl_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -12367,7 +12442,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 12370 "configure" +#line 12445 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -12386,16 +12461,16 @@ dlopen (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:12389: \"$ac_link\"") >&5 +if { (eval echo "$as_me:12464: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:12392: \$? = $ac_status" >&5 + echo "$as_me:12467: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:12395: \"$ac_try\"") >&5 + { (eval echo "$as_me:12470: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:12398: \$? = $ac_status" >&5 + echo "$as_me:12473: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dl_dlopen=yes else @@ -12406,12 +12481,12 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:12409: result: $ac_cv_lib_dl_dlopen" >&5 +echo "$as_me:12484: result: $ac_cv_lib_dl_dlopen" >&5 echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 if test $ac_cv_lib_dl_dlopen = yes; then lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else - echo "$as_me:12414: checking for dlopen in -lsvld" >&5 + echo "$as_me:12489: checking for dlopen in -lsvld" >&5 echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6 if test "${ac_cv_lib_svld_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -12419,7 +12494,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 12422 "configure" +#line 12497 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -12438,16 +12513,16 @@ dlopen (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:12441: \"$ac_link\"") >&5 +if { (eval echo "$as_me:12516: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:12444: \$? = $ac_status" >&5 + echo "$as_me:12519: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:12447: \"$ac_try\"") >&5 + { (eval echo "$as_me:12522: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:12450: \$? = $ac_status" >&5 + echo "$as_me:12525: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_svld_dlopen=yes else @@ -12458,12 +12533,12 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:12461: result: $ac_cv_lib_svld_dlopen" >&5 +echo "$as_me:12536: result: $ac_cv_lib_svld_dlopen" >&5 echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6 if test $ac_cv_lib_svld_dlopen = yes; then lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else - echo "$as_me:12466: checking for dld_link in -ldld" >&5 + echo "$as_me:12541: checking for dld_link in -ldld" >&5 echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6 if test "${ac_cv_lib_dld_dld_link+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -12471,7 +12546,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 12474 "configure" +#line 12549 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -12490,16 +12565,16 @@ dld_link (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:12493: \"$ac_link\"") >&5 +if { (eval echo "$as_me:12568: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:12496: \$? = $ac_status" >&5 + echo "$as_me:12571: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:12499: \"$ac_try\"") >&5 + { (eval echo "$as_me:12574: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:12502: \$? = $ac_status" >&5 + echo "$as_me:12577: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dld_dld_link=yes else @@ -12510,7 +12585,7 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:12513: result: $ac_cv_lib_dld_dld_link" >&5 +echo "$as_me:12588: result: $ac_cv_lib_dld_dld_link" >&5 echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6 if test $ac_cv_lib_dld_dld_link = yes; then lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" @@ -12546,7 +12621,7 @@ fi save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" - echo "$as_me:12549: checking whether a program can dlopen itself" >&5 + echo "$as_me:12624: checking whether a program can dlopen itself" >&5 echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6 if test "${lt_cv_dlopen_self+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -12557,7 +12632,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <&5 + if { (eval echo "$as_me:12696: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:12624: \$? = $ac_status" >&5 + echo "$as_me:12699: \$? = $ac_status" >&5 (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) 2>/dev/null lt_status=$? @@ -12638,12 +12713,12 @@ fi rm -fr conftest* fi -echo "$as_me:12641: result: $lt_cv_dlopen_self" >&5 +echo "$as_me:12716: result: $lt_cv_dlopen_self" >&5 echo "${ECHO_T}$lt_cv_dlopen_self" >&6 if test "x$lt_cv_dlopen_self" = xyes; then LDFLAGS="$LDFLAGS $link_static_flag" - echo "$as_me:12646: checking whether a statically linked program can dlopen itself" >&5 + echo "$as_me:12721: checking whether a statically linked program can dlopen itself" >&5 echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6 if test "${lt_cv_dlopen_self_static+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -12654,7 +12729,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <&5 + if { (eval echo "$as_me:12793: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:12721: \$? = $ac_status" >&5 + echo "$as_me:12796: \$? = $ac_status" >&5 (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) 2>/dev/null lt_status=$? @@ -12735,7 +12810,7 @@ fi rm -fr conftest* fi -echo "$as_me:12738: result: $lt_cv_dlopen_self_static" >&5 +echo "$as_me:12813: result: $lt_cv_dlopen_self_static" >&5 echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6 fi @@ -13168,7 +13243,7 @@ lt_prog_compiler_no_builtin_flag_GCJ= if test "$GCC" = yes; then lt_prog_compiler_no_builtin_flag_GCJ=' -fno-builtin' - echo "$as_me:13171: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 + echo "$as_me:13246: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6 if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -13193,7 +13268,7 @@ else CFLAGS="$save_CFLAGS" fi -echo "$as_me:13196: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +echo "$as_me:13271: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6 if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then @@ -13208,7 +13283,7 @@ lt_prog_compiler_wl_GCJ= lt_prog_compiler_pic_GCJ= lt_prog_compiler_static_GCJ= -echo "$as_me:13211: checking for $compiler option to produce PIC" >&5 +echo "$as_me:13286: checking for $compiler option to produce PIC" >&5 echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 if test "$GCC" = yes; then @@ -13361,14 +13436,14 @@ echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 esac fi -echo "$as_me:13364: result: $lt_prog_compiler_pic_GCJ" >&5 +echo "$as_me:13439: result: $lt_prog_compiler_pic_GCJ" >&5 echo "${ECHO_T}$lt_prog_compiler_pic_GCJ" >&6 # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic_GCJ"; then - echo "$as_me:13371: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5 + echo "$as_me:13446: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5 echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works... $ECHO_C" >&6 if test "${lt_prog_compiler_pic_works_GCJ+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -13393,7 +13468,7 @@ else CFLAGS="$save_CFLAGS" fi -echo "$as_me:13396: result: $lt_prog_compiler_pic_works_GCJ" >&5 +echo "$as_me:13471: result: $lt_prog_compiler_pic_works_GCJ" >&5 echo "${ECHO_T}$lt_prog_compiler_pic_works_GCJ" >&6 if test x"$lt_prog_compiler_pic_works_GCJ" = xyes; then @@ -13417,7 +13492,7 @@ case "$host_os" in ;; esac -echo "$as_me:13420: checking if $compiler supports -c -o file.$ac_objext" >&5 +echo "$as_me:13495: checking if $compiler supports -c -o file.$ac_objext" >&5 echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 if test "${lt_cv_prog_compiler_c_o_GCJ+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -13458,13 +13533,13 @@ else $rm conftest* fi -echo "$as_me:13461: result: $lt_cv_prog_compiler_c_o_GCJ" >&5 +echo "$as_me:13536: result: $lt_cv_prog_compiler_c_o_GCJ" >&5 echo "${ECHO_T}$lt_cv_prog_compiler_c_o_GCJ" >&6 hard_links="nottested" if test "$lt_cv_prog_compiler_c_o_GCJ" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user - echo "$as_me:13467: checking if we can lock with hard links" >&5 + echo "$as_me:13542: checking if we can lock with hard links" >&5 echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 hard_links=yes $rm conftest* @@ -13472,10 +13547,10 @@ echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no - echo "$as_me:13475: result: $hard_links" >&5 + echo "$as_me:13550: result: $hard_links" >&5 echo "${ECHO_T}$hard_links" >&6 if test "$hard_links" = no; then - { echo "$as_me:13478: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 + { echo "$as_me:13553: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi @@ -13483,7 +13558,7 @@ else need_locks=no fi -echo "$as_me:13486: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo "$as_me:13561: checking whether the $compiler linker ($LD) supports shared libraries" >&5 echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6 runpath_var= @@ -13833,7 +13908,7 @@ EOF allow_undefined_flag_GCJ='-berok' # Determine the default libpath from the value encoded in an empty executable. cat >conftest.$ac_ext <<_ACEOF -#line 13836 "configure" +#line 13911 "configure" #include "confdefs.h" int @@ -13845,16 +13920,16 @@ main () } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:13848: \"$ac_link\"") >&5 +if { (eval echo "$as_me:13923: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:13851: \$? = $ac_status" >&5 + echo "$as_me:13926: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:13854: \"$ac_try\"") >&5 + { (eval echo "$as_me:13929: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:13857: \$? = $ac_status" >&5 + echo "$as_me:13932: \$? = $ac_status" >&5 (exit $ac_status); }; }; then aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } @@ -13879,7 +13954,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi else # Determine the default libpath from the value encoded in an empty executable. cat >conftest.$ac_ext <<_ACEOF -#line 13882 "configure" +#line 13957 "configure" #include "confdefs.h" int @@ -13891,16 +13966,16 @@ main () } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:13894: \"$ac_link\"") >&5 +if { (eval echo "$as_me:13969: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:13897: \$? = $ac_status" >&5 + echo "$as_me:13972: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:13900: \"$ac_try\"") >&5 + { (eval echo "$as_me:13975: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:13903: \$? = $ac_status" >&5 + echo "$as_me:13978: \$? = $ac_status" >&5 (exit $ac_status); }; }; then aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } @@ -14267,7 +14342,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi esac fi -echo "$as_me:14270: result: $ld_shlibs_GCJ" >&5 +echo "$as_me:14345: result: $ld_shlibs_GCJ" >&5 echo "${ECHO_T}$ld_shlibs_GCJ" >&6 test "$ld_shlibs_GCJ" = no && can_build_shared=no @@ -14289,15 +14364,15 @@ if test "$enable_shared" = yes && test "$GCC" = yes; then # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. - echo "$as_me:14292: checking whether -lc should be explicitly linked in" >&5 + echo "$as_me:14367: checking whether -lc should be explicitly linked in" >&5 echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 $rm conftest* echo 'static int dummy;' > conftest.$ac_ext - if { (eval echo "$as_me:14297: \"$ac_compile\"") >&5 + if { (eval echo "$as_me:14372: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:14300: \$? = $ac_status" >&5 + echo "$as_me:14375: \$? = $ac_status" >&5 (exit $ac_status); } 2>conftest.err; then soname=conftest lib=conftest @@ -14311,10 +14386,10 @@ echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >& libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag_GCJ allow_undefined_flag_GCJ= - if { (eval echo "$as_me:14314: \"$archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + if { (eval echo "$as_me:14389: \"$archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 (eval $archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? - echo "$as_me:14317: \$? = $ac_status" >&5 + echo "$as_me:14392: \$? = $ac_status" >&5 (exit $ac_status); } then archive_cmds_need_lc_GCJ=no @@ -14326,13 +14401,13 @@ echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >& cat conftest.err 1>&5 fi $rm conftest* - echo "$as_me:14329: result: $archive_cmds_need_lc_GCJ" >&5 + echo "$as_me:14404: result: $archive_cmds_need_lc_GCJ" >&5 echo "${ECHO_T}$archive_cmds_need_lc_GCJ" >&6 ;; esac fi -echo "$as_me:14335: checking how to hardcode library paths into programs" >&5 +echo "$as_me:14410: checking how to hardcode library paths into programs" >&5 echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 hardcode_action_GCJ= if test -n "$hardcode_libdir_flag_spec_GCJ" || \ @@ -14356,7 +14431,7 @@ else # directories. hardcode_action_GCJ=unsupported fi -echo "$as_me:14359: result: $hardcode_action_GCJ" >&5 +echo "$as_me:14434: result: $hardcode_action_GCJ" >&5 echo "${ECHO_T}$hardcode_action_GCJ" >&6 if test "$hardcode_action_GCJ" = relink; then @@ -14370,19 +14445,19 @@ fi striplib= old_striplib= -echo "$as_me:14373: checking whether stripping libraries is possible" >&5 +echo "$as_me:14448: checking whether stripping libraries is possible" >&5 echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" - echo "$as_me:14378: result: yes" >&5 + echo "$as_me:14453: result: yes" >&5 echo "${ECHO_T}yes" >&6 else - echo "$as_me:14381: result: no" >&5 + echo "$as_me:14456: result: no" >&5 echo "${ECHO_T}no" >&6 fi -echo "$as_me:14385: checking dynamic linker characteristics" >&5 +echo "$as_me:14460: checking dynamic linker characteristics" >&5 echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 library_names_spec= libname_spec='lib$name' @@ -14821,7 +14896,7 @@ uts4*) dynamic_linker=no ;; esac -echo "$as_me:14824: result: $dynamic_linker" >&5 +echo "$as_me:14899: result: $dynamic_linker" >&5 echo "${ECHO_T}$dynamic_linker" >&6 test "$dynamic_linker" = no && can_build_shared=no @@ -14846,13 +14921,13 @@ else ;; *) - echo "$as_me:14849: checking for shl_load" >&5 + echo "$as_me:14924: checking for shl_load" >&5 echo $ECHO_N "checking for shl_load... $ECHO_C" >&6 if test "${ac_cv_func_shl_load+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 14855 "configure" +#line 14930 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char shl_load (); below. */ @@ -14883,16 +14958,16 @@ f = shl_load; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:14886: \"$ac_link\"") >&5 +if { (eval echo "$as_me:14961: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:14889: \$? = $ac_status" >&5 + echo "$as_me:14964: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:14892: \"$ac_try\"") >&5 + { (eval echo "$as_me:14967: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:14895: \$? = $ac_status" >&5 + echo "$as_me:14970: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_shl_load=yes else @@ -14902,12 +14977,12 @@ ac_cv_func_shl_load=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:14905: result: $ac_cv_func_shl_load" >&5 +echo "$as_me:14980: result: $ac_cv_func_shl_load" >&5 echo "${ECHO_T}$ac_cv_func_shl_load" >&6 if test $ac_cv_func_shl_load = yes; then lt_cv_dlopen="shl_load" else - echo "$as_me:14910: checking for shl_load in -ldld" >&5 + echo "$as_me:14985: checking for shl_load in -ldld" >&5 echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6 if test "${ac_cv_lib_dld_shl_load+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -14915,7 +14990,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 14918 "configure" +#line 14993 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -14934,16 +15009,16 @@ shl_load (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:14937: \"$ac_link\"") >&5 +if { (eval echo "$as_me:15012: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:14940: \$? = $ac_status" >&5 + echo "$as_me:15015: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:14943: \"$ac_try\"") >&5 + { (eval echo "$as_me:15018: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:14946: \$? = $ac_status" >&5 + echo "$as_me:15021: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dld_shl_load=yes else @@ -14954,18 +15029,18 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:14957: result: $ac_cv_lib_dld_shl_load" >&5 +echo "$as_me:15032: result: $ac_cv_lib_dld_shl_load" >&5 echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6 if test $ac_cv_lib_dld_shl_load = yes; then lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" else - echo "$as_me:14962: checking for dlopen" >&5 + echo "$as_me:15037: checking for dlopen" >&5 echo $ECHO_N "checking for dlopen... $ECHO_C" >&6 if test "${ac_cv_func_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 14968 "configure" +#line 15043 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char dlopen (); below. */ @@ -14996,16 +15071,16 @@ f = dlopen; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:14999: \"$ac_link\"") >&5 +if { (eval echo "$as_me:15074: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:15002: \$? = $ac_status" >&5 + echo "$as_me:15077: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:15005: \"$ac_try\"") >&5 + { (eval echo "$as_me:15080: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:15008: \$? = $ac_status" >&5 + echo "$as_me:15083: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_dlopen=yes else @@ -15015,12 +15090,12 @@ ac_cv_func_dlopen=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:15018: result: $ac_cv_func_dlopen" >&5 +echo "$as_me:15093: result: $ac_cv_func_dlopen" >&5 echo "${ECHO_T}$ac_cv_func_dlopen" >&6 if test $ac_cv_func_dlopen = yes; then lt_cv_dlopen="dlopen" else - echo "$as_me:15023: checking for dlopen in -ldl" >&5 + echo "$as_me:15098: checking for dlopen in -ldl" >&5 echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 if test "${ac_cv_lib_dl_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -15028,7 +15103,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 15031 "configure" +#line 15106 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -15047,16 +15122,16 @@ dlopen (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:15050: \"$ac_link\"") >&5 +if { (eval echo "$as_me:15125: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:15053: \$? = $ac_status" >&5 + echo "$as_me:15128: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:15056: \"$ac_try\"") >&5 + { (eval echo "$as_me:15131: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:15059: \$? = $ac_status" >&5 + echo "$as_me:15134: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dl_dlopen=yes else @@ -15067,12 +15142,12 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:15070: result: $ac_cv_lib_dl_dlopen" >&5 +echo "$as_me:15145: result: $ac_cv_lib_dl_dlopen" >&5 echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 if test $ac_cv_lib_dl_dlopen = yes; then lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else - echo "$as_me:15075: checking for dlopen in -lsvld" >&5 + echo "$as_me:15150: checking for dlopen in -lsvld" >&5 echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6 if test "${ac_cv_lib_svld_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -15080,7 +15155,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 15083 "configure" +#line 15158 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -15099,16 +15174,16 @@ dlopen (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:15102: \"$ac_link\"") >&5 +if { (eval echo "$as_me:15177: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:15105: \$? = $ac_status" >&5 + echo "$as_me:15180: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:15108: \"$ac_try\"") >&5 + { (eval echo "$as_me:15183: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:15111: \$? = $ac_status" >&5 + echo "$as_me:15186: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_svld_dlopen=yes else @@ -15119,12 +15194,12 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:15122: result: $ac_cv_lib_svld_dlopen" >&5 +echo "$as_me:15197: result: $ac_cv_lib_svld_dlopen" >&5 echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6 if test $ac_cv_lib_svld_dlopen = yes; then lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else - echo "$as_me:15127: checking for dld_link in -ldld" >&5 + echo "$as_me:15202: checking for dld_link in -ldld" >&5 echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6 if test "${ac_cv_lib_dld_dld_link+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -15132,7 +15207,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 15135 "configure" +#line 15210 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -15151,16 +15226,16 @@ dld_link (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:15154: \"$ac_link\"") >&5 +if { (eval echo "$as_me:15229: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:15157: \$? = $ac_status" >&5 + echo "$as_me:15232: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:15160: \"$ac_try\"") >&5 + { (eval echo "$as_me:15235: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:15163: \$? = $ac_status" >&5 + echo "$as_me:15238: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dld_dld_link=yes else @@ -15171,7 +15246,7 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:15174: result: $ac_cv_lib_dld_dld_link" >&5 +echo "$as_me:15249: result: $ac_cv_lib_dld_dld_link" >&5 echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6 if test $ac_cv_lib_dld_dld_link = yes; then lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" @@ -15207,7 +15282,7 @@ fi save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" - echo "$as_me:15210: checking whether a program can dlopen itself" >&5 + echo "$as_me:15285: checking whether a program can dlopen itself" >&5 echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6 if test "${lt_cv_dlopen_self+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -15218,7 +15293,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <&5 + if { (eval echo "$as_me:15357: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:15285: \$? = $ac_status" >&5 + echo "$as_me:15360: \$? = $ac_status" >&5 (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) 2>/dev/null lt_status=$? @@ -15299,12 +15374,12 @@ fi rm -fr conftest* fi -echo "$as_me:15302: result: $lt_cv_dlopen_self" >&5 +echo "$as_me:15377: result: $lt_cv_dlopen_self" >&5 echo "${ECHO_T}$lt_cv_dlopen_self" >&6 if test "x$lt_cv_dlopen_self" = xyes; then LDFLAGS="$LDFLAGS $link_static_flag" - echo "$as_me:15307: checking whether a statically linked program can dlopen itself" >&5 + echo "$as_me:15382: checking whether a statically linked program can dlopen itself" >&5 echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6 if test "${lt_cv_dlopen_self_static+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -15315,7 +15390,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <&5 + if { (eval echo "$as_me:15454: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:15382: \$? = $ac_status" >&5 + echo "$as_me:15457: \$? = $ac_status" >&5 (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) 2>/dev/null lt_status=$? @@ -15396,7 +15471,7 @@ fi rm -fr conftest* fi -echo "$as_me:15399: result: $lt_cv_dlopen_self_static" >&5 +echo "$as_me:15474: result: $lt_cv_dlopen_self_static" >&5 echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6 fi @@ -16196,7 +16271,7 @@ CC="$lt_save_CC" ;; *) - { { echo "$as_me:16199: error: Unsupported tag name: $tagname" >&5 + { { echo "$as_me:16274: error: Unsupported tag name: $tagname" >&5 echo "$as_me: error: Unsupported tag name: $tagname" >&2;} { (exit 1); exit 1; }; } ;; @@ -16214,7 +16289,7 @@ echo "$as_me: error: Unsupported tag name: $tagname" >&2;} chmod +x "$ofile" else rm -f "${ofile}T" - { { echo "$as_me:16217: error: unable to update list of available tagged configurations." >&5 + { { echo "$as_me:16292: error: unable to update list of available tagged configurations." >&5 echo "$as_me: error: unable to update list of available tagged configurations." >&2;} { (exit 1); exit 1; }; } fi @@ -16235,7 +16310,7 @@ LIBTOOL='$(SHELL) $(top_builddir)/libtool' if test "$enable_shared" = yes && test "$enable_static" = yes; then case $library_names_spec in *libname.a*) - { { echo "$as_me:16238: error: cannot create both shared and static libraries on this system, --disable one of the two" >&5 + { { echo "$as_me:16313: error: cannot create both shared and static libraries on this system, --disable one of the two" >&5 echo "$as_me: error: cannot create both shared and static libraries on this system, --disable one of the two" >&2;} { (exit 1); exit 1; }; } ;; @@ -16249,11 +16324,11 @@ fi test -n "$CCAS" || CCAS="$CC -c" case $host in - i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-*) + i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-* | viac3*-*-* | x86_64-*-*) # If there's any sse2 or mmx in the path, check whether the assembler # supports it, and remove if not. case "$path" in - *mmx*) echo "$as_me:16256: checking if the assembler knows about MMX instructions" >&5 + *mmx*) echo "$as_me:16331: checking if the assembler knows about MMX instructions" >&5 echo $ECHO_N "checking if the assembler knows about MMX instructions... $ECHO_C" >&6 if test "${gmp_cv_asm_x86_mmx+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -16263,10 +16338,10 @@ else movq %mm0, %mm1 EOF gmp_assemble="$CCAS $CFLAGS conftest.s >conftest.out 2>&1" -if { (eval echo "$as_me:16266: \"$gmp_assemble\"") >&5 +if { (eval echo "$as_me:16341: \"$gmp_assemble\"") >&5 (eval $gmp_assemble) 2>&5 ac_status=$? - echo "$as_me:16269: \$? = $ac_status" >&5 + echo "$as_me:16344: \$? = $ac_status" >&5 (exit $ac_status); }; then cat conftest.out >&5 gmp_cv_asm_x86_mmx=yes @@ -16277,7 +16352,7 @@ case $host in gmp_cv_asm_x86_mmx=movq-bug fi else - { echo "$as_me:16280: WARNING: \"dis\" not available to check for \"as\" movq bug" >&5 + { echo "$as_me:16355: WARNING: \"dis\" not available to check for \"as\" movq bug" >&5 echo "$as_me: WARNING: \"dis\" not available to check for \"as\" movq bug" >&2;} fi esac @@ -16290,44 +16365,44 @@ fi rm -f conftest* fi -echo "$as_me:16293: result: $gmp_cv_asm_x86_mmx" >&5 +echo "$as_me:16368: result: $gmp_cv_asm_x86_mmx" >&5 echo "${ECHO_T}$gmp_cv_asm_x86_mmx" >&6 case $gmp_cv_asm_x86_mmx in movq-bug) - { echo "$as_me:16298: WARNING: +----------------------------------------------------------" >&5 + { echo "$as_me:16373: WARNING: +----------------------------------------------------------" >&5 echo "$as_me: WARNING: +----------------------------------------------------------" >&2;} - { echo "$as_me:16300: WARNING: | WARNING WARNING WARNING" >&5 + { echo "$as_me:16375: WARNING: | WARNING WARNING WARNING" >&5 echo "$as_me: WARNING: | WARNING WARNING WARNING" >&2;} - { echo "$as_me:16302: WARNING: | Host CPU has MMX code, but the assembler" >&5 + { echo "$as_me:16377: WARNING: | Host CPU has MMX code, but the assembler" >&5 echo "$as_me: WARNING: | Host CPU has MMX code, but the assembler" >&2;} - { echo "$as_me:16304: WARNING: | $CCAS $CFLAGS" >&5 + { echo "$as_me:16379: WARNING: | $CCAS $CFLAGS" >&5 echo "$as_me: WARNING: | $CCAS $CFLAGS" >&2;} - { echo "$as_me:16306: WARNING: | has the Solaris 2.6 and 2.7 bug where register to register" >&5 + { echo "$as_me:16381: WARNING: | has the Solaris 2.6 and 2.7 bug where register to register" >&5 echo "$as_me: WARNING: | has the Solaris 2.6 and 2.7 bug where register to register" >&2;} - { echo "$as_me:16308: WARNING: | movq operands are reversed." >&5 + { echo "$as_me:16383: WARNING: | movq operands are reversed." >&5 echo "$as_me: WARNING: | movq operands are reversed." >&2;} - { echo "$as_me:16310: WARNING: | Non-MMX replacements will be used." >&5 + { echo "$as_me:16385: WARNING: | Non-MMX replacements will be used." >&5 echo "$as_me: WARNING: | Non-MMX replacements will be used." >&2;} - { echo "$as_me:16312: WARNING: | This will be an inferior build." >&5 + { echo "$as_me:16387: WARNING: | This will be an inferior build." >&5 echo "$as_me: WARNING: | This will be an inferior build." >&2;} - { echo "$as_me:16314: WARNING: +----------------------------------------------------------" >&5 + { echo "$as_me:16389: WARNING: +----------------------------------------------------------" >&5 echo "$as_me: WARNING: +----------------------------------------------------------" >&2;} ;; no) - { echo "$as_me:16318: WARNING: +----------------------------------------------------------" >&5 + { echo "$as_me:16393: WARNING: +----------------------------------------------------------" >&5 echo "$as_me: WARNING: +----------------------------------------------------------" >&2;} - { echo "$as_me:16320: WARNING: | WARNING WARNING WARNING" >&5 + { echo "$as_me:16395: WARNING: | WARNING WARNING WARNING" >&5 echo "$as_me: WARNING: | WARNING WARNING WARNING" >&2;} - { echo "$as_me:16322: WARNING: | Host CPU has MMX code, but it can't be assembled by" >&5 + { echo "$as_me:16397: WARNING: | Host CPU has MMX code, but it can't be assembled by" >&5 echo "$as_me: WARNING: | Host CPU has MMX code, but it can't be assembled by" >&2;} - { echo "$as_me:16324: WARNING: | $CCAS $CFLAGS" >&5 + { echo "$as_me:16399: WARNING: | $CCAS $CFLAGS" >&5 echo "$as_me: WARNING: | $CCAS $CFLAGS" >&2;} - { echo "$as_me:16326: WARNING: | Non-MMX replacements will be used." >&5 + { echo "$as_me:16401: WARNING: | Non-MMX replacements will be used." >&5 echo "$as_me: WARNING: | Non-MMX replacements will be used." >&2;} - { echo "$as_me:16328: WARNING: | This will be an inferior build." >&5 + { echo "$as_me:16403: WARNING: | This will be an inferior build." >&5 echo "$as_me: WARNING: | This will be an inferior build." >&2;} - { echo "$as_me:16330: WARNING: +----------------------------------------------------------" >&5 + { echo "$as_me:16405: WARNING: +----------------------------------------------------------" >&5 echo "$as_me: WARNING: +----------------------------------------------------------" >&2;} ;; esac @@ -16347,7 +16422,7 @@ fi ;; esac case "$path" in - *sse2*) echo "$as_me:16350: checking if the assembler knows about SSE2 instructions" >&5 + *sse2*) echo "$as_me:16425: checking if the assembler knows about SSE2 instructions" >&5 echo $ECHO_N "checking if the assembler knows about SSE2 instructions... $ECHO_C" >&6 if test "${gmp_cv_asm_x86_sse2+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -16357,10 +16432,10 @@ else paddq %mm0, %mm1 EOF gmp_assemble="$CCAS $CFLAGS conftest.s >conftest.out 2>&1" -if { (eval echo "$as_me:16360: \"$gmp_assemble\"") >&5 +if { (eval echo "$as_me:16435: \"$gmp_assemble\"") >&5 (eval $gmp_assemble) 2>&5 ac_status=$? - echo "$as_me:16363: \$? = $ac_status" >&5 + echo "$as_me:16438: \$? = $ac_status" >&5 (exit $ac_status); }; then cat conftest.out >&5 gmp_cv_asm_x86_sse2=yes @@ -16373,26 +16448,26 @@ fi rm -f conftest* fi -echo "$as_me:16376: result: $gmp_cv_asm_x86_sse2" >&5 +echo "$as_me:16451: result: $gmp_cv_asm_x86_sse2" >&5 echo "${ECHO_T}$gmp_cv_asm_x86_sse2" >&6 case $gmp_cv_asm_x86_sse2 in yes) : ;; *) - { echo "$as_me:16383: WARNING: +----------------------------------------------------------" >&5 + { echo "$as_me:16458: WARNING: +----------------------------------------------------------" >&5 echo "$as_me: WARNING: +----------------------------------------------------------" >&2;} - { echo "$as_me:16385: WARNING: | WARNING WARNING WARNING" >&5 + { echo "$as_me:16460: WARNING: | WARNING WARNING WARNING" >&5 echo "$as_me: WARNING: | WARNING WARNING WARNING" >&2;} - { echo "$as_me:16387: WARNING: | Host CPU has SSE2 code, but it can't be assembled by" >&5 + { echo "$as_me:16462: WARNING: | Host CPU has SSE2 code, but it can't be assembled by" >&5 echo "$as_me: WARNING: | Host CPU has SSE2 code, but it can't be assembled by" >&2;} - { echo "$as_me:16389: WARNING: | $CCAS $CFLAGS" >&5 + { echo "$as_me:16464: WARNING: | $CCAS $CFLAGS" >&5 echo "$as_me: WARNING: | $CCAS $CFLAGS" >&2;} - { echo "$as_me:16391: WARNING: | Non-SSE2 replacements will be used." >&5 + { echo "$as_me:16466: WARNING: | Non-SSE2 replacements will be used." >&5 echo "$as_me: WARNING: | Non-SSE2 replacements will be used." >&2;} - { echo "$as_me:16393: WARNING: | This will be an inferior build." >&5 + { echo "$as_me:16468: WARNING: | This will be an inferior build." >&5 echo "$as_me: WARNING: | This will be an inferior build." >&2;} - { echo "$as_me:16395: WARNING: +----------------------------------------------------------" >&5 + { echo "$as_me:16470: WARNING: +----------------------------------------------------------" >&5 echo "$as_me: WARNING: +----------------------------------------------------------" >&2;} tmp_path= for i in $path; do @@ -16413,13 +16488,13 @@ esac # The library and header checks are mostly for the benefit of supplementary # programs. libgmp doesn't use anything too weird. -echo "$as_me:16416: checking for ANSI C header files" >&5 +echo "$as_me:16491: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 16422 "configure" +#line 16497 "configure" #include "confdefs.h" #include #include @@ -16427,13 +16502,13 @@ else #include _ACEOF -if { (eval echo "$as_me:16430: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:16505: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:16436: \$? = $ac_status" >&5 + echo "$as_me:16511: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -16455,7 +16530,7 @@ rm -f conftest.err conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF -#line 16458 "configure" +#line 16533 "configure" #include "confdefs.h" #include @@ -16473,7 +16548,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF -#line 16476 "configure" +#line 16551 "configure" #include "confdefs.h" #include @@ -16494,7 +16569,7 @@ if test $ac_cv_header_stdc = yes; then : else cat >conftest.$ac_ext <<_ACEOF -#line 16497 "configure" +#line 16572 "configure" #include "confdefs.h" #include #if ((' ' & 0x0FF) == 0x020) @@ -16520,15 +16595,15 @@ main () } _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:16523: \"$ac_link\"") >&5 +if { (eval echo "$as_me:16598: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:16526: \$? = $ac_status" >&5 + echo "$as_me:16601: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:16528: \"$ac_try\"") >&5 + { (eval echo "$as_me:16603: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:16531: \$? = $ac_status" >&5 + echo "$as_me:16606: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -16541,7 +16616,7 @@ rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi -echo "$as_me:16544: result: $ac_cv_header_stdc" >&5 +echo "$as_me:16619: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6 if test $ac_cv_header_stdc = yes; then @@ -16551,13 +16626,13 @@ EOF fi -echo "$as_me:16554: checking whether time.h and sys/time.h may both be included" >&5 +echo "$as_me:16629: checking whether time.h and sys/time.h may both be included" >&5 echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6 if test "${ac_cv_header_time+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 16560 "configure" +#line 16635 "configure" #include "confdefs.h" #include #include @@ -16573,16 +16648,16 @@ return 0; } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:16576: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:16651: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:16579: \$? = $ac_status" >&5 + echo "$as_me:16654: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:16582: \"$ac_try\"") >&5 + { (eval echo "$as_me:16657: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:16585: \$? = $ac_status" >&5 + echo "$as_me:16660: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_header_time=yes else @@ -16592,7 +16667,7 @@ ac_cv_header_time=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:16595: result: $ac_cv_header_time" >&5 +echo "$as_me:16670: result: $ac_cv_header_time" >&5 echo "${ECHO_T}$ac_cv_header_time" >&6 if test $ac_cv_header_time = yes; then @@ -16618,23 +16693,23 @@ fi for ac_header in fcntl.h locale.h sys/mman.h sys/param.h sys/processor.h sys/resource.h sys/sysctl.h sys/syssgi.h sys/systemcfg.h sys/time.h sys/times.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -echo "$as_me:16621: checking for $ac_header" >&5 +echo "$as_me:16696: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 16627 "configure" +#line 16702 "configure" #include "confdefs.h" #include <$ac_header> _ACEOF -if { (eval echo "$as_me:16631: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:16706: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:16637: \$? = $ac_status" >&5 + echo "$as_me:16712: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -16653,7 +16728,7 @@ else fi rm -f conftest.err conftest.$ac_ext fi -echo "$as_me:16656: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "$as_me:16731: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <&5 +echo "$as_me:16748: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 16679 "configure" +#line 16754 "configure" #include "confdefs.h" $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:16685: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:16760: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:16688: \$? = $ac_status" >&5 + echo "$as_me:16763: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:16691: \"$ac_try\"") >&5 + { (eval echo "$as_me:16766: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:16694: \$? = $ac_status" >&5 + echo "$as_me:16769: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_Header=yes" else @@ -16701,7 +16776,7 @@ eval "$as_ac_Header=no" fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:16704: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "$as_me:16779: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <&5 +echo "$as_me:16789: checking whether fgetc is declared" >&5 echo $ECHO_N "checking whether fgetc is declared... $ECHO_C" >&6 if test "${ac_cv_have_decl_fgetc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 16720 "configure" +#line 16795 "configure" #include "confdefs.h" $ac_includes_default int @@ -16732,16 +16807,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:16735: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:16810: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:16738: \$? = $ac_status" >&5 + echo "$as_me:16813: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:16741: \"$ac_try\"") >&5 + { (eval echo "$as_me:16816: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:16744: \$? = $ac_status" >&5 + echo "$as_me:16819: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_have_decl_fgetc=yes else @@ -16751,7 +16826,7 @@ ac_cv_have_decl_fgetc=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:16754: result: $ac_cv_have_decl_fgetc" >&5 +echo "$as_me:16829: result: $ac_cv_have_decl_fgetc" >&5 echo "${ECHO_T}$ac_cv_have_decl_fgetc" >&6 if test $ac_cv_have_decl_fgetc = yes; then @@ -16765,13 +16840,13 @@ else EOF fi -echo "$as_me:16768: checking whether fscanf is declared" >&5 +echo "$as_me:16843: checking whether fscanf is declared" >&5 echo $ECHO_N "checking whether fscanf is declared... $ECHO_C" >&6 if test "${ac_cv_have_decl_fscanf+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 16774 "configure" +#line 16849 "configure" #include "confdefs.h" $ac_includes_default int @@ -16786,16 +16861,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:16789: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:16864: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:16792: \$? = $ac_status" >&5 + echo "$as_me:16867: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:16795: \"$ac_try\"") >&5 + { (eval echo "$as_me:16870: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:16798: \$? = $ac_status" >&5 + echo "$as_me:16873: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_have_decl_fscanf=yes else @@ -16805,7 +16880,7 @@ ac_cv_have_decl_fscanf=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:16808: result: $ac_cv_have_decl_fscanf" >&5 +echo "$as_me:16883: result: $ac_cv_have_decl_fscanf" >&5 echo "${ECHO_T}$ac_cv_have_decl_fscanf" >&6 if test $ac_cv_have_decl_fscanf = yes; then @@ -16819,13 +16894,13 @@ else EOF fi -echo "$as_me:16822: checking whether optarg is declared" >&5 +echo "$as_me:16897: checking whether optarg is declared" >&5 echo $ECHO_N "checking whether optarg is declared... $ECHO_C" >&6 if test "${ac_cv_have_decl_optarg+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 16828 "configure" +#line 16903 "configure" #include "confdefs.h" $ac_includes_default int @@ -16840,16 +16915,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:16843: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:16918: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:16846: \$? = $ac_status" >&5 + echo "$as_me:16921: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:16849: \"$ac_try\"") >&5 + { (eval echo "$as_me:16924: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:16852: \$? = $ac_status" >&5 + echo "$as_me:16927: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_have_decl_optarg=yes else @@ -16859,7 +16934,7 @@ ac_cv_have_decl_optarg=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:16862: result: $ac_cv_have_decl_optarg" >&5 +echo "$as_me:16937: result: $ac_cv_have_decl_optarg" >&5 echo "${ECHO_T}$ac_cv_have_decl_optarg" >&6 if test $ac_cv_have_decl_optarg = yes; then @@ -16873,13 +16948,13 @@ else EOF fi -echo "$as_me:16876: checking whether ungetc is declared" >&5 +echo "$as_me:16951: checking whether ungetc is declared" >&5 echo $ECHO_N "checking whether ungetc is declared... $ECHO_C" >&6 if test "${ac_cv_have_decl_ungetc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 16882 "configure" +#line 16957 "configure" #include "confdefs.h" $ac_includes_default int @@ -16894,16 +16969,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:16897: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:16972: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:16900: \$? = $ac_status" >&5 + echo "$as_me:16975: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:16903: \"$ac_try\"") >&5 + { (eval echo "$as_me:16978: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:16906: \$? = $ac_status" >&5 + echo "$as_me:16981: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_have_decl_ungetc=yes else @@ -16913,7 +16988,7 @@ ac_cv_have_decl_ungetc=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:16916: result: $ac_cv_have_decl_ungetc" >&5 +echo "$as_me:16991: result: $ac_cv_have_decl_ungetc" >&5 echo "${ECHO_T}$ac_cv_have_decl_ungetc" >&6 if test $ac_cv_have_decl_ungetc = yes; then @@ -16927,13 +17002,13 @@ else EOF fi -echo "$as_me:16930: checking whether vfprintf is declared" >&5 +echo "$as_me:17005: checking whether vfprintf is declared" >&5 echo $ECHO_N "checking whether vfprintf is declared... $ECHO_C" >&6 if test "${ac_cv_have_decl_vfprintf+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 16936 "configure" +#line 17011 "configure" #include "confdefs.h" $ac_includes_default int @@ -16948,16 +17023,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:16951: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:17026: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:16954: \$? = $ac_status" >&5 + echo "$as_me:17029: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:16957: \"$ac_try\"") >&5 + { (eval echo "$as_me:17032: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:16960: \$? = $ac_status" >&5 + echo "$as_me:17035: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_have_decl_vfprintf=yes else @@ -16967,7 +17042,7 @@ ac_cv_have_decl_vfprintf=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:16970: result: $ac_cv_have_decl_vfprintf" >&5 +echo "$as_me:17045: result: $ac_cv_have_decl_vfprintf" >&5 echo "${ECHO_T}$ac_cv_have_decl_vfprintf" >&6 if test $ac_cv_have_decl_vfprintf = yes; then @@ -16982,13 +17057,13 @@ EOF fi -echo "$as_me:16985: checking return type of signal handlers" >&5 +echo "$as_me:17060: checking return type of signal handlers" >&5 echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6 if test "${ac_cv_type_signal+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 16991 "configure" +#line 17066 "configure" #include "confdefs.h" #include #include @@ -17010,16 +17085,16 @@ int i; } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:17013: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:17088: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:17016: \$? = $ac_status" >&5 + echo "$as_me:17091: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:17019: \"$ac_try\"") >&5 + { (eval echo "$as_me:17094: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:17022: \$? = $ac_status" >&5 + echo "$as_me:17097: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_type_signal=void else @@ -17029,7 +17104,7 @@ ac_cv_type_signal=int fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:17032: result: $ac_cv_type_signal" >&5 +echo "$as_me:17107: result: $ac_cv_type_signal" >&5 echo "${ECHO_T}$ac_cv_type_signal" >&6 cat >>confdefs.h <>confdefs.h <&5 +echo "$as_me:17115: checking for intmax_t" >&5 echo $ECHO_N "checking for intmax_t... $ECHO_C" >&6 if test "${ac_cv_type_intmax_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 17046 "configure" +#line 17121 "configure" #include "confdefs.h" $ac_includes_default int @@ -17058,16 +17133,16 @@ if (sizeof (intmax_t)) } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:17061: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:17136: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:17064: \$? = $ac_status" >&5 + echo "$as_me:17139: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:17067: \"$ac_try\"") >&5 + { (eval echo "$as_me:17142: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:17070: \$? = $ac_status" >&5 + echo "$as_me:17145: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_type_intmax_t=yes else @@ -17077,7 +17152,7 @@ ac_cv_type_intmax_t=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:17080: result: $ac_cv_type_intmax_t" >&5 +echo "$as_me:17155: result: $ac_cv_type_intmax_t" >&5 echo "${ECHO_T}$ac_cv_type_intmax_t" >&6 if test $ac_cv_type_intmax_t = yes; then @@ -17086,13 +17161,13 @@ cat >>confdefs.h <&5 +echo "$as_me:17164: checking for long double" >&5 echo $ECHO_N "checking for long double... $ECHO_C" >&6 if test "${ac_cv_type_long_double+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 17095 "configure" +#line 17170 "configure" #include "confdefs.h" $ac_includes_default int @@ -17107,16 +17182,16 @@ if (sizeof (long double)) } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:17110: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:17185: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:17113: \$? = $ac_status" >&5 + echo "$as_me:17188: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:17116: \"$ac_try\"") >&5 + { (eval echo "$as_me:17191: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:17119: \$? = $ac_status" >&5 + echo "$as_me:17194: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_type_long_double=yes else @@ -17126,7 +17201,7 @@ ac_cv_type_long_double=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:17129: result: $ac_cv_type_long_double" >&5 +echo "$as_me:17204: result: $ac_cv_type_long_double" >&5 echo "${ECHO_T}$ac_cv_type_long_double" >&6 if test $ac_cv_type_long_double = yes; then @@ -17135,13 +17210,13 @@ cat >>confdefs.h <&5 +echo "$as_me:17213: checking for long long" >&5 echo $ECHO_N "checking for long long... $ECHO_C" >&6 if test "${ac_cv_type_long_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 17144 "configure" +#line 17219 "configure" #include "confdefs.h" $ac_includes_default int @@ -17156,16 +17231,16 @@ if (sizeof (long long)) } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:17159: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:17234: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:17162: \$? = $ac_status" >&5 + echo "$as_me:17237: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:17165: \"$ac_try\"") >&5 + { (eval echo "$as_me:17240: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:17168: \$? = $ac_status" >&5 + echo "$as_me:17243: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_type_long_long=yes else @@ -17175,7 +17250,7 @@ ac_cv_type_long_long=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:17178: result: $ac_cv_type_long_long" >&5 +echo "$as_me:17253: result: $ac_cv_type_long_long" >&5 echo "${ECHO_T}$ac_cv_type_long_long" >&6 if test $ac_cv_type_long_long = yes; then @@ -17184,13 +17259,13 @@ cat >>confdefs.h <&5 +echo "$as_me:17262: checking for ptrdiff_t" >&5 echo $ECHO_N "checking for ptrdiff_t... $ECHO_C" >&6 if test "${ac_cv_type_ptrdiff_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 17193 "configure" +#line 17268 "configure" #include "confdefs.h" $ac_includes_default int @@ -17205,16 +17280,16 @@ if (sizeof (ptrdiff_t)) } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:17208: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:17283: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:17211: \$? = $ac_status" >&5 + echo "$as_me:17286: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:17214: \"$ac_try\"") >&5 + { (eval echo "$as_me:17289: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:17217: \$? = $ac_status" >&5 + echo "$as_me:17292: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_type_ptrdiff_t=yes else @@ -17224,7 +17299,7 @@ ac_cv_type_ptrdiff_t=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:17227: result: $ac_cv_type_ptrdiff_t" >&5 +echo "$as_me:17302: result: $ac_cv_type_ptrdiff_t" >&5 echo "${ECHO_T}$ac_cv_type_ptrdiff_t" >&6 if test $ac_cv_type_ptrdiff_t = yes; then @@ -17233,13 +17308,13 @@ cat >>confdefs.h <&5 +echo "$as_me:17311: checking for quad_t" >&5 echo $ECHO_N "checking for quad_t... $ECHO_C" >&6 if test "${ac_cv_type_quad_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 17242 "configure" +#line 17317 "configure" #include "confdefs.h" $ac_includes_default int @@ -17254,16 +17329,16 @@ if (sizeof (quad_t)) } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:17257: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:17332: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:17260: \$? = $ac_status" >&5 + echo "$as_me:17335: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:17263: \"$ac_try\"") >&5 + { (eval echo "$as_me:17338: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:17266: \$? = $ac_status" >&5 + echo "$as_me:17341: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_type_quad_t=yes else @@ -17273,7 +17348,7 @@ ac_cv_type_quad_t=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:17276: result: $ac_cv_type_quad_t" >&5 +echo "$as_me:17351: result: $ac_cv_type_quad_t" >&5 echo "${ECHO_T}$ac_cv_type_quad_t" >&6 if test $ac_cv_type_quad_t = yes; then @@ -17283,13 +17358,13 @@ EOF fi -echo "$as_me:17286: checking for preprocessor stringizing operator" >&5 +echo "$as_me:17361: checking for preprocessor stringizing operator" >&5 echo $ECHO_N "checking for preprocessor stringizing operator... $ECHO_C" >&6 if test "${ac_cv_c_stringize+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 17292 "configure" +#line 17367 "configure" #include "confdefs.h" #define x(y) #y @@ -17304,7 +17379,7 @@ fi rm -f conftest* fi -echo "$as_me:17307: result: $ac_cv_c_stringize" >&5 +echo "$as_me:17382: result: $ac_cv_c_stringize" >&5 echo "${ECHO_T}$ac_cv_c_stringize" >&6 if test $ac_cv_c_stringize = yes; then @@ -17314,13 +17389,13 @@ EOF fi -echo "$as_me:17317: checking for working volatile" >&5 +echo "$as_me:17392: checking for working volatile" >&5 echo $ECHO_N "checking for working volatile... $ECHO_C" >&6 if test "${ac_cv_c_volatile+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 17323 "configure" +#line 17398 "configure" #include "confdefs.h" int @@ -17334,16 +17409,16 @@ int * volatile y; } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:17337: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:17412: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:17340: \$? = $ac_status" >&5 + echo "$as_me:17415: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:17343: \"$ac_try\"") >&5 + { (eval echo "$as_me:17418: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:17346: \$? = $ac_status" >&5 + echo "$as_me:17421: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_c_volatile=yes else @@ -17353,7 +17428,7 @@ ac_cv_c_volatile=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:17356: result: $ac_cv_c_volatile" >&5 +echo "$as_me:17431: result: $ac_cv_c_volatile" >&5 echo "${ECHO_T}$ac_cv_c_volatile" >&6 if test $ac_cv_c_volatile = no; then @@ -17363,13 +17438,13 @@ EOF fi -echo "$as_me:17366: checking whether exists and works" >&5 +echo "$as_me:17441: checking whether exists and works" >&5 echo $ECHO_N "checking whether exists and works... $ECHO_C" >&6 if test "${gmp_cv_c_stdarg+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 17372 "configure" +#line 17447 "configure" #include "confdefs.h" #include int foo (int x, ...) @@ -17390,16 +17465,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:17393: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:17468: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:17396: \$? = $ac_status" >&5 + echo "$as_me:17471: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:17399: \"$ac_try\"") >&5 + { (eval echo "$as_me:17474: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:17402: \$? = $ac_status" >&5 + echo "$as_me:17477: \$? = $ac_status" >&5 (exit $ac_status); }; }; then gmp_cv_c_stdarg=yes else @@ -17410,7 +17485,7 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:17413: result: $gmp_cv_c_stdarg" >&5 +echo "$as_me:17488: result: $gmp_cv_c_stdarg" >&5 echo "${ECHO_T}$gmp_cv_c_stdarg" >&6 if test $gmp_cv_c_stdarg = yes; then @@ -17420,13 +17495,13 @@ EOF fi -echo "$as_me:17423: checking whether gcc __attribute__ ((const)) works" >&5 +echo "$as_me:17498: checking whether gcc __attribute__ ((const)) works" >&5 echo $ECHO_N "checking whether gcc __attribute__ ((const)) works... $ECHO_C" >&6 if test "${gmp_cv_c_attribute_const+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 17429 "configure" +#line 17504 "configure" #include "confdefs.h" int foo (int x) __attribute__ ((const)); int @@ -17438,16 +17513,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:17441: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:17516: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:17444: \$? = $ac_status" >&5 + echo "$as_me:17519: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:17447: \"$ac_try\"") >&5 + { (eval echo "$as_me:17522: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:17450: \$? = $ac_status" >&5 + echo "$as_me:17525: \$? = $ac_status" >&5 (exit $ac_status); }; }; then gmp_cv_c_attribute_const=yes else @@ -17458,7 +17533,7 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:17461: result: $gmp_cv_c_attribute_const" >&5 +echo "$as_me:17536: result: $gmp_cv_c_attribute_const" >&5 echo "${ECHO_T}$gmp_cv_c_attribute_const" >&6 if test $gmp_cv_c_attribute_const = yes; then @@ -17468,7 +17543,7 @@ EOF fi -echo "$as_me:17471: checking whether gcc __attribute__ ((malloc)) works" >&5 +echo "$as_me:17546: checking whether gcc __attribute__ ((malloc)) works" >&5 echo $ECHO_N "checking whether gcc __attribute__ ((malloc)) works... $ECHO_C" >&6 if test "${gmp_cv_c_attribute_malloc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -17477,10 +17552,10 @@ else void *foo (int x) __attribute__ ((malloc)); EOF gmp_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >conftest.out 2>&1" -if { (eval echo "$as_me:17480: \"$gmp_compile\"") >&5 +if { (eval echo "$as_me:17555: \"$gmp_compile\"") >&5 (eval $gmp_compile) 2>&5 ac_status=$? - echo "$as_me:17483: \$? = $ac_status" >&5 + echo "$as_me:17558: \$? = $ac_status" >&5 (exit $ac_status); }; then if grep "attribute directive ignored" conftest.out >/dev/null; then gmp_cv_c_attribute_malloc=no @@ -17494,7 +17569,7 @@ cat conftest.out >&5 rm -f conftest* fi -echo "$as_me:17497: result: $gmp_cv_c_attribute_malloc" >&5 +echo "$as_me:17572: result: $gmp_cv_c_attribute_malloc" >&5 echo "${ECHO_T}$gmp_cv_c_attribute_malloc" >&6 if test $gmp_cv_c_attribute_malloc = yes; then @@ -17504,13 +17579,13 @@ EOF fi -echo "$as_me:17507: checking whether gcc __attribute__ ((mode (XX))) works" >&5 +echo "$as_me:17582: checking whether gcc __attribute__ ((mode (XX))) works" >&5 echo $ECHO_N "checking whether gcc __attribute__ ((mode (XX))) works... $ECHO_C" >&6 if test "${gmp_cv_c_attribute_mode+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 17513 "configure" +#line 17588 "configure" #include "confdefs.h" typedef int SItype __attribute__ ((mode (SI))); int @@ -17522,16 +17597,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:17525: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:17600: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:17528: \$? = $ac_status" >&5 + echo "$as_me:17603: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:17531: \"$ac_try\"") >&5 + { (eval echo "$as_me:17606: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:17534: \$? = $ac_status" >&5 + echo "$as_me:17609: \$? = $ac_status" >&5 (exit $ac_status); }; }; then gmp_cv_c_attribute_mode=yes else @@ -17542,7 +17617,7 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:17545: result: $gmp_cv_c_attribute_mode" >&5 +echo "$as_me:17620: result: $gmp_cv_c_attribute_mode" >&5 echo "${ECHO_T}$gmp_cv_c_attribute_mode" >&6 if test $gmp_cv_c_attribute_mode = yes; then @@ -17552,13 +17627,13 @@ EOF fi -echo "$as_me:17555: checking whether gcc __attribute__ ((noreturn)) works" >&5 +echo "$as_me:17630: checking whether gcc __attribute__ ((noreturn)) works" >&5 echo $ECHO_N "checking whether gcc __attribute__ ((noreturn)) works... $ECHO_C" >&6 if test "${gmp_cv_c_attribute_noreturn+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 17561 "configure" +#line 17636 "configure" #include "confdefs.h" void foo (int x) __attribute__ ((noreturn)); int @@ -17570,16 +17645,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:17573: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:17648: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:17576: \$? = $ac_status" >&5 + echo "$as_me:17651: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:17579: \"$ac_try\"") >&5 + { (eval echo "$as_me:17654: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:17582: \$? = $ac_status" >&5 + echo "$as_me:17657: \$? = $ac_status" >&5 (exit $ac_status); }; }; then gmp_cv_c_attribute_noreturn=yes else @@ -17590,7 +17665,7 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:17593: result: $gmp_cv_c_attribute_noreturn" >&5 +echo "$as_me:17668: result: $gmp_cv_c_attribute_noreturn" >&5 echo "${ECHO_T}$gmp_cv_c_attribute_noreturn" >&6 if test $gmp_cv_c_attribute_noreturn = yes; then @@ -17600,7 +17675,7 @@ EOF fi -echo "$as_me:17603: checking for inline" >&5 +echo "$as_me:17678: checking for inline" >&5 echo $ECHO_N "checking for inline... $ECHO_C" >&6 if test "${gmp_cv_c_inline+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -17608,7 +17683,7 @@ else gmp_cv_c_inline=no for i in inline __inline__ __inline; do cat >conftest.$ac_ext <<_ACEOF -#line 17611 "configure" +#line 17686 "configure" #include "confdefs.h" #ifndef __cplusplus typedef int foo_t; @@ -17624,16 +17699,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:17627: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:17702: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:17630: \$? = $ac_status" >&5 + echo "$as_me:17705: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:17633: \"$ac_try\"") >&5 + { (eval echo "$as_me:17708: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:17636: \$? = $ac_status" >&5 + echo "$as_me:17711: \$? = $ac_status" >&5 (exit $ac_status); }; }; then gmp_cv_c_inline=$i break @@ -17648,7 +17723,7 @@ if test $gmp_cv_c_inline = inline; then fi fi -echo "$as_me:17651: result: $gmp_cv_c_inline" >&5 +echo "$as_me:17726: result: $gmp_cv_c_inline" >&5 echo "${ECHO_T}$gmp_cv_c_inline" >&6 case $gmp_cv_c_inline in inline | yes) ;; @@ -17667,7 +17742,7 @@ case $gmp_cv_c_inline in no) ;; *) cat >conftest.$ac_ext <<_ACEOF -#line 17670 "configure" +#line 17745 "configure" #include "confdefs.h" #define __GMP_WITHIN_CONFIGURE_INLINE 1 #define __GMP_WITHIN_CONFIGURE 1 /* ignore template stuff */ @@ -17690,16 +17765,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:17693: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:17768: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:17696: \$? = $ac_status" >&5 + echo "$as_me:17771: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:17699: \"$ac_try\"") >&5 + { (eval echo "$as_me:17774: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:17702: \$? = $ac_status" >&5 + echo "$as_me:17777: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -17709,7 +17784,7 @@ case $gmp_cv_c_inline in yes) tmp_inline=inline ;; *) tmp_inline=$gmp_cv_c_inline ;; esac - { echo "$as_me:17712: WARNING: gmp.h doesnt recognise compiler \"$tmp_inline\", inlines will be unavailable" >&5 + { echo "$as_me:17787: WARNING: gmp.h doesnt recognise compiler \"$tmp_inline\", inlines will be unavailable" >&5 echo "$as_me: WARNING: gmp.h doesnt recognise compiler \"$tmp_inline\", inlines will be unavailable" >&2;} fi rm -f conftest.$ac_objext conftest.$ac_ext @@ -17723,7 +17798,7 @@ case $host in # These system don't have libm ;; *-ncr-sysv4.3*) - echo "$as_me:17726: checking for _mwvalidcheckl in -lmw" >&5 + echo "$as_me:17801: checking for _mwvalidcheckl in -lmw" >&5 echo $ECHO_N "checking for _mwvalidcheckl in -lmw... $ECHO_C" >&6 if test "${ac_cv_lib_mw__mwvalidcheckl+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -17731,7 +17806,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-lmw $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 17734 "configure" +#line 17809 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -17750,16 +17825,16 @@ _mwvalidcheckl (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:17753: \"$ac_link\"") >&5 +if { (eval echo "$as_me:17828: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:17756: \$? = $ac_status" >&5 + echo "$as_me:17831: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:17759: \"$ac_try\"") >&5 + { (eval echo "$as_me:17834: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:17762: \$? = $ac_status" >&5 + echo "$as_me:17837: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_mw__mwvalidcheckl=yes else @@ -17770,13 +17845,13 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:17773: result: $ac_cv_lib_mw__mwvalidcheckl" >&5 +echo "$as_me:17848: result: $ac_cv_lib_mw__mwvalidcheckl" >&5 echo "${ECHO_T}$ac_cv_lib_mw__mwvalidcheckl" >&6 if test $ac_cv_lib_mw__mwvalidcheckl = yes; then LIBM="-lmw" fi - echo "$as_me:17779: checking for main in -lm" >&5 + echo "$as_me:17854: checking for main in -lm" >&5 echo $ECHO_N "checking for main in -lm... $ECHO_C" >&6 if test "${ac_cv_lib_m_main+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -17784,7 +17859,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 17787 "configure" +#line 17862 "configure" #include "confdefs.h" int @@ -17796,16 +17871,16 @@ main (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:17799: \"$ac_link\"") >&5 +if { (eval echo "$as_me:17874: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:17802: \$? = $ac_status" >&5 + echo "$as_me:17877: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:17805: \"$ac_try\"") >&5 + { (eval echo "$as_me:17880: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:17808: \$? = $ac_status" >&5 + echo "$as_me:17883: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_m_main=yes else @@ -17816,7 +17891,7 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:17819: result: $ac_cv_lib_m_main" >&5 +echo "$as_me:17894: result: $ac_cv_lib_m_main" >&5 echo "${ECHO_T}$ac_cv_lib_m_main" >&6 if test $ac_cv_lib_m_main = yes; then LIBM="$LIBM -lm" @@ -17824,7 +17899,7 @@ fi ;; *) - echo "$as_me:17827: checking for main in -lm" >&5 + echo "$as_me:17902: checking for main in -lm" >&5 echo $ECHO_N "checking for main in -lm... $ECHO_C" >&6 if test "${ac_cv_lib_m_main+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -17832,7 +17907,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 17835 "configure" +#line 17910 "configure" #include "confdefs.h" int @@ -17844,16 +17919,16 @@ main (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:17847: \"$ac_link\"") >&5 +if { (eval echo "$as_me:17922: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:17850: \$? = $ac_status" >&5 + echo "$as_me:17925: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:17853: \"$ac_try\"") >&5 + { (eval echo "$as_me:17928: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:17856: \$? = $ac_status" >&5 + echo "$as_me:17931: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_m_main=yes else @@ -17864,7 +17939,7 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:17867: result: $ac_cv_lib_m_main" >&5 +echo "$as_me:17942: result: $ac_cv_lib_m_main" >&5 echo "${ECHO_T}$ac_cv_lib_m_main" >&6 if test $ac_cv_lib_m_main = yes; then LIBM="-lm" @@ -17875,13 +17950,13 @@ esac # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! -echo "$as_me:17878: checking for working alloca.h" >&5 +echo "$as_me:17953: checking for working alloca.h" >&5 echo $ECHO_N "checking for working alloca.h... $ECHO_C" >&6 if test "${gmp_cv_header_alloca+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 17884 "configure" +#line 17959 "configure" #include "confdefs.h" #include int @@ -17893,16 +17968,16 @@ char *p = (char *) alloca (2 * sizeof (int)); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:17896: \"$ac_link\"") >&5 +if { (eval echo "$as_me:17971: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:17899: \$? = $ac_status" >&5 + echo "$as_me:17974: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:17902: \"$ac_try\"") >&5 + { (eval echo "$as_me:17977: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:17905: \$? = $ac_status" >&5 + echo "$as_me:17980: \$? = $ac_status" >&5 (exit $ac_status); }; }; then gmp_cv_header_alloca=yes else @@ -17912,7 +17987,7 @@ gmp_cv_header_alloca=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:17915: result: $gmp_cv_header_alloca" >&5 +echo "$as_me:17990: result: $gmp_cv_header_alloca" >&5 echo "${ECHO_T}$gmp_cv_header_alloca" >&6 if test $gmp_cv_header_alloca = yes; then @@ -17922,13 +17997,13 @@ EOF fi -echo "$as_me:17925: checking for alloca (via gmp-impl.h)" >&5 +echo "$as_me:18000: checking for alloca (via gmp-impl.h)" >&5 echo $ECHO_N "checking for alloca (via gmp-impl.h)... $ECHO_C" >&6 if test "${gmp_cv_func_alloca+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 17931 "configure" +#line 18006 "configure" #include "confdefs.h" #define __GMP_WITHIN_CONFIGURE 1 /* ignore template stuff */ #define GMP_NAIL_BITS $GMP_NAIL_BITS @@ -17948,16 +18023,16 @@ char *p = (char *) alloca (1); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:17951: \"$ac_link\"") >&5 +if { (eval echo "$as_me:18026: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:17954: \$? = $ac_status" >&5 + echo "$as_me:18029: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:17957: \"$ac_try\"") >&5 + { (eval echo "$as_me:18032: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:17960: \$? = $ac_status" >&5 + echo "$as_me:18035: \$? = $ac_status" >&5 (exit $ac_status); }; }; then gmp_cv_func_alloca=yes else @@ -17967,7 +18042,7 @@ gmp_cv_func_alloca=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:17970: result: $gmp_cv_func_alloca" >&5 +echo "$as_me:18045: result: $gmp_cv_func_alloca" >&5 echo "${ECHO_T}$gmp_cv_func_alloca" >&6 if test $gmp_cv_func_alloca = yes; then @@ -17977,7 +18052,7 @@ EOF fi -echo "$as_me:17980: checking how to allocate temporary memory" >&5 +echo "$as_me:18055: checking how to allocate temporary memory" >&5 echo $ECHO_N "checking how to allocate temporary memory... $ECHO_C" >&6 if test "${gmp_cv_option_alloca+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -18001,12 +18076,12 @@ else esac fi -echo "$as_me:18004: result: $gmp_cv_option_alloca" >&5 +echo "$as_me:18079: result: $gmp_cv_option_alloca" >&5 echo "${ECHO_T}$gmp_cv_option_alloca" >&6 case $gmp_cv_option_alloca in alloca) if test $gmp_cv_func_alloca = no; then - { { echo "$as_me:18009: error: --enable-alloca=alloca specified, but alloca not available" >&5 + { { echo "$as_me:18084: error: --enable-alloca=alloca specified, but alloca not available" >&5 echo "$as_me: error: --enable-alloca=alloca specified, but alloca not available" >&2;} { (exit 1); exit 1; }; } fi @@ -18042,14 +18117,14 @@ EOF ;; *) # checks at the start of configure.in should protect us - { { echo "$as_me:18045: error: unrecognised --enable-alloca=$gmp_cv_option_alloca" >&5 + { { echo "$as_me:18120: error: unrecognised --enable-alloca=$gmp_cv_option_alloca" >&5 echo "$as_me: error: unrecognised --enable-alloca=$gmp_cv_option_alloca" >&2;} { (exit 1); exit 1; }; } ;; esac cat >conftest.$ac_ext <<_ACEOF -#line 18052 "configure" +#line 18127 "configure" #include "confdefs.h" #include #define __GMP_WITHIN_CONFIGURE 1 /* ignore template stuff */ @@ -18072,22 +18147,22 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:18075: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:18150: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:18078: \$? = $ac_status" >&5 + echo "$as_me:18153: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:18081: \"$ac_try\"") >&5 + { (eval echo "$as_me:18156: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:18084: \$? = $ac_status" >&5 + echo "$as_me:18159: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 -{ echo "$as_me:18090: WARNING: gmp.h doesnt recognise , FILE prototypes will be unavailable" >&5 +{ echo "$as_me:18165: WARNING: gmp.h doesnt recognise , FILE prototypes will be unavailable" >&5 echo "$as_me: WARNING: gmp.h doesnt recognise , FILE prototypes will be unavailable" >&2;} fi rm -f conftest.$ac_objext conftest.$ac_ext @@ -18106,7 +18181,7 @@ case $host in ;; *) cat >conftest.$ac_ext <<_ACEOF -#line 18109 "configure" +#line 18184 "configure" #include "confdefs.h" #include #define __GMP_WITHIN_CONFIGURE 1 /* ignore template stuff */ @@ -18130,27 +18205,27 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:18133: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:18208: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:18136: \$? = $ac_status" >&5 + echo "$as_me:18211: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:18139: \"$ac_try\"") >&5 + { (eval echo "$as_me:18214: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:18142: \$? = $ac_status" >&5 + echo "$as_me:18217: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 - { echo "$as_me:18149: WARNING: gmp-impl.h doesnt recognise \"double\" as IEEE." >&5 + { echo "$as_me:18224: WARNING: gmp-impl.h doesnt recognise \"double\" as IEEE." >&5 echo "$as_me: WARNING: gmp-impl.h doesnt recognise \"double\" as IEEE." >&2;} - { echo "$as_me:18151: WARNING: If your CPU floats are in fact IEEE then you" >&5 + { echo "$as_me:18226: WARNING: If your CPU floats are in fact IEEE then you" >&5 echo "$as_me: WARNING: If your CPU floats are in fact IEEE then you" >&2;} - { echo "$as_me:18153: WARNING: might like to augment the tests there." >&5 + { echo "$as_me:18228: WARNING: might like to augment the tests there." >&5 echo "$as_me: WARNING: might like to augment the tests there." >&2;} fi @@ -18165,7 +18240,7 @@ esac if test "$cross_compiling" = yes; then ac_cv_c_bigendian=unknown fi -echo "$as_me:18168: checking whether byte ordering is bigendian" >&5 +echo "$as_me:18243: checking whether byte ordering is bigendian" >&5 echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6 if test "${ac_cv_c_bigendian+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -18173,7 +18248,7 @@ else ac_cv_c_bigendian=unknown # See if sys/param.h defines the BYTE_ORDER macro. cat >conftest.$ac_ext <<_ACEOF -#line 18176 "configure" +#line 18251 "configure" #include "confdefs.h" #include #include @@ -18190,20 +18265,20 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:18193: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:18268: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:18196: \$? = $ac_status" >&5 + echo "$as_me:18271: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:18199: \"$ac_try\"") >&5 + { (eval echo "$as_me:18274: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:18202: \$? = $ac_status" >&5 + echo "$as_me:18277: \$? = $ac_status" >&5 (exit $ac_status); }; }; then # It does; now see whether it defined to BIG_ENDIAN or not. cat >conftest.$ac_ext <<_ACEOF -#line 18206 "configure" +#line 18281 "configure" #include "confdefs.h" #include #include @@ -18220,16 +18295,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:18223: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:18298: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:18226: \$? = $ac_status" >&5 + echo "$as_me:18301: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:18229: \"$ac_try\"") >&5 + { (eval echo "$as_me:18304: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:18232: \$? = $ac_status" >&5 + echo "$as_me:18307: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_c_bigendian=yes else @@ -18245,12 +18320,12 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then if test "$cross_compiling" = yes; then - { { echo "$as_me:18248: error: cannot run test program while cross compiling" >&5 + { { echo "$as_me:18323: error: cannot run test program while cross compiling" >&5 echo "$as_me: error: cannot run test program while cross compiling" >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF -#line 18253 "configure" +#line 18328 "configure" #include "confdefs.h" int main () @@ -18266,15 +18341,15 @@ main () } _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:18269: \"$ac_link\"") >&5 +if { (eval echo "$as_me:18344: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:18272: \$? = $ac_status" >&5 + echo "$as_me:18347: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:18274: \"$ac_try\"") >&5 + { (eval echo "$as_me:18349: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:18277: \$? = $ac_status" >&5 + echo "$as_me:18352: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_c_bigendian=no else @@ -18287,7 +18362,7 @@ rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi -echo "$as_me:18290: result: $ac_cv_c_bigendian" >&5 +echo "$as_me:18365: result: $ac_cv_c_bigendian" >&5 echo "${ECHO_T}$ac_cv_c_bigendian" >&6 if test $ac_cv_c_bigendian = yes; then @@ -18309,12 +18384,12 @@ EOF EOF ;; unknown) ;; - *) { { echo "$as_me:18312: error: Oops, unrecognised ac_cv_c_bigendian" >&5 + *) { { echo "$as_me:18387: error: Oops, unrecognised ac_cv_c_bigendian" >&5 echo "$as_me: error: Oops, unrecognised ac_cv_c_bigendian" >&2;} { (exit 1); exit 1; }; } ;; esac -echo "$as_me:18317: checking format of \`double' floating point" >&5 +echo "$as_me:18392: checking format of \`double' floating point" >&5 echo $ECHO_N "checking format of \`double' floating point... $ECHO_C" >&6 if test "${gmp_cv_c_double_format+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -18332,10 +18407,10 @@ struct { }; EOF gmp_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >&5 2>&1" -if { (eval echo "$as_me:18335: \"$gmp_compile\"") >&5 +if { (eval echo "$as_me:18410: \"$gmp_compile\"") >&5 (eval $gmp_compile) 2>&5 ac_status=$? - echo "$as_me:18338: \$? = $ac_status" >&5 + echo "$as_me:18413: \$? = $ac_status" >&5 (exit $ac_status); }; then cat >conftest.awk <<\EOF @@ -18471,12 +18546,12 @@ EOF ;; esac else - { echo "$as_me:18474: WARNING: oops, cannot compile test program" >&5 + { echo "$as_me:18549: WARNING: oops, cannot compile test program" >&5 echo "$as_me: WARNING: oops, cannot compile test program" >&2;} fi fi -echo "$as_me:18479: result: $gmp_cv_c_double_format" >&5 +echo "$as_me:18554: result: $gmp_cv_c_double_format" >&5 echo "${ECHO_T}$gmp_cv_c_double_format" >&6 case $gmp_cv_c_double_format in @@ -18513,7 +18588,7 @@ EOF unknown*) ;; *) - { echo "$as_me:18516: WARNING: oops, unrecognised float format: $gmp_cv_c_double_format" >&5 + { echo "$as_me:18591: WARNING: oops, unrecognised float format: $gmp_cv_c_double_format" >&5 echo "$as_me: WARNING: oops, unrecognised float format: $gmp_cv_c_double_format" >&2;} ;; esac @@ -18554,13 +18629,13 @@ esac for ac_func in alarm clock clock_gettime cputime getpagesize getrusage gettimeofday localeconv memset mmap mprotect obstack_vprintf popen processor_info read_real_time sigaction sigaltstack sigstack syssgi strchr strnlen strtoul sysconf sysctl sysctlbyname times do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:18557: checking for $ac_func" >&5 +echo "$as_me:18632: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 18563 "configure" +#line 18638 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. */ @@ -18591,16 +18666,16 @@ f = $ac_func; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:18594: \"$ac_link\"") >&5 +if { (eval echo "$as_me:18669: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:18597: \$? = $ac_status" >&5 + echo "$as_me:18672: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:18600: \"$ac_try\"") >&5 + { (eval echo "$as_me:18675: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:18603: \$? = $ac_status" >&5 + echo "$as_me:18678: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_var=yes" else @@ -18610,7 +18685,7 @@ eval "$as_ac_var=no" fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:18613: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "$as_me:18688: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <&5 +echo "$as_me:18701: checking for vsnprintf" >&5 echo $ECHO_N "checking for vsnprintf... $ECHO_C" >&6 if test "${ac_cv_func_vsnprintf+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 18632 "configure" +#line 18707 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char vsnprintf (); below. */ @@ -18660,16 +18735,16 @@ f = vsnprintf; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:18663: \"$ac_link\"") >&5 +if { (eval echo "$as_me:18738: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:18666: \$? = $ac_status" >&5 + echo "$as_me:18741: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:18669: \"$ac_try\"") >&5 + { (eval echo "$as_me:18744: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:18672: \$? = $ac_status" >&5 + echo "$as_me:18747: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_vsnprintf=yes else @@ -18679,7 +18754,7 @@ ac_cv_func_vsnprintf=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:18682: result: $ac_cv_func_vsnprintf" >&5 +echo "$as_me:18757: result: $ac_cv_func_vsnprintf" >&5 echo "${ECHO_T}$ac_cv_func_vsnprintf" >&6 if test $ac_cv_func_vsnprintf = yes; then gmp_vsnprintf_exists=yes @@ -18690,7 +18765,7 @@ fi if test "$gmp_vsnprintf_exists" = no; then gmp_cv_func_vsnprintf=no else - echo "$as_me:18693: checking whether vsnprintf works" >&5 + echo "$as_me:18768: checking whether vsnprintf works" >&5 echo $ECHO_N "checking whether vsnprintf works... $ECHO_C" >&6 if test "${gmp_cv_func_vsnprintf+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -18701,7 +18776,7 @@ else gmp_cv_func_vsnprintf=probably; break else cat >conftest.$ac_ext <<_ACEOF -#line 18704 "configure" +#line 18779 "configure" #include "confdefs.h" #include /* for strcmp */ @@ -18754,15 +18829,15 @@ $i _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:18757: \"$ac_link\"") >&5 +if { (eval echo "$as_me:18832: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:18760: \$? = $ac_status" >&5 + echo "$as_me:18835: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:18762: \"$ac_try\"") >&5 + { (eval echo "$as_me:18837: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:18765: \$? = $ac_status" >&5 + echo "$as_me:18840: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -18776,10 +18851,10 @@ fi done fi -echo "$as_me:18779: result: $gmp_cv_func_vsnprintf" >&5 +echo "$as_me:18854: result: $gmp_cv_func_vsnprintf" >&5 echo "${ECHO_T}$gmp_cv_func_vsnprintf" >&6 if test "$gmp_cv_func_vsnprintf" = probably; then - { echo "$as_me:18782: WARNING: cannot check for properly working vsnprintf when cross compiling, will assume it's ok" >&5 + { echo "$as_me:18857: WARNING: cannot check for properly working vsnprintf when cross compiling, will assume it's ok" >&5 echo "$as_me: WARNING: cannot check for properly working vsnprintf when cross compiling, will assume it's ok" >&2;} fi if test "$gmp_cv_func_vsnprintf" != no; then @@ -18798,7 +18873,7 @@ if test "$gmp_cv_func_vsnprintf" = no; then fi -echo "$as_me:18801: checking whether sscanf needs writable input" >&5 +echo "$as_me:18876: checking whether sscanf needs writable input" >&5 echo $ECHO_N "checking whether sscanf needs writable input... $ECHO_C" >&6 if test "${gmp_cv_func_sscanf_writable_input+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -18810,7 +18885,7 @@ else esac fi -echo "$as_me:18813: result: $gmp_cv_func_sscanf_writable_input" >&5 +echo "$as_me:18888: result: $gmp_cv_func_sscanf_writable_input" >&5 echo "${ECHO_T}$gmp_cv_func_sscanf_writable_input" >&6 case $gmp_cv_func_sscanf_writable_input in yes) @@ -18819,7 +18894,7 @@ cat >>confdefs.h <<\EOF EOF ;; no) ;; - *) { { echo "$as_me:18822: error: unrecognised \$gmp_cv_func_sscanf_writable_input" >&5 + *) { { echo "$as_me:18897: error: unrecognised \$gmp_cv_func_sscanf_writable_input" >&5 echo "$as_me: error: unrecognised \$gmp_cv_func_sscanf_writable_input" >&2;} { (exit 1); exit 1; }; } ;; esac @@ -19002,7 +19077,7 @@ EOF fi done if test $found = no; then - { { echo "$as_me:19005: error: no version of $tmp_fn found in path: $path" >&5 + { { echo "$as_me:19080: error: no version of $tmp_fn found in path: $path" >&5 echo "$as_me: error: no version of $tmp_fn found in path: $path" >&2;} { (exit 1); exit 1; }; } fi @@ -19017,7 +19092,7 @@ fi # Don't demand an m4 unless it's actually needed. if test $found_asm = yes; then -echo "$as_me:19020: checking for suitable m4" >&5 +echo "$as_me:19095: checking for suitable m4" >&5 echo $ECHO_N "checking for suitable m4... $ECHO_C" >&6 if test "${gmp_cv_prog_m4+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -19053,7 +19128,7 @@ EOF done IFS="$ac_save_ifs" if test -z "$gmp_cv_prog_m4"; then - { { echo "$as_me:19056: error: No usable m4 in \$PATH or /usr/5bin (see config.log for reasons)." >&5 + { { echo "$as_me:19131: error: No usable m4 in \$PATH or /usr/5bin (see config.log for reasons)." >&5 echo "$as_me: error: No usable m4 in \$PATH or /usr/5bin (see config.log for reasons)." >&2;} { (exit 1); exit 1; }; } fi @@ -19061,11 +19136,11 @@ echo "$as_me: error: No usable m4 in \$PATH or /usr/5bin (see config.log for rea rm -f conftest.m4 fi fi -echo "$as_me:19064: result: $gmp_cv_prog_m4" >&5 +echo "$as_me:19139: result: $gmp_cv_prog_m4" >&5 echo "${ECHO_T}$gmp_cv_prog_m4" >&6 M4="$gmp_cv_prog_m4" -echo "$as_me:19068: checking if m4wrap produces spurious output" >&5 +echo "$as_me:19143: checking if m4wrap produces spurious output" >&5 echo $ECHO_N "checking if m4wrap produces spurious output... $ECHO_C" >&6 if test "${gmp_cv_m4_m4wrap_spurious+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -19087,7 +19162,7 @@ else fi fi -echo "$as_me:19090: result: $gmp_cv_m4_m4wrap_spurious" >&5 +echo "$as_me:19165: result: $gmp_cv_m4_m4wrap_spurious" >&5 echo "${ECHO_T}$gmp_cv_m4_m4wrap_spurious" >&6 echo "define(,<$gmp_cv_m4_m4wrap_spurious>)" >> $gmp_tmpconfigm4 @@ -19102,7 +19177,7 @@ if test $found_asm = no && test $found_S = no; then fi if test "$gmp_asm_syntax_testing" != no; then - echo "$as_me:19105: checking how to switch to text section" >&5 + echo "$as_me:19180: checking how to switch to text section" >&5 echo $ECHO_N "checking how to switch to text section... $ECHO_C" >&6 if test "${gmp_cv_asm_text+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -19114,11 +19189,11 @@ else esac fi -echo "$as_me:19117: result: $gmp_cv_asm_text" >&5 +echo "$as_me:19192: result: $gmp_cv_asm_text" >&5 echo "${ECHO_T}$gmp_cv_asm_text" >&6 echo "define(, <$gmp_cv_asm_text>)" >> $gmp_tmpconfigm4 - echo "$as_me:19121: checking how to switch to data section" >&5 + echo "$as_me:19196: checking how to switch to data section" >&5 echo $ECHO_N "checking how to switch to data section... $ECHO_C" >&6 if test "${gmp_cv_asm_data+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -19129,11 +19204,11 @@ else esac fi -echo "$as_me:19132: result: $gmp_cv_asm_data" >&5 +echo "$as_me:19207: result: $gmp_cv_asm_data" >&5 echo "${ECHO_T}$gmp_cv_asm_data" >&6 echo "define(, <$gmp_cv_asm_data>)" >> $gmp_tmpconfigm4 - echo "$as_me:19136: checking what assembly label suffix to use" >&5 + echo "$as_me:19211: checking what assembly label suffix to use" >&5 echo $ECHO_N "checking what assembly label suffix to use... $ECHO_C" >&6 if test "${gmp_cv_asm_label_suffix+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -19145,11 +19220,11 @@ else esac fi -echo "$as_me:19148: result: $gmp_cv_asm_label_suffix" >&5 +echo "$as_me:19223: result: $gmp_cv_asm_label_suffix" >&5 echo "${ECHO_T}$gmp_cv_asm_label_suffix" >&6 echo "define(, <\$1$gmp_cv_asm_label_suffix>)" >> $gmp_tmpconfigm4 - echo "$as_me:19152: checking how to export a symbol" >&5 + echo "$as_me:19227: checking how to export a symbol" >&5 echo $ECHO_N "checking how to export a symbol... $ECHO_C" >&6 if test "${gmp_cv_asm_globl+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -19160,11 +19235,11 @@ else esac fi -echo "$as_me:19163: result: $gmp_cv_asm_globl" >&5 +echo "$as_me:19238: result: $gmp_cv_asm_globl" >&5 echo "${ECHO_T}$gmp_cv_asm_globl" >&6 echo "define(, <$gmp_cv_asm_globl>)" >> $gmp_tmpconfigm4 -echo "$as_me:19167: checking if globals are prefixed by underscore" >&5 +echo "$as_me:19242: checking if globals are prefixed by underscore" >&5 echo $ECHO_N "checking if globals are prefixed by underscore... $ECHO_C" >&6 if test "${gmp_cv_asm_underscore+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -19190,10 +19265,10 @@ EOF ;; esac gmp_compile="$CC $CFLAGS $CPPFLAGS -c conftes1.c >&5 && $CCAS $CFLAGS conftes2.s >&5 && $CC $CFLAGS conftes1.$OBJEXT conftes2.$OBJEXT >&5" - if { (eval echo "$as_me:19193: \"$gmp_compile\"") >&5 + if { (eval echo "$as_me:19268: \"$gmp_compile\"") >&5 (eval $gmp_compile) 2>&5 ac_status=$? - echo "$as_me:19196: \$? = $ac_status" >&5 + echo "$as_me:19271: \$? = $ac_status" >&5 (exit $ac_status); }; then eval tmp_result$tmp_underscore=yes else @@ -19203,7 +19278,7 @@ done if test $tmp_result_ = yes; then if test $tmp_result = yes; then - { { echo "$as_me:19206: error: Test program unexpectedly links both with and without underscore." >&5 + { { echo "$as_me:19281: error: Test program unexpectedly links both with and without underscore." >&5 echo "$as_me: error: Test program unexpectedly links both with and without underscore." >&2;} { (exit 1); exit 1; }; } else @@ -19213,7 +19288,7 @@ else if test $tmp_result = yes; then gmp_cv_asm_underscore=no else - { { echo "$as_me:19216: error: Test program links neither with nor without underscore." >&5 + { { echo "$as_me:19291: error: Test program links neither with nor without underscore." >&5 echo "$as_me: error: Test program links neither with nor without underscore." >&2;} { (exit 1); exit 1; }; } fi @@ -19221,7 +19296,7 @@ fi rm -f conftes1* conftes2* a.out fi -echo "$as_me:19224: result: $gmp_cv_asm_underscore" >&5 +echo "$as_me:19299: result: $gmp_cv_asm_underscore" >&5 echo "${ECHO_T}$gmp_cv_asm_underscore" >&6 if test "$gmp_cv_asm_underscore" = "yes"; then @@ -19233,14 +19308,14 @@ echo 'define(, <>)' >>$gmp_tmpconfigm4 fi -echo "$as_me:19236: checking how to switch to read-only data section" >&5 +echo "$as_me:19311: checking how to switch to read-only data section" >&5 echo $ECHO_N "checking how to switch to read-only data section... $ECHO_C" >&6 if test "${gmp_cv_asm_rodata+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $host in -i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-*) gmp_cv_asm_rodata="$gmp_cv_asm_data" ;; +i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-* | viac3*-*-*) gmp_cv_asm_rodata="$gmp_cv_asm_data" ;; *) gmp_cv_asm_rodata="$gmp_cv_asm_text" ;; esac @@ -19250,10 +19325,10 @@ EOF echo "Test program:" >&5 cat conftest.c >&5 gmp_compile="$CC $CFLAGS $CPPFLAGS -S conftest.c >&5" -if { (eval echo "$as_me:19253: \"$gmp_compile\"") >&5 +if { (eval echo "$as_me:19328: \"$gmp_compile\"") >&5 (eval $gmp_compile) 2>&5 ac_status=$? - echo "$as_me:19256: \$? = $ac_status" >&5 + echo "$as_me:19331: \$? = $ac_status" >&5 (exit $ac_status); }; then echo "Compiler output:" >&5 cat conftest.s >&5 @@ -19283,11 +19358,11 @@ if { (eval echo "$as_me:19253: \"$gmp_compile\"") >&5 fi fi -echo "$as_me:19286: result: $gmp_cv_asm_rodata" >&5 +echo "$as_me:19361: result: $gmp_cv_asm_rodata" >&5 echo "${ECHO_T}$gmp_cv_asm_rodata" >&6 echo "define(, <$gmp_cv_asm_rodata>)" >> $gmp_tmpconfigm4 - echo "$as_me:19290: checking if the export directive needs an attribute" >&5 + echo "$as_me:19365: checking if the export directive needs an attribute" >&5 echo $ECHO_N "checking if the export directive needs an attribute... $ECHO_C" >&6 if test "${gmp_cv_asm_globl_attr+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -19298,11 +19373,11 @@ else esac fi -echo "$as_me:19301: result: $gmp_cv_asm_globl_attr" >&5 +echo "$as_me:19376: result: $gmp_cv_asm_globl_attr" >&5 echo "${ECHO_T}$gmp_cv_asm_globl_attr" >&6 echo "define(, <$gmp_cv_asm_globl_attr>)" >> $gmp_tmpconfigm4 - echo "$as_me:19305: checking for assembler .type directive" >&5 + echo "$as_me:19380: checking for assembler .type directive" >&5 echo $ECHO_N "checking for assembler .type directive... $ECHO_C" >&6 if test "${gmp_cv_asm_type+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -19313,10 +19388,10 @@ for gmp_tmp_prefix in @ \# %; do .type sym,${gmp_tmp_prefix}function EOF gmp_assemble="$CCAS $CFLAGS conftest.s >conftest.out 2>&1" -if { (eval echo "$as_me:19316: \"$gmp_assemble\"") >&5 +if { (eval echo "$as_me:19391: \"$gmp_assemble\"") >&5 (eval $gmp_assemble) 2>&5 ac_status=$? - echo "$as_me:19319: \$? = $ac_status" >&5 + echo "$as_me:19394: \$? = $ac_status" >&5 (exit $ac_status); }; then cat conftest.out >&5 if grep "\.type pseudo-op used outside of \.def/\.endef ignored" conftest.out >/dev/null; then : ; @@ -19336,11 +19411,11 @@ done rm -f conftest* fi -echo "$as_me:19339: result: $gmp_cv_asm_type" >&5 +echo "$as_me:19414: result: $gmp_cv_asm_type" >&5 echo "${ECHO_T}$gmp_cv_asm_type" >&6 echo "define(, <$gmp_cv_asm_type>)" >> $gmp_tmpconfigm4 - echo "$as_me:19343: checking for assembler .size directive" >&5 + echo "$as_me:19418: checking for assembler .size directive" >&5 echo $ECHO_N "checking for assembler .size directive... $ECHO_C" >&6 if test "${gmp_cv_asm_size+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -19350,10 +19425,10 @@ cat >conftest.s <&5 +if { (eval echo "$as_me:19428: \"$gmp_assemble\"") >&5 (eval $gmp_assemble) 2>&5 ac_status=$? - echo "$as_me:19356: \$? = $ac_status" >&5 + echo "$as_me:19431: \$? = $ac_status" >&5 (exit $ac_status); }; then cat conftest.out >&5 if grep "\.size pseudo-op used outside of \.def/\.endef ignored" conftest.out >/dev/null; then : ; @@ -19369,11 +19444,11 @@ fi rm -f conftest* fi -echo "$as_me:19372: result: $gmp_cv_asm_size" >&5 +echo "$as_me:19447: result: $gmp_cv_asm_size" >&5 echo "${ECHO_T}$gmp_cv_asm_size" >&6 echo "define(, <$gmp_cv_asm_size>)" >> $gmp_tmpconfigm4 -echo "$as_me:19376: checking what prefix to use for a local label" >&5 +echo "$as_me:19451: checking what prefix to use for a local label" >&5 echo $ECHO_N "checking what prefix to use for a local label... $ECHO_C" >&6 if test "${gmp_cv_asm_lsym_prefix+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -19385,15 +19460,15 @@ dummy${gmp_cv_asm_label_suffix} ${gmp_tmp_pre}gurkmacka${gmp_cv_asm_label_suffix} EOF gmp_assemble="$CCAS $CFLAGS conftest.s >conftest.out 2>&1" -if { (eval echo "$as_me:19388: \"$gmp_assemble\"") >&5 +if { (eval echo "$as_me:19463: \"$gmp_assemble\"") >&5 (eval $gmp_assemble) 2>&5 ac_status=$? - echo "$as_me:19391: \$? = $ac_status" >&5 + echo "$as_me:19466: \$? = $ac_status" >&5 (exit $ac_status); }; then cat conftest.out >&5 if $NM conftest.$OBJEXT >conftest.nm 2>&5; then : ; else cat conftest.nm >&5 - { echo "$as_me:19396: WARNING: \"$NM\" failure" >&5 + { echo "$as_me:19471: WARNING: \"$NM\" failure" >&5 echo "$as_me: WARNING: \"$NM\" failure" >&2;} break fi @@ -19422,12 +19497,12 @@ done rm -f conftest* if test -z "$gmp_cv_asm_lsym_prefix"; then gmp_cv_asm_lsym_prefix=L - { echo "$as_me:19425: WARNING: cannot determine local label, using default $gmp_cv_asm_lsym_prefix" >&5 + { echo "$as_me:19500: WARNING: cannot determine local label, using default $gmp_cv_asm_lsym_prefix" >&5 echo "$as_me: WARNING: cannot determine local label, using default $gmp_cv_asm_lsym_prefix" >&2;} fi fi -echo "$as_me:19430: result: $gmp_cv_asm_lsym_prefix" >&5 +echo "$as_me:19505: result: $gmp_cv_asm_lsym_prefix" >&5 echo "${ECHO_T}$gmp_cv_asm_lsym_prefix" >&6 echo "define(, <${gmp_cv_asm_lsym_prefix}>)" >> $gmp_tmpconfigm4 @@ -19435,7 +19510,7 @@ cat >>confdefs.h <&5 +echo "$as_me:19513: checking how to define a 32-bit word" >&5 echo $ECHO_N "checking how to define a 32-bit word... $ECHO_C" >&6 if test "${gmp_cv_asm_w32+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -19460,10 +19535,10 @@ foo$gmp_cv_asm_label_suffix .byte 0 EOF gmp_assemble="$CCAS $CFLAGS conftest.s >conftest.out 2>&1" -if { (eval echo "$as_me:19463: \"$gmp_assemble\"") >&5 +if { (eval echo "$as_me:19538: \"$gmp_assemble\"") >&5 (eval $gmp_assemble) 2>&5 ac_status=$? - echo "$as_me:19466: \$? = $ac_status" >&5 + echo "$as_me:19541: \$? = $ac_status" >&5 (exit $ac_status); }; then cat conftest.out >&5 gmp_tmp_val=`$NM conftest.$OBJEXT | grep foo | \ @@ -19485,17 +19560,17 @@ rm -f conftest* ;; esac if test -z "$gmp_cv_asm_w32"; then - { { echo "$as_me:19488: error: cannot determine how to define a 32-bit word" >&5 + { { echo "$as_me:19563: error: cannot determine how to define a 32-bit word" >&5 echo "$as_me: error: cannot determine how to define a 32-bit word" >&2;} { (exit 1); exit 1; }; } fi fi -echo "$as_me:19494: result: $gmp_cv_asm_w32" >&5 +echo "$as_me:19569: result: $gmp_cv_asm_w32" >&5 echo "${ECHO_T}$gmp_cv_asm_w32" >&6 echo "define(, <$gmp_cv_asm_w32>)" >> $gmp_tmpconfigm4 -echo "$as_me:19498: checking if .align assembly directive is logarithmic" >&5 +echo "$as_me:19573: checking if .align assembly directive is logarithmic" >&5 echo $ECHO_N "checking if .align assembly directive is logarithmic... $ECHO_C" >&6 if test "${gmp_cv_asm_align_log+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -19510,10 +19585,10 @@ foo$gmp_cv_asm_label_suffix .byte 2 EOF gmp_assemble="$CCAS $CFLAGS conftest.s >conftest.out 2>&1" -if { (eval echo "$as_me:19513: \"$gmp_assemble\"") >&5 +if { (eval echo "$as_me:19588: \"$gmp_assemble\"") >&5 (eval $gmp_assemble) 2>&5 ac_status=$? - echo "$as_me:19516: \$? = $ac_status" >&5 + echo "$as_me:19591: \$? = $ac_status" >&5 (exit $ac_status); }; then cat conftest.out >&5 gmp_tmp_val=`$NM conftest.$OBJEXT | grep foo | \ @@ -19527,14 +19602,14 @@ else cat conftest.out >&5 echo "configure: failed program was:" >&5 cat conftest.s >&5 - { { echo "$as_me:19530: error: cannot assemble alignment test" >&5 + { { echo "$as_me:19605: error: cannot assemble alignment test" >&5 echo "$as_me: error: cannot assemble alignment test" >&2;} { (exit 1); exit 1; }; } fi rm -f conftest* fi -echo "$as_me:19537: result: $gmp_cv_asm_align_log" >&5 +echo "$as_me:19612: result: $gmp_cv_asm_align_log" >&5 echo "${ECHO_T}$gmp_cv_asm_align_log" >&6 echo "define(,<$gmp_cv_asm_align_log>)" >> $gmp_tmpconfigm4 @@ -19542,7 +19617,7 @@ echo "define(,<$gmp_cv_asm_align_log>)" >> $gmp_tmpconfigm4 case $host in m68*-*-*) -echo "$as_me:19545: checking assembler instruction and register style" >&5 +echo "$as_me:19620: checking assembler instruction and register style" >&5 echo $ECHO_N "checking assembler instruction and register style... $ECHO_C" >&6 if test "${gmp_cv_asm_m68k_instruction+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -19554,10 +19629,10 @@ for i in "addl %d0,%d1" "add.l %d0,%d1" "addl d0,d1" "add.l d0,d1"; do $i EOF gmp_assemble="$CCAS $CFLAGS conftest.s >conftest.out 2>&1" -if { (eval echo "$as_me:19557: \"$gmp_assemble\"") >&5 +if { (eval echo "$as_me:19632: \"$gmp_assemble\"") >&5 (eval $gmp_assemble) 2>&5 ac_status=$? - echo "$as_me:19560: \$? = $ac_status" >&5 + echo "$as_me:19635: \$? = $ac_status" >&5 (exit $ac_status); }; then cat conftest.out >&5 gmp_cv_asm_m68k_instruction=$i @@ -19574,14 +19649,14 @@ rm -f conftest* done fi -echo "$as_me:19577: result: $gmp_cv_asm_m68k_instruction" >&5 +echo "$as_me:19652: result: $gmp_cv_asm_m68k_instruction" >&5 echo "${ECHO_T}$gmp_cv_asm_m68k_instruction" >&6 case $gmp_cv_asm_m68k_instruction in "addl d0,d1") want_dot_size=no; want_register_percent=no ;; "addl %d0,%d1") want_dot_size=no; want_register_percent=yes ;; "add.l d0,d1") want_dot_size=yes; want_register_percent=no ;; "add.l %d0,%d1") want_dot_size=yes; want_register_percent=yes ;; -*) { { echo "$as_me:19584: error: cannot determine assembler instruction and register style" >&5 +*) { { echo "$as_me:19659: error: cannot determine assembler instruction and register style" >&5 echo "$as_me: error: cannot determine assembler instruction and register style" >&2;} { (exit 1); exit 1; }; } ;; esac @@ -19590,7 +19665,7 @@ echo "define(, <\`$want_register_percent'>)" >> $gmp_tmpc echo "define(, <\`$want_dot_size'>)" >> $gmp_tmpconfigm4 -echo "$as_me:19593: checking assembler addressing style" >&5 +echo "$as_me:19668: checking assembler addressing style" >&5 echo $ECHO_N "checking assembler addressing style... $ECHO_C" >&6 if test "${gmp_cv_asm_m68k_addressing+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -19598,14 +19673,14 @@ else case $gmp_cv_asm_m68k_instruction in addl*) movel=movel ;; add.l*) movel=move.l ;; -*) { { echo "$as_me:19601: error: oops, unrecognised gmp_cv_asm_m68k_instruction" >&5 +*) { { echo "$as_me:19676: error: oops, unrecognised gmp_cv_asm_m68k_instruction" >&5 echo "$as_me: error: oops, unrecognised gmp_cv_asm_m68k_instruction" >&2;} { (exit 1); exit 1; }; } ;; esac case $gmp_cv_asm_m68k_instruction in *"%d0,%d1") dreg=%d0; areg=%a0 ;; *"d0,d1") dreg=d0; areg=a0 ;; -*) { { echo "$as_me:19608: error: oops, unrecognised gmp_cv_asm_m68k_instruction" >&5 +*) { { echo "$as_me:19683: error: oops, unrecognised gmp_cv_asm_m68k_instruction" >&5 echo "$as_me: error: oops, unrecognised gmp_cv_asm_m68k_instruction" >&2;} { (exit 1); exit 1; }; } ;; esac @@ -19614,10 +19689,10 @@ cat >conftest.s <&5 +if { (eval echo "$as_me:19692: \"$gmp_assemble\"") >&5 (eval $gmp_assemble) 2>&5 ac_status=$? - echo "$as_me:19620: \$? = $ac_status" >&5 + echo "$as_me:19695: \$? = $ac_status" >&5 (exit $ac_status); }; then cat conftest.out >&5 gmp_cv_asm_m68k_addressing=mit @@ -19630,10 +19705,10 @@ else $movel $dreg, -($areg) EOF gmp_assemble="$CCAS $CFLAGS conftest.s >conftest.out 2>&1" -if { (eval echo "$as_me:19633: \"$gmp_assemble\"") >&5 +if { (eval echo "$as_me:19708: \"$gmp_assemble\"") >&5 (eval $gmp_assemble) 2>&5 ac_status=$? - echo "$as_me:19636: \$? = $ac_status" >&5 + echo "$as_me:19711: \$? = $ac_status" >&5 (exit $ac_status); }; then cat conftest.out >&5 gmp_cv_asm_m68k_addressing=motorola @@ -19641,7 +19716,7 @@ else cat conftest.out >&5 echo "configure: failed program was:" >&5 cat conftest.s >&5 - { { echo "$as_me:19644: error: cannot determine assembler addressing style" >&5 + { { echo "$as_me:19719: error: cannot determine assembler addressing style" >&5 echo "$as_me: error: cannot determine assembler addressing style" >&2;} { (exit 1); exit 1; }; } fi @@ -19651,12 +19726,12 @@ fi rm -f conftest* fi -echo "$as_me:19654: result: $gmp_cv_asm_m68k_addressing" >&5 +echo "$as_me:19729: result: $gmp_cv_asm_m68k_addressing" >&5 echo "${ECHO_T}$gmp_cv_asm_m68k_addressing" >&6 echo "define(, <\`$gmp_cv_asm_m68k_addressing'>)" >> $gmp_tmpconfigm4 -echo "$as_me:19659: checking assembler shortest branches" >&5 +echo "$as_me:19734: checking assembler shortest branches" >&5 echo $ECHO_N "checking assembler shortest branches... $ECHO_C" >&6 if test "${gmp_cv_asm_m68k_branches+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -19669,10 +19744,10 @@ foo$gmp_cv_asm_label_suffix $i foo EOF gmp_assemble="$CCAS $CFLAGS conftest.s >conftest.out 2>&1" -if { (eval echo "$as_me:19672: \"$gmp_assemble\"") >&5 +if { (eval echo "$as_me:19747: \"$gmp_assemble\"") >&5 (eval $gmp_assemble) 2>&5 ac_status=$? - echo "$as_me:19675: \$? = $ac_status" >&5 + echo "$as_me:19750: \$? = $ac_status" >&5 (exit $ac_status); }; then cat conftest.out >&5 gmp_cv_asm_m68k_branches=$i @@ -19689,10 +19764,10 @@ rm -f conftest* done fi -echo "$as_me:19692: result: $gmp_cv_asm_m68k_branches" >&5 +echo "$as_me:19767: result: $gmp_cv_asm_m68k_branches" >&5 echo "${ECHO_T}$gmp_cv_asm_m68k_branches" >&6 if test "$gmp_cv_asm_m68k_branches" = unknown; then - { { echo "$as_me:19695: error: cannot determine assembler branching style" >&5 + { { echo "$as_me:19770: error: cannot determine assembler branching style" >&5 echo "$as_me: error: cannot determine assembler branching style" >&2;} { (exit 1); exit 1; }; } fi @@ -19702,7 +19777,7 @@ echo "define(, <\`$gmp_cv_asm_m68k_branches'>)" >> $gmp_tmpconfig ;; powerpc*-*-*) -echo "$as_me:19705: checking if the assembler needs r on registers" >&5 +echo "$as_me:19780: checking if the assembler needs r on registers" >&5 echo $ECHO_N "checking if the assembler needs r on registers... $ECHO_C" >&6 if test "${gmp_cv_asm_powerpc_r_registers+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -19712,10 +19787,10 @@ else mtctr 6 EOF gmp_assemble="$CCAS $CFLAGS conftest.s >conftest.out 2>&1" -if { (eval echo "$as_me:19715: \"$gmp_assemble\"") >&5 +if { (eval echo "$as_me:19790: \"$gmp_assemble\"") >&5 (eval $gmp_assemble) 2>&5 ac_status=$? - echo "$as_me:19718: \$? = $ac_status" >&5 + echo "$as_me:19793: \$? = $ac_status" >&5 (exit $ac_status); }; then cat conftest.out >&5 gmp_cv_asm_powerpc_r_registers=no @@ -19728,10 +19803,10 @@ else mtctr r6 EOF gmp_assemble="$CCAS $CFLAGS conftest.s >conftest.out 2>&1" -if { (eval echo "$as_me:19731: \"$gmp_assemble\"") >&5 +if { (eval echo "$as_me:19806: \"$gmp_assemble\"") >&5 (eval $gmp_assemble) 2>&5 ac_status=$? - echo "$as_me:19734: \$? = $ac_status" >&5 + echo "$as_me:19809: \$? = $ac_status" >&5 (exit $ac_status); }; then cat conftest.out >&5 gmp_cv_asm_powerpc_r_registers=yes @@ -19739,7 +19814,7 @@ else cat conftest.out >&5 echo "configure: failed program was:" >&5 cat conftest.s >&5 - { { echo "$as_me:19742: error: neither \"mtctr 6\" nor \"mtctr r6\" works" >&5 + { { echo "$as_me:19817: error: neither \"mtctr 6\" nor \"mtctr r6\" works" >&5 echo "$as_me: error: neither \"mtctr 6\" nor \"mtctr r6\" works" >&2;} { (exit 1); exit 1; }; } fi @@ -19749,7 +19824,7 @@ fi rm -f conftest* fi -echo "$as_me:19752: result: $gmp_cv_asm_powerpc_r_registers" >&5 +echo "$as_me:19827: result: $gmp_cv_asm_powerpc_r_registers" >&5 echo "${ECHO_T}$gmp_cv_asm_powerpc_r_registers" >&6 echo "define(,<$gmp_cv_asm_powerpc_r_registers>)" >> $gmp_tmpconfigm4 @@ -19764,6 +19839,13 @@ echo "include_mpn(\`powerpc64/aix.m4')" >> $gmp_tmpconfigm4i ;; *) echo "include_mpn(\`powerpc32/aix.m4')" >> $gmp_tmpconfigm4i + ;; + esac + ;; + powerpc*-*-linux*) + case $ABI in + 64) +echo "include_mpn(\`powerpc64/linux64.m4')" >> $gmp_tmpconfigm4i ;; esac ;; @@ -19778,7 +19860,7 @@ echo "include_mpn(\`powerpc32/aix.m4')" >> $gmp_tmpconfigm4i case $ABI in 64) -echo "$as_me:19781: checking if the assembler accepts \".register\"" >&5 +echo "$as_me:19863: checking if the assembler accepts \".register\"" >&5 echo $ECHO_N "checking if the assembler accepts \".register\"... $ECHO_C" >&6 if test "${gmp_cv_asm_sparc_register+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -19789,10 +19871,10 @@ else EOF gmp_assemble="$CCAS $CFLAGS conftest.s >conftest.out 2>&1" -if { (eval echo "$as_me:19792: \"$gmp_assemble\"") >&5 +if { (eval echo "$as_me:19874: \"$gmp_assemble\"") >&5 (eval $gmp_assemble) 2>&5 ac_status=$? - echo "$as_me:19795: \$? = $ac_status" >&5 + echo "$as_me:19877: \$? = $ac_status" >&5 (exit $ac_status); }; then cat conftest.out >&5 gmp_cv_asm_sparc_register=yes @@ -19805,7 +19887,7 @@ fi rm -f conftest* fi -echo "$as_me:19808: result: $gmp_cv_asm_sparc_register" >&5 +echo "$as_me:19890: result: $gmp_cv_asm_sparc_register" >&5 echo "${ECHO_T}$gmp_cv_asm_sparc_register" >&6 echo "define(,<$gmp_cv_asm_sparc_register>)" >> $gmp_tmpconfigm4 @@ -19813,9 +19895,9 @@ echo "define(,<$gmp_cv_asm_sparc_register>)" >> $gmp_tmpconfigm4 ;; esac ;; - i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-*) + i?86*-*-* | k[5-8]*-*-* | pentium*-*-* | athlon-*-* | viac3*-*-* | x86_64-*-*) -echo "$as_me:19818: checking if the .align directive accepts an 0x90 fill in .text" >&5 +echo "$as_me:19900: checking if the .align directive accepts an 0x90 fill in .text" >&5 echo $ECHO_N "checking if the .align directive accepts an 0x90 fill in .text... $ECHO_C" >&6 if test "${gmp_cv_asm_align_fill_0x90+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -19827,10 +19909,10 @@ else .align 4, 0x90 EOF gmp_assemble="$CCAS $CFLAGS conftest.s >conftest.out 2>&1" -if { (eval echo "$as_me:19830: \"$gmp_assemble\"") >&5 +if { (eval echo "$as_me:19912: \"$gmp_assemble\"") >&5 (eval $gmp_assemble) 2>&5 ac_status=$? - echo "$as_me:19833: \$? = $ac_status" >&5 + echo "$as_me:19915: \$? = $ac_status" >&5 (exit $ac_status); }; then cat conftest.out >&5 if grep "Warning: Fill parameter ignored for executable section" conftest.out >/dev/null; then @@ -19848,12 +19930,12 @@ fi rm -f conftest* fi -echo "$as_me:19851: result: $gmp_cv_asm_align_fill_0x90" >&5 +echo "$as_me:19933: result: $gmp_cv_asm_align_fill_0x90" >&5 echo "${ECHO_T}$gmp_cv_asm_align_fill_0x90" >&6 echo "define(,<$gmp_cv_asm_align_fill_0x90>)" >> $gmp_tmpconfigm4 -echo "$as_me:19856: checking if the assembler takes cl with shldl" >&5 +echo "$as_me:19938: checking if the assembler takes cl with shldl" >&5 echo $ECHO_N "checking if the assembler takes cl with shldl... $ECHO_C" >&6 if test "${gmp_cv_asm_x86_shldl_cl+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -19863,10 +19945,10 @@ else shldl %cl, %eax, %ebx EOF gmp_assemble="$CCAS $CFLAGS conftest.s >conftest.out 2>&1" -if { (eval echo "$as_me:19866: \"$gmp_assemble\"") >&5 +if { (eval echo "$as_me:19948: \"$gmp_assemble\"") >&5 (eval $gmp_assemble) 2>&5 ac_status=$? - echo "$as_me:19869: \$? = $ac_status" >&5 + echo "$as_me:19951: \$? = $ac_status" >&5 (exit $ac_status); }; then cat conftest.out >&5 gmp_cv_asm_x86_shldl_cl=yes @@ -19879,7 +19961,7 @@ fi rm -f conftest* fi -echo "$as_me:19882: result: $gmp_cv_asm_x86_shldl_cl" >&5 +echo "$as_me:19964: result: $gmp_cv_asm_x86_shldl_cl" >&5 echo "${ECHO_T}$gmp_cv_asm_x86_shldl_cl" >&6 if test "$gmp_cv_asm_x86_shldl_cl" = "yes"; then @@ -19893,7 +19975,7 @@ fi if test "$enable_profiling" != no; then -echo "$as_me:19896: checking how to call x86 mcount" >&5 +echo "$as_me:19978: checking how to call x86 mcount" >&5 echo $ECHO_N "checking how to call x86 mcount... $ECHO_C" >&6 cat >conftest.c <&5 + if { (eval echo "$as_me:19986: \"$gmp_asmout_compile\"") >&5 (eval $gmp_asmout_compile) 2>&5 ac_status=$? - echo "$as_me:19907: \$? = $ac_status" >&5 + echo "$as_me:19989: \$? = $ac_status" >&5 (exit $ac_status); }; then if grep '\.data' conftest.s >/dev/null; then mcount_nonpic_reg=`sed -n '/esp/!s/.*movl.*,\(%[a-z]*\).*$/\1/p' conftest.s` @@ -19913,12 +19995,12 @@ if test "$enable_static" = yes; then fi mcount_nonpic_call=`grep 'call.*mcount' conftest.s` if test -z "$mcount_nonpic_call"; then - { { echo "$as_me:19916: error: Cannot find mcount call for non-PIC" >&5 + { { echo "$as_me:19998: error: Cannot find mcount call for non-PIC" >&5 echo "$as_me: error: Cannot find mcount call for non-PIC" >&2;} { (exit 1); exit 1; }; } fi else - { { echo "$as_me:19921: error: Cannot compile test program for non-PIC" >&5 + { { echo "$as_me:20003: error: Cannot compile test program for non-PIC" >&5 echo "$as_me: error: Cannot compile test program for non-PIC" >&2;} { (exit 1); exit 1; }; } fi @@ -19926,10 +20008,10 @@ fi if test "$enable_shared" = yes; then gmp_asmout_compile="$CC $CFLAGS $CPPFLAGS $lt_prog_compiler_pic -S conftest.c 1>&5" - if { (eval echo "$as_me:19929: \"$gmp_asmout_compile\"") >&5 + if { (eval echo "$as_me:20011: \"$gmp_asmout_compile\"") >&5 (eval $gmp_asmout_compile) 2>&5 ac_status=$? - echo "$as_me:19932: \$? = $ac_status" >&5 + echo "$as_me:20014: \$? = $ac_status" >&5 (exit $ac_status); }; then if grep '\.data' conftest.s >/dev/null; then case $lt_prog_compiler_pic in @@ -19946,12 +20028,12 @@ if test "$enable_shared" = yes; then fi mcount_pic_call=`grep 'call.*mcount' conftest.s` if test -z "$mcount_pic_call"; then - { { echo "$as_me:19949: error: Cannot find mcount call for PIC" >&5 + { { echo "$as_me:20031: error: Cannot find mcount call for PIC" >&5 echo "$as_me: error: Cannot find mcount call for PIC" >&2;} { (exit 1); exit 1; }; } fi else - { { echo "$as_me:19954: error: Cannot compile test program for PIC" >&5 + { { echo "$as_me:20036: error: Cannot compile test program for PIC" >&5 echo "$as_me: error: Cannot compile test program for PIC" >&2;} { (exit 1); exit 1; }; } fi @@ -19966,7 +20048,7 @@ echo "define(, <\`$mcount_pic_reg'>)" >> $gmp_tmpconfigm4 echo "define(, <\`$mcount_pic_call'>)" >> $gmp_tmpconfigm4 rm -f conftest.* -echo "$as_me:19969: result: determined" >&5 +echo "$as_me:20051: result: determined" >&5 echo "${ECHO_T}determined" >&6 fi @@ -19995,7 +20077,7 @@ for gmp_mparam_dir in $path; do fi done if test -z "$gmp_mparam_source"; then - { { echo "$as_me:19998: error: no version of gmp-mparam.h found in path: $path" >&5 + { { echo "$as_me:20080: error: no version of gmp-mparam.h found in path: $path" >&5 echo "$as_me: error: no version of gmp-mparam.h found in path: $path" >&2;} { (exit 1); exit 1; }; } fi @@ -20027,13 +20109,13 @@ BITS_PER_MP_LIMB=`sed -n 's/^#define BITS_PER_MP_LIMB[ ][ ]*\([0-9]*\).*$/\1/p if test -n "$BITS_PER_MP_LIMB" \ && grep "^#define BYTES_PER_MP_LIMB" $gmp_mparam_source >/dev/null; then : ; else - echo "$as_me:20030: checking for mp_limb_t" >&5 + echo "$as_me:20112: checking for mp_limb_t" >&5 echo $ECHO_N "checking for mp_limb_t... $ECHO_C" >&6 if test "${ac_cv_type_mp_limb_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 20036 "configure" +#line 20118 "configure" #include "confdefs.h" #include #define __GMP_WITHIN_CONFIGURE 1 /* ignore template stuff */ @@ -20055,16 +20137,16 @@ if (sizeof (mp_limb_t)) } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:20058: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:20140: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:20061: \$? = $ac_status" >&5 + echo "$as_me:20143: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:20064: \"$ac_try\"") >&5 + { (eval echo "$as_me:20146: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:20067: \$? = $ac_status" >&5 + echo "$as_me:20149: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_type_mp_limb_t=yes else @@ -20074,10 +20156,10 @@ ac_cv_type_mp_limb_t=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:20077: result: $ac_cv_type_mp_limb_t" >&5 +echo "$as_me:20159: result: $ac_cv_type_mp_limb_t" >&5 echo "${ECHO_T}$ac_cv_type_mp_limb_t" >&6 -echo "$as_me:20080: checking size of mp_limb_t" >&5 +echo "$as_me:20162: checking size of mp_limb_t" >&5 echo $ECHO_N "checking size of mp_limb_t... $ECHO_C" >&6 if test "${ac_cv_sizeof_mp_limb_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -20086,7 +20168,7 @@ else if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF -#line 20089 "configure" +#line 20171 "configure" #include "confdefs.h" #include #define __GMP_WITHIN_CONFIGURE 1 /* ignore template stuff */ @@ -20105,21 +20187,21 @@ int _array_ [1 - 2 * !((sizeof (mp_limb_t)) >= 0)] } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:20108: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:20190: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:20111: \$? = $ac_status" >&5 + echo "$as_me:20193: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:20114: \"$ac_try\"") >&5 + { (eval echo "$as_me:20196: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:20117: \$? = $ac_status" >&5 + echo "$as_me:20199: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF -#line 20122 "configure" +#line 20204 "configure" #include "confdefs.h" #include #define __GMP_WITHIN_CONFIGURE 1 /* ignore template stuff */ @@ -20138,16 +20220,16 @@ int _array_ [1 - 2 * !((sizeof (mp_limb_t)) <= $ac_mid)] } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:20141: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:20223: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:20144: \$? = $ac_status" >&5 + echo "$as_me:20226: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:20147: \"$ac_try\"") >&5 + { (eval echo "$as_me:20229: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:20150: \$? = $ac_status" >&5 + echo "$as_me:20232: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_hi=$ac_mid; break else @@ -20163,7 +20245,7 @@ cat conftest.$ac_ext >&5 ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF -#line 20166 "configure" +#line 20248 "configure" #include "confdefs.h" #include #define __GMP_WITHIN_CONFIGURE 1 /* ignore template stuff */ @@ -20182,16 +20264,16 @@ int _array_ [1 - 2 * !((sizeof (mp_limb_t)) >= $ac_mid)] } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:20185: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:20267: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:20188: \$? = $ac_status" >&5 + echo "$as_me:20270: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:20191: \"$ac_try\"") >&5 + { (eval echo "$as_me:20273: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:20194: \$? = $ac_status" >&5 + echo "$as_me:20276: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_lo=$ac_mid; break else @@ -20207,7 +20289,7 @@ rm -f conftest.$ac_objext conftest.$ac_ext while test "x$ac_lo" != "x$ac_hi"; do ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` cat >conftest.$ac_ext <<_ACEOF -#line 20210 "configure" +#line 20292 "configure" #include "confdefs.h" #include #define __GMP_WITHIN_CONFIGURE 1 /* ignore template stuff */ @@ -20226,16 +20308,16 @@ int _array_ [1 - 2 * !((sizeof (mp_limb_t)) <= $ac_mid)] } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:20229: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:20311: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:20232: \$? = $ac_status" >&5 + echo "$as_me:20314: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:20235: \"$ac_try\"") >&5 + { (eval echo "$as_me:20317: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:20238: \$? = $ac_status" >&5 + echo "$as_me:20320: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_hi=$ac_mid else @@ -20248,12 +20330,12 @@ done ac_cv_sizeof_mp_limb_t=$ac_lo else if test "$cross_compiling" = yes; then - { { echo "$as_me:20251: error: cannot run test program while cross compiling" >&5 + { { echo "$as_me:20333: error: cannot run test program while cross compiling" >&5 echo "$as_me: error: cannot run test program while cross compiling" >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF -#line 20256 "configure" +#line 20338 "configure" #include "confdefs.h" #include #define __GMP_WITHIN_CONFIGURE 1 /* ignore template stuff */ @@ -20276,15 +20358,15 @@ fclose (f); } _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:20279: \"$ac_link\"") >&5 +if { (eval echo "$as_me:20361: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:20282: \$? = $ac_status" >&5 + echo "$as_me:20364: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:20284: \"$ac_try\"") >&5 + { (eval echo "$as_me:20366: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:20287: \$? = $ac_status" >&5 + echo "$as_me:20369: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_sizeof_mp_limb_t=`cat conftest.val` else @@ -20300,14 +20382,14 @@ else ac_cv_sizeof_mp_limb_t=0 fi fi -echo "$as_me:20303: result: $ac_cv_sizeof_mp_limb_t" >&5 +echo "$as_me:20385: result: $ac_cv_sizeof_mp_limb_t" >&5 echo "${ECHO_T}$ac_cv_sizeof_mp_limb_t" >&6 cat >>confdefs.h <&5 + { { echo "$as_me:20392: error: some sort of compiler problem, mp_limb_t doesn't seem to work" >&5 echo "$as_me: error: some sort of compiler problem, mp_limb_t doesn't seem to work" >&2;} { (exit 1); exit 1; }; } fi @@ -20328,13 +20410,13 @@ if grep "^#define BITS_PER_ULONG" $gmp_mparam_source >/dev/null; then : ; else case $limb_chosen in longlong) - echo "$as_me:20331: checking for unsigned long" >&5 + echo "$as_me:20413: checking for unsigned long" >&5 echo $ECHO_N "checking for unsigned long... $ECHO_C" >&6 if test "${ac_cv_type_unsigned_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 20337 "configure" +#line 20419 "configure" #include "confdefs.h" $ac_includes_default int @@ -20349,16 +20431,16 @@ if (sizeof (unsigned long)) } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:20352: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:20434: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:20355: \$? = $ac_status" >&5 + echo "$as_me:20437: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:20358: \"$ac_try\"") >&5 + { (eval echo "$as_me:20440: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:20361: \$? = $ac_status" >&5 + echo "$as_me:20443: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_type_unsigned_long=yes else @@ -20368,10 +20450,10 @@ ac_cv_type_unsigned_long=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:20371: result: $ac_cv_type_unsigned_long" >&5 +echo "$as_me:20453: result: $ac_cv_type_unsigned_long" >&5 echo "${ECHO_T}$ac_cv_type_unsigned_long" >&6 -echo "$as_me:20374: checking size of unsigned long" >&5 +echo "$as_me:20456: checking size of unsigned long" >&5 echo $ECHO_N "checking size of unsigned long... $ECHO_C" >&6 if test "${ac_cv_sizeof_unsigned_long+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -20380,7 +20462,7 @@ else if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat >conftest.$ac_ext <<_ACEOF -#line 20383 "configure" +#line 20465 "configure" #include "confdefs.h" $ac_includes_default int @@ -20392,21 +20474,21 @@ int _array_ [1 - 2 * !((sizeof (unsigned long)) >= 0)] } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:20395: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:20477: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:20398: \$? = $ac_status" >&5 + echo "$as_me:20480: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:20401: \"$ac_try\"") >&5 + { (eval echo "$as_me:20483: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:20404: \$? = $ac_status" >&5 + echo "$as_me:20486: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_lo=0 ac_mid=0 while :; do cat >conftest.$ac_ext <<_ACEOF -#line 20409 "configure" +#line 20491 "configure" #include "confdefs.h" $ac_includes_default int @@ -20418,16 +20500,16 @@ int _array_ [1 - 2 * !((sizeof (unsigned long)) <= $ac_mid)] } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:20421: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:20503: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:20424: \$? = $ac_status" >&5 + echo "$as_me:20506: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:20427: \"$ac_try\"") >&5 + { (eval echo "$as_me:20509: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:20430: \$? = $ac_status" >&5 + echo "$as_me:20512: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_hi=$ac_mid; break else @@ -20443,7 +20525,7 @@ cat conftest.$ac_ext >&5 ac_hi=-1 ac_mid=-1 while :; do cat >conftest.$ac_ext <<_ACEOF -#line 20446 "configure" +#line 20528 "configure" #include "confdefs.h" $ac_includes_default int @@ -20455,16 +20537,16 @@ int _array_ [1 - 2 * !((sizeof (unsigned long)) >= $ac_mid)] } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:20458: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:20540: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:20461: \$? = $ac_status" >&5 + echo "$as_me:20543: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:20464: \"$ac_try\"") >&5 + { (eval echo "$as_me:20546: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:20467: \$? = $ac_status" >&5 + echo "$as_me:20549: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_lo=$ac_mid; break else @@ -20480,7 +20562,7 @@ rm -f conftest.$ac_objext conftest.$ac_ext while test "x$ac_lo" != "x$ac_hi"; do ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` cat >conftest.$ac_ext <<_ACEOF -#line 20483 "configure" +#line 20565 "configure" #include "confdefs.h" $ac_includes_default int @@ -20492,16 +20574,16 @@ int _array_ [1 - 2 * !((sizeof (unsigned long)) <= $ac_mid)] } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:20495: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:20577: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:20498: \$? = $ac_status" >&5 + echo "$as_me:20580: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:20501: \"$ac_try\"") >&5 + { (eval echo "$as_me:20583: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:20504: \$? = $ac_status" >&5 + echo "$as_me:20586: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_hi=$ac_mid else @@ -20514,12 +20596,12 @@ done ac_cv_sizeof_unsigned_long=$ac_lo else if test "$cross_compiling" = yes; then - { { echo "$as_me:20517: error: cannot run test program while cross compiling" >&5 + { { echo "$as_me:20599: error: cannot run test program while cross compiling" >&5 echo "$as_me: error: cannot run test program while cross compiling" >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF -#line 20522 "configure" +#line 20604 "configure" #include "confdefs.h" $ac_includes_default int @@ -20535,15 +20617,15 @@ fclose (f); } _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:20538: \"$ac_link\"") >&5 +if { (eval echo "$as_me:20620: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:20541: \$? = $ac_status" >&5 + echo "$as_me:20623: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:20543: \"$ac_try\"") >&5 + { (eval echo "$as_me:20625: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:20546: \$? = $ac_status" >&5 + echo "$as_me:20628: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_sizeof_unsigned_long=`cat conftest.val` else @@ -20559,7 +20641,7 @@ else ac_cv_sizeof_unsigned_long=0 fi fi -echo "$as_me:20562: result: $ac_cv_sizeof_unsigned_long" >&5 +echo "$as_me:20644: result: $ac_cv_sizeof_unsigned_long" >&5 echo "${ECHO_T}$ac_cv_sizeof_unsigned_long" >&6 cat >>confdefs.h <&5 +echo "$as_me:20700: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 20624 "configure" +#line 20706 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. */ @@ -20652,16 +20734,16 @@ f = $ac_func; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:20655: \"$ac_link\"") >&5 +if { (eval echo "$as_me:20737: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:20658: \$? = $ac_status" >&5 + echo "$as_me:20740: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:20661: \"$ac_try\"") >&5 + { (eval echo "$as_me:20743: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:20664: \$? = $ac_status" >&5 + echo "$as_me:20746: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_var=yes" else @@ -20671,7 +20753,7 @@ eval "$as_ac_var=no" fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:20674: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "$as_me:20756: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <&5 + echo "$as_me:20771: checking for IEEE-754 switches" >&5 echo $ECHO_N "checking for IEEE-754 switches... $ECHO_C" >&6 if test "${mpfr_cv_ieee_switches+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -20699,7 +20781,7 @@ else fi CFLAGS="$CFLAGS $mpfr_cv_ieee_switches" cat >conftest.$ac_ext <<_ACEOF -#line 20702 "configure" +#line 20784 "configure" #include "confdefs.h" int @@ -20711,16 +20793,16 @@ main () } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:20714: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:20796: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:20717: \$? = $ac_status" >&5 + echo "$as_me:20799: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:20720: \"$ac_try\"") >&5 + { (eval echo "$as_me:20802: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:20723: \$? = $ac_status" >&5 + echo "$as_me:20805: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else @@ -20731,7 +20813,7 @@ fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:20734: result: $mpfr_cv_ieee_switches" >&5 +echo "$as_me:20816: result: $mpfr_cv_ieee_switches" >&5 echo "${ECHO_T}$mpfr_cv_ieee_switches" >&6 if test "$mpfr_cv_ieee_switches" = "none"; then CFLAGS="$saved_CFLAGS" @@ -20743,23 +20825,23 @@ esac for ac_header in fpu_control.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` -echo "$as_me:20746: checking for $ac_header" >&5 +echo "$as_me:20828: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 20752 "configure" +#line 20834 "configure" #include "confdefs.h" #include <$ac_header> _ACEOF -if { (eval echo "$as_me:20756: \"$ac_cpp conftest.$ac_ext\"") >&5 +if { (eval echo "$as_me:20838: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 - echo "$as_me:20762: \$? = $ac_status" >&5 + echo "$as_me:20844: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag @@ -20778,7 +20860,7 @@ else fi rm -f conftest.err conftest.$ac_ext fi -echo "$as_me:20781: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "$as_me:20863: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <&5 +echo "$as_me:20873: checking for fesetround" >&5 echo $ECHO_N "checking for fesetround... $ECHO_C" >&6 if test "${mpfr_cv_have_fesetround+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -20797,7 +20879,7 @@ else saved_LIBS="$LIBS" LIBS="$LIBS $LM9X" cat >conftest.$ac_ext <<_ACEOF -#line 20800 "configure" +#line 20882 "configure" #include "confdefs.h" #include int @@ -20809,16 +20891,16 @@ fesetround(FE_TONEAREST); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:20812: \"$ac_link\"") >&5 +if { (eval echo "$as_me:20894: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:20815: \$? = $ac_status" >&5 + echo "$as_me:20897: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:20818: \"$ac_try\"") >&5 + { (eval echo "$as_me:20900: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:20821: \$? = $ac_status" >&5 + echo "$as_me:20903: \$? = $ac_status" >&5 (exit $ac_status); }; }; then mpfr_cv_have_fesetround=yes else @@ -20830,7 +20912,7 @@ rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS="$saved_LIBS" fi -echo "$as_me:20833: result: $mpfr_cv_have_fesetround" >&5 +echo "$as_me:20915: result: $mpfr_cv_have_fesetround" >&5 echo "${ECHO_T}$mpfr_cv_have_fesetround" >&6 if test "$mpfr_cv_have_fesetround" = "yes"; then LIBS="$LIBS $LM9X" @@ -20844,13 +20926,13 @@ fi for ac_func in lrand48 do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -echo "$as_me:20847: checking for $ac_func" >&5 +echo "$as_me:20929: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 20853 "configure" +#line 20935 "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. */ @@ -20881,16 +20963,16 @@ f = $ac_func; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:20884: \"$ac_link\"") >&5 +if { (eval echo "$as_me:20966: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:20887: \$? = $ac_status" >&5 + echo "$as_me:20969: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:20890: \"$ac_try\"") >&5 + { (eval echo "$as_me:20972: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:20893: \$? = $ac_status" >&5 + echo "$as_me:20975: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_var=yes" else @@ -20900,7 +20982,7 @@ eval "$as_ac_var=no" fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi -echo "$as_me:20903: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "$as_me:20985: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <&5 +echo "$as_me:20995: checking for valid NaN" >&5 echo $ECHO_N "checking for valid NaN... $ECHO_C" >&6 if test "${mpfr_cv_valid_nan+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -20920,7 +21002,7 @@ if test "$cross_compiling" = yes; then mpfr_cv_valid_nan=no else cat >conftest.$ac_ext <<_ACEOF -#line 20923 "configure" +#line 21005 "configure" #include "confdefs.h" #include @@ -20932,15 +21014,15 @@ int main() _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:20935: \"$ac_link\"") >&5 +if { (eval echo "$as_me:21017: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:20938: \$? = $ac_status" >&5 + echo "$as_me:21020: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:20940: \"$ac_try\"") >&5 + { (eval echo "$as_me:21022: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:20943: \$? = $ac_status" >&5 + echo "$as_me:21025: \$? = $ac_status" >&5 (exit $ac_status); }; }; then mpfr_cv_valid_nan=yes else @@ -20953,7 +21035,7 @@ rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi -echo "$as_me:20956: result: $mpfr_cv_valid_nan" >&5 +echo "$as_me:21038: result: $mpfr_cv_valid_nan" >&5 echo "${ECHO_T}$mpfr_cv_valid_nan" >&6 if test "$mpfr_cv_valid_nan" = "yes"; then @@ -20964,7 +21046,7 @@ EOF fi if test -n "$GCC"; then - echo "$as_me:20967: checking for gcc float-conversion bug" >&5 + echo "$as_me:21049: checking for gcc float-conversion bug" >&5 echo $ECHO_N "checking for gcc float-conversion bug... $ECHO_C" >&6 if test "${mpfr_cv_gcc_floatconv_bug+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -20974,7 +21056,7 @@ else mpfr_cv_gcc_floatconv_bug="cannot test, use -ffloat-store" else cat >conftest.$ac_ext <<_ACEOF -#line 20977 "configure" +#line 21059 "configure" #include "confdefs.h" #include @@ -21002,15 +21084,15 @@ int main() _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:21005: \"$ac_link\"") >&5 +if { (eval echo "$as_me:21087: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:21008: \$? = $ac_status" >&5 + echo "$as_me:21090: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:21010: \"$ac_try\"") >&5 + { (eval echo "$as_me:21092: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:21013: \$? = $ac_status" >&5 + echo "$as_me:21095: \$? = $ac_status" >&5 (exit $ac_status); }; }; then mpfr_cv_gcc_floatconv_bug="no" else @@ -21023,14 +21105,14 @@ rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi -echo "$as_me:21026: result: $mpfr_cv_gcc_floatconv_bug" >&5 +echo "$as_me:21108: result: $mpfr_cv_gcc_floatconv_bug" >&5 echo "${ECHO_T}$mpfr_cv_gcc_floatconv_bug" >&6 if test "$mpfr_cv_gcc_floatconv_bug" != "no"; then CFLAGS="$CFLAGS -ffloat-store" fi fi -echo "$as_me:21033: checking for denormalized numbers" >&5 +echo "$as_me:21115: checking for denormalized numbers" >&5 echo $ECHO_N "checking for denormalized numbers... $ECHO_C" >&6 if test "${mpfr_cv_have_denorms+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -21040,7 +21122,7 @@ if test "$cross_compiling" = yes; then mpfr_cv_have_denorms=no else cat >conftest.$ac_ext <<_ACEOF -#line 21043 "configure" +#line 21125 "configure" #include "confdefs.h" #include @@ -21054,15 +21136,15 @@ int main() _ACEOF rm -f conftest$ac_exeext -if { (eval echo "$as_me:21057: \"$ac_link\"") >&5 +if { (eval echo "$as_me:21139: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:21060: \$? = $ac_status" >&5 + echo "$as_me:21142: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:21062: \"$ac_try\"") >&5 + { (eval echo "$as_me:21144: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:21065: \$? = $ac_status" >&5 + echo "$as_me:21147: \$? = $ac_status" >&5 (exit $ac_status); }; }; then mpfr_cv_have_denorms=yes else @@ -21075,7 +21157,7 @@ rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi -echo "$as_me:21078: result: $mpfr_cv_have_denorms" >&5 +echo "$as_me:21160: result: $mpfr_cv_have_denorms" >&5 echo "${ECHO_T}$mpfr_cv_have_denorms" >&6 if test "$mpfr_cv_have_denorms" = "yes"; then @@ -21178,13 +21260,13 @@ yes) HAVE_SYS_RESOURCE_H_01=1 no) HAVE_SYS_RESOURCE_H_01=0 ;; esac -echo "$as_me:21181: checking for stack_t" >&5 +echo "$as_me:21263: checking for stack_t" >&5 echo $ECHO_N "checking for stack_t... $ECHO_C" >&6 if test "${ac_cv_type_stack_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF -#line 21187 "configure" +#line 21269 "configure" #include "confdefs.h" #include @@ -21200,16 +21282,16 @@ if (sizeof (stack_t)) } _ACEOF rm -f conftest.$ac_objext -if { (eval echo "$as_me:21203: \"$ac_compile\"") >&5 +if { (eval echo "$as_me:21285: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? - echo "$as_me:21206: \$? = $ac_status" >&5 + echo "$as_me:21288: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:21209: \"$ac_try\"") >&5 + { (eval echo "$as_me:21291: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:21212: \$? = $ac_status" >&5 + echo "$as_me:21294: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_type_stack_t=yes else @@ -21219,7 +21301,7 @@ ac_cv_type_stack_t=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi -echo "$as_me:21222: result: $ac_cv_type_stack_t" >&5 +echo "$as_me:21304: result: $ac_cv_type_stack_t" >&5 echo "${ECHO_T}$ac_cv_type_stack_t" >&6 if test $ac_cv_type_stack_t = yes; then @@ -21242,7 +21324,7 @@ ac_config_files="$ac_config_files demos/calc/calc-config.h:demos/calc/calc-confi use_readline=$with_readline if test $with_readline = detect; then - echo "$as_me:21245: checking for readline in -lreadline" >&5 + echo "$as_me:21327: checking for readline in -lreadline" >&5 echo $ECHO_N "checking for readline in -lreadline... $ECHO_C" >&6 if test "${ac_cv_lib_readline_readline+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -21250,7 +21332,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-lreadline $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 21253 "configure" +#line 21335 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -21269,16 +21351,16 @@ readline (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:21272: \"$ac_link\"") >&5 +if { (eval echo "$as_me:21354: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:21275: \$? = $ac_status" >&5 + echo "$as_me:21357: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:21278: \"$ac_try\"") >&5 + { (eval echo "$as_me:21360: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:21281: \$? = $ac_status" >&5 + echo "$as_me:21363: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_readline_readline=yes else @@ -21289,7 +21371,7 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:21292: result: $ac_cv_lib_readline_readline" >&5 +echo "$as_me:21374: result: $ac_cv_lib_readline_readline" >&5 echo "${ECHO_T}$ac_cv_lib_readline_readline" >&6 if test $ac_cv_lib_readline_readline = yes; then use_readline=yes @@ -21308,7 +21390,7 @@ for ac_prog in 'bison -y' byacc do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -echo "$as_me:21311: checking for $ac_word" >&5 +echo "$as_me:21393: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_YACC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -21323,7 +21405,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_YACC="$ac_prog" -echo "$as_me:21326: found $ac_dir/$ac_word" >&5 +echo "$as_me:21408: found $ac_dir/$ac_word" >&5 break done @@ -21331,10 +21413,10 @@ fi fi YACC=$ac_cv_prog_YACC if test -n "$YACC"; then - echo "$as_me:21334: result: $YACC" >&5 + echo "$as_me:21416: result: $YACC" >&5 echo "${ECHO_T}$YACC" >&6 else - echo "$as_me:21337: result: no" >&5 + echo "$as_me:21419: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -21346,7 +21428,7 @@ for ac_prog in flex lex do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -echo "$as_me:21349: checking for $ac_word" >&5 +echo "$as_me:21431: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_LEX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -21361,7 +21443,7 @@ for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. $as_executable_p "$ac_dir/$ac_word" || continue ac_cv_prog_LEX="$ac_prog" -echo "$as_me:21364: found $ac_dir/$ac_word" >&5 +echo "$as_me:21446: found $ac_dir/$ac_word" >&5 break done @@ -21369,10 +21451,10 @@ fi fi LEX=$ac_cv_prog_LEX if test -n "$LEX"; then - echo "$as_me:21372: result: $LEX" >&5 + echo "$as_me:21454: result: $LEX" >&5 echo "${ECHO_T}$LEX" >&6 else - echo "$as_me:21375: result: no" >&5 + echo "$as_me:21457: result: no" >&5 echo "${ECHO_T}no" >&6 fi @@ -21382,7 +21464,7 @@ test -n "$LEX" || LEX=":" if test -z "$LEXLIB" then - echo "$as_me:21385: checking for yywrap in -lfl" >&5 + echo "$as_me:21467: checking for yywrap in -lfl" >&5 echo $ECHO_N "checking for yywrap in -lfl... $ECHO_C" >&6 if test "${ac_cv_lib_fl_yywrap+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -21390,7 +21472,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-lfl $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 21393 "configure" +#line 21475 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -21409,16 +21491,16 @@ yywrap (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:21412: \"$ac_link\"") >&5 +if { (eval echo "$as_me:21494: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:21415: \$? = $ac_status" >&5 + echo "$as_me:21497: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:21418: \"$ac_try\"") >&5 + { (eval echo "$as_me:21500: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:21421: \$? = $ac_status" >&5 + echo "$as_me:21503: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_fl_yywrap=yes else @@ -21429,12 +21511,12 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:21432: result: $ac_cv_lib_fl_yywrap" >&5 +echo "$as_me:21514: result: $ac_cv_lib_fl_yywrap" >&5 echo "${ECHO_T}$ac_cv_lib_fl_yywrap" >&6 if test $ac_cv_lib_fl_yywrap = yes; then LEXLIB="-lfl" else - echo "$as_me:21437: checking for yywrap in -ll" >&5 + echo "$as_me:21519: checking for yywrap in -ll" >&5 echo $ECHO_N "checking for yywrap in -ll... $ECHO_C" >&6 if test "${ac_cv_lib_l_yywrap+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -21442,7 +21524,7 @@ else ac_check_lib_save_LIBS=$LIBS LIBS="-ll $LIBS" cat >conftest.$ac_ext <<_ACEOF -#line 21445 "configure" +#line 21527 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ @@ -21461,16 +21543,16 @@ yywrap (); } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:21464: \"$ac_link\"") >&5 +if { (eval echo "$as_me:21546: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:21467: \$? = $ac_status" >&5 + echo "$as_me:21549: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:21470: \"$ac_try\"") >&5 + { (eval echo "$as_me:21552: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:21473: \$? = $ac_status" >&5 + echo "$as_me:21555: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_l_yywrap=yes else @@ -21481,7 +21563,7 @@ fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -echo "$as_me:21484: result: $ac_cv_lib_l_yywrap" >&5 +echo "$as_me:21566: result: $ac_cv_lib_l_yywrap" >&5 echo "${ECHO_T}$ac_cv_lib_l_yywrap" >&6 if test $ac_cv_lib_l_yywrap = yes; then LEXLIB="-ll" @@ -21492,7 +21574,7 @@ fi fi if test "x$LEX" != "x:"; then - echo "$as_me:21495: checking lex output file root" >&5 + echo "$as_me:21577: checking lex output file root" >&5 echo $ECHO_N "checking lex output file root... $ECHO_C" >&6 if test "${ac_cv_prog_lex_root+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -21506,16 +21588,16 @@ if test -f lex.yy.c; then elif test -f lexyy.c; then ac_cv_prog_lex_root=lexyy else - { { echo "$as_me:21509: error: cannot find output from $LEX; giving up" >&5 + { { echo "$as_me:21591: error: cannot find output from $LEX; giving up" >&5 echo "$as_me: error: cannot find output from $LEX; giving up" >&2;} { (exit 1); exit 1; }; } fi fi -echo "$as_me:21514: result: $ac_cv_prog_lex_root" >&5 +echo "$as_me:21596: result: $ac_cv_prog_lex_root" >&5 echo "${ECHO_T}$ac_cv_prog_lex_root" >&6 LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root -echo "$as_me:21518: checking whether yytext is a pointer" >&5 +echo "$as_me:21600: checking whether yytext is a pointer" >&5 echo $ECHO_N "checking whether yytext is a pointer... $ECHO_C" >&6 if test "${ac_cv_prog_lex_yytext_pointer+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -21531,16 +21613,16 @@ cat >conftest.$ac_ext <<_ACEOF `cat $LEX_OUTPUT_ROOT.c` _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext -if { (eval echo "$as_me:21534: \"$ac_link\"") >&5 +if { (eval echo "$as_me:21616: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? - echo "$as_me:21537: \$? = $ac_status" >&5 + echo "$as_me:21619: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' - { (eval echo "$as_me:21540: \"$ac_try\"") >&5 + { (eval echo "$as_me:21622: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? - echo "$as_me:21543: \$? = $ac_status" >&5 + echo "$as_me:21625: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_lex_yytext_pointer=yes else @@ -21552,7 +21634,7 @@ LIBS=$ac_save_LIBS rm -f "${LEX_OUTPUT_ROOT}.c" fi -echo "$as_me:21555: result: $ac_cv_prog_lex_yytext_pointer" >&5 +echo "$as_me:21637: result: $ac_cv_prog_lex_yytext_pointer" >&5 echo "${ECHO_T}$ac_cv_prog_lex_yytext_pointer" >&6 if test $ac_cv_prog_lex_yytext_pointer = yes; then @@ -21692,7 +21774,7 @@ DEFS=-DHAVE_CONFIG_H : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ echo "$as_me:21695: creating $CONFIG_STATUS" >&5 +{ echo "$as_me:21777: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $SHELL @@ -21871,7 +21953,7 @@ cat >>$CONFIG_STATUS <<\EOF echo "$ac_cs_version"; exit 0 ;; --he | --h) # Conflict between --help and --header - { { echo "$as_me:21874: error: ambiguous option: $1 + { { echo "$as_me:21956: error: ambiguous option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2;} @@ -21890,7 +21972,7 @@ Try \`$0 --help' for more information." >&2;} ac_need_defaults=false;; # This is an error. - -*) { { echo "$as_me:21893: error: unrecognized option: $1 + -*) { { echo "$as_me:21975: error: unrecognized option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2;} @@ -21969,7 +22051,7 @@ do "gmp-mparam.h" ) CONFIG_LINKS="$CONFIG_LINKS gmp-mparam.h:mpn/$gmp_mparam_dir/gmp-mparam.h" ;; "default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;; - *) { { echo "$as_me:21972: error: invalid argument: $ac_config_target" >&5 + *) { { echo "$as_me:22054: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac @@ -22276,7 +22358,7 @@ done; } esac if test x"$ac_file" != x-; then - { echo "$as_me:22279: creating $ac_file" >&5 + { echo "$as_me:22361: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} rm -f "$ac_file" fi @@ -22294,7 +22376,7 @@ echo "$as_me: creating $ac_file" >&6;} -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:22297: error: cannot find input file: $f" >&5 + test -f "$f" || { { echo "$as_me:22379: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; @@ -22307,7 +22389,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;} echo $srcdir/$f else # /dev/null tree - { { echo "$as_me:22310: error: cannot find input file: $f" >&5 + { { echo "$as_me:22392: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; @@ -22368,7 +22450,7 @@ for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue * ) ac_file_in=$ac_file.in ;; esac - test x"$ac_file" != x- && { echo "$as_me:22371: creating $ac_file" >&5 + test x"$ac_file" != x- && { echo "$as_me:22453: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} # First look for the input files in the build tree, otherwise in the @@ -22379,7 +22461,7 @@ echo "$as_me: creating $ac_file" >&6;} -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) - test -f "$f" || { { echo "$as_me:22382: error: cannot find input file: $f" >&5 + test -f "$f" || { { echo "$as_me:22464: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; @@ -22392,7 +22474,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;} echo $srcdir/$f else # /dev/null tree - { { echo "$as_me:22395: error: cannot find input file: $f" >&5 + { { echo "$as_me:22477: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; @@ -22509,7 +22591,7 @@ cat >>$CONFIG_STATUS <<\EOF rm -f $tmp/in if test x"$ac_file" != x-; then if cmp -s $ac_file $tmp/config.h 2>/dev/null; then - { echo "$as_me:22512: $ac_file is unchanged" >&5 + { echo "$as_me:22594: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ @@ -22566,11 +22648,11 @@ for ac_file in : $CONFIG_LINKS; do test "x$ac_file" = x: && continue ac_dest=`echo "$ac_file" | sed 's,:.*,,'` ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` - { echo "$as_me:22569: linking $srcdir/$ac_source to $ac_dest" >&5 + { echo "$as_me:22651: linking $srcdir/$ac_source to $ac_dest" >&5 echo "$as_me: linking $srcdir/$ac_source to $ac_dest" >&6;} if test ! -r $srcdir/$ac_source; then - { { echo "$as_me:22573: error: $srcdir/$ac_source: File not found" >&5 + { { echo "$as_me:22655: error: $srcdir/$ac_source: File not found" >&5 echo "$as_me: error: $srcdir/$ac_source: File not found" >&2;} { (exit 1); exit 1; }; } fi @@ -22620,7 +22702,7 @@ done; } # Make a symlink if possible; otherwise try a hard link. ln -s $ac_rel_source $ac_dest 2>/dev/null || ln $srcdir/$ac_source $ac_dest || - { { echo "$as_me:22623: error: cannot link $ac_dest to $srcdir/$ac_source" >&5 + { { echo "$as_me:22705: error: cannot link $ac_dest to $srcdir/$ac_source" >&5 echo "$as_me: error: cannot link $ac_dest to $srcdir/$ac_source" >&2;} { (exit 1); exit 1; }; } done diff --git a/src/gmp/configure.in b/src/gmp/configure.in index ac1568da6..95a6e4863 100644 --- a/src/gmp/configure.in +++ b/src/gmp/configure.in @@ -3,7 +3,7 @@ dnl Process this file with autoconf to produce a configure script. AC_COPYRIGHT([ -Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software +Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -124,7 +124,7 @@ fi AC_ARG_ENABLE(mpbsd, AC_HELP_STRING([--enable-mpbsd], - [build Berkley MP compatibility library [[default=no]]]), + [build Berkeley MP compatibility library [[default=no]]]), [case $enableval in yes|no) ;; *) AC_MSG_ERROR([bad value $enableval for --enable-mpbsd, need yes or no]) ;; @@ -168,6 +168,17 @@ no|prof|gprof) ;; esac], [enable_profiling=no]) +case $enable_profiling in + prof) + AC_DEFINE(WANT_PROFILING_PROF, 1, + [Define to 1 if --enable-profiling=prof]) + ;; + gprof) + AC_DEFINE(WANT_PROFILING_GPROF, 1, + [Define to 1 if --enable-profiling=gprof]) + ;; +esac + GMP_DEFINE_RAW(["define(,<\`$enable_profiling'>)"]) # -fomit-frame-pointer is incompatible with -pg, on x86s at least @@ -557,7 +568,7 @@ case $host in m68020-*-*) gcc_cflags_arch="-m68020" ;; m68030-*-*) gcc_cflags_arch="-m68030" ;; m68040-*-*) gcc_cflags_arch="-m68040" ;; - m68060-*-*) gcc_cflags_arch="-m68060 -m68040" ;; + m68060-*-*) gcc_cflags_arch="-m68060 -m68000" ;; m68360-*-*) gcc_cflags_arch="-mcpu32 -m68000" ;; *) gcc_cflags_arch="-m68000" ;; esac @@ -566,9 +577,9 @@ case $host in # tested. Will need to introduce an m68k/cpu32 if m68k/mc62020 ever uses # the bitfield instructions. case $host in - [m680[2346]0-*-* | m68360-*-*]) path="m68k/mc68020 m68k" - extra_functions="udiv umul" ;; - *) path="m68k" ;; + [m680[234]0-*-* | m68360-*-*]) path="m68k/mc68020 m68k" + extra_functions="udiv umul" ;; + *) path="m68k" ;; esac ;; @@ -747,6 +758,30 @@ case $host in path_aix64="powerpc64" extra_functions_aix64="umul" ;; + *-*-linux*) + # On GNU/Linux, assume the processor is in 64-bit mode. Some + # environments have a gcc that is always in 64-bit mode, while + # others require -m64, hence the use of cflags_maybe. The + # sizeof-long-8 test checks the mode is right (for the no option + # case). + # + # -mpowerpc64 is not used, since it should be the default in + # 64-bit mode. (We need its effect for the various longlong.h + # asm macros to be right of course.) + # + # gcc64 was an early port of gcc to 64-bit mode, but should be + # obsolete before too long. We prefer plain gcc when it knows + # 64-bits. + # + abilist="64 $abilist" + cclist_64="gcc gcc64" + gcc_64_cflags_maybe="-m64" + gcc_64_cflags="-O3" + gcc_64_cflags_optlist="cpu" + path_64="powerpc64" + any_64_testlist="sizeof-long-8" + gmp_cv_asm_underscore=no # Kludge + ;; esac ;; esac @@ -849,7 +884,9 @@ case $host in gcc_cflags="-g -O2 -Wa,-xarch=v8plus" gcc_cflags_cpu="-mcpu=ultrasparc -mcpu=v9 -mcpu=v8 -mv8" - cc_cflags="-xtarget=native -xarch=v8 -xO4" + # must have -xarch=v8plus here, to get the right assembler options + # for our mpn/sparc32/v9 code + cc_cflags="-xtarget=native -xarch=v8plus -xO4" case $host in [*-*-solaris2.[7-9]]) @@ -894,7 +931,7 @@ case $host in # AMD and Intel x86 configurations - X86_PATTERN) + X86_PATTERN | x86_64-*-*) AC_DEFINE(HAVE_HOST_CPU_FAMILY_x86) # Rumour has it gcc -O2 used to give worse register allocation than just # -O, but lets assume that's no longer true. @@ -951,12 +988,27 @@ case $host in gcc_cflags_cpu="-mcpu=athlon -mcpu=pentiumpro -mcpu=i486 -m486" gcc_cflags_arch="-march=athlon -march=pentiumpro -march=pentium -march=i486" ;; - pentium4-*-*) + pentium4-*-* | i786-*-*) # pentium4 is known to gcc 3.1 and up, not sure what cpu choice # would best suit previous versions, pentiumpro will get us cmov # from gcc 2.95.4 up, otherwise let's just try i486. gcc_cflags_cpu="-mcpu=pentium4 -mcpu=pentiumpro -mcpu=i486 -m486" - gcc_cflags_arch="-march=pentium4 -march=pentiumpro -march=pentium -march=i486" + gcc_cflags_arch="-march=pentium4~-mno-sse2 -march=pentiumpro -march=pentium -march=i486" + ;; + viac32-*-*) + # Not sure of the best fallbacks here for -mcpu. + # c3-2 has sse and mmx, so pentium3 is good for -march. + gcc_cflags_cpu="-mtune=c3-2 -mcpu=c3-2 -mcpu=i486 -m486" + gcc_cflags_arch="-march=c3-2 -march=pentium3 -march=pentiumpro -march=pentium" + ;; + viac3*-*-*) + # Not sure of the best fallbacks here. + gcc_cflags_cpu="-mtune=c3 -mcpu=c3 -mcpu=i486 -m486" + gcc_cflags_arch="-march=c3 -march=pentium-mmx -march=pentium" + ;; + x86_64-*-*) + gcc_cflags_cpu="-mtune=k8 -mcpu=athlon -mcpu=pentiumpro -mcpu=i486 -m486" + gcc_cflags_arch="-march=k8 -march=k8~-mno-sse2 -march=athlon -march=pentiumpro -march=pentium" ;; esac @@ -969,8 +1021,25 @@ case $host in pentium3-*-*) path="x86/p6/p3mmx x86/p6/mmx x86/p6 x86";; [k6[23]*-*-*]) path="x86/k6/k62mmx x86/k6/mmx x86/k6 x86" ;; k6*-*-*) path="x86/k6/mmx x86/k6 x86" ;; - athlon-*-*) path="x86/k7/mmx x86/k7 x86" ;; - pentium4-*-*) path="x86/pentium4/sse2 x86/pentium4/mmx x86/pentium4 x86" ;; + # we don't have any specific 32-bit code for opteron (x86_64), the + # athlon code should be reasonable + athlon-*-* | x86_64-*-*) path="x86/k7/mmx x86/k7 x86" ;; + i786-*-* | pentium4-*-*) + path="x86/pentium4/sse2 x86/pentium4/mmx x86/pentium4 x86" ;; + # VIA/Centaur processors, sold as CyrixIII and C3. + viac32-*-*) path="x86/p6/p3mmx x86/p6/mmx x86/p6 x86";; + viac3*-*-*) path="x86/pentium/mmx x86/pentium x86";; + *) path="x86" ;; + esac + + case $host in + x86_64-*-*) + abilist="64 32" + path_64="x86-64" + cclist_64="gcc" + gcc_64_cflags="-O2 -m64" + gcc_64_cflags_optlist="cpu" + ;; esac ;; @@ -1587,7 +1656,7 @@ test -n "$CCAS" || CCAS="$CC -c" AC_SUBST(CCAS) case $host in - X86_PATTERN) + X86_PATTERN | x86_64-*-*) # If there's any sse2 or mmx in the path, check whether the assembler # supports it, and remove if not. case "$path" in @@ -1948,6 +2017,11 @@ if test "$gmp_asm_syntax_testing" != no; then *) GMP_INCLUDE_MPN(powerpc32/aix.m4) ;; esac ;; + powerpc*-*-linux*) + case $ABI in + 64) GMP_INCLUDE_MPN(powerpc64/linux64.m4) ;; + esac + ;; esac ;; power*-*-aix*) @@ -1960,7 +2034,7 @@ if test "$gmp_asm_syntax_testing" != no; then ;; esac ;; - X86_PATTERN) + X86_PATTERN | x86_64-*-*) GMP_ASM_ALIGN_FILL_0x90 GMP_ASM_X86_SHLDL_CL if test "$enable_profiling" != no; then diff --git a/src/gmp/demos/expr/expr-impl.h b/src/gmp/demos/expr/expr-impl.h index 620a96bc3..4df1f7698 100644 --- a/src/gmp/demos/expr/expr-impl.h +++ b/src/gmp/demos/expr/expr-impl.h @@ -27,6 +27,7 @@ MA 02111-1307, USA. */ #if defined (__STDC__) \ || defined (__cplusplus) \ || defined (_AIX) \ + || defined (__DECC) \ || (defined (__mips) && defined (_SYSTYPE_SVR4)) \ || defined (_MSC_VER) \ || defined(_WIN32) diff --git a/src/gmp/demos/factorize.c b/src/gmp/demos/factorize.c index fcee6d1ab..d02c6e614 100644 --- a/src/gmp/demos/factorize.c +++ b/src/gmp/demos/factorize.c @@ -1,7 +1,7 @@ /* Factoring with Pollard's rho method. -Copyright 1995, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, -Inc. +Copyright 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003 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 @@ -180,7 +180,7 @@ S2: } S3: k--; - if (k != 0) + if (k > 0) goto S2; mpz_gcd (g, P, n); diff --git a/src/gmp/demos/perl/GMP.pm b/src/gmp/demos/perl/GMP.pm index 23738bb08..5d932919d 100644 --- a/src/gmp/demos/perl/GMP.pm +++ b/src/gmp/demos/perl/GMP.pm @@ -1,6 +1,6 @@ # GMP perl module -# Copyright 2001 Free Software Foundation, Inc. +# Copyright 2001, 2002, 2003, 2004 Free Software Foundation, Inc. # # This file is part of the GNU MP Library. # @@ -19,6 +19,10 @@ # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, # MA 02111-1307, USA. +# [Note: The above copyright notice is repeated in the documentation section +# below, in order to get it into man pages etc generated by the various pod +# conversions. When changing, be sure to update below too.] + # This code is designed to work with perl 5.005, so it and the sub-packages # aren't as modern as they could be. @@ -32,12 +36,13 @@ require DynaLoader; @EXPORT = qw(); @EXPORT_OK = qw(version); -%EXPORT_TAGS = ('all' => [qw(get_d get_si get_str integer_p printf sgn - sprintf)], +%EXPORT_TAGS = ('all' => [qw( + get_d get_d_2exp get_si get_str integer_p + printf sgn sprintf)], 'constants' => [()]); Exporter::export_ok_tags('all'); -$VERSION = '1'; +$VERSION = '2.00'; bootstrap GMP $VERSION; @@ -177,12 +182,12 @@ corresponding GMP mpz functions, =item -bin, cdiv, cdiv_2exp, clrbit, congruent_p, congruent_2exp_p, divexact, -divisible_p, divisible_2exp_p, even_p, fac, fdiv, fdiv_2exp, fib, fib2, gcd, -gcdext, hamdist, invert, jacobi, kronecker, lcm, lucnum, lucnum2, mod, -nextprime, odd_p, perfect_power_p, perfect_square_p, popcount, powm, -probab_prime_p, realloc, remove, root, roote, scan0, scan1, setbit, -sizeinbase, sqrtrem, tdiv, tdiv_2exp, tstbit +bin, cdiv, cdiv_2exp, clrbit, congruent_p, congruent_2exp_p, +divexact, divisible_p, divisible_2exp_p, even_p, fac, fdiv, fdiv_2exp, fib, +fib2, gcd, gcdext, hamdist, invert, jacobi, kronecker, lcm, lucnum, lucnum2, +mod, mpz_export, mpz_import, nextprime, odd_p, perfect_power_p, +perfect_square_p, popcount, powm, probab_prime_p, realloc, remove, root, +roote, scan0, scan1, setbit, sizeinbase, sqrtrem, tdiv, tdiv_2exp, tstbit =back @@ -197,16 +202,27 @@ more). C returns a triplet of gcd and two cofactors, for example ($g, $x, $y) = gcdext ($a, $b); print "gcd($a,$b) is $g, and $g == $a*$x + $b*$y\n"; -C returns the inverse, or undef if it doesn't exist. -C returns a remainder/multiplicty pair. C returns the -nth root, and C returns a root/bool pair, the bool indicating -whether the root is exact. C returns a root/remainder pair. +C and C are so named to avoid the C keyword. +Their parameters are as follows, -C and C expect a variable which they can modify, it doesn't -make sense to pass a literal constant. Only the given variable is modified, -if other variables are referencing the same mpz object then a new copy is -made of it. If the variable isn't an mpz it will be coerced to one. For -instance, + $z = mpz_import ($order, $size, $endian, $nails, $string); + $string = mpz_export ($order, $size, $endian, $nails, $z); + +The order, size, endian and nails parameters are as per the corresponding C +functions. The string input for C is interpreted as byte data +and must be a multiple of $size bytes. C conversely returns a +string of byte data, which will be a multiple of $size bytes. + +C returns the inverse, or undef if it doesn't exist. C +returns a remainder/multiplicty pair. C returns the nth root, and +C returns a root/bool pair, the bool indicating whether the root is +exact. C returns a root/remainder pair. + +C and C expect a variable which they can modify, +it doesn't make sense to pass a literal constant. Only the given variable +is modified, if other variables are referencing the same mpz object then a +new copy is made of it. If the variable isn't an mpz it will be coerced to +one. For instance, use GMP::Mpz qw(setbit); setbit (123, 0); # wrong, don't pass a constant @@ -214,8 +230,7 @@ instance, $b = $a; setbit ($a, 0); # $a becomes 7, $b stays at 6 -C and C return ULONG_MAX if no 0 or 1 bit is found, as per the -C functions. That value can be obtained in perl with C<~0>. +C and C return ~0 if no 0 or 1 bit respectively is found. =head2 GMP::Mpq @@ -239,7 +254,7 @@ always represented as 0/1. If not then C can be called to put it in that form. For example, use GMP::Mpq qw(:all); - $q = mpq(21,15); # eek! common factor 5 + $q = mpq(21,15); # eek! common factor 3 canonicalize($q); # get rid of it The following overloaded operators are available, and corresponding @@ -337,25 +352,30 @@ The following functions are available in the GMP class, =item -fits_slong_p, get_d, get_si, get_str, integer_p, printf, sgn, sprintf, -version +fits_slong_p, get_d, get_d_2exp, get_si, get_str, integer_p, printf, sgn, +sprintf, version =back -C accepts an integer, string, float, mpz, mpq or mpf. The base is -specified by an optional second parameter, or defaults to decimal. A -negative base means upper case, as per the C functions. For integer, -integer string, mpz or mpq operands a string is returned. For example, +C accepts any integer, string, float, mpz, mpq or mpf operands +and returns a float and an integer exponent, + + ($dbl, $exp) = get_d_2exp (mpf ("3.0")); + # dbl is 0.75, exp is 2 + +C takes an optional second argument which is the base, defaulting +to decimal. A negative base means upper case, as per the C functions. For +integer, integer string, mpz or mpq operands a string is returned. use GMP qw(:all); use GMP::Mpq qw(:all); print get_str(mpq(-5,8)),"\n"; # -5/8 print get_str(255,16),"\n"; # ff -For float, float strings or mpf operands C accepts an optional -third parameter being how many digits to produce, which defaults to 0 -meaning all digits. No more digits than can be accurately represented by -the float precision are ever produced though. A string/exponent pair is +For float, float strings or mpf operands, C accepts an optional +third parameter being how many digits to produce, defaulting to 0 which +means all digits. (Only as many digits as can be accurately represented by +the float precision are ever produced though.) A string/exponent pair is returned, as per the C mpf_get_str function. For example, use GMP qw(:all); @@ -446,10 +466,10 @@ corresponding GMP function. For example, use GMP::Rand (:all); $r = randstate(); - $a = mpz_urandomb($r,256); # uniform, 256 bits - $b = mpz_urandomm($r,mpz(3)**100); # uniform, 0 to 3**100-1 - $c = mpz_rrandomb($r,1024); # special, 1024 bits - $f = mpf_urandomb($r,128); # uniform, 128 bits, 0<=$f<1 + $a = mpz_urandomb($r,256); # uniform mpz, 256 bits + $b = mpz_urandomm($r,mpz(3)**100); # uniform mpz, 0 to 3**100-1 + $c = mpz_rrandomb($r,1024); # special mpz, 1024 bits + $f = mpf_urandomb($r,128); # uniform mpf, 128 bits, 0<=$f<1 =head2 Coercion @@ -549,9 +569,9 @@ GMP manual, L, L. =head1 BUGS -The overloaded constants sometimes provoke seg faults from perl 5.005_03 on -i386 FreeBSD. Don't know if that's a perl bug or a GMP module bug, though -it does seem to go bad before reaching anything in GMP.xs. +In perl 5.005_03 on i386 FreeBSD, the overloaded constants sometimes provoke +seg faults. Don't know if that's a perl bug or a GMP module bug, though it +does seem to go bad before reaching anything in GMP.xs. There's no way to specify an arbitrary base when converting a string to an mpz (or mpq or mpf), only hex or octal with 0x or 0 (for mpz and mpq, but @@ -570,7 +590,11 @@ be manipulated. C could usefully accept %b for mpz, mpq and mpf, and perhaps %x for mpf too. -There's no interface to mpfr. +C returning different style values for integer versus float is a +bit unfortunate. With mpz, mpq and mpf objects there's no doubt what it +will do, but on a plain scalar its action depends on whether the scalar was +promoted to a float at any stage, and then on the GMP module rules about +using the integer or float part. =head1 INTERNALS @@ -597,6 +621,27 @@ directly. Some assertion checking is available as a compile-time option. +=head1 COPYRIGHT + +Copyright 2001, 2002, 2003, 2004 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 Lesser General Public License as published +by the Free Software Foundation; either version 2.1 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 Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser 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. + =cut # Local variables: diff --git a/src/gmp/demos/perl/GMP.xs b/src/gmp/demos/perl/GMP.xs index 6c4524bba..7283561bc 100644 --- a/src/gmp/demos/perl/GMP.xs +++ b/src/gmp/demos/perl/GMP.xs @@ -1,6 +1,6 @@ /* GMP module external subroutines. -Copyright 2001 Free Software Foundation, Inc. +Copyright 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -24,7 +24,7 @@ MA 02111-1307, USA. */ Routines are grouped with the alias feature and a table of function pointers where possible, since each xsub routine ends up with quite a bit - of overhead. Different combinations of arguments and return values have + of code size. Different combinations of arguments and return values have to be separate though. The "INTERFACE:" feature isn't available in perl 5.005 and so isn't used. @@ -35,31 +35,30 @@ MA 02111-1307, USA. */ Mixed-type swapped-order assignments like "$a = 123; $a += mpz(456);" invoke the plain overloaded "+", not "+=", which makes life easier. - The various mpz_assume types are used with the overloaded operators since - we know they always pass a class object as the first argument and we can - save an sv_derived_from() lookup. There's assert()s in MPX_ASSUME() to - check though. + mpz_assume etc types are used with the overloaded operators since such + operators are always called with a class object as the first argument, we + don't need an sv_derived_from() lookup to check. There's assert()s in + MPX_ASSUME() for this though. The overload_constant routines reached via overload::constant get 4 arguments in perl 5.6, not the 3 as documented. This is apparently a bug, using "..." lets us ignore the extra one. - There's only a few "si" functions in gmp, so generally SvIV values get + There's only a few "si" functions in gmp, so usually SvIV values get handled with an mpz_set_si into a temporary and then a full precision mpz routine. This is reasonably efficient. - Strings are identified with "SvPOK(sv)||SvPOKp(sv)" so that magic - SVt_PVLV returns from substr() will work. SvPV() always gives a plain - actual string. + Argument types are checked, with a view to preserving all bits in the + operand. Perl is a bit looser in its arithmetic, allowing rounding or + truncation to an intended operand type (IV, UV or NV). Bugs: - Should IV's and/or NV's be identified with the same dual test as for - strings? - The memory leak detection attempted in GMP::END() doesn't work when mpz's are created as constants because END() is called before they're - destroyed. What's the right place to hook such a check? */ + destroyed. What's the right place to hook such a check? + + See the bugs section of GMP.pm too. */ /* Comment this out to get assertion checking. */ @@ -80,6 +79,16 @@ MA 02111-1307, USA. */ #include "gmp.h" +/* Perl 5.005 doesn't have SvIsUV, only 5.6 and up. + Perl 5.8 has SvUOK, but not 5.6, so we don't use that. */ +#ifndef SvIsUV +#define SvIsUV(sv) 0 +#endif +#ifndef SvUVX +#define SvUVX(sv) (croak("GMP: oops, shouldn't be using SvUVX"), 0) +#endif + + /* Code which doesn't check anything itself, but exists to support other assert()s. */ #ifdef NDEBUG @@ -88,12 +97,45 @@ MA 02111-1307, USA. */ #define assert_support(x) x #endif +/* LONG_MAX + 1 and ULONG_MAX + 1, as a doubles */ +#define LONG_MAX_P1_AS_DOUBLE ((double) ((unsigned long) LONG_MAX + 1)) +#define ULONG_MAX_P1_AS_DOUBLE (2.0 * (double) ((unsigned long) ULONG_MAX/2 + 1)) + +/* Check for perl version "major.minor". + Perl 5.004 doesn't have PERL_REVISION and PERL_VERSION, but that's ok, + we're only interested in tests above that. */ +#if defined (PERL_REVISION) && defined (PERL_VERSION) +#define PERL_GE(major,minor) \ + (PERL_REVISION > (major) \ + || ((major) == PERL_REVISION && PERL_VERSION >= (minor))) +#else +#define PERL_GE(major,minor) (0) +#endif +#define PERL_LT(major,minor) (! PERL_GE(major,minor)) + /* sv_derived_from etc in 5.005 took "char *" rather than "const char *". Avoid some compiler warnings by using const only where it works. */ -#if PERL_REVISION > 5 || (PERL_REVISION == 5 && PERL_VERSION >= 6) -#define classconst const -#else +#if PERL_LT (5,6) #define classconst +#else +#define classconst const +#endif + +/* In a MINGW or Cygwin DLL build of gmp, the various gmp functions are + given with dllimport directives, which prevents them being used as + initializers for constant data. We give function tables as + "static_functable const ...", which is normally "static const", but for + mingw expands to just "const" making the table an automatic with a + run-time initializer. + + In gcc 3.3.1, the function tables initialized like this end up getting + all the __imp__foo values fetched, even though just one or two will be + used. This is wasteful, but probably not too bad. */ + +#if defined (__MINGW32__) || defined (__CYGWIN__) +#define static_functable +#else +#define static_functable static #endif #define GMP_MALLOC_ID 42 @@ -103,6 +145,9 @@ static classconst char mpq_class[] = "GMP::Mpq"; static classconst char mpf_class[] = "GMP::Mpf"; static classconst char rand_class[] = "GMP::Rand"; +static HV *mpz_class_hv; +static HV *mpq_class_hv; +static HV *mpf_class_hv; assert_support (static long mpz_count = 0;) assert_support (static long mpq_count = 0;) @@ -128,7 +173,6 @@ assert_support (static long rand_count = 0;) typedef struct type##_elem *type; \ typedef struct type##_elem *type##_assume; \ typedef type##_ptr type##_coerce; \ - typedef type##_ptr type##_mutate; \ \ static type type##_freelist = NULL; \ \ @@ -215,6 +259,9 @@ static mpz_t tmp_mpz_0, tmp_mpz_1, tmp_mpz_2; static mpq_t tmp_mpq_0, tmp_mpq_1; static tmp_mpf_t tmp_mpf_0, tmp_mpf_1; +/* for GMP::Mpz::export */ +#define tmp_mpz_4 tmp_mpz_2 + #define FREE_MPX_FREELIST(p,type) \ do { \ @@ -241,6 +288,11 @@ static tmp_mpf_t tmp_mpf_0, tmp_mpf_1; #define free_mpq(q) FREE_MPX_FREELIST (q, mpq) +/* Return a new mortal SV holding the given mpx_ptr pointer. + class_hv should be one of mpz_class_hv etc. */ +#define MPX_NEWMORTAL(mpx_ptr, class_hv) \ + sv_bless (sv_setref_pv (sv_newmortal(), NULL, mpx_ptr), class_hv) + /* Aliases for use in typemaps */ typedef char *malloced_string; typedef const char *const_string; @@ -251,6 +303,7 @@ typedef SV *dummy; typedef SV *SV_copy_0; typedef unsigned long ulong_coerce; typedef __gmp_randstate_struct *randstate; +typedef UV gmp_UV; #define SvMPX(s,type) ((type) SvIV((SV*) SvRV(s))) #define SvMPZ(s) SvMPX(s,mpz) @@ -275,10 +328,6 @@ typedef __gmp_randstate_struct *randstate; #define x_mpq_integer_p(q) \ (mpz_cmp_ui (mpq_denref(q), 1L) == 0) -#define x_mpq_equal_si(q,n,d) \ - (mpz_cmp_si (mpq_numref(q), n) == 0 && mpz_cmp_ui (mpq_denref(q), d) == 0) -#define x_mpq_equal_z(q,z) \ - (x_mpq_integer_p(q) && mpz_cmp (mpq_numref(q), z) == 0) #define assert_table(ix) assert (ix >= 0 && ix < numberof (table)) @@ -287,13 +336,12 @@ typedef __gmp_randstate_struct *randstate; #define MPF_PTR_SWAP(x,y) \ do { mpf_ptr __tmp = (x); (x) = (y); (y) = __tmp; } while (0) -#define SvPOKorp(sv) (SvPOK(sv) || SvPOKp(sv)) static void -class_or_croak (SV *sv, classconst char *class) +class_or_croak (SV *sv, classconst char *cl) { - if (! sv_derived_from (sv, class)) - croak("not type %s", class); + if (! sv_derived_from (sv, cl)) + croak("not type %s", cl); } @@ -351,7 +399,7 @@ my_gmp_free (void *p, size_t n) const char *str; \ STRLEN len; \ TRACE (printf (" my_" #type "_set_svstr\n")); \ - assert (SvPOKorp (sv)); \ + assert (SvPOK(sv) || SvPOKp(sv)); \ str = SvPV (sv, len); \ TRACE (printf (" str \"%s\"\n", str)); \ if (type##_set_str (x, str, 0) != 0) \ @@ -403,319 +451,477 @@ x_mpz_cmp_f (mpz_srcptr x, mpf_srcptr y) } +#define USE_UNKNOWN 0 +#define USE_IVX 1 +#define USE_UVX 2 +#define USE_NVX 3 +#define USE_PVX 4 +#define USE_MPZ 5 +#define USE_MPQ 6 +#define USE_MPF 7 + +/* mg_get is called every time we get a value, even if the private flags are + still set from a previous such call. This is the same as as SvIV and + friends do. + + When POK, we use the PV, even if there's an IV or NV available. This is + because it's hard to be sure there wasn't any rounding in establishing + the IV and/or NV. Cases of overflow, where the PV should definitely be + used, are easy enough to spot, but rounding is hard. So although IV or + NV would be more efficient, we must use the PV to be sure of getting all + the data. Applications should convert once to mpz, mpq or mpf when using + a value repeatedly. + + Zany dual-type scalars like $! where the IV is an error code and the PV + is an error description string won't work with this preference for PV, + but that's too bad. Such scalars should be rare, and unlikely to be used + in bignum calculations. + + When IOK and NOK are both set, we would prefer to use the IV since it can + be converted more efficiently, and because on a 64-bit system the NV may + have less bits than the IV. The following rules are applied, + + - If the NV is not an integer, then we must use that NV, since clearly + the IV was merely established by rounding and is not the full value. + + - In perl prior to 5.8, an NV too big for an IV leaves an overflow value + 0xFFFFFFFF. If the NV is too big to fit an IV then clearly it's the NV + which is the true value and must be used. + + - In perl 5.8 and up, such an overflow doesn't set IOK, so that test is + unnecessary. However when coming from get-magic, IOKp _is_ set, and we + must check for overflow the same as in older perl. + + FIXME: + + We'd like to call mg_get just once, but unfortunately sv_derived_from() + will call it for each of our checks. We could do a string compare like + sv_isa ourselves, but that only tests the exact class, it doesn't + recognise subclassing. There doesn't seem to be a public interface to + the subclassing tests (in the internal isa_lookup() function). */ + +int +use_sv (SV *sv) +{ + double d; + + if (SvGMAGICAL(sv)) + { + mg_get(sv); + + if (SvPOKp(sv)) + return USE_PVX; + + if (SvIOKp(sv)) + { + if (SvIsUV(sv)) + { + if (SvNOKp(sv)) + goto u_or_n; + return USE_UVX; + } + else + { + if (SvNOKp(sv)) + goto i_or_n; + return USE_IVX; + } + } + + if (SvNOKp(sv)) + return USE_NVX; + + goto rok_or_unknown; + } + + if (SvPOK(sv)) + return USE_PVX; + + if (SvIOK(sv)) + { + if (SvIsUV(sv)) + { + if (SvNOK(sv)) + { + if (PERL_LT (5, 8)) + { + u_or_n: + d = SvNVX(sv); + if (d >= ULONG_MAX_P1_AS_DOUBLE || d < 0.0) + return USE_NVX; + } + d = SvNVX(sv); + if (d != floor (d)) + return USE_NVX; + } + return USE_UVX; + } + else + { + if (SvNOK(sv)) + { + if (PERL_LT (5, 8)) + { + i_or_n: + d = SvNVX(sv); + if (d >= LONG_MAX_P1_AS_DOUBLE || d < (double) LONG_MIN) + return USE_NVX; + } + d = SvNVX(sv); + if (d != floor (d)) + return USE_NVX; + } + return USE_IVX; + } + } + + if (SvNOK(sv)) + return USE_NVX; + + rok_or_unknown: + if (SvROK(sv)) + { + if (sv_derived_from (sv, mpz_class)) + return USE_MPZ; + if (sv_derived_from (sv, mpq_class)) + return USE_MPQ; + if (sv_derived_from (sv, mpf_class)) + return USE_MPF; + } + + return USE_UNKNOWN; +} + + /* Coerce sv to an mpz. Use tmp to hold the converted value if sv isn't already an mpz (or an mpq of which the numerator can be used). Return the chosen mpz (tmp or the contents of sv). */ + static mpz_ptr -coerce_mpz (mpz_ptr tmp, SV *sv) +coerce_mpz_using (mpz_ptr tmp, SV *sv, int use) { - if (SvIOK(sv)) + switch (use) { + case USE_IVX: + mpz_set_si (tmp, SvIVX(sv)); + return tmp; + + case USE_UVX: + mpz_set_ui (tmp, SvUVX(sv)); + return tmp; + + case USE_NVX: { - mpz_set_si (tmp, SvIVX(sv)); - return tmp; - } - if (SvPOKorp(sv)) - { - my_mpz_set_svstr (tmp, sv); - return tmp; - } - if (SvNOK(sv)) - { - double d = SvNVX(sv); + double d; + d = SvNVX(sv); if (! double_integer_p (d)) croak ("cannot coerce non-integer double to mpz"); mpz_set_d (tmp, d); return tmp; } - if (SvROK(sv)) + + case USE_PVX: + my_mpz_set_svstr (tmp, sv); + return tmp; + + case USE_MPZ: + return SvMPZ(sv)->m; + + case USE_MPQ: { - if (sv_derived_from (sv, mpz_class)) - { - return SvMPZ(sv)->m; - } - if (sv_derived_from (sv, mpq_class)) - { - mpq q = SvMPQ(sv); - if (! x_mpq_integer_p (q->m)) - croak ("cannot coerce non-integer mpq to mpz"); - return mpq_numref(q->m); - } - if (sv_derived_from (sv, mpf_class)) - { - mpf f = SvMPF(sv); - if (! mpf_integer_p (f)) - croak ("cannot coerce non-integer mpf to mpz"); - mpz_set_f (tmp, f); - return tmp; - } + mpq q = SvMPQ(sv); + if (! x_mpq_integer_p (q->m)) + croak ("cannot coerce non-integer mpq to mpz"); + return mpq_numref(q->m); } - croak ("cannot coerce to mpz"); + + case USE_MPF: + { + mpf f = SvMPF(sv); + if (! mpf_integer_p (f)) + croak ("cannot coerce non-integer mpf to mpz"); + mpz_set_f (tmp, f); + return tmp; + } + + default: + croak ("cannot coerce to mpz"); + } +} +static mpz_ptr +coerce_mpz (mpz_ptr tmp, SV *sv) +{ + return coerce_mpz_using (tmp, sv, use_sv (sv)); } /* Coerce sv to an mpq. If sv is an mpq then just return that, otherwise use tmp to hold the converted value and return that. */ + +static mpq_ptr +coerce_mpq_using (mpq_ptr tmp, SV *sv, int use) +{ + TRACE (printf ("coerce_mpq_using %p %d\n", tmp, use)); + switch (use) { + case USE_IVX: + mpq_set_si (tmp, SvIVX(sv), 1L); + return tmp; + + case USE_UVX: + mpq_set_ui (tmp, SvUVX(sv), 1L); + return tmp; + + case USE_NVX: + mpq_set_d (tmp, SvNVX(sv)); + return tmp; + + case USE_PVX: + my_mpq_set_svstr (tmp, sv); + return tmp; + + case USE_MPZ: + mpq_set_z (tmp, SvMPZ(sv)->m); + return tmp; + + case USE_MPQ: + return SvMPQ(sv)->m; + + case USE_MPF: + mpq_set_f (tmp, SvMPF(sv)); + return tmp; + + default: + croak ("cannot coerce to mpq"); + } +} static mpq_ptr coerce_mpq (mpq_ptr tmp, SV *sv) { - if (SvIOK(sv)) - { - mpq_set_si (tmp, SvIVX(sv), 1L); - return tmp; - } - if (SvNOK(sv)) - { - mpq_set_d (tmp, SvNVX(sv)); - return tmp; - } - if (SvPOKorp(sv)) - { - my_mpq_set_svstr (tmp, sv); - return tmp; - } - if (SvROK(sv)) - { - if (sv_derived_from (sv, mpz_class)) - { - mpq_set_z (tmp, SvMPZ(sv)->m); - return tmp; - } - if (sv_derived_from (sv, mpq_class)) - { - return SvMPQ(sv)->m; - } - if (sv_derived_from (sv, mpf_class)) - { - mpq_set_f (tmp, SvMPF(sv)); - return tmp; - } - } - croak ("cannot coerce to mpq"); + return coerce_mpq_using (tmp, sv, use_sv (sv)); } static void -my_mpf_set_sv (mpf_ptr f, SV *sv) +my_mpf_set_sv_using (mpf_ptr f, SV *sv, int use) { - if (SvIOK(sv)) + switch (use) { + case USE_IVX: mpf_set_si (f, SvIVX(sv)); - else if (SvPOKorp(sv)) - my_mpf_set_svstr (f, sv); - else if (SvNOK(sv)) + break; + + case USE_UVX: + mpf_set_ui (f, SvUVX(sv)); + break; + + case USE_NVX: mpf_set_d (f, SvNVX(sv)); - else if (SvROK(sv)) - { - if (sv_derived_from (sv, mpz_class)) - mpf_set_z (f, SvMPZ(sv)->m); - else if (sv_derived_from (sv, mpq_class)) - mpf_set_q (f, SvMPQ(sv)->m); - else if (sv_derived_from (sv, mpf_class)) - mpf_set (f, SvMPF(sv)); - else - goto invalid; - } - else - { - invalid: - croak ("cannot coerce to mpf"); - } + break; + + case USE_PVX: + my_mpf_set_svstr (f, sv); + break; + + case USE_MPZ: + mpf_set_z (f, SvMPZ(sv)->m); + break; + + case USE_MPQ: + mpf_set_q (f, SvMPQ(sv)->m); + break; + + case USE_MPF: + mpf_set (f, SvMPF(sv)); + break; + + default: + croak ("cannot coerce to mpf"); + } } /* Coerce sv to an mpf. If sv is an mpf then just return that, otherwise use tmp to hold the converted value (with prec precision). */ static mpf_ptr -coerce_mpf (tmp_mpf_ptr tmp, SV *sv, unsigned long prec) +coerce_mpf_using (tmp_mpf_ptr tmp, SV *sv, unsigned long prec, int use) { - if (SvROK(sv) && sv_derived_from (sv, mpf_class)) + if (use == USE_MPF) return SvMPF(sv); tmp_mpf_set_prec (tmp, prec); - my_mpf_set_sv (tmp->m, sv); + my_mpf_set_sv_using (tmp->m, sv, use); return tmp->m; } +static mpf_ptr +coerce_mpf (tmp_mpf_ptr tmp, SV *sv, unsigned long prec) +{ + return coerce_mpf_using (tmp, sv, prec, use_sv (sv)); +} /* Coerce xv to an mpf and store the pointer in x, ditto for yv to x. If one of xv or yv is an mpf then use it for the precision, otherwise use the default precision. */ -#define COERCE_MPF_PAIR(prec, x,xv, y,yv) \ - do { \ - if (SvROK(xv) && sv_derived_from (xv, mpf_class)) \ - { \ - x = SvMPF(xv); \ - prec = mpf_get_prec (x); \ - y = coerce_mpf (tmp_mpf_0, yv, prec); \ - } \ - else \ - { \ - y = coerce_mpf (tmp_mpf_0, yv, mpf_get_default_prec()); \ - prec = mpf_get_prec (y); \ - x = coerce_mpf (tmp_mpf_1, xv, prec); \ - } \ - } while (0) - +unsigned long +coerce_mpf_pair (mpf *xp, SV *xv, mpf *yp, SV *yv) +{ + int x_use = use_sv (xv); + int y_use = use_sv (yv); + unsigned long prec; + mpf x, y; + if (x_use == USE_MPF) + { + x = SvMPF(xv); + prec = mpf_get_prec (x); + y = coerce_mpf_using (tmp_mpf_0, yv, prec, y_use); + } + else + { + y = coerce_mpf_using (tmp_mpf_0, yv, mpf_get_default_prec(), y_use); + prec = mpf_get_prec (y); + x = coerce_mpf_using (tmp_mpf_1, xv, prec, x_use); + } + *xp = x; + *yp = y; + return prec; +} + + +/* Note that SvUV is not used, since it merely treats the signed IV as if it + was unsigned. We get an IV and check its sign. */ static unsigned long coerce_ulong (SV *sv) { long n; - if (SvIOK(sv)) + + switch (use_sv (sv)) { + case USE_IVX: + n = SvIVX(sv); + negative_check: + if (n < 0) + goto range_error; + return n; + + case USE_UVX: + return SvUVX(sv); + + case USE_NVX: { - n = SvIVX(sv); - negative_check: - if (n < 0) - { - range_error: - croak ("out of range for ulong"); - } - return n; - } - if (SvNOK(sv)) - { - double d = SvNVX(sv); + double d; + d = SvNVX(sv); if (! double_integer_p (d)) - { - integer_error: - croak ("not an integer"); - } + goto integer_error; n = SvIV(sv); - goto negative_check; } - if (SvPOKorp(sv)) + goto negative_check; + + case USE_PVX: + /* FIXME: Check the string is an integer. */ + n = SvIV(sv); + goto negative_check; + + case USE_MPZ: { - n = SvIV(sv); - goto negative_check; + mpz z = SvMPZ(sv); + if (! mpz_fits_ulong_p (z->m)) + goto range_error; + return mpz_get_ui (z->m); } - if (SvROK(sv)) + + case USE_MPQ: { - if (sv_derived_from (sv, mpz_class)) - { - mpz z = SvMPZ(sv); - if (! mpz_fits_ulong_p (z->m)) - goto range_error; - return mpz_get_ui (z->m); - } - if (sv_derived_from (sv, mpq_class)) - { - mpq q = SvMPQ(sv); - if (! x_mpq_integer_p (q->m)) - goto integer_error; - if (! mpz_fits_ulong_p (mpq_numref (q->m))) - goto range_error; - return mpz_get_ui (mpq_numref (q->m)); - } - if (sv_derived_from (sv, mpf_class)) - { - mpf f = SvMPF(sv); - if (! mpf_integer_p (f)) - goto integer_error; - if (! mpf_fits_ulong_p (f)) - goto range_error; - return mpf_get_ui (f); - } + mpq q = SvMPQ(sv); + if (! x_mpq_integer_p (q->m)) + goto integer_error; + if (! mpz_fits_ulong_p (mpq_numref (q->m))) + goto range_error; + return mpz_get_ui (mpq_numref (q->m)); } - croak ("cannot coerce to ulong"); + + case USE_MPF: + { + mpf f = SvMPF(sv); + if (! mpf_integer_p (f)) + goto integer_error; + if (! mpf_fits_ulong_p (f)) + goto range_error; + return mpf_get_ui (f); + } + + default: + croak ("cannot coerce to ulong"); + } + + integer_error: + croak ("not an integer"); + + range_error: + croak ("out of range for ulong"); } static long coerce_long (SV *sv) { - if (SvIOK(sv)) + switch (use_sv (sv)) { + case USE_IVX: return SvIVX(sv); - if (SvNOK(sv)) + case USE_UVX: + { + UV u = SvUVX(sv); + if (u > (UV) LONG_MAX) + goto range_error; + return u; + } + + case USE_NVX: { double d = SvNVX(sv); if (! double_integer_p (d)) - { - integer_error: - croak ("not an integer"); - } + goto integer_error; return SvIV(sv); } - if (SvPOKorp(sv)) + case USE_PVX: + /* FIXME: Check the string is an integer. */ return SvIV(sv); - if (SvROK(sv)) + case USE_MPZ: { - if (sv_derived_from (sv, mpz_class)) - { - mpz z = SvMPZ(sv); - if (! mpz_fits_slong_p (z->m)) - { - range_error: - croak ("out of range for ulong"); - } - return mpz_get_si (z->m); - } - if (sv_derived_from (sv, mpq_class)) - { - mpq q = SvMPQ(sv); - if (! x_mpq_integer_p (q->m)) - goto integer_error; - if (! mpz_fits_slong_p (mpq_numref (q->m))) - goto range_error; - return mpz_get_si (mpq_numref (q->m)); - } - if (sv_derived_from (sv, mpf_class)) - { - mpf f = SvMPF(sv); - if (! mpf_integer_p (f)) - goto integer_error; - if (! mpf_fits_slong_p (f)) - goto range_error; - return mpf_get_si (f); - } + mpz z = SvMPZ(sv); + if (! mpz_fits_slong_p (z->m)) + goto range_error; + return mpz_get_si (z->m); } - croak ("cannot coerce to long"); -} - -#define mpx_set_maybe(dst,src,type) \ - do { if ((dst) != (src)) type##_set (dst, src); } while (0) - -#define coerce_mpx_into(p,sv,type) \ - do { \ - type##_ptr __new_p = coerce_##type (p, sv); \ - mpx_set_maybe (p, __new_p, type); \ - } while (0) - -/* Like plain coerce_mpz or coerce_mpq, but force the result into p by - copying if necessary. */ -#define coerce_mpz_into(z,sv) coerce_mpx_into(z,sv,mpz) -#define coerce_mpq_into(q,sv) coerce_mpx_into(q,sv,mpq) - - -/* Prepare sv to be a changable mpz. If it's not an mpz then turn it into - one. If it is an mpz then ensure the reference count is 1. */ -static mpz_ptr -mutate_mpz (SV *sv) -{ - mpz old_z, new_z; - - TRACE (printf ("mutate_mpz %p\n", sv)); - TRACE (printf (" type %d\n", SvTYPE(sv))); - - if (SvROK (sv) && sv_derived_from (sv, mpz_class)) + case USE_MPQ: { - old_z = SvMPZ(sv); - if (SvREFCNT(SvRV(sv)) == 1) - return SvMPZ(sv)->m; + mpq q = SvMPQ(sv); + if (! x_mpq_integer_p (q->m)) + goto integer_error; + if (! mpz_fits_slong_p (mpq_numref (q->m))) + goto range_error; + return mpz_get_si (mpq_numref (q->m)); + } - TRACE (printf ("mutate_mpz(): forking new mpz\n")); - new_z = new_mpz (); - mpz_set (new_z->m, old_z->m); - } - else + case USE_MPF: { - TRACE (printf ("mutate_mpz(): coercing new mpz\n")); - new_z = new_mpz (); - coerce_mpz_into (new_z->m, sv); + mpf f = SvMPF(sv); + if (! mpf_integer_p (f)) + goto integer_error; + if (! mpf_fits_slong_p (f)) + goto range_error; + return mpf_get_si (f); } - sv_setref_pv (sv, mpz_class, new_z); - return new_z->m; + + default: + croak ("cannot coerce to long"); + } + + integer_error: + croak ("not an integer"); + + range_error: + croak ("out of range for ulong"); } @@ -733,6 +939,9 @@ BOOT: mpq_init (tmp_mpq_1); tmp_mpf_init (tmp_mpf_0); tmp_mpf_init (tmp_mpf_1); + mpz_class_hv = gv_stashpv (mpz_class, 1); + mpq_class_hv = gv_stashpv (mpq_class, 1); + mpf_class_hv = gv_stashpv (mpf_class, 1); void @@ -758,17 +967,27 @@ OUTPUT: bool fits_slong_p (sv) SV *sv -PREINIT: - mpq_srcptr q; CODE: - if (SvIOK(sv)) + switch (use_sv (sv)) { + case USE_IVX: RETVAL = 1; - else if (SvNOK(sv)) + break; + + case USE_UVX: + { + UV u = SvUVX(sv); + RETVAL = (u <= LONG_MAX); + } + break; + + case USE_NVX: { double d = SvNVX(sv); - RETVAL = (d >= LONG_MIN && d <= LONG_MAX); + RETVAL = (d >= (double) LONG_MIN && d < LONG_MAX_P1_AS_DOUBLE); } - else if (SvPOKorp(sv)) + break; + + case USE_PVX: { STRLEN len; const char *str = SvPV (sv, len); @@ -783,22 +1002,23 @@ CODE: RETVAL = mpf_fits_slong_p (tmp_mpf_0->m); } } - else if (SvROK(sv)) - { - if (sv_derived_from (sv, mpz_class)) - RETVAL = mpz_fits_slong_p (SvMPZ(sv)->m); - else if (sv_derived_from (sv, mpq_class)) - RETVAL = x_mpq_fits_slong_p (SvMPQ(sv)->m); - else if (sv_derived_from (sv, mpf_class)) - RETVAL = mpf_fits_slong_p (SvMPF(sv)); - else - goto invalid; - } - else - { - invalid: - croak ("GMP::fits_slong_p invalid argument"); - } + break; + + case USE_MPZ: + RETVAL = mpz_fits_slong_p (SvMPZ(sv)->m); + break; + + case USE_MPQ: + RETVAL = x_mpq_fits_slong_p (SvMPQ(sv)->m); + break; + + case USE_MPF: + RETVAL = mpf_fits_slong_p (SvMPF(sv)); + break; + + default: + croak ("GMP::fits_slong_p invalid argument"); + } OUTPUT: RETVAL @@ -807,71 +1027,143 @@ double get_d (sv) SV *sv CODE: - if (SvIOK(sv)) + switch (use_sv (sv)) { + case USE_IVX: RETVAL = (double) SvIVX(sv); - else if (SvNOK(sv)) + break; + + case USE_UVX: + RETVAL = (double) SvUVX(sv); + break; + + case USE_NVX: RETVAL = SvNVX(sv); - else if (SvPOKorp(sv)) + break; + + case USE_PVX: { STRLEN len; RETVAL = atof(SvPV(sv, len)); } - else if (SvROK(sv)) - { - if (sv_derived_from (sv, mpz_class)) - RETVAL = mpz_get_d (SvMPZ(sv)->m); - else if (sv_derived_from (sv, mpq_class)) - RETVAL = mpq_get_d (SvMPQ(sv)->m); - else if (sv_derived_from (sv, mpf_class)) - RETVAL = mpf_get_d (SvMPF(sv)); - else - goto invalid; - } - else - { - invalid: - croak ("GMP::get_d invalid argument"); - } + break; + + case USE_MPZ: + RETVAL = mpz_get_d (SvMPZ(sv)->m); + break; + + case USE_MPQ: + RETVAL = mpq_get_d (SvMPQ(sv)->m); + break; + + case USE_MPF: + RETVAL = mpf_get_d (SvMPF(sv)); + break; + + default: + croak ("GMP::get_d invalid argument"); + } OUTPUT: RETVAL +void +get_d_2exp (sv) + SV *sv +PREINIT: + double ret; + long exp; +PPCODE: + switch (use_sv (sv)) { + case USE_IVX: + ret = (double) SvIVX(sv); + goto use_frexp; + + case USE_UVX: + ret = (double) SvUVX(sv); + goto use_frexp; + + case USE_NVX: + { + int i_exp; + ret = SvNVX(sv); + use_frexp: + ret = frexp (ret, &i_exp); + exp = i_exp; + } + break; + + case USE_PVX: + /* put strings through mpf to give full exp range */ + tmp_mpf_set_prec (tmp_mpf_0, DBL_MANT_DIG); + my_mpf_set_svstr (tmp_mpf_0->m, sv); + ret = mpf_get_d_2exp (&exp, tmp_mpf_0->m); + break; + + case USE_MPZ: + ret = mpz_get_d_2exp (&exp, SvMPZ(sv)->m); + break; + + case USE_MPQ: + tmp_mpf_set_prec (tmp_mpf_0, DBL_MANT_DIG); + mpf_set_q (tmp_mpf_0->m, SvMPQ(sv)->m); + ret = mpf_get_d_2exp (&exp, tmp_mpf_0->m); + break; + + case USE_MPF: + ret = mpf_get_d_2exp (&exp, SvMPF(sv)); + break; + + default: + croak ("GMP::get_d_2exp invalid argument"); + } + PUSHs (sv_2mortal (newSVnv (ret))); + PUSHs (sv_2mortal (newSViv (exp))); + + long get_si (sv) SV *sv CODE: - if (SvIOK(sv)) + switch (use_sv (sv)) { + case USE_IVX: RETVAL = SvIVX(sv); - else if (SvNOK(sv)) + break; + + case USE_UVX: + RETVAL = SvUVX(sv); + break; + + case USE_NVX: RETVAL = (long) SvNVX(sv); - else if (SvPOKorp(sv)) + break; + + case USE_PVX: RETVAL = SvIV(sv); - else if (SvROK(sv)) - { - if (sv_derived_from (sv, mpz_class)) - RETVAL = mpz_get_si (SvMPZ(sv)->m); - else if (sv_derived_from (sv, mpq_class)) - { - mpz_set_q (tmp_mpz_0, SvMPQ(sv)->m); - RETVAL = mpz_get_si (tmp_mpz_0); - } - else if (sv_derived_from (sv, mpf_class)) - RETVAL = mpf_get_si (SvMPF(sv)); - else - goto invalid; - } - else - { - invalid: - croak ("GMP::get_si invalid argument"); - } + break; + + case USE_MPZ: + RETVAL = mpz_get_si (SvMPZ(sv)->m); + break; + + case USE_MPQ: + mpz_set_q (tmp_mpz_0, SvMPQ(sv)->m); + RETVAL = mpz_get_si (tmp_mpz_0); + break; + + case USE_MPF: + RETVAL = mpf_get_si (SvMPF(sv)); + break; + + default: + croak ("GMP::get_si invalid argument"); + } OUTPUT: RETVAL void get_str (sv, ...) - SV *sv + SV *sv PREINIT: char *str; mp_exp_t exp; @@ -896,23 +1188,27 @@ PPCODE: TRACE (printf (" ndigits=%d\n", ndigits)); EXTEND (SP, 2); - - if (SvIOK(sv)) - { - mpz_set_si (tmp_mpz_0, SvIVX(sv)); - z = tmp_mpz_0; - goto get_mpz; - } - else if (SvNOK(sv)) - { - /* only digits in the original double, not in the coerced form */ - if (ndigits == 0) - ndigits = DBL_DIG; - mpf_set_d (tmp_mpf_0->m, SvNVX(sv)); - f = tmp_mpf_0->m; - goto get_mpf; - } - else if (SvPOKorp(sv)) + + switch (use_sv (sv)) { + case USE_IVX: + mpz_set_si (tmp_mpz_0, SvIVX(sv)); + get_tmp_mpz_0: + z = tmp_mpz_0; + goto get_mpz; + + case USE_UVX: + mpz_set_ui (tmp_mpz_0, SvUVX(sv)); + goto get_tmp_mpz_0; + + case USE_NVX: + /* only digits in the original double, not in the coerced form */ + if (ndigits == 0) + ndigits = DBL_DIG; + mpf_set_d (tmp_mpf_0->m, SvNVX(sv)); + f = tmp_mpf_0->m; + goto get_mpf; + + case USE_PVX: { /* get_str on a string is not much more than a base conversion */ STRLEN len; @@ -942,50 +1238,50 @@ PPCODE: croak ("GMP::get_str invalid string format"); } } - else if (SvROK(sv)) - { - if (sv_derived_from (sv, mpz_class)) - { - z = SvMPZ(sv)->m; - get_mpz: - str = mpz_get_str (NULL, base, z); - push_str: - PUSHs (sv_2mortal (newSVpv (str, 0))); - } - else if (sv_derived_from (sv, mpq_class)) - { - q = SvMPQ(sv)->m; - get_mpq: - str = mpq_get_str (NULL, base, q); - goto push_str; - } - else if (sv_derived_from (sv, mpf_class)) - { - f = SvMPF(sv); - get_mpf: - str = mpf_get_str (NULL, &exp, base, 0, f); - PUSHs (sv_2mortal (newSVpv (str, 0))); - PUSHs (sv_2mortal (newSViv (exp))); - } - else - goto invalid; - } - else - { - invalid: - croak ("GMP::get_str invalid argument"); - } + break; + + case USE_MPZ: + z = SvMPZ(sv)->m; + get_mpz: + str = mpz_get_str (NULL, base, z); + push_str: + PUSHs (sv_2mortal (newSVpv (str, 0))); + break; + + case USE_MPQ: + q = SvMPQ(sv)->m; + get_mpq: + str = mpq_get_str (NULL, base, q); + goto push_str; + + case USE_MPF: + f = SvMPF(sv); + get_mpf: + str = mpf_get_str (NULL, &exp, base, 0, f); + PUSHs (sv_2mortal (newSVpv (str, 0))); + PUSHs (sv_2mortal (newSViv (exp))); + break; + + default: + croak ("GMP::get_str invalid argument"); + } bool integer_p (sv) SV *sv CODE: - if (SvIOK(sv)) + switch (use_sv (sv)) { + case USE_IVX: + case USE_UVX: RETVAL = 1; - else if (SvNOK(sv)) + break; + + case USE_NVX: RETVAL = double_integer_p (SvNVX(sv)); - else if (SvPOKorp(sv)) + break; + + case USE_PVX: { /* FIXME: Maybe this should be done by parsing the string, not by an actual conversion. */ @@ -1003,22 +1299,23 @@ CODE: croak ("GMP::integer_p invalid string format"); } } - else if (SvROK(sv)) - { - if (sv_derived_from (sv, mpz_class)) - RETVAL = 1; - else if (sv_derived_from (sv, mpq_class)) - RETVAL = x_mpq_integer_p (SvMPQ(sv)->m); - else if (sv_derived_from (sv, mpf_class)) - RETVAL = mpf_integer_p (SvMPF(sv)); - else - goto invalid; - } - else - { - invalid: - croak ("GMP::integer_p invalid argument"); - } + break; + + case USE_MPZ: + RETVAL = 1; + break; + + case USE_MPQ: + RETVAL = x_mpq_integer_p (SvMPQ(sv)->m); + break; + + case USE_MPF: + RETVAL = mpf_integer_p (SvMPF(sv)); + break; + + default: + croak ("GMP::integer_p invalid argument"); + } OUTPUT: RETVAL @@ -1027,11 +1324,20 @@ int sgn (sv) SV *sv CODE: - if (SvIOK(sv)) + switch (use_sv (sv)) { + case USE_IVX: RETVAL = SGN (SvIVX(sv)); - else if (SvNOK(sv)) + break; + + case USE_UVX: + RETVAL = (SvUVX(sv) > 0); + break; + + case USE_NVX: RETVAL = SGN (SvNVX(sv)); - else if (SvPOKorp(sv)) + break; + + case USE_PVX: { /* FIXME: Maybe this should be done by parsing the string, not by an actual conversion. */ @@ -1049,22 +1355,23 @@ CODE: croak ("GMP::sgn invalid string format"); } } - else if (SvROK(sv)) - { - if (sv_derived_from (sv, mpz_class)) - RETVAL = mpz_sgn (SvMPZ(sv)->m); - else if (sv_derived_from (sv, mpq_class)) - RETVAL = mpq_sgn (SvMPQ(sv)->m); - else if (sv_derived_from (sv, mpf_class)) - RETVAL = mpf_sgn (SvMPF(sv)); - else - goto invalid; - } - else - { - invalid: - croak ("GMP::sgn invalid argument"); - } + break; + + case USE_MPZ: + RETVAL = mpz_sgn (SvMPZ(sv)->m); + break; + + case USE_MPQ: + RETVAL = mpq_sgn (SvMPQ(sv)->m); + break; + + case USE_MPF: + RETVAL = mpf_sgn (SvMPF(sv)); + break; + + default: + croak ("GMP::sgn invalid argument"); + } OUTPUT: RETVAL @@ -1122,32 +1429,51 @@ ALIAS: PREINIT: SV *sv; CODE: - TRACE (printf ("%s new, ix=%ld, items=%d\n", mpz_class, ix, items)); + TRACE (printf ("%s new, ix=%ld, items=%d\n", mpz_class, ix, (int) items)); RETVAL = new_mpz(); switch (items) { case 0: mpz_set_ui (RETVAL->m, 0L); break; + case 1: sv = ST(0); - if (SvIOK(sv)) mpz_set_si (RETVAL->m, SvIVX(sv)); - else if (SvNOK(sv)) mpz_set_d (RETVAL->m, SvNVX(sv)); - else if (SvPOKorp(sv)) my_mpz_set_svstr (RETVAL->m, sv); - else if (SvROK(sv)) - { - if (sv_derived_from (sv, mpz_class)) - mpz_set (RETVAL->m, SvMPZ(sv)->m); - else if (sv_derived_from (sv, mpq_class)) - mpz_set_q (RETVAL->m, SvMPQ(sv)->m); - else if (sv_derived_from (sv, mpf_class)) - mpz_set_f (RETVAL->m, SvMPF(sv)); - else - goto invalid; - } - else + TRACE (printf (" use %d\n", use_sv (sv))); + switch (use_sv (sv)) { + case USE_IVX: + mpz_set_si (RETVAL->m, SvIVX(sv)); + break; + + case USE_UVX: + mpz_set_ui (RETVAL->m, SvUVX(sv)); + break; + + case USE_NVX: + mpz_set_d (RETVAL->m, SvNVX(sv)); + break; + + case USE_PVX: + my_mpz_set_svstr (RETVAL->m, sv); + break; + + case USE_MPZ: + mpz_set (RETVAL->m, SvMPZ(sv)->m); + break; + + case USE_MPQ: + mpz_set_q (RETVAL->m, SvMPQ(sv)->m); + break; + + case USE_MPF: + mpz_set_f (RETVAL->m, SvMPF(sv)); + break; + + default: goto invalid; + } break; + default: invalid: croak ("%s new: invalid arguments", mpz_class); @@ -1168,7 +1494,7 @@ PPCODE: z = new_mpz(); if (mpz_set_str (z->m, str, 0) == 0) { - SV *sv = sv_newmortal(); sv_setref_pv (sv, mpz_class, z); PUSHs(sv); + PUSHs (MPX_NEWMORTAL (z, mpz_class_hv)); } else { @@ -1223,7 +1549,7 @@ ALIAS: GMP::Mpz::overload_ior = 6 GMP::Mpz::overload_xor = 7 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpz_ptr, mpz_srcptr, mpz_srcptr); } table[] = { { mpz_add }, /* 0 */ @@ -1261,7 +1587,7 @@ ALIAS: GMP::Mpz::overload_ioreq = 6 GMP::Mpz::overload_xoreq = 7 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpz_ptr, mpz_srcptr, mpz_srcptr); } table[] = { { mpz_add }, /* 0 */ @@ -1288,7 +1614,7 @@ ALIAS: GMP::Mpz::overload_rshift = 1 GMP::Mpz::overload_pow = 2 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpz_ptr, mpz_srcptr, unsigned long); } table[] = { { mpz_mul_2exp }, /* 0 */ @@ -1314,7 +1640,7 @@ ALIAS: GMP::Mpz::overload_rshifteq = 1 GMP::Mpz::overload_poweq = 2 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpz_ptr, mpz_srcptr, unsigned long); } table[] = { { mpz_mul_2exp }, /* 0 */ @@ -1337,7 +1663,7 @@ ALIAS: GMP::Mpz::overload_com = 2 GMP::Mpz::overload_sqrt = 3 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpz_ptr w, mpz_srcptr x); } table[] = { { mpz_abs }, /* 0 */ @@ -1361,7 +1687,7 @@ overload_inc (z, d1, d2) ALIAS: GMP::Mpz::overload_dec = 1 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpz_ptr w, mpz_srcptr x, unsigned long y); } table[] = { { mpz_add_ui }, /* 0 */ @@ -1382,28 +1708,31 @@ PREINIT: CODE: TRACE (printf ("%s overload_spaceship\n", mpz_class)); MPZ_ASSUME (x, xv); - if (SvIOK(yv)) + switch (use_sv (yv)) { + case USE_IVX: RETVAL = mpz_cmp_si (x->m, SvIVX(yv)); - else if (SvPOKorp(yv)) + break; + case USE_UVX: + RETVAL = mpz_cmp_ui (x->m, SvUVX(yv)); + break; + case USE_PVX: RETVAL = mpz_cmp (x->m, coerce_mpz (tmp_mpz_0, yv)); - else if (SvNOK(yv)) + break; + case USE_NVX: RETVAL = mpz_cmp_d (x->m, SvNVX(yv)); - else if (SvROK(yv)) - { - if (sv_derived_from (yv, mpz_class)) - RETVAL = mpz_cmp (x->m, SvMPZ(yv)->m); - else if (sv_derived_from (yv, mpq_class)) - RETVAL = x_mpz_cmp_q (x->m, SvMPQ(yv)->m); - else if (sv_derived_from (yv, mpf_class)) - RETVAL = x_mpz_cmp_f (x->m, SvMPF(yv)); - else - goto invalid; - } - else - { - invalid: - croak ("%s <=>: invalid operand", mpz_class); - } + break; + case USE_MPZ: + RETVAL = mpz_cmp (x->m, SvMPZ(yv)->m); + break; + case USE_MPQ: + RETVAL = x_mpz_cmp_q (x->m, SvMPQ(yv)->m); + break; + case USE_MPF: + RETVAL = x_mpz_cmp_f (x->m, SvMPF(yv)); + break; + default: + croak ("%s <=>: invalid operand", mpz_class); + } RETVAL = SGN (RETVAL); if (order == &PL_sv_yes) RETVAL = -RETVAL; @@ -1432,7 +1761,7 @@ ALIAS: GMP::Mpz::root = 1 PREINIT: /* mpz_root returns an int, hence the cast */ - static const struct { + static_functable const struct { void (*op) (mpz_ptr, mpz_srcptr, unsigned long); } table[] = { { mpz_bin_ui }, /* 0 */ @@ -1454,7 +1783,7 @@ ALIAS: GMP::Mpz::fdiv = 1 GMP::Mpz::tdiv = 2 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); } table[] = { { mpz_cdiv_qr }, /* 0 */ @@ -1462,15 +1791,14 @@ PREINIT: { mpz_tdiv_qr }, /* 2 */ }; mpz q, r; - SV *sv; PPCODE: assert_table (ix); q = new_mpz(); r = new_mpz(); (*table[ix].op) (q->m, r->m, a, d); EXTEND (SP, 2); - sv = sv_newmortal(); sv_setref_pv (sv, mpz_class, q); PUSHs(sv); - sv = sv_newmortal(); sv_setref_pv (sv, mpz_class, r); PUSHs(sv); + PUSHs (MPX_NEWMORTAL (q, mpz_class_hv)); + PUSHs (MPX_NEWMORTAL (r, mpz_class_hv)); void @@ -1481,7 +1809,7 @@ ALIAS: GMP::Mpz::fdiv_2exp = 1 GMP::Mpz::tdiv_2exp = 2 PREINIT: - static const struct { + static_functable const struct { void (*q) (mpz_ptr, mpz_srcptr, unsigned long); void (*r) (mpz_ptr, mpz_srcptr, unsigned long); } table[] = { @@ -1490,7 +1818,6 @@ PREINIT: { mpz_tdiv_q_2exp, mpz_tdiv_r_2exp }, /* 2 */ }; mpz q, r; - SV *sv; PPCODE: assert_table (ix); q = new_mpz(); @@ -1498,8 +1825,8 @@ PPCODE: (*table[ix].q) (q->m, a, d); (*table[ix].r) (r->m, a, d); EXTEND (SP, 2); - sv = sv_newmortal(); sv_setref_pv (sv, mpz_class, q); PUSHs(sv); - sv = sv_newmortal(); sv_setref_pv (sv, mpz_class, r); PUSHs(sv); + PUSHs (MPX_NEWMORTAL (q, mpz_class_hv)); + PUSHs (MPX_NEWMORTAL (r, mpz_class_hv)); bool @@ -1533,7 +1860,7 @@ divexact (a, d) ALIAS: GMP::Mpz::mod = 1 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpz_ptr, mpz_srcptr, mpz_srcptr); } table[] = { { mpz_divexact }, /* 0 */ @@ -1575,7 +1902,7 @@ ALIAS: GMP::Mpz::perfect_square_p = 2 GMP::Mpz::perfect_power_p = 3 PREINIT: - static const struct { + static_functable const struct { int (*op) (mpz_srcptr z); } table[] = { { x_mpz_even_p }, /* 0 */ @@ -1597,7 +1924,7 @@ ALIAS: GMP::Mpz::fib = 1 GMP::Mpz::lucnum = 2 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpz_ptr r, unsigned long n); } table[] = { { mpz_fac_ui }, /* 0 */ @@ -1618,22 +1945,21 @@ fib2 (n) ALIAS: GMP::Mpz::lucnum2 = 1 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpz_ptr r, mpz_ptr r2, unsigned long n); } table[] = { { mpz_fib2_ui }, /* 0 */ { mpz_lucnum2_ui }, /* 1 */ }; mpz r, r2; - SV *sv; PPCODE: assert_table (ix); r = new_mpz(); r2 = new_mpz(); (*table[ix].op) (r->m, r2->m, n); EXTEND (SP, 2); - sv = sv_newmortal(); sv_setref_pv (sv, mpz_class, r); PUSHs(sv); - sv = sv_newmortal(); sv_setref_pv (sv, mpz_class, r2); PUSHs(sv); + PUSHs (MPX_NEWMORTAL (r, mpz_class_hv)); + PUSHs (MPX_NEWMORTAL (r2, mpz_class_hv)); mpz @@ -1642,7 +1968,7 @@ gcd (x, ...) ALIAS: GMP::Mpz::lcm = 1 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpz_ptr w, mpz_srcptr x, mpz_srcptr y); void (*op_ui) (mpz_ptr w, mpz_srcptr x, unsigned long y); } table[] = { @@ -1687,9 +2013,9 @@ PPCODE: y = new_mpz(); mpz_gcdext (g->m, x->m, y->m, a, b); EXTEND (SP, 3); - sv = sv_newmortal(); sv_setref_pv (sv, mpz_class, g); PUSHs(sv); - sv = sv_newmortal(); sv_setref_pv (sv, mpz_class, x); PUSHs(sv); - sv = sv_newmortal(); sv_setref_pv (sv, mpz_class, y); PUSHs(sv); + PUSHs (MPX_NEWMORTAL (g, mpz_class_hv)); + PUSHs (MPX_NEWMORTAL (x, mpz_class_hv)); + PUSHs (MPX_NEWMORTAL (y, mpz_class_hv)); unsigned long @@ -1743,6 +2069,51 @@ OUTPUT: RETVAL +void +mpz_export (order, size, endian, nails, z) + int order + size_t size + int endian + size_t nails + mpz_coerce z +PREINIT: + size_t numb, count, bytes, actual_count; + char *data; + SV *sv; +PPCODE: + numb = 8*size - nails; + count = (mpz_sizeinbase (z, 2) + numb-1) / numb; + bytes = count * size; + New (GMP_MALLOC_ID, data, bytes+1, char); + mpz_export (data, &actual_count, order, size, endian, nails, z); + assert (count == actual_count); + data[bytes] = '\0'; + sv = sv_newmortal(); sv_usepvn_mg (sv, data, bytes); PUSHs(sv); + + +mpz +mpz_import (order, size, endian, nails, sv) + int order + size_t size + int endian + size_t nails + SV *sv +PREINIT: + size_t count; + const char *data; + STRLEN len; +CODE: + data = SvPV (sv, len); + if ((len % size) != 0) + croak ("%s mpz_import: string not a multiple of the given size", + mpz_class); + count = len / size; + RETVAL = new_mpz(); + mpz_import (RETVAL->m, count, order, size, endian, nails, data); +OUTPUT: + RETVAL + + mpz nextprime (z) mpz_coerce z @@ -1801,12 +2172,11 @@ PREINIT: SV *sv; mpz rem; unsigned long mult; - dTARG; PPCODE: rem = new_mpz(); mult = mpz_remove (rem->m, z, f); EXTEND (SP, 2); - sv = sv_newmortal(); sv_setref_pv (sv, mpz_class, rem); PUSHs(sv); + PUSHs (MPX_NEWMORTAL (rem, mpz_class_hv)); PUSHs (sv_2mortal (newSViv (mult))); @@ -1822,18 +2192,33 @@ PPCODE: root = new_mpz(); exact = mpz_root (root->m, z, n); EXTEND (SP, 2); - sv = sv_newmortal(); sv_setref_pv (sv, mpz_class, root); PUSHs(sv); + PUSHs (MPX_NEWMORTAL (root, mpz_class_hv)); sv = (exact ? &PL_sv_yes : &PL_sv_no); sv_2mortal(sv); PUSHs(sv); -unsigned long +# In the past scan0 and scan1 were described as returning ULONG_MAX which +# could be obtained in perl with ~0. That wasn't true on 64-bit systems +# (eg. alpha) with perl 5.005, since in that version IV and UV were still +# 32-bits. +# +# We changed in gmp 4.1.3 to just say ~0 for the not-found return. It's +# likely most people have used ~0 rather than POSIX::ULONG_MAX(), so this +# change should match existing usage. It only actually makes a difference +# in old perl, since recent versions have gone to 64-bits for IV and UV, the +# same as a ulong. +# +# In perl 5.005 we explicitly mask the mpz return down to 32-bits to get ~0. +# UV_MAX is no good, it reflects the size of the UV type (64-bits), rather +# than the size of the values one ought to be storing in an SV (32-bits). + +gmp_UV scan0 (z, start) mpz_coerce z ulong_coerce start ALIAS: GMP::Mpz::scan1 = 1 PREINIT: - static const struct { + static_functable const struct { unsigned long (*op) (mpz_srcptr, unsigned long); } table[] = { { mpz_scan0 }, /* 0 */ @@ -1842,28 +2227,49 @@ PREINIT: CODE: assert_table (ix); RETVAL = (*table[ix].op) (z, start); + if (PERL_LT (5,6)) + RETVAL &= 0xFFFFFFFF; OUTPUT: RETVAL void -setbit (z, bit) - mpz_mutate z +setbit (sv, bit) + SV *sv ulong_coerce bit ALIAS: GMP::Mpz::clrbit = 1 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpz_ptr, unsigned long); } table[] = { { mpz_setbit }, /* 0 */ { mpz_clrbit }, /* 1 */ }; + int use; + mpz z; CODE: - TRACE (printf ("%s %s\n", mpz_class, (ix==0 ? "setbit" : "clrbit"))); - assert (SvROK(ST(0)) && SvREFCNT(SvRV(ST(0))) == 1); - assert_table (ix); - (*table[ix].op) (z, bit); + use = use_sv (sv); + if (use == USE_MPZ && SvREFCNT(SvRV(sv)) == 1 && ! SvSMAGICAL(sv)) + { + /* our operand is a non-magical mpz with a reference count of 1, so + we can just modify it */ + (*table[ix].op) (SvMPZ(sv)->m, bit); + } + else + { + /* otherwise we need to make a new mpz, from whatever we have, and + operate on that, possibly invoking magic when storing back */ + SV *new_sv; + mpz z = new_mpz (); + mpz_ptr coerce_ptr = coerce_mpz_using (z->m, sv, use); + if (coerce_ptr != z->m) + mpz_set (z->m, coerce_ptr); + (*table[ix].op) (z->m, bit); + new_sv = sv_bless (sv_setref_pv (sv_newmortal(), NULL, z), + mpz_class_hv); + SvSetMagicSV (sv, new_sv); + } void @@ -1878,8 +2284,8 @@ PPCODE: rem = new_mpz(); mpz_sqrtrem (root->m, rem->m, z); EXTEND (SP, 2); - sv = sv_newmortal(); sv_setref_pv (sv, mpz_class, root); PUSHs(sv); - sv = sv_newmortal(); sv_setref_pv (sv, mpz_class, rem); PUSHs(sv); + PUSHs (MPX_NEWMORTAL (root, mpz_class_hv)); + PUSHs (MPX_NEWMORTAL (rem, mpz_class_hv)); size_t @@ -1912,21 +2318,33 @@ mpq mpq (...) ALIAS: GMP::Mpq::new = 1 -PREINIT: CODE: - TRACE (printf ("%s new\n", mpq_class)); + TRACE (printf ("%s new, ix=%ld, items=%d\n", mpq_class, ix, (int) items)); RETVAL = new_mpq(); - switch (items) { case 0: mpq_set_ui (RETVAL->m, 0L, 1L); break; case 1: - coerce_mpq_into (RETVAL->m, ST(0)); + { + mpq_ptr rp = RETVAL->m; + mpq_ptr cp = coerce_mpq (rp, ST(0)); + if (cp != rp) + mpq_set (rp, cp); + } break; case 2: - coerce_mpz_into (mpq_numref(RETVAL->m), ST(0)); - coerce_mpz_into (mpq_denref(RETVAL->m), ST(1)); + { + mpz_ptr rp, cp; + rp = mpq_numref (RETVAL->m); + cp = coerce_mpz (rp, ST(0)); + if (cp != rp) + mpz_set (rp, cp); + rp = mpq_denref (RETVAL->m); + cp = coerce_mpz (rp, ST(1)); + if (cp != rp) + mpz_set (rp, cp); + } break; default: croak ("%s new: invalid arguments", mpq_class); @@ -1947,7 +2365,7 @@ PPCODE: TRACE (printf ("%s constant: %s\n", mpq_class, str)); q = new_mpq(); if (mpq_set_str (q->m, str, 0) == 0) - { sv = sv_newmortal(); sv_setref_pv (sv, mpq_class, q); } + { sv = sv_bless (sv_setref_pv (sv_newmortal(), NULL, q), mpq_class_hv); } else { free_mpq (q); sv = pv; } XPUSHs(sv); @@ -1995,7 +2413,7 @@ ALIAS: GMP::Mpq::overload_mul = 2 GMP::Mpq::overload_div = 3 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpq_ptr, mpq_srcptr, mpq_srcptr); } table[] = { { mpq_add }, /* 0 */ @@ -2026,7 +2444,7 @@ ALIAS: GMP::Mpq::overload_muleq = 2 GMP::Mpq::overload_diveq = 3 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpq_ptr, mpq_srcptr, mpq_srcptr); } table[] = { { mpq_add }, /* 0 */ @@ -2049,7 +2467,7 @@ ALIAS: GMP::Mpq::overload_rshift = 1 GMP::Mpq::overload_pow = 2 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpq_ptr, mpq_srcptr, unsigned long); } table[] = { { mpq_mul_2exp }, /* 0 */ @@ -2075,7 +2493,7 @@ ALIAS: GMP::Mpq::overload_rshifteq = 1 GMP::Mpq::overload_poweq = 2 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpq_ptr, mpq_srcptr, unsigned long); } table[] = { { mpq_mul_2exp }, /* 0 */ @@ -2096,7 +2514,7 @@ overload_inc (q, d1, d2) ALIAS: GMP::Mpq::overload_dec = 1 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpz_ptr, mpz_srcptr, mpz_srcptr); } table[] = { { mpz_add }, /* 0 */ @@ -2115,7 +2533,7 @@ overload_abs (q, d1, d2) ALIAS: GMP::Mpq::overload_neg = 1 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpq_ptr w, mpq_srcptr x); } table[] = { { mpq_abs }, /* 0 */ @@ -2163,23 +2581,39 @@ overload_eq (x, yv, d) dummy d ALIAS: GMP::Mpq::overload_ne = 1 +PREINIT: + int use; CODE: - if (SvIOK(yv)) - RETVAL = x_mpq_equal_si (x->m, SvIVX(yv), 1L); - else if (SvROK(yv)) - { - if (sv_derived_from (yv, mpz_class)) - RETVAL = x_mpq_equal_z (x->m, SvMPZ(yv)->m); - else if (sv_derived_from (yv, mpq_class)) - RETVAL = mpq_equal (x->m, SvMPQ(yv)->m); - else - goto coerce; - } - else - { - coerce: - RETVAL = mpq_equal (x->m, coerce_mpq (tmp_mpq_0, yv)); - } + use = use_sv (yv); + switch (use) { + case USE_IVX: + case USE_UVX: + case USE_MPZ: + RETVAL = 0; + if (x_mpq_integer_p (x->m)) + { + switch (use) { + case USE_IVX: + RETVAL = (mpz_cmp_si (mpq_numref(x->m), SvIVX(yv)) == 0); + break; + case USE_UVX: + RETVAL = (mpz_cmp_ui (mpq_numref(x->m), SvUVX(yv)) == 0); + break; + case USE_MPZ: + RETVAL = (mpz_cmp (mpq_numref(x->m), SvMPZ(yv)->m) == 0); + break; + } + } + break; + + case USE_MPQ: + RETVAL = (mpq_equal (x->m, SvMPQ(yv)->m) != 0); + break; + + default: + RETVAL = (mpq_equal (x->m, coerce_mpq_using (tmp_mpq_0, yv, use)) != 0); + break; + } RETVAL ^= ix; OUTPUT: RETVAL @@ -2233,7 +2667,10 @@ CODE: prec = (items == 2 ? coerce_ulong (ST(1)) : mpf_get_default_prec()); RETVAL = new_mpf (prec); if (items >= 1) - my_mpf_set_sv (RETVAL, ST(0)); + { + SV *sv = ST(0); + my_mpf_set_sv_using (RETVAL, sv, use_sv(sv)); + } OUTPUT: RETVAL @@ -2243,8 +2680,6 @@ overload_constant (sv, d1, d2, ...) SV *sv dummy d1 dummy d2 -PREINIT: - mpf f; CODE: assert (SvPOK (sv)); TRACE (printf ("%s constant: %s\n", mpq_class, SvPVX(sv))); @@ -2288,7 +2723,7 @@ ALIAS: GMP::Mpf::overload_mul = 2 GMP::Mpf::overload_div = 3 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpf_ptr, mpf_srcptr, mpf_srcptr); } table[] = { { mpf_add }, /* 0 */ @@ -2296,7 +2731,6 @@ PREINIT: { mpf_mul }, /* 2 */ { mpf_div }, /* 3 */ }; - unsigned long prec; CODE: assert_table (ix); RETVAL = new_mpf (mpf_get_prec (x)); @@ -2317,7 +2751,7 @@ ALIAS: GMP::Mpf::overload_muleq = 2 GMP::Mpf::overload_diveq = 3 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpf_ptr, mpf_srcptr, mpf_srcptr); } table[] = { { mpf_add }, /* 0 */ @@ -2340,7 +2774,7 @@ ALIAS: GMP::Mpf::overload_rshift = 1 GMP::Mpf::overload_pow = 2 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpf_ptr, mpf_srcptr, unsigned long); } table[] = { { mpf_mul_2exp }, /* 0 */ @@ -2371,7 +2805,7 @@ ALIAS: GMP::Mpf::overload_rshifteq = 1 GMP::Mpf::overload_poweq = 2 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpf_ptr, mpf_srcptr, unsigned long); } table[] = { { mpf_mul_2exp }, /* 0 */ @@ -2393,7 +2827,7 @@ ALIAS: GMP::Mpf::overload_neg = 1 GMP::Mpf::overload_sqrt = 2 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpf_ptr w, mpf_srcptr x); } table[] = { { mpf_abs }, /* 0 */ @@ -2416,7 +2850,7 @@ overload_inc (f, d1, d2) ALIAS: GMP::Mpf::overload_dec = 1 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpf_ptr w, mpf_srcptr x, unsigned long y); } table[] = { { mpf_add_ui }, /* 0 */ @@ -2436,11 +2870,17 @@ PREINIT: mpf x; CODE: MPF_ASSUME (x, xv); - if (SvIOK(yv)) + switch (use_sv (yv)) { + case USE_IVX: RETVAL = mpf_cmp_si (x, SvIVX(yv)); - else if (SvNOK(yv)) + break; + case USE_UVX: + RETVAL = mpf_cmp_ui (x, SvUVX(yv)); + break; + case USE_NVX: RETVAL = mpf_cmp_d (x, SvNVX(yv)); - else if (SvPOKorp(yv)) + break; + case USE_PVX: { STRLEN len; const char *str = SvPV (yv, len); @@ -2450,21 +2890,18 @@ CODE: croak ("%s <=>: invalid string format", mpf_class); RETVAL = mpf_cmp (x, tmp_mpf_0->m); } - else if (SvROK(yv)) - { - if (sv_derived_from (yv, mpz_class)) - RETVAL = - x_mpz_cmp_f (SvMPZ(yv)->m, x); - else if (sv_derived_from (yv, mpf_class)) - RETVAL = mpf_cmp (x, SvMPF(yv)); - else - goto use_mpq; - } - else - { - use_mpq: - RETVAL = mpq_cmp (coerce_mpq (tmp_mpq_0, xv), - coerce_mpq (tmp_mpq_1, yv)); - } + break; + case USE_MPZ: + RETVAL = - x_mpz_cmp_f (SvMPZ(yv)->m, x); + break; + case USE_MPF: + RETVAL = mpf_cmp (x, SvMPF(yv)); + break; + default: + RETVAL = mpq_cmp (coerce_mpq (tmp_mpq_0, xv), + coerce_mpq (tmp_mpq_1, yv)); + break; + } RETVAL = SGN (RETVAL); if (order == &PL_sv_yes) RETVAL = -RETVAL; @@ -2492,7 +2929,7 @@ ALIAS: GMP::Mpf::floor = 1 GMP::Mpf::trunc = 2 PREINIT: - static const struct { + static_functable const struct { void (*op) (mpf_ptr w, mpf_srcptr x); } table[] = { { mpf_ceil }, /* 0 */ @@ -2531,10 +2968,9 @@ mpf_eq (xv, yv, bits) ulong_coerce bits PREINIT: mpf x, y; - unsigned long prec; CODE: TRACE (printf ("%s eq\n", mpf_class)); - COERCE_MPF_PAIR (prec, x,xv, y,yv); + coerce_mpf_pair (&x,xv, &y,yv); RETVAL = mpf_eq (x, y, bits); OUTPUT: RETVAL @@ -2549,7 +2985,7 @@ PREINIT: unsigned long prec; CODE: TRACE (printf ("%s reldiff\n", mpf_class)); - COERCE_MPF_PAIR (prec, x,xv, y,yv); + prec = coerce_mpf_pair (&x,xv, &y,yv); RETVAL = new_mpf (prec); mpf_reldiff (RETVAL, x, y); OUTPUT: @@ -2570,9 +3006,11 @@ set_prec (sv, prec) ulong_coerce prec PREINIT: mpf_ptr old_f, new_f; + int use; CODE: TRACE (printf ("%s set_prec to %lu\n", mpf_class, prec)); - if (SvROK (sv) && sv_derived_from (sv, mpf_class)) + use = use_sv (sv); + if (use == USE_MPF) { old_f = SvMPF(sv); if (SvREFCNT(SvRV(sv)) == 1) @@ -2589,9 +3027,9 @@ CODE: { TRACE (printf (" coerce to mpf\n")); new_f = new_mpf (prec); - my_mpf_set_sv (new_f, sv); + my_mpf_set_sv_using (new_f, sv, use); setref: - sv_setref_pv (sv, mpf_class, new_f); + sv_bless (sv_setref_pv (sv, NULL, new_f), mpf_class_hv); } @@ -2617,32 +3055,34 @@ CODE: } else { - STRLEN len; - const char *method = SvPV (ST(0), len); - assert (len == strlen (method)); - if (strcmp (method, "lc_2exp") == 0) { - if (items != 4) - goto invalid; - gmp_randinit_lc_2exp (RETVAL, - coerce_mpz (tmp_mpz_0, ST(1)), - coerce_ulong (ST(2)), - coerce_ulong (ST(3))); - } - else if (strcmp (method, "lc_2exp_size") == 0) - { - if (items != 2) - goto invalid; - if (! gmp_randinit_lc_2exp_size (RETVAL, coerce_ulong (ST(1)))) + STRLEN len; + const char *method = SvPV (ST(0), len); + assert (len == strlen (method)); + if (strcmp (method, "lc_2exp") == 0) { - Safefree (RETVAL); - XSRETURN_UNDEF; + if (items != 4) + goto invalid; + gmp_randinit_lc_2exp (RETVAL, + coerce_mpz (tmp_mpz_0, ST(1)), + coerce_ulong (ST(2)), + coerce_ulong (ST(3))); + } + else if (strcmp (method, "lc_2exp_size") == 0) + { + if (items != 2) + goto invalid; + if (! gmp_randinit_lc_2exp_size (RETVAL, coerce_ulong (ST(1)))) + { + Safefree (RETVAL); + XSRETURN_UNDEF; + } + } + else + { + invalid: + croak ("%s new: invalid arguments", rand_class); } - } - else - { - invalid: - croak ("%s new: invalid arguments", rand_class); } } OUTPUT: @@ -2675,7 +3115,7 @@ mpz_urandomb (r, bits) ALIAS: GMP::Rand::mpz_rrandomb = 1 PREINIT: - static const struct { + static_functable const struct { void (*fun) (mpz_ptr, gmp_randstate_t r, unsigned long bits); } table[] = { { mpz_urandomb }, /* 0 */ diff --git a/src/gmp/demos/perl/GMP/Mpf.pm b/src/gmp/demos/perl/GMP/Mpf.pm index 76246ea33..258ee43e3 100644 --- a/src/gmp/demos/perl/GMP/Mpf.pm +++ b/src/gmp/demos/perl/GMP/Mpf.pm @@ -1,6 +1,6 @@ # GMP mpf module. -# Copyright 2001 Free Software Foundation, Inc. +# Copyright 2001, 2003 Free Software Foundation, Inc. # # This file is part of the GNU MP Library. # @@ -73,20 +73,17 @@ sub import { sub overload_string { my $fmt; - { - # don't whinge about $# being deprecated - local $^W = 0; + BEGIN { $^W = 0; } + if (defined ($#)) { $fmt = $#; - } - if (! defined $fmt) { - $fmt = '%.Fg'; - } else { + BEGIN { $^W = 1; } # protect against calling sprintf_internal with a bad format - if ($# !~ /^(%%|[^%])*%[-+ .\d]*[eEfgG](%%|[^%])*$/) { + if ($fmt !~ /^((%%|[^%])*%[-+ .\d]*)([eEfgG](%%|[^%])*)$/) { die "GMP::Mpf: invalid \$# format: $#\n"; } - $fmt = $OFMT; - $fmt =~ s/(.)$/F$1/; + $fmt = $1 . 'F' . $3; + } else { + $fmt = '%.Fg'; } GMP::sprintf_internal ($fmt, $_[0]); } diff --git a/src/gmp/demos/perl/GMP/Mpz.pm b/src/gmp/demos/perl/GMP/Mpz.pm index b21f2acc8..11751e857 100644 --- a/src/gmp/demos/perl/GMP/Mpz.pm +++ b/src/gmp/demos/perl/GMP/Mpz.pm @@ -1,6 +1,6 @@ # GMP mpz module. -# Copyright 2001 Free Software Foundation, Inc. +# Copyright 2001, 2002, 2003 Free Software Foundation, Inc. # # This file is part of the GNU MP Library. # @@ -32,7 +32,8 @@ require Exporter; congruent_2exp_p divexact divisible_p divisible_2exp_p even_p fac fdiv fdiv_2exp fib fib2 gcd gcdext hamdist invert jacobi kronecker - lcm lucnum lucnum2 mod mpz nextprime odd_p + lcm lucnum lucnum2 mod mpz mpz_export + mpz_import nextprime odd_p perfect_power_p perfect_square_p popcount powm probab_prime_p realloc remove root roote scan0 scan1 setbit sizeinbase sqrtrem tdiv tdiv_2exp diff --git a/src/gmp/demos/perl/Makefile.PL b/src/gmp/demos/perl/Makefile.PL index 3d917c4b5..27b0cf2fb 100644 --- a/src/gmp/demos/perl/Makefile.PL +++ b/src/gmp/demos/perl/Makefile.PL @@ -1,6 +1,6 @@ # Makefile for GMP perl module. -# Copyright 2001 Free Software Foundation, Inc. +# Copyright 2001, 2003, 2004 Free Software Foundation, Inc. # # This file is part of the GNU MP Library. # @@ -53,11 +53,18 @@ if (defined $GMP_BUILDDIR) { WriteMakefile( NAME => 'GMP', - VERSION => '1', + VERSION => '2.00', LIBS => [$LIBS], OBJECT => $OBJECT, INC => $INC, clean => { FILES => 'test.tmp' }, + PM => { + 'GMP.pm' => '$(INST_LIBDIR)/GMP.pm', + 'GMP/Mpz.pm' => '$(INST_LIBDIR)/GMP/Mpz.pm', + 'GMP/Mpq.pm' => '$(INST_LIBDIR)/GMP/Mpq.pm', + 'GMP/Mpf.pm' => '$(INST_LIBDIR)/GMP/Mpf.pm', + 'GMP/Rand.pm' => '$(INST_LIBDIR)/GMP/Rand.pm', + } ); diff --git a/src/gmp/demos/perl/sample.pl b/src/gmp/demos/perl/sample.pl index 1f87420fd..cad679bf5 100644 --- a/src/gmp/demos/perl/sample.pl +++ b/src/gmp/demos/perl/sample.pl @@ -2,7 +2,7 @@ # Some sample GMP module operations -# Copyright 2001 Free Software Foundation, Inc. +# Copyright 2001, 2004 Free Software Foundation, Inc. # # This file is part of the GNU MP Library. # @@ -24,6 +24,10 @@ use strict; +use GMP; +print "using GMP module $GMP::VERSION and GMP library ",GMP::version(),"\n"; + + use GMP::Mpz qw(:all); print "the 200th fibonacci number is ", fib(200), "\n"; print "next prime after 10**30 is (probably) ", nextprime(mpz(10)**30), "\n"; diff --git a/src/gmp/demos/perl/test.pl b/src/gmp/demos/perl/test.pl index 9b4cc242d..56d5d1dc5 100644 --- a/src/gmp/demos/perl/test.pl +++ b/src/gmp/demos/perl/test.pl @@ -1,6 +1,8 @@ +#!/usr/bin/perl -w + # GMP perl module tests -# Copyright 2001 Free Software Foundation, Inc. +# Copyright 2001, 2002, 2003 Free Software Foundation, Inc. # # This file is part of the GNU MP Library. # @@ -54,267 +56,292 @@ use GMP::Mpq qw(:noconstants); use GMP::Mpf qw(:constants); use GMP::Mpf qw(:noconstants); -use GMP qw(version); -print '$GMP::VERSION ',$GMP::VERSION,' GMP::version() ',version(),"\n"; +package Mytie; +use Exporter; +use vars qw($val $fetched $stored); +$val = 0; +$fetched = 0; +$stored = 0; +sub TIESCALAR { + my ($class, $newval) = @_; + my $var = 'mytie dummy refed var'; + $val = $newval; + $fetched = 0; + $stored = 0; + return bless \$var, $class; +} +sub FETCH { + my ($self) = @_; + $fetched++; + return $val; +} +sub STORE { + my ($self, $newval) = @_; + $val = $newval; + $stored++; +} +package main; -# force to a string, not a PVIV +# check Mytie does what it should +{ tie my $t, 'Mytie', 123; + ok ($Mytie::val == 123); + $Mytie::val = 456; + ok ($t == 456); + $t = 789; + ok ($Mytie::val == 789); +} + + +# Usage: str(x) +# Return x forced to a string, not a PVIV. +# sub str { - my $s = "@_[0]" . ""; + my $s = "$_[0]" . ""; return $s; } -foreach my $name ('mpz', 'mpq', 'mpf') { - print "$name\n"; - my $mpx = eval("\\&$name"); +my $ivnv_2p128 = 65536.0 * 65536.0 * 65536.0 * 65536.0 + * 65536.0 * 65536.0 * 65536.0 * 65536.0; +kill (0, $ivnv_2p128); +my $str_2p128 = '340282366920938463463374607431768211456'; - ok (&$mpx() == 0); - - foreach my $x (0, 1, -1, 123, -123) { - foreach my $y ($x, ""."$x", substr("$x",0), 0.0+$x, - mpz($x), mpq($x), mpf($x)) { - ok (&$mpx($x) == $x); - } - } - - ok (&$mpx(substr("11",0,1)) == 1); - - ok (&$mpx(0) < 1); - ok (&$mpx(0) > -1); - - ok (&$mpx(0) != 1); - ok (&$mpx(0) != -1); - ok (&$mpx(1) != 0); - ok (&$mpx(1) != -1); - ok (&$mpx(-1) != 0); - ok (&$mpx(-1) != 1); - - ok (&$mpx(0) + 1 == 1); - ok (&$mpx(-1) + 1 == 0); - ok (1 + &$mpx(0) == 1); - ok (1 + &$mpx(-1) == 0); - - ok (&$mpx(0) - 1 == -1); - ok (&$mpx(1) - 1 == 0); - ok (1 - &$mpx(0) == 1); - ok (1 - &$mpx(1) == 0); - - ok (&$mpx(2) * 3 == 6); - - ok (&$mpx(6) / 2 == 3); - ok (&$mpx(-6) / 2 == -3); - ok (&$mpx(6) / -2 == -3); - ok (&$mpx(-6) / -2 == 3); - - ok (abs(&$mpx(0)) == 0); - ok (abs(&$mpx(1)) == 1); - ok (abs(&$mpx(-1)) == 1); - { my $x = &$mpx(-123); $x = abs($x); ok ($x == 123); } - { my $x = &$mpx(-1); $x = abs($x); ok ($x == 1); } - { my $x = &$mpx(0); $x = abs($x); ok ($x == 0); } - { my $x = &$mpx(1); $x = abs($x); ok ($x == 1); } - { my $x = &$mpx(123); $x = abs($x); ok ($x == 123); } +my $uv_max = ~ 0; +my $uv_max_str = ~ 0; +$uv_max_str = "$uv_max_str"; +$uv_max_str = "" . "$uv_max_str"; - foreach my $x (-123, -1, 0, 1, 123) { - foreach my $xv ($x, "$x", substr("$x",0), $x+0.0, - mpz($x), mpq($x), mpf($x)) { - my $xm = &$mpx($xv); - if ($xm) { - ok ($x); - } else { - ok (not $x); - } - if (not $xm) { - ok (not $x); - } else { - ok ($x); - } - if (! $xm) { - ok (not $x); - } else { - ok ($x); - } - } - } +#------------------------------------------------------------------------------ +# GMP::version - ok (- &$mpx(0) == 0); - ok (- &$mpx(1) == -1); - ok (- &$mpx(-1) == 1); +use GMP qw(version); +print '$GMP::VERSION ',$GMP::VERSION,' GMP::version() ',version(),"\n"; - { - my $a = &$mpx(0); my $b = $a; - $a = &$mpx(1); - ok ($a == 1); - ok ($b == 0); - } - { - my $a = &$mpx(0); my $b = $a; - $a++; - ok ($a == 1); - ok ($b == 0); - } - { - my $a = &$mpx(0); my $b = $a; - $a--; - ok ($a == -1); - ok ($b == 0); - } - { - my $a = &$mpx(0); my $b = $a; - $a++; - ok ($a == 1); - ok ($b == 0); - } - { my $a = &$mpx(0); ok ($a++ == 0); } - { my $a = &$mpx(0); ok ($a-- == 0); } - { my $a = &$mpx(0); ok (++$a == 1); } - { my $a = &$mpx(0); ok (--$a == -1); } +#------------------------------------------------------------------------------ +# GMP::Mpz::new - { my $x = &$mpx(0); ok("$x" eq "0"); } - { my $x = &$mpx(123); ok("$x" eq "123"); } - { my $x = &$mpx(-123); ok("$x" eq "-123"); } +ok (mpz(0) == 0); +ok (mpz('0') == 0); +ok (mpz(substr('101',1,1)) == 0); +ok (mpz(0.0) == 0); +ok (mpz(mpz(0)) == 0); +ok (mpz(mpq(0)) == 0); +ok (mpz(mpf(0)) == 0); - ok (&$mpx(0) ** 1 == 0); - ok (&$mpx(1) ** 1 == 1); - ok (&$mpx(2) ** 0 == 1); - ok (&$mpx(2) ** 1 == 2); - ok (&$mpx(2) ** 2 == 4); - ok (&$mpx(2) ** 3 == 8); - ok (&$mpx(2) ** 4 == 16); +{ tie my $t, 'Mytie', 0; + ok (mpz($t) == 0); + ok ($Mytie::fetched > 0); +} +{ tie my $t, 'Mytie', '0'; + ok (mpz($t) == 0); + ok ($Mytie::fetched > 0); +} +{ tie my $t, 'Mytie', substr('101',1,1); ok (mpz($t) == 0); } +{ tie my $t, 'Mytie', 0.0; ok (mpz($t) == 0); } +{ tie my $t, 'Mytie', mpz(0); ok (mpz($t) == 0); } +{ tie my $t, 'Mytie', mpq(0); ok (mpz($t) == 0); } +{ tie my $t, 'Mytie', mpf(0); ok (mpz($t) == 0); } - ok (&$mpx(0) ** &$mpx(1) == 0); - ok (&$mpx(1) ** &$mpx(1) == 1); - ok (&$mpx(2) ** &$mpx(0) == 1); - ok (&$mpx(2) ** &$mpx(1) == 2); - ok (&$mpx(2) ** &$mpx(2) == 4); - ok (&$mpx(2) ** &$mpx(3) == 8); - ok (&$mpx(2) ** &$mpx(4) == 16); +ok (mpz(-123) == -123); +ok (mpz('-123') == -123); +ok (mpz(substr('1-1231',1,4)) == -123); +ok (mpz(-123.0) == -123); +ok (mpz(mpz(-123)) == -123); +ok (mpz(mpq(-123)) == -123); +ok (mpz(mpf(-123)) == -123); - { my $a = &$mpx(7); $a += 1; ok ($a == 8); } - { my $a = &$mpx(7); $a -= 1; ok ($a == 6); } - { my $a = &$mpx(7); $a *= 3; ok ($a == 21); } - { my $a = &$mpx(21); $a /= 3; ok ($a == 7); } - { my $a = &$mpx(7); $a <<= 1; ok ($a == 14); } - { my $a = &$mpx(32); $a >>= 1; ok ($a == 16); } - { my $a = &$mpx(3); $a **= 4; ok ($a == 81); } +{ tie my $t, 'Mytie', -123; ok (mpz($t) == -123); } +{ tie my $t, 'Mytie', '-123'; ok (mpz($t) == -123); } +{ tie my $t, 'Mytie', substr('1-1231',1,4); ok (mpz($t) == -123); } +{ tie my $t, 'Mytie', -123.0; ok (mpz($t) == -123); } +{ tie my $t, 'Mytie', mpz(-123); ok (mpz($t) == -123); } +{ tie my $t, 'Mytie', mpq(-123); ok (mpz($t) == -123); } +{ tie my $t, 'Mytie', mpf(-123); ok (mpz($t) == -123); } - ok (! &$mpx("-9999999999999999999999999999999999999999999")->fits_slong_p()); - ok ( &$mpx(-123)->fits_slong_p()); - ok ( &$mpx(0)->fits_slong_p()); - ok ( &$mpx(123)->fits_slong_p()); - ok (! &$mpx("9999999999999999999999999999999999999999999")->fits_slong_p()); +ok (mpz($ivnv_2p128) == $str_2p128); +{ tie my $t, 'Mytie', $ivnv_2p128; ok (mpz($t) == $str_2p128); } - ok (&$mpx(-123)->sgn() == -1); - ok (&$mpx(-1) ->sgn() == -1); - ok (&$mpx(0) ->sgn() == 0); - ok (&$mpx(1) ->sgn() == 1); - ok (&$mpx(123) ->sgn() == 1); +ok (mpz($uv_max) > 0); +ok (mpz($uv_max) == mpz($uv_max_str)); +{ tie my $t, 'Mytie', $uv_max; ok (mpz($t) > 0); } +{ tie my $t, 'Mytie', $uv_max; ok (mpz($t) == mpz($uv_max_str)); } + +{ my $s = '999999999999999999999999999999'; + kill (0, $s); + ok (mpz($s) == '999999999999999999999999999999'); + tie my $t, 'Mytie', $s; + ok (mpz($t) == '999999999999999999999999999999'); } -foreach my $x (-123, -1, 0, 1, 123) { - foreach my $xv ($x, "$x", substr("$x",0), $x+0.0, - mpz($x), mpq($x), mpf($x)) { +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_abs - ok (GMP::get_d($xv) == $x); - ok (GMP::get_si($xv) == $x); - ok (GMP::integer_p($xv) == 1); - ok (GMP::sgn($xv) == ($x <=> 0)); - - foreach my $y (-123, -1, 0, 1, 123) { - foreach my $yv ($y, "$y", 0.0+$y, mpz($y), mpq($y), mpf($y)) { +ok (abs(mpz(0)) == 0); +ok (abs(mpz(123)) == 123); +ok (abs(mpz(-123)) == 123); - ok (($xv <=> $yv) == ($x <=> $y)); - } - } - } -} +{ my $x = mpz(-123); $x = abs($x); ok ($x == 123); } +{ my $x = mpz(0); $x = abs($x); ok ($x == 0); } +{ my $x = mpz(123); $x = abs($x); ok ($x == 123); } -foreach my $xpair ([-123,"-7b"], [-1,"-1"], [0,"0"], [1,"1"], [123,"7b"]) { - my $x = $$xpair[0]; - my $xhex = $$xpair[1]; +{ tie my $t, 'Mytie', mpz(0); ok (abs($t) == 0); } +{ tie my $t, 'Mytie', mpz(123); ok (abs($t) == 123); } +{ tie my $t, 'Mytie', mpz(-123); ok (abs($t) == 123); } - foreach my $xv ($x, "$x", substr("$x",0), - mpz($x), mpq($x)) { +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_add - ok (get_str($xv) eq "$x"); - ok (get_str($xv,10) eq "$x"); +ok (mpz(0) + 1 == 1); +ok (mpz(-1) + 1 == 0); +ok (1 + mpz(0) == 1); +ok (1 + mpz(-1) == 0); - ok (get_str($xv,16) == $xhex); - $xhex =~ tr [a-z] [A-Z]; - ok (get_str($xv,-16) == $xhex); - } -} +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_addeq -ok (GMP::get_str(mpq(5/8)) eq "5/8"); -ok (GMP::get_str(mpq(-5/8)) eq "-5/8"); -ok (GMP::get_str(mpq(255/256),16) eq "ff/100"); -ok (GMP::get_str(mpq(255/256),-16) eq "FF/100"); -ok (GMP::get_str(mpq(-255/256),16) eq "-ff/100"); -ok (GMP::get_str(mpq(-255/256),-16) eq "-FF/100"); +{ my $a = mpz(7); $a += 1; ok ($a == 8); } +{ my $a = mpz(7); my $b = $a; $a += 1; ok ($a == 8); ok ($b == 7); } -foreach my $x (1.5, mpf(1.5)) { - { my ($s,$e) = get_str($x, 10); - ok ($s eq '15'); - ok ($e == 1); } -} -foreach my $x (-1.5, mpf(-1.5)) { - { my ($s,$e) = get_str($x, 10); - ok ($s eq '-15'); - ok ($e == 1); } -} -foreach my $x (1.5, mpf(1.5)) { - { my ($s,$e) = get_str($x, 16); - ok ($s eq '18'); - ok ($e == 1); } -} -foreach my $x (-1.5, mpf(-1.5)) { - { my ($s,$e) = get_str($x, 16); - ok ($s eq '-18'); - ok ($e == 1); } -} -foreach my $x (65536.0, mpf(65536.0)) { - { my ($s,$e) = get_str($x, 16); - ok ($s eq '1'); - ok ($e == 5); } -} -foreach my $x (1.625, mpf(1.625)) { - { my ($s,$e) = get_str($x, 16); - ok ($s eq '1a'); - ok ($e == 1); } -} -foreach my $x (1.625, mpf(1.625)) { - { my ($s,$e) = get_str($x, -16); - ok ($s eq '1A'); - ok ($e == 1); } -} -foreach my $f (255.0, mpf(255)) { - my ($s, $e) = get_str(255.0,16,0); - ok ($s eq "ff"); - ok ($e == 2); -} -foreach my $f (255.0, mpf(255)) { - my ($s, $e) = get_str(255.0,-16,0); - ok ($s eq "FF"); - ok ($e == 2); -} -foreach my $f (-255.0, mpf(-255)) { - my ($s, $e) = get_str(-255.0,16,0); - ok ($s eq "-ff"); - ok ($e == 2); -} -foreach my $f (-255.0, mpf(-255)) { - my ($s, $e) = get_str(-255.0,-16,0); - ok ($s eq "-FF"); - ok ($e == 2); -} +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_and +ok ((mpz(3) & 1) == 1); +ok ((mpz(3) & 4) == 0); -ok ( GMP::integer_p (mpq(1))); -ok (! GMP::integer_p (mpq(1,2))); -ok ( GMP::integer_p (mpf(1.0))); -ok (! GMP::integer_p (mpf(1.5))); +{ my $a = mpz(3); $a &= 1; ok ($a == 1); } +{ my $a = mpz(3); $a &= 4; ok ($a == 0); } +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_bool + +if (mpz(0)) { ok (0); } else { ok (1); } +if (mpz(123)) { ok (1); } else { ok (0); } + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_com + +ok (~ mpz(0) == -1); +ok (~ mpz(1) == -2); +ok (~ mpz(-2) == 1); +ok (~ mpz(0xFF) == -0x100); +ok (~ mpz(-0x100) == 0xFF); + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_dec + +{ my $a = mpz(0); ok ($a-- == 0); ok ($a == -1); } +{ my $a = mpz(0); ok (--$a == -1); } + +{ my $a = mpz(0); my $b = $a; $a--; ok ($a == -1); ok ($b == 0); } + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_div + +ok (mpz(6) / 2 == 3); +ok (mpz(-6) / 2 == -3); +ok (mpz(6) / -2 == -3); +ok (mpz(-6) / -2 == 3); + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_diveq + +{ my $a = mpz(21); $a /= 3; ok ($a == 7); } +{ my $a = mpz(21); my $b = $a; $a /= 3; ok ($a == 7); ok ($b == 21); } + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_eq + +{ my $a = mpz(0); + my $b = $a; + $a = mpz(1); + ok ($a == 1); + ok ($b == 0); } + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_inc + +{ my $a = mpz(0); ok ($a++ == 0); ok ($a == 1); } +{ my $a = mpz(0); ok (++$a == 1); } + +{ my $a = mpz(0); my $b = $a; $a++; ok ($a == 1); ok ($b == 0); } + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_ior + +ok ((mpz(3) | 1) == 3); +ok ((mpz(3) | 4) == 7); + +{ my $a = mpz(3); $a |= 1; ok ($a == 3); } +{ my $a = mpz(3); $a |= 4; ok ($a == 7); } + +ok ((mpz("0xAA") | mpz("0x55")) == mpz("0xFF")); + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_lshift + +{ my $a = mpz(7) << 1; ok ($a == 14); } + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_lshifteq + +{ my $a = mpz(7); $a <<= 1; ok ($a == 14); } +{ my $a = mpz(7); my $b = $a; $a <<= 1; ok ($a == 14); ok ($b == 7); } + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_mul + +ok (mpz(2) * 3 == 6); + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_muleq + +{ my $a = mpz(7); $a *= 3; ok ($a == 21); } +{ my $a = mpz(7); my $b = $a; $a *= 3; ok ($a == 21); ok ($b == 7); } + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_neg + +ok (- mpz(0) == 0); +ok (- mpz(123) == -123); +ok (- mpz(-123) == 123); + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_not + +if (not mpz(0)) { ok (1); } else { ok (0); } +if (not mpz(123)) { ok (0); } else { ok (1); } + +ok ((! mpz(0)) == 1); +ok ((! mpz(123)) == 0); + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_pow + +ok (mpz(0) ** 1 == 0); +ok (mpz(1) ** 1 == 1); +ok (mpz(2) ** 0 == 1); +ok (mpz(2) ** 1 == 2); +ok (mpz(2) ** 2 == 4); +ok (mpz(2) ** 3 == 8); +ok (mpz(2) ** 4 == 16); + +ok (mpz(0) ** mpz(1) == 0); +ok (mpz(1) ** mpz(1) == 1); +ok (mpz(2) ** mpz(0) == 1); +ok (mpz(2) ** mpz(1) == 2); +ok (mpz(2) ** mpz(2) == 4); +ok (mpz(2) ** mpz(3) == 8); +ok (mpz(2) ** mpz(4) == 16); + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_poweq + +{ my $a = mpz(3); $a **= 4; ok ($a == 81); } +{ my $a = mpz(3); my $b = $a; $a **= 4; ok ($a == 81); ok ($b == 3); } + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_rem ok (mpz(-8) % 3 == -2); ok (mpz(-7) % 3 == -1); @@ -325,29 +352,79 @@ ok (mpz(8) % 3 == 2); { my $a = mpz(24); $a %= 7; ok ($a == 3); } -ok ((mpz(3) & 1) == 1); -ok ((mpz(3) & 4) == 0); -ok ((mpz(3) | 1) == 3); -ok ((mpz(3) | 4) == 7); +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_rshift + +{ my $a = mpz(32) >> 1; ok ($a == 16); } + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_rshifteq + +{ my $a = mpz(32); $a >>= 1; ok ($a == 16); } +{ my $a = mpz(32); my $b = $a; $a >>= 1; ok ($a == 16); ok ($b == 32); } + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_spaceship + +ok (mpz(0) < 1); +ok (mpz(0) > -1); + +ok (mpz(0) != 1); +ok (mpz(0) != -1); +ok (mpz(1) != 0); +ok (mpz(1) != -1); +ok (mpz(-1) != 0); +ok (mpz(-1) != 1); + +ok (mpz(0) < 1.0); +ok (mpz(0) < '1'); +ok (mpz(0) < substr('-1',1,1)); +ok (mpz(0) < mpz(1)); +ok (mpz(0) < mpq(1)); +ok (mpz(0) < mpf(1)); +ok (mpz(0) < $uv_max); + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_sqrt + +ok (sqrt(mpz(0)) == 0); +ok (sqrt(mpz(1)) == 1); +ok (sqrt(mpz(4)) == 2); +ok (sqrt(mpz(81)) == 9); + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_string + +{ my $x = mpz(0); ok("$x" eq "0"); } +{ my $x = mpz(123); ok("$x" eq "123"); } +{ my $x = mpz(-123); ok("$x" eq "-123"); } + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_sub + +ok (mpz(0) - 1 == -1); +ok (mpz(1) - 1 == 0); +ok (1 - mpz(0) == 1); +ok (1 - mpz(1) == 0); + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_subeq + +{ my $a = mpz(7); $a -= 1; ok ($a == 6); } +{ my $a = mpz(7); my $b = $a; $a -= 1; ok ($a == 6); ok ($b == 7); } + +#------------------------------------------------------------------------------ +# GMP::Mpz::overload_xor + ok ((mpz(3) ^ 1) == 2); ok ((mpz(3) ^ 4) == 7); -ok ((mpz("0xAA") | mpz("0x55")) == mpz("0xFF")); -{ my $a = mpz(3); $a &= 1; ok ($a == 1); } -{ my $a = mpz(3); $a &= 4; ok ($a == 0); } -{ my $a = mpz(3); $a |= 1; ok ($a == 3); } -{ my $a = mpz(3); $a |= 4; ok ($a == 7); } { my $a = mpz(3); $a ^= 1; ok ($a == 2); } { my $a = mpz(3); $a ^= 4; ok ($a == 7); } -ok (~ mpz(0) == -1); -ok (~ mpz(1) == -2); -ok (~ mpz(-2) == 1); -ok (~ mpz(0xFF) == -0x100); -ok (~ mpz(-0x100) == 0xFF); - -# mpz functions +#------------------------------------------------------------------------------ +# GMP::Mpz::bin ok (bin(2,0) == 1); ok (bin(2,1) == 2); @@ -358,6 +435,10 @@ ok (bin(3,1) == 3); ok (bin(3,2) == 3); ok (bin(3,3) == 1); + +#------------------------------------------------------------------------------ +# GMP::Mpz::cdiv + { my ($q, $r); ($q, $r) = cdiv (16, 3); ok ($q == 6); @@ -372,6 +453,153 @@ ok (bin(3,3) == 1); ok ($q == 6); ok ($r == 2); } + + +#------------------------------------------------------------------------------ +# GMP::Mpz::cdiv_2exp + +{ my ($q, $r); + ($q, $r) = cdiv_2exp (23, 2); + ok ($q == 6); + ok ($r == -1); + ($q, $r) = cdiv_2exp (-23, 2); + ok ($q == -5); + ok ($r == -3); +} + + +#------------------------------------------------------------------------------ +# GMP::Mpz::clrbit + +{ my $a = mpz(3); clrbit ($a, 1); ok ($a == 1); + ok (UNIVERSAL::isa($a,"GMP::Mpz")); } +{ my $a = mpz(3); clrbit ($a, 2); ok ($a == 3); + ok (UNIVERSAL::isa($a,"GMP::Mpz")); } + +{ my $a = 3; clrbit ($a, 1); ok ($a == 1); + ok (UNIVERSAL::isa($a,"GMP::Mpz")); } +{ my $a = 3; clrbit ($a, 2); ok ($a == 3); + ok (UNIVERSAL::isa($a,"GMP::Mpz")); } + +# mutate only given variable +{ my $a = mpz(3); + my $b = $a; + clrbit ($a, 0); + ok ($a == 2); + ok ($b == 3); +} +{ my $a = 3; + my $b = $a; + clrbit ($a, 0); + ok ($a == 2); + ok ($b == 3); +} + +{ tie my $a, 'Mytie', mpz(3); + clrbit ($a, 1); + ok ($Mytie::fetched > 0); # used fetch + ok ($Mytie::stored > 0); # used store + ok ($a == 1); # expected result + ok (UNIVERSAL::isa($a,"GMP::Mpz")); + ok (tied($a)); # still tied +} +{ tie my $a, 'Mytie', 3; + clrbit ($a, 1); + ok ($Mytie::fetched > 0); # used fetch + ok ($Mytie::stored > 0); # used store + ok ($a == 1); # expected result + ok (UNIVERSAL::isa($a,"GMP::Mpz")); + ok (tied($a)); # still tied +} + +{ my $b = mpz(3); + tie my $a, 'Mytie', $b; + clrbit ($a, 0); + ok ($a == 2); + ok ($b == 3); + ok (tied($a)); +} +{ my $b = 3; + tie my $a, 'Mytie', $b; + clrbit ($a, 0); + ok ($a == 2); + ok ($b == 3); + ok (tied($a)); +} + + +#------------------------------------------------------------------------------ +# GMP::Mpz::congruent_p + +ok ( congruent_p (21, 0, 7)); +ok (! congruent_p (21, 1, 7)); +ok ( congruent_p (21, 5, 8)); +ok (! congruent_p (21, 6, 8)); + + +#------------------------------------------------------------------------------ +# GMP::Mpz::congruent_2exp_p + +ok ( congruent_2exp_p (20, 0, 2)); +ok (! congruent_2exp_p (21, 0, 2)); +ok (! congruent_2exp_p (20, 1, 2)); + +#------------------------------------------------------------------------------ +# GMP::Mpz::divexact + +ok (divexact(27,3) == 9); +ok (divexact(27,-3) == -9); +ok (divexact(-27,3) == -9); +ok (divexact(-27,-3) == 9); + +#------------------------------------------------------------------------------ +# GMP::Mpz::divisible_p + +ok ( divisible_p (21, 7)); +ok (! divisible_p (21, 8)); + +#------------------------------------------------------------------------------ +# GMP::Mpz::divisible_2exp_p + +ok ( divisible_2exp_p (20, 2)); +ok (! divisible_2exp_p (21, 2)); + +#------------------------------------------------------------------------------ +# GMP::Mpz::even_p + +ok (! even_p(mpz(-3))); +ok ( even_p(mpz(-2))); +ok (! even_p(mpz(-1))); +ok ( even_p(mpz(0))); +ok (! even_p(mpz(1))); +ok ( even_p(mpz(2))); +ok (! even_p(mpz(3))); + +#------------------------------------------------------------------------------ +# GMP::Mpz::export + +{ my $s = mpz_export (1, 2, 1, 0, "0x61626364"); + ok ($s eq 'abcd'); } +{ my $s = mpz_export (-1, 2, 1, 0, "0x61626364"); + ok ($s eq 'cdab'); } +{ my $s = mpz_export (1, 2, -1, 0, "0x61626364"); + ok ($s eq 'badc'); } +{ my $s = mpz_export (-1, 2, -1, 0, "0x61626364"); + ok ($s eq 'dcba'); } + +#------------------------------------------------------------------------------ +# GMP::Mpz::fac + +ok (fac(0) == 1); +ok (fac(1) == 1); +ok (fac(2) == 2); +ok (fac(3) == 6); +ok (fac(4) == 24); +ok (fac(5) == 120); + +#------------------------------------------------------------------------------ +# GMP::Mpz::fdiv + { my ($q, $r); ($q, $r) = fdiv (16, 3); ok ($q == 5); @@ -387,29 +615,9 @@ ok (bin(3,3) == 1); ok ($r == -1); } -{ my ($q, $r); - ($q, $r) = tdiv (16, 3); - ok ($q == 5); - ok ($r == 1); - ($q, $r) = tdiv (16, -3); - ok ($q == -5); - ok ($r == 1); - ($q, $r) = tdiv (-16, 3); - ok ($q == -5); - ok ($r == -1); - ($q, $r) = tdiv (-16, -3); - ok ($q == 5); - ok ($r == -1); -} +#------------------------------------------------------------------------------ +# GMP::Mpz::fdiv_2exp -{ my ($q, $r); - ($q, $r) = cdiv_2exp (23, 2); - ok ($q == 6); - ok ($r == -1); - ($q, $r) = cdiv_2exp (-23, 2); - ok ($q == -5); - ok ($r == -3); -} { my ($q, $r); ($q, $r) = fdiv_2exp (23, 2); ok ($q == 5); @@ -419,75 +627,8 @@ ok (bin(3,3) == 1); ok ($r == 1); } -{ my ($q, $r); - ($q, $r) = tdiv_2exp (23, 2); - ok ($q == 5); - ok ($r == 3); - ($q, $r) = tdiv_2exp (-23, 2); - ok ($q == -5); - ok ($r == -3); -} - -{ - my $a = 3; - my $b = $a; - ok ($b == 3); - clrbit ($a, 0); - print "a==2\n"; - ok ($a == 2); - print "b==3\n"; - ok ($b == 3); - print "b=a\n"; - $b = $a; - print "b==2\n"; - ok ($b == 2); - print "done\n"; -} -{ - my $a = 0; - my $b = $a; - ok ($b == 0); - setbit ($a, 0); - ok ($a == 1); - ok ($b == 0); - $b = $a; - ok ($b == 1); -} - -ok ( congruent_p (21, 0, 7)); -ok (! congruent_p (21, 1, 7)); -ok ( congruent_p (21, 5, 8)); -ok (! congruent_p (21, 6, 8)); - -ok ( congruent_2exp_p (20, 0, 2)); -ok (! congruent_2exp_p (21, 0, 2)); -ok (! congruent_2exp_p (20, 1, 2)); - -ok (divexact(27,3) == 9); -ok (divexact(27,-3) == -9); -ok (divexact(-27,3) == -9); -ok (divexact(-27,-3) == 9); - -ok ( divisible_p (21, 7)); -ok (! divisible_p (21, 8)); - -ok ( divisible_2exp_p (20, 2)); -ok (! divisible_2exp_p (21, 2)); - -ok (! even_p(mpz(-3))); -ok ( even_p(mpz(-2))); -ok (! even_p(mpz(-1))); -ok ( even_p(mpz(0))); -ok (! even_p(mpz(1))); -ok ( even_p(mpz(2))); -ok (! even_p(mpz(3))); - -ok (fac(0) == 1); -ok (fac(1) == 1); -ok (fac(2) == 2); -ok (fac(3) == 6); -ok (fac(4) == 24); -ok (fac(5) == 120); +#------------------------------------------------------------------------------ +# GMP::Mpz::fib ok (fib(0) == 0); ok (fib(1) == 1); @@ -497,6 +638,9 @@ ok (fib(4) == 3); ok (fib(5) == 5); ok (fib(6) == 8); +#------------------------------------------------------------------------------ +# GMP::Mpz::fib2 + { my ($a, $b) = fib2(0); ok($a==0); ok($b==1); } { my ($a, $b) = fib2(1); ok($a==1); ok($b==0); } { my ($a, $b) = fib2(2); ok($a==1); ok($b==1); } @@ -505,6 +649,9 @@ ok (fib(6) == 8); { my ($a, $b) = fib2(5); ok($a==5); ok($b==3); } { my ($a, $b) = fib2(6); ok($a==8); ok($b==5); } +#------------------------------------------------------------------------------ +# GMP::Mpz::gcd + ok (gcd (21) == 21); ok (gcd (21,15) == 3); ok (gcd (21,15,30,57) == 3); @@ -512,6 +659,9 @@ ok (gcd (21,-15) == 3); ok (gcd (-21,15) == 3); ok (gcd (-21,-15) == 3); +#------------------------------------------------------------------------------ +# GMP::Mpz::gcdext + { my ($g, $x, $y) = gcdext (3,5); ok ($g == 1); @@ -519,12 +669,33 @@ ok (gcd (-21,-15) == 3); ok ($y == -1); } +#------------------------------------------------------------------------------ +# GMP::Mpz::hamdist + ok (hamdist(5,7) == 1); +#------------------------------------------------------------------------------ +# GMP::Mpz::import + +{ my $z = mpz_import (1, 2, 1, 0, 'abcd'); + ok ($z == 0x61626364); } +{ my $z = mpz_import (-1, 2, 1, 0, 'abcd'); + ok ($z == 0x63646162); } +{ my $z = mpz_import (1, 2, -1, 0, 'abcd'); + ok ($z == 0x62616463); } +{ my $z = mpz_import (-1, 2, -1, 0, 'abcd'); + ok ($z == 0x64636261); } + +#------------------------------------------------------------------------------ +# GMP::Mpz::invert + ok (invert(1,123) == 1); ok (invert(6,7) == 6); ok (! defined invert(2,8)); +#------------------------------------------------------------------------------ +# GMP::Mpz::jacobi, GMP::Mpz::kronecker + foreach my $i ([ 1, 19, 1 ], [ 4, 19, 1 ], [ 5, 19, 1 ], @@ -556,6 +727,9 @@ foreach my $i ([ 1, 19, 1 ], } } +#------------------------------------------------------------------------------ +# GMP::Mpz::lcm + ok (lcm (2) == 2); ok (lcm (0) == 0); ok (lcm (0,0) == 0); @@ -577,6 +751,9 @@ ok (lcm (mpz(2)**512,-mpz(2)**512) == mpz(2)**512); ok (lcm (-mpz(2)**512,mpz(2)**512) == mpz(2)**512); ok (lcm (-mpz(2)**512,-mpz(2)**512) == mpz(2)**512); +#------------------------------------------------------------------------------ +# GMP::Mpz::lucnum + ok (lucnum(0) == 2); ok (lucnum(1) == 1); ok (lucnum(2) == 3); @@ -585,6 +762,9 @@ ok (lucnum(4) == 7); ok (lucnum(5) == 11); ok (lucnum(6) == 18); +#------------------------------------------------------------------------------ +# GMP::Mpz::lucnum2 + { my ($a, $b) = lucnum2(0); ok($a==2); ok($b==-1); } { my ($a, $b) = lucnum2(1); ok($a==1); ok($b==2); } { my ($a, $b) = lucnum2(2); ok($a==3); ok($b==1); } @@ -593,19 +773,17 @@ ok (lucnum(6) == 18); { my ($a, $b) = lucnum2(5); ok($a==11); ok($b==7); } { my ($a, $b) = lucnum2(6); ok($a==18); ok($b==11); } +#------------------------------------------------------------------------------ +# GMP::Mpz::nextprime + ok (nextprime(2) == 3); ok (nextprime(3) == 5); ok (nextprime(5) == 7); ok (nextprime(7) == 11); ok (nextprime(11) == 13); -ok ( odd_p(mpz(-3))); -ok (! odd_p(mpz(-2))); -ok ( odd_p(mpz(-1))); -ok (! odd_p(mpz(0))); -ok ( odd_p(mpz(1))); -ok (! odd_p(mpz(2))); -ok ( odd_p(mpz(3))); +#------------------------------------------------------------------------------ +# GMP::Mpz::perfect_power_p # ok ( perfect_power_p(mpz(-27))); # ok (! perfect_power_p(mpz(-9))); @@ -619,6 +797,9 @@ ok ( perfect_power_p(mpz(9))); ok ( perfect_power_p(mpz(27))); ok ( perfect_power_p(mpz(81))); +#------------------------------------------------------------------------------ +# GMP::Mpz::perfect_square_p + ok (! perfect_square_p(mpz(-9))); ok (! perfect_square_p(mpz(-1))); ok ( perfect_square_p(mpz(0))); @@ -630,17 +811,30 @@ ok ( perfect_square_p(mpz(9))); ok (! perfect_square_p(mpz(27))); ok ( perfect_square_p(mpz(81))); +#------------------------------------------------------------------------------ +# GMP::Mpz::popcount + ok (popcount(7) == 3); +#------------------------------------------------------------------------------ +# GMP::Mpz::powm + ok (powm (3,2,8) == 1); +#------------------------------------------------------------------------------ +# GMP::Mpz::probab_prime_p + ok ( probab_prime_p(89,1)); ok (! probab_prime_p(81,1)); -{ - my $z = mpz(123); - realloc ($z, 512); -} +#------------------------------------------------------------------------------ +# GMP::Mpz::realloc + +{ my $z = mpz(123); + realloc ($z, 512); } + +#------------------------------------------------------------------------------ +# GMP::Mpz::remove { my ($rem, $mult); @@ -652,12 +846,18 @@ ok (! probab_prime_p(81,1)); ok ($mult == 2); } +#------------------------------------------------------------------------------ +# GMP::Mpz::root + ok (root(0,2) == 0); ok (root(8,3) == 2); ok (root(-8,3) == -2); ok (root(81,4) == 3); ok (root(243,5) == 3); +#------------------------------------------------------------------------------ +# GMP::Mpz::roote + { my ($r,$e); ($r, $e) = roote(0,2); ok ($r == 0); @@ -670,33 +870,88 @@ ok (root(243,5) == 3); ok (! $e); } -{ - my $ulong_max = ~ 0; - ok (scan0 (0, 0) == 0); - ok (scan0 (1, 0) == 1); - ok (scan0 (3, 0) == 2); - ok (scan0 (-1, 0) == $ulong_max); - ok (scan0 (-2, 1) == $ulong_max); +#------------------------------------------------------------------------------ +# GMP::Mpz::scan0 - ok (scan1 (1, 0) == 0); - ok (scan1 (2, 0) == 1); - ok (scan1 (4, 0) == 2); - ok (scan1 (0, 0) == $ulong_max); - ok (scan1 (3, 2) == $ulong_max); +ok (scan0 (0, 0) == 0); +ok (scan0 (1, 0) == 1); +ok (scan0 (3, 0) == 2); +ok (scan0 (-1, 0) == ~0); +ok (scan0 (-2, 1) == ~0); + +#------------------------------------------------------------------------------ +# GMP::Mpz::scan1 + +ok (scan1 (1, 0) == 0); +ok (scan1 (2, 0) == 1); +ok (scan1 (4, 0) == 2); +ok (scan1 (0, 0) == ~0); +ok (scan1 (3, 2) == ~0); + +#------------------------------------------------------------------------------ +# GMP::Mpz::setbit + +{ my $a = mpz(3); setbit ($a, 1); ok ($a == 3); } +{ my $a = mpz(3); setbit ($a, 2); ok ($a == 7); } + +{ my $a = 3; setbit ($a, 1); ok ($a == 3); } +{ my $a = 3; setbit ($a, 2); ok ($a == 7); } + +# mutate only given variable +{ my $a = mpz(0); + my $b = $a; + setbit ($a, 0); + ok ($a == 1); + ok ($b == 0); } +{ my $a = 0; + my $b = $a; + setbit ($a, 0); + ok ($a == 1); + ok ($b == 0); +} + +{ tie my $a, 'Mytie', mpz(3); + setbit ($a, 2); + ok ($Mytie::fetched > 0); # used fetch + ok ($Mytie::stored > 0); # used store + ok ($a == 7); # expected result + ok (UNIVERSAL::isa($a,"GMP::Mpz")); + ok (tied($a)); # still tied +} +{ tie my $a, 'Mytie', 3; + setbit ($a, 2); + ok ($Mytie::fetched > 0); # used fetch + ok ($Mytie::stored > 0); # used store + ok ($a == 7); # expected result + ok (UNIVERSAL::isa($a,"GMP::Mpz")); + ok (tied($a)); # still tied +} + +{ my $b = mpz(2); + tie my $a, 'Mytie', $b; + setbit ($a, 0); + ok ($a == 3); + ok ($b == 2); + ok (tied($a)); +} +{ my $b = 2; + tie my $a, 'Mytie', $b; + setbit ($a, 0); + ok ($a == 3); + ok ($b == 2); + ok (tied($a)); +} + +#------------------------------------------------------------------------------ +# GMP::Mpz::sizeinbase ok (sizeinbase(1,10) == 1); ok (sizeinbase(100,10) == 3); ok (sizeinbase(9999,10) == 5); -foreach my $name ('mpz', 'mpf') { - print "$name\n"; - my $mpx = eval("\\&$name"); - ok (sqrt(&$mpx(0)) == 0); - ok (sqrt(&$mpx(1)) == 1); - ok (sqrt(&$mpx(4)) == 2); - ok (sqrt(&$mpx(81)) == 9); -} +#------------------------------------------------------------------------------ +# GMP::Mpz::sqrtrem { my ($root, $rem) = sqrtrem(mpz(0)); @@ -729,13 +984,87 @@ foreach my $name ('mpz', 'mpf') { ok ($rem == 0); } +#------------------------------------------------------------------------------ +# GMP::Mpz::tdiv + +{ my ($q, $r); + ($q, $r) = tdiv (16, 3); + ok ($q == 5); + ok ($r == 1); + ($q, $r) = tdiv (16, -3); + ok ($q == -5); + ok ($r == 1); + ($q, $r) = tdiv (-16, 3); + ok ($q == -5); + ok ($r == -1); + ($q, $r) = tdiv (-16, -3); + ok ($q == 5); + ok ($r == -1); +} + +#------------------------------------------------------------------------------ +# GMP::Mpz::tdiv_2exp + +{ my ($q, $r); + ($q, $r) = tdiv_2exp (23, 2); + ok ($q == 5); + ok ($r == 3); + ($q, $r) = tdiv_2exp (-23, 2); + ok ($q == -5); + ok ($r == -3); +} + +#------------------------------------------------------------------------------ +# GMP::Mpz::tstbit + ok (tstbit (6, 0) == 0); ok (tstbit (6, 1) == 1); ok (tstbit (6, 2) == 1); ok (tstbit (6, 3) == 0); -# mpq functions + + +#------------------------------------------------------------------------------ +# GMP::Mpq + +#------------------------------------------------------------------------------ +# GMP::Mpq::new + +ok (mpq(0) == 0); +ok (mpq('0') == 0); +ok (mpq(substr('101',1,1)) == 0); +ok (mpq(0.0) == 0); +ok (mpq(mpz(0)) == 0); +ok (mpq(mpq(0)) == 0); +ok (mpq(mpf(0)) == 0); + +{ tie my $t, 'Mytie', 0; ok (mpq($t) == 0); } +{ tie my $t, 'Mytie', '0'; ok (mpq($t) == 0); } +{ tie my $t, 'Mytie', substr('101',1,1); ok (mpq($t) == 0); } +{ tie my $t, 'Mytie', 0.0; ok (mpq($t) == 0); } +{ tie my $t, 'Mytie', mpz(0); ok (mpq($t) == 0); } +{ tie my $t, 'Mytie', mpq(0); ok (mpq($t) == 0); } +{ tie my $t, 'Mytie', mpf(0); ok (mpq($t) == 0); } + +ok (mpq(-123) == -123); +ok (mpq('-123') == -123); +ok (mpq(substr('1-1231',1,4)) == -123); +ok (mpq(-123.0) == -123); +ok (mpq(mpz(-123)) == -123); +ok (mpq(mpq(-123)) == -123); +ok (mpq(mpf(-123)) == -123); + +{ tie my $t, 'Mytie', -123; ok (mpq($t) == -123); } +{ tie my $t, 'Mytie', '-123'; ok (mpq($t) == -123); } +{ tie my $t, 'Mytie', substr('1-1231',1,4); ok (mpq($t) == -123); } +{ tie my $t, 'Mytie', -123.0; ok (mpq($t) == -123); } +{ tie my $t, 'Mytie', mpz(-123); ok (mpq($t) == -123); } +{ tie my $t, 'Mytie', mpq(-123); ok (mpq($t) == -123); } +{ tie my $t, 'Mytie', mpf(-123); ok (mpq($t) == -123); } + +ok (mpq($ivnv_2p128) == $str_2p128); +{ tie my $t, 'Mytie', $ivnv_2p128; ok (mpq($t) == $str_2p128); } ok (mpq('3/2') == mpq(3,2)); ok (mpq('3/1') == mpq(3,1)); @@ -745,30 +1074,285 @@ ok (mpq('0x3') == mpq(3,1)); ok (mpq('0b111') == mpq(7,1)); ok (mpq('0b0') == mpq(0,1)); -ok (mpq(3,2) > 1); -ok (mpq(3,2) < 2); +ok (mpq($uv_max) > 0); +ok (mpq($uv_max) == mpq($uv_max_str)); +{ tie my $t, 'Mytie', $uv_max; ok (mpq($t) > 0); } +{ tie my $t, 'Mytie', $uv_max; ok (mpq($t) == mpq($uv_max_str)); } + +{ my $x = 123.5; + kill (0, $x); + ok (mpq($x) == 123.5); + tie my $t, 'Mytie', $x; + ok (mpq($t) == 123.5); +} + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_abs + +ok (abs(mpq(0)) == 0); +ok (abs(mpq(123)) == 123); +ok (abs(mpq(-123)) == 123); + +{ my $x = mpq(-123); $x = abs($x); ok ($x == 123); } +{ my $x = mpq(0); $x = abs($x); ok ($x == 0); } +{ my $x = mpq(123); $x = abs($x); ok ($x == 123); } + +{ tie my $t, 'Mytie', mpq(0); ok (abs($t) == 0); } +{ tie my $t, 'Mytie', mpq(123); ok (abs($t) == 123); } +{ tie my $t, 'Mytie', mpq(-123); ok (abs($t) == 123); } + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_add + +ok (mpq(0) + 1 == 1); +ok (mpq(-1) + 1 == 0); +ok (1 + mpq(0) == 1); +ok (1 + mpq(-1) == 0); ok (mpq(1,2)+mpq(1,3) == mpq(5,6)); ok (mpq(1,2)+mpq(-1,3) == mpq(1,6)); ok (mpq(-1,2)+mpq(1,3) == mpq(-1,6)); ok (mpq(-1,2)+mpq(-1,3) == mpq(-5,6)); +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_addeq + +{ my $a = mpq(7); $a += 1; ok ($a == 8); } +{ my $a = mpq(7); my $b = $a; $a += 1; ok ($a == 8); ok ($b == 7); } + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_bool + +if (mpq(0)) { ok (0); } else { ok (1); } +if (mpq(123)) { ok (1); } else { ok (0); } + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_dec + +{ my $a = mpq(0); ok ($a-- == 0); ok ($a == -1); } +{ my $a = mpq(0); ok (--$a == -1); } + +{ my $a = mpq(0); my $b = $a; $a--; ok ($a == -1); ok ($b == 0); } + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_div + +ok (mpq(6) / 2 == 3); +ok (mpq(-6) / 2 == -3); +ok (mpq(6) / -2 == -3); +ok (mpq(-6) / -2 == 3); + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_diveq + +{ my $a = mpq(21); $a /= 3; ok ($a == 7); } +{ my $a = mpq(21); my $b = $a; $a /= 3; ok ($a == 7); ok ($b == 21); } + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_eq + +{ my $a = mpq(0); + my $b = $a; + $a = mpq(1); + ok ($a == 1); + ok ($b == 0); } + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_inc + +{ my $a = mpq(0); ok ($a++ == 0); ok ($a == 1); } +{ my $a = mpq(0); ok (++$a == 1); } + +{ my $a = mpq(0); my $b = $a; $a++; ok ($a == 1); ok ($b == 0); } + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_lshift + +{ my $a = mpq(7) << 1; ok ($a == 14); } + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_lshifteq + +{ my $a = mpq(7); $a <<= 1; ok ($a == 14); } +{ my $a = mpq(7); my $b = $a; $a <<= 1; ok ($a == 14); ok ($b == 7); } + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_mul + +ok (mpq(2) * 3 == 6); + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_muleq + +{ my $a = mpq(7); $a *= 3; ok ($a == 21); } +{ my $a = mpq(7); my $b = $a; $a *= 3; ok ($a == 21); ok ($b == 7); } + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_neg + +ok (- mpq(0) == 0); +ok (- mpq(123) == -123); +ok (- mpq(-123) == 123); + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_not + +if (not mpq(0)) { ok (1); } else { ok (0); } +if (not mpq(123)) { ok (0); } else { ok (1); } + +ok ((! mpq(0)) == 1); +ok ((! mpq(123)) == 0); + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_pow + +ok (mpq(0) ** 1 == 0); +ok (mpq(1) ** 1 == 1); +ok (mpq(2) ** 0 == 1); +ok (mpq(2) ** 1 == 2); +ok (mpq(2) ** 2 == 4); +ok (mpq(2) ** 3 == 8); +ok (mpq(2) ** 4 == 16); + +ok (mpq(0) ** mpq(1) == 0); +ok (mpq(1) ** mpq(1) == 1); +ok (mpq(2) ** mpq(0) == 1); +ok (mpq(2) ** mpq(1) == 2); +ok (mpq(2) ** mpq(2) == 4); +ok (mpq(2) ** mpq(3) == 8); +ok (mpq(2) ** mpq(4) == 16); + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_poweq + +{ my $a = mpq(3); $a **= 4; ok ($a == 81); } +{ my $a = mpq(3); my $b = $a; $a **= 4; ok ($a == 81); ok ($b == 3); } + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_rshift + +{ my $a = mpq(32) >> 1; ok ($a == 16); } + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_rshifteq + +{ my $a = mpq(32); $a >>= 1; ok ($a == 16); } +{ my $a = mpq(32); my $b = $a; $a >>= 1; ok ($a == 16); ok ($b == 32); } + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_spaceship + +ok (mpq(0) < 1); +ok (mpq(0) > -1); + +ok (mpq(0) != 1); +ok (mpq(0) != -1); +ok (mpq(1) != 0); +ok (mpq(1) != -1); +ok (mpq(-1) != 0); +ok (mpq(-1) != 1); + +ok (mpq(3,2) > 1); +ok (mpq(3,2) < 2); + +ok (mpq(0) < 1.0); +ok (mpq(0) < '1'); +ok (mpq(0) < substr('-1',1,1)); +ok (mpq(0) < mpz(1)); +ok (mpq(0) < mpq(1)); +ok (mpq(0) < mpf(1)); +ok (mpq(0) < $uv_max); + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_string + +{ my $x = mpq(0); ok("$x" eq "0"); } +{ my $x = mpq(123); ok("$x" eq "123"); } +{ my $x = mpq(-123); ok("$x" eq "-123"); } + +{ my $q = mpq(5,7); ok("$q" eq "5/7"); } +{ my $q = mpq(-5,7); ok("$q" eq "-5/7"); } + +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_sub + +ok (mpq(0) - 1 == -1); +ok (mpq(1) - 1 == 0); +ok (1 - mpq(0) == 1); +ok (1 - mpq(1) == 0); + ok (mpq(1,2)-mpq(1,3) == mpq(1,6)); ok (mpq(1,2)-mpq(-1,3) == mpq(5,6)); ok (mpq(-1,2)-mpq(1,3) == mpq(-5,6)); ok (mpq(-1,2)-mpq(-1,3) == mpq(-1,6)); -{ - my $q = mpq(21,15); canonicalize($q); +#------------------------------------------------------------------------------ +# GMP::Mpq::overload_subeq + +{ my $a = mpq(7); $a -= 1; ok ($a == 6); } +{ my $a = mpq(7); my $b = $a; $a -= 1; ok ($a == 6); ok ($b == 7); } + +#------------------------------------------------------------------------------ +# GMP::Mpq::canonicalize + +{ my $q = mpq(21,15); canonicalize($q); ok (num($q) == 7); ok (den($q) == 5); } -{ my $q = mpq(5,7); ok("$q" eq "5/7"); } -{ my $q = mpq(-5,7); ok("$q" eq "-5/7"); } +#------------------------------------------------------------------------------ +# GMP::Mpq::den + +{ my $q = mpq(5,9); ok (den($q) == 9); } + +#------------------------------------------------------------------------------ +# GMP::Mpq::num + +{ my $q = mpq(5,9); ok (num($q) == 5); } -# mpf functions + + +#------------------------------------------------------------------------------ +# GMP::Mpf + +#------------------------------------------------------------------------------ +# GMP::Mpf::new + +ok (mpf(0) == 0); +ok (mpf('0') == 0); +ok (mpf(substr('101',1,1)) == 0); +ok (mpf(0.0) == 0); +ok (mpf(mpz(0)) == 0); +ok (mpf(mpq(0)) == 0); +ok (mpf(mpf(0)) == 0); + +{ tie my $t, 'Mytie', 0; ok (mpf($t) == 0); } +{ tie my $t, 'Mytie', '0'; ok (mpf($t) == 0); } +{ tie my $t, 'Mytie', substr('101',1,1); ok (mpf($t) == 0); } +{ tie my $t, 'Mytie', 0.0; ok (mpf($t) == 0); } +{ tie my $t, 'Mytie', mpz(0); ok (mpf($t) == 0); } +{ tie my $t, 'Mytie', mpq(0); ok (mpf($t) == 0); } +{ tie my $t, 'Mytie', mpf(0); ok (mpf($t) == 0); } + +ok (mpf(-123) == -123); +ok (mpf('-123') == -123); +ok (mpf(substr('1-1231',1,4)) == -123); +ok (mpf(-123.0) == -123); +ok (mpf(mpz(-123)) == -123); +ok (mpf(mpq(-123)) == -123); +ok (mpf(mpf(-123)) == -123); + +{ tie my $t, 'Mytie', -123; ok (mpf($t) == -123); } +{ tie my $t, 'Mytie', '-123'; ok (mpf($t) == -123); } +{ tie my $t, 'Mytie', substr('1-1231',1,4); ok (mpf($t) == -123); } +{ tie my $t, 'Mytie', -123.0; ok (mpf($t) == -123); } +{ tie my $t, 'Mytie', mpz(-123); ok (mpf($t) == -123); } +{ tie my $t, 'Mytie', mpq(-123); ok (mpf($t) == -123); } +{ tie my $t, 'Mytie', mpf(-123); ok (mpf($t) == -123); } + +ok (mpf($ivnv_2p128) == $str_2p128); +{ tie my $t, 'Mytie', $ivnv_2p128; ok (mpf($t) == $str_2p128); } ok (mpf(-1.5) == -1.5); ok (mpf(-1.0) == -1.0); @@ -786,126 +1370,694 @@ ok (mpf("0.5") == 0.5); ok (mpf("1.0") == 1.0); ok (mpf("1.5") == 1.5); -{ my $f = mpf(0.25); ok("$f" eq "0.25"); } -{ my $f = mpf(-0.25); ok("$f" eq "-0.25"); } -{ my $f = mpf(1.25); ok("$f" eq "1.25"); } -{ my $f = mpf(-1.25); ok("$f" eq "-1.25"); } -{ my $f = mpf(1000000); ok("$f" eq "1000000"); } -{ my $f = mpf(-1000000); ok("$f" eq "-1000000"); } +ok (mpf($uv_max) > 0); +ok (mpf($uv_max) == mpf($uv_max_str)); +{ tie my $t, 'Mytie', $uv_max; ok (mpf($t) > 0); } +{ tie my $t, 'Mytie', $uv_max; ok (mpf($t) == mpf($uv_max_str)); } + +{ my $x = 123.5; + kill (0, $x); + ok (mpf($x) == 123.5); + tie my $t, 'Mytie', $x; + ok (mpf($t) == 123.5); +} + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_abs + +ok (abs(mpf(0)) == 0); +ok (abs(mpf(123)) == 123); +ok (abs(mpf(-123)) == 123); + +{ my $x = mpf(-123); $x = abs($x); ok ($x == 123); } +{ my $x = mpf(0); $x = abs($x); ok ($x == 0); } +{ my $x = mpf(123); $x = abs($x); ok ($x == 123); } + +{ tie my $t, 'Mytie', mpf(0); ok (abs($t) == 0); } +{ tie my $t, 'Mytie', mpf(123); ok (abs($t) == 123); } +{ tie my $t, 'Mytie', mpf(-123); ok (abs($t) == 123); } + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_add + +ok (mpf(0) + 1 == 1); +ok (mpf(-1) + 1 == 0); +ok (1 + mpf(0) == 1); +ok (1 + mpf(-1) == 0); + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_addeq + +{ my $a = mpf(7); $a += 1; ok ($a == 8); } +{ my $a = mpf(7); my $b = $a; $a += 1; ok ($a == 8); ok ($b == 7); } + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_bool + +if (mpf(0)) { ok (0); } else { ok (1); } +if (mpf(123)) { ok (1); } else { ok (0); } + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_dec + +{ my $a = mpf(0); ok ($a-- == 0); ok ($a == -1); } +{ my $a = mpf(0); ok (--$a == -1); } + +{ my $a = mpf(0); my $b = $a; $a--; ok ($a == -1); ok ($b == 0); } + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_div + +ok (mpf(6) / 2 == 3); +ok (mpf(-6) / 2 == -3); +ok (mpf(6) / -2 == -3); +ok (mpf(-6) / -2 == 3); + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_diveq + +{ my $a = mpf(21); $a /= 3; ok ($a == 7); } +{ my $a = mpf(21); my $b = $a; $a /= 3; ok ($a == 7); ok ($b == 21); } + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_eq + +{ my $a = mpf(0); + my $b = $a; + $a = mpf(1); + ok ($a == 1); + ok ($b == 0); } + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_inc + +{ my $a = mpf(0); ok ($a++ == 0); ok ($a == 1); } +{ my $a = mpf(0); ok (++$a == 1); } + +{ my $a = mpf(0); my $b = $a; $a++; ok ($a == 1); ok ($b == 0); } + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_lshift + +{ my $a = mpf(7) << 1; ok ($a == 14); } + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_lshifteq + +{ my $a = mpf(7); $a <<= 1; ok ($a == 14); } +{ my $a = mpf(7); my $b = $a; $a <<= 1; ok ($a == 14); ok ($b == 7); } + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_mul + +ok (mpf(2) * 3 == 6); + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_muleq + +{ my $a = mpf(7); $a *= 3; ok ($a == 21); } +{ my $a = mpf(7); my $b = $a; $a *= 3; ok ($a == 21); ok ($b == 7); } + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_neg + +ok (- mpf(0) == 0); +ok (- mpf(123) == -123); +ok (- mpf(-123) == 123); + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_not + +if (not mpf(0)) { ok (1); } else { ok (0); } +if (not mpf(123)) { ok (0); } else { ok (1); } + +ok ((! mpf(0)) == 1); +ok ((! mpf(123)) == 0); + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_pow + +ok (mpf(0) ** 1 == 0); +ok (mpf(1) ** 1 == 1); +ok (mpf(2) ** 0 == 1); +ok (mpf(2) ** 1 == 2); +ok (mpf(2) ** 2 == 4); +ok (mpf(2) ** 3 == 8); +ok (mpf(2) ** 4 == 16); + +ok (mpf(0) ** mpf(1) == 0); +ok (mpf(1) ** mpf(1) == 1); +ok (mpf(2) ** mpf(0) == 1); +ok (mpf(2) ** mpf(1) == 2); +ok (mpf(2) ** mpf(2) == 4); +ok (mpf(2) ** mpf(3) == 8); +ok (mpf(2) ** mpf(4) == 16); + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_poweq + +{ my $a = mpf(3); $a **= 4; ok ($a == 81); } +{ my $a = mpf(3); my $b = $a; $a **= 4; ok ($a == 81); ok ($b == 3); } + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_rshift + +{ my $a = mpf(32) >> 1; ok ($a == 16); } + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_rshifteq + +{ my $a = mpf(32); $a >>= 1; ok ($a == 16); } +{ my $a = mpf(32); my $b = $a; $a >>= 1; ok ($a == 16); ok ($b == 32); } + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_sqrt + +ok (sqrt(mpf(0)) == 0); +ok (sqrt(mpf(1)) == 1); +ok (sqrt(mpf(4)) == 2); +ok (sqrt(mpf(81)) == 9); + +ok (sqrt(mpf(0.25)) == 0.5); + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_spaceship + +ok (mpf(0) < 1); +ok (mpf(0) > -1); + +ok (mpf(0) != 1); +ok (mpf(0) != -1); +ok (mpf(1) != 0); +ok (mpf(1) != -1); +ok (mpf(-1) != 0); +ok (mpf(-1) != 1); + +ok (mpf(0) < 1.0); +ok (mpf(0) < '1'); +ok (mpf(0) < substr('-1',1,1)); +ok (mpf(0) < mpz(1)); +ok (mpf(0) < mpq(1)); +ok (mpf(0) < mpf(1)); +ok (mpf(0) < $uv_max); + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_string + +{ my $x = mpf(0); ok ("$x" eq "0"); } +{ my $x = mpf(123); ok ("$x" eq "123"); } +{ my $x = mpf(-123); ok ("$x" eq "-123"); } + +{ my $f = mpf(0.25); ok ("$f" eq "0.25"); } +{ my $f = mpf(-0.25); ok ("$f" eq "-0.25"); } +{ my $f = mpf(1.25); ok ("$f" eq "1.25"); } +{ my $f = mpf(-1.25); ok ("$f" eq "-1.25"); } +{ my $f = mpf(1000000); ok ("$f" eq "1000000"); } +{ my $f = mpf(-1000000); ok ("$f" eq "-1000000"); } + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_sub + +ok (mpf(0) - 1 == -1); +ok (mpf(1) - 1 == 0); +ok (1 - mpf(0) == 1); +ok (1 - mpf(1) == 0); + +#------------------------------------------------------------------------------ +# GMP::Mpf::overload_subeq + +{ my $a = mpf(7); $a -= 1; ok ($a == 6); } +{ my $a = mpf(7); my $b = $a; $a -= 1; ok ($a == 6); ok ($b == 7); } + + +#------------------------------------------------------------------------------ +# GMP::Mpf::ceil + +ok (ceil (mpf(-7.5)) == -7.0); +ok (ceil (mpf(7.5)) == 8.0); + +#------------------------------------------------------------------------------ +# GMP::Mpf::floor ok (floor(mpf(-7.5)) == -8.0); -ok (ceil (mpf(-7.5)) == -7.0); -ok (trunc(mpf(-7.5)) == -7.0); ok (floor(mpf(7.5)) == 7.0); -ok (ceil (mpf(7.5)) == 8.0); -ok (trunc(mpf(7.5)) == 7.0); -set_default_prec(128); -ok ( mpf_eq (mpz("0x10000000000000001"), mpz("0x10000000000000002"), 1)); -ok (! mpf_eq (mpz("0x11"), mpz("0x12"), 128)); +#------------------------------------------------------------------------------ +# GMP::Mpf::mpf_eq -{ +{ my $old_prec = get_default_prec(); set_default_prec(128); - my $p = get_default_prec(); - set_default_prec($p); - ok (get_default_prec() == $p); + + ok ( mpf_eq (mpz("0x10000000000000001"), mpz("0x10000000000000002"), 1)); + ok (! mpf_eq (mpz("0x11"), mpz("0x12"), 128)); + + set_default_prec($old_prec); } +#------------------------------------------------------------------------------ +# GMP::Mpf::get_default_prec + +get_default_prec(); + +#------------------------------------------------------------------------------ +# GMP::Mpf::get_prec + +{ my $x = mpf(1.0, 512); + ok (get_prec ($x) == 512); +} + +#------------------------------------------------------------------------------ +# GMP::Mpf::reldiff + ok (reldiff (2,4) == 1); ok (reldiff (4,2) == 0.5); -{ - my $x = mpf(1.0, 512); - my $y = $x; - my $yprec = get_prec ($y); - set_prec ($x, 1024); - ok (get_prec ($y) == $yprec); +#------------------------------------------------------------------------------ +# GMP::Mpf::set_default_prec - my $xprec = get_prec ($x); - set_prec ($x, $xprec); - ok (get_prec ($x) == $xprec); +{ my $old_prec = get_default_prec(); + + set_default_prec(512); + ok (get_default_prec () == 512); + + set_default_prec($old_prec); } +#------------------------------------------------------------------------------ +# GMP::Mpf::set_prec -# random functions +{ my $x = mpf(1.0, 512); + my $y = $x; + set_prec ($x, 1024); + ok (get_prec ($x) == 1024); + ok (get_prec ($y) == 512); +} + +#------------------------------------------------------------------------------ +# GMP::Mpf::trunc + +ok (trunc(mpf(-7.5)) == -7.0); +ok (trunc(mpf(7.5)) == 7.0); + + + +#------------------------------------------------------------------------------ +# GMP::Rand + +#------------------------------------------------------------------------------ +# GMP::Rand::new { my $r = randstate(); ok (defined $r); } { my $r = randstate('lc_2exp', 1, 2, 3); ok (defined $r); } { my $r = randstate('lc_2exp_size', 64); ok (defined $r); } { my $r = randstate('lc_2exp_size', 999999999); ok (! defined $r); } -{ - my $r = randstate(); + +#------------------------------------------------------------------------------ +# GMP::Rand::seed + +{ my $r = randstate(); $r->seed(123); $r->seed(time()); - mpf_urandomb($r,1024); - mpz_urandomb($r,1024); - mpz_rrandomb($r,1024); - mpz_urandomm($r,mpz(3)**100); } +#------------------------------------------------------------------------------ +# GMP::Rand::mpf_urandomb +{ my $r = randstate(); + my $f = mpf_urandomb($r,1024); + ok (UNIVERSAL::isa($f,"GMP::Mpf")); } + +#------------------------------------------------------------------------------ +# GMP::Rand::mpz_urandomb + +{ my $r = randstate(); + my $z = mpz_urandomb($r, 1024); + ok (UNIVERSAL::isa($z,"GMP::Mpz")); } + +#------------------------------------------------------------------------------ +# GMP::Rand::mpz_rrandomb + +{ my $r = randstate(); + my $z = mpz_rrandomb($r, 1024); + ok (UNIVERSAL::isa($z,"GMP::Mpz")); } + +#------------------------------------------------------------------------------ +# GMP::Rand::mpz_urandomm + +{ my $r = randstate(); + my $z = mpz_urandomm($r, mpz(3)**100); + ok (UNIVERSAL::isa($z,"GMP::Mpz")); } + + + + +#------------------------------------------------------------------------------ +# GMP module + +#------------------------------------------------------------------------------ +# GMP::fits_slong_p + +ok (GMP::fits_slong_p(0)); + +# in perl 5.005 uv_max is only 32-bits on a 64-bit system, so won't exceed a +# long +# ok (! GMP::fits_slong_p($uv_max)); + +ok (GMP::fits_slong_p(0.0)); + +ok (GMP::fits_slong_p('0')); + +ok (GMP::fits_slong_p(substr('999999999999999999999999999999',1,1))); + +ok (! mpz("-9999999999999999999999999999999999999999999")->fits_slong_p()); +ok ( mpz(-123)->fits_slong_p()); +ok ( mpz(0)->fits_slong_p()); +ok ( mpz(123)->fits_slong_p()); +ok (! mpz("9999999999999999999999999999999999999999999")->fits_slong_p()); + +ok (! mpq("-9999999999999999999999999999999999999999999")->fits_slong_p()); +ok ( mpq(-123)->fits_slong_p()); +ok ( mpq(0)->fits_slong_p()); +ok ( mpq(123)->fits_slong_p()); +ok (! mpq("9999999999999999999999999999999999999999999")->fits_slong_p()); + +ok (! mpf("-9999999999999999999999999999999999999999999")->fits_slong_p()); +ok ( mpf(-123)->fits_slong_p()); +ok ( mpf(0)->fits_slong_p()); +ok ( mpf(123)->fits_slong_p()); +ok (! mpf("9999999999999999999999999999999999999999999")->fits_slong_p()); + +#------------------------------------------------------------------------------ +# GMP::get_d + +ok (GMP::get_d(123) == 123.0); + +ok (GMP::get_d($uv_max) > 0); + +ok (GMP::get_d(123.0) == 123.0); + +ok (GMP::get_d('123') == 123.0); + +ok (GMP::get_d(mpz(123)) == 123.0); + +ok (GMP::get_d(mpq(123)) == 123.0); + +ok (GMP::get_d(mpf(123)) == 123.0); + +#------------------------------------------------------------------------------ +# GMP::get_d_2exp + +{ my ($dbl, $exp) = get_d_2exp (0); + ok ($dbl == 0); ok ($exp == 0); } +{ my ($dbl, $exp) = get_d_2exp (1); + ok ($dbl == 0.5); ok ($exp == 1); } + +{ my ($dbl, $exp) = get_d_2exp ($uv_max); + ok ($dbl > 0.0); ok ($exp > 0); } + +{ my ($dbl, $exp) = get_d_2exp (0.5); + ok ($dbl == 0.5); ok ($exp == 0); } +{ my ($dbl, $exp) = get_d_2exp (0.25); + ok ($dbl == 0.5); ok ($exp == -1); } + +{ my ($dbl, $exp) = get_d_2exp ("1.0"); + ok ($dbl == 0.5); ok ($exp == 1); } + +{ my ($dbl, $exp) = get_d_2exp (mpz ("256")); + ok ($dbl == 0.5); ok ($exp == 9); } + +{ my ($dbl, $exp) = get_d_2exp (mpq ("1/16")); + ok ($dbl == 0.5); ok ($exp == -3); } + +{ my ($dbl, $exp) = get_d_2exp (mpf ("1.5")); + ok ($dbl == 0.75); ok ($exp == 1); } +{ my ($dbl, $exp) = get_d_2exp (mpf ("3.0")); + ok ($dbl == 0.75); ok ($exp == 2); } + +#------------------------------------------------------------------------------ +# GMP::get_str + +ok (get_str(-123) eq '-123'); +ok (get_str('-123') eq '-123'); +ok (get_str(substr('x-123x',1,4)) eq '-123'); +ok (get_str(mpz(-123)) eq '-123'); +ok (get_str(mpq(-123)) eq '-123'); + +ok (get_str(-123,10) eq '-123'); +ok (get_str('-123',10) eq '-123'); +ok (get_str(substr('x-123x',1,4),10) eq '-123'); +ok (get_str(mpz(-123),10) eq '-123'); +ok (get_str(mpq(-123),10) eq '-123'); + +ok (get_str(-123,16) eq '-7b'); +ok (get_str('-123',16) eq '-7b'); +ok (get_str(substr('x-123x',1,4),16) eq '-7b'); +ok (get_str(mpz(-123),16) eq '-7b'); +ok (get_str(mpq(-123),16) eq '-7b'); + +ok (get_str(-123,-16) eq '-7B'); +ok (get_str('-123',-16) eq '-7B'); +ok (get_str(substr('x-123x',1,4),-16) eq '-7B'); +ok (get_str(mpz(-123),-16) eq '-7B'); +ok (get_str(mpq(-123),-16) eq '-7B'); + +# is a float in past versions of perl without UV type +{ my ($str, $exp) = get_str($uv_max); + ok ($str eq $uv_max_str); } + +ok (get_str(mpq(5/8)) eq "5/8"); +ok (get_str(mpq(-5/8)) eq "-5/8"); +ok (get_str(mpq(255/256),16) eq "ff/100"); +ok (get_str(mpq(255/256),-16) eq "FF/100"); +ok (get_str(mpq(-255/256),16) eq "-ff/100"); +ok (get_str(mpq(-255/256),-16) eq "-FF/100"); + +{ my ($s,$e) = get_str(1.5, 10); ok ($s eq '15'); ok ($e == 1); } +{ my ($s,$e) = get_str(mpf(1.5), 10); ok ($s eq '15'); ok ($e == 1); } + +{ my ($s,$e) = get_str(-1.5, 10); ok ($s eq '-15'); ok ($e == 1); } +{ my ($s,$e) = get_str(mpf(-1.5), 10); ok ($s eq '-15'); ok ($e == 1); } + +{ my ($s,$e) = get_str(1.5, 16); ok ($s eq '18'); ok ($e == 1); } +{ my ($s,$e) = get_str(mpf(1.5), 16); ok ($s eq '18'); ok ($e == 1); } + +{ my ($s,$e) = get_str(-1.5, 16); ok ($s eq '-18'); ok ($e == 1); } +{ my ($s,$e) = get_str(mpf(-1.5), 16); ok ($s eq '-18'); ok ($e == 1); } + +{ my ($s,$e) = get_str(65536.0, 16); ok ($s eq '1'); ok ($e == 5); } +{ my ($s,$e) = get_str(mpf(65536.0), 16); ok ($s eq '1'); ok ($e == 5); } + +{ my ($s,$e) = get_str(1.625, 16); ok ($s eq '1a'); ok ($e == 1); } +{ my ($s,$e) = get_str(mpf(1.625), 16); ok ($s eq '1a'); ok ($e == 1); } + +{ my ($s,$e) = get_str(1.625, -16); ok ($s eq '1A'); ok ($e == 1); } +{ my ($s,$e) = get_str(mpf(1.625), -16); ok ($s eq '1A'); ok ($e == 1); } + +{ my ($s, $e) = get_str(255.0,16,0); ok ($s eq "ff"); ok ($e == 2); } +{ my ($s, $e) = get_str(mpf(255.0),16,0); ok ($s eq "ff"); ok ($e == 2); } + +{ my ($s, $e) = get_str(255.0,-16,0); ok ($s eq "FF"); ok ($e == 2); } +{ my ($s, $e) = get_str(mpf(255.0),-16,0); ok ($s eq "FF"); ok ($e == 2); } + +#------------------------------------------------------------------------------ +# GMP::get_si + +ok (GMP::get_si(123) == 123.0); + +# better not assume anything about the relatives sizes of long and UV +ok (GMP::get_si($uv_max) != 0); + +ok (GMP::get_si(123.0) == 123.0); + +ok (GMP::get_si('123') == 123.0); + +ok (GMP::get_si(mpz(123)) == 123.0); + +ok (GMP::get_si(mpq(123)) == 123.0); + +ok (GMP::get_si(mpf(123)) == 123.0); + +#------------------------------------------------------------------------------ +# GMP::integer_p + +ok ( GMP::integer_p (0)); +ok ( GMP::integer_p (123)); +ok ( GMP::integer_p (-123)); + +ok ( GMP::integer_p ($uv_max)); + +ok ( GMP::integer_p (0.0)); +ok ( GMP::integer_p (123.0)); +ok ( GMP::integer_p (-123.0)); +ok (! GMP::integer_p (0.5)); +ok (! GMP::integer_p (123.5)); +ok (! GMP::integer_p (-123.5)); + +ok ( GMP::integer_p ('0')); +ok ( GMP::integer_p ('123')); +ok ( GMP::integer_p ('-123')); +ok (! GMP::integer_p ('0.5')); +ok (! GMP::integer_p ('123.5')); +ok (! GMP::integer_p ('-123.5')); +ok (! GMP::integer_p ('5/8')); + +ok ( GMP::integer_p (mpz(1))); + +ok ( GMP::integer_p (mpq(1))); +ok (! GMP::integer_p (mpq(1,2))); + +ok ( GMP::integer_p (mpf(1.0))); +ok (! GMP::integer_p (mpf(1.5))); + +#------------------------------------------------------------------------------ +# GMP::odd_p + +ok (! odd_p(0)); +ok ( odd_p(1)); +ok (! odd_p(2)); + +ok ( odd_p($uv_max)); + +ok ( odd_p(mpz(-3))); +ok (! odd_p(mpz(-2))); +ok ( odd_p(mpz(-1))); +ok (! odd_p(mpz(0))); +ok ( odd_p(mpz(1))); +ok (! odd_p(mpz(2))); +ok ( odd_p(mpz(3))); + +#------------------------------------------------------------------------------ +# GMP::printf + +GMP::printf ("hello world\n"); + +sub via_printf { + my $s; + open TEMP, ">test.tmp" or die; + GMP::printf TEMP @_; + close TEMP or die; + open TEMP, "sgn() == -1); +ok (mpz(0) ->sgn() == 0); +ok (mpz(123) ->sgn() == 1); + +ok (mpq(-123)->sgn() == -1); +ok (mpq(0) ->sgn() == 0); +ok (mpq(123) ->sgn() == 1); + +ok (mpf(-123)->sgn() == -1); +ok (mpf(0) ->sgn() == 0); +ok (mpf(123) ->sgn() == 1); + + + +#------------------------------------------------------------------------------ # overloaded constants -if ($^V > 5.00503) { +if ($] > 5.00503) { if (! do 'test2.pl') { die "Cannot run test2.pl\n"; } } -# printf functions -{ - GMP::printf ("hello world\n"); - sub via_printf { - my $s; - open TEMP, ">test.tmp" or die; - GMP::printf TEMP @_; - close TEMP or die; - open TEMP, " -Copyright 2000, 2001, 2002 Free Software Foundation, Inc.

+Copyright 2000, 2001, 2002, 2003, 2004 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 Lesser General Public License as published @@ -33,40 +33,54 @@ MA 02111-1307, USA.
- This file current as of 14 May 2002. An up-to-date version is available at - http://www.swox.com/gmp/projects.html. + This file current as of 16 Apr 2004. An up-to-date version is available at + http://swox.com/gmp/projects.html. Please send comments about this page to - bug-gmp@gnu.org. + gmp-devel@swox.com.

This file lists projects suitable for volunteers. Please see the tasks file for smaller tasks. -

If you want to work on any of the projects below, please let tege@swox.com - know. If you want to help with a project that already somebody else is - working on, please talk to that person too, tege@swox.com can put you in - touch. (There are no email addresses of volunteers below, due to spamming - problems.) +

If you want to work on any of the projects below, please let gmp-devel@swox.com know. If you want + to help with a project that already somebody else is working on, you will + get in touch through gmp-devel@swox.com. (There are no email addresses of + volunteers below, due to spamming problems.)

  • Faster multiplication -

    The current multiplication code uses Karatsuba, 3-way Toom-Cook, - or Fermat FFT. Several new developments are desirable: +

    The current multiplication code uses Karatsuba, 3-way Toom, and Fermat + FFT. Several new developments are desirable:

      -
    1. Handle multiplication of operands with different digit count - better than today. We now split the operands in a very - inefficient way, see mpn/generic/mul.c. -
    2. Consider N-way Toom-Cook. See Knuth's Seminumerical - Algorithms for details on the method. Code implementing it - exists. This is asymptotically inferior to FFTs, but is finer - grained. A toom-4 might fit in between toom-3 and the FFTs - (or it might not). +
    3. Handle multiplication of operands with different digit count better + than today. We now split the operands in a very inefficient way, see + mpn/generic/mul.c. -
    4. It's possible CPU dependent effects like cache locality will - have a greater impact on speed than algorithmic improvements. +
    5. Implement an FFT variant computing the coefficients mod m different + limb size primes of the form l*2^k+1. i.e., compute m separate FFTs. + The wanted coefficients will at the end be found by lifting with CRT + (Chinese Remainder Theorem). If we let m = 3, i.e., use 3 primes, we + can split the operands into coefficients at limb boundaries, and if + our machine uses b-bit limbs, we can multiply numbers with close to + 2^b limbs without coefficient overflow. For smaller multiplication, + we might perhaps let m = 1, and instead of splitting our operands at + limb boundaries, split them in much smaller pieces. We might also use + 4 or more primes, and split operands into bigger than b-bit chunks. + By using more primes, the gain in shorter transform length, but lose + in having to do more FFTs, but that is a slight total save. We then + lose in more expensive CRT. + +
    6. Perhaps consider N-way Toom. See Knuth's Seminumerical Algorithms for + details on the method. Code implementing it exists. This is + asymptotically inferior to FFTs, but is finer grained. A toom-4 might + fit in between toom-3 and the FFTs (or it might not). + +
    7. It's possible CPU dependent effects like cache locality will have a + greater impact on speed than algorithmic improvements.
    8. Add support for partial products, either a given number of low limbs or high limbs of the result. A high partial product can be used by @@ -127,8 +141,7 @@ MA 02111-1307, USA. current code can mostly be reused. It should be possible to share code between GCD and GCDEXT, and probably with Jacobi symbols too. -

      Paul Zimmermann has worked on sub-quadratic GCD and GCDEXT, but it seems - that the most likely algorithm doesn't kick in until about 3000 limbs. +

      Work on Schöhage GCDEXT for large numbers is in progress.

    9. Math functions for the mpf layer @@ -159,9 +172,10 @@ MA 02111-1307, USA.

    10. Nth root -

      Implement, at the mpn level, a routine for computing the nth root of a - number. The routine should use Newton's method, preferably without using - division. +

      Improve mpn_rootrem. The current code is really naive, using full + precision from the first iteration. Also, calling mpn_pow_1 isn't very + clever, as only 1/n of the result bits will be used; truncation after each + multiplication would be better. Avoiding division might also be possible.

      If the routine becomes fast enough, perhaps square roots could be computed using this function. @@ -286,15 +300,31 @@ MA 02111-1307, USA. requiring longjmp. Wrapping every GMP function call with a setjmp would be very inconvenient. +

      Another option would be to let mpz_t etc hold a sort of + NaN, a special value indicating an out-of-memory or other failure. This + would be similar to NaNs in MPFR. Unfortunately such a scheme could + only be used by programs prepared to handle such special values, since + for instance a program waiting for some condition to be satisfied could + become an infinite loop if it wasn't also watching for NaNs. The work + to implement this would be significant too, lots of checking of inputs + and intermediate results. And if mpn routines were to + participate in this (which they would have to internally) a lot of new + return values would need to be added, since of course there's no + mpz_t etc structure for them to indicate failure in. +

      Stack overflow is another possible exception, but perhaps not one that can be easily detected in general. On i386 GNU/Linux for instance GCC normally doesn't generate stack probes for an alloca, but merely adjusts %esp. A big enough alloca can miss the stack redzone and hit arbitrary data. GMP stack usage is - normally a function of operand size, knowing that might suffice for some - applications. Otherwise a fixed maximum usage can probably be obtained - by building with --enable-alloca=malloc-reentrant (or - notreentrant). + normally a function of operand size, which might be enough for some + applications to know they'll be safe. Otherwise a fixed maximum usage + can probably be obtained by building with + --enable-alloca=malloc-reentrant (or + notreentrant). Arranging the default to be + alloca only on blocks up to a certain size and + malloc thereafter might be a better approach and would have + the advantage of not having calculations limited by available stack.

      Actually recovering from stack overflow is of course another problem. It might be possible to catch a SIGSEGV in the stack @@ -303,6 +333,17 @@ MA 02111-1307, USA. bearing in mind because there's no point worrying about tight and careful out-of-memory recovery if an out-of-stack is fatal. +

      Operand overflow is another exception to be addressed. It's easy for + instance to ask mpz_pow_ui for a result bigger than an + mpz_t can possibly represent. Currently overflows in limb + or byte count calculations will go undetected. Often they'll still end + up asking the memory functions for blocks bigger than available memory, + but that's by no means certain and results are unpredictable in general. + It'd be desirable to tighten up such size calculations. Probably only + selected routines would need checks, if it's assumed say that no input + will be more than half of all memory and hence size additions like say + mpz_mul won't overflow. +

    11. Test Suite @@ -355,6 +396,273 @@ MA 02111-1307, USA. lots of portability and accuracy questions. +

    12. restrict + +

      There might be some value in judicious use of C99 style + restrict on various pointers, but this would need some + careful thought about what it implies for the various operand overlaps + permitted in GMP. + +

      Rumour has it some pre-C99 compilers had restrict, but + expressing tighter (or perhaps looser) requirements. Might be worth + investigating that before using restrict unconditionally. + +

      Loops are presumably where the greatest benefit would be had, by + allowing the compiler to advance reads ahead of writes, perhaps as part + of loop unrolling. However critical loops are generally coded in + assembler, so there might not be very much to gain. And on Cray systems + the explicit use of _Pragma gives an equivalent effect. + +

      One thing to note is that Microsoft C headers (on ia64 at least) contain + __declspec(restrict), so a #define of + restrict should be avoided. It might be wisest to setup a + gmp_restrict. + + +

    13. Nx1 Division + +

      The limb-by-limb dependencies in the existing Nx1 division (and + remainder) code means that chips with multiple execution units or + pipelined multipliers are not fully utilized. + +

      One possibility is to follow the current preinv method but taking two + limbs at a time. That means a 2x2->4 and a 2x1->2 multiply for + each two limbs processed, and because the 2x2 and 2x1 can each be done + in parallel the latency will be not much more than 2 multiplies for two + limbs, whereas the single limb method has a 2 multiply latency for just + one limb. A version of mpn_divrem_1 doing this has been + written in C, but not yet tested on likely chips. Clearly this scheme + would extend to 3x3->9 and 3x1->3 etc, though with diminishing + returns. + +

      For mpn_mod_1, Peter L. Montgomery proposes the following + scheme. For a limb R=2^bits_per_mp_limb, pre-calculate + values R mod N, R^2 mod N, R^3 mod N, R^4 mod N. Then take dividend + limbs and multiply them by those values, thereby reducing them (moving + them down) by the corresponding factor. The products can be added to + produce an intermediate remainder of 2 or 3 limbs to be similarly + included in the next step. The point is that such multiplies can be + done in parallel, meaning as little as 1 multiply worth of latency for 4 + limbs. If the modulus N is less than R/4 (or is it R/5?) the summed + products will fit in 2 limbs, otherwise 3 will be required, but with the + high only being small. Clearly this extends to as many factors of R as + a chip can efficiently apply. + +

      The logical conculsion for powers R^i is a whole array "p[i] = R^i mod + N" for i up to k, the size of the dividend. This could then be applied + at multiplier throughput speed like an inner product. If the powers + took roughly k divide steps to calculate then there'd be an advantage + any time the same N was used three or more times. Suggested by Victor + Shoup in connection with chinese-remainder style decompositions, but + perhaps with other uses. + +

      mpn_modexact_1_odd calculates an x in the range 0<=xmpn_modexact_1_odd to be pressed into + service for an mpn_mod_1. modexact_1 is + simpler and on some chips can run noticably faster than plain + mod_1, on Athlon for instance 11 cycles/limb instead of 17. + Such a difference could soon overcome the time to calculate b^n. The + requirement for an odd divisor in modexact can be handled + by some shifting on-the-fly, or perhaps by an extra partial-limb step at + the end. + + +

    14. Factorial + +

      The removal of twos in the current code could be extended to factors of + 3 or 5. Taking this to its logical conclusion would be a + complete decomposition into powers of primes. The power for a prime p + is of course floor(n/p)+floor(n/p^2)+... Conrad Curry found this is + quite fast (using simultaneous powering as per Handbook of Applied + Cryptography algorithm 14.88). + +

      A difficulty with using all primes is that quite large n can be + calculated on a system with enough memory, larger than we'd probably + want for a table of primes, so some sort of sieving would be wanted. + Perhaps just taking out the factors of 3 and 5 would give most of the + speedup that a prime decomposition can offer. + + +

    15. Binomial Coefficients + +

      An obvious improvement to the current code would be to strip factors of + 2 from each multiplier and divisor and count them separately, to be + applied with a bit shift at the end. Factors of 3 and perhaps 5 could + even be handled similarly. + +

      Conrad Curry reports a big speedup for binomial coefficients using a + prime powering scheme, at least for k near n/2. Of course this is only + practical for moderate size n since again it requires primes up to n. + +

      When k is small the current (n-k+1)...n/1...k will be fastest. Some + sort of rule would be needed for when to use this or when to use prime + powering. Such a rule will be a function of both n and k. Some + investigation is needed to see what sort of shape the crossover line + will have, the usual parameter tuning can of course find machine + dependent constants to fill in where necessary. + +

      An easier possibility also reported by Conrad Curry is that it may be + faster not to divide out the denominator (1...k) one-limb at a time, but + do one big division at the end. Is this because a big divisor in + mpn_bdivmod trades the latency of + mpn_divexact_1 for the throughput of + mpn_submul_1? Overheads must hurt though. + +

      Another reason a big divisor might help is that + mpn_divexact_1 won't be getting a full limb in + mpz_bin_uiui. It's called when the n accumulator is full + but the k may be far from full. Perhaps the two could be decoupled so k + is applied when full. It'd be necessary to delay consideration of k + terms until the corresponding n terms had been applied though, since + otherwise the division won't be exact. + + +

    16. Perfect Power Testing + +

      mpz_perfect_power_p could be improved in a number of ways, + for instance p-adic arithmetic to find possible roots. + +

      Non-powers can be quickly identified by checking for Nth power residues + modulo small primes, like mpn_perfect_square_p does for + squares. The residues to each power N for a given remainder could be + grouped into a bit mask, the masks for the remainders to each divisor + would then be "and"ed together to hopefully leave only a few candidate + powers. Need to think about how wide to make such masks, ie. how many + powers to examine in this way. + +

      Any zero remainders found in residue testing reveal factors which can be + divided out, with the multiplicity restricting the powers that need to + be considered, as per the current code. Further prime dividing should + be grouped into limbs like PP. Need to think about how + much dividing to do like that, probably more for bigger inputs, less for + smaller inputs. + +

      mpn_gcd_1 would probably be better than the current private + GCD routine. The use it's put to isn't time-critical, and it might help + ensure correctness to just use the main GCD routine. + + +

    17. Prime Testing + +

      GMP is not really a number theory library and probably shouldn't have + large amounts of code dedicated to sophisticated prime testing + algorithms, but basic things well-implemented would suit. Tests + offering certainty are probably all too big or too slow (or both!) to + justify inclusion in the main library. Demo programs showing some + possibilities would be good though. + +

      The present "repetitions" argument to mpz_probab_prime_p is + rather specific to the Miller-Rabin tests of the current implementation. + Better would be some sort of parameter asking perhaps for a maximum + chance 1/2^x of a probable prime in fact being composite. If + applications follow the advice that the present reps gives 1/4^reps + chance then perhaps such a change is unnecessary, but an explicitly + described 1/2^x would allow for changes in the implementation or even + for new proofs about the theory. + +

      mpz_probab_prime_p always initializes a new + gmp_randstate_t for randomized tests, which unfortunately + means it's not really very random and in particular always runs the same + tests for a given input. Perhaps a new interface could accept an rstate + to use, so successive tests could increase confidence in the result. + +

      mpn_mod_34lsub1 is an obvious and easy improvement to the + trial divisions. And since the various prime factors are constants, the + remainder can be tested with something like +

      +#define MP_LIMB_DIVISIBLE_7_P(n) \
      +  ((n) * MODLIMB_INVERSE_7 <= MP_LIMB_T_MAX/7)
      +
      + Which would help compilers that don't know how to optimize divisions by + constants, and is even an improvement on current gcc 3.2 code. This + technique works for any modulus, see Granlund and Montgomery "Division + by Invariant Integers" section 9. + +

      The trial divisions are done with primes generated and grouped at + runtime. This could instead be a table of data, with pre-calculated + inverses too. Storing deltas, ie. amounts to add, rather than actual + primes would save space. udiv_qrnnd_preinv style inverses + can be made to exist by adding dummy factors of 2 if necessary. Some + thought needs to be given as to how big such a table should be, based on + how much dividing would be profitable for what sort of size inputs. The + data could be shared by the perfect power testing. + +

      Jason Moxham points out that if a sqrt(-1) mod N exists then any factor + of N must be == 1 mod 4, saving half the work in trial dividing. (If + x^2==-1 mod N then for a prime factor p we have x^2==-1 mod p and so the + jacobi symbol (-1/p)=1. But also (-1/p)=(-1)^((p-1)/2), hence must have + p==1 mod 4.) But knowing whether sqrt(-1) mod N exists is not too easy. + A strong pseudoprime test can reveal one, so perhaps such a test could + be inserted part way though the dividing. + +

      Jon Grantham "Frobenius Pseudoprimes" (www.pseudoprime.com) describes a + quadratic pseudoprime test taking about 3x longer than a plain test, but + with only a 1/7710 chance of error (whereas 3 plain Miller-Rabin tests + would offer only (1/4)^3 == 1/64). Such a test needs completely random + parameters to satisfy the theory, though single-limb values would run + faster. It's probably best to do at least one plain Miller-Rabin before + any quadratic tests, since that can identify composites in less total + time. + +

      Some thought needs to be given to the structure of which tests (trial + division, Miller-Rabin, quadratic) and how many are done, based on what + sort of inputs we expect, with a view to minimizing average time. + +

      It might be a good idea to break out subroutines for the various tests, + so that an application can combine them in ways it prefers, if sensible + defaults in mpz_probab_prime_p don't suit. In particular + this would let applications skip tests it knew would be unprofitable, + like trial dividing when an input is already known to have no small + factors. + +

      For small inputs, combinations of theory and explicit search make it + relatively easy to offer certainty. For instance numbers up to 2^32 + could be handled with a strong pseudoprime test and table lookup. But + it's rather doubtful whether a smallnum prime test belongs in a bignum + library. Perhaps if it had other internal uses. + +

      An mpz_nthprime might be cute, but is almost certainly + impractical for anything but small n. + + +

    18. Intra-Library Calls + +

      On various systems, calls within libgmp still go through the PLT, TOC or + other mechanism, which makes the code bigger and slower than it needs to + be. + +

      The theory would be to have all GMP intra-library calls resolved + directly to the routines in the library. An application wouldn't be + able to replace a routine, the way it can normally, but there seems no + good reason to do that, in normal circumstances. + +

      The visibility attribute in recent gcc is good for this, + because it lets gcc omit unnecessary GOT pointer setups or whatever if + it finds all calls are local and there's no global data references. + Documented entrypoints would be protected, and purely + internal things not wanted by test programs or anything can be + internal. + +

      Unfortunately, on i386 it seems protected ends up causing + text segment relocations within libgmp.so, meaning the library code + can't be shared between processes, defeating the purpose of a shared + library. Perhaps this is just a gremlin in binutils (debian packaged + 2.13.90.0.16-1). + +

      The linker can be told directly (with a link script, or options) to do + the same sort of thing. This doesn't change the code emitted by gcc of + course, but it does mean calls are resolved directly to their targets, + avoiding a PLT entry. + +

      Keeping symbols private to libgmp.so is probably a good thing in general + too, to stop anyone even attempting to access them. But some + undocumented things will need or want to be kept visibible, for use by + mpfr, or the test and tune programs. Libtool has a standard option for + selecting public symbols (used now for libmp). + +


diff --git a/src/gmp/doc/tasks.html b/src/gmp/doc/tasks.html index 839cdfd89..a7f0a7211 100644 --- a/src/gmp/doc/tasks.html +++ b/src/gmp/doc/tasks.html @@ -14,7 +14,7 @@ -Copyright 2000, 2001, 2002 Free Software Foundation, Inc.

+Copyright 2000, 2001, 2002, 2003, 2004 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 Lesser General Public License as published @@ -33,10 +33,10 @@ MA 02111-1307, USA.
- This file current as of 20 May 2002. An up-to-date version is available at - http://www.swox.com/gmp/tasks.html. + This file current as of 14 Apr 2004. An up-to-date version is available at + http://swox.com/gmp/tasks.html. Please send comments about this page to - bug-gmp@gnu.org. + gmp-devel@swox.com.

These are itemized GMP development tasks. Not all the tasks @@ -46,6 +46,13 @@ MA 02111-1307, USA.

Correctness and Completeness

    +
  • _LONG_LONG_LIMB in gmp.h is not namespace clean. Reported + by Patrick Pelissier. +
    + We sort of mentioned _LONG_LONG_LIMB in past releases, so + need to be careful about changing it. It used to be a define + applications had to set for long long limb systems, but that in + particular is no longer relevant now that it's established automatically.
  • The various reuse.c tests need to force reallocation by calling _mpz_realloc with a small (1 limb) size.
  • One reuse case is missing from mpX/tests/reuse.c: @@ -63,35 +70,79 @@ MA 02111-1307, USA.
  • mpf_eq is not always correct, when one operand is 1000000000... and the other operand is 0111111111..., i.e., extremely close. There is a special case in mpf_sub for this - situation; put similar code in mpf_eq. + situation; put similar code in mpf_eq. [In progress.]
  • mpf_eq doesn't implement what gmp.texi specifies. It should - not use just whole limbs, but partial limbs. + not use just whole limbs, but partial limbs. [In progress.]
  • mpf_set_str doesn't validate it's exponent, for instance garbage 123.456eX789X is accepted (and an exponent 0 used), and overflow of a long is not detected.
  • mpf_add doesn't check for a carry from truncated portions of the inputs, and in that respect doesn't implement the "infinite precision followed by truncate" specified in the manual. -
  • mpf_div of x/x doesn't always give 1, reported by Peter - Moulder. Perhaps it suffices to put +1 on the effective divisor prec, so - that data bits rather than zeros are shifted in when normalizing. Would - prefer to switch to mpn_tdiv_qr, where all shifting should - disappear.
  • Windows DLLs: tests/mpz/reuse.c and tests/mpf/reuse.c initialize global variables with pointers to mpz_add etc, which doesn't work when those routines are coming from a DLL (because they're effectively function pointer global variables themselves). Need to rearrange perhaps to a set of calls to a test function rather than iterating over an array. -
  • demos/pexpr.c: The local variables in main might be - clobbered by the longjmp. +
  • mpz_pow_ui: Detect when the result would be more memory than + a size_t can represent and raise some suitable exception, + probably an alloc call asking for SIZE_T_MAX, and if that + somehow succeeds then an abort. Various size overflows of + this kind are not handled gracefully, probably resulting in segvs. +
    + In mpz_n_pow_ui, detect when the count of low zero bits + exceeds an unsigned long. There's a (small) chance of this + happening but still having enough memory to represent the value. + Reported by Winfried Dreckmann in for instance mpz_ui_pow_ui (x, + 4UL, 1431655766UL). +
  • mpf: Detect exponent overflow and raise some exception. + It'd be nice to allow the full mp_exp_t range since that's + how it's been in the past, but maybe dropping one bit would make it + easier to test if e1+e2 goes out of bounds.

Machine Independent Optimization

    -
  • mpn_gcdext, mpz_get_d, - mpf_get_str: Don't test count_leading_zeros for +
  • mpf_cmp: For better cache locality, don't test for low zero + limbs until the high limbs fail to give an ordering. Reduce code size by + turning the three mpn_cmp's into a single loop stopping when + the end of one operand is reached (and then looking for a non-zero in the + rest of the other). +
  • mpf_mul_2exp, mpf_div_2exp: The use of + mpn_lshift for any size<=prec means repeated + mul_2exp and div_2exp calls accumulate low zero + limbs until size==prec+1 is reached. Those zeros will slow down + subsequent operations, especially if the value is otherwise only small. + If low bits of the low limb are zero, use mpn_rshift so as + to not increase the size. +
  • mpn_dc_sqrtrem: Don't use mpn_addmul_1 with + multiplier==2, instead either mpn_addlsh1_n when available, + or mpn_lshift+mpn_add_n if not. +
  • mpn_dc_sqrtrem, mpn_sqrtrem2: Don't use + mpn_add_1 and mpn_sub_1 for 1 limb operations, + instead ADDC_LIMB and SUBC_LIMB. +
  • mpn_sqrtrem2: Use plain variables for sp[0] and + rp[0] calculations, so the compiler needn't worry about + aliasing between sp and rp. +
  • mpn_sqrtrem: Some work can be saved in the last step when + the remainder is not required, as noted in Paul's paper. +
  • mpq_add, mpq_add: The division "op1.den / gcd" + is done twice, where of course only once is necessary. Reported by Larry + Lambe. +
  • mpq_add, mpq_sub: The gcd fits a single limb + with high probability and in this case modlimb_invert could + be used to calculate the inverse just once for the two exact divisions + "op1.den / gcd" and "op2.den / gcd", rather than letting + mpn_divexact_1 do it each time. This would require a new + mpn_preinv_divexact_1 interface. Not sure if it'd be worth + the trouble. +
  • mpq_add, mpq_sub: The use of + mpz_mul(x,y,x) causes temp allocation or copying in + mpz_mul which can probably be avoided. A rewrite using + mpn might be best. +
  • mpn_gcdext: Don't test count_leading_zeros for zero, instead check the high bit of the operand and avoid invoking count_leading_zeros. This is an optimization on all machines, and significant on machines with slow @@ -135,84 +186,8 @@ MA 02111-1307, USA. moderate sizes by improving find_a, possibly just by providing an alternate implementation for CPUs with slowish count_leading_zeros. -
  • Toom3 USE_MORE_MPN could use a low to high cache localized - evaluate and interpolate. The necessary mpn_divexact_by3c - exists. -
  • mpn_mul_basecase on NxM with big N but small M could try for - better cache locality by taking N piece by piece. The current code could - be left available for CPUs without caching. Depending how karatsuba etc - is applied to unequal size operands it might be possible to assume M is - always smallish. -
  • mpn_perfect_square_p on small operands might be better off - skipping the residue tests and just taking a square root. -
  • mpz_perfect_power_p could be improved in a number of ways. - Test for Nth power residues modulo small primes like - mpn_perfect_square_p does. Use p-adic arithmetic to find - possible roots. Divisibility by other primes should be tested by - grouping into a limb like PP. -
  • mpz_perfect_power_p might like to use mpn_gcd_1 - instead of a private GCD routine. The use it's put to isn't - time-critical, and it might help be ensure correctness to use the main GCD - routine. -
  • mpz_perfect_power_p could use - mpz_divisible_ui_p instead of mpz_tdiv_ui for - divisibility testing, the former is faster on a number of systems. (But - all that prime test stuff is going to be rewritten some time.) -
  • Change PP/PP_INVERTED into an array of such - pairs, listing several hundred primes. Perhaps actually make the - products larger than one limb each. -
  • PP can have factors of 2 introduced in order to get the high - bit set and therefore a PP_INVERTED existing. The factors - of 2 don't affect the way the remainder r = a % ((x*y*z)*2^n) is used, - further remainders r%x, r%y, etc, are the same since x, y, etc are odd. - The advantage of this is that mpn_preinv_mod_1 can then be - used if it's faster than plain mpn_mod_1. This would be a - change only for 16-bit limbs, all the rest already have PP - in the right form. -
  • PP could have extra factors of 3 or 5 or whatever introduced - if they fit, and final remainders mod 9 or 25 or whatever used, thereby - making more efficient use of the mpn_mod_1 done. On a - 16-bit limb it looks like PP could take an extra factor of - 3. -
  • mpz_probab_prime_p, mpn_perfect_square_p and - mpz_perfect_power_p could use mpn_mod_34lsub1 - to take a remainder mod 2^24-1 or 2^48-1 and quickly get remainders mod - 3, 5, 7, 13 and 17 (factors of 2^24-1). This could either replace the - PP division currently done, or allow PP to do - larger primes, depending how many residue tests seem worthwhile before - launching into full root extractions or Miller-Rabin etc. -
  • mpz_probab_prime_p (and maybe others) could code the - divisibility tests like n%7 == 0 in the form -
    -#define MP_LIMB_DIVISIBLE_7_P(n) \
    -  ((n) * MODLIMB_INVERSE_7 <= MP_LIMB_T_MAX/7)
    -
    - This would help compilers which don't know how to optimize divisions by - constants, and would help current gcc (3.0) too since gcc forms a whole - remainder rather than using a modular inverse and comparing. This - technique works for any odd modulus, and with some tweaks for even moduli - too. See Granlund and Montgomery "Division By Invariant Integers" - section 9. -
  • mpz_probab_prime_p and mpz_nextprime could - offer certainty for primes up to 2^32 by using a one limb miller-rabin - test to base 2, combined with a table of actual strong pseudoprimes in - that range (2314 of them). If that table is too big then both base 2 and - base 3 tests could be done, leaving a table of 104. The test could use - REDC and therefore be a modlimb_invert a remainder (maybe) - then two multiplies per bit (successively dependent). Processors with - pipelined multipliers could do base 2 and 3 in parallel. Vector systems - could do a whole bunch of bases in parallel, and perhaps offer near - certainty up to 64-bits (certainty might depend on an exhaustive search - of pseudoprimes up to that limit). Obviously 2^32 is not a big number, - but an efficient and certain calculation is attractive. It might find - other uses internally, and could even be offered as a one limb prime test - mpn_probab_prime_1_p or gmp_probab_prime_ui_p - perhaps. -
  • mpz_probab_prime_p doesn't need to make a copy of - n when the input is negative, it can setup an - mpz_t alias, same data pointer but a positive size. With no - need to clear before returning, the recursive function call could be - dispensed with too. +
  • Toom3 could use a low to high cache localized evaluate and interpolate. + The necessary mpn_divexact_by3c exists.
  • mpf_set_str produces low zero limbs when a string has a fraction but is exactly representable, eg. 0.5 in decimal. These could be stripped to save work in later operations. @@ -228,14 +203,24 @@ MA 02111-1307, USA. result, perhaps test for r==u and do nothing in that case, rather than currently it looks like an MPN_COPY_INCR will be done to reduce prec+1 limbs to prec. +
  • mpf_div_ui: Instead of padding with low zeros, call + mpn_divrem_1 asking for fractional quotient limbs. +
  • mpf_div_ui: Eliminate TMP_ALLOC. When r!=u + there's no overlap and the division can be called on those operands. + When r==u and is prec+1 limbs, then it's an in-place division. If r==u + and not prec+1 limbs, then move the available limbs up to prec+1 and do + an in-place there. +
  • mpf_div_ui: Whether the high quotient limb is zero can be + determined by testing the dividend for highTMP_ALLOC is eliminated).
  • mpn_divrem_2 could usefully accept unnormalized divisors and shift the dividend on-the-fly, since this should cost nothing on superscalar processors and avoid the need for temporary copying in mpn_tdiv_qr. -
  • mpf_sqrt_ui calculates prec+1 limbs, whereas just prec would - satisfy the application requested precision. It should suffice to simply - reduce the rsize temporary to 2*prec-1 limbs. mpf_sqrt - might be similar. +
  • mpf_sqrt: If r!=u, and if u doesn't need to be padded with + zeros, then there's no need for the tp temporary.
  • invert_limb generic C: The division could use dividend b*(b-d)-1 which is high:low of (b-1-d):(b-1), instead of the current (b-d):0, where b=2^BITS_PER_MP_LIMB and d=divisor. The @@ -264,16 +249,6 @@ MA 02111-1307, USA. bitfield for the mantissa extraction, not two, when endianness permits. Might depend on the compiler allowing long long bit fields when that's the only actual 64-bit type. -
  • mpf_get_d could be more like mpz_get_d and do - more in integers and give the float conversion as such a chance to round - in its preferred direction. Some code sharing ought to be possible. Or - if nothing else then for consistency the two ought to give identical - results on integer operands (not clear if this is so right now). -
  • usqr_ppm or some such could do a widening square in the - style of umul_ppmm. This would help 68000, and be a small - improvement for the generic C (which is used on UltraSPARC/64 for - instance). GCC recognises the generic C ul*vh and vl*uh are identical, - but does two separate additions to the rest of the result.
  • tal-notreent.c could keep a block of memory permanently allocated. Currently the last nested TMP_FREE releases all memory, so there's an allocate and free every time a top-level function using @@ -300,12 +275,6 @@ MA 02111-1307, USA.
  • __mp_bases field big_base_inverted is only used if USE_PREINV_DIVREM_1 is true, and could be omitted otherwise, to save space. -
  • Make mpf_get_str and mpf_set_str call the - corresponding, much faster, mpn functions. -
  • mpn_mod_1 could pre-calculate values of R mod N, R^2 mod N, - R^3 mod N, etc, with R=2^BITS_PER_MP_LIMB, and use them to - process multiple limbs at each step by multiplying. Suggested by Peter - L. Montgomery.
  • mpz_get_str, mtox: For power-of-2 bases, which are of course fast, it seems a little silly to make a second pass over the mpn_get_str output to convert to ASCII. Perhaps combine @@ -315,28 +284,27 @@ MA 02111-1307, USA. deriving S from that. Perhaps it'd be possible to arrange to get S in the first place by calling mpn_gcdext with A+B,B. This might only be an advantage if A and B are about the same size. -
  • mpn_toom3_mul_n, mpn_toom3_sqr_n: Temporaries - B and D are adjacent in memory and at the final - coefficient additions look like they could use a single - mpn_add_n of l4 limbs rather than two of - l2 limbs. +
  • mpz_n_pow_ui does a good job with small bases and stripping + powers of 2, but it's perhaps a bit too complicated for what it gains. + The simpler mpn_pow_1 is a little faster on small exponents. + (Note some of the ugliness in mpz_n_pow_ui is due to + supporting mpn_mul_2.) +
    + Perhaps the stripping of 2s in mpz_n_pow_ui should be + confined to single limb operands for simplicity and since that's where + the greatest gain would be. +
    + Ideally mpn_pow_1 and mpz_n_pow_ui would be + merged. The reason mpz_n_pow_ui writes to an + mpz_t is that its callers leave it to make a good estimate + of the result size. Callers of mpn_pow_1 already know the + size by separate means (mp_bases). +
  • mpz_invert should call mpn_gcdext directly.

Machine Dependent Optimization

    -
  • udiv_qrnnd_preinv2norm, the branch-free version of - udiv_qrnnd_preinv, might be faster on various pipelined - chips. In particular the first if (_xh != 0) in - udiv_qrnnd_preinv might be roughly a 50/50 chance and might - branch predict poorly. (The second test is probably almost always - false.) Measuring with the tuneup program would be possible, but perhaps - a bit messy. In any case maybe the default should be the branch-free - version. -
    - Note that the current udiv_qrnnd_preinv2norm implementation - assumes a right shift will sign extend, which is not guaranteed by the C - standards, and doesn't happen on Cray vector systems.
  • Run the `tune' utility for more compiler/CPU combinations. We would like to have gmp-mparam.h files in practically every implementation specific mpn subdirectory, and repeat each *_THRESHOLD for gcc and the system @@ -358,6 +326,11 @@ MA 02111-1307, USA. #endif
  • invert_limb on various processors might benefit from the little Newton iteration done for alpha and ia64. +
  • Alpha 21264: mpn_addlsh1_n could be implemented with + mpn_addmul_1, since that code at 3.5 is a touch faster than + a separate lshift and add_n at + 1.75+2.125=3.875. Or very likely some specific addlsh1_n + code could beat both.
  • Alpha 21264: Improve feed-in code for mpn_mul_1, mpn_addmul_1, and mpn_submul_1.
  • Alpha 21164: Rewrite mpn_mul_1, mpn_addmul_1, @@ -366,23 +339,28 @@ MA 02111-1307, USA. operations, the single-limb multiplier should be split into three 21-bit chunks, or perhaps even better in four 16-bit chunks. Probably possible to reach 9 cycles/limb. -
  • Alpha 21264 ev67: Use ctlz and cttz for - count_leading_zeros andcount_trailing_zeros. - Use inline for gcc, probably want asm files for elsewhere. -
  • ARC: gcc longlong.h sets up umul_ppmm to call - __umulsidi3 in libgcc. Could be copied straight across, but - perhaps ought to be tested. -
  • ARM: On v5 cpus see if the clz instruction can be used for - count_leading_zeros. -
  • Itanium: mpn_divexact_by3 isn't particularly important, but - the generic C runs at about 27 c/l, whereas with the multiplies off the - dependent chain about 3 c/l ought to be possible. -
  • Itanium: mpn_hamdist could be put together based on the - current mpn_popcount. -
  • Itanium: popc_limb in gmp-impl.h could use the - popcnt insn. -
  • Itanium: mpn_submul_1 is not implemented directly, only via - a combination of mpn_mul_1 and mpn_sub_n. +
  • Alpha: GCC 3.4 will introduce __builtin_ctzl, + __builtin_clzl and __builtin_popcountl using + the corresponding CIX ct instructions, and + __builtin_alpha_cmpbge. These should give GCC more + information about sheduling etc than the asm blocks + currently used in longlong.h and gmp-impl.h. +
  • Alpha Unicos: Apparently there's no alloca on this system, + making configure choose the slower + malloc-reentrant allocation method. Is there a better way? + Maybe variable-length arrays per notes below. +
  • Alpha Unicos 21164, 21264: .align is not used since it pads + with garbage. Does the code get the intended slotting required for the + claimed speeds? .align at the start of a function would + presumably be safe no matter how it pads. +
  • ARM V5: count_leading_zeros can use the clz + instruction. For GCC 3.4 and up, do this via __builtin_clzl + since then gcc knows it's "predicable". +
  • Itanium: GCC 3.4 introduces __builtin_popcount which can be + used instead of an asm block. The builtin should give gcc + more opportunities for scheduling, bundling and predication. + __builtin_ctz similarly (it just uses popcount as per + current longlong.h).
  • UltraSPARC/64: Optimize mpn_mul_1, mpn_addmul_1, for s2 < 2^32 (or perhaps for any zero 16-bit s2 chunk). Not sure how much this can improve the speed, though, since the symmetry that we rely @@ -394,10 +372,6 @@ MA 02111-1307, USA. "mulx"s either with an asm block or via the generic C code is about 90 cycles. Try using fp operations, and also try using karatsuba for just three "mulx"s. -
  • UltraSPARC/64: mpn_divrem_1, mpn_mod_1, - mpn_divexact_1 and mpn_modexact_1_odd could - process 32 bits at a time when the divisor fits 32-bits. This will need - only 4 mulx's per limb instead of 8 in the general case.
  • UltraSPARC/32: Rewrite mpn_lshift, mpn_rshift. Will give 2 cycles/limb. Trivial modifications of mpn/sparc64 should do.
  • UltraSPARC/32: Write special mpn_Xmul_1 loops for s2 < 2^16. @@ -409,21 +383,32 @@ MA 02111-1307, USA. gcc/config/sol2-sld-64.h. Will need to pass something through from ./configure to select the right code in longlong.h. (Currently nothing is lost because mulx for multiplying is commented out.) +
  • UltraSPARC/32: mpn_divexact_1 and + mpn_modexact_1c_odd can use a 64-bit inverse and take + 64-bits at a time from the dividend, as per the 32-bit divisor case in + mpn/sparc64/mode1o.c. This must be done in assembler, since the full + 64-bit registers (%gN) are not available from C. +
  • UltraSPARC/32: mpn_divexact_by3c can work 64-bits at a time + using mulx, in assembler. This would be the same as for + sparc64.
  • UltraSPARC: modlimb_invert might save a few cycles from masking down to just the useful bits at each point in the calculation, since mulx speed depends on the highest bit set. Either explicit masks or small types like short and int ought to work. -
  • Sparc64 HAL R1: mpn_popcount and mpn_hamdist - could use popc currently commented out in gmp-impl.h. This - chip reputedly implements popc properly (see gcc sparc.md), - would need to recognise the chip as sparchalr1 or something - in configure / config.sub / config.guess. +
  • Sparc64 HAL R1 popc: This chip reputedly implements + popc properly (see gcc sparc.md). Would need to recognise + it as sparchalr1 or something in configure / config.sub / + config.guess. popc_limb in gmp-impl.h could use this (per + commented out code). count_trailing_zeros could use it too.
  • PA64: Improve mpn_addmul_1, mpn_submul_1, and mpn_mul_1. The current code runs at 11 cycles/limb. It should be possible to saturate the cache, which will happen at 8 cycles/limb (7.5 for mpn_mul_1). Write special loops for s2 < 2^32; it should be possible to make them run at about 5 cycles/limb. +
  • PPC601: See which of the power or powerpc32 code runs better. Currently + the powerpc32 is used, but only because it's the default for + powerpc*.
  • PPC630: Rewrite mpn_addmul_1, mpn_submul_1, and mpn_mul_1. Use both integer and floating-point operations, possibly two floating-point and one integer limb per loop. Split operands @@ -434,8 +419,6 @@ MA 02111-1307, USA. as mpn_lshift. Some judicious use of m4 might let the two share source code, or with a register to control the loop direction perhaps even share object code. -
  • PowerPC-32: mpn_rshift should do the same sort of unrolled - loop as mpn_lshift.
  • Implement mpn_mul_basecase and mpn_sqr_basecase for important machines. Helping the generic sqr_basecase.c with an mpn_sqr_diagonal might be enough for some of the RISCs. @@ -456,23 +439,17 @@ MA 02111-1307, USA. might benefit from some destination prefetching.
  • PentiumPro: mpn_divrem_1 might be able to use a mul-by-inverse, hoping for maybe 30 c/l. -
  • P6: mpn_add_n and mpn_sub_n should be able to go - faster than the generic x86 code at 3.5 c/l. The athlon code for instance - runs at about 2.7.
  • K7: mpn_lshift and mpn_rshift might be able to do something branch-free for unaligned startups, and shaving one insn from the loop with alternative indexing might save a cycle.
  • PPC32: Try using fewer registers in the current mpn_lshift. The pipeline is now extremely deep, perhaps unnecessarily deep. -
  • PPC32: Write mpn_rshift based on new mpn_lshift. -
  • PPC32: Rewrite mpn_add_n and mpn_sub_n. Should - run at just 3.25 cycles/limb.
  • Fujitsu VPP: Vectorize main functions, perhaps in assembly language.
  • Fujitsu VPP: Write mpn_mul_basecase and mpn_sqr_basecase. This should use a "vertical multiplication method", to avoid carry propagation. splitting one of the operands in 11-bit chunks. -
  • 68k, Pentium: mpn_lshift by 31 should use the special rshift +
  • Pentium: mpn_lshift by 31 should use the special rshift by 1 code, and vice versa mpn_rshift by 31 should use the special lshift by 1. This would be best as a jump across to the other routine, could let both live in lshift.asm and omit rshift.asm on finding @@ -498,19 +475,12 @@ MA 02111-1307, USA. Does it? bits_per_digit and the inner loop over bits in a limb might prevent it. Perhaps special cases for binary, octal and hex would be worthwhile (very possibly for all processors too). -
  • Cray: popc_limb could use the Cray _popc - intrinsic. That would help mpz_hamdist and might make the - generic C versions of mpn_popcount and - mpn_hamdist suffice for Cray (if it vectorizes, or can be - given a hint to do so). -
  • 68000: mpn_mul_1, mpn_addmul_1, - mpn_submul_1: Check for a 16-bit multiplier and use two - multiplies per limb, not four. -
  • 68000: mpn_lshift and mpn_rshift could use a - roll and mask instead of lsrl and - lsll. This promises to be a speedup, effectively trading a - 6+2*n shift for one or two 4 cycle masks. Suggested by Jean-Charles - Meyrignac. +
  • S390: BSWAP_LIMB_FETCH looks like it could be done with + lrvg, as per glibc sysdeps/s390/s390-64/bits/byteswap.h. + This is only for 64-bit mode or something is it, since 32-bit mode has + other code? Also, is it worth using for BSWAP_LIMB too, or + would that mean a store and re-fetch? Presumably that's what comes out + in glibc.
  • Improve count_leading_zeros for 64-bit machines:
     	   if ((x >> 32) == 0) { x <<= 32; cnt += 32; }
    @@ -519,10 +489,11 @@ MA 02111-1307, USA.
     
  • IRIX 6 MIPSpro compiler has an __inline which could perhaps be used in __GMP_EXTERN_INLINE. What would be the right way to identify suitable versions of that compiler? -
  • VAX D and G format double floats are straightforward and - could perhaps be handled directly in __gmp_extract_double - and maybe in mpz_get_d, rather than falling back on the - generic code. (Both formats are detected by configure.) +
  • IRIX cc is rumoured to have an _int_mult_upper + (in <intrinsics.h> like Cray), but it didn't seem to + exist on some IRIX 6.5 systems tried. If it does actually exist + somewhere it would very likely be an improvement over a function call to + umul.asm.
  • mpn_get_str final divisions by the base with udiv_qrnd_unnorm could use some sort of multiply-by-inverse on suitable machines. This ends up happening for decimal by presenting @@ -533,14 +504,17 @@ MA 02111-1307, USA. particular helping RISCs that don't do store-to-load forwarding. Clearly this is only possible if the ABI returns a structure of two mp_limb_ts in registers. +
    + On PowerPC, structures are returned in memory on AIX and Darwin. In SVR4 + they're returned in registers, except that draft SVR4 had said memory, so + it'd be prudent to check which is done. We can jam the compiler into the + right mode if we know how, since all this is purely internal to libgmp. + (gcc has an option, though of course gcc doesn't matter since we use + inline asm there.)

New Functionality

    -
  • Add in-memory versions of mp?_out_raw and - mp?_inp_raw. -
  • mpz_get_nth_ui. Return the nth word (not necessarily the - nth limb).
  • Maybe add mpz_crr (Chinese Remainder Reconstruction).
  • Let `0b' and `0B' mean binary input everywhere.
  • mpz_init and mpq_init could do lazy allocation. @@ -571,25 +545,14 @@ MA 02111-1307, USA.
  • Add mpf_out_raw and mpf_inp_raw. Make sure format is portable between 32-bit and 64-bit machines, and between - little-endian and big-endian machines. + little-endian and big-endian machines. A format which MPFR can use too + would be good.
  • mpn_and_n ... mpn_copyd: Perhaps make the mpn logops and copys available in gmp.h, either as library functions or inlines, with the availability of library functions instantiated in the generated gmp.h at build time.
  • mpz_set_str etc variants taking string lengths rather than null-terminators. -
  • Consider changing the thresholds to apply the simpler algorithm when - "<=" rather than "<", so a threshold can - be set to MP_SIZE_T_MAX to get only the simpler code (the - compiler will know size <= MP_SIZE_T_MAX is always true). - Alternately it looks like the ABOVE_THRESHOLD and - BELOW_THRESHOLD macros can do this adequately, and also pick - up cases where a threshold of zero should mean only the second algorithm. -
  • mpz_nthprime. -
  • Perhaps mpz_init2, initializing and making initial room for - N bits. The actual size would be rounded up to a limb, and perhaps an - extra limb added since so many mpz routines need that on - their destination.
  • mpz_andn, mpz_iorn, mpz_nand, mpz_nior, mpz_xnor might be useful additions, if they could share code with the current such functions (which should be @@ -604,20 +567,10 @@ MA 02111-1307, USA.
  • GMP_LONG_LONG_LIMB or some such could become a documented feature of gmp.h, so applications could know whether to printf a limb using %lu or %Lu. -
  • PRIdMP_LIMB and similar defines following C99 - <inttypes.h> might be of use to applications printing limbs. - Perhaps they should be defined only if specifically requested, the way - <inttypes.h> does. But if GMP_LONG_LONG_LIMB or - whatever is added then perhaps this can easily enough be left to - applications. -
  • mpf_get_ld and mpf_set_ld converting - mpf_t to and from long double. Other - long double routines would be desirable too, but these would - be a start. Often long double is the same as - double, which is easy but pretty pointless. Should - recognise the Intel 80-bit format on i386, and IEEE 128-bit quad on - sparc, hppa and power. Might like an ABI sub-option or something when - it's a compiler option for 64-bit or 128-bit long double. +
  • GMP_PRIdMP_LIMB and similar defines following C99 + <inttypes.h> might be of use to applications printing limbs. But + if GMP_LONG_LONG_LIMB or whatever is added then perhaps this + can easily enough be left to applications.
  • gmp_printf could accept %b for binary output. It'd be nice if it worked for plain int etc too, not just mpz_t etc. @@ -625,9 +578,6 @@ MA 02111-1307, USA. for both integer and float conversions. A base either in the format string or as a parameter with * should be allowed. Maybe &13b (b for base) or something like that. -
  • gmp_printf could perhaps have a type code for an - mp_limb_t. That would save an application from having to - worry whether it's a long or a long long.
  • gmp_printf could perhaps accept mpq_t for float conversions, eg. "%.4Qf". This would be merely for convenience, but still might be useful. Rounding would be the same as @@ -636,15 +586,12 @@ MA 02111-1307, USA. mpq_get_str_point or some such might be more use. Suggested by Pedro Gimeno.
  • gmp_printf could usefully accept a flag to control the - rounding of float conversions. The wouldn't do much for + rounding of float conversions. This wouldn't do much for mpf_t, but would be good if mpfr_t was supported in the future, or perhaps for mpq_t. Something like &*r (r for rounding, and mpfr style GMP_RND parameter). -
  • mpz_combit to toggle a bit would be a good companion for - mpz_setbit and mpz_clrbit. Suggested by Niels - Möller (and has done some work towards it). -
  • mpz_scan0_reverse or mpz_scan0low or some such +
  • mpz_rscan0 or mpz_revscan0 or some such searching towards the low end of an integer might match mpz_scan0 nicely. Likewise for scan1. Suggested by Roberto Bagnara. @@ -653,17 +600,25 @@ MA 02111-1307, USA. indicating whether it's a proper or non-proper subset would be good and wouldn't cost anything in the implementation. Suggested by Roberto Bagnara. -
  • gmp_randinit_r and maybe gmp_randstate_set to - init-and-copy or to just copy a gmp_randstate_t. Suggested - by Pedro Gimeno.
  • mpf_get_ld, mpf_set_ld: Conversions between mpf_t and long double, suggested by Dan - Christensen. There'd be some work to be done by configure - to recognise the format in use. xlc on aix for instance apparently has - an option for either plain double 64-bit or quad 128-bit precision. This - might mean library contents vary with the compiler used to build, which - is undesirable. It might be possible to detect the mode the application - is compiling with, and try to avoid mismatch problems. + Christensen. Other long double routines might be desirable + too, but mpf would be a start. +
    + long double is an ANSI-ism, so everything involving it would + need to be suppressed on a K&R compiler. +
    + There'd be some work to be done by configure to recognise + the format in use, MPFR has a start on this. Often long + double is the same as double, which is easy but + pretty pointless. A single float format detector macro could look at + double then long double +
    + Sometimes there's a compiler option for the size of a long + double, eg. xlc on AIX can use either 64-bit or 128-bit. It's + probably simplest to regard this as a compiler compatibility issue, and + leave it to users or sysadmins to ensure application and library code is + built the same.
  • mpz_sqrt_if_perfect_square: When mpz_perfect_square_p does its tests it calculates a square root and then discards it. For some applications it might be useful to @@ -672,14 +627,15 @@ MA 02111-1307, USA. mpz_get_sll, mpz_get_sll: Conversions for long long. These would aid interoperability, though a mixture of GMP and long long would probably not be too - common. Disadvantages of using long long in libgmp.a would - be + common. Since long long is not always available (it's in + C99 and GCC though), disadvantages of using long long in + libgmp.a would be
    • Library contents vary according to the build compiler.
    • gmp.h would need an ugly #ifdef block to decide if the application compiler could take the long long prototypes. -
    • Some sort of LIBGMP_HAS_LONGLONG would be wanted to +
    • Some sort of LIBGMP_HAS_LONGLONG might be wanted to indicate whether the functions are available. (Applications using autoconf could probe the library too.)
    @@ -700,7 +656,16 @@ MA 02111-1307, USA. uniformity with inferior ones. Plain use of long long is probably the lesser evil, if only - because it makes best use of gcc. + because it makes best use of gcc. In fact perhaps it would suffice to + guarantee long long conversions only when using GCC for both + application and library. That would cover free software, and we can + worry about selected vendor compilers later. +
    + In C++ the situation is probably clearer, we demand fairly recent C++ so + long long should be available always. We'd probably prefer + to have the C and C++ the same in respect of long long + support, but it would be possible to have it unconditionally in gmpxx.h, + by some means or another.
  • mpz_strtoz parsing the same as strtol. Suggested by Alexander Kruppa. @@ -709,20 +674,22 @@ MA 02111-1307, USA.

    Configuration

      -
    • Floating-point format: GMP_C_DOUBLE_FORMAT seems to work - well. Get rid of the #ifdef mess in gmp-impl.h and use the - results of the test instead. -
    • a29k: umul.s and udiv.s exist but don't get used. +
    • Alpha ev7, ev79: Add code to config.guess to detect these. Believe ev7 + will be "3-1307" in the current switch, but need to verify that. (On + OSF, current configfsf.guess identifies ev7 using psrinfo, we need to do + it ourselves for other systems.) +
    • Alpha OSF: Libtool (version 1.5) doesn't seem to recognise this system is + "pic always" and ends up running gcc twice with the same options. This + is wasteful, but harmless. Perhaps a newer libtool will be better. +
    • Alpha OSF: Libtool (version 1.5) ends up with some ${wl} + bits coming through to the commands run. Seems to work anyway, but + hopefully a newer version will have this fixed.
    • ARM: umul_ppmm in longlong.h always uses umull, but is that available only for M series chips or some such? Perhaps it should be configured in some way.
    • HPPA: config.guess should recognize 7000, 7100, 7200, and 8x00. -
    • HPPA 2.0w: gcc is rumoured to support 2.0w as of version 3, though - perhaps just as a build-time choice. In any case, figure out how to - identify a suitable gcc or put it in the right mode, for the GMP compiler - choices. -
    • IA64: Latest libtool has some nonsense to detect ELF-32 or ELF-64 on - ia64-*-hpux*. Does GMP need to know anything about that? +
    • HPPA: gcc 3.2 introduces a -mschedule=7200 etc parameter, + which could be driven by an exact hppa cpu type.
    • Mips: config.guess should say mipsr3000, mipsr4000, mipsr10000, etc. "hinv -c processor" gives lots of information on Irix. Standard config.guess appends "el" to indicate endianness, but @@ -731,43 +698,6 @@ MA 02111-1307, USA. *-*-aix*. It might be more reliable to do some sort of feature test, examining the compiler output perhaps. It might also be nice to merge the aix.m4 files into powerpc-defs.m4. -
    • Sparc: config.guess recognises various exact sparcs, make - use of that information in configure (work on this is in - progress). -
    • Sparc32: floating point or integer udiv should be selected - according to the CPU target. Currently floating point ends up being - used on all sparcs, which is probably not right for generic V7 and V8. -
    • Sparc: The use of -xtarget=native with cc is - incorrect when cross-compiling, the target should be set according to the - configured $host CPU. -
    • m68k: config.guess can detect 68000, 68010, CPU32 and 68020, but relies - on system information for 030, 040 and 060. Can they be identified by - running some code? -
    • m68k: gas 2.11.90.0.1 pads with zero bytes in text segments, which is not - valid code. Probably need .balignw <n>,0x4e7f to get - nops, if ALIGN is going to be used for anything that's - executed across. -
    • Some CPUs have umul and udiv code not being - used. Check all such for bit rot and then put umul and udiv in - $gmp_mpn_functions_optional as "standard optional" objects. -
      In particular Sparc and SparcV8 on non-gcc should benefit from - umul.asm enabled; the generic umul is suspected to be making sqr_basecase - slower than mul_basecase. -
    • HPPA mpn_umul_ppmm and mpn_udiv_qrnnd have a - different parameter order than those functions on other CPUs. It might - avoid confusion to have them under different names, maybe - mpn_umul_ppmm_r or some such. Prototypes then wouldn't - be conditionalized, and the appropriate form could be selected with the - HAVE_NATIVE scheme if/when the code switches to use a - PROLOGUE style. -
    • DItype: The setup in gmp-impl.h for non-GCC could use an - autoconf test to determine whether long long is available. -
    • m88k: Make the assembler code work on non-underscore systems. Conversion - to .asm would be desirable. Ought to be easy, but would want to be - tested. -
    • z8k: The use of a 32-bit limb in mpn/z8000x as opposed to 16-bits in - mpn/z8000 could be an ABI choice. But this chip is obsolete and nothing - is likely to be done unless someone is actively using it.
    • config.m4 is generated only by the configure script, it won't be regenerated by config.status. Creating it as an AC_OUTPUT would work, but it might upset "make" to have things like L$ @@ -775,18 +705,23 @@ MA 02111-1307, USA. AC_CONFIG_COMMANDS would be the alternative. With some careful m4 quoting the changequote calls might not be needed, which might free up the order in which things had to be output. -
    • make distclean: Only the mpn directory links which were - created are removed, but perhaps all possible links should be removed, in - case someone runs configure a second time without a - distclean in between. The only tricky part would be making - sure all possible extra_functions are covered. -
    • MinGW: Apparently a Cygwin version of gcc can be used by passing - -mno-cygwin. For --host=*-*-mingw32* it might - be convenient to automatically use that option, if it works. Needs - someone with a dual cygwin/mingw setup to test.
    • Automake: Latest automake has a CCAS, CCASFLAGS scheme. Though we probably wouldn't be using its assembler support we could try to use those variables in compatible ways. +
    • GMP_LDFLAGS could probably be done with plain + LDFLAGS already used by automake for all linking. But with + a bit of luck the next libtool will pass pretty much all + CFLAGS through to the compiler when linking, making + GMP_LDFLAGS unnecessary. +
    • mpn/Makeasm.am uses -c and -o together in the + .S and .asm rules, but apparently that isn't completely portable (there's + an autoconf AC_PROG_CC_C_O test for it). So far we've not + had problems, but perhaps the rules could be rewritten to use "foo.s" as + the temporary, or to do a suitable "mv" of the result. The only danger + from using foo.s would be if a compile failed and the temporary foo.s + then looked like the primary source. Hopefully if the + SUFFIXES are ordered to have .S and .asm ahead of .s that + wouldn't happen. Might need to check.
    @@ -801,32 +736,9 @@ MA 02111-1307, USA. avoid mpn_mul calls. Perhaps the same for two limbs.
  • Inline the lc code, to avoid a function call and TMP_ALLOC for every chunk. -
  • The special case for seedn==0 will be very rarely used, - and on that basis seems unnecessary.
  • Perhaps the 2exp and general LC cases should be split, for clarity (if the general case is retained). -
  • gmp_randinit_mers for a Mersenne Twister generator. It's - likely to be more random and about the same speed as Knuth's 55-element - Fibonacci generator, and can probably become the default. Pedro Gimeno - has started on this. -
  • gmp_randinit_lc: Finish or remove. Doing a division for - every every step won't be very fast, so check whether the usefulness of - this algorithm can be justified. (Consensus is that it's not useful and - can be removed.) -
  • Blum-Blum-Shub: Finish or remove. A separate - gmp_randinit_bbs would be wanted, not the currently - commented out case in gmp_randinit. -
  • _gmp_rand could be done as a function pointer within - gmp_randstate_t (or rather in the _mp_algdata - part), instead of switching on a gmp_randalg_t. Likewise - gmp_randclear, and perhaps gmp_randseed if it - became algorithm-specific. This would be more modular, and would ensure - only code for the desired algorithms is dragged into the link. -
  • mpz_urandomm should do something for n<=0, but what? -
  • mpz_urandomm implementation looks like it could be improved. - Perhaps it's enough to calculate nbits as ceil(log2(n)) and - call _gmp_rand until a value <n is obtained.
  • gmp_randstate_t used for parameters perhaps should become gmp_randstate_ptr the same as other types.
  • Some of the empirical randomness tests could be included in a "make @@ -834,18 +746,48 @@ MA 02111-1307, USA. +

    C++

    +
      +
    • mpz_class(string), etc: Use the C++ global locale to + identify whitespace. +
      + mpf_class(string): Use the C++ global locale decimal point, + rather than the C one. +
      + Consider making these variant mpz_set_str etc forms + available for mpz_t too, not just mpz_class + etc. +
    • mpq_class operator+=: Don't emit an unnecssary + mpq_set(q,q) before mpz_addmul etc. +
    • Put various bits of gmpxx.h into libgmpxx, to avoid excessive inlining. + Candidates for this would be, +
        +
      • mpz_class(const char *), etc: since they're normally + not fast anyway, and we can hide the exception throw. +
      • mpz_class(string), etc: to hide the cstr + needed to get to the C conversion function. +
      • mpz_class string, char* etc constructors: likewise to + hide the throws and conversions. +
      • mpz_class::get_str, etc: to hide the char* + to string conversion and free. Perhaps + mpz_get_str can write directly into a + string, to avoid copying. +
        + Consider making such string returning variants + available for use with plain mpz_t etc too. +
      + The mpfr routines are not candidates, since we don't want MPFR support in + libgmpxx yet. +
    +

    Miscellaneous

      -
    • Make mpz_div and mpz_divmod use rounding - analogous to mpz_mod. Document, and list as an - incompatibility.
    • mpz_gcdext and mpn_gcdext ought to document what range of values the generated cofactors can take, and preferably ensure the definition uniquely specifies the cofactors for given inputs. A basic extended Euclidean algorithm or multi-step variant leads to |x|<|b| and |y|<|a| or something like that, but there's probably two solutions under just those restrictions. -
    • mpz_invert should call mpn_gcdext directly.
    • demos/factorize.c: use mpz_divisible_ui_p rather than mpz_tdiv_qr_ui. (Of course dividing multiple primes at a time would be better still.) @@ -855,18 +797,6 @@ MA 02111-1307, USA. possible some attention could be paid to the order of the tests, so a libgmp routine is only used for tests once it seems to be good. -
    • mpf_set_q is very similar to mpf_div, it'd be - good for the two to share code. Perhaps mpf_set_q should - make some mpf_t aliases for its numerator and denominator - and just call mpf_div. Both would be simplified a good deal - by switching to mpn_tdiv_qr perhaps making them small enough - not to bother with sharing (especially since mpf_set_q - wouldn't need to watch out for overlaps). -
    • PowerPC: The cpu time base registers (per mftb and - mftbu) could be used for the speed and tune programs. Would - need to know its frequency of course. Usually it's 1/4 of bus speed - (eg. 25 MHz) but some chips drive it from an external input. Probably - have to measure to be sure.
    • MUL_FFT_THRESHOLD etc: the FFT thresholds should allow a return to a previous k at certain sizes. This arises basically due to the step effect caused by size multiples effectively used for each k. @@ -895,14 +825,28 @@ MA 02111-1307, USA. Currently we pretend in configure that the dodgy m68k netbsd 1.4.1 getrusage doesn't exist. If a test might take a long time to run then perhaps cache the result in a file somewhere. +
    • tune/time.c could choose the default precision based on the + speed_unittime determined, independent of the method in use. +
    • Cray vector systems: CPU frequency could be determined from + sysconf(_SC_CLK_TCK), since it seems to be clock cycle + based. Is this true for all Cray systems? Would like some documentation + or something to confirm.

    Documentation

      -
    • Document conventions, like that unsigned long int is used for - bit counts/ranges, and that mp_size_t is used for limb counts.
    • mpz_inp_str (etc) doesn't say when it stops reading digits. +
    • mpn_get_str isn't terribly clear about how many digits it + produces. It'd probably be possible to say at most one leading zero, + which is what both it and mpz_get_str currently do. But + want to be careful not to bind ourselves to something that might not suit + another implementation. +
    • va_arg doesn't do the right thing with mpz_t + etc directly, but instead needs a pointer type like MP_INT*. + It'd be good to show how to do this, but we'd either need to document + mpz_ptr and friends, or perhaps fallback on something + slightly nasty with void*.
    @@ -930,10 +874,6 @@ near future, but are at least worth thinking about.
  • mpz_get_si returns 0x80000000 for -0x100000000, whereas it's sort of supposed to return the low 31 (or 63) bits. But this is undocumented, and perhaps not too important. -
  • mpz_*_ui division routines currently return abs(a%b). - Perhaps make them return the real remainder instead? Return type would - be signed long int. But this would be an incompatible - change, so it might have to be under newly named functions.
  • mpz_init_set* and mpz_realloc could allocate say an extra 16 limbs over what's needed, so as to reduce the chance of having to do a reallocate if the mpz_t grows a bit more. @@ -962,33 +902,29 @@ near future, but are at least worth thinking about. mpn_add_1 and one from mpn_sub_1. If those two routines were opened up a bit maybe that code could be shared. When a copy needs to be done there's no carry to append for the add, and if the - copy is non-empty no high zero for the sub.
    An alternative would be - to do a copy at the start and then an in-place add or sub. Obviously - that duplicates the fetches and stores for carry propagation, but that's - normally only one or two limbs. The same applies to mpz_add - when one operand is longer than the other, and to mpz_com - since it's just -(x+1). -
  • restrict'ed pointers: Does the C99 definition of restrict - (one writer many readers, or whatever it is) suit the GMP style "same or - separate" function parameters? If so, judicious use might improve the - code generated a bit. Do any compilers have their own flavour of - restrict as "completely unaliased", and is that still usable? -
  • 68000: A 16-bit limb might suit 68000 better than 32-bits, since the - native multiply is only 16x16. Could have this as an ABI - option, selecting _SHORT_LIMB in gmp.h. Naturally a new set - of asm subroutines would be necessary. Would need new - mpz_set_ui etc since the current code assumes limb>=long, - but 2-limb operand forms would find a use for long long on - other processors too. -
  • Nx1 remainders can be taken at multiplier throughput speed by - pre-calculating an array "p[i] = 2^(i*BITS_PER_MP_LIMB) mod - m", then for the input limbs x calculating an inner product "sum - p[i]*x[i]", and a final 3x1 limb remainder mod m. If those powers take - roughly N divide steps to calculate then there'd be an advantage any time - the same m is used three or more times. Suggested by Victor Shoup in - connection with chinese-remainder style decompositions, but perhaps with - other uses. + copy is non-empty no high zero for the sub. + + +

    Old and Obsolete Stuff

    + +The following tasks apply to chips or systems that are old and/or obsolete. +It's unlikely anything will be done about them unless anyone is actively using +them. + +
      +
    • Sparc32: The integer based udiv_nfp.asm used to be selected by + configure --nfp but that option is gone now that autoconf is + used. The file could go somewhere suitable in the mpn search if any + chips might benefit from it, though it's possible we don't currently + differentiate enough exact cpu types to do this properly. +
    • VAX D and G format double floats are straightforward and + could perhaps be handled directly in __gmp_extract_double + and maybe in mpn_get_d, rather than falling back on the + generic code. (Both formats are detected by configure.) +
    + +
    diff --git a/src/gmp/fdl.texi b/src/gmp/fdl.texi index 5f11d0ffd..4aa8ce80b 100644 --- a/src/gmp/fdl.texi +++ b/src/gmp/fdl.texi @@ -1,12 +1,15 @@ @c GMP tweak: Have this in gmp.texi to help texinfo-mode +@c And we prefer @appendix rather than @appendixsec +@c (change to @appendixsubsec below too) +@c @c @node GNU Free Documentation License @c @appendixsec GNU Free Documentation License @cindex FDL, GNU Free Documentation License -@center Version 1.1, March 2000 +@center Version 1.2, November 2002 @display -Copyright @copyright{} 2000 Free Software Foundation, Inc. +Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA Everyone is permitted to copy and distribute verbatim copies @@ -18,12 +21,12 @@ of this license document, but changing it is not allowed. PREAMBLE The purpose of this License is to make a manual, textbook, or other -written document @dfn{free} in the sense of freedom: to assure everyone -the effective freedom to copy and redistribute it, with or without -modifying it, either commercially or noncommercially. Secondarily, -this License preserves for the author and publisher a way to get -credit for their work, while not being considered responsible for -modifications made by others. +functional and useful document @dfn{free} in the sense of freedom: to +assure everyone the effective freedom to copy and redistribute it, +with or without modifying it, either commercially or noncommercially. +Secondarily, this License preserves for the author and publisher a way +to get credit for their work, while not being considered responsible +for modifications made by others. This License is a kind of ``copyleft'', which means that derivative works of the document must themselves be free in the same sense. It @@ -41,57 +44,69 @@ principally for works whose purpose is instruction or reference. @item APPLICABILITY AND DEFINITIONS -This License applies to any manual or other work that contains a -notice placed by the copyright holder saying it can be distributed -under the terms of this License. The ``Document'', below, refers to any -such manual or work. Any member of the public is a licensee, and is -addressed as ``you''. +This License applies to any manual or other work, in any medium, that +contains a notice placed by the copyright holder saying it can be +distributed under the terms of this License. Such a notice grants a +world-wide, royalty-free license, unlimited in duration, to use that +work under the conditions stated herein. The ``Document'', below, +refers to any such manual or work. Any member of the public is a +licensee, and is addressed as ``you''. You accept the license if you +copy, modify or distribute the work in a way requiring permission +under copyright law. A ``Modified Version'' of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language. -A ``Secondary Section'' is a named appendix or a front-matter section of -the Document that deals exclusively with the relationship of the -publishers or authors of the Document to the Document's overall subject -(or to related matters) and contains nothing that could fall directly -within that overall subject. (For example, if the Document is in part a -textbook of mathematics, a Secondary Section may not explain any -mathematics.) The relationship could be a matter of historical +A ``Secondary Section'' is a named appendix or a front-matter section +of the Document that deals exclusively with the relationship of the +publishers or authors of the Document to the Document's overall +subject (or to related matters) and contains nothing that could fall +directly within that overall subject. (Thus, if the Document is in +part a textbook of mathematics, a Secondary Section may not explain +any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them. The ``Invariant Sections'' are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice -that says that the Document is released under this License. +that says that the Document is released under this License. If a +section does not fit the above definition of Secondary then it is not +allowed to be designated as Invariant. The Document may contain zero +Invariant Sections. If the Document does not identify any Invariant +Sections then there are none. The ``Cover Texts'' are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that -the Document is released under this License. +the Document is released under this License. A Front-Cover Text may +be at most 5 words, and a Back-Cover Text may be at most 25 words. A ``Transparent'' copy of the Document means a machine-readable copy, represented in a format whose specification is available to the -general public, whose contents can be viewed and edited directly and +general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file -format whose markup has been designed to thwart or discourage -subsequent modification by readers is not Transparent. A copy that is -not ``Transparent'' is called ``Opaque''. +format whose markup, or absence of markup, has been arranged to thwart +or discourage subsequent modification by readers is not Transparent. +An image format is not Transparent if used for any substantial amount +of text. A copy that is not ``Transparent'' is called ``Opaque''. Examples of suitable formats for Transparent copies include plain -@sc{ascii} without markup, Texinfo input format, La@TeX{} input format, -@acronym{SGML} or @acronym{XML} using a publicly available -@acronym{DTD}, and standard-conforming simple @acronym{HTML} designed -for human modification. Opaque formats include PostScript, -@acronym{PDF}, proprietary formats that can be read and edited only by -proprietary word processors, @acronym{SGML} or @acronym{XML} for which -the @acronym{DTD} and/or processing tools are not generally available, -and the machine-generated @acronym{HTML} produced by some word -processors for output purposes only. +@sc{ascii} without markup, Texinfo input format, La@TeX{} input +format, @acronym{SGML} or @acronym{XML} using a publicly available +@acronym{DTD}, and standard-conforming simple @acronym{HTML}, +PostScript or @acronym{PDF} designed for human modification. Examples +of transparent image formats include @acronym{PNG}, @acronym{XCF} and +@acronym{JPG}. Opaque formats include proprietary formats that can be +read and edited only by proprietary word processors, @acronym{SGML} or +@acronym{XML} for which the @acronym{DTD} and/or processing tools are +not generally available, and the machine-generated @acronym{HTML}, +PostScript or @acronym{PDF} produced by some word processors for +output purposes only. The ``Title Page'' means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material @@ -100,6 +115,21 @@ formats which do not have any title page as such, ``Title Page'' means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text. +A section ``Entitled XYZ'' means a named subunit of the Document whose +title either is precisely XYZ or contains XYZ in parentheses following +text that translates XYZ in another language. (Here XYZ stands for a +specific section name mentioned below, such as ``Acknowledgements'', +``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title'' +of such a section when you modify the Document means that it remains a +section ``Entitled XYZ'' according to this definition. + +The Document may include Warranty Disclaimers next to the notice which +states that this License applies to the Document. These Warranty +Disclaimers are considered to be included by reference in this +License, but only as regards disclaiming warranties: any other +implication that these Warranty Disclaimers may have is void and has +no effect on the meaning of this License. + @item VERBATIM COPYING @@ -119,9 +149,10 @@ you may publicly display copies. @item COPYING IN QUANTITY -If you publish printed copies of the Document numbering more than 100, -and the Document's license notice requires Cover Texts, you must enclose -the copies in covers that carry, clearly and legibly, all these Cover +If you publish printed copies (or copies in media that commonly have +printed covers) of the Document, numbering more than 100, and the +Document's license notice requires Cover Texts, you must enclose the +copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present @@ -139,16 +170,15 @@ pages. If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy -a publicly-accessible computer-network location containing a complete -Transparent copy of the Document, free of added material, which the -general network-using public has access to download anonymously at no -charge using public-standard network protocols. If you use the latter -option, you must take reasonably prudent steps, when you begin -distribution of Opaque copies in quantity, to ensure that this -Transparent copy will remain thus accessible at the stated location -until at least one year after the last time you distribute an Opaque -copy (directly or through your agents or retailers) of that edition to -the public. +a computer-network location from which the general network-using +public has access to download using public-standard network protocols +a complete Transparent copy of the Document, free of added material. +If you use the latter option, you must take reasonably prudent steps, +when you begin distribution of Opaque copies in quantity, to ensure +that this Transparent copy will remain thus accessible at the stated +location until at least one year after the last time you distribute an +Opaque copy (directly or through your agents or retailers) of that +edition to the public. It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give @@ -176,7 +206,8 @@ if the original publisher of that version gives permission. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the -Document (all of its principal authors, if it has less than five). +Document (all of its principal authors, if it has fewer than five), +unless they release you from this requirement. @item State on the Title page the name of the publisher of the @@ -202,10 +233,10 @@ and required Cover Texts given in the Document's license notice. Include an unaltered copy of this License. @item -Preserve the section entitled ``History'', and its title, and add to -it an item stating at least the title, year, new authors, and +Preserve the section Entitled ``History'', Preserve its Title, and add +to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If -there is no section entitled ``History'' in the Document, create one +there is no section Entitled ``History'' in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence. @@ -220,10 +251,10 @@ least four years before the Document itself, or if the original publisher of the version it refers to gives permission. @item -In any section entitled ``Acknowledgments'' or ``Dedications'', -preserve the section's title, and preserve in the section all the -substance and tone of each of the contributor acknowledgments -and/or dedications given therein. +For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve +the Title of the section, and preserve in the section all the +substance and tone of each of the contributor acknowledgements and/or +dedications given therein. @item Preserve all the Invariant Sections of the Document, @@ -231,12 +262,15 @@ unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles. @item -Delete any section entitled ``Endorsements''. Such a section +Delete any section Entitled ``Endorsements''. Such a section may not be included in the Modified Version. @item -Do not retitle any existing section as ``Endorsements'' -or to conflict in title with any Invariant Section. +Do not retitle any existing section to be Entitled ``Endorsements'' or +to conflict in title with any Invariant Section. + +@item +Preserve any Warranty Disclaimers. @end enumerate If the Modified Version includes new front-matter sections or @@ -246,7 +280,7 @@ of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles. -You may add a section entitled ``Endorsements'', provided it contains +You may add a section Entitled ``Endorsements'', provided it contains nothing but endorsements of your Modified Version by various parties---for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a @@ -274,7 +308,7 @@ License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its -license notice. +license notice, and that you preserve all their Warranty Disclaimers. The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single @@ -285,11 +319,11 @@ author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work. -In the combination, you must combine any sections entitled ``History'' -in the various original documents, forming one section entitled -``History''; likewise combine any sections entitled ``Acknowledgments'', -and any sections entitled ``Dedications''. You must delete all sections -entitled ``Endorsements.'' +In the combination, you must combine any sections Entitled ``History'' +in the various original documents, forming one section Entitled +``History''; likewise combine any sections Entitled ``Acknowledgements'', +and any sections Entitled ``Dedications''. You must delete all +sections Entitled ``Endorsements.'' @item COLLECTIONS OF DOCUMENTS @@ -310,18 +344,20 @@ AGGREGATION WITH INDEPENDENT WORKS A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or -distribution medium, does not as a whole count as a Modified Version -of the Document, provided no compilation copyright is claimed for the -compilation. Such a compilation is called an ``aggregate'', and this -License does not apply to the other self-contained works thus compiled -with the Document, on account of their being thus compiled, if they -are not themselves derivative works of the Document. +distribution medium, is called an ``aggregate'' if the copyright +resulting from the compilation is not used to limit the legal rights +of the compilation's users beyond what the individual works permit. +When the Document is included in an aggregate, this License does not +apply to the other works in the aggregate which are not themselves +derivative works of the Document. If the Cover Text requirement of section 3 is applicable to these -copies of the Document, then if the Document is less than one quarter -of the entire aggregate, the Document's Cover Texts may be placed on -covers that surround only the Document within the aggregate. -Otherwise they must appear on covers around the whole aggregate. +copies of the Document, then if the Document is less than one half of +the entire aggregate, the Document's Cover Texts may be placed on +covers that bracket the Document within the aggregate, or the +electronic equivalent of covers if the Document is in electronic form. +Otherwise they must appear on printed covers that bracket the whole +aggregate. @item TRANSLATION @@ -332,10 +368,17 @@ Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a -translation of this License provided that you also include the -original English version of this License. In case of a disagreement -between the translation and the original English version of this -License, the original English version will prevail. +translation of this License, and all the license notices in the +Document, and any Warranty Disclaimers, provided that you also include +the original English version of this License and the original versions +of those notices and disclaimers. In case of a disagreement between +the translation and the original version of this License or a notice +or disclaimer, the original version will prevail. + +If a section in the Document is Entitled ``Acknowledgements'', +``Dedications'', or ``History'', the requirement (section 4) to Preserve +its Title (section 1) will typically require changing the actual +title. @item TERMINATION @@ -368,8 +411,9 @@ as a draft) by the Free Software Foundation. @end enumerate @page -@c GMP tweak: Use @appendixsec -@c @appendixsubsec ADDENDUM: How to use this License for your documents +@c GMP tweak: changed sectioning to @appendix/@appendixsec rather than +@c @appendix/@appendixsec +@c @appendixsubsec ADDENDUM: How to use this License for your documents @appendixsec ADDENDUM: How to use this License for your documents To use this License in a document you have written, include a copy of @@ -380,19 +424,28 @@ license notices just after the title page: @group Copyright (C) @var{year} @var{your name}. Permission is granted to copy, distribute and/or modify this document - under the terms of the GNU Free Documentation License, Version 1.1 + under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; - with the Invariant Sections being @var{list their titles}, with the - Front-Cover Texts being @var{list}, and with the Back-Cover Texts being @var{list}. - A copy of the license is included in the section entitled ``GNU + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover + Texts. A copy of the license is included in the section entitled ``GNU Free Documentation License''. @end group @end smallexample -If you have no Invariant Sections, write ``with no Invariant Sections'' -instead of saying which ones are invariant. If you have no -Front-Cover Texts, write ``no Front-Cover Texts'' instead of -``Front-Cover Texts being @var{list}''; likewise for Back-Cover Texts. +If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, +replace the ``with...Texts.'' line with this: + +@smallexample +@group + with the Invariant Sections being @var{list their titles}, with + the Front-Cover Texts being @var{list}, and with the Back-Cover Texts + being @var{list}. +@end group +@end smallexample + +If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of diff --git a/src/gmp/gmp-h.in b/src/gmp/gmp-h.in index 0edc5fcfb..ca36b99f2 100644 --- a/src/gmp/gmp-h.in +++ b/src/gmp/gmp-h.in @@ -1,7 +1,7 @@ /* Definitions for GNU multiple precision functions. -*- mode: c -*- -Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002 -Free Software Foundation, Inc. +Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003, +2004 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -28,7 +28,7 @@ MA 02111-1307, USA. */ /* Instantiated by configure. */ -#if ! __GMP_WITHIN_CONFIGURE +#if ! defined (__GMP_WITHIN_CONFIGURE) #define __GMP_BITS_PER_MP_LIMB @BITS_PER_MP_LIMB@ #define __GMP_HAVE_HOST_CPU_FAMILY_power @HAVE_HOST_CPU_FAMILY_power@ #define __GMP_HAVE_HOST_CPU_FAMILY_powerpc @HAVE_HOST_CPU_FAMILY_powerpc@ @@ -36,7 +36,7 @@ MA 02111-1307, USA. */ #define GMP_NAIL_BITS @GMP_NAIL_BITS@ #endif #define GMP_NUMB_BITS (GMP_LIMB_BITS - GMP_NAIL_BITS) -#define GMP_NUMB_MASK ((~(mp_limb_t) 0) >> GMP_NAIL_BITS) +#define GMP_NUMB_MASK ((~ __GMP_CAST (mp_limb_t, 0)) >> GMP_NAIL_BITS) #define GMP_NUMB_MAX GMP_NUMB_MASK #define GMP_NAIL_MASK (~ GMP_NUMB_MASK) @@ -56,7 +56,7 @@ MA 02111-1307, USA. */ #undef __need_size_t /* Instantiated by configure. */ -#if ! __GMP_WITHIN_CONFIGURE +#if ! defined (__GMP_WITHIN_CONFIGURE) @DEFN_LONG_LONG_LIMB@ #define __GMP_LIBGMP_DLL @LIBGMP_DLL@ #endif @@ -164,7 +164,7 @@ MA 02111-1307, USA. */ #endif -#ifdef _SHORT_LIMB +#ifdef __GMP_SHORT_LIMB typedef unsigned int mp_limb_t; typedef int mp_limb_signed_t; #else @@ -305,7 +305,8 @@ typedef __mpq_struct *mpq_ptr; || defined (_STDIO_INCLUDED) /* HPUX */ \ || defined (__dj_include_stdio_h_) /* DJGPP */ \ || defined (_FILE_DEFINED) /* Microsoft */ \ - || defined (__STDIO__) /* Apple MPW MrC */ + || defined (__STDIO__) /* Apple MPW MrC */ \ + || defined (_MSL_STDIO_H) /* Metrowerks */ #define _GMP_H_HAVE_FILE 1 #endif @@ -350,6 +351,20 @@ typedef __mpq_struct *mpq_ptr; #endif +/* __GMP_CAST allows us to use static_cast in C++, so our macros are clean + to "g++ -Wold-style-cast". + + Casts in "extern inline" code within an extern "C" block don't induce + these warnings, so __GMP_CAST only needs to be used on documented + macros. */ + +#ifdef __cplusplus +#define __GMP_CAST(type, expr) (static_cast (expr)) +#else +#define __GMP_CAST(type, expr) ((type) (expr)) +#endif + + /* An empty "throw ()" means the function doesn't throw any C++ exceptions, this can save some stack frame info in applications. @@ -393,10 +408,12 @@ typedef __mpq_struct *mpq_ptr; "extern" is apparently ignored, so foo is inlined if possible but also emitted as a global, which causes multiple definition errors when building a shared libgmp. */ +#ifdef __SCO_VERSION__ #if __SCO_VERSION__ > 400000000 && __STDC__ != 1 \ && ! defined (__GMP_EXTERN_INLINE) #define __GMP_EXTERN_INLINE static inline #endif +#endif /* C++ always has "inline" and since it's a normal feature the linker should discard duplicate non-inlined copies, or if it doesn't then that's a @@ -503,17 +520,17 @@ __GMP_DECLSPEC void gmp_randclear __GMP_PROTO ((gmp_randstate_t)); __GMP_DECLSPEC int gmp_asprintf __GMP_PROTO ((char **, const char *, ...)); #define gmp_fprintf __gmp_fprintf -#if _GMP_H_HAVE_FILE +#ifdef _GMP_H_HAVE_FILE __GMP_DECLSPEC int gmp_fprintf __GMP_PROTO ((FILE *, const char *, ...)); #endif #define gmp_obstack_printf __gmp_obstack_printf -#if _GMP_H_HAVE_OBSTACK +#if defined (_GMP_H_HAVE_OBSTACK) __GMP_DECLSPEC int gmp_obstack_printf __GMP_PROTO ((struct obstack *, const char *, ...)); #endif #define gmp_obstack_vprintf __gmp_obstack_vprintf -#if _GMP_H_HAVE_OBSTACK && _GMP_H_HAVE_VA_LIST +#if defined (_GMP_H_HAVE_OBSTACK) && defined (_GMP_H_HAVE_VA_LIST) __GMP_DECLSPEC int gmp_obstack_vprintf __GMP_PROTO ((struct obstack *, const char *, va_list)); #endif @@ -527,27 +544,27 @@ __GMP_DECLSPEC int gmp_snprintf __GMP_PROTO ((char *, size_t, const char *, ...) __GMP_DECLSPEC int gmp_sprintf __GMP_PROTO ((char *, const char *, ...)); #define gmp_vasprintf __gmp_vasprintf -#if _GMP_H_HAVE_VA_LIST +#if defined (_GMP_H_HAVE_VA_LIST) __GMP_DECLSPEC int gmp_vasprintf __GMP_PROTO ((char **, const char *, va_list)); #endif #define gmp_vfprintf __gmp_vfprintf -#if _GMP_H_HAVE_FILE && _GMP_H_HAVE_VA_LIST +#if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST) __GMP_DECLSPEC int gmp_vfprintf __GMP_PROTO ((FILE *, const char *, va_list)); #endif #define gmp_vprintf __gmp_vprintf -#if _GMP_H_HAVE_VA_LIST +#if defined (_GMP_H_HAVE_VA_LIST) __GMP_DECLSPEC int gmp_vprintf __GMP_PROTO ((const char *, va_list)); #endif #define gmp_vsnprintf __gmp_vsnprintf -#if _GMP_H_HAVE_VA_LIST +#if defined (_GMP_H_HAVE_VA_LIST) __GMP_DECLSPEC int gmp_vsnprintf __GMP_PROTO ((char *, size_t, const char *, va_list)); #endif #define gmp_vsprintf __gmp_vsprintf -#if _GMP_H_HAVE_VA_LIST +#if defined (_GMP_H_HAVE_VA_LIST) __GMP_DECLSPEC int gmp_vsprintf __GMP_PROTO ((char *, const char *, va_list)); #endif @@ -555,7 +572,7 @@ __GMP_DECLSPEC int gmp_vsprintf __GMP_PROTO ((char *, const char *, va_list)); /**************** Formatted input routines. ****************/ #define gmp_fscanf __gmp_fscanf -#if _GMP_H_HAVE_FILE +#ifdef _GMP_H_HAVE_FILE __GMP_DECLSPEC int gmp_fscanf __GMP_PROTO ((FILE *, const char *, ...)); #endif @@ -566,17 +583,17 @@ __GMP_DECLSPEC int gmp_scanf __GMP_PROTO ((const char *, ...)); __GMP_DECLSPEC int gmp_sscanf __GMP_PROTO ((const char *, const char *, ...)); #define gmp_vfscanf __gmp_vfscanf -#if _GMP_H_HAVE_FILE && _GMP_H_HAVE_VA_LIST +#if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST) __GMP_DECLSPEC int gmp_vfscanf __GMP_PROTO ((FILE *, const char *, va_list)); #endif #define gmp_vscanf __gmp_vscanf -#if _GMP_H_HAVE_VA_LIST +#if defined (_GMP_H_HAVE_VA_LIST) __GMP_DECLSPEC int gmp_vscanf __GMP_PROTO ((const char *, va_list)); #endif #define gmp_vsscanf __gmp_vsscanf -#if _GMP_H_HAVE_VA_LIST +#if defined (_GMP_H_HAVE_VA_LIST) __GMP_DECLSPEC int gmp_vsscanf __GMP_PROTO ((const char *, const char *, va_list)); #endif @@ -588,7 +605,7 @@ __GMP_DECLSPEC int gmp_vsscanf __GMP_PROTO ((const char *, const char *, va_list __GMP_DECLSPEC void *_mpz_realloc __GMP_PROTO ((mpz_ptr, mp_size_t)); #define mpz_abs __gmpz_abs -#if __GMP_INLINE_PROTOTYPES || __GMP_FORCE_mpz_abs +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_abs) __GMP_DECLSPEC void mpz_abs __GMP_PROTO ((mpz_ptr, mpz_srcptr)); #endif @@ -749,17 +766,17 @@ __GMP_DECLSPEC int mpz_fits_slong_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __G __GMP_DECLSPEC int mpz_fits_sshort_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #define mpz_fits_uint_p __gmpz_fits_uint_p -#if __GMP_INLINE_PROTOTYPES || __GMP_FORCE_mpz_fits_uint_p +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_uint_p) __GMP_DECLSPEC int mpz_fits_uint_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #endif #define mpz_fits_ulong_p __gmpz_fits_ulong_p -#if __GMP_INLINE_PROTOTYPES || __GMP_FORCE_mpz_fits_ulong_p +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ulong_p) __GMP_DECLSPEC int mpz_fits_ulong_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #endif #define mpz_fits_ushort_p __gmpz_fits_ushort_p -#if __GMP_INLINE_PROTOTYPES || __GMP_FORCE_mpz_fits_ushort_p +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ushort_p) __GMP_DECLSPEC int mpz_fits_ushort_p __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #endif @@ -785,12 +802,12 @@ __GMP_DECLSPEC /* signed */ long int mpz_get_si __GMP_PROTO ((mpz_srcptr)) __GMP __GMP_DECLSPEC char *mpz_get_str __GMP_PROTO ((char *, int, mpz_srcptr)); #define mpz_get_ui __gmpz_get_ui -#if __GMP_INLINE_PROTOTYPES || __GMP_FORCE_mpz_get_ui +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_get_ui) __GMP_DECLSPEC unsigned long int mpz_get_ui __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #endif #define mpz_getlimbn __gmpz_getlimbn -#if __GMP_INLINE_PROTOTYPES || __GMP_FORCE_mpz_getlimbn +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_getlimbn) __GMP_DECLSPEC mp_limb_t mpz_getlimbn __GMP_PROTO ((mpz_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #endif @@ -887,7 +904,7 @@ __GMP_DECLSPEC void mpz_mul_si __GMP_PROTO ((mpz_ptr, mpz_srcptr, long int)); __GMP_DECLSPEC void mpz_mul_ui __GMP_PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); #define mpz_neg __gmpz_neg -#if __GMP_INLINE_PROTOTYPES || __GMP_FORCE_mpz_neg +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_neg) __GMP_DECLSPEC void mpz_neg __GMP_PROTO ((mpz_ptr, mpz_srcptr)); #endif @@ -908,12 +925,12 @@ __GMP_DECLSPEC size_t mpz_out_str __GMP_PROTO ((FILE *, int, mpz_srcptr)); __GMP_DECLSPEC int mpz_perfect_power_p __GMP_PROTO ((mpz_srcptr)) __GMP_ATTRIBUTE_PURE; #define mpz_perfect_square_p __gmpz_perfect_square_p -#if __GMP_INLINE_PROTOTYPES || __GMP_FORCE_mpz_perfect_square_p +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_perfect_square_p) __GMP_DECLSPEC int mpz_perfect_square_p __GMP_PROTO ((mpz_srcptr)) __GMP_ATTRIBUTE_PURE; #endif #define mpz_popcount __gmpz_popcount -#if __GMP_INLINE_PROTOTYPES || __GMP_FORCE_mpz_popcount +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_popcount) __GMP_DECLSPEC unsigned long int mpz_popcount __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #endif @@ -963,7 +980,7 @@ __GMP_DECLSPEC void mpz_set_d __GMP_PROTO ((mpz_ptr, double)); __GMP_DECLSPEC void mpz_set_f __GMP_PROTO ((mpz_ptr, mpf_srcptr)); #define mpz_set_q __gmpz_set_q -#if __GMP_INLINE_PROTOTYPES || __GMP_FORCE_mpz_set_q +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_set_q) __GMP_DECLSPEC void mpz_set_q __GMP_PROTO ((mpz_ptr, mpq_srcptr)); #endif @@ -980,7 +997,7 @@ __GMP_DECLSPEC void mpz_set_ui __GMP_PROTO ((mpz_ptr, unsigned long int)); __GMP_DECLSPEC void mpz_setbit __GMP_PROTO ((mpz_ptr, unsigned long int)); #define mpz_size __gmpz_size -#if __GMP_INLINE_PROTOTYPES || __GMP_FORCE_mpz_size +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_size) __GMP_DECLSPEC size_t mpz_size __GMP_PROTO ((mpz_srcptr)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #endif @@ -1058,7 +1075,7 @@ __GMP_DECLSPEC void mpz_xor __GMP_PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr)); /**************** Rational (i.e. Q) routines. ****************/ #define mpq_abs __gmpq_abs -#if __GMP_INLINE_PROTOTYPES || __GMP_FORCE_mpq_abs +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_abs) __GMP_DECLSPEC void mpq_abs __GMP_PROTO ((mpq_ptr, mpq_srcptr)); #endif @@ -1119,7 +1136,7 @@ __GMP_DECLSPEC void mpq_mul __GMP_PROTO ((mpq_ptr, mpq_srcptr, mpq_srcptr)); __GMP_DECLSPEC void mpq_mul_2exp __GMP_PROTO ((mpq_ptr, mpq_srcptr, unsigned long)); #define mpq_neg __gmpq_neg -#if __GMP_INLINE_PROTOTYPES || __GMP_FORCE_mpq_neg +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_neg) __GMP_DECLSPEC void mpq_neg __GMP_PROTO ((mpq_ptr, mpq_srcptr)); #endif @@ -1368,12 +1385,12 @@ __GMP_DECLSPEC void mpf_urandomb __GMP_PROTO ((mpf_t, gmp_randstate_t, unsigned /* This is ugly, but we need to make user calls reach the prefixed function. */ #define mpn_add __MPN(add) -#if __GMP_INLINE_PROTOTYPES || __GMP_FORCE_mpn_add +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add) __GMP_DECLSPEC mp_limb_t mpn_add __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr,mp_size_t)); #endif #define mpn_add_1 __MPN(add_1) -#if __GMP_INLINE_PROTOTYPES || __GMP_FORCE_mpn_add_1 +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add_1) __GMP_DECLSPEC mp_limb_t mpn_add_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t)) __GMP_NOTHROW; #endif @@ -1387,18 +1404,18 @@ __GMP_DECLSPEC mp_limb_t mpn_addmul_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t __GMP_DECLSPEC mp_limb_t mpn_bdivmod __GMP_PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, unsigned long int)); #define mpn_cmp __MPN(cmp) -#if __GMP_INLINE_PROTOTYPES || __GMP_FORCE_mpn_cmp +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_cmp) __GMP_DECLSPEC int mpn_cmp __GMP_PROTO ((mp_srcptr, mp_srcptr, mp_size_t)) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE; #endif #define mpn_divexact_by3(dst,src,size) \ - mpn_divexact_by3c (dst, src, size, (mp_limb_t) 0) + mpn_divexact_by3c (dst, src, size, __GMP_CAST (mp_limb_t, 0)) #define mpn_divexact_by3c __MPN(divexact_by3c) __GMP_DECLSPEC mp_limb_t mpn_divexact_by3c __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t)); #define mpn_divmod_1(qp,np,nsize,dlimb) \ - mpn_divrem_1 (qp, (mp_size_t) 0, np, nsize, dlimb) + mpn_divrem_1 (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dlimb) #define mpn_divrem __MPN(divrem) __GMP_DECLSPEC mp_limb_t mpn_divrem __GMP_PROTO ((mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr, mp_size_t)); @@ -1474,12 +1491,12 @@ __GMP_DECLSPEC mp_size_t mpn_set_str __GMP_PROTO ((mp_ptr, __gmp_const unsigned __GMP_DECLSPEC mp_size_t mpn_sqrtrem __GMP_PROTO ((mp_ptr, mp_ptr, mp_srcptr, mp_size_t)); #define mpn_sub __MPN(sub) -#if __GMP_INLINE_PROTOTYPES || __GMP_FORCE_mpn_sub +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub) __GMP_DECLSPEC mp_limb_t mpn_sub __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_srcptr,mp_size_t)); #endif #define mpn_sub_1 __MPN(sub_1) -#if __GMP_INLINE_PROTOTYPES || __GMP_FORCE_mpn_sub_1 +#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub_1) __GMP_DECLSPEC mp_limb_t mpn_sub_1 __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_t, mp_limb_t)) __GMP_NOTHROW; #endif @@ -1509,7 +1526,7 @@ __GMP_DECLSPEC void mpn_tdiv_qr __GMP_PROTO ((mp_ptr, mp_ptr, mp_size_t, mp_srcp is wanted for the inline than for the library version, then __GMP_FORCE_foo arranges the inline to be suppressed, eg. mpz_abs. */ -#if defined (__GMP_EXTERN_INLINE) && ! __GMP_FORCE_mpz_abs +#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_abs) __GMP_EXTERN_INLINE void mpz_abs (mpz_ptr __gmp_w, mpz_srcptr __gmp_u) { @@ -1532,8 +1549,8 @@ mpz_abs (mpz_ptr __gmp_w, mpz_srcptr __gmp_u) || (__gmp_n == 2 && __gmp_p[1] <= ((mp_limb_t) maxval >> GMP_NUMB_BITS))); #endif -#if defined (__GMP_EXTERN_INLINE) || __GMP_FORCE_mpz_fits_uint_p -#if ! __GMP_FORCE_mpz_fits_uint_p +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_uint_p) +#if ! defined (__GMP_FORCE_mpz_fits_uint_p) __GMP_EXTERN_INLINE #endif int @@ -1543,8 +1560,8 @@ mpz_fits_uint_p (mpz_srcptr __gmp_z) __GMP_NOTHROW } #endif -#if defined (__GMP_EXTERN_INLINE) || __GMP_FORCE_mpz_fits_ulong_p -#if ! __GMP_FORCE_mpz_fits_ulong_p +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ulong_p) +#if ! defined (__GMP_FORCE_mpz_fits_ulong_p) __GMP_EXTERN_INLINE #endif int @@ -1554,8 +1571,8 @@ mpz_fits_ulong_p (mpz_srcptr __gmp_z) __GMP_NOTHROW } #endif -#if defined (__GMP_EXTERN_INLINE) || __GMP_FORCE_mpz_fits_ushort_p -#if ! __GMP_FORCE_mpz_fits_ushort_p +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ushort_p) +#if ! defined (__GMP_FORCE_mpz_fits_ushort_p) __GMP_EXTERN_INLINE #endif int @@ -1565,8 +1582,8 @@ mpz_fits_ushort_p (mpz_srcptr __gmp_z) __GMP_NOTHROW } #endif -#if defined (__GMP_EXTERN_INLINE) || __GMP_FORCE_mpz_get_ui -#if ! __GMP_FORCE_mpz_get_ui +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_get_ui) +#if ! defined (__GMP_FORCE_mpz_get_ui) __GMP_EXTERN_INLINE #endif unsigned long @@ -1590,8 +1607,8 @@ mpz_get_ui (mpz_srcptr __gmp_z) __GMP_NOTHROW } #endif -#if defined (__GMP_EXTERN_INLINE) || __GMP_FORCE_mpz_getlimbn -#if ! __GMP_FORCE_mpz_getlimbn +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_getlimbn) +#if ! defined (__GMP_FORCE_mpz_getlimbn) __GMP_EXTERN_INLINE #endif mp_limb_t @@ -1604,7 +1621,7 @@ mpz_getlimbn (mpz_srcptr __gmp_z, mp_size_t __gmp_n) __GMP_NOTHROW } #endif -#if defined (__GMP_EXTERN_INLINE) && ! __GMP_FORCE_mpz_neg +#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_neg) __GMP_EXTERN_INLINE void mpz_neg (mpz_ptr __gmp_w, mpz_srcptr __gmp_u) { @@ -1614,8 +1631,8 @@ mpz_neg (mpz_ptr __gmp_w, mpz_srcptr __gmp_u) } #endif -#if defined (__GMP_EXTERN_INLINE) || __GMP_FORCE_mpz_perfect_square_p -#if ! __GMP_FORCE_mpz_perfect_square_p +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_perfect_square_p) +#if ! defined (__GMP_FORCE_mpz_perfect_square_p) __GMP_EXTERN_INLINE #endif int @@ -1629,8 +1646,8 @@ mpz_perfect_square_p (mpz_srcptr __gmp_a) } #endif -#if defined (__GMP_EXTERN_INLINE) || __GMP_FORCE_mpz_popcount -#if ! __GMP_FORCE_mpz_popcount +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_popcount) +#if ! defined (__GMP_FORCE_mpz_popcount) __GMP_EXTERN_INLINE #endif unsigned long @@ -1645,8 +1662,8 @@ mpz_popcount (mpz_srcptr __gmp_u) __GMP_NOTHROW } #endif -#if defined (__GMP_EXTERN_INLINE) || __GMP_FORCE_mpz_set_q -#if ! __GMP_FORCE_mpz_set_q +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_set_q) +#if ! defined (__GMP_FORCE_mpz_set_q) __GMP_EXTERN_INLINE #endif void @@ -1656,8 +1673,8 @@ mpz_set_q (mpz_ptr __gmp_w, mpq_srcptr __gmp_u) } #endif -#if defined (__GMP_EXTERN_INLINE) || __GMP_FORCE_mpz_size -#if ! __GMP_FORCE_mpz_size +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_size) +#if ! defined (__GMP_FORCE_mpz_size) __GMP_EXTERN_INLINE #endif size_t @@ -1670,7 +1687,7 @@ mpz_size (mpz_srcptr __gmp_z) __GMP_NOTHROW /**************** mpq inlines ****************/ -#if defined (__GMP_EXTERN_INLINE) && ! __GMP_FORCE_mpq_abs +#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_abs) __GMP_EXTERN_INLINE void mpq_abs (mpq_ptr __gmp_w, mpq_srcptr __gmp_u) { @@ -1680,7 +1697,7 @@ mpq_abs (mpq_ptr __gmp_w, mpq_srcptr __gmp_u) } #endif -#if defined (__GMP_EXTERN_INLINE) && ! __GMP_FORCE_mpq_neg +#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_neg) __GMP_EXTERN_INLINE void mpq_neg (mpq_ptr __gmp_w, mpq_srcptr __gmp_u) { @@ -1959,8 +1976,8 @@ mpq_neg (mpq_ptr __gmp_w, mpq_srcptr __gmp_u) #endif -#if defined (__GMP_EXTERN_INLINE) || __GMP_FORCE_mpn_add -#if ! __GMP_FORCE_mpn_add +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add) +#if ! defined (__GMP_FORCE_mpn_add) __GMP_EXTERN_INLINE #endif mp_limb_t @@ -1972,8 +1989,8 @@ mpn_add (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr _ } #endif -#if defined (__GMP_EXTERN_INLINE) || __GMP_FORCE_mpn_add_1 -#if ! __GMP_FORCE_mpn_add_1 +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add_1) +#if ! defined (__GMP_FORCE_mpn_add_1) __GMP_EXTERN_INLINE #endif mp_limb_t @@ -1985,8 +2002,8 @@ mpn_add_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_ } #endif -#if defined (__GMP_EXTERN_INLINE) || __GMP_FORCE_mpn_cmp -#if ! __GMP_FORCE_mpn_cmp +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_cmp) +#if ! defined (__GMP_FORCE_mpn_cmp) __GMP_EXTERN_INLINE #endif int @@ -1998,8 +2015,8 @@ mpn_cmp (mp_srcptr __gmp_xp, mp_srcptr __gmp_yp, mp_size_t __gmp_size) __GMP_NOT } #endif -#if defined (__GMP_EXTERN_INLINE) || __GMP_FORCE_mpn_sub -#if ! __GMP_FORCE_mpn_sub +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub) +#if ! defined (__GMP_FORCE_mpn_sub) __GMP_EXTERN_INLINE #endif mp_limb_t @@ -2011,8 +2028,8 @@ mpn_sub (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr _ } #endif -#if defined (__GMP_EXTERN_INLINE) || __GMP_FORCE_mpn_sub_1 -#if ! __GMP_FORCE_mpn_sub_1 +#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub_1) +#if ! defined (__GMP_FORCE_mpn_sub_1) __GMP_EXTERN_INLINE #endif mp_limb_t @@ -2042,14 +2059,14 @@ mpn_sub_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_ #define mpz_cmp_si(Z,SI) \ (__builtin_constant_p (SI) && (SI) == 0 ? mpz_sgn (Z) \ : __builtin_constant_p (SI) && (SI) > 0 \ - ? _mpz_cmp_ui (Z, (unsigned long int) SI) \ + ? _mpz_cmp_ui (Z, __GMP_CAST (unsigned long int, SI)) \ : _mpz_cmp_si (Z,SI)) #define mpq_cmp_ui(Q,NUI,DUI) \ (__builtin_constant_p (NUI) && (NUI) == 0 \ ? mpq_sgn (Q) : _mpq_cmp_ui (Q,NUI,DUI)) #define mpq_cmp_si(q,n,d) \ (__builtin_constant_p ((n) >= 0) && (n) >= 0 \ - ? mpq_cmp_ui (q, (unsigned long) (n), d) \ + ? mpq_cmp_ui (q, __GMP_CAST (unsigned long, n), d) \ : _mpq_cmp_si (q, n, d)) #else #define mpz_cmp_ui(Z,UI) _mpz_cmp_ui (Z,UI) @@ -2062,7 +2079,7 @@ mpn_sub_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_ /* Using "&" rather than "&&" means these can come out branch-free. Every mpz_t has at least one limb allocated, so fetching the low limb is always allowed. */ -#define mpz_odd_p(z) ((int) ((z)->_mp_size != 0) & (int) (z)->_mp_d[0]) +#define mpz_odd_p(z) (((z)->_mp_size != 0) & __GMP_CAST (int, (z)->_mp_d[0])) #define mpz_even_p(z) (! mpz_odd_p (z)) @@ -2088,9 +2105,9 @@ __GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpf_ptr); #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)) + (((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)) + (((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 @@ -2116,7 +2133,7 @@ enum /* Major version number is the value of __GNU_MP__ too, above and in mp.h. */ #define __GNU_MP_VERSION 4 #define __GNU_MP_VERSION_MINOR 1 -#define __GNU_MP_VERSION_PATCHLEVEL 2 +#define __GNU_MP_VERSION_PATCHLEVEL 4 #define __GMP_H__ #endif /* __GMP_H__ */ diff --git a/src/gmp/gmp-impl.h b/src/gmp/gmp-impl.h index 57044b937..c26deed31 100644 --- a/src/gmp/gmp-impl.h +++ b/src/gmp/gmp-impl.h @@ -3,8 +3,8 @@ THE CONTENTS OF THIS FILE ARE FOR INTERNAL USE AND ARE ALMOST CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES IN FUTURE GNU MP RELEASES. -Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002 Free -Software Foundation, Inc. +Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003, +2004 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -330,7 +330,9 @@ void __gmp_tmp_debug_free _PROTO ((const char *, int, int, #define MPN_CMP(result, xp, yp, size) __GMPN_CMP(result, xp, yp, size) #define ABS(x) ((x) >= 0 ? (x) : -(x)) +#undef MIN #define MIN(l,o) ((l) < (o) ? (l) : (o)) +#undef MAX #define MAX(h,i) ((h) > (i) ? (h) : (i)) #define numberof(x) (sizeof (x) / sizeof ((x)[0])) @@ -576,7 +578,8 @@ void __gmp_default_free _PROTO ((void *, size_t)); the regparm parameters. Calls to local (ie. static) functions could still use this, if we cared to differentiate locals and globals. */ -#if HAVE_HOST_CPU_FAMILY_x86 && __GMP_GNUC_PREREQ (2,96) && ! defined (PIC) +#if HAVE_HOST_CPU_FAMILY_x86 && __GMP_GNUC_PREREQ (2,96) && ! defined (PIC) \ + && ! WANT_PROFILING_PROF && ! WANT_PROFILING_GPROF #define USE_LEADING_REGPARM 1 #else #define USE_LEADING_REGPARM 0 @@ -825,7 +828,7 @@ mp_size_t mpn_rootrem _PROTO ((mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_limb_t)) #endif #define mpn_copyi __MPN(copyi) -void mpn_copyi _PROTO ((mp_ptr, mp_srcptr, mp_size_t)); +__GMP_DECLSPEC void mpn_copyi _PROTO ((mp_ptr, mp_srcptr, mp_size_t)); #if ! defined (MPN_COPY_INCR) && HAVE_NATIVE_mpn_copyi #define MPN_COPY_INCR(dst, src, size) \ @@ -893,7 +896,7 @@ void mpn_copyi _PROTO ((mp_ptr, mp_srcptr, mp_size_t)); #endif #define mpn_copyd __MPN(copyd) -void mpn_copyd _PROTO ((mp_ptr, mp_srcptr, mp_size_t)); +__GMP_DECLSPEC void mpn_copyd _PROTO ((mp_ptr, mp_srcptr, mp_size_t)); #if ! defined (MPN_COPY_DECR) && HAVE_NATIVE_mpn_copyd #define MPN_COPY_DECR(dst, src, size) \ @@ -1114,7 +1117,7 @@ void mpn_copyd _PROTO ((mp_ptr, mp_srcptr, mp_size_t)); This data generated by code at the end of mpn/generic/fib2_ui.c. */ -extern const mp_limb_t __gmp_fib_table[]; +__GMP_DECLSPEC extern const mp_limb_t __gmp_fib_table[]; #define FIB_TABLE(n) (__gmp_fib_table[(n)+1]) #if GMP_NUMB_BITS >= 64 @@ -2531,6 +2534,7 @@ union ieee_double_extract || defined (__pyr__) \ || defined (__ibm032__) \ || defined (_IBMR2) || defined (_ARCH_PPC) \ + || defined (__s390__) \ || defined (__sh__) \ || defined (__sparc) || defined (sparc) || defined (__sparc__) \ || defined (__sparc_v9) || defined (__sparc_v9__) \ diff --git a/src/gmp/gmp.info b/src/gmp/gmp.info new file mode 100644 index 000000000..dae65cc6f --- /dev/null +++ b/src/gmp/gmp.info @@ -0,0 +1,165 @@ +This is gmp.info, produced by makeinfo version 4.6 from gmp.texi. + +This manual describes how to install and use the GNU multiple precision +arithmetic library, version 4.1.4. + + Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004 Free Software Foundation, Inc. + + Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, Version +1.1 or any later version published by the Free Software Foundation; +with no Invariant Sections, with the Front-Cover Texts being "A GNU +Manual", and with the Back-Cover Texts being "You have freedom to copy +and modify this GNU Manual, like GNU software". A copy of the license +is included in *Note GNU Free Documentation License::. +INFO-DIR-SECTION GNU libraries +START-INFO-DIR-ENTRY +* gmp: (gmp). GNU Multiple Precision Arithmetic Library. +END-INFO-DIR-ENTRY + + +Indirect: +gmp.info-1: 913 +gmp.info-2: 297472 + +Tag Table: +(Indirect) +Node: Top913 +Node: Copying3097 +Node: Introduction to GMP4950 +Node: Installing GMP8141 +Node: Build Options8835 +Node: ABI and ISA25028 +Node: Notes for Package Builds30470 +Node: Notes for Particular Systems32506 +Node: Known Build Problems39091 +Node: GMP Basics44563 +Node: Headers and Libraries45207 +Node: Nomenclature and Types46722 +Node: Function Classes47774 +Node: Variable Conventions49209 +Node: Parameter Conventions50810 +Node: Memory Management52863 +Node: Reentrancy53983 +Node: Useful Macros and Constants55817 +Node: Compatibility with older versions56583 +Node: Demonstration Programs57536 +Node: Efficiency58795 +Node: Debugging66429 +Node: Profiling72955 +Node: Autoconf74574 +Node: Emacs77217 +Node: Reporting Bugs77883 +Node: Integer Functions80409 +Node: Initializing Integers81151 +Node: Assigning Integers84847 +Node: Simultaneous Integer Init & Assign86291 +Node: Converting Integers87903 +Node: Integer Arithmetic90304 +Node: Integer Division91883 +Node: Integer Exponentiation97719 +Node: Integer Roots98558 +Node: Number Theoretic Functions100013 +Node: Integer Comparisons106025 +Node: Integer Logic and Bit Fiddling107213 +Node: I/O of Integers109695 +Node: Integer Random Numbers112166 +Node: Integer Import and Export114774 +Node: Miscellaneous Integer Functions118759 +Node: Rational Number Functions120717 +Node: Initializing Rationals121905 +Node: Rational Conversions124101 +Node: Rational Arithmetic125422 +Node: Comparing Rationals126741 +Node: Applying Integer Functions128095 +Node: I/O of Rationals129564 +Node: Floating-point Functions131414 +Node: Initializing Floats134295 +Node: Assigning Floats137984 +Node: Simultaneous Float Init & Assign140315 +Node: Converting Floats141830 +Node: Float Arithmetic144144 +Node: Float Comparison146164 +Node: I/O of Floats147499 +Node: Miscellaneous Float Functions149812 +Node: Low-level Functions151692 +Node: Random Number Functions172917 +Node: Random State Initialization173950 +Node: Random State Seeding176418 +Node: Formatted Output177762 +Node: Formatted Output Strings178001 +Node: Formatted Output Functions182875 +Node: C++ Formatted Output186853 +Node: Formatted Input189433 +Node: Formatted Input Strings189663 +Node: Formatted Input Functions194107 +Node: C++ Formatted Input196130 +Node: C++ Class Interface197500 +Node: C++ Interface General198518 +Node: C++ Interface Integers201582 +Node: C++ Interface Rationals204702 +Node: C++ Interface Floats208071 +Node: C++ Interface MPFR212401 +Node: C++ Interface Random Numbers212980 +Node: C++ Interface Limitations215381 +Node: BSD Compatible Functions218197 +Node: Custom Allocation222885 +Node: Language Bindings226651 +Node: Algorithms230633 +Node: Multiplication Algorithms231328 +Node: Basecase Multiplication232361 +Node: Karatsuba Multiplication234238 +Node: Toom-Cook 3-Way Multiplication237862 +Node: FFT Multiplication245614 +Node: Other Multiplication250941 +Node: Division Algorithms253420 +Node: Single Limb Division253757 +Node: Basecase Division256662 +Node: Divide and Conquer Division257851 +Node: Exact Division260070 +Node: Exact Remainder263239 +Node: Small Quotient Division265498 +Node: Greatest Common Divisor Algorithms267082 +Node: Binary GCD267345 +Node: Accelerated GCD268829 +Node: Extended GCD270612 +Node: Jacobi Symbol272267 +Node: Powering Algorithms273169 +Node: Normal Powering Algorithm273422 +Node: Modular Powering Algorithm273936 +Node: Root Extraction Algorithms274985 +Node: Square Root Algorithm275290 +Node: Nth Root Algorithm276254 +Node: Perfect Square Algorithm277025 +Node: Perfect Power Algorithm278018 +Node: Radix Conversion Algorithms278625 +Node: Binary to Radix278991 +Node: Radix to Binary282906 +Node: Other Algorithms284823 +Node: Factorial Algorithm285109 +Node: Binomial Coefficients Algorithm286448 +Node: Fibonacci Numbers Algorithm287770 +Node: Lucas Numbers Algorithm290240 +Node: Assembler Coding290914 +Node: Assembler Code Organisation291819 +Node: Assembler Basics292421 +Node: Assembler Carry Propagation293500 +Node: Assembler Cache Handling295322 +Node: Assembler Floating Point297472 +Node: Assembler SIMD Instructions301252 +Node: Assembler Software Pipelining302226 +Node: Assembler Loop Unrolling303482 +Node: Internals305857 +Node: Integer Internals306363 +Node: Rational Internals308376 +Node: Float Internals309604 +Node: Raw Output Internals316698 +Node: C++ Interface Internals317882 +Node: Contributors321192 +Node: References324952 +Node: GNU Free Documentation License329658 +Node: Concept Index352073 +Node: Function Index366046 + +End Tag Table diff --git a/src/gmp/gmp.info-1 b/src/gmp/gmp.info-1 new file mode 100644 index 000000000..ac0c19b2f --- /dev/null +++ b/src/gmp/gmp.info-1 @@ -0,0 +1,7035 @@ +This is gmp.info, produced by makeinfo version 4.6 from gmp.texi. + +This manual describes how to install and use the GNU multiple precision +arithmetic library, version 4.1.4. + + Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004 Free Software Foundation, Inc. + + Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, Version +1.1 or any later version published by the Free Software Foundation; +with no Invariant Sections, with the Front-Cover Texts being "A GNU +Manual", and with the Back-Cover Texts being "You have freedom to copy +and modify this GNU Manual, like GNU software". A copy of the license +is included in *Note GNU Free Documentation License::. +INFO-DIR-SECTION GNU libraries +START-INFO-DIR-ENTRY +* gmp: (gmp). GNU Multiple Precision Arithmetic Library. +END-INFO-DIR-ENTRY + + +File: gmp.info, Node: Top, Next: Copying, Prev: (dir), Up: (dir) + +GNU MP +****** + +This manual describes how to install and use the GNU multiple precision +arithmetic library, version 4.1.4. + + Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004 Free Software Foundation, Inc. + + Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, Version +1.1 or any later version published by the Free Software Foundation; +with no Invariant Sections, with the Front-Cover Texts being "A GNU +Manual", and with the Back-Cover Texts being "You have freedom to copy +and modify this GNU Manual, like GNU software". A copy of the license +is included in *Note GNU Free Documentation License::. + +* Menu: + +* Copying:: GMP Copying Conditions (LGPL). +* Introduction to GMP:: Brief introduction to GNU MP. +* Installing GMP:: How to configure and compile the GMP library. +* GMP Basics:: What every GMP user should know. +* Reporting Bugs:: How to usefully report bugs. +* Integer Functions:: Functions for arithmetic on signed integers. +* Rational Number Functions:: Functions for arithmetic on rational numbers. +* Floating-point Functions:: Functions for arithmetic on floats. +* Low-level Functions:: Fast functions for natural numbers. +* Random Number Functions:: Functions for generating random numbers. +* Formatted Output:: `printf' style output. +* Formatted Input:: `scanf' style input. +* C++ Class Interface:: Class wrappers around GMP types. +* BSD Compatible Functions:: All functions found in BSD MP. +* Custom Allocation:: How to customize the internal allocation. +* Language Bindings:: Using GMP from other languages. +* Algorithms:: What happens behind the scenes. +* Internals:: How values are represented behind the scenes. + +* Contributors:: Who brings your this library? +* References:: Some useful papers and books to read. +* GNU Free Documentation License:: +* Concept Index:: +* Function Index:: + + +File: gmp.info, Node: Copying, Next: Introduction to GMP, Prev: Top, Up: Top + +GNU MP Copying Conditions +************************* + +This library is "free"; this means that everyone is free to use it and +free to redistribute it on a free basis. The library is not in the +public domain; it is copyrighted and there are restrictions on its +distribution, but these restrictions are designed to permit everything +that a good cooperating citizen would want to do. What is not allowed +is to try to prevent others from further sharing any version of this +library that they might get from you. + + Specifically, we want to make sure that you have the right to give +away copies of the library, that you receive source code or else can +get it if you want it, that you can change this library or use pieces +of it in new free programs, and that you know you can do these things. + + To make sure that everyone has such rights, we have to forbid you to +deprive anyone else of these rights. For example, if you distribute +copies of the GNU MP library, you must give the recipients all the +rights that you have. You must make sure that they, too, receive or +can get the source code. And you must tell them their rights. + + Also, for our own protection, we must make certain that everyone +finds out that there is no warranty for the GNU MP library. If it is +modified by someone else and passed on, we want their recipients to +know that what they have is not what we distributed, so that any +problems introduced by others will not reflect on our reputation. + + The precise conditions of the license for the GNU MP library are +found in the Lesser General Public License version 2.1 that accompanies +the source code, see `COPYING.LIB'. Certain demonstration programs are +provided under the terms of the plain General Public License version 2, +see `COPYING'. + + +File: gmp.info, Node: Introduction to GMP, Next: Installing GMP, Prev: Copying, Up: Top + +Introduction to GNU MP +********************** + +GNU MP is a portable library written in C for arbitrary precision +arithmetic on integers, rational numbers, and floating-point numbers. +It aims to provide the fastest possible arithmetic for all applications +that need higher precision than is directly supported by the basic C +types. + + Many applications use just a few hundred bits of precision; but some +applications may need thousands or even millions of bits. GMP is +designed to give good performance for both, by choosing algorithms +based on the sizes of the operands, and by carefully keeping the +overhead at a minimum. + + The speed of GMP is achieved by using fullwords as the basic +arithmetic type, by using sophisticated algorithms, by including +carefully optimized assembly code for the most common inner loops for +many different CPUs, and by a general emphasis on speed (as opposed to +simplicity or elegance). + + There is carefully optimized assembly code for these CPUs: ARM, DEC +Alpha 21064, 21164, and 21264, AMD 29000, AMD K6, K6-2 and Athlon, +Hitachi SuperH and SH-2, HPPA 1.0, 1.1 and 2.0, Intel Pentium, Pentium +Pro/II/III, Pentium 4, generic x86, Intel IA-64, i960, Motorola +MC68000, MC68020, MC88100, and MC88110, Motorola/IBM PowerPC 32 and 64, +National NS32000, IBM POWER, MIPS R3000, R4000, SPARCv7, SuperSPARC, +generic SPARCv8, UltraSPARC, DEC VAX, and Zilog Z8000. Some +optimizations also for Cray vector systems, Clipper, IBM ROMP (RT), and +Pyramid AP/XP. + + There are two public mailing lists of interest. One for general +questions and discussions about usage of the GMP library and one for +discussions about development of GMP. There's more information about +the mailing lists at `http://swox.com/mailman/listinfo/'. These lists +are *not* for bug reports. + + The proper place for bug reports is . See *Note +Reporting Bugs:: for info about reporting bugs. + +For up-to-date information on GMP, please see the GMP web pages at + + `http://swox.com/gmp/' + +The latest version of the library is available at + + `ftp://ftp.gnu.org/gnu/gmp' + + Many sites around the world mirror `ftp.gnu.org', please use a mirror +near you, see `http://www.gnu.org/order/ftp.html' for a full list. + + There are three public mailing lists of interest. One for release +announcements, one for general questions and discussions about usage of +the GMP library and one for discussions about development of GMP. +These lists are *not* for bug reports. For more information, see + + `http://swox.com/mailman/listinfo/'. + + The proper place for bug reports is . See *Note +Reporting Bugs:: for information about reporting bugs. + + +How to use this Manual +====================== + +Everyone should read *Note GMP Basics::. If you need to install the +library yourself, then read *Note Installing GMP::. If you have a +system with multiple ABIs, then read *Note ABI and ISA::, for the +compiler options that must be used on applications. + + The rest of the manual can be used for later reference, although it +is probably a good idea to glance through it. + + +File: gmp.info, Node: Installing GMP, Next: GMP Basics, Prev: Introduction to GMP, Up: Top + +Installing GMP +************** + +GMP has an autoconf/automake/libtool based configuration system. On a +Unix-like system a basic build can be done with + + ./configure + make + +Some self-tests can be run with + + make check + +And you can install (under `/usr/local' by default) with + + make install + + If you experience problems, please report them to . +See *Note Reporting Bugs::, for information on what to include in +useful bug reports. + +* Menu: + +* Build Options:: +* ABI and ISA:: +* Notes for Package Builds:: +* Notes for Particular Systems:: +* Known Build Problems:: + + +File: gmp.info, Node: Build Options, Next: ABI and ISA, Prev: Installing GMP, Up: Installing GMP + +Build Options +============= + +All the usual autoconf configure options are available, run `./configure +--help' for a summary. The file `INSTALL.autoconf' has some generic +installation information too. + +Non-Unix Systems + `configure' requires various Unix-like tools. On an MS-DOS system + DJGPP can be used, and on MS Windows Cygwin or MINGW can be used, + + `http://www.cygwin.com/' + `http://www.delorie.com/djgpp' + `http://www.mingw.org' + + Microsoft also publishes an Interix "Services for Unix" which can + be used to build GMP on Windows (with a normal `./configure'), but + it's not free software. + + The `macos' directory contains an unsupported port to MacOS 9 on + Power Macintosh, see `macos/README'. Note that MacOS X "Darwin" + should use the normal Unix-style `./configure'. + + It might be possible to build without the help of `configure', + certainly all the code is there, but unfortunately you'll be on + your own. + +Build Directory + To compile in a separate build directory, `cd' to that directory, + and prefix the configure command with the path to the GMP source + directory. For example + + cd /my/build/dir + /my/sources/gmp-4.1.4/configure + + Not all `make' programs have the necessary features (`VPATH') to + support this. In particular, SunOS and Slowaris `make' have bugs + that make them unable to build in a separate directory. Use GNU + `make' instead. + +`--prefix' and `--exec-prefix' + The `--prefix' option can be used in the normal way to direct GMP + to install under a particular tree. The default is `/usr/local'. + + `--exec-prefix' can be used to direct architecture-dependent files + like `libgmp.a' to a different location. This can be used to share + architecture-independent parts like the documentation, but + separate the dependent parts. Note however that `gmp.h' and + `mp.h' are architecture-dependent since they encode certain + aspects of `libgmp', so it will be necessary to ensure both + `$prefix/include' and `$exec_prefix/include' are available to the + compiler. + +`--disable-shared', `--disable-static' + By default both shared and static libraries are built (where + possible), but one or other can be disabled. Shared libraries + result in smaller executables and permit code sharing between + separate running processes, but on some CPUs are slightly slower, + having a small cost on each function call. + +Native Compilation, `--build=CPU-VENDOR-OS' + For normal native compilation, the system can be specified with + `--build'. By default `./configure' uses the output from running + `./config.guess'. On some systems `./config.guess' can determine + the exact CPU type, on others it will be necessary to give it + explicitly. For example, + + ./configure --build=ultrasparc-sun-solaris2.7 + + In all cases the `OS' part is important, since it controls how + libtool generates shared libraries. Running `./config.guess' is + the simplest way to see what it should be, if you don't know + already. + +Cross Compilation, `--host=CPU-VENDOR-OS' + When cross-compiling, the system used for compiling is given by + `--build' and the system where the library will run is given by + `--host'. For example when using a FreeBSD Athlon system to build + GNU/Linux m68k binaries, + + ./configure --build=athlon-pc-freebsd3.5 --host=m68k-mac-linux-gnu + + Compiler tools are sought first with the host system type as a + prefix. For example `m68k-mac-linux-gnu-ranlib' is tried, then + plain `ranlib'. This makes it possible for a set of + cross-compiling tools to co-exist with native tools. The prefix + is the argument to `--host', and this can be an alias, such as + `m68k-linux'. But note that tools don't have to be setup this + way, it's enough to just have a `PATH' with a suitable + cross-compiling `cc' etc. + + Compiling for a different CPU in the same family as the build + system is a form of cross-compilation, though very possibly this + would merely be special options on a native compiler. In any case + `./configure' avoids depending on being able to run code on the + build system, which is important when creating binaries for a + newer CPU since they very possibly won't run on the build system. + + In all cases the compiler must be able to produce an executable + (of whatever format) from a standard C `main'. Although only + object files will go to make up `libgmp', `./configure' uses + linking tests for various purposes, such as determining what + functions are available on the host system. + + Currently a warning is given unless an explicit `--build' is used + when cross-compiling, because it may not be possible to correctly + guess the build system type if the `PATH' has only a + cross-compiling `cc'. + + Note that the `--target' option is not appropriate for GMP. It's + for use when building compiler tools, with `--host' being where + they will run, and `--target' what they'll produce code for. + Ordinary programs or libraries like GMP are only interested in the + `--host' part, being where they'll run. (Some past versions of + GMP used `--target' incorrectly.) + +CPU types + In general, if you want a library that runs as fast as possible, + you should configure GMP for the exact CPU type your system uses. + However, this may mean the binaries won't run on older members of + the family, and might run slower on other members, older or newer. + The best idea is always to build GMP for the exact machine type + you intend to run it on. + + The following CPUs have specific support. See `configure.in' for + details of what code and compiler options they select. + + * Alpha: alpha, alphaev5, alphaev56, alphapca56, alphapca57, + alphaev6, alphaev67, alphaev68 + + * Cray: c90, j90, t90, sv1 + + * HPPA: hppa1.0, hppa1.1, hppa2.0, hppa2.0n, hppa2.0w + + * IA-64: ia64 + + * MIPS: mips, mips3, mips64 + + * Motorola: m68k, m68000, m68010, m68020, m68030, m68040, + m68060, m68302, m68360, m88k, m88110 + + * POWER: power, power1, power2, power2sc + + * PowerPC: powerpc, powerpc64, powerpc401, powerpc403, + powerpc405, powerpc505, powerpc601, powerpc602, powerpc603, + powerpc603e, powerpc604, powerpc604e, powerpc620, powerpc630, + powerpc740, powerpc7400, powerpc7450, powerpc750, powerpc801, + powerpc821, powerpc823, powerpc860, + + * SPARC: sparc, sparcv8, microsparc, supersparc, sparcv9, + ultrasparc, ultrasparc2, ultrasparc2i, ultrasparc3, sparc64 + + * x86 family: i386, i486, i586, pentium, pentiummmx, pentiumpro, + pentium2, pentium3, pentium4, k6, k62, k63, athlon, x86_64, + viac3, viac32 + + * Other: a29k, arm, clipper, i960, ns32k, pyramid, sh, sh2, vax, + z8k + + CPUs not listed will use generic C code. + +Generic C Build + If some of the assembly code causes problems, or if otherwise + desired, the generic C code can be selected with CPU `none'. For + example, + + ./configure --host=none-unknown-freebsd3.5 + + Note that this will run quite slowly, but it should be portable + and should at least make it possible to get something running if + all else fails. + +`ABI' + On some systems GMP supports multiple ABIs (application binary + interfaces), meaning data type sizes and calling conventions. By + default GMP chooses the best ABI available, but a particular ABI + can be selected. For example + + ./configure --host=mips64-sgi-irix6 ABI=n32 + + See *Note ABI and ISA::, for the available choices on relevant + CPUs, and what applications need to do. + +`CC', `CFLAGS' + By default the C compiler used is chosen from among some likely + candidates, with `gcc' normally preferred if it's present. The + usual `CC=whatever' can be passed to `./configure' to choose + something different. + + For some systems, default compiler flags are set based on the CPU + and compiler. The usual `CFLAGS="-whatever"' can be passed to + `./configure' to use something different or to set good flags for + systems GMP doesn't otherwise know. + + The `CC' and `CFLAGS' used are printed during `./configure', and + can be found in each generated `Makefile'. This is the easiest way + to check the defaults when considering changing or adding + something. + + Note that when `CC' and `CFLAGS' are specified on a system + supporting multiple ABIs it's important to give an explicit + `ABI=whatever', since GMP can't determine the ABI just from the + flags and won't be able to select the correct assembler code. + + If just `CC' is selected then normal default `CFLAGS' for that + compiler will be used (if GMP recognises it). For example + `CC=gcc' can be used to force the use of GCC, with default flags + (and default ABI). + +`CPPFLAGS' + Any flags like `-D' defines or `-I' includes required by the + preprocessor should be set in `CPPFLAGS' rather than `CFLAGS'. + Compiling is done with both `CPPFLAGS' and `CFLAGS', but + preprocessing uses just `CPPFLAGS'. This distinction is because + most preprocessors won't accept all the flags the compiler does. + Preprocessing is done separately in some configure tests, and in + the `ansi2knr' support for K&R compilers. + +C++ Support, `--enable-cxx' + C++ support in GMP can be enabled with `--enable-cxx', in which + case a C++ compiler will be required. As a convenience + `--enable-cxx=detect' can be used to enable C++ support only if a + compiler can be found. The C++ support consists of a library + `libgmpxx.la' and header file `gmpxx.h'. + + A separate `libgmpxx.la' has been adopted rather than having C++ + objects within `libgmp.la' in order to ensure dynamic linked C + programs aren't bloated by a dependency on the C++ standard + library, and to avoid any chance that the C++ compiler could be + required when linking plain C programs. + + `libgmpxx.la' will use certain internals from `libgmp.la' and can + only be expected to work with `libgmp.la' from the same GMP + version. Future changes to the relevant internals will be + accompanied by renaming, so a mismatch will cause unresolved + symbols rather than perhaps mysterious misbehaviour. + + In general `libgmpxx.la' will be usable only with the C++ compiler + that built it, since name mangling and runtime support are usually + incompatible between different compilers. + +`CXX', `CXXFLAGS' + When C++ support is enabled, the C++ compiler and its flags can be + set with variables `CXX' and `CXXFLAGS' in the usual way. The + default for `CXX' is the first compiler that works from a list of + likely candidates, with `g++' normally preferred when available. + The default for `CXXFLAGS' is to try `CFLAGS', `CFLAGS' without + `-g', then for `g++' either `-g -O2' or `-O2', or for other + compilers `-g' or nothing. Trying `CFLAGS' this way is convenient + when using `gcc' and `g++' together, since the flags for `gcc' will + usually suit `g++'. + + It's important that the C and C++ compilers match, meaning their + startup and runtime support routines are compatible and that they + generate code in the same ABI (if there's a choice of ABIs on the + system). `./configure' isn't currently able to check these things + very well itself, so for that reason `--disable-cxx' is the + default, to avoid a build failure due to a compiler mismatch. + Perhaps this will change in the future. + + Incidentally, it's normally not good enough to set `CXX' to the + same as `CC'. Although `gcc' for instance recognises `foo.cc' as + C++ code, only `g++' will invoke the linker the right way when + building an executable or shared library from object files. + +Temporary Memory, `--enable-alloca=' + GMP allocates temporary workspace using one of the following three + methods, which can be selected with for instance + `--enable-alloca=malloc-reentrant'. + + * `alloca' - C library or compiler builtin. + + * `malloc-reentrant' - the heap, in a re-entrant fashion. + + * `malloc-notreentrant' - the heap, with global variables. + + For convenience, the following choices are also available. + `--disable-alloca' is the same as `--enable-alloca=no'. + + * `yes' - a synonym for `alloca'. + + * `no' - a synonym for `malloc-reentrant'. + + * `reentrant' - `alloca' if available, otherwise + `malloc-reentrant'. This is the default. + + * `notreentrant' - `alloca' if available, otherwise + `malloc-notreentrant'. + + `alloca' is reentrant and fast, and is recommended, but when + working with large numbers it can overflow the available stack + space, in which case one of the two malloc methods will need to be + used. Alternately it might be possible to increase available + stack with `limit', `ulimit' or `setrlimit', or under DJGPP with + `stubedit' or `_stklen'. Note that depending on the system the + only indication of stack overflow might be a segmentation + violation. + + `malloc-reentrant' is, as the name suggests, reentrant and thread + safe, but `malloc-notreentrant' is faster and should be used if + reentrancy is not required. + + The two malloc methods in fact use the memory allocation functions + selected by `mp_set_memory_functions', these being `malloc' and + friends by default. *Note Custom Allocation::. + + An additional choice `--enable-alloca=debug' is available, to help + when debugging memory related problems (*note Debugging::). + +FFT Multiplication, `--disable-fft' + By default multiplications are done using Karatsuba, 3-way + Toom-Cook, and Fermat FFT. The FFT is only used on large to very + large operands and can be disabled to save code size if desired. + +Berkeley MP, `--enable-mpbsd' + The Berkeley MP compatibility library (`libmp') and header file + (`mp.h') are built and installed only if `--enable-mpbsd' is used. + *Note BSD Compatible Functions::. + +MPFR, `--enable-mpfr' + The optional MPFR functions are built and installed only if + `--enable-mpfr' is used. These are in a separate library + `libmpfr.a' and are documented separately too (*note Introduction + to MPFR: (mpfr)Introduction to MPFR.). + +Assertion Checking, `--enable-assert' + This option enables some consistency checking within the library. + This can be of use while debugging, *note Debugging::. + +Execution Profiling, `--enable-profiling=prof/gprof' + Profiling support can be enabled either for `prof' or `gprof'. + This adds `-p' or `-pg' respectively to `CFLAGS', and for some + systems adds corresponding `mcount' calls to the assembler code. + *Note Profiling::. + +`MPN_PATH' + Various assembler versions of each mpn subroutines are provided. + For a given CPU, a search is made though a path to choose a + version of each. For example `sparcv8' has + + MPN_PATH="sparc32/v8 sparc32 generic" + + which means look first for v8 code, then plain sparc32 (which is + v7), and finally fall back on generic C. Knowledgeable users with + special requirements can specify a different path. Normally this + is completely unnecessary. + +Documentation + The document you're now reading is `gmp.texi'. The usual automake + targets are available to make PostScript `gmp.ps' and/or DVI + `gmp.dvi'. + + HTML can be produced with `makeinfo --html', see *Note Generating + HTML: (texinfo)Generating HTML. Or alternately `texi2html', see + *Note Texinfo to HTML: (texi2html)Top. + + PDF can be produced with `texi2dvi --pdf' (*note PDF: (texinfo)PDF + Output.) or with `pdftex'. + + Some supplementary notes can be found in the `doc' subdirectory. + + + +File: gmp.info, Node: ABI and ISA, Next: Notes for Package Builds, Prev: Build Options, Up: Installing GMP + +ABI and ISA +=========== + +ABI (Application Binary Interface) refers to the calling conventions +between functions, meaning what registers are used and what sizes the +various C data types are. ISA (Instruction Set Architecture) refers to +the instructions and registers a CPU has available. + + Some 64-bit ISA CPUs have both a 64-bit ABI and a 32-bit ABI +defined, the latter for compatibility with older CPUs in the family. +GMP supports some CPUs like this in both ABIs. In fact within GMP +`ABI' means a combination of chip ABI, plus how GMP chooses to use it. +For example in some 32-bit ABIs, GMP may support a limb as either a +32-bit `long' or a 64-bit `long long'. + + By default GMP chooses the best ABI available for a given system, +and this generally gives significantly greater speed. But an ABI can +be chosen explicitly to make GMP compatible with other libraries, or +particular application requirements. For example, + + ./configure ABI=32 + + In all cases it's vital that all object code used in a given program +is compiled for the same ABI. + + Usually a limb is implemented as a `long'. When a `long long' limb +is used this is encoded in the generated `gmp.h'. This is convenient +for applications, but it does mean that `gmp.h' will vary, and can't be +just copied around. `gmp.h' remains compiler independent though, since +all compilers for a particular ABI will be expected to use the same +limb type. + + Currently no attempt is made to follow whatever conventions a system +has for installing library or header files built for a particular ABI. +This will probably only matter when installing multiple builds of GMP, +and it might be as simple as configuring with a special `libdir', or it +might require more than that. Note that builds for different ABIs need +to done separately, with a fresh `./configure' and `make' each. + + +HPPA 2.0 (`hppa2.0*') + + `ABI=2.0w' + The 2.0w ABI uses 64-bit limbs and pointers and is available + on HP-UX 11 or up when using `cc'. `gcc' support for this is + in progress. Applications must be compiled with + + cc +DD64 + + `ABI=2.0n' + The 2.0n ABI means the 32-bit HPPA 1.0 ABI but with a 64-bit + limb using `long long'. This is available on HP-UX 10 or up + when using `cc'. No `gcc' support is planned for this. + Applications must be compiled with + + cc +DA2.0 +e + + `ABI=1.0' + HPPA 2.0 CPUs can run all HPPA 1.0 and 1.1 code in the 32-bit + HPPA 1.0 ABI. No special compiler options are needed for + applications. + + All three ABIs are available for CPUs `hppa2.0w' and `hppa2.0', but + for CPU `hppa2.0n' only 2.0n or 1.0 are allowed. + + +MIPS under IRIX 6 (`mips*-*-irix[6789]') + IRIX 6 supports the n32 and 64 ABIs and always has a 64-bit MIPS 3 + or better CPU. In both these ABIs GMP uses a 64-bit limb. A new + enough `gcc' is required (2.95 for instance). + + `ABI=n32' + The n32 ABI is 32-bit pointers and integers, but with a + 64-bit limb using a `long long'. Applications must be + compiled with + + gcc -mabi=n32 + cc -n32 + + `ABI=64' + The 64-bit ABI is 64-bit pointers and integers. Applications + must be compiled with + + gcc -mabi=64 + cc -64 + + Note that MIPS GNU/Linux, as of kernel version 2.2, doesn't have + the necessary support for n32 or 64 and so only gets a 32-bit limb + and the MIPS 2 code. + + +PowerPC 64 (`powerpc64', `powerpc620', `powerpc630') + + `ABI=aix64' + The AIX 64 ABI uses 64-bit limbs and pointers and is + available on systems `*-*-aix*'. Applications must be + compiled (and linked) with + + gcc -maix64 + xlc -q64 + + `ABI=32' + This is the basic 32-bit PowerPC ABI. No special compiler + options are needed for applications. + + +Sparc V9 (`sparcv9' and `ultrasparc*') + + `ABI=64' + The 64-bit V9 ABI is available on Solaris 2.7 and up and + GNU/Linux. GCC 2.95 or up, or Sun `cc' is required. + Applications must be compiled with + + gcc -m64 -mptr64 -Wa,-xarch=v9 -mcpu=v9 + cc -xarch=v9 + + `ABI=32' + On Solaris 2.6 and earlier, and on Solaris 2.7 with the + kernel in 32-bit mode, only the plain V8 32-bit ABI can be + used, since the kernel doesn't save all registers. GMP still + uses as much of the V9 ISA as it can in these circumstances. + No special compiler options are required for applications, + though using something like the following requesting V9 code + within the V8 ABI is recommended. + + gcc -mv8plus + cc -xarch=v8plus + + `gcc' 2.8 and earlier only supports `-mv8' though. + + Don't be confused by the names of these sparc `-m' and `-x' + options, they're called `arch' but they effectively control the + ABI. + + On Solaris 2.7 with the kernel in 32-bit-mode, a normal native + build will reject `ABI=64' because the resulting executables won't + run. `ABI=64' can still be built if desired by making it look + like a cross-compile, for example + + ./configure --build=none --host=sparcv9-sun-solaris2.7 ABI=64 + + +File: gmp.info, Node: Notes for Package Builds, Next: Notes for Particular Systems, Prev: ABI and ISA, Up: Installing GMP + +Notes for Package Builds +======================== + +GMP should present no great difficulties for packaging in a binary +distribution. + + Libtool is used to build the library and `-version-info' is set +appropriately, having started from `3:0:0' in GMP 3.0. The GMP 4 series +will be upwardly binary compatible in each release and will be upwardly +binary compatible with all of the GMP 3 series. Additional function +interfaces may be added in each release, so on systems where libtool +versioning is not fully checked by the loader an auxiliary mechanism +may be needed to express that a dynamic linked application depends on a +new enough GMP. + + An auxiliary mechanism may also be needed to express that +`libgmpxx.la' (from `--enable-cxx', *note Build Options::) requires +`libgmp.la' from the same GMP version, since this is not done by the +libtool versioning, nor otherwise. A mismatch will result in +unresolved symbols from the linker, or perhaps the loader. + + Using `DESTDIR' or a `prefix' override with `make install' and a +shared `libgmpxx' may run into a libtool relinking problem, see *Note +Known Build Problems::. + + When building a package for a CPU family, care should be taken to use +`--host' (or `--build') to choose the least common denominator among +the CPUs which might use the package. For example this might +necessitate `i386' for x86s, or plain `sparc' (meaning V7) for SPARCs. + + Users who care about speed will want GMP built for their exact CPU +type, to make use of the available optimizations. Providing a way to +suitably rebuild a package may be useful. This could be as simple as +making it possible for a user to omit `--build' (and `--host') so +`./config.guess' will detect the CPU. But a way to manually specify a +`--build' will be wanted for systems where `./config.guess' is inexact. + + Note that `gmp.h' is a generated file, and will be architecture and +ABI dependent. + + +File: gmp.info, Node: Notes for Particular Systems, Next: Known Build Problems, Prev: Notes for Package Builds, Up: Installing GMP + +Notes for Particular Systems +============================ + +AIX 3 and 4 + On systems `*-*-aix[34]*' shared libraries are disabled by + default, since some versions of the native `ar' fail on the + convenience libraries used. A shared build can be attempted with + + ./configure --enable-shared --disable-static + + Note that the `--disable-static' is necessary because in a shared + build libtool makes `libgmp.a' a symlink to `libgmp.so', + apparently for the benefit of old versions of `ld' which only + recognise `.a', but unfortunately this is done even if a fully + functional `ld' is available. + +ARM + On systems `arm*-*-*', versions of GCC up to and including 2.95.3 + have a bug in unsigned division, giving wrong results for some + operands. GMP `./configure' will demand GCC 2.95.4 or later. + +Compaq C++ + Compaq C++ on OSF 5.1 has two flavours of `iostream', a standard + one and an old pre-standard one (see `man iostream_intro'). GMP + can only use the standard one, which unfortunately is not the + default but must be selected by defining `__USE_STD_IOSTREAM'. + Configure with for instance + + ./configure --enable-cxx CPPFLAGS=-D__USE_STD_IOSTREAM + +Floating Point Mode + On some systems, the hardware floating point has a control mode + which can set all operations to be done in a particular precision, + for instance single, double or extended on x86 systems (x87 + floating point). The GMP functions involving a `double' cannot be + expected to operate to their full precision when the hardware is + in single precision mode. Of course this affects all code, + including application code, not just GMP. + +Microsoft Windows + On systems `*-*-cygwin*', `*-*-mingw*' and `*-*-pw32*' by default + GMP builds only a static library, but a DLL can be built instead + using + + ./configure --disable-static --enable-shared + + Static and DLL libraries can't both be built, since certain export + directives in `gmp.h' must be different. `--enable-cxx' cannot be + used when building a DLL, since libtool doesn't currently support + C++ DLLs. This might change in the future. + +Microsoft C + A MINGW DLL build of GMP can be used with Microsoft C. Libtool + doesn't install `.lib' and `.exp' files, but they can be created + with the following commands, where `/my/inst/dir' is the install + directory (with a `lib' subdirectory). + + lib /machine:IX86 /def:.libs/libgmp-3.dll-def + cp libgmp-3.lib /my/inst/dir/lib + cp .libs/libgmp-3.dll-exp /my/inst/dir/lib/libgmp-3.exp + + MINGW uses the C runtime library `msvcrt.dll' for I/O, so + applications wanting to use the GMP I/O routines must be compiled + with `cl /MD' to do the same. If one of the other C runtime + library choices provided by MS C is desired then the suggestion is + to use the GMP string functions and confine I/O to the application. + +Motorola 68k CPU Types + `m68k' is taken to mean 68000. `m68020' or higher will give a + performance boost on applicable CPUs. `m68360' can be used for + CPU32 series chips. `m68302' can be used for "Dragonball" series + chips, though this is merely a synonym for `m68000'. + +OpenBSD 2.6 + `m4' in this release of OpenBSD has a bug in `eval' that makes it + unsuitable for `.asm' file processing. `./configure' will detect + the problem and either abort or choose another m4 in the `PATH'. + The bug is fixed in OpenBSD 2.7, so either upgrade or use GNU m4. + +Power CPU Types + In GMP, CPU types `power*' and `powerpc*' will each use + instructions not available on the other, so it's important to + choose the right one for the CPU that will be used. Currently GMP + has no assembler code support for using just the common + instruction subset. To get executables that run on both, the + current suggestion is to use the generic C code (CPU `none'), + possibly with appropriate compiler options (like `-mcpu=common' for + `gcc'). CPU `rs6000' (which is not a CPU but a family of + workstations) is accepted by `config.sub', but is currently + equivalent to `none'. + +Sparc CPU Types + `sparcv8' or `supersparc' on relevant systems will give a + significant performance increase over the V7 code. + +Sparc App Regs + The GMP assembler code for both 32-bit and 64-bit Sparc clobbers + the "application registers" `g2', `g3' and `g4', the same way that + the GCC default `-mapp-regs' does (*note SPARC Options: (gcc)SPARC + Options.). + + This makes that code unsuitable for use with the special V9 + `-mcmodel=embmedany' (which uses `g4' as a data segment pointer), + and for applications wanting to use those registers for special + purposes. In these cases the only suggestion currently is to + build GMP with CPU `none' to avoid the assembler code. + +SunOS 4 + `/usr/bin/m4' lacks various features needed to process `.asm' + files, and instead `./configure' will automatically use + `/usr/5bin/m4', which we believe is always available (if not then + use GNU m4). + +x86 CPU Types + `i386' selects generic code which will run reasonably well on all + x86 chips. + + `i586', `pentium' or `pentiummmx' code is good for the intended P5 + Pentium chips, but quite slow when run on Intel P6 class chips + (PPro, P-II, P-III). `i386' is a better choice when making + binaries that must run on both. + + `pentium4' and an SSE2 capable assembler are important for best + results on Pentium 4. The specific code is for instance roughly a + 2x to 3x speedup over the generic `i386' code. + +x86 MMX and SSE2 Code + If the CPU selected has MMX code but the assembler doesn't support + it, a warning is given and non-MMX code is used instead. This + will be an inferior build, since the MMX code that's present is + there because it's faster than the corresponding plain integer + code. The same applies to SSE2. + + Old versions of `gas' don't support MMX instructions, in particular + version 1.92.3 that comes with FreeBSD 2.2.8 doesn't (and + unfortunately there's no newer assembler for that system). + + Solaris 2.6 and 2.7 `as' generate incorrect object code for + register to register `movq' instructions, and so can't be used for + MMX code. Install a recent `gas' if MMX code is wanted on these + systems. + + +File: gmp.info, Node: Known Build Problems, Prev: Notes for Particular Systems, Up: Installing GMP + +Known Build Problems +==================== + +You might find more up-to-date information at `http://swox.com/gmp/'. + +Compiler link options + The version of libtool currently in use rather aggressively strips + compiler options when linking a shared library. This will + hopefully be relaxed in the future, but for now if this is a + problem the suggestion is to create a little script to hide them, + and for instance configure with + + ./configure CC=gcc-with-my-options + +DJGPP + The DJGPP port of `bash' 2.03 is unable to run the `configure' + script, it exits silently, having died writing a preamble to + `config.log'. Use `bash' 2.04 or higher. + + `make all' was found to run out of memory during the final + `libgmp.la' link on one system tested, despite having 64Mb + available. A separate `make libgmp.la' helped, perhaps recursing + into the various subdirectories uses up memory. + +`DESTDIR' and shared `libgmpxx' + `make install DESTDIR=/my/staging/area', or the same with a + `prefix' override, to install to a temporary directory is not + fully supported by current versions of libtool when building a + shared version of a library which depends on another being built + at the same time, like `libgmpxx' and `libgmp'. + + The problem is that `libgmpxx' is relinked at the install stage to + ensure that if the system puts a hard-coded path to `libgmp' within + `libgmpxx' then that path will be correct. Naturally the linker is + directed to look only at the final location, not the staging area, + so if `libgmp' is not already in that final location then the link + will fail. + + A workaround for this on SVR4 style systems, such as GNU/Linux, + where paths are not hard-coded, is to include the staging area in + the linker's search using `LD_LIBRARY_PATH'. For example with + `--prefix=/usr' but installing under `/my/staging/area', + + LD_LIBRARY_PATH=/my/staging/area/usr/lib \ + make install DESTDIR=/my/staging/area + +GNU binutils `strip' prior to 2.12 + `strip' from GNU binutils 2.11 and earlier should not be used on + the static libraries `libgmp.a' and `libmp.a' since it will + discard all but the last of multiple archive members with the same + name, like the three versions of `init.o' in `libgmp.a'. Binutils + 2.12 or higher can be used successfully. + + The shared libraries `libgmp.so' and `libmp.so' are not affected by + this and any version of `strip' can be used on them. + +`make' syntax error + On certain versions of SCO OpenServer 5 and IRIX 6.5 the native + `make' is unable to handle the long dependencies list for + `libgmp.la'. The symptom is a "syntax error" on the following + line of the top-level `Makefile'. + + libgmp.la: $(libgmp_la_OBJECTS) $(libgmp_la_DEPENDENCIES) + + Either use GNU Make, or as a workaround remove + `$(libgmp_la_DEPENDENCIES)' from that line (which will make the + initial build work, but if any recompiling is done `libgmp.la' + might not be rebuilt). + +MacOS X and GCC + Libtool currently only knows how to create shared libraries on + MacOS X using the native `cc' (which is a modified GCC), not a + plain GCC. A static-only build should work though + (`--disable-shared'). + + Also, libtool currently cannot build C++ shared libraries on MacOS + X, so if `--enable-cxx' is desired then `--disable-shared' must be + used. Hopefully this will be fixed in the future. + +Motorola 68k ABI + The GMP assembler code has been written for the SVR4 standard ABI. + GCC option `-mshort' changes the calling conventions and is not + currently supported. We believe the PalmOS calling conventions + are similarly different and are likewise not currently supported. + +NeXT prior to 3.3 + The system compiler on old versions of NeXT was a massacred and + old GCC, even if it called itself `cc'. This compiler cannot be + used to build GMP, you need to get a real GCC, and install that. + (NeXT may have fixed this in release 3.3 of their system.) + +POWER and PowerPC + Bugs in GCC 2.7.2 (and 2.6.3) mean it can't be used to compile GMP + on POWER or PowerPC. If you want to use GCC for these machines, + get GCC 2.7.2.1 (or later). + +Sequent Symmetry + Use the GNU assembler instead of the system assembler, since the + latter has serious bugs. + +Solaris 2.6 + The system `sed' prints an error "Output line too long" when + libtool builds `libgmp.la'. This doesn't seem to cause any + obvious ill effects, but GNU `sed' is recommended, to avoid any + doubt. + +Sparc Solaris 2.7 with gcc 2.95.2 in ABI=32 + A shared library build of GMP seems to fail in this combination, + it builds but then fails the tests, apparently due to some + incorrect data relocations within `gmp_randinit_lc_2exp_size'. + The exact cause is unknown, `--disable-shared' is recommended. + +Windows DLL test programs + When creating a DLL version of `libgmp', libtool creates wrapper + scripts like `t-mul' for programs that would normally be + `t-mul.exe', in order to setup the right library paths etc. This + works fine, but the absence of `t-mul.exe' etc causes `make' to + think they need recompiling every time, which is an annoyance when + re-running a `make check'. + + +File: gmp.info, Node: GMP Basics, Next: Reporting Bugs, Prev: Installing GMP, Up: Top + +GMP Basics +********** + +*Using functions, macros, data types, etc. not documented in this +manual is strongly discouraged. If you do so your application is +guaranteed to be incompatible with future versions of GMP.* + +* Menu: + +* Headers and Libraries:: +* Nomenclature and Types:: +* Function Classes:: +* Variable Conventions:: +* Parameter Conventions:: +* Memory Management:: +* Reentrancy:: +* Useful Macros and Constants:: +* Compatibility with older versions:: +* Demonstration Programs:: +* Efficiency:: +* Debugging:: +* Profiling:: +* Autoconf:: +* Emacs:: + + +File: gmp.info, Node: Headers and Libraries, Next: Nomenclature and Types, Prev: GMP Basics, Up: GMP Basics + +Headers and Libraries +===================== + +All declarations needed to use GMP are collected in the include file +`gmp.h'. It is designed to work with both C and C++ compilers. + + #include + + Note however that prototypes for GMP functions with `FILE *' +parameters are only provided if `' is included too. + + #include + #include + + Likewise `' (or `') is required for prototypes +with `va_list' parameters, such as `gmp_vprintf'. And `' +for prototypes with `struct obstack' parameters, such as +`gmp_obstack_printf', when available. + + All programs using GMP must link against the `libgmp' library. On a +typical Unix-like system this can be done with `-lgmp', for example + + gcc myprogram.c -lgmp + + GMP C++ functions are in a separate `libgmpxx' library. This is +built and installed if C++ support has been enabled (*note Build +Options::). For example, + + g++ mycxxprog.cc -lgmpxx -lgmp + + GMP is built using Libtool and an application can use that to link +if desired, *note Shared library support for GNU: (libtool)Top. + + If GMP has been installed to a non-standard location then it may be +necessary to use `-I' and `-L' compiler options to point to the right +directories, and some sort of run-time path for a shared library. +Consult your compiler documentation, for instance *Note Introduction: +(gcc)Top. + + +File: gmp.info, Node: Nomenclature and Types, Next: Function Classes, Prev: Headers and Libraries, Up: GMP Basics + +Nomenclature and Types +====================== + +In this manual, "integer" usually means a multiple precision integer, as +defined by the GMP library. The C data type for such integers is +`mpz_t'. Here are some examples of how to declare such integers: + + mpz_t sum; + + struct foo { mpz_t x, y; }; + + mpz_t vec[20]; + +"Rational number" means a multiple precision fraction. The C data type +for these fractions is `mpq_t'. For example: + + mpq_t quotient; + +"Floating point number" or "Float" for short, is an arbitrary precision +mantissa with a limited precision exponent. The C data type for such +objects is `mpf_t'. + +A "limb" means the part of a multi-precision number that fits in a +single machine word. (We chose this word because a limb of the human +body is analogous to a digit, only larger, and containing several +digits.) Normally a limb is 32 or 64 bits. The C data type for a limb +is `mp_limb_t'. + + +File: gmp.info, Node: Function Classes, Next: Variable Conventions, Prev: Nomenclature and Types, Up: GMP Basics + +Function Classes +================ + +There are six classes of functions in the GMP library: + + 1. Functions for signed integer arithmetic, with names beginning with + `mpz_'. The associated type is `mpz_t'. There are about 150 + functions in this class. + + 2. Functions for rational number arithmetic, with names beginning with + `mpq_'. The associated type is `mpq_t'. There are about 40 + functions in this class, but the integer functions can be used for + arithmetic on the numerator and denominator separately. + + 3. Functions for floating-point arithmetic, with names beginning with + `mpf_'. The associated type is `mpf_t'. There are about 60 + functions is this class. + + 4. Functions compatible with Berkeley MP, such as `itom', `madd', and + `mult'. The associated type is `MINT'. + + 5. Fast low-level functions that operate on natural numbers. These + are used by the functions in the preceding groups, and you can + also call them directly from very time-critical user programs. + These functions' names begin with `mpn_'. The associated type is + array of `mp_limb_t'. There are about 30 (hard-to-use) functions + in this class. + + 6. Miscellaneous functions. Functions for setting up custom + allocation and functions for generating random numbers. + + +File: gmp.info, Node: Variable Conventions, Next: Parameter Conventions, Prev: Function Classes, Up: GMP Basics + +Variable Conventions +==================== + +GMP functions generally have output arguments before input arguments. +This notation is by analogy with the assignment operator. The BSD MP +compatibility functions are exceptions, having the output arguments +last. + + GMP lets you use the same variable for both input and output in one +call. For example, the main function for integer multiplication, +`mpz_mul', can be used to square `x' and put the result back in `x' with + + mpz_mul (x, x, x); + + Before you can assign to a GMP variable, you need to initialize it +by calling one of the special initialization functions. When you're +done with a variable, you need to clear it out, using one of the +functions for that purpose. Which function to use depends on the type +of variable. See the chapters on integer functions, rational number +functions, and floating-point functions for details. + + A variable should only be initialized once, or at least cleared +between each initialization. After a variable has been initialized, it +may be assigned to any number of times. + + For efficiency reasons, avoid excessive initializing and clearing. +In general, initialize near the start of a function and clear near the +end. For example, + + void + foo (void) + { + mpz_t n; + int i; + mpz_init (n); + for (i = 1; i < 100; i++) + { + mpz_mul (n, ...); + mpz_fdiv_q (n, ...); + ... + } + mpz_clear (n); + } + + +File: gmp.info, Node: Parameter Conventions, Next: Memory Management, Prev: Variable Conventions, Up: GMP Basics + +Parameter Conventions +===================== + +When a GMP variable is used as a function parameter, it's effectively a +call-by-reference, meaning if the function stores a value there it will +change the original in the caller. Parameters which are input-only can +be designated `const' to provoke a compiler error or warning on +attempting to modify them. + + When a function is going to return a GMP result, it should designate +a parameter that it sets, like the library functions do. More than one +value can be returned by having more than one output parameter, again +like the library functions. A `return' of an `mpz_t' etc doesn't +return the object, only a pointer, and this is almost certainly not +what's wanted. + + Here's an example accepting an `mpz_t' parameter, doing a +calculation, and storing the result to the indicated parameter. + + void + foo (mpz_t result, const mpz_t param, unsigned long n) + { + unsigned long i; + mpz_mul_ui (result, param, n); + for (i = 1; i < n; i++) + mpz_add_ui (result, result, i*7); + } + + int + main (void) + { + mpz_t r, n; + mpz_init (r); + mpz_init_set_str (n, "123456", 0); + foo (r, n, 20L); + gmp_printf ("%Zd\n", r); + return 0; + } + + `foo' works even if the mainline passes the same variable for +`param' and `result', just like the library functions. But sometimes +it's tricky to make that work, and an application might not want to +bother supporting that sort of thing. + + For interest, the GMP types `mpz_t' etc are implemented as +one-element arrays of certain structures. This is why declaring a +variable creates an object with the fields GMP needs, but then using it +as a parameter passes a pointer to the object. Note that the actual +fields in each `mpz_t' etc are for internal use only and should not be +accessed directly by code that expects to be compatible with future GMP +releases. + + +File: gmp.info, Node: Memory Management, Next: Reentrancy, Prev: Parameter Conventions, Up: GMP Basics + +Memory Management +================= + +The GMP types like `mpz_t' are small, containing only a couple of sizes, +and pointers to allocated data. Once a variable is initialized, GMP +takes care of all space allocation. Additional space is allocated +whenever a variable doesn't have enough. + + `mpz_t' and `mpq_t' variables never reduce their allocated space. +Normally this is the best policy, since it avoids frequent reallocation. +Applications that need to return memory to the heap at some particular +point can use `mpz_realloc2', or clear variables no longer needed. + + `mpf_t' variables, in the current implementation, use a fixed amount +of space, determined by the chosen precision and allocated at +initialization, so their size doesn't change. + + All memory is allocated using `malloc' and friends by default, but +this can be changed, see *Note Custom Allocation::. Temporary memory +on the stack is also used (via `alloca'), but this can be changed at +build-time if desired, see *Note Build Options::. + + +File: gmp.info, Node: Reentrancy, Next: Useful Macros and Constants, Prev: Memory Management, Up: GMP Basics + +Reentrancy +========== + +GMP is reentrant and thread-safe, with some exceptions: + + * If configured with `--enable-alloca=malloc-notreentrant' (or with + `--enable-alloca=notreentrant' when `alloca' is not available), + then naturally GMP is not reentrant. + + * `mpf_set_default_prec' and `mpf_init' use a global variable for the + selected precision. `mpf_init2' can be used instead, and in the + C++ interface an explicit precision to the `mpf_class' constructor. + + * `mpz_random' and the other old random number functions use a global + random state and are hence not reentrant. The newer random number + functions that accept a `gmp_randstate_t' parameter can be used + instead. + + * `gmp_randinit' (obsolete) returns an error indication through a + global variable, which is not thread safe. Applications are + advised to use `gmp_randinit_lc_2exp' instead. + + * `mp_set_memory_functions' uses global variables to store the + selected memory allocation functions. + + * If the memory allocation functions set by a call to + `mp_set_memory_functions' (or `malloc' and friends by default) are + not reentrant, then GMP will not be reentrant either. + + * If the standard I/O functions such as `fwrite' are not reentrant + then the GMP I/O functions using them will not be reentrant either. + + * It's safe for two threads to read from the same GMP variable + simultaneously, but it's not safe for one to read while the + another might be writing, nor for two threads to write + simultaneously. It's not safe for two threads to generate a + random number from the same `gmp_randstate_t' simultaneously, + since this involves an update of that variable. + + +File: gmp.info, Node: Useful Macros and Constants, Next: Compatibility with older versions, Prev: Reentrancy, Up: GMP Basics + +Useful Macros and Constants +=========================== + + - Global Constant: const int mp_bits_per_limb + The number of bits per limb. + + - Macro: __GNU_MP_VERSION + - Macro: __GNU_MP_VERSION_MINOR + - Macro: __GNU_MP_VERSION_PATCHLEVEL + The major and minor GMP version, and patch level, respectively, as + integers. For GMP i.j, these numbers will be i, j, and 0, + respectively. For GMP i.j.k, these numbers will be i, j, and k, + respectively. + + - Global Constant: const char * const gmp_version + The GMP version number, as a null-terminated string, in the form + "i.j" or "i.j.k". This release is "4.1.4". + + +File: gmp.info, Node: Compatibility with older versions, Next: Demonstration Programs, Prev: Useful Macros and Constants, Up: GMP Basics + +Compatibility with older versions +================================= + +This version of GMP is upwardly binary compatible with all 4.x and 3.x +versions, and upwardly compatible at the source level with all 2.x +versions, with the following exceptions. + + * `mpn_gcd' had its source arguments swapped as of GMP 3.0, for + consistency with other `mpn' functions. + + * `mpf_get_prec' counted precision slightly differently in GMP 3.0 + and 3.0.1, but in 3.1 reverted to the 2.x style. + + There are a number of compatibility issues between GMP 1 and GMP 2 +that of course also apply when porting applications from GMP 1 to GMP +4. Please see the GMP 2 manual for details. + + The Berkeley MP compatibility library (*note BSD Compatible +Functions::) is source and binary compatible with the standard `libmp'. + + +File: gmp.info, Node: Demonstration Programs, Next: Efficiency, Prev: Compatibility with older versions, Up: GMP Basics + +Demonstration programs +====================== + +The `demos' subdirectory has some sample programs using GMP. These +aren't built or installed, but there's a `Makefile' with rules for them. +For instance, + + make pexpr + ./pexpr 68^975+10 + +The following programs are provided + + * `pexpr' is an expression evaluator, the program used on the GMP + web page. + + * The `calc' subdirectory has a similar but simpler evaluator using + `lex' and `yacc'. + + * The `expr' subdirectory is yet another expression evaluator, a + library designed for ease of use within a C program. See + `demos/expr/README' for more information. + + * `factorize' is a Pollard-Rho factorization program. + + * `isprime' is a command-line interface to the `mpz_probab_prime_p' + function. + + * `primes' counts or lists primes in an interval, using a sieve. + + * `qcn' is an example use of `mpz_kronecker_ui' to estimate quadratic + class numbers. + + * The `perl' subdirectory is a comprehensive perl interface to GMP. + See `demos/perl/INSTALL' for more information. Documentation is + in POD format in `demos/perl/GMP.pm'. + + +File: gmp.info, Node: Efficiency, Next: Debugging, Prev: Demonstration Programs, Up: GMP Basics + +Efficiency +========== + +Small operands + On small operands, the time for function call overheads and memory + allocation can be significant in comparison to actual calculation. + This is unavoidable in a general purpose variable precision + library, although GMP attempts to be as efficient as it can on + both large and small operands. + +Static Linking + On some CPUs, in particular the x86s, the static `libgmp.a' should + be used for maximum speed, since the PIC code in the shared + `libgmp.so' will have a small overhead on each function call and + global data address. For many programs this will be + insignificant, but for long calculations there's a gain to be had. + +Initializing and clearing + Avoid excessive initializing and clearing of variables, since this + can be quite time consuming, especially in comparison to otherwise + fast operations like addition. + + A language interpreter might want to keep a free list or stack of + initialized variables ready for use. It should be possible to + integrate something like that with a garbage collector too. + +Reallocations + An `mpz_t' or `mpq_t' variable used to hold successively increasing + values will have its memory repeatedly `realloc'ed, which could be + quite slow or could fragment memory, depending on the C library. + If an application can estimate the final size then `mpz_init2' or + `mpz_realloc2' can be called to allocate the necessary space from + the beginning (*note Initializing Integers::). + + It doesn't matter if a size set with `mpz_init2' or `mpz_realloc2' + is too small, since all functions will do a further reallocation + if necessary. Badly overestimating memory required will waste + space though. + +`2exp' functions + It's up to an application to call functions like `mpz_mul_2exp' + when appropriate. General purpose functions like `mpz_mul' make + no attempt to identify powers of two or other special forms, + because such inputs will usually be very rare and testing every + time would be wasteful. + +`ui' and `si' functions + The `ui' functions and the small number of `si' functions exist for + convenience and should be used where applicable. But if for + example an `mpz_t' contains a value that fits in an `unsigned + long' there's no need extract it and call a `ui' function, just + use the regular `mpz' function. + +In-Place Operations + `mpz_abs', `mpq_abs', `mpf_abs', `mpz_neg', `mpq_neg' and + `mpf_neg' are fast when used for in-place operations like + `mpz_abs(x,x)', since in the current implementation only a single + field of `x' needs changing. On suitable compilers (GCC for + instance) this is inlined too. + + `mpz_add_ui', `mpz_sub_ui', `mpf_add_ui' and `mpf_sub_ui' benefit + from an in-place operation like `mpz_add_ui(x,x,y)', since usually + only one or two limbs of `x' will need to be changed. The same + applies to the full precision `mpz_add' etc if `y' is small. If + `y' is big then cache locality may be helped, but that's all. + + `mpz_mul' is currently the opposite, a separate destination is + slightly better. A call like `mpz_mul(x,x,y)' will, unless `y' is + only one limb, make a temporary copy of `x' before forming the + result. Normally that copying will only be a tiny fraction of the + time for the multiply, so this is not a particularly important + consideration. + + `mpz_set', `mpq_set', `mpq_set_num', `mpf_set', etc, make no + attempt to recognise a copy of something to itself, so a call like + `mpz_set(x,x)' will be wasteful. Naturally that would never be + written deliberately, but if it might arise from two pointers to + the same object then a test to avoid it might be desirable. + + if (x != y) + mpz_set (x, y); + + Note that it's never worth introducing extra `mpz_set' calls just + to get in-place operations. If a result should go to a particular + variable then just direct it there and let GMP take care of data + movement. + +Divisibility Testing (Small Integers) + `mpz_divisible_ui_p' and `mpz_congruent_ui_p' are the best + functions for testing whether an `mpz_t' is divisible by an + individual small integer. They use an algorithm which is faster + than `mpz_tdiv_ui', but which gives no useful information about + the actual remainder, only whether it's zero (or a particular + value). + + However when testing divisibility by several small integers, it's + best to take a remainder modulo their product, to save + multi-precision operations. For instance to test whether a number + is divisible by any of 23, 29 or 31 take a remainder modulo + 23*29*31 = 20677 and then test that. + + The division functions like `mpz_tdiv_q_ui' which give a quotient + as well as a remainder are generally a little slower than the + remainder-only functions like `mpz_tdiv_ui'. If the quotient is + only rarely wanted then it's probably best to just take a + remainder and then go back and calculate the quotient if and when + it's wanted (`mpz_divexact_ui' can be used if the remainder is + zero). + +Rational Arithmetic + The `mpq' functions operate on `mpq_t' values with no common + factors in the numerator and denominator. Common factors are + checked-for and cast out as necessary. In general, cancelling + factors every time is the best approach since it minimizes the + sizes for subsequent operations. + + However, applications that know something about the factorization + of the values they're working with might be able to avoid some of + the GCDs used for canonicalization, or swap them for divisions. + For example when multiplying by a prime it's enough to check for + factors of it in the denominator instead of doing a full GCD. Or + when forming a big product it might be known that very little + cancellation will be possible, and so canonicalization can be left + to the end. + + The `mpq_numref' and `mpq_denref' macros give access to the + numerator and denominator to do things outside the scope of the + supplied `mpq' functions. *Note Applying Integer Functions::. + + The canonical form for rationals allows mixed-type `mpq_t' and + integer additions or subtractions to be done directly with + multiples of the denominator. This will be somewhat faster than + `mpq_add'. For example, + + /* mpq increment */ + mpz_add (mpq_numref(q), mpq_numref(q), mpq_denref(q)); + + /* mpq += unsigned long */ + mpz_addmul_ui (mpq_numref(q), mpq_denref(q), 123UL); + + /* mpq -= mpz */ + mpz_submul (mpq_numref(q), mpq_denref(q), z); + +Number Sequences + Functions like `mpz_fac_ui', `mpz_fib_ui' and `mpz_bin_uiui' are + designed for calculating isolated values. If a range of values is + wanted it's probably best to call to get a starting point and + iterate from there. + +Text Input/Output + Hexadecimal or octal are suggested for input or output in text + form. Power-of-2 bases like these can be converted much more + efficiently than other bases, like decimal. For big numbers + there's usually nothing of particular interest to be seen in the + digits, so the base doesn't matter much. + + Maybe we can hope octal will one day become the normal base for + everyday use, as proposed by King Charles XII of Sweden and later + reformers. + + +File: gmp.info, Node: Debugging, Next: Profiling, Prev: Efficiency, Up: GMP Basics + +Debugging +========= + +Stack Overflow + Depending on the system, a segmentation violation or bus error + might be the only indication of stack overflow. See + `--enable-alloca' choices in *Note Build Options::, for how to + address this. + + In new enough versions of GCC, `-fstack-check' may be able to + ensure an overflow is recognised by the system before too much + damage is done, or `-fstack-limit-symbol' or + `-fstack-limit-register' may be able to add checking if the system + itself doesn't do any (*note Options for Code Generation: + (gcc)Code Gen Options.). These options must be added to the + `CFLAGS' used in the GMP build (*note Build Options::), adding + them just to an application will have no effect. Note also + they're a slowdown, adding overhead to each function call and each + stack allocation. + +Heap Problems + The most likely cause of application problems with GMP is heap + corruption. Failing to `init' GMP variables will have + unpredictable effects, and corruption arising elsewhere in a + program may well affect GMP. Initializing GMP variables more than + once or failing to clear them will cause memory leaks. + + In all such cases a malloc debugger is recommended. On a GNU or + BSD system the standard C library `malloc' has some diagnostic + facilities, see *Note Allocation Debugging: (libc)Allocation + Debugging, or `man 3 malloc'. Other possibilities, in no + particular order, include + + `http://www.inf.ethz.ch/personal/biere/projects/ccmalloc' + `http://dmalloc.com' + `http://www.perens.com/FreeSoftware' (electric fence) + `http://packages.debian.org/fda' + `http://www.gnupdate.org/components/leakbug' + `http://people.redhat.com/~otaylor/memprof' + `http://www.cbmamiga.demon.co.uk/mpatrol' + + The GMP default allocation routines in `memory.c' also have a + simple sentinel scheme which can be enabled with `#define DEBUG' + in that file. This is mainly designed for detecting buffer + overruns during GMP development, but might find other uses. + +Stack Backtraces + On some systems the compiler options GMP uses by default can + interfere with debugging. In particular on x86 and 68k systems + `-fomit-frame-pointer' is used and this generally inhibits stack + backtracing. Recompiling without such options may help while + debugging, though the usual caveats about it potentially moving a + memory problem or hiding a compiler bug will apply. + +GNU Debugger + A sample `.gdbinit' is included in the distribution, showing how + to call some undocumented dump functions to print GMP variables + from within GDB. Note that these functions shouldn't be used in + final application code since they're undocumented and may be + subject to incompatible changes in future versions of GMP. + +Source File Paths + GMP has multiple source files with the same name, in different + directories. For example `mpz', `mpq', `mpf' and `mpfr' each have + an `init.c'. If the debugger can't already determine the right + one it may help to build with absolute paths on each C file. One + way to do that is to use a separate object directory with an + absolute path to the source directory. + + cd /my/build/dir + /my/source/dir/gmp-4.1.4/configure + + This works via `VPATH', and might require GNU `make'. Alternately + it might be possible to change the `.c.lo' rules appropriately. + +Assertion Checking + The build option `--enable-assert' is available to add some + consistency checks to the library (see *Note Build Options::). + These are likely to be of limited value to most applications. + Assertion failures are just as likely to indicate memory + corruption as a library or compiler bug. + + Applications using the low-level `mpn' functions, however, will + benefit from `--enable-assert' since it adds checks on the + parameters of most such functions, many of which have subtle + restrictions on their usage. Note however that only the generic C + code has checks, not the assembler code, so CPU `none' should be + used for maximum checking. + +Temporary Memory Checking + The build option `--enable-alloca=debug' arranges that each block + of temporary memory in GMP is allocated with a separate call to + `malloc' (or the allocation function set with + `mp_set_memory_functions'). + + This can help a malloc debugger detect accesses outside the + intended bounds, or detect memory not released. In a normal + build, on the other hand, temporary memory is allocated in blocks + which GMP divides up for its own use, or may be allocated with a + compiler builtin `alloca' which will go nowhere near any malloc + debugger hooks. + +Maximum Debuggability + To summarize the above, a GMP build for maximum debuggability + would be + + ./configure --disable-shared --enable-assert \ + --enable-alloca=debug --host=none CFLAGS=-g + + For C++, add `--enable-cxx CXXFLAGS=-g'. + +Checker + The checker program (`http://savannah.gnu.org/projects/checker') + can be used with GMP. It contains a stub library which means GMP + applications compiled with checker can use a normal GMP build. + + A build of GMP with checking within GMP itself can be made. This + will run very very slowly. Configure with + + ./configure --host=none-pc-linux-gnu CC=checkergcc + + `--host=none' must be used, since the GMP assembler code doesn't + support the checking scheme. The GMP C++ features cannot be used, + since current versions of checker (0.9.9.1) don't yet support the + standard C++ library. + +Valgrind + The valgrind program (`http://valgrind.kde.org/') is a memory + checker for x86s. It translates and emulates machine instructions + to do strong checks for uninitialized data (at the level of + individual bits), memory accesses through bad pointers, and memory + leaks. + + Recent versions of Valgrind are getting support for MMX and + SSE/SSE2 instructions, for past versions GMP will need to be + configured not to use those, ie. for an x86 without them (for + instance plain `i486'). + +Other Problems + Any suspected bug in GMP itself should be isolated to make sure + it's not an application problem, see *Note Reporting Bugs::. + + +File: gmp.info, Node: Profiling, Next: Autoconf, Prev: Debugging, Up: GMP Basics + +Profiling +========= + +Running a program under a profiler is a good way to find where it's +spending most time and where improvements can be best sought. + + Depending on the system, it may be possible to get a flat profile, +meaning simple timer sampling of the program counter, with no special +GMP build options, just a `-p' when compiling the mainline. This is a +good way to ensure minimum interference with normal operation. The +necessary symbol type and size information exists in most of the GMP +assembler code. + + The `--enable-profiling' build option can be used to add suitable +compiler flags, either for `prof' (`-p') or `gprof' (`-pg'), see *Note +Build Options::. Which of the two is available and what they do will +depend on the system, and possibly on support available in `libc'. For +some systems appropriate corresponding `mcount' calls are added to the +assembler code too. + + On x86 systems `prof' gives call counting, so that average time spent +in a function can be determined. `gprof', where supported, adds call +graph construction, so for instance calls to `mpn_add_n' from `mpz_add' +and from `mpz_mul' can be differentiated. + + On x86 and 68k systems `-pg' and `-fomit-frame-pointer' are +incompatible, so the latter is not used when `gprof' profiling is +selected, which may result in poorer code generation. If `prof' +profiling is selected instead it should still be possible to use +`gprof', but only the `gprof -p' flat profile and call counts can be +expected to be valid, not the `gprof -q' call graph. + + +File: gmp.info, Node: Autoconf, Next: Emacs, Prev: Profiling, Up: GMP Basics + +Autoconf +======== + +Autoconf based applications can easily check whether GMP is installed. +The only thing to be noted is that GMP library symbols from version 3 +onwards have prefixes like `__gmpz'. The following therefore would be +a simple test, + + AC_CHECK_LIB(gmp, __gmpz_init) + + This just uses the default `AC_CHECK_LIB' actions for found or not +found, but an application that must have GMP would want to generate an +error if not found. For example, + + AC_CHECK_LIB(gmp, __gmpz_init, , [AC_MSG_ERROR( + [GNU MP not found, see http://swox.com/gmp])]) + + If functions added in some particular version of GMP are required, +then one of those can be used when checking. For example `mpz_mul_si' +was added in GMP 3.1, + + AC_CHECK_LIB(gmp, __gmpz_mul_si, , [AC_MSG_ERROR( + [GNU MP not found, or not 3.1 or up, see http://swox.com/gmp])]) + + An alternative would be to test the version number in `gmp.h' using +say `AC_EGREP_CPP'. That would make it possible to test the exact +version, if some particular sub-minor release is known to be necessary. + + An application that can use either GMP 2 or 3 will need to test for +`__gmpz_init' (GMP 3 and up) or `mpz_init' (GMP 2), and it's also worth +checking for `libgmp2' since Debian GNU/Linux systems used that name in +the past. For example, + + AC_CHECK_LIB(gmp, __gmpz_init, , + [AC_CHECK_LIB(gmp, mpz_init, , + [AC_CHECK_LIB(gmp2, mpz_init)])]) + + In general it's suggested that applications should simply demand a +new enough GMP rather than trying to provide supplements for features +not available in past versions. + + Occasionally an application will need or want to know the size of a +type at configuration or preprocessing time, not just with `sizeof' in +the code. This can be done in the normal way with `mp_limb_t' etc, but +GMP 4.0 or up is best for this, since prior versions needed certain +`-D' defines on systems using a `long long' limb. The following would +suit Autoconf 2.50 or up, + + AC_CHECK_SIZEOF(mp_limb_t, , [#include ]) + + The optional `mpfr' functions are provided in a separate +`libmpfr.a', and this might be from GMP with `--enable-mpfr' or from +MPFR installed separately. Either way `libmpfr' depends on `libgmp', +it doesn't stand alone. Currently only a static `libmpfr.a' will be +available, not a shared library, since upward binary compatibility is +not guaranteed. + + AC_CHECK_LIB(mpfr, mpfr_add, , [AC_MSG_ERROR( + [Need MPFR either from GNU MP 4 or separate MPFR package. + See http://www.mpfr.org or http://swox.com/gmp]) + + +File: gmp.info, Node: Emacs, Prev: Autoconf, Up: GMP Basics + +Emacs +===== + + (`info-lookup-symbol') is a good way to find documentation on +C functions while editing (*note Info Documentation Lookup: (emacs)Info +Lookup.). + + The GMP manual can be included in such lookups by putting the +following in your `.emacs', + + (eval-after-load "info-look" + '(let ((mode-value (assoc 'c-mode (assoc 'symbol info-lookup-alist)))) + (setcar (nthcdr 3 mode-value) + (cons '("(gmp)Function Index" nil "^ -.* " "\\>") + (nth 3 mode-value))))) + + The same can be done for MPFR, with `(mpfr)' in place of `(gmp)'. + + +File: gmp.info, Node: Reporting Bugs, Next: Integer Functions, Prev: GMP Basics, Up: Top + +Reporting Bugs +************** + +If you think you have found a bug in the GMP library, please +investigate it and report it. We have made this library available to +you, and it is not too much to ask you to report the bugs you find. + + Before you report a bug, check it's not already addressed in *Note +Known Build Problems::, or perhaps *Note Notes for Particular +Systems::. You may also want to check `http://swox.com/gmp/' for +patches for this release. + + Please include the following in any report, + + * The GMP version number, and if pre-packaged or patched then say so. + + * A test program that makes it possible for us to reproduce the bug. + Include instructions on how to run the program. + + * A description of what is wrong. If the results are incorrect, in + what way. If you get a crash, say so. + + * If you get a crash, include a stack backtrace from the debugger if + it's informative (`where' in `gdb', or `$C' in `adb'). + + * Please do not send core dumps, executables or `strace's. + + * The configuration options you used when building GMP, if any. + + * The name of the compiler and its version. For `gcc', get the + version with `gcc -v', otherwise perhaps `what `which cc`', or + similar. + + * The output from running `uname -a'. + + * The output from running `./config.guess', and from running + `./configfsf.guess' (might be the same). + + * If the bug is related to `configure', then the contents of + `config.log'. + + * If the bug is related to an `asm' file not assembling, then the + contents of `config.m4' and the offending line or lines from the + temporary `mpn/tmp-.s'. + + Please make an effort to produce a self-contained report, with +something definite that can be tested or debugged. Vague queries or +piecemeal messages are difficult to act on and don't help the +development effort. + + It is not uncommon that an observed problem is actually due to a bug +in the compiler; the GMP code tends to explore interesting corners in +compilers. + + If your bug report is good, we will do our best to help you get a +corrected version of the library; if the bug report is poor, we won't +do anything about it (except maybe ask you to send a better report). + + Send your report to: . + + If you think something in this manual is unclear, or downright +incorrect, or if the language needs to be improved, please send a note +to the same address. + + +File: gmp.info, Node: Integer Functions, Next: Rational Number Functions, Prev: Reporting Bugs, Up: Top + +Integer Functions +***************** + +This chapter describes the GMP functions for performing integer +arithmetic. These functions start with the prefix `mpz_'. + + GMP integers are stored in objects of type `mpz_t'. + +* Menu: + +* Initializing Integers:: +* Assigning Integers:: +* Simultaneous Integer Init & Assign:: +* Converting Integers:: +* Integer Arithmetic:: +* Integer Division:: +* Integer Exponentiation:: +* Integer Roots:: +* Number Theoretic Functions:: +* Integer Comparisons:: +* Integer Logic and Bit Fiddling:: +* I/O of Integers:: +* Integer Random Numbers:: +* Integer Import and Export:: +* Miscellaneous Integer Functions:: + + +File: gmp.info, Node: Initializing Integers, Next: Assigning Integers, Prev: Integer Functions, Up: Integer Functions + +Initialization Functions +======================== + +The functions for integer arithmetic assume that all integer objects are +initialized. You do that by calling the function `mpz_init'. For +example, + + { + mpz_t integ; + mpz_init (integ); + ... + mpz_add (integ, ...); + ... + mpz_sub (integ, ...); + + /* Unless the program is about to exit, do ... */ + mpz_clear (integ); + } + + As you can see, you can store new values any number of times, once an +object is initialized. + + - Function: void mpz_init (mpz_t INTEGER) + Initialize INTEGER, and set its value to 0. + + - Function: void mpz_init2 (mpz_t INTEGER, unsigned long N) + Initialize INTEGER, with space for N bits, and set its value to 0. + + N is only the initial space, INTEGER will grow automatically in + the normal way, if necessary, for subsequent values stored. + `mpz_init2' makes it possible to avoid such reallocations if a + maximum size is known in advance. + + - Function: void mpz_clear (mpz_t INTEGER) + Free the space occupied by INTEGER. Call this function for all + `mpz_t' variables when you are done with them. + + - Function: void mpz_realloc2 (mpz_t INTEGER, unsigned long N) + Change the space allocated for INTEGER to N bits. The value in + INTEGER is preserved if it fits, or is set to 0 if not. + + This function can be used to increase the space for a variable in + order to avoid repeated automatic reallocations, or to decrease it + to give memory back to the heap. + + - Function: void mpz_array_init (mpz_t INTEGER_ARRAY[], size_t + ARRAY_SIZE, mp_size_t FIXED_NUM_BITS) + This is a special type of initialization. *Fixed* space of + FIXED_NUM_BITS bits is allocated to each of the ARRAY_SIZE + integers in INTEGER_ARRAY. + + The space will not be automatically increased, unlike the normal + `mpz_init', but instead an application must ensure it's sufficient + for any value stored. The following space requirements apply to + various functions, + + * `mpz_abs', `mpz_neg', `mpz_set', `mpz_set_si' and + `mpz_set_ui' need room for the value they store. + + * `mpz_add', `mpz_add_ui', `mpz_sub' and `mpz_sub_ui' need room + for the larger of the two operands, plus an extra + `mp_bits_per_limb'. + + * `mpz_mul', `mpz_mul_ui' and `mpz_mul_ui' need room for the sum + of the number of bits in their operands, but each rounded up + to a multiple of `mp_bits_per_limb'. + + * `mpz_swap' can be used between two array variables, but not + between an array and a normal variable. + + For other functions, or if in doubt, the suggestion is to + calculate in a regular `mpz_init' variable and copy the result to + an array variable with `mpz_set'. + + `mpz_array_init' can reduce memory usage in algorithms that need + large arrays of integers, since it avoids allocating and + reallocating lots of small memory blocks. There is no way to free + the storage allocated by this function. Don't call `mpz_clear'! + + - Function: void * _mpz_realloc (mpz_t INTEGER, mp_size_t NEW_ALLOC) + Change the space for INTEGER to NEW_ALLOC limbs. The value in + INTEGER is preserved if it fits, or is set to 0 if not. The return + value is not useful to applications and should be ignored. + + `mpz_realloc2' is the preferred way to accomplish allocation + changes like this. `mpz_realloc2' and `_mpz_realloc' are the same + except that `_mpz_realloc' takes the new size in limbs. + + +File: gmp.info, Node: Assigning Integers, Next: Simultaneous Integer Init & Assign, Prev: Initializing Integers, Up: Integer Functions + +Assignment Functions +==================== + +These functions assign new values to already initialized integers +(*note Initializing Integers::). + + - Function: void mpz_set (mpz_t ROP, mpz_t OP) + - Function: void mpz_set_ui (mpz_t ROP, unsigned long int OP) + - Function: void mpz_set_si (mpz_t ROP, signed long int OP) + - Function: void mpz_set_d (mpz_t ROP, double OP) + - Function: void mpz_set_q (mpz_t ROP, mpq_t OP) + - Function: void mpz_set_f (mpz_t ROP, mpf_t OP) + Set the value of ROP from OP. + + `mpz_set_d', `mpz_set_q' and `mpz_set_f' truncate OP to make it an + integer. + + - Function: int mpz_set_str (mpz_t ROP, char *STR, int BASE) + Set the value of ROP from STR, a null-terminated C string in base + BASE. White space is allowed in the string, and is simply + ignored. The base may vary from 2 to 36. If BASE is 0, the + actual base is determined from the leading characters: if the + first two characters are "0x" or "0X", hexadecimal is assumed, + otherwise if the first character is "0", octal is assumed, + otherwise decimal is assumed. + + This function returns 0 if the entire string is a valid number in + base BASE. Otherwise it returns -1. + + - Function: void mpz_swap (mpz_t ROP1, mpz_t ROP2) + Swap the values ROP1 and ROP2 efficiently. + + +File: gmp.info, Node: Simultaneous Integer Init & Assign, Next: Converting Integers, Prev: Assigning Integers, Up: Integer Functions + +Combined Initialization and Assignment Functions +================================================ + +For convenience, GMP provides a parallel series of initialize-and-set +functions which initialize the output and then store the value there. +These functions' names have the form `mpz_init_set...' + + Here is an example of using one: + + { + mpz_t pie; + mpz_init_set_str (pie, "3141592653589793238462643383279502884", 10); + ... + mpz_sub (pie, ...); + ... + mpz_clear (pie); + } + +Once the integer has been initialized by any of the `mpz_init_set...' +functions, it can be used as the source or destination operand for the +ordinary integer functions. Don't use an initialize-and-set function +on a variable already initialized! + + - Function: void mpz_init_set (mpz_t ROP, mpz_t OP) + - Function: void mpz_init_set_ui (mpz_t ROP, unsigned long int OP) + - Function: void mpz_init_set_si (mpz_t ROP, signed long int OP) + - Function: void mpz_init_set_d (mpz_t ROP, double OP) + Initialize ROP with limb space and set the initial numeric value + from OP. + + - Function: int mpz_init_set_str (mpz_t ROP, char *STR, int BASE) + Initialize ROP and set its value like `mpz_set_str' (see its + documentation above for details). + + If the string is a correct base BASE number, the function returns + 0; if an error occurs it returns -1. ROP is initialized even if + an error occurs. (I.e., you have to call `mpz_clear' for it.) + + +File: gmp.info, Node: Converting Integers, Next: Integer Arithmetic, Prev: Simultaneous Integer Init & Assign, Up: Integer Functions + +Conversion Functions +==================== + +This section describes functions for converting GMP integers to +standard C types. Functions for converting _to_ GMP integers are +described in *Note Assigning Integers:: and *Note I/O of Integers::. + + - Function: unsigned long int mpz_get_ui (mpz_t OP) + Return the value of OP as an `unsigned long'. + + If OP is too big to fit an `unsigned long' then just the least + significant bits that do fit are returned. The sign of OP is + ignored, only the absolute value is used. + + - Function: signed long int mpz_get_si (mpz_t OP) + If OP fits into a `signed long int' return the value of OP. + Otherwise return the least significant part of OP, with the same + sign as OP. + + If OP is too big to fit in a `signed long int', the returned + result is probably not very useful. To find out if the value will + fit, use the function `mpz_fits_slong_p'. + + - Function: double mpz_get_d (mpz_t OP) + Convert OP to a `double'. + + - Function: double mpz_get_d_2exp (signed long int *EXP, mpz_t OP) + Find D and EXP such that D times 2 raised to EXP, with + 0.5<=abs(D)<1, is a good approximation to OP. + + - Function: char * mpz_get_str (char *STR, int BASE, mpz_t OP) + Convert OP to a string of digits in base BASE. The base may vary + from 2 to 36. + + If STR is `NULL', the result string is allocated using the current + allocation function (*note Custom Allocation::). The block will be + `strlen(str)+1' bytes, that being exactly enough for the string and + null-terminator. + + If STR is not `NULL', it should point to a block of storage large + enough for the result, that being `mpz_sizeinbase (OP, BASE) + 2'. + The two extra bytes are for a possible minus sign, and the + null-terminator. + + A pointer to the result string is returned, being either the + allocated block, or the given STR. + + - Function: mp_limb_t mpz_getlimbn (mpz_t OP, mp_size_t N) + Return limb number N from OP. The sign of OP is ignored, just the + absolute value is used. The least significant limb is number 0. + + `mpz_size' can be used to find how many limbs make up OP. + `mpz_getlimbn' returns zero if N is outside the range 0 to + `mpz_size(OP)-1'. + + +File: gmp.info, Node: Integer Arithmetic, Next: Integer Division, Prev: Converting Integers, Up: Integer Functions + +Arithmetic Functions +==================== + + - Function: void mpz_add (mpz_t ROP, mpz_t OP1, mpz_t OP2) + - Function: void mpz_add_ui (mpz_t ROP, mpz_t OP1, unsigned long int + OP2) + Set ROP to OP1 + OP2. + + - Function: void mpz_sub (mpz_t ROP, mpz_t OP1, mpz_t OP2) + - Function: void mpz_sub_ui (mpz_t ROP, mpz_t OP1, unsigned long int + OP2) + - Function: void mpz_ui_sub (mpz_t ROP, unsigned long int OP1, mpz_t + OP2) + Set ROP to OP1 - OP2. + + - Function: void mpz_mul (mpz_t ROP, mpz_t OP1, mpz_t OP2) + - Function: void mpz_mul_si (mpz_t ROP, mpz_t OP1, long int OP2) + - Function: void mpz_mul_ui (mpz_t ROP, mpz_t OP1, unsigned long int + OP2) + Set ROP to OP1 times OP2. + + - Function: void mpz_addmul (mpz_t ROP, mpz_t OP1, mpz_t OP2) + - Function: void mpz_addmul_ui (mpz_t ROP, mpz_t OP1, unsigned long + int OP2) + Set ROP to ROP + OP1 times OP2. + + - Function: void mpz_submul (mpz_t ROP, mpz_t OP1, mpz_t OP2) + - Function: void mpz_submul_ui (mpz_t ROP, mpz_t OP1, unsigned long + int OP2) + Set ROP to ROP - OP1 times OP2. + + - Function: void mpz_mul_2exp (mpz_t ROP, mpz_t OP1, unsigned long int + OP2) + Set ROP to OP1 times 2 raised to OP2. This operation can also be + defined as a left shift by OP2 bits. + + - Function: void mpz_neg (mpz_t ROP, mpz_t OP) + Set ROP to -OP. + + - Function: void mpz_abs (mpz_t ROP, mpz_t OP) + Set ROP to the absolute value of OP. + + +File: gmp.info, Node: Integer Division, Next: Integer Exponentiation, Prev: Integer Arithmetic, Up: Integer Functions + +Division Functions +================== + +Division is undefined if the divisor is zero. Passing a zero divisor +to the division or modulo functions (including the modular powering +functions `mpz_powm' and `mpz_powm_ui'), will cause an intentional +division by zero. This lets a program handle arithmetic exceptions in +these functions the same way as for normal C `int' arithmetic. + + - Function: void mpz_cdiv_q (mpz_t Q, mpz_t N, mpz_t D) + - Function: void mpz_cdiv_r (mpz_t R, mpz_t N, mpz_t D) + - Function: void mpz_cdiv_qr (mpz_t Q, mpz_t R, mpz_t N, mpz_t D) + - Function: unsigned long int mpz_cdiv_q_ui (mpz_t Q, mpz_t N, + unsigned long int D) + - Function: unsigned long int mpz_cdiv_r_ui (mpz_t R, mpz_t N, + unsigned long int D) + - Function: unsigned long int mpz_cdiv_qr_ui (mpz_t Q, mpz_t R, + mpz_t N, unsigned long int D) + - Function: unsigned long int mpz_cdiv_ui (mpz_t N, + unsigned long int D) + - Function: void mpz_cdiv_q_2exp (mpz_t Q, mpz_t N, + unsigned long int B) + - Function: void mpz_cdiv_r_2exp (mpz_t R, mpz_t N, + unsigned long int B) + + - Function: void mpz_fdiv_q (mpz_t Q, mpz_t N, mpz_t D) + - Function: void mpz_fdiv_r (mpz_t R, mpz_t N, mpz_t D) + - Function: void mpz_fdiv_qr (mpz_t Q, mpz_t R, mpz_t N, mpz_t D) + - Function: unsigned long int mpz_fdiv_q_ui (mpz_t Q, mpz_t N, + unsigned long int D) + - Function: unsigned long int mpz_fdiv_r_ui (mpz_t R, mpz_t N, + unsigned long int D) + - Function: unsigned long int mpz_fdiv_qr_ui (mpz_t Q, mpz_t R, + mpz_t N, unsigned long int D) + - Function: unsigned long int mpz_fdiv_ui (mpz_t N, + unsigned long int D) + - Function: void mpz_fdiv_q_2exp (mpz_t Q, mpz_t N, + unsigned long int B) + - Function: void mpz_fdiv_r_2exp (mpz_t R, mpz_t N, + unsigned long int B) + + - Function: void mpz_tdiv_q (mpz_t Q, mpz_t N, mpz_t D) + - Function: void mpz_tdiv_r (mpz_t R, mpz_t N, mpz_t D) + - Function: void mpz_tdiv_qr (mpz_t Q, mpz_t R, mpz_t N, mpz_t D) + - Function: unsigned long int mpz_tdiv_q_ui (mpz_t Q, mpz_t N, + unsigned long int D) + - Function: unsigned long int mpz_tdiv_r_ui (mpz_t R, mpz_t N, + unsigned long int D) + - Function: unsigned long int mpz_tdiv_qr_ui (mpz_t Q, mpz_t R, + mpz_t N, unsigned long int D) + - Function: unsigned long int mpz_tdiv_ui (mpz_t N, + unsigned long int D) + - Function: void mpz_tdiv_q_2exp (mpz_t Q, mpz_t N, + unsigned long int B) + - Function: void mpz_tdiv_r_2exp (mpz_t R, mpz_t N, + unsigned long int B) + + Divide N by D, forming a quotient Q and/or remainder R. For the + `2exp' functions, D=2^B. The rounding is in three styles, each + suiting different applications. + + * `cdiv' rounds Q up towards +infinity, and R will have the + opposite sign to D. The `c' stands for "ceil". + + * `fdiv' rounds Q down towards -infinity, and R will have the + same sign as D. The `f' stands for "floor". + + * `tdiv' rounds Q towards zero, and R will have the same sign + as N. The `t' stands for "truncate". + + In all cases Q and R will satisfy N=Q*D+R, and R will satisfy + 0<=abs(R)1, such that OP equals A raised to the + power B. + + Under this definition both 0 and 1 are considered to be perfect + powers. Negative values of OP are accepted, but of course can + only be odd perfect powers. + + - Function: int mpz_perfect_square_p (mpz_t OP) + Return non-zero if OP is a perfect square, i.e., if the square + root of OP is an integer. Under this definition both 0 and 1 are + considered to be perfect squares. + + +File: gmp.info, Node: Number Theoretic Functions, Next: Integer Comparisons, Prev: Integer Roots, Up: Integer Functions + +Number Theoretic Functions +========================== + + - Function: int mpz_probab_prime_p (mpz_t N, int REPS) + Determine whether N is prime. Return 2 if N is definitely prime, + return 1 if N is probably prime (without being certain), or return + 0 if N is definitely composite. + + This function does some trial divisions, then some Miller-Rabin + probabilistic primality tests. REPS controls how many such tests + are done, 5 to 10 is a reasonable number, more will reduce the + chances of a composite being returned as "probably prime". + + Miller-Rabin and similar tests can be more properly called + compositeness tests. Numbers which fail are known to be composite + but those which pass might be prime or might be composite. Only a + few composites pass, hence those which pass are considered + probably prime. + + - Function: void mpz_nextprime (mpz_t ROP, mpz_t OP) + Set ROP to the next prime greater than OP. + + This function uses a probabilistic algorithm to identify primes. + For practical purposes it's adequate, the chance of a composite + passing will be extremely small. + + - Function: void mpz_gcd (mpz_t ROP, mpz_t OP1, mpz_t OP2) + Set ROP to the greatest common divisor of OP1 and OP2. The result + is always positive even if one or both input operands are negative. + + - Function: unsigned long int mpz_gcd_ui (mpz_t ROP, mpz_t OP1, + unsigned long int OP2) + Compute the greatest common divisor of OP1 and OP2. If ROP is not + `NULL', store the result there. + + If the result is small enough to fit in an `unsigned long int', it + is returned. If the result does not fit, 0 is returned, and the + result is equal to the argument OP1. Note that the result will + always fit if OP2 is non-zero. + + - Function: void mpz_gcdext (mpz_t G, mpz_t S, mpz_t T, mpz_t A, mpz_t + B) + Set G to the greatest common divisor of A and B, and in addition + set S and T to coefficients satisfying A*S + B*T = G. G is always + positive, even if one or both of A and B are negative. + + If T is `NULL' then that value is not computed. + + - Function: void mpz_lcm (mpz_t ROP, mpz_t OP1, mpz_t OP2) + - Function: void mpz_lcm_ui (mpz_t ROP, mpz_t OP1, unsigned long OP2) + Set ROP to the least common multiple of OP1 and OP2. ROP is + always positive, irrespective of the signs of OP1 and OP2. ROP + will be zero if either OP1 or OP2 is zero. + + - Function: int mpz_invert (mpz_t ROP, mpz_t OP1, mpz_t OP2) + Compute the inverse of OP1 modulo OP2 and put the result in ROP. + If the inverse exists, the return value is non-zero and ROP will + satisfy 0 <= ROP < OP2. If an inverse doesn't exist the return + value is zero and ROP is undefined. + + - Function: int mpz_jacobi (mpz_t A, mpz_t B) + Calculate the Jacobi symbol (A/B). This is defined only for B odd. + + - Function: int mpz_legendre (mpz_t A, mpz_t P) + Calculate the Legendre symbol (A/P). This is defined only for P + an odd positive prime, and for such P it's identical to the Jacobi + symbol. + + - Function: int mpz_kronecker (mpz_t A, mpz_t B) + - Function: int mpz_kronecker_si (mpz_t A, long B) + - Function: int mpz_kronecker_ui (mpz_t A, unsigned long B) + - Function: int mpz_si_kronecker (long A, mpz_t B) + - Function: int mpz_ui_kronecker (unsigned long A, mpz_t B) + Calculate the Jacobi symbol (A/B) with the Kronecker extension + (a/2)=(2/a) when a odd, or (a/2)=0 when a even. + + When B is odd the Jacobi symbol and Kronecker symbol are + identical, so `mpz_kronecker_ui' etc can be used for mixed + precision Jacobi symbols too. + + For more information see Henri Cohen section 1.4.2 (*note + References::), or any number theory textbook. See also the + example program `demos/qcn.c' which uses `mpz_kronecker_ui'. + + - Function: unsigned long int mpz_remove (mpz_t ROP, mpz_t OP, mpz_t F) + Remove all occurrences of the factor F from OP and store the + result in ROP. The return value is how many such occurrences were + removed. + + - Function: void mpz_fac_ui (mpz_t ROP, unsigned long int OP) + Set ROP to OP!, the factorial of OP. + + - Function: void mpz_bin_ui (mpz_t ROP, mpz_t N, unsigned long int K) + - Function: void mpz_bin_uiui (mpz_t ROP, unsigned long int N, + unsigned long int K) + Compute the binomial coefficient N over K and store the result in + ROP. Negative values of N are supported by `mpz_bin_ui', using + the identity bin(-n,k) = (-1)^k * bin(n+k-1,k), see Knuth volume 1 + section 1.2.6 part G. + + - Function: void mpz_fib_ui (mpz_t FN, unsigned long int N) + - Function: void mpz_fib2_ui (mpz_t FN, mpz_t FNSUB1, unsigned long + int N) + `mpz_fib_ui' sets FN to to F[n], the N'th Fibonacci number. + `mpz_fib2_ui' sets FN to F[n], and FNSUB1 to F[n-1]. + + These functions are designed for calculating isolated Fibonacci + numbers. When a sequence of values is wanted it's best to start + with `mpz_fib2_ui' and iterate the defining F[n+1]=F[n]+F[n-1] or + similar. + + - Function: void mpz_lucnum_ui (mpz_t LN, unsigned long int N) + - Function: void mpz_lucnum2_ui (mpz_t LN, mpz_t LNSUB1, unsigned long + int N) + `mpz_lucnum_ui' sets LN to to L[n], the N'th Lucas number. + `mpz_lucnum2_ui' sets LN to L[n], and LNSUB1 to L[n-1]. + + These functions are designed for calculating isolated Lucas + numbers. When a sequence of values is wanted it's best to start + with `mpz_lucnum2_ui' and iterate the defining L[n+1]=L[n]+L[n-1] + or similar. + + The Fibonacci numbers and Lucas numbers are related sequences, so + it's never necessary to call both `mpz_fib2_ui' and + `mpz_lucnum2_ui'. The formulas for going from Fibonacci to Lucas + can be found in *Note Lucas Numbers Algorithm::, the reverse is + straightforward too. + + +File: gmp.info, Node: Integer Comparisons, Next: Integer Logic and Bit Fiddling, Prev: Number Theoretic Functions, Up: Integer Functions + +Comparison Functions +==================== + + - Function: int mpz_cmp (mpz_t OP1, mpz_t OP2) + - Function: int mpz_cmp_d (mpz_t OP1, double OP2) + - Macro: int mpz_cmp_si (mpz_t OP1, signed long int OP2) + - Macro: int mpz_cmp_ui (mpz_t OP1, unsigned long int OP2) + Compare OP1 and OP2. Return a positive value if OP1 > OP2, zero + if OP1 = OP2, or a negative value if OP1 < OP2. + + Note that `mpz_cmp_ui' and `mpz_cmp_si' are macros and will + evaluate their arguments more than once. + + - Function: int mpz_cmpabs (mpz_t OP1, mpz_t OP2) + - Function: int mpz_cmpabs_d (mpz_t OP1, double OP2) + - Function: int mpz_cmpabs_ui (mpz_t OP1, unsigned long int OP2) + Compare the absolute values of OP1 and OP2. Return a positive + value if abs(OP1) > abs(OP2), zero if abs(OP1) = abs(OP2), or a + negative value if abs(OP1) < abs(OP2). + + - Macro: int mpz_sgn (mpz_t OP) + Return +1 if OP > 0, 0 if OP = 0, and -1 if OP < 0. + + This function is actually implemented as a macro. It evaluates + its argument multiple times. + + +File: gmp.info, Node: Integer Logic and Bit Fiddling, Next: I/O of Integers, Prev: Integer Comparisons, Up: Integer Functions + +Logical and Bit Manipulation Functions +====================================== + +These functions behave as if twos complement arithmetic were used +(although sign-magnitude is the actual implementation). The least +significant bit is number 0. + + - Function: void mpz_and (mpz_t ROP, mpz_t OP1, mpz_t OP2) + Set ROP to OP1 bitwise-and OP2. + + - Function: void mpz_ior (mpz_t ROP, mpz_t OP1, mpz_t OP2) + Set ROP to OP1 bitwise inclusive-or OP2. + + - Function: void mpz_xor (mpz_t ROP, mpz_t OP1, mpz_t OP2) + Set ROP to OP1 bitwise exclusive-or OP2. + + - Function: void mpz_com (mpz_t ROP, mpz_t OP) + Set ROP to the one's complement of OP. + + - Function: unsigned long int mpz_popcount (mpz_t OP) + If OP>=0, return the population count of OP, which is the number + of 1 bits in the binary representation. If OP<0, the number of 1s + is infinite, and the return value is ULONG_MAX, the largest + possible `unsigned long'. + + - Function: unsigned long int mpz_hamdist (mpz_t OP1, mpz_t OP2) + If OP1 and OP2 are both >=0 or both <0, return the hamming + distance between the two operands, which is the number of bit + positions where OP1 and OP2 have different bit values. If one + operand is >=0 and the other <0 then the number of bits different + is infinite, and the return value is ULONG_MAX, the largest + possible `unsigned long'. + + - Function: unsigned long int mpz_scan0 (mpz_t OP, unsigned long int + STARTING_BIT) + - Function: unsigned long int mpz_scan1 (mpz_t OP, unsigned long int + STARTING_BIT) + Scan OP, starting from bit STARTING_BIT, towards more significant + bits, until the first 0 or 1 bit (respectively) is found. Return + the index of the found bit. + + If the bit at STARTING_BIT is already what's sought, then + STARTING_BIT is returned. + + If there's no bit found, then ULONG_MAX is returned. This will + happen in `mpz_scan0' past the end of a positive number, or + `mpz_scan1' past the end of a negative. + + - Function: void mpz_setbit (mpz_t ROP, unsigned long int BIT_INDEX) + Set bit BIT_INDEX in ROP. + + - Function: void mpz_clrbit (mpz_t ROP, unsigned long int BIT_INDEX) + Clear bit BIT_INDEX in ROP. + + - Function: int mpz_tstbit (mpz_t OP, unsigned long int BIT_INDEX) + Test bit BIT_INDEX in OP and return 0 or 1 accordingly. + + +File: gmp.info, Node: I/O of Integers, Next: Integer Random Numbers, Prev: Integer Logic and Bit Fiddling, Up: Integer Functions + +Input and Output Functions +========================== + +Functions that perform input from a stdio stream, and functions that +output to a stdio stream. Passing a `NULL' pointer for a STREAM +argument to any of these functions will make them read from `stdin' and +write to `stdout', respectively. + + When using any of these functions, it is a good idea to include +`stdio.h' before `gmp.h', since that will allow `gmp.h' to define +prototypes for these functions. + + - Function: size_t mpz_out_str (FILE *STREAM, int BASE, mpz_t OP) + Output OP on stdio stream STREAM, as a string of digits in base + BASE. The base may vary from 2 to 36. + + Return the number of bytes written, or if an error occurred, + return 0. + + - Function: size_t mpz_inp_str (mpz_t ROP, FILE *STREAM, int BASE) + Input a possibly white-space preceded string in base BASE from + stdio stream STREAM, and put the read integer in ROP. The base + may vary from 2 to 36. If BASE is 0, the actual base is + determined from the leading characters: if the first two + characters are `0x' or `0X', hexadecimal is assumed, otherwise if + the first character is `0', octal is assumed, otherwise decimal is + assumed. + + Return the number of bytes read, or if an error occurred, return 0. + + - Function: size_t mpz_out_raw (FILE *STREAM, mpz_t OP) + Output OP on stdio stream STREAM, in raw binary format. The + integer is written in a portable format, with 4 bytes of size + information, and that many bytes of limbs. Both the size and the + limbs are written in decreasing significance order (i.e., in + big-endian). + + The output can be read with `mpz_inp_raw'. + + Return the number of bytes written, or if an error occurred, + return 0. + + The output of this can not be read by `mpz_inp_raw' from GMP 1, + because of changes necessary for compatibility between 32-bit and + 64-bit machines. + + - Function: size_t mpz_inp_raw (mpz_t ROP, FILE *STREAM) + Input from stdio stream STREAM in the format written by + `mpz_out_raw', and put the result in ROP. Return the number of + bytes read, or if an error occurred, return 0. + + This routine can read the output from `mpz_out_raw' also from GMP + 1, in spite of changes necessary for compatibility between 32-bit + and 64-bit machines. + + +File: gmp.info, Node: Integer Random Numbers, Next: Integer Import and Export, Prev: I/O of Integers, Up: Integer Functions + +Random Number Functions +======================= + +The random number functions of GMP come in two groups; older function +that rely on a global state, and newer functions that accept a state +parameter that is read and modified. Please see the *Note Random +Number Functions:: for more information on how to use and not to use +random number functions. + + - Function: void mpz_urandomb (mpz_t ROP, gmp_randstate_t STATE, + unsigned long int N) + Generate a uniformly distributed random integer in the range 0 to + 2^N-1, inclusive. + + The variable STATE must be initialized by calling one of the + `gmp_randinit' functions (*Note Random State Initialization::) + before invoking this function. + + - Function: void mpz_urandomm (mpz_t ROP, gmp_randstate_t STATE, mpz_t + N) + Generate a uniform random integer in the range 0 to N-1, inclusive. + + The variable STATE must be initialized by calling one of the + `gmp_randinit' functions (*Note Random State Initialization::) + before invoking this function. + + - Function: void mpz_rrandomb (mpz_t ROP, gmp_randstate_t STATE, + unsigned long int N) + Generate a random integer with long strings of zeros and ones in + the binary representation. Useful for testing functions and + algorithms, since this kind of random numbers have proven to be + more likely to trigger corner-case bugs. The random number will + be in the range 0 to 2^N-1, inclusive. + + The variable STATE must be initialized by calling one of the + `gmp_randinit' functions (*Note Random State Initialization::) + before invoking this function. + + - Function: void mpz_random (mpz_t ROP, mp_size_t MAX_SIZE) + Generate a random integer of at most MAX_SIZE limbs. The generated + random number doesn't satisfy any particular requirements of + randomness. Negative random numbers are generated when MAX_SIZE + is negative. + + This function is obsolete. Use `mpz_urandomb' or `mpz_urandomm' + instead. + + - Function: void mpz_random2 (mpz_t ROP, mp_size_t MAX_SIZE) + Generate a random integer of at most MAX_SIZE limbs, with long + strings of zeros and ones in the binary representation. Useful + for testing functions and algorithms, since this kind of random + numbers have proven to be more likely to trigger corner-case bugs. + Negative random numbers are generated when MAX_SIZE is negative. + + This function is obsolete. Use `mpz_rrandomb' instead. + + +File: gmp.info, Node: Integer Import and Export, Next: Miscellaneous Integer Functions, Prev: Integer Random Numbers, Up: Integer Functions + +Integer Import and Export +========================= + +`mpz_t' variables can be converted to and from arbitrary words of binary +data with the following functions. + + - Function: void mpz_import (mpz_t ROP, size_t COUNT, int ORDER, int + SIZE, int ENDIAN, size_t NAILS, const void *OP) + Set ROP from an array of word data at OP. + + The parameters specify the format of the data. COUNT many words + are read, each SIZE bytes. ORDER can be 1 for most significant + word first or -1 for least significant first. Within each word + ENDIAN can be 1 for most significant byte first, -1 for least + significant first, or 0 for the native endianness of the host CPU. + The most significant NAILS bits of each word are skipped, this + can be 0 to use the full words. + + There is no sign taken from the data, ROP will simply be a positive + integer. An application can handle any sign itself, and apply it + for instance with `mpz_neg'. + + There are no data alignment restrictions on OP, any address is + allowed. + + Here's an example converting an array of `unsigned long' data, most + significant element first, and host byte order within each value. + + unsigned long a[20]; + mpz_t z; + mpz_import (z, 20, 1, sizeof(a[0]), 0, 0, a); + + This example assumes the full `sizeof' bytes are used for data in + the given type, which is usually true, and certainly true for + `unsigned long' everywhere we know of. However on Cray vector + systems it may be noted that `short' and `int' are always stored + in 8 bytes (and with `sizeof' indicating that) but use only 32 or + 46 bits. The NAILS feature can account for this, by passing for + instance `8*sizeof(int)-INT_BIT'. + + - Function: void * mpz_export (void *ROP, size_t *COUNTP, int ORDER, + int SIZE, int ENDIAN, size_t NAILS, mpz_t OP) + Fill ROP with word data from OP. + + The parameters specify the format of the data produced. Each word + will be SIZE bytes and ORDER can be 1 for most significant word + first or -1 for least significant first. Within each word ENDIAN + can be 1 for most significant byte first, -1 for least significant + first, or 0 for the native endianness of the host CPU. The most + significant NAILS bits of each word are unused and set to zero, + this can be 0 to produce full words. + + The number of words produced is written to `*COUNTP', or COUNTP + can be `NULL' to discard the count. ROP must have enough space + for the data, or if ROP is `NULL' then a result array of the + necessary size is allocated using the current GMP allocation + function (*note Custom Allocation::). In either case the return + value is the destination used, either ROP or the allocated block. + + If OP is non-zero then the most significant word produced will be + non-zero. If OP is zero then the count returned will be zero and + nothing written to ROP. If ROP is `NULL' in this case, no block + is allocated, just `NULL' is returned. + + The sign of OP is ignored, just the absolute value is exported. An + application can use `mpz_sgn' to get the sign and handle it as + desired. (*note Integer Comparisons::) + + There are no data alignment restrictions on ROP, any address is + allowed. + + When an application is allocating space itself the required size + can be determined with a calculation like the following. Since + `mpz_sizeinbase' always returns at least 1, `count' here will be + at least one, which avoids any portability problems with + `malloc(0)', though if `z' is zero no space at all is actually + needed (or written). + + numb = 8*size - nail; + count = (mpz_sizeinbase (z, 2) + numb-1) / numb; + p = malloc (count * size); + + +File: gmp.info, Node: Miscellaneous Integer Functions, Prev: Integer Import and Export, Up: Integer Functions + +Miscellaneous Functions +======================= + + - Function: int mpz_fits_ulong_p (mpz_t OP) + - Function: int mpz_fits_slong_p (mpz_t OP) + - Function: int mpz_fits_uint_p (mpz_t OP) + - Function: int mpz_fits_sint_p (mpz_t OP) + - Function: int mpz_fits_ushort_p (mpz_t OP) + - Function: int mpz_fits_sshort_p (mpz_t OP) + Return non-zero iff the value of OP fits in an `unsigned long int', + `signed long int', `unsigned int', `signed int', `unsigned short + int', or `signed short int', respectively. Otherwise, return zero. + + - Macro: int mpz_odd_p (mpz_t OP) + - Macro: int mpz_even_p (mpz_t OP) + Determine whether OP is odd or even, respectively. Return + non-zero if yes, zero if no. These macros evaluate their argument + more than once. + + - Function: size_t mpz_size (mpz_t OP) + Return the size of OP measured in number of limbs. If OP is zero, + the returned value will be zero. + + - Function: size_t mpz_sizeinbase (mpz_t OP, int BASE) + Return the size of OP measured in number of digits in the given + BASE. BASE can vary from 2 to 36. The sign of OP is ignored, + just the absolute value is used. The result will be either exact + or 1 too big. If BASE is a power of 2, the result is always + exact. If OP is zero the return value is always 1. + + This function can be used to determine the space required when + converting OP to a string. The right amount of allocation is + normally two more than the value returned by `mpz_sizeinbase', one + extra for a minus sign and one for the null-terminator. + + It will be noted that `mpz_sizeinbase(OP,2)' can be used to locate + the most significant 1 bit in OP, counting from 1. (Unlike the + bitwise functions which start from 0, *Note Logical and Bit + Manipulation Functions: Integer Logic and Bit Fiddling.) + + +File: gmp.info, Node: Rational Number Functions, Next: Floating-point Functions, Prev: Integer Functions, Up: Top + +Rational Number Functions +************************* + +This chapter describes the GMP functions for performing arithmetic on +rational numbers. These functions start with the prefix `mpq_'. + + Rational numbers are stored in objects of type `mpq_t'. + + All rational arithmetic functions assume operands have a canonical +form, and canonicalize their result. The canonical from means that the +denominator and the numerator have no common factors, and that the +denominator is positive. Zero has the unique representation 0/1. + + Pure assignment functions do not canonicalize the assigned variable. +It is the responsibility of the user to canonicalize the assigned +variable before any arithmetic operations are performed on that +variable. + + - Function: void mpq_canonicalize (mpq_t OP) + Remove any factors that are common to the numerator and + denominator of OP, and make the denominator positive. + +* Menu: + +* Initializing Rationals:: +* Rational Conversions:: +* Rational Arithmetic:: +* Comparing Rationals:: +* Applying Integer Functions:: +* I/O of Rationals:: + + +File: gmp.info, Node: Initializing Rationals, Next: Rational Conversions, Prev: Rational Number Functions, Up: Rational Number Functions + +Initialization and Assignment Functions +======================================= + + - Function: void mpq_init (mpq_t DEST_RATIONAL) + Initialize DEST_RATIONAL and set it to 0/1. Each variable should + normally only be initialized once, or at least cleared out (using + the function `mpq_clear') between each initialization. + + - Function: void mpq_clear (mpq_t RATIONAL_NUMBER) + Free the space occupied by RATIONAL_NUMBER. Make sure to call this + function for all `mpq_t' variables when you are done with them. + + - Function: void mpq_set (mpq_t ROP, mpq_t OP) + - Function: void mpq_set_z (mpq_t ROP, mpz_t OP) + Assign ROP from OP. + + - Function: void mpq_set_ui (mpq_t ROP, unsigned long int OP1, + unsigned long int OP2) + - Function: void mpq_set_si (mpq_t ROP, signed long int OP1, unsigned + long int OP2) + Set the value of ROP to OP1/OP2. Note that if OP1 and OP2 have + common factors, ROP has to be passed to `mpq_canonicalize' before + any operations are performed on ROP. + + - Function: int mpq_set_str (mpq_t ROP, char *STR, int BASE) + Set ROP from a null-terminated string STR in the given BASE. + + The string can be an integer like "41" or a fraction like + "41/152". The fraction must be in canonical form (*note Rational + Number Functions::), or if not then `mpq_canonicalize' must be + called. + + The numerator and optional denominator are parsed the same as in + `mpz_set_str' (*note Assigning Integers::). White space is + allowed in the string, and is simply ignored. The BASE can vary + from 2 to 36, or if BASE is 0 then the leading characters are + used: `0x' for hex, `0' for octal, or decimal otherwise. Note + that this is done separately for the numerator and denominator, so + for instance `0xEF/100' is 239/100, whereas `0xEF/0x100' is + 239/256. + + The return value is 0 if the entire string is a valid number, or + -1 if not. + + - Function: void mpq_swap (mpq_t ROP1, mpq_t ROP2) + Swap the values ROP1 and ROP2 efficiently. + + +File: gmp.info, Node: Rational Conversions, Next: Rational Arithmetic, Prev: Initializing Rationals, Up: Rational Number Functions + +Conversion Functions +==================== + + - Function: double mpq_get_d (mpq_t OP) + Convert OP to a `double'. + + - Function: void mpq_set_d (mpq_t ROP, double OP) + - Function: void mpq_set_f (mpq_t ROP, mpf_t OP) + Set ROP to the value of OP, without rounding. + + - Function: char * mpq_get_str (char *STR, int BASE, mpq_t OP) + Convert OP to a string of digits in base BASE. The base may vary + from 2 to 36. The string will be of the form `num/den', or if the + denominator is 1 then just `num'. + + If STR is `NULL', the result string is allocated using the current + allocation function (*note Custom Allocation::). The block will be + `strlen(str)+1' bytes, that being exactly enough for the string and + null-terminator. + + If STR is not `NULL', it should point to a block of storage large + enough for the result, that being + + mpz_sizeinbase (mpq_numref(OP), BASE) + + mpz_sizeinbase (mpq_denref(OP), BASE) + 3 + + The three extra bytes are for a possible minus sign, possible + slash, and the null-terminator. + + A pointer to the result string is returned, being either the + allocated block, or the given STR. + + +File: gmp.info, Node: Rational Arithmetic, Next: Comparing Rationals, Prev: Rational Conversions, Up: Rational Number Functions + +Arithmetic Functions +==================== + + - Function: void mpq_add (mpq_t SUM, mpq_t ADDEND1, mpq_t ADDEND2) + Set SUM to ADDEND1 + ADDEND2. + + - Function: void mpq_sub (mpq_t DIFFERENCE, mpq_t MINUEND, mpq_t + SUBTRAHEND) + Set DIFFERENCE to MINUEND - SUBTRAHEND. + + - Function: void mpq_mul (mpq_t PRODUCT, mpq_t MULTIPLIER, mpq_t + MULTIPLICAND) + Set PRODUCT to MULTIPLIER times MULTIPLICAND. + + - Function: void mpq_mul_2exp (mpq_t ROP, mpq_t OP1, unsigned long int + OP2) + Set ROP to OP1 times 2 raised to OP2. + + - Function: void mpq_div (mpq_t QUOTIENT, mpq_t DIVIDEND, mpq_t + DIVISOR) + Set QUOTIENT to DIVIDEND/DIVISOR. + + - Function: void mpq_div_2exp (mpq_t ROP, mpq_t OP1, unsigned long int + OP2) + Set ROP to OP1 divided by 2 raised to OP2. + + - Function: void mpq_neg (mpq_t NEGATED_OPERAND, mpq_t OPERAND) + Set NEGATED_OPERAND to -OPERAND. + + - Function: void mpq_abs (mpq_t ROP, mpq_t OP) + Set ROP to the absolute value of OP. + + - Function: void mpq_inv (mpq_t INVERTED_NUMBER, mpq_t NUMBER) + Set INVERTED_NUMBER to 1/NUMBER. If the new denominator is zero, + this routine will divide by zero. + + +File: gmp.info, Node: Comparing Rationals, Next: Applying Integer Functions, Prev: Rational Arithmetic, Up: Rational Number Functions + +Comparison Functions +==================== + + - Function: int mpq_cmp (mpq_t OP1, mpq_t OP2) + Compare OP1 and OP2. Return a positive value if OP1 > OP2, zero + if OP1 = OP2, and a negative value if OP1 < OP2. + + To determine if two rationals are equal, `mpq_equal' is faster than + `mpq_cmp'. + + - Macro: int mpq_cmp_ui (mpq_t OP1, unsigned long int NUM2, unsigned + long int DEN2) + - Macro: int mpq_cmp_si (mpq_t OP1, long int NUM2, unsigned long int + DEN2) + Compare OP1 and NUM2/DEN2. Return a positive value if OP1 > + NUM2/DEN2, zero if OP1 = NUM2/DEN2, and a negative value if OP1 < + NUM2/DEN2. + + NUM2 and DEN2 are allowed to have common factors. + + These functions are implemented as a macros and evaluate their + arguments multiple times. + + - Macro: int mpq_sgn (mpq_t OP) + Return +1 if OP > 0, 0 if OP = 0, and -1 if OP < 0. + + This function is actually implemented as a macro. It evaluates its + arguments multiple times. + + - Function: int mpq_equal (mpq_t OP1, mpq_t OP2) + Return non-zero if OP1 and OP2 are equal, zero if they are + non-equal. Although `mpq_cmp' can be used for the same purpose, + this function is much faster. + + +File: gmp.info, Node: Applying Integer Functions, Next: I/O of Rationals, Prev: Comparing Rationals, Up: Rational Number Functions + +Applying Integer Functions to Rationals +======================================= + +The set of `mpq' functions is quite small. In particular, there are few +functions for either input or output. The following functions give +direct access to the numerator and denominator of an `mpq_t'. + + Note that if an assignment to the numerator and/or denominator could +take an `mpq_t' out of the canonical form described at the start of +this chapter (*note Rational Number Functions::) then +`mpq_canonicalize' must be called before any other `mpq' functions are +applied to that `mpq_t'. + + - Macro: mpz_t mpq_numref (mpq_t OP) + - Macro: mpz_t mpq_denref (mpq_t OP) + Return a reference to the numerator and denominator of OP, + respectively. The `mpz' functions can be used on the result of + these macros. + + - Function: void mpq_get_num (mpz_t NUMERATOR, mpq_t RATIONAL) + - Function: void mpq_get_den (mpz_t DENOMINATOR, mpq_t RATIONAL) + - Function: void mpq_set_num (mpq_t RATIONAL, mpz_t NUMERATOR) + - Function: void mpq_set_den (mpq_t RATIONAL, mpz_t DENOMINATOR) + Get or set the numerator or denominator of a rational. These + functions are equivalent to calling `mpz_set' with an appropriate + `mpq_numref' or `mpq_denref'. Direct use of `mpq_numref' or + `mpq_denref' is recommended instead of these functions. + + +File: gmp.info, Node: I/O of Rationals, Prev: Applying Integer Functions, Up: Rational Number Functions + +Input and Output Functions +========================== + +When using any of these functions, it's a good idea to include `stdio.h' +before `gmp.h', since that will allow `gmp.h' to define prototypes for +these functions. + + Passing a `NULL' pointer for a STREAM argument to any of these +functions will make them read from `stdin' and write to `stdout', +respectively. + + - Function: size_t mpq_out_str (FILE *STREAM, int BASE, mpq_t OP) + Output OP on stdio stream STREAM, as a string of digits in base + BASE. The base may vary from 2 to 36. Output is in the form + `num/den' or if the denominator is 1 then just `num'. + + Return the number of bytes written, or if an error occurred, + return 0. + + - Function: size_t mpq_inp_str (mpq_t ROP, FILE *STREAM, int BASE) + Read a string of digits from STREAM and convert them to a rational + in ROP. Any initial white-space characters are read and + discarded. Return the number of characters read (including white + space), or 0 if a rational could not be read. + + The input can be a fraction like `17/63' or just an integer like + `123'. Reading stops at the first character not in this form, and + white space is not permitted within the string. If the input + might not be in canonical form, then `mpq_canonicalize' must be + called (*note Rational Number Functions::). + + The BASE can be between 2 and 36, or can be 0 in which case the + leading characters of the string determine the base, `0x' or `0X' + for hexadecimal, `0' for octal, or decimal otherwise. The leading + characters are examined separately for the numerator and + denominator of a fraction, so for instance `0x10/11' is 16/11, + whereas `0x10/0x11' is 16/17. + + +File: gmp.info, Node: Floating-point Functions, Next: Low-level Functions, Prev: Rational Number Functions, Up: Top + +Floating-point Functions +************************ + +GMP floating point numbers are stored in objects of type `mpf_t' and +functions operating on them have an `mpf_' prefix. + + The mantissa of each float has a user-selectable precision, limited +only by available memory. Each variable has its own precision, and +that can be increased or decreased at any time. + + The exponent of each float is a fixed precision, one machine word on +most systems. In the current implementation the exponent is a count of +limbs, so for example on a 32-bit system this means a range of roughly +2^-68719476768 to 2^68719476736, or on a 64-bit system this will be +greater. Note however `mpf_get_str' can only return an exponent which +fits an `mp_exp_t' and currently `mpf_set_str' doesn't accept exponents +bigger than a `long'. + + Each variable keeps a size for the mantissa data actually in use. +This means that if a float is exactly represented in only a few bits +then only those bits will be used in a calculation, even if the +selected precision is high. + + All calculations are performed to the precision of the destination +variable. Each function is defined to calculate with "infinite +precision" followed by a truncation to the destination precision, but +of course the work done is only what's needed to determine a result +under that definition. + + The precision selected for a variable is a minimum value, GMP may +increase it a little to facilitate efficient calculation. Currently +this means rounding up to a whole limb, and then sometimes having a +further partial limb, depending on the high limb of the mantissa. But +applications shouldn't be concerned by such details. + + The mantissa in stored in binary, as might be imagined from the fact +precisions are expressed in bits. One consequence of this is that +decimal fractions like 0.1 cannot be represented exactly. The same is +true of plain IEEE `double' floats. This makes both highly unsuitable +for calculations involving money or other values that should be exact +decimal fractions. (Suitably scaled integers, or perhaps rationals, +are better choices.) + + `mpf' functions and variables have no special notion of infinity or +not-a-number, and applications must take care not to overflow the +exponent or results will be unpredictable. This might change in a +future release. + + Note that the `mpf' functions are _not_ intended as a smooth +extension to IEEE P754 arithmetic. In particular results obtained on +one computer often differ from the results on a computer with a +different word size. + +* Menu: + +* Initializing Floats:: +* Assigning Floats:: +* Simultaneous Float Init & Assign:: +* Converting Floats:: +* Float Arithmetic:: +* Float Comparison:: +* I/O of Floats:: +* Miscellaneous Float Functions:: + + +File: gmp.info, Node: Initializing Floats, Next: Assigning Floats, Prev: Floating-point Functions, Up: Floating-point Functions + +Initialization Functions +======================== + + - Function: void mpf_set_default_prec (unsigned long int PREC) + Set the default precision to be *at least* PREC bits. All + subsequent calls to `mpf_init' will use this precision, but + previously initialized variables are unaffected. + + - Function: unsigned long int mpf_get_default_prec (void) + Return the default default precision actually used. + + An `mpf_t' object must be initialized before storing the first value +in it. The functions `mpf_init' and `mpf_init2' are used for that +purpose. + + - Function: void mpf_init (mpf_t X) + Initialize X to 0. Normally, a variable should be initialized + once only or at least be cleared, using `mpf_clear', between + initializations. The precision of X is undefined unless a default + precision has already been established by a call to + `mpf_set_default_prec'. + + - Function: void mpf_init2 (mpf_t X, unsigned long int PREC) + Initialize X to 0 and set its precision to be *at least* PREC + bits. Normally, a variable should be initialized once only or at + least be cleared, using `mpf_clear', between initializations. + + - Function: void mpf_clear (mpf_t X) + Free the space occupied by X. Make sure to call this function for + all `mpf_t' variables when you are done with them. + + Here is an example on how to initialize floating-point variables: + { + mpf_t x, y; + mpf_init (x); /* use default precision */ + mpf_init2 (y, 256); /* precision _at least_ 256 bits */ + ... + /* Unless the program is about to exit, do ... */ + mpf_clear (x); + mpf_clear (y); + } + + The following three functions are useful for changing the precision +during a calculation. A typical use would be for adjusting the +precision gradually in iterative algorithms like Newton-Raphson, making +the computation precision closely match the actual accurate part of the +numbers. + + - Function: unsigned long int mpf_get_prec (mpf_t OP) + Return the current precision of OP, in bits. + + - Function: void mpf_set_prec (mpf_t ROP, unsigned long int PREC) + Set the precision of ROP to be *at least* PREC bits. The value in + ROP will be truncated to the new precision. + + This function requires a call to `realloc', and so should not be + used in a tight loop. + + - Function: void mpf_set_prec_raw (mpf_t ROP, unsigned long int PREC) + Set the precision of ROP to be *at least* PREC bits, without + changing the memory allocated. + + PREC must be no more than the allocated precision for ROP, that + being the precision when ROP was initialized, or in the most recent + `mpf_set_prec'. + + The value in ROP is unchanged, and in particular if it had a higher + precision than PREC it will retain that higher precision. New + values written to ROP will use the new PREC. + + Before calling `mpf_clear' or the full `mpf_set_prec', another + `mpf_set_prec_raw' call must be made to restore ROP to its original + allocated precision. Failing to do so will have unpredictable + results. + + `mpf_get_prec' can be used before `mpf_set_prec_raw' to get the + original allocated precision. After `mpf_set_prec_raw' it + reflects the PREC value set. + + `mpf_set_prec_raw' is an efficient way to use an `mpf_t' variable + at different precisions during a calculation, perhaps to gradually + increase precision in an iteration, or just to use various + different precisions for different purposes during a calculation. + + +File: gmp.info, Node: Assigning Floats, Next: Simultaneous Float Init & Assign, Prev: Initializing Floats, Up: Floating-point Functions + +Assignment Functions +==================== + +These functions assign new values to already initialized floats (*note +Initializing Floats::). + + - Function: void mpf_set (mpf_t ROP, mpf_t OP) + - Function: void mpf_set_ui (mpf_t ROP, unsigned long int OP) + - Function: void mpf_set_si (mpf_t ROP, signed long int OP) + - Function: void mpf_set_d (mpf_t ROP, double OP) + - Function: void mpf_set_z (mpf_t ROP, mpz_t OP) + - Function: void mpf_set_q (mpf_t ROP, mpq_t OP) + Set the value of ROP from OP. + + - Function: int mpf_set_str (mpf_t ROP, char *STR, int BASE) + Set the value of ROP from the string in STR. The string is of the + form `M@N' or, if the base is 10 or less, alternatively `MeN'. + `M' is the mantissa and `N' is the exponent. The mantissa is + always in the specified base. The exponent is either in the + specified base or, if BASE is negative, in decimal. The decimal + point expected is taken from the current locale, on systems + providing `localeconv'. + + The argument BASE may be in the ranges 2 to 36, or -36 to -2. + Negative values are used to specify that the exponent is in + decimal. + + Unlike the corresponding `mpz' function, the base will not be + determined from the leading characters of the string if BASE is 0. + This is so that numbers like `0.23' are not interpreted as octal. + + White space is allowed in the string, and is simply ignored. + [This is not really true; white-space is ignored in the beginning + of the string and within the mantissa, but not in other places, + such as after a minus sign or in the exponent. We are considering + changing the definition of this function, making it fail when + there is any white-space in the input, since that makes a lot of + sense. Please tell us your opinion about this change. Do you + really want it to accept "3 14" as meaning 314 as it does now?] + + This function returns 0 if the entire string is a valid number in + base BASE. Otherwise it returns -1. + + - Function: void mpf_swap (mpf_t ROP1, mpf_t ROP2) + Swap ROP1 and ROP2 efficiently. Both the values and the + precisions of the two variables are swapped. + + +File: gmp.info, Node: Simultaneous Float Init & Assign, Next: Converting Floats, Prev: Assigning Floats, Up: Floating-point Functions + +Combined Initialization and Assignment Functions +================================================ + +For convenience, GMP provides a parallel series of initialize-and-set +functions which initialize the output and then store the value there. +These functions' names have the form `mpf_init_set...' + + Once the float has been initialized by any of the `mpf_init_set...' +functions, it can be used as the source or destination operand for the +ordinary float functions. Don't use an initialize-and-set function on +a variable already initialized! + + - Function: void mpf_init_set (mpf_t ROP, mpf_t OP) + - Function: void mpf_init_set_ui (mpf_t ROP, unsigned long int OP) + - Function: void mpf_init_set_si (mpf_t ROP, signed long int OP) + - Function: void mpf_init_set_d (mpf_t ROP, double OP) + Initialize ROP and set its value from OP. + + The precision of ROP will be taken from the active default + precision, as set by `mpf_set_default_prec'. + + - Function: int mpf_init_set_str (mpf_t ROP, char *STR, int BASE) + Initialize ROP and set its value from the string in STR. See + `mpf_set_str' above for details on the assignment operation. + + Note that ROP is initialized even if an error occurs. (I.e., you + have to call `mpf_clear' for it.) + + The precision of ROP will be taken from the active default + precision, as set by `mpf_set_default_prec'. + + +File: gmp.info, Node: Converting Floats, Next: Float Arithmetic, Prev: Simultaneous Float Init & Assign, Up: Floating-point Functions + +Conversion Functions +==================== + + - Function: double mpf_get_d (mpf_t OP) + Convert OP to a `double'. + + - Function: double mpf_get_d_2exp (signed long int *EXP, mpf_t OP) + Find D and EXP such that D times 2 raised to EXP, with + 0.5<=abs(D)<1, is a good approximation to OP. This is similar to + the standard C function `frexp'. + + - Function: long mpf_get_si (mpf_t OP) + - Function: unsigned long mpf_get_ui (mpf_t OP) + Convert OP to a `long' or `unsigned long', truncating any fraction + part. If OP is too big for the return type, the result is + undefined. + + See also `mpf_fits_slong_p' and `mpf_fits_ulong_p' (*note + Miscellaneous Float Functions::). + + - Function: char * mpf_get_str (char *STR, mp_exp_t *EXPPTR, int BASE, + size_t N_DIGITS, mpf_t OP) + Convert OP to a string of digits in base BASE. BASE can be 2 to + 36. Up to N_DIGITS digits will be generated. Trailing zeros are + not returned. No more digits than can be accurately represented + by OP are ever generated. If N_DIGITS is 0 then that accurate + maximum number of digits are generated. + + If STR is `NULL', the result string is allocated using the current + allocation function (*note Custom Allocation::). The block will be + `strlen(str)+1' bytes, that being exactly enough for the string and + null-terminator. + + If STR is not `NULL', it should point to a block of N_DIGITS + 2 + bytes, that being enough for the mantissa, a possible minus sign, + and a null-terminator. When N_DIGITS is 0 to get all significant + digits, an application won't be able to know the space required, + and STR should be `NULL' in that case. + + The generated string is a fraction, with an implicit radix point + immediately to the left of the first digit. The applicable + exponent is written through the EXPPTR pointer. For example, the + number 3.1416 would be returned as string "31416" and exponent 1. + + When OP is zero, an empty string is produced and the exponent + returned is 0. + + A pointer to the result string is returned, being either the + allocated block or the given STR. + + +File: gmp.info, Node: Float Arithmetic, Next: Float Comparison, Prev: Converting Floats, Up: Floating-point Functions + +Arithmetic Functions +==================== + + - Function: void mpf_add (mpf_t ROP, mpf_t OP1, mpf_t OP2) + - Function: void mpf_add_ui (mpf_t ROP, mpf_t OP1, unsigned long int + OP2) + Set ROP to OP1 + OP2. + + - Function: void mpf_sub (mpf_t ROP, mpf_t OP1, mpf_t OP2) + - Function: void mpf_ui_sub (mpf_t ROP, unsigned long int OP1, mpf_t + OP2) + - Function: void mpf_sub_ui (mpf_t ROP, mpf_t OP1, unsigned long int + OP2) + Set ROP to OP1 - OP2. + + - Function: void mpf_mul (mpf_t ROP, mpf_t OP1, mpf_t OP2) + - Function: void mpf_mul_ui (mpf_t ROP, mpf_t OP1, unsigned long int + OP2) + Set ROP to OP1 times OP2. + + Division is undefined if the divisor is zero, and passing a zero +divisor to the divide functions will make these functions intentionally +divide by zero. This lets the user handle arithmetic exceptions in +these functions in the same manner as other arithmetic exceptions. + + - Function: void mpf_div (mpf_t ROP, mpf_t OP1, mpf_t OP2) + - Function: void mpf_ui_div (mpf_t ROP, unsigned long int OP1, mpf_t + OP2) + - Function: void mpf_div_ui (mpf_t ROP, mpf_t OP1, unsigned long int + OP2) + Set ROP to OP1/OP2. + + - Function: void mpf_sqrt (mpf_t ROP, mpf_t OP) + - Function: void mpf_sqrt_ui (mpf_t ROP, unsigned long int OP) + Set ROP to the square root of OP. + + - Function: void mpf_pow_ui (mpf_t ROP, mpf_t OP1, unsigned long int + OP2) + Set ROP to OP1 raised to the power OP2. + + - Function: void mpf_neg (mpf_t ROP, mpf_t OP) + Set ROP to -OP. + + - Function: void mpf_abs (mpf_t ROP, mpf_t OP) + Set ROP to the absolute value of OP. + + - Function: void mpf_mul_2exp (mpf_t ROP, mpf_t OP1, unsigned long int + OP2) + Set ROP to OP1 times 2 raised to OP2. + + - Function: void mpf_div_2exp (mpf_t ROP, mpf_t OP1, unsigned long int + OP2) + Set ROP to OP1 divided by 2 raised to OP2. + + +File: gmp.info, Node: Float Comparison, Next: I/O of Floats, Prev: Float Arithmetic, Up: Floating-point Functions + +Comparison Functions +==================== + + - Function: int mpf_cmp (mpf_t OP1, mpf_t OP2) + - Function: int mpf_cmp_d (mpf_t OP1, double OP2) + - Function: int mpf_cmp_ui (mpf_t OP1, unsigned long int OP2) + - Function: int mpf_cmp_si (mpf_t OP1, signed long int OP2) + Compare OP1 and OP2. Return a positive value if OP1 > OP2, zero + if OP1 = OP2, and a negative value if OP1 < OP2. + + - Function: int mpf_eq (mpf_t OP1, mpf_t OP2, unsigned long int op3) + Return non-zero if the first OP3 bits of OP1 and OP2 are equal, + zero otherwise. I.e., test of OP1 and OP2 are approximately equal. + + Caution: Currently only whole limbs are compared, and only in an + exact fashion. In the future values like 1000 and 0111 may be + considered the same to 3 bits (on the basis that their difference + is that small). + + - Function: void mpf_reldiff (mpf_t ROP, mpf_t OP1, mpf_t OP2) + Compute the relative difference between OP1 and OP2 and store the + result in ROP. This is abs(OP1-OP2)/OP1. + + - Macro: int mpf_sgn (mpf_t OP) + Return +1 if OP > 0, 0 if OP = 0, and -1 if OP < 0. + + This function is actually implemented as a macro. It evaluates + its arguments multiple times. + + +File: gmp.info, Node: I/O of Floats, Next: Miscellaneous Float Functions, Prev: Float Comparison, Up: Floating-point Functions + +Input and Output Functions +========================== + +Functions that perform input from a stdio stream, and functions that +output to a stdio stream. Passing a `NULL' pointer for a STREAM +argument to any of these functions will make them read from `stdin' and +write to `stdout', respectively. + + When using any of these functions, it is a good idea to include +`stdio.h' before `gmp.h', since that will allow `gmp.h' to define +prototypes for these functions. + + - Function: size_t mpf_out_str (FILE *STREAM, int BASE, size_t + N_DIGITS, mpf_t OP) + Print OP to STREAM, as a string of digits. Return the number of + bytes written, or if an error occurred, return 0. + + The mantissa is prefixed with an `0.' and is in the given BASE, + which may vary from 2 to 36. An exponent then printed, separated + by an `e', or if BASE is greater than 10 then by an `@'. The + exponent is always in decimal. The decimal point follows the + current locale, on systems providing `localeconv'. + + Up to N_DIGITS will be printed from the mantissa, except that no + more digits than are accurately representable by OP will be + printed. N_DIGITS can be 0 to select that accurate maximum. + + - Function: size_t mpf_inp_str (mpf_t ROP, FILE *STREAM, int BASE) + Read a string in base BASE from STREAM, and put the read float in + ROP. The string is of the form `M@N' or, if the base is 10 or + less, alternatively `MeN'. `M' is the mantissa and `N' is the + exponent. The mantissa is always in the specified base. The + exponent is either in the specified base or, if BASE is negative, + in decimal. The decimal point expected is taken from the current + locale, on systems providing `localeconv'. + + The argument BASE may be in the ranges 2 to 36, or -36 to -2. + Negative values are used to specify that the exponent is in + decimal. + + Unlike the corresponding `mpz' function, the base will not be + determined from the leading characters of the string if BASE is 0. + This is so that numbers like `0.23' are not interpreted as octal. + + Return the number of bytes read, or if an error occurred, return 0. + + +File: gmp.info, Node: Miscellaneous Float Functions, Prev: I/O of Floats, Up: Floating-point Functions + +Miscellaneous Functions +======================= + + - Function: void mpf_ceil (mpf_t ROP, mpf_t OP) + - Function: void mpf_floor (mpf_t ROP, mpf_t OP) + - Function: void mpf_trunc (mpf_t ROP, mpf_t OP) + Set ROP to OP rounded to an integer. `mpf_ceil' rounds to the + next higher integer, `mpf_floor' to the next lower, and `mpf_trunc' + to the integer towards zero. + + - Function: int mpf_integer_p (mpf_t OP) + Return non-zero if OP is an integer. + + - Function: int mpf_fits_ulong_p (mpf_t OP) + - Function: int mpf_fits_slong_p (mpf_t OP) + - Function: int mpf_fits_uint_p (mpf_t OP) + - Function: int mpf_fits_sint_p (mpf_t OP) + - Function: int mpf_fits_ushort_p (mpf_t OP) + - Function: int mpf_fits_sshort_p (mpf_t OP) + Return non-zero if OP would fit in the respective C data type, when + truncated to an integer. + + - Function: void mpf_urandomb (mpf_t ROP, gmp_randstate_t STATE, + unsigned long int NBITS) + Generate a uniformly distributed random float in ROP, such that 0 + <= ROP < 1, with NBITS significant bits in the mantissa. + + The variable STATE must be initialized by calling one of the + `gmp_randinit' functions (*Note Random State Initialization::) + before invoking this function. + + - Function: void mpf_random2 (mpf_t ROP, mp_size_t MAX_SIZE, mp_exp_t + EXP) + Generate a random float of at most MAX_SIZE limbs, with long + strings of zeros and ones in the binary representation. The + exponent of the number is in the interval -EXP to EXP (in limbs). + This function is useful for testing functions and algorithms, + since these kind of random numbers have proven to be more likely + to trigger corner-case bugs. Negative random numbers are + generated when MAX_SIZE is negative. + + +File: gmp.info, Node: Low-level Functions, Next: Random Number Functions, Prev: Floating-point Functions, Up: Top + +Low-level Functions +******************* + +This chapter describes low-level GMP functions, used to implement the +high-level GMP functions, but also intended for time-critical user code. + + These functions start with the prefix `mpn_'. + + The `mpn' functions are designed to be as fast as possible, *not* to +provide a coherent calling interface. The different functions have +somewhat similar interfaces, but there are variations that make them +hard to use. These functions do as little as possible apart from the +real multiple precision computation, so that no time is spent on things +that not all callers need. + + A source operand is specified by a pointer to the least significant +limb and a limb count. A destination operand is specified by just a +pointer. It is the responsibility of the caller to ensure that the +destination has enough space for storing the result. + + With this way of specifying operands, it is possible to perform +computations on subranges of an argument, and store the result into a +subrange of a destination. + + A common requirement for all functions is that each source area +needs at least one limb. No size argument may be zero. Unless +otherwise stated, in-place operations are allowed where source and +destination are the same, but not where they only partly overlap. + + The `mpn' functions are the base for the implementation of the +`mpz_', `mpf_', and `mpq_' functions. + + This example adds the number beginning at S1P and the number +beginning at S2P and writes the sum at DESTP. All areas have N limbs. + + cy = mpn_add_n (destp, s1p, s2p, n) + +In the notation used here, a source operand is identified by the +pointer to the least significant limb, and the limb count in braces. +For example, {S1P, S1N}. + + - Function: mp_limb_t mpn_add_n (mp_limb_t *RP, const mp_limb_t *S1P, + const mp_limb_t *S2P, mp_size_t N) + Add {S1P, N} and {S2P, N}, and write the N least significant limbs + of the result to RP. Return carry, either 0 or 1. + + This is the lowest-level function for addition. It is the + preferred function for addition, since it is written in assembly + for most CPUs. For addition of a variable to itself (i.e., S1P + equals S2P, use `mpn_lshift' with a count of 1 for optimal speed. + + - Function: mp_limb_t mpn_add_1 (mp_limb_t *RP, const mp_limb_t *S1P, + mp_size_t N, mp_limb_t S2LIMB) + Add {S1P, N} and S2LIMB, and write the N least significant limbs + of the result to RP. Return carry, either 0 or 1. + + - Function: mp_limb_t mpn_add (mp_limb_t *RP, const mp_limb_t *S1P, + mp_size_t S1N, const mp_limb_t *S2P, mp_size_t S2N) + Add {S1P, S1N} and {S2P, S2N}, and write the S1N least significant + limbs of the result to RP. Return carry, either 0 or 1. + + This function requires that S1N is greater than or equal to S2N. + + - Function: mp_limb_t mpn_sub_n (mp_limb_t *RP, const mp_limb_t *S1P, + const mp_limb_t *S2P, mp_size_t N) + Subtract {S2P, N} from {S1P, N}, and write the N least significant + limbs of the result to RP. Return borrow, either 0 or 1. + + This is the lowest-level function for subtraction. It is the + preferred function for subtraction, since it is written in + assembly for most CPUs. + + - Function: mp_limb_t mpn_sub_1 (mp_limb_t *RP, const mp_limb_t *S1P, + mp_size_t N, mp_limb_t S2LIMB) + Subtract S2LIMB from {S1P, N}, and write the N least significant + limbs of the result to RP. Return borrow, either 0 or 1. + + - Function: mp_limb_t mpn_sub (mp_limb_t *RP, const mp_limb_t *S1P, + mp_size_t S1N, const mp_limb_t *S2P, mp_size_t S2N) + Subtract {S2P, S2N} from {S1P, S1N}, and write the S1N least + significant limbs of the result to RP. Return borrow, either 0 or + 1. + + This function requires that S1N is greater than or equal to S2N. + + - Function: void mpn_mul_n (mp_limb_t *RP, const mp_limb_t *S1P, const + mp_limb_t *S2P, mp_size_t N) + Multiply {S1P, N} and {S2P, N}, and write the 2*N-limb result to + RP. + + The destination has to have space for 2*N limbs, even if the + product's most significant limb is zero. No overlap is permitted + between the destination and either source. + + - Function: mp_limb_t mpn_mul_1 (mp_limb_t *RP, const mp_limb_t *S1P, + mp_size_t N, mp_limb_t S2LIMB) + Multiply {S1P, N} by S2LIMB, and write the N least significant + limbs of the product to RP. Return the most significant limb of + the product. {S1P, N} and {RP, N} are allowed to overlap provided + RP <= S1P. + + This is a low-level function that is a building block for general + multiplication as well as other operations in GMP. It is written + in assembly for most CPUs. + + Don't call this function if S2LIMB is a power of 2; use + `mpn_lshift' with a count equal to the logarithm of S2LIMB + instead, for optimal speed. + + - Function: mp_limb_t mpn_addmul_1 (mp_limb_t *RP, const mp_limb_t + *S1P, mp_size_t N, mp_limb_t S2LIMB) + Multiply {S1P, N} and S2LIMB, and add the N least significant + limbs of the product to {RP, N} and write the result to RP. + Return the most significant limb of the product, plus carry-out + from the addition. + + This is a low-level function that is a building block for general + multiplication as well as other operations in GMP. It is written + in assembly for most CPUs. + + - Function: mp_limb_t mpn_submul_1 (mp_limb_t *RP, const mp_limb_t + *S1P, mp_size_t N, mp_limb_t S2LIMB) + Multiply {S1P, N} and S2LIMB, and subtract the N least significant + limbs of the product from {RP, N} and write the result to RP. + Return the most significant limb of the product, minus borrow-out + from the subtraction. + + This is a low-level function that is a building block for general + multiplication and division as well as other operations in GMP. + It is written in assembly for most CPUs. + + - Function: mp_limb_t mpn_mul (mp_limb_t *RP, const mp_limb_t *S1P, + mp_size_t S1N, const mp_limb_t *S2P, mp_size_t S2N) + Multiply {S1P, S1N} and {S2P, S2N}, and write the result to RP. + Return the most significant limb of the result. + + The destination has to have space for S1N + S2N limbs, even if the + result might be one limb smaller. + + This function requires that S1N is greater than or equal to S2N. + The destination must be distinct from both input operands. + + - Function: void mpn_tdiv_qr (mp_limb_t *QP, mp_limb_t *RP, mp_size_t + QXN, const mp_limb_t *NP, mp_size_t NN, const mp_limb_t *DP, + mp_size_t DN) + Divide {NP, NN} by {DP, DN} and put the quotient at {QP, NN-DN+1} + and the remainder at {RP, DN}. The quotient is rounded towards 0. + + No overlap is permitted between arguments. NN must be greater + than or equal to DN. The most significant limb of DP must be + non-zero. The QXN operand must be zero. + + - Function: mp_limb_t mpn_divrem (mp_limb_t *R1P, mp_size_t QXN, + mp_limb_t *RS2P, mp_size_t RS2N, const mp_limb_t *S3P, + mp_size_t S3N) + [This function is obsolete. Please call `mpn_tdiv_qr' instead for + best performance.] + + Divide {RS2P, RS2N} by {S3P, S3N}, and write the quotient at R1P, + with the exception of the most significant limb, which is + returned. The remainder replaces the dividend at RS2P; it will be + S3N limbs long (i.e., as many limbs as the divisor). + + In addition to an integer quotient, QXN fraction limbs are + developed, and stored after the integral limbs. For most usages, + QXN will be zero. + + It is required that RS2N is greater than or equal to S3N. It is + required that the most significant bit of the divisor is set. + + If the quotient is not needed, pass RS2P + S3N as R1P. Aside from + that special case, no overlap between arguments is permitted. + + Return the most significant limb of the quotient, either 0 or 1. + + The area at R1P needs to be RS2N - S3N + QXN limbs large. + + - Function: mp_limb_t mpn_divrem_1 (mp_limb_t *R1P, mp_size_t QXN, + mp_limb_t *S2P, mp_size_t S2N, mp_limb_t S3LIMB) + - Macro: mp_limb_t mpn_divmod_1 (mp_limb_t *R1P, mp_limb_t *S2P, + mp_size_t S2N, mp_limb_t S3LIMB) + Divide {S2P, S2N} by S3LIMB, and write the quotient at R1P. + Return the remainder. + + The integer quotient is written to {R1P+QXN, S2N} and in addition + QXN fraction limbs are developed and written to {R1P, QXN}. + Either or both S2N and QXN can be zero. For most usages, QXN will + be zero. + + `mpn_divmod_1' exists for upward source compatibility and is + simply a macro calling `mpn_divrem_1' with a QXN of 0. + + The areas at R1P and S2P have to be identical or completely + separate, not partially overlapping. + + - Function: mp_limb_t mpn_divmod (mp_limb_t *R1P, mp_limb_t *RS2P, + mp_size_t RS2N, const mp_limb_t *S3P, mp_size_t S3N) + [This function is obsolete. Please call `mpn_tdiv_qr' instead for + best performance.] + + - Macro: mp_limb_t mpn_divexact_by3 (mp_limb_t *RP, mp_limb_t *SP, + mp_size_t N) + - Function: mp_limb_t mpn_divexact_by3c (mp_limb_t *RP, mp_limb_t *SP, + mp_size_t N, mp_limb_t CARRY) + Divide {SP, N} by 3, expecting it to divide exactly, and writing + the result to {RP, N}. If 3 divides exactly, the return value is + zero and the result is the quotient. If not, the return value is + non-zero and the result won't be anything useful. + + `mpn_divexact_by3c' takes an initial carry parameter, which can be + the return value from a previous call, so a large calculation can + be done piece by piece from low to high. `mpn_divexact_by3' is + simply a macro calling `mpn_divexact_by3c' with a 0 carry + parameter. + + These routines use a multiply-by-inverse and will be faster than + `mpn_divrem_1' on CPUs with fast multiplication but slow division. + + The source a, result q, size n, initial carry i, and return value + c satisfy c*b^n + a-i = 3*q, where b=2^mp_bits_per_limb. The + return c is always 0, 1 or 2, and the initial carry i must also be + 0, 1 or 2 (these are both borrows really). When c=0 clearly + q=(a-i)/3. When c!=0, the remainder (a-i) mod 3 is given by 3-c, + because b == 1 mod 3 (when `mp_bits_per_limb' is even, which is + always so currently). + + - Function: mp_limb_t mpn_mod_1 (mp_limb_t *S1P, mp_size_t S1N, + mp_limb_t S2LIMB) + Divide {S1P, S1N} by S2LIMB, and return the remainder. S1N can be + zero. + + - Function: mp_limb_t mpn_bdivmod (mp_limb_t *RP, mp_limb_t *S1P, + mp_size_t S1N, const mp_limb_t *S2P, mp_size_t S2N, unsigned + long int D) + This function puts the low floor(D/mp_bits_per_limb) limbs of Q = + {S1P, S1N}/{S2P, S2N} mod 2^D at RP, and returns the high D mod + `mp_bits_per_limb' bits of Q. + + {S1P, S1N} - Q * {S2P, S2N} mod 2^(S1N*mp_bits_per_limb) is placed + at S1P. Since the low floor(D/mp_bits_per_limb) limbs of this + difference are zero, it is possible to overwrite the low limbs at + S1P with this difference, provided RP <= S1P. + + This function requires that S1N * mp_bits_per_limb >= D, and that + {S2P, S2N} is odd. + + *This interface is preliminary. It might change incompatibly in + future revisions.* + + - Function: mp_limb_t mpn_lshift (mp_limb_t *RP, const mp_limb_t *SP, + mp_size_t N, unsigned int COUNT) + Shift {SP, N} left by COUNT bits, and write the result to {RP, N}. + The bits shifted out at the left are returned in the least + significant COUNT bits of the return value (the rest of the return + value is zero). + + COUNT must be in the range 1 to mp_bits_per_limb-1. The regions + {SP, N} and {RP, N} may overlap, provided RP >= SP. + + This function is written in assembly for most CPUs. + + - Function: mp_limb_t mpn_rshift (mp_limb_t *RP, const mp_limb_t *SP, + mp_size_t N, unsigned int COUNT) + Shift {SP, N} right by COUNT bits, and write the result to {RP, + N}. The bits shifted out at the right are returned in the most + significant COUNT bits of the return value (the rest of the return + value is zero). + + COUNT must be in the range 1 to mp_bits_per_limb-1. The regions + {SP, N} and {RP, N} may overlap, provided RP <= SP. + + This function is written in assembly for most CPUs. + + - Function: int mpn_cmp (const mp_limb_t *S1P, const mp_limb_t *S2P, + mp_size_t N) + Compare {S1P, N} and {S2P, N} and return a positive value if S1 > + S2, 0 if they are equal, or a negative value if S1 < S2. + + - Function: mp_size_t mpn_gcd (mp_limb_t *RP, mp_limb_t *S1P, + mp_size_t S1N, mp_limb_t *S2P, mp_size_t S2N) + Set {RP, RETVAL} to the greatest common divisor of {S1P, S1N} and + {S2P, S2N}. The result can be up to S2N limbs, the return value + is the actual number produced. Both source operands are destroyed. + + {S1P, S1N} must have at least as many bits as {S2P, S2N}. {S2P, + S2N} must be odd. Both operands must have non-zero most + significant limbs. No overlap is permitted between {S1P, S1N} and + {S2P, S2N}. + + - Function: mp_limb_t mpn_gcd_1 (const mp_limb_t *S1P, mp_size_t S1N, + mp_limb_t S2LIMB) + Return the greatest common divisor of {S1P, S1N} and S2LIMB. Both + operands must be non-zero. + + - Function: mp_size_t mpn_gcdext (mp_limb_t *R1P, mp_limb_t *R2P, + mp_size_t *R2N, mp_limb_t *S1P, mp_size_t S1N, mp_limb_t + *S2P, mp_size_t S2N) + Calculate the greatest common divisor of {S1P, S1N} and {S2P, + S2N}. Store the gcd at {R1P, RETVAL} and the first cofactor at + {R2P, *R2N}, with *R2N negative if the cofactor is negative. R1P + and R2P should each have room for S1N+1 limbs, but the return + value and value stored through R2N indicate the actual number + produced. + + {S1P, S1N} >= {S2P, S2N} is required, and both must be non-zero. + The regions {S1P, S1N+1} and {S2P, S2N+1} are destroyed (i.e. the + operands plus an extra limb past the end of each). + + The cofactor R1 will satisfy R2*S1 + K*S2 = R1. The second + cofactor K is not calculated but can easily be obtained from (R1 - + R2*S1) / S2. + + - Function: mp_size_t mpn_sqrtrem (mp_limb_t *R1P, mp_limb_t *R2P, + const mp_limb_t *SP, mp_size_t N) + Compute the square root of {SP, N} and put the result at {R1P, + ceil(N/2)} and the remainder at {R2P, RETVAL}. R2P needs space + for N limbs, but the return value indicates how many are produced. + + The most significant limb of {SP, N} must be non-zero. The areas + {R1P, ceil(N/2)} and {SP, N} must be completely separate. The + areas {R2P, N} and {SP, N} must be either identical or completely + separate. + + If the remainder is not wanted then R2P can be `NULL', and in this + case the return value is zero or non-zero according to whether the + remainder would have been zero or non-zero. + + A return value of zero indicates a perfect square. See also + `mpz_perfect_square_p'. + + - Function: mp_size_t mpn_get_str (unsigned char *STR, int BASE, + mp_limb_t *S1P, mp_size_t S1N) + Convert {S1P, S1N} to a raw unsigned char array at STR in base + BASE, and return the number of characters produced. There may be + leading zeros in the string. The string is not in ASCII; to + convert it to printable format, add the ASCII codes for `0' or + `A', depending on the base and range. BASE can vary from 2 to 256. + + The most significant limb of the input {S1P, S1N} must be + non-zero. The input {S1P, S1N} is clobbered, except when BASE is + a power of 2, in which case it's unchanged. + + The area at STR has to have space for the largest possible number + represented by a S1N long limb array, plus one extra character. + + - Function: mp_size_t mpn_set_str (mp_limb_t *RP, const unsigned char + *STR, size_t STRSIZE, int BASE) + Convert bytes {STR,STRSIZE} in the given BASE to limbs at RP. + + STR[0] is the most significant byte and STR[STRSIZE-1] is the + least significant. Each byte should be a value in the range 0 to + BASE-1, not an ASCII character. BASE can vary from 2 to 256. + + The return value is the number of limbs written to RP. If the most + significant input byte is non-zero then the high limb at RP will be + non-zero, and only that exact number of limbs will be required + there. + + If the most significant input byte is zero then there may be high + zero limbs written to RP and included in the return value. + + STRSIZE must be at least 1, and no overlap is permitted between + {STR,STRSIZE} and the result at RP. + + - Function: unsigned long int mpn_scan0 (const mp_limb_t *S1P, + unsigned long int BIT) + Scan S1P from bit position BIT for the next clear bit. + + It is required that there be a clear bit within the area at S1P at + or beyond bit position BIT, so that the function has something to + return. + + - Function: unsigned long int mpn_scan1 (const mp_limb_t *S1P, + unsigned long int BIT) + Scan S1P from bit position BIT for the next set bit. + + It is required that there be a set bit within the area at S1P at or + beyond bit position BIT, so that the function has something to + return. + + - Function: void mpn_random (mp_limb_t *R1P, mp_size_t R1N) + - Function: void mpn_random2 (mp_limb_t *R1P, mp_size_t R1N) + Generate a random number of length R1N and store it at R1P. The + most significant limb is always non-zero. `mpn_random' generates + uniformly distributed limb data, `mpn_random2' generates long + strings of zeros and ones in the binary representation. + + `mpn_random2' is intended for testing the correctness of the `mpn' + routines. + + - Function: unsigned long int mpn_popcount (const mp_limb_t *S1P, + mp_size_t N) + Count the number of set bits in {S1P, N}. + + - Function: unsigned long int mpn_hamdist (const mp_limb_t *S1P, const + mp_limb_t *S2P, mp_size_t N) + Compute the hamming distance between {S1P, N} and {S2P, N}, which + is the number of bit positions where the two operands have + different bit values. + + - Function: int mpn_perfect_square_p (const mp_limb_t *S1P, mp_size_t + N) + Return non-zero iff {S1P, N} is a perfect square. + + +Nails +===== + +*Everything in this section is highly experimental and may disappear or +be subject to incompatible changes in a future version of GMP.* + + Nails are an experimental feature whereby a few bits are left unused +at the top of each `mp_limb_t'. This can significantly improve carry +handling on some processors. + + All the `mpn' functions accepting limb data will expect the nail +bits to be zero on entry, and will return data with the nails similarly +all zero. This applies both to limb vectors and to single limb +arguments. + + Nails can be enabled by configuring with `--enable-nails'. By +default the number of bits will be chosen according to what suits the +host processor, but a particular number can be selected with +`--enable-nails=N'. + + At the mpn level, a nail build is neither source nor binary +compatible with a non-nail build, strictly speaking. But programs +acting on limbs only through the mpn functions are likely to work +equally well with either build, and judicious use of the definitions +below should make any program compatible with either build, at the +source level. + + For the higher level routines, meaning `mpz' etc, a nail build +should be fully source and binary compatible with a non-nail build. + + - Macro: GMP_NAIL_BITS + - Macro: GMP_NUMB_BITS + - Macro: GMP_LIMB_BITS + `GMP_NAIL_BITS' is the number of nail bits, or 0 when nails are + not in use. `GMP_NUMB_BITS' is the number of data bits in a limb. + `GMP_LIMB_BITS' is the total number of bits in an `mp_limb_t'. In + all cases + + GMP_LIMB_BITS == GMP_NAIL_BITS + GMP_NUMB_BITS + + - Macro: GMP_NAIL_MASK + - Macro: GMP_NUMB_MASK + Bit masks for the nail and number parts of a limb. + `GMP_NAIL_MASK' is 0 when nails are not in use. + + `GMP_NAIL_MASK' is not often needed, since the nail part can be + obtained with `x >> GMP_NUMB_BITS', and that means one less large + constant, which can help various RISC chips. + + - Macro: GMP_NUMB_MAX + The maximum value that can be stored in the number part of a limb. + This is the same as `GMP_NUMB_MASK', but can be used for clarity + when doing comparisons rather than bit-wise operations. + + The term "nails" comes from finger or toe nails, which are at the +ends of a limb (arm or leg). "numb" is short for number, but is also +how the developers felt after trying for a long time to come up with +sensible names for these things. + + In the future (the distant future most likely) a non-zero nail might +be permitted, giving non-unique representations for numbers in a limb +vector. This would help vector processors since carries would only +ever need to propagate one or two limbs. + + +File: gmp.info, Node: Random Number Functions, Next: Formatted Output, Prev: Low-level Functions, Up: Top + +Random Number Functions +*********************** + +Sequences of pseudo-random numbers in GMP are generated using a +variable of type `gmp_randstate_t', which holds an algorithm selection +and a current state. Such a variable must be initialized by a call to +one of the `gmp_randinit' functions, and can be seeded with one of the +`gmp_randseed' functions. + + The functions actually generating random numbers are described in +*Note Integer Random Numbers::, and *Note Miscellaneous Float +Functions::. + + The older style random number functions don't accept a +`gmp_randstate_t' parameter but instead share a global variable of that +type. They use a default algorithm and are currently not seeded +(though perhaps that will change in the future). The new functions +accepting a `gmp_randstate_t' are recommended for applications that +care about randomness. + +* Menu: + +* Random State Initialization:: +* Random State Seeding:: + + +File: gmp.info, Node: Random State Initialization, Next: Random State Seeding, Prev: Random Number Functions, Up: Random Number Functions + +Random State Initialization +=========================== + + - Function: void gmp_randinit_default (gmp_randstate_t STATE) + Initialize STATE with a default algorithm. This will be a + compromise between speed and randomness, and is recommended for + applications with no special requirements. + + - Function: void gmp_randinit_lc_2exp (gmp_randstate_t STATE, mpz_t A, + unsigned long C, unsigned long M2EXP) + Initialize STATE with a linear congruential algorithm X = (A*X + + C) mod 2^M2EXP. + + The low bits of X in this algorithm are not very random. The least + significant bit will have a period no more than 2, and the second + bit no more than 4, etc. For this reason only the high half of + each X is actually used. + + When a random number of more than M2EXP/2 bits is to be generated, + multiple iterations of the recurrence are used and the results + concatenated. + + - Function: int gmp_randinit_lc_2exp_size (gmp_randstate_t STATE, + unsigned long SIZE) + Initialize STATE for a linear congruential algorithm as per + `gmp_randinit_lc_2exp'. A, C and M2EXP are selected from a table, + chosen so that SIZE bits (or more) of each X will be used, ie. + M2EXP/2 >= SIZE. + + If successful the return value is non-zero. If SIZE is bigger + than the table data provides then the return value is zero. The + maximum SIZE currently supported is 128. + + - Function: void gmp_randinit (gmp_randstate_t STATE, + gmp_randalg_t ALG, ...) + *This function is obsolete.* + + Initialize STATE with an algorithm selected by ALG. The only + choice is `GMP_RAND_ALG_LC', which is `gmp_randinit_lc_2exp_size' + described above. A third parameter of type `unsigned long' is + required, this is the SIZE for that function. + `GMP_RAND_ALG_DEFAULT' or 0 are the same as `GMP_RAND_ALG_LC'. + + `gmp_randinit' sets bits in the global variable `gmp_errno' to + indicate an error. `GMP_ERROR_UNSUPPORTED_ARGUMENT' if ALG is + unsupported, or `GMP_ERROR_INVALID_ARGUMENT' if the SIZE parameter + is too big. It may be noted this error reporting is not thread + safe (a good reason to use `gmp_randinit_lc_2exp_size' instead). + + - Function: void gmp_randclear (gmp_randstate_t STATE) + Free all memory occupied by STATE. + + +File: gmp.info, Node: Random State Seeding, Prev: Random State Initialization, Up: Random Number Functions + +Random State Seeding +==================== + + - Function: void gmp_randseed (gmp_randstate_t STATE, mpz_t SEED) + - Function: void gmp_randseed_ui (gmp_randstate_t STATE, + unsigned long int SEED) + Set an initial seed value into STATE. + + The size of a seed determines how many different sequences of + random numbers that it's possible to generate. The "quality" of + the seed is the randomness of a given seed compared to the + previous seed used, and this affects the randomness of separate + number sequences. The method for choosing a seed is critical if + the generated numbers are to be used for important applications, + such as generating cryptographic keys. + + Traditionally the system time has been used to seed, but care + needs to be taken with this. If an application seeds often and + the resolution of the system clock is low, then the same sequence + of numbers might be repeated. Also, the system time is quite easy + to guess, so if unpredictability is required then it should + definitely not be the only source for the seed value. On some + systems there's a special device `/dev/random' which provides + random data better suited for use as a seed. + + +File: gmp.info, Node: Formatted Output, Next: Formatted Input, Prev: Random Number Functions, Up: Top + +Formatted Output +**************** + +* Menu: + +* Formatted Output Strings:: +* Formatted Output Functions:: +* C++ Formatted Output:: + + +File: gmp.info, Node: Formatted Output Strings, Next: Formatted Output Functions, Prev: Formatted Output, Up: Formatted Output + +Format Strings +============== + +`gmp_printf' and friends accept format strings similar to the standard C +`printf' (*note Formatted Output: (libc)Formatted Output.). A format +specification is of the form + + % [flags] [width] [.[precision]] [type] conv + + GMP adds types `Z', `Q' and `F' for `mpz_t', `mpq_t' and `mpf_t' +respectively, and `N' for an `mp_limb_t' array. `Z', `Q' and `N' +behave like integers. `Q' will print a `/' and a denominator, if +needed. `F' behaves like a float. For example, + + mpz_t z; + gmp_printf ("%s is an mpz %Zd\n", "here", z); + + mpq_t q; + gmp_printf ("a hex rational: %#40Qx\n", q); + + mpf_t f; + int n; + gmp_printf ("fixed point mpf %.*Ff with %d digits\n", n, f, n); + + const mp_limb_t *ptr; + mp_size_t size; + gmp_printf ("limb array %Nx\n", ptr, size); + + For `N' the limbs are expected least significant first, as per the +`mpn' functions (*note Low-level Functions::). A negative size can be +given to print the value as a negative. + + All the standard C `printf' types behave the same as the C library +`printf', and can be freely intermixed with the GMP extensions. In the +current implementation the standard parts of the format string are +simply handed to `printf' and only the GMP extensions handled directly. + + The flags accepted are as follows. GLIBC style ' is only for the +standard C types (not the GMP types), and only if the C library +supports it. + + 0 pad with zeros (rather than spaces) + # show the base with `0x', `0X' or `0' + + always show a sign + (space) show a space or a `-' sign + ' group digits, GLIBC style (not GMP types) + + The optional width and precision can be given as a number within the +format string, or as a `*' to take an extra parameter of type `int', the +same as the standard `printf'. + + The standard types accepted are as follows. `h' and `l' are +portable, the rest will depend on the compiler (or include files) for +the type and the C library for the output. + + h short + hh char + j intmax_t or uintmax_t + l long or wchar_t + ll long long + L long double + q quad_t or u_quad_t + t ptrdiff_t + z size_t + +The GMP types are + + F mpf_t, float conversions + Q mpq_t, integer conversions + N mp_limb_t array, integer conversions + Z mpz_t, integer conversions + + The conversions accepted are as follows. `a' and `A' are always +supported for `mpf_t' but depend on the C library for standard C float +types. `m' and `p' depend on the C library. + + a A hex floats, C99 style + c character + d decimal integer + e E scientific format float + f fixed point float + i same as d + g G fixed or scientific float + m `strerror' string, GLIBC style + n store characters written so far + o octal integer + p pointer + s string + u unsigned integer + x X hex integer + + `o', `x' and `X' are unsigned for the standard C types, but for +types `Z', `Q' and `N' they are signed. `u' is not meaningful for `Z', +`Q' and `N'. + + `n' can be used with any type, even the GMP types. + + Other types or conversions that might be accepted by the C library +`printf' cannot be used through `gmp_printf', this includes for +instance extensions registered with GLIBC `register_printf_function'. +Also currently there's no support for POSIX `$' style numbered arguments +(perhaps this will be added in the future). + + The precision field has it's usual meaning for integer `Z' and float +`F' types, but is currently undefined for `Q' and should not be used +with that. + + `mpf_t' conversions only ever generate as many digits as can be +accurately represented by the operand, the same as `mpf_get_str' does. +Zeros will be used if necessary to pad to the requested precision. This +happens even for an `f' conversion of an `mpf_t' which is an integer, +for instance 2^1024 in an `mpf_t' of 128 bits precision will only +produce about 40 digits, then pad with zeros to the decimal point. An +empty precision field like `%.Fe' or `%.Ff' can be used to specifically +request just the significant digits. + + The decimal point character (or string) is taken from the current +locale settings on systems which provide `localeconv' (*note Locales +and Internationalization: (libc)Locales.). The C library will normally +do the same for standard float output. + + The format string is only interpreted as plain `char's, multibyte +characters are not recognised. Perhaps this will change in the future. + + +File: gmp.info, Node: Formatted Output Functions, Next: C++ Formatted Output, Prev: Formatted Output Strings, Up: Formatted Output + +Functions +========= + +Each of the following functions is similar to the corresponding C +library function. The basic `printf' forms take a variable argument +list. The `vprintf' forms take an argument pointer, see *Note Variadic +Functions: (libc)Variadic Functions, or `man 3 va_start'. + + It should be emphasised that if a format string is invalid, or the +arguments don't match what the format specifies, then the behaviour of +any of these functions will be unpredictable. GCC format string +checking is not available, since it doesn't recognise the GMP +extensions. + + The file based functions `gmp_printf' and `gmp_fprintf' will return +-1 to indicate a write error. All the functions can return -1 if the C +library `printf' variant in use returns -1, but this shouldn't normally +occur. + + - Function: int gmp_printf (const char *FMT, ...) + - Function: int gmp_vprintf (const char *FMT, va_list AP) + Print to the standard output `stdout'. Return the number of + characters written, or -1 if an error occurred. + + - Function: int gmp_fprintf (FILE *FP, const char *FMT, ...) + - Function: int gmp_vfprintf (FILE *FP, const char *FMT, va_list AP) + Print to the stream FP. Return the number of characters written, + or -1 if an error occurred. + + - Function: int gmp_sprintf (char *BUF, const char *FMT, ...) + - Function: int gmp_vsprintf (char *BUF, const char *FMT, va_list AP) + Form a null-terminated string in BUF. Return the number of + characters written, excluding the terminating null. + + No overlap is permitted between the space at BUF and the string + FMT. + + These functions are not recommended, since there's no protection + against exceeding the space available at BUF. + + - Function: int gmp_snprintf (char *BUF, size_t SIZE, const char *FMT, + ...) + - Function: int gmp_vsnprintf (char *BUF, size_t SIZE, const char + *FMT, va_list AP) + Form a null-terminated string in BUF. No more than SIZE bytes + will be written. To get the full output, SIZE must be enough for + the string and null-terminator. + + The return value is the total number of characters which ought to + have been produced, excluding the terminating null. If RETVAL >= + SIZE then the actual output has been truncated to the first SIZE-1 + characters, and a null appended. + + No overlap is permitted between the region {BUF,SIZE} and the FMT + string. + + Notice the return value is in ISO C99 `snprintf' style. This is + so even if the C library `vsnprintf' is the older GLIBC 2.0.x + style. + + - Function: int gmp_asprintf (char **PP, const char *FMT, ...) + - Function: int gmp_vasprintf (char *PP, const char *FMT, va_list AP) + Form a null-terminated string in a block of memory obtained from + the current memory allocation function (*note Custom + Allocation::). The block will be the size of the string and + null-terminator. Put the address of the block in *PP. Return the + number of characters produced, excluding the null-terminator. + + Unlike the C library `asprintf', `gmp_asprintf' doesn't return -1 + if there's no more memory available, it lets the current allocation + function handle that. + + - Function: int gmp_obstack_printf (struct obstack *OB, const char + *FMT, ...) + - Function: int gmp_obstack_vprintf (struct obstack *OB, const char + *FMT, va_list AP) + Append to the current obstack object, in the same style as + `obstack_printf'. Return the number of characters written. A + null-terminator is not written. + + FMT cannot be within the current obstack object, since the object + might move as it grows. + + These functions are available only when the C library provides the + obstack feature, which probably means only on GNU systems, see + *Note Obstacks: (libc)Obstacks. + + +File: gmp.info, Node: C++ Formatted Output, Prev: Formatted Output Functions, Up: Formatted Output + +C++ Formatted Output +==================== + +The following functions are provided in `libgmpxx', which is built if +C++ support is enabled (*note Build Options::). Prototypes are +available from `'. + + - Function: ostream& operator<< (ostream& STREAM, mpz_t OP) + Print OP to STREAM, using its `ios' formatting settings. + `ios::width' is reset to 0 after output, the same as the standard + `ostream operator<<' routines do. + + In hex or octal, OP is printed as a signed number, the same as for + decimal. This is unlike the standard `operator<<' routines on + `int' etc, which instead give twos complement. + + - Function: ostream& operator<< (ostream& STREAM, mpq_t OP) + Print OP to STREAM, using its `ios' formatting settings. + `ios::width' is reset to 0 after output, the same as the standard + `ostream operator<<' routines do. + + Output will be a fraction like `5/9', or if the denominator is 1 + then just a plain integer like `123'. + + In hex or octal, OP is printed as a signed value, the same as for + decimal. If `ios::showbase' is set then a base indicator is shown + on both the numerator and denominator (if the denominator is + required). + + - Function: ostream& operator<< (ostream& STREAM, mpf_t OP) + Print OP to STREAM, using its `ios' formatting settings. + `ios::width' is reset to 0 after output, the same as the standard + `ostream operator<<' routines do. The decimal point follows the + current locale, on systems providing `localeconv'. + + Hex and octal are supported, unlike the standard `operator<<' on + `double'. The mantissa will be in hex or octal, the exponent will + be in decimal. For hex the exponent delimiter is an `@'. This is + as per `mpf_out_str'. + + `ios::showbase' is supported, and will put a base on the mantissa, + for example hex `0x1.8' or `0x0.8', or octal `01.4' or `00.4'. + This last form is slightly strange, but at least differentiates + itself from decimal. + + These operators mean that GMP types can be printed in the usual C++ +way, for example, + + mpz_t z; + int n; + ... + cout << "iteration " << n << " value " << z << "\n"; + + But note that `ostream' output (and `istream' input, *note C++ +Formatted Input::) is the only overloading available for the GMP types +and that for instance using `+' with an `mpz_t' will have unpredictable +results. For classes with overloading, see *Note C++ Class Interface::. + + +File: gmp.info, Node: Formatted Input, Next: C++ Class Interface, Prev: Formatted Output, Up: Top + +Formatted Input +*************** + +* Menu: + +* Formatted Input Strings:: +* Formatted Input Functions:: +* C++ Formatted Input:: + + +File: gmp.info, Node: Formatted Input Strings, Next: Formatted Input Functions, Prev: Formatted Input, Up: Formatted Input + +Formatted Input Strings +======================= + +`gmp_scanf' and friends accept format strings similar to the standard C +`scanf' (*note Formatted Input: (libc)Formatted Input.). A format +specification is of the form + + % [flags] [width] [type] conv + + GMP adds types `Z', `Q' and `F' for `mpz_t', `mpq_t' and `mpf_t' +respectively. `Z' and `Q' behave like integers. `Q' will read a `/' +and a denominator, if present. `F' behaves like a float. + + GMP variables don't require an `&' when passed to `gmp_scanf', since +they're already "call-by-reference". For example, + + /* to read say "a(5) = 1234" */ + int n; + mpz_t z; + gmp_scanf ("a(%d) = %Zd\n", &n, z); + + mpq_t q1, q2; + gmp_sscanf ("0377 + 0x10/0x11", "%Qi + %Qi", q1, q2); + + /* to read say "topleft (1.55,-2.66)" */ + mpf_t x, y; + char buf[32]; + gmp_scanf ("%31s (%Ff,%Ff)", buf, x, y); + + All the standard C `scanf' types behave the same as in the C library +`scanf', and can be freely intermixed with the GMP extensions. In the +current implementation the standard parts of the format string are +simply handed to `scanf' and only the GMP extensions handled directly. + + The flags accepted are as follows. `a' and `'' will depend on +support from the C library, and `'' cannot be used with GMP types. + + * read but don't store + a allocate a buffer (string conversions) + ' group digits, GLIBC style (not GMP types) + + The standard types accepted are as follows. `h' and `l' are +portable, the rest will depend on the compiler (or include files) for +the type and the C library for the input. + + h short + hh char + j intmax_t or uintmax_t + l long int, double or wchar_t + ll long long + L long double + q quad_t or u_quad_t + t ptrdiff_t + z size_t + +The GMP types are + + F mpf_t, float conversions + Q mpq_t, integer conversions + Z mpz_t, integer conversions + + The conversions accepted are as follows. `p' and `[' will depend on +support from the C library, the rest are standard. + + c character or characters + d decimal integer + e E f g G float + i integer with base indicator + n characters read so far + o octal integer + p pointer + s string of non-whitespace characters + u decimal integer + x X hex integer + [ string of characters in a set + + `e', `E', `f', `g' and `G' are identical, they all read either fixed +point or scientific format, and either `e' or `E' for the exponent in +scientific format. + + `x' and `X' are identical, both accept both upper and lower case +hexadecimal. + + `o', `u', `x' and `X' all read positive or negative values. For the +standard C types these are described as "unsigned" conversions, but +that merely affects certain overflow handling, negatives are still +allowed (per `strtoul', *note Parsing of Integers: (libc)Parsing of +Integers.). For GMP types there are no overflows, so `d' and `u' are +identical. + + `Q' type reads the numerator and (optional) denominator as given. +If the value might not be in canonical form then `mpq_canonicalize' +must be called before using it in any calculations (*note Rational +Number Functions::). + + `Qi' will read a base specification separately for the numerator and +denominator. For example `0x10/11' would be 16/11, whereas `0x10/0x11' +would be 16/17. + + `n' can be used with any of the types above, even the GMP types. +`*' to suppress assignment is allowed, though the field would then do +nothing at all. + + Other conversions or types that might be accepted by the C library +`scanf' cannot be used through `gmp_scanf'. + + Whitespace is read and discarded before a field, except for `c' and +`[' conversions. + + For float conversions, the decimal point character (or string) +expected is taken from the current locale settings on systems which +provide `localeconv' (*note Locales and Internationalization: +(libc)Locales.). The C library will normally do the same for standard +float input. + + The format string is only interpreted as plain `char's, multibyte +characters are not recognised. Perhaps this will change in the future. + + +File: gmp.info, Node: Formatted Input Functions, Next: C++ Formatted Input, Prev: Formatted Input Strings, Up: Formatted Input + +Formatted Input Functions +========================= + +Each of the following functions is similar to the corresponding C +library function. The plain `scanf' forms take a variable argument +list. The `vscanf' forms take an argument pointer, see *Note Variadic +Functions: (libc)Variadic Functions, or `man 3 va_start'. + + It should be emphasised that if a format string is invalid, or the +arguments don't match what the format specifies, then the behaviour of +any of these functions will be unpredictable. GCC format string +checking is not available, since it doesn't recognise the GMP +extensions. + + No overlap is permitted between the FMT string and any of the results +produced. + + - Function: int gmp_scanf (const char *FMT, ...) + - Function: int gmp_vscanf (const char *FMT, va_list AP) + Read from the standard input `stdin'. + + - Function: int gmp_fscanf (FILE *FP, const char *FMT, ...) + - Function: int gmp_vfscanf (FILE *FP, const char *FMT, va_list AP) + Read from the stream FP. + + - Function: int gmp_sscanf (const char *S, const char *FMT, ...) + - Function: int gmp_vsscanf (const char *S, const char *FMT, va_list + AP) + Read from a null-terminated string S. + + The return value from each of these functions is the same as the +standard C99 `scanf', namely the number of fields successfully parsed +and stored. `%n' fields and fields read but suppressed by `*' don't +count towards the return value. + + If end of file or file error, or end of string, is reached when a +match is required, and when no previous non-suppressed fields have +matched, then the return value is EOF instead of 0. A match is +required for a literal character in the format string or a field other +than `%n'. Whitespace in the format string is only an optional match +and won't induce an EOF in this fashion. Leading whitespace read and +discarded for a field doesn't count as a match. + + +File: gmp.info, Node: C++ Formatted Input, Prev: Formatted Input Functions, Up: Formatted Input + +C++ Formatted Input +=================== + +The following functions are provided in `libgmpxx', which is built only +if C++ support is enabled (*note Build Options::). Prototypes are +available from `'. + + - Function: istream& operator>> (istream& STREAM, mpz_t ROP) + Read ROP from STREAM, using its `ios' formatting settings. + + - Function: istream& operator>> (istream& STREAM, mpq_t ROP) + Read ROP from STREAM, using its `ios' formatting settings. + + An integer like `123' will be read, or a fraction like `5/9'. If + the fraction is not in canonical form then `mpq_canonicalize' must + be called (*note Rational Number Functions::). + + - Function: istream& operator>> (istream& STREAM, mpf_t ROP) + Read ROP from STREAM, using its `ios' formatting settings. + + Hex or octal floats are not supported, but might be in the future. + + These operators mean that GMP types can be read in the usual C++ +way, for example, + + mpz_t z; + ... + cin >> z; + + But note that `istream' input (and `ostream' output, *note C++ +Formatted Output::) is the only overloading available for the GMP types +and that for instance using `+' with an `mpz_t' will have unpredictable +results. For classes with overloading, see *Note C++ Class Interface::. + + +File: gmp.info, Node: C++ Class Interface, Next: BSD Compatible Functions, Prev: Formatted Input, Up: Top + +C++ Class Interface +******************* + +This chapter describes the C++ class based interface to GMP. + + All GMP C language types and functions can be used in C++ programs, +since `gmp.h' has `extern "C"' qualifiers, but the class interface +offers overloaded functions and operators which may be more convenient. + + Due to the implementation of this interface, a reasonably recent C++ +compiler is required, one supporting namespaces, partial specialization +of templates and member templates. For GCC this means version 2.91 or +later. + + *Everything described in this chapter is to be considered preliminary +and might be subject to incompatible changes if some unforeseen +difficulty reveals itself.* + +* Menu: + +* C++ Interface General:: +* C++ Interface Integers:: +* C++ Interface Rationals:: +* C++ Interface Floats:: +* C++ Interface MPFR:: +* C++ Interface Random Numbers:: +* C++ Interface Limitations:: + + +File: gmp.info, Node: C++ Interface General, Next: C++ Interface Integers, Prev: C++ Class Interface, Up: C++ Class Interface + +C++ Interface General +===================== + +All the C++ classes and functions are available with + + #include + + Programs should be linked with the `libgmpxx' and `libgmp' +libraries. For example, + + g++ mycxxprog.cc -lgmpxx -lgmp + +The classes defined are + + - Class: mpz_class + - Class: mpq_class + - Class: mpf_class + + The standard operators and various standard functions are overloaded +to allow arithmetic with these classes. For example, + + int + main (void) + { + mpz_class a, b, c; + + a = 1234; + b = "-5678"; + c = a+b; + cout << "sum is " << c << "\n"; + cout << "absolute value is " << abs(c) << "\n"; + + return 0; + } + + An important feature of the implementation is that an expression like +`a=b+c' results in a single call to the corresponding `mpz_add', +without using a temporary for the `b+c' part. Expressions which by +their nature imply intermediate values, like `a=b*c+d*e', still use +temporaries though. + + The classes can be freely intermixed in expressions, as can the +classes and the standard types `long', `unsigned long' and `double'. +Smaller types like `int' or `float' can also be intermixed, since C++ +will promote them. + + Note that `bool' is not accepted directly, but must be explicitly +cast to an `int' first. This is because C++ will automatically convert +any pointer to a `bool', so if GMP accepted `bool' it would make all +sorts of invalid class and pointer combinations compile but almost +certainly not do anything sensible. + + Conversions back from the classes to standard C++ types aren't done +automatically, instead member functions like `get_si' are provided (see +the following sections for details). + + Also there are no automatic conversions from the classes to the +corresponding GMP C types, instead a reference to the underlying C +object can be obtained with the following functions, + + - Function: mpz_t mpz_class::get_mpz_t () + - Function: mpq_t mpq_class::get_mpq_t () + - Function: mpf_t mpf_class::get_mpf_t () + + These can be used to call a C function which doesn't have a C++ class +interface. For example to set `a' to the GCD of `b' and `c', + + mpz_class a, b, c; + ... + mpz_gcd (a.get_mpz_t(), b.get_mpz_t(), c.get_mpz_t()); + + In the other direction, a class can be initialized from the +corresponding GMP C type, or assigned to if an explicit constructor is +used. In both cases this makes a copy of the value, it doesn't create +any sort of association. For example, + + mpz_t z; + // ... init and calculate z ... + mpz_class x(z); + mpz_class y; + y = mpz_class (z); + + There are no namespace setups in `gmpxx.h', all types and functions +are simply put into the global namespace. This is what `gmp.h' has +done in the past, and continues to do for compatibility. The extras +provided by `gmpxx.h' follow GMP naming conventions and are unlikely to +clash with anything. + + +File: gmp.info, Node: C++ Interface Integers, Next: C++ Interface Rationals, Prev: C++ Interface General, Up: C++ Class Interface + +C++ Interface Integers +====================== + + - Function: void mpz_class::mpz_class (type N) + Construct an `mpz_class'. All the standard C++ types may be used, + except `long long' and `long double', and all the GMP C++ classes + can be used. Any necessary conversion follows the corresponding C + function, for example `double' follows `mpz_set_d' (*note + Assigning Integers::). + + - Function: void mpz_class::mpz_class (mpz_t Z) + Construct an `mpz_class' from an `mpz_t'. The value in Z is + copied into the new `mpz_class', there won't be any permanent + association between it and Z. + + - Function: void mpz_class::mpz_class (const char *S) + - Function: void mpz_class::mpz_class (const char *S, int base) + - Function: void mpz_class::mpz_class (const string& S) + - Function: void mpz_class::mpz_class (const string& S, int base) + Construct an `mpz_class' converted from a string using + `mpz_set_str', (*note Assigning Integers::). If the BASE is not + given then 0 is used. + + - Function: mpz_class operator/ (mpz_class A, mpz_class D) + - Function: mpz_class operator% (mpz_class A, mpz_class D) + Divisions involving `mpz_class' round towards zero, as per the + `mpz_tdiv_q' and `mpz_tdiv_r' functions (*note Integer Division::). + This is the same as the C99 `/' and `%' operators. + + The `mpz_fdiv...' or `mpz_cdiv...' functions can always be called + directly if desired. For example, + + mpz_class q, a, d; + ... + mpz_fdiv_q (q.get_mpz_t(), a.get_mpz_t(), d.get_mpz_t()); + + - Function: mpz_class abs (mpz_class OP1) + - Function: int cmp (mpz_class OP1, type OP2) + - Function: int cmp (type OP1, mpz_class OP2) + - Function: double mpz_class::get_d (void) + - Function: long mpz_class::get_si (void) + - Function: unsigned long mpz_class::get_ui (void) + - Function: bool mpz_class::fits_sint_p (void) + - Function: bool mpz_class::fits_slong_p (void) + - Function: bool mpz_class::fits_sshort_p (void) + - Function: bool mpz_class::fits_uint_p (void) + - Function: bool mpz_class::fits_ulong_p (void) + - Function: bool mpz_class::fits_ushort_p (void) + - Function: int sgn (mpz_class OP) + - Function: mpz_class sqrt (mpz_class OP) + These functions provide a C++ class interface to the corresponding + GMP C routines. + + `cmp' can be used with any of the classes or the standard C++ + types, except `long long' and `long double'. + + + Overloaded operators for combinations of `mpz_class' and `double' +are provided for completeness, but it should be noted that if the given +`double' is not an integer then the way any rounding is done is +currently unspecified. The rounding might take place at the start, in +the middle, or at the end of the operation, and it might change in the +future. + + Conversions between `mpz_class' and `double', however, are defined +to follow the corresponding C functions `mpz_get_d' and `mpz_set_d'. +And comparisons are always made exactly, as per `mpz_cmp_d'. + + +File: gmp.info, Node: C++ Interface Rationals, Next: C++ Interface Floats, Prev: C++ Interface Integers, Up: C++ Class Interface + +C++ Interface Rationals +======================= + +In all the following constructors, if a fraction is given then it +should be in canonical form, or if not then `mpq_class::canonicalize' +called. + + - Function: void mpq_class::mpq_class (type OP) + - Function: void mpq_class::mpq_class (integer NUM, integer DEN) + Construct an `mpq_class'. The initial value can be a single value + of any type, or a pair of integers (`mpz_class' or standard C++ + integer types) representing a fraction, except that `long long' + and `long double' are not supported. For example, + + mpq_class q (99); + mpq_class q (1.75); + mpq_class q (1, 3); + + - Function: void mpq_class::mpq_class (mpq_t Q) + Construct an `mpq_class' from an `mpq_t'. The value in Q is + copied into the new `mpq_class', there won't be any permanent + association between it and Q. + + - Function: void mpq_class::mpq_class (const char *S) + - Function: void mpq_class::mpq_class (const char *S, int base) + - Function: void mpq_class::mpq_class (const string& S) + - Function: void mpq_class::mpq_class (const string& S, int base) + Construct an `mpq_class' converted from a string using + `mpq_set_str', (*note Initializing Rationals::). If the BASE is + not given then 0 is used. + + - Function: void mpq_class::canonicalize () + Put an `mpq_class' into canonical form, as per *Note Rational + Number Functions::. All arithmetic operators require their + operands in canonical form, and will return results in canonical + form. + + - Function: mpq_class abs (mpq_class OP) + - Function: int cmp (mpq_class OP1, type OP2) + - Function: int cmp (type OP1, mpq_class OP2) + - Function: double mpq_class::get_d (void) + - Function: int sgn (mpq_class OP) + These functions provide a C++ class interface to the corresponding + GMP C routines. + + `cmp' can be used with any of the classes or the standard C++ + types, except `long long' and `long double'. + + - Function: mpz_class& mpq_class::get_num () + - Function: mpz_class& mpq_class::get_den () + Get a reference to an `mpz_class' which is the numerator or + denominator of an `mpq_class'. This can be used both for read and + write access. If the object returned is modified, it modifies the + original `mpq_class'. + + If direct manipulation might produce a non-canonical value, then + `mpq_class::canonicalize' must be called before further operations. + + - Function: mpz_t mpq_class::get_num_mpz_t () + - Function: mpz_t mpq_class::get_den_mpz_t () + Get a reference to the underlying `mpz_t' numerator or denominator + of an `mpq_class'. This can be passed to C functions expecting an + `mpz_t'. Any modifications made to the `mpz_t' will modify the + original `mpq_class'. + + If direct manipulation might produce a non-canonical value, then + `mpq_class::canonicalize' must be called before further operations. + + - Function: istream& operator>> (istream& STREAM, mpq_class& ROP); + Read ROP from STREAM, using its `ios' formatting settings, the + same as `mpq_t operator>>' (*note C++ Formatted Input::). + + If the ROP read might not be in canonical form then + `mpq_class::canonicalize' must be called. + + +File: gmp.info, Node: C++ Interface Floats, Next: C++ Interface MPFR, Prev: C++ Interface Rationals, Up: C++ Class Interface + +C++ Interface Floats +==================== + +When an expression requires the use of temporary intermediate +`mpf_class' values, like `f=g*h+x*y', those temporaries will have the +same precision as the destination `f'. Explicit constructors can be +used if this doesn't suit. + + - Function: mpf_class::mpf_class (type OP) + - Function: mpf_class::mpf_class (type OP, unsigned long PREC) + Construct an `mpf_class'. Any standard C++ type can be used, + except `long long' and `long double', and any of the GMP C++ + classes can be used. + + If PREC is given, the initial precision is that value, in bits. If + PREC is not given, then the initial precision is determined by the + type of OP given. An `mpz_class', `mpq_class', string, or C++ + builtin type will give the default `mpf' precision (*note + Initializing Floats::). An `mpf_class' or expression will give + the precision of that value. The precision of a binary expression + is the higher of the two operands. + + mpf_class f(1.5); // default precision + mpf_class f(1.5, 500); // 500 bits (at least) + mpf_class f(x); // precision of x + mpf_class f(abs(x)); // precision of x + mpf_class f(-g, 1000); // 1000 bits (at least) + mpf_class f(x+y); // greater of precisions of x and y + + - Function: mpf_class& mpf_class::operator= (type OP) + Convert and store the given OP value to an `mpf_class' object. The + same types are accepted as for the constructors above. + + Note that `operator=' only stores a new value, it doesn't copy or + change the precision of the destination, instead the value is + truncated if necessary. This is the same as `mpf_set' etc. Note + in particular this means for `mpf_class' a copy constructor is not + the same as a default constructor plus assignment. + + mpf_class x (y); // x created with precision of y + + mpf_class x; // x created with default precision + x = y; // value truncated to that precision + + Applications using templated code may need to be careful about the + assumptions the code makes in this area, when working with + `mpf_class' values of various different or non-default precisions. + For instance implementations of the standard `complex' template + have been seen in both styles above, though of course `complex' is + normally only actually specified for use with the builtin float + types. + + - Function: mpf_class abs (mpf_class OP) + - Function: mpf_class ceil (mpf_class OP) + - Function: int cmp (mpf_class OP1, type OP2) + - Function: int cmp (type OP1, mpf_class OP2) + - Function: mpf_class floor (mpf_class OP) + - Function: mpf_class hypot (mpf_class OP1, mpf_class OP2) + - Function: double mpf_class::get_d (void) + - Function: long mpf_class::get_si (void) + - Function: unsigned long mpf_class::get_ui (void) + - Function: bool mpf_class::fits_sint_p (void) + - Function: bool mpf_class::fits_slong_p (void) + - Function: bool mpf_class::fits_sshort_p (void) + - Function: bool mpf_class::fits_uint_p (void) + - Function: bool mpf_class::fits_ulong_p (void) + - Function: bool mpf_class::fits_ushort_p (void) + - Function: int sgn (mpf_class OP) + - Function: mpf_class sqrt (mpf_class OP) + - Function: mpf_class trunc (mpf_class OP) + These functions provide a C++ class interface to the corresponding + GMP C routines. + + `cmp' can be used with any of the classes or the standard C++ + types, except `long long' and `long double'. + + The accuracy provided by `hypot' is not currently guaranteed. + + - Function: unsigned long int mpf_class::get_prec () + - Function: void mpf_class::set_prec (unsigned long PREC) + - Function: void mpf_class::set_prec_raw (unsigned long PREC) + Get or set the current precision of an `mpf_class'. + + The restrictions described for `mpf_set_prec_raw' (*note + Initializing Floats::) apply to `mpf_class::set_prec_raw'. Note + in particular that the `mpf_class' must be restored to it's + allocated precision before being destroyed. This must be done by + application code, there's no automatic mechanism for it. + + +File: gmp.info, Node: C++ Interface MPFR, Next: C++ Interface Random Numbers, Prev: C++ Interface Floats, Up: C++ Class Interface + +C++ Interface MPFR +================== + +The C++ class interface to MPFR is provided if MPFR is enabled (*note +Build Options::). This interface must be regarded as preliminary and +possibly subject to incompatible changes in the future, since MPFR +itself is preliminary. All definitions can be obtained with + + #include + +This defines + + - Class: mpfr_class + +which behaves similarly to `mpf_class' (*note C++ Interface Floats::). + + +File: gmp.info, Node: C++ Interface Random Numbers, Next: C++ Interface Limitations, Prev: C++ Interface MPFR, Up: C++ Class Interface + +C++ Interface Random Numbers +============================ + + - Class: gmp_randclass + The C++ class interface to the GMP random number functions uses + `gmp_randclass' to hold an algorithm selection and current state, + as per `gmp_randstate_t'. + + - Function: gmp_randclass::gmp_randclass (void (*RANDINIT) + (gmp_randstate_t, ...), ...) + Construct a `gmp_randclass', using a call to the given RANDINIT + function (*note Random State Initialization::). The arguments + expected are the same as RANDINIT, but with `mpz_class' instead of + `mpz_t'. For example, + + gmp_randclass r1 (gmp_randinit_default); + gmp_randclass r2 (gmp_randinit_lc_2exp_size, 32); + gmp_randclass r3 (gmp_randinit_lc_2exp, a, c, m2exp); + + `gmp_randinit_lc_2exp_size' can fail if the size requested is too + big, the behaviour of `gmp_randclass::gmp_randclass' is undefined + in this case (perhaps this will change in the future). + + - Function: gmp_randclass::gmp_randclass (gmp_randalg_t ALG, ...) + Construct a `gmp_randclass' using the same parameters as + `gmp_randinit' (*note Random State Initialization::). This + function is obsolete and the above RANDINIT style should be + preferred. + + - Function: void gmp_randclass::seed (unsigned long int S) + - Function: void gmp_randclass::seed (mpz_class S) + Seed a random number generator. See *note Random Number + Functions::, for how to choose a good seed. + + - Function: mpz_class gmp_randclass::get_z_bits (unsigned long BITS) + - Function: mpz_class gmp_randclass::get_z_bits (mpz_class BITS) + Generate a random integer with a specified number of bits. + + - Function: mpz_class gmp_randclass::get_z_range (mpz_class N) + Generate a random integer in the range 0 to N-1 inclusive. + + - Function: mpf_class gmp_randclass::get_f () + - Function: mpf_class gmp_randclass::get_f (unsigned long PREC) + Generate a random float F in the range 0 <= F < 1. F will be to + PREC bits precision, or if PREC is not given then to the precision + of the destination. For example, + + gmp_randclass r; + ... + mpf_class f (0, 512); // 512 bits precision + f = r.get_f(); // random number, 512 bits + + +File: gmp.info, Node: C++ Interface Limitations, Prev: C++ Interface Random Numbers, Up: C++ Class Interface + +C++ Interface Limitations +========================= + +`mpq_class' and Templated Reading + A generic piece of template code probably won't know that + `mpq_class' requires a `canonicalize' call if inputs read with + `operator>>' might be non-canonical. This can lead to incorrect + results. + + `operator>>' behaves as it does for reasons of efficiency. A + canonicalize can be quite time consuming on large operands, and is + best avoided if it's not necessary. + + But this potential difficulty reduces the usefulness of + `mpq_class'. Perhaps a mechanism to tell `operator>>' what to do + will be adopted in the future, maybe a preprocessor define, a + global flag, or an `ios' flag pressed into service. Or maybe, at + the risk of inconsistency, the `mpq_class' `operator>>' could + canonicalize and leave `mpq_t' `operator>>' not doing so, for use + on those occasions when that's acceptable. Send feedback or + alternate ideas to . + +Subclassing + Subclassing the GMP C++ classes works, but is not currently + recommended. + + Expressions involving subclasses resolve correctly (or seem to), + but in normal C++ fashion the subclass doesn't inherit + constructors and assignments. There's many of those in the GMP + classes, and a good way to reestablish them in a subclass is not + yet provided. + +Templated Expressions + A subtle difficulty exists when using expressions together with + application-defined template functions. Consider the following, + with `T' intended to be some numeric type, + + template + T fun (const T &, const T &); + + When used with, say, plain `mpz_class' variables, it works fine: + `T' is resolved as `mpz_class'. + + mpz_class f(1), g(2); + fun (f, g); // Good + + But when one of the arguments is an expression, it doesn't work. + + mpz_class f(1), g(2), h(3); + fun (f, g+h); // Bad + + This is because `g+h' ends up being a certain expression template + type internal to `gmpxx.h', which the C++ template resolution + rules are unable to automatically convert to `mpz_class'. The + workaround is simply to add an explicit cast. + + mpz_class f(1), g(2), h(3); + fun (f, mpz_class(g+h)); // Good + + Similarly, within `fun' it may be necessary to cast an expression + to type `T' when calling a templated `fun2'. + + template + void fun (T f, T g) + { + fun2 (f, f+g); // Bad + } + + template + void fun (T f, T g) + { + fun2 (f, T(f+g)); // Good + } + + +File: gmp.info, Node: BSD Compatible Functions, Next: Custom Allocation, Prev: C++ Class Interface, Up: Top + +Berkeley MP Compatible Functions +******************************** + +These functions are intended to be fully compatible with the Berkeley MP +library which is available on many BSD derived U*ix systems. The +`--enable-mpbsd' option must be used when building GNU MP to make these +available (*note Installing GMP::). + + The original Berkeley MP library has a usage restriction: you cannot +use the same variable as both source and destination in a single +function call. The compatible functions in GNU MP do not share this +restriction--inputs and outputs may overlap. + + It is not recommended that new programs are written using these +functions. Apart from the incomplete set of functions, the interface +for initializing `MINT' objects is more error prone, and the `pow' +function collides with `pow' in `libm.a'. + + Include the header `mp.h' to get the definition of the necessary +types and functions. If you are on a BSD derived system, make sure to +include GNU `mp.h' if you are going to link the GNU `libmp.a' to your +program. This means that you probably need to give the `-I' +option to the compiler, where `' is the directory where you have +GNU `mp.h'. + + - Function: MINT * itom (signed short int INITIAL_VALUE) + Allocate an integer consisting of a `MINT' object and dynamic limb + space. Initialize the integer to INITIAL_VALUE. Return a pointer + to the `MINT' object. + + - Function: MINT * xtom (char *INITIAL_VALUE) + Allocate an integer consisting of a `MINT' object and dynamic limb + space. Initialize the integer from INITIAL_VALUE, a hexadecimal, + null-terminated C string. Return a pointer to the `MINT' object. + + - Function: void move (MINT *SRC, MINT *DEST) + Set DEST to SRC by copying. Both variables must be previously + initialized. + + - Function: void madd (MINT *SRC_1, MINT *SRC_2, MINT *DESTINATION) + Add SRC_1 and SRC_2 and put the sum in DESTINATION. + + - Function: void msub (MINT *SRC_1, MINT *SRC_2, MINT *DESTINATION) + Subtract SRC_2 from SRC_1 and put the difference in DESTINATION. + + - Function: void mult (MINT *SRC_1, MINT *SRC_2, MINT *DESTINATION) + Multiply SRC_1 and SRC_2 and put the product in DESTINATION. + + - Function: void mdiv (MINT *DIVIDEND, MINT *DIVISOR, MINT *QUOTIENT, + MINT *REMAINDER) + - Function: void sdiv (MINT *DIVIDEND, signed short int DIVISOR, MINT + *QUOTIENT, signed short int *REMAINDER) + Set QUOTIENT to DIVIDEND/DIVISOR, and REMAINDER to DIVIDEND mod + DIVISOR. The quotient is rounded towards zero; the remainder has + the same sign as the dividend unless it is zero. + + Some implementations of these functions work differently--or not + at all--for negative arguments. + + - Function: void msqrt (MINT *OP, MINT *ROOT, MINT *REMAINDER) + Set ROOT to the truncated integer part of the square root of OP, + like `mpz_sqrt'. Set REMAINDER to OP-ROOT*ROOT, i.e. zero if OP + is a perfect square. + + If ROOT and REMAINDER are the same variable, the results are + undefined. + + - Function: void pow (MINT *BASE, MINT *EXP, MINT *MOD, MINT *DEST) + Set DEST to (BASE raised to EXP) modulo MOD. + + Note that the name `pow' clashes with `pow' from the standard C + math library (*note Exponentiation and Logarithms: (libc)Exponents + and Logarithms.). An application will only be able to use one or + the other. + + - Function: void rpow (MINT *BASE, signed short int EXP, MINT *DEST) + Set DEST to BASE raised to EXP. + + - Function: void gcd (MINT *OP1, MINT *OP2, MINT *RES) + Set RES to the greatest common divisor of OP1 and OP2. + + - Function: int mcmp (MINT *OP1, MINT *OP2) + Compare OP1 and OP2. Return a positive value if OP1 > OP2, zero + if OP1 = OP2, and a negative value if OP1 < OP2. + + - Function: void min (MINT *DEST) + Input a decimal string from `stdin', and put the read integer in + DEST. SPC and TAB are allowed in the number string, and are + ignored. + + - Function: void mout (MINT *SRC) + Output SRC to `stdout', as a decimal string. Also output a + newline. + + - Function: char * mtox (MINT *OP) + Convert OP to a hexadecimal string, and return a pointer to the + string. The returned string is allocated using the default memory + allocation function, `malloc' by default. It will be + `strlen(str)+1' bytes, that being exactly enough for the string + and null-terminator. + + - Function: void mfree (MINT *OP) + De-allocate, the space used by OP. *This function should only be + passed a value returned by `itom' or `xtom'.* + + +File: gmp.info, Node: Custom Allocation, Next: Language Bindings, Prev: BSD Compatible Functions, Up: Top + +Custom Allocation +***************** + +By default GMP uses `malloc', `realloc' and `free' for memory +allocation, and if they fail GMP prints a message to the standard error +output and terminates the program. + + Alternate functions can be specified to allocate memory in a +different way or to have a different error action on running out of +memory. + + This feature is available in the Berkeley compatibility library +(*note BSD Compatible Functions::) as well as the main GMP library. + + - Function: void mp_set_memory_functions ( + void *(*ALLOC_FUNC_PTR) (size_t), + void *(*REALLOC_FUNC_PTR) (void *, size_t, size_t), + void (*FREE_FUNC_PTR) (void *, size_t)) + Replace the current allocation functions from the arguments. If + an argument is `NULL', the corresponding default function is used. + + These functions will be used for all memory allocation done by + GMP, apart from temporary space from `alloca' if that function is + available and GMP is configured to use it (*note Build Options::). + + *Be sure to call `mp_set_memory_functions' only when there are no + active GMP objects allocated using the previous memory functions! + Usually that means calling it before any other GMP function.* + + The functions supplied should fit the following declarations: + + - Function: void * allocate_function (size_t ALLOC_SIZE) + Return a pointer to newly allocated space with at least ALLOC_SIZE + bytes. + + - Function: void * reallocate_function (void *PTR, size_t OLD_SIZE, + size_t NEW_SIZE) + Resize a previously allocated block PTR of OLD_SIZE bytes to be + NEW_SIZE bytes. + + The block may be moved if necessary or if desired, and in that + case the smaller of OLD_SIZE and NEW_SIZE bytes must be copied to + the new location. The return value is a pointer to the resized + block, that being the new location if moved or just PTR if not. + + PTR is never `NULL', it's always a previously allocated block. + NEW_SIZE may be bigger or smaller than OLD_SIZE. + + - Function: void deallocate_function (void *PTR, size_t SIZE) + De-allocate the space pointed to by PTR. + + PTR is never `NULL', it's always a previously allocated block of + SIZE bytes. + + A "byte" here means the unit used by the `sizeof' operator. + + The OLD_SIZE parameters to REALLOCATE_FUNCTION and +DEALLOCATE_FUNCTION are passed for convenience, but of course can be +ignored if not needed. The default functions using `malloc' and friends +for instance don't use them. + + No error return is allowed from any of these functions, if they +return then they must have performed the specified operation. In +particular note that ALLOCATE_FUNCTION or REALLOCATE_FUNCTION mustn't +return `NULL'. + + Getting a different fatal error action is a good use for custom +allocation functions, for example giving a graphical dialog rather than +the default print to `stderr'. How much is possible when genuinely out +of memory is another question though. + + There's currently no defined way for the allocation functions to +recover from an error such as out of memory, they must terminate +program execution. A `longjmp' or throwing a C++ exception will have +undefined results. This may change in the future. + + GMP may use allocated blocks to hold pointers to other allocated +blocks. This will limit the assumptions a conservative garbage +collection scheme can make. + + Since the default GMP allocation uses `malloc' and friends, those +functions will be linked in even if the first thing a program does is an +`mp_set_memory_functions'. It's necessary to change the GMP sources if +this is a problem. + + +File: gmp.info, Node: Language Bindings, Next: Algorithms, Prev: Custom Allocation, Up: Top + +Language Bindings +***************** + +The following packages and projects offer access to GMP from languages +other than C, though perhaps with varying levels of functionality and +efficiency. + + +C++ + * GMP C++ class interface, *note C++ Class Interface:: + Straightforward interface, expression templates to eliminate + temporaries. + + * ALP `http://www.inria.fr/saga/logiciels/ALP' + Linear algebra and polynomials using templates. + + * Arithmos `http://win-www.uia.ac.be/u/cant/arithmos' + Rationals with infinities and square roots. + + * CLN `http://www.ginac.de/CLN/' + High level classes for arithmetic. + + * LiDIA `http://www.informatik.tu-darmstadt.de/TI/LiDIA' + A C++ library for computational number theory. + + * Linbox `http://www.linalg.org' + Sparse vectors and matrices. + + * NTL `http://www.shoup.net/ntl' + A C++ number theory library. + +Fortran + * Omni F77 `http://phase.hpcc.jp/Omni/home.html' + Arbitrary precision floats. + +Haskell + * Glasgow Haskell Compiler `http://www.haskell.org/ghc' + +Java + * Kaffe `http://www.kaffe.org' + + * Kissme `http://kissme.sourceforge.net' + +Lisp + * GNU Common Lisp `http://www.gnu.org/software/gcl/gcl.html' + In the process of switching to GMP for bignums. + + * Librep `http://librep.sourceforge.net' + + * XEmacs (21.5.18 beta and up) `http://www.xemacs.org' + Optional big integers, rationals and floats using GMP. + +M4 + * GNU m4 betas `http://www.seindal.dk/rene/gnu' + Optionally provides an arbitrary precision `mpeval'. + +ML + * MLton compiler `http://www.mlton.org' + +Objective Caml + * MLGMP `http://www.di.ens.fr/~monniaux/programmes.html.en' + + * Numerix `http://pauillac.inria.fr/~quercia/' + Optionally using GMP. + +Oz + * Mozart `http://www.mozart-oz.org' + +Pascal + * GNU Pascal Compiler `http://www.gnu-pascal.de' + GMP unit. + + * Numerix `http://pauillac.inria.fr/~quercia/' + For Free Pascal, optionally using GMP. + +Perl + * GMP module, see `demos/perl' in the GMP sources. + + * Math::GMP `http://www.cpan.org' + Compatible with Math::BigInt, but not as many functions as + the GMP module above. + + * Math::BigInt::GMP `http://www.cpan.org' + Plug Math::GMP into normal Math::BigInt operations. + +Pike + * mpz module in the standard distribution, + `http://pike.ida.liu.se/' + +Prolog + * SWI Prolog `http://www.swi.psy.uva.nl/projects/SWI-Prolog' + Arbitrary precision floats. + +Python + * mpz module in the standard distribution, + `http://www.python.org' + + * GMPY `http://gmpy.sourceforge.net' + +Scheme + * GNU Guile (upcoming 1.8) + `http://www.gnu.org/software/guile/guile.html' + + * RScheme `http://www.rscheme.org' + + * STklos `http://kaolin.unice.fr/STklos' + +Smalltalk + * GNU Smalltalk + `http://www.smalltalk.org/versions/GNUSmalltalk.html' + +Other + * Axiom `http://savannah.nongnu.org/projects/axiom' + Computer algebra using GCL. + + * DrGenius `http://drgenius.seul.org' + Geometry system and mathematical programming language. + + * GiNaC `http://www.ginac.de' + C++ computer algebra using CLN. + + * GOO `http://www.googoogaga.org/' + Dynamic object oriented language. + + * Maxima `http://www.ma.utexas.edu/users/wfs/maxima.html' + Macsyma computer algebra using GCL. + + * Q `http://www.musikwissenschaft.uni-mainz.de/~ag/q' + Equational programming system. + + * Regina `http://regina.sourceforge.net' + Topological calculator. + + * Yacas `http://www.xs4all.nl/~apinkus/yacas.html' + Yet another computer algebra system. + + + +File: gmp.info, Node: Algorithms, Next: Internals, Prev: Language Bindings, Up: Top + +Algorithms +********** + +This chapter is an introduction to some of the algorithms used for +various GMP operations. The code is likely to be hard to understand +without knowing something about the algorithms. + + Some GMP internals are mentioned, but applications that expect to be +compatible with future GMP releases should take care to use only the +documented functions. + +* Menu: + +* Multiplication Algorithms:: +* Division Algorithms:: +* Greatest Common Divisor Algorithms:: +* Powering Algorithms:: +* Root Extraction Algorithms:: +* Radix Conversion Algorithms:: +* Other Algorithms:: +* Assembler Coding:: + + +File: gmp.info, Node: Multiplication Algorithms, Next: Division Algorithms, Prev: Algorithms, Up: Algorithms + +Multiplication +============== + +NxN limb multiplications and squares are done using one of four +algorithms, as the size N increases. + + Algorithm Threshold + Basecase (none) + Karatsuba `MUL_KARATSUBA_THRESHOLD' + Toom-3 `MUL_TOOM3_THRESHOLD' + FFT `MUL_FFT_THRESHOLD' + + Similarly for squaring, with the `SQR' thresholds. Note though that +the FFT is only used if GMP is configured with `--enable-fft', *note +Build Options::. + + NxM multiplications of operands with different sizes above +`MUL_KARATSUBA_THRESHOLD' are currently done by splitting into MxM +pieces. The Karatsuba and Toom-3 routines then operate only on equal +size operands. This is not very efficient, and is slated for +improvement in the future. + +* Menu: + +* Basecase Multiplication:: +* Karatsuba Multiplication:: +* Toom-Cook 3-Way Multiplication:: +* FFT Multiplication:: +* Other Multiplication:: + + +File: gmp.info, Node: Basecase Multiplication, Next: Karatsuba Multiplication, Prev: Multiplication Algorithms, Up: Multiplication Algorithms + +Basecase Multiplication +----------------------- + +Basecase NxM multiplication is a straightforward rectangular set of +cross-products, the same as long multiplication done by hand and for +that reason sometimes known as the schoolbook or grammar school method. +This is an O(N*M) algorithm. See Knuth section 4.3.1 algorithm M +(*note References::), and the `mpn/generic/mul_basecase.c' code. + + Assembler implementations of `mpn_mul_basecase' are essentially the +same as the generic C code, but have all the usual assembler tricks and +obscurities introduced for speed. + + A square can be done in roughly half the time of a multiply, by +using the fact that the cross products above and below the diagonal are +the same. A triangle of products below the diagonal is formed, doubled +(left shift by one bit), and then the products on the diagonal added. +This can be seen in `mpn/generic/sqr_basecase.c'. Again the assembler +implementations take essentially the same approach. + + u0 u1 u2 u3 u4 + +---+---+---+---+---+ + u0 | d | | | | | + +---+---+---+---+---+ + u1 | | d | | | | + +---+---+---+---+---+ + u2 | | | d | | | + +---+---+---+---+---+ + u3 | | | | d | | + +---+---+---+---+---+ + u4 | | | | | d | + +---+---+---+---+---+ + + In practice squaring isn't a full 2x faster than multiplying, it's +usually around 1.5x. Less than 1.5x probably indicates +`mpn_sqr_basecase' wants improving on that CPU. + + On some CPUs `mpn_mul_basecase' can be faster than the generic C +`mpn_sqr_basecase'. `SQR_BASECASE_THRESHOLD' is the size at which to +use `mpn_sqr_basecase', this will be zero if that routine should be +used always. + + +File: gmp.info, Node: Karatsuba Multiplication, Next: Toom-Cook 3-Way Multiplication, Prev: Basecase Multiplication, Up: Multiplication Algorithms + +Karatsuba Multiplication +------------------------ + +The Karatsuba multiplication algorithm is described in Knuth section +4.3.3 part A, and various other textbooks. A brief description is +given here. + + The inputs x and y are treated as each split into two parts of equal +length (or the most significant part one limb shorter if N is odd). + + high low + +----------+----------+ + | x1 | x0 | + +----------+----------+ + + +----------+----------+ + | y1 | y0 | + +----------+----------+ + + Let b be the power of 2 where the split occurs, ie. if x0 is k limbs +(y0 the same) then b=2^(k*mp_bits_per_limb). With that x=x1*b+x0 and +y=y1*b+y0, and the following holds, + + x*y = (b^2+b)*x1*y1 - b*(x1-x0)*(y1-y0) + (b+1)*x0*y0 + + This formula means doing only three multiplies of (N/2)x(N/2) limbs, +whereas a basecase multiply of NxN limbs is equivalent to four +multiplies of (N/2)x(N/2). The factors (b^2+b) etc represent the +positions where the three products must be added. + + high low + +--------+--------+ +--------+--------+ + | x1*y1 | | x0*y0 | + +--------+--------+ +--------+--------+ + +--------+--------+ + add | x1*y1 | + +--------+--------+ + +--------+--------+ + add | x0*y0 | + +--------+--------+ + +--------+--------+ + sub | (x1-x0)*(y1-y0) | + +--------+--------+ + + The term (x1-x0)*(y1-y0) is best calculated as an absolute value, +and the sign used to choose to add or subtract. Notice the sum +high(x0*y0)+low(x1*y1) occurs twice, so it's possible to do 5*k limb +additions, rather than 6*k, but in GMP extra function call overheads +outweigh the saving. + + Squaring is similar to multiplying, but with x=y the formula reduces +to an equivalent with three squares, + + x^2 = (b^2+b)*x1^2 - b*(x1-x0)^2 + (b+1)*x0^2 + + The final result is accumulated from those three squares the same +way as for the three multiplies above. The middle term (x1-x0)^2 is now +always positive. + + A similar formula for both multiplying and squaring can be +constructed with a middle term (x1+x0)*(y1+y0). But those sums can +exceed k limbs, leading to more carry handling and additions than the +form above. + + Karatsuba multiplication is asymptotically an O(N^1.585) algorithm, +the exponent being log(3)/log(2), representing 3 multiplies each 1/2 +the size of the inputs. This is a big improvement over the basecase +multiply at O(N^2) and the advantage soon overcomes the extra additions +Karatsuba performs. `MUL_KARATSUBA_THRESHOLD' can be as little as 10 +limbs. The `SQR' threshold is usually about twice the `MUL'. + + The basecase algorithm will take a time of the form M(N) = a*N^2 + +b*N + c and the Karatsuba algorithm K(N) = 3*M(N/2) + d*N + e, which +expands to K(N) = 3/4*a*N^2 + 3/2*b*N + 3*c + d*N + e. The factor 3/4 +for a means per-crossproduct speedups in the basecase code will +increase the threshold since they benefit M(N) more than K(N). And +conversely the 3/2 for b means linear style speedups of b will increase +the threshold since they benefit K(N) more than M(N). The latter can +be seen for instance when adding an optimized `mpn_sqr_diagonal' to +`mpn_sqr_basecase'. Of course all speedups reduce total time, and in +that sense the algorithm thresholds are merely of academic interest. + + +File: gmp.info, Node: Toom-Cook 3-Way Multiplication, Next: FFT Multiplication, Prev: Karatsuba Multiplication, Up: Multiplication Algorithms + +Toom-Cook 3-Way Multiplication +------------------------------ + +The Karatsuba formula is the simplest case of a general approach to +splitting inputs that leads to both Toom-Cook and FFT algorithms. A +description of Toom-Cook can be found in Knuth section 4.3.3, with an +example 3-way calculation after Theorem A. The 3-way form used in GMP +is described here. + + The operands are each considered split into 3 pieces of equal length +(or the most significant part 1 or 2 limbs shorter than the others). + + high low + +----------+----------+----------+ + | x2 | x1 | x0 | + +----------+----------+----------+ + + +----------+----------+----------+ + | y2 | y1 | y0 | + +----------+----------+----------+ + +These parts are treated as the coefficients of two polynomials + + X(t) = x2*t^2 + x1*t + x0 + Y(t) = y2*t^2 + y1*t + y0 + + Again let b equal the power of 2 which is the size of the x0, x1, y0 +and y1 pieces, ie. if they're k limbs each then +b=2^(k*mp_bits_per_limb). With this x=X(b) and y=Y(b). + + Let a polynomial W(t)=X(t)*Y(t) and suppose its coefficients are + + W(t) = w4*t^4 + w3*t^3 + w2*t^2 + w1*t + w0 + +The w[i] are going to be determined, and when they are they'll give the +final result using w=W(b), since x*y=X(b)*Y(b)=W(b). The coefficients +will be roughly b^2 each, and the final W(b) will be an addition like, + + high low + +-------+-------+ + | w4 | + +-------+-------+ + +--------+-------+ + | w3 | + +--------+-------+ + +--------+-------+ + | w2 | + +--------+-------+ + +--------+-------+ + | w1 | + +--------+-------+ + +-------+-------+ + | w0 | + +-------+-------+ + + The w[i] coefficients could be formed by a simple set of cross +products, like w4=x2*y2, w3=x2*y1+x1*y2, w2=x2*y0+x1*y1+x0*y2 etc, but +this would need all nine x[i]*y[j] for i,j=0,1,2, and would be +equivalent merely to a basecase multiply. Instead the following +approach is used. + + X(t) and Y(t) are evaluated and multiplied at 5 points, giving +values of W(t) at those points. The points used can be chosen in +various ways, but in GMP the following are used + + Point Value + t=0 x0*y0, which gives w0 immediately + t=2 (4*x2+2*x1+x0)*(4*y2+2*y1+y0) + t=1 (x2+x1+x0)*(y2+y1+y0) + t=1/2 (x2+2*x1+4*x0)*(y2+2*y1+4*y0) + t=inf x2*y2, which gives w4 immediately + + At t=1/2 the value calculated is actually 16*X(1/2)*Y(1/2), giving a +value for 16*W(1/2), and this is always an integer. At t=inf the value +is actually X(t)*Y(t)/t^4 in the limit as t approaches infinity, but +it's much easier to think of as simply x2*y2 giving w4 immediately +(much like x0*y0 at t=0 gives w0 immediately). + + Now each of the points substituted into W(t)=w4*t^4+...+w0 gives a +linear combination of the w[i] coefficients, and the value of those +combinations has just been calculated. + + W(0) = w0 + 16*W(1/2) = w4 + 2*w3 + 4*w2 + 8*w1 + 16*w0 + W(1) = w4 + w3 + w2 + w1 + w0 + W(2) = 16*w4 + 8*w3 + 4*w2 + 2*w1 + w0 + W(inf) = w4 + + This is a set of five equations in five unknowns, and some +elementary linear algebra quickly isolates each w[i], by subtracting +multiples of one equation from another. + + In the code the set of five values W(0),...,W(inf) will represent +those certain linear combinations. By adding or subtracting one from +another as necessary, values which are each w[i] alone are arrived at. +This involves only a few subtractions of small multiples (some of which +are powers of 2), and so is fast. A couple of divisions remain by +powers of 2 and one division by 3 (or by 6 rather), and that last uses +the special `mpn_divexact_by3' (*note Exact Division::). + + In the code the values w4, w2 and w0 are formed in the destination +with pointers `E', `C' and `A', and w3 and w1 in temporary space `D' +and `B' are added to them. There are extra limbs `tD', `tC' and `tB' +at the high end of w3, w2 and w1 which are handled separately. The +final addition then is as follows. + + high low + +-------+-------+-------+-------+-------+-------+ + | E | C | A | + +-------+-------+-------+-------+-------+-------+ + +------+-------++------+-------+ + | D || B | + +------+-------++------+-------+ + -- -- -- + |tD| |tC| |tB| + -- -- -- + + The conversion of W(t) values to the coefficients is interpolation. +A polynomial of degree 4 like W(t) is uniquely determined by values +known at 5 different points. The points can be chosen to make the +linear equations come out with a convenient set of steps for isolating +the w[i]. + + In `mpn/generic/mul_n.c' the `interpolate3' routine performs the +interpolation. The open-coded one-pass version may be a bit hard to +understand, the steps performed can be better seen in the `USE_MORE_MPN' +version. + + Squaring follows the same procedure as multiplication, but there's +only one X(t) and it's evaluated at 5 points, and those values squared +to give values of W(t). The interpolation is then identical, and in +fact the same `interpolate3' subroutine is used for both squaring and +multiplying. + + Toom-3 is asymptotically O(N^1.465), the exponent being +log(5)/log(3), representing 5 recursive multiplies of 1/3 the original +size. This is an improvement over Karatsuba at O(N^1.585), though +Toom-Cook does more work in the evaluation and interpolation and so it +only realizes its advantage above a certain size. + + Near the crossover between Toom-3 and Karatsuba there's generally a +range of sizes where the difference between the two is small. +`MUL_TOOM3_THRESHOLD' is a somewhat arbitrary point in that range and +successive runs of the tune program can give different values due to +small variations in measuring. A graph of time versus size for the two +shows the effect, see `tune/README'. + + At the fairly small sizes where the Toom-3 thresholds occur it's +worth remembering that the asymptotic behaviour for Karatsuba and +Toom-3 can't be expected to make accurate predictions, due of course to +the big influence of all sorts of overheads, and the fact that only a +few recursions of each are being performed. Even at large sizes +there's a good chance machine dependent effects like cache architecture +will mean actual performance deviates from what might be predicted. + + The formula given above for the Karatsuba algorithm has an +equivalent for Toom-3 involving only five multiplies, but this would be +complicated and unenlightening. + + An alternate view of Toom-3 can be found in Zuras (*note +References::), using a vector to represent the x and y splits and a +matrix multiplication for the evaluation and interpolation stages. The +matrix inverses are not meant to be actually used, and they have +elements with values much greater than in fact arise in the +interpolation steps. The diagram shown for the 3-way is attractive, +but again doesn't have to be implemented that way and for example with +a bit of rearrangement just one division by 6 can be done. + + +File: gmp.info, Node: FFT Multiplication, Next: Other Multiplication, Prev: Toom-Cook 3-Way Multiplication, Up: Multiplication Algorithms + +FFT Multiplication +------------------ + +At large to very large sizes a Fermat style FFT multiplication is used, +following Scho"nhage and Strassen (*note References::). Descriptions +of FFTs in various forms can be found in many textbooks, for instance +Knuth section 4.3.3 part C or Lipson chapter IX. A brief description +of the form used in GMP is given here. + + The multiplication done is x*y mod 2^N+1, for a given N. A full +product x*y is obtained by choosing N>=bits(x)+bits(y) and padding x +and y with high zero limbs. The modular product is the native form for +the algorithm, so padding to get a full product is unavoidable. + + The algorithm follows a split, evaluate, pointwise multiply, +interpolate and combine similar to that described above for Karatsuba +and Toom-3. A k parameter controls the split, with an FFT-k splitting +into 2^k pieces of M=N/2^k bits each. N must be a multiple of +(2^k)*mp_bits_per_limb so the split falls on limb boundaries, avoiding +bit shifts in the split and combine stages. + + The evaluations, pointwise multiplications, and interpolation, are +all done modulo 2^N'+1 where N' is 2M+k+3 rounded up to a multiple of +2^k and of `mp_bits_per_limb'. The results of interpolation will be +the following negacyclic convolution of the input pieces, and the +choice of N' ensures these sums aren't truncated. + + --- + \ b + w[n] = / (-1) * x[i] * y[j] + --- + i+j==b*2^k+n + b=0,1 + + The points used for the evaluation are g^i for i=0 to 2^k-1 where +g=2^(2N'/2^k). g is a 2^k'th root of unity mod 2^N'+1, which produces +necessary cancellations at the interpolation stage, and it's also a +power of 2 so the fast fourier transforms used for the evaluation and +interpolation do only shifts, adds and negations. + + The pointwise multiplications are done modulo 2^N'+1 and either +recurse into a further FFT or use a plain multiplication (Toom-3, +Karatsuba or basecase), whichever is optimal at the size N'. The +interpolation is an inverse fast fourier transform. The resulting set +of sums of x[i]*y[j] are added at appropriate offsets to give the final +result. + + Squaring is the same, but x is the only input so it's one transform +at the evaluate stage and the pointwise multiplies are squares. The +interpolation is the same. + + For a mod 2^N+1 product, an FFT-k is an O(N^(k/(k-1))) algorithm, +the exponent representing 2^k recursed modular multiplies each +1/2^(k-1) the size of the original. Each successive k is an asymptotic +improvement, but overheads mean each is only faster at bigger and +bigger sizes. In the code, `MUL_FFT_TABLE' and `SQR_FFT_TABLE' are the +thresholds where each k is used. Each new k effectively swaps some +multiplying for some shifts, adds and overheads. + + A mod 2^N+1 product can be formed with a normal NxN->2N bit multiply +plus a subtraction, so an FFT and Toom-3 etc can be compared directly. +A k=4 FFT at O(N^1.333) can be expected to be the first faster than +Toom-3 at O(N^1.465). In practice this is what's found, with +`MUL_FFT_MODF_THRESHOLD' and `SQR_FFT_MODF_THRESHOLD' being between 300 +and 1000 limbs, depending on the CPU. So far it's been found that only +very large FFTs recurse into pointwise multiplies above these sizes. + + When an FFT is to give a full product, the change of N to 2N doesn't +alter the theoretical complexity for a given k, but for the purposes of +considering where an FFT might be first used it can be assumed that the +FFT is recursing into a normal multiply and that on that basis it's +doing 2^k recursed multiplies each 1/2^(k-2) the size of the inputs, +making it O(N^(k/(k-2))). This would mean k=7 at O(N^1.4) would be the +first FFT faster than Toom-3. In practice `MUL_FFT_THRESHOLD' and +`SQR_FFT_THRESHOLD' have been found to be in the k=8 range, somewhere +between 3000 and 10000 limbs. + + The way N is split into 2^k pieces and then 2M+k+3 is rounded up to +a multiple of 2^k and `mp_bits_per_limb' means that when +2^k>=mp_bits_per_limb the effective N is a multiple of 2^(2k-1) bits. +The +k+3 means some values of N just under such a multiple will be +rounded to the next. The complexity calculations above assume that a +favourable size is used, meaning one which isn't padded through +rounding, and it's also assumed that the extra +k+3 bits are negligible +at typical FFT sizes. + + The practical effect of the 2^(2k-1) constraint is to introduce a +step-effect into measured speeds. For example k=8 will round N up to a +multiple of 32768 bits, so for a 32-bit limb there'll be 512 limb +groups of sizes for which `mpn_mul_n' runs at the same speed. Or for +k=9 groups of 2048 limbs, k=10 groups of 8192 limbs, etc. In practice +it's been found each k is used at quite small multiples of its size +constraint and so the step effect is quite noticeable in a time versus +size graph. + + The threshold determinations currently measure at the mid-points of +size steps, but this is sub-optimal since at the start of a new step it +can happen that it's better to go back to the previous k for a while. +Something more sophisticated for `MUL_FFT_TABLE' and `SQR_FFT_TABLE' +will be needed. + + +File: gmp.info, Node: Other Multiplication, Prev: FFT Multiplication, Up: Multiplication Algorithms + +Other Multiplication +-------------------- + +The 3-way Toom-Cook algorithm described above (*note Toom-Cook 3-Way +Multiplication::) generalizes to split into an arbitrary number of +pieces, as per Knuth section 4.3.3 algorithm C. This is not currently +used, though it's possible a Toom-4 might fit in between Toom-3 and the +FFTs. The notes here are merely for interest. + + In general a split into r+1 pieces is made, and evaluations and +pointwise multiplications done at 2*r+1 points. A 4-way split does 7 +pointwise multiplies, 5-way does 9, etc. Asymptotically an (r+1)-way +algorithm is O(N^(log(2*r+1)/log(r+1))). Only the pointwise +multiplications count towards big-O complexity, but the time spent in +the evaluate and interpolate stages grows with r and has a significant +practical impact, with the asymptotic advantage of each r realized only +at bigger and bigger sizes. The overheads grow as O(N*r), whereas in +an r=2^k FFT they grow only as O(N*log(r)). + + Knuth algorithm C evaluates at points 0,1,2,...,2*r, but exercise 4 +uses -r,...,0,...,r and the latter saves some small multiplies in the +evaluate stage (or rather trades them for additions), and has a further +saving of nearly half the interpolate steps. The idea is to separate +odd and even final coefficients and then perform algorithm C steps C7 +and C8 on them separately. The divisors at step C7 become j^2 and the +multipliers at C8 become 2*t*j-j^2. + + Splitting odd and even parts through positive and negative points +can be thought of as using -1 as a square root of unity. If a 4th root +of unity was available then a further split and speedup would be +possible, but no such root exists for plain integers. Going to complex +integers with i=sqrt(-1) doesn't help, essentially because in cartesian +form it takes three real multiplies to do a complex multiply. The +existence of 2^k'th roots of unity in a suitable ring or field lets the +fast fourier transform keep splitting and get to O(N*log(r)). + + Floating point FFTs use complex numbers approximating Nth roots of +unity. Some processors have special support for such FFTs. But these +are not used in GMP since it's very difficult to guarantee an exact +result (to some number of bits). An occasional difference of 1 in the +last bit might not matter to a typical signal processing algorithm, but +is of course of vital importance to GMP. + + +File: gmp.info, Node: Division Algorithms, Next: Greatest Common Divisor Algorithms, Prev: Multiplication Algorithms, Up: Algorithms + +Division Algorithms +=================== + +* Menu: + +* Single Limb Division:: +* Basecase Division:: +* Divide and Conquer Division:: +* Exact Division:: +* Exact Remainder:: +* Small Quotient Division:: + + +File: gmp.info, Node: Single Limb Division, Next: Basecase Division, Prev: Division Algorithms, Up: Division Algorithms + +Single Limb Division +-------------------- + +Nx1 division is implemented using repeated 2x1 divisions from high to +low, either with a hardware divide instruction or a multiplication by +inverse, whichever is best on a given CPU. + + The multiply by inverse follows section 8 of "Division by Invariant +Integers using Multiplication" by Granlund and Montgomery (*note +References::) and is implemented as `udiv_qrnnd_preinv' in +`gmp-impl.h'. The idea is to have a fixed-point approximation to 1/d +(see `invert_limb') and then multiply by the high limb (plus one bit) +of the dividend to get a quotient q. With d normalized (high bit set), +q is no more than 1 too small. Subtracting q*d from the dividend gives +a remainder, and reveals whether q or q-1 is correct. + + The result is a division done with two multiplications and four or +five arithmetic operations. On CPUs with low latency multipliers this +can be much faster than a hardware divide, though the cost of +calculating the inverse at the start may mean it's only better on +inputs bigger than say 4 or 5 limbs. + + When a divisor must be normalized, either for the generic C +`__udiv_qrnnd_c' or the multiply by inverse, the division performed is +actually a*2^k by d*2^k where a is the dividend and k is the power +necessary to have the high bit of d*2^k set. The bit shifts for the +dividend are usually accomplished "on the fly" meaning by extracting +the appropriate bits at each step. Done this way the quotient limbs +come out aligned ready to store. When only the remainder is wanted, an +alternative is to take the dividend limbs unshifted and calculate r = a +mod d*2^k followed by an extra final step r*2^k mod d*2^k. This can +help on CPUs with poor bit shifts or few registers. + + The multiply by inverse can be done two limbs at a time. The +calculation is basically the same, but the inverse is two limbs and the +divisor treated as if padded with a low zero limb. This means more +work, since the inverse will need a 2x2 multiply, but the four 1x1s to +do that are independent and can therefore be done partly or wholly in +parallel. Likewise for a 2x1 calculating q*d. The net effect is to +process two limbs with roughly the same two multiplies worth of latency +that one limb at a time gives. This extends to 3 or 4 limbs at a time, +though the extra work to apply the inverse will almost certainly soon +reach the limits of multiplier throughput. + + A similar approach in reverse can be taken to process just half a +limb at a time if the divisor is only a half limb. In this case the +1x1 multiply for the inverse effectively becomes two (1/2)x1 for each +limb, which can be a saving on CPUs with a fast half limb multiply, or +in fact if the only multiply is a half limb, and especially if it's not +pipelined. + + +File: gmp.info, Node: Basecase Division, Next: Divide and Conquer Division, Prev: Single Limb Division, Up: Division Algorithms + +Basecase Division +----------------- + +Basecase NxM division is like long division done by hand, but in base +2^mp_bits_per_limb. See Knuth section 4.3.1 algorithm D, and +`mpn/generic/sb_divrem_mn.c'. + + Briefly stated, while the dividend remains larger than the divisor, +a high quotient limb is formed and the Nx1 product q*d subtracted at +the top end of the dividend. With a normalized divisor (most +significant bit set), each quotient limb can be formed with a 2x1 +division and a 1x1 multiplication plus some subtractions. The 2x1 +division is by the high limb of the divisor and is done either with a +hardware divide or a multiply by inverse (the same as in *Note Single +Limb Division::) whichever is faster. Such a quotient is sometimes one +too big, requiring an addback of the divisor, but that happens rarely. + + With Q=N-M being the number of quotient limbs, this is an O(Q*M) +algorithm and will run at a speed similar to a basecase QxM +multiplication, differing in fact only in the extra multiply and divide +for each of the Q quotient limbs. + + +File: gmp.info, Node: Divide and Conquer Division, Next: Exact Division, Prev: Basecase Division, Up: Division Algorithms + +Divide and Conquer Division +--------------------------- + +For divisors larger than `DIV_DC_THRESHOLD', division is done by +dividing. Or to be precise by a recursive divide and conquer algorithm +based on work by Moenck and Borodin, Jebelean, and Burnikel and Ziegler +(*note References::). + + The algorithm consists essentially of recognising that a 2NxN +division can be done with the basecase division algorithm (*note +Basecase Division::), but using N/2 limbs as a base, not just a single +limb. This way the multiplications that arise are (N/2)x(N/2) and can +take advantage of Karatsuba and higher multiplication algorithms (*note +Multiplication Algorithms::). The "digits" of the quotient are formed +by recursive Nx(N/2) divisions. + + If the (N/2)x(N/2) multiplies are done with a basecase multiplication +then the work is about the same as a basecase division, but with more +function call overheads and with some subtractions separated from the +multiplies. These overheads mean that it's only when N/2 is above +`MUL_KARATSUBA_THRESHOLD' that divide and conquer is of use. + + `DIV_DC_THRESHOLD' is based on the divisor size N, so it will be +somewhere above twice `MUL_KARATSUBA_THRESHOLD', but how much above +depends on the CPU. An optimized `mpn_mul_basecase' can lower +`DIV_DC_THRESHOLD' a little by offering a ready-made advantage over +repeated `mpn_submul_1' calls. + + Divide and conquer is asymptotically O(M(N)*log(N)) where M(N) is +the time for an NxN multiplication done with FFTs. The actual time is +a sum over multiplications of the recursed sizes, as can be seen near +the end of section 2.2 of Burnikel and Ziegler. For example, within +the Toom-3 range, divide and conquer is 2.63*M(N). With higher +algorithms the M(N) term improves and the multiplier tends to log(N). +In practice, at moderate to large sizes, a 2NxN division is about 2 to +4 times slower than an NxN multiplication. + + Newton's method used for division is asymptotically O(M(N)) and +should therefore be superior to divide and conquer, but it's believed +this would only be for large to very large N. + + +File: gmp.info, Node: Exact Division, Next: Exact Remainder, Prev: Divide and Conquer Division, Up: Division Algorithms + +Exact Division +-------------- + +A so-called exact division is when the dividend is known to be an exact +multiple of the divisor. Jebelean's exact division algorithm uses this +knowledge to make some significant optimizations (*note References::). + + The idea can be illustrated in decimal for example with 368154 +divided by 543. Because the low digit of the dividend is 4, the low +digit of the quotient must be 8. This is arrived at from 4*7 mod 10, +using the fact 7 is the modular inverse of 3 (the low digit of the +divisor), since 3*7 == 1 mod 10. So 8*543=4344 can be subtracted from +the dividend leaving 363810. Notice the low digit has become zero. + + The procedure is repeated at the second digit, with the next +quotient digit 7 (7 == 1*7 mod 10), subtracting 7*543=3801, leaving +325800. And finally at the third digit with quotient digit 6 (8*7 mod +10), subtracting 6*543=3258 leaving 0. So the quotient is 678. + + Notice however that the multiplies and subtractions don't need to +extend past the low three digits of the dividend, since that's enough +to determine the three quotient digits. For the last quotient digit no +subtraction is needed at all. On a 2NxN division like this one, only +about half the work of a normal basecase division is necessary. + + For an NxM exact division producing Q=N-M quotient limbs, the saving +over a normal basecase division is in two parts. Firstly, each of the +Q quotient limbs needs only one multiply, not a 2x1 divide and +multiply. Secondly, the crossproducts are reduced when Q>M to +Q*M-M*(M+1)/2, or when Q<=M to Q*(Q-1)/2. Notice the savings are +complementary. If Q is big then many divisions are saved, or if Q is +small then the crossproducts reduce to a small number. + + The modular inverse used is calculated efficiently by +`modlimb_invert' in `gmp-impl.h'. This does four multiplies for a +32-bit limb, or six for a 64-bit limb. `tune/modlinv.c' has some +alternate implementations that might suit processors better at bit +twiddling than multiplying. + + The sub-quadratic exact division described by Jebelean in "Exact +Division with Karatsuba Complexity" is not currently implemented. It +uses a rearrangement similar to the divide and conquer for normal +division (*note Divide and Conquer Division::), but operating from low +to high. A further possibility not currently implemented is +"Bidirectional Exact Integer Division" by Krandick and Jebelean which +forms quotient limbs from both the high and low ends of the dividend, +and can halve once more the number of crossproducts needed in a 2NxN +division. + + A special case exact division by 3 exists in `mpn_divexact_by3', +supporting Toom-3 multiplication and `mpq' canonicalizations. It forms +quotient digits with a multiply by the modular inverse of 3 (which is +`0xAA..AAB') and uses two comparisons to determine a borrow for the next +limb. The multiplications don't need to be on the dependent chain, as +long as the effect of the borrows is applied. Only a few optimized +assembler implementations currently exist. + + +File: gmp.info, Node: Exact Remainder, Next: Small Quotient Division, Prev: Exact Division, Up: Division Algorithms + +Exact Remainder +--------------- + +If the exact division algorithm is done with a full subtraction at each +stage and the dividend isn't a multiple of the divisor, then low zero +limbs are produced but with a remainder in the high limbs. For +dividend a, divisor d, quotient q, and b = 2^mp_bits_per_limb, then this +remainder r is of the form + + a = q*d + r*b^n + + n represents the number of zero limbs produced by the subtractions, +that being the number of limbs produced for q. r will be in the range +0<=rb*r+u2 condition appropriately relaxed. + + +File: gmp.info, Node: Greatest Common Divisor Algorithms, Next: Powering Algorithms, Prev: Division Algorithms, Up: Algorithms + +Greatest Common Divisor +======================= + +* Menu: + +* Binary GCD:: +* Accelerated GCD:: +* Extended GCD:: +* Jacobi Symbol:: + + +File: gmp.info, Node: Binary GCD, Next: Accelerated GCD, Prev: Greatest Common Divisor Algorithms, Up: Greatest Common Divisor Algorithms + +Binary GCD +---------- + +At small sizes GMP uses an O(N^2) binary style GCD. This is described +in many textbooks, for example Knuth section 4.5.2 algorithm B. It +simply consists of successively reducing operands a and b using +gcd(a,b) = gcd(min(a,b),abs(a-b)), and also that if a and b are first +made odd then abs(a-b) is even and factors of two can be discarded. + + Variants like letting a-b become negative and doing a different next +step are of interest only as far as they suit particular CPUs, since on +small operands it's machine dependent factors that determine +performance. + + The Euclidean GCD algorithm, as per Knuth algorithms E and A, +reduces using a mod b but this has so far been found to be slower +everywhere. One reason the binary method does well is that the implied +quotient at each step is usually small, so often only one or two +subtractions are needed to get the same effect as a division. +Quotients 1, 2 and 3 for example occur 67.7% of the time, see Knuth +section 4.5.3 Theorem E. + + When the implied quotient is large, meaning b is much smaller than +a, then a division is worthwhile. This is the basis for the initial a +mod b reductions in `mpn_gcd' and `mpn_gcd_1' (the latter for both Nx1 +and 1x1 cases). But after that initial reduction, big quotients occur +too rarely to make it worth checking for them. + + +File: gmp.info, Node: Accelerated GCD, Next: Extended GCD, Prev: Binary GCD, Up: Greatest Common Divisor Algorithms + +Accelerated GCD +--------------- + +For sizes above `GCD_ACCEL_THRESHOLD', GMP uses the Accelerated GCD +algorithm described independently by Weber and Jebelean (the latter as +the "Generalized Binary" algorithm), *note References::. This +algorithm is still O(N^2), but is much faster than the binary algorithm +since it does fewer multi-precision operations. It consists of +alternating the k-ary reduction by Sorenson, and a "dmod" exact +remainder reduction. + + For operands u and v the k-ary reduction replaces u with n*v-d*u +where n and d are single limb values chosen to give two trailing zero +limbs on that value, which can be stripped. n and d are calculated +using an algorithm similar to half of a two limb GCD (see `find_a' in +`mpn/generic/gcd.c'). + + When u and v differ in size by more than a certain number of bits, a +dmod is performed to zero out bits at the low end of the larger. It +consists of an exact remainder style division applied to an appropriate +number of bits (*note Exact Division::, and *note Exact Remainder::). +This is faster than a k-ary reduction but useful only when the operands +differ in size. There's a dmod after each k-ary reduction, and if the +dmod leaves the operands still differing in size then it's repeated. + + The k-ary reduction step can introduce spurious factors into the GCD +calculated, and these are eliminated at the end by taking GCDs with the +original inputs gcd(u,gcd(v,g)) using the binary algorithm. Since g is +almost always small this takes very little time. + + At small sizes the algorithm needs a good implementation of +`find_a'. At larger sizes it's dominated by `mpn_addmul_1' applying n +and d. + + +File: gmp.info, Node: Extended GCD, Next: Jacobi Symbol, Prev: Accelerated GCD, Up: Greatest Common Divisor Algorithms + +Extended GCD +------------ + +The extended GCD calculates gcd(a,b) and also cofactors x and y +satisfying a*x+b*y=gcd(a,b). Lehmer's multi-step improvement of the +extended Euclidean algorithm is used. See Knuth section 4.5.2 +algorithm L, and `mpn/generic/gcdext.c'. This is an O(N^2) algorithm. + + The multipliers at each step are found using single limb +calculations for sizes up to `GCDEXT_THRESHOLD', or double limb +calculations above that. The single limb code is faster but doesn't +produce full-limb multipliers, hence not making full use of the +`mpn_addmul_1' calls. + + When a CPU has a data-dependent multiplier, meaning one which is +faster on operands with fewer bits, the extra work in the double-limb +calculation might only save some looping overheads, leading to a large +`GCDEXT_THRESHOLD'. + + Currently the single limb calculation doesn't optimize for the small +quotients that often occur, and this can lead to unusually low values of +`GCDEXT_THRESHOLD', depending on the CPU. + + An analysis of double-limb calculations can be found in "A +Double-Digit Lehmer-Euclid Algorithm" by Jebelean (*note References::). +The code in GMP was developed independently. + + It should be noted that when a double limb calculation is used, it's +used for the whole of that GCD, it doesn't fall back to single limb +part way through. This is because as the algorithm proceeds, the +inputs a and b are reduced, but the cofactors x and y grow, so the +multipliers at each step are applied to a roughly constant total number +of limbs. + + +File: gmp.info, Node: Jacobi Symbol, Prev: Extended GCD, Up: Greatest Common Divisor Algorithms + +Jacobi Symbol +------------- + +`mpz_jacobi' and `mpz_kronecker' are currently implemented with a +simple binary algorithm similar to that described for the GCDs (*note +Binary GCD::). They're not very fast when both inputs are large. +Lehmer's multi-step improvement or a binary based multi-step algorithm +is likely to be better. + + When one operand fits a single limb, and that includes +`mpz_kronecker_ui' and friends, an initial reduction is done with +either `mpn_mod_1' or `mpn_modexact_1_odd', followed by the binary +algorithm on a single limb. The binary algorithm is well suited to a +single limb, and the whole calculation in this case is quite efficient. + + In all the routines sign changes for the result are accumulated +using some bit twiddling, avoiding table lookups or conditional jumps. + + +File: gmp.info, Node: Powering Algorithms, Next: Root Extraction Algorithms, Prev: Greatest Common Divisor Algorithms, Up: Algorithms + +Powering Algorithms +=================== + +* Menu: + +* Normal Powering Algorithm:: +* Modular Powering Algorithm:: + + +File: gmp.info, Node: Normal Powering Algorithm, Next: Modular Powering Algorithm, Prev: Powering Algorithms, Up: Powering Algorithms + +Normal Powering +--------------- + +Normal `mpz' or `mpf' powering uses a simple binary algorithm, +successively squaring and then multiplying by the base when a 1 bit is +seen in the exponent, as per Knuth section 4.6.3. The "left to right" +variant described there is used rather than algorithm A, since it's +just as easy and can be done with somewhat less temporary memory. + + +File: gmp.info, Node: Modular Powering Algorithm, Prev: Normal Powering Algorithm, Up: Powering Algorithms + +Modular Powering +---------------- + +Modular powering is implemented using a 2^k-ary sliding window +algorithm, as per "Handbook of Applied Cryptography" algorithm 14.85 +(*note References::). k is chosen according to the size of the +exponent. Larger exponents use larger values of k, the choice being +made to minimize the average number of multiplications that must +supplement the squaring. + + The modular multiplies and squares use either a simple division or +the REDC method by Montgomery (*note References::). REDC is a little +faster, essentially saving N single limb divisions in a fashion similar +to an exact remainder (*note Exact Remainder::). The current REDC has +some limitations. It's only O(N^2) so above `POWM_THRESHOLD' division +becomes faster and is used. It doesn't attempt to detect small bases, +but rather always uses a REDC form, which is usually a full size +operand. And lastly it's only applied to odd moduli. + + +File: gmp.info, Node: Root Extraction Algorithms, Next: Radix Conversion Algorithms, Prev: Powering Algorithms, Up: Algorithms + +Root Extraction Algorithms +========================== + +* Menu: + +* Square Root Algorithm:: +* Nth Root Algorithm:: +* Perfect Square Algorithm:: +* Perfect Power Algorithm:: + + +File: gmp.info, Node: Square Root Algorithm, Next: Nth Root Algorithm, Prev: Root Extraction Algorithms, Up: Root Extraction Algorithms + +Square Root +----------- + +Square roots are taken using the "Karatsuba Square Root" algorithm by +Paul Zimmermann (*note References::). This is expressed in a divide +and conquer form, but as noted in the paper it can also be viewed as a +discrete variant of Newton's method. + + In the Karatsuba multiplication range this is an O(1.5*M(N/2)) +algorithm, where M(n) is the time to multiply two numbers of n limbs. +In the FFT multiplication range this grows to a bound of O(6*M(N/2)). +In practice a factor of about 1.5 to 1.8 is found in the Karatsuba and +Toom-3 ranges, growing to 2 or 3 in the FFT range. + + The algorithm does all its calculations in integers and the resulting +`mpn_sqrtrem' is used for both `mpz_sqrt' and `mpf_sqrt'. The extended +precision given by `mpf_sqrt_ui' is obtained by padding with zero limbs. + + +File: gmp.info, Node: Nth Root Algorithm, Next: Perfect Square Algorithm, Prev: Square Root Algorithm, Up: Root Extraction Algorithms + +Nth Root +-------- + +Integer Nth roots are taken using Newton's method with the following +iteration, where A is the input and n is the root to be taken. + + 1 A + a[i+1] = - * ( --------- + (n-1)*a[i] ) + n a[i]^(n-1) + + The initial approximation a[1] is generated bitwise by successively +powering a trial root with or without new 1 bits, aiming to be just +above the true root. The iteration converges quadratically when +started from a good approximation. When n is large more initial bits +are needed to get good convergence. The current implementation is not +particularly well optimized. + + +File: gmp.info, Node: Perfect Square Algorithm, Next: Perfect Power Algorithm, Prev: Nth Root Algorithm, Up: Root Extraction Algorithms + +Perfect Square +-------------- + +`mpz_perfect_square_p' is able to quickly exclude most non-squares by +checking whether the input is a quadratic residue modulo some small +integers. + + The first test is modulo 256 which means simply examining the least +significant byte. Only 44 different values occur as the low byte of a +square, so 82.8% of non-squares can be immediately excluded. Similar +tests modulo primes from 3 to 29 exclude 99.5% of those remaining, or +if a limb is 64 bits then primes up to 53 are used, excluding 99.99%. +A single Nx1 remainder using `PP' from `gmp-impl.h' quickly gives all +these remainders. + + A square root must still be taken for any value that passes the +residue tests, to verify it's really a square and not one of the 0.086% +(or 0.000156% for 64 bits) non-squares that get through. *Note Square +Root Algorithm::. + + +File: gmp.info, Node: Perfect Power Algorithm, Prev: Perfect Square Algorithm, Up: Root Extraction Algorithms + +Perfect Power +------------- + +Detecting perfect powers is required by some factorization algorithms. +Currently `mpz_perfect_power_p' is implemented using repeated Nth root +extractions, though naturally only prime roots need to be considered. +(*Note Nth Root Algorithm::.) + + If a prime divisor p with multiplicity e can be found, then only +roots which are divisors of e need to be considered, much reducing the +work necessary. To this end divisibility by a set of small primes is +checked. + + +File: gmp.info, Node: Radix Conversion Algorithms, Next: Other Algorithms, Prev: Root Extraction Algorithms, Up: Algorithms + +Radix Conversion +================ + +Radix conversions are less important than other algorithms. A program +dominated by conversions should probably use a different data +representation. + +* Menu: + +* Binary to Radix:: +* Radix to Binary:: + + +File: gmp.info, Node: Binary to Radix, Next: Radix to Binary, Prev: Radix Conversion Algorithms, Up: Radix Conversion Algorithms + +Binary to Radix +--------------- + +Conversions from binary to a power-of-2 radix use a simple and fast +O(N) bit extraction algorithm. + + Conversions from binary to other radices use one of two algorithms. +Sizes below `GET_STR_PRECOMPUTE_THRESHOLD' use a basic O(N^2) method. +Repeated divisions by b^n are made, where b is the radix and n is the +biggest power that fits in a limb. But instead of simply using the +remainder r from such divisions, an extra divide step is done to give a +fractional limb representing r/b^n. The digits of r can then be +extracted using multiplications by b rather than divisions. Special +case code is provided for decimal, allowing multiplications by 10 to +optimize to shifts and adds. + + Above `GET_STR_PRECOMPUTE_THRESHOLD' a sub-quadratic algorithm is +used. For an input t, powers b^(n*2^i) of the radix are calculated, +until a power between t and sqrt(t) is reached. t is then divided by +that largest power, giving a quotient which is the digits above that +power, and a remainder which is those below. These two parts are in +turn divided by the second highest power, and so on recursively. When +a piece has been divided down to less than `GET_STR_DC_THRESHOLD' +limbs, the basecase algorithm described above is used. + + The advantage of this algorithm is that big divisions can make use +of the sub-quadratic divide and conquer division (*note Divide and +Conquer Division::), and big divisions tend to have less overheads than +lots of separate single limb divisions anyway. But in any case the +cost of calculating the powers b^(n*2^i) must first be overcome. + + `GET_STR_PRECOMPUTE_THRESHOLD' and `GET_STR_DC_THRESHOLD' represent +the same basic thing, the point where it becomes worth doing a big +division to cut the input in half. `GET_STR_PRECOMPUTE_THRESHOLD' +includes the cost of calculating the radix power required, whereas +`GET_STR_DC_THRESHOLD' assumes that's already available, which is the +case when recursing. + + Since the base case produces digits from least to most significant +but they want to be stored from most to least, it's necessary to +calculate in advance how many digits there will be, or at least be sure +not to underestimate that. For GMP the number of input bits is +multiplied by `chars_per_bit_exactly' from `mp_bases', rounding up. +The result is either correct or one too big. + + Examining some of the high bits of the input could increase the +chance of getting the exact number of digits, but an exact result every +time would not be practical, since in general the difference between +numbers 100... and 99... is only in the last few bits and the work to +identify 99... might well be almost as much as a full conversion. + + `mpf_get_str' doesn't currently use the algorithm described here, it +multiplies or divides by a power of b to move the radix point to the +just above the highest non-zero digit (or at worst one above that +location), then multiplies by b^n to bring out digits. This is O(N^2) +and is certainly not optimal. + + The r/b^n scheme described above for using multiplications to bring +out digits might be useful for more than a single limb. Some brief +experiments with it on the base case when recursing didn't give a +noticeable improvement, but perhaps that was only due to the +implementation. Something similar would work for the sub-quadratic +divisions too, though there would be the cost of calculating a bigger +radix power. + + Another possible improvement for the sub-quadratic part would be to +arrange for radix powers that balanced the sizes of quotient and +remainder produced, ie. the highest power would be an b^(n*k) +approximately equal to sqrt(t), not restricted to a 2^i factor. That +ought to smooth out a graph of times against sizes, but may or may not +be a net speedup. + + +File: gmp.info, Node: Radix to Binary, Prev: Binary to Radix, Up: Radix Conversion Algorithms + +Radix to Binary +--------------- + +Conversions from a power-of-2 radix into binary use a simple and fast +O(N) bitwise concatenation algorithm. + + Conversions from other radices use one of two algorithms. Sizes +below `SET_STR_THRESHOLD' use a basic O(N^2) method. Groups of n +digits are converted to limbs, where n is the biggest power of the base +b which will fit in a limb, then those groups are accumulated into the +result by multiplying by b^n and adding. This saves multi-precision +operations, as per Knuth section 4.4 part E (*note References::). Some +special case code is provided for decimal, giving the compiler a chance +to optimize multiplications by 10. + + Above `SET_STR_THRESHOLD' a sub-quadratic algorithm is used. First +groups of n digits are converted into limbs. Then adjacent limbs are +combined into limb pairs with x*b^n+y, where x and y are the limbs. +Adjacent limb pairs are combined into quads similarly with x*b^(2n)+y. +This continues until a single block remains, that being the result. + + The advantage of this method is that the multiplications for each x +are big blocks, allowing Karatsuba and higher algorithms to be used. +But the cost of calculating the powers b^(n*2^i) must be overcome. +`SET_STR_THRESHOLD' usually ends up quite big, around 5000 digits, and +on some processors much bigger still. + + `SET_STR_THRESHOLD' is based on the input digits (and tuned for +decimal), though it might be better based on a limb count, so as to be +independent of the base. But that sort of count isn't used by the base +case and so would need some sort of initial calculation or estimate. + + The main reason `SET_STR_THRESHOLD' is so much bigger than the +corresponding `GET_STR_PRECOMPUTE_THRESHOLD' is that `mpn_mul_1' is +much faster than `mpn_divrem_1' (often by a factor of 10, or more). + + +File: gmp.info, Node: Other Algorithms, Next: Assembler Coding, Prev: Radix Conversion Algorithms, Up: Algorithms + +Other Algorithms +================ + +* Menu: + +* Factorial Algorithm:: +* Binomial Coefficients Algorithm:: +* Fibonacci Numbers Algorithm:: +* Lucas Numbers Algorithm:: + + +File: gmp.info, Node: Factorial Algorithm, Next: Binomial Coefficients Algorithm, Prev: Other Algorithms, Up: Other Algorithms + +Factorial +--------- + +Factorials n! are calculated by a simple product from 1 to n, but +arranged into certain sub-products. + + First as many factors as fit in a limb are accumulated, then two of +those multiplied to give a 2-limb product. When two 2-limb products +are ready they're multiplied to a 4-limb product, and when two 4-limbs +are ready they're multiplied to an 8-limb product, etc. A stack of +outstanding products is built up, with two of the same size multiplied +together when ready. + + Arranging for multiplications to have operands the same (or nearly +the same) size means the Karatsuba and higher multiplication algorithms +can be used. And even on sizes below the Karatsuba threshold an NxN +multiply will give a basecase multiply more to work on. + + An obvious improvement not currently implemented would be to strip +factors of 2 from the products and apply them at the end with a bit +shift. Another possibility would be to determine the prime +factorization of the result (which can be done easily), and use a +powering method, at each stage squaring then multiplying in those +primes with a 1 in their exponent at that point. The advantage would +be some multiplies turned into squares. + + +File: gmp.info, Node: Binomial Coefficients Algorithm, Next: Fibonacci Numbers Algorithm, Prev: Factorial Algorithm, Up: Other Algorithms + +Binomial Coefficients +--------------------- + +Binomial coefficients C(n,k) are calculated by first arranging k <= n/2 +using C(n,k) = C(n,n-k) if necessary, and then evaluating the following +product simply from i=2 to i=k. + + k (n-k+i) + C(n,k) = (n-k+1) * prod ------- + i=2 i + + It's easy to show that each denominator i will divide the product so +far, so the exact division algorithm is used (*note Exact Division::). + + The numerators n-k+i and denominators i are first accumulated into +as many fit a limb, to save multi-precision operations, though for +`mpz_bin_ui' this applies only to the divisors, since n is an `mpz_t' +and n-k+i in general won't fit in a limb at all. + + An obvious improvement would be to strip factors of 2 from each +multiplier and divisor and count them separately, to be applied with a +bit shift at the end. Factors of 3 and perhaps 5 could even be handled +similarly. Another possibility, if n is not too big, would be to +determine the prime factorization of the result based on the factorials +involved, and power up those primes appropriately. This would help +most when k is near n/2. + + +File: gmp.info, Node: Fibonacci Numbers Algorithm, Next: Lucas Numbers Algorithm, Prev: Binomial Coefficients Algorithm, Up: Other Algorithms + +Fibonacci Numbers +----------------- + +The Fibonacci functions `mpz_fib_ui' and `mpz_fib2_ui' are designed for +calculating isolated F[n] or F[n],F[n-1] values efficiently. + + For small n, a table of single limb values in `__gmp_fib_table' is +used. On a 32-bit limb this goes up to F[47], or on a 64-bit limb up +to F[93]. For convenience the table starts at F[-1]. + + Beyond the table, values are generated with a binary powering +algorithm, calculating a pair F[n] and F[n-1] working from high to low +across the bits of n. The formulas used are + + F[2k+1] = 4*F[k]^2 - F[k-1]^2 + 2*(-1)^k + F[2k-1] = F[k]^2 + F[k-1]^2 + + F[2k] = F[2k+1] - F[2k-1] + + At each step, k is the high b bits of n. If the next bit of n is 0 +then F[2k],F[2k-1] is used, or if it's a 1 then F[2k+1],F[2k] is used, +and the process repeated until all bits of n are incorporated. Notice +these formulas require just two squares per bit of n. + + It'd be possible to handle the first few n above the single limb +table with simple additions, using the defining Fibonacci recurrence +F[k+1]=F[k]+F[k-1], but this is not done since it usually turns out to +be faster for only about 10 or 20 values of n, and including a block of +code for just those doesn't seem worthwhile. If they really mattered +it'd be better to extend the data table. + + Using a table avoids lots of calculations on small numbers, and +makes small n go fast. A bigger table would make more small n go fast, +it's just a question of balancing size against desired speed. For GMP +the code is kept compact, with the emphasis primarily on a good +powering algorithm. + + `mpz_fib2_ui' returns both F[n] and F[n-1], but `mpz_fib_ui' is only +interested in F[n]. In this case the last step of the algorithm can +become one multiply instead of two squares. One of the following two +formulas is used, according as n is odd or even. + + F[2k] = F[k]*(F[k]+2F[k-1]) + + F[2k+1] = (2F[k]+F[k-1])*(2F[k]-F[k-1]) + 2*(-1)^k + + F[2k+1] here is the same as above, just rearranged to be a multiply. +For interest, the 2*(-1)^k term both here and above can be applied +just to the low limb of the calculation, without a carry or borrow into +further limbs, which saves some code size. See comments with +`mpz_fib_ui' and the internal `mpn_fib2_ui' for how this is done. + + +File: gmp.info, Node: Lucas Numbers Algorithm, Prev: Fibonacci Numbers Algorithm, Up: Other Algorithms + +Lucas Numbers +------------- + +`mpz_lucnum2_ui' derives a pair of Lucas numbers from a pair of +Fibonacci numbers with the following simple formulas. + + L[k] = F[k] + 2*F[k-1] + L[k-1] = 2*F[k] - F[k-1] + + `mpz_lucnum_ui' is only interested in L[n], and some work can be +saved. Trailing zero bits on n can be handled with a single square +each. + + L[2k] = L[k]^2 - 2*(-1)^k + + And the lowest 1 bit can be handled with one multiply of a pair of +Fibonacci numbers, similar to what `mpz_fib_ui' does. + + L[2k+1] = 5*F[k-1]*(2*F[k]+F[k-1]) - 4*(-1)^k + + +File: gmp.info, Node: Assembler Coding, Prev: Other Algorithms, Up: Algorithms + +Assembler Coding +================ + +The assembler subroutines in GMP are the most significant source of +speed at small to moderate sizes. At larger sizes algorithm selection +becomes more important, but of course speedups in low level routines +will still speed up everything proportionally. + + Carry handling and widening multiplies that are important for GMP +can't be easily expressed in C. GCC `asm' blocks help a lot and are +provided in `longlong.h', but hand coding low level routines invariably +offers a speedup over generic C by a factor of anything from 2 to 10. + +* Menu: + +* Assembler Code Organisation:: +* Assembler Basics:: +* Assembler Carry Propagation:: +* Assembler Cache Handling:: +* Assembler Floating Point:: +* Assembler SIMD Instructions:: +* Assembler Software Pipelining:: +* Assembler Loop Unrolling:: + + +File: gmp.info, Node: Assembler Code Organisation, Next: Assembler Basics, Prev: Assembler Coding, Up: Assembler Coding + +Code Organisation +----------------- + +The various `mpn' subdirectories contain machine-dependent code, written +in C or assembler. The `mpn/generic' subdirectory contains default +code, used when there's no machine-specific version of a particular +file. + + Each `mpn' subdirectory is for an ISA family. Generally 32-bit and +64-bit variants in a family cannot share code and will have separate +directories. Within a family further subdirectories may exist for CPU +variants. + + +File: gmp.info, Node: Assembler Basics, Next: Assembler Carry Propagation, Prev: Assembler Code Organisation, Up: Assembler Coding + +Assembler Basics +---------------- + +`mpn_addmul_1' and `mpn_submul_1' are the most important routines for +overall GMP performance. All multiplications and divisions come down to +repeated calls to these. `mpn_add_n', `mpn_sub_n', `mpn_lshift' and +`mpn_rshift' are next most important. + + On some CPUs assembler versions of the internal functions +`mpn_mul_basecase' and `mpn_sqr_basecase' give significant speedups, +mainly through avoiding function call overheads. They can also +potentially make better use of a wide superscalar processor. + + The restrictions on overlaps between sources and destinations (*note +Low-level Functions::) are designed to facilitate a variety of +implementations. For example, knowing `mpn_add_n' won't have partly +overlapping sources and destination means reading can be done far ahead +of writing on superscalar processors, and loops can be vectorized on a +vector processor, depending on the carry handling. + + +File: gmp.info, Node: Assembler Carry Propagation, Next: Assembler Cache Handling, Prev: Assembler Basics, Up: Assembler Coding + +Carry Propagation +----------------- + +The problem that presents most challenges in GMP is propagating carries +from one limb to the next. In functions like `mpn_addmul_1' and +`mpn_add_n', carries are the only dependencies between limb operations. + + On processors with carry flags, a straightforward CISC style `adc' is +generally best. AMD K6 `mpn_addmul_1' however is an example of an +unusual set of circumstances where a branch works out better. + + On RISC processors generally an add and compare for overflow is +used. This sort of thing can be seen in `mpn/generic/aors_n.c'. Some +carry propagation schemes require 4 instructions, meaning at least 4 +cycles per limb, but other schemes may use just 1 or 2. On wide +superscalar processors performance may be completely determined by the +number of dependent instructions between carry-in and carry-out for +each limb. + + On vector processors good use can be made of the fact that a carry +bit only very rarely propagates more than one limb. When adding a +single bit to a limb, there's only a carry out if that limb was +`0xFF...FF' which on random data will be only 1 in 2^mp_bits_per_limb. +`mpn/cray/add_n.c' is an example of this, it adds all limbs in +parallel, adds one set of carry bits in parallel and then only rarely +needs to fall through to a loop propagating further carries. + + On the x86s, GCC (as of version 2.95.2) doesn't generate +particularly good code for the RISC style idioms that are necessary to +handle carry bits in C. Often conditional jumps are generated where +`adc' or `sbb' forms would be better. And so unfortunately almost any +loop involving carry bits needs to be coded in assembler for best +results. + + +File: gmp.info, Node: Assembler Cache Handling, Next: Assembler Floating Point, Prev: Assembler Carry Propagation, Up: Assembler Coding + +Cache Handling +-------------- + +GMP aims to perform well both on operands that fit entirely in L1 cache +and those which don't. + + Basic routines like `mpn_add_n' or `mpn_lshift' are often used on +large operands, so L2 and main memory performance is important for them. +`mpn_mul_1' and `mpn_addmul_1' are mostly used for multiply and square +basecases, so L1 performance matters most for them, unless assembler +versions of `mpn_mul_basecase' and `mpn_sqr_basecase' exist, in which +case the remaining uses are mostly for larger operands. + + For L2 or main memory operands, memory access times will almost +certainly be more than the calculation time. The aim therefore is to +maximize memory throughput, by starting a load of the next cache line +which processing the contents of the previous one. Clearly this is +only possible if the chip has a lock-up free cache or some sort of +prefetch instruction. Most current chips have both these features. + + Prefetching sources combines well with loop unrolling, since a +prefetch can be initiated once per unrolled loop (or more than once if +the loop covers more than one cache line). + + On CPUs without write-allocate caches, prefetching destinations will +ensure individual stores don't go further down the cache hierarchy, +limiting bandwidth. Of course for calculations which are slow anyway, +like `mpn_divrem_1', write-throughs might be fine. + + The distance ahead to prefetch will be determined by memory latency +versus throughput. The aim of course is to have data arriving +continuously, at peak throughput. Some CPUs have limits on the number +of fetches or prefetches in progress. + + If a special prefetch instruction doesn't exist then a plain load +can be used, but in that case care must be taken not to attempt to read +past the end of an operand, since that might produce a segmentation +violation. + + Some CPUs or systems have hardware that detects sequential memory +accesses and initiates suitable cache movements automatically, making +life easy. + diff --git a/src/gmp/gmp.info-2 b/src/gmp/gmp.info-2 new file mode 100644 index 000000000..3d512ceb9 --- /dev/null +++ b/src/gmp/gmp.info-2 @@ -0,0 +1,1877 @@ +This is gmp.info, produced by makeinfo version 4.6 from gmp.texi. + +This manual describes how to install and use the GNU multiple precision +arithmetic library, version 4.1.4. + + Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004 Free Software Foundation, Inc. + + Permission is granted to copy, distribute and/or modify this +document under the terms of the GNU Free Documentation License, Version +1.1 or any later version published by the Free Software Foundation; +with no Invariant Sections, with the Front-Cover Texts being "A GNU +Manual", and with the Back-Cover Texts being "You have freedom to copy +and modify this GNU Manual, like GNU software". A copy of the license +is included in *Note GNU Free Documentation License::. +INFO-DIR-SECTION GNU libraries +START-INFO-DIR-ENTRY +* gmp: (gmp). GNU Multiple Precision Arithmetic Library. +END-INFO-DIR-ENTRY + + +File: gmp.info, Node: Assembler Floating Point, Next: Assembler SIMD Instructions, Prev: Assembler Cache Handling, Up: Assembler Coding + +Floating Point +-------------- + +Floating point arithmetic is used in GMP for multiplications on CPUs +with poor integer multipliers. It's mostly useful for `mpn_mul_1', +`mpn_addmul_1' and `mpn_submul_1' on 64-bit machines, and +`mpn_mul_basecase' on both 32-bit and 64-bit machines. + + With IEEE 53-bit double precision floats, integer multiplications +producing up to 53 bits will give exact results. Breaking a 64x64 +multiplication into eight 16x32->48 bit pieces is convenient. With +some care though six 21x32->53 bit products can be used, if one of the +lower two 21-bit pieces also uses the sign bit. + + For the `mpn_mul_1' family of functions on a 64-bit machine, the +invariant single limb is split at the start, into 3 or 4 pieces. +Inside the loop, the bignum operand is split into 32-bit pieces. Fast +conversion of these unsigned 32-bit pieces to floating point is highly +machine-dependent. In some cases, reading the data into the integer +unit, zero-extending to 64-bits, then transferring to the floating +point unit back via memory is the only option. + + Converting partial products back to 64-bit limbs is usually best +done as a signed conversion. Since all values are smaller than 2^53, +signed and unsigned are the same, but most processors lack unsigned +conversions. + + + + Here is a diagram showing 16x32 bit products for an `mpn_mul_1' or +`mpn_addmul_1' with a 64-bit limb. The single limb operand V is split +into four 16-bit parts. The multi-limb operand U is split in the loop +into two 32-bit parts. + + +---+---+---+---+ + |v48|v32|v16|v00| V operand + +---+---+---+---+ + + +-------+---+---+ + x | u32 | u00 | U operand (one limb) + +---------------+ + + --------------------------------- + + +-----------+ + | u00 x v00 | p00 48-bit products + +-----------+ + +-----------+ + | u00 x v16 | p16 + +-----------+ + +-----------+ + | u00 x v32 | p32 + +-----------+ + +-----------+ + | u00 x v48 | p48 + +-----------+ + +-----------+ + | u32 x v00 | r32 + +-----------+ + +-----------+ + | u32 x v16 | r48 + +-----------+ + +-----------+ + | u32 x v32 | r64 + +-----------+ + +-----------+ + | u32 x v48 | r80 + +-----------+ + + p32 and r32 can be summed using floating-point addition, and +likewise p48 and r48. p00 and p16 can be summed with r64 and r80 from +the previous iteration. + + For each loop then, four 49-bit quantities are transfered to the +integer unit, aligned as follows, + + |-----64bits----|-----64bits----| + +------------+ + | p00 + r64' | i00 + +------------+ + +------------+ + | p16 + r80' | i16 + +------------+ + +------------+ + | p32 + r32 | i32 + +------------+ + +------------+ + | p48 + r48 | i48 + +------------+ + + The challenge then is to sum these efficiently and add in a carry +limb, generating a low 64-bit result limb and a high 33-bit carry limb +(i48 extends 33 bits into the high half). + + +File: gmp.info, Node: Assembler SIMD Instructions, Next: Assembler Software Pipelining, Prev: Assembler Floating Point, Up: Assembler Coding + +SIMD Instructions +----------------- + +The single-instruction multiple-data support in current microprocessors +is aimed at signal processing algorithms where each data point can be +treated more or less independently. There's generally not much support +for propagating the sort of carries that arise in GMP. + + SIMD multiplications of say four 16x16 bit multiplies only do as much +work as one 32x32 from GMP's point of view, and need some shifts and +adds besides. But of course if say the SIMD form is fully pipelined +and uses less instruction decoding then it may still be worthwhile. + + On the 80x86 chips, MMX has so far found a use in `mpn_rshift' and +`mpn_lshift' since it allows 64-bit operations, and is used in a special +case for 16-bit multipliers in the P55 `mpn_mul_1'. 3DNow and SSE +haven't found a use so far. + + +File: gmp.info, Node: Assembler Software Pipelining, Next: Assembler Loop Unrolling, Prev: Assembler SIMD Instructions, Up: Assembler Coding + +Software Pipelining +------------------- + +Software pipelining consists of scheduling instructions around the +branch point in a loop. For example a loop taking a checksum of an +array of limbs might have a load and an add, but the load wouldn't be +for that add, rather for the one next time around the loop. Each load +then is effectively scheduled back in the previous iteration, allowing +latency to be hidden. + + Naturally this is wanted only when doing things like loads or +multiplies that take a few cycles to complete, and only where a CPU has +multiple functional units so that other work can be done while waiting. + + A pipeline with several stages will have a data value in progress at +each stage and each loop iteration moves them along one stage. This is +like juggling. + + Within the loop some moves between registers may be necessary to +have the right values in the right places for each iteration. Loop +unrolling can help this, with each unrolled block able to use different +registers for different values, even if some shuffling is still needed +just before going back to the top of the loop. + + +File: gmp.info, Node: Assembler Loop Unrolling, Prev: Assembler Software Pipelining, Up: Assembler Coding + +Loop Unrolling +-------------- + +Loop unrolling consists of replicating code so that several limbs are +processed in each loop. At a minimum this reduces loop overheads by a +corresponding factor, but it can also allow better register usage, for +example alternately using one register combination and then another. +Judicious use of `m4' macros can help avoid lots of duplication in the +source code. + + Unrolling is commonly done to a power of 2 multiple so the number of +unrolled loops and the number of remaining limbs can be calculated with +a shift and mask. But other multiples can be used too, just by +subtracting each N limbs processed from a counter and waiting for less +than N remaining (or offsetting the counter by N so it goes negative +when there's less than N remaining). + + The limbs not a multiple of the unrolling can be handled in various +ways, for example + + * A simple loop at the end (or the start) to process the excess. + Care will be wanted that it isn't too much slower than the + unrolled part. + + * A set of binary tests, for example after an 8-limb unrolling, test + for 4 more limbs to process, then a further 2 more or not, and + finally 1 more or not. This will probably take more code space + than a simple loop. + + * A `switch' statement, providing separate code for each possible + excess, for example an 8-limb unrolling would have separate code + for 0 remaining, 1 remaining, etc, up to 7 remaining. This might + take a lot of code, but may be the best way to optimize all cases + in combination with a deep pipelined loop. + + * A computed jump into the middle of the loop, thus making the first + iteration handle the excess. This should make times smoothly + increase with size, which is attractive, but setups for the jump + and adjustments for pointers can be tricky and could become quite + difficult in combination with deep pipelining. + + One way to write the setups and finishups for a pipelined unrolled +loop is simply to duplicate the loop at the start and the end, then +delete instructions at the start which have no valid antecedents, and +delete instructions at the end whose results are unwanted. Sizes not a +multiple of the unrolling can then be handled as desired. + + +File: gmp.info, Node: Internals, Next: Contributors, Prev: Algorithms, Up: Top + +Internals +********* + +*This chapter is provided only for informational purposes and the +various internals described here may change in future GMP releases. +Applications expecting to be compatible with future releases should use +only the documented interfaces described in previous chapters.* + +* Menu: + +* Integer Internals:: +* Rational Internals:: +* Float Internals:: +* Raw Output Internals:: +* C++ Interface Internals:: + + +File: gmp.info, Node: Integer Internals, Next: Rational Internals, Prev: Internals, Up: Internals + +Integer Internals +================= + +`mpz_t' variables represent integers using sign and magnitude, in space +dynamically allocated and reallocated. The fields are as follows. + +`_mp_size' + The number of limbs, or the negative of that when representing a + negative integer. Zero is represented by `_mp_size' set to zero, + in which case the `_mp_d' data is unused. + +`_mp_d' + A pointer to an array of limbs which is the magnitude. These are + stored "little endian" as per the `mpn' functions, so `_mp_d[0]' + is the least significant limb and `_mp_d[ABS(_mp_size)-1]' is the + most significant. Whenever `_mp_size' is non-zero, the most + significant limb is non-zero. + + Currently there's always at least one limb allocated, so for + instance `mpz_set_ui' never needs to reallocate, and `mpz_get_ui' + can fetch `_mp_d[0]' unconditionally (though its value is then + only wanted if `_mp_size' is non-zero). + +`_mp_alloc' + `_mp_alloc' is the number of limbs currently allocated at `_mp_d', + and naturally `_mp_alloc >= ABS(_mp_size)'. When an `mpz' routine + is about to (or might be about to) increase `_mp_size', it checks + `_mp_alloc' to see whether there's enough space, and reallocates + if not. `MPZ_REALLOC' is generally used for this. + + The various bitwise logical functions like `mpz_and' behave as if +negative values were twos complement. But sign and magnitude is always +used internally, and necessary adjustments are made during the +calculations. Sometimes this isn't pretty, but sign and magnitude are +best for other routines. + + Some internal temporary variables are setup with `MPZ_TMP_INIT' and +these have `_mp_d' space obtained from `TMP_ALLOC' rather than the +memory allocation functions. Care is taken to ensure that these are +big enough that no reallocation is necessary (since it would have +unpredictable consequences). + + +File: gmp.info, Node: Rational Internals, Next: Float Internals, Prev: Integer Internals, Up: Internals + +Rational Internals +================== + +`mpq_t' variables represent rationals using an `mpz_t' numerator and +denominator (*note Integer Internals::). + + The canonical form adopted is denominator positive (and non-zero), +no common factors between numerator and denominator, and zero uniquely +represented as 0/1. + + It's believed that casting out common factors at each stage of a +calculation is best in general. A GCD is an O(N^2) operation so it's +better to do a few small ones immediately than to delay and have to do +a big one later. Knowing the numerator and denominator have no common +factors can be used for example in `mpq_mul' to make only two cross +GCDs necessary, not four. + + This general approach to common factors is badly sub-optimal in the +presence of simple factorizations or little prospect for cancellation, +but GMP has no way to know when this will occur. As per *Note +Efficiency::, that's left to applications. The `mpq_t' framework might +still suit, with `mpq_numref' and `mpq_denref' for direct access to the +numerator and denominator, or of course `mpz_t' variables can be used +directly. + + +File: gmp.info, Node: Float Internals, Next: Raw Output Internals, Prev: Rational Internals, Up: Internals + +Float Internals +=============== + +Efficient calculation is the primary aim of GMP floats and the use of +whole limbs and simple rounding facilitates this. + + `mpf_t' floats have a variable precision mantissa and a single +machine word signed exponent. The mantissa is represented using sign +and magnitude. + + most least + significant significant + limb limb + + _mp_d + |---- _mp_exp ---> | + _____ _____ _____ _____ _____ + |_____|_____|_____|_____|_____| + . <------------ radix point + + <-------- _mp_size ---------> + +The fields are as follows. + +`_mp_size' + The number of limbs currently in use, or the negative of that when + representing a negative value. Zero is represented by `_mp_size' + and `_mp_exp' both set to zero, and in that case the `_mp_d' data + is unused. (In the future `_mp_exp' might be undefined when + representing zero.) + +`_mp_prec' + The precision of the mantissa, in limbs. In any calculation the + aim is to produce `_mp_prec' limbs of result (the most significant + being non-zero). + +`_mp_d' + A pointer to the array of limbs which is the absolute value of the + mantissa. These are stored "little endian" as per the `mpn' + functions, so `_mp_d[0]' is the least significant limb and + `_mp_d[ABS(_mp_size)-1]' the most significant. + + The most significant limb is always non-zero, but there are no + other restrictions on its value, in particular the highest 1 bit + can be anywhere within the limb. + + `_mp_prec+1' limbs are allocated to `_mp_d', the extra limb being + for convenience (see below). There are no reallocations during a + calculation, only in a change of precision with `mpf_set_prec'. + +`_mp_exp' + The exponent, in limbs, determining the location of the implied + radix point. Zero means the radix point is just above the most + significant limb. Positive values mean a radix point offset + towards the lower limbs and hence a value >= 1, as for example in + the diagram above. Negative exponents mean a radix point further + above the highest limb. + + Naturally the exponent can be any value, it doesn't have to fall + within the limbs as the diagram shows, it can be a long way above + or a long way below. Limbs other than those included in the + `{_mp_d,_mp_size}' data are treated as zero. + + +The following various points should be noted. + +Low Zeros + The least significant limbs `_mp_d[0]' etc can be zero, though + such low zeros can always be ignored. Routines likely to produce + low zeros check and avoid them to save time in subsequent + calculations, but for most routines they're quite unlikely and + aren't checked. + +Mantissa Size Range + The `_mp_size' count of limbs in use can be less than `_mp_prec' if + the value can be represented in less. This means low precision + values or small integers stored in a high precision `mpf_t' can + still be operated on efficiently. + + `_mp_size' can also be greater than `_mp_prec'. Firstly a value is + allowed to use all of the `_mp_prec+1' limbs available at `_mp_d', + and secondly when `mpf_set_prec_raw' lowers `_mp_prec' it leaves + `_mp_size' unchanged and so the size can be arbitrarily bigger than + `_mp_prec'. + +Rounding + All rounding is done on limb boundaries. Calculating `_mp_prec' + limbs with the high non-zero will ensure the application requested + minimum precision is obtained. + + The use of simple "trunc" rounding towards zero is efficient, + since there's no need to examine extra limbs and increment or + decrement. + +Bit Shifts + Since the exponent is in limbs, there are no bit shifts in basic + operations like `mpf_add' and `mpf_mul'. When differing exponents + are encountered all that's needed is to adjust pointers to line up + the relevant limbs. + + Of course `mpf_mul_2exp' and `mpf_div_2exp' will require bit + shifts, but the choice is between an exponent in limbs which + requires shifts there, or one in bits which requires them almost + everywhere else. + +Use of `_mp_prec+1' Limbs + The extra limb on `_mp_d' (`_mp_prec+1' rather than just + `_mp_prec') helps when an `mpf' routine might get a carry from its + operation. `mpf_add' for instance will do an `mpn_add' of + `_mp_prec' limbs. If there's no carry then that's the result, but + if there is a carry then it's stored in the extra limb of space and + `_mp_size' becomes `_mp_prec+1'. + + Whenever `_mp_prec+1' limbs are held in a variable, the low limb + is not needed for the intended precision, only the `_mp_prec' high + limbs. But zeroing it out or moving the rest down is unnecessary. + Subsequent routines reading the value will simply take the high + limbs they need, and this will be `_mp_prec' if their target has + that same precision. This is no more than a pointer adjustment, + and must be checked anyway since the destination precision can be + different from the sources. + + Copy functions like `mpf_set' will retain a full `_mp_prec+1' limbs + if available. This ensures that a variable which has `_mp_size' + equal to `_mp_prec+1' will get its full exact value copied. + Strictly speaking this is unnecessary since only `_mp_prec' limbs + are needed for the application's requested precision, but it's + considered that an `mpf_set' from one variable into another of the + same precision ought to produce an exact copy. + +Application Precisions + `__GMPF_BITS_TO_PREC' converts an application requested precision + to an `_mp_prec'. The value in bits is rounded up to a whole limb + then an extra limb is added since the most significant limb of + `_mp_d' is only non-zero and therefore might contain only one bit. + + `__GMPF_PREC_TO_BITS' does the reverse conversion, and removes the + extra limb from `_mp_prec' before converting to bits. The net + effect of reading back with `mpf_get_prec' is simply the precision + rounded up to a multiple of `mp_bits_per_limb'. + + Note that the extra limb added here for the high only being + non-zero is in addition to the extra limb allocated to `_mp_d'. + For example with a 32-bit limb, an application request for 250 + bits will be rounded up to 8 limbs, then an extra added for the + high being only non-zero, giving an `_mp_prec' of 9. `_mp_d' then + gets 10 limbs allocated. Reading back with `mpf_get_prec' will + take `_mp_prec' subtract 1 limb and multiply by 32, giving 256 + bits. + + Strictly speaking, the fact the high limb has at least one bit + means that a float with, say, 3 limbs of 32-bits each will be + holding at least 65 bits, but for the purposes of `mpf_t' it's + considered simply to be 64 bits, a nice multiple of the limb size. + + +File: gmp.info, Node: Raw Output Internals, Next: C++ Interface Internals, Prev: Float Internals, Up: Internals + +Raw Output Internals +==================== + +`mpz_out_raw' uses the following format. + + +------+------------------------+ + | size | data bytes | + +------+------------------------+ + + The size is 4 bytes written most significant byte first, being the +number of subsequent data bytes, or the twos complement negative of +that when a negative integer is represented. The data bytes are the +absolute value of the integer, written most significant byte first. + + The most significant data byte is always non-zero, so the output is +the same on all systems, irrespective of limb size. + + In GMP 1, leading zero bytes were written to pad the data bytes to a +multiple of the limb size. `mpz_inp_raw' will still accept this, for +compatibility. + + The use of "big endian" for both the size and data fields is +deliberate, it makes the data easy to read in a hex dump of a file. +Unfortunately it also means that the limb data must be reversed when +reading or writing, so neither a big endian nor little endian system +can just read and write `_mp_d'. + + +File: gmp.info, Node: C++ Interface Internals, Prev: Raw Output Internals, Up: Internals + +C++ Interface Internals +======================= + +A system of expression templates is used to ensure something like +`a=b+c' turns into a simple call to `mpz_add' etc. For `mpf_class' and +`mpfr_class' the scheme also ensures the precision of the final +destination is used for any temporaries within a statement like +`f=w*x+y*z'. These are important features which a naive implementation +cannot provide. + + A simplified description of the scheme follows. The true scheme is +complicated by the fact that expressions have different return types. +For detailed information, refer to the source code. + + To perform an operation, say, addition, we first define a "function +object" evaluating it, + + struct __gmp_binary_plus + { + static void eval(mpf_t f, mpf_t g, mpf_t h) { mpf_add(f, g, h); } + }; + +And an "additive expression" object, + + __gmp_expr<__gmp_binary_expr > + operator+(const mpf_class &f, const mpf_class &g) + { + return __gmp_expr + <__gmp_binary_expr >(f, g); + } + + The seemingly redundant `__gmp_expr<__gmp_binary_expr<...>>' is used +to encapsulate any possible kind of expression into a single template +type. In fact even `mpf_class' etc are `typedef' specializations of +`__gmp_expr'. + + Next we define assignment of `__gmp_expr' to `mpf_class'. + + template + mpf_class & mpf_class::operator=(const __gmp_expr &expr) + { + expr.eval(this->get_mpf_t(), this->precision()); + return *this; + } + + template + void __gmp_expr<__gmp_binary_expr >::eval + (mpf_t f, unsigned long int precision) + { + Op::eval(f, expr.val1.get_mpf_t(), expr.val2.get_mpf_t()); + } + + where `expr.val1' and `expr.val2' are references to the expression's +operands (here `expr' is the `__gmp_binary_expr' stored within the +`__gmp_expr'). + + This way, the expression is actually evaluated only at the time of +assignment, when the required precision (that of `f') is known. +Furthermore the target `mpf_t' is now available, thus we can call +`mpf_add' directly with `f' as the output argument. + + Compound expressions are handled by defining operators taking +subexpressions as their arguments, like this: + + template + __gmp_expr + <__gmp_binary_expr<__gmp_expr, __gmp_expr, __gmp_binary_plus> > + operator+(const __gmp_expr &expr1, const __gmp_expr &expr2) + { + return __gmp_expr + <__gmp_binary_expr<__gmp_expr, __gmp_expr, __gmp_binary_plus> > + (expr1, expr2); + } + + And the corresponding specializations of `__gmp_expr::eval': + + template + void __gmp_expr + <__gmp_binary_expr<__gmp_expr, __gmp_expr, Op> >::eval + (mpf_t f, unsigned long int precision) + { + // declare two temporaries + mpf_class temp1(expr.val1, precision), temp2(expr.val2, precision); + Op::eval(f, temp1.get_mpf_t(), temp2.get_mpf_t()); + } + + The expression is thus recursively evaluated to any level of +complexity and all subexpressions are evaluated to the precision of `f'. + + +File: gmp.info, Node: Contributors, Next: References, Prev: Internals, Up: Top + +Contributors +************ + +Torbjorn Granlund wrote the original GMP library and is still +developing and maintaining it. Several other individuals and +organizations have contributed to GMP in various ways. Here is a list +in chronological order: + + Gunnar Sjoedin and Hans Riesel helped with mathematical problems in +early versions of the library. + + Richard Stallman contributed to the interface design and revised the +first version of this manual. + + Brian Beuning and Doug Lea helped with testing of early versions of +the library and made creative suggestions. + + John Amanatides of York University in Canada contributed the function +`mpz_probab_prime_p'. + + Paul Zimmermann of Inria sparked the development of GMP 2, with his +comparisons between bignum packages. + + Ken Weber (Kent State University, Universidade Federal do Rio Grande +do Sul) contributed `mpz_gcd', `mpz_divexact', `mpn_gcd', and +`mpn_bdivmod', partially supported by CNPq (Brazil) grant 301314194-2. + + Per Bothner of Cygnus Support helped to set up GMP to use Cygnus' +configure. He has also made valuable suggestions and tested numerous +intermediary releases. + + Joachim Hollman was involved in the design of the `mpf' interface, +and in the `mpz' design revisions for version 2. + + Bennet Yee contributed the initial versions of `mpz_jacobi' and +`mpz_legendre'. + + Andreas Schwab contributed the files `mpn/m68k/lshift.S' and +`mpn/m68k/rshift.S' (now in `.asm' form). + + The development of floating point functions of GNU MP 2, were +supported in part by the ESPRIT-BRA (Basic Research Activities) 6846 +project POSSO (POlynomial System SOlving). + + GNU MP 2 was finished and released by SWOX AB, SWEDEN, in +cooperation with the IDA Center for Computing Sciences, USA. + + Robert Harley of Inria, France and David Seal of ARM, England, +suggested clever improvements for population count. + + Robert Harley also wrote highly optimized Karatsuba and 3-way Toom +multiplication functions for GMP 3. He also contributed the ARM +assembly code. + + Torsten Ekedahl of the Mathematical department of Stockholm +University provided significant inspiration during several phases of +the GMP development. His mathematical expertise helped improve several +algorithms. + + Paul Zimmermann wrote the Divide and Conquer division code, the REDC +code, the REDC-based mpz_powm code, the FFT multiply code, and the +Karatsuba square root. The ECMNET project Paul is organizing was a +driving force behind many of the optimizations in GMP 3. + + Linus Nordberg wrote the new configure system based on autoconf and +implemented the new random functions. + + Kent Boortz made the Macintosh port. + + Kevin Ryde worked on a number of things: optimized x86 code, m4 asm +macros, parameter tuning, speed measuring, the configure system, +function inlining, divisibility tests, bit scanning, Jacobi symbols, +Fibonacci and Lucas number functions, printf and scanf functions, perl +interface, demo expression parser, the algorithms chapter in the +manual, `gmpasm-mode.el', and various miscellaneous improvements +elsewhere. + + Steve Root helped write the optimized alpha 21264 assembly code. + + Gerardo Ballabio wrote the `gmpxx.h' C++ class interface and the C++ +`istream' input routines. + + GNU MP 4.0 was finished and released by Torbjorn Granlund and Kevin +Ryde. Torbjorn's work was partially funded by the IDA Center for +Computing Sciences, USA. + + (This list is chronological, not ordered after significance. If you +have contributed to GMP but are not listed above, please tell + about the omission!) + + Thanks goes to Hans Thorsen for donating an SGI system for the GMP +test system environment. + + +File: gmp.info, Node: References, Next: GNU Free Documentation License, Prev: Contributors, Up: Top + +References +********** + +Books +===== + + * Jonathan M. Borwein and Peter B. Borwein, "Pi and the AGM: A Study + in Analytic Number Theory and Computational Complexity", Wiley, + John & Sons, 1998. + + * Henri Cohen, "A Course in Computational Algebraic Number Theory", + Graduate Texts in Mathematics number 138, Springer-Verlag, 1993. + `http://www.math.u-bordeaux.fr/~cohen' + + * Donald E. Knuth, "The Art of Computer Programming", volume 2, + "Seminumerical Algorithms", 3rd edition, Addison-Wesley, 1998. + `http://www-cs-faculty.stanford.edu/~knuth/taocp.html' + + * John D. Lipson, "Elements of Algebra and Algebraic Computing", The + Benjamin Cummings Publishing Company Inc, 1981. + + * Alfred J. Menezes, Paul C. van Oorschot and Scott A. Vanstone, + "Handbook of Applied Cryptography", + `http://www.cacr.math.uwaterloo.ca/hac/' + + * Richard M. Stallman, "Using and Porting GCC", Free Software + Foundation, 1999, available online + `http://www.gnu.org/software/gcc/onlinedocs/', and in the GCC + package `ftp://ftp.gnu.org/gnu/gcc/' + +Papers +====== + + * Yves Bertot, Nicolas Magaud and Paul Zimmermann, "A Proof of GMP + Square Root", Journal of Automated Reasoning, volume 29, 2002, pp. + 225-252. Also available online as INRIA Research Report 4475, + June 2001, `http://www.inria.fr/rrrt/rr-4475.html' + + * Christoph Burnikel and Joachim Ziegler, "Fast Recursive Division", + Max-Planck-Institut fuer Informatik Research Report + MPI-I-98-1-022, + `http://data.mpi-sb.mpg.de/internet/reports.nsf/NumberView/1998-1-022' + + * Torbjorn Granlund and Peter L. Montgomery, "Division by Invariant + Integers using Multiplication", in Proceedings of the SIGPLAN + PLDI'94 Conference, June 1994. Also available + `ftp://ftp.cwi.nl/pub/pmontgom/divcnst.psa4.gz' (and .psl.gz). + + * Peter L. Montgomery, "Modular Multiplication Without Trial + Division", in Mathematics of Computation, volume 44, number 170, + April 1985. + + * Tudor Jebelean, "An algorithm for exact division", Journal of + Symbolic Computation, volume 15, 1993, pp. 169-180. Research + report version available + `ftp://ftp.risc.uni-linz.ac.at/pub/techreports/1992/92-35.ps.gz' + + * Tudor Jebelean, "Exact Division with Karatsuba Complexity - + Extended Abstract", RISC-Linz technical report 96-31, + `ftp://ftp.risc.uni-linz.ac.at/pub/techreports/1996/96-31.ps.gz' + + * Tudor Jebelean, "Practical Integer Division with Karatsuba + Complexity", ISSAC 97, pp. 339-341. Technical report available + `ftp://ftp.risc.uni-linz.ac.at/pub/techreports/1996/96-29.ps.gz' + + * Tudor Jebelean, "A Generalization of the Binary GCD Algorithm", + ISSAC 93, pp. 111-116. Technical report version available + `ftp://ftp.risc.uni-linz.ac.at/pub/techreports/1993/93-01.ps.gz' + + * Tudor Jebelean, "A Double-Digit Lehmer-Euclid Algorithm for + Finding the GCD of Long Integers", Journal of Symbolic + Computation, volume 19, 1995, pp. 145-157. Technical report + version also available + `ftp://ftp.risc.uni-linz.ac.at/pub/techreports/1992/92-69.ps.gz' + + * Werner Krandick and Tudor Jebelean, "Bidirectional Exact Integer + Division", Journal of Symbolic Computation, volume 21, 1996, pp. + 441-455. Early technical report version also available + `ftp://ftp.risc.uni-linz.ac.at/pub/techreports/1994/94-50.ps.gz' + + * R. Moenck and A. Borodin, "Fast Modular Transforms via Division", + Proceedings of the 13th Annual IEEE Symposium on Switching and + Automata Theory, October 1972, pp. 90-96. Reprinted as "Fast + Modular Transforms", Journal of Computer and System Sciences, + volume 8, number 3, June 1974, pp. 366-386. + + * Arnold Scho"nhage and Volker Strassen, "Schnelle Multiplikation + grosser Zahlen", Computing 7, 1971, pp. 281-292. + + * Kenneth Weber, "The accelerated integer GCD algorithm", ACM + Transactions on Mathematical Software, volume 21, number 1, March + 1995, pp. 111-122. + + * Paul Zimmermann, "Karatsuba Square Root", INRIA Research Report + 3805, November 1999, `http://www.inria.fr/RRRT/RR-3805.html' + + * Paul Zimmermann, "A Proof of GMP Fast Division and Square Root + Implementations", + `http://www.loria.fr/~zimmerma/papers/proof-div-sqrt.ps.gz' + + * Dan Zuras, "On Squaring and Multiplying Large Integers", ARITH-11: + IEEE Symposium on Computer Arithmetic, 1993, pp. 260 to 271. + Reprinted as "More on Multiplying and Squaring Large Integers", + IEEE Transactions on Computers, volume 43, number 8, August 1994, + pp. 899-908. + + +File: gmp.info, Node: GNU Free Documentation License, Next: Concept Index, Prev: References, Up: Top + +GNU Free Documentation License +****************************** + + Version 1.2, November 2002 + Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + 0. PREAMBLE + + The purpose of this License is to make a manual, textbook, or other + functional and useful document "free" in the sense of freedom: to + assure everyone the effective freedom to copy and redistribute it, + with or without modifying it, either commercially or + noncommercially. Secondarily, this License preserves for the + author and publisher a way to get credit for their work, while not + being considered responsible for modifications made by others. + + This License is a kind of "copyleft", which means that derivative + works of the document must themselves be free in the same sense. + It complements the GNU General Public License, which is a copyleft + license designed for free software. + + We have designed this License in order to use it for manuals for + free software, because free software needs free documentation: a + free program should come with manuals providing the same freedoms + that the software does. But this License is not limited to + software manuals; it can be used for any textual work, regardless + of subject matter or whether it is published as a printed book. + We recommend this License principally for works whose purpose is + instruction or reference. + + 1. APPLICABILITY AND DEFINITIONS + + This License applies to any manual or other work, in any medium, + that contains a notice placed by the copyright holder saying it + can be distributed under the terms of this License. Such a notice + grants a world-wide, royalty-free license, unlimited in duration, + to use that work under the conditions stated herein. The + "Document", below, refers to any such manual or work. Any member + of the public is a licensee, and is addressed as "you". You + accept the license if you copy, modify or distribute the work in a + way requiring permission under copyright law. + + A "Modified Version" of the Document means any work containing the + Document or a portion of it, either copied verbatim, or with + modifications and/or translated into another language. + + A "Secondary Section" is a named appendix or a front-matter section + of the Document that deals exclusively with the relationship of the + publishers or authors of the Document to the Document's overall + subject (or to related matters) and contains nothing that could + fall directly within that overall subject. (Thus, if the Document + is in part a textbook of mathematics, a Secondary Section may not + explain any mathematics.) The relationship could be a matter of + historical connection with the subject or with related matters, or + of legal, commercial, philosophical, ethical or political position + regarding them. + + The "Invariant Sections" are certain Secondary Sections whose + titles are designated, as being those of Invariant Sections, in + the notice that says that the Document is released under this + License. If a section does not fit the above definition of + Secondary then it is not allowed to be designated as Invariant. + The Document may contain zero Invariant Sections. If the Document + does not identify any Invariant Sections then there are none. + + The "Cover Texts" are certain short passages of text that are + listed, as Front-Cover Texts or Back-Cover Texts, in the notice + that says that the Document is released under this License. A + Front-Cover Text may be at most 5 words, and a Back-Cover Text may + be at most 25 words. + + A "Transparent" copy of the Document means a machine-readable copy, + represented in a format whose specification is available to the + general public, that is suitable for revising the document + straightforwardly with generic text editors or (for images + composed of pixels) generic paint programs or (for drawings) some + widely available drawing editor, and that is suitable for input to + text formatters or for automatic translation to a variety of + formats suitable for input to text formatters. A copy made in an + otherwise Transparent file format whose markup, or absence of + markup, has been arranged to thwart or discourage subsequent + modification by readers is not Transparent. An image format is + not Transparent if used for any substantial amount of text. A + copy that is not "Transparent" is called "Opaque". + + Examples of suitable formats for Transparent copies include plain + ASCII without markup, Texinfo input format, LaTeX input format, + SGML or XML using a publicly available DTD, and + standard-conforming simple HTML, PostScript or PDF designed for + human modification. Examples of transparent image formats include + PNG, XCF and JPG. Opaque formats include proprietary formats that + can be read and edited only by proprietary word processors, SGML or + XML for which the DTD and/or processing tools are not generally + available, and the machine-generated HTML, PostScript or PDF + produced by some word processors for output purposes only. + + The "Title Page" means, for a printed book, the title page itself, + plus such following pages as are needed to hold, legibly, the + material this License requires to appear in the title page. For + works in formats which do not have any title page as such, "Title + Page" means the text near the most prominent appearance of the + work's title, preceding the beginning of the body of the text. + + A section "Entitled XYZ" means a named subunit of the Document + whose title either is precisely XYZ or contains XYZ in parentheses + following text that translates XYZ in another language. (Here XYZ + stands for a specific section name mentioned below, such as + "Acknowledgements", "Dedications", "Endorsements", or "History".) + To "Preserve the Title" of such a section when you modify the + Document means that it remains a section "Entitled XYZ" according + to this definition. + + The Document may include Warranty Disclaimers next to the notice + which states that this License applies to the Document. These + Warranty Disclaimers are considered to be included by reference in + this License, but only as regards disclaiming warranties: any other + implication that these Warranty Disclaimers may have is void and + has no effect on the meaning of this License. + + 2. VERBATIM COPYING + + You may copy and distribute the Document in any medium, either + commercially or noncommercially, provided that this License, the + copyright notices, and the license notice saying this License + applies to the Document are reproduced in all copies, and that you + add no other conditions whatsoever to those of this License. You + may not use technical measures to obstruct or control the reading + or further copying of the copies you make or distribute. However, + you may accept compensation in exchange for copies. If you + distribute a large enough number of copies you must also follow + the conditions in section 3. + + You may also lend copies, under the same conditions stated above, + and you may publicly display copies. + + 3. COPYING IN QUANTITY + + If you publish printed copies (or copies in media that commonly + have printed covers) of the Document, numbering more than 100, and + the Document's license notice requires Cover Texts, you must + enclose the copies in covers that carry, clearly and legibly, all + these Cover Texts: Front-Cover Texts on the front cover, and + Back-Cover Texts on the back cover. Both covers must also clearly + and legibly identify you as the publisher of these copies. The + front cover must present the full title with all words of the + title equally prominent and visible. You may add other material + on the covers in addition. Copying with changes limited to the + covers, as long as they preserve the title of the Document and + satisfy these conditions, can be treated as verbatim copying in + other respects. + + If the required texts for either cover are too voluminous to fit + legibly, you should put the first ones listed (as many as fit + reasonably) on the actual cover, and continue the rest onto + adjacent pages. + + If you publish or distribute Opaque copies of the Document + numbering more than 100, you must either include a + machine-readable Transparent copy along with each Opaque copy, or + state in or with each Opaque copy a computer-network location from + which the general network-using public has access to download + using public-standard network protocols a complete Transparent + copy of the Document, free of added material. If you use the + latter option, you must take reasonably prudent steps, when you + begin distribution of Opaque copies in quantity, to ensure that + this Transparent copy will remain thus accessible at the stated + location until at least one year after the last time you + distribute an Opaque copy (directly or through your agents or + retailers) of that edition to the public. + + It is requested, but not required, that you contact the authors of + the Document well before redistributing any large number of + copies, to give them a chance to provide you with an updated + version of the Document. + + 4. MODIFICATIONS + + You may copy and distribute a Modified Version of the Document + under the conditions of sections 2 and 3 above, provided that you + release the Modified Version under precisely this License, with + the Modified Version filling the role of the Document, thus + licensing distribution and modification of the Modified Version to + whoever possesses a copy of it. In addition, you must do these + things in the Modified Version: + + A. Use in the Title Page (and on the covers, if any) a title + distinct from that of the Document, and from those of + previous versions (which should, if there were any, be listed + in the History section of the Document). You may use the + same title as a previous version if the original publisher of + that version gives permission. + + B. List on the Title Page, as authors, one or more persons or + entities responsible for authorship of the modifications in + the Modified Version, together with at least five of the + principal authors of the Document (all of its principal + authors, if it has fewer than five), unless they release you + from this requirement. + + C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. + + D. Preserve all the copyright notices of the Document. + + E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. + + F. Include, immediately after the copyright notices, a license + notice giving the public permission to use the Modified + Version under the terms of this License, in the form shown in + the Addendum below. + + G. Preserve in that license notice the full lists of Invariant + Sections and required Cover Texts given in the Document's + license notice. + + H. Include an unaltered copy of this License. + + I. Preserve the section Entitled "History", Preserve its Title, + and add to it an item stating at least the title, year, new + authors, and publisher of the Modified Version as given on + the Title Page. If there is no section Entitled "History" in + the Document, create one stating the title, year, authors, + and publisher of the Document as given on its Title Page, + then add an item describing the Modified Version as stated in + the previous sentence. + + J. Preserve the network location, if any, given in the Document + for public access to a Transparent copy of the Document, and + likewise the network locations given in the Document for + previous versions it was based on. These may be placed in + the "History" section. You may omit a network location for a + work that was published at least four years before the + Document itself, or if the original publisher of the version + it refers to gives permission. + + K. For any section Entitled "Acknowledgements" or "Dedications", + Preserve the Title of the section, and preserve in the + section all the substance and tone of each of the contributor + acknowledgements and/or dedications given therein. + + L. Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers + or the equivalent are not considered part of the section + titles. + + M. Delete any section Entitled "Endorsements". Such a section + may not be included in the Modified Version. + + N. Do not retitle any existing section to be Entitled + "Endorsements" or to conflict in title with any Invariant + Section. + + O. Preserve any Warranty Disclaimers. + + If the Modified Version includes new front-matter sections or + appendices that qualify as Secondary Sections and contain no + material copied from the Document, you may at your option + designate some or all of these sections as invariant. To do this, + add their titles to the list of Invariant Sections in the Modified + Version's license notice. These titles must be distinct from any + other section titles. + + You may add a section Entitled "Endorsements", provided it contains + nothing but endorsements of your Modified Version by various + parties--for example, statements of peer review or that the text + has been approved by an organization as the authoritative + definition of a standard. + + You may add a passage of up to five words as a Front-Cover Text, + and a passage of up to 25 words as a Back-Cover Text, to the end + of the list of Cover Texts in the Modified Version. Only one + passage of Front-Cover Text and one of Back-Cover Text may be + added by (or through arrangements made by) any one entity. If the + Document already includes a cover text for the same cover, + previously added by you or by arrangement made by the same entity + you are acting on behalf of, you may not add another; but you may + replace the old one, on explicit permission from the previous + publisher that added the old one. + + The author(s) and publisher(s) of the Document do not by this + License give permission to use their names for publicity for or to + assert or imply endorsement of any Modified Version. + + 5. COMBINING DOCUMENTS + + You may combine the Document with other documents released under + this License, under the terms defined in section 4 above for + modified versions, provided that you include in the combination + all of the Invariant Sections of all of the original documents, + unmodified, and list them all as Invariant Sections of your + combined work in its license notice, and that you preserve all + their Warranty Disclaimers. + + The combined work need only contain one copy of this License, and + multiple identical Invariant Sections may be replaced with a single + copy. If there are multiple Invariant Sections with the same name + but different contents, make the title of each such section unique + by adding at the end of it, in parentheses, the name of the + original author or publisher of that section if known, or else a + unique number. Make the same adjustment to the section titles in + the list of Invariant Sections in the license notice of the + combined work. + + In the combination, you must combine any sections Entitled + "History" in the various original documents, forming one section + Entitled "History"; likewise combine any sections Entitled + "Acknowledgements", and any sections Entitled "Dedications". You + must delete all sections Entitled "Endorsements." + + 6. COLLECTIONS OF DOCUMENTS + + You may make a collection consisting of the Document and other + documents released under this License, and replace the individual + copies of this License in the various documents with a single copy + that is included in the collection, provided that you follow the + rules of this License for verbatim copying of each of the + documents in all other respects. + + You may extract a single document from such a collection, and + distribute it individually under this License, provided you insert + a copy of this License into the extracted document, and follow + this License in all other respects regarding verbatim copying of + that document. + + 7. AGGREGATION WITH INDEPENDENT WORKS + + A compilation of the Document or its derivatives with other + separate and independent documents or works, in or on a volume of + a storage or distribution medium, is called an "aggregate" if the + copyright resulting from the compilation is not used to limit the + legal rights of the compilation's users beyond what the individual + works permit. When the Document is included in an aggregate, this + License does not apply to the other works in the aggregate which + are not themselves derivative works of the Document. + + If the Cover Text requirement of section 3 is applicable to these + copies of the Document, then if the Document is less than one half + of the entire aggregate, the Document's Cover Texts may be placed + on covers that bracket the Document within the aggregate, or the + electronic equivalent of covers if the Document is in electronic + form. Otherwise they must appear on printed covers that bracket + the whole aggregate. + + 8. TRANSLATION + + Translation is considered a kind of modification, so you may + distribute translations of the Document under the terms of section + 4. Replacing Invariant Sections with translations requires special + permission from their copyright holders, but you may include + translations of some or all Invariant Sections in addition to the + original versions of these Invariant Sections. You may include a + translation of this License, and all the license notices in the + Document, and any Warranty Disclaimers, provided that you also + include the original English version of this License and the + original versions of those notices and disclaimers. In case of a + disagreement between the translation and the original version of + this License or a notice or disclaimer, the original version will + prevail. + + If a section in the Document is Entitled "Acknowledgements", + "Dedications", or "History", the requirement (section 4) to + Preserve its Title (section 1) will typically require changing the + actual title. + + 9. TERMINATION + + You may not copy, modify, sublicense, or distribute the Document + except as expressly provided for under this License. Any other + attempt to copy, modify, sublicense or distribute the Document is + void, and will automatically terminate your rights under this + License. However, parties who have received copies, or rights, + from you under this License will not have their licenses + terminated so long as such parties remain in full compliance. + + 10. FUTURE REVISIONS OF THIS LICENSE + + The Free Software Foundation may publish new, revised versions of + the GNU Free Documentation License from time to time. Such new + versions will be similar in spirit to the present version, but may + differ in detail to address new problems or concerns. See + `http://www.gnu.org/copyleft/'. + + Each version of the License is given a distinguishing version + number. If the Document specifies that a particular numbered + version of this License "or any later version" applies to it, you + have the option of following the terms and conditions either of + that specified version or of any later version that has been + published (not as a draft) by the Free Software Foundation. If + the Document does not specify a version number of this License, + you may choose any version ever published (not as a draft) by the + Free Software Foundation. + +ADDENDUM: How to use this License for your documents +==================================================== + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and license +notices just after the title page: + + Copyright (C) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover + Texts. A copy of the license is included in the section entitled ``GNU + Free Documentation License''. + + If you have Invariant Sections, Front-Cover Texts and Back-Cover +Texts, replace the "with...Texts." line with this: + + with the Invariant Sections being LIST THEIR TITLES, with + the Front-Cover Texts being LIST, and with the Back-Cover Texts + being LIST. + + If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. + + If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, to +permit their use in free software. + + +File: gmp.info, Node: Concept Index, Next: Function Index, Prev: GNU Free Documentation License, Up: Top + +Concept Index +************* + +* Menu: + +* --exec-prefix: Build Options. +* --prefix: Build Options. +* 68000: Known Build Problems. +* ABI: ABI and ISA. +* About this manual: Introduction to GMP. +* Algorithms: Algorithms. +* alloca: Build Options. +* Allocation of memory: Custom Allocation. +* Anonymous FTP of latest version: Introduction to GMP. +* Application Binary Interface: ABI and ISA. +* Arithmetic functions <1>: Float Arithmetic. +* Arithmetic functions <2>: Rational Arithmetic. +* Arithmetic functions: Integer Arithmetic. +* Assignment functions <1>: Assigning Floats. +* Assignment functions: Assigning Integers. +* Autoconf detections: Autoconf. +* Basics: GMP Basics. +* Berkeley MP compatible functions: BSD Compatible Functions. +* Binomial coefficient functions: Number Theoretic Functions. +* Bit manipulation functions: Integer Logic and Bit Fiddling. +* Bit shift left: Integer Arithmetic. +* Bit shift right: Integer Division. +* Bits per limb: Useful Macros and Constants. +* BSD MP compatible functions: BSD Compatible Functions. +* Bug reporting: Reporting Bugs. +* Build notes for binary packaging: Notes for Package Builds. +* Build notes for particular systems: Notes for Particular Systems. +* Build options: Build Options. +* Build problems known: Known Build Problems. +* Building GMP: Installing GMP. +* C++ Interface: C++ Class Interface. +* C++ istream input: C++ Formatted Input. +* C++ ostream output: C++ Formatted Output. +* Comparison functions <1>: Integer Comparisons. +* Comparison functions <2>: Float Comparison. +* Comparison functions: Comparing Rationals. +* Compatibility with older versions: Compatibility with older versions. +* Conditions for copying GNU MP: Copying. +* Configuring GMP: Installing GMP. +* Constants: Useful Macros and Constants. +* Contributors: Contributors. +* Conventions for parameters: Parameter Conventions. +* Conventions for variables: Variable Conventions. +* Conversion functions <1>: Converting Integers. +* Conversion functions <2>: Converting Floats. +* Conversion functions: Rational Conversions. +* Copying conditions: Copying. +* CPUs supported: Introduction to GMP. +* Custom allocation: Custom Allocation. +* Debugging: Debugging. +* Demonstration programs: Demonstration Programs. +* DESTDIR: Known Build Problems. +* Digits in an integer: Miscellaneous Integer Functions. +* Division algorithms: Division Algorithms. +* Division functions <1>: Integer Division. +* Division functions <2>: Rational Arithmetic. +* Division functions: Float Arithmetic. +* Efficiency: Efficiency. +* Emacs: Emacs. +* Exact division functions: Integer Division. +* Example programs: Demonstration Programs. +* Exec prefix: Build Options. +* Exponentiation functions <1>: Integer Exponentiation. +* Exponentiation functions: Float Arithmetic. +* Export: Integer Import and Export. +* Extended GCD: Number Theoretic Functions. +* Factorial functions: Number Theoretic Functions. +* FDL, GNU Free Documentation License: GNU Free Documentation License. +* Fibonacci sequence functions: Number Theoretic Functions. +* Float arithmetic functions: Float Arithmetic. +* Float assignment functions: Assigning Floats. +* Float comparison functions: Float Comparison. +* Float conversion functions: Converting Floats. +* Float functions: Floating-point Functions. +* Float init and assign functions: Simultaneous Float Init & Assign. +* Float initialization functions: Initializing Floats. +* Float input and output functions: I/O of Floats. +* Float miscellaneous functions: Miscellaneous Float Functions. +* Float sign tests: Float Comparison. +* Floating point mode: Notes for Particular Systems. +* Floating-point functions: Floating-point Functions. +* Floating-point number: Nomenclature and Types. +* Formatted input: Formatted Input. +* Formatted output: Formatted Output. +* FTP of latest version: Introduction to GMP. +* Function classes: Function Classes. +* GMP version number: Useful Macros and Constants. +* gmp.h: Headers and Libraries. +* gmpxx.h: C++ Interface General. +* GNU Free Documentation License: GNU Free Documentation License. +* Greatest common divisor algorithms: Greatest Common Divisor Algorithms. +* Greatest common divisor functions: Number Theoretic Functions. +* Hardware floating point mode: Notes for Particular Systems. +* Headers: Headers and Libraries. +* Home page: Introduction to GMP. +* I/O functions <1>: I/O of Rationals. +* I/O functions <2>: I/O of Floats. +* I/O functions: I/O of Integers. +* Import: Integer Import and Export. +* Initialization and assignment functions <1>: Simultaneous Integer Init & Assign. +* Initialization and assignment functions <2>: Initializing Rationals. +* Initialization and assignment functions: Simultaneous Float Init & Assign. +* Initialization functions <1>: Initializing Floats. +* Initialization functions: Initializing Integers. +* Input functions <1>: I/O of Integers. +* Input functions <2>: I/O of Rationals. +* Input functions: I/O of Floats. +* Install prefix: Build Options. +* Installing GMP: Installing GMP. +* Instruction Set Architecture: ABI and ISA. +* Integer: Nomenclature and Types. +* Integer arithmetic functions: Integer Arithmetic. +* Integer assignment functions: Assigning Integers. +* Integer bit manipulation functions: Integer Logic and Bit Fiddling. +* Integer comparison functions: Integer Comparisons. +* Integer conversion functions: Converting Integers. +* Integer division functions: Integer Division. +* Integer exponentiation functions: Integer Exponentiation. +* Integer export: Integer Import and Export. +* Integer functions: Integer Functions. +* Integer import: Integer Import and Export. +* Integer init and assign: Simultaneous Integer Init & Assign. +* Integer initialization functions: Initializing Integers. +* Integer input and output functions: I/O of Integers. +* Integer miscellaneous functions: Miscellaneous Integer Functions. +* Integer random number functions: Integer Random Numbers. +* Integer root functions: Integer Roots. +* Integer sign tests: Integer Comparisons. +* Introduction: Introduction to GMP. +* ISA: ABI and ISA. +* istream input: C++ Formatted Input. +* Jacobi symbol functions: Number Theoretic Functions. +* Kronecker symbol functions: Number Theoretic Functions. +* Latest version of GMP: Introduction to GMP. +* Least common multiple functions: Number Theoretic Functions. +* Libraries: Headers and Libraries. +* Libtool versioning: Notes for Package Builds. +* License conditions: Copying. +* Limb: Nomenclature and Types. +* Limb size: Useful Macros and Constants. +* Linking: Headers and Libraries. +* Logical functions: Integer Logic and Bit Fiddling. +* Low-level functions: Low-level Functions. +* Lucas number functions: Number Theoretic Functions. +* Mailing lists: Introduction to GMP. +* Memory allocation: Custom Allocation. +* Memory Management: Memory Management. +* Miscellaneous float functions: Miscellaneous Float Functions. +* Miscellaneous integer functions: Miscellaneous Integer Functions. +* Modular inverse functions: Number Theoretic Functions. +* Most significant bit: Miscellaneous Integer Functions. +* mp.h: BSD Compatible Functions. +* MPFR: Build Options. +* mpfrxx.h: C++ Interface MPFR. +* Multi-threading: Reentrancy. +* Multiplication algorithms: Multiplication Algorithms. +* Nails: Low-level Functions. +* Nomenclature: Nomenclature and Types. +* Number theoretic functions: Number Theoretic Functions. +* Numerator and denominator: Applying Integer Functions. +* ostream output: C++ Formatted Output. +* Output functions <1>: I/O of Integers. +* Output functions <2>: I/O of Floats. +* Output functions: I/O of Rationals. +* Packaged builds: Notes for Package Builds. +* PalmOS: Known Build Problems. +* Parameter conventions: Parameter Conventions. +* Particular systems: Notes for Particular Systems. +* perl: Demonstration Programs. +* Powering algorithms: Powering Algorithms. +* Powering functions <1>: Integer Exponentiation. +* Powering functions: Float Arithmetic. +* Precision of floats: Floating-point Functions. +* Precision of hardware floating point: Notes for Particular Systems. +* Prefix: Build Options. +* Prime testing functions: Number Theoretic Functions. +* printf formatted output: Formatted Output. +* Profiling: Profiling. +* Radix conversion algorithms: Radix Conversion Algorithms. +* Random number functions <1>: Integer Random Numbers. +* Random number functions: Random Number Functions. +* Random number seeding: Random State Seeding. +* Random number state: Random State Initialization. +* Rational arithmetic functions: Rational Arithmetic. +* Rational comparison functions: Comparing Rationals. +* Rational conversion functions: Rational Conversions. +* Rational init and assign: Initializing Rationals. +* Rational input and output functions: I/O of Rationals. +* Rational number: Nomenclature and Types. +* Rational number functions: Rational Number Functions. +* Rational numerator and denominator: Applying Integer Functions. +* Rational sign tests: Comparing Rationals. +* Reentrancy: Reentrancy. +* References: References. +* Reporting bugs: Reporting Bugs. +* Root extraction algorithms: Root Extraction Algorithms. +* Root extraction functions <1>: Float Arithmetic. +* Root extraction functions: Integer Roots. +* Sample programs: Demonstration Programs. +* scanf formatted input: Formatted Input. +* Shared library versioning: Notes for Package Builds. +* Sign tests <1>: Comparing Rationals. +* Sign tests <2>: Float Comparison. +* Sign tests: Integer Comparisons. +* Size in digits: Miscellaneous Integer Functions. +* Sparc: Notes for Particular Systems. +* Stack overflow segfaults: Build Options. +* Stripped libraries: Known Build Problems. +* Systems: Notes for Particular Systems. +* Thread safety: Reentrancy. +* Types: Nomenclature and Types. +* Upward compatibility: Compatibility with older versions. +* Useful macros and constants: Useful Macros and Constants. +* User-defined precision: Floating-point Functions. +* Valgrind: Debugging. +* Variable conventions: Variable Conventions. +* Version number: Useful Macros and Constants. +* Web page: Introduction to GMP. +* x87: Notes for Particular Systems. + + +File: gmp.info, Node: Function Index, Prev: Concept Index, Up: Top + +Function and Type Index +*********************** + +* Menu: + +* __GNU_MP_VERSION: Useful Macros and Constants. +* __GNU_MP_VERSION_MINOR: Useful Macros and Constants. +* __GNU_MP_VERSION_PATCHLEVEL: Useful Macros and Constants. +* _mpz_realloc: Initializing Integers. +* abs <1>: C++ Interface Integers. +* abs <2>: C++ Interface Floats. +* abs: C++ Interface Rationals. +* allocate_function: Custom Allocation. +* ceil: C++ Interface Floats. +* cmp <1>: C++ Interface Floats. +* cmp <2>: C++ Interface Integers. +* cmp <3>: C++ Interface Rationals. +* cmp <4>: C++ Interface Floats. +* cmp: C++ Interface Rationals. +* deallocate_function: Custom Allocation. +* floor: C++ Interface Floats. +* gcd: BSD Compatible Functions. +* gmp_asprintf: Formatted Output Functions. +* gmp_errno: Random State Initialization. +* GMP_ERROR_INVALID_ARGUMENT: Random State Initialization. +* GMP_ERROR_UNSUPPORTED_ARGUMENT: Random State Initialization. +* gmp_fprintf: Formatted Output Functions. +* gmp_fscanf: Formatted Input Functions. +* GMP_LIMB_BITS: Low-level Functions. +* GMP_NAIL_BITS: Low-level Functions. +* GMP_NAIL_MASK: Low-level Functions. +* GMP_NUMB_BITS: Low-level Functions. +* GMP_NUMB_MASK: Low-level Functions. +* GMP_NUMB_MAX: Low-level Functions. +* gmp_obstack_printf: Formatted Output Functions. +* gmp_obstack_vprintf: Formatted Output Functions. +* gmp_printf: Formatted Output Functions. +* GMP_RAND_ALG_DEFAULT: Random State Initialization. +* GMP_RAND_ALG_LC: Random State Initialization. +* gmp_randclass: C++ Interface Random Numbers. +* gmp_randclass::get_f: C++ Interface Random Numbers. +* gmp_randclass::get_z_bits: C++ Interface Random Numbers. +* gmp_randclass::get_z_range: C++ Interface Random Numbers. +* gmp_randclass::gmp_randclass: C++ Interface Random Numbers. +* gmp_randclass::seed: C++ Interface Random Numbers. +* gmp_randclear: Random State Initialization. +* gmp_randinit: Random State Initialization. +* gmp_randinit_default: Random State Initialization. +* gmp_randinit_lc_2exp: Random State Initialization. +* gmp_randinit_lc_2exp_size: Random State Initialization. +* gmp_randseed: Random State Seeding. +* gmp_randseed_ui: Random State Seeding. +* gmp_scanf: Formatted Input Functions. +* gmp_snprintf: Formatted Output Functions. +* gmp_sprintf: Formatted Output Functions. +* gmp_sscanf: Formatted Input Functions. +* gmp_vasprintf: Formatted Output Functions. +* gmp_version: Useful Macros and Constants. +* gmp_vfprintf: Formatted Output Functions. +* gmp_vfscanf: Formatted Input Functions. +* gmp_vprintf: Formatted Output Functions. +* gmp_vscanf: Formatted Input Functions. +* gmp_vsnprintf: Formatted Output Functions. +* gmp_vsprintf: Formatted Output Functions. +* gmp_vsscanf: Formatted Input Functions. +* hypot: C++ Interface Floats. +* itom: BSD Compatible Functions. +* madd: BSD Compatible Functions. +* mcmp: BSD Compatible Functions. +* mdiv: BSD Compatible Functions. +* mfree: BSD Compatible Functions. +* min: BSD Compatible Functions. +* mout: BSD Compatible Functions. +* move: BSD Compatible Functions. +* mp_bits_per_limb: Useful Macros and Constants. +* mp_limb_t: Nomenclature and Types. +* mp_set_memory_functions: Custom Allocation. +* mpf_abs: Float Arithmetic. +* mpf_add: Float Arithmetic. +* mpf_add_ui: Float Arithmetic. +* mpf_ceil: Miscellaneous Float Functions. +* mpf_class: C++ Interface General. +* mpf_class::fits_sint_p: C++ Interface Floats. +* mpf_class::fits_slong_p: C++ Interface Floats. +* mpf_class::fits_sshort_p: C++ Interface Floats. +* mpf_class::fits_uint_p: C++ Interface Floats. +* mpf_class::fits_ulong_p: C++ Interface Floats. +* mpf_class::fits_ushort_p: C++ Interface Floats. +* mpf_class::get_d: C++ Interface Floats. +* mpf_class::get_mpf_t: C++ Interface General. +* mpf_class::get_prec: C++ Interface Floats. +* mpf_class::get_si: C++ Interface Floats. +* mpf_class::get_ui: C++ Interface Floats. +* mpf_class::mpf_class: C++ Interface Floats. +* mpf_class::operator=: C++ Interface Floats. +* mpf_class::set_prec: C++ Interface Floats. +* mpf_class::set_prec_raw: C++ Interface Floats. +* mpf_clear: Initializing Floats. +* mpf_cmp: Float Comparison. +* mpf_cmp_d: Float Comparison. +* mpf_cmp_si: Float Comparison. +* mpf_cmp_ui: Float Comparison. +* mpf_div: Float Arithmetic. +* mpf_div_2exp: Float Arithmetic. +* mpf_div_ui: Float Arithmetic. +* mpf_eq: Float Comparison. +* mpf_fits_sint_p: Miscellaneous Float Functions. +* mpf_fits_slong_p: Miscellaneous Float Functions. +* mpf_fits_sshort_p: Miscellaneous Float Functions. +* mpf_fits_uint_p: Miscellaneous Float Functions. +* mpf_fits_ulong_p: Miscellaneous Float Functions. +* mpf_fits_ushort_p: Miscellaneous Float Functions. +* mpf_floor: Miscellaneous Float Functions. +* mpf_get_d: Converting Floats. +* mpf_get_d_2exp: Converting Floats. +* mpf_get_default_prec: Initializing Floats. +* mpf_get_prec: Initializing Floats. +* mpf_get_si: Converting Floats. +* mpf_get_str: Converting Floats. +* mpf_get_ui: Converting Floats. +* mpf_init: Initializing Floats. +* mpf_init2: Initializing Floats. +* mpf_init_set: Simultaneous Float Init & Assign. +* mpf_init_set_d: Simultaneous Float Init & Assign. +* mpf_init_set_si: Simultaneous Float Init & Assign. +* mpf_init_set_str: Simultaneous Float Init & Assign. +* mpf_init_set_ui: Simultaneous Float Init & Assign. +* mpf_inp_str: I/O of Floats. +* mpf_integer_p: Miscellaneous Float Functions. +* mpf_mul: Float Arithmetic. +* mpf_mul_2exp: Float Arithmetic. +* mpf_mul_ui: Float Arithmetic. +* mpf_neg: Float Arithmetic. +* mpf_out_str: I/O of Floats. +* mpf_pow_ui: Float Arithmetic. +* mpf_random2: Miscellaneous Float Functions. +* mpf_reldiff: Float Comparison. +* mpf_set: Assigning Floats. +* mpf_set_d: Assigning Floats. +* mpf_set_default_prec: Initializing Floats. +* mpf_set_prec: Initializing Floats. +* mpf_set_prec_raw: Initializing Floats. +* mpf_set_q: Assigning Floats. +* mpf_set_si: Assigning Floats. +* mpf_set_str: Assigning Floats. +* mpf_set_ui: Assigning Floats. +* mpf_set_z: Assigning Floats. +* mpf_sgn: Float Comparison. +* mpf_sqrt: Float Arithmetic. +* mpf_sqrt_ui: Float Arithmetic. +* mpf_sub: Float Arithmetic. +* mpf_sub_ui: Float Arithmetic. +* mpf_swap: Assigning Floats. +* mpf_t: Nomenclature and Types. +* mpf_trunc: Miscellaneous Float Functions. +* mpf_ui_div: Float Arithmetic. +* mpf_ui_sub: Float Arithmetic. +* mpf_urandomb: Miscellaneous Float Functions. +* mpfr_class: C++ Interface MPFR. +* mpn_add: Low-level Functions. +* mpn_add_1: Low-level Functions. +* mpn_add_n: Low-level Functions. +* mpn_addmul_1: Low-level Functions. +* mpn_bdivmod: Low-level Functions. +* mpn_cmp: Low-level Functions. +* mpn_divexact_by3: Low-level Functions. +* mpn_divexact_by3c: Low-level Functions. +* mpn_divmod: Low-level Functions. +* mpn_divmod_1: Low-level Functions. +* mpn_divrem: Low-level Functions. +* mpn_divrem_1: Low-level Functions. +* mpn_gcd: Low-level Functions. +* mpn_gcd_1: Low-level Functions. +* mpn_gcdext: Low-level Functions. +* mpn_get_str: Low-level Functions. +* mpn_hamdist: Low-level Functions. +* mpn_lshift: Low-level Functions. +* mpn_mod_1: Low-level Functions. +* mpn_mul: Low-level Functions. +* mpn_mul_1: Low-level Functions. +* mpn_mul_n: Low-level Functions. +* mpn_perfect_square_p: Low-level Functions. +* mpn_popcount: Low-level Functions. +* mpn_random: Low-level Functions. +* mpn_random2: Low-level Functions. +* mpn_rshift: Low-level Functions. +* mpn_scan0: Low-level Functions. +* mpn_scan1: Low-level Functions. +* mpn_set_str: Low-level Functions. +* mpn_sqrtrem: Low-level Functions. +* mpn_sub: Low-level Functions. +* mpn_sub_1: Low-level Functions. +* mpn_sub_n: Low-level Functions. +* mpn_submul_1: Low-level Functions. +* mpn_tdiv_qr: Low-level Functions. +* mpq_abs: Rational Arithmetic. +* mpq_add: Rational Arithmetic. +* mpq_canonicalize: Rational Number Functions. +* mpq_class: C++ Interface General. +* mpq_class::canonicalize: C++ Interface Rationals. +* mpq_class::get_d: C++ Interface Rationals. +* mpq_class::get_den: C++ Interface Rationals. +* mpq_class::get_den_mpz_t: C++ Interface Rationals. +* mpq_class::get_mpq_t: C++ Interface General. +* mpq_class::get_num: C++ Interface Rationals. +* mpq_class::get_num_mpz_t: C++ Interface Rationals. +* mpq_class::mpq_class: C++ Interface Rationals. +* mpq_clear: Initializing Rationals. +* mpq_cmp: Comparing Rationals. +* mpq_cmp_si: Comparing Rationals. +* mpq_cmp_ui: Comparing Rationals. +* mpq_denref: Applying Integer Functions. +* mpq_div: Rational Arithmetic. +* mpq_div_2exp: Rational Arithmetic. +* mpq_equal: Comparing Rationals. +* mpq_get_d: Rational Conversions. +* mpq_get_den: Applying Integer Functions. +* mpq_get_num: Applying Integer Functions. +* mpq_get_str: Rational Conversions. +* mpq_init: Initializing Rationals. +* mpq_inp_str: I/O of Rationals. +* mpq_inv: Rational Arithmetic. +* mpq_mul: Rational Arithmetic. +* mpq_mul_2exp: Rational Arithmetic. +* mpq_neg: Rational Arithmetic. +* mpq_numref: Applying Integer Functions. +* mpq_out_str: I/O of Rationals. +* mpq_set: Initializing Rationals. +* mpq_set_d: Rational Conversions. +* mpq_set_den: Applying Integer Functions. +* mpq_set_f: Rational Conversions. +* mpq_set_num: Applying Integer Functions. +* mpq_set_si: Initializing Rationals. +* mpq_set_str: Initializing Rationals. +* mpq_set_ui: Initializing Rationals. +* mpq_set_z: Initializing Rationals. +* mpq_sgn: Comparing Rationals. +* mpq_sub: Rational Arithmetic. +* mpq_swap: Initializing Rationals. +* mpq_t: Nomenclature and Types. +* mpz_abs: Integer Arithmetic. +* mpz_add: Integer Arithmetic. +* mpz_add_ui: Integer Arithmetic. +* mpz_addmul: Integer Arithmetic. +* mpz_addmul_ui: Integer Arithmetic. +* mpz_and: Integer Logic and Bit Fiddling. +* mpz_array_init: Initializing Integers. +* mpz_bin_ui: Number Theoretic Functions. +* mpz_bin_uiui: Number Theoretic Functions. +* mpz_cdiv_q: Integer Division. +* mpz_cdiv_q_2exp: Integer Division. +* mpz_cdiv_q_ui: Integer Division. +* mpz_cdiv_qr: Integer Division. +* mpz_cdiv_qr_ui: Integer Division. +* mpz_cdiv_r: Integer Division. +* mpz_cdiv_r_2exp: Integer Division. +* mpz_cdiv_r_ui: Integer Division. +* mpz_cdiv_ui: Integer Division. +* mpz_class: C++ Interface General. +* mpz_class::fits_sint_p: C++ Interface Integers. +* mpz_class::fits_slong_p: C++ Interface Integers. +* mpz_class::fits_sshort_p: C++ Interface Integers. +* mpz_class::fits_uint_p: C++ Interface Integers. +* mpz_class::fits_ulong_p: C++ Interface Integers. +* mpz_class::fits_ushort_p: C++ Interface Integers. +* mpz_class::get_d: C++ Interface Integers. +* mpz_class::get_mpz_t: C++ Interface General. +* mpz_class::get_si: C++ Interface Integers. +* mpz_class::get_ui: C++ Interface Integers. +* mpz_class::mpz_class: C++ Interface Integers. +* mpz_clear: Initializing Integers. +* mpz_clrbit: Integer Logic and Bit Fiddling. +* mpz_cmp: Integer Comparisons. +* mpz_cmp_d: Integer Comparisons. +* mpz_cmp_si: Integer Comparisons. +* mpz_cmp_ui: Integer Comparisons. +* mpz_cmpabs: Integer Comparisons. +* mpz_cmpabs_d: Integer Comparisons. +* mpz_cmpabs_ui: Integer Comparisons. +* mpz_com: Integer Logic and Bit Fiddling. +* mpz_congruent_2exp_p: Integer Division. +* mpz_congruent_p: Integer Division. +* mpz_congruent_ui_p: Integer Division. +* mpz_divexact: Integer Division. +* mpz_divexact_ui: Integer Division. +* mpz_divisible_2exp_p: Integer Division. +* mpz_divisible_p: Integer Division. +* mpz_divisible_ui_p: Integer Division. +* mpz_even_p: Miscellaneous Integer Functions. +* mpz_export: Integer Import and Export. +* mpz_fac_ui: Number Theoretic Functions. +* mpz_fdiv_q: Integer Division. +* mpz_fdiv_q_2exp: Integer Division. +* mpz_fdiv_q_ui: Integer Division. +* mpz_fdiv_qr: Integer Division. +* mpz_fdiv_qr_ui: Integer Division. +* mpz_fdiv_r: Integer Division. +* mpz_fdiv_r_2exp: Integer Division. +* mpz_fdiv_r_ui: Integer Division. +* mpz_fdiv_ui: Integer Division. +* mpz_fib2_ui: Number Theoretic Functions. +* mpz_fib_ui: Number Theoretic Functions. +* mpz_fits_sint_p: Miscellaneous Integer Functions. +* mpz_fits_slong_p: Miscellaneous Integer Functions. +* mpz_fits_sshort_p: Miscellaneous Integer Functions. +* mpz_fits_uint_p: Miscellaneous Integer Functions. +* mpz_fits_ulong_p: Miscellaneous Integer Functions. +* mpz_fits_ushort_p: Miscellaneous Integer Functions. +* mpz_gcd: Number Theoretic Functions. +* mpz_gcd_ui: Number Theoretic Functions. +* mpz_gcdext: Number Theoretic Functions. +* mpz_get_d: Converting Integers. +* mpz_get_d_2exp: Converting Integers. +* mpz_get_si: Converting Integers. +* mpz_get_str: Converting Integers. +* mpz_get_ui: Converting Integers. +* mpz_getlimbn: Converting Integers. +* mpz_hamdist: Integer Logic and Bit Fiddling. +* mpz_import: Integer Import and Export. +* mpz_init: Initializing Integers. +* mpz_init2: Initializing Integers. +* mpz_init_set: Simultaneous Integer Init & Assign. +* mpz_init_set_d: Simultaneous Integer Init & Assign. +* mpz_init_set_si: Simultaneous Integer Init & Assign. +* mpz_init_set_str: Simultaneous Integer Init & Assign. +* mpz_init_set_ui: Simultaneous Integer Init & Assign. +* mpz_inp_raw: I/O of Integers. +* mpz_inp_str: I/O of Integers. +* mpz_invert: Number Theoretic Functions. +* mpz_ior: Integer Logic and Bit Fiddling. +* mpz_jacobi: Number Theoretic Functions. +* mpz_kronecker: Number Theoretic Functions. +* mpz_kronecker_si: Number Theoretic Functions. +* mpz_kronecker_ui: Number Theoretic Functions. +* mpz_lcm: Number Theoretic Functions. +* mpz_lcm_ui: Number Theoretic Functions. +* mpz_legendre: Number Theoretic Functions. +* mpz_lucnum2_ui: Number Theoretic Functions. +* mpz_lucnum_ui: Number Theoretic Functions. +* mpz_mod: Integer Division. +* mpz_mod_ui: Integer Division. +* mpz_mul: Integer Arithmetic. +* mpz_mul_2exp: Integer Arithmetic. +* mpz_mul_si: Integer Arithmetic. +* mpz_mul_ui: Integer Arithmetic. +* mpz_neg: Integer Arithmetic. +* mpz_nextprime: Number Theoretic Functions. +* mpz_odd_p: Miscellaneous Integer Functions. +* mpz_out_raw: I/O of Integers. +* mpz_out_str: I/O of Integers. +* mpz_perfect_power_p: Integer Roots. +* mpz_perfect_square_p: Integer Roots. +* mpz_popcount: Integer Logic and Bit Fiddling. +* mpz_pow_ui: Integer Exponentiation. +* mpz_powm: Integer Exponentiation. +* mpz_powm_ui: Integer Exponentiation. +* mpz_probab_prime_p: Number Theoretic Functions. +* mpz_random: Integer Random Numbers. +* mpz_random2: Integer Random Numbers. +* mpz_realloc2: Initializing Integers. +* mpz_remove: Number Theoretic Functions. +* mpz_root: Integer Roots. +* mpz_rrandomb: Integer Random Numbers. +* mpz_scan0: Integer Logic and Bit Fiddling. +* mpz_scan1: Integer Logic and Bit Fiddling. +* mpz_set: Assigning Integers. +* mpz_set_d: Assigning Integers. +* mpz_set_f: Assigning Integers. +* mpz_set_q: Assigning Integers. +* mpz_set_si: Assigning Integers. +* mpz_set_str: Assigning Integers. +* mpz_set_ui: Assigning Integers. +* mpz_setbit: Integer Logic and Bit Fiddling. +* mpz_sgn: Integer Comparisons. +* mpz_si_kronecker: Number Theoretic Functions. +* mpz_size: Miscellaneous Integer Functions. +* mpz_sizeinbase: Miscellaneous Integer Functions. +* mpz_sqrt: Integer Roots. +* mpz_sqrtrem: Integer Roots. +* mpz_sub: Integer Arithmetic. +* mpz_sub_ui: Integer Arithmetic. +* mpz_submul: Integer Arithmetic. +* mpz_submul_ui: Integer Arithmetic. +* mpz_swap: Assigning Integers. +* mpz_t: Nomenclature and Types. +* mpz_tdiv_q: Integer Division. +* mpz_tdiv_q_2exp: Integer Division. +* mpz_tdiv_q_ui: Integer Division. +* mpz_tdiv_qr: Integer Division. +* mpz_tdiv_qr_ui: Integer Division. +* mpz_tdiv_r: Integer Division. +* mpz_tdiv_r_2exp: Integer Division. +* mpz_tdiv_r_ui: Integer Division. +* mpz_tdiv_ui: Integer Division. +* mpz_tstbit: Integer Logic and Bit Fiddling. +* mpz_ui_kronecker: Number Theoretic Functions. +* mpz_ui_pow_ui: Integer Exponentiation. +* mpz_ui_sub: Integer Arithmetic. +* mpz_urandomb: Integer Random Numbers. +* mpz_urandomm: Integer Random Numbers. +* mpz_xor: Integer Logic and Bit Fiddling. +* msqrt: BSD Compatible Functions. +* msub: BSD Compatible Functions. +* mtox: BSD Compatible Functions. +* mult: BSD Compatible Functions. +* operator%: C++ Interface Integers. +* operator/: C++ Interface Integers. +* operator<<: C++ Formatted Output. +* operator>> <1>: C++ Formatted Input. +* operator>>: C++ Interface Rationals. +* pow: BSD Compatible Functions. +* reallocate_function: Custom Allocation. +* rpow: BSD Compatible Functions. +* sdiv: BSD Compatible Functions. +* sgn <1>: C++ Interface Rationals. +* sgn <2>: C++ Interface Floats. +* sgn: C++ Interface Integers. +* sqrt <1>: C++ Interface Integers. +* sqrt: C++ Interface Floats. +* trunc: C++ Interface Floats. +* xtom: BSD Compatible Functions. + + diff --git a/src/gmp/gmp.texi b/src/gmp/gmp.texi index fd739e389..832664210 100644 --- a/src/gmp/gmp.texi +++ b/src/gmp/gmp.texi @@ -13,17 +13,20 @@ This manual describes how to install and use the GNU multiple precision arithmetic library, version @value{VERSION}. -Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 -Free Software Foundation, Inc. +Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +2003, 2004 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover Texts being ``A GNU Manual'', and with the Back-Cover Texts being ``You have freedom to copy and modify this GNU Manual, like GNU -software''. A copy of the license is included in @ref{GNU Free Documentation -License}. +software''. A copy of the license is included in +@ref{GNU Free Documentation License}. @end copying +@c Note the @ref above must be on one line, a line break in an @ref within +@c @copying will bomb in recent texinfo.tex (eg. 2004-04-07.08 which comes +@c with texinfo 4.7), with messages about missing @endcsname. @c Texinfo version 4.2 or up will be needed to process this into .info files. @@ -460,6 +463,7 @@ The proper place for bug reports is @email{bug-gmp@@gnu.org}. See @cindex Home page @cindex Web page +@noindent For up-to-date information on GMP, please see the GMP web pages at @display @@ -469,6 +473,7 @@ For up-to-date information on GMP, please see the GMP web pages at @cindex Latest version of GMP @cindex Anonymous FTP of latest version @cindex FTP of latest version +@noindent The latest version of the library is available at @display @@ -478,7 +483,20 @@ The latest version of the library is available at Many sites around the world mirror @samp{ftp.gnu.org}, please use a mirror near you, see @uref{http://www.gnu.org/order/ftp.html} for a full list. +@cindex Mailing lists +There are three public mailing lists of interest. One for release +announcements, one for general questions and discussions about usage of the +GMP library and one for discussions about development of GMP. These lists are +@strong{not} for bug reports. For more information, see +@display +@uref{http://swox.com/mailman/listinfo/}. +@end display + +The proper place for bug reports is @email{bug-gmp@@gnu.org}. See +@ref{Reporting Bugs} for information about reporting bugs. + +@sp 1 @section How to use this Manual @cindex About this manual @@ -548,7 +566,7 @@ installation information too. can be used, and on MS Windows Cygwin or MINGW can be used, @display -@uref{http://www.cygnus.com/cygwin} +@uref{http://www.cygwin.com/} @uref{http://www.delorie.com/djgpp} @uref{http://www.mingw.org} @end display @@ -580,6 +598,23 @@ support this. In particular, SunOS and Slowaris @command{make} have bugs that make them unable to build in a separate directory. Use GNU @command{make} instead. +@item @option{--prefix} and @option{--exec-prefix} +@cindex Prefix +@cindex Exec prefix +@cindex Install prefix +@cindex @code{--prefix} +@cindex @code{--exec-prefix} +The @option{--prefix} option can be used in the normal way to direct GMP to +install under a particular tree. The default is @samp{/usr/local}. + +@option{--exec-prefix} can be used to direct architecture-dependent files like +@file{libgmp.a} to a different location. This can be used to share +architecture-independent parts like the documentation, but separate the +dependent parts. Note however that @file{gmp.h} and @file{mp.h} are +architecture-dependent since they encode certain aspects of @file{libgmp}, so +it will be necessary to ensure both @file{$prefix/include} and +@file{$exec_prefix/include} are available to the compiler. + @item @option{--disable-shared}, @option{--disable-static} By default both shared and static libraries are built (where possible), but @@ -685,6 +720,10 @@ HPPA: @nisamp{hppa2.0n}, @nisamp{hppa2.0w} +@item +IA-64: +@nisamp{ia64} + @item MIPS: @nisamp{mips}, @@ -751,7 +790,7 @@ SPARC: @nisamp{sparc64} @item -80x86 family: +x86 family: @nisamp{i386}, @nisamp{i486}, @nisamp{i586}, @@ -764,7 +803,10 @@ SPARC: @nisamp{k6}, @nisamp{k62}, @nisamp{k63}, -@nisamp{athlon} +@nisamp{athlon}, +@nisamp{x86_64}, +@nisamp{viac3}, +@nisamp{viac32} @item Other: @@ -991,10 +1033,9 @@ The document you're now reading is @file{gmp.texi}. The usual automake targets are available to make PostScript @file{gmp.ps} and/or DVI @file{gmp.dvi}. -HTML can be produced with @samp{makeinfo --html}, see @ref{makeinfo -html,Generating HTML,Generating HTML,texinfo,Texinfo}. Or alternately -@samp{texi2html}, see @ref{Top,Texinfo to HTML,About,texi2html,Texinfo To -HTML}. +HTML can be produced with @samp{makeinfo --html}, see @ref{Generating HTML,,, +texinfo, Texinfo}. Or alternately @samp{texi2html}, see @ref{Top,Texinfo to +HTML,About,texi2html,Texinfo To HTML}. PDF can be produced with @samp{texi2dvi --pdf} (@pxref{PDF Output,PDF,,texinfo,Texinfo}) or with @samp{pdftex}. @@ -1049,8 +1090,8 @@ as simple as configuring with a special @samp{libdir}, or it might require more than that. Note that builds for different ABIs need to done separately, with a fresh @command{./configure} and @command{make} each. -@table @asis @sp 1 +@table @asis @need 1000 @item HPPA 2.0 (@samp{hppa2.0*}) @@ -1275,6 +1316,18 @@ defining @code{__USE_STD_IOSTREAM}. Configure with for instance ./configure --enable-cxx CPPFLAGS=-D__USE_STD_IOSTREAM @end example +@item Floating Point Mode +@cindex Floating point mode +@cindex Hardware floating point mode +@cindex Precision of hardware floating point +@cindex x87 +On some systems, the hardware floating point has a control mode which can set +all operations to be done in a particular precision, for instance single, +double or extended on x86 systems (x87 floating point). The GMP functions +involving a @code{double} cannot be expected to operate to their full +precision when the hardware is in single precision mode. Of course this +affects all code, including application code, not just GMP. + @item Microsoft Windows On systems @samp{*-*-cygwin*}, @samp{*-*-mingw*} and @samp{*-*-pw32*} by default GMP builds only a static library, but a DLL can be built instead using @@ -1295,15 +1348,16 @@ following commands, where @file{/my/inst/dir} is the install directory (with a @file{lib} subdirectory). @example -lib /machine:IX86 /def:_libs/libgmp-3.dll-def +lib /machine:IX86 /def:.libs/libgmp-3.dll-def cp libgmp-3.lib /my/inst/dir/lib -cp _libs/libgmp-3.dll-exp /my/inst/dir/lib/libgmp-3.exp +cp .libs/libgmp-3.dll-exp /my/inst/dir/lib/libgmp-3.exp @end example -MINGW uses @samp{msvcrt.dll} for I/O, so applications wanting to use the GMP -I/O routines must be compiled with @samp{cl /MD} to do the same. If one of -the other I/O choices provided by MS C is desired then the suggestion is to -use the GMP string functions and confine I/O to the application. +MINGW uses the C runtime library @samp{msvcrt.dll} for I/O, so applications +wanting to use the GMP I/O routines must be compiled with @samp{cl /MD} to do +the same. If one of the other C runtime library choices provided by MS C is +desired then the suggestion is to use the GMP string functions and confine I/O +to the application. @item Motorola 68k CPU Types @@ -1479,6 +1533,22 @@ Also, libtool currently cannot build C++ shared libraries on MacOS X, so if @samp{--enable-cxx} is desired then @samp{--disable-shared} must be used. Hopefully this will be fixed in the future. +@item Motorola 68k ABI +@cindex 68000 +@cindex PalmOS +The GMP assembler code has been written for the SVR4 standard ABI. GCC option +@samp{-mshort} changes the calling conventions and is not currently supported. +We believe the PalmOS calling conventions are similarly different and are +likewise not currently supported. +@c +@c For reference, -mshort doesn't just change the size of an int but also +@c changes the stack alignment to only 16-bits, where in svr4 it's 32-bits. +@c This affects mpn_lshift and mpn_rshift in the gmp code, but perhaps +@c nowhere else. Having those routines understand the variant stack frame +@c wouldn't be hard, if anyone was keen. (PalmOS had problems building due +@c to lack of stdio.h last time it was tried, so it's not yet really a +@c target.) + @item NeXT prior to 3.3 The system compiler on old versions of NeXT was a massacred and old GCC, even @@ -1831,13 +1901,19 @@ then naturally GMP is not reentrant. @item @code{mpf_set_default_prec} and @code{mpf_init} use a global variable for the -selected precision. @code{mpf_init2} can be used instead. +selected precision. @code{mpf_init2} can be used instead, and in the C++ +interface an explicit precision to the @code{mpf_class} constructor. @item @code{mpz_random} and the other old random number functions use a global random state and are hence not reentrant. The newer random number functions that accept a @code{gmp_randstate_t} parameter can be used instead. +@item +@code{gmp_randinit} (obsolete) returns an error indication through a global +variable, which is not thread safe. Applications are advised to use +@code{gmp_randinit_lc_2exp} instead. + @item @code{mp_set_memory_functions} uses global variables to store the selected memory allocation functions. @@ -1857,11 +1933,6 @@ but it's not safe for one to read while the another might be writing, nor for two threads to write simultaneously. It's not safe for two threads to generate a random number from the same @code{gmp_randstate_t} simultaneously, since this involves an update of that variable. - -@item -On SCO systems the default @code{} macros use per-file static -variables and may not be reentrant, depending whether the compiler optimizes -away fetches from them. The GMP text-based input functions are affected. @end itemize @@ -2208,7 +2279,6 @@ the standard C library @code{malloc} has some diagnostic facilities, see @display @uref{http://www.inf.ethz.ch/personal/biere/projects/ccmalloc} -@uref{http://quorum.tamu.edu/jon/gnu} @ (debauch) @uref{http://dmalloc.com} @uref{http://www.perens.com/FreeSoftware} @ (electric fence) @uref{http://packages.debian.org/fda} @@ -2302,14 +2372,15 @@ the checking scheme. The GMP C++ features cannot be used, since current versions of checker (0.9.9.1) don't yet support the standard C++ library. @item Valgrind -The valgrind program (@uref{http://devel-home.kde.org/~sewardj}) is a memory +@cindex Valgrind +The valgrind program (@uref{http://valgrind.kde.org/}) is a memory checker for x86s. It translates and emulates machine instructions to do strong checks for uninitialized data (at the level of individual bits), memory accesses through bad pointers, and memory leaks. -Current versions (20020226 snapshot) don't support MMX or SSE, so GMP must be -configured for an x86 without those (eg. plain @samp{i386}), or with a special -@code{MPN_PATH} that excludes those subdirectories (@pxref{Build Options}). +Recent versions of Valgrind are getting support for MMX and SSE/SSE2 +instructions, for past versions GMP will need to be configured not to use +those, ie.@: for an x86 without them (for instance plain @samp{i486}). @item Other Problems Any suspected bug in GMP itself should be isolated to make sure it's not an @@ -2690,14 +2761,13 @@ assumed, otherwise decimal is assumed. This function returns 0 if the entire string is a valid number in base @var{base}. Otherwise it returns @minus{}1. - -[It turns out that it is not entirely true that this function ignores -white-space. It does ignore it between digits, but not after a minus sign or -within or after ``0x''. We are considering changing the definition of this -function, making it fail when there is any white-space in the input, since -that makes a lot of sense. Send your opinion of this change to -@email{bug-gmp@@gnu.org}. Do you really want it to accept @nicode{"3 14"} as -meaning 314 as it does now?] +@c +@c It turns out that it is not entirely true that this function ignores +@c white-space. It does ignore it between digits, but not after a minus sign +@c or within or after ``0x''. Some thought was given to disallowing all +@c whitespace, but that would be an incompatible change, whitespace has been +@c documented as ignored ever since GMP 1. +@c @end deftypefun @deftypefun void mpz_swap (mpz_t @var{rop1}, mpz_t @var{rop2}) @@ -3269,9 +3339,6 @@ Compare the absolute values of @var{op1} and @var{op2}. Return a positive value if @math{@GMPabs{@var{op1}} > @GMPabs{@var{op2}}}, zero if @math{@GMPabs{@var{op1}} = @GMPabs{@var{op2}}}, or a negative value if @math{@GMPabs{@var{op1}} < @GMPabs{@var{op2}}}. - -Note that @code{mpz_cmpabs_si} is a macro and will evaluate its arguments more -than once. @end deftypefn @deftypefn Macro int mpz_sgn (mpz_t @var{op}) @@ -3297,15 +3364,15 @@ sign-magnitude is the actual implementation). The least significant bit is number 0. @deftypefun void mpz_and (mpz_t @var{rop}, mpz_t @var{op1}, mpz_t @var{op2}) -Set @var{rop} to @var{op1} logical-and @var{op2}. +Set @var{rop} to @var{op1} bitwise-and @var{op2}. @end deftypefun @deftypefun void mpz_ior (mpz_t @var{rop}, mpz_t @var{op1}, mpz_t @var{op2}) -Set @var{rop} to @var{op1} inclusive-or @var{op2}. +Set @var{rop} to @var{op1} bitwise inclusive-or @var{op2}. @end deftypefun @deftypefun void mpz_xor (mpz_t @var{rop}, mpz_t @var{op1}, mpz_t @var{op2}) -Set @var{rop} to @var{op1} exclusive-or @var{op2}. +Set @var{rop} to @var{op1} bitwise exclusive-or @var{op2}. @end deftypefun @deftypefun void mpz_com (mpz_t @var{rop}, mpz_t @var{op}) @@ -3315,7 +3382,7 @@ Set @var{rop} to the one's complement of @var{op}. @deftypefun {unsigned long int} mpz_popcount (mpz_t @var{op}) If @math{@var{op}@ge{}0}, return the population count of @var{op}, which is the number of 1 bits in the binary representation. If @math{@var{op}<0}, the -number of 1s is infinite, and the return value is @var{MAX_ULONG}, the largest +number of 1s is infinite, and the return value is @var{ULONG_MAX}, the largest possible @code{unsigned long}. @end deftypefun @@ -3324,7 +3391,7 @@ If @var{op1} and @var{op2} are both @math{@ge{}0} or both @math{<0}, return the hamming distance between the two operands, which is the number of bit positions where @var{op1} and @var{op2} have different bit values. If one operand is @math{@ge{}0} and the other @math{<0} then the number of bits -different is infinite, and the return value is @var{MAX_ULONG}, the largest +different is infinite, and the return value is @var{ULONG_MAX}, the largest possible @code{unsigned long}. @end deftypefun @@ -3337,7 +3404,7 @@ the found bit. If the bit at @var{starting_bit} is already what's sought, then @var{starting_bit} is returned. -If there's no bit found, then @var{MAX_ULONG} is returned. This will happen +If there's no bit found, then @var{ULONG_MAX} is returned. This will happen in @code{mpz_scan0} past the end of a positive number, or @code{mpz_scan1} past the end of a negative. @end deftypefun @@ -3495,10 +3562,14 @@ first or -1 for least significant first. Within each word @var{endian} can be the native endianness of the host CPU. The most significant @var{nails} bits of each word are skipped, this can be 0 to use the full words. +There is no sign taken from the data, @var{rop} will simply be a positive +integer. An application can handle any sign itself, and apply it for instance +with @code{mpz_neg}. + There are no data alignment restrictions on @var{op}, any address is allowed. Here's an example converting an array of @code{unsigned long} data, most -significant element first and host byte order within each value. +significant element first, and host byte order within each value. @example unsigned long a[20]; @@ -3515,7 +3586,7 @@ feature can account for this, by passing for instance @code{8*sizeof(int)-INT_BIT}. @end deftypefun -@deftypefun void *mpz_export (void *@var{rop}, size_t *@var{count}, int @var{order}, int @var{size}, int @var{endian}, size_t @var{nails}, mpz_t @var{op}) +@deftypefun {void *} mpz_export (void *@var{rop}, size_t *@var{countp}, int @var{order}, int @var{size}, int @var{endian}, size_t @var{nails}, mpz_t @var{op}) @cindex Integer export @cindex Export Fill @var{rop} with word data from @var{op}. @@ -3527,25 +3598,29 @@ most significant byte first, -1 for least significant first, or 0 for the native endianness of the host CPU. The most significant @var{nails} bits of each word are unused and set to zero, this can be 0 to produce full words. -The number of words produced is written to @code{*@var{count}}. @var{rop} -must have enough space for the data, or if @var{rop} is @code{NULL} then a -result array of the necessary size is allocated using the current GMP -allocation function (@pxref{Custom Allocation}). In either case the return -value is the destination used, @var{rop} or the allocated block. +The number of words produced is written to @code{*@var{countp}}, or +@var{countp} can be @code{NULL} to discard the count. @var{rop} must have +enough space for the data, or if @var{rop} is @code{NULL} then a result array +of the necessary size is allocated using the current GMP allocation function +(@pxref{Custom Allocation}). In either case the return value is the +destination used, either @var{rop} or the allocated block. If @var{op} is non-zero then the most significant word produced will be non-zero. If @var{op} is zero then the count returned will be zero and nothing written to @var{rop}. If @var{rop} is @code{NULL} in this case, no block is allocated, just @code{NULL} is returned. +The sign of @var{op} is ignored, just the absolute value is exported. An +application can use @code{mpz_sgn} to get the sign and handle it as desired. +(@pxref{Integer Comparisons}) + There are no data alignment restrictions on @var{rop}, any address is allowed. -The sign of @var{op} is ignored, just the absolute value is used. When an application is allocating space itself the required size can be determined with a calculation like the following. Since @code{mpz_sizeinbase} always returns at least 1, @code{count} here will be at least one, which avoids any portability problems with @code{malloc(0)}, though if @code{z} is -zero no space at all is actually needed. +zero no space at all is actually needed (or written). @example numb = 8*size - nail; @@ -3586,16 +3661,24 @@ the returned value will be zero. @end deftypefun @deftypefun size_t mpz_sizeinbase (mpz_t @var{op}, int @var{base}) -Return the size of @var{op} measured in number of digits in base @var{base}. -The base may vary from 2 to 36. The sign of @var{op} is ignored, just the -absolute value is used. The result will be exact or 1 too big. If @var{base} -is a power of 2, the result will always be exact. If @var{op} is zero the -return value is always 1. +@cindex Size in digits +@cindex Digits in an integer +Return the size of @var{op} measured in number of digits in the given +@var{base}. @var{base} can vary from 2 to 36. The sign of @var{op} is +ignored, just the absolute value is used. The result will be either exact or +1 too big. If @var{base} is a power of 2, the result is always exact. If +@var{op} is zero the return value is always 1. -This function is useful in order to allocate the right amount of space before -converting @var{op} to a string. The right amount of allocation is normally -two more than the value returned by @code{mpz_sizeinbase} (one extra for a -minus sign and one for the null-terminator). +This function can be used to determine the space required when converting +@var{op} to a string. The right amount of allocation is normally two more +than the value returned by @code{mpz_sizeinbase}, one extra for a minus sign +and one for the null-terminator. + +@cindex Most significant bit +It will be noted that @code{mpz_sizeinbase(@var{op},2)} can be used to locate +the most significant 1 bit in @var{op}, counting from 1. (Unlike the bitwise +functions which start from 0, @xref{Integer Logic and Bit Fiddling,, Logical +and Bit Manipulation Functions}.) @end deftypefun @@ -4413,10 +4496,10 @@ invoking this function. @deftypefun void mpf_random2 (mpf_t @var{rop}, mp_size_t @var{max_size}, mp_exp_t @var{exp}) Generate a random float of at most @var{max_size} limbs, with long strings of zeros and ones in the binary representation. The exponent of the number is in -the interval @minus{}@var{exp} to @var{exp}. This function is useful for -testing functions and algorithms, since this kind of random numbers have proven -to be more likely to trigger corner-case bugs. Negative random numbers are -generated when @var{max_size} is negative. +the interval @minus{}@var{exp} to @var{exp} (in limbs). This function is +useful for testing functions and algorithms, since these kind of random +numbers have proven to be more likely to trigger corner-case bugs. Negative +random numbers are generated when @var{max_size} is negative. @end deftypefun @c @deftypefun size_t mpf_size (mpf_t @var{op}) @@ -4529,7 +4612,8 @@ Multiply @{@var{s1p}, @var{n}@} and @{@var{s2p}, @var{n}@}, and write the 2*@var{n}-limb result to @var{rp}. The destination has to have space for 2*@var{n} limbs, even if the product's -most significant limb is zero. +most significant limb is zero. No overlap is permitted between the +destination and either source. @end deftypefun @deftypefun mp_limb_t mpn_mul_1 (mp_limb_t *@var{rp}, const mp_limb_t *@var{s1p}, mp_size_t @var{n}, mp_limb_t @var{s2limb}) @@ -4840,7 +4924,8 @@ Count the number of set bits in @{@var{s1p}, @var{n}@}. @deftypefun {unsigned long int} mpn_hamdist (const mp_limb_t *@var{s1p}, const mp_limb_t *@var{s2p}, mp_size_t @var{n}) Compute the hamming distance between @{@var{s1p}, @var{n}@} and @{@var{s2p}, -@var{n}@}. +@var{n}@}, which is the number of bit positions where the two operands have +different bit values. @end deftypefun @deftypefun int mpn_perfect_square_p (const mp_limb_t *@var{s1p}, mp_size_t @var{n}) @@ -4975,18 +5060,31 @@ table data provides then the return value is zero. The maximum @var{size} currently supported is 128. @end deftypefun +@c Although gmp_randinit, gmp_errno and related constants are obsolete, we +@c still put @findex entries for them, since they're still documented and +@c someone might be looking them up when perusing old application code. + @deftypefun void gmp_randinit (gmp_randstate_t @var{state}, @w{gmp_randalg_t @var{alg}}, ...) @strong{This function is obsolete.} +@findex GMP_RAND_ALG_LC +@findex GMP_RAND_ALG_DEFAULT Initialize @var{state} with an algorithm selected by @var{alg}. The only -choice is @code{GMP_RAND_ALG_LC}, which is @code{gmp_randinit_lc_2exp_size}. -A third parameter of type @code{unsigned long} is required, this is the -@var{size} for that function. @code{GMP_RAND_ALG_DEFAULT} or 0 are the same -as @code{GMP_RAND_ALG_LC}. +choice is @code{GMP_RAND_ALG_LC}, which is @code{gmp_randinit_lc_2exp_size} +described above. A third parameter of type @code{unsigned long} is required, +this is the @var{size} for that function. @code{GMP_RAND_ALG_DEFAULT} or 0 +are the same as @code{GMP_RAND_ALG_LC}. -@code{gmp_randinit} sets bits in @code{gmp_errno} to indicate an error. -@code{GMP_ERROR_UNSUPPORTED_ARGUMENT} if @var{alg} is unsupported, or -@code{GMP_ERROR_INVALID_ARGUMENT} if the @var{size} parameter is too big. +@c For reference, this is the only place gmp_errno has been documented, and +@c due to being non thread safe we won't be adding to it's uses. +@findex gmp_errno +@findex GMP_ERROR_UNSUPPORTED_ARGUMENT +@findex GMP_ERROR_INVALID_ARGUMENT +@code{gmp_randinit} sets bits in the global variable @code{gmp_errno} to +indicate an error. @code{GMP_ERROR_UNSUPPORTED_ARGUMENT} if @var{alg} is +unsupported, or @code{GMP_ERROR_INVALID_ARGUMENT} if the @var{size} parameter +is too big. It may be noted this error reporting is not thread safe (a good +reason to use @code{gmp_randinit_lc_2exp_size} instead). @end deftypefun @c Not yet in the library. @@ -5333,8 +5431,9 @@ cout << "iteration " << n << " value " << z << "\n"; @end example But note that @code{ostream} output (and @code{istream} input, @pxref{C++ -Formatted Input}) is the only overloading available and using for instance -@code{+} with an @code{mpz_t} will have unpredictable results. +Formatted Input}) is the only overloading available for the GMP types and that +for instance using @code{+} with an @code{mpz_t} will have unpredictable +results. For classes with overloading, see @ref{C++ Class Interface}. @node Formatted Input, C++ Class Interface, Formatted Output, Top @@ -5458,9 +5557,9 @@ hexadecimal. @samp{o}, @samp{u}, @samp{x} and @samp{X} all read positive or negative values. For the standard C types these are described as ``unsigned'' conversions, but that merely affects certain overflow handling, negatives are -still allowed (see @code{strtoul}, @ref{Parsing of Integers,,,libc,The GNU C -Library Reference Manual}). For GMP types there are no overflows, and -@samp{d} and @samp{u} are identical. +still allowed (per @code{strtoul}, @pxref{Parsing of Integers,, Parsing of +Integers, libc, The GNU C Library Reference Manual}). For GMP types there are +no overflows, so @samp{d} and @samp{u} are identical. @samp{Q} type reads the numerator and (optional) denominator as given. If the value might not be in canonical form then @code{mpq_canonicalize} must be @@ -5574,8 +5673,10 @@ cin >> z; @end example But note that @code{istream} input (and @code{ostream} output, @pxref{C++ -Formatted Output}) is the only overloading available and using for instance -@code{+} with an @code{mpz_t} will have unpredictable results. +Formatted Output}) is the only overloading available for the GMP types and +that for instance using @code{+} with an @code{mpz_t} will have unpredictable +results. For classes with overloading, see @ref{C++ Class Interface}. + @node C++ Class Interface, BSD Compatible Functions, Formatted Input, Top @@ -5740,10 +5841,9 @@ given then 0 is used. @deftypefunx mpz_class operator% (mpz_class @var{a}, mpz_class @var{d}) Divisions involving @code{mpz_class} round towards zero, as per the @code{mpz_tdiv_q} and @code{mpz_tdiv_r} functions (@pxref{Integer Division}). -This corresponds to the rounding used for plain @code{int} calculations on -most machines. +This is the same as the C99 @code{/} and @code{%} operators. -The @code{mpz_fdiv...} or @code{mpz_cdiv...} functions can always be called +The @code{mpz_fdiv@dots{}} or @code{mpz_cdiv@dots{}} functions can always be called directly if desired. For example, @example @@ -5905,6 +6005,31 @@ mpf_class f(x+y); // greater of precisions of x and y @end example @end deftypefun +@deftypefun {mpf_class&} mpf_class::operator= (type @var{op}) +Convert and store the given @var{op} value to an @code{mpf_class} object. The +same types are accepted as for the constructors above. + +Note that @code{operator=} only stores a new value, it doesn't copy or change +the precision of the destination, instead the value is truncated if necessary. +This is the same as @code{mpf_set} etc. Note in particular this means for +@code{mpf_class} a copy constructor is not the same as a default constructor +plus assignment. + +@example +mpf_class x (y); // x created with precision of y + +mpf_class x; // x created with default precision +x = y; // value truncated to that precision +@end example + +Applications using templated code may need to be careful about the assumptions +the code makes in this area, when working with @code{mpf_class} values of +various different or non-default precisions. For instance implementations of +the standard @code{complex} template have been seen in both styles above, +though of course @code{complex} is normally only actually specified for use +with the builtin float types. +@end deftypefun + @deftypefun mpf_class abs (mpf_class @var{op}) @deftypefunx mpf_class ceil (mpf_class @var{op}) @deftypefunx int cmp (mpf_class @var{op1}, type @var{op2}) @@ -6201,6 +6326,11 @@ undefined. @deftypefun void pow (MINT *@var{base}, MINT *@var{exp}, MINT *@var{mod}, MINT *@var{dest}) Set @var{dest} to (@var{base} raised to @var{exp}) modulo @var{mod}. + +Note that the name @code{pow} clashes with @code{pow} from the standard C math +library (@pxref{Exponents and Logarithms,, Exponentiation and Logarithms, +libc, The GNU C Library Reference Manual}). An application will only be able +to use one or the other. @end deftypefun @deftypefun void rpow (MINT *@var{base}, signed short int @var{exp}, MINT *@var{dest}) @@ -6364,8 +6494,7 @@ polynomials using templates. Arithmos @spaceuref{http://win-www.uia.ac.be/u/cant/arithmos} @* Rationals with infinities and square roots. @item -CLN @spaceuref{http://clisp.cons.org/~haible/packages-cln.html} @* High level -classes for arithmetic. +CLN @spaceuref{http://www.ginac.de/CLN/} @* High level classes for arithmetic. @item LiDIA @spaceuref{http://www.informatik.tu-darmstadt.de/TI/LiDIA} @* A C++ library for computational number theory. @@ -6378,8 +6507,8 @@ NTL @spaceuref{http://www.shoup.net/ntl} @* A C++ number theory library. @item Fortran @itemize @bullet @item -Omni F77 @spaceuref{http://pdplab.trc.rwcp.or.jp/pdperf/Omni/home.html} @* -Arbitrary precision floats. +Omni F77 @spaceuref{http://phase.hpcc.jp/Omni/home.html} @* Arbitrary +precision floats. @end itemize @item Haskell @@ -6403,6 +6532,11 @@ GNU Common Lisp @spaceuref{http://www.gnu.org/software/gcl/gcl.html} @* In the process of switching to GMP for bignums. @item Librep @spaceuref{http://librep.sourceforge.net} +@item +@c FIXME: When there's a stable release with gmp support, just refer to it +@c rather than bothering to talk about betas. +XEmacs (21.5.18 beta and up) @spaceuref{http://www.xemacs.org} @* Optional +big integers, rationals and floats using GMP. @end itemize @item M4 @@ -6418,6 +6552,15 @@ an arbitrary precision @code{mpeval}. MLton compiler @spaceuref{http://www.mlton.org} @end itemize +@item Objective Caml +@itemize @bullet +@item +MLGMP @spaceuref{http://www.di.ens.fr/~monniaux/programmes.html.en} +@item +Numerix @spaceuref{http://pauillac.inria.fr/~quercia/} @* Optionally using +GMP. +@end itemize + @item Oz @itemize @bullet @item @@ -6428,6 +6571,9 @@ Mozart @spaceuref{http://www.mozart-oz.org} @itemize @bullet @item GNU Pascal Compiler @spaceuref{http://www.gnu-pascal.de} @* GMP unit. +@item +Numerix @spaceuref{http://pauillac.inria.fr/~quercia/} @* For Free Pascal, +optionally using GMP. @end itemize @item Perl @@ -6446,7 +6592,7 @@ normal Math::BigInt operations. @item Pike @itemize @bullet @item -mpz module in the standard distribution, @uref{http://pike.idonex.com} +mpz module in the standard distribution, @uref{http://pike.ida.liu.se/} @end itemize @need 500 @@ -6468,6 +6614,9 @@ GMPY @uref{http://gmpy.sourceforge.net} @item Scheme @itemize @bullet @item +GNU Guile (upcoming 1.8) +@spaceuref{http://www.gnu.org/software/guile/guile.html} +@item RScheme @spaceuref{http://www.rscheme.org} @item STklos @spaceuref{http://kaolin.unice.fr/STklos} @@ -6482,11 +6631,17 @@ GNU Smalltalk @spaceuref{http://www.smalltalk.org/versions/GNUSmalltalk.html} @item Other @itemize @bullet @item +Axiom @uref{http://savannah.nongnu.org/projects/axiom} @* Computer algebra +using GCL. +@item DrGenius @spaceuref{http://drgenius.seul.org} @* Geometry system and mathematical programming language. @item GiNaC @spaceuref{http://www.ginac.de} @* C++ computer algebra using CLN. @item +GOO @spaceuref{http://www.googoogaga.org/} @* Dynamic object oriented +language. +@item Maxima @uref{http://www.ma.utexas.edu/users/wfs/maxima.html} @* Macsyma computer algebra using GCL. @item @@ -6793,20 +6948,23 @@ above. Karatsuba multiplication is asymptotically an @math{O(N^@W{1.585})} algorithm, the exponent being @m{\log3/\log2,log(3)/log(2)}, representing 3 multiplies -each 1/2 the size of the inputs. This is a big improvement over the basecase -multiply at @math{O(N^2)} and the advantage soon overcomes the extra additions -Karatsuba performs. +each @math{1/2} the size of the inputs. This is a big improvement over the +basecase multiply at @math{O(N^2)} and the advantage soon overcomes the extra +additions Karatsuba performs. @code{MUL_KARATSUBA_THRESHOLD} can be as little +as 10 limbs. The @code{SQR} threshold is usually about twice the @code{MUL}. -@code{MUL_KARATSUBA_THRESHOLD} can be as little as 10 limbs. The @code{SQR} -threshold is usually about twice the @code{MUL}. The basecase algorithm will -take a time of the form @m{M(N) = aN^2 + bN + c, M(N) = a*N^2 + b*N + c} and -the Karatsuba algorithm @m{K(N) = 3M(N/2) + dN + e, K(N) = 3*M(N/2) + d*N + -e}. Clearly per-crossproduct speedups in the basecase code reduce @math{a} -and decrease the threshold, but linear style speedups reducing @math{b} will -actually increase the threshold. The latter can be seen for instance when -adding an optimized @code{mpn_sqr_diagonal} to @code{mpn_sqr_basecase}. Of -course all speedups reduce total time, and in that sense the algorithm -thresholds are merely of academic interest. +The basecase algorithm will take a time of the form @m{M(N) = aN^2 + bN + c, +M(N) = a*N^2 + b*N + c} and the Karatsuba algorithm @m{K(N) = 3M(N/2) + dN + +e, K(N) = 3*M(N/2) + d*N + e}, which expands to @m{K(N) = {3\over4} aN^2 + +{3\over2} bN + 3c + dN + e, K(N) = 3/4*a*N^2 + 3/2*b*N + 3*c + d*N + e}. The +factor @m{3\over4, 3/4} for @math{a} means per-crossproduct speedups in the +basecase code will increase the threshold since they benefit @math{M(N)} more +than @math{K(N)}. And conversely the @m{3\over2, 3/2} for @math{b} means +linear style speedups of @math{b} will increase the threshold since they +benefit @math{K(N)} more than @math{M(N)}. The latter can be seen for +instance when adding an optimized @code{mpn_sqr_diagonal} to +@code{mpn_sqr_basecase}. Of course all speedups reduce total time, and in +that sense the algorithm thresholds are merely of academic interest. @node Toom-Cook 3-Way Multiplication, FFT Multiplication, Karatsuba Multiplication, Multiplication Algorithms @@ -7336,7 +7494,7 @@ throughput. A similar approach in reverse can be taken to process just half a limb at a time if the divisor is only a half limb. In this case the 1@cross{}1 multiply -for the inverse effectively becomes two @m{1\over2@cross{}1, (1/2)x1} for each +for the inverse effectively becomes two @m{{1\over2}\times1, (1/2)x1} for each limb, which can be a saving on CPUs with a fast half limb multiply, or in fact if the only multiply is a half limb, and especially if it's not pipelined. @@ -7882,7 +8040,7 @@ is certainly not optimal. The @math{r/b^n} scheme described above for using multiplications to bring out digits might be useful for more than a single limb. Some brief experiments -with it on the base case when recursing didn't give a noticable improvement, +with it on the base case when recursing didn't give a noticeable improvement, but perhaps that was only due to the implementation. Something similar would work for the sub-quadratic divisions too, though there would be the cost of calculating a bigger radix power. @@ -9159,6 +9317,12 @@ the GCC package @uref{ftp://ftp.gnu.org/gnu/gcc/} @section Papers @itemize @bullet +@item +Yves Bertot, Nicolas Magaud and Paul Zimmermann, ``A Proof of GMP Square +Root'', Journal of Automated Reasoning, volume 29, 2002, pp.@: 225-252. Also +available online as INRIA Research Report 4475, June 2001, +@uref{http://www.inria.fr/rrrt/rr-4475.html} + @item Christoph Burnikel and Joachim Ziegler, ``Fast Recursive Division'', Max-Planck-Institut fuer Informatik Research Report MPI-I-98-1-022, @texlinebreak{} diff --git a/src/gmp/gmpxx.h b/src/gmp/gmpxx.h index 81ccabb8b..c4b6b5cf7 100644 --- a/src/gmp/gmpxx.h +++ b/src/gmp/gmpxx.h @@ -1,6 +1,6 @@ /* gmpxx.h -- C++ class wrapper for GMP types. -*- C++ -*- -Copyright 2001, 2002 Free Software Foundation, Inc. +Copyright 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -681,7 +681,11 @@ struct __gmp_binary_divides if (mpz_fits_slong_p(w)) mpz_set_si(z, l / mpz_get_si(w)); else - mpz_set_si(z, 0); + { + /* if w is bigger than a long then the quotient must be zero, unless + l==LONG_MIN and w==-LONG_MIN in which case the quotient is -1 */ + mpz_set_si (z, (mpz_cmpabs_ui (w, (l >= 0 ? l : -l)) == 0 ? -1 : 0)); + } } static void eval(mpz_ptr z, mpz_srcptr w, double d) { @@ -872,17 +876,18 @@ struct __gmp_binary_modulus } static void eval(mpz_ptr z, mpz_srcptr w, signed long int l) { - if (l >= 0) - mpz_mod_ui(z, w, l); - else - mpz_mod_ui(z, w, -l); + mpz_tdiv_r_ui (z, w, (l >= 0 ? l : -l)); } static void eval(mpz_ptr z, signed long int l, mpz_srcptr w) { if (mpz_fits_slong_p(w)) mpz_set_si(z, l % mpz_get_si(w)); else - mpz_set_si(z, l); + { + /* if w is bigger than a long then the remainder is l unchanged, + unless l==LONG_MIN and w==-LONG_MIN in which case it's 0 */ + mpz_set_si (z, mpz_cmpabs_ui (w, (l >= 0 ? l : -l)) == 0 ? 0 : l); + } } static void eval(mpz_ptr z, mpz_srcptr w, double d) { diff --git a/src/gmp/longlong.h b/src/gmp/longlong.h index 5e2a119c8..9d875aaa7 100644 --- a/src/gmp/longlong.h +++ b/src/gmp/longlong.h @@ -1,7 +1,7 @@ /* longlong.h -- definitions for mixed size 32/64 bit arithmetic. -Copyright 1991, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001, 2002 Free -Software Foundation, Inc. +Copyright 1991, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001, 2002, 2003 +Free Software Foundation, Inc. This file is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -94,7 +94,25 @@ MA 02111-1307, USA. */ and is lost. If any of these macros are left undefined for a particular CPU, - C macros are used. */ + C macros are used. + + + Notes: + + For add_ssaaaa the two high and two low addends can both commute, but + unfortunately gcc only supports one "%" commutative in each asm block. + This has always been so but is only documented in recent versions + (eg. pre-release 3.3). Having two or more "%"s can cause an internal + compiler error in certain rare circumstances. + + Apparently it was only the last "%" that was ever actually respected, so + the code has been updated to leave just that. Clearly there's a free + choice whether high or low should get it, if there's a reason to favour + one over the other. Also obviously when the constraints on the two + operands are identical there's no benefit to the reloader in any "%" at + all. + + */ /* The CPUs come in alphabetical order below. @@ -183,11 +201,14 @@ long __MPN(count_leading_zeros) _PROTO ((UDItype)); #endif /* _CRAY */ #if defined (__hppa) && W_TYPE_SIZE == 64 -#if defined (__GNUC__) +/* These macros are for ABI=2.0w. In ABI=2.0n they can't be used, since GCC + (3.2) puts longlong into two adjacent 32-bit registers. Presumably this + is just a case of no direct support for 2.0n but treating it like 1.0. */ +#if defined (__GNUC__) && ! defined (_LONG_LONG_LIMB) #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add %4,%5,%1\n\tadd,dc %2,%3,%0" \ : "=r" (sh), "=&r" (sl) \ - : "%rM" (ah), "rM" (bh), "%rM" (al), "rM" (bl)) + : "rM" (ah), "rM" (bh), "%rM" (al), "rM" (bl)) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub %4,%5,%1\n\tsub,db %2,%3,%0" \ : "=r" (sh), "=&r" (sl) \ @@ -269,7 +290,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype, UWtype, UWtype, UWtype *)); #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add %1,%4,%5\n\taddc %0,%2,%3" \ : "=r" (sh), "=&r" (sl) \ - : "%r" (ah), "rI" (bh), "%r" (al), "rI" (bl)) + : "r" (ah), "rI" (bh), "%r" (al), "rI" (bl)) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub %1,%4,%5\n\tsubc %0,%2,%3" \ : "=r" (sh), "=&r" (sl) \ @@ -300,7 +321,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype, UWtype, UWtype, UWtype *)); __asm__ ("add.f\t%1, %4, %5\n\tadc\t%0, %2, %3" \ : "=r" ((USItype) (sh)), \ "=&r" ((USItype) (sl)) \ - : "%r" ((USItype) (ah)), \ + : "r" ((USItype) (ah)), \ "rIJ" ((USItype) (bh)), \ "%r" ((USItype) (al)), \ "rIJ" ((USItype) (bl))) @@ -318,7 +339,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype, UWtype, UWtype, UWtype *)); #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("adds\t%1, %4, %5\n\tadc\t%0, %2, %3" \ : "=r" (sh), "=&r" (sl) \ - : "%r" (ah), "rI" (bh), "%r" (al), "rI" (bl) __CLOBBER_CC) + : "r" (ah), "rI" (bh), "%r" (al), "rI" (bl) __CLOBBER_CC) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ do { \ if (__builtin_constant_p (al)) \ @@ -456,7 +477,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype)); #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add.w %5,%1\n\taddx %3,%0" \ : "=g" ((USItype)(sh)), "=&g" ((USItype)(sl)) \ - : "%0" ((USItype)(ah)), "g" ((USItype)(bh)), \ + : "0" ((USItype)(ah)), "g" ((USItype)(bh)), \ "%1" ((USItype)(al)), "g" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub.w %5,%1\n\tsubx %3,%0" \ @@ -480,7 +501,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype)); #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add %4,%5,%1\n\taddc %2,%3,%0" \ : "=r" (sh), "=&r" (sl) \ - : "%rM" (ah), "rM" (bh), "%rM" (al), "rM" (bl)) + : "rM" (ah), "rM" (bh), "%rM" (al), "rM" (bl)) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub %4,%5,%1\n\tsubb %2,%3,%0" \ : "=r" (sh), "=&r" (sl) \ @@ -560,7 +581,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype)); #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addl %5,%1\n\tadcl %3,%0" \ : "=r" ((USItype)(sh)), "=&r" ((USItype)(sl)) \ - : "%0" ((USItype)(ah)), "g" ((USItype)(bh)), \ + : "0" ((USItype)(ah)), "g" ((USItype)(bh)), \ "%1" ((USItype)(al)), "g" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subl %5,%1\n\tsbbl %3,%0" \ @@ -691,7 +712,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype)); #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addq %5,%1\n\tadcq %3,%0" \ : "=r" ((UDItype)(sh)), "=&r" ((UDItype)(sl)) \ - : "%0" ((UDItype)(ah)), "g" ((UDItype)(bh)), \ + : "0" ((UDItype)(ah)), "g" ((UDItype)(bh)), \ "%1" ((UDItype)(al)), "g" ((UDItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subq %5,%1\n\tsbbq %3,%0" \ @@ -713,10 +734,12 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype)); __asm__ ("bsrq %1,%0" : "=r" (__cbtmp) : "rm" ((UDItype)(x))); \ (count) = __cbtmp ^ 63; \ } while (0) +/* bsfq destination must be a 64-bit register, "%q0" forces this in case + count is only an int. */ #define count_trailing_zeros(count, x) \ do { \ ASSERT ((x) != 0); \ - __asm__ ("bsfq %1,%0" : "=r" (count) : "rm" ((UDItype)(x))); \ + __asm__ ("bsfq %1,%q0" : "=r" (count) : "rm" ((UDItype)(x))); \ } while (0) #endif /* x86_64 */ @@ -730,7 +753,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype)); #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("cmpo 1,0\;addc %5,%4,%1\;addc %3,%2,%0" \ : "=r" (sh), "=&r" (sl) \ - : "%dI" (ah), "dI" (bh), "%dI" (al), "dI" (bl)) + : "dI" (ah), "dI" (bh), "%dI" (al), "dI" (bl)) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("cmpo 0,0\;subc %5,%4,%1\;subc %3,%2,%0" \ : "=r" (sh), "=&r" (sl) \ @@ -781,7 +804,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype)); #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add%.l %5,%1\n\taddx%.l %3,%0" \ : "=d" ((USItype)(sh)), "=&d" ((USItype)(sl)) \ - : "%0" ((USItype)(ah)), "d" ((USItype)(bh)), \ + : "0" ((USItype)(ah)), "d" ((USItype)(bh)), \ "%1" ((USItype)(al)), "g" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub%.l %5,%1\n\tsubx%.l %3,%0" \ @@ -840,12 +863,15 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype)); #define UMUL_TIME 100 #define UDIV_TIME 400 #endif /* not mc68020 */ -/* The '020, '030, '040 and '060 have bitfield insns. */ -#if defined (__mc68020__) || defined (mc68020) \ +/* The '020, '030, '040 and '060 have bitfield insns. + GCC 3.4 defines __mc68020__ when in CPU32 mode, check for __mcpu32__ to + exclude bfffo on that chip (bitfield insns not available). */ +#if (defined (__mc68020__) || defined (mc68020) \ || defined (__mc68030__) || defined (mc68030) \ || defined (__mc68040__) || defined (mc68040) \ || defined (__mc68060__) || defined (mc68060) \ - || defined (__NeXT__) + || defined (__NeXT__)) \ + && ! defined (__mcpu32__) #define count_leading_zeros(count, x) \ __asm__ ("bfffo %1{%b2:%b2},%0" \ : "=d" ((USItype) (count)) \ @@ -858,7 +884,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype)); #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addu.co %1,%r4,%r5\n\taddu.ci %0,%r2,%r3" \ : "=r" (sh), "=&r" (sl) \ - : "%rJ" (ah), "rJ" (bh), "%rJ" (al), "rJ" (bl)) + : "rJ" (ah), "rJ" (bh), "%rJ" (al), "rJ" (bl)) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subu.co %1,%r4,%r5\n\tsubu.ci %0,%r2,%r3" \ : "=r" (sh), "=&r" (sl) \ @@ -955,15 +981,15 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype)); #endif /* __ns32000__ */ /* FIXME: We should test _IBMR2 here when we add assembly support for the - system vendor compilers. - FIXME: What's needed for gcc PowerPC VxWorks? __vxworks__ is not good - enough, since that hits ARM and m68k too. */ + system vendor compilers. */ #if (defined (_ARCH_PPC) /* AIX */ \ || defined (_ARCH_PWR) /* AIX */ \ || defined (__powerpc__) /* gcc */ \ || defined (__POWERPC__) /* BEOS */ \ || defined (__ppc__) /* Darwin */ \ - || defined (PPC) /* GNU/Linux, SysV */ \ + || (defined (PPC) && ! defined (CPU_FAMILY)) /* gcc 2.7.x GNU&SysV */ \ + || (defined (PPC) && defined (CPU_FAMILY) /* VxWorks */ \ + && CPU_FAMILY == PPC) \ ) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ do { \ @@ -976,7 +1002,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype)); else \ __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \ : "=r" (sh), "=&r" (sl) \ - : "%r" (ah), "r" (bh), "%r" (al), "rI" (bl)); \ + : "r" (ah), "r" (bh), "%r" (al), "rI" (bl)); \ } while (0) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ do { \ @@ -1001,7 +1027,10 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype)); __asm__ ("{cntlz|cntlzw} %0,%1" : "=r" (count) : "r" (x)) #define COUNT_LEADING_ZEROS_0 32 #if defined (_ARCH_PPC) || defined (__powerpc__) || defined (__POWERPC__) \ - || defined (__ppc__) || defined (PPC) || defined (__vxworks__) + || defined (__ppc__) \ + || (defined (PPC) && ! defined (CPU_FAMILY)) /* gcc 2.7.x GNU&SysV */ \ + || (defined (PPC) && defined (CPU_FAMILY) /* VxWorks */ \ + && CPU_FAMILY == PPC) #define umul_ppmm(ph, pl, m0, m1) \ do { \ USItype __m0 = (m0), __m1 = (m1); \ @@ -1042,7 +1071,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype)); else \ __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \ : "=r" (sh), "=&r" (sl) \ - : "%r" (ah), "r" (bh), "%r" (al), "rI" (bl)); \ + : "r" (ah), "r" (bh), "%r" (al), "rI" (bl)); \ } while (0) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ do { \ @@ -1087,7 +1116,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype)); #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addw %5,%1\n\taddwc %3,%0" \ : "=r" ((USItype)(sh)), "=&r" ((USItype)(sl)) \ - : "%0" ((USItype)(ah)), "g" ((USItype)(bh)), \ + : "0" ((USItype)(ah)), "g" ((USItype)(bh)), \ "%1" ((USItype)(al)), "g" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subw %5,%1\n\tsubwb %3,%0" \ @@ -1109,7 +1138,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype)); #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("a %1,%5\n\tae %0,%3" \ : "=r" ((USItype)(sh)), "=&r" ((USItype)(sl)) \ - : "%0" ((USItype)(ah)), "r" ((USItype)(bh)), \ + : "0" ((USItype)(ah)), "r" ((USItype)(bh)), \ "%1" ((USItype)(al)), "r" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("s %1,%5\n\tse %0,%3" \ @@ -1168,7 +1197,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype)); #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addcc %r4,%5,%1\n\taddx %r2,%3,%0" \ : "=r" (sh), "=&r" (sl) \ - : "%rJ" (ah), "rI" (bh),"%rJ" (al), "rI" (bl) \ + : "rJ" (ah), "rI" (bh),"%rJ" (al), "rI" (bl) \ __CLOBBER_CC) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subcc %r4,%5,%1\n\tsubx %r2,%3,%0" \ @@ -1353,7 +1382,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype)); " addccc %r6,%7,%%g0\n" \ " addc %r2,%3,%0" \ : "=r" (sh), "=&r" (sl) \ - : "%rJ" (ah), "rI" (bh), "%rJ" (al), "rI" (bl), \ + : "rJ" (ah), "rI" (bh), "%rJ" (al), "rI" (bl), \ "%rJ" ((al) >> 32), "rI" ((bl) >> 32) \ __CLOBBER_CC) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ @@ -1371,7 +1400,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype)); #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("addl2 %5,%1\n\tadwc %3,%0" \ : "=g" ((USItype)(sh)), "=&g" ((USItype)(sl)) \ - : "%0" ((USItype)(ah)), "g" ((USItype)(bh)), \ + : "0" ((USItype)(ah)), "g" ((USItype)(bh)), \ "%1" ((USItype)(al)), "g" ((USItype)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("subl2 %5,%1\n\tsbwc %3,%0" \ @@ -1413,7 +1442,7 @@ extern UWtype __MPN(udiv_qrnnd) _PROTO ((UWtype *, UWtype, UWtype, UWtype)); #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add %H1,%H5\n\tadc %H0,%H3" \ : "=r" ((unsigned int)(sh)), "=&r" ((unsigned int)(sl)) \ - : "%0" ((unsigned int)(ah)), "r" ((unsigned int)(bh)), \ + : "0" ((unsigned int)(ah)), "r" ((unsigned int)(bh)), \ "%1" ((unsigned int)(al)), "rQR" ((unsigned int)(bl))) #define sub_ddmmss(sh, sl, ah, al, bh, bl) \ __asm__ ("sub %H1,%H5\n\tsbc %H0,%H3" \ diff --git a/src/gmp/macos/Makefile.in b/src/gmp/macos/Makefile.in index 1068bbf59..7b76be1d3 100644 --- a/src/gmp/macos/Makefile.in +++ b/src/gmp/macos/Makefile.in @@ -1,4 +1,4 @@ -# Copyright 2000, 2001 Free Software Foundation, Inc. +# Copyright 2000, 2001, 2003, 2004 Free Software Foundation, Inc. # # This file is part of the GNU MP Library. # @@ -42,6 +42,8 @@ MpfObjDir = :MpfObj: MpnObjDir = :MpnObj: MpqObjDir = :MpqObj: MpzObjDir = :MpzObj: +PrintfObjDir = :PrintfObj: +ScanfObjDir = :ScanfObj: CmnObjDir = :CmnObj: AsmObjDir = :AsmObj: AsmSrcDir = :Asm: @@ -50,6 +52,7 @@ MpqBinDir = :MpqBin: MpzBinDir = :MpzBin: ObjDirs = {MpfObjDir} {MpnObjDir} {MpqObjDir} {MpzObjDir} @c@ + {PrintfObjDir} {ScanfObjDir} @c@ {CmnObjDir} {AsmObjDir} {AsmSrcDir} @c@ {MpfBinDir} {MpqBinDir} {MpzBinDir} @@ -71,10 +74,16 @@ MpqObjs = @c@ MpzObjs = @c@ @mpz_objects@ -CmnObjs = @c@ +PrintfObjs = @c@ + @printf_objects@ + +ScanfObjs = @c@ + @scanf_objects@ + +CmnObjs = {CmnObjDir}tal-notreent.o @c@ @gmp_objects@ -Objs = {AsmObjs} {MpfObjs} {MpnObjs} {MpqObjs} {MpzObjs} {CmnObjs} +Objs = {AsmObjs} {MpfObjs} {MpnObjs} {MpqObjs} {MpzObjs} {PrintfObjs} {ScanfObjs} {CmnObjs} @@ -97,6 +106,10 @@ all @dep@ {Lib} {MpzObjDir} @dep@ ::mpz: +{PrintfObjDir} @dep@ ::printf: + +{ScanfObjDir} @dep@ ::scanf: + {CmnObjDir} @dep@ :: {AsmObjDir} @dep@ :Asm: diff --git a/src/gmp/macos/configure b/src/gmp/macos/configure index 0755f8c63..c1946bf20 100755 --- a/src/gmp/macos/configure +++ b/src/gmp/macos/configure @@ -1,8 +1,10 @@ +#!/usr/bin/perl + # This is a simple configure script for MacOS and MPW. # Note that this script can't be run directly from MPW perl # because it has the wrong end-of-line characters. See README. -# Copyright 2000, 2001, 2002 Free Software Foundation, Inc. +# Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. # # This file is part of the GNU MP Library. # @@ -53,6 +55,8 @@ my @dirs = 'MpnObj', 'MpqObj', 'MpzObj', + 'PrintfObj', + 'ScanfObj', 'CmnObj', 'AsmObj', 'Asm', @@ -246,6 +250,8 @@ my $file; foreach $file (@asm_files) { my $ifile = mf("$mpn_asm_dir/$file.asm"); my $ofile = mf("Asm/$file.s"); + my $func; + my %defs = (); open(ASM, $ifile) or die "Can't read file \"$ifile\"\n"; @@ -261,9 +267,22 @@ foreach $file (@asm_files) { s/ASM_START\s*\(.*?\)/$asm_start/; - s/PROLOGUE\s*\(\s*(.*?)\s*\)/asm_prologue($1)/e; + if (s/PROLOGUE\s*\(\s*(.*?)\s*\)/asm_prologue($1)/e) { + $func = $1; + } - s/EPILOGUE\s*\(\s*(.*?)\s*\)/asm_epilogue($1)/e; + s/EPILOGUE\s*\(\s*(.*?)\s*\)/asm_epilogue($func)/e; + + s/L\(([^)]*)\)/L$1/g; # L() style labels + + # register name defines + if (/\bdefine\(`?([a-zA-Z0-9]+)'?,`?([^')]*)\'?\)/) { + $defs{$1} = $2; + $_ = "\n"; + } + foreach my $i (keys %defs) { + s/\b\Q$i\E\b/$defs{$i}/g; + } s/\n/\x0D/g; print NEW "$_\x0D"; # Use MacOS end-of-line character @@ -315,6 +334,8 @@ my %config = 'mpz_objects' => what_objects("mpz","../mpz","{MpzObjDir}"), 'mpf_objects' => what_objects("mpf","../mpf","{MpfObjDir}"), 'mpq_objects' => what_objects("mpq","../mpq","{MpqObjDir}"), + 'printf_objects' => what_objects("printf","../printf","{PrintfObjDir}"), + 'scanf_objects' => what_objects("scanf","../scanf","{ScanfObjDir}"), 'gmp_objects' => what_objects("gmp","..", "{CmnObjDir}"), %{$cfg}, ); @@ -429,7 +450,7 @@ sub what_objects { close MAKEFILE_AM; my @ofiles = split(' ',$text); - @ofiles > 10 or die "Can't find $part files in \"$makefile_am\"\n"; + @ofiles > 8 or die "Can't find $part files in \"$makefile_am\"\n"; my $ofiles = join(' ', map {/^(.+)\.c$/ and $_ = "$dstdir$1.o"} @ofiles); $ofiles =~ s/(.{1,66})\s/$1 \xB6\x0D\t/g; diff --git a/src/gmp/mp-h.in b/src/gmp/mp-h.in index 4c4981c20..a8ae23347 100644 --- a/src/gmp/mp-h.in +++ b/src/gmp/mp-h.in @@ -1,7 +1,7 @@ /* mp-h.in -- Definitions for the GNU multiple precision library -*-mode:c-*- BSD mp compatible functions. -Copyright 1991, 1993, 1994, 1995, 1996, 2000, 2001, 2002 Free Software +Copyright 1991, 1993, 1994, 1995, 1996, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -39,7 +39,7 @@ MA 02111-1307, USA. */ #undef __need_size_t /* The following instantiated by configure, for internal use only */ -#if ! __GMP_WITHIN_CONFIGURE +#if ! defined (__GMP_WITHIN_CONFIGURE) @DEFN_LONG_LONG_LIMB@ #define __GMP_LIBGMP_DLL @LIBGMP_DLL@ #endif @@ -69,7 +69,11 @@ MA 02111-1307, USA. */ #define __gmp_signed #endif -#if defined (__GNUC__) || defined (_MSC_VER) || defined (__BORLANDC__) +#if defined (__GNUC__) +#define __GMP_DECLSPEC_EXPORT __declspec(__dllexport__) +#define __GMP_DECLSPEC_IMPORT __declspec(__dllimport__) +#endif +#if defined (_MSC_VER) || defined (__BORLANDC__) #define __GMP_DECLSPEC_EXPORT __declspec(dllexport) #define __GMP_DECLSPEC_IMPORT __declspec(dllimport) #endif @@ -92,7 +96,7 @@ MA 02111-1307, USA. */ #define __GMP_DECLSPEC #endif -#ifdef _SHORT_LIMB +#ifdef __GMP_SHORT_LIMB typedef unsigned int mp_limb_t; typedef int mp_limb_signed_t; #else diff --git a/src/gmp/mpf/ceilfloor.c b/src/gmp/mpf/ceilfloor.c index ff86c3322..60211c179 100644 --- a/src/gmp/mpf/ceilfloor.c +++ b/src/gmp/mpf/ceilfloor.c @@ -1,6 +1,6 @@ /* mpf_ceil, mpf_floor -- round an mpf to an integer. -Copyright 2001 Free Software Foundation, Inc. +Copyright 2001, 2004 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -31,7 +31,7 @@ MA 02111-1307, USA. */ static void __gmpf_ceil_or_floor _PROTO ((REGPARM_2_1 (mpf_ptr r, mpf_srcptr u, int dir))) REGPARM_ATTR (1); #define mpf_ceil_or_floor(r,u,dir) __gmpf_ceil_or_floor (REGPARM_2_1 (r, u, dir)) -static void +REGPARM_ATTR (1) static void mpf_ceil_or_floor (mpf_ptr r, mpf_srcptr u, int dir) { mp_ptr rp, up, p; diff --git a/src/gmp/mpf/get_d_2exp.c b/src/gmp/mpf/get_d_2exp.c index c16752b7d..f03292012 100644 --- a/src/gmp/mpf/get_d_2exp.c +++ b/src/gmp/mpf/get_d_2exp.c @@ -1,6 +1,6 @@ /* double mpf_get_d_2exp (signed long int *exp, mpf_t src). -Copyright 2001, 2002 Free Software Foundation, Inc. +Copyright 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -52,5 +52,23 @@ mpf_get_d_2exp (signed long int *exp2, mpf_srcptr src) *exp2 = EXP(src) * GMP_NUMB_BITS - cnt + GMP_NAIL_BITS; res = res * ((mp_limb_t) 1 << cnt); + /* gcc on m68k and x86 holds floats in the coprocessor, which may mean + "res" has extra precision. Force it through memory to ensure any + rounding takes place now and won't become 1.0 in the caller. */ +#if (HAVE_HOST_CPU_FAMILY_m68k || HAVE_HOST_CPU_FAMILY_x86) \ + && defined (__GNUC__) + asm ("" : "=m" (res) : "0" (res)); +#endif + + /* if hardware floats are in round upwards mode then res may be 1.0 */ + if (res >= 1.0) + { + res *= 0.5; + (*exp2)++; + } + + ASSERT (res >= 0.5); + ASSERT (res < 1.0); + return negative ? -res : res; } diff --git a/src/gmp/mpf/sub.c b/src/gmp/mpf/sub.c index 2e2cff945..0dcfbab24 100644 --- a/src/gmp/mpf/sub.c +++ b/src/gmp/mpf/sub.c @@ -1,6 +1,6 @@ /* mpf_sub -- Subtract two floats. -Copyright 1993, 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software +Copyright 1993, 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -105,26 +105,29 @@ mpf_sub (mpf_ptr r, mpf_srcptr u, mpf_srcptr v) if (usize == 0) { + /* u cancels high limbs of v, result is rest of v */ + negate ^= 1; + cancellation: + /* strip high zeros before truncating to prec */ + while (vsize != 0 && vp[vsize - 1] == 0) + { + vsize--; + exp--; + } if (vsize > prec) { vp += vsize - prec; vsize = prec; } - rsize = vsize; - tp = (mp_ptr) vp; - negate ^= 1; - goto normalize; + MPN_COPY_INCR (rp, vp, vsize); + rsize = vsize; + goto done; } if (vsize == 0) { - if (usize > prec) - { - up += usize - prec; - usize = prec; - } - rsize = usize; - tp = (mp_ptr) up; - goto normalize; + vp = up; + vsize = usize; + goto cancellation; } } while (up[usize - 1] == vp[vsize - 1]); @@ -401,6 +404,8 @@ general_case: done: r->_mp_size = negate ? -rsize : rsize; + if (rsize == 0) + exp = 0; r->_mp_exp = exp; TMP_FREE (marker); } diff --git a/src/gmp/mpfr/agm.c b/src/gmp/mpfr/agm.c index 72ab12b21..7bce9b734 100644 --- a/src/gmp/mpfr/agm.c +++ b/src/gmp/mpfr/agm.c @@ -1,6 +1,6 @@ /* mpfr_agm -- arithmetic-geometric mean of two floating-point numbers -Copyright 1999, 2000, 2001, 2002 Free Software Foundation. +Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation. This file is part of the MPFR Library. @@ -117,14 +117,18 @@ mpfr_agm (mpfr_ptr r, mpfr_srcptr op2, mpfr_srcptr op1, mp_rnd_t rnd_mode) while (go_on) { int err, can_round; mp_prec_t eq; + double erraux; - err=1 + (int) ((3.0/2.0*(double)_mpfr_ceil_log2((double)p)+1.0)*_mpfr_ceil_exp2(-(double)p) - +3.0*_mpfr_ceil_exp2(-2.0*(double)p*uo/(vo-uo))); + erraux = (vo == uo) ? 0.0 : _mpfr_ceil_exp2 (-2.0 * (double) p * uo + / (vo - uo)); + err = 1 + (int) ((3.0 / 2.0 * (double) _mpfr_ceil_log2 ((double) p) + + 1.0) * _mpfr_ceil_exp2 (- (double) p) + + 3.0 * erraux); if(p-err-3<=q) { p=q+err+4; err= 1 + (int) ((3.0/2.0*_mpfr_ceil_log2((double)p)+1.0)*_mpfr_ceil_exp2(-(double)p) - +3.0*_mpfr_ceil_exp2(-2.0*(double)p*uo/(vo-uo))); + +3.0 * erraux); } /* Calculus of un and vn */ diff --git a/src/gmp/mpfr/exp_2.c b/src/gmp/mpfr/exp_2.c index 135f1d04c..4300a99d0 100644 --- a/src/gmp/mpfr/exp_2.c +++ b/src/gmp/mpfr/exp_2.c @@ -1,7 +1,7 @@ /* mpfr_exp_2 -- exponential of a floating-point number using Brent's algorithms in O(n^(1/2)*M(n)) and O(n^(1/3)*M(n)) -Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -23,6 +23,7 @@ MA 02111-1307, USA. */ #include #include "gmp.h" #include "gmp-impl.h" +#include "longlong.h" #include "mpfr.h" #include "mpfr-impl.h" @@ -109,12 +110,20 @@ mpfr_exp_2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) { int n, K, precy, q, k, l, err, exps, inexact; mpfr_t r, s, t; mpz_t ss; + int error_r; TMP_DECL(marker); precy = MPFR_PREC(y); n = (int) (mpfr_get_d1 (x) / LOG2); + /* error bounds the cancelled bits in x - n*log(2) */ + if (n == 0) + error_r = 0; + else + count_leading_zeros (error_r, (mp_limb_t) (n < 0) ? -n : n); + error_r = BITS_PER_MP_LIMB - error_r + 2; + /* for the O(n^(1/2)*M(n)) method, the Taylor series computation of n/K terms costs about n/(2K) multiplications when computed in fixed point */ @@ -123,8 +132,8 @@ mpfr_exp_2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) err = K + (int) _mpfr_ceil_log2 (2.0 * (double) l + 18.0); /* add K extra bits, i.e. failure probability <= 1/2^K = O(1/precy) */ q = precy + err + K + 3; - mpfr_init2 (r, q); - mpfr_init2 (s, q); + mpfr_init2 (r, q + error_r); + mpfr_init2 (s, q + error_r); mpfr_init2 (t, q); /* the algorithm consists in computing an upper bound of exp(x) using a precision of q bits, and see if we can round to MPFR_PREC(y) taking @@ -157,6 +166,7 @@ mpfr_exp_2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) if (n<0) mpfr_neg(r, r, GMP_RNDD); mpfr_sub(r, x, r, GMP_RNDU); } + mpfr_round_prec (r, GMP_RNDU, q); #ifdef DEBUG printf("x-r=%1.20e\n", mpfr_get_d1 (r)); printf(" ="); mpfr_print_binary(r); putchar('\n'); diff --git a/src/gmp/mpfr/mpfr.info b/src/gmp/mpfr/mpfr.info index e225a4e8f..a51b3c4e7 100644 --- a/src/gmp/mpfr/mpfr.info +++ b/src/gmp/mpfr/mpfr.info @@ -1,4 +1,4 @@ -This is mpfr.info, produced by makeinfo version 4.2 from mpfr.texi. +This is mpfr.info, produced by makeinfo version 4.6 from mpfr.texi. START-INFO-DIR-ENTRY * mpfr: (mpfr.info). Multiple Precision Floating-Point Reliable Library. @@ -7,7 +7,7 @@ END-INFO-DIR-ENTRY This file documents MPFR, a library for reliable multiple precision floating-point arithmetic - Copyright (C) 1999-2002, Free Software Foundation. + Copyright (C) 1999-2002, 2004 Free Software Foundation. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are @@ -29,7 +29,7 @@ File: mpfr.info, Node: Top, Next: Copying, Prev: (dir), Up: (dir) MPFR **** - This manual documents how to install and use the Multiple Precision +This manual documents how to install and use the Multiple Precision Floating-Point Reliable Library, version 2.0.1 * Menu: @@ -52,8 +52,8 @@ File: mpfr.info, Node: Copying, Next: Introduction to MPFR, Prev: Top, Up: T MPFR Copying Conditions *********************** - This library is "free"; this means that everyone is free to use it -and free to redistribute it on a free basis. The library is not in the +This library is "free"; this means that everyone is free to use it and +free to redistribute it on a free basis. The library is not in the public domain; it is copyrighted and there are restrictions on its distribution, but these restrictions are designed to permit everything that a good cooperating citizen would want to do. What is not allowed @@ -87,7 +87,7 @@ File: mpfr.info, Node: Introduction to MPFR, Next: Installing MPFR, Prev: Cop Introduction to MPFR ******************** - MPFR is a portable library written in C for arbitrary precision +MPFR is a portable library written in C for arbitrary precision arithmetic on reliable floating-point numbers. It is based on the GNU MP library. It aims to extend the class of floating-point numbers provided by the GNU MP library by "reliable" floating-point numbers. It @@ -116,8 +116,8 @@ a modified MPFR is provided. How to use this Manual ====================== - Everyone should read *Note MPFR Basics::. If you need to install -the library yourself, you need to read *Note Installing MPFR::, too. +Everyone should read *Note MPFR Basics::. If you need to install the +library yourself, you need to read *Note Installing MPFR::, too. The rest of the manual can be used for later reference, although it is probably a good idea to glance through it. @@ -128,7 +128,7 @@ File: mpfr.info, Node: Installing MPFR, Next: Reporting Bugs, Prev: Introduct Installing MPFR *************** - To build MPFR, you first have to install GNU MP (version 4.0.1 or +To build MPFR, you first have to install GNU MP (version 4.0.1 or higher) on your computer. You need a C compiler, preferably GCC, but any reasonable compiler should work. And you need a standard Unix `make' program, plus some other standard Unix utility programs. @@ -189,8 +189,7 @@ any reasonable compiler should work. And you need a standard Unix Known Build Problems ==================== - MPFR suffers from all bugs from the GNU MP library, plus many many -more. +MPFR suffers from all bugs from the GNU MP library, plus many many more. Please report other problems to `mpfr@loria.fr'. *Note Reporting Bugs::. Some bug fixes are available on the MPFR web page @@ -202,7 +201,7 @@ File: mpfr.info, Node: Reporting Bugs, Next: MPFR Basics, Prev: Installing MP Reporting Bugs ************** - If you think you have found a bug in the MPFR library, first have a +If you think you have found a bug in the MPFR library, first have a look on the MPFR web page `http://www.loria.fr/projets/mpfr/' or `http://www.mpfr.org/': perhaps this bug is already known, in which case you will find a workaround for it. Otherwise, please investigate @@ -239,7 +238,7 @@ File: mpfr.info, Node: MPFR Basics, Next: Floating-point Functions, Prev: Rep MPFR Basics *********** - All declarations needed to use MPFR are collected in the include file +All declarations needed to use MPFR are collected in the include file `mpfr.h'. It is designed to work with both C and C++ compilers. You should include that file in any program using the MPFR library: @@ -275,7 +274,7 @@ Normally a limb contains 32 or 64 bits. The C data type for a limb is Function Classes ================ - There is only one class of functions in the MPFR library: +There is only one class of functions in the MPFR library: 1. Functions for floating-point arithmetic, with names beginning with `mpfr_'. The associated type is `mpfr_t'. @@ -283,7 +282,7 @@ Function Classes MPFR Variable Conventions ========================= - As a general rule, all MPFR functions expect output arguments before +As a general rule, all MPFR functions expect output arguments before input arguments. This notation is based on an analogy with the assignment operator. @@ -315,9 +314,9 @@ its life. Compatibility with MPF ====================== - A header file `mpf2mpfr.h' is included in the distribution of MPFR -for compatibility with the GNU MP class MPF. After inserting the -following two lines after the `#include "gmp.h"' line, +A header file `mpf2mpfr.h' is included in the distribution of MPFR for +compatibility with the GNU MP class MPF. After inserting the following +two lines after the `#include "gmp.h"' line, `#include "mpfr.h"' @@ -333,7 +332,7 @@ rounding mode, which can be reset with `mpfr_set_default_rounding_mode'. Getting the Latest Version of MPFR ================================== - The latest version of MPFR is available from +The latest version of MPFR is available from `http://www.loria.fr/projets/mpfr/' or `http://www.mpfr.org/'.  @@ -342,7 +341,7 @@ File: mpfr.info, Node: Floating-point Functions, Next: Contributors, Prev: MP Floating-point Functions ************************ - The floating-point functions expect arguments of type `mpfr_t'. +The floating-point functions expect arguments of type `mpfr_t'. The MPFR floating-point functions have an interface that is similar to the GNU MP integer functions. The function prefix for @@ -389,7 +388,7 @@ File: mpfr.info, Node: Rounding Modes, Next: Exceptions, Prev: Floating-point Rounding Modes ============== - The following four rounding modes are supported: +The following four rounding modes are supported: * `GMP_RNDN': round to nearest * `GMP_RNDZ': round towards zero @@ -453,9 +452,9 @@ File: mpfr.info, Node: Exceptions, Next: Initializing Floats, Prev: Rounding Exceptions ========== - Note: Overflow handling is still experimental and currently -implemented very partially. If an overflow occurs internally at the -wrong place, anything can happen (crash, wrong results, etc). +Note: Overflow handling is still experimental and currently implemented +very partially. If an overflow occurs internally at the wrong place, +anything can happen (crash, wrong results, etc). - Function: mp_exp_t mpfr_get_emin (void) - Function: mp_exp_t mpfr_get_emax (void) @@ -585,13 +584,13 @@ File: mpfr.info, Node: Assigning Floats, Next: Simultaneous Float Init & Assig Assignment Functions ==================== - These functions assign new values to already initialized floats -(*note Initializing Floats::). +These functions assign new values to already initialized floats (*note +Initializing Floats::). - Function: int mpfr_set (mpfr_t ROP, mpfr_t OP, mp_rnd_t RND) - Function: int mpfr_set_ui (mpfr_t ROP, unsigned long int OP, mp_rnd_t RND) - - Function: int mpfr_set_si (mpfr_t ROP, long int OP, mp_rnd_t RND + - Function: int mpfr_set_si (mpfr_t ROP, long int OP, mp_rnd_t RND) - Function: int mpfr_set_d (mpfr_t ROP, double OP, mp_rnd_t RND) - Function: int mpfr_set_z (mpfr_t ROP, mpz_t OP, mp_rnd_t RND) - Function: int mpfr_set_q (mpfr_t ROP, mpq_t OP, mp_rnd_t RND) @@ -1022,8 +1021,8 @@ File: mpfr.info, Node: I/O of Floats, Next: Miscellaneous Float Functions, Pr Input and Output Functions ========================== - Functions that perform input from a standard input/output stream, -and functions that output to a standard input/output stream. Passing a +Functions that perform input from a standard input/output stream, and +functions that output to a standard input/output stream. Passing a null pointer for a STREAM argument to any of these functions will make them read from `stdin' and write to `stdout', respectively. @@ -1113,10 +1112,10 @@ Miscellaneous Functions Internals ========= - These types and functions were mainly designed for the -implementation of `mpfr', but may be useful for users too. However no -upward compatibility is guaranteed. You need to include `mpfr-impl.h' -to use them. +These types and functions were mainly designed for the implementation +of `mpfr', but may be useful for users too. However no upward +compatibility is guaranteed. You need to include `mpfr-impl.h' to use +them. The `mpfr_t' type consists of four fields. The `_mpfr_prec' field is used to store the precision of the variable (in bits); this is not @@ -1180,7 +1179,7 @@ File: mpfr.info, Node: Contributors, Next: References, Prev: Floating-point F Contributors ************ - The main developers consist of Guillaume Hanrot, Vincent Lefèvre and +The main developers consist of Guillaume Hanrot, Vincent Lefèvre and Paul Zimmermann. We would like to thank Jean-Michel Muller and Joris van der Hoeven @@ -1402,26 +1401,26 @@ Function and Type Index  Tag Table: -Node: Top1010 -Node: Copying1677 -Node: Introduction to MPFR3397 -Node: Installing MPFR5133 -Node: Reporting Bugs7665 -Node: MPFR Basics9195 -Node: Floating-point Functions13276 -Node: Rounding Modes15114 -Node: Exceptions18227 -Node: Initializing Floats20496 -Node: Assigning Floats24168 -Node: Simultaneous Float Init & Assign27386 -Node: Converting Floats28627 -Node: Float Arithmetic31301 -Node: Float Comparison37456 -Node: I/O of Floats45234 -Node: Miscellaneous Float Functions47671 -Node: Contributors52903 -Node: References54098 -Node: Concept Index54714 -Node: Function Index56376 +Node: Top1015 +Node: Copying1679 +Node: Introduction to MPFR3396 +Node: Installing MPFR5126 +Node: Reporting Bugs7652 +Node: MPFR Basics9179 +Node: Floating-point Functions13245 +Node: Rounding Modes15080 +Node: Exceptions18190 +Node: Initializing Floats20456 +Node: Assigning Floats24128 +Node: Simultaneous Float Init & Assign27344 +Node: Converting Floats28585 +Node: Float Arithmetic31259 +Node: Float Comparison37414 +Node: I/O of Floats45192 +Node: Miscellaneous Float Functions47626 +Node: Contributors52855 +Node: References54047 +Node: Concept Index54663 +Node: Function Index56325  End Tag Table diff --git a/src/gmp/mpfr/mpfr.texi b/src/gmp/mpfr/mpfr.texi index fb2d16cee..1fb836002 100644 --- a/src/gmp/mpfr/mpfr.texi +++ b/src/gmp/mpfr/mpfr.texi @@ -32,7 +32,7 @@ END-INFO-DIR-ENTRY @ifinfo This file documents MPFR, a library for reliable multiple precision floating-point arithmetic -Copyright (C) 1999-2002, Free Software Foundation. +Copyright (C) 1999-2002, 2004 Free Software Foundation. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -102,7 +102,7 @@ by the Foundation. @end titlepage @headings double -@ifinfo +@ifnottex @node Top, Copying, (dir), (dir) @top MPFR @@ -110,7 +110,7 @@ by the Foundation. This manual documents how to install and use the Multiple Precision Floating-Point Reliable Library, version 2.0.1 -@end ifinfo +@end ifnottex @menu * Copying:: GMP Copying Conditions (LGPL). @@ -726,7 +726,7 @@ These functions assign new values to already initialized floats @deftypefun int mpfr_set (mpfr_t @var{rop}, mpfr_t @var{op}, mp_rnd_t @var{rnd}) @deftypefunx int mpfr_set_ui (mpfr_t @var{rop}, unsigned long int @var{op}, mp_rnd_t @var{rnd}) -@deftypefunx int mpfr_set_si (mpfr_t @var{rop}, long int @var{op}, mp_rnd_t @var{rnd} +@deftypefunx int mpfr_set_si (mpfr_t @var{rop}, long int @var{op}, mp_rnd_t @var{rnd}) @deftypefunx int mpfr_set_d (mpfr_t @var{rop}, double @var{op}, mp_rnd_t @var{rnd}) @deftypefunx int mpfr_set_z (mpfr_t @var{rop}, mpz_t @var{op}, mp_rnd_t @var{rnd}) @deftypefunx int mpfr_set_q (mpfr_t @var{rop}, mpq_t @var{op}, mp_rnd_t @var{rnd}) diff --git a/src/gmp/mpfr/out_str.c b/src/gmp/mpfr/out_str.c index a186eb6c3..6a648399a 100644 --- a/src/gmp/mpfr/out_str.c +++ b/src/gmp/mpfr/out_str.c @@ -1,6 +1,6 @@ /* mpfr_out_str -- output a floating-point number to a stream -Copyright 1999, 2001 Free Software Foundation, Inc. +Copyright 1999, 2001, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -35,6 +35,10 @@ mpfr_out_str (FILE *stream, int base, size_t n_digits, mpfr_srcptr op, size_t l; mp_exp_t e; + /* when stream=NULL, output to stdout */ + if (stream == NULL) + stream = stdout; + if (MPFR_IS_NAN(op)) { fprintf (stream, "NaN"); diff --git a/src/gmp/mpfr/rnd_mode.c b/src/gmp/mpfr/rnd_mode.c index 3f4229f6e..145e99787 100644 --- a/src/gmp/mpfr/rnd_mode.c +++ b/src/gmp/mpfr/rnd_mode.c @@ -1,6 +1,6 @@ /* mpfr_set_machine_rnd_mode -- set the rounding mode for machine floats -Copyright 1999, 2001, 2002 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2004 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -28,16 +28,61 @@ MA 02111-1307, USA. */ #ifdef MPFR_HAVE_FESETROUND #include -/* sets the machine rounding mode to the value rnd_mode */ +/* sets the machine rounding mode to the value rnd_mode + + Doing an exit(0) when an FE mode is not available is a nasty hack. It's + done to let the test programs stop gracefully when they attempt an + unsupported mode. This happens for instance on ARM systems, which lack + FE_TOWARDZERO. + + Applications which have been using this function are not harmed by this + hack. In the past the code didn't even compile on systems with an + incomplete set of FE choices. Applications won't want to be using this + anyway, it's been moved to the test suite in newer mpfr. */ + void mpfr_set_machine_rnd_mode (mp_rnd_t rnd_mode) { switch (rnd_mode) { - case GMP_RNDN: fesetround(FE_TONEAREST); break; - case GMP_RNDZ: fesetround(FE_TOWARDZERO); break; - case GMP_RNDU: fesetround(FE_UPWARD); break; - case GMP_RNDD: fesetround(FE_DOWNWARD); break; - default: fprintf(stderr, "invalid rounding mode\n"); exit(1); + + case GMP_RNDN: +#ifdef FE_TONEAREST + fesetround(FE_TONEAREST); + return; +#else + break; +#endif + + case GMP_RNDZ: +#ifdef FE_TOWARDZERO + fesetround(FE_TOWARDZERO); + return; +#else + break; +#endif + + case GMP_RNDU: +#ifdef FE_UPWARD + fesetround(FE_UPWARD); + return; +#else + break; +#endif + + case GMP_RNDD: +#ifdef FE_DOWNWARD + fesetround(FE_DOWNWARD); + return; +#else + break; +#endif + + default: + fprintf(stderr, "invalid rounding mode\n"); + exit(1); } + + printf ("mpfr_set_machine_rnd_mode(): rounding mode %d not available, exiting\n", rnd_mode); + exit (0); } #endif diff --git a/src/gmp/mpfr/set_str.c b/src/gmp/mpfr/set_str.c index b1b46d165..83733f8e7 100644 --- a/src/gmp/mpfr/set_str.c +++ b/src/gmp/mpfr/set_str.c @@ -23,13 +23,8 @@ MA 02111-1307, USA. */ #include #include #include -#include - -#ifdef HAVE_STRCASECMP #include -#else -int strcasecmp (const char *, const char *); -#endif +#include #include "gmp.h" #include "gmp-impl.h" @@ -37,21 +32,44 @@ int strcasecmp (const char *, const char *); #include "mpfr.h" #include "mpfr-impl.h" +/* from mpf/set_str.c */ +static int +digit_value_in_base (int c, int base) +{ + int digit; + + if (isdigit (c)) + digit = c - '0'; + else if (islower (c)) + digit = c - 'a' + 10; + else if (isupper (c)) + digit = c - 'A' + 10; + else + return -1; + + if (digit < base) + return digit; + return -1; +} + int mpfr_set_str (mpfr_ptr x, __gmp_const char *str, int base, mp_rnd_t rnd_mode) { mpz_t mantissa; - int negative, inex; + int negative, inex, value; long k = 0; unsigned char c; long e; mp_prec_t q; mpfr_t y, z; + const char *str0 = str; if (base < 2 || base > 36) - return 1; + return -1; - if (strcasecmp(str, "NaN") == 0) + /* be careful that 'nan' is a valid number in base >= 24, + since n=23, a=10, n=23 */ + if (((base < 24) ? strncasecmp : strncmp) (str, "NaN", 3) == 0) { MPFR_SET_NAN(x); /* MPFR_RET_NAN not used as the return value isn't a ternary value */ @@ -63,7 +81,9 @@ mpfr_set_str (mpfr_ptr x, __gmp_const char *str, int base, mp_rnd_t rnd_mode) if (negative || *str == '+') str++; - if (strcasecmp(str, "Inf") == 0) + /* be careful that 'inf' is a valid number in base >= 24, + since i=18, n=23, f=15 */ + if (((base < 24) ? strncasecmp : strncmp) (str, "Inf", 3) == 0) { MPFR_CLEAR_NAN(x); MPFR_SET_INF(x); @@ -74,8 +94,8 @@ mpfr_set_str (mpfr_ptr x, __gmp_const char *str, int base, mp_rnd_t rnd_mode) return 0; } - mpz_init(mantissa); - mpz_set_ui(mantissa, 0); + mpz_init (mantissa); + mpz_set_ui (mantissa, 0); while (*str == '0') str++; /* skip initial zeros */ @@ -83,12 +103,11 @@ mpfr_set_str (mpfr_ptr x, __gmp_const char *str, int base, mp_rnd_t rnd_mode) /* allowed characters are '0' to '0'+base-1 if base <= 10, and '0' to '9' plus 'a' to 'a'+base-11 if 10 < base <= 36 */ while (c = *str, - (isdigit(c) && c < '0' + base) || - (islower(c) && c < 'a'-10 + base)) + (value = digit_value_in_base (c, base)) >= 0) { str++; - mpz_mul_ui(mantissa, mantissa, base); - mpz_add_ui(mantissa, mantissa, isdigit(c) ? c - '0' : c - ('a'-10)); + mpz_mul_ui (mantissa, mantissa, base); + mpz_add_ui (mantissa, mantissa, value); } /* k is the number of non-zero digits before the decimal point */ @@ -102,37 +121,36 @@ mpfr_set_str (mpfr_ptr x, __gmp_const char *str, int base, mp_rnd_t rnd_mode) { if (k == LONG_MAX) { - mpz_clear(mantissa); + mpz_clear (mantissa); return -1; } k++; str++; - mpz_mul_ui(mantissa, mantissa, base); - mpz_add_ui(mantissa, mantissa, isdigit(c) ? c - '0' : c - ('a'-10)); + mpz_mul_ui (mantissa, mantissa, base); + mpz_add_ui (mantissa, mantissa, isdigit(c) ? c - '0' : c - ('a' - 10)); } } - if (*str == '\0') /* no exponent */ - { - e = -k; - } - else if ((base <= 10 && (*str == 'e' || *str == 'E')) || *str == '@') + if ((base <= 10 && (*str == 'e' || *str == 'E')) || *str == '@') { char *endptr; if (*++str == '\0') /* exponent character but no exponent */ { - mpz_clear(mantissa); - return 1; + mpz_clear (mantissa); + return -1; } errno = 0; - e = strtol(str, &endptr, 10); /* signed exponent after 'e', 'E' or '@' */ + e = strtol (str, &endptr, 10); /* signed exponent after 'e', 'E' or '@' */ +#ifdef REQUIRE_END_OF_STRING if (*endptr != '\0') { - mpz_clear(mantissa); - return 1; + mpz_clear (mantissa); + return -1; } +#endif + str = endptr; if (errno) { mpz_clear(mantissa); @@ -146,48 +164,54 @@ mpfr_set_str (mpfr_ptr x, __gmp_const char *str, int base, mp_rnd_t rnd_mode) } e -= k; } - else /* unexpected character */ + else /* no exponent */ { - mpz_clear(mantissa); - return 1; +#ifdef REQUIRE_END_OF_STRING + if (*str != '\0') + { + mpz_clear (mantissa); + return -1; + } +#endif + e = -k; } /* the number is mantissa*base^expn */ q = MPFR_PREC(x) & ~(mp_prec_t) (BITS_PER_MP_LIMB - 1); - mpfr_init(y); - mpfr_init(z); + mpfr_init (y); + mpfr_init (z); do { q += BITS_PER_MP_LIMB; - mpfr_set_prec(y, q); - mpfr_set_z(y, mantissa, GMP_RNDN); /* error <= 1/2*ulp(y) */ + mpfr_set_prec (y, q); + mpfr_set_z (y, mantissa, GMP_RNDN); /* error <= 1/2*ulp(y) */ - mpfr_set_prec(z, q); + mpfr_set_prec (z, q); if (e > 0) { - inex = mpfr_ui_pow_ui(z, base, e, GMP_RNDN); - mpfr_mul(y, y, z, GMP_RNDN); + inex = mpfr_ui_pow_ui (z, base, e, GMP_RNDN); + mpfr_mul (y, y, z, GMP_RNDN); } else if (e < 0) { - inex = mpfr_ui_pow_ui(z, base, -e, GMP_RNDN); - mpfr_div(y, y, z, GMP_RNDN); + inex = mpfr_ui_pow_ui (z, base, -e, GMP_RNDN); + mpfr_div (y, y, z, GMP_RNDN); } else inex = 1; if (negative) - mpfr_neg(y, y, GMP_RNDN); + mpfr_neg (y, y, GMP_RNDN); } - while (mpfr_can_round(y, q-inex, GMP_RNDN, rnd_mode, MPFR_PREC(x))==0 - && q<=2*MPFR_PREC(x)); + while (mpfr_can_round (y, q-inex, GMP_RNDN, rnd_mode, MPFR_PREC(x)) == 0 + && q <= 2*MPFR_PREC(x)); - mpfr_set(x, y, rnd_mode); + mpfr_set (x, y, rnd_mode); - mpz_clear(mantissa); - mpfr_clear(y); - mpfr_clear(z); + mpz_clear (mantissa); + mpfr_clear (y); + mpfr_clear (z); return 0; } diff --git a/src/gmp/mpfr/tests/tsqrt_ui.c b/src/gmp/mpfr/tests/tsqrt_ui.c index cbb5f9d31..8b0e1c3c0 100644 --- a/src/gmp/mpfr/tests/tsqrt_ui.c +++ b/src/gmp/mpfr/tests/tsqrt_ui.c @@ -1,6 +1,6 @@ /* Test file for mpfr_sqrt_ui. -Copyright 2000, 2001, 2002 Free Software Foundation, Inc. +Copyright 2000, 2001, 2002, 2004 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -61,6 +61,10 @@ double five = 5.0; int main (void) { + /* on debian s390 this test has been seen failing, due to a wrong rounding + from sqrt() on an input a=891885598, so disable */ +#if 0 + #ifdef MPFR_HAVE_FESETROUND int i; unsigned long a; @@ -96,5 +100,6 @@ main (void) check (0, GMP_RNDN, 0.0); check (2116118, GMP_RNDU, 1.45468828276026215e3); +#endif /* 0 */ return 0; } diff --git a/src/gmp/mpfr/urandomb.c b/src/gmp/mpfr/urandomb.c index 2592fb1a1..fe0314299 100644 --- a/src/gmp/mpfr/urandomb.c +++ b/src/gmp/mpfr/urandomb.c @@ -3,7 +3,7 @@ using STATE as the random state previously initialized by a call to gmp_randinit(). -Copyright 2000, 2001 Free Software Foundation, Inc. +Copyright 2000, 2001, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -60,13 +60,16 @@ mpfr_urandomb (mpfr_ptr rop, gmp_randstate_t rstate) exp--; } - count_leading_zeros (cnt, rp[nlimbs - 1]); - if (cnt) mpn_lshift (rp, rp, nlimbs, cnt); - exp -= cnt; + if (nlimbs != 0) /* otherwise value is zero */ + { + count_leading_zeros (cnt, rp[nlimbs - 1]); + if (cnt) mpn_lshift (rp, rp, nlimbs, cnt); + exp -= cnt; - cnt = nlimbs*BITS_PER_MP_LIMB - nbits; - /* cnt is the number of non significant bits in the low limb */ - rp[0] &= ~((MP_LIMB_T_ONE << cnt) - 1); + cnt = nlimbs*BITS_PER_MP_LIMB - nbits; + /* cnt is the number of non significant bits in the low limb */ + rp[0] &= ~((MP_LIMB_T_ONE << cnt) - 1); + } MPFR_EXP (rop) = exp; } diff --git a/src/gmp/mpfrxx.h b/src/gmp/mpfrxx.h index 57ee0ab6e..6a9c53167 100644 --- a/src/gmp/mpfrxx.h +++ b/src/gmp/mpfrxx.h @@ -1,6 +1,6 @@ /* mpfrxx.h -- C++ class wrapper for MPFR. -*- C++ -*- -Copyright 2001, 2002 Free Software Foundation, Inc. +Copyright 2001, 2002, 2004 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -480,7 +480,7 @@ template inline void __gmp_set_expr (mpfr_ptr f, const __gmp_expr<__gmpf_value, T> &expr) { - mpq_class temp(expr); + mpf_class temp(expr); mpfr_set_f(f, temp.get_mpf_t(), __gmp_default_rounding_mode); } diff --git a/src/gmp/mpn/generic/mul_fft.c b/src/gmp/mpn/generic/mul_fft.c index 22649e15f..e16f61883 100644 --- a/src/gmp/mpn/generic/mul_fft.c +++ b/src/gmp/mpn/generic/mul_fft.c @@ -6,7 +6,7 @@ INTERFACES. IT IS ALMOST GUARANTEED THAT THEY'LL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE. -Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +Copyright 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -72,8 +72,10 @@ _PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, int, int, mp_ptr *, mp_ptr *, mp_ptr, mp_ptr, mp_size_t, mp_size_t, mp_size_t, int **, mp_ptr,int)); -/* Find the best k to use for a mod 2^(n*BITS_PER_MP_LIMB)+1 FFT. - sqr==0 if for a multiply, sqr==1 for a square */ +/* Find the best k to use for a mod 2^(m*BITS_PER_MP_LIMB)+1 FFT + with m >= n. + sqr==0 if for a multiply, sqr==1 for a square. +*/ int mpn_fft_best_k (mp_size_t n, int sqr) { @@ -91,26 +93,17 @@ mpn_fft_best_k (mp_size_t n, int sqr) } -/* Returns smallest possible number of limbs >= pl for a fft of size 2^k. - - FIXME: Is this N rounded up to the next multiple of (2^k)*BITS_PER_MP_LIMB - bits and therefore simply pl rounded up to a multiple of 2^k? */ +/* Returns smallest possible number of limbs >= pl for a fft of size 2^k, + i.e. smallest multiple of 2^k >= pl. */ mp_size_t mpn_fft_next_size (mp_size_t pl, int k) { - mp_size_t N, M; - int K; + unsigned long K; - /* if (k==0) k = mpn_fft_best_k (pl, sqr); */ - N = pl * BITS_PER_MP_LIMB; K = 1 << k; - if (N % K) - N = (N / K + 1) * K; - M = N / K; - if (M % BITS_PER_MP_LIMB) - N = ((M / BITS_PER_MP_LIMB) + 1) * BITS_PER_MP_LIMB * K; - return N / BITS_PER_MP_LIMB; + pl = 1 + (pl - 1) / K; /* ceil(pl/K) */ + return pl * K; } @@ -184,10 +177,10 @@ mpn_fft_add_modF (mp_ptr ap, mp_ptr bp, int n) mp_limb_t c; c = ap[n] + bp[n] + mpn_add_n (ap, ap, bp, n); - if (c > 1) + if (c > 1) /* subtract c-1 to both ap[0] and ap[n] */ { - ap[n] = c - 1; - mpn_decr_u (ap, 1); + ap[n] = 1; + mpn_decr_u (ap, c - 1); } else ap[n] = c; @@ -205,15 +198,18 @@ mpn_fft_fft_sqr (mp_ptr *Ap, mp_size_t K, int **ll, { if (K == 2) { + mp_limb_t cy; #if HAVE_NATIVE_mpn_addsub_n - if (mpn_addsub_n (Ap[0], Ap[inc], Ap[0], Ap[inc], n + 1) & 1) - Ap[inc][n] = mpn_add_1 (Ap[inc], Ap[inc], n, CNST_LIMB(1)); + cy = mpn_addsub_n (Ap[0], Ap[inc], Ap[0], Ap[inc], n + 1) & 1; #else MPN_COPY (tp, Ap[0], n + 1); - mpn_add_n (Ap[0], Ap[0], Ap[inc],n + 1); - if (mpn_sub_n (Ap[inc], tp, Ap[inc],n + 1)) - Ap[inc][n] = mpn_add_1 (Ap[inc], Ap[inc], n, CNST_LIMB(1)); + mpn_add_n (Ap[0], Ap[0], Ap[inc], n + 1); + cy = mpn_sub_n (Ap[inc], tp, Ap[inc], n + 1); #endif + if (Ap[0][n] > CNST_LIMB(1)) /* can be 2 or 3 */ + Ap[0][n] = CNST_LIMB(1) - mpn_sub_1 (Ap[0], Ap[0], n, Ap[0][n] - CNST_LIMB(1)); + if (cy) /* Ap[inc][n] can be -1 or -2 */ + Ap[inc][n] = mpn_add_1 (Ap[inc], Ap[inc], n, ~Ap[inc][n] + CNST_LIMB(1)); } else { @@ -252,24 +248,26 @@ mpn_fft_fft (mp_ptr *Ap, mp_ptr *Bp, mp_size_t K, int **ll, { if (K == 2) { + mp_limb_t ca, cb; #if HAVE_NATIVE_mpn_addsub_n - if (mpn_addsub_n (Ap[0], Ap[inc], Ap[0], Ap[inc], n + 1) & 1) - Ap[inc][n] = mpn_add_1 (Ap[inc], Ap[inc], n, CNST_LIMB(1)); + ca = mpn_addsub_n (Ap[0], Ap[inc], Ap[0], Ap[inc], n + 1) & 1; + cb = mpn_addsub_n (Bp[0], Bp[inc], Bp[0], Bp[inc], n + 1) & 1; #else MPN_COPY (tp, Ap[0], n + 1); - mpn_add_n (Ap[0], Ap[0], Ap[inc],n + 1); - if (mpn_sub_n (Ap[inc], tp, Ap[inc],n + 1)) - Ap[inc][n] = mpn_add_1 (Ap[inc], Ap[inc], n, CNST_LIMB(1)); -#endif -#if HAVE_NATIVE_mpn_addsub_n - if (mpn_addsub_n (Bp[0], Bp[inc], Bp[0], Bp[inc], n + 1) & 1) - Bp[inc][n] = mpn_add_1 (Bp[inc], Bp[inc], n, CNST_LIMB(1)); -#else + mpn_add_n (Ap[0], Ap[0], Ap[inc], n + 1); + ca = mpn_sub_n (Ap[inc], tp, Ap[inc], n + 1); MPN_COPY (tp, Bp[0], n + 1); - mpn_add_n (Bp[0], Bp[0], Bp[inc],n + 1); - if (mpn_sub_n (Bp[inc], tp, Bp[inc],n + 1)) - Bp[inc][n] = mpn_add_1 (Bp[inc], Bp[inc], n, CNST_LIMB(1)); + mpn_add_n (Bp[0], Bp[0], Bp[inc], n + 1); + cb = mpn_sub_n (Bp[inc], tp, Bp[inc], n + 1); #endif + if (Ap[0][n] > CNST_LIMB(1)) /* can be 2 or 3 */ + Ap[0][n] = CNST_LIMB(1) - mpn_sub_1 (Ap[0], Ap[0], n, Ap[0][n] - CNST_LIMB(1)); + if (ca) /* Ap[inc][n] can be -1 or -2 */ + Ap[inc][n] = mpn_add_1 (Ap[inc], Ap[inc], n, ~Ap[inc][n] + CNST_LIMB(1)); + if (Bp[0][n] > CNST_LIMB(1)) /* can be 2 or 3 */ + Bp[0][n] = CNST_LIMB(1) - mpn_sub_1 (Bp[0], Bp[0], n, Bp[0][n] - CNST_LIMB(1)); + if (cb) /* Bp[inc][n] can be -1 or -2 */ + Bp[inc][n] = mpn_add_1 (Bp[inc], Bp[inc], n, ~Bp[inc][n] + CNST_LIMB(1)); } else { @@ -339,13 +337,29 @@ mpn_fft_mul_modF_K (mp_ptr *ap, mp_ptr *bp, mp_size_t n, int K) mp_ptr *Ap,*Bp,A,B,T; k = mpn_fft_best_k (n, sqr); - K2 = 1<BITS_PER_MP_LIMB) ? K2 : BITS_PER_MP_LIMB; M2 = n*BITS_PER_MP_LIMB/K2; - l = n/K2; - Nprime2 = ((2 * M2+k+2+maxLK)/maxLK)*maxLK; /* ceil()(2*M2+k+3)/maxLK)*maxLK*/ - nprime2 = Nprime2/BITS_PER_MP_LIMB; - Mp2 = Nprime2/K2; + l = n / K2; + Nprime2 = ((2 * M2+k+2+maxLK)/maxLK)*maxLK; /* ceil((2*M2+k+3)/maxLK)*maxLK*/ + nprime2 = Nprime2 / BITS_PER_MP_LIMB; + + /* we should ensure that nprime2 is a multiple of the next K */ + if (nprime2 >= (sqr ? SQR_FFT_MODF_THRESHOLD : MUL_FFT_MODF_THRESHOLD)) + { + unsigned long K3; + while (nprime2 % (K3 = 1 << mpn_fft_best_k (nprime2, sqr))) + { + nprime2 = ((nprime2 + K3 - 1) / K3) * K3; + Nprime2 = nprime2 * BITS_PER_MP_LIMB; + /* warning: since nprime2 changed, K3 may change too! */ + } + ASSERT(nprime2 % K3 == 0); + } + ASSERT_ALWAYS(nprime2 < n); /* otherwise we'll loop */ + + Mp2 = Nprime2 / K2; Ap = TMP_ALLOC_MP_PTRS (K2); Bp = TMP_ALLOC_MP_PTRS (K2); @@ -402,22 +416,28 @@ mpn_fft_mul_modF_K (mp_ptr *ap, mp_ptr *bp, mp_size_t n, int K) /* input: A^[l[k][0]] A^[l[k][1]] ... A^[l[k][K-1]] - output: K*A[0] K*A[K-1] ... K*A[1] */ + output: K*A[0] K*A[K-1] ... K*A[1]. + Assumes the Ap[] are pseudo-normalized, i.e. 0 <= Ap[][n] <= 1. + This condition is also fulfilled at exit. +*/ static void mpn_fft_fftinv (mp_ptr *Ap, int K, mp_size_t omega, mp_size_t n, mp_ptr tp) { if (K == 2) { + mp_limb_t cy; #if HAVE_NATIVE_mpn_addsub_n - if (mpn_addsub_n (Ap[0], Ap[1], Ap[0], Ap[1], n + 1) & 1) - Ap[1][n] = mpn_add_1 (Ap[1], Ap[1], n, CNST_LIMB(1)); + cy = mpn_addsub_n (Ap[0], Ap[1], Ap[0], Ap[1], n + 1) & 1; #else MPN_COPY (tp, Ap[0], n + 1); mpn_add_n (Ap[0], Ap[0], Ap[1], n + 1); - if (mpn_sub_n (Ap[1], tp, Ap[1], n + 1)) - Ap[1][n] = mpn_add_1 (Ap[1], Ap[1], n, CNST_LIMB(1)); + cy = mpn_sub_n (Ap[1], tp, Ap[1], n + 1); #endif + if (Ap[0][n] > CNST_LIMB(1)) /* can be 2 or 3 */ + Ap[0][n] = CNST_LIMB(1) - mpn_sub_1 (Ap[0], Ap[0], n, Ap[0][n] - CNST_LIMB(1)); + if (cy) /* Ap[1][n] can be -1 or -2 */ + Ap[1][n] = mpn_add_1 (Ap[1], Ap[1], n, ~Ap[1][n] + CNST_LIMB(1)); } else { @@ -459,12 +479,13 @@ mpn_fft_div_2exp_modF (mp_ptr ap, int k, mp_size_t n, mp_ptr tp) } -/* R <- A mod 2^(n*BITS_PER_MP_LIMB)+1, n<=an<=3*n */ +/* R <- A mod 2^(n*BITS_PER_MP_LIMB)+1, n <= an <= 3*n */ static void mpn_fft_norm_modF (mp_ptr rp, mp_ptr ap, mp_size_t n, mp_size_t an) { mp_size_t l; + ASSERT (n <= an && an <= 3 * n); if (an > 2 * n) { l = n; @@ -595,7 +616,7 @@ mpn_mul_fft_internal (mp_ptr op, mp_srcptr n, mp_srcptr m, mp_size_t pl, /* op <- n*m mod 2^N+1 with fft of size 2^k where N=pl*BITS_PER_MP_LIMB n and m have respectively nl and ml limbs op must have space for pl+1 limbs - One must have pl = mpn_fft_next_size (pl, k). + Assumes pl is multiple of 2^k. */ void @@ -612,7 +633,6 @@ mpn_mul_fft (mp_ptr op, mp_size_t pl, TMP_DECL(marker); TRACE (printf ("\nmpn_mul_fft pl=%ld nl=%ld ml=%ld k=%d\n", pl, nl, ml, k)); - ASSERT_ALWAYS (mpn_fft_next_size (pl, k) == pl); TMP_MARK(marker); N = pl * BITS_PER_MP_LIMB; @@ -620,25 +640,31 @@ mpn_mul_fft (mp_ptr op, mp_size_t pl, for (i = 0; i <= k; i++) _fft_l[i] = TMP_ALLOC_TYPE (1<BITS_PER_MP_LIMB) ? K : BITS_PER_MP_LIMB; Nprime = ((2 * M + k + 2 + maxLK) / maxLK) * maxLK; /* ceil((2*M+k+3)/maxLK)*maxLK; */ nprime = Nprime / BITS_PER_MP_LIMB; + /* with B := BITS_PER_MP_LIMB, nprime >= 2*M/B = 2*N/(K*B) = 2*pl/K = 2*l */ TRACE (printf ("N=%d K=%d, M=%d, l=%d, maxLK=%d, Np=%d, np=%d\n", N, K, M, l, maxLK, Nprime, nprime)); + /* we should ensure that recursively, nprime is a multiple of the next K */ if (nprime >= (sqr ? SQR_FFT_MODF_THRESHOLD : MUL_FFT_MODF_THRESHOLD)) { - maxLK = (1 << mpn_fft_best_k (nprime,n == m)) * BITS_PER_MP_LIMB; - if (Nprime % maxLK) - { - Nprime = ((Nprime / maxLK) + 1) * maxLK; - nprime = Nprime / BITS_PER_MP_LIMB; - } + unsigned long K2; + while (nprime % (K2 = 1 << mpn_fft_best_k (nprime, sqr))) + { + nprime = ((nprime + K2 - 1) / K2) * K2; + Nprime = nprime * BITS_PER_MP_LIMB; + /* warning: since nprime changed, K2 may change too! */ + } TRACE (printf ("new maxLK=%d, Np=%d, np=%d\n", maxLK, Nprime, nprime)); + ASSERT(nprime % K2 == 0); } + ASSERT_ALWAYS (nprime < pl); /* otherwise we'll loop */ T = TMP_ALLOC_LIMBS (nprime + 1); Mp = Nprime/K; diff --git a/src/gmp/mpn/ia64/add_n.asm b/src/gmp/mpn/ia64/add_n.asm index 54333233c..6d10e08c1 100644 --- a/src/gmp/mpn/ia64/add_n.asm +++ b/src/gmp/mpn/ia64/add_n.asm @@ -30,7 +30,7 @@ C n = r35 C cycles/limb C Itanium: 6 -C Itanium 2: ? +C Itanium 2: 3 ASM_START() diff --git a/src/gmp/mpn/ia64/addmul_1.asm b/src/gmp/mpn/ia64/addmul_1.asm index c2eb292fa..d337c1e7d 100644 --- a/src/gmp/mpn/ia64/addmul_1.asm +++ b/src/gmp/mpn/ia64/addmul_1.asm @@ -30,7 +30,7 @@ C v = r35 C cycles/limb C Itanium: 4 -C Itanium 2: ? +C Itanium 2: 7 C The full speed is reached C only for really huge operands. See README for C possible improvements. diff --git a/src/gmp/mpn/ia64/mul_1.asm b/src/gmp/mpn/ia64/mul_1.asm index 0e423453e..e201c9921 100644 --- a/src/gmp/mpn/ia64/mul_1.asm +++ b/src/gmp/mpn/ia64/mul_1.asm @@ -30,7 +30,7 @@ C v = r35 C cycles/limb C Itanium: 4 -C Itanium 2: ? +C Itanium 2: 6 C The full speed is reached C only for really huge operands. See README for C possible improvements. diff --git a/src/gmp/mpn/ia64/popcount.asm b/src/gmp/mpn/ia64/popcount.asm index 8f6b7f6ce..ef3f9d962 100644 --- a/src/gmp/mpn/ia64/popcount.asm +++ b/src/gmp/mpn/ia64/popcount.asm @@ -48,6 +48,7 @@ PROLOGUE(mpn_popcount) .L0: mov ar.lc = r23 ;; br.cloop.dptk .L1 ;; + mov ar.lc = r2 br.ret.sptk.many b0 ;; .L1: ld8 r16 = [r32], 8 ;; ld8 r17 = [r32], 8 ;; @@ -94,6 +95,7 @@ PROLOGUE(mpn_popcount) add r23 = r23, r22 ;; add r8 = r8, r21 ;; add r8 = r8, r23 + mov ar.lc = r2 br.ret.sptk.many b0 .Ldone1: @@ -106,6 +108,6 @@ PROLOGUE(mpn_popcount) add r8 = r8, r21 ;; add r8 = r8, r23 mov ar.lc = r2 - br.ret.sptk.many b0 + br.ret.sptk.many b0 EPILOGUE(mpn_popcount) ASM_END() diff --git a/src/gmp/mpn/ia64/sub_n.asm b/src/gmp/mpn/ia64/sub_n.asm index c0b7e6f3f..74f301e52 100644 --- a/src/gmp/mpn/ia64/sub_n.asm +++ b/src/gmp/mpn/ia64/sub_n.asm @@ -30,7 +30,7 @@ C n = r35 C cycles/limb C Itanium: 6 -C Itanium 2: ? +C Itanium 2: 3 ASM_START() diff --git a/src/gmp/mpn/m68k/README b/src/gmp/mpn/m68k/README index f2ad01283..d7ee8c67d 100644 --- a/src/gmp/mpn/m68k/README +++ b/src/gmp/mpn/m68k/README @@ -1,4 +1,4 @@ -Copyright 2001 Free Software Foundation, Inc. +Copyright 2001, 2003, 2004 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -29,14 +29,55 @@ This directory contains mpn functions for various m68k family chips. CODE ORGANIZATION - m68k m68000, m68010 - m68k/mc68020 m68020 and up, including CPU32 + m68k m68000, m68010, m68060 + m68k/mc68020 m68020, m68030, m68040, and CPU32 The m5200 "coldfire", which is m68000 less a few instructions, currently has no assembler code support. +STATUS + +The code herein is old and poorly maintained. If somebody really cared, it +could be optimized substantially. For example, + +* mpn_add_n and mpn_sub_n could, with more unrolling be improved from 6 to + close to 4 c/l (on m68040). + +* The multiplication loops could be sped up by using the FPU. + +* mpn_lshift by 31 should use the special-case mpn_rshift by 1 code, and + vice versa mpn_rshift by 31 use the special lshift by 1, when operand + overlap permits. + +* On 68000, mpn_mul_1, mpn_addmul_1 and mpn_submul_1 could check for a + 16-bit multiplier and use two multiplies per limb, not four. + + Similarly various other _1 operations like mpn_mod_1, mpn_divrem_1, + mpn_divexact_1, mpn_modexact_1c_odd. + +* On 68000, mpn_lshift and mpn_rshift could use a roll and mask instead of + lsrl and lsll. This promises to be a speedup, effectively trading a 6+2*n + shift for one or two 4 cycle masks. Suggested by Jean-Charles Meyrignac. + +* config.guess detects 68000, 68010, CPU32 and 68020 by running some code, + but relies on system information for 030, 040 and 060. Can they be + identified by running some code? Currently this only makes a difference + to the compiler options selected, since we have no specific asm code for + those chips. + +One novel idea for 68000 would be to use a 16-bit limb instead of 32-bits. +This would suit the native 16x16 multiply, but might make it difficult to +get full value from the native 32x32 add/sub/etc. This would be an ABI +option, and would select "__GMP_SHORT_LIMB" in gmp.h. + +Naturally an entirely new set of asm subroutines would be needed for a +16-bit limb. Also there's various places in the C code assuming limb>=long, +which would need to be updated, eg. mpz_set_ui. Some of the nails changes +may have helped cover some of this. + + ASM FILES The .asm files are put through m4 for macro processing, and with the help of @@ -48,12 +89,11 @@ instance has things like $ for immediates on CRDS or reversed cmp order for AT&T SGS. These could probably be handled if anyone really needs it. - REFERENCES "Motorola M68000 Family Programmer's Reference Manual", available online, - http://e-www.motorola.com/collateral/M68000PM.pdf + http://e-www.motorola.com/brdata/PDFDB/docs/M68000PM.pdf "System V Application Binary Interface: Motorola 68000 Processor Family Supplement", AT&T, 1990, ISBN 0-13-877553-6. Has details of calling diff --git a/src/gmp/mpn/m68k/aors_n.asm b/src/gmp/mpn/m68k/aors_n.asm index c4ef26722..173e912dd 100644 --- a/src/gmp/mpn/m68k/aors_n.asm +++ b/src/gmp/mpn/m68k/aors_n.asm @@ -1,10 +1,7 @@ dnl mc68020 mpn_add_n, mpn_sub_n -- add or subtract limb vectors -dnl -dnl cycles/limb -dnl 68040: 4.5 -dnl Copyright 1992, 1994, 1996, 1999, 2000, 2001 Free Software Foundation, -dnl Inc. +dnl Copyright 1992, 1994, 1996, 1999, 2000, 2001, 2002, 2003 Free Software +dnl Foundation, Inc. dnl dnl This file is part of the GNU MP Library. dnl @@ -25,6 +22,8 @@ dnl Suite 330, Boston, MA 02111-1307, USA. include(`../config.m4') +C cycles/limb +C 68040: 6 ifdef(`OPERATION_add_n',` define(M4_inst, addxl) @@ -42,8 +41,8 @@ MULFUNC_PROLOGUE(mpn_addmul_1 mpn_submul_1) C INPUT PARAMETERS C res_ptr (sp + 4) C s1_ptr (sp + 8) -C s2_ptr (sp + 16) -C size (sp + 12) +C s2_ptr (sp + 12) +C size (sp + 16) PROLOGUE(M4_function_n) diff --git a/src/gmp/mpn/m68k/lshift.asm b/src/gmp/mpn/m68k/lshift.asm index b22113dfa..596b971f4 100644 --- a/src/gmp/mpn/m68k/lshift.asm +++ b/src/gmp/mpn/m68k/lshift.asm @@ -4,7 +4,8 @@ dnl cycles/limb dnl shift==1 shift>1 dnl 68040: 3.5 9.5 -dnl Copyright 1996, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +dnl Copyright 1996, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, +dnl Inc. dnl dnl This file is part of the GNU MP Library. dnl @@ -29,8 +30,8 @@ include(`../config.m4') C INPUT PARAMETERS C res_ptr (sp + 4) C s_ptr (sp + 8) -C s_size (sp + 16) -C cnt (sp + 12) +C s_size (sp + 12) +C cnt (sp + 16) define(res_ptr, `a1') define(s_ptr, `a0') diff --git a/src/gmp/mpn/m68k/mc68020/aorsmul_1.asm b/src/gmp/mpn/m68k/mc68020/aorsmul_1.asm index 9877a2e3b..02df945fc 100644 --- a/src/gmp/mpn/m68k/mc68020/aorsmul_1.asm +++ b/src/gmp/mpn/m68k/mc68020/aorsmul_1.asm @@ -1,10 +1,7 @@ dnl mc68020 mpn_addmul_1, mpn_submul_1 -- add or subtract mpn multiple. -dnl -dnl cycles/limb -dnl 68040: 20.5 -dnl Copyright 1992, 1994, 1996, 1999, 2000, 2001 Free Software Foundation, -dnl Inc. +dnl Copyright 1992, 1994, 1996, 1999, 2000, 2001, 2002 Free Software +dnl Foundation, Inc. dnl dnl This file is part of the GNU MP Library. dnl @@ -25,6 +22,8 @@ dnl Suite 330, Boston, MA 02111-1307, USA. include(`../config.m4') +C cycles/limb +C 68040: 25 ifdef(`OPERATION_addmul_1',` define(M4_inst, addl) diff --git a/src/gmp/mpn/m68k/mc68020/mul_1.asm b/src/gmp/mpn/m68k/mc68020/mul_1.asm index 9192fb4f8..bb6c0bd8c 100644 --- a/src/gmp/mpn/m68k/mc68020/mul_1.asm +++ b/src/gmp/mpn/m68k/mc68020/mul_1.asm @@ -1,10 +1,7 @@ dnl mc68020 mpn_mul_1 -- mpn by limb multiply -dnl -dnl cycles/limb -dnl 68040: 19.5 -dnl Copyright 1992, 1994, 1996, 1999, 2000, 2001 Free Software Foundation, -dnl Inc. +dnl Copyright 1992, 1994, 1996, 1999, 2000, 2001, 2002 Free Software +dnl Foundation, Inc. dnl dnl This file is part of the GNU MP Library. dnl @@ -25,6 +22,8 @@ dnl Suite 330, Boston, MA 02111-1307, USA. include(`../config.m4') +C cycles/limb +C 68040: 24 C INPUT PARAMETERS C res_ptr (sp + 4) diff --git a/src/gmp/mpn/m68k/rshift.asm b/src/gmp/mpn/m68k/rshift.asm index a7250eee8..d9eabc9ab 100644 --- a/src/gmp/mpn/m68k/rshift.asm +++ b/src/gmp/mpn/m68k/rshift.asm @@ -4,7 +4,8 @@ dnl cycles/limb dnl shift==1 shift>1 dnl 68040: 7.0 9.5 -dnl Copyright 1996, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +dnl Copyright 1996, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, +dnl Inc. dnl dnl This file is part of the GNU MP Library. dnl @@ -29,8 +30,8 @@ include(`../config.m4') C INPUT PARAMETERS C res_ptr (sp + 4) C s_ptr (sp + 8) -C s_size (sp + 16) -C cnt (sp + 12) +C s_size (sp + 12) +C cnt (sp + 16) define(res_ptr, `a1') define(s_ptr, `a0') diff --git a/src/gmp/mpn/m68k/t-m68k-defs.pl b/src/gmp/mpn/m68k/t-m68k-defs.pl index 1fe95eb90..35ec99dd0 100644 --- a/src/gmp/mpn/m68k/t-m68k-defs.pl +++ b/src/gmp/mpn/m68k/t-m68k-defs.pl @@ -1,6 +1,6 @@ #! /usr/bin/perl -w -# Copyright 2001 Free Software Foundation, Inc. +# Copyright 2001, 2003 Free Software Foundation, Inc. # # This file is part of the GNU MP Library. # @@ -40,8 +40,8 @@ open(FD, ") { - if (/^m68k_defbranch\(\s*(.*)\)/) { %branch->{"b".$1}=1; } - if (/^m68k_definsn\(\s*(.*),\s*(.*)\)/) { %insn->{$1.$2}=1; } + if (/^m68k_defbranch\(\s*(.*)\)/) { $branch{"b".$1} = 1; } + if (/^m68k_definsn\(\s*(.*),\s*(.*)\)/) { $insn{$1.$2} = 1; } } close(FD); @@ -62,8 +62,8 @@ foreach my $file (glob("*.asm"), glob("*/*.asm")) { # instructions with an l, w or b suffix should have a definsn # (unless they're already a defbranch) if ($opcode =~ /[lwb]$/ - && ! defined %insn->{$opcode} - && ! defined %branch->{$opcode}) + && ! defined $insn{$opcode} + && ! defined $branch{$opcode}) { print "$file: $.: missing m68k_definsn: $opcode\n"; } @@ -71,8 +71,8 @@ foreach my $file (glob("*.asm"), glob("*/*.asm")) { # instructions bXX should have a defbranch (unless they're # already a definsn) if ($opcode =~ /^b/ - && ! defined %insn->{$opcode} - && ! defined %branch->{$opcode}) + && ! defined $insn{$opcode} + && ! defined $branch{$opcode}) { print "$file: $.: missing m68k_defbranch: $opcode\n"; } diff --git a/src/gmp/mpn/m88k/README b/src/gmp/mpn/m88k/README new file mode 100644 index 000000000..b79df28bc --- /dev/null +++ b/src/gmp/mpn/m88k/README @@ -0,0 +1,52 @@ +Copyright 2003 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 Lesser General Public License as published by +the Free Software Foundation; either version 2.1 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 Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser 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. + + + + + + M88K MPN SUBROUTINES + +This directory contains mpn functions for various m88k family chips. + +CODE ORGANIZATION + + m88k m88000, m88100 + m88k/mc88110 m88110 + +STATUS + +The code herein is old and poorly maintained. + +* The .s files assume the system uses a "_" underscore prefix, which + should be controlled by configure. + +* The mc88110/*.S files are using the defunct "sysdep.h" configuration + scheme and won't compile. + +Conversion to the current m4 .asm style wouldn't be difficult. + + + + +---------------- +Local variables: +mode: text +fill-column: 76 +End: diff --git a/src/gmp/mpn/pa64/add_n.asm b/src/gmp/mpn/pa64/add_n.asm index 9ad578974..f55bd4609 100644 --- a/src/gmp/mpn/pa64/add_n.asm +++ b/src/gmp/mpn/pa64/add_n.asm @@ -1,7 +1,7 @@ dnl HP-PA 2.0 mpn_add_n -- Add two limb vectors of the same length > 0 and dnl store sum in a third limb vector. -dnl Copyright 1997, 2000, 2002 Free Software Foundation, Inc. +dnl Copyright 1997, 2000, 2002, 2003 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. @@ -35,8 +35,8 @@ define(`vp',`%r24') define(`n',`%r23') ifdef(`HAVE_ABI_2_0w', -` .level 2.0W -',` .level 2.0N +` .level 2.0w +',` .level 2.0 ') PROLOGUE(mpn_add_n) sub %r0, n, %r22 diff --git a/src/gmp/mpn/pa64/addmul_1.asm b/src/gmp/mpn/pa64/addmul_1.asm index 516e25729..bb43aaed9 100644 --- a/src/gmp/mpn/pa64/addmul_1.asm +++ b/src/gmp/mpn/pa64/addmul_1.asm @@ -1,7 +1,7 @@ dnl HP-PA 2.0 64-bit mpn_addmul_1 -- Multiply a limb vector with a limb and dnl add the result to a second limb vector. -dnl Copyright 1998, 1999, 2000, 2002 Free Software Foundation, Inc. +dnl Copyright 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. @@ -96,8 +96,8 @@ define(`vlimb',`%r23') dnl define(`climb',`%r23') dnl ifdef(`HAVE_ABI_2_0w', -` .level 2.0W -',` .level 2.0N +` .level 2.0w +',` .level 2.0 ') PROLOGUE(mpn_addmul_1) diff --git a/src/gmp/mpn/pa64/lshift.asm b/src/gmp/mpn/pa64/lshift.asm index 34a06ba3e..411a9eeaf 100644 --- a/src/gmp/mpn/pa64/lshift.asm +++ b/src/gmp/mpn/pa64/lshift.asm @@ -1,6 +1,6 @@ dnl HP-PA 2.0 mpn_lshift -- Left shift. -dnl Copyright 1997, 2000, 2002 Free Software Foundation, Inc. +dnl Copyright 1997, 2000, 2002, 2003 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. @@ -31,8 +31,8 @@ define(`n',`%r24') define(`cnt',`%r23') ifdef(`HAVE_ABI_2_0w', -` .level 2.0W -',` .level 2.0N +` .level 2.0w +',` .level 2.0 ') PROLOGUE(mpn_lshift) shladd n, 3, up, up diff --git a/src/gmp/mpn/pa64/mul_1.asm b/src/gmp/mpn/pa64/mul_1.asm index 22b067f88..9be43860c 100644 --- a/src/gmp/mpn/pa64/mul_1.asm +++ b/src/gmp/mpn/pa64/mul_1.asm @@ -1,7 +1,7 @@ dnl HP-PA 2.0 64-bit mpn_mul_1 -- Multiply a limb vector with a limb and store dnl the result in a second limb vector. -dnl Copyright 1998, 1999, 2000, 2002 Free Software Foundation, Inc. +dnl Copyright 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. @@ -94,8 +94,8 @@ define(`vlimb',`%r23') dnl define(`climb',`%r23') dnl ifdef(`HAVE_ABI_2_0w', -` .level 2.0W -',` .level 2.0N +` .level 2.0w +',` .level 2.0 ') PROLOGUE(mpn_mul_1) diff --git a/src/gmp/mpn/pa64/rshift.asm b/src/gmp/mpn/pa64/rshift.asm index 6e7b67075..ff75907dd 100644 --- a/src/gmp/mpn/pa64/rshift.asm +++ b/src/gmp/mpn/pa64/rshift.asm @@ -1,6 +1,6 @@ dnl HP-PA 2.0 mpn_rshift -- Right shift. -dnl Copyright 1997, 2000, 2002 Free Software Foundation, Inc. +dnl Copyright 1997, 2000, 2002, 2003 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. @@ -31,8 +31,8 @@ define(`n',`%r24') define(`cnt',`%r23') ifdef(`HAVE_ABI_2_0w', -` .level 2.0W -',` .level 2.0N +` .level 2.0w +',` .level 2.0 ') PROLOGUE(mpn_rshift) mtsar cnt diff --git a/src/gmp/mpn/pa64/sqr_diagonal.asm b/src/gmp/mpn/pa64/sqr_diagonal.asm index 838869279..1d41a4841 100644 --- a/src/gmp/mpn/pa64/sqr_diagonal.asm +++ b/src/gmp/mpn/pa64/sqr_diagonal.asm @@ -1,6 +1,6 @@ dnl HP-PA 2.0 64-bit mpn_sqr_diagonal. -dnl Copyright 2001, 2002 Free Software Foundation, Inc. +dnl Copyright 2001, 2002, 2003 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. @@ -38,12 +38,10 @@ define(`t0',`%r19') define(`t1',`%r20') ifdef(`HAVE_ABI_2_0w', -` .level 2.0W -',` .level 2.0N +` .level 2.0w +',` .level 2.0 ') PROLOGUE(mpn_sqr_diagonal) - .proc - .entry ldo 128(%r30),%r30 fldds,ma 8(up),%fr8 @@ -177,5 +175,4 @@ L(end1) xmpyu %fr8l,%fr8r,%fr10 std p64,-8(rp) bve (%r2) ldo -128(%r30),%r30 - .procend EPILOGUE(mpn_sqr_diagonal) diff --git a/src/gmp/mpn/pa64/sub_n.asm b/src/gmp/mpn/pa64/sub_n.asm index 0f28bd54a..16dc8db59 100644 --- a/src/gmp/mpn/pa64/sub_n.asm +++ b/src/gmp/mpn/pa64/sub_n.asm @@ -1,7 +1,7 @@ dnl HP-PA 2.0 mpn_sub_n -- Subtract two limb vectors of the same length > 0 dnl and store difference in a third limb vector. -dnl Copyright 1997, 2000, 2002 Free Software Foundation, Inc. +dnl Copyright 1997, 2000, 2002, 2003 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. @@ -35,8 +35,8 @@ define(`vp',`%r24') define(`n',`%r23') ifdef(`HAVE_ABI_2_0w', -` .level 2.0W -',` .level 2.0N +` .level 2.0w +',` .level 2.0 ') PROLOGUE(mpn_sub_n) sub %r0, n, %r22 @@ -77,7 +77,7 @@ L(2) ldd 48(up), %r20 std %r20, 48(rp) L(1) ldd 56(up), %r21 ldd 56(vp),%r19 - sub, db %r21, %r19, %r21 + sub,db %r21, %r19, %r21 ldo 64(up), up std %r21, 56(rp) ldo 64(vp), vp diff --git a/src/gmp/mpn/pa64/submul_1.asm b/src/gmp/mpn/pa64/submul_1.asm index cc10cb84f..df46b8ef5 100644 --- a/src/gmp/mpn/pa64/submul_1.asm +++ b/src/gmp/mpn/pa64/submul_1.asm @@ -1,7 +1,7 @@ dnl HP-PA 2.0 64-bit mpn_submul_1 -- Multiply a limb vector with a limb and dnl subtract the result from a second limb vector. -dnl Copyright 1998, 1999, 2000, 2002 Free Software Foundation, Inc. +dnl Copyright 1998, 1999, 2000, 2002, 2003 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. @@ -94,8 +94,8 @@ define(`vlimb',`%r23') dnl define(`climb',`%r23') dnl ifdef(`HAVE_ABI_2_0w', -` .level 2.0W -',` .level 2.0N +` .level 2.0w +',` .level 2.0 ') PROLOGUE(mpn_submul_1) diff --git a/src/gmp/mpn/pa64/udiv_qrnnd.asm b/src/gmp/mpn/pa64/udiv_qrnnd.asm index 85b431345..0d73649ef 100644 --- a/src/gmp/mpn/pa64/udiv_qrnnd.asm +++ b/src/gmp/mpn/pa64/udiv_qrnnd.asm @@ -1,6 +1,6 @@ dnl HP-PA 2.0 64-bit mpn_udiv_qrnnd. -dnl Copyright 2001, 2002 Free Software Foundation, Inc. +dnl Copyright 2001, 2002, 2003 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. @@ -49,13 +49,10 @@ define(`divstep', ') ifdef(`HAVE_ABI_2_0w', -` .level 2.0W -',` .level 2.0N +` .level 2.0w +',` .level 2.0 ') PROLOGUE(mpn_udiv_qrnnd) - .proc - .entry - .callinfo frame=0,no_calls,save_rp,entry_gr=7 ifdef(`HAVE_ABI_2_0n', ` depd %r25,31,32,%r26 @@ -116,5 +113,4 @@ ifdef(`HAVE_ABI_2_0n', bve (%r2) std n1,0(remptr) C store remainder - .procend EPILOGUE(mpn_udiv_qrnnd) diff --git a/src/gmp/mpn/pa64/umul_ppmm.asm b/src/gmp/mpn/pa64/umul_ppmm.asm index 6e1b4e129..8947838c1 100644 --- a/src/gmp/mpn/pa64/umul_ppmm.asm +++ b/src/gmp/mpn/pa64/umul_ppmm.asm @@ -1,4 +1,4 @@ -dnl Copyright 1999, 2000, 2002 Free Software Foundation, Inc. +dnl Copyright 1999, 2000, 2002, 2003 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. @@ -36,8 +36,8 @@ define(`m0',`%r23') define(`m1',`%r24') ifdef(`HAVE_ABI_2_0w', -` .level 2.0W -',` .level 2.0N +` .level 2.0w +',` .level 2.0 ') PROLOGUE(mpn_umul_ppmm) ldo 128(%r30),%r30 diff --git a/src/gmp/randlc2x.c b/src/gmp/randlc2x.c index f9d73c8ba..386067670 100644 --- a/src/gmp/randlc2x.c +++ b/src/gmp/randlc2x.c @@ -2,7 +2,7 @@ state STATE for a linear congruential generator with multiplier A, adder C, and modulus 2 ^ M2EXP. -Copyright 2000, 2002 Free Software Foundation, Inc. +Copyright 2000, 2002, 2004 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -37,7 +37,11 @@ gmp_randinit_lc_2exp (gmp_randstate_t rstate, rstate->_mp_algdata._mp_lc = (__gmp_randata_lc *) (*__gmp_allocate_func) (sizeof (__gmp_randata_lc)); - mpz_init_set (rstate->_mp_algdata._mp_lc->_mp_a, a); + mpz_init (rstate->_mp_algdata._mp_lc->_mp_a); + mpz_fdiv_r_2exp (rstate->_mp_algdata._mp_lc->_mp_a, a, m2exp); + + if (m2exp < BITS_PER_ULONG) + c &= ((1L << m2exp) - 1); rstate->_mp_algdata._mp_lc->_mp_c = c; /* Cover weird case where m2exp is 0, which means that m is used diff --git a/src/gmp/randraw.c b/src/gmp/randraw.c index 43dade379..d88d96ecb 100644 --- a/src/gmp/randraw.c +++ b/src/gmp/randraw.c @@ -2,7 +2,7 @@ length NBITS in RP. RP must have enough space allocated to hold NBITS. -Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +Copyright 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -98,6 +98,17 @@ lc (mp_ptr rp, gmp_randstate_t rstate) mp_limb_t c; TMP_DECL (mark); + /* Zero out the limbs _gmp_rand below expects us to write. This is a hack + to cover the seedn==0 case, and in case tn < cn due to small "a" and + seed. (Incidentally, the "return m2exp" for the seedn==0 case is + bogus, _gmp_rand ignores the return, it expects and looks at just + "m2exp/2" always.) */ + { + int chunk_nbits = rstate->_mp_algdata._mp_lc->_mp_m2exp / 2; + mp_size_t cn = (chunk_nbits + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS; + MPN_ZERO (rp, cn); + } + m2exp = rstate->_mp_algdata._mp_lc->_mp_m2exp; /* The code below assumes the mod part is a power of two. Make sure @@ -109,20 +120,30 @@ lc (mp_ptr rp, gmp_randstate_t rstate) seedp = PTR (rstate->_mp_seed); seedn = SIZ (rstate->_mp_seed); - if (seedn == 0) + ap = PTR (rstate->_mp_algdata._mp_lc->_mp_a); + an = SIZ (rstate->_mp_algdata._mp_lc->_mp_a); + + if (seedn == 0 || an == 0) { /* Seed is 0. Result is C % M. Assume table is sensibly stored, with C smaller than M*/ *rp = c; + /* Discard the lower m2exp/2 bits of result. */ + { + unsigned long int bits = m2exp / 2; + mp_size_t xn = bits / GMP_NUMB_BITS; + if (bits >= GMP_LIMB_BITS) + *rp = 0; + else + *rp >>= bits; + } + *seedp = c; SIZ (rstate->_mp_seed) = 1; return m2exp; } - ap = PTR (rstate->_mp_algdata._mp_lc->_mp_a); - an = SIZ (rstate->_mp_algdata._mp_lc->_mp_a); - /* Allocate temporary storage. Let there be room for calculation of (A * seed + C) % M, or M if bigger than that. */ @@ -141,11 +162,12 @@ lc (mp_ptr rp, gmp_randstate_t rstate) tp[tn] = 0; /* sentinel, stops MPN_INCR_U */ MPN_INCR_U (tp, tn, c); - ASSERT_ALWAYS (m2exp / GMP_NUMB_BITS < ta); - + if (tn > m2exp / GMP_NUMB_BITS) + { /* t = t % m */ tp[m2exp / GMP_NUMB_BITS] &= ((mp_limb_t) 1 << m2exp % GMP_NUMB_BITS) - 1; tn = (m2exp + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS; + } /* Save result as next seed. */ MPN_COPY (PTR (rstate->_mp_seed), tp, tn); diff --git a/src/gmp/randsd.c b/src/gmp/randsd.c index 40d16c5a5..75f90d10d 100644 --- a/src/gmp/randsd.c +++ b/src/gmp/randsd.c @@ -1,7 +1,7 @@ /* gmp_randseed (state, seed) -- Set initial seed SEED in random state STATE. -Copyright 2000 Free Software Foundation, Inc. +Copyright 2000, 2004 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -27,5 +27,7 @@ void gmp_randseed (gmp_randstate_t rstate, mpz_srcptr seed) { - mpz_set (rstate->_mp_seed, seed); + mpz_fdiv_r_2exp (rstate->_mp_seed, seed, + rstate->_mp_algdata._mp_lc->_mp_m2exp); + } diff --git a/src/gmp/stamp-vti b/src/gmp/stamp-vti index 7f2451b07..6e1315c35 100644 --- a/src/gmp/stamp-vti +++ b/src/gmp/stamp-vti @@ -1,4 +1,4 @@ -@set UPDATED 20 December 2002 -@set UPDATED-MONTH December 2002 -@set EDITION 4.1.2 -@set VERSION 4.1.2 +@set UPDATED 21 September 2004 +@set UPDATED-MONTH September 2004 +@set EDITION 4.1.4 +@set VERSION 4.1.4 diff --git a/src/gmp/texinfo.tex b/src/gmp/texinfo.tex index df62a127b..d93d432f3 100644 --- a/src/gmp/texinfo.tex +++ b/src/gmp/texinfo.tex @@ -3,10 +3,11 @@ % Load plain if necessary, i.e., if running under initex. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % -\def\texinfoversion{2002-03-26.08} +\def\texinfoversion{2004-04-07.08} % -% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, -% 2000, 01, 02 Free Software Foundation, Inc. +% Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, +% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software +% Foundation, Inc. % % This texinfo.tex file is free software; you can redistribute it and/or % modify it under the terms of the GNU General Public License as @@ -23,24 +24,17 @@ % to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, % Boston, MA 02111-1307, USA. % -% In other words, you are welcome to use, share and improve this program. -% You are forbidden to forbid anyone else to use, share and improve -% what you give them. Help stamp out software-hoarding! -% +% As a special exception, when this file is read by TeX when processing +% a Texinfo source document, you may use the result without +% restriction. (This has been our intent since Texinfo was invented.) +% % Please try the latest version of texinfo.tex before submitting bug % reports; you can get the latest version from: -% ftp://ftp.gnu.org/gnu/texinfo.tex -% (and all GNU mirrors, see http://www.gnu.org/order/ftp.html) -% ftp://texinfo.org/texinfo/texinfo.tex +% http://www.gnu.org/software/texinfo/ (the Texinfo home page), or % ftp://tug.org/tex/texinfo.tex -% (and all CTAN mirrors, see http://www.ctan.org), -% and /home/gd/gnu/doc/texinfo.tex on the GNU machines. -% -% The texinfo.tex in any given Texinfo distribution could well be out +% (and all CTAN mirrors, see http://www.ctan.org). +% The texinfo.tex in any given distribution could well be out % of date, so if that's what you're using, please check. -% -% Texinfo has a small home page at http://texinfo.org/ and also -% http://www.gnu.org/software/texinfo. % % Send bug reports to bug-texinfo@gnu.org. Please include including a % complete document in each bug report with which we can reproduce the @@ -58,8 +52,12 @@ % Sometimes one run after texindex suffices, and sometimes you need more % than two; texi2dvi does it as many times as necessary. % -% It is possible to adapt texinfo.tex for other languages. You can get -% the existing language-specific files from the full Texinfo distribution. +% It is possible to adapt texinfo.tex for other languages, to some +% extent. You can get the existing language-specific files from the +% full Texinfo distribution. +% +% The GNU Texinfo home page is http://www.gnu.org/software/texinfo. + \message{Loading texinfo [version \texinfoversion]:} @@ -69,7 +67,14 @@ \everyjob{\message{[Texinfo version \texinfoversion]}% \catcode`+=\active \catcode`\_=\active} -% Save some parts of plain tex whose names we will redefine. +\message{Basics,} +\chardef\other=12 + +% We never want plain's \outer definition of \+ in Texinfo. +% For @tex, we can use \tabalign. +\let\+ = \relax + +% Save some plain tex macros whose names we will redefine. \let\ptexb=\b \let\ptexbullet=\bullet \let\ptexc=\c @@ -79,23 +84,34 @@ \let\ptexend=\end \let\ptexequiv=\equiv \let\ptexexclam=\! +\let\ptexfootnote=\footnote +\let\ptexgtr=> +\let\ptexhat=^ \let\ptexi=\i +\let\ptexindent=\indent +\let\ptexnoindent=\noindent +\let\ptexinsert=\insert \let\ptexlbrace=\{ +\let\ptexless=< +\let\ptexplus=+ \let\ptexrbrace=\} +\let\ptexslash=\/ \let\ptexstar=\* \let\ptext=\t -% We never want plain's outer \+ definition in Texinfo. -% For @tex, we can use \tabalign. -\let\+ = \relax - -\message{Basics,} -\chardef\other=12 - % If this character appears in an error message or help string, it % starts a new line in the output. \newlinechar = `^^J +% Use TeX 3.0's \inputlineno to get the line number, for better error +% messages, but if we're using an old version of TeX, don't do anything. +% +\ifx\inputlineno\thisisundefined + \let\linenumber = \empty % Pre-3.0. +\else + \def\linenumber{l.\the\inputlineno:\space} +\fi + % Set up fixed words for English if not already set. \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi @@ -134,48 +150,111 @@ \ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi \ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi \ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi -\ifx\putwordDeftypevar\undefined\gdef\putwordDeftypevar{Variable}\fi \ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi -\ifx\putwordDeftypefun\undefined\gdef\putwordDeftypefun{Function}\fi + +% In some macros, we cannot use the `\? notation---the left quote is +% in some cases the escape char. +\chardef\colonChar = `\: +\chardef\commaChar = `\, +\chardef\dotChar = `\. +\chardef\exclamChar= `\! +\chardef\questChar = `\? +\chardef\semiChar = `\; +\chardef\underChar = `\_ + +\chardef\spaceChar = `\ % +\chardef\spacecat = 10 +\def\spaceisspace{\catcode\spaceChar=\spacecat} % Ignore a token. % \def\gobble#1{} -\hyphenation{ap-pen-dix} -\hyphenation{mini-buf-fer mini-buf-fers} -\hyphenation{eshell} -\hyphenation{white-space} +% The following is used inside several \edef's. +\def\makecsname#1{\expandafter\noexpand\csname#1\endcsname} + +% Hyphenation fixes. +\hyphenation{ + Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script + ap-pen-dix bit-map bit-maps + data-base data-bases eshell fall-ing half-way long-est man-u-script + man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm + par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces + spell-ing spell-ings + stand-alone strong-est time-stamp time-stamps which-ever white-space + wide-spread wrap-around +} % Margin to add to right of even pages, to left of odd pages. -\newdimen \bindingoffset -\newdimen \normaloffset +\newdimen\bindingoffset +\newdimen\normaloffset \newdimen\pagewidth \newdimen\pageheight +% For a final copy, take out the rectangles +% that mark overfull boxes (in case you have decided +% that the text looks ok even though it passes the margin). +% +\def\finalout{\overfullrule=0pt} + +% @| inserts a changebar to the left of the current line. It should +% surround any changed text. This approach does *not* work if the +% change spans more than two lines of output. To handle that, we would +% have adopt a much more difficult approach (putting marks into the main +% vertical list for the beginning and end of each change). +% +\def\|{% + % \vadjust can only be used in horizontal mode. + \leavevmode + % + % Append this vertical mode material after the current line in the output. + \vadjust{% + % We want to insert a rule with the height and depth of the current + % leading; that is exactly what \strutbox is supposed to record. + \vskip-\baselineskip + % + % \vadjust-items are inserted at the left edge of the type. So + % the \llap here moves out into the left-hand margin. + \llap{% + % + % For a thicker or thinner bar, change the `1pt'. + \vrule height\baselineskip width1pt + % + % This is the space between the bar and the text. + \hskip 12pt + }% + }% +} + % Sometimes it is convenient to have everything in the transcript file % and nothing on the terminal. We don't just call \tracingall here, -% since that produces some useless output on the terminal. +% since that produces some useless output on the terminal. We also make +% some effort to order the tracing commands to reduce output in the log +% file; cf. trace.sty in LaTeX. % \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% -\ifx\eTeXversion\undefined -\def\loggingall{\tracingcommands2 \tracingstats2 - \tracingpages1 \tracingoutput1 \tracinglostchars1 - \tracingmacros2 \tracingparagraphs1 \tracingrestores1 - \showboxbreadth\maxdimen\showboxdepth\maxdimen +\def\loggingall{% + \tracingstats2 + \tracingpages1 + \tracinglostchars2 % 2 gives us more in etex + \tracingparagraphs1 + \tracingoutput1 + \tracingmacros2 + \tracingrestores1 + \showboxbreadth\maxdimen \showboxdepth\maxdimen + \ifx\eTeXversion\undefined\else % etex gives us more logging + \tracingscantokens1 + \tracingifs1 + \tracinggroups1 + \tracingnesting2 + \tracingassigns1 + \fi + \tracingcommands3 % 3 gives us more in etex + \errorcontextlines16 }% -\else -\def\loggingall{\tracingcommands3 \tracingstats2 - \tracingpages1 \tracingoutput1 \tracinglostchars1 - \tracingmacros2 \tracingparagraphs1 \tracingrestores1 - \tracingscantokens1 \tracingassigns1 \tracingifs1 - \tracinggroups1 \tracingnesting2 - \showboxbreadth\maxdimen\showboxdepth\maxdimen -}% -\fi % add check for \lastpenalty to plain's definitions. If the last thing % we did was a \nobreak, we don't want to insert more space. -% +% \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount \removelastskip\penalty-50\smallskip\fi\fi} \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount @@ -228,7 +307,7 @@ % the page break happens to be in the middle of an example. \shipout\vbox{% % Do this early so pdf references go to the beginning of the page. - \ifpdfmakepagedest \pdfmkdest{\the\pageno} \fi + \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi % \ifcropmarks \vbox to \outervsize\bgroup \hsize = \outerhsize @@ -276,7 +355,7 @@ \egroup % \vbox from first cropmarks clause \fi }% end of \shipout\vbox - }% end of group with \turnoffactive + }% end of group with \normalturnoffactive \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi } @@ -309,143 +388,162 @@ % the input line (except we remove a trailing comment). #1 should be a % macro which expects an ordinary undelimited TeX argument. % -\def\parsearg#1{% - \let\next = #1% +\def\parsearg{\parseargusing{}} +\def\parseargusing#1#2{% + \def\next{#2}% \begingroup \obeylines - \futurelet\temp\parseargx + \spaceisspace + #1% + \parseargline\empty% Insert the \empty token, see \finishparsearg below. } -% If the next token is an obeyed space (from an @example environment or -% the like), remove it and recurse. Otherwise, we're done. -\def\parseargx{% - % \obeyedspace is defined far below, after the definition of \sepspaces. - \ifx\obeyedspace\temp - \expandafter\parseargdiscardspace - \else - \expandafter\parseargline - \fi -} - -% Remove a single space (as the delimiter token to the macro call). -{\obeyspaces % - \gdef\parseargdiscardspace {\futurelet\temp\parseargx}} - {\obeylines % \gdef\parseargline#1^^M{% \endgroup % End of the group started in \parsearg. - % - % First remove any @c comment, then any @comment. - % Result of each macro is put in \toks0. - \argremovec #1\c\relax % - \expandafter\argremovecomment \the\toks0 \comment\relax % - % - % Call the caller's macro, saved as \next in \parsearg. - \expandafter\next\expandafter{\the\toks0}% + \argremovecomment #1\comment\ArgTerm% }% } -% Since all \c{,omment} does is throw away the argument, we can let TeX -% do that for us. The \relax here is matched by the \relax in the call -% in \parseargline; it could be more or less anything, its purpose is -% just to delimit the argument to the \c. -\def\argremovec#1\c#2\relax{\toks0 = {#1}} -\def\argremovecomment#1\comment#2\relax{\toks0 = {#1}} +% First remove any @comment, then any @c comment. +\def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm} +\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm} -% \argremovec{,omment} might leave us with trailing spaces, though; e.g., +% Each occurence of `\^^M' or `\^^M' is replaced by a single space. +% +% \argremovec might leave us with trailing space, e.g., % @end itemize @c foo -% will have two active spaces as part of the argument with the -% `itemize'. Here we remove all active spaces from #1, and assign the -% result to \toks0. +% This space token undergoes the same procedure and is eventually removed +% by \finishparsearg. % -% This loses if there are any *other* active characters besides spaces -% in the argument -- _ ^ +, for example -- since they get expanded. -% Fortunately, Texinfo does not define any such commands. (If it ever -% does, the catcode of the characters in questionwill have to be changed -% here.) But this means we cannot call \removeactivespaces as part of -% \argremovec{,omment}, since @c uses \parsearg, and thus the argument -% that \parsearg gets might well have any character at all in it. -% -\def\removeactivespaces#1{% - \begingroup - \ignoreactivespaces - \edef\temp{#1}% - \global\toks0 = \expandafter{\temp}% - \endgroup +\def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M} +\def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M} +\def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{% + \def\temp{#3}% + \ifx\temp\empty + % We cannot use \next here, as it holds the macro to run; + % thus we reuse \temp. + \let\temp\finishparsearg + \else + \let\temp\argcheckspaces + \fi + % Put the space token in: + \temp#1 #3\ArgTerm } -% Change the active space to expand to nothing. +% If a _delimited_ argument is enclosed in braces, they get stripped; so +% to get _exactly_ the rest of the line, we had to prevent such situation. +% We prepended an \empty token at the very beginning and we expand it now, +% just before passing the control to \next. +% (Similarily, we have to think about #3 of \argcheckspacesY above: it is +% either the null string, or it ends with \^^M---thus there is no danger +% that a pair of braces would be stripped. % -\begingroup +% But first, we have to remove the trailing space token. +% +\def\finishparsearg#1 \ArgTerm{\expandafter\next\expandafter{#1}} + +% \parseargdef\foo{...} +% is roughly equivalent to +% \def\foo{\parsearg\Xfoo} +% \def\Xfoo#1{...} +% +% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my +% favourite TeX trick. --kasal, 16nov03 + +\def\parseargdef#1{% + \expandafter \doparseargdef \csname\string#1\endcsname #1% +} +\def\doparseargdef#1#2{% + \def#2{\parsearg#1}% + \def#1##1% +} + +% Several utility definitions with active space: +{ \obeyspaces - \gdef\ignoreactivespaces{\obeyspaces\let =\empty} -\endgroup + \gdef\obeyedspace{ } + + % Make each space character in the input produce a normal interword + % space in the output. Don't allow a line break at this space, as this + % is used only in environments like @example, where each line of input + % should produce a line of output anyway. + % + \gdef\sepspaces{\obeyspaces\let =\tie} + + % If an index command is used in an @example environment, any spaces + % therein should become regular spaces in the raw index file, not the + % expansion of \tie (\leavevmode \penalty \@M \ ). + \gdef\unsepspaces{\let =\space} +} \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} -%% These are used to keep @begin/@end levels from running away -%% Call \inENV within environments (after a \begingroup) -\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi} -\def\ENVcheck{% -\ifENV\errmessage{Still within an environment; press RETURN to continue} -\endgroup\fi} % This is not perfect, but it should reduce lossage +% Define the framework for environments in texinfo.tex. It's used like this: +% +% \envdef\foo{...} +% \def\Efoo{...} +% +% It's the responsibility of \envdef to insert \begingroup before the +% actual body; @end closes the group after calling \Efoo. \envdef also +% defines \thisenv, so the current environment is known; @end checks +% whether the environment name matches. The \checkenv macro can also be +% used to check whether the current environment is the one expected. +% +% Non-false conditionals (@iftex, @ifset) don't fit into this, so they +% are not treated as enviroments; they don't open a group. (The +% implementation of @end takes care not to call \endgroup in this +% special case.) -% @begin foo is the same as @foo, for now. -\newhelp\EMsimple{Press RETURN to continue.} -\outer\def\begin{\parsearg\beginxxx} +% At runtime, environments start with this: +\def\startenvironment#1{\begingroup\def\thisenv{#1}} +% initialize +\let\thisenv\empty -\def\beginxxx #1{% -\expandafter\ifx\csname #1\endcsname\relax -{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else -\csname #1\endcsname\fi} +% ... but they get defined via ``\envdef\foo{...}'': +\long\def\envdef#1#2{\def#1{\startenvironment#1#2}} +\def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}} -% @end foo executes the definition of \Efoo. -% -\def\end{\parsearg\endxxx} -\def\endxxx #1{% - \removeactivespaces{#1}% - \edef\endthing{\the\toks0}% - % - \expandafter\ifx\csname E\endthing\endcsname\relax - \expandafter\ifx\csname \endthing\endcsname\relax - % There's no \foo, i.e., no ``environment'' foo. - \errhelp = \EMsimple - \errmessage{Undefined command `@end \endthing'}% - \else - \unmatchedenderror\endthing - \fi +% Check whether we're in the right environment: +\def\checkenv#1{% + \def\temp{#1}% + \ifx\thisenv\temp \else - % Everything's ok; the right environment has been started. - \csname E\endthing\endcsname + \badenverr \fi } -% There is an environment #1, but it hasn't been started. Give an error. -% -\def\unmatchedenderror#1{% +% Evironment mismatch, #1 expected: +\def\badenverr{% \errhelp = \EMsimple - \errmessage{This `@end #1' doesn't have a matching `@#1'}% + \errmessage{This command can appear only \inenvironment\temp, + not \inenvironment\thisenv}% +} +\def\inenvironment#1{% + \ifx#1\empty + out of any environment% + \else + in environment \expandafter\string#1% + \fi } -% Define the control sequence \E#1 to give an unmatched @end error. +% @end foo executes the definition of \Efoo. +% But first, it executes a specialized version of \checkenv % -\def\defineunmatchedend#1{% - \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}% +\parseargdef\end{% + \if 1\csname iscond.#1\endcsname + \else + % The general wording of \badenverr may not be ideal, but... --kasal, 06nov03 + \expandafter\checkenv\csname#1\endcsname + \csname E#1\endcsname + \endgroup + \fi } +\newhelp\EMsimple{Press RETURN to continue.} -% Single-spacing is done by various environments (specifically, in -% \nonfillstart and \quotations). -\newskip\singlespaceskip \singlespaceskip = 12.5pt -\def\singlespace{% - % Why was this kern here? It messes up equalizing space above and below - % environments. --karl, 6may93 - %{\advance \baselineskip by -\singlespaceskip - %\kern \baselineskip}% - \setleading\singlespaceskip -} %% Simple single-character @ commands @@ -466,16 +564,22 @@ \let\{=\mylbrace \let\}=\myrbrace \begingroup - % Definitions to produce actual \{ & \} command in an index. - \catcode`\{ = 12 \catcode`\} = 12 + % Definitions to produce \{ and \} commands for indices, + % and @{ and @} for the aux file. + \catcode`\{ = \other \catcode`\} = \other \catcode`\[ = 1 \catcode`\] = 2 - \catcode`\@ = 0 \catcode`\\ = 12 - @gdef@lbracecmd[\{]% - @gdef@rbracecmd[\}]% -@endgroup + \catcode`\! = 0 \catcode`\\ = \other + !gdef!lbracecmd[\{]% + !gdef!rbracecmd[\}]% + !gdef!lbraceatcmd[@{]% + !gdef!rbraceatcmd[@}]% +!endgroup + +% @comma{} to avoid , parsing problems. +\let\comma = , % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent -% Others are defined by plain TeX: @` @' @" @^ @~ @= @v @H. +% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H. \let\, = \c \let\dotaccent = \. \def\ringaccent#1{{\accent23 #1}} @@ -483,10 +587,12 @@ \let\ubaraccent = \b \let\udotaccent = \d -% Other special characters: @questiondown @exclamdown -% Plain TeX defines: @AA @AE @O @OE @L (and lowercase versions) @ss. +% Other special characters: @questiondown @exclamdown @ordf @ordm +% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss. \def\questiondown{?`} \def\exclamdown{!`} +\def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}} +\def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}} % Dotless i and dotless j, used for accents. \def\imacro{i} @@ -499,6 +605,25 @@ \fi\fi } +% The \TeX{} logo, as in plain, but resetting the spacing so that a +% period following counts as ending a sentence. (Idea found in latex.) +% +\edef\TeX{\TeX \spacefactor=3000 } + +% @LaTeX{} logo. Not quite the same results as the definition in +% latex.ltx, since we use a different font for the raised A; it's most +% convenient for us to use an explicitly smaller font, rather than using +% the \scriptstyle font (since we don't reset \scriptstyle and +% \scriptscriptstyle). +% +\def\LaTeX{% + L\kern-.36em + {\setbox0=\hbox{T}% + \vbox to \ht0{\hbox{\selectfonts\lllsize A}\vss}}% + \kern-.15em + \TeX +} + % Be sure we're in horizontal mode when doing a tie, since we make space % equivalent to this in @example-like environments. Otherwise, a space % at the beginning of a line will start with \penalty -- and @@ -517,6 +642,9 @@ % @* forces a line break. \def\*{\hfil\break\hbox{}\ignorespaces} +% @/ allows a line break. +\let\/=\allowbreak + % @. is an end-of-sentence period. \def\.{.\spacefactor=3000 } @@ -539,47 +667,24 @@ % therefore, no glue is inserted, and the space between the headline and % the text is small, which looks bad. % -\def\group{\begingroup - \ifnum\catcode13=\active \else +% Another complication is that the group might be very large. This can +% cause the glue on the previous page to be unduly stretched, because it +% does not have much material. In this case, it's better to add an +% explicit \vfill so that the extra space is at the bottom. The +% threshold for doing this is if the group is more than \vfilllimit +% percent of a page (\vfilllimit can be changed inside of @tex). +% +\newbox\groupbox +\def\vfilllimit{0.7} +% +\envdef\group{% + \ifnum\catcode`\^^M=\active \else \errhelp = \groupinvalidhelp \errmessage{@group invalid in context where filling is enabled}% \fi + \startsavinginserts % - % The \vtop we start below produces a box with normal height and large - % depth; thus, TeX puts \baselineskip glue before it, and (when the - % next line of text is done) \lineskip glue after it. (See p.82 of - % the TeXbook.) Thus, space below is not quite equal to space - % above. But it's pretty close. - \def\Egroup{% - \egroup % End the \vtop. - \endgroup % End the \group. - }% - % - \vtop\bgroup - % We have to put a strut on the last line in case the @group is in - % the midst of an example, rather than completely enclosing it. - % Otherwise, the interline space between the last line of the group - % and the first line afterwards is too small. But we can't put the - % strut in \Egroup, since there it would be on a line by itself. - % Hence this just inserts a strut at the beginning of each line. - \everypar = {\strut}% - % - % Since we have a strut on every line, we don't need any of TeX's - % normal interline spacing. - \offinterlineskip - % - % OK, but now we have to do something about blank - % lines in the input in @example-like environments, which normally - % just turn into \lisppar, which will insert no space now that we've - % turned off the interline space. Simplest is to make them be an - % empty paragraph. - \ifx\par\lisppar - \edef\par{\leavevmode \par}% - % - % Reset ^^M's definition to new definition of \par. - \obeylines - \fi - % + \setbox\groupbox = \vtop\bgroup % Do @comment since we are called inside an environment such as % @example, where each end-of-line in the input causes an % end-of-line in the output. We don't want the end-of-line after @@ -589,6 +694,32 @@ \comment } % +% The \vtop produces a box with normal height and large depth; thus, TeX puts +% \baselineskip glue before it, and (when the next line of text is done) +% \lineskip glue after it. Thus, space below is not quite equal to space +% above. But it's pretty close. +\def\Egroup{% + % To get correct interline space between the last line of the group + % and the first line afterwards, we have to propagate \prevdepth. + \endgraf % Not \par, as it may have been set to \lisppar. + \global\dimen1 = \prevdepth + \egroup % End the \vtop. + % \dimen0 is the vertical size of the group's box. + \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox + % \dimen2 is how much space is left on the page (more or less). + \dimen2 = \pageheight \advance\dimen2 by -\pagetotal + % if the group doesn't fit on the current page, and it's a big big + % group, force a page break. + \ifdim \dimen0 > \dimen2 + \ifdim \pagetotal < \vfilllimit\pageheight + \page + \fi + \fi + \box\groupbox + \prevdepth = \dimen1 + \checkinserts +} +% % TeX puts in an \escapechar (i.e., `@') at the beginning of the help % message, so this ends up printing `@group can only ...'. % @@ -601,10 +732,8 @@ where each line of input produces a line of output.} \newdimen\mil \mil=0.001in -\def\need{\parsearg\needx} - % Old definition--didn't work. -%\def\needx #1{\par % +%\parseargdef\need{\par % %% This method tries to make TeX break the page naturally %% if the depth of the box does not fit. %{\baselineskip=0pt% @@ -612,7 +741,7 @@ where each line of input produces a line of output.} %\prevdepth=-1000pt %}} -\def\needx#1{% +\parseargdef\need{% % Ensure vertical mode, so we don't make a big box in the middle of a % paragraph. \par @@ -651,37 +780,11 @@ where each line of input produces a line of output.} \fi } -% @br forces paragraph break +% @br forces paragraph break (and is undocumented). \let\br = \par -% @dots{} output an ellipsis using the current font. -% We do .5em per period so that it has the same spacing in a typewriter -% font as three actual period characters. -% -\def\dots{% - \leavevmode - \hbox to 1.5em{% - \hskip 0pt plus 0.25fil minus 0.25fil - .\hss.\hss.% - \hskip 0pt plus 0.5fil minus 0.5fil - }% -} - -% @enddots{} is an end-of-sentence ellipsis. -% -\def\enddots{% - \leavevmode - \hbox to 2em{% - \hskip 0pt plus 0.25fil minus 0.25fil - .\hss.\hss.\hss.% - \hskip 0pt plus 0.5fil minus 0.5fil - }% - \spacefactor=3000 -} - - -% @page forces the start of a new page +% @page forces the start of a new page. % \def\page{\par\vfill\supereject} @@ -693,13 +796,11 @@ where each line of input produces a line of output.} \newskip\exdentamount % This defn is used inside fill environments such as @defun. -\def\exdent{\parsearg\exdentyyy} -\def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}} +\parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break} % This defn is used inside nofill environments such as @example. -\def\nofillexdent{\parsearg\nofillexdentyyy} -\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount -\leftline{\hskip\leftskip{\rm#1}}}} +\parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount + \leftline{\hskip\leftskip{\rm#1}}}} % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current % paragraph. For more general purposes, use the \margin insertion @@ -730,10 +831,10 @@ where each line of input produces a line of output.} % @inmargin{TEXT [, RIGHT-TEXT]} % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right; % else use TEXT for both). -% +% \def\inmargin#1{\parseinmargin #1,,\finish} \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing. - \setbox0 = \hbox{\ignorespaces #2}% + \setbox0 = \hbox{\ignorespaces #2}% \ifdim\wd0 > 0pt \def\lefttext{#1}% have both texts \def\righttext{#2}% @@ -751,37 +852,71 @@ where each line of input produces a line of output.} } % @include file insert text of that file as input. -% Allow normal characters that we make active in the argument (a file name). -\def\include{\begingroup - \catcode`\\=12 - \catcode`~=12 - \catcode`^=12 - \catcode`_=12 - \catcode`|=12 - \catcode`<=12 - \catcode`>=12 - \catcode`+=12 - \parsearg\includezzz} -% Restore active chars for included file. -\def\includezzz#1{\endgroup\begingroup - % Read the included file in a group so nested @include's work. +% +\def\include{\parseargusing\filenamecatcodes\includezzz} +\def\includezzz#1{% + \pushthisfilestack \def\thisfile{#1}% - \input\thisfile -\endgroup} + {% + \makevalueexpandable + \def\temp{\input #1 }% + \expandafter + }\temp + \popthisfilestack +} +\def\filenamecatcodes{% + \catcode`\\=\other + \catcode`~=\other + \catcode`^=\other + \catcode`_=\other + \catcode`|=\other + \catcode`<=\other + \catcode`>=\other + \catcode`+=\other + \catcode`-=\other +} + +\def\pushthisfilestack{% + \expandafter\pushthisfilestackX\popthisfilestack\StackTerm +} +\def\pushthisfilestackX{% + \expandafter\pushthisfilestackY\thisfile\StackTerm +} +\def\pushthisfilestackY #1\StackTerm #2\StackTerm {% + \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}% +} + +\def\popthisfilestack{\errthisfilestackempty} +\def\errthisfilestackempty{\errmessage{Internal error: + the stack of filenames is empty.}} \def\thisfile{} -% @center line outputs that line, centered - -\def\center{\parsearg\centerzzz} -\def\centerzzz #1{{\advance\hsize by -\leftskip -\advance\hsize by -\rightskip -\centerline{#1}}} +% @center line +% outputs that line, centered. +% +\parseargdef\center{% + \ifhmode + \let\next\centerH + \else + \let\next\centerV + \fi + \next{\hfil \ignorespaces#1\unskip \hfil}% +} +\def\centerH#1{% + {% + \hfil\break + \advance\hsize by -\leftskip + \advance\hsize by -\rightskip + \line{#1}% + \break + }% +} +\def\centerV#1{\line{\kern\leftskip #1\kern\rightskip}} % @sp n outputs n lines of vertical space -\def\sp{\parsearg\spxxx} -\def\spxxx #1{\vskip #1\baselineskip} +\parseargdef\sp{\vskip #1\baselineskip} % @comment ...line which is ignored... % @c is the same as @comment @@ -796,13 +931,13 @@ where each line of input produces a line of output.} % @paragraphindent NCHARS % We'll use ems for NCHARS, close enough. -% We cannot implement @paragraphindent asis, though. -% +% NCHARS can also be the word `asis' or `none'. +% We cannot feasibly implement @paragraphindent asis, though. +% \def\asisword{asis} % no translation, these are keywords \def\noneword{none} % -\def\paragraphindent{\parsearg\doparagraphindent} -\def\doparagraphindent#1{% +\parseargdef\paragraphindent{% \def\temp{#1}% \ifx\temp\asisword \else @@ -819,8 +954,7 @@ where each line of input produces a line of output.} % We'll use ems for NCHARS like @paragraphindent. % It seems @exampleindent asis isn't necessary, but % I preserve it to make it similar to @paragraphindent. -\def\exampleindent{\parsearg\doexampleindent} -\def\doexampleindent#1{% +\parseargdef\exampleindent{% \def\temp{#1}% \ifx\temp\asisword \else @@ -832,51 +966,138 @@ where each line of input produces a line of output.} \fi } +% @firstparagraphindent WORD +% If WORD is `none', then suppress indentation of the first paragraph +% after a section heading. If WORD is `insert', then do indent at such +% paragraphs. +% +% The paragraph indentation is suppressed or not by calling +% \suppressfirstparagraphindent, which the sectioning commands do. +% We switch the definition of this back and forth according to WORD. +% By default, we suppress indentation. +% +\def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent} +\def\insertword{insert} +% +\parseargdef\firstparagraphindent{% + \def\temp{#1}% + \ifx\temp\noneword + \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent + \else\ifx\temp\insertword + \let\suppressfirstparagraphindent = \relax + \else + \errhelp = \EMsimple + \errmessage{Unknown @firstparagraphindent option `\temp'}% + \fi\fi +} + +% Here is how we actually suppress indentation. Redefine \everypar to +% \kern backwards by \parindent, and then reset itself to empty. +% +% We also make \indent itself not actually do anything until the next +% paragraph. +% +\gdef\dosuppressfirstparagraphindent{% + \gdef\indent{% + \restorefirstparagraphindent + \indent + }% + \gdef\noindent{% + \restorefirstparagraphindent + \noindent + }% + \global\everypar = {% + \kern -\parindent + \restorefirstparagraphindent + }% +} + +\gdef\restorefirstparagraphindent{% + \global \let \indent = \ptexindent + \global \let \noindent = \ptexnoindent + \global \everypar = {}% +} + + % @asis just yields its argument. Used with @table, for example. % \def\asis#1{#1} % @math outputs its argument in math mode. -% We don't use $'s directly in the definition of \math because we need -% to set catcodes according to plain TeX first, to allow for subscripts, -% superscripts, special math chars, etc. -% -% @math does not do math typesetting in section titles, index -% entries, and other such contexts where the catcodes are set before -% @math gets a chance to work. This could perhaps be fixed, but for now -% at least we can have real math in the main text, where it's needed most. -% -\let\implicitmath = $%$ font-lock fix % % One complication: _ usually means subscripts, but it could also mean % an actual _ character, as in @math{@var{some_variable} + 1}. So make -% _ within @math be active (mathcode "8000), and distinguish by seeing -% if the current family is \slfam, which is what @var uses. -% -{\catcode95 = \active % 95 = _ -\gdef\mathunderscore{% - \catcode95=\active - \def_{\ifnum\fam=\slfam \_\else\sb\fi}% -}} -% +% _ active, and distinguish by seeing if the current family is \slfam, +% which is what @var uses. +{ + \catcode\underChar = \active + \gdef\mathunderscore{% + \catcode\underChar=\active + \def_{\ifnum\fam=\slfam \_\else\sb\fi}% + } +} % Another complication: we want \\ (and @\) to output a \ character. % FYI, plain.tex uses \\ as a temporary control sequence (why?), but % this is not advertised and we don't care. Texinfo does not % otherwise define @\. -% +% % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\. \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi} % \def\math{% \tex - \mathcode`\_="8000 \mathunderscore + \mathunderscore \let\\ = \mathbackslash - \implicitmath\finishmath} -\def\finishmath#1{#1\implicitmath\Etex} + \mathactive + $\finishmath +} +\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex. + +% Some active characters (such as <) are spaced differently in math. +% We have to reset their definitions in case the @math was an argument +% to a command which sets the catcodes (such as @item or @section). +% +{ + \catcode`^ = \active + \catcode`< = \active + \catcode`> = \active + \catcode`+ = \active + \gdef\mathactive{% + \let^ = \ptexhat + \let< = \ptexless + \let> = \ptexgtr + \let+ = \ptexplus + } +} % @bullet and @minus need the same treatment as @math, just above. -\def\bullet{\implicitmath\ptexbullet\implicitmath} -\def\minus{\implicitmath-\implicitmath} +\def\bullet{$\ptexbullet$} +\def\minus{$-$} + +% @dots{} outputs an ellipsis using the current font. +% We do .5em per period so that it has the same spacing in a typewriter +% font as three actual period characters. +% +\def\dots{% + \leavevmode + \hbox to 1.5em{% + \hskip 0pt plus 0.25fil + .\hfil.\hfil.% + \hskip 0pt plus 0.5fil + }% +} + +% @enddots{} is an end-of-sentence ellipsis. +% +\def\enddots{% + \dots + \spacefactor=3000 +} + +% @comma{} is so commas can be inserted into text without messing up +% Texinfo's parsing. +% +\let\comma = , % @refill is a no-op. \let\refill=\relax @@ -892,20 +1113,20 @@ where each line of input produces a line of output.} % So open here the files we need to have open while reading the input. % This makes it possible to make a .fmt file for texinfo. \def\setfilename{% + \fixbackslash % Turn off hack to swallow `\input texinfo'. \iflinks - \readauxfile + \tryauxfile + % Open the new aux file. TeX will close it automatically at exit. + \immediate\openout\auxfile=\jobname.aux \fi % \openindices needs to do some work in any case. \openindices - \fixbackslash % Turn off hack to swallow `\input texinfo'. - \global\let\setfilename=\comment % Ignore extra @setfilename cmds. + \let\setfilename=\comment % Ignore extra @setfilename cmds. % % If texinfo.cnf is present on the system, read it. % Useful for site-wide @afourpaper, etc. - % Just to be on the safe side, close the input stream before the \input. \openin 1 texinfo.cnf - \ifeof1 \let\temp=\relax \else \def\temp{\input texinfo.cnf }\fi - \closein1 - \temp + \ifeof 1 \else \input texinfo.cnf \fi + \closein 1 % \comment % Ignore the actual filename. } @@ -941,17 +1162,23 @@ where each line of input produces a line of output.} \newif\ifpdf \newif\ifpdfmakepagedest +% when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1 +% can be set). So we test for \relax and 0 as well as \undefined, +% borrowed from ifpdf.sty. \ifx\pdfoutput\undefined - \pdffalse - \let\pdfmkdest = \gobble - \let\pdfurl = \gobble - \let\endlink = \relax - \let\linkcolor = \relax - \let\pdfmakeoutlines = \relax \else - \pdftrue - \pdfoutput = 1 + \ifx\pdfoutput\relax + \else + \ifcase\pdfoutput + \else + \pdftrue + \fi + \fi +\fi +% +\ifpdf \input pdfcolor + \pdfcatalog{/PageMode /UseOutlines}% \def\dopdfimage#1#2#3{% \def\imagewidth{#2}% \def\imageheight{#3}% @@ -965,14 +1192,20 @@ where each line of input produces a line of output.} \ifx\empty\imagewidth\else width \imagewidth \fi \ifx\empty\imageheight\else height \imageheight \fi \ifnum\pdftexversion<13 - #1.pdf% + #1.pdf% \else {#1.pdf}% \fi \ifnum\pdftexversion < 14 \else \pdfrefximage \pdflastximage \fi} - \def\pdfmkdest#1{{\normalturnoffactive \pdfdest name{#1} xyz}} + \def\pdfmkdest#1{{% + % We have to set dummies so commands such as @code in a section title + % aren't expanded. + \atdummies + \normalturnoffactive + \pdfdest name{#1} xyz% + }} \def\pdfmkpgn#1{#1} \let\linkcolor = \Blue % was Cyan, but that seems light? \def\endlink{\Black\pdfendlink} @@ -981,49 +1214,94 @@ where each line of input produces a line of output.} \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% \else \csname#1\endcsname \fi} \def\advancenumber#1{\tempnum=\expnumber{#1}\relax - \advance\tempnum by1 + \advance\tempnum by 1 \expandafter\xdef\csname#1\endcsname{\the\tempnum}} - \def\pdfmakeoutlines{{% - \openin 1 \jobname.toc - \ifeof 1\else\begingroup - \closein 1 - \indexnofonts - \def\tt{} - \let\_ = \normalunderscore - % Thanh's hack / proper braces in bookmarks + % + % #1 is the section text. #2 is the pdf expression for the number + % of subentries (or empty, for subsubsections). #3 is the node + % text, which might be empty if this toc entry had no + % corresponding node. #4 is the page number. + % + \def\dopdfoutline#1#2#3#4{% + % Generate a link to the node text if that exists; else, use the + % page number. We could generate a destination for the section + % text in the case where a section has no node, but it doesn't + % seem worthwhile, since most documents are normally structured. + \def\pdfoutlinedest{#3}% + \ifx\pdfoutlinedest\empty \def\pdfoutlinedest{#4}\fi + % + \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{#1}% + } + % + \def\pdfmakeoutlines{% + \begingroup + % Thanh's hack / proper braces in bookmarks \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace % - \def\chapentry ##1##2##3{} - \let\appendixentry = \chapentry - \def\unnumbchapentry ##1##2{} - \def\secentry ##1##2##3##4{\advancenumber{chap##2}} - \def\unnumbsecentry ##1##2##3{\advancenumber{chap##2}} - \def\subsecentry ##1##2##3##4##5{\advancenumber{sec##2.##3}} - \def\unnumbsubsecentry ##1##2##3##4{\advancenumber{sec##2.##3}} - \def\subsubsecentry ##1##2##3##4##5##6{\advancenumber{subsec##2.##3.##4}} - \def\unnumbsubsubsecentry ##1##2##3##4##5{\advancenumber{subsec##2.##3.##4}} + % Read toc silently, to get counts of subentries for \pdfoutline. + \def\numchapentry##1##2##3##4{% + \def\thischapnum{##2}% + \let\thissecnum\empty + \let\thissubsecnum\empty + }% + \def\numsecentry##1##2##3##4{% + \advancenumber{chap\thischapnum}% + \def\thissecnum{##2}% + \let\thissubsecnum\empty + }% + \def\numsubsecentry##1##2##3##4{% + \advancenumber{sec\thissecnum}% + \def\thissubsecnum{##2}% + }% + \def\numsubsubsecentry##1##2##3##4{% + \advancenumber{subsec\thissubsecnum}% + }% + \let\thischapnum\empty + \let\thissecnum\empty + \let\thissubsecnum\empty + % + % use \def rather than \let here because we redefine \chapentry et + % al. a second time, below. + \def\appentry{\numchapentry}% + \def\appsecentry{\numsecentry}% + \def\appsubsecentry{\numsubsecentry}% + \def\appsubsubsecentry{\numsubsubsecentry}% + \def\unnchapentry{\numchapentry}% + \def\unnsecentry{\numsecentry}% + \def\unnsubsecentry{\numsubsecentry}% + \def\unnsubsubsecentry{\numsubsubsecentry}% \input \jobname.toc - \def\chapentry ##1##2##3{% - \pdfoutline goto name{\pdfmkpgn{##3}}count-\expnumber{chap##2}{##1}} - \let\appendixentry = \chapentry - \def\unnumbchapentry ##1##2{% - \pdfoutline goto name{\pdfmkpgn{##2}}{##1}} - \def\secentry ##1##2##3##4{% - \pdfoutline goto name{\pdfmkpgn{##4}}count-\expnumber{sec##2.##3}{##1}} - \def\unnumbsecentry ##1##2##3{% - \pdfoutline goto name{\pdfmkpgn{##3}}{##1}} - \def\subsecentry ##1##2##3##4##5{% - \pdfoutline goto name{\pdfmkpgn{##5}}count-\expnumber{subsec##2.##3.##4}{##1}} - \def\unnumbsubsecentry ##1##2##3##4{% - \pdfoutline goto name{\pdfmkpgn{##4}}{##1}} - \def\subsubsecentry ##1##2##3##4##5##6{% - \pdfoutline goto name{\pdfmkpgn{##6}}{##1}} - \def\unnumbsubsubsecentry ##1##2##3##4##5{% - \pdfoutline goto name{\pdfmkpgn{##5}}{##1}} + % + % Read toc second time, this time actually producing the outlines. + % The `-' means take the \expnumber as the absolute number of + % subentries, which we calculated on our first read of the .toc above. + % + % We use the node names as the destinations. + \def\numchapentry##1##2##3##4{% + \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}% + \def\numsecentry##1##2##3##4{% + \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}% + \def\numsubsecentry##1##2##3##4{% + \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}% + \def\numsubsubsecentry##1##2##3##4{% count is always zero + \dopdfoutline{##1}{}{##3}{##4}}% + % + % PDF outlines are displayed using system fonts, instead of + % document fonts. Therefore we cannot use special characters, + % since the encoding is unknown. For example, the eogonek from + % Latin 2 (0xea) gets translated to a | character. Info from + % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100. + % + % xx to do this right, we have to translate 8-bit characters to + % their "best" equivalent, based on the @documentencoding. Right + % now, I guess we'll just let the pdf reader have its way. + \indexnofonts + \turnoffactive \input \jobname.toc - \endgroup\fi - }} + \endgroup + } + % \def\makelinks #1,{% \def\params{#1}\def\E{END}% \ifx\params\E @@ -1032,7 +1310,7 @@ where each line of input produces a line of output.} \let\nextmakelinks=\makelinks \ifnum\lnkcount>0,\fi \picknum{#1}% - \startlink attr{/Border [0 0 0]} + \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{\the\pgn}}% \linkcolor #1% \advance\lnkcount by 1% @@ -1054,7 +1332,6 @@ where each line of input produces a line of output.} \def\ppn#1{\pgn=#1\gobble} \def\ppnn{\pgn=\first} \def\pdfmklnk#1{\lnkcount=0\makelinks #1,END,} - \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} \def\skipspaces#1{\def\PP{#1}\def\D{|}% \ifx\PP\D\let\nextsp\relax \else\let\nextsp\skipspaces @@ -1072,22 +1349,21 @@ where each line of input produces a line of output.} \def\pdfurl#1{% \begingroup \normalturnoffactive\def\@{@}% - \let\value=\expandablevalue + \makevalueexpandable \leavevmode\Red \startlink attr{/Border [0 0 0]}% user{/Subtype /Link /A << /S /URI /URI (#1) >>}% - % #1 \endgroup} \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}} \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks} \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}} \def\maketoks{% - \expandafter\poptoks\the\toksA|ENDTOKS| + \expandafter\poptoks\the\toksA|ENDTOKS|\relax \ifx\first0\adn0 \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3 \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6 - \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 + \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 \else \ifnum0=\countA\else\makelink\fi \ifx\first.\let\next=\done\else @@ -1103,20 +1379,44 @@ where each line of input produces a line of output.} \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}} \linkcolor #1\endlink} \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} -\fi % \ifx\pdfoutput +\else + \let\pdfmkdest = \gobble + \let\pdfurl = \gobble + \let\endlink = \relax + \let\linkcolor = \relax + \let\pdfmakeoutlines = \relax +\fi % \ifx\pdfoutput \message{fonts,} -% Font-change commands. + +% Change the current font style to #1, remembering it in \curfontstyle. +% For now, we do not accumulate font styles: @b{@i{foo}} prints foo in +% italics, not bold italics. +% +\def\setfontstyle#1{% + \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd. + \csname ten#1\endcsname % change the current font +} + +% Select #1 fonts with the current style. +% +\def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname} + +\def\rm{\fam=0 \setfontstyle{rm}} +\def\it{\fam=\itfam \setfontstyle{it}} +\def\sl{\fam=\slfam \setfontstyle{sl}} +\def\bf{\fam=\bffam \setfontstyle{bf}} +\def\tt{\fam=\ttfam \setfontstyle{tt}} % Texinfo sort of supports the sans serif font style, which plain TeX does not. -% So we set up a \sf analogous to plain's \rm, etc. +% So we set up a \sf. \newfam\sffam -\def\sf{\fam=\sffam \tensf} +\def\sf{\fam=\sffam \setfontstyle{sf}} \let\li = \sf % Sometimes we call it \li, not \sf. -% We don't need math for this one. -\def\ttsl{\tenttsl} +% We don't need math for this font style. +\def\ttsl{\setfontstyle{ttsl}} % Default leading. \newdimen\textleading \textleading = 13.2pt @@ -1167,10 +1467,11 @@ where each line of input produces a line of output.} \def\scshape{csc} \def\scbshape{csc} +% Text fonts (11.2pt, magstep1). \newcount\mainmagstep \ifx\bigger\relax % not really supported. - \let\mainmagstep=\magstep1 + \mainmagstep=\magstep1 \setfont\textrm\rmshape{12}{1000} \setfont\texttt\ttshape{12}{1000} \else @@ -1178,9 +1479,6 @@ where each line of input produces a line of output.} \setfont\textrm\rmshape{10}{\mainmagstep} \setfont\texttt\ttshape{10}{\mainmagstep} \fi -% Instead of cmb10, you many want to use cmbx10. -% cmbx10 is a prettier font on its own, but cmb10 -% looks better when embedded in a line with cmr10. \setfont\textbf\bfshape{10}{\mainmagstep} \setfont\textit\itshape{10}{\mainmagstep} \setfont\textsl\slshape{10}{\mainmagstep} @@ -1190,10 +1488,11 @@ where each line of input produces a line of output.} \font\texti=cmmi10 scaled \mainmagstep \font\textsy=cmsy10 scaled \mainmagstep -% A few fonts for @defun, etc. -\setfont\defbf\bxshape{10}{\magstep1} %was 1314 +% A few fonts for @defun names and args. +\setfont\defbf\bfshape{10}{\magstep1} \setfont\deftt\ttshape{10}{\magstep1} -\def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf} +\setfont\defttsl\ttslshape{10}{\magstep1} +\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} % Fonts for indices, footnotes, small examples (9pt). \setfont\smallrm\rmshape{9}{1000} @@ -1219,7 +1518,7 @@ where each line of input produces a line of output.} \font\smalleri=cmmi8 \font\smallersy=cmsy8 -% Fonts for title page: +% Fonts for title page (20.4pt): \setfont\titlerm\rmbshape{12}{\magstep3} \setfont\titleit\itbshape{10}{\magstep4} \setfont\titlesl\slbshape{10}{\magstep4} @@ -1231,6 +1530,7 @@ where each line of input produces a line of output.} \font\titlei=cmmi12 scaled \magstep3 \font\titlesy=cmsy10 scaled \magstep4 \def\authorrm{\secrm} +\def\authortt{\sectt} % Chapter (and unnumbered) fonts (17.28pt). \setfont\chaprm\rmbshape{12}{\magstep2} @@ -1264,11 +1564,21 @@ where each line of input produces a line of output.} \setfont\ssecttsl\ttslshape{10}{1315} \setfont\ssecsf\sfbshape{12}{\magstephalf} \let\ssecbf\ssecrm -\setfont\ssecsc\scbshape{10}{\magstep1} +\setfont\ssecsc\scbshape{10}{1315} \font\sseci=cmmi12 scaled \magstephalf \font\ssecsy=cmsy10 scaled 1315 -% The smallcaps and symbol fonts should actually be scaled \magstep1.5, -% but that is not a standard magnification. + +% Reduced fonts for @acro in text (10pt). +\setfont\reducedrm\rmshape{10}{1000} +\setfont\reducedtt\ttshape{10}{1000} +\setfont\reducedbf\bfshape{10}{1000} +\setfont\reducedit\itshape{10}{1000} +\setfont\reducedsl\slshape{10}{1000} +\setfont\reducedsf\sfshape{10}{1000} +\setfont\reducedsc\scshape{10}{1000} +\setfont\reducedttsl\ttslshape{10}{1000} +\font\reducedi=cmmi10 +\font\reducedsy=cmsy10 % In order for the font changes to affect most math symbols and letters, % we have to define the \textfont of the standard families. Since @@ -1283,56 +1593,95 @@ where each line of input produces a line of output.} } % The font-changing commands redefine the meanings of \tenSTYLE, instead -% of just \STYLE. We do this so that font changes will continue to work -% in math mode, where it is the current \fam that is relevant in most -% cases, not the current font. Plain TeX does \def\bf{\fam=\bffam -% \tenbf}, for example. By redefining \tenbf, we obviate the need to -% redefine \bf itself. +% of just \STYLE. We do this because \STYLE needs to also set the +% current \fam for math mode. Our \STYLE (e.g., \rm) commands hardwire +% \tenSTYLE to set the current font. +% +% Each font-changing command also sets the names \lsize (one size lower) +% and \lllsize (three sizes lower). These relative commands are used in +% the LaTeX logo and acronyms. +% +% This all needs generalizing, badly. +% \def\textfonts{% \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc - \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl + \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy + \let\tenttsl=\textttsl + \def\lsize{reduced}\def\lllsize{smaller}% \resetmathfonts \setleading{\textleading}} \def\titlefonts{% \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy \let\tenttsl=\titlettsl + \def\lsize{chap}\def\lllsize{subsec}% \resetmathfonts \setleading{25pt}} \def\titlefont#1{{\titlefonts\rm #1}} \def\chapfonts{% \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl + \def\lsize{sec}\def\lllsize{text}% \resetmathfonts \setleading{19pt}} \def\secfonts{% \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc - \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \let\tenttsl=\secttsl + \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy + \let\tenttsl=\secttsl + \def\lsize{subsec}\def\lllsize{reduced}% \resetmathfonts \setleading{16pt}} \def\subsecfonts{% \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc - \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \let\tenttsl=\ssecttsl + \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy + \let\tenttsl=\ssecttsl + \def\lsize{text}\def\lllsize{small}% \resetmathfonts \setleading{15pt}} -\let\subsubsecfonts = \subsecfonts % Maybe make sssec fonts scaled magstephalf? +\let\subsubsecfonts = \subsecfonts +\def\reducedfonts{% + \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl + \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc + \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy + \let\tenttsl=\reducedttsl + \def\lsize{small}\def\lllsize{smaller}% + \resetmathfonts \setleading{10.5pt}} \def\smallfonts{% \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy \let\tenttsl=\smallttsl + \def\lsize{smaller}\def\lllsize{smaller}% \resetmathfonts \setleading{10.5pt}} \def\smallerfonts{% \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy \let\tenttsl=\smallerttsl + \def\lsize{smaller}\def\lllsize{smaller}% \resetmathfonts \setleading{9.5pt}} -\let\smallexamplefonts = \smallerfonts + +% Set the fonts to use with the @small... environments. +\let\smallexamplefonts = \smallfonts + +% About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample +% can fit this many characters: +% 8.5x11=86 smallbook=72 a4=90 a5=69 +% If we use \scriptfonts (8pt), then we can fit this many characters: +% 8.5x11=90+ smallbook=80 a4=90+ a5=77 +% For me, subjectively, the few extra characters that fit aren't worth +% the additional smallness of 8pt. So I'm making the default 9pt. +% +% By the way, for comparison, here's what fits with @example (10pt): +% 8.5x11=71 smallbook=60 a4=75 a5=58 +% +% I wish the USA used A4 paper. +% --karl, 24jan03. + % Set up the default fonts, so we can use them for creating boxes. % -\textfonts +\textfonts \rm % Define these so they can be easily changed for other fonts. \def\angleleft{$\langle$} @@ -1343,23 +1692,32 @@ where each line of input produces a line of output.} % Fonts for short table of contents. \setfont\shortcontrm\rmshape{12}{1000} -\setfont\shortcontbf\bxshape{12}{1000} +\setfont\shortcontbf\bfshape{10}{\magstep1} % no cmb12 \setfont\shortcontsl\slshape{12}{1000} +\setfont\shortconttt\ttshape{12}{1000} %% Add scribe-like font environments, plus @l for inline lisp (usually sans %% serif) and @ii for TeX italic % \smartitalic{ARG} outputs arg in italics, followed by an italic correction % unless the following character is such as not to need one. -\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi} -\def\smartslanted#1{{\sl #1}\futurelet\next\smartitalicx} -\def\smartitalic#1{{\it #1}\futurelet\next\smartitalicx} +\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else + \ptexslash\fi\fi\fi} +\def\smartslanted#1{{\ifusingtt\ttsl\sl #1}\futurelet\next\smartitalicx} +\def\smartitalic#1{{\ifusingtt\ttsl\it #1}\futurelet\next\smartitalicx} + +% like \smartslanted except unconditionally uses \ttsl. +% @var is set to this for defun arguments. +\def\ttslanted#1{{\ttsl #1}\futurelet\next\smartitalicx} + +% like \smartslanted except unconditionally use \sl. We never want +% ttsl for book titles, do we? +\def\cite#1{{\sl #1}\futurelet\next\smartitalicx} \let\i=\smartitalic \let\var=\smartslanted \let\dfn=\smartslanted \let\emph=\smartitalic -\let\cite=\smartslanted \def\b#1{{\bf #1}} \let\strong=\b @@ -1371,11 +1729,21 @@ where each line of input produces a line of output.} \def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} \def\restorehyphenation{\hyphenchar\font = `- } +% Set sfcode to normal for the chars that usually have another value. +% Can't use plain's \frenchspacing because it uses the `\x notation, and +% sometimes \x has an active definition that messes things up. +% +\catcode`@=11 + \def\frenchspacing{% + \sfcode\dotChar =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m + \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m + } +\catcode`@=\other + \def\t#1{% {\tt \rawbackslash \frenchspacing #1}% \null } -\let\ttfont=\t \def\samp#1{`\tclose{#1}'\null} \setfont\keyrm\rmshape{8}{1000} \font\keysy=cmsy9 @@ -1416,7 +1784,7 @@ where each line of input produces a line of output.} \null } -% We *must* turn on hyphenation at `-' and `_' in \code. +% We *must* turn on hyphenation at `-' and `_' in @code. % Otherwise, it is too hard to avoid overfull hboxes % in the Emacs manual, the Library manual, etc. @@ -1434,10 +1802,6 @@ where each line of input produces a line of output.} \catcode`\_=\active \let_\codeunder \codex } - % - % If we end up with any active - characters when handling the index, - % just treat them as a normal -. - \global\def\indexbreaks{\catcode`\-=\active \let-\realdash} } \def\realdash{-} @@ -1461,8 +1825,7 @@ where each line of input produces a line of output.} % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), % `example' (@kbd uses ttsl only inside of @example and friends), % or `code' (@kbd uses normal tty font always). -\def\kbdinputstyle{\parsearg\kbdinputstylexxx} -\def\kbdinputstylexxx#1{% +\parseargdef\kbdinputstyle{% \def\arg{#1}% \ifx\arg\worddistinct \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% @@ -1470,15 +1833,17 @@ where each line of input produces a line of output.} \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% \else\ifx\arg\wordcode \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% + \else + \errhelp = \EMsimple + \errmessage{Unknown @kbdinputstyle option `\arg'}% \fi\fi\fi } \def\worddistinct{distinct} \def\wordexample{example} \def\wordcode{code} -% Default is kbdinputdistinct. (Too much of a hassle to call the macro, -% the catcodes are wrong for parsearg to work.) -\gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl} +% Default is `distinct.' +\kbdinputstyle distinct \def\xkey{\key} \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% @@ -1486,8 +1851,8 @@ where each line of input produces a line of output.} \else{\tclose{\kbdfont\look}}\fi \else{\tclose{\kbdfont\look}}\fi} -% For @url, @env, @command quotes seem unnecessary, so use \code. -\let\url=\code +% For @indicateurl, @env, @command quotes seem unnecessary, so use \code. +\let\indicateurl=\code \let\env=\code \let\command=\code @@ -1519,9 +1884,13 @@ where each line of input produces a line of output.} \endlink \endgroup} +% @url synonym for @uref, since that's how everyone uses it. +% +\let\url=\uref + % rms does not like angle brackets --karl, 17may97. % So now @email is just like @uref, unless we are pdf. -% +% %\def\email#1{\angleleft{\tt #1}\angleright} \ifpdf \def\email#1{\doemail#1,,\finish} @@ -1560,12 +1929,29 @@ where each line of input produces a line of output.} \def\sc#1{{\smallcaps#1}} % smallcaps font \def\ii#1{{\it #1}} % italic font -% @acronym downcases the argument and prints in smallcaps. -\def\acronym#1{{\smallcaps \lowercase{#1}}} +\def\acronym#1{\doacronym #1,,\finish} +\def\doacronym#1,#2,#3\finish{% + {\selectfonts\lsize #1}% + \def\temp{#2}% + \ifx\temp\empty \else + \space ({\unsepspaces \ignorespaces \temp \unskip})% + \fi +} -% @pounds{} is a sterling sign. +% @pounds{} is a sterling sign, which is in the CM italic font. +% \def\pounds{{\it\$}} +% @registeredsymbol - R in a circle. The font for the R should really +% be smaller yet, but lllsize is the best we can do for now. +% Adapted from the plain.tex definition of \copyright. +% +\def\registeredsymbol{% + $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}% + \hfil\crcr\Orb}}% + }$% +} + \message{page headings,} @@ -1584,86 +1970,103 @@ where each line of input produces a line of output.} \newif\ifsetshortcontentsaftertitlepage \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue -\def\shorttitlepage{\parsearg\shorttitlepagezzz} -\def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}% +\parseargdef\shorttitlepage{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}% \endgroup\page\hbox{}\page} -\def\titlepage{\begingroup \parindent=0pt \textfonts - \let\subtitlerm=\tenrm - \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}% - % - \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}% - % - % Leave some space at the very top of the page. - \vglue\titlepagetopglue - % - % Now you can print the title using @title. - \def\title{\parsearg\titlezzz}% - \def\titlezzz##1{\leftline{\titlefonts\rm ##1} - % print a rule at the page bottom also. - \finishedtitlepagefalse - \vskip4pt \hrule height 4pt width \hsize \vskip4pt}% - % No rule at page bottom unless we print one at the top with @title. - \finishedtitlepagetrue - % - % Now you can put text using @subtitle. - \def\subtitle{\parsearg\subtitlezzz}% - \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}% - % - % @author should come last, but may come many times. - \def\author{\parsearg\authorzzz}% - \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi - {\authorfont \leftline{##1}}}% - % - % Most title ``pages'' are actually two pages long, with space - % at the top of the second. We don't want the ragged left on the second. - \let\oldpage = \page - \def\page{% +\envdef\titlepage{% + % Open one extra group, as we want to close it in the middle of \Etitlepage. + \begingroup + \parindent=0pt \textfonts + % Leave some space at the very top of the page. + \vglue\titlepagetopglue + % No rule at page bottom unless we print one at the top with @title. + \finishedtitlepagetrue + % + % Most title ``pages'' are actually two pages long, with space + % at the top of the second. We don't want the ragged left on the second. + \let\oldpage = \page + \def\page{% \iffinishedtitlepage\else - \finishtitlepage + \finishtitlepage \fi - \oldpage \let\page = \oldpage - \hbox{}}% -% \def\page{\oldpage \hbox{}} + \page + \null + }% } \def\Etitlepage{% - \iffinishedtitlepage\else - \finishtitlepage - \fi - % It is important to do the page break before ending the group, - % because the headline and footline are only empty inside the group. - % If we use the new definition of \page, we always get a blank page - % after the title page, which we certainly don't want. - \oldpage - \endgroup - % - % Need this before the \...aftertitlepage checks so that if they are - % in effect the toc pages will come out with page numbers. - \HEADINGSon - % - % If they want short, they certainly want long too. - \ifsetshortcontentsaftertitlepage - \shortcontents - \contents - \global\let\shortcontents = \relax - \global\let\contents = \relax - \fi - % - \ifsetcontentsaftertitlepage - \contents - \global\let\contents = \relax - \global\let\shortcontents = \relax - \fi + \iffinishedtitlepage\else + \finishtitlepage + \fi + % It is important to do the page break before ending the group, + % because the headline and footline are only empty inside the group. + % If we use the new definition of \page, we always get a blank page + % after the title page, which we certainly don't want. + \oldpage + \endgroup + % + % Need this before the \...aftertitlepage checks so that if they are + % in effect the toc pages will come out with page numbers. + \HEADINGSon + % + % If they want short, they certainly want long too. + \ifsetshortcontentsaftertitlepage + \shortcontents + \contents + \global\let\shortcontents = \relax + \global\let\contents = \relax + \fi + % + \ifsetcontentsaftertitlepage + \contents + \global\let\contents = \relax + \global\let\shortcontents = \relax + \fi } \def\finishtitlepage{% - \vskip4pt \hrule height 2pt width \hsize - \vskip\titlepagebottomglue - \finishedtitlepagetrue + \vskip4pt \hrule height 2pt width \hsize + \vskip\titlepagebottomglue + \finishedtitlepagetrue } +%%% Macros to be used within @titlepage: + +\let\subtitlerm=\tenrm +\def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines} + +\def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines + \let\tt=\authortt} + +\parseargdef\title{% + \checkenv\titlepage + \leftline{\titlefonts\rm #1} + % print a rule at the page bottom also. + \finishedtitlepagefalse + \vskip4pt \hrule height 4pt width \hsize \vskip4pt +} + +\parseargdef\subtitle{% + \checkenv\titlepage + {\subtitlefont \rightline{#1}}% +} + +% @author should come last, but may come many times. +% It can also be used inside @quotation. +% +\parseargdef\author{% + \def\temp{\quotation}% + \ifx\thisenv\temp + \def\quotationauthor{#1}% printed in \Equotation. + \else + \checkenv\titlepage + \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi + {\authorfont \leftline{#1}}% + \fi +} + + %%% Set up page headings and footings. \let\thispage=\folio @@ -1673,7 +2076,7 @@ where each line of input produces a line of output.} \newtoks\evenfootline % footline on even pages \newtoks\oddfootline % footline on odd pages -% Now make Tex use those variables +% Now make TeX use those variables \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline \else \the\evenheadline \fi}} \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline @@ -1687,32 +2090,27 @@ where each line of input produces a line of output.} % @evenfooting @thisfile|| % @oddfooting ||@thisfile + \def\evenheading{\parsearg\evenheadingxxx} -\def\oddheading{\parsearg\oddheadingxxx} -\def\everyheading{\parsearg\everyheadingxxx} - -\def\evenfooting{\parsearg\evenfootingxxx} -\def\oddfooting{\parsearg\oddfootingxxx} -\def\everyfooting{\parsearg\everyfootingxxx} - -{\catcode`\@=0 % - -\gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish} -\gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{% +\def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish} +\def\evenheadingyyy #1\|#2\|#3\|#4\finish{% \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} -\gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish} -\gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{% +\def\oddheading{\parsearg\oddheadingxxx} +\def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish} +\def\oddheadingyyy #1\|#2\|#3\|#4\finish{% \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} -\gdef\everyheadingxxx#1{\oddheadingxxx{#1}\evenheadingxxx{#1}}% +\parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}% -\gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish} -\gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{% +\def\evenfooting{\parsearg\evenfootingxxx} +\def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish} +\def\evenfootingyyy #1\|#2\|#3\|#4\finish{% \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} -\gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish} -\gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{% +\def\oddfooting{\parsearg\oddfootingxxx} +\def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish} +\def\oddfootingyyy #1\|#2\|#3\|#4\finish{% \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}% % % Leave some space for the footline. Hopefully ok to assume @@ -1721,9 +2119,8 @@ where each line of input produces a line of output.} \global\advance\vsize by -\baselineskip } -\gdef\everyfootingxxx#1{\oddfootingxxx{#1}\evenfootingxxx{#1}} -% -}% unbind the catcode of @. +\parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}} + % @headings double turns headings on for double-sided printing. % @headings single turns headings on for single-sided printing. @@ -1737,7 +2134,7 @@ where each line of input produces a line of output.} \def\headings #1 {\csname HEADINGS#1\endcsname} -\def\HEADINGSoff{ +\def\HEADINGSoff{% \global\evenheadline={\hfil} \global\evenfootline={\hfil} \global\oddheadline={\hfil} \global\oddfootline={\hfil}} \HEADINGSoff @@ -1746,7 +2143,7 @@ where each line of input produces a line of output.} % chapter name on inside top of right hand pages, document % title on inside top of left hand pages, and page numbers on outside top % edge of all pages. -\def\HEADINGSdouble{ +\def\HEADINGSdouble{% \global\pageno=1 \global\evenfootline={\hfil} \global\oddfootline={\hfil} @@ -1758,7 +2155,7 @@ where each line of input produces a line of output.} % For single-sided printing, chapter title goes across top left of page, % page number on top right. -\def\HEADINGSsingle{ +\def\HEADINGSsingle{% \global\pageno=1 \global\evenfootline={\hfil} \global\oddfootline={\hfil} @@ -1805,12 +2202,11 @@ where each line of input produces a line of output.} % @settitle line... specifies the title of the document, for headings. % It generates no output of its own. \def\thistitle{\putwordNoTitle} -\def\settitle{\parsearg\settitlezzz} -\def\settitlezzz #1{\gdef\thistitle{#1}} +\def\settitle{\parsearg{\gdef\thistitle}} \message{tables,} -% Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x). +% Tables -- @table, @ftable, @vtable, @item(x). % default indentation of table text \newdimen\tableindent \tableindent=.8in @@ -1822,7 +2218,7 @@ where each line of input produces a line of output.} % used internally for \itemindent minus \itemmargin \newdimen\itemmax -% Note @table, @vtable, and @vtable define @item, @itemx, etc., with +% Note @table, @ftable, and @vtable define @item, @itemx, etc., with % these defs. % They also define \itemindex % to index the item name in whatever manner is desired (perhaps none). @@ -1834,22 +2230,10 @@ where each line of input produces a line of output.} \def\internalBitem{\smallbreak \parsearg\itemzzz} \def\internalBitemx{\itemxpar \parsearg\itemzzz} -\def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz} -\def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz} - -\def\internalBkitem{\smallbreak \parsearg\kitemzzz} -\def\internalBkitemx{\itemxpar \parsearg\kitemzzz} - -\def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}% - \itemzzz {#1}} - -\def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}% - \itemzzz {#1}} - \def\itemzzz #1{\begingroup % \advance\hsize by -\rightskip \advance\hsize by -\tableindent - \setbox0=\hbox{\itemfont{#1}}% + \setbox0=\hbox{\itemindicate{#1}}% \itemindex{#1}% \nobreak % This prevents a break before @itemx. % @@ -1873,10 +2257,18 @@ where each line of input produces a line of output.} % \parskip glue -- logically it's part of the @item we just started. \nobreak \vskip-\parskip % - % Stop a page break at the \parskip glue coming up. Unfortunately + % Stop a page break at the \parskip glue coming up. (Unfortunately % we can't prevent a possible page break at the following - % \baselineskip glue. - \nobreak + % \baselineskip glue.) However, if what follows is an environment + % such as @example, there will be no \parskip glue; then + % the negative vskip we just would cause the example and the item to + % crash together. So we use this bizarre value of 10001 as a signal + % to \aboveenvbreak to insert \parskip glue after all. + % (Possibly there are other commands that could be followed by + % @example which need the same treatment, but not section titles; or + % maybe section titles are the only special case and they should be + % penalty 10001...) + \penalty 10001 \endgroup \itemxneedsnegativevskipfalse \else @@ -1895,97 +2287,95 @@ where each line of input produces a line of output.} \fi } -\def\item{\errmessage{@item while not in a table}} -\def\itemx{\errmessage{@itemx while not in a table}} -\def\kitem{\errmessage{@kitem while not in a table}} -\def\kitemx{\errmessage{@kitemx while not in a table}} -\def\xitem{\errmessage{@xitem while not in a table}} -\def\xitemx{\errmessage{@xitemx while not in a table}} - -% Contains a kludge to get @end[description] to work. -\def\description{\tablez{\dontindex}{1}{}{}{}{}} +\def\item{\errmessage{@item while not in a list environment}} +\def\itemx{\errmessage{@itemx while not in a list environment}} % @table, @ftable, @vtable. -\def\table{\begingroup\inENV\obeylines\obeyspaces\tablex} -{\obeylines\obeyspaces% -\gdef\tablex #1^^M{% -\tabley\dontindex#1 \endtabley}} - -\def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex} -{\obeylines\obeyspaces% -\gdef\ftablex #1^^M{% -\tabley\fnitemindex#1 \endtabley -\def\Eftable{\endgraf\afterenvbreak\endgroup}% -\let\Etable=\relax}} - -\def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex} -{\obeylines\obeyspaces% -\gdef\vtablex #1^^M{% -\tabley\vritemindex#1 \endtabley -\def\Evtable{\endgraf\afterenvbreak\endgroup}% -\let\Etable=\relax}} - -\def\dontindex #1{} -\def\fnitemindex #1{\doind {fn}{\code{#1}}}% -\def\vritemindex #1{\doind {vr}{\code{#1}}}% - -{\obeyspaces % -\gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup% -\tablez{#1}{#2}{#3}{#4}{#5}{#6}}} - -\def\tablez #1#2#3#4#5#6{% -\aboveenvbreak % -\begingroup % -\def\Edescription{\Etable}% Necessary kludge. -\let\itemindex=#1% -\ifnum 0#3>0 \advance \leftskip by #3\mil \fi % -\ifnum 0#4>0 \tableindent=#4\mil \fi % -\ifnum 0#5>0 \advance \rightskip by #5\mil \fi % -\def\itemfont{#2}% -\itemmax=\tableindent % -\advance \itemmax by -\itemmargin % -\advance \leftskip by \tableindent % -\exdentamount=\tableindent -\parindent = 0pt -\parskip = \smallskipamount -\ifdim \parskip=0pt \parskip=2pt \fi% -\def\Etable{\endgraf\afterenvbreak\endgroup}% -\let\item = \internalBitem % -\let\itemx = \internalBitemx % -\let\kitem = \internalBkitem % -\let\kitemx = \internalBkitemx % -\let\xitem = \internalBxitem % -\let\xitemx = \internalBxitemx % +\envdef\table{% + \let\itemindex\gobble + \tablex } +\envdef\ftable{% + \def\itemindex ##1{\doind {fn}{\code{##1}}}% + \tablex +} +\envdef\vtable{% + \def\itemindex ##1{\doind {vr}{\code{##1}}}% + \tablex +} +\def\tablex#1{% + \def\itemindicate{#1}% + \parsearg\tabley +} +\def\tabley#1{% + {% + \makevalueexpandable + \edef\temp{\noexpand\tablez #1\space\space\space}% + \expandafter + }\temp \endtablez +} +\def\tablez #1 #2 #3 #4\endtablez{% + \aboveenvbreak + \ifnum 0#1>0 \advance \leftskip by #1\mil \fi + \ifnum 0#2>0 \tableindent=#2\mil \fi + \ifnum 0#3>0 \advance \rightskip by #3\mil \fi + \itemmax=\tableindent + \advance \itemmax by -\itemmargin + \advance \leftskip by \tableindent + \exdentamount=\tableindent + \parindent = 0pt + \parskip = \smallskipamount + \ifdim \parskip=0pt \parskip=2pt \fi + \let\item = \internalBitem + \let\itemx = \internalBitemx +} +\def\Etable{\endgraf\afterenvbreak} +\let\Eftable\Etable +\let\Evtable\Etable +\let\Eitemize\Etable +\let\Eenumerate\Etable % This is the counter used by @enumerate, which is really @itemize \newcount \itemno -\def\itemize{\parsearg\itemizezzz} +\envdef\itemize{\parsearg\doitemize} -\def\itemizezzz #1{% - \begingroup % ended by the @end itemize - \itemizey {#1}{\Eitemize} +\def\doitemize#1{% + \aboveenvbreak + \itemmax=\itemindent + \advance\itemmax by -\itemmargin + \advance\leftskip by \itemindent + \exdentamount=\itemindent + \parindent=0pt + \parskip=\smallskipamount + \ifdim\parskip=0pt \parskip=2pt \fi + \def\itemcontents{#1}% + % @itemize with no arg is equivalent to @itemize @bullet. + \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi + \let\item=\itemizeitem } -\def\itemizey #1#2{% -\aboveenvbreak % -\itemmax=\itemindent % -\advance \itemmax by -\itemmargin % -\advance \leftskip by \itemindent % -\exdentamount=\itemindent -\parindent = 0pt % -\parskip = \smallskipamount % -\ifdim \parskip=0pt \parskip=2pt \fi% -\def#2{\endgraf\afterenvbreak\endgroup}% -\def\itemcontents{#1}% -\let\item=\itemizeitem} - -% Set sfcode to normal for the chars that usually have another value. -% These are `.?!:;,' -\def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000 - \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 } +% Definition of @item while inside @itemize and @enumerate. +% +\def\itemizeitem{% + \advance\itemno by 1 % for enumerations + {\let\par=\endgraf \smallbreak}% reasonable place to break + {% + % If the document has an @itemize directly after a section title, a + % \nobreak will be last on the list, and \sectionheading will have + % done a \vskip-\parskip. In that case, we don't want to zero + % parskip, or the item text will crash with the heading. On the + % other hand, when there is normal text preceding the item (as there + % usually is), we do want to zero parskip, or there would be too much + % space. In that case, we won't have a \nobreak before. At least + % that's the theory. + \ifnum\lastpenalty<10000 \parskip=0in \fi + \noindent + \hbox to 0pt{\hss \itemcontents \kern\itemmargin}% + \vadjust{\penalty 1200}}% not good to break after first line of item. + \flushcr +} % \splitoff TOKENS\endmark defines \first to be the first token in % TOKENS, and \rest to be the remainder. @@ -1996,11 +2386,8 @@ where each line of input produces a line of output.} % or number, to specify the first label in the enumerated list. No % argument is the same as `1'. % -\def\enumerate{\parsearg\enumeratezzz} -\def\enumeratezzz #1{\enumeratey #1 \endenumeratey} +\envparseargdef\enumerate{\enumeratey #1 \endenumeratey} \def\enumeratey #1 #2\endenumeratey{% - \begingroup % ended by the @end enumerate - % % If we were given no argument, pretend we were given `1'. \def\thearg{#1}% \ifx\thearg\empty \def\thearg{1}\fi @@ -2071,13 +2458,13 @@ where each line of input produces a line of output.} }% } -% Call itemizey, adding a period to the first argument and supplying the +% Call \doitemize, adding a period to the first argument and supplying the % common last two arguments. Also subtract one from the initial value in % \itemno, since @item increments \itemno. % \def\startenumeration#1{% \advance\itemno by -1 - \itemizey{#1.}\Eenumerate\flushcr + \doitemize{#1.}\flushcr } % @alphaenumerate and @capsenumerate are abbreviations for giving an arg @@ -2088,16 +2475,6 @@ where each line of input produces a line of output.} \def\Ealphaenumerate{\Eenumerate} \def\Ecapsenumerate{\Eenumerate} -% Definition of @item while inside @itemize. - -\def\itemizeitem{% -\advance\itemno by 1 -{\let\par=\endgraf \smallbreak}% -\ifhmode \errmessage{In hmode at itemizeitem}\fi -{\parskip=0in \hskip 0pt -\hbox to 0pt{\hss \itemcontents\hskip \itemmargin}% -\vadjust{\penalty 1200}}% -\flushcr} % @multitable macros % Amy Hendrickson, 8/18/94, 3/6/96 @@ -2124,24 +2501,14 @@ where each line of input produces a line of output.} % @multitable {Column 1 template} {Column 2 template} {Column 3 template} % @item ... % using the widest term desired in each column. -% -% For those who want to use more than one line's worth of words in -% the preamble, break the line within one argument and it -% will parse correctly, i.e., -% -% @multitable {Column 1 template} {Column 2 template} {Column 3 -% template} -% Not: -% @multitable {Column 1 template} {Column 2 template} -% {Column 3 template} % Each new table line starts with @item, each subsequent new column % starts with @tab. Empty columns may be produced by supplying @tab's % with nothing between them for as many times as empty columns are needed, % ie, @tab@tab@tab will produce two empty columns. -% @item, @tab, @multitable or @end multitable do not need to be on their -% own lines, but it will not hurt if they are. +% @item, @tab do not need to be on their own lines, but it will not hurt +% if they are. % Sample multitable: @@ -2185,13 +2552,12 @@ where each line of input produces a line of output.} \def\xcolumnfractions{\columnfractions} \newif\ifsetpercent -% #1 is the part of the @columnfraction before the decimal point, which -% is presumably either 0 or the empty string (but we don't check, we -% just throw it away). #2 is the decimal part, which we use as the -% percent of \hsize for this column. -\def\pickupwholefraction#1.#2 {% +% #1 is the @columnfraction, usually a decimal number like .5, but might +% be just 1. We just use it, whatever it is. +% +\def\pickupwholefraction#1 {% \global\advance\colcount by 1 - \expandafter\xdef\csname col\the\colcount\endcsname{.#2\hsize}% + \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}% \setuptable } @@ -2208,8 +2574,8 @@ where each line of input produces a line of output.} \let\go\pickupwholefraction \else \global\advance\colcount by 1 - \setbox0=\hbox{#1\unskip }% Add a normal word space as a separator; - % typically that is always in the input, anyway. + \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a + % separator; typically that is always in the input, anyway. \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% \fi \fi @@ -2224,18 +2590,30 @@ where each line of input produces a line of output.} \go } -% This used to have \hskip1sp. But then the space in a template line is -% not enough. That is bad. So let's go back to just & until we -% encounter the problem it was intended to solve again. -% --karl, nathan@acm.org, 20apr99. -\def\tab{&} +% multitable-only commands. +% +% @headitem starts a heading row, which we typeset in bold. +% Assignments have to be global since we are inside the implicit group +% of an alignment entry. Note that \everycr resets \everytab. +\def\headitem{\checkenv\multitable \crcr \global\everytab={\bf}\the\everytab}% +% +% A \tab used to include \hskip1sp. But then the space in a template +% line is not enough. That is bad. So let's go back to just `&' until +% we encounter the problem it was intended to solve again. +% --karl, nathan@acm.org, 20apr99. +\def\tab{\checkenv\multitable &\the\everytab}% % @multitable ... @end multitable definitions: % -\def\multitable{\parsearg\dotable} -\def\dotable#1{\bgroup +\newtoks\everytab % insert after every tab. +% +\envdef\multitable{% \vskip\parskip + \startsavinginserts + % + % @item within a multitable starts a normal row. \let\item\crcr + % \tolerance=9500 \hbadness=9500 \setmultitablespacing @@ -2243,66 +2621,80 @@ where each line of input produces a line of output.} \parindent=\multitableparindent \overfullrule=0pt \global\colcount=0 - \def\Emultitable{\global\setpercentfalse\cr\egroup\egroup}% % + \everycr = {% + \noalign{% + \global\everytab={}% + \global\colcount=0 % Reset the column counter. + % Check for saved footnotes, etc. + \checkinserts + % Keeps underfull box messages off when table breaks over pages. + %\filbreak + % Maybe so, but it also creates really weird page breaks when the + % table breaks over pages. Wouldn't \vfil be better? Wait until the + % problem manifests itself, so it can be fixed for real --karl. + }% + }% + % + \parsearg\domultitable +} +\def\domultitable#1{% % To parse everything between @multitable and @item: \setuptable#1 \endsetuptable % - % \everycr will reset column counter, \colcount, at the end of - % each line. Every column entry will cause \colcount to advance by one. - % The table preamble - % looks at the current \colcount to find the correct column width. - \everycr{\noalign{% - % - % \filbreak%% keeps underfull box messages off when table breaks over pages. - % Maybe so, but it also creates really weird page breaks when the table - % breaks over pages. Wouldn't \vfil be better? Wait until the problem - % manifests itself, so it can be fixed for real --karl. - \global\colcount=0\relax}}% - % % This preamble sets up a generic column definition, which will % be used as many times as user calls for columns. % \vtop will set a single line and will also let text wrap and % continue for many paragraphs if desired. - \halign\bgroup&\global\advance\colcount by 1\relax - \multistrut\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname - % - % In order to keep entries from bumping into each other - % we will add a \leftskip of \multitablecolspace to all columns after - % the first one. - % - % If a template has been used, we will add \multitablecolspace - % to the width of each template entry. - % - % If the user has set preamble in terms of percent of \hsize we will - % use that dimension as the width of the column, and the \leftskip - % will keep entries from bumping into each other. Table will start at - % left margin and final column will justify at right margin. - % - % Make sure we don't inherit \rightskip from the outer environment. - \rightskip=0pt - \ifnum\colcount=1 - % The first column will be indented with the surrounding text. - \advance\hsize by\leftskip - \else - \ifsetpercent \else - % If user has not set preamble in terms of percent of \hsize - % we will advance \hsize by \multitablecolspace. - \advance\hsize by \multitablecolspace - \fi - % In either case we will make \leftskip=\multitablecolspace: - \leftskip=\multitablecolspace - \fi - % Ignoring space at the beginning and end avoids an occasional spurious - % blank line, when TeX decides to break the line at the space before the - % box from the multistrut, so the strut ends up on a line by itself. - % For example: - % @multitable @columnfractions .11 .89 - % @item @code{#} - % @tab Legal holiday which is valid in major parts of the whole country. - % Is automatically provided with highlighting sequences respectively marking - % characters. - \noindent\ignorespaces##\unskip\multistrut}\cr + \halign\bgroup &% + \global\advance\colcount by 1 + \multistrut + \vtop{% + % Use the current \colcount to find the correct column width: + \hsize=\expandafter\csname col\the\colcount\endcsname + % + % In order to keep entries from bumping into each other + % we will add a \leftskip of \multitablecolspace to all columns after + % the first one. + % + % If a template has been used, we will add \multitablecolspace + % to the width of each template entry. + % + % If the user has set preamble in terms of percent of \hsize we will + % use that dimension as the width of the column, and the \leftskip + % will keep entries from bumping into each other. Table will start at + % left margin and final column will justify at right margin. + % + % Make sure we don't inherit \rightskip from the outer environment. + \rightskip=0pt + \ifnum\colcount=1 + % The first column will be indented with the surrounding text. + \advance\hsize by\leftskip + \else + \ifsetpercent \else + % If user has not set preamble in terms of percent of \hsize + % we will advance \hsize by \multitablecolspace. + \advance\hsize by \multitablecolspace + \fi + % In either case we will make \leftskip=\multitablecolspace: + \leftskip=\multitablecolspace + \fi + % Ignoring space at the beginning and end avoids an occasional spurious + % blank line, when TeX decides to break the line at the space before the + % box from the multistrut, so the strut ends up on a line by itself. + % For example: + % @multitable @columnfractions .11 .89 + % @item @code{#} + % @tab Legal holiday which is valid in major parts of the whole country. + % Is automatically provided with highlighting sequences respectively + % marking characters. + \noindent\ignorespaces##\unskip\multistrut + }\cr +} +\def\Emultitable{% + \crcr + \egroup % end the \halign + \global\setpercentfalse } \def\setmultitablespacing{% test to see if user has set \multitablelinespace. @@ -2334,237 +2726,108 @@ width0pt\relax} \fi \message{conditionals,} -% Prevent errors for section commands. -% Used in @ignore and in failing conditionals. -\def\ignoresections{% - \let\chapter=\relax - \let\unnumbered=\relax - \let\top=\relax - \let\unnumberedsec=\relax - \let\unnumberedsection=\relax - \let\unnumberedsubsec=\relax - \let\unnumberedsubsection=\relax - \let\unnumberedsubsubsec=\relax - \let\unnumberedsubsubsection=\relax - \let\section=\relax - \let\subsec=\relax - \let\subsubsec=\relax - \let\subsection=\relax - \let\subsubsection=\relax - \let\appendix=\relax - \let\appendixsec=\relax - \let\appendixsection=\relax - \let\appendixsubsec=\relax - \let\appendixsubsection=\relax - \let\appendixsubsubsec=\relax - \let\appendixsubsubsection=\relax - \let\contents=\relax - \let\smallbook=\relax - \let\titlepage=\relax -} -% Used in nested conditionals, where we have to parse the Texinfo source -% and so want to turn off most commands, in case they are used -% incorrectly. +% @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext, +% @ifnotxml always succeed. They currently do nothing; we don't +% attempt to check whether the conditionals are properly nested. But we +% have to remember that they are conditionals, so that @end doesn't +% attempt to close an environment group. % -\def\ignoremorecommands{% - \let\defcodeindex = \relax - \let\defcv = \relax - \let\deffn = \relax - \let\deffnx = \relax - \let\defindex = \relax - \let\defivar = \relax - \let\defmac = \relax - \let\defmethod = \relax - \let\defop = \relax - \let\defopt = \relax - \let\defspec = \relax - \let\deftp = \relax - \let\deftypefn = \relax - \let\deftypefun = \relax - \let\deftypeivar = \relax - \let\deftypeop = \relax - \let\deftypevar = \relax - \let\deftypevr = \relax - \let\defun = \relax - \let\defvar = \relax - \let\defvr = \relax - \let\ref = \relax - \let\xref = \relax - \let\printindex = \relax - \let\pxref = \relax - \let\settitle = \relax - \let\setchapternewpage = \relax - \let\setchapterstyle = \relax - \let\everyheading = \relax - \let\evenheading = \relax - \let\oddheading = \relax - \let\everyfooting = \relax - \let\evenfooting = \relax - \let\oddfooting = \relax - \let\headings = \relax - \let\include = \relax - \let\lowersections = \relax - \let\down = \relax - \let\raisesections = \relax - \let\up = \relax - \let\set = \relax - \let\clear = \relax - \let\item = \relax +\def\makecond#1{% + \expandafter\let\csname #1\endcsname = \relax + \expandafter\let\csname iscond.#1\endcsname = 1 } +\makecond{iftex} +\makecond{ifnotdocbook} +\makecond{ifnothtml} +\makecond{ifnotinfo} +\makecond{ifnotplaintext} +\makecond{ifnotxml} -% Ignore @ignore, @ifhtml, @ifinfo, @ifplaintext, @ifnottex, @html, @menu, -% @direntry, and @documentdescription. +% Ignore @ignore, @ifhtml, @ifinfo, and the like. % -\def\ignore{\doignore{ignore}} -\def\ifhtml{\doignore{ifhtml}} -\def\ifinfo{\doignore{ifinfo}} -\def\ifplaintext{\doignore{ifplaintext}} -\def\ifnottex{\doignore{ifnottex}} -\def\html{\doignore{html}} -\def\menu{\doignore{menu}} \def\direntry{\doignore{direntry}} \def\documentdescription{\doignore{documentdescription}} -\def\documentdescriptionword{documentdescription} +\def\docbook{\doignore{docbook}} +\def\html{\doignore{html}} +\def\ifdocbook{\doignore{ifdocbook}} +\def\ifhtml{\doignore{ifhtml}} +\def\ifinfo{\doignore{ifinfo}} +\def\ifnottex{\doignore{ifnottex}} +\def\ifplaintext{\doignore{ifplaintext}} +\def\ifxml{\doignore{ifxml}} +\def\ignore{\doignore{ignore}} +\def\menu{\doignore{menu}} +\def\xml{\doignore{xml}} -% @dircategory CATEGORY -- specify a category of the dir file -% which this file should belong to. Ignore this in TeX. -\let\dircategory = \comment - -% Ignore text until a line `@end #1'. +% Ignore text until a line `@end #1', keeping track of nested conditionals. % +% A count to remember the depth of nesting. +\newcount\doignorecount + \def\doignore#1{\begingroup - % Don't complain about control sequences we have declared \outer. - \ignoresections - % - % Define a command to swallow text until we reach `@end #1'. - % This @ is a catcode 12 token (that is the normal catcode of @ in - % this texinfo.tex file). We change the catcode of @ below to match. - \long\def\doignoretext##1@end #1{\enddoignore}% + % Scan in ``verbatim'' mode: + \catcode`\@ = \other + \catcode`\{ = \other + \catcode`\} = \other % % Make sure that spaces turn into tokens that match what \doignoretext wants. - \catcode32 = 10 + \spaceisspace % - % Ignore braces, too, so mismatched braces don't cause trouble. - \catcode`\{ = 9 - \catcode`\} = 9 + % Count number of #1's that we've seen. + \doignorecount = 0 % - % We must not have @c interpreted as a control sequence. - \catcode`\@ = 12 + % Swallow text until we reach the matching `@end #1'. + \dodoignore {#1}% +} + +{ \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source. + \obeylines % % - \def\ignoreword{#1}% - \ifx\ignoreword\documentdescriptionword - % The c kludge breaks documentdescription, since - % `documentdescription' contains a `c'. Means not everything will - % be ignored inside @documentdescription, but oh well... - \else - % Make the letter c a comment character so that the rest of the line - % will be ignored. This way, the document can have (for example) - % @c @end ifinfo - % and the @end ifinfo will be properly ignored. - % (We've just changed @ to catcode 12.) - \catcode`\c = 14 + \gdef\dodoignore#1{% + % #1 contains the string `ifinfo'. + % + % Define a command to find the next `@end #1', which must be on a line + % by itself. + \long\def\doignoretext##1^^M@end #1{\doignoretextyyy##1^^M@#1\_STOP_}% + % And this command to find another #1 command, at the beginning of a + % line. (Otherwise, we would consider a line `@c @ifset', for + % example, to count as an @ifset for nesting.) + \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}% + % + % And now expand that command. + \obeylines % + \doignoretext ^^M% + }% +} + +\def\doignoreyyy#1{% + \def\temp{#1}% + \ifx\temp\empty % Nothing found. + \let\next\doignoretextzzz + \else % Found a nested condition, ... + \advance\doignorecount by 1 + \let\next\doignoretextyyy % ..., look for another. + % If we're here, #1 ends with ^^M\ifinfo (for example). \fi - % - % And now expand the command defined above. - \doignoretext + \next #1% the token \_STOP_ is present just after this macro. } -% What we do to finish off ignored text. -% -\def\enddoignore{\endgroup\ignorespaces}% - -\newif\ifwarnedobs\warnedobsfalse -\def\obstexwarn{% - \ifwarnedobs\relax\else - % We need to warn folks that they may have trouble with TeX 3.0. - % This uses \immediate\write16 rather than \message to get newlines. - \immediate\write16{} - \immediate\write16{WARNING: for users of Unix TeX 3.0!} - \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).} - \immediate\write16{If you are running another version of TeX, relax.} - \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.} - \immediate\write16{ Then upgrade your TeX installation if you can.} - \immediate\write16{ (See ftp://ftp.gnu.org/pub/gnu/TeX.README.)} - \immediate\write16{If you are stuck with version 3.0, run the} - \immediate\write16{ script ``tex3patch'' from the Texinfo distribution} - \immediate\write16{ to use a workaround.} - \immediate\write16{} - \global\warnedobstrue - \fi +% We have to swallow the remaining "\_STOP_". +% +\def\doignoretextzzz#1{% + \ifnum\doignorecount = 0 % We have just found the outermost @end. + \let\next\enddoignore + \else % Still inside a nested condition. + \advance\doignorecount by -1 + \let\next\doignoretext % Look for the next @end. + \fi + \next } -% **In TeX 3.0, setting text in \nullfont hangs tex. For a -% workaround (which requires the file ``dummy.tfm'' to be installed), -% uncomment the following line: -%%%%%\font\nullfont=dummy\let\obstexwarn=\relax +% Finish off ignored text. +\def\enddoignore{\endgroup\ignorespaces} -% Ignore text, except that we keep track of conditional commands for -% purposes of nesting, up to an `@end #1' command. -% -\def\nestedignore#1{% - \obstexwarn - % We must actually expand the ignored text to look for the @end - % command, so that nested ignore constructs work. Thus, we put the - % text into a \vbox and then do nothing with the result. To minimize - % the change of memory overflow, we follow the approach outlined on - % page 401 of the TeXbook: make the current font be a dummy font. - % - \setbox0 = \vbox\bgroup - % Don't complain about control sequences we have declared \outer. - \ignoresections - % - % Define `@end #1' to end the box, which will in turn undefine the - % @end command again. - \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}% - % - % We are going to be parsing Texinfo commands. Most cause no - % trouble when they are used incorrectly, but some commands do - % complicated argument parsing or otherwise get confused, so we - % undefine them. - % - % We can't do anything about stray @-signs, unfortunately; - % they'll produce `undefined control sequence' errors. - \ignoremorecommands - % - % Set the current font to be \nullfont, a TeX primitive, and define - % all the font commands to also use \nullfont. We don't use - % dummy.tfm, as suggested in the TeXbook, because not all sites - % might have that installed. Therefore, math mode will still - % produce output, but that should be an extremely small amount of - % stuff compared to the main input. - % - \nullfont - \let\tenrm=\nullfont \let\tenit=\nullfont \let\tensl=\nullfont - \let\tenbf=\nullfont \let\tentt=\nullfont \let\smallcaps=\nullfont - \let\tensf=\nullfont - % Similarly for index fonts. - \let\smallrm=\nullfont \let\smallit=\nullfont \let\smallsl=\nullfont - \let\smallbf=\nullfont \let\smalltt=\nullfont \let\smallsc=\nullfont - \let\smallsf=\nullfont - % Similarly for smallexample fonts. - \let\smallerrm=\nullfont \let\smallerit=\nullfont \let\smallersl=\nullfont - \let\smallerbf=\nullfont \let\smallertt=\nullfont \let\smallersc=\nullfont - \let\smallersf=\nullfont - % - % Don't complain when characters are missing from the fonts. - \tracinglostchars = 0 - % - % Don't bother to do space factor calculations. - \frenchspacing - % - % Don't report underfull hboxes. - \hbadness = 10000 - % - % Do minimal line-breaking. - \pretolerance = 10000 - % - % Do not execute instructions in @tex - \def\tex{\doignore{tex}}% - % Do not execute macro definitions. - % `c' is a comment character, so the word `macro' will get cut off. - \def\macro{\doignore{ma}}% -} % @set VAR sets the variable VAR to an empty value. % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. @@ -2572,56 +2835,63 @@ width0pt\relax} \fi % Since we want to separate VAR from REST-OF-LINE (which might be % empty), we can't just use \parsearg; we have to insert a space of our % own to delimit the rest of the line, and then take it out again if we -% didn't need it. Make sure the catcode of space is correct to avoid -% losing inside @example, for instance. +% didn't need it. +% We rely on the fact that \parsearg sets \catcode`\ =10. % -\def\set{\begingroup\catcode` =10 - \catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR. - \parsearg\setxxx} -\def\setxxx#1{\setyyy#1 \endsetyyy} +\parseargdef\set{\setyyy#1 \endsetyyy} \def\setyyy#1 #2\endsetyyy{% - \def\temp{#2}% - \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty - \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted. - \fi - \endgroup + {% + \makevalueexpandable + \def\temp{#2}% + \edef\next{\gdef\makecsname{SET#1}}% + \ifx\temp\empty + \next{}% + \else + \setzzz#2\endsetzzz + \fi + }% } -% Can't use \xdef to pre-expand #2 and save some time, since \temp or -% \next or other control sequences that we've defined might get us into -% an infinite loop. Consider `@set foo @cite{bar}'. -\def\setzzz#1#2 \endsetzzz{\expandafter\gdef\csname SET#1\endcsname{#2}} +% Remove the trailing space \setxxx inserted. +\def\setzzz#1 \endsetzzz{\next{#1}} % @clear VAR clears (i.e., unsets) the variable VAR. % -\def\clear{\parsearg\clearxxx} -\def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax} +\parseargdef\clear{% + {% + \makevalueexpandable + \global\expandafter\let\csname SET#1\endcsname=\relax + }% +} % @value{foo} gets the text saved in variable foo. -{ - \catcode`\_ = \active - % - % We might end up with active _ or - characters in the argument if - % we're called from @code, as @code{@value{foo-bar_}}. So \let any - % such active characters to their normal equivalents. - \gdef\value{\begingroup - \catcode`\-=12 \catcode`\_=12 - \indexbreaks \let_\normalunderscore - \valuexxx} -} +\def\value{\begingroup\makevalueexpandable\valuexxx} \def\valuexxx#1{\expandablevalue{#1}\endgroup} +{ + \catcode`\- = \active \catcode`\_ = \active + % + \gdef\makevalueexpandable{% + \let\value = \expandablevalue + % We don't want these characters active, ... + \catcode`\-=\other \catcode`\_=\other + % ..., but we might end up with active ones in the argument if + % we're called from @code, as @code{@value{foo-bar_}}, though. + % So \let them to their normal equivalents. + \let-\realdash \let_\normalunderscore + } +} % We have this subroutine so that we can handle at least some @value's -% properly in indexes (we \let\value to this in \indexdummies). Ones -% whose names contain - or _ still won't work, but we can't do anything -% about that. The command has to be fully expandable, since the result -% winds up in the index file. This means that if the variable's value -% contains other Texinfo commands, it's almost certain it will fail -% (although perhaps we could fix that with sufficient work to do a -% one-level expansion on the result, instead of complete). +% properly in indexes (we call \makevalueexpandable in \indexdummies). +% The command has to be fully expandable (if the variable is set), since +% the result winds up in the index file. This means that if the +% variable's value contains other Texinfo commands, it's almost certain +% it will fail (although perhaps we could fix that with sufficient work +% to do a one-level expansion on the result, instead of complete). % \def\expandablevalue#1{% \expandafter\ifx\csname SET#1\endcsname\relax {[No value for ``#1'']}% + \message{Variable `#1', used in @value, is not set.}% \else \csname SET#1\endcsname \fi @@ -2630,68 +2900,36 @@ width0pt\relax} \fi % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined % with @set. % -\def\ifset{\parsearg\ifsetxxx} -\def\ifsetxxx #1{% - \expandafter\ifx\csname SET#1\endcsname\relax - \expandafter\ifsetfail - \else - \expandafter\ifsetsucceed - \fi +% To get special treatment of `@end ifset,' call \makeond and the redefine. +% +\makecond{ifset} +\def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}} +\def\doifset#1#2{% + {% + \makevalueexpandable + \let\next=\empty + \expandafter\ifx\csname SET#2\endcsname\relax + #1% If not set, redefine \next. + \fi + \expandafter + }\next } -\def\ifsetsucceed{\conditionalsucceed{ifset}} -\def\ifsetfail{\nestedignore{ifset}} -\defineunmatchedend{ifset} +\def\ifsetfail{\doignore{ifset}} % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been % defined with @set, or has been undefined with @clear. % -\def\ifclear{\parsearg\ifclearxxx} -\def\ifclearxxx #1{% - \expandafter\ifx\csname SET#1\endcsname\relax - \expandafter\ifclearsucceed - \else - \expandafter\ifclearfail - \fi -} -\def\ifclearsucceed{\conditionalsucceed{ifclear}} -\def\ifclearfail{\nestedignore{ifclear}} -\defineunmatchedend{ifclear} - -% @iftex, @ifnothtml, @ifnotinfo, @ifnotplaintext always succeed; we -% read the text following, through the first @end iftex (etc.). Make -% `@end iftex' (etc.) valid only after an @iftex. +% The `\else' inside the `\doifset' parameter is a trick to reuse the +% above code: if the variable is not set, do nothing, if it is set, +% then redefine \next to \ifclearfail. % -\def\iftex{\conditionalsucceed{iftex}} -\def\ifnothtml{\conditionalsucceed{ifnothtml}} -\def\ifnotinfo{\conditionalsucceed{ifnotinfo}} -\def\ifnotplaintext{\conditionalsucceed{ifnotplaintext}} -\defineunmatchedend{iftex} -\defineunmatchedend{ifnothtml} -\defineunmatchedend{ifnotinfo} -\defineunmatchedend{ifnotplaintext} +\makecond{ifclear} +\def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}} +\def\ifclearfail{\doignore{ifclear}} -% We can't just want to start a group at @iftex (etc.) and end it at -% @end iftex, since then @set commands inside the conditional have no -% effect (they'd get reverted at the end of the group). So we must -% define \Eiftex to redefine itself to be its previous value. (We can't -% just define it to fail again with an ``unmatched end'' error, since -% the @ifset might be nested.) -% -\def\conditionalsucceed#1{% - \edef\temp{% - % Remember the current value of \E#1. - \let\nece{prevE#1} = \nece{E#1}% - % - % At the `@end #1', redefine \E#1 to be its previous value. - \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}% - }% - \temp -} - -% We need to expand lots of \csname's, but we don't want to expand the -% control sequences after we've constructed them. -% -\def\nece#1{\expandafter\noexpand\csname#1\endcsname} +% @dircategory CATEGORY -- specify a category of the dir file +% which this file should belong to. Ignore this in TeX. +\let\dircategory=\comment % @defininfoenclose. \let\definfoenclose=\comment @@ -2742,10 +2980,10 @@ width0pt\relax} \fi % @synindex foo bar makes index foo feed into index bar. % Do this instead of @defindex foo if you don't want it as a separate index. -% +% % @syncodeindex foo bar similar, but put all entries made for index foo % inside @code. -% +% \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}} \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}} @@ -2784,284 +3022,391 @@ width0pt\relax} \fi \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} -% Take care of texinfo commands likely to appear in an index entry. -% (Must be a way to avoid doing expansion at all, and thus not have to -% laboriously list every single command here.) -% +% Take care of Texinfo commands that can appear in an index entry. +% Since there are some commands we want to expand, and others we don't, +% we have to laboriously prevent expansion for those that we don't. +% \def\indexdummies{% -\def\ { }% -\def\@{@}% change to @@ when we switch to @ as escape char in aux files. -% Need these in case \tex is in effect and \{ is a \delimiter again. -% But can't use \lbracecmd and \rbracecmd because texindex assumes -% braces and backslashes are used only as delimiters. -\let\{ = \mylbrace -\let\} = \myrbrace -\def\_{{\realbackslash _}}% -\normalturnoffactive -% -% Take care of the plain tex accent commands. -\def\,##1{\realbackslash ,{##1}}% -\def\"{\realbackslash "}% -\def\`{\realbackslash `}% -\def\'{\realbackslash '}% -\def\^{\realbackslash ^}% -\def\~{\realbackslash ~}% -\def\={\realbackslash =}% -\def\b{\realbackslash b}% -\def\c{\realbackslash c}% -\def\d{\realbackslash d}% -\def\u{\realbackslash u}% -\def\v{\realbackslash v}% -\def\H{\realbackslash H}% -\def\dotless##1{\realbackslash dotless {##1}}% -% Take care of the plain tex special European modified letters. -\def\AA{\realbackslash AA}% -\def\AE{\realbackslash AE}% -\def\L{\realbackslash L}% -\def\OE{\realbackslash OE}% -\def\O{\realbackslash O}% -\def\aa{\realbackslash aa}% -\def\ae{\realbackslash ae}% -\def\l{\realbackslash l}% -\def\oe{\realbackslash oe}% -\def\o{\realbackslash o}% -\def\ss{\realbackslash ss}% -% -% Although these internals commands shouldn't show up, sometimes they do. -\def\bf{\realbackslash bf }% -\def\gtr{\realbackslash gtr}% -\def\hat{\realbackslash hat}% -\def\less{\realbackslash less}% -%\def\rm{\realbackslash rm }% -\def\sf{\realbackslash sf}% -\def\sl{\realbackslash sl }% -\def\tclose##1{\realbackslash tclose {##1}}% -\def\tt{\realbackslash tt}% -% -\def\b##1{\realbackslash b {##1}}% -\def\i##1{\realbackslash i {##1}}% -\def\sc##1{\realbackslash sc {##1}}% -\def\t##1{\realbackslash t {##1}}% -\def\r##1{\realbackslash r {##1}}% -% -\def\TeX{\realbackslash TeX}% -\def\acronym##1{\realbackslash acronym {##1}}% -\def\cite##1{\realbackslash cite {##1}}% -\def\code##1{\realbackslash code {##1}}% -\def\command##1{\realbackslash command {##1}}% -\def\dfn##1{\realbackslash dfn {##1}}% -\def\dots{\realbackslash dots }% -\def\emph##1{\realbackslash emph {##1}}% -\def\env##1{\realbackslash env {##1}}% -\def\file##1{\realbackslash file {##1}}% -\def\kbd##1{\realbackslash kbd {##1}}% -\def\key##1{\realbackslash key {##1}}% -\def\math##1{\realbackslash math {##1}}% -\def\option##1{\realbackslash option {##1}}% -\def\samp##1{\realbackslash samp {##1}}% -\def\strong##1{\realbackslash strong {##1}}% -\def\uref##1{\realbackslash uref {##1}}% -\def\url##1{\realbackslash url {##1}}% -\def\var##1{\realbackslash var {##1}}% -\def\w{\realbackslash w }% -% -% These math commands don't seem likely to be used in index entries. -\def\copyright{\realbackslash copyright}% -\def\equiv{\realbackslash equiv}% -\def\error{\realbackslash error}% -\def\expansion{\realbackslash expansion}% -\def\point{\realbackslash point}% -\def\print{\realbackslash print}% -\def\result{\realbackslash result}% -% -% Handle some cases of @value -- where the variable name does not -% contain - or _, and the value does not contain any -% (non-fully-expandable) commands. -\let\value = \expandablevalue -% -\unsepspaces -% Turn off macro expansion -\turnoffmacros + \def\@{@}% change to @@ when we switch to @ as escape char in index files. + \def\ {\realbackslash\space }% + % Need these in case \tex is in effect and \{ is a \delimiter again. + % But can't use \lbracecmd and \rbracecmd because texindex assumes + % braces and backslashes are used only as delimiters. + \let\{ = \mylbrace + \let\} = \myrbrace + % + % \definedummyword defines \#1 as \realbackslash #1\space, thus + % effectively preventing its expansion. This is used only for control + % words, not control letters, because the \space would be incorrect + % for control characters, but is needed to separate the control word + % from whatever follows. + % + % For control letters, we have \definedummyletter, which omits the + % space. + % + % These can be used both for control words that take an argument and + % those that do not. If it is followed by {arg} in the input, then + % that will dutifully get written to the index (or wherever). + % + \def\definedummyword##1{% + \expandafter\def\csname ##1\endcsname{\realbackslash ##1\space}% + }% + \def\definedummyletter##1{% + \expandafter\def\csname ##1\endcsname{\realbackslash ##1}% + }% + % + % Do the redefinitions. + \commondummies } -% If an index command is used in an @example environment, any spaces -% therein should become regular spaces in the raw index file, not the -% expansion of \tie (\leavevmode \penalty \@M \ ). -{\obeyspaces - \gdef\unsepspaces{\obeyspaces\let =\space}} +% For the aux file, @ is the escape character. So we want to redefine +% everything using @ instead of \realbackslash. When everything uses +% @, this will be simpler. +% +\def\atdummies{% + \def\@{@@}% + \def\ {@ }% + \let\{ = \lbraceatcmd + \let\} = \rbraceatcmd + % + % (See comments in \indexdummies.) + \def\definedummyword##1{% + \expandafter\def\csname ##1\endcsname{@##1\space}% + }% + \def\definedummyletter##1{% + \expandafter\def\csname ##1\endcsname{@##1}% + }% + % + % Do the redefinitions. + \commondummies +} -% \indexnofonts no-ops all font-change commands. -% This is used when outputting the strings to sort the index by. -\def\indexdummyfont#1{#1} -\def\indexdummytex{TeX} -\def\indexdummydots{...} +% Called from \indexdummies and \atdummies. \definedummyword and +% \definedummyletter must be defined first. +% +\def\commondummies{% + % + \normalturnoffactive + % + \commondummiesnofonts + % + \definedummyletter{_}% + % + % Non-English letters. + \definedummyword{AA}% + \definedummyword{AE}% + \definedummyword{L}% + \definedummyword{OE}% + \definedummyword{O}% + \definedummyword{aa}% + \definedummyword{ae}% + \definedummyword{l}% + \definedummyword{oe}% + \definedummyword{o}% + \definedummyword{ss}% + \definedummyword{exclamdown}% + \definedummyword{questiondown}% + \definedummyword{ordf}% + \definedummyword{ordm}% + % + % Although these internal commands shouldn't show up, sometimes they do. + \definedummyword{bf}% + \definedummyword{gtr}% + \definedummyword{hat}% + \definedummyword{less}% + \definedummyword{sf}% + \definedummyword{sl}% + \definedummyword{tclose}% + \definedummyword{tt}% + % + \definedummyword{LaTeX}% + \definedummyword{TeX}% + % + % Assorted special characters. + \definedummyword{bullet}% + \definedummyword{copyright}% + \definedummyword{registeredsymbol}% + \definedummyword{dots}% + \definedummyword{enddots}% + \definedummyword{equiv}% + \definedummyword{error}% + \definedummyword{expansion}% + \definedummyword{minus}% + \definedummyword{pounds}% + \definedummyword{point}% + \definedummyword{print}% + \definedummyword{result}% + % + % Handle some cases of @value -- where it does not contain any + % (non-fully-expandable) commands. + \makevalueexpandable + % + % Normal spaces, not active ones. + \unsepspaces + % + % No macro expansion. + \turnoffmacros +} +% \commondummiesnofonts: common to \commondummies and \indexnofonts. +% +% Better have this without active chars. +{ + \catcode`\~=\other + \gdef\commondummiesnofonts{% + % Control letters and accents. + \definedummyletter{!}% + \definedummyletter{"}% + \definedummyletter{'}% + \definedummyletter{*}% + \definedummyletter{,}% + \definedummyletter{.}% + \definedummyletter{/}% + \definedummyletter{:}% + \definedummyletter{=}% + \definedummyletter{?}% + \definedummyletter{^}% + \definedummyletter{`}% + \definedummyletter{~}% + \definedummyword{u}% + \definedummyword{v}% + \definedummyword{H}% + \definedummyword{dotaccent}% + \definedummyword{ringaccent}% + \definedummyword{tieaccent}% + \definedummyword{ubaraccent}% + \definedummyword{udotaccent}% + \definedummyword{dotless}% + % + % Texinfo font commands. + \definedummyword{b}% + \definedummyword{i}% + \definedummyword{r}% + \definedummyword{sc}% + \definedummyword{t}% + % + % Commands that take arguments. + \definedummyword{acronym}% + \definedummyword{cite}% + \definedummyword{code}% + \definedummyword{command}% + \definedummyword{dfn}% + \definedummyword{emph}% + \definedummyword{env}% + \definedummyword{file}% + \definedummyword{kbd}% + \definedummyword{key}% + \definedummyword{math}% + \definedummyword{option}% + \definedummyword{samp}% + \definedummyword{strong}% + \definedummyword{tie}% + \definedummyword{uref}% + \definedummyword{url}% + \definedummyword{var}% + \definedummyword{verb}% + \definedummyword{w}% + } +} + +% \indexnofonts is used when outputting the strings to sort the index +% by, and when constructing control sequence names. It eliminates all +% control sequences and just writes whatever the best ASCII sort string +% would be for a given command (usually its argument). +% \def\indexnofonts{% -\def\@{@}% -% how to handle braces? -\def\_{\normalunderscore}% -% -\let\,=\indexdummyfont -\let\"=\indexdummyfont -\let\`=\indexdummyfont -\let\'=\indexdummyfont -\let\^=\indexdummyfont -\let\~=\indexdummyfont -\let\==\indexdummyfont -\let\b=\indexdummyfont -\let\c=\indexdummyfont -\let\d=\indexdummyfont -\let\u=\indexdummyfont -\let\v=\indexdummyfont -\let\H=\indexdummyfont -\let\dotless=\indexdummyfont -% Take care of the plain tex special European modified letters. -\def\AA{AA}% -\def\AE{AE}% -\def\L{L}% -\def\OE{OE}% -\def\O{O}% -\def\aa{aa}% -\def\ae{ae}% -\def\l{l}% -\def\oe{oe}% -\def\o{o}% -\def\ss{ss}% -% -% Don't no-op \tt, since it isn't a user-level command -% and is used in the definitions of the active chars like <, >, |, etc. -% Likewise with the other plain tex font commands. -%\let\tt=\indexdummyfont -% -\let\b=\indexdummyfont -\let\i=\indexdummyfont -\let\r=\indexdummyfont -\let\sc=\indexdummyfont -\let\t=\indexdummyfont -% -\let\TeX=\indexdummytex -\let\acronym=\indexdummyfont -\let\cite=\indexdummyfont -\let\code=\indexdummyfont -\let\command=\indexdummyfont -\let\dfn=\indexdummyfont -\let\dots=\indexdummydots -\let\emph=\indexdummyfont -\let\env=\indexdummyfont -\let\file=\indexdummyfont -\let\kbd=\indexdummyfont -\let\key=\indexdummyfont -\let\math=\indexdummyfont -\let\option=\indexdummyfont -\let\samp=\indexdummyfont -\let\strong=\indexdummyfont -\let\uref=\indexdummyfont -\let\url=\indexdummyfont -\let\var=\indexdummyfont -\let\w=\indexdummyfont + \def\definedummyword##1{% + \expandafter\let\csname ##1\endcsname\asis + }% + % We can just ignore the accent commands and other control letters. + \def\definedummyletter##1{% + \expandafter\def\csname ##1\endcsname{}% + }% + % + \commondummiesnofonts + % + % Don't no-op \tt, since it isn't a user-level command + % and is used in the definitions of the active chars like <, >, |, etc. + % Likewise with the other plain tex font commands. + %\let\tt=\asis + % + \def\ { }% + \def\@{@}% + % how to handle braces? + \def\_{\normalunderscore}% + % + % Non-English letters. + \def\AA{AA}% + \def\AE{AE}% + \def\L{L}% + \def\OE{OE}% + \def\O{O}% + \def\aa{aa}% + \def\ae{ae}% + \def\l{l}% + \def\oe{oe}% + \def\o{o}% + \def\ss{ss}% + \def\exclamdown{!}% + \def\questiondown{?}% + \def\ordf{a}% + \def\ordm{o}% + % + \def\LaTeX{LaTeX}% + \def\TeX{TeX}% + % + % Assorted special characters. + % (The following {} will end up in the sort string, but that's ok.) + \def\bullet{bullet}% + \def\copyright{copyright}% + \def\registeredsymbol{R}% + \def\dots{...}% + \def\enddots{...}% + \def\equiv{==}% + \def\error{error}% + \def\expansion{==>}% + \def\minus{-}% + \def\pounds{pounds}% + \def\point{.}% + \def\print{-|}% + \def\result{=>}% } -% To define \realbackslash, we must make \ not be an escape. -% We must first make another character (@) an escape -% so we do not become unable to do a definition. - -{\catcode`\@=0 \catcode`\\=\other - @gdef@realbackslash{\}} - \let\indexbackslash=0 %overridden during \printindex. \let\SETmarginindex=\relax % put index entries in margin (undocumented)? -% For \ifx comparisons. -\def\emptymacro{\empty} - % Most index entries go through here, but \dosubind is the general case. -% -\def\doind#1#2{\dosubind{#1}{#2}\empty} +% #1 is the index name, #2 is the entry text. +\def\doind#1#2{\dosubind{#1}{#2}{}} % Workhorse for all \fooindexes. % #1 is name of index, #2 is stuff to put there, #3 is subentry -- -% \empty if called from \doind, as we usually are. The main exception -% is with defuns, which call us directly. +% empty if called from \doind, as we usually are (the main exception +% is with most defuns, which call us directly). % \def\dosubind#1#2#3{% + \iflinks + {% + % Store the main index entry text (including the third arg). + \toks0 = {#2}% + % If third arg is present, precede it with a space. + \def\thirdarg{#3}% + \ifx\thirdarg\empty \else + \toks0 = \expandafter{\the\toks0 \space #3}% + \fi + % + \edef\writeto{\csname#1indfile\endcsname}% + % + \ifvmode + \dosubindsanitize + \else + \dosubindwrite + \fi + }% + \fi +} + +% Write the entry in \toks0 to the index file: +% +\def\dosubindwrite{% % Put the index entry in the margin if desired. \ifx\SETmarginindex\relax\else - \insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}% + \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}% \fi - {% - \count255=\lastpenalty - {% - \indexdummies % Must do this here, since \bf, etc expand at this stage - \escapechar=`\\ - {% - \let\folio = 0% We will expand all macros now EXCEPT \folio. - \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now - % so it will be output as is; and it will print as backslash. - % - \def\thirdarg{#3}% - % - % If third arg is present, precede it with space in sort key. - \ifx\thirdarg\emptymacro - \let\subentry = \empty - \else - \def\subentry{ #3}% - \fi - % - % First process the index entry with all font commands turned - % off to get the string to sort by. - {\indexnofonts \xdef\indexsorttmp{#2\subentry}}% - % - % Now the real index entry with the fonts. - \toks0 = {#2}% - % - % If the third (subentry) arg is present, add it to the index - % line to write. - \ifx\thirdarg\emptymacro \else - \toks0 = \expandafter{\the\toks0{#3}}% - \fi - % - % Set up the complete index entry, with both the sort key and - % the original text, including any font commands. We write - % three arguments to \entry to the .?? file (four in the - % subentry case), texindex reduces to two when writing the .??s - % sorted result. - \edef\temp{% - \write\csname#1indfile\endcsname{% - \realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}% - }% - % - % If a skip is the last thing on the list now, preserve it - % by backing up by \lastskip, doing the \write, then inserting - % the skip again. Otherwise, the whatsit generated by the - % \write will make \lastskip zero. The result is that sequences - % like this: - % @end defun - % @tindex whatever - % @defun ... - % will have extra space inserted, because the \medbreak in the - % start of the @defun won't see the skip inserted by the @end of - % the previous defun. - % - % But don't do any of this if we're not in vertical mode. We - % don't want to do a \vskip and prematurely end a paragraph. - % - % Avoid page breaks due to these extra skips, too. - % - \iflinks - \ifvmode - \skip0 = \lastskip - \ifdim\lastskip = 0pt \else \nobreak\vskip-\lastskip \fi - \fi - % - \temp % do the write - % - % - \ifvmode \ifdim\skip0 = 0pt \else \nobreak\vskip\skip0 \fi \fi - \fi - }% - }% - \penalty\count255 + % + % Remember, we are within a group. + \indexdummies % Must do this here, since \bf, etc expand at this stage + \escapechar=`\\ + \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now + % so it will be output as is; and it will print as backslash. + % + % Process the index entry with all font commands turned off, to + % get the string to sort by. + {\indexnofonts + \edef\temp{\the\toks0}% need full expansion + \xdef\indexsorttmp{\temp}% }% + % + % Set up the complete index entry, with both the sort key and + % the original text, including any font commands. We write + % three arguments to \entry to the .?? file (four in the + % subentry case), texindex reduces to two when writing the .??s + % sorted result. + \edef\temp{% + \write\writeto{% + \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}% + }% + \temp +} + +% Take care of unwanted page breaks: +% +% If a skip is the last thing on the list now, preserve it +% by backing up by \lastskip, doing the \write, then inserting +% the skip again. Otherwise, the whatsit generated by the +% \write will make \lastskip zero. The result is that sequences +% like this: +% @end defun +% @tindex whatever +% @defun ... +% will have extra space inserted, because the \medbreak in the +% start of the @defun won't see the skip inserted by the @end of +% the previous defun. +% +% But don't do any of this if we're not in vertical mode. We +% don't want to do a \vskip and prematurely end a paragraph. +% +% Avoid page breaks due to these extra skips, too. +% +% But wait, there is a catch there: +% We'll have to check whether \lastskip is zero skip. \ifdim is not +% sufficient for this purpose, as it ignores stretch and shrink parts +% of the skip. The only way seems to be to check the textual +% representation of the skip. +% +% The following is almost like \def\zeroskipmacro{0.0pt} except that +% the ``p'' and ``t'' characters have catcode \other, not 11 (letter). +% +\edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname} +% +% ..., ready, GO: +% +\def\dosubindsanitize{% + % \lastskip and \lastpenalty cannot both be nonzero simultaneously. + \skip0 = \lastskip + \edef\lastskipmacro{\the\lastskip}% + \count255 = \lastpenalty + % + % If \lastskip is nonzero, that means the last item was a + % skip. And since a skip is discardable, that means this + % -\skip0 glue we're inserting is preceded by a + % non-discardable item, therefore it is not a potential + % breakpoint, therefore no \nobreak needed. + \ifx\lastskipmacro\zeroskipmacro + \else + \vskip-\skip0 + \fi + % + \dosubindwrite + % + \ifx\lastskipmacro\zeroskipmacro + % if \lastskip was zero, perhaps the last item was a + % penalty, and perhaps it was >=10000, e.g., a \nobreak. + % In that case, we want to re-insert the penalty; since we + % just inserted a non-discardable item, any following glue + % (such as a \parskip) would be a breakpoint. For example: + % @deffn deffn-whatever + % @vindex index-whatever + % Description. + % would allow a break between the index-whatever whatsit + % and the "Description." paragraph. + \ifnum\count255>9999 \nobreak \fi + \else + % On the other hand, if we had a nonzero \lastskip, + % this make-up glue would be preceded by a non-discardable item + % (the whatsit from the \write), so we must insert a \nobreak. + \nobreak\vskip\skip0 + \fi } % The index entry written in the file actually looks like @@ -3099,13 +3444,12 @@ width0pt\relax} \fi % @printindex causes a particular index (the ??s file) to get printed. % It does not print any chapter heading (usually an @unnumbered). % -\def\printindex{\parsearg\doprintindex} -\def\doprintindex#1{\begingroup +\parseargdef\printindex{\begingroup \dobreak \chapheadingskip{10000}% % \smallfonts \rm \tolerance = 9500 - \indexbreaks + \everypar = {}% don't want the \kern\-parindent from indentation suppression. % % See if the index file exists and is nonempty. % Change catcode of @ here so that if the index file contains @@ -3132,7 +3476,7 @@ width0pt\relax} \fi % Index files are almost Texinfo source, but we use \ as the escape % character. It would be better to use @, but that's too big a change % to make right now. - \def\indexbackslash{\rawbackslashxx}% + \def\indexbackslash{\backslashcurfont}% \catcode`\\ = 0 \escapechar = `\\ \begindoublecolumns @@ -3170,74 +3514,95 @@ width0pt\relax} \fi \nobreak }} -% This typesets a paragraph consisting of #1, dot leaders, and then #2 -% flush to the right margin. It is used for index and table of contents -% entries. The paragraph is indented by \leftskip. +% \entry typesets a paragraph consisting of the text (#1), dot leaders, and +% then page number (#2) flushed to the right margin. It is used for index +% and table of contents entries. The paragraph is indented by \leftskip. % -\def\entry#1#2{\begingroup - % - % Start a new paragraph if necessary, so our assignments below can't - % affect previous text. - \par - % - % Do not fill out the last line with white space. - \parfillskip = 0in - % - % No extra space above this paragraph. - \parskip = 0in - % - % Do not prefer a separate line ending with a hyphen to fewer lines. - \finalhyphendemerits = 0 - % - % \hangindent is only relevant when the entry text and page number - % don't both fit on one line. In that case, bob suggests starting the - % dots pretty far over on the line. Unfortunately, a large - % indentation looks wrong when the entry text itself is broken across - % lines. So we use a small indentation and put up with long leaders. - % - % \hangafter is reset to 1 (which is the value we want) at the start - % of each paragraph, so we need not do anything with that. - \hangindent = 2em - % - % When the entry text needs to be broken, just fill out the first line - % with blank space. - \rightskip = 0pt plus1fil - % - % A bit of stretch before each entry for the benefit of balancing columns. - \vskip 0pt plus1pt - % - % Start a ``paragraph'' for the index entry so the line breaking - % parameters we've set above will have an effect. - \noindent - % - % Insert the text of the index entry. TeX will do line-breaking on it. - #1% - % The following is kludged to not output a line of dots in the index if - % there are no page numbers. The next person who breaks this will be - % cursed by a Unix daemon. - \def\tempa{{\rm }}% - \def\tempb{#2}% - \edef\tempc{\tempa}% - \edef\tempd{\tempb}% - \ifx\tempc\tempd\ \else% +% A straightforward implementation would start like this: +% \def\entry#1#2{... +% But this frozes the catcodes in the argument, and can cause problems to +% @code, which sets - active. This problem was fixed by a kludge--- +% ``-'' was active throughout whole index, but this isn't really right. +% +% The right solution is to prevent \entry from swallowing the whole text. +% --kasal, 21nov03 +\def\entry{% + \begingroup % - % If we must, put the page number on a line of its own, and fill out - % this line with blank space. (The \hfil is overwhelmed with the - % fill leaders glue in \indexdotfill if the page number does fit.) - \hfil\penalty50 - \null\nobreak\indexdotfill % Have leaders before the page number. + % Start a new paragraph if necessary, so our assignments below can't + % affect previous text. + \par % - % The `\ ' here is removed by the implicit \unskip that TeX does as - % part of (the primitive) \par. Without it, a spurious underfull - % \hbox ensues. - \ifpdf - \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. + % Do not fill out the last line with white space. + \parfillskip = 0in + % + % No extra space above this paragraph. + \parskip = 0in + % + % Do not prefer a separate line ending with a hyphen to fewer lines. + \finalhyphendemerits = 0 + % + % \hangindent is only relevant when the entry text and page number + % don't both fit on one line. In that case, bob suggests starting the + % dots pretty far over on the line. Unfortunately, a large + % indentation looks wrong when the entry text itself is broken across + % lines. So we use a small indentation and put up with long leaders. + % + % \hangafter is reset to 1 (which is the value we want) at the start + % of each paragraph, so we need not do anything with that. + \hangindent = 2em + % + % When the entry text needs to be broken, just fill out the first line + % with blank space. + \rightskip = 0pt plus1fil + % + % A bit of stretch before each entry for the benefit of balancing + % columns. + \vskip 0pt plus1pt + % + % Swallow the left brace of the text (first parameter): + \afterassignment\doentry + \let\temp = +} +\def\doentry{% + \bgroup % Instead of the swallowed brace. + \noindent + \aftergroup\finishentry + % And now comes the text of the entry. +} +\def\finishentry#1{% + % #1 is the page number. + % + % The following is kludged to not output a line of dots in the index if + % there are no page numbers. The next person who breaks this will be + % cursed by a Unix daemon. + \def\tempa{{\rm }}% + \def\tempb{#1}% + \edef\tempc{\tempa}% + \edef\tempd{\tempb}% + \ifx\tempc\tempd + \ % \else - \ #2% The page number ends the paragraph. + % + % If we must, put the page number on a line of its own, and fill out + % this line with blank space. (The \hfil is overwhelmed with the + % fill leaders glue in \indexdotfill if the page number does fit.) + \hfil\penalty50 + \null\nobreak\indexdotfill % Have leaders before the page number. + % + % The `\ ' here is removed by the implicit \unskip that TeX does as + % part of (the primitive) \par. Without it, a spurious underfull + % \hbox ensues. + \ifpdf + \pdfgettoks#1.% + \ \the\toksA + \else + \ #1% + \fi \fi - \fi% - \par -\endgroup} + \par + \endgroup +} % Like \dotfill except takes at least 1 em. \def\indexdotfill{\cleaders @@ -3348,7 +3713,7 @@ width0pt\relax} \fi \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}% } -% +% % All done with double columns. \def\enddoublecolumns{% \output = {% @@ -3406,6 +3771,12 @@ width0pt\relax} \fi \message{sectioning,} % Chapters, sections, etc. +% \unnumberedno is an oxymoron, of course. But we count the unnumbered +% sections so that we can refer to them unambiguously in the pdf +% outlines by their "section number". We avoid collisions with chapter +% numbers by starting them at 10000. (If a document ever has 10000 +% chapters, we're in trouble anyway, I'm sure.) +\newcount\unnumberedno \unnumberedno = 10000 \newcount\chapno \newcount\secno \secno=0 \newcount\subsecno \subsecno=0 @@ -3413,9 +3784,12 @@ width0pt\relax} \fi % This counter is funny since it counts through charcodes of letters A, B, ... \newcount\appendixno \appendixno = `\@ +% % \def\appendixletter{\char\the\appendixno} -% We do the following for the sake of pdftex, which needs the actual +% We do the following ugly conditional instead of the above simple +% construct for the sake of pdftex, which needs the actual % letter in the expansion, not just typeset. +% \def\appendixletter{% \ifnum\appendixno=`A A% \else\ifnum\appendixno=`B B% @@ -3453,11 +3827,12 @@ width0pt\relax} \fi % Each @chapter defines this as the name of the chapter. % page headings and footings can use it. @section does likewise. +% However, they are not reliable, because we don't use marks. \def\thischapter{} \def\thissection{} \newcount\absseclevel % used to calculate proper heading level -\newcount\secbase\secbase=0 % @raise/lowersections modify this count +\newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count % @raisesections: treat @section as chapter, @subsection as section, etc. \def\raisesections{\global\advance\secbase by -1} @@ -3467,288 +3842,246 @@ width0pt\relax} \fi \def\lowersections{\global\advance\secbase by 1} \let\down=\lowersections % original BFox name -% Choose a numbered-heading macro -% #1 is heading level if unmodified by @raisesections or @lowersections -% #2 is text for heading -\def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 -\ifcase\absseclevel - \chapterzzz{#2} -\or - \seczzz{#2} -\or - \numberedsubseczzz{#2} -\or - \numberedsubsubseczzz{#2} -\else - \ifnum \absseclevel<0 - \chapterzzz{#2} +% we only have subsub. +\chardef\maxseclevel = 3 +% +% A numbered section within an unnumbered changes to unnumbered too. +% To achive this, remember the "biggest" unnum. sec. we are currently in: +\chardef\unmlevel = \maxseclevel +% +% Trace whether the current chapter is an appendix or not: +% \chapheadtype is "N" or "A", unnumbered chapters are ignored. +\def\chapheadtype{N} + +% Choose a heading macro +% #1 is heading type +% #2 is heading level +% #3 is text for heading +\def\genhead#1#2#3{% + % Compute the abs. sec. level: + \absseclevel=#2 + \advance\absseclevel by \secbase + % Make sure \absseclevel doesn't fall outside the range: + \ifnum \absseclevel < 0 + \absseclevel = 0 \else - \numberedsubsubseczzz{#2} + \ifnum \absseclevel > 3 + \absseclevel = 3 + \fi \fi -\fi -} - -% like \numhead, but chooses appendix heading levels -\def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 -\ifcase\absseclevel - \appendixzzz{#2} -\or - \appendixsectionzzz{#2} -\or - \appendixsubseczzz{#2} -\or - \appendixsubsubseczzz{#2} -\else - \ifnum \absseclevel<0 - \appendixzzz{#2} + % The heading type: + \def\headtype{#1}% + \if \headtype U% + \ifnum \absseclevel < \unmlevel + \chardef\unmlevel = \absseclevel + \fi \else - \appendixsubsubseczzz{#2} + % Check for appendix sections: + \ifnum \absseclevel = 0 + \edef\chapheadtype{\headtype}% + \else + \if \headtype A\if \chapheadtype N% + \errmessage{@appendix... within a non-appendix chapter}% + \fi\fi + \fi + % Check for numbered within unnumbered: + \ifnum \absseclevel > \unmlevel + \def\headtype{U}% + \else + \chardef\unmlevel = 3 + \fi \fi -\fi -} - -% like \numhead, but chooses numberless heading levels -\def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 -\ifcase\absseclevel - \unnumberedzzz{#2} -\or - \unnumberedseczzz{#2} -\or - \unnumberedsubseczzz{#2} -\or - \unnumberedsubsubseczzz{#2} -\else - \ifnum \absseclevel<0 - \unnumberedzzz{#2} + % Now print the heading: + \if \headtype U% + \ifcase\absseclevel + \unnumberedzzz{#3}% + \or \unnumberedseczzz{#3}% + \or \unnumberedsubseczzz{#3}% + \or \unnumberedsubsubseczzz{#3}% + \fi \else - \unnumberedsubsubseczzz{#2} + \if \headtype A% + \ifcase\absseclevel + \appendixzzz{#3}% + \or \appendixsectionzzz{#3}% + \or \appendixsubseczzz{#3}% + \or \appendixsubsubseczzz{#3}% + \fi + \else + \ifcase\absseclevel + \chapterzzz{#3}% + \or \seczzz{#3}% + \or \numberedsubseczzz{#3}% + \or \numberedsubsubseczzz{#3}% + \fi + \fi \fi -\fi + \suppressfirstparagraphindent } -% @chapter, @appendix, @unnumbered. -\def\thischaptername{No Chapter Title} -\outer\def\chapter{\parsearg\chapteryyy} -\def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz -\def\chapterzzz #1{% -\secno=0 \subsecno=0 \subsubsecno=0 -\global\advance \chapno by 1 \message{\putwordChapter\space \the\chapno}% -\chapmacro {#1}{\the\chapno}% -\gdef\thissection{#1}% -\gdef\thischaptername{#1}% -% We don't substitute the actual chapter name into \thischapter -% because we don't want its macros evaluated now. -\xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}% - {\the\chapno}}}% -\temp -\donoderef -\global\let\section = \numberedsec -\global\let\subsection = \numberedsubsec -\global\let\subsubsection = \numberedsubsubsec +% an interface: +\def\numhead{\genhead N} +\def\apphead{\genhead A} +\def\unnmhead{\genhead U} + +% @chapter, @appendix, @unnumbered. Increment top-level counter, reset +% all lower-level sectioning counters to zero. +% +% Also set \chaplevelprefix, which we prepend to @float sequence numbers +% (e.g., figures), q.v. By default (before any chapter), that is empty. +\let\chaplevelprefix = \empty +% +\outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz +\def\chapterzzz#1{% + % section resetting is \global in case the chapter is in a group, such + % as an @include file. + \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 + \global\advance\chapno by 1 + % + % Used for \float. + \gdef\chaplevelprefix{\the\chapno.}% + \resetallfloatnos + % + \message{\putwordChapter\space \the\chapno}% + % + % Write the actual heading. + \chapmacro{#1}{Ynumbered}{\the\chapno}% + % + % So @section and the like are numbered underneath this chapter. + \global\let\section = \numberedsec + \global\let\subsection = \numberedsubsec + \global\let\subsubsection = \numberedsubsubsec } -\outer\def\appendix{\parsearg\appendixyyy} -\def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz -\def\appendixzzz #1{% -\secno=0 \subsecno=0 \subsubsecno=0 -\global\advance \appendixno by 1 -\message{\putwordAppendix\space \appendixletter}% -\chapmacro {#1}{\putwordAppendix{} \appendixletter}% -\gdef\thissection{#1}% -\gdef\thischaptername{#1}% -\xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash appendixentry{\the\toks0}% - {\appendixletter}}}% -\temp -\appendixnoderef -\global\let\section = \appendixsec -\global\let\subsection = \appendixsubsec -\global\let\subsubsection = \appendixsubsubsec +\outer\parseargdef\appendix{\apphead0{#1}} % normally apphead0 calls appendixzzz +\def\appendixzzz#1{% + \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 + \global\advance\appendixno by 1 + \gdef\chaplevelprefix{\appendixletter.}% + \resetallfloatnos + % + \def\appendixnum{\putwordAppendix\space \appendixletter}% + \message{\appendixnum}% + % + \chapmacro{#1}{Yappendix}{\appendixletter}% + % + \global\let\section = \appendixsec + \global\let\subsection = \appendixsubsec + \global\let\subsubsection = \appendixsubsubsec +} + +\outer\parseargdef\unnumbered{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz +\def\unnumberedzzz#1{% + \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 + \global\advance\unnumberedno by 1 + % + % Since an unnumbered has no number, no prefix for figures. + \global\let\chaplevelprefix = \empty + \resetallfloatnos + % + % This used to be simply \message{#1}, but TeX fully expands the + % argument to \message. Therefore, if #1 contained @-commands, TeX + % expanded them. For example, in `@unnumbered The @cite{Book}', TeX + % expanded @cite (which turns out to cause errors because \cite is meant + % to be executed, not expanded). + % + % Anyway, we don't want the fully-expanded definition of @cite to appear + % as a result of the \message, we just want `@cite' itself. We use + % \the to achieve this: TeX expands \the only once, + % simply yielding the contents of . (We also do this for + % the toc entries.) + \toks0 = {#1}% + \message{(\the\toks0)}% + % + \chapmacro{#1}{Ynothing}{\the\unnumberedno}% + % + \global\let\section = \unnumberedsec + \global\let\subsection = \unnumberedsubsec + \global\let\subsubsection = \unnumberedsubsubsec } % @centerchap is like @unnumbered, but the heading is centered. -\outer\def\centerchap{\parsearg\centerchapyyy} -\def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}} +\outer\parseargdef\centerchap{% + % Well, we could do the following in a group, but that would break + % an assumption that \chapmacro is called at the outermost level. + % Thus we are safer this way: --kasal, 24feb04 + \let\centerparametersmaybe = \centerparameters + \unnmhead0{#1}% + \let\centerparametersmaybe = \relax +} % @top is like @unnumbered. -\outer\def\top{\parsearg\unnumberedyyy} - -\outer\def\unnumbered{\parsearg\unnumberedyyy} -\def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz -\def\unnumberedzzz #1{% -\secno=0 \subsecno=0 \subsubsecno=0 -% -% This used to be simply \message{#1}, but TeX fully expands the -% argument to \message. Therefore, if #1 contained @-commands, TeX -% expanded them. For example, in `@unnumbered The @cite{Book}', TeX -% expanded @cite (which turns out to cause errors because \cite is meant -% to be executed, not expanded). -% -% Anyway, we don't want the fully-expanded definition of @cite to appear -% as a result of the \message, we just want `@cite' itself. We use -% \the to achieve this: TeX expands \the only once, -% simply yielding the contents of . (We also do this for -% the toc entries.) -\toks0 = {#1}\message{(\the\toks0)}% -% -\unnumbchapmacro {#1}% -\gdef\thischapter{#1}\gdef\thissection{#1}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash unnumbchapentry{\the\toks0}}}% -\temp -\unnumbnoderef -\global\let\section = \unnumberedsec -\global\let\subsection = \unnumberedsubsec -\global\let\subsubsection = \unnumberedsubsubsec -} +\let\top\unnumbered % Sections. -\outer\def\numberedsec{\parsearg\secyyy} -\def\secyyy #1{\numhead1{#1}} % normally calls seczzz -\def\seczzz #1{% -\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % -\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}% - {\the\chapno}{\the\secno}}}% -\temp -\donoderef -\nobreak +\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz +\def\seczzz#1{% + \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 + \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}% } -\outer\def\appendixsection{\parsearg\appendixsecyyy} -\outer\def\appendixsec{\parsearg\appendixsecyyy} -\def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz -\def\appendixsectionzzz #1{% -\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % -\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}% - {\appendixletter}{\the\secno}}}% -\temp -\appendixnoderef -\nobreak +\outer\parseargdef\appendixsection{\apphead1{#1}} % normally calls appendixsectionzzz +\def\appendixsectionzzz#1{% + \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 + \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}% } +\let\appendixsec\appendixsection -\outer\def\unnumberedsec{\parsearg\unnumberedsecyyy} -\def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz -\def\unnumberedseczzz #1{% -\plainsecheading {#1}\gdef\thissection{#1}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsecentry% - {\the\toks0}{\the\chapno}}}% -\temp -\unnumbnoderef -\nobreak +\outer\parseargdef\unnumberedsec{\unnmhead1{#1}} % normally calls unnumberedseczzz +\def\unnumberedseczzz#1{% + \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 + \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}% } % Subsections. -\outer\def\numberedsubsec{\parsearg\numberedsubsecyyy} -\def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz -\def\numberedsubseczzz #1{% -\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % -\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}% - {\the\chapno}{\the\secno}{\the\subsecno}}}% -\temp -\donoderef -\nobreak +\outer\parseargdef\numberedsubsec{\numhead2{#1}} % normally calls numberedsubseczzz +\def\numberedsubseczzz#1{% + \global\subsubsecno=0 \global\advance\subsecno by 1 + \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}% } -\outer\def\appendixsubsec{\parsearg\appendixsubsecyyy} -\def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz -\def\appendixsubseczzz #1{% -\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % -\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}% - {\appendixletter}{\the\secno}{\the\subsecno}}}% -\temp -\appendixnoderef -\nobreak +\outer\parseargdef\appendixsubsec{\apphead2{#1}} % normally calls appendixsubseczzz +\def\appendixsubseczzz#1{% + \global\subsubsecno=0 \global\advance\subsecno by 1 + \sectionheading{#1}{subsec}{Yappendix}% + {\appendixletter.\the\secno.\the\subsecno}% } -\outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy} -\def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz -\def\unnumberedsubseczzz #1{% -\plainsubsecheading {#1}\gdef\thissection{#1}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsecentry% - {\the\toks0}{\the\chapno}{\the\secno}}}% -\temp -\unnumbnoderef -\nobreak +\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} %normally calls unnumberedsubseczzz +\def\unnumberedsubseczzz#1{% + \global\subsubsecno=0 \global\advance\subsecno by 1 + \sectionheading{#1}{subsec}{Ynothing}% + {\the\unnumberedno.\the\secno.\the\subsecno}% } % Subsubsections. -\outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy} -\def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz -\def\numberedsubsubseczzz #1{% -\gdef\thissection{#1}\global\advance \subsubsecno by 1 % -\subsubsecheading {#1} - {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}% - {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}% -\temp -\donoderef -\nobreak +\outer\parseargdef\numberedsubsubsec{\numhead3{#1}} % normally numberedsubsubseczzz +\def\numberedsubsubseczzz#1{% + \global\advance\subsubsecno by 1 + \sectionheading{#1}{subsubsec}{Ynumbered}% + {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}% } -\outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy} -\def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz -\def\appendixsubsubseczzz #1{% -\gdef\thissection{#1}\global\advance \subsubsecno by 1 % -\subsubsecheading {#1} - {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}% - {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}% -\temp -\appendixnoderef -\nobreak +\outer\parseargdef\appendixsubsubsec{\apphead3{#1}} % normally appendixsubsubseczzz +\def\appendixsubsubseczzz#1{% + \global\advance\subsubsecno by 1 + \sectionheading{#1}{subsubsec}{Yappendix}% + {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}% } -\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy} -\def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz -\def\unnumberedsubsubseczzz #1{% -\plainsubsubsecheading {#1}\gdef\thissection{#1}% -\toks0 = {#1}% -\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsubsecentry% - {\the\toks0}{\the\chapno}{\the\secno}{\the\subsecno}}}% -\temp -\unnumbnoderef -\nobreak +\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} %normally unnumberedsubsubseczzz +\def\unnumberedsubsubseczzz#1{% + \global\advance\subsubsecno by 1 + \sectionheading{#1}{subsubsec}{Ynothing}% + {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}% } -% These are variants which are not "outer", so they can appear in @ifinfo. -% Actually, they should now be obsolete; ordinary section commands should work. -\def\infotop{\parsearg\unnumberedzzz} -\def\infounnumbered{\parsearg\unnumberedzzz} -\def\infounnumberedsec{\parsearg\unnumberedseczzz} -\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz} -\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz} - -\def\infoappendix{\parsearg\appendixzzz} -\def\infoappendixsec{\parsearg\appendixseczzz} -\def\infoappendixsubsec{\parsearg\appendixsubseczzz} -\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz} - -\def\infochapter{\parsearg\chapterzzz} -\def\infosection{\parsearg\sectionzzz} -\def\infosubsection{\parsearg\subsectionzzz} -\def\infosubsubsection{\parsearg\subsubsectionzzz} - % These macros control what the section commands do, according % to what kind of chapter we are in (ordinary, appendix, or unnumbered). % Define them by default for a numbered chapter. -\global\let\section = \numberedsec -\global\let\subsection = \numberedsubsec -\global\let\subsubsection = \numberedsubsubsec +\let\section = \numberedsec +\let\subsection = \numberedsubsec +\let\subsubsection = \numberedsubsubsec % Define @majorheading, @heading and @subheading @@ -3761,23 +4094,27 @@ width0pt\relax} \fi % if justification is not attempted. Hence \raggedright. -\def\majorheading{\parsearg\majorheadingzzz} -\def\majorheadingzzz #1{% -{\advance\chapheadingskip by 10pt \chapbreak }% -{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\penalty 200} +\def\majorheading{% + {\advance\chapheadingskip by 10pt \chapbreak }% + \parsearg\chapheadingzzz +} -\def\chapheading{\parsearg\chapheadingzzz} -\def\chapheadingzzz #1{\chapbreak % -{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\raggedright - \rm #1\hfill}}\bigskip \par\penalty 200} +\def\chapheading{\chapbreak \parsearg\chapheadingzzz} +\def\chapheadingzzz#1{% + {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}% + \bigskip \par\penalty 200\relax + \suppressfirstparagraphindent +} % @heading, @subheading, @subsubheading. -\def\heading{\parsearg\plainsecheading} -\def\subheading{\parsearg\plainsubsecheading} -\def\subsubheading{\parsearg\plainsubsubsecheading} +\parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{} + \suppressfirstparagraphindent} +\parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{} + \suppressfirstparagraphindent} +\parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{} + \suppressfirstparagraphindent} % These macros generate a chapter, section, etc. heading only % (including whitespace, linebreaking, etc. around it), @@ -3786,8 +4123,6 @@ width0pt\relax} \fi %%% Args are the skip and penalty (usually negative) \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} -\def\setchapterstyle #1 {\csname CHAPF#1\endcsname} - %%% Define plain chapter starts, and page on/off switching for it % Parameter controlling skip before chapter headings (if needed) @@ -3810,7 +4145,7 @@ width0pt\relax} \fi \global\let\pagealignmacro=\chappager \global\def\HEADINGSon{\HEADINGSsingle}} -\def\CHAPPAGodd{ +\def\CHAPPAGodd{% \global\let\contentsalignmacro = \chapoddpage \global\let\pchapsepmacro=\chapoddpage \global\let\pagealignmacro=\chapoddpage @@ -3818,107 +4153,193 @@ width0pt\relax} \fi \CHAPPAGon -\def\CHAPFplain{ -\global\let\chapmacro=\chfplain -\global\let\unnumbchapmacro=\unnchfplain -\global\let\centerchapmacro=\centerchfplain} - -% Plain chapter opening. -% #1 is the text, #2 the chapter number or empty if unnumbered. -\def\chfplain#1#2{% +% Chapter opening. +% +% #1 is the text, #2 is the section type (Ynumbered, Ynothing, +% Yappendix, Yomitfromtoc), #3 the chapter number. +% +% To test against our argument. +\def\Ynothingkeyword{Ynothing} +\def\Yomitfromtockeyword{Yomitfromtoc} +\def\Yappendixkeyword{Yappendix} +% +\def\chapmacro#1#2#3{% \pchapsepmacro {% \chapfonts \rm - \def\chapnum{#2}% - \setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}% + % + % Have to define \thissection before calling \donoderef, because the + % xref code eventually uses it. On the other hand, it has to be called + % after \pchapsepmacro, or the headline will change too soon. + \gdef\thissection{#1}% + \gdef\thischaptername{#1}% + % + % Only insert the separating space if we have a chapter/appendix + % number, and don't print the unnumbered ``number''. + \def\temptype{#2}% + \ifx\temptype\Ynothingkeyword + \setbox0 = \hbox{}% + \def\toctype{unnchap}% + \def\thischapter{#1}% + \else\ifx\temptype\Yomitfromtockeyword + \setbox0 = \hbox{}% contents like unnumbered, but no toc entry + \def\toctype{omit}% + \xdef\thischapter{}% + \else\ifx\temptype\Yappendixkeyword + \setbox0 = \hbox{\putwordAppendix{} #3\enspace}% + \def\toctype{app}% + % We don't substitute the actual chapter name into \thischapter + % because we don't want its macros evaluated now. And we don't + % use \thissection because that changes with each section. + % + \xdef\thischapter{\putwordAppendix{} \appendixletter: + \noexpand\thischaptername}% + \else + \setbox0 = \hbox{#3\enspace}% + \def\toctype{numchap}% + \xdef\thischapter{\putwordChapter{} \the\chapno: + \noexpand\thischaptername}% + \fi\fi\fi + % + % Write the toc entry for this chapter. Must come before the + % \donoderef, because we include the current node name in the toc + % entry, and \donoderef resets it to empty. + \writetocentry{\toctype}{#1}{#3}% + % + % For pdftex, we have to write out the node definition (aka, make + % the pdfdest) after any page break, but before the actual text has + % been typeset. If the destination for the pdf outline is after the + % text, then jumping from the outline may wind up with the text not + % being visible, for instance under high magnification. + \donoderef{#2}% + % + % Typeset the actual heading. \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright - \hangindent = \wd0 \centerparametersmaybe + \hangindent=\wd0 \centerparametersmaybe \unhbox0 #1\par}% }% \nobreak\bigskip % no page break after a chapter title \nobreak } -% Plain opening for unnumbered. -\def\unnchfplain#1{\chfplain{#1}{}} - % @centerchap -- centered and unnumbered. \let\centerparametersmaybe = \relax -\def\centerchfplain#1{{% - \def\centerparametersmaybe{% - \advance\rightskip by 3\rightskip - \leftskip = \rightskip - \parfillskip = 0pt - }% - \chfplain{#1}{}% -}} +\def\centerparameters{% + \advance\rightskip by 3\rightskip + \leftskip = \rightskip + \parfillskip = 0pt +} -\CHAPFplain % The default +% I don't think this chapter style is supported any more, so I'm not +% updating it with the new noderef stuff. We'll see. --karl, 11aug03. +% +\def\setchapterstyle #1 {\csname CHAPF#1\endcsname} +% \def\unnchfopen #1{% \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt\raggedright \rm #1\hfill}}\bigskip \par\nobreak } - \def\chfopen #1#2{\chapoddpage {\chapfonts \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% \par\penalty 5000 % } - \def\centerchfopen #1{% \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt \hfill {\rm #1}\hfill}}\bigskip \par\nobreak } - -\def\CHAPFopen{ -\global\let\chapmacro=\chfopen -\global\let\unnumbchapmacro=\unnchfopen -\global\let\centerchapmacro=\centerchfopen} +\def\CHAPFopen{% + \global\let\chapmacro=\chfopen + \global\let\centerchapmacro=\centerchfopen} -% Section titles. +% Section titles. These macros combine the section number parts and +% call the generic \sectionheading to do the printing. +% \newskip\secheadingskip -\def\secheadingbreak{\dobreak \secheadingskip {-1000}} -\def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}} -\def\plainsecheading#1{\sectionheading{sec}{}{#1}} +\def\secheadingbreak{\dobreak \secheadingskip{-1000}} % Subsection titles. -\newskip \subsecheadingskip -\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}} -\def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}} -\def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}} +\newskip\subsecheadingskip +\def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}} % Subsubsection titles. -\let\subsubsecheadingskip = \subsecheadingskip -\let\subsubsecheadingbreak = \subsecheadingbreak -\def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}} -\def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}} +\def\subsubsecheadingskip{\subsecheadingskip} +\def\subsubsecheadingbreak{\subsecheadingbreak} -% Print any size section title. -% -% #1 is the section type (sec/subsec/subsubsec), #2 is the section -% number (maybe empty), #3 the text. -\def\sectionheading#1#2#3{% - {% - \expandafter\advance\csname #1headingskip\endcsname by \parskip - \csname #1headingbreak\endcsname - }% +% Print any size, any type, section title. +% +% #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is +% the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the +% section number. +% +\def\sectionheading#1#2#3#4{% {% % Switch to the right set of fonts. - \csname #1fonts\endcsname \rm + \csname #2fonts\endcsname \rm % - % Only insert the separating space if we have a section number. - \def\secnum{#2}% - \setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}% + % Insert space above the heading. + \csname #2headingbreak\endcsname % + % Only insert the space after the number if we have a section number. + \def\sectionlevel{#2}% + \def\temptype{#3}% + % + \ifx\temptype\Ynothingkeyword + \setbox0 = \hbox{}% + \def\toctype{unn}% + \gdef\thissection{#1}% + \else\ifx\temptype\Yomitfromtockeyword + % for @headings -- no section number, don't include in toc, + % and don't redefine \thissection. + \setbox0 = \hbox{}% + \def\toctype{omit}% + \let\sectionlevel=\empty + \else\ifx\temptype\Yappendixkeyword + \setbox0 = \hbox{#4\enspace}% + \def\toctype{app}% + \gdef\thissection{#1}% + \else + \setbox0 = \hbox{#4\enspace}% + \def\toctype{num}% + \gdef\thissection{#1}% + \fi\fi\fi + % + % Write the toc entry (before \donoderef). See comments in \chfplain. + \writetocentry{\toctype\sectionlevel}{#1}{#4}% + % + % Write the node reference (= pdf destination for pdftex). + % Again, see comments in \chfplain. + \donoderef{#3}% + % + % Output the actual section heading. \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright - \hangindent = \wd0 % zero if no section number - \unhbox0 #3}% + \hangindent=\wd0 % zero if no section number + \unhbox0 #1}% }% - \ifdim\parskip<10pt \nobreak\kern10pt\nobreak\kern-\parskip\fi \nobreak + % Add extra space after the heading -- half of whatever came above it. + % Don't allow stretch, though. + \kern .5 \csname #2headingskip\endcsname + % + % Do not let the kern be a potential breakpoint, as it would be if it + % was followed by glue. + \nobreak + % + % We'll almost certainly start a paragraph next, so don't let that + % glue accumulate. (Not a breakpoint because it's preceded by a + % discardable item.) + \vskip-\parskip + % + % This \nobreak is purely so the last item on the list is a \penalty + % of 10000. This is so other code, for instance \parsebodycommon, can + % check for and avoid allowing breakpoints. Otherwise, it would + % insert a valid breakpoint between: + % @section sec-whatever + % @deffn def-whatever + \nobreak } @@ -3927,140 +4348,137 @@ width0pt\relax} \fi \newwrite\tocfile % Write an entry to the toc file, opening it if necessary. -% Called from @chapter, etc. We supply {\folio} at the end of the -% argument, which will end up as the last argument to the \...entry macro. -% -% We open the .toc file here instead of at @setfilename or any other -% fixed time so that @contents can be put in the document anywhere. +% Called from @chapter, etc. +% +% Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno} +% We append the current node name (if any) and page number as additional +% arguments for the \{chap,sec,...}entry macros which will eventually +% read this. The node name is used in the pdf outlines as the +% destination to jump to. +% +% We open the .toc file for writing here instead of at @setfilename (or +% any other fixed time) so that @contents can be anywhere in the document. +% But if #1 is `omit', then we don't do anything. This is used for the +% table of contents chapter openings themselves. % \newif\iftocfileopened -\def\writetocentry#1{% - \iftocfileopened\else - \immediate\openout\tocfile = \jobname.toc - \global\tocfileopenedtrue +\def\omitkeyword{omit}% +% +\def\writetocentry#1#2#3{% + \edef\writetoctype{#1}% + \ifx\writetoctype\omitkeyword \else + \iftocfileopened\else + \immediate\openout\tocfile = \jobname.toc + \global\tocfileopenedtrue + \fi + % + \iflinks + \toks0 = {#2}% + \toks2 = \expandafter{\lastnode}% + \edef\temp{\write\tocfile{\realbackslash #1entry{\the\toks0}{#3}% + {\the\toks2}{\noexpand\folio}}}% + \temp + \fi \fi - \iflinks \write\tocfile{#1{\folio}}\fi % - % Tell \shipout to create a page destination if we're doing pdf, which - % will be the target of the links in the table of contents. We can't - % just do it on every page because the title pages are numbered 1 and - % 2 (the page numbers aren't printed), and so are the first two pages - % of the document. Thus, we'd have two destinations named `1', and - % two named `2'. - \ifpdf \pdfmakepagedesttrue \fi + % Tell \shipout to create a pdf destination on each page, if we're + % writing pdf. These are used in the table of contents. We can't + % just write one on every page because the title pages are numbered + % 1 and 2 (the page numbers aren't printed), and so are the first + % two pages of the document. Thus, we'd have two destinations named + % `1', and two named `2'. + \ifpdf \global\pdfmakepagedesttrue \fi } \newskip\contentsrightmargin \contentsrightmargin=1in \newcount\savepageno \newcount\lastnegativepageno \lastnegativepageno = -1 -% Finish up the main text and prepare to read what we've written -% to \tocfile. +% Prepare to read what we've written to \tocfile. % \def\startcontents#1{% - % If @setchapternewpage on, and @headings double, the contents should - % start on an odd page, unlike chapters. Thus, we maintain - % \contentsalignmacro in parallel with \pagealignmacro. - % From: Torbjorn Granlund - \contentsalignmacro - \immediate\closeout\tocfile - % - % Don't need to put `Contents' or `Short Contents' in the headline. - % It is abundantly clear what they are. - \unnumbchapmacro{#1}\def\thischapter{}% - \savepageno = \pageno - \begingroup % Set up to handle contents files properly. - \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 - % We can't do this, because then an actual ^ in a section - % title fails, e.g., @chapter ^ -- exponentiation. --karl, 9jul97. - %\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi - \raggedbottom % Worry more about breakpoints than the bottom. - \advance\hsize by -\contentsrightmargin % Don't use the full line length. - % - % Roman numerals for page numbers. - \ifnum \pageno>0 \pageno = \lastnegativepageno \fi + % If @setchapternewpage on, and @headings double, the contents should + % start on an odd page, unlike chapters. Thus, we maintain + % \contentsalignmacro in parallel with \pagealignmacro. + % From: Torbjorn Granlund + \contentsalignmacro + \immediate\closeout\tocfile + % + % Don't need to put `Contents' or `Short Contents' in the headline. + % It is abundantly clear what they are. + \def\thischapter{}% + \chapmacro{#1}{Yomitfromtoc}{}% + % + \savepageno = \pageno + \begingroup % Set up to handle contents files properly. + \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 + % We can't do this, because then an actual ^ in a section + % title fails, e.g., @chapter ^ -- exponentiation. --karl, 9jul97. + %\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi + \raggedbottom % Worry more about breakpoints than the bottom. + \advance\hsize by -\contentsrightmargin % Don't use the full line length. + % + % Roman numerals for page numbers. + \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi } % Normal (long) toc. \def\contents{% - \startcontents{\putwordTOC}% - \openin 1 \jobname.toc - \ifeof 1 \else - \closein 1 - \input \jobname.toc - \fi - \vfill \eject - \contentsalignmacro % in case @setchapternewpage odd is in effect - \pdfmakeoutlines - \endgroup - \lastnegativepageno = \pageno - \pageno = \savepageno + \startcontents{\putwordTOC}% + \openin 1 \jobname.toc + \ifeof 1 \else + \input \jobname.toc + \fi + \vfill \eject + \contentsalignmacro % in case @setchapternewpage odd is in effect + \ifeof 1 \else + \pdfmakeoutlines + \fi + \closein 1 + \endgroup + \lastnegativepageno = \pageno + \global\pageno = \savepageno } % And just the chapters. \def\summarycontents{% - \startcontents{\putwordShortTOC}% - % - \let\chapentry = \shortchapentry - \let\appendixentry = \shortappendixentry - \let\unnumbchapentry = \shortunnumberedentry - % We want a true roman here for the page numbers. - \secfonts - \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl - \rm - \hyphenpenalty = 10000 - \advance\baselineskip by 1pt % Open it up a little. - \def\secentry ##1##2##3##4{} - \def\unnumbsecentry ##1##2##3{} - \def\subsecentry ##1##2##3##4##5{} - \def\unnumbsubsecentry ##1##2##3##4{} - \def\subsubsecentry ##1##2##3##4##5##6{} - \def\unnumbsubsubsecentry ##1##2##3##4##5{} - \openin 1 \jobname.toc - \ifeof 1 \else - \closein 1 - \input \jobname.toc - \fi - \vfill \eject - \contentsalignmacro % in case @setchapternewpage odd is in effect - \endgroup - \lastnegativepageno = \pageno - \pageno = \savepageno + \startcontents{\putwordShortTOC}% + % + \let\numchapentry = \shortchapentry + \let\appentry = \shortchapentry + \let\unnchapentry = \shortunnchapentry + % We want a true roman here for the page numbers. + \secfonts + \let\rm=\shortcontrm \let\bf=\shortcontbf + \let\sl=\shortcontsl \let\tt=\shortconttt + \rm + \hyphenpenalty = 10000 + \advance\baselineskip by 1pt % Open it up a little. + \def\numsecentry##1##2##3##4{} + \let\appsecentry = \numsecentry + \let\unnsecentry = \numsecentry + \let\numsubsecentry = \numsecentry + \let\appsubsecentry = \numsecentry + \let\unnsubsecentry = \numsecentry + \let\numsubsubsecentry = \numsecentry + \let\appsubsubsecentry = \numsecentry + \let\unnsubsubsecentry = \numsecentry + \openin 1 \jobname.toc + \ifeof 1 \else + \input \jobname.toc + \fi + \closein 1 + \vfill \eject + \contentsalignmacro % in case @setchapternewpage odd is in effect + \endgroup + \lastnegativepageno = \pageno + \global\pageno = \savepageno } \let\shortcontents = \summarycontents -\ifpdf - \pdfcatalog{/PageMode /UseOutlines}% -\fi - -% These macros generate individual entries in the table of contents. -% The first argument is the chapter or section name. -% The last argument is the page number. -% The arguments in between are the chapter number, section number, ... - -% Chapters, in the main contents. -\def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}} -% -% Chapters, in the short toc. -% See comments in \dochapentry re vbox and related settings. -\def\shortchapentry#1#2#3{% - \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#3\egroup}% -} - -% Appendices, in the main contents. -\def\appendixentry#1#2#3{\dochapentry{\putwordAppendix{} #2\labelspace#1}{#3}} -% -% Appendices, in the short toc. -\let\shortappendixentry = \shortchapentry - % Typeset the label for a chapter or appendix for the short contents. -% The arg is, e.g., `Appendix A' for an appendix, or `3' for a chapter. -% We could simplify the code here by writing out an \appendixentry -% command in the toc file for appendices, instead of using \chapentry -% for both, but it doesn't seem worth it. -% -\newdimen\shortappendixwidth +% The arg is, e.g., `A' for an appendix, or `3' for a chapter. % \def\shortchaplabel#1{% % This space should be enough, since a single number is .5em, and the @@ -4068,29 +4486,61 @@ width0pt\relax} \fi % But use \hss just in case. % (This space doesn't include the extra space that gets added after % the label; that gets put in by \shortchapentry above.) - \dimen0 = 1em - \hbox to \dimen0{#1\hss}% + % + % We'd like to right-justify chapter numbers, but that looks strange + % with appendix letters. And right-justifying numbers and + % left-justifying letters looks strange when there is less than 10 + % chapters. Have to read the whole toc once to know how many chapters + % there are before deciding ... + \hbox to 1em{#1\hss}% } +% These macros generate individual entries in the table of contents. +% The first argument is the chapter or section name. +% The last argument is the page number. +% The arguments in between are the chapter number, section number, ... + +% Chapters, in the main contents. +\def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}} +% +% Chapters, in the short toc. +% See comments in \dochapentry re vbox and related settings. +\def\shortchapentry#1#2#3#4{% + \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}% +} + +% Appendices, in the main contents. +% Need the word Appendix, and a fixed-size box. +% +\def\appendixbox#1{% + % We use M since it's probably the widest letter. + \setbox0 = \hbox{\putwordAppendix{} M}% + \hbox to \wd0{\putwordAppendix{} #1\hss}} +% +\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}} + % Unnumbered chapters. -\def\unnumbchapentry#1#2{\dochapentry{#1}{#2}} -\def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno\bgroup#2\egroup}} +\def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}} +\def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}} % Sections. -\def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}} -\def\unnumbsecentry#1#2#3{\dosecentry{#1}{#3}} +\def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}} +\let\appsecentry=\numsecentry +\def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}} % Subsections. -\def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}} -\def\unnumbsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}} +\def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}} +\let\appsubsecentry=\numsubsecentry +\def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}} % And subsubsections. -\def\subsubsecentry#1#2#3#4#5#6{% - \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}} -\def\unnumbsubsubsecentry#1#2#3#4#5{\dosubsubsecentry{#1}{#5}} +\def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}} +\let\appsubsubsecentry=\numsubsubsecentry +\def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}} % This parameter controls the indentation of the various levels. -\newdimen\tocindent \tocindent = 3pc +% Same as \defaultparindent. +\newdimen\tocindent \tocindent = 15pt % Now for the actual typesetting. In all these, #1 is the text and #2 is the % page number. @@ -4121,17 +4571,8 @@ width0pt\relax} \fi \tocentry{#1}{\dopageno\bgroup#2\egroup}% \endgroup} -% Final typesetting of a toc entry; we use the same \entry macro as for -% the index entries, but we want to suppress hyphenation here. (We -% can't do that in the \entry macro, since index entries might consist -% of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.) -\def\tocentry#1#2{\begingroup - \vskip 0pt plus1pt % allow a little stretch for the sake of nice page breaks - % Do not use \turnoffactive in these arguments. Since the toc is - % typeset in cmr, characters such as _ would come out wrong; we - % have to do the usual translation tricks. - \entry{#1}{#2}% -\endgroup} +% We use the same \entry macro as for the index entries. +\let\tocentry = \entry % Space between chapter (or whatever) number and the title. \def\labelspace{\hskip1em \relax} @@ -4141,15 +4582,15 @@ width0pt\relax} \fi \def\chapentryfonts{\secfonts \rm} \def\secentryfonts{\textfonts} -\let\subsecentryfonts = \textfonts -\let\subsubsecentryfonts = \textfonts +\def\subsecentryfonts{\textfonts} +\def\subsubsecentryfonts{\textfonts} \message{environments,} % @foo ... @end foo. % @point{}, @result{}, @expansion{}, @print{}, @equiv{}. -% +% % Since these characters are used in examples, it should be an even number of % \tt widths. Each \tt character is 1en, so two makes it 1em. % @@ -4161,7 +4602,7 @@ width0pt\relax} \fi % The @error{} command. % Adapted from the TeXbook's \boxit. -% +% \newbox\errorbox % {\tentt \global\dimen0 = 3em}% Width of the box. @@ -4169,10 +4610,10 @@ width0pt\relax} \fi % The text. (`r' is open on the right, `e' somewhat less so on the left.) \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt} % -\global\setbox\errorbox=\hbox to \dimen0{\hfil +\setbox\errorbox=\hbox to \dimen0{\hfil \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. \advance\hsize by -2\dimen2 % Rules. - \vbox{ + \vbox{% \hrule height\dimen2 \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. @@ -4186,17 +4627,16 @@ width0pt\relax} \fi % One exception: @ is still an escape character, so that @end tex works. % But \@ or @@ will get a plain tex @ character. -\def\tex{\begingroup +\envdef\tex{% \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 - \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie + \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie \catcode `\%=14 - \catcode 43=12 % plus - \catcode`\"=12 - \catcode`\==12 - \catcode`\|=12 - \catcode`\<=12 - \catcode`\>=12 + \catcode `\+=\other + \catcode `\"=\other + \catcode `\|=\other + \catcode `\<=\other + \catcode `\>=\other \escapechar=`\\ % \let\b=\ptexb @@ -4208,19 +4648,23 @@ width0pt\relax} \fi \let\equiv=\ptexequiv \let\!=\ptexexclam \let\i=\ptexi + \let\indent=\ptexindent + \let\noindent=\ptexnoindent \let\{=\ptexlbrace \let\+=\tabalign \let\}=\ptexrbrace + \let\/=\ptexslash \let\*=\ptexstar \let\t=\ptext % \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}% \def\@{@}% -\let\Etex=\endgroup} +} +% There is no need to define \Etex. % Define @lisp ... @end lisp. -% @lisp does a \begingroup so it can rebind things, +% @lisp environment forms a group so it can rebind things, % including the definition of @end lisp (which normally is erroneous). % Amount to narrow the margins by for @lisp. @@ -4231,34 +4675,24 @@ width0pt\relax} \fi % have any width. \def\lisppar{\null\endgraf} -% Make each space character in the input produce a normal interword -% space in the output. Don't allow a line break at this space, as this -% is used only in environments like @example, where each line of input -% should produce a line of output anyway. -% -{\obeyspaces % -\gdef\sepspaces{\obeyspaces\let =\tie}} - -% Define \obeyedspace to be our active space, whatever it is. This is -% for use in \parsearg. -{\sepspaces% -\global\let\obeyedspace= } - % This space is always present above and below environments. \newskip\envskipamount \envskipamount = 0pt % Make spacing and below environment symmetrical. We use \parskip here % to help in doing that, since in @example-like environments \parskip % is reset to zero; thus the \afterenvbreak inserts no space -- but the -% start of the next paragraph will insert \parskip +% start of the next paragraph will insert \parskip. % \def\aboveenvbreak{{% - \ifnum\lastpenalty < 10000 + % =10000 instead of <10000 because of a special case in \itemzzz, q.v. + \ifnum \lastpenalty=10000 \else \advance\envskipamount by \parskip \endgraf \ifdim\lastskip<\envskipamount \removelastskip - \penalty-50 + % it's not a good place to break if the last penalty was \nobreak + % or better ... + \ifnum\lastpenalty<10000 \penalty-50 \fi \vskip\envskipamount \fi \fi @@ -4290,54 +4724,54 @@ width0pt\relax} \fi % \newskip\lskip\newskip\rskip -\long\def\cartouche{% -\begingroup - \lskip=\leftskip \rskip=\rightskip - \leftskip=0pt\rightskip=0pt %we want these *outside*. - \cartinner=\hsize \advance\cartinner by-\lskip - \advance\cartinner by-\rskip - \cartouter=\hsize - \advance\cartouter by 18.4pt % allow for 3pt kerns on either -% side, and for 6pt waste from -% each corner char, and rule thickness - \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip - % Flag to tell @lisp, etc., not to narrow margin. - \let\nonarrowing=\comment - \vbox\bgroup - \baselineskip=0pt\parskip=0pt\lineskip=0pt - \carttop - \hbox\bgroup - \hskip\lskip - \vrule\kern3pt - \vbox\bgroup - \hsize=\cartinner - \kern3pt - \begingroup - \baselineskip=\normbskip - \lineskip=\normlskip - \parskip=\normpskip - \vskip -\parskip +\envdef\cartouche{% + \ifhmode\par\fi % can't be in the midst of a paragraph. + \startsavinginserts + \lskip=\leftskip \rskip=\rightskip + \leftskip=0pt\rightskip=0pt % we want these *outside*. + \cartinner=\hsize \advance\cartinner by-\lskip + \advance\cartinner by-\rskip + \cartouter=\hsize + \advance\cartouter by 18.4pt % allow for 3pt kerns on either + % side, and for 6pt waste from + % each corner char, and rule thickness + \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip + % Flag to tell @lisp, etc., not to narrow margin. + \let\nonarrowing=\comment + \vbox\bgroup + \baselineskip=0pt\parskip=0pt\lineskip=0pt + \carttop + \hbox\bgroup + \hskip\lskip + \vrule\kern3pt + \vbox\bgroup + \kern3pt + \hsize=\cartinner + \baselineskip=\normbskip + \lineskip=\normlskip + \parskip=\normpskip + \vskip -\parskip + \comment % For explanation, see the end of \def\group. +} \def\Ecartouche{% - \endgroup - \kern3pt - \egroup - \kern3pt\vrule - \hskip\rskip - \egroup - \cartbot - \egroup -\endgroup -}} + \ifhmode\par\fi + \kern3pt + \egroup + \kern3pt\vrule + \hskip\rskip + \egroup + \cartbot + \egroup + \checkinserts +} % This macro is called at the beginning of all the @example variants, % inside a group. \def\nonfillstart{% \aboveenvbreak - \inENV % This group ends at the end of the body \hfuzz = 12pt % Don't be fussy \sepspaces % Make spaces be word-separators rather than space tokens. - \singlespace \let\par = \lisppar % don't ignore blank lines \obeylines % each line of input is a line of output \parskip = 0pt @@ -4348,115 +4782,99 @@ width0pt\relax} \fi \ifx\nonarrowing\relax \advance \leftskip by \lispnarrowing \exdentamount=\lispnarrowing - \let\exdent=\nofillexdent - \let\nonarrowing=\relax + \fi + \let\exdent=\nofillexdent +} + +% If you want all examples etc. small: @set dispenvsize small. +% If you want even small examples the full size: @set dispenvsize nosmall. +% This affects the following displayed environments: +% @example, @display, @format, @lisp +% +\def\smallword{small} +\def\nosmallword{nosmall} +\let\SETdispenvsize\relax +\def\setnormaldispenv{% + \ifx\SETdispenvsize\smallword + \smallexamplefonts \rm + \fi +} +\def\setsmalldispenv{% + \ifx\SETdispenvsize\nosmallword + \else + \smallexamplefonts \rm \fi } -% Define the \E... control sequence only if we are inside the particular -% environment, so the error checking in \end will work. -% -% To end an @example-like environment, we first end the paragraph (via -% \afterenvbreak's vertical glue), and then the group. That way we keep -% the zero \parskip that the environments set -- \parskip glue will be -% inserted at the beginning of the next paragraph in the document, after -% the environment. -% -\def\nonfillfinish{\afterenvbreak\endgroup} +% We often define two environments, @foo and @smallfoo. +% Let's do it by one command: +\def\makedispenv #1#2{ + \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2} + \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2} + \expandafter\let\csname E#1\endcsname \afterenvbreak + \expandafter\let\csname Esmall#1\endcsname \afterenvbreak +} -% @lisp: indented, narrowed, typewriter font. -\def\lisp{\begingroup +% Define two synonyms: +\def\maketwodispenvs #1#2#3{ + \makedispenv{#1}{#3} + \makedispenv{#2}{#3} +} + +% @lisp: indented, narrowed, typewriter font; @example: same as @lisp. +% +% @smallexample and @smalllisp: use smaller fonts. +% Originally contributed by Pavel@xerox. +% +\maketwodispenvs {lisp}{example}{% \nonfillstart - \let\Elisp = \nonfillfinish \tt \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. \gobble % eat return } -% @example: Same as @lisp. -\def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp} - -% @small... is usually equivalent to the non-small (@smallbook -% redefines). We must call \example (or whatever) last in the -% definition, since it reads the return following the @example (or -% whatever) command. +% @display/@smalldisplay: same as @lisp except keep current font. % -% This actually allows (for example) @end display inside an -% @smalldisplay. Too bad, but makeinfo will catch the error anyway. -% -\def\smalldisplay{\begingroup\def\Esmalldisplay{\nonfillfinish\endgroup}\display} -\def\smallexample{\begingroup\def\Esmallexample{\nonfillfinish\endgroup}\lisp} -\def\smallformat{\begingroup\def\Esmallformat{\nonfillfinish\endgroup}\format} -\def\smalllisp{\begingroup\def\Esmalllisp{\nonfillfinish\endgroup}\lisp} - -% Real @smallexample and @smalllisp (when @smallbook): use smaller fonts. -% Originally contributed by Pavel@xerox. -\def\smalllispx{\begingroup - \def\Esmalllisp{\nonfillfinish\endgroup}% - \def\Esmallexample{\nonfillfinish\endgroup}% - \smallexamplefonts - \lisp -} - -% @display: same as @lisp except keep current font. -% -\def\display{\begingroup +\makedispenv {display}{% \nonfillstart - \let\Edisplay = \nonfillfinish \gobble } -% -% @smalldisplay (when @smallbook): @display plus smaller fonts. -% -\def\smalldisplayx{\begingroup - \def\Esmalldisplay{\nonfillfinish\endgroup}% - \smallexamplefonts \rm - \display -} -% @format: same as @display except don't narrow margins. +% @format/@smallformat: same as @display except don't narrow margins. % -\def\format{\begingroup - \let\nonarrowing = t +\makedispenv{format}{% + \let\nonarrowing = t% \nonfillstart - \let\Eformat = \nonfillfinish \gobble } -% -% @smallformat (when @smallbook): @format plus smaller fonts. -% -\def\smallformatx{\begingroup - \def\Esmallformat{\nonfillfinish\endgroup}% - \smallexamplefonts \rm - \format -} -% @flushleft (same as @format). -% -\def\flushleft{\begingroup \def\Eflushleft{\nonfillfinish\endgroup}\format} +% @flushleft: same as @format, but doesn't obey \SETdispenvsize. +\envdef\flushleft{% + \let\nonarrowing = t% + \nonfillstart + \gobble +} +\let\Eflushleft = \afterenvbreak % @flushright. % -\def\flushright{\begingroup - \let\nonarrowing = t +\envdef\flushright{% + \let\nonarrowing = t% \nonfillstart - \let\Eflushright = \nonfillfinish \advance\leftskip by 0pt plus 1fill \gobble } +\let\Eflushright = \afterenvbreak % @quotation does normal linebreaking (hence we can't use \nonfillstart) -% and narrows the margins. +% and narrows the margins. We keep \parskip nonzero in general, since +% we're doing normal filling. So, when using \aboveenvbreak and +% \afterenvbreak, temporarily make \parskip 0. % -\def\quotation{% - \begingroup\inENV %This group ends at the end of the @quotation body +\envdef\quotation{% {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip - \singlespace \parindent=0pt - % We have retained a nonzero parskip for the environment, since we're - % doing normal filling. So to avoid extra space below the environment... - \def\Equotation{\parskip = 0pt \nonfillfinish}% % % @cartouche defines \nonarrowing to inhibit narrowing at next level down. \ifx\nonarrowing\relax @@ -4465,24 +4883,49 @@ width0pt\relax} \fi \exdentamount = \lispnarrowing \let\nonarrowing = \relax \fi + \parsearg\quotationlabel +} + +% We have retained a nonzero parskip for the environment, since we're +% doing normal filling. +% +\def\Equotation{% + \par + \ifx\quotationauthor\undefined\else + % indent a bit. + \leftline{\kern 2\leftskip \sl ---\quotationauthor}% + \fi + {\parskip=0pt \afterenvbreak}% +} + +% If we're given an argument, typeset it in bold with a colon after. +\def\quotationlabel#1{% + \def\temp{#1}% + \ifx\temp\empty \else + {\bf #1: }% + \fi } % LaTeX-like @verbatim...@end verbatim and @verb{...} -% If we want to allow any as delimiter, +% If we want to allow any as delimiter, % we need the curly braces so that makeinfo sees the @verb command, eg: % `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org % % [Knuth]: Donald Ervin Knuth, 1996. The TeXbook. % -% [Knuth] p. 344; only we need to do '@' too +% [Knuth] p.344; only we need to do the other characters Texinfo sets +% active too. Otherwise, they get lost as the first character on a +% verbatim line. \def\dospecials{% - \do\ \do\\\do\@\do\{\do\}\do\$\do\&% - \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~} + \do\ \do\\\do\{\do\}\do\$\do\&% + \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~% + \do\<\do\>\do\|\do\@\do+\do\"% +} % % [Knuth] p. 380 \def\uncatcodespecials{% - \def\do##1{\catcode`##1=12}\dospecials} + \def\do##1{\catcode`##1=\other}\dospecials} % % [Knuth] pp. 380,381,391 % Disable Spanish ligatures ?` and !` of \tt font @@ -4530,6 +4973,8 @@ width0pt\relax} \fi } \endgroup \def\setupverbatim{% + \nonfillstart + \advance\leftskip by -\defbodyindent % Easiest (and conventionally used) font for verbatim \tt \def\par{\leavevmode\egroup\box0\endgraf}% @@ -4543,15 +4988,15 @@ width0pt\relax} \fi \everypar{\starttabbox}% } -% Do the @verb magic: verbatim text is quoted by unique -% delimiter characters. Before first delimiter expect a +% Do the @verb magic: verbatim text is quoted by unique +% delimiter characters. Before first delimiter expect a % right brace, after last delimiter expect closing brace: % % \def\doverb'{'#1'}'{#1} % % [Knuth] p. 382; only eat outer {} \begingroup - \catcode`[=1\catcode`]=2\catcode`\{=12\catcode`\}=12 + \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next] \endgroup % @@ -4563,635 +5008,444 @@ width0pt\relax} \fi % % \def\doverbatim#1@end verbatim{#1} % -% For Texinfo it's a lot easier than for LaTeX, +% For Texinfo it's a lot easier than for LaTeX, % because texinfo's \verbatim doesn't stop at '\end{verbatim}': -% we need not redefine '\', '{' and '}' +% we need not redefine '\', '{' and '}'. % % Inspired by LaTeX's verbatim command set [latex.ltx] -%% Include LaTeX hack for completeness -- never know -%% \begingroup -%% \catcode`|=0 \catcode`[=1 -%% \catcode`]=2\catcode`\{=12\catcode`\}=12\catcode`\ =\active -%% \catcode`\\=12|gdef|doverbatim#1@end verbatim[ -%% #1|endgroup|def|Everbatim[]|end[verbatim]] -%% |endgroup +% \begingroup \catcode`\ =\active - \gdef\doverbatim#1@end verbatim{#1\end{verbatim}} + \obeylines % + % ignore everything up to the first ^^M, that's the newline at the end + % of the @verbatim input line itself. Otherwise we get an extra blank + % line in the output. + \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}% + % We really want {...\end verbatim} in the body of the macro, but + % without the active space; thus we have to use \xdef and \gobble. \endgroup % -\def\verbatim{% - \def\Everbatim{\nonfillfinish\endgroup}% - \begingroup - \nonfillstart - \advance\leftskip by -\defbodyindent - \begingroup\setupverbatim\doverbatim +\envdef\verbatim{% + \setupverbatim\doverbatim } +\let\Everbatim = \afterenvbreak + % @verbatiminclude FILE - insert text of file in verbatim environment. % -% Allow normal characters that we make active in the argument (a file name). -\def\verbatiminclude{% - \begingroup - \catcode`\\=12 - \catcode`~=12 - \catcode`^=12 - \catcode`_=12 - \catcode`|=12 - \catcode`<=12 - \catcode`>=12 - \catcode`+=12 - \parsearg\doverbatiminclude -} -\def\setupverbatiminclude{% - \begingroup - \nonfillstart - \advance\leftskip by -\defbodyindent - \begingroup\setupverbatim -} +\def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude} % \def\doverbatiminclude#1{% - % Restore active chars for included file. - \endgroup - \begingroup - \def\thisfile{#1}% - \expandafter\expandafter\setupverbatiminclude\input\thisfile - \endgroup\nonfillfinish\endgroup + {% + \makevalueexpandable + \setupverbatim + \input #1 + \afterenvbreak + }% } % @copying ... @end copying. -% Save the text away for @insertcopying later. -% -\newbox\copyingbox +% Save the text away for @insertcopying later. Many commands won't be +% allowed in this context, but that's ok. +% +% We save the uninterpreted tokens, rather than creating a box. +% Saving the text in a box would be much easier, but then all the +% typesetting commands (@smallbook, font changes, etc.) have to be done +% beforehand -- and a) we want @copying to be done first in the source +% file; b) letting users define the frontmatter in as flexible order as +% possible is very desirable. % \def\copying{\begingroup - \parindent = 0pt % looks wrong on title page - \def\Ecopying{\egroup\endgroup}% - \global\setbox\copyingbox = \vbox\bgroup + % Define a command to swallow text until we reach `@end copying'. + % \ is the escape char in this texinfo.tex file, so it is the + % delimiter for the command; @ will be the escape char when we read + % it, but that doesn't matter. + \long\def\docopying##1\end copying{\gdef\copyingtext{##1}\enddocopying}% + % + % We must preserve ^^M's in the input file; see \insertcopying below. + \catcode`\^^M = \active + \docopying } -% @insertcopying. -% -\def\insertcopying{\unvcopy\copyingbox} +% What we do to finish off the copying text. +% +\def\enddocopying{\endgroup\ignorespaces} +% @insertcopying. Here we must play games with ^^M's. On the one hand, +% we need them to delimit commands such as `@end quotation', so they +% must be active. On the other hand, we certainly don't want every +% end-of-line to be a \par, as would happen with the normal active +% definition of ^^M. On the third hand, two ^^M's in a row should still +% generate a \par. +% +% Our approach is to make ^^M insert a space and a penalty1 normally; +% then it can also check if \lastpenalty=1. If it does, then manually +% do \par. +% +% This messes up the normal definitions of @c[omment], so we redefine +% it. Similarly for @ignore. (These commands are used in the gcc +% manual for man page generation.) +% +% Seems pretty fragile, most line-oriented commands will presumably +% fail, but for the limited use of getting the copying text (which +% should be quite simple) inserted, we can hope it's ok. +% +{\catcode`\^^M=\active % +\gdef\insertcopying{\begingroup % + \parindent = 0pt % looks wrong on title page + \def^^M{% + \ifnum \lastpenalty=1 % + \par % + \else % + \space \penalty 1 % + \fi % + }% + % + % Fix @c[omment] for catcode 13 ^^M's. + \def\c##1^^M{\ignorespaces}% + \let\comment = \c % + % + % Don't bother jumping through all the hoops that \doignore does, it + % would be very hard since the catcodes are already set. + \long\def\ignore##1\end ignore{\ignorespaces}% + % + \copyingtext % +\endgroup}% +} \message{defuns,} % @defun etc. -% Allow user to change definition object font (\df) internally -\def\setdeffont #1 {\csname DEF#1\endcsname} - \newskip\defbodyindent \defbodyindent=.4in \newskip\defargsindent \defargsindent=50pt -\newskip\deftypemargin \deftypemargin=12pt \newskip\deflastargmargin \deflastargmargin=18pt -\newcount\parencount -% define \functionparens, which makes ( and ) and & do special things. -% \functionparens affects the group it is contained in. +% Start the processing of @deffn: +\def\startdefun{% + \ifnum\lastpenalty<10000 + \medbreak + \else + % If there are two @def commands in a row, we'll have a \nobreak, + % which is there to keep the function description together with its + % header. But if there's nothing but headers, we need to allow a + % break somewhere. Check for penalty 10002 (inserted by + % \defargscommonending) instead of 10000, since the sectioning + % commands insert a \penalty10000, and we don't want to allow a break + % between a section heading and a defun. + \ifnum\lastpenalty=10002 \penalty2000 \fi + % + % Similarly, after a section heading, do not allow a break. + % But do insert the glue. + \medskip % preceded by discardable penalty, so not a breakpoint + \fi + % + \parindent=0in + \advance\leftskip by \defbodyindent + \exdentamount=\defbodyindent +} + +\def\dodefunx#1{% + % First, check whether we are in the right environment: + \checkenv#1% + % + % As above, allow line break if we have multiple x headers in a row. + % It's not a great place, though. + \ifnum\lastpenalty=10002 \penalty3000 \fi + % + % And now, it's time to reuse the body of the original defun: + \expandafter\gobbledefun#1% +} +\def\gobbledefun#1\startdefun{} + +% \printdefunline \deffnheader{text} +% +\def\printdefunline#1#2{% + \begingroup + % call \deffnheader: + #1#2 \endheader + % common ending: + \interlinepenalty = 10000 + \advance\rightskip by 0pt plus 1fil + \endgraf + \nobreak\vskip -\parskip + \penalty 10002 % signal to \startdefun and \dodefunx + % Some of the @defun-type tags do not enable magic parentheses, + % rendering the following check redundant. But we don't optimize. + \checkparencounts + \endgroup +} + +\def\Edefun{\endgraf\medbreak} + +% \makedefun{deffn} creates \deffn, \deffnx and \Edeffn; +% the only thing remainnig is to define \deffnheader. +% +\def\makedefun#1{% + \expandafter\let\csname E#1\endcsname = \Edefun + \edef\temp{\noexpand\domakedefun + \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}% + \temp +} + +% \domakedefun \deffn \deffnx \deffnheader +% +% Define \deffn and \deffnx, without parameters. +% \deffnheader has to be defined explicitly. +% +\def\domakedefun#1#2#3{% + \envdef#1{% + \startdefun + \parseargusing\activeparens{\printdefunline#3}% + }% + \def#2{\dodefunx#1}% + \def#3% +} + +%%% Untyped functions: + +% @deffn category name args +\makedefun{deffn}{\deffngeneral{}} + +% @deffn category class name args +\makedefun{defop}#1 {\defopon{#1\ \putwordon}} + +% \defopon {category on}class name args +\def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } + +% \deffngeneral {subind}category name args +% +\def\deffngeneral#1#2 #3 #4\endheader{% + % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}. + \dosubind{fn}{\code{#3}}{#1}% + \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}% +} + +%%% Typed functions: + +% @deftypefn category type name args +\makedefun{deftypefn}{\deftypefngeneral{}} + +% @deftypeop category class type name args +\makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}} + +% \deftypeopon {category on}class type name args +\def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } + +% \deftypefngeneral {subind}category type name args +% +\def\deftypefngeneral#1#2 #3 #4 #5\endheader{% + \dosubind{fn}{\code{#4}}{#1}% + \defname{#2}{#3}{#4}\defunargs{#5\unskip}% +} + +%%% Typed variables: + +% @deftypevr category type var args +\makedefun{deftypevr}{\deftypecvgeneral{}} + +% @deftypecv category class type var args +\makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}} + +% \deftypecvof {category of}class type var args +\def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} } + +% \deftypecvgeneral {subind}category type var args +% +\def\deftypecvgeneral#1#2 #3 #4 #5\endheader{% + \dosubind{vr}{\code{#4}}{#1}% + \defname{#2}{#3}{#4}\defunargs{#5\unskip}% +} + +%%% Untyped variables: + +% @defvr category var args +\makedefun{defvr}#1 {\deftypevrheader{#1} {} } + +% @defcv category class var args +\makedefun{defcv}#1 {\defcvof{#1\ \putwordof}} + +% \defcvof {category of}class var args +\def\defcvof#1#2 {\deftypecvof{#1}#2 {} } + +%%% Type: +% @deftp category name args +\makedefun{deftp}#1 #2 #3\endheader{% + \doind{tp}{\code{#2}}% + \defname{#1}{}{#2}\defunargs{#3\unskip}% +} + +% Remaining @defun-like shortcuts: +\makedefun{defun}{\deffnheader{\putwordDeffunc} } +\makedefun{defmac}{\deffnheader{\putwordDefmac} } +\makedefun{defspec}{\deffnheader{\putwordDefspec} } +\makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} } +\makedefun{defvar}{\defvrheader{\putwordDefvar} } +\makedefun{defopt}{\defvrheader{\putwordDefopt} } +\makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} } +\makedefun{defmethod}{\defopon\putwordMethodon} +\makedefun{deftypemethod}{\deftypeopon\putwordMethodon} +\makedefun{defivar}{\defcvof\putwordInstanceVariableof} +\makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof} + +% \defname, which formats the name of the @def (not the args). +% #1 is the category, such as "Function". +% #2 is the return type, if any. +% #3 is the function name. +% +% We are followed by (but not passed) the arguments, if any. +% +\def\defname#1#2#3{% + % Get the values of \leftskip and \rightskip as they were outside the @def... + \advance\leftskip by -\defbodyindent + % + % How we'll format the type name. Putting it in brackets helps + % distinguish it from the body text that may end up on the next line + % just below it. + \def\temp{#1}% + \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi} + % + % Figure out line sizes for the paragraph shape. + % The first line needs space for \box0; but if \rightskip is nonzero, + % we need only space for the part of \box0 which exceeds it: + \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip + % The continuations: + \dimen2=\hsize \advance\dimen2 by -\defargsindent + % (plain.tex says that \dimen1 should be used only as global.) + \parshape 2 0in \dimen0 \defargsindent \dimen2 + % + % Put the type name to the right margin. + \noindent + \hbox to 0pt{% + \hfil\box0 \kern-\hsize + % \hsize has to be shortened this way: + \kern\leftskip + % Intentionally do not respect \rightskip, since we need the space. + }% + % + % Allow all lines to be underfull without complaint: + \tolerance=10000 \hbadness=10000 + \exdentamount=\defbodyindent + {% + % defun fonts. We use typewriter by default (used to be bold) because: + % . we're printing identifiers, they should be in tt in principle. + % . in languages with many accents, such as Czech or French, it's + % common to leave accents off identifiers. The result looks ok in + % tt, but exceedingly strange in rm. + % . we don't want -- and --- to be treated as ligatures. + % . this still does not fix the ?` and !` ligatures, but so far no + % one has made identifiers using them :). + \df \tt + \def\temp{#2}% return value type + \ifx\temp\empty\else \tclose{\temp} \fi + #3% output function name + }% + {\rm\enskip}% hskip 0.5 em of \tenrm + % + \boldbrax + % arguments will be output next, if any. +} + +% Print arguments in slanted roman (not ttsl), inconsistently with using +% tt for the name. This is because literal text is sometimes needed in +% the argument list (groff manual), and ttsl and tt are not very +% distinguishable. Prevent hyphenation at `-' chars. +% +\def\defunargs#1{% + % use sl by default (not ttsl), + % tt for the names. + \df \sl \hyphenchar\font=0 + % + % On the other hand, if an argument has two dashes (for instance), we + % want a way to get ttsl. Let's try @var for that. + \let\var=\ttslanted + #1% + \sl\hyphenchar\font=45 +} + +% We want ()&[] to print specially on the defun line. +% \def\activeparens{% -\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active -\catcode`\[=\active \catcode`\]=\active} + \catcode`\(=\active \catcode`\)=\active + \catcode`\[=\active \catcode`\]=\active + \catcode`\&=\active +} % Make control sequences which act like normal parenthesis chars. \let\lparen = ( \let\rparen = ) -{\activeparens % Now, smart parens don't turn on until &foo (see \amprm) - % Be sure that we always have a definition for `(', etc. For example, % if the fn name has parens in it, \boldbrax will not be in effect yet, % so TeX would otherwise complain about undefined control sequence. -\global\let(=\lparen \global\let)=\rparen -\global\let[=\lbrack \global\let]=\rbrack - -\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 } -\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} -% This is used to turn on special parens -% but make & act ordinary (given that it's active). -\gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr} - -% Definitions of (, ) and & used in args for functions. -% This is the definition of ( outside of all parentheses. -\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested - \global\advance\parencount by 1 -} -% -% This is the definition of ( when already inside a level of parens. -\gdef\opnested{\char`\(\global\advance\parencount by 1 } -% -\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0. - % also in that case restore the outer-level definition of (. - \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi - \global\advance \parencount by -1 } -% If we encounter &foo, then turn on ()-hacking afterwards -\gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ } -% -\gdef\normalparens{\boldbrax\let&=\ampnr} -} % End of definition inside \activeparens -%% These parens (in \boldbrax) actually are a little bolder than the -%% contained text. This is especially needed for [ and ] -\def\opnr{{\sf\char`\(}\global\advance\parencount by 1 } -\def\clnr{{\sf\char`\)}\global\advance\parencount by -1 } -\let\ampnr = \& -\def\lbrb{{\bf\char`\[}} -\def\rbrb{{\bf\char`\]}} - -% Active &'s sneak into the index arguments, so make sure it's defined. { - \catcode`& = 13 - \global\let& = \ampnr + \activeparens + \global\let(=\lparen \global\let)=\rparen + \global\let[=\lbrack \global\let]=\rbrack + \global\let& = \& + + \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} + \gdef\magicamp{\let&=\amprm} } -% First, defname, which formats the header line itself. -% #1 should be the function name. -% #2 should be the type of definition, such as "Function". +\newcount\parencount -\def\defname #1#2{% -% Get the values of \leftskip and \rightskip as they were -% outside the @def... -\dimen2=\leftskip -\advance\dimen2 by -\defbodyindent -\noindent -\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}% -\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line -\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations -\parshape 2 0in \dimen0 \defargsindent \dimen1 -% Now output arg 2 ("Function" or some such) -% ending at \deftypemargin from the right margin, -% but stuck inside a box of width 0 so it does not interfere with linebreaking -{% Adjust \hsize to exclude the ambient margins, -% so that \rightline will obey them. -\advance \hsize by -\dimen2 -\rlap{\rightline{{\rm #2}\hskip -1.25pc }}}% -% Make all lines underfull and no complaints: -\tolerance=10000 \hbadness=10000 -\advance\leftskip by -\defbodyindent -\exdentamount=\defbodyindent -{\df #1}\enskip % Generate function name +% If we encounter &foo, then turn on ()-hacking afterwards +\newif\ifampseen +\def\amprm#1 {\ampseentrue{\bf\ }} + +\def\parenfont{% + \ifampseen + % At the first level, print parens in roman, + % otherwise use the default font. + \ifnum \parencount=1 \rm \fi + \else + % The \sf parens (in \boldbrax) actually are a little bolder than + % the contained text. This is especially needed for [ and ] . + \sf + \fi +} +\def\infirstlevel#1{% + \ifampseen + \ifnum\parencount=1 + #1% + \fi + \fi +} +\def\bfafterword#1 {#1 \bf} + +\def\opnr{% + \global\advance\parencount by 1 + {\parenfont(}% + \infirstlevel \bfafterword +} +\def\clnr{% + {\parenfont)}% + \infirstlevel \sl + \global\advance\parencount by -1 } -% Actually process the body of a definition -% #1 should be the terminating control sequence, such as \Edefun. -% #2 should be the "another name" control sequence, such as \defunx. -% #3 should be the control sequence that actually processes the header, -% such as \defunheader. - -\def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2{\begingroup\obeylines\activeparens\spacesplit#3}% -\parindent=0in -\advance\leftskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup % -\catcode 61=\active % 61 is `=' -\obeylines\activeparens\spacesplit#3} - -% #1 is the \E... control sequence to end the definition (which we define). -% #2 is the \...x control sequence for consecutive fns (which we define). -% #3 is the control sequence to call to resume processing. -% #4, delimited by the space, is the class name. -% -\def\defmethparsebody#1#2#3#4 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}% -\parindent=0in -\advance\leftskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\activeparens\spacesplit{#3{#4}}} - -% Used for @deftypemethod and @deftypeivar. -% #1 is the \E... control sequence to end the definition (which we define). -% #2 is the \...x control sequence for consecutive fns (which we define). -% #3 is the control sequence to call to resume processing. -% #4, delimited by a space, is the class name. -% #5 is the method's return type. -% -\def\deftypemethparsebody#1#2#3#4 #5 {\begingroup\inENV - \medbreak - \def#1{\endgraf\endgroup\medbreak}% - \def#2##1 ##2 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}{##2}}}% - \parindent=0in - \advance\leftskip by \defbodyindent - \exdentamount=\defbodyindent - \begingroup\obeylines\activeparens\spacesplit{#3{#4}{#5}}} - -% Used for @deftypeop. The change from \deftypemethparsebody is an -% extra argument at the beginning which is the `category', instead of it -% being the hardwired string `Method' or `Instance Variable'. We have -% to account for this both in the \...x definition and in parsing the -% input at hand. Thus also need a control sequence (passed as #5) for -% the \E... definition to assign the category name to. -% -\def\deftypeopparsebody#1#2#3#4#5 #6 {\begingroup\inENV - \medbreak - \def#1{\endgraf\endgroup\medbreak}% - \def#2##1 ##2 ##3 {% - \def#4{##1}% - \begingroup\obeylines\activeparens\spacesplit{#3{##2}{##3}}}% - \parindent=0in - \advance\leftskip by \defbodyindent - \exdentamount=\defbodyindent - \begingroup\obeylines\activeparens\spacesplit{#3{#5}{#6}}} - -\def\defopparsebody #1#2#3#4#5 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 ##2 {\def#4{##1}% -\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}% -\parindent=0in -\advance\leftskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\activeparens\spacesplit{#3{#5}}} - -% These parsing functions are similar to the preceding ones -% except that they do not make parens into active characters. -% These are used for "variables" since they have no arguments. - -\def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2{\begingroup\obeylines\spacesplit#3}% -\parindent=0in -\advance\leftskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup % -\catcode 61=\active % -\obeylines\spacesplit#3} - -% This is used for \def{tp,vr}parsebody. It could probably be used for -% some of the others, too, with some judicious conditionals. -% -\def\parsebodycommon#1#2#3{% - \begingroup\inENV % - \medbreak % - % Define the end token that this defining construct specifies - % so that it will exit this group. - \def#1{\endgraf\endgroup\medbreak}% - \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}% - \parindent=0in - \advance\leftskip by \defbodyindent - \exdentamount=\defbodyindent - \begingroup\obeylines +\newcount\brackcount +\def\lbrb{% + \global\advance\brackcount by 1 + {\bf[}% +} +\def\rbrb{% + {\bf]}% + \global\advance\brackcount by -1 } -\def\defvrparsebody#1#2#3#4 {% - \parsebodycommon{#1}{#2}{#3}% - \spacesplit{#3{#4}}% +\def\checkparencounts{% + \ifnum\parencount=0 \else \badparencount \fi + \ifnum\brackcount=0 \else \badbrackcount \fi } - -% This loses on `@deftp {Data Type} {struct termios}' -- it thinks the -% type is just `struct', because we lose the braces in `{struct -% termios}' when \spacesplit reads its undelimited argument. Sigh. -% \let\deftpparsebody=\defvrparsebody -% -% So, to get around this, we put \empty in with the type name. That -% way, TeX won't find exactly `{...}' as an undelimited argument, and -% won't strip off the braces. -% -\def\deftpparsebody #1#2#3#4 {% - \parsebodycommon{#1}{#2}{#3}% - \spacesplit{\parsetpheaderline{#3{#4}}}\empty +\def\badparencount{% + \errmessage{Unbalanced parentheses in @def}% + \global\parencount=0 } - -% Fine, but then we have to eventually remove the \empty *and* the -% braces (if any). That's what this does. -% -\def\removeemptybraces\empty#1\relax{#1} - -% After \spacesplit has done its work, this is called -- #1 is the final -% thing to call, #2 the type name (which starts with \empty), and #3 -% (which might be empty) the arguments. -% -\def\parsetpheaderline#1#2#3{% - #1{\removeemptybraces#2\relax}{#3}% -}% - -\def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV % -\medbreak % -% Define the end token that this defining construct specifies -% so that it will exit this group. -\def#1{\endgraf\endgroup\medbreak}% -\def#2##1 ##2 {\def#4{##1}% -\begingroup\obeylines\spacesplit{#3{##2}}}% -\parindent=0in -\advance\leftskip by \defbodyindent -\exdentamount=\defbodyindent -\begingroup\obeylines\spacesplit{#3{#5}}} - -% Split up #2 at the first space token. -% call #1 with two arguments: -% the first is all of #2 before the space token, -% the second is all of #2 after that space token. -% If #2 contains no space token, all of it is passed as the first arg -% and the second is passed as empty. - -{\obeylines -\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}% -\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{% -\ifx\relax #3% -#1{#2}{}\else #1{#2}{#3#4}\fi}} - -% So much for the things common to all kinds of definitions. - -% Define @defun. - -% First, define the processing that is wanted for arguments of \defun -% Use this to expand the args and terminate the paragraph they make up - -\def\defunargs#1{\functionparens \sl -% Expand, preventing hyphenation at `-' chars. -% Note that groups don't affect changes in \hyphenchar. -% Set the font temporarily and use \font in case \setfont made \tensl a macro. -{\tensl\hyphenchar\font=0}% -#1% -{\tensl\hyphenchar\font=45}% -\ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi% -\interlinepenalty=10000 -\advance\rightskip by 0pt plus 1fil -\endgraf\nobreak\vskip -\parskip\nobreak +\def\badbrackcount{% + \errmessage{Unbalanced square braces in @def}% + \global\brackcount=0 } -\def\deftypefunargs #1{% -% Expand, preventing hyphenation at `-' chars. -% Note that groups don't affect changes in \hyphenchar. -% Use \boldbraxnoamp, not \functionparens, so that & is not special. -\boldbraxnoamp -\tclose{#1}% avoid \code because of side effects on active chars -\interlinepenalty=10000 -\advance\rightskip by 0pt plus 1fil -\endgraf\nobreak\vskip -\parskip\nobreak -} - -% Do complete processing of one @defun or @defunx line already parsed. - -% @deffn Command forward-char nchars - -\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader} - -\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}% -\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @defun == @deffn Function - -\def\defun{\defparsebody\Edefun\defunx\defunheader} - -\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index -\begingroup\defname {#1}{\putwordDeffunc}% -\defunargs {#2}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @deftypefun int foobar (int @var{foo}, float @var{bar}) - -\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader} - -% #1 is the data type. #2 is the name and args. -\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax} -% #1 is the data type, #2 the name, #3 the args. -\def\deftypefunheaderx #1#2 #3\relax{% -\doind {fn}{\code{#2}}% Make entry in function index -\begingroup\defname {\defheaderxcond#1\relax$.$#2}{\putwordDeftypefun}% -\deftypefunargs {#3}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) - -\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader} - -% \defheaderxcond#1\relax$.$ -% puts #1 in @code, followed by a space, but does nothing if #1 is null. -\def\defheaderxcond#1#2$.${\ifx#1\relax\else\code{#1#2} \fi} - -% #1 is the classification. #2 is the data type. #3 is the name and args. -\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax} -% #1 is the classification, #2 the data type, #3 the name, #4 the args. -\def\deftypefnheaderx #1#2#3 #4\relax{% -\doind {fn}{\code{#3}}% Make entry in function index -\begingroup -\normalparens % notably, turn off `&' magic, which prevents -% at least some C++ text from working -\defname {\defheaderxcond#2\relax$.$#3}{#1}% -\deftypefunargs {#4}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @defmac == @deffn Macro - -\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader} - -\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index -\begingroup\defname {#1}{\putwordDefmac}% -\defunargs {#2}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @defspec == @deffn Special Form - -\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader} - -\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index -\begingroup\defname {#1}{\putwordDefspec}% -\defunargs {#2}\endgroup % -\catcode 61=\other % Turn off change made in \defparsebody -} - -% @defop CATEGORY CLASS OPERATION ARG... -% -\def\defop #1 {\def\defoptype{#1}% -\defopparsebody\Edefop\defopx\defopheader\defoptype} -% -\def\defopheader#1#2#3{% -\dosubind {fn}{\code{#2}}{\putwordon\ #1}% Make entry in function index -\begingroup\defname {#2}{\defoptype\ \putwordon\ #1}% -\defunargs {#3}\endgroup % -} - -% @deftypeop CATEGORY CLASS TYPE OPERATION ARG... -% -\def\deftypeop #1 {\def\deftypeopcategory{#1}% - \deftypeopparsebody\Edeftypeop\deftypeopx\deftypeopheader - \deftypeopcategory} -% -% #1 is the class name, #2 the data type, #3 the operation name, #4 the args. -\def\deftypeopheader#1#2#3#4{% - \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index - \begingroup - \defname{\defheaderxcond#2\relax$.$#3} - {\deftypeopcategory\ \putwordon\ \code{#1}}% - \deftypefunargs{#4}% - \endgroup -} - -% @deftypemethod CLASS TYPE METHOD ARG... -% -\def\deftypemethod{% - \deftypemethparsebody\Edeftypemethod\deftypemethodx\deftypemethodheader} -% -% #1 is the class name, #2 the data type, #3 the method name, #4 the args. -\def\deftypemethodheader#1#2#3#4{% - \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index - \begingroup - \defname{\defheaderxcond#2\relax$.$#3}{\putwordMethodon\ \code{#1}}% - \deftypefunargs{#4}% - \endgroup -} - -% @deftypeivar CLASS TYPE VARNAME -% -\def\deftypeivar{% - \deftypemethparsebody\Edeftypeivar\deftypeivarx\deftypeivarheader} -% -% #1 is the class name, #2 the data type, #3 the variable name. -\def\deftypeivarheader#1#2#3{% - \dosubind{vr}{\code{#3}}{\putwordof\ \code{#1}}% entry in variable index - \begingroup - \defname{\defheaderxcond#2\relax$.$#3} - {\putwordInstanceVariableof\ \code{#1}}% - \defvarargs{#3}% - \endgroup -} - -% @defmethod == @defop Method -% -\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader} -% -% #1 is the class name, #2 the method name, #3 the args. -\def\defmethodheader#1#2#3{% - \dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% entry in function index - \begingroup - \defname{#2}{\putwordMethodon\ \code{#1}}% - \defunargs{#3}% - \endgroup -} - -% @defcv {Class Option} foo-class foo-flag - -\def\defcv #1 {\def\defcvtype{#1}% -\defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype} - -\def\defcvarheader #1#2#3{% -\dosubind {vr}{\code{#2}}{\putwordof\ #1}% Make entry in var index -\begingroup\defname {#2}{\defcvtype\ \putwordof\ #1}% -\defvarargs {#3}\endgroup % -} - -% @defivar CLASS VARNAME == @defcv {Instance Variable} CLASS VARNAME -% -\def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader} -% -\def\defivarheader#1#2#3{% - \dosubind {vr}{\code{#2}}{\putwordof\ #1}% entry in var index - \begingroup - \defname{#2}{\putwordInstanceVariableof\ #1}% - \defvarargs{#3}% - \endgroup -} - -% @defvar -% First, define the processing that is wanted for arguments of @defvar. -% This is actually simple: just print them in roman. -% This must expand the args and terminate the paragraph they make up -\def\defvarargs #1{\normalparens #1% -\interlinepenalty=10000 -\endgraf\nobreak\vskip -\parskip\nobreak} - -% @defvr Counter foo-count - -\def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader} - -\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}% -\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup} - -% @defvar == @defvr Variable - -\def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader} - -\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index -\begingroup\defname {#1}{\putwordDefvar}% -\defvarargs {#2}\endgroup % -} - -% @defopt == @defvr {User Option} - -\def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader} - -\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index -\begingroup\defname {#1}{\putwordDefopt}% -\defvarargs {#2}\endgroup % -} - -% @deftypevar int foobar - -\def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader} - -% #1 is the data type. #2 is the name, perhaps followed by text that -% is actually part of the data type, which should not be put into the index. -\def\deftypevarheader #1#2{% -\dovarind#2 \relax% Make entry in variables index -\begingroup\defname {\defheaderxcond#1\relax$.$#2}{\putwordDeftypevar}% -\interlinepenalty=10000 -\endgraf\nobreak\vskip -\parskip\nobreak -\endgroup} -\def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}} - -% @deftypevr {Global Flag} int enable - -\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader} - -\def\deftypevrheader #1#2#3{\dovarind#3 \relax% -\begingroup\defname {\defheaderxcond#2\relax$.$#3}{#1} -\interlinepenalty=10000 -\endgraf\nobreak\vskip -\parskip\nobreak -\endgroup} - -% Now define @deftp -% Args are printed in bold, a slight difference from @defvar. - -\def\deftpargs #1{\bf \defvarargs{#1}} - -% @deftp Class window height width ... - -\def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader} - -\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}% -\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup} - -% These definitions are used if you use @defunx (etc.) -% anywhere other than immediately after a @defun or @defunx. -% -\def\defcvx#1 {\errmessage{@defcvx in invalid context}} -\def\deffnx#1 {\errmessage{@deffnx in invalid context}} -\def\defivarx#1 {\errmessage{@defivarx in invalid context}} -\def\defmacx#1 {\errmessage{@defmacx in invalid context}} -\def\defmethodx#1 {\errmessage{@defmethodx in invalid context}} -\def\defoptx #1 {\errmessage{@defoptx in invalid context}} -\def\defopx#1 {\errmessage{@defopx in invalid context}} -\def\defspecx#1 {\errmessage{@defspecx in invalid context}} -\def\deftpx#1 {\errmessage{@deftpx in invalid context}} -\def\deftypefnx#1 {\errmessage{@deftypefnx in invalid context}} -\def\deftypefunx#1 {\errmessage{@deftypefunx in invalid context}} -\def\deftypeivarx#1 {\errmessage{@deftypeivarx in invalid context}} -\def\deftypemethodx#1 {\errmessage{@deftypemethodx in invalid context}} -\def\deftypeopx#1 {\errmessage{@deftypeopx in invalid context}} -\def\deftypevarx#1 {\errmessage{@deftypevarx in invalid context}} -\def\deftypevrx#1 {\errmessage{@deftypevrx in invalid context}} -\def\defunx#1 {\errmessage{@defunx in invalid context}} -\def\defvarx#1 {\errmessage{@defvarx in invalid context}} -\def\defvrx#1 {\errmessage{@defvrx in invalid context}} - \message{macros,} % @macro. @@ -5199,28 +5453,33 @@ width0pt\relax} \fi % To do this right we need a feature of e-TeX, \scantokens, % which we arrange to emulate with a temporary file in ordinary TeX. \ifx\eTeXversion\undefined - \newwrite\macscribble - \def\scanmacro#1{% - \begingroup \newlinechar`\^^M - % Undo catcode changes of \startcontents and \doprintindex - \catcode`\@=0 \catcode`\\=12 \escapechar=`\@ - % Append \endinput to make sure that TeX does not see the ending newline. - \toks0={#1\endinput}% - \immediate\openout\macscribble=\jobname.tmp - \immediate\write\macscribble{\the\toks0}% - \immediate\closeout\macscribble - \let\xeatspaces\eatspaces - \input \jobname.tmp - \endgroup -} -\else -\def\scanmacro#1{% -\begingroup \newlinechar`\^^M -% Undo catcode changes of \startcontents and \doprintindex -\catcode`\@=0 \catcode`\\=12 \escapechar=`\@ -\let\xeatspaces\eatspaces\scantokens{#1\endinput}\endgroup} + \newwrite\macscribble + \def\scantokens#1{% + \toks0={#1\endinput}% + \immediate\openout\macscribble=\jobname.tmp + \immediate\write\macscribble{\the\toks0}% + \immediate\closeout\macscribble + \input \jobname.tmp + } \fi +\def\scanmacro#1{% + \begingroup + \newlinechar`\^^M + \let\xeatspaces\eatspaces + % Undo catcode changes of \startcontents and \doprintindex + \catcode`\@=0 \catcode`\\=\other \escapechar=`\@ + % ... and \example + \spaceisspace + % + % Append \endinput to make sure that TeX does not see the ending newline. + % + % I've verified that it is necessary both for e-TeX and for ordinary TeX + % --kasal, 29nov03 + \scantokens{#1\endinput}% + \endgroup +} + \newcount\paramno % Count of parameters \newtoks\macname % Macro name \newif\ifrecursive % Is it recursive? @@ -5228,7 +5487,7 @@ width0pt\relax} \fi % \do\macro1\do\macro2... % Utility routines. -% Thisdoes \let #1 = #2, except with \csnames. +% This does \let #1 = #2, except with \csnames. \def\cslet#1#2{% \expandafter\expandafter \expandafter\let @@ -5247,7 +5506,7 @@ width0pt\relax} \fi } % Trim a single trailing ^^M off a string. -{\catcode`\^^M=12\catcode`\Q=3% +{\catcode`\^^M=\other \catcode`\Q=3% \gdef\eatcr #1{\eatcra #1Q^^MQ}% \gdef\eatcra#1^^MQ{\eatcrb#1Q}% \gdef\eatcrb#1Q#2Q{#1}% @@ -5262,29 +5521,29 @@ width0pt\relax} \fi % body, and then making it the \newlinechar in \scanmacro. \def\macrobodyctxt{% - \catcode`\~=12 - \catcode`\^=12 - \catcode`\_=12 - \catcode`\|=12 - \catcode`\<=12 - \catcode`\>=12 - \catcode`\+=12 - \catcode`\{=12 - \catcode`\}=12 - \catcode`\@=12 - \catcode`\^^M=12 + \catcode`\~=\other + \catcode`\^=\other + \catcode`\_=\other + \catcode`\|=\other + \catcode`\<=\other + \catcode`\>=\other + \catcode`\+=\other + \catcode`\{=\other + \catcode`\}=\other + \catcode`\@=\other + \catcode`\^^M=\other \usembodybackslash} \def\macroargctxt{% - \catcode`\~=12 - \catcode`\^=12 - \catcode`\_=12 - \catcode`\|=12 - \catcode`\<=12 - \catcode`\>=12 - \catcode`\+=12 - \catcode`\@=12 - \catcode`\\=12} + \catcode`\~=\other + \catcode`\^=\other + \catcode`\_=\other + \catcode`\|=\other + \catcode`\<=\other + \catcode`\>=\other + \catcode`\+=\other + \catcode`\@=\other + \catcode`\\=\other} % \mbodybackslash is the definition of \ in @macro bodies. % It maps \foo\ => \csname macarg.foo\endcsname => #N @@ -5325,32 +5584,32 @@ width0pt\relax} \fi \else \expandafter\parsemacbody \fi} -\def\unmacro{\parsearg\unmacroxxx} -\def\unmacroxxx#1{% +\parseargdef\unmacro{% \if1\csname ismacro.#1\endcsname \global\cslet{#1}{macsave.#1}% \global\expandafter\let \csname ismacro.#1\endcsname=0% - % Remove the macro name from \macrolist + % Remove the macro name from \macrolist: \begingroup - \edef\tempa{\expandafter\noexpand\csname#1\endcsname}% - \def\do##1{% - \def\tempb{##1}% - \ifx\tempa\tempb - % remove this - \else - \toks0 = \expandafter{\newmacrolist\do}% - \edef\newmacrolist{\the\toks0\expandafter\noexpand\tempa}% - \fi}% - \def\newmacrolist{}% - % Execute macro list to define \newmacrolist - \macrolist - \global\let\macrolist\newmacrolist + \expandafter\let\csname#1\endcsname \relax + \let\do\unmacrodo + \xdef\macrolist{\macrolist}% \endgroup \else \errmessage{Macro #1 not defined}% \fi } +% Called by \do from \dounmacro on each macro. The idea is to omit any +% macro definitions that have been changed to \relax. +% +\def\unmacrodo#1{% + \ifx#1\relax + % remove this + \else + \noexpand\do \noexpand #1% + \fi +} + % This makes use of the obscure feature that if the last token of a % is #, then the preceding argument is delimited by % an opening brace, and that opening brace is not consumed. @@ -5475,16 +5734,18 @@ width0pt\relax} \fi % @alias. % We need some trickery to remove the optional spaces around the equal % sign. Just make them active and then expand them all to nothing. -\def\alias{\begingroup\obeyspaces\parsearg\aliasxxx} +\def\alias{\parseargusing\obeyspaces\aliasxxx} \def\aliasxxx #1{\aliasyyy#1\relax} -\def\aliasyyy #1=#2\relax{\ignoreactivespaces -\edef\next{\global\let\expandafter\noexpand\csname#1\endcsname=% - \expandafter\noexpand\csname#2\endcsname}% -\expandafter\endgroup\next} +\def\aliasyyy #1=#2\relax{% + {% + \expandafter\let\obeyedspace=\empty + \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}% + }% + \next +} \message{cross references,} -% @xref etc. \newwrite\auxfile @@ -5496,56 +5757,70 @@ width0pt\relax} \fi \def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, node \samp{\ignorespaces#1{}}} -% @node's job is to define \lastnode. -\def\node{\ENVcheck\parsearg\nodezzz} -\def\nodezzz#1{\nodexxx [#1,]} -\def\nodexxx[#1,#2]{\gdef\lastnode{#1}} +% @node's only job in TeX is to define \lastnode, which is used in +% cross-references. The @node line might or might not have commas, and +% might or might not have spaces before the first comma, like: +% @node foo , bar , ... +% We don't want such trailing spaces in the node name. +% +\parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse} +% +% also remove a trailing comma, in case of something like this: +% @node Help-Cross, , , Cross-refs +\def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse} +\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}} + \let\nwnode=\node -\let\lastnode=\relax +\let\lastnode=\empty -% The sectioning commands (@chapter, etc.) call these. -\def\donoderef{% - \ifx\lastnode\relax\else - \expandafter\expandafter\expandafter\setref{\lastnode}% - {Ysectionnumberandtype}% - \global\let\lastnode=\relax +% Write a cross-reference definition for the current node. #1 is the +% type (Ynumbered, Yappendix, Ynothing). +% +\def\donoderef#1{% + \ifx\lastnode\empty\else + \setref{\lastnode}{#1}% + \global\let\lastnode=\empty \fi } -\def\unnumbnoderef{% - \ifx\lastnode\relax\else - \expandafter\expandafter\expandafter\setref{\lastnode}{Ynothing}% - \global\let\lastnode=\relax - \fi -} -\def\appendixnoderef{% - \ifx\lastnode\relax\else - \expandafter\expandafter\expandafter\setref{\lastnode}% - {Yappendixletterandtype}% - \global\let\lastnode=\relax - \fi -} - % @anchor{NAME} -- define xref target at arbitrary point. % \newcount\savesfregister -\gdef\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi} -\gdef\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi} -\gdef\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces} - -% \setref{NAME}{SNT} defines a cross-reference point NAME, namely -% NAME-title, NAME-pg, and NAME-SNT. Called from \foonoderef. We have -% to set \indexdummies so commands such as @code in a section title -% aren't expanded. It would be nicer not to expand the titles in the -% first place, but there's so many layers that that is hard to do. % -\def\setref#1#2{{% - \indexdummies +\def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi} +\def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi} +\def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces} + +% \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an +% anchor), which consists of three parts: +% 1) NAME-title - the current sectioning name taken from \thissection, +% or the anchor name. +% 2) NAME-snt - section number and type, passed as the SNT arg, or +% empty for anchors. +% 3) NAME-pg - the page number. +% +% This is called from \donoderef, \anchor, and \dofloat. In the case of +% floats, there is an additional part, which is not written here: +% 4) NAME-lof - the text as it should appear in a @listoffloats. +% +\def\setref#1#2{% \pdfmkdest{#1}% - \dosetq{#1-title}{Ytitle}% - \dosetq{#1-pg}{Ypagenumber}% - \dosetq{#1-snt}{#2}% -}} + \iflinks + {% + \atdummies % preserve commands, but don't expand them + \turnoffactive + \otherbackslash + \edef\writexrdef##1##2{% + \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef + ##1}{##2}}% these are parameters of \writexrdef + }% + \toks0 = \expandafter{\thissection}% + \immediate \writexrdef{title}{\the\toks0 }% + \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc. + \writexrdef{pg}{\folio}% will be written later, during \shipout + }% + \fi +} % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is % the node name, #2 the name of the Info cross-reference, #3 the printed @@ -5558,137 +5833,156 @@ width0pt\relax} \fi \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup \unsepspaces \def\printedmanual{\ignorespaces #5}% - \def\printednodename{\ignorespaces #3}% - \setbox1=\hbox{\printedmanual}% - \setbox0=\hbox{\printednodename}% + \def\printedrefname{\ignorespaces #3}% + \setbox1=\hbox{\printedmanual\unskip}% + \setbox0=\hbox{\printedrefname\unskip}% \ifdim \wd0 = 0pt % No printed node name was explicitly given. \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax % Use the node name inside the square brackets. - \def\printednodename{\ignorespaces #1}% + \def\printedrefname{\ignorespaces #1}% \else % Use the actual chapter/section title appear inside % the square brackets. Use the real section title if we have it. \ifdim \wd1 > 0pt % It is in another manual, so we don't have it. - \def\printednodename{\ignorespaces #1}% + \def\printedrefname{\ignorespaces #1}% \else \ifhavexrefs % We know the real title if we have the xref values. - \def\printednodename{\refx{#1-title}{}}% + \def\printedrefname{\refx{#1-title}{}}% \else % Otherwise just copy the Info node name. - \def\printednodename{\ignorespaces #1}% + \def\printedrefname{\ignorespaces #1}% \fi% \fi \fi \fi % - % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not - % insert empty discretionaries after hyphens, which means that it will - % not find a line break at a hyphen in a node names. Since some manuals - % are best written with fairly long node names, containing hyphens, this - % is a loss. Therefore, we give the text of the node name again, so it - % is as if TeX is seeing it for the first time. + % Make link in pdf output. \ifpdf \leavevmode \getfilename{#4}% - {\normalturnoffactive + {\turnoffactive \otherbackslash \ifnum\filenamelength>0 \startlink attr{/Border [0 0 0]}% goto file{\the\filename.pdf} name{#1}% \else \startlink attr{/Border [0 0 0]}% - goto name{#1}% + goto name{\pdfmkpgn{#1}}% \fi }% \linkcolor \fi % - \ifdim \wd1 > 0pt - \putwordsection{} ``\printednodename'' \putwordin{} \cite{\printedmanual}% + % Float references are printed completely differently: "Figure 1.2" + % instead of "[somenode], p.3". We distinguish them by the + % LABEL-title being set to a magic string. + {% + % Have to otherify everything special to allow the \csname to + % include an _ in the xref name, etc. + \indexnofonts + \turnoffactive + \otherbackslash + \expandafter\global\expandafter\let\expandafter\Xthisreftitle + \csname XR#1-title\endcsname + }% + \iffloat\Xthisreftitle + % If the user specified the print name (third arg) to the ref, + % print it instead of our usual "Figure 1.2". + \ifdim\wd0 = 0pt + \refx{#1-snt}% + \else + \printedrefname + \fi + % + % if the user also gave the printed manual name (fifth arg), append + % "in MANUALNAME". + \ifdim \wd1 > 0pt + \space \putwordin{} \cite{\printedmanual}% + \fi \else - % _ (for example) has to be the character _ for the purposes of the - % control sequence corresponding to the node, but it has to expand - % into the usual \leavevmode...\vrule stuff for purposes of - % printing. So we \turnoffactive for the \refx-snt, back on for the - % printing, back off for the \refx-pg. - {\normalturnoffactive - % Only output a following space if the -snt ref is nonempty; for - % @unnumbered and @anchor, it won't be. - \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}% - \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi - }% - % [mynode], - [\printednodename],\space - % page 3 - \turnoffactive \putwordpage\tie\refx{#1-pg}{}% + % node/anchor (non-float) references. + % + % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not + % insert empty discretionaries after hyphens, which means that it will + % not find a line break at a hyphen in a node names. Since some manuals + % are best written with fairly long node names, containing hyphens, this + % is a loss. Therefore, we give the text of the node name again, so it + % is as if TeX is seeing it for the first time. + \ifdim \wd1 > 0pt + \putwordsection{} ``\printedrefname'' \putwordin{} \cite{\printedmanual}% + \else + % _ (for example) has to be the character _ for the purposes of the + % control sequence corresponding to the node, but it has to expand + % into the usual \leavevmode...\vrule stuff for purposes of + % printing. So we \turnoffactive for the \refx-snt, back on for the + % printing, back off for the \refx-pg. + {\turnoffactive \otherbackslash + % Only output a following space if the -snt ref is nonempty; for + % @unnumbered and @anchor, it won't be. + \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}% + \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi + }% + % output the `[mynode]' via a macro so it can be overridden. + \xrefprintnodename\printedrefname + % + % But we always want a comma and a space: + ,\space + % + % output the `page 3'. + \turnoffactive \otherbackslash \putwordpage\tie\refx{#1-pg}{}% + \fi \fi \endlink \endgroup} -% \dosetq is the interface for calls from other macros - -% Use \normalturnoffactive so that punctuation chars such as underscore -% and backslash work in node names. (\turnoffactive doesn't do \.) -\def\dosetq#1#2{% - {\let\folio=0% - \normalturnoffactive - \edef\next{\write\auxfile{\internalsetq{#1}{#2}}}% - \iflinks - \next - \fi - }% -} - -% \internalsetq {foo}{page} expands into -% CHARACTERS 'xrdef {foo}{...expansion of \Ypage...} -% When the aux file is read, ' is the escape character - -\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}} - -% Things to be expanded by \internalsetq - -\def\Ypagenumber{\folio} - -\def\Ytitle{\thissection} - -\def\Ynothing{} - -\def\Ysectionnumberandtype{% -\ifnum\secno=0 \putwordChapter\xreftie\the\chapno % -\else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno % -\else \ifnum \subsubsecno=0 % -\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno % -\else % -\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno % -\fi \fi \fi } - -\def\Yappendixletterandtype{% -\ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}% -\else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno % -\else \ifnum \subsubsecno=0 % -\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno % -\else % -\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno % -\fi \fi \fi } - -\gdef\xreftie{'tie} - -% Use TeX 3.0's \inputlineno to get the line number, for better error -% messages, but if we're using an old version of TeX, don't do anything. +% This macro is called from \xrefX for the `[nodename]' part of xref +% output. It's a separate macro only so it can be changed more easily, +% since square brackets don't work well in some documents. Particularly +% one that Bob is working on :). % -\ifx\inputlineno\thisisundefined - \let\linenumber = \empty % Non-3.0. -\else - \def\linenumber{\the\inputlineno:\space} -\fi +\def\xrefprintnodename#1{[#1]} + +% Things referred to by \setref. +% +\def\Ynothing{} +\def\Yomitfromtoc{} +\def\Ynumbered{% + \ifnum\secno=0 + \putwordChapter@tie \the\chapno + \else \ifnum\subsecno=0 + \putwordSection@tie \the\chapno.\the\secno + \else \ifnum\subsubsecno=0 + \putwordSection@tie \the\chapno.\the\secno.\the\subsecno + \else + \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno + \fi\fi\fi +} +\def\Yappendix{% + \ifnum\secno=0 + \putwordAppendix@tie @char\the\appendixno{}% + \else \ifnum\subsecno=0 + \putwordSection@tie @char\the\appendixno.\the\secno + \else \ifnum\subsubsecno=0 + \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno + \else + \putwordSection@tie + @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno + \fi\fi\fi +} % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. % If its value is nonempty, SUFFIX is output afterward. - +% \def\refx#1#2{% - \expandafter\ifx\csname X#1\endcsname\relax + {% + \indexnofonts + \otherbackslash + \expandafter\global\expandafter\let\expandafter\thisrefX + \csname XR#1\endcsname + }% + \ifx\thisrefX\relax % If not defined, say something at least. \angleleft un\-de\-fined\angleright \iflinks @@ -5703,21 +5997,49 @@ width0pt\relax} \fi \fi \else % It's defined, so just use it. - \csname X#1\endcsname + \thisrefX \fi #2% Output the suffix in any case. } -% This is the macro invoked by entries in the aux file. +% This is the macro invoked by entries in the aux file. Usually it's +% just a \def (we prepend XR to the control sequence name to avoid +% collisions). But if this is a float type, we have more work to do. % -\def\xrdef#1{\begingroup - % Reenable \ as an escape while reading the second argument. - \catcode`\\ = 0 - \afterassignment\endgroup - \expandafter\gdef\csname X#1\endcsname +\def\xrdef#1#2{% + \expandafter\gdef\csname XR#1\endcsname{#2}% remember this xref value. + % + % Was that xref control sequence that we just defined for a float? + \expandafter\iffloat\csname XR#1\endcsname + % it was a float, and we have the (safe) float type in \iffloattype. + \expandafter\let\expandafter\floatlist + \csname floatlist\iffloattype\endcsname + % + % Is this the first time we've seen this float type? + \expandafter\ifx\floatlist\relax + \toks0 = {\do}% yes, so just \do + \else + % had it before, so preserve previous elements in list. + \toks0 = \expandafter{\floatlist\do}% + \fi + % + % Remember this xref in the control sequence \floatlistFLOATTYPE, + % for later use in \listoffloats. + \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0{#1}}% + \fi } % Read the last existing aux file, if any. No error if none exists. +% +\def\tryauxfile{% + \openin 1 \jobname.aux + \ifeof 1 \else + \readauxfile + \global\havexrefstrue + \fi + \closein 1 +} + \def\readauxfile{\begingroup \catcode`\^^@=\other \catcode`\^^A=\other @@ -5746,9 +6068,7 @@ width0pt\relax} \fi \catcode`\^^]=\other \catcode`\^^^=\other \catcode`\^^_=\other - \catcode`\@=\other - \catcode`\^=\other - % It was suggested to define this as 7, which would allow ^^e4 etc. + % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc. % in xref tags, i.e., node names. But since ^^e4 notation isn't % supported in the main text, it doesn't seem desirable. Furthermore, % that is not enough: for node names that actually contain a ^ @@ -5761,6 +6081,9 @@ width0pt\relax} \fi % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter % and then to call \auxhat in \setq. % + \catcode`\^=\other + % + % Special characters. Should be turned off anyway, but... \catcode`\~=\other \catcode`\[=\other \catcode`\]=\other @@ -5772,8 +6095,19 @@ width0pt\relax} \fi \catcode`\$=\other \catcode`\#=\other \catcode`\&=\other + \catcode`\%=\other \catcode`+=\other % avoid \+ for paranoia even though we've turned it off - % Make the characters 128-255 be printing characters + % + % This is to support \ in node names and titles, since the \ + % characters end up in a \csname. It's easier than + % leaving it active and making its active definition an actual \ + % character. What I don't understand is why it works in the *value* + % of the xrdef. Seems like it should be a catcode12 \, and that + % should not typeset properly. But it works, so I'm moving on for + % now. --karl, 15jan04. + \catcode`\\=\other + % + % Make the characters 128-255 be printing characters. {% \count 1=128 \def\loop{% @@ -5782,31 +6116,18 @@ width0pt\relax} \fi \ifnum \count 1<256 \loop \fi }% }% - % The aux file uses ' as the escape (for now). - % Turn off \ as an escape so we do not lose on - % entries which were dumped with control sequences in their names. - % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^ - % Reference to such entries still does not work the way one would wish, - % but at least they do not bomb out when the aux file is read in. + % + % @ is our escape character in .aux files, and we need braces. \catcode`\{=1 \catcode`\}=2 - \catcode`\%=\other - \catcode`\'=0 - \catcode`\\=\other + \catcode`\@=0 % - \openin 1 \jobname.aux - \ifeof 1 \else - \closein 1 - \input \jobname.aux - \global\havexrefstrue - \global\warnedobstrue - \fi - % Open the new aux file. TeX will close it automatically at exit. - \openout\auxfile=\jobname.aux + \input \jobname.aux \endgroup} -% Footnotes. +\message{insertions,} +% including footnotes. \newcount \footnoteno @@ -5820,37 +6141,39 @@ width0pt\relax} \fi % @footnotestyle is meaningful for info output only. \let\footnotestyle=\comment -\let\ptexfootnote=\footnote - {\catcode `\@=11 % % Auto-number footnotes. Otherwise like plain. \gdef\footnote{% + \let\indent=\ptexindent + \let\noindent=\ptexnoindent \global\advance\footnoteno by \@ne \edef\thisfootno{$^{\the\footnoteno}$}% % % In case the footnote comes at the end of a sentence, preserve the % extra spacing after we do the footnote number. \let\@sf\empty - \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi + \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi % % Remove inadvertent blank space before typesetting the footnote number. \unskip \thisfootno\@sf - \footnotezzz + \dofootnote }% % Don't bother with the trickery in plain.tex to not require the % footnote text as a parameter. Our footnotes don't need to be so general. % -% Oh yes, they do; otherwise, @ifset and anything else that uses -% \parseargline fail inside footnotes because the tokens are fixed when +% Oh yes, they do; otherwise, @ifset (and anything else that uses +% \parseargline) fails inside footnotes because the tokens are fixed when % the footnote is read. --karl, 16nov96. % -\long\gdef\footnotezzz{\insert\footins\bgroup +\gdef\dofootnote{% + \insert\footins\bgroup % We want to typeset this text as a normal paragraph, even if the % footnote reference occurs in (for example) a display environment. % So reset some parameters. + \hsize=\pagewidth \interlinepenalty\interfootnotelinepenalty \splittopskip\ht\strutbox % top baseline for broken footnotes \splitmaxdepth\dp\strutbox @@ -5880,48 +6203,68 @@ width0pt\relax} \fi \footstrut \futurelet\next\fo@t } -\def\fo@t{\ifcat\bgroup\noexpand\next \let\next\f@@t - \else\let\next\f@t\fi \next} -\def\f@@t{\bgroup\aftergroup\@foot\let\next} -\def\f@t#1{#1\@foot} -\def\@foot{\strut\par\egroup} - }%end \catcode `\@=11 -% @| inserts a changebar to the left of the current line. It should -% surround any changed text. This approach does *not* work if the -% change spans more than two lines of output. To handle that, we would -% have adopt a much more difficult approach (putting marks into the main -% vertical list for the beginning and end of each change). +% In case a @footnote appears in a vbox, save the footnote text and create +% the real \insert just after the vbox finished. Otherwise, the insertion +% would be lost. +% Similarily, if a @footnote appears inside an alignment, save the footnote +% text to a box and make the \insert when a row of the table is finished. +% And the same can be done for other insert classes. --kasal, 16nov03. + +% Replace the \insert primitive by a cheating macro. +% Deeper inside, just make sure that the saved insertions are not spilled +% out prematurely. % -\def\|{% - % \vadjust can only be used in horizontal mode. - \leavevmode - % - % Append this vertical mode material after the current line in the output. - \vadjust{% - % We want to insert a rule with the height and depth of the current - % leading; that is exactly what \strutbox is supposed to record. - \vskip-\baselineskip - % - % \vadjust-items are inserted at the left edge of the type. So - % the \llap here moves out into the left-hand margin. - \llap{% - % - % For a thicker or thinner bar, change the `1pt'. - \vrule height\baselineskip width1pt - % - % This is the space between the bar and the text. - \hskip 12pt - }% - }% +\def\startsavinginserts{% + \ifx \insert\ptexinsert + \let\insert\saveinsert + \else + \let\checkinserts\relax + \fi } -% For a final copy, take out the rectangles -% that mark overfull boxes (in case you have decided -% that the text looks ok even though it passes the margin). +% This \insert replacement works for both \insert\footins{foo} and +% \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}. % -\def\finalout{\overfullrule=0pt} +\def\saveinsert#1{% + \edef\next{\noexpand\savetobox \makeSAVEname#1}% + \afterassignment\next + % swallow the left brace + \let\temp = +} +\def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}} +\def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1} + +\def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi} + +\def\placesaveins#1{% + \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname + {\box#1}% +} + +% eat @SAVE -- beware, all of them have catcode \other: +{ + \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-) + \gdef\gobblesave @SAVE{} +} + +% initialization: +\def\newsaveins #1{% + \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}% + \next +} +\def\newsaveinsX #1{% + \csname newbox\endcsname #1% + \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts + \checksaveins #1}% +} + +% initialize: +\let\checkinserts\empty +\newsaveins\footins +\newsaveins\margin + % @image. We use the macros from epsf.tex to support this. % If epsf.tex is not installed and @image is used, we complain. @@ -5931,12 +6274,12 @@ width0pt\relax} \fi % undone and the next image would fail. \openin 1 = epsf.tex \ifeof 1 \else - \closein 1 - % Do not bother showing banner with post-v2.7 epsf.tex (available in - % doc/epsf.tex until it shows up on ctan). + % Do not bother showing banner with epsf.tex v2.7k (available in + % doc/epsf.tex and on ctan). \def\epsfannounce{\toks0 = }% \input epsf.tex \fi +\closein 1 % % We will only complain once about lack of epsf.tex. \newif\ifwarnednoepsf @@ -5972,7 +6315,7 @@ width0pt\relax} \fi \nobreak\bigskip % Usually we'll have text after the image which will insert % \parskip glue, so insert it here too to equalize the space - % above and below. + % above and below. \nobreak\vskip\parskip \nobreak \line\bgroup\hss @@ -5992,6 +6335,252 @@ width0pt\relax} \fi \endgroup} +% @float FLOATTYPE,LOC ... @end float for displayed figures, tables, etc. +% We don't actually implement floating yet, we just plop the float "here". +% But it seemed the best name for the future. +% +\envparseargdef\float{\dofloat #1,,,\finish} + +% #1 is the optional FLOATTYPE, the text label for this float, typically +% "Figure", "Table", "Example", etc. Can't contain commas. If omitted, +% this float will not be numbered and cannot be referred to. +% +% #2 is the optional xref label. Also must be present for the float to +% be referable. +% +% #3 is the optional positioning argument; for now, it is ignored. It +% will somehow specify the positions allowed to float to (here, top, bottom). +% +% We keep a separate counter for each FLOATTYPE, which we reset at each +% chapter-level command. +\let\resetallfloatnos=\empty +% +\def\dofloat#1,#2,#3,#4\finish{% + \let\thiscaption=\empty + \let\thisshortcaption=\empty + % + % don't lose footnotes inside @float. + \startsavinginserts + % + % We can't be used inside a paragraph. + \par + % + \vtop\bgroup + \def\floattype{#1}% + \def\floatlabel{#2}% + \def\floatloc{#3}% we do nothing with this yet. + % + \ifx\floattype\empty + \let\safefloattype=\empty + \else + {% + % the floattype might have accents or other special characters, + % but we need to use it in a control sequence name. + \indexnofonts + \turnoffactive + \xdef\safefloattype{\floattype}% + }% + \fi + % + % If label is given but no type, we handle that as the empty type. + \ifx\floatlabel\empty \else + % We want each FLOATTYPE to be numbered separately (Figure 1, + % Table 1, Figure 2, ...). (And if no label, no number.) + % + \expandafter\getfloatno\csname\safefloattype floatno\endcsname + \global\advance\floatno by 1 + % + {% + % This magic value for \thissection is output by \setref as the + % XREFLABEL-title value. \xrefX uses it to distinguish float + % labels (which have a completely different output format) from + % node and anchor labels. And \xrdef uses it to construct the + % lists of floats. + % + \edef\thissection{\floatmagic=\safefloattype}% + \setref{\floatlabel}{Yfloat}% + }% + \fi + % + % start with \parskip glue, I guess. + \vskip\parskip + % + % Don't suppress indentation if a float happens to start a section. + \restorefirstparagraphindent +} + +% we have these possibilities: +% @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap +% @float Foo,lbl & no caption: Foo 1.1 +% @float Foo & @caption{Cap}: Foo: Cap +% @float Foo & no caption: Foo +% @float ,lbl & Caption{Cap}: 1.1: Cap +% @float ,lbl & no caption: 1.1 +% @float & @caption{Cap}: Cap +% @float & no caption: +% +\def\Efloat{% + \let\floatident = \empty + % + % In all cases, if we have a float type, it comes first. + \ifx\floattype\empty \else \def\floatident{\floattype}\fi + % + % If we have an xref label, the number comes next. + \ifx\floatlabel\empty \else + \ifx\floattype\empty \else % if also had float type, need tie first. + \appendtomacro\floatident{\tie}% + \fi + % the number. + \appendtomacro\floatident{\chaplevelprefix\the\floatno}% + \fi + % + % Start the printed caption with what we've constructed in + % \floatident, but keep it separate; we need \floatident again. + \let\captionline = \floatident + % + \ifx\thiscaption\empty \else + \ifx\floatident\empty \else + \appendtomacro\captionline{: }% had ident, so need a colon between + \fi + % + % caption text. + \appendtomacro\captionline\thiscaption + \fi + % + % If we have anything to print, print it, with space before. + % Eventually this needs to become an \insert. + \ifx\captionline\empty \else + \vskip.5\parskip + \captionline + \fi + % + % If have an xref label, write the list of floats info. Do this + % after the caption, to avoid chance of it being a breakpoint. + \ifx\floatlabel\empty \else + % Write the text that goes in the lof to the aux file as + % \floatlabel-lof. Besides \floatident, we include the short + % caption if specified, else the full caption if specified, else nothing. + {% + \atdummies \turnoffactive \otherbackslash + \immediate\write\auxfile{@xrdef{\floatlabel-lof}{% + \floatident + \ifx\thisshortcaption\empty + \ifx\thiscaption\empty \else : \thiscaption \fi + \else + : \thisshortcaption + \fi + }}% + }% + \fi + % + % Space below caption, if we printed anything. + \ifx\printedsomething\empty \else \vskip\parskip \fi + \egroup % end of \vtop + \checkinserts +} + +% Append the tokens #2 to the definition of macro #1, not expanding either. +% +\newtoks\appendtomacroAtoks +\newtoks\appendtomacroBtoks +\def\appendtomacro#1#2{% + \appendtomacroAtoks = \expandafter{#1}% + \appendtomacroBtoks = {#2}% + \edef#1{\the\appendtomacroAtoks \the\appendtomacroBtoks}% +} + +% @caption, @shortcaption are easy. +% +\long\def\caption#1{\checkenv\float \def\thiscaption{#1}} +\def\shortcaption#1{\checkenv\float \def\thisshortcaption{#1}} + +% The parameter is the control sequence identifying the counter we are +% going to use. Create it if it doesn't exist and assign it to \floatno. +\def\getfloatno#1{% + \ifx#1\relax + % Haven't seen this figure type before. + \csname newcount\endcsname #1% + % + % Remember to reset this floatno at the next chap. + \expandafter\gdef\expandafter\resetallfloatnos + \expandafter{\resetallfloatnos #1=0 }% + \fi + \let\floatno#1% +} + +% \setref calls this to get the XREFLABEL-snt value. We want an @xref +% to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we +% first read the @float command. +% +\def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}% + +% Magic string used for the XREFLABEL-title value, so \xrefX can +% distinguish floats from other xref types. +\def\floatmagic{!!float!!} + +% #1 is the control sequence we are passed; we expand into a conditional +% which is true if #1 represents a float ref. That is, the magic +% \thissection value which we \setref above. +% +\def\iffloat#1{\expandafter\doiffloat#1==\finish} +% +% #1 is (maybe) the \floatmagic string. If so, #2 will be the +% (safe) float type for this float. We set \iffloattype to #2. +% +\def\doiffloat#1=#2=#3\finish{% + \def\temp{#1}% + \def\iffloattype{#2}% + \ifx\temp\floatmagic +} + +% @listoffloats FLOATTYPE - print a list of floats like a table of contents. +% +\parseargdef\listoffloats{% + \def\floattype{#1}% floattype + {% + % the floattype might have accents or other special characters, + % but we need to use it in a control sequence name. + \indexnofonts + \turnoffactive + \xdef\safefloattype{\floattype}% + }% + % + % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE. + \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax + \ifhavexrefs + % if the user said @listoffloats foo but never @float foo. + \message{\linenumber No `\safefloattype' floats to list.}% + \fi + \else + \begingroup + \leftskip=\tocindent % indent these entries like a toc + \let\do=\listoffloatsdo + \csname floatlist\safefloattype\endcsname + \endgroup + \fi +} + +% This is called on each entry in a list of floats. We're passed the +% xref label, in the form LABEL-title, which is how we save it in the +% aux file. We strip off the -title and look up \XRLABEL-lof, which +% has the text we're supposed to typeset here. +% +% Figures without xref labels will not be included in the list (since +% they won't appear in the aux file). +% +\def\listoffloatsdo#1{\listoffloatsdoentry#1\finish} +\def\listoffloatsdoentry#1-title\finish{{% + % Can't fully expand XR#1-lof because it can contain anything. Just + % pass the control sequence. On the other hand, XR#1-pg is just the + % page number, and we want to fully expand that so we can get a link + % in pdf output. + \toksA = \expandafter{\csname XR#1-lof\endcsname}% + % + % use the same \entry macro we use to generate the TOC and index. + \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}% + \writeentry +}} + \message{localization,} % and i18n. @@ -6000,19 +6589,17 @@ width0pt\relax} \fi % properly. Single argument is the language abbreviation. % It would be nice if we could set up a hyphenation file here. % -\def\documentlanguage{\parsearg\dodocumentlanguage} -\def\dodocumentlanguage#1{% +\parseargdef\documentlanguage{% \tex % read txi-??.tex file in plain TeX. - % Read the file if it exists. - \openin 1 txi-#1.tex - \ifeof1 - \errhelp = \nolanghelp - \errmessage{Cannot read language file txi-#1.tex}% - \let\temp = \relax - \else - \def\temp{\input txi-#1.tex }% - \fi - \temp + % Read the file if it exists. + \openin 1 txi-#1.tex + \ifeof 1 + \errhelp = \nolanghelp + \errmessage{Cannot read language file txi-#1.tex}% + \else + \input txi-#1.tex + \fi + \closein 1 \endgroup } \newhelp\nolanghelp{The given language definition file cannot be found or @@ -6058,11 +6645,13 @@ should work if nowhere else does.} } % Parameters in order: 1) textheight; 2) textwidth; 3) voffset; -% 4) hoffset; 5) binding offset; 6) topskip. We also call -% \setleading{\textleading}, so the caller should define \textleading. -% The caller should also set \parskip. +% 4) hoffset; 5) binding offset; 6) topskip; 7) physical page height; 8) +% physical page width. % -\def\internalpagesizes#1#2#3#4#5#6{% +% We also call \setleading{\textleading}, so the caller should define +% \textleading. The caller should also set \parskip. +% +\def\internalpagesizes#1#2#3#4#5#6#7#8{% \voffset = #3\relax \topskip = #6\relax \splittopskip = \topskip @@ -6081,28 +6670,27 @@ should work if nowhere else does.} \normaloffset = #4\relax \bindingoffset = #5\relax % + \ifpdf + \pdfpageheight #7\relax + \pdfpagewidth #8\relax + \fi + % \setleading{\textleading} % \parindent = \defaultparindent \setemergencystretch } -% Use `small' versions. -% -\def\smallenvironments{% - \let\smalldisplay = \smalldisplayx - \let\smallexample = \smalllispx - \let\smallformat = \smallformatx - \let\smalllisp = \smalllispx -} - % @letterpaper (the default). \def\letterpaper{{\globaldefs = 1 \parskip = 3pt plus 2pt minus 1pt \textleading = 13.2pt % % If page is nothing but text, make it come out even. - \internalpagesizes{46\baselineskip}{6in}{\voffset}{.25in}{\bindingoffset}{36pt}% + \internalpagesizes{46\baselineskip}{6in}% + {\voffset}{.25in}% + {\bindingoffset}{36pt}% + {11in}{8.5in}% }} % Use @smallbook to reset parameters for 7x9.5 (or so) format. @@ -6110,26 +6698,42 @@ should work if nowhere else does.} \parskip = 2pt plus 1pt \textleading = 12pt % - \internalpagesizes{7.5in}{5.in}{\voffset}{.25in}{\bindingoffset}{16pt}% + \internalpagesizes{7.5in}{5in}% + {\voffset}{.25in}% + {\bindingoffset}{16pt}% + {9.25in}{7in}% % \lispnarrowing = 0.3in \tolerance = 700 \hfuzz = 1pt \contentsrightmargin = 0pt - \deftypemargin = 0pt \defbodyindent = .5cm - \smallenvironments }} % Use @afourpaper to print on European A4 paper. \def\afourpaper{{\globaldefs = 1 \parskip = 3pt plus 2pt minus 1pt - \textleading = 12pt + \textleading = 13.2pt % - \internalpagesizes{53\baselineskip}{160mm}{\voffset}{4mm}{\bindingoffset}{44pt}% + % Double-side printing via postscript on Laserjet 4050 + % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm. + % To change the settings for a different printer or situation, adjust + % \normaloffset until the front-side and back-side texts align. Then + % do the same for \bindingoffset. You can set these for testing in + % your texinfo source file like this: + % @tex + % \global\normaloffset = -6mm + % \global\bindingoffset = 10mm + % @end tex + \internalpagesizes{51\baselineskip}{160mm} + {\voffset}{\hoffset}% + {\bindingoffset}{44pt}% + {297mm}{210mm}% % \tolerance = 700 \hfuzz = 1pt + \contentsrightmargin = 0pt + \defbodyindent = 5mm }} % Use @afivepaper to print on European A5 paper. @@ -6139,44 +6743,46 @@ should work if nowhere else does.} \parskip = 2pt plus 1pt minus 0.1pt \textleading = 12.5pt % - \internalpagesizes{166mm}{120mm}{\voffset}{-8mm}{\bindingoffset}{8pt}% + \internalpagesizes{160mm}{120mm}% + {\voffset}{\hoffset}% + {\bindingoffset}{8pt}% + {210mm}{148mm}% % \lispnarrowing = 0.2in \tolerance = 800 \hfuzz = 1.2pt - \contentsrightmargin = 0mm - \deftypemargin = 0pt + \contentsrightmargin = 0pt \defbodyindent = 2mm \tableindent = 12mm - % - \smallenvironments }} -% A specific text layout, 24x15cm overall, intended for A4 paper. Top margin -% 29mm, hence bottom margin 28mm, nominal side margin 3cm. +% A specific text layout, 24x15cm overall, intended for A4 paper. \def\afourlatex{{\globaldefs = 1 - \textleading = 13.6pt - % \afourpaper - \internalpagesizes{237mm}{150mm}{3.6mm}{3.6mm}{3mm}{7mm}% + \internalpagesizes{237mm}{150mm}% + {\voffset}{4.6mm}% + {\bindingoffset}{7mm}% + {297mm}{210mm}% % - % Must explicitly reset to 0 because we call \afourpaper, apparently, - % although this does not entirely make sense. + % Must explicitly reset to 0 because we call \afourpaper. \globaldefs = 0 }} -% Use @afourwide to print on European A4 paper in wide format. -\def\afourwide{% +% Use @afourwide to print on A4 paper in landscape format. +\def\afourwide{{\globaldefs = 1 \afourpaper - \internalpagesizes{6.5in}{9.5in}{\hoffset}{\normaloffset}{\bindingoffset}{7mm}% -} + \internalpagesizes{241mm}{165mm}% + {\voffset}{-2.95mm}% + {\bindingoffset}{7mm}% + {297mm}{210mm}% + \globaldefs = 0 +}} % @pagesizes TEXTHEIGHT[,TEXTWIDTH] % Perhaps we should allow setting the margins, \topskip, \parskip, % and/or leading, also. Or perhaps we should compute them somehow. % -\def\pagesizes{\parsearg\pagesizesxxx} -\def\pagesizesxxx#1{\pagesizesyyy #1,,\finish} +\parseargdef\pagesizes{\pagesizesyyy #1,,\finish} \def\pagesizesyyy#1,#2,#3\finish{{% \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi \globaldefs = 1 @@ -6184,7 +6790,16 @@ should work if nowhere else does.} \parskip = 3pt plus 2pt minus 1pt \setleading{\textleading}% % - \internalpagesizes{#1}{\hsize}{\voffset}{\normaloffset}{\bindingoffset}{44pt}% + \dimen0 = #1 + \advance\dimen0 by \voffset + % + \dimen2 = \hsize + \advance\dimen2 by \normaloffset + % + \internalpagesizes{#1}{\hsize}% + {\voffset}{\normaloffset}% + {\bindingoffset}{44pt}% + {\dimen0}{\dimen2}% }} % Set default to letter. @@ -6214,8 +6829,8 @@ should work if nowhere else does.} \def\normalplus{+} \def\normaldollar{$}%$ font-lock fix -% This macro is used to make a character print one way in ttfont -% where it can probably just be output, and another way in other fonts, +% This macro is used to make a character print one way in \tt +% (where it can probably be output as-is), and another way in other fonts, % where something hairier probably needs to be done. % % #1 is what to print if we are indeed using \tt; #2 is what to print @@ -6248,7 +6863,7 @@ should work if nowhere else does.} \catcode`\_=\active \def_{\ifusingtt\normalunderscore\_} % Subroutine for the previous macro. -\def\_{\leavevmode \kern.06em \vbox{\hrule width.3em height.1ex}} +\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em } \catcode`\|=\active \def|{{\tt\char124}} @@ -6262,15 +6877,6 @@ should work if nowhere else does.} \def+{{\tt \char 43}} \catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix -%\catcode 27=\active -%\def^^[{$\diamondsuit$} - -% Set up an active definition for =, but don't enable it most of the time. -{\catcode`\==\active -\global\def={{\tt \char 61}}} - -\catcode`+=\active -\catcode`\_=\active % If a .fmt file is being used, characters that might appear in a file % name cannot be active until we have parsed the command line. @@ -6280,44 +6886,48 @@ should work if nowhere else does.} \catcode`\@=0 -% \rawbackslashxx output one backslash character in current font -\global\chardef\rawbackslashxx=`\\ -%{\catcode`\\=\other -%@gdef@rawbackslashxx{\}} +% \backslashcurfont outputs one backslash character in current font, +% as in \char`\\. +\global\chardef\backslashcurfont=`\\ +\global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work -% \rawbackslash redefines \ as input to do \rawbackslashxx. +% \rawbackslash defines an active \ to do \backslashcurfont. +% \otherbackslash defines an active \ to be a literal `\' character with +% catcode other. {\catcode`\\=\active -@gdef@rawbackslash{@let\=@rawbackslashxx }} + @gdef@rawbackslash{@let\=@backslashcurfont} + @gdef@otherbackslash{@let\=@realbackslash} +} + +% \realbackslash is an actual character `\' with catcode other. +{\catcode`\\=\other @gdef@realbackslash{\}} % \normalbackslash outputs one backslash in fixed width font. -\def\normalbackslash{{\tt\rawbackslashxx}} +\def\normalbackslash{{\tt\backslashcurfont}} -% \catcode 17=0 % Define control-q \catcode`\\=\active % Used sometimes to turn off (effectively) the active characters % even after parsing them. -@def@turnoffactive{@let"=@normaldoublequote -@let\=@realbackslash -@let~=@normaltilde -@let^=@normalcaret -@let_=@normalunderscore -@let|=@normalverticalbar -@let<=@normalless -@let>=@normalgreater -@let+=@normalplus -@let$=@normaldollar}%$ font-lock fix +@def@turnoffactive{% + @let"=@normaldoublequote + @let\=@realbackslash + @let~=@normaltilde + @let^=@normalcaret + @let_=@normalunderscore + @let|=@normalverticalbar + @let<=@normalless + @let>=@normalgreater + @let+=@normalplus + @let$=@normaldollar %$ font-lock fix + @unsepspaces +} -@def@normalturnoffactive{@let"=@normaldoublequote -@let\=@normalbackslash -@let~=@normaltilde -@let^=@normalcaret -@let_=@normalunderscore -@let|=@normalverticalbar -@let<=@normalless -@let>=@normalgreater -@let+=@normalplus -@let$=@normaldollar}%$ font-lock fix +% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of +% the literal character `\'. (Thus, \ is not expandable when this is in +% effect.) +% +@def@normalturnoffactive{@turnoffactive @let\=@normalbackslash} % Make _ and + \other characters, temporarily. % This is canceled by @fixbackslash. @@ -6345,15 +6955,11 @@ should work if nowhere else does.} % Say @foo, not \foo, in error messages. @escapechar = `@@ -% These look ok in all fonts, so just make them not special. +% These look ok in all fonts, so just make them not special. @catcode`@& = @other @catcode`@# = @other @catcode`@% = @other -@c Set initial fonts. -@textfonts -@rm - @c Local variables: @c eval: (add-hook 'write-file-hooks 'time-stamp) @@ -6362,3 +6968,9 @@ should work if nowhere else does.} @c time-stamp-format: "%:y-%02m-%02d.%02H" @c time-stamp-end: "}" @c End: + +@c vim:sw=2: + +@ignore + arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115 +@end ignore diff --git a/src/gmp/version.texi b/src/gmp/version.texi index 7f2451b07..6e1315c35 100644 --- a/src/gmp/version.texi +++ b/src/gmp/version.texi @@ -1,4 +1,4 @@ -@set UPDATED 20 December 2002 -@set UPDATED-MONTH December 2002 -@set EDITION 4.1.2 -@set VERSION 4.1.2 +@set UPDATED 21 September 2004 +@set UPDATED-MONTH September 2004 +@set EDITION 4.1.4 +@set VERSION 4.1.4