Upgraded to GMP-4.1.4

This commit is contained in:
jjgarcia 2005-03-11 09:28:27 +00:00
parent b8e4936a1f
commit e2ccbb7cdb
82 changed files with 19800 additions and 6585 deletions

View file

@ -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
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 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.

View file

@ -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.
<one line to give the library's name and a brief idea of what it
does.>
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice

View file

@ -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 <tege@swox.com>
* Version 4.1.4 released.
* config.sub: Recognize viac3*.
2004-09-21 Torbjorn Granlund <tege@swox.com>
* gmp.texi: Update cpu list.
* configure.in: Merge x86_64 changes from HEAD.
* acinclude.m4 (X86_PATTERN): Add viac3.
2004-09-20 Torbjorn Granlund <tege@swox.com>
* 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 <tege@swox.com>
* tests/misc.c (tests_rand_start): Shift tv_usec for better seeding.
2004-09-18 Torbjorn Granlund <tege@swox.com>
* 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 <tege@swox.com>
* mpn/generic/mul_fft.c: Additional changes from Paul.
2004-09-16 Torbjorn Granlund <tege@swox.com>
* gmp-h.in (__GNU_MP_VERSION_PATCHLEVEL): Bump to 4.1.4.
2004-04-16 Paul Zimmermann <Paul.Zimmermann@loria.fr>
* mpn/generic/mul_fft.c (mpn_mul_fft): Fix a bug in the choice of the
recursive fft parameters.
2004-09-15 Torbjorn Granlund <tege@swox.com>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* Version 4.1.3 released.
2004-04-26 Torbjorn Granlund <tege@swox.com>
* mpn/ia64/*.asm: Add Itanium2 cycle counts.
2004-04-25 Kevin Ryde <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <Paul.Zimmermann@loria.fr>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* mpfrxx.h: Fix typo in assignments of mpfr_class from mpf_class.
Reported by Derrick Bass.
* tests/cxx/t-locale.cc: Use <strstream> instead of <strstream.h>, 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 <string.h> 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* gmp.texi (Language Bindings): Add GOO, MLGMP and Numerix.
2004-03-04 Kevin Ryde <kevin@swox.se>
* 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 <kevin@swox.se>
* gmp.texi (C++ Interface Integers): Note / and % rounding follows
C99 / and %.
2004-02-22 Kevin Ryde <kevin@swox.se>
* 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 <kevin@swox.se>
* gmp.texi (Miscellaneous Float Functions): For mpf_random2, note
exponent is in limbs.
2004-01-17 Kevin Ryde <kevin@swox.se>
* gmp-h.in (_GMP_H_HAVE_FILE): Add _MSL_STDIO_H for Metrowerks.
Reported by Tomas Zahradnicky.
2004-01-07 Kevin Ryde <kevin@swox.se>
* 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 <kevin@swox.se>
* gmp.texi (Single Limb Division): Correction to tex expression
for (1/2)x1.
2003-12-31 Kevin Ryde <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* gmp.texi (Debugging): Remove debauch, seems to have disappeared.
(Language Bindings): Corrections to URLs for CLN, Omni F77, Pike.
2003-11-29 Kevin Ryde <kevin@swox.se>
* 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 <kevin@swox.se>
* gmp.texi (Language Bindings): Add Axiom.
2003-11-15 Kevin Ryde <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <tege@swox.com>
* 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 <kevin@swox.se>
* mpn/x86/pentium4/sse2/diveby3.asm: Remove non-PIC RODATA memory
access for 0xAAAAAAAB constant.
2003-10-09 Kevin Ryde <kevin@swox.se>
* tests/devel/try.c (_SC_PAGESIZE): Define from _SC_PAGE_SIZE on
systems which use that, eg. hpux 9.
2003-10-04 Kevin Ryde <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
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 <kevin@swox.se>
* 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 <kevin@swox.se>
* configure.in (i786-*-*): Recognise as pentium4, per configfsf.sub.
2003-06-28 Kevin Ryde <kevin@swox.se>
* mpz/get_d_2exp.c, mpf/get_d_2exp.c: Avoid res==1.0 when floats round
upwards.
2003-06-22 Kevin Ryde <kevin@swox.se>
* 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 <kevin@swox.se>
* mpn/x86/k6/mode1o.asm: Remove a bogus ASSERT.
2003-06-08 Kevin Ryde <kevin@swox.se>
* 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 <tege@swox.com>
* mpn/pa64: Change ".level 2.0W" to ".level 2.0w" to please
picky GNU assembler.
2003-05-19 Torbjorn Granlund <tege@swox.com>
* 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 <linus@nordberg.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* gmp-impl.h (mpn_copyi, mpn_copyd): Add __GMP_DECLSPEC.
2003-04-06 Kevin Ryde <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* 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 <kevin@swox.se>
* gmp.texi (Notes for Particular Systems): Add hardware floating point
precision mode.
2003-01-05 Kevin Ryde <kevin@swox.se>
* 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 <kevin@swox.se>
* gmp.texi (Introduction to GMP): Mention release announcements
mailing list, and put home page and ftp before mailing lists.
2002-12-24 Kevin Ryde <kevin@swox.se>
* gmp.texi (Integer Import and Export): Clarify treatment of signs,
reported by Kent Boortz.
2002-12-13 Pedro Gimeno <pggimeno@wanadoo.es>
* tests/rand/t-lc2exp.c (check_bigs): Test negative seeds.
2002-12-07 Pedro Gimeno <pggimeno@wanadoo.es>
* tests/rand/t-lc2exp.c (check_bigm, check_bigs): New tests.
2002-12-05 Torbjorn Granlund <tege@swox.com>
* mpn/pa64/sqr_diagonal.asm: Remove .entry, .proc, .procend.
* mpn/pa64/udiv_qrnnd.asm: Likewise.
2002-12-05 Kevin Ryde <kevin@swox.se>
* 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 <tege@swox.com>
* mpn/ia64/popcount.asm: Properly restore register ar.lc.
* gmp-impl.h: #undef MIN and MAX before #defining.
2002-11-04 Kevin Ryde <kevin@swox.se>
* demos/expr/expr-impl.h (stdarg.h): Test __DECC same as gmp.h.
2002-09-18 Kevin Ryde <kevin@swox.se>
* gmp.texi (Integer Comparisons): Remove mention of non-existant
mpz_cmpabs_si, reported by Conrad Curry.
2002-09-07 Kevin Ryde <kevin@swox.se>
* gmp-h.in, mp-h.in: Use #ifdef for tests, for the benefit of
applications using gcc -Wundef.
2002-08-22 Kevin Ryde <kevin@swox.se>
* config.guess (powerpc*-*-*): Use a { } construct to suppress SIGILL
message on AIX.
2002-06-18 Kevin Ryde <kevin@swox.se>
* tests/rand/t-lc2exp.c: New file.
* tests/rand/Makefile.am: Add it, and use tests/libtests.la.
2002-06-15 Kevin Ryde <kevin@swox.se>
* config.guess (CC_FOR_BUILD): Try c99, same as configfsf.guess.
2002-06-14 Kevin Ryde <kevin@swox.se>
* randlc2x.c: Allow for a<0
* randraw.c (lc): Allow for a==0.
2002-12-24 Kevin Ryde <kevin@swox.se>
* Version 4.1.2 released.

View file

@ -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 \

View file

@ -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

View file

@ -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,

View file

@ -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-*-*]])

2
src/gmp/aclocal.m4 vendored
View file

@ -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-*-*]])

36
src/gmp/config.guess vendored
View file

@ -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;

View file

@ -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

2
src/gmp/config.sub vendored
View file

@ -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 ;;

View file

@ -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 <<EOF >$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.

View file

@ -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
;;

2606
src/gmp/configure vendored

File diff suppressed because it is too large Load diff

View file

@ -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(<WANT_PROFILING>,<\`$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

View file

@ -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)

View file

@ -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);

View file

@ -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<gcdext> 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<invert> returns the inverse, or undef if it doesn't exist.
C<remove> returns a remainder/multiplicty pair. C<root> returns the
nth root, and C<roote> returns a root/bool pair, the bool indicating
whether the root is exact. C<sqrtrem> returns a root/remainder pair.
C<mpz_import> and C<mpz_export> are so named to avoid the C<import> keyword.
Their parameters are as follows,
C<clrbit> and C<setbit> 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<mpz_import> is interpreted as byte data
and must be a multiple of $size bytes. C<mpz_export> conversely returns a
string of byte data, which will be a multiple of $size bytes.
C<invert> returns the inverse, or undef if it doesn't exist. C<remove>
returns a remainder/multiplicty pair. C<root> returns the nth root, and
C<roote> returns a root/bool pair, the bool indicating whether the root is
exact. C<sqrtrem> returns a root/remainder pair.
C<clrbit> and C<setbit> 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<scan0> and C<scan1> 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<scan0> and C<scan1> 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<canonicalize> 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<get_str> 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<get_d_2exp> 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<get_str> 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<get_str> 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<get_str> 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<perl>, L<overload>.
=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<printf> could usefully accept %b for mpz, mpq and mpf, and perhaps %x for
mpf too.
There's no interface to mpfr.
C<get_str> 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:

File diff suppressed because it is too large Load diff

View file

@ -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]);
}

View file

@ -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

View file

@ -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',
}
);

View file

@ -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";

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
# GMP module external subroutine type mappings.
# Copyright 2001 Free Software Foundation, Inc.
# Copyright 2001, 2003 Free Software Foundation, Inc.
#
# This file is part of the GNU MP Library.
#
@ -33,12 +33,13 @@ mpz_coerce MPZ_COERCE
mpq_coerce MPQ_COERCE
mpf_coerce_st0 MPF_COERCE_ST0
mpf_coerce_def MPF_COERCE_DEF
mpz_mutate MPZ_MUTATE
randstate RANDSTATE
ulong_coerce ULONG_COERCE
malloced_string MALLOCED_STRING
order_noswap ORDER_NOSWAP
dummy DUMMY
# perl 5.005 doesn't have UV in its standard typemap, so use this instead
gmp_UV GMP_UV
INPUT
@ -67,8 +68,6 @@ MPF_COERCE_DEF
/* default precision used */
$var = coerce_mpf (tmp_mpf_${(my $stnum=$arg)=~s/[^0-9]//g;\$stnum},
$arg, mpf_get_default_prec())
MPZ_MUTATE
$var = mutate_mpz ($arg)
RANDSTATE
class_or_croak ($arg, rand_class); $var = SvRANDSTATE($arg);
ULONG_COERCE
@ -87,18 +86,14 @@ CONST_STRING_ASSUME
OUTPUT
MPZ
sv_setref_pv ($arg, mpz_class, $var);
sv_bless (sv_setref_pv ($arg, NULL, $var), mpz_class_hv);
MPQ
sv_setref_pv ($arg, mpq_class, $var);
sv_bless (sv_setref_pv ($arg, NULL, $var), mpq_class_hv);
MPF
sv_setref_pv ($arg, mpf_class, $var);
MPZ_ASSUME
sv_setref_pv ($arg, mpz_class, $var);
MPQ_ASSUME
sv_setref_pv ($arg, mpq_class, $var);
MPF_ASSUME
sv_setref_pv ($arg, mpf_class, $var);
sv_bless (sv_setref_pv ($arg, NULL, $var), mpf_class_hv);
RANDSTATE
sv_setref_pv ($arg, rand_class, $var);
MALLOCED_STRING
sv_usepvn_mg ($arg, $var, strlen($var));
GMP_UV
sv_setuv ($arg, (UV) ($var));

View file

@ -14,7 +14,7 @@
</center>
<font size=-1>
Copyright 2000, 2001, 2002 Free Software Foundation, Inc. <br><br>
Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. <br><br>
This file is part of the GNU MP Library. <br><br>
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.
<hr>
<!-- NB. timestamp updated automatically by emacs -->
<comment>
This file current as of 14 May 2002. An up-to-date version is available at
<a href="http://www.swox.com/gmp/projects.html">http://www.swox.com/gmp/projects.html</a>.
This file current as of 16 Apr 2004. An up-to-date version is available at
<a href="http://swox.com/gmp/projects.html">http://swox.com/gmp/projects.html</a>.
Please send comments about this page to
<a href="mailto:bug-gmp@gnu.org">bug-gmp@gnu.org</a>.
<a href="mailto:gmp-devel@swox.com">gmp-devel@swox.com</a>.
</comment>
<p> This file lists projects suitable for volunteers. Please see the
<a href="tasks.html">tasks file</a> for smaller tasks.
<p> 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.)
<p> If you want to work on any of the projects below, please let <a
href="mailto:gmp-devel@swox.com">gmp-devel@swox.com</a> 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.)
<ul>
<li> <strong>Faster multiplication</strong>
<p> The current multiplication code uses Karatsuba, 3-way Toom-Cook,
or Fermat FFT. Several new developments are desirable:
<p> The current multiplication code uses Karatsuba, 3-way Toom, and Fermat
FFT. Several new developments are desirable:
<ol>
<li> 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.
<li> 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).
<li> 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.
<li> It's possible CPU dependent effects like cache locality will
have a greater impact on speed than algorithmic improvements.
<li> 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.
<li> 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).
<li> It's possible CPU dependent effects like cache locality will have a
greater impact on speed than algorithmic improvements.
<li> 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.
<p> 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.
<p> Work on Schöhage GCDEXT for large numbers is in progress.
<p> <li> <strong>Math functions for the mpf layer</strong>
@ -159,9 +172,10 @@ MA 02111-1307, USA.
<p> <li> <strong>Nth root</strong>
<p> 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.
<p> 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.
<p> If the routine becomes fast enough, perhaps square roots could be computed
using this function.
@ -286,15 +300,31 @@ MA 02111-1307, USA.
requiring <code>longjmp</code>. Wrapping every GMP function call with a
<code>setjmp</code> would be very inconvenient.
<p> Another option would be to let <code>mpz_t</code> 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 <code>mpn</code> 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
<code>mpz_t</code> etc structure for them to indicate failure in.
<p> 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 <code>alloca</code>, but
merely adjusts <code>%esp</code>. A big enough <code>alloca</code> 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 <code>--enable-alloca=malloc-reentrant</code> (or
<code>notreentrant</code>).
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
<code>--enable-alloca=malloc-reentrant</code> (or
<code>notreentrant</code>). Arranging the default to be
<code>alloca</code> only on blocks up to a certain size and
<code>malloc</code> thereafter might be a better approach and would have
the advantage of not having calculations limited by available stack.
<p> Actually recovering from stack overflow is of course another problem.
It might be possible to catch a <code>SIGSEGV</code> 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.
<p> Operand overflow is another exception to be addressed. It's easy for
instance to ask <code>mpz_pow_ui</code> for a result bigger than an
<code>mpz_t</code> 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
<code>mpz_mul</code> won't overflow.
<p> <li> <strong>Test Suite</strong>
@ -355,6 +396,273 @@ MA 02111-1307, USA.
lots of portability and accuracy questions.
<p> <li> <strong><code>restrict</code></strong>
<p> There might be some value in judicious use of C99 style
<code>restrict</code> on various pointers, but this would need some
careful thought about what it implies for the various operand overlaps
permitted in GMP.
<p> Rumour has it some pre-C99 compilers had <code>restrict</code>, but
expressing tighter (or perhaps looser) requirements. Might be worth
investigating that before using <code>restrict</code> unconditionally.
<p> 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 <code>_Pragma</code> gives an equivalent effect.
<p> One thing to note is that Microsoft C headers (on ia64 at least) contain
<code>__declspec(restrict)</code>, so a <code>#define</code> of
<code>restrict</code> should be avoided. It might be wisest to setup a
<code>gmp_restrict</code>.
<p> <li> <strong>Nx1 Division</strong>
<p> 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.
<p> One possibility is to follow the current preinv method but taking two
limbs at a time. That means a 2x2-&gt;4 and a 2x1-&gt;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 <code>mpn_divrem_1</code> doing this has been
written in C, but not yet tested on likely chips. Clearly this scheme
would extend to 3x3-&gt;9 and 3x1-&gt;3 etc, though with diminishing
returns.
<p> For <code>mpn_mod_1</code>, Peter L. Montgomery proposes the following
scheme. For a limb R=2^</code>bits_per_mp_limb</code>, 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.
<p> 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.
<p> <code>mpn_modexact_1_odd</code> calculates an x in the range 0<=x<d
satisfying a = q*d + x*b^n, where b=2^bits_per_limb. The factor b^n
needed to get the true remainder r could be calculated by a powering
algorithm, allowing <code>mpn_modexact_1_odd</code> to be pressed into
service for an <code>mpn_mod_1</code>. <code>modexact_1</code> is
simpler and on some chips can run noticably faster than plain
<code>mod_1</code>, 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 <code>modexact</code> can be handled
by some shifting on-the-fly, or perhaps by an extra partial-limb step at
the end.
<p> <li> <strong>Factorial</strong>
<p> 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).
<p> 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.
<p> <li> <strong>Binomial Coefficients</strong>
<p> 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.
<p> 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.
<p> 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.
<p> 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
<code>mpn_bdivmod</code> trades the latency of
<code>mpn_divexact_1</code> for the throughput of
<code>mpn_submul_1</code>? Overheads must hurt though.
<p> Another reason a big divisor might help is that
<code>mpn_divexact_1</code> won't be getting a full limb in
<code>mpz_bin_uiui</code>. 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.
<p> <li> <strong>Perfect Power Testing</strong>
<p> <code>mpz_perfect_power_p</code> could be improved in a number of ways,
for instance p-adic arithmetic to find possible roots.
<p> Non-powers can be quickly identified by checking for Nth power residues
modulo small primes, like <code>mpn_perfect_square_p</code> 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.
<p> 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 <code>PP</code>. Need to think about how
much dividing to do like that, probably more for bigger inputs, less for
smaller inputs.
<p> <code>mpn_gcd_1</code> 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.
<p> <li> <strong>Prime Testing</strong>
<p> 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.
<p> The present "repetitions" argument to <code>mpz_probab_prime_p</code> 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.
<p> <code>mpz_probab_prime_p</code> always initializes a new
<code>gmp_randstate_t</code> 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.
<p> <code>mpn_mod_34lsub1</code> 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
<pre>
#define MP_LIMB_DIVISIBLE_7_P(n) \
((n) * MODLIMB_INVERSE_7 &lt;= MP_LIMB_T_MAX/7)
</pre>
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.
<p> 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. <code>udiv_qrnnd_preinv</code> 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.
<p> 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.
<p> 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.
<p> 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.
<p> 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 <code>mpz_probab_prime_p</code> 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.
<p> 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.
<p> An <code>mpz_nthprime</code> might be cute, but is almost certainly
impractical for anything but small n.
<p> <li> <strong>Intra-Library Calls</strong>
<p> 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.
<p> 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.
<p> The <code>visibility</code> 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 <code>protected</code>, and purely
internal things not wanted by test programs or anything can be
<code>internal</code>.
<p> Unfortunately, on i386 it seems <code>protected</code> 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).
<p> 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.
<p> 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).
</ul>
<hr>

View file

@ -14,7 +14,7 @@
</center>
<font size=-1>
Copyright 2000, 2001, 2002 Free Software Foundation, Inc. <br><br>
Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. <br><br>
This file is part of the GNU MP Library. <br><br>
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.
<hr>
<!-- NB. timestamp updated automatically by emacs -->
<comment>
This file current as of 20 May 2002. An up-to-date version is available at
<a href="http://www.swox.com/gmp/tasks.html">http://www.swox.com/gmp/tasks.html</a>.
This file current as of 14 Apr 2004. An up-to-date version is available at
<a href="http://swox.com/gmp/tasks.html">http://swox.com/gmp/tasks.html</a>.
Please send comments about this page to
<a href="mailto:bug-gmp@gnu.org">bug-gmp@gnu.org</a>.
<a href="mailto:gmp-devel@swox.com">gmp-devel@swox.com</a>.
</comment>
<p> These are itemized GMP development tasks. Not all the tasks
@ -46,6 +46,13 @@ MA 02111-1307, USA.
<h4>Correctness and Completeness</h4>
<ul>
<li> <code>_LONG_LONG_LIMB</code> in gmp.h is not namespace clean. Reported
by Patrick Pelissier.
<br>
We sort of mentioned <code>_LONG_LONG_LIMB</code> 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.
<li> The various reuse.c tests need to force reallocation by calling
<code>_mpz_realloc</code> with a small (1 limb) size.
<li> One reuse case is missing from mpX/tests/reuse.c:
@ -63,35 +70,79 @@ MA 02111-1307, USA.
<li> <code>mpf_eq</code> 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 <code>mpf_sub</code> for this
situation; put similar code in <code>mpf_eq</code>.
situation; put similar code in <code>mpf_eq</code>. [In progress.]
<li> <code>mpf_eq</code> 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.]
<li> <code>mpf_set_str</code> doesn't validate it's exponent, for instance
garbage 123.456eX789X is accepted (and an exponent 0 used), and overflow
of a <code>long</code> is not detected.
<li> <code>mpf_add</code> 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.
<li> <code>mpf_div</code> 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 <code>mpn_tdiv_qr</code>, where all shifting should
disappear.
<li> Windows DLLs: tests/mpz/reuse.c and tests/mpf/reuse.c initialize global
variables with pointers to <code>mpz_add</code> 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.
<li> demos/pexpr.c: The local variables in <code>main</code> might be
clobbered by the <code>longjmp</code>.
<li> <code>mpz_pow_ui</code>: Detect when the result would be more memory than
a <code>size_t</code> can represent and raise some suitable exception,
probably an alloc call asking for <code>SIZE_T_MAX</code>, and if that
somehow succeeds then an <code>abort</code>. Various size overflows of
this kind are not handled gracefully, probably resulting in segvs.
<br>
In <code>mpz_n_pow_ui</code>, detect when the count of low zero bits
exceeds an <code>unsigned long</code>. There's a (small) chance of this
happening but still having enough memory to represent the value.
Reported by Winfried Dreckmann in for instance <code>mpz_ui_pow_ui (x,
4UL, 1431655766UL)</code>.
<li> <code>mpf</code>: Detect exponent overflow and raise some exception.
It'd be nice to allow the full <code>mp_exp_t</code> 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.
</ul>
<h4>Machine Independent Optimization</h4>
<ul>
<li> <code>mpn_gcdext</code>, <code>mpz_get_d</code>,
<code>mpf_get_str</code>: Don't test <code>count_leading_zeros</code> for
<li> <code>mpf_cmp</code>: 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 <code>mpn_cmp</code>'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).
<li> <code>mpf_mul_2exp</code>, <code>mpf_div_2exp</code>: The use of
<code>mpn_lshift</code> for any size&lt;=prec means repeated
<code>mul_2exp</code> and <code>div_2exp</code> 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 <code>mpn_rshift</code> so as
to not increase the size.
<li> <code>mpn_dc_sqrtrem</code>: Don't use <code>mpn_addmul_1</code> with
multiplier==2, instead either <code>mpn_addlsh1_n</code> when available,
or <code>mpn_lshift</code>+<code>mpn_add_n</code> if not.
<li> <code>mpn_dc_sqrtrem</code>, <code>mpn_sqrtrem2</code>: Don't use
<code>mpn_add_1</code> and <code>mpn_sub_1</code> for 1 limb operations,
instead <code>ADDC_LIMB</code> and <code>SUBC_LIMB</code>.
<li> <code>mpn_sqrtrem2</code>: Use plain variables for <code>sp[0]</code> and
<code>rp[0]</code> calculations, so the compiler needn't worry about
aliasing between <code>sp</code> and <code>rp</code>.
<li> <code>mpn_sqrtrem</code>: Some work can be saved in the last step when
the remainder is not required, as noted in Paul's paper.
<li> <code>mpq_add</code>, <code>mpq_add</code>: The division "op1.den / gcd"
is done twice, where of course only once is necessary. Reported by Larry
Lambe.
<li> <code>mpq_add</code>, <code>mpq_sub</code>: The gcd fits a single limb
with high probability and in this case <code>modlimb_invert</code> could
be used to calculate the inverse just once for the two exact divisions
"op1.den / gcd" and "op2.den / gcd", rather than letting
<code>mpn_divexact_1</code> do it each time. This would require a new
<code>mpn_preinv_divexact_1</code> interface. Not sure if it'd be worth
the trouble.
<li> <code>mpq_add</code>, <code>mpq_sub</code>: The use of
<code>mpz_mul(x,y,x)</code> causes temp allocation or copying in
<code>mpz_mul</code> which can probably be avoided. A rewrite using
<code>mpn</code> might be best.
<li> <code>mpn_gcdext</code>: Don't test <code>count_leading_zeros</code> for
zero, instead check the high bit of the operand and avoid invoking
<code>count_leading_zeros</code>. 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 <code>find_a</code>, possibly just by
providing an alternate implementation for CPUs with slowish
<code>count_leading_zeros</code>.
<li> Toom3 <code>USE_MORE_MPN</code> could use a low to high cache localized
evaluate and interpolate. The necessary <code>mpn_divexact_by3c</code>
exists.
<li> <code>mpn_mul_basecase</code> 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.
<li> <code>mpn_perfect_square_p</code> on small operands might be better off
skipping the residue tests and just taking a square root.
<li> <code>mpz_perfect_power_p</code> could be improved in a number of ways.
Test for Nth power residues modulo small primes like
<code>mpn_perfect_square_p</code> does. Use p-adic arithmetic to find
possible roots. Divisibility by other primes should be tested by
grouping into a limb like <code>PP</code>.
<li> <code>mpz_perfect_power_p</code> might like to use <code>mpn_gcd_1</code>
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.
<li> <code>mpz_perfect_power_p</code> could use
<code>mpz_divisible_ui_p</code> instead of <code>mpz_tdiv_ui</code> 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.)
<li> Change <code>PP</code>/<code>PP_INVERTED</code> into an array of such
pairs, listing several hundred primes. Perhaps actually make the
products larger than one limb each.
<li> <code>PP</code> can have factors of 2 introduced in order to get the high
bit set and therefore a <code>PP_INVERTED</code> 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 <code>mpn_preinv_mod_1</code> can then be
used if it's faster than plain <code>mpn_mod_1</code>. This would be a
change only for 16-bit limbs, all the rest already have <code>PP</code>
in the right form.
<li> <code>PP</code> 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 <code>mpn_mod_1</code> done. On a
16-bit limb it looks like <code>PP</code> could take an extra factor of
3.
<li> <code>mpz_probab_prime_p</code>, <code>mpn_perfect_square_p</code> and
<code>mpz_perfect_power_p</code> could use <code>mpn_mod_34lsub1</code>
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
<code>PP</code> division currently done, or allow <code>PP</code> to do
larger primes, depending how many residue tests seem worthwhile before
launching into full root extractions or Miller-Rabin etc.
<li> <code>mpz_probab_prime_p</code> (and maybe others) could code the
divisibility tests like <code>n%7 == 0</code> in the form
<pre>
#define MP_LIMB_DIVISIBLE_7_P(n) \
((n) * MODLIMB_INVERSE_7 &lt;= MP_LIMB_T_MAX/7)
</pre>
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.
<li> <code>mpz_probab_prime_p</code> and <code>mpz_nextprime</code> 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 <code>modlimb_invert</code> 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
<code>mpn_probab_prime_1_p</code> or <code>gmp_probab_prime_ui_p</code>
perhaps.
<li> <code>mpz_probab_prime_p</code> doesn't need to make a copy of
<code>n</code> when the input is negative, it can setup an
<code>mpz_t</code> alias, same data pointer but a positive size. With no
need to clear before returning, the recursive function call could be
dispensed with too.
<li> Toom3 could use a low to high cache localized evaluate and interpolate.
The necessary <code>mpn_divexact_by3c</code> exists.
<li> <code>mpf_set_str</code> 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 <code>MPN_COPY_INCR</code> will be done to
reduce prec+1 limbs to prec.
<li> <code>mpf_div_ui</code>: Instead of padding with low zeros, call
<code>mpn_divrem_1</code> asking for fractional quotient limbs.
<li> <code>mpf_div_ui</code>: Eliminate <code>TMP_ALLOC</code>. 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.
<li> <code>mpf_div_ui</code>: Whether the high quotient limb is zero can be
determined by testing the dividend for high<divisor. When non-zero, the
divison can be done on prec dividend limbs instead of prec+1. The result
size is also known before the division, so that can be a tail call (once
the <code>TMP_ALLOC</code> is eliminated).
<li> <code>mpn_divrem_2</code> 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
<code>mpn_tdiv_qr</code>.
<li> <code>mpf_sqrt_ui</code> 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. <code>mpf_sqrt</code>
might be similar.
<li> <code>mpf_sqrt</code>: If r!=u, and if u doesn't need to be padded with
zeros, then there's no need for the tp temporary.
<li> <code>invert_limb</code> 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^<code>BITS_PER_MP_LIMB</code> 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 <code>long long</code> bit fields
when that's the only actual 64-bit type.
<li> <code>mpf_get_d</code> could be more like <code>mpz_get_d</code> 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).
<li> <code>usqr_ppm</code> or some such could do a widening square in the
style of <code>umul_ppmm</code>. 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.
<li> tal-notreent.c could keep a block of memory permanently allocated.
Currently the last nested <code>TMP_FREE</code> 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.
<li> <code>__mp_bases</code> field <code>big_base_inverted</code> is only used
if <code>USE_PREINV_DIVREM_1</code> is true, and could be omitted
otherwise, to save space.
<li> Make <code>mpf_get_str</code> and <code>mpf_set_str</code> call the
corresponding, much faster, mpn functions.
<li> <code>mpn_mod_1</code> could pre-calculate values of R mod N, R^2 mod N,
R^3 mod N, etc, with R=2^<code>BITS_PER_MP_LIMB</code>, and use them to
process multiple limbs at each step by multiplying. Suggested by Peter
L. Montgomery.
<li> <code>mpz_get_str</code>, <code>mtox</code>: For power-of-2 bases, which
are of course fast, it seems a little silly to make a second pass over
the <code>mpn_get_str</code> 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 <code>mpn_gcdext</code> with A+B,B. This
might only be an advantage if A and B are about the same size.
<li> <code>mpn_toom3_mul_n</code>, <code>mpn_toom3_sqr_n</code>: Temporaries
<code>B</code> and <code>D</code> are adjacent in memory and at the final
coefficient additions look like they could use a single
<code>mpn_add_n</code> of <code>l4</code> limbs rather than two of
<code>l2</code> limbs.
<li> <code>mpz_n_pow_ui</code> 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 <code>mpn_pow_1</code> is a little faster on small exponents.
(Note some of the ugliness in <code>mpz_n_pow_ui</code> is due to
supporting <code>mpn_mul_2</code>.)
<br>
Perhaps the stripping of 2s in <code>mpz_n_pow_ui</code> should be
confined to single limb operands for simplicity and since that's where
the greatest gain would be.
<br>
Ideally <code>mpn_pow_1</code> and <code>mpz_n_pow_ui</code> would be
merged. The reason <code>mpz_n_pow_ui</code> writes to an
<code>mpz_t</code> is that its callers leave it to make a good estimate
of the result size. Callers of <code>mpn_pow_1</code> already know the
size by separate means (<code>mp_bases</code>).
<li> <code>mpz_invert</code> should call <code>mpn_gcdext</code> directly.
</ul>
<h4>Machine Dependent Optimization</h4>
<ul>
<li> <code>udiv_qrnnd_preinv2norm</code>, the branch-free version of
<code>udiv_qrnnd_preinv</code>, might be faster on various pipelined
chips. In particular the first <code>if (_xh != 0)</code> in
<code>udiv_qrnnd_preinv</code> 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.
<br>
Note that the current <code>udiv_qrnnd_preinv2norm</code> implementation
assumes a right shift will sign extend, which is not guaranteed by the C
standards, and doesn't happen on Cray vector systems.
<li> 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 </pre>
<li> <code>invert_limb</code> on various processors might benefit from the
little Newton iteration done for alpha and ia64.
<li> Alpha 21264: <code>mpn_addlsh1_n</code> could be implemented with
<code>mpn_addmul_1</code>, since that code at 3.5 is a touch faster than
a separate <code>lshift</code> and <code>add_n</code> at
1.75+2.125=3.875. Or very likely some specific <code>addlsh1_n</code>
code could beat both.
<li> Alpha 21264: Improve feed-in code for <code>mpn_mul_1</code>,
<code>mpn_addmul_1</code>, and <code>mpn_submul_1</code>.
<li> Alpha 21164: Rewrite <code>mpn_mul_1</code>, <code>mpn_addmul_1</code>,
@ -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.
<li> Alpha 21264 ev67: Use <code>ctlz</code> and <code>cttz</code> for
<code>count_leading_zeros</code> and<code>count_trailing_zeros</code>.
Use inline for gcc, probably want asm files for elsewhere.
<li> ARC: gcc longlong.h sets up <code>umul_ppmm</code> to call
<code>__umulsidi3</code> in libgcc. Could be copied straight across, but
perhaps ought to be tested.
<li> ARM: On v5 cpus see if the <code>clz</code> instruction can be used for
<code>count_leading_zeros</code>.
<li> Itanium: <code>mpn_divexact_by3</code> 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.
<li> Itanium: <code>mpn_hamdist</code> could be put together based on the
current <code>mpn_popcount</code>.
<li> Itanium: <code>popc_limb</code> in gmp-impl.h could use the
<code>popcnt</code> insn.
<li> Itanium: <code>mpn_submul_1</code> is not implemented directly, only via
a combination of <code>mpn_mul_1</code> and <code>mpn_sub_n</code>.
<li> Alpha: GCC 3.4 will introduce <code>__builtin_ctzl</code>,
<code>__builtin_clzl</code> and <code>__builtin_popcountl</code> using
the corresponding CIX <code>ct</code> instructions, and
<code>__builtin_alpha_cmpbge</code>. These should give GCC more
information about sheduling etc than the <code>asm</code> blocks
currently used in longlong.h and gmp-impl.h.
<li> Alpha Unicos: Apparently there's no <code>alloca</code> on this system,
making <code>configure</code> choose the slower
<code>malloc-reentrant</code> allocation method. Is there a better way?
Maybe variable-length arrays per notes below.
<li> Alpha Unicos 21164, 21264: <code>.align</code> is not used since it pads
with garbage. Does the code get the intended slotting required for the
claimed speeds? <code>.align</code> at the start of a function would
presumably be safe no matter how it pads.
<li> ARM V5: <code>count_leading_zeros</code> can use the <code>clz</code>
instruction. For GCC 3.4 and up, do this via <code>__builtin_clzl</code>
since then gcc knows it's "predicable".
<li> Itanium: GCC 3.4 introduces <code>__builtin_popcount</code> which can be
used instead of an <code>asm</code> block. The builtin should give gcc
more opportunities for scheduling, bundling and predication.
<code>__builtin_ctz</code> similarly (it just uses popcount as per
current longlong.h).
<li> UltraSPARC/64: Optimize <code>mpn_mul_1</code>, <code>mpn_addmul_1</code>,
for s2 &lt; 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.
"<code>mulx</code>"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 "<code>mulx</code>"s.
<li> UltraSPARC/64: <code>mpn_divrem_1</code>, <code>mpn_mod_1</code>,
<code>mpn_divexact_1</code> and <code>mpn_modexact_1_odd</code> could
process 32 bits at a time when the divisor fits 32-bits. This will need
only 4 <code>mulx</code>'s per limb instead of 8 in the general case.
<li> UltraSPARC/32: Rewrite <code>mpn_lshift</code>, <code>mpn_rshift</code>.
Will give 2 cycles/limb. Trivial modifications of mpn/sparc64 should do.
<li> UltraSPARC/32: Write special mpn_Xmul_1 loops for s2 &lt; 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 <code>mulx</code> for multiplying is commented out.)
<li> UltraSPARC/32: <code>mpn_divexact_1</code> and
<code>mpn_modexact_1c_odd</code> 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 (<code>%gN</code>) are not available from C.
<li> UltraSPARC/32: <code>mpn_divexact_by3c</code> can work 64-bits at a time
using <code>mulx</code>, in assembler. This would be the same as for
sparc64.
<li> UltraSPARC: <code>modlimb_invert</code> might save a few cycles from
masking down to just the useful bits at each point in the calculation,
since <code>mulx</code> speed depends on the highest bit set. Either
explicit masks or small types like <code>short</code> and
<code>int</code> ought to work.
<li> Sparc64 HAL R1: <code>mpn_popcount</code> and <code>mpn_hamdist</code>
could use <code>popc</code> currently commented out in gmp-impl.h. This
chip reputedly implements <code>popc</code> properly (see gcc sparc.md),
would need to recognise the chip as <code>sparchalr1</code> or something
in configure / config.sub / config.guess.
<li> Sparc64 HAL R1 <code>popc</code>: This chip reputedly implements
<code>popc</code> properly (see gcc sparc.md). Would need to recognise
it as <code>sparchalr1</code> or something in configure / config.sub /
config.guess. <code>popc_limb</code> in gmp-impl.h could use this (per
commented out code). <code>count_trailing_zeros</code> could use it too.
<li> PA64: Improve <code>mpn_addmul_1</code>, <code>mpn_submul_1</code>, and
<code>mpn_mul_1</code>. 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 &lt; 2^32;
it should be possible to make them run at about 5 cycles/limb.
<li> PPC601: See which of the power or powerpc32 code runs better. Currently
the powerpc32 is used, but only because it's the default for
<code>powerpc*</code>.
<li> PPC630: Rewrite <code>mpn_addmul_1</code>, <code>mpn_submul_1</code>, and
<code>mpn_mul_1</code>. 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 <code>mpn_lshift</code>. 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.
<li> PowerPC-32: <code>mpn_rshift</code> should do the same sort of unrolled
loop as <code>mpn_lshift</code>.
<li> Implement <code>mpn_mul_basecase</code> and <code>mpn_sqr_basecase</code>
for important machines. Helping the generic sqr_basecase.c with an
<code>mpn_sqr_diagonal</code> might be enough for some of the RISCs.
@ -456,23 +439,17 @@ MA 02111-1307, USA.
might benefit from some destination prefetching.
<li> PentiumPro: <code>mpn_divrem_1</code> might be able to use a
mul-by-inverse, hoping for maybe 30 c/l.
<li> P6: <code>mpn_add_n</code> and <code>mpn_sub_n</code> 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.
<li> K7: <code>mpn_lshift</code> and <code>mpn_rshift</code> 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.
<li> PPC32: Try using fewer registers in the current <code>mpn_lshift</code>.
The pipeline is now extremely deep, perhaps unnecessarily deep.
<li> PPC32: Write <code>mpn_rshift</code> based on new <code>mpn_lshift</code>.
<li> PPC32: Rewrite <code>mpn_add_n</code> and <code>mpn_sub_n</code>. Should
run at just 3.25 cycles/limb.
<li> Fujitsu VPP: Vectorize main functions, perhaps in assembly language.
<li> Fujitsu VPP: Write <code>mpn_mul_basecase</code> and
<code>mpn_sqr_basecase</code>. This should use a "vertical multiplication
method", to avoid carry propagation. splitting one of the operands in
11-bit chunks.
<li> 68k, Pentium: <code>mpn_lshift</code> by 31 should use the special rshift
<li> Pentium: <code>mpn_lshift</code> by 31 should use the special rshift
by 1 code, and vice versa <code>mpn_rshift</code> 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? <code>bits_per_digit</code> 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).
<li> Cray: <code>popc_limb</code> could use the Cray <code>_popc</code>
intrinsic. That would help <code>mpz_hamdist</code> and might make the
generic C versions of <code>mpn_popcount</code> and
<code>mpn_hamdist</code> suffice for Cray (if it vectorizes, or can be
given a hint to do so).
<li> 68000: <code>mpn_mul_1</code>, <code>mpn_addmul_1</code>,
<code>mpn_submul_1</code>: Check for a 16-bit multiplier and use two
multiplies per limb, not four.
<li> 68000: <code>mpn_lshift</code> and <code>mpn_rshift</code> could use a
<code>roll</code> and mask instead of <code>lsrl</code> and
<code>lsll</code>. 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.
<li> S390: <code>BSWAP_LIMB_FETCH</code> looks like it could be done with
<code>lrvg</code>, 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 <code>BSWAP_LIMB</code> too, or
would that mean a store and re-fetch? Presumably that's what comes out
in glibc.
<li> Improve <code>count_leading_zeros</code> for 64-bit machines:
<pre>
if ((x &gt&gt 32) == 0) { x &lt&lt= 32; cnt += 32; }
@ -519,10 +489,11 @@ MA 02111-1307, USA.
<li> IRIX 6 MIPSpro compiler has an <code>__inline</code> which could perhaps
be used in <code>__GMP_EXTERN_INLINE</code>. What would be the right way
to identify suitable versions of that compiler?
<li> VAX D and G format <code>double</code> floats are straightforward and
could perhaps be handled directly in <code>__gmp_extract_double</code>
and maybe in <code>mpz_get_d</code>, rather than falling back on the
generic code. (Both formats are detected by <code>configure</code>.)
<li> IRIX <code>cc</code> is rumoured to have an <code>_int_mult_upper</code>
(in <code>&lt;intrinsics.h&gt;</code> 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.
<li> <code>mpn_get_str</code> final divisions by the base with
<code>udiv_qrnd_unnorm</code> 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
<code>mp_limb_t</code>s in registers.
<br>
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.)
</ul>
<h4>New Functionality</h4>
<ul>
<li> Add in-memory versions of <code>mp?_out_raw</code> and
<code>mp?_inp_raw</code>.
<li> <code>mpz_get_nth_ui</code>. Return the nth word (not necessarily the
nth limb).
<li> Maybe add <code>mpz_crr</code> (Chinese Remainder Reconstruction).
<li> Let `0b' and `0B' mean binary input everywhere.
<li> <code>mpz_init</code> and <code>mpq_init</code> could do lazy allocation.
@ -571,25 +545,14 @@ MA 02111-1307, USA.
</ul>
<li> Add <code>mpf_out_raw</code> and <code>mpf_inp_raw</code>. 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.
<li> <code>mpn_and_n</code> ... <code>mpn_copyd</code>: 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.
<li> <code>mpz_set_str</code> etc variants taking string lengths rather than
null-terminators.
<li> Consider changing the thresholds to apply the simpler algorithm when
"<code>&lt;=</code>" rather than "<code>&lt;</code>", so a threshold can
be set to <code>MP_SIZE_T_MAX</code> to get only the simpler code (the
compiler will know <code>size &lt;= MP_SIZE_T_MAX</code> is always true).
Alternately it looks like the <code>ABOVE_THRESHOLD</code> and
<code>BELOW_THRESHOLD</code> macros can do this adequately, and also pick
up cases where a threshold of zero should mean only the second algorithm.
<li> <code>mpz_nthprime</code>.
<li> Perhaps <code>mpz_init2</code>, 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 <code>mpz</code> routines need that on
their destination.
<li> <code>mpz_andn</code>, <code>mpz_iorn</code>, <code>mpz_nand</code>,
<code>mpz_nior</code>, <code>mpz_xnor</code> 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.
<li> <code>GMP_LONG_LONG_LIMB</code> or some such could become a documented
feature of gmp.h, so applications could know whether to
<code>printf</code> a limb using <code>%lu</code> or <code>%Lu</code>.
<li> <code>PRIdMP_LIMB</code> and similar defines following C99
&lt;inttypes.h&gt; might be of use to applications printing limbs.
Perhaps they should be defined only if specifically requested, the way
&lt;inttypes.h&gt; does. But if <code>GMP_LONG_LONG_LIMB</code> or
whatever is added then perhaps this can easily enough be left to
applications.
<li> <code>mpf_get_ld</code> and <code>mpf_set_ld</code> converting
<code>mpf_t</code> to and from <code>long double</code>. Other
<code>long double</code> routines would be desirable too, but these would
be a start. Often <code>long double</code> is the same as
<code>double</code>, 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 <code>long double</code>.
<li> <code>GMP_PRIdMP_LIMB</code> and similar defines following C99
&lt;inttypes.h&gt; might be of use to applications printing limbs. But
if <code>GMP_LONG_LONG_LIMB</code> or whatever is added then perhaps this
can easily enough be left to applications.
<li> <code>gmp_printf</code> could accept <code>%b</code> for binary output.
It'd be nice if it worked for plain <code>int</code> etc too, not just
<code>mpz_t</code> 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 <code>*</code> should be allowed. Maybe
<code>&amp;13b</code> (b for base) or something like that.
<li> <code>gmp_printf</code> could perhaps have a type code for an
<code>mp_limb_t</code>. That would save an application from having to
worry whether it's a <code>long</code> or a <code>long long</code>.
<li> <code>gmp_printf</code> could perhaps accept <code>mpq_t</code> for float
conversions, eg. <code>"%.4Qf"</code>. 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.
<code>mpq_get_str_point</code> or some such might be more use. Suggested
by Pedro Gimeno.
<li> <code>gmp_printf</code> 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
<code>mpf_t</code>, but would be good if <code>mpfr_t</code> was
supported in the future, or perhaps for <code>mpq_t</code>. Something
like <code>&amp;*r</code> (r for rounding, and mpfr style
<code>GMP_RND</code> parameter).
<li> <code>mpz_combit</code> to toggle a bit would be a good companion for
<code>mpz_setbit</code> and <code>mpz_clrbit</code>. Suggested by Niels
Möller (and has done some work towards it).
<li> <code>mpz_scan0_reverse</code> or <code>mpz_scan0low</code> or some such
<li> <code>mpz_rscan0</code> or <code>mpz_revscan0</code> or some such
searching towards the low end of an integer might match
<code>mpz_scan0</code> nicely. Likewise for <code>scan1</code>.
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.
<li> <code>gmp_randinit_r</code> and maybe <code>gmp_randstate_set</code> to
init-and-copy or to just copy a <code>gmp_randstate_t</code>. Suggested
by Pedro Gimeno.
<li> <code>mpf_get_ld</code>, <code>mpf_set_ld</code>: Conversions between
<code>mpf_t</code> and <code>long double</code>, suggested by Dan
Christensen. There'd be some work to be done by <code>configure</code>
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 <code>long double</code> routines might be desirable
too, but <code>mpf</code> would be a start.
<br>
<code>long double</code> is an ANSI-ism, so everything involving it would
need to be suppressed on a K&R compiler.
<br>
There'd be some work to be done by <code>configure</code> to recognise
the format in use, MPFR has a start on this. Often <code>long
double</code> is the same as <code>double</code>, which is easy but
pretty pointless. A single float format detector macro could look at
<code>double</code> then <code>long double</code>
<br>
Sometimes there's a compiler option for the size of a <code>long
double</code>, 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.
<li> <code>mpz_sqrt_if_perfect_square</code>: When
<code>mpz_perfect_square_p</code> 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.
<code>mpz_get_sll</code>, <code>mpz_get_sll</code>: Conversions for
<code>long long</code>. These would aid interoperability, though a
mixture of GMP and <code>long long</code> would probably not be too
common. Disadvantages of using <code>long long</code> in libgmp.a would
be
common. Since <code>long long</code> is not always available (it's in
C99 and GCC though), disadvantages of using <code>long long</code> in
libgmp.a would be
<ul>
<li> Library contents vary according to the build compiler.
<li> gmp.h would need an ugly <code>#ifdef</code> block to decide if the
application compiler could take the <code>long long</code>
prototypes.
<li> Some sort of <code>LIBGMP_HAS_LONGLONG</code> would be wanted to
<li> Some sort of <code>LIBGMP_HAS_LONGLONG</code> might be wanted to
indicate whether the functions are available. (Applications using
autoconf could probe the library too.)
</ul>
@ -700,7 +656,16 @@ MA 02111-1307, USA.
uniformity with inferior ones.
</ul>
Plain use of <code>long long</code> 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 <code>long long</code> conversions only when using GCC for both
application and library. That would cover free software, and we can
worry about selected vendor compilers later.
<br>
In C++ the situation is probably clearer, we demand fairly recent C++ so
<code>long long</code> should be available always. We'd probably prefer
to have the C and C++ the same in respect of <code>long long</code>
support, but it would be possible to have it unconditionally in gmpxx.h,
by some means or another.
<li> <code>mpz_strtoz</code> parsing the same as <code>strtol</code>.
Suggested by Alexander Kruppa.
</ul>
@ -709,20 +674,22 @@ MA 02111-1307, USA.
<h4>Configuration</h4>
<ul>
<li> Floating-point format: <code>GMP_C_DOUBLE_FORMAT</code> seems to work
well. Get rid of the <code>#ifdef</code> mess in gmp-impl.h and use the
results of the test instead.
<li> a29k: umul.s and udiv.s exist but don't get used.
<li> 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.)
<li> 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.
<li> Alpha OSF: Libtool (version 1.5) ends up with some <code>${wl}</code>
bits coming through to the commands run. Seems to work anyway, but
hopefully a newer version will have this fixed.
<li> ARM: <code>umul_ppmm</code> in longlong.h always uses <code>umull</code>,
but is that available only for M series chips or some such? Perhaps it
should be configured in some way.
<li> HPPA: config.guess should recognize 7000, 7100, 7200, and 8x00.
<li> 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.
<li> IA64: Latest libtool has some nonsense to detect ELF-32 or ELF-64 on
<code>ia64-*-hpux*</code>. Does GMP need to know anything about that?
<li> HPPA: gcc 3.2 introduces a <code>-mschedule=7200</code> etc parameter,
which could be driven by an exact hppa cpu type.
<li> 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.
<code>*-*-aix*</code>. 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.
<li> Sparc: <code>config.guess</code> recognises various exact sparcs, make
use of that information in <code>configure</code> (work on this is in
progress).
<li> Sparc32: floating point or integer <code>udiv</code> 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.
<li> Sparc: The use of <code>-xtarget=native</code> with <code>cc</code> is
incorrect when cross-compiling, the target should be set according to the
configured <code>$host</code> CPU.
<li> 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?
<li> m68k: gas 2.11.90.0.1 pads with zero bytes in text segments, which is not
valid code. Probably need <code>.balignw &lt;n&gt;,0x4e7f</code> to get
nops, if <code>ALIGN</code> is going to be used for anything that's
executed across.
<li> Some CPUs have <code>umul</code> and <code>udiv</code> code not being
used. Check all such for bit rot and then put umul and udiv in
<code>$gmp_mpn_functions_optional</code> as "standard optional" objects.
<br> 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.
<li> HPPA <code>mpn_umul_ppmm</code> and <code>mpn_udiv_qrnnd</code> have a
different parameter order than those functions on other CPUs. It might
avoid confusion to have them under different names, maybe
<code>mpn_umul_ppmm_r</code> or some such. Prototypes then wouldn't
be conditionalized, and the appropriate form could be selected with the
<code>HAVE_NATIVE</code> scheme if/when the code switches to use a
<code>PROLOGUE</code> style.
<li> <code>DItype</code>: The setup in gmp-impl.h for non-GCC could use an
autoconf test to determine whether <code>long long</code> is available.
<li> 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.
<li> 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.
<li> config.m4 is generated only by the configure script, it won't be
regenerated by config.status. Creating it as an <code>AC_OUTPUT</code>
would work, but it might upset "make" to have things like <code>L$</code>
@ -775,18 +705,23 @@ MA 02111-1307, USA.
<code>AC_CONFIG_COMMANDS</code> would be the alternative. With some
careful m4 quoting the <code>changequote</code> calls might not be
needed, which might free up the order in which things had to be output.
<li> <code>make distclean</code>: 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
<code>distclean</code> in between. The only tricky part would be making
sure all possible <code>extra_functions</code> are covered.
<li> MinGW: Apparently a Cygwin version of gcc can be used by passing
<code>-mno-cygwin</code>. For <code>--host=*-*-mingw32*</code> it might
be convenient to automatically use that option, if it works. Needs
someone with a dual cygwin/mingw setup to test.
<li> Automake: Latest automake has a <code>CCAS</code>, <code>CCASFLAGS</code>
scheme. Though we probably wouldn't be using its assembler support we
could try to use those variables in compatible ways.
<li> <code>GMP_LDFLAGS</code> could probably be done with plain
<code>LDFLAGS</code> already used by automake for all linking. But with
a bit of luck the next libtool will pass pretty much all
<code>CFLAGS</code> through to the compiler when linking, making
<code>GMP_LDFLAGS</code> unnecessary.
<li> mpn/Makeasm.am uses <code>-c</code> and <code>-o</code> together in the
.S and .asm rules, but apparently that isn't completely portable (there's
an autoconf <code>AC_PROG_CC_C_O</code> 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
<code>SUFFIXES</code> are ordered to have .S and .asm ahead of .s that
wouldn't happen. Might need to check.
</ul>
@ -801,32 +736,9 @@ MA 02111-1307, USA.
avoid <code>mpn_mul</code> calls. Perhaps the same for two limbs.
<li> Inline the <code>lc</code> code, to avoid a function call and
<code>TMP_ALLOC</code> for every chunk.
<li> The special case for <code>seedn==0</code> will be very rarely used,
and on that basis seems unnecessary.
<li> Perhaps the <code>2exp</code> and general LC cases should be split,
for clarity (if the general case is retained).
</ul>
<li> <code>gmp_randinit_mers</code> 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.
<li> <code>gmp_randinit_lc</code>: 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.)
<li> Blum-Blum-Shub: Finish or remove. A separate
<code>gmp_randinit_bbs</code> would be wanted, not the currently
commented out case in <code>gmp_randinit</code>.
<li> <code>_gmp_rand</code> could be done as a function pointer within
<code>gmp_randstate_t</code> (or rather in the <code>_mp_algdata</code>
part), instead of switching on a <code>gmp_randalg_t</code>. Likewise
<code>gmp_randclear</code>, and perhaps <code>gmp_randseed</code> if it
became algorithm-specific. This would be more modular, and would ensure
only code for the desired algorithms is dragged into the link.
<li> <code>mpz_urandomm</code> should do something for n&lt;=0, but what?
<li> <code>mpz_urandomm</code> implementation looks like it could be improved.
Perhaps it's enough to calculate <code>nbits</code> as ceil(log2(n)) and
call <code>_gmp_rand</code> until a value <code>&lt;n</code> is obtained.
<li> <code>gmp_randstate_t</code> used for parameters perhaps should become
<code>gmp_randstate_ptr</code> the same as other types.
<li> Some of the empirical randomness tests could be included in a "make
@ -834,18 +746,48 @@ MA 02111-1307, USA.
</ul>
<h4>C++</h4>
<ul>
<li> <code>mpz_class(string)</code>, etc: Use the C++ global locale to
identify whitespace.
<br>
<code>mpf_class(string)</code>: Use the C++ global locale decimal point,
rather than the C one.
<br>
Consider making these variant <code>mpz_set_str</code> etc forms
available for <code>mpz_t</code> too, not just <code>mpz_class</code>
etc.
<li> <code>mpq_class operator+=</code>: Don't emit an unnecssary
<code>mpq_set(q,q)</code> before <code>mpz_addmul</code> etc.
<li> Put various bits of gmpxx.h into libgmpxx, to avoid excessive inlining.
Candidates for this would be,
<ul>
<li> <code>mpz_class(const char *)</code>, etc: since they're normally
not fast anyway, and we can hide the exception <code>throw</code>.
<li> <code>mpz_class(string)</code>, etc: to hide the <code>cstr</code>
needed to get to the C conversion function.
<li> <code>mpz_class string, char*</code> etc constructors: likewise to
hide the throws and conversions.
<li> <code>mpz_class::get_str</code>, etc: to hide the <code>char*</code>
to <code>string</code> conversion and free. Perhaps
<code>mpz_get_str</code> can write directly into a
<code>string</code>, to avoid copying.
<br>
Consider making such <code>string</code> returning variants
available for use with plain <code>mpz_t</code> etc too.
</ul>
The mpfr routines are not candidates, since we don't want MPFR support in
libgmpxx yet.
</ul>
<h4>Miscellaneous</h4>
<ul>
<li> Make <code>mpz_div</code> and <code>mpz_divmod</code> use rounding
analogous to <code>mpz_mod</code>. Document, and list as an
incompatibility.
<li> <code>mpz_gcdext</code> and <code>mpn_gcdext</code> 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|&lt;|b| and |y|&lt;|a| or something like that, but there's probably
two solutions under just those restrictions.
<li> <code>mpz_invert</code> should call <code>mpn_gcdext</code> directly.
<li> demos/factorize.c: use <code>mpz_divisible_ui_p</code> rather than
<code>mpz_tdiv_qr_ui</code>. (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
<code>libgmp</code> routine is only used for tests once it seems to be
good.
<li> <code>mpf_set_q</code> is very similar to <code>mpf_div</code>, it'd be
good for the two to share code. Perhaps <code>mpf_set_q</code> should
make some <code>mpf_t</code> aliases for its numerator and denominator
and just call <code>mpf_div</code>. Both would be simplified a good deal
by switching to <code>mpn_tdiv_qr</code> perhaps making them small enough
not to bother with sharing (especially since <code>mpf_set_q</code>
wouldn't need to watch out for overlaps).
<li> PowerPC: The cpu time base registers (per <code>mftb</code> and
<code>mftbu</code>) 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.
<li> <code>MUL_FFT_THRESHOLD</code> 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
<code>getrusage</code> doesn't exist. If a test might take a long time
to run then perhaps cache the result in a file somewhere.
<li> tune/time.c could choose the default precision based on the
<code>speed_unittime</code> determined, independent of the method in use.
<li> Cray vector systems: CPU frequency could be determined from
<code>sysconf(_SC_CLK_TCK)</code>, since it seems to be clock cycle
based. Is this true for all Cray systems? Would like some documentation
or something to confirm.
</ul>
<h4>Documentation</h4>
<ul>
<li> Document conventions, like that <code> unsigned long int</code> is used for
bit counts/ranges, and that <code>mp_size_t</code> is used for limb counts.
<li> <code>mpz_inp_str</code> (etc) doesn't say when it stops reading digits.
<li> <code>mpn_get_str</code> 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 <code>mpz_get_str</code> currently do. But
want to be careful not to bind ourselves to something that might not suit
another implementation.
<li> <code>va_arg</code> doesn't do the right thing with <code>mpz_t</code>
etc directly, but instead needs a pointer type like <code>MP_INT*</code>.
It'd be good to show how to do this, but we'd either need to document
<code>mpz_ptr</code> and friends, or perhaps fallback on something
slightly nasty with <code>void*</code>.
</ul>
@ -930,10 +874,6 @@ near future, but are at least worth thinking about.
<li> <code>mpz_get_si</code> 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.
<li> <code>mpz_*_ui</code> division routines currently return abs(a%b).
Perhaps make them return the real remainder instead? Return type would
be <code>signed long int</code>. But this would be an incompatible
change, so it might have to be under newly named functions.
<li> <code>mpz_init_set*</code> and <code>mpz_realloc</code> 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 <code>mpz_t</code> grows a bit more.
@ -962,33 +902,29 @@ near future, but are at least worth thinking about.
<code>mpn_add_1</code> and one from <code>mpn_sub_1</code>. 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. <br> 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 <code>mpz_add</code>
when one operand is longer than the other, and to <code>mpz_com</code>
since it's just -(x+1).
<li> <code>restrict</code>'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?
<li> 68000: A 16-bit limb might suit 68000 better than 32-bits, since the
native multiply is only 16x16. Could have this as an <code>ABI</code>
option, selecting <code>_SHORT_LIMB</code> in gmp.h. Naturally a new set
of asm subroutines would be necessary. Would need new
<code>mpz_set_ui</code> etc since the current code assumes limb&gt;=long,
but 2-limb operand forms would find a use for <code>long long</code> on
other processors too.
<li> Nx1 remainders can be taken at multiplier throughput speed by
pre-calculating an array "p[i] = 2^(i*<code>BITS_PER_MP_LIMB</code>) 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.
</ul>
<h4>Old and Obsolete Stuff</h4>
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.
<ul>
<li> Sparc32: The integer based udiv_nfp.asm used to be selected by
<code>configure --nfp</code> 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.
<li> VAX D and G format <code>double</code> floats are straightforward and
could perhaps be handled directly in <code>__gmp_extract_double</code>
and maybe in <code>mpn_get_d</code>, rather than falling back on the
generic code. (Both formats are detected by <code>configure</code>.)
</ul>
<hr>
</body>

View file

@ -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

View file

@ -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<type> (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__ */

View file

@ -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__) \

165
src/gmp/gmp.info Normal file
View file

@ -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

7035
src/gmp/gmp.info-1 Normal file

File diff suppressed because it is too large Load diff

1877
src/gmp/gmp.info-2 Normal file

File diff suppressed because it is too large Load diff

View file

@ -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{<ctype.h>} 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{}

View file

@ -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)
{

View file

@ -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" \

View file

@ -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:

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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 */

View file

@ -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 <stdio.h>
#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');

View file

@ -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

View file

@ -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})

View file

@ -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");

View file

@ -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 <fenv.h>
/* 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

View file

@ -23,13 +23,8 @@ MA 02111-1307, USA. */
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
#ifdef HAVE_STRCASECMP
#include <string.h>
#else
int strcasecmp (const char *, const char *);
#endif
#include <errno.h>
#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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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 <class T>
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);
}

View file

@ -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<<k;
K2 = 1 << k;
ASSERT_ALWAYS(n % K2 == 0);
maxLK = (K2>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<<i, int);
mpn_fft_initl (_fft_l, k);
K = 1<<k;
M = N/K; /* N = 2^k M */
l = M/BITS_PER_MP_LIMB;
K = 1 << k;
ASSERT_ALWAYS (pl % K == 0);
M = N/K; /* exact: N = 2^k M */
l = M / BITS_PER_MP_LIMB; /* l = pl / K also */
maxLK = (K>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;

View file

@ -30,7 +30,7 @@ C n = r35
C cycles/limb
C Itanium: 6
C Itanium 2: ?
C Itanium 2: 3
ASM_START()

View file

@ -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.

View file

@ -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.

View file

@ -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()

View file

@ -30,7 +30,7 @@ C n = r35
C cycles/limb
C Itanium: 6
C Itanium 2: ?
C Itanium 2: 3
ASM_START()

View file

@ -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

View file

@ -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)

View file

@ -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')

View file

@ -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)

View file

@ -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)

View file

@ -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')

View file

@ -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, "<m68k-defs.m4")
or die "Cannot open m68k-defs.m4: $!\nIs this the mpn/m68k source directory?\n";
my ($srcdir, $top_srcdir);
while (<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";
}

52
src/gmp/mpn/m88k/README Normal file
View file

@ -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:

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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);

View file

@ -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);
}

View file

@ -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

File diff suppressed because it is too large Load diff

View file

@ -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