Add Chromium-only Blender WebEngine parity work

This commit is contained in:
mes123456
2026-08-12 04:47:48 -04:00
commit 9fd26010f6
18225 changed files with 11622124 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
# Copyright 1999 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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
define pz
set __gmpz_dump ($)
end
define pq
set __gmpz_dump ($->_mp_num)
echo /
set __gmpz_dump ($->_mp_den)
end
define pf
set __gmpf_dump ($)
end

110
blender-5.2.0/extern/gmp-source/AUTHORS vendored Normal file
View File

@@ -0,0 +1,110 @@
Authors of GNU MP (in chronological order of initial contribution)
Torbjörn Granlund Main author
John Amanatides Original version of mpz/pprime_p.c
Paul Zimmermann mpn/generic/mul_fft.c, now defunct dc_divrem_n.c,
rootrem.c, old mpz/powm.c, old toom3 code.
Ken Weber Now defunct mpn/generic/bdivmod.c, old mpn/generic/gcd.c
Bennet Yee Previous versions of mpz/jacobi.c mpz/legendre.c
Andreas Schwab mpn/m68k/lshift.asm, mpn/m68k/rshift.asm
Robert Harley Old mpn/generic/mul_n.c, previous versions of files in
mpn/arm
Linus Nordberg Random number framework, original autoconfery
Kent Boortz MacOS 9 port, now defunct.
Kevin Ryde Most x86 assembly, new autoconfery, and countless other
things (please see the GMP manual for complete list)
Gerardo Ballabio gmpxx.h and C++ istream input
Pedro Gimeno Mersenne Twister random generator, other random number
revisions
Jason Moxham Previous versions of mpz/fac_ui.c and gen-fac_ui.c
Niels Möller gen-jacobitab.c,
mpn/generic/hgcd2.c, hgcd.c, hgcd_step.c,
hgcd_appr.c, hgcd_matrix.c, hgcd_reduce.c,
gcd.c, gcd_11.c, gcd_22.c, gcdext.c, matrix22_mul.c,
gcdext_1.c, gcd_subdiv_step.c, gcd_lehmer.c,
gcdext_subdiv_step.c, gcdext_lehmer.c,
jacobi_2.c, jacbase.c, hgcd_jacobi.c, hgcd2_jacobi.c,
matrix22_mul1_inverse_vector.c,
toom_interpolate_7pts, mulmod_bnm1.c, dcpi1_bdiv_qr.c,
dcpi1_bdiv_q.c, sbpi1_bdiv_qr.c, sbpi1_bdiv_q.c,
sec_invert.c,
toom_eval_dgr3_pm1.c, toom_eval_dgr3_pm2.c,
toom_eval_pm1.c, toom_eval_pm2.c, toom_eval_pm2exp.c,
divexact.c, mod_1_1.c, div_qr_2.c,
div_qr_2n_pi1.c, div_qr_2u_pi1.c, broot.c,
brootinv.c,
mpn/x86/k7/invert_limb.asm, mod_1_1.asm,
mpn/x86_64/invert_limb.asm,
invert_limb_table.asm, mod_1_1.asm,
div_qr_2n_pi1.asm, div_qr_2u_pi1.asm,
mpn/x86_64/core2/aorsmul_1.asm,
mpz/nextprime.c, divexact.c, gcd.c, gcdext.c,
jacobi.c, combit.c, mini-gmp/mini-gmp.c.
Marco Bodrato mpn/generic/toom44_mul.c, toom4_sqr.c, toom53_mul.c,
toom62_mul.c, toom43_mul.c, toom52_mul.c, toom54_mul.c,
toom_interpolate_6pts.c, toom_couple_handling.c,
toom63_mul.c, toom_interpolate_8pts.c,
toom6h_mul.c, toom6_sqr.c, toom_interpolate_12pts.c,
toom8h_mul.c, toom8_sqr.c, toom_interpolate_16pts.c,
mulmod_bnm1.c, sqrmod_bnm1.c, nussbaumer_mul.c,
toom_eval_pm2.c, toom_eval_pm2rexp.c,
fib2m.c, strongfibo.c, mulmod_bknp1.c,
mullo_n.c, sqrlo.c, invert.c, invertappr.c;
mpn/x86/atom/aors_n.asm, aorslshC_n.asm,
aorrlsh{1,2,C}_n.asm, aorsmul_1.asm, logops_n.asm,
sublsh2_n.asm, rshift.asm; primesieve.c;
mpz/fac_ui.c, 2fac_ui.c, mfac_uiui.c, oddfac_1.c,
primorial_ui.c, prodlimbs.c, bin_ui.c,
lucmod.c, stronglucas.c,
goetgheluck_bin_uiui.c; mini-gmp/mini-mpq.c.
David Harvey mpn/generic/add_err1_n.c, add_err2_n.c,
add_err3_n.c, sub_err1_n.c, sub_err2_n.c,
sub_err3_n.c, mulmid_basecase.c, mulmid_n.c,
toom42_mulmid.c,
mpn/x86_64/mul_basecase.asm, aors_err1_n.asm,
aors_err2_n.asm, aors_err3_n.asm,
mulmid_basecase.asm,
mpn/x86_64/core2/aors_err1_n.asm.
Martin Boij mpn/generic/perfpow.c
Marc Glisse gmpxx.h improvements
David Miller mpn/sparc32/ultrasparct1/{addmul_1,mul_1,submul_1}.asm
mpn/sparc64/ultrasparct3/{mul_1,addmul_1,submul_1}.asm
mpn/sparc64/ultrasparct3/{add_n,sub_n}.asm
mpn/sparc64/ultrasparct3/{popcount,hamdist}.asm
mpn/sparc64/ultrasparct3/cnd_aors_n.asm
mpn/sparc64/{rshift,lshift,lshiftc}.asm
mpn/sparc64/tabselect.asm
Mark Sofroniou mpn/generic/mul_fft.c type cleanup.
Ulrich Weigand Changes to support powerpc64le:
configure.ac, mpn/powerpc64/{elf,aix,darwin}.m4,
mpn/powerpc32/{darwin,elf}.m4,
mpn/powerpc64/mode64/{dive_1,divrem_1,divrem_2}.asm,
mpn/powerpc64/mode64/{gcd_1,invert_limb,mode1o}.asm,
mpn/powerpc64/mode64/{mod_1_1,mod_1_4}.asm,
mpn/powerpc64/mode64/p7/gcd_1.asm,
mpn/powerpc64/p6/{lshift,lshiftc,rshift}.asm,
mpn/powerpc64/vmx/popcount.asm.
Seth Troisi mpz/nextprime.c general speed-up and prevprime.
Marius Hillenbrand mpn/s390_64/z13/*.c (later used as basis for asm code)

674
blender-5.2.0/extern/gmp-source/COPYING vendored Normal file
View File

@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state 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 program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program 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.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU 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 Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
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 that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany 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,
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 Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, 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 and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program 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 to
this License.
7. 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
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
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 Program.
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
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program 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.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our 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
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. 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 program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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 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.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
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. Here is a sample; alter the names:
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 Lesser General
Public License instead of this License.

View File

@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state 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 program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program 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.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU 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 Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/philosophy/why-not-lgpl.html>.

36201
blender-5.2.0/extern/gmp-source/ChangeLog vendored Normal file

File diff suppressed because it is too large Load Diff

80
blender-5.2.0/extern/gmp-source/INSTALL vendored Normal file
View File

@@ -0,0 +1,80 @@
Copyright 1996, 1997, 1999-2002, 2006 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/.
INSTALLING GNU MP
=================
These instructions are only for the impatient. Others should read the install
instructions in gmp.info. Use
info -f doc/gmp.info
from the gmp source directory.
Here are some brief instructions on how to install GMP. First you need to
compile. Since you're impatient, try this
./configure
make
make check <= VERY IMPORTANT!!
If that fails, or you care about the performance of GMP, you need to read the
full instructions in the chapter "Installing GMP" in the manual.
You should not skip the "make check" part; the risk that the GMP sources are
miscompiled are unfortunately quite high. And if they indeed are, "make check"
is very likely to trigger the compiler-introduced bug.
Optionally, you can install the library with the following command. This will
be to /usr/local by default, and you'll probably need to be "root" to be able
to write there.
make install
To create the printable documentation from the texinfo source, type "make
gmp.dvi" or "make gmp.ps". This requires various "tex" commands.
If you are new to GMP, it is a good idea you at least read the chapter "GMP
Basics" in the manual.
Some known build problems are noted in the "Installing GMP" chapter of
the manual. Please report other problems to gmp-bugs@gmplib.org.
The GMP web site is located here: https://gmplib.org/.
----------------
Local variables:
mode: text
fill-column: 78
End:

View File

@@ -0,0 +1,228 @@
Copyright (C) 1994-1996, 1999-2002 Free Software Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. (Caching is
disabled by default to prevent problems with accidental use of stale
cache files.)
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You only need
`configure.ac' if you want to change it or regenerate `configure' using
a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. Run `./configure --help'
for details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not support the `VPATH'
variable, you have to compile the package for one architecture at a
time in the source code directory. After you have installed the
package for one architecture, use `make distclean' before reconfiguring
for another architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on. Usually, assuming the package is built to be run on the
_same_ architectures, `configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the `--target=TYPE' option to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
will cause the specified gcc to be used as the C compiler (unless it is
overridden in the site shell script).
`configure' Invocation
======================
`configure' recognizes the following options to control how it
operates.
`--help'
`-h'
Print a summary of the options to `configure', and exit.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

View File

@@ -0,0 +1,467 @@
## Process this file with automake to generate Makefile.in
# Copyright 1991, 1993, 1994, 1996, 1997, 1999-2004, 2006-2009, 2011-2016,
# 2018, 2020 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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
# The following options are the same as AM_INIT_AUTOMAKE in configure.in,
# except no $(top_builddir) on ansi2knr. That directory is wanted for the
# Makefiles in subdirectories, but here we must omit it so automake gives
# the actual ansi2knr build rule, not "cd $(top_builddir) && make ansi2knr".
#
# AUTOMAKE_OPTIONS = 1.8 gnu no-dependencies
# Libtool -version-info for libgmp.la and libmp.la. See "Versioning" in the
# libtool manual.
#
# CURRENT:REVISION:AGE
#
# 1. No interfaces changed, only implementations (good): Increment REVISION.
#
# 2. Interfaces added, none removed (good): Increment CURRENT, increment
# AGE, set REVISION to 0.
#
# 3. Interfaces removed (BAD, breaks upward compatibility): Increment
# CURRENT, set AGE and REVISION to 0.
#
# Do this separately for libgmp, libgmpxx and libmp, and only for releases.
#
# GMP -version-info
# release libgmp libgmpxx libmp
# 2.0.x - - -
# 3.0 3:0:0 - 3:0:0
# 3.0.1 3:1:0 - 3:0:0
# 3.1 4:0:1 - 4:0:1
# 3.1.1 4:1:1 - 4:1:1
# 4.0 5:0:2 3:0:0 4:2:1
# 4.0.1 5:1:2 3:1:0 4:3:1
# 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
# 4.1.4 6:3:3 3:5:0 4:7:1 WRONG, same as 4.1.3!
# 4.2 6:0:3 3:2:0 4:4:1 REALLY WRONG, same as 4.1!
# 4.2.1 7:1:4 4:1:1 4:10:1 WRONG for libgmpxx
# 4.2.2 7:2:4 4:2:0 4:11:1
# 4.2.3 7:3:4 4:3:0 4:12:1
# 4.2.4 7:4:4 4:4:0 4:13:1
# 4.3.0 8:0:5 5:0:1 4:14:1
# 4.3.1 8:1:5 5:1:1 4:15:1 WRONG Really used same as 4.3.0
# 4.3.2 8:2:5 5:2:1 4:16:1
# 5.0.0 9:0:6 6:0:2 4:20:1 Should have been 10:0:0
# 5.0.1 10:1:0 6:1:2 4:21:1
# 5.0.2 10:2:0 6:2:2 4:22:1
# 5.0.3 10:3:0 6:3:2 4:23:1
# 5.0.4 10:4:0 6:4:2 4:24:1
# 5.0.5 10:5:0 6:5:2 4:25:1
# 5.1.0 11:0:1 7:0:3 -
# 5.1.1 11:1:1 7:1:3 -
# 5.1.2 11:2:1 7:2:3 -
# 6.0.0 12:0:2 8:0:4 -
# 6.1.0 13:0:3 9:0:5 -
# 6.1.1 13:1:3 9:1:5 -
# 6.1.2 13:2:3 9:2:5 -
# 6.2.0 14:0:4 10:0:6 -
# 6.2.1 14:1:4 10:1:6 -
# 6.3.0 15:0:5 11:0:7 -
#
# 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
# packages of gmp 2. Pretend gmp 2 was 2:0:0, so the interface changes for
# gmp 3 mean 3:0:0 is right.
#
# We interpret "implementation changed" in item "1." above as meaning any
# release, ie. the REVISION is incremented every time (if nothing else).
# Even if we thought the code generated will be identical on all systems,
# it's still good to get the shared library filename (like
# libgmpxx.so.3.0.4) incrementing, to make it clear which GMP it's from.
LIBGMP_LT_CURRENT = 15
LIBGMP_LT_REVISION = 0
LIBGMP_LT_AGE = 5
LIBGMPXX_LT_CURRENT = 11
LIBGMPXX_LT_REVISION = 0
LIBGMPXX_LT_AGE = 7
SUBDIRS = tests mpn mpz mpq mpf printf scanf rand cxx demos tune doc
EXTRA_DIST = configfsf.guess configfsf.sub .gdbinit INSTALL.autoconf \
COPYING.LESSERv3 COPYINGv2 COPYINGv3
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = gmp.pc
# Put asl.h here for now.
EXTRA_DIST += asl.h
if WANT_CXX
GMPXX_HEADERS_OPTION = gmpxx.h
pkgconfig_DATA += gmpxx.pc
endif
EXTRA_DIST += gmpxx.h
# gmp.h is architecture dependent, mainly since it encodes the limb size used
# in libgmp. For that reason it belongs 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 knowledgeable enough to be playing with exec_prefix will be able
# to address that.
#
includeexecdir = $(exec_prefix)/include
include_HEADERS = $(GMPXX_HEADERS_OPTION)
nodist_includeexec_HEADERS = gmp.h
lib_LTLIBRARIES = libgmp.la $(GMPXX_LTLIBRARIES_OPTION)
BUILT_SOURCES = gmp.h
DISTCLEANFILES = $(BUILT_SOURCES) config.m4 @gmp_srclinks@
# Tell gmp.h it's building gmp, not an application, used by windows DLL stuff.
AM_CPPFLAGS=-D__GMP_WITHIN_GMP
MPF_OBJECTS = mpf/init$U.lo mpf/init2$U.lo mpf/inits$U.lo mpf/set$U.lo \
mpf/set_ui$U.lo mpf/set_si$U.lo mpf/set_str$U.lo mpf/set_d$U.lo \
mpf/set_z$U.lo mpf/iset$U.lo mpf/iset_ui$U.lo mpf/iset_si$U.lo \
mpf/iset_str$U.lo mpf/iset_d$U.lo mpf/clear$U.lo mpf/clears$U.lo \
mpf/get_str$U.lo mpf/dump$U.lo mpf/size$U.lo mpf/eq$U.lo mpf/reldiff$U.lo \
mpf/sqrt$U.lo mpf/random2$U.lo mpf/inp_str$U.lo mpf/out_str$U.lo \
mpf/add$U.lo mpf/add_ui$U.lo mpf/sub$U.lo mpf/sub_ui$U.lo mpf/ui_sub$U.lo \
mpf/mul$U.lo mpf/mul_ui$U.lo mpf/div$U.lo mpf/div_ui$U.lo mpf/cmp_z$U.lo \
mpf/cmp$U.lo mpf/cmp_d$U.lo mpf/cmp_ui$U.lo mpf/cmp_si$U.lo \
mpf/mul_2exp$U.lo mpf/div_2exp$U.lo mpf/abs$U.lo mpf/neg$U.lo \
mpf/set_q$U.lo mpf/get_d$U.lo mpf/get_d_2exp$U.lo mpf/set_dfl_prec$U.lo \
mpf/set_prc$U.lo mpf/set_prc_raw$U.lo mpf/get_dfl_prec$U.lo \
mpf/get_prc$U.lo mpf/ui_div$U.lo mpf/sqrt_ui$U.lo \
mpf/ceilfloor$U.lo mpf/trunc$U.lo mpf/pow_ui$U.lo \
mpf/urandomb$U.lo mpf/swap$U.lo \
mpf/fits_sint$U.lo mpf/fits_slong$U.lo mpf/fits_sshort$U.lo \
mpf/fits_uint$U.lo mpf/fits_ulong$U.lo mpf/fits_ushort$U.lo \
mpf/get_si$U.lo mpf/get_ui$U.lo \
mpf/int_p$U.lo
MPZ_OBJECTS = mpz/abs$U.lo mpz/add$U.lo mpz/add_ui$U.lo \
mpz/aorsmul$U.lo mpz/aorsmul_i$U.lo mpz/and$U.lo mpz/array_init$U.lo \
mpz/bin_ui$U.lo mpz/bin_uiui$U.lo \
mpz/cdiv_q$U.lo mpz/cdiv_q_ui$U.lo \
mpz/cdiv_qr$U.lo mpz/cdiv_qr_ui$U.lo \
mpz/cdiv_r$U.lo mpz/cdiv_r_ui$U.lo mpz/cdiv_ui$U.lo \
mpz/cfdiv_q_2exp$U.lo mpz/cfdiv_r_2exp$U.lo \
mpz/clear$U.lo mpz/clears$U.lo mpz/clrbit$U.lo \
mpz/cmp$U.lo mpz/cmp_d$U.lo mpz/cmp_si$U.lo mpz/cmp_ui$U.lo \
mpz/cmpabs$U.lo mpz/cmpabs_d$U.lo mpz/cmpabs_ui$U.lo \
mpz/com$U.lo mpz/combit$U.lo \
mpz/cong$U.lo mpz/cong_2exp$U.lo mpz/cong_ui$U.lo \
mpz/divexact$U.lo mpz/divegcd$U.lo mpz/dive_ui$U.lo \
mpz/divis$U.lo mpz/divis_ui$U.lo mpz/divis_2exp$U.lo mpz/dump$U.lo \
mpz/export$U.lo mpz/mfac_uiui$U.lo \
mpz/2fac_ui$U.lo mpz/fac_ui$U.lo mpz/oddfac_1$U.lo mpz/prodlimbs$U.lo \
mpz/fdiv_q_ui$U.lo mpz/fdiv_qr$U.lo mpz/fdiv_qr_ui$U.lo \
mpz/fdiv_r$U.lo mpz/fdiv_r_ui$U.lo mpz/fdiv_q$U.lo \
mpz/fdiv_ui$U.lo mpz/fib_ui$U.lo mpz/fib2_ui$U.lo mpz/fits_sint$U.lo \
mpz/fits_slong$U.lo mpz/fits_sshort$U.lo mpz/fits_uint$U.lo \
mpz/fits_ulong$U.lo mpz/fits_ushort$U.lo mpz/gcd$U.lo \
mpz/gcd_ui$U.lo mpz/gcdext$U.lo mpz/get_d$U.lo mpz/get_d_2exp$U.lo \
mpz/get_si$U.lo mpz/get_str$U.lo mpz/get_ui$U.lo mpz/getlimbn$U.lo \
mpz/hamdist$U.lo \
mpz/import$U.lo mpz/init$U.lo mpz/init2$U.lo mpz/inits$U.lo \
mpz/inp_raw$U.lo mpz/inp_str$U.lo mpz/invert$U.lo \
mpz/ior$U.lo mpz/iset$U.lo mpz/iset_d$U.lo mpz/iset_si$U.lo \
mpz/iset_str$U.lo mpz/iset_ui$U.lo mpz/jacobi$U.lo mpz/kronsz$U.lo \
mpz/kronuz$U.lo mpz/kronzs$U.lo mpz/kronzu$U.lo \
mpz/lcm$U.lo mpz/lcm_ui$U.lo mpz/limbs_finish$U.lo \
mpz/limbs_modify$U.lo mpz/limbs_read$U.lo mpz/limbs_write$U.lo \
mpz/lucmod$U.lo mpz/lucnum_ui$U.lo mpz/lucnum2_ui$U.lo \
mpz/millerrabin$U.lo mpz/mod$U.lo mpz/mul$U.lo mpz/mul_2exp$U.lo \
mpz/mul_si$U.lo mpz/mul_ui$U.lo \
mpz/n_pow_ui$U.lo mpz/neg$U.lo mpz/nextprime$U.lo \
mpz/out_raw$U.lo mpz/out_str$U.lo mpz/perfpow$U.lo mpz/perfsqr$U.lo \
mpz/popcount$U.lo mpz/pow_ui$U.lo mpz/powm$U.lo mpz/powm_sec$U.lo \
mpz/powm_ui$U.lo mpz/primorial_ui$U.lo \
mpz/pprime_p$U.lo mpz/random$U.lo mpz/random2$U.lo \
mpz/realloc$U.lo mpz/realloc2$U.lo mpz/remove$U.lo mpz/roinit_n$U.lo \
mpz/root$U.lo mpz/rootrem$U.lo mpz/rrandomb$U.lo mpz/scan0$U.lo \
mpz/scan1$U.lo mpz/set$U.lo mpz/set_d$U.lo mpz/set_f$U.lo \
mpz/set_q$U.lo mpz/set_si$U.lo mpz/set_str$U.lo mpz/set_ui$U.lo \
mpz/setbit$U.lo \
mpz/size$U.lo mpz/sizeinbase$U.lo mpz/sqrt$U.lo \
mpz/sqrtrem$U.lo mpz/stronglucas$U.lo mpz/sub$U.lo \
mpz/sub_ui$U.lo mpz/swap$U.lo \
mpz/tdiv_ui$U.lo mpz/tdiv_q$U.lo mpz/tdiv_q_2exp$U.lo \
mpz/tdiv_q_ui$U.lo mpz/tdiv_qr$U.lo mpz/tdiv_qr_ui$U.lo \
mpz/tdiv_r$U.lo mpz/tdiv_r_2exp$U.lo mpz/tdiv_r_ui$U.lo \
mpz/tstbit$U.lo mpz/ui_pow_ui$U.lo mpz/ui_sub$U.lo mpz/urandomb$U.lo \
mpz/urandomm$U.lo mpz/xor$U.lo
MPQ_OBJECTS = mpq/abs$U.lo mpq/aors$U.lo \
mpq/canonicalize$U.lo mpq/clear$U.lo mpq/clears$U.lo \
mpq/cmp$U.lo mpq/cmp_si$U.lo mpq/cmp_ui$U.lo mpq/div$U.lo \
mpq/get_d$U.lo mpq/get_den$U.lo mpq/get_num$U.lo mpq/get_str$U.lo \
mpq/init$U.lo mpq/inits$U.lo mpq/inp_str$U.lo mpq/inv$U.lo \
mpq/md_2exp$U.lo mpq/mul$U.lo mpq/neg$U.lo mpq/out_str$U.lo \
mpq/set$U.lo mpq/set_den$U.lo mpq/set_num$U.lo \
mpq/set_si$U.lo mpq/set_str$U.lo mpq/set_ui$U.lo \
mpq/equal$U.lo mpq/set_z$U.lo mpq/set_d$U.lo \
mpq/set_f$U.lo mpq/swap$U.lo
MPN_OBJECTS = mpn/fib_table$U.lo mpn/mp_bases$U.lo
PRINTF_OBJECTS = \
printf/asprintf$U.lo printf/asprntffuns$U.lo \
printf/doprnt$U.lo printf/doprntf$U.lo printf/doprnti$U.lo \
printf/fprintf$U.lo \
printf/obprintf$U.lo printf/obvprintf$U.lo printf/obprntffuns$U.lo \
printf/printf$U.lo printf/printffuns$U.lo \
printf/snprintf$U.lo printf/snprntffuns$U.lo \
printf/sprintf$U.lo printf/sprintffuns$U.lo \
printf/vasprintf$U.lo printf/vfprintf$U.lo printf/vprintf$U.lo \
printf/vsnprintf$U.lo printf/vsprintf$U.lo \
printf/repl-vsnprintf$U.lo
SCANF_OBJECTS = \
scanf/doscan$U.lo scanf/fscanf$U.lo scanf/fscanffuns$U.lo \
scanf/scanf$U.lo scanf/sscanf$U.lo scanf/sscanffuns$U.lo \
scanf/vfscanf$U.lo scanf/vscanf$U.lo scanf/vsscanf$U.lo
RANDOM_OBJECTS = \
rand/rand$U.lo rand/randclr$U.lo rand/randdef$U.lo rand/randiset$U.lo \
rand/randlc2s$U.lo rand/randlc2x$U.lo rand/randmt$U.lo \
rand/randmts$U.lo rand/rands$U.lo rand/randsd$U.lo rand/randsdui$U.lo \
rand/randbui$U.lo rand/randmui$U.lo
# no $U for C++ files
CXX_OBJECTS = \
cxx/isfuns.lo cxx/ismpf.lo cxx/ismpq.lo cxx/ismpz.lo cxx/ismpznw.lo \
cxx/limits.lo cxx/osdoprnti.lo cxx/osfuns.lo \
cxx/osmpf.lo cxx/osmpq.lo cxx/osmpz.lo
# In libtool 1.5 it doesn't work to build libgmp.la from the convenience
# libraries like mpz/libmpz.la. Or rather it works, but it ends up putting
# PIC objects into libgmp.a if shared and static are both built. (The PIC
# objects go into mpz/.libs/libmpz.a, and thence into .libs/libgmp.a.)
#
# For now the big lists of objects above are used. Something like mpz/*.lo
# would probably work, but might risk missing something out or getting
# something extra. The source files for each .lo are listed in the
# Makefile.am's in the subdirectories.
#
# Currently, for libgmp, unlike libmp below, we're not using
# -export-symbols, since the tune and speed programs, and perhaps some of
# the test programs, want to access undocumented symbols.
libgmp_la_SOURCES = gmp-impl.h longlong.h \
assert.c compat.c errno.c extract-dbl.c invalid.c memory.c \
mp_bpl.c mp_clz_tab.c mp_dv_tab.c mp_minv_tab.c mp_get_fns.c mp_set_fns.c \
version.c nextprime.c primesieve.c
EXTRA_libgmp_la_SOURCES = tal-debug.c tal-notreent.c tal-reent.c
libgmp_la_DEPENDENCIES = @TAL_OBJECT@ \
$(MPF_OBJECTS) $(MPZ_OBJECTS) $(MPQ_OBJECTS) \
$(MPN_OBJECTS) @mpn_objs_in_libgmp@ \
$(PRINTF_OBJECTS) $(SCANF_OBJECTS) $(RANDOM_OBJECTS)
libgmp_la_LIBADD = $(libgmp_la_DEPENDENCIES)
libgmp_la_LDFLAGS = $(GMP_LDFLAGS) $(LIBGMP_LDFLAGS) \
-version-info $(LIBGMP_LT_CURRENT):$(LIBGMP_LT_REVISION):$(LIBGMP_LT_AGE)
# We need at least one .cc file in $(libgmpxx_la_SOURCES) so automake will
# use $(CXXLINK) rather than the plain C $(LINK). cxx/dummy.cc is that
# file.
if WANT_CXX
GMPXX_LTLIBRARIES_OPTION = libgmpxx.la
endif
libgmpxx_la_SOURCES = cxx/dummy.cc
libgmpxx_la_DEPENDENCIES = $(CXX_OBJECTS) libgmp.la
libgmpxx_la_LIBADD = $(libgmpxx_la_DEPENDENCIES)
libgmpxx_la_LDFLAGS = $(GMP_LDFLAGS) $(LIBGMPXX_LDFLAGS) \
-version-info $(LIBGMPXX_LT_CURRENT):$(LIBGMPXX_LT_REVISION):$(LIBGMPXX_LT_AGE)
install-data-hook:
@echo ''
@echo '+-------------------------------------------------------------+'
@echo '| CAUTION: |'
@echo '| |'
@echo '| If you have not already run "make check", then we strongly |'
@echo '| recommend you do so. |'
@echo '| |'
@echo '| GMP has been carefully tested by its authors, but compilers |'
@echo '| are all too often released with serious bugs. GMP tends to |'
@echo '| explore interesting corners in compilers and has hit bugs |'
@echo '| on quite a few occasions. |'
@echo '| |'
@echo '+-------------------------------------------------------------+'
@echo ''
# The "test -f" support for srcdir!=builddir is similar to the automake .c.o
# etc rules, but with each foo.c explicitly, since $< is not portable
# outside an inference rule.
#
# A quoted 'foo.c' is used with the "test -f"'s to avoid Sun make rewriting
# it as part of its VPATH support. See the autoconf manual "Limitations of
# Make".
#
# Generated .h files which are used by gmp-impl.h are BUILT_SOURCES since
# they must exist before anything can be compiled.
#
# Other generated .h files are also BUILT_SOURCES so as to get all the
# build-system stuff over and done with at the start. Also, dependencies on
# the .h files are not properly expressed for the various objects that use
# them.
EXTRA_DIST += bootstrap.c
fac_table.h: gen-fac$(EXEEXT_FOR_BUILD)
./gen-fac $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >fac_table.h || (rm -f fac_table.h; exit 1)
BUILT_SOURCES += fac_table.h
gen-fac$(EXEEXT_FOR_BUILD): gen-fac$(U_FOR_BUILD).c bootstrap.c
$(CC_FOR_BUILD) `test -f 'gen-fac$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-fac$(U_FOR_BUILD).c -o gen-fac$(EXEEXT_FOR_BUILD)
DISTCLEANFILES += gen-fac$(EXEEXT_FOR_BUILD)
EXTRA_DIST += gen-fac.c
sieve_table.h: gen-sieve$(EXEEXT_FOR_BUILD)
./gen-sieve $(GMP_LIMB_BITS) >sieve_table.h || (rm -f sieve_table.h; exit 1)
BUILT_SOURCES += sieve_table.h
gen-sieve$(EXEEXT_FOR_BUILD): gen-sieve$(U_FOR_BUILD).c bootstrap.c
$(CC_FOR_BUILD) `test -f 'gen-sieve$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-sieve$(U_FOR_BUILD).c -o gen-sieve$(EXEEXT_FOR_BUILD)
DISTCLEANFILES += gen-sieve$(EXEEXT_FOR_BUILD)
EXTRA_DIST += gen-sieve.c
fib_table.h: gen-fib$(EXEEXT_FOR_BUILD)
./gen-fib header $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >fib_table.h || (rm -f fib_table.h; exit 1)
BUILT_SOURCES += fib_table.h
mpn/fib_table.c: gen-fib$(EXEEXT_FOR_BUILD)
./gen-fib table $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >mpn/fib_table.c || (rm -f mpn/fib_table.c; exit 1)
BUILT_SOURCES += mpn/fib_table.c
gen-fib$(EXEEXT_FOR_BUILD): gen-fib$(U_FOR_BUILD).c bootstrap.c
$(CC_FOR_BUILD) `test -f 'gen-fib$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-fib$(U_FOR_BUILD).c -o gen-fib$(EXEEXT_FOR_BUILD)
DISTCLEANFILES += gen-fib$(EXEEXT_FOR_BUILD)
EXTRA_DIST += gen-fib.c
mp_bases.h: gen-bases$(EXEEXT_FOR_BUILD)
./gen-bases header $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >mp_bases.h || (rm -f mp_bases.h; exit 1)
BUILT_SOURCES += mp_bases.h
mpn/mp_bases.c: gen-bases$(EXEEXT_FOR_BUILD)
./gen-bases table $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >mpn/mp_bases.c || (rm -f mpn/mp_bases.c; exit 1)
BUILT_SOURCES += mpn/mp_bases.c
gen-bases$(EXEEXT_FOR_BUILD): gen-bases$(U_FOR_BUILD).c bootstrap.c
$(CC_FOR_BUILD) `test -f 'gen-bases$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-bases$(U_FOR_BUILD).c -o gen-bases$(EXEEXT_FOR_BUILD) $(LIBM_FOR_BUILD)
DISTCLEANFILES += gen-bases$(EXEEXT_FOR_BUILD)
EXTRA_DIST += gen-bases.c
trialdivtab.h: gen-trialdivtab$(EXEEXT_FOR_BUILD)
./gen-trialdivtab $(GMP_LIMB_BITS) 8000 >trialdivtab.h || (rm -f trialdivtab.h; exit 1)
BUILT_SOURCES += trialdivtab.h
gen-trialdivtab$(EXEEXT_FOR_BUILD): gen-trialdivtab$(U_FOR_BUILD).c bootstrap.c
$(CC_FOR_BUILD) `test -f 'gen-trialdivtab$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-trialdivtab$(U_FOR_BUILD).c -o gen-trialdivtab$(EXEEXT_FOR_BUILD) $(LIBM_FOR_BUILD)
DISTCLEANFILES += gen-trialdivtab$(EXEEXT_FOR_BUILD)
EXTRA_DIST += gen-trialdivtab.c
mpn/jacobitab.h: gen-jacobitab$(EXEEXT_FOR_BUILD)
./gen-jacobitab >mpn/jacobitab.h || (rm -f mpn/jacobitab.h; exit 1)
BUILT_SOURCES += mpn/jacobitab.h
gen-jacobitab$(EXEEXT_FOR_BUILD): gen-jacobitab$(U_FOR_BUILD).c
$(CC_FOR_BUILD) `test -f 'gen-jacobitab$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-jacobitab$(U_FOR_BUILD).c -o gen-jacobitab$(EXEEXT_FOR_BUILD)
DISTCLEANFILES += gen-jacobitab$(EXEEXT_FOR_BUILD)
EXTRA_DIST += gen-jacobitab.c
mpn/perfsqr.h: gen-psqr$(EXEEXT_FOR_BUILD)
./gen-psqr $(GMP_LIMB_BITS) $(GMP_NAIL_BITS) >mpn/perfsqr.h || (rm -f mpn/perfsqr.h; exit 1)
BUILT_SOURCES += mpn/perfsqr.h
gen-psqr$(EXEEXT_FOR_BUILD): gen-psqr$(U_FOR_BUILD).c bootstrap.c
$(CC_FOR_BUILD) `test -f 'gen-psqr$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-psqr$(U_FOR_BUILD).c -o gen-psqr$(EXEEXT_FOR_BUILD) $(LIBM_FOR_BUILD)
DISTCLEANFILES += gen-psqr$(EXEEXT_FOR_BUILD)
EXTRA_DIST += gen-psqr.c
# Distribute mini-gmp. Test sources copied by dist-hook.
EXTRA_DIST += mini-gmp/README mini-gmp/mini-gmp.c mini-gmp/mini-gmp.h \
mini-gmp/ChangeLog mini-gmp/mini-mpq.c mini-gmp/mini-mpq.h \
mini-gmp/tests/Makefile mini-gmp/tests/run-tests
# Avoid: CVS - cvs directories
# *~ - emacs backups
# .#* - cvs merge originals
#
# *~ and .#* only occur when a whole directory without it's own Makefile.am
# is distributed, like "doc" or the mpn cpu subdirectories.
#
dist-hook:
-find $(distdir) \( -name CVS -type d \) -o -name "*~" -o -name ".#*" \
| xargs rm -rf
cp "$(srcdir)"/mini-gmp/tests/*.[ch] "$(distdir)/mini-gmp/tests"
# grep -F $(VERSION) $(srcdir)/Makefile.am \
# | grep -q "^# *$(VERSION) *$(LIBGMP_LT_CURRENT):$(LIBGMP_LT_REVISION):$(LIBGMP_LT_AGE) *$(LIBGMPXX_LT_CURRENT):$(LIBGMPXX_LT_REVISION):$(LIBGMPXX_LT_AGE)"
# test -z "`sed -n 's/^# *[0-9]*\.[0-9]*\.[0-9]* *\([0-9]*:[0-9]*:[0-9]*\) *\([0-9]*:[0-9]*:[0-9]*\) *\([0-9]*:[0-9]*:[0-9]*\).*/A\1\nB\2\nC\3/p' $(srcdir)/Makefile.am | grep -v 'A6:3:3\|B3:5:0\|C4:7:1' | sort | uniq -d`"
.PHONY: check-mini-gmp clean-mini-gmp
check-mini-gmp:
abs_srcdir="`cd $(srcdir) && pwd`" ; \
$(MKDIR_P) mini-gmp/tests \
&& cd mini-gmp/tests \
&& TEST_SHLIB_DIR="${abs_top_builddir}/.libs" \
$(MAKE) -f "$$abs_srcdir/mini-gmp/tests/Makefile" \
VPATH="$$abs_srcdir/mini-gmp/tests" \
srcdir="$$abs_srcdir/mini-gmp/tests" \
MINI_GMP_DIR="$$abs_srcdir/mini-gmp" \
LDFLAGS="-L../../.libs" \
LIBS="-lgmp -lm" \
CC="$(CC)" CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS) -I../.." check
clean-mini-gmp:
if [ -d mini-gmp/tests ] ; then \
abs_srcdir="`cd $(srcdir) && pwd`" ; \
cd mini-gmp/tests \
&& $(MAKE) -f "$$abs_srcdir/mini-gmp/tests/Makefile" clean ; \
fi
clean-local: clean-mini-gmp
distclean-local: clean-mini-gmp

File diff suppressed because it is too large Load Diff

1091
blender-5.2.0/extern/gmp-source/NEWS vendored Normal file

File diff suppressed because it is too large Load Diff

111
blender-5.2.0/extern/gmp-source/README vendored Normal file
View File

@@ -0,0 +1,111 @@
Copyright 1991, 1996, 1999, 2000, 2007 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/.
THE GNU MP LIBRARY
GNU MP is a library for arbitrary precision arithmetic, operating on signed
integers, rational numbers, and floating point numbers. It has a rich set of
functions, and the functions have a regular interface.
GNU MP is designed to be as fast as possible, both for small operands and huge
operands. The speed is achieved by using fullwords as the basic arithmetic
type, by using fast algorithms, with carefully optimized assembly code for the
most common inner loops for lots of CPUs, and by a general emphasis on speed
(instead of simplicity or elegance).
GNU MP is believed to be faster than any other similar library. Its advantage
increases with operand sizes for certain operations, since GNU MP in many
cases has asymptotically faster algorithms.
GNU MP is free software and may be freely copied on the terms contained in the
files COPYING* (see the manual for information on which license(s) applies to
which components of GNU MP).
OVERVIEW OF GNU MP
There are four classes of functions in GNU MP.
1. Signed integer arithmetic functions (mpz). These functions are intended
to be easy to use, with their regular interface. The associated type is
`mpz_t'.
2. Rational arithmetic functions (mpq). For now, just a small set of
functions necessary for basic rational arithmetics. The associated type
is `mpq_t'.
3. Floating-point arithmetic functions (mpf). If the C type `double'
doesn't give enough precision for your application, declare your
variables as `mpf_t' instead, set the precision to any number desired,
and call the functions in the mpf class for the arithmetic operations.
4. Positive-integer, hard-to-use, very low overhead functions are in the
mpn class. No memory management is performed. The caller must ensure
enough space is available for the results. The set of functions is not
regular, nor is the calling interface. These functions accept input
arguments in the form of pairs consisting of a pointer to the least
significant word, and an integral size telling how many limbs (= words)
the pointer points to.
Almost all calculations, in the entire package, are made by calling these
low-level functions.
For more information on how to use GNU MP, please refer to the documentation.
It is composed from the file doc/gmp.texi, and can be displayed on the screen
or printed. How to do that, as well how to build the library, is described in
the INSTALL file in this directory.
REPORTING BUGS
If you find a bug in the library, please make sure to tell us about it!
You should first check the GNU MP web pages at https://gmplib.org/, under
"Status of the current release". There will be patches for all known serious
bugs there.
Report bugs to gmp-bugs@gmplib.org. What information is needed in a useful bug
report is described in the manual. The same address can be used for suggesting
modifications and enhancements.
----------------
Local variables:
mode: text
fill-column: 78
End:

File diff suppressed because it is too large Load Diff

9921
blender-5.2.0/extern/gmp-source/aclocal.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

127
blender-5.2.0/extern/gmp-source/asl.h vendored Normal file
View File

@@ -0,0 +1,127 @@
/* asl.h -- artificially small limbs support by means of C++ operator
overloading.
Copyright 2016 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <iostream>
#include <cstdint>
#include <cstdlib>
// #include <stdexcept>
#ifndef GMP_ASSERT_ALWAYS
#define GMP_ASSERT_ALWAYS(cc) do {if (!(cc)) abort();} while (0)
#endif
// Missing: post++ post-- ++pre --prec bool(limb) !limb
#ifndef GMP_LIMB_BITS
#define GMP_LIMB_BITS 4
#endif
#define GMP_NUMB_MASK (2 * (1ul << (GMP_LIMB_BITS - 1)) - 1)
#define BINOP_MASK(op, type) \
mp_limb_t& operator op##=(const type& rhs) { \
limbo = (limbo op rhs.limbo) & GMP_NUMB_MASK; \
return *this; \
}
#define BINOP_NOMASK(op, type) \
mp_limb_t& operator op##=(const type& rhs) { \
limbo = limbo op rhs.limbo; \
return *this; \
}
typedef std::conditional<(GMP_NUMB_MASK <= 0xffff), uint16_t, uint32_t >::type type24;
typedef std::conditional<(GMP_NUMB_MASK <= 0xff), uint8_t, type24>::type mtype;
class mp_limb_t {
public:
mp_limb_t() {} // put random garbage in limbo?
mp_limb_t(const unsigned int rhs) { limbo = rhs & GMP_NUMB_MASK; }
// mp_limb_t(const mp_limb_t& rhs) { limbo = rhs.limbo; } // Causes havoc
BINOP_MASK(+, mp_limb_t)
BINOP_MASK(-, mp_limb_t)
BINOP_MASK(*, mp_limb_t)
BINOP_NOMASK(/, mp_limb_t)
BINOP_NOMASK(%, mp_limb_t)
BINOP_NOMASK(&, mp_limb_t)
BINOP_NOMASK(|, mp_limb_t)
BINOP_NOMASK(^, mp_limb_t)
mp_limb_t& operator<<=(const unsigned int rhs) {
GMP_ASSERT_ALWAYS (rhs < GMP_LIMB_BITS);
limbo = (limbo << rhs) & GMP_NUMB_MASK;
return *this;
}
mp_limb_t& operator>>=(const unsigned int rhs) {
GMP_ASSERT_ALWAYS (rhs < GMP_LIMB_BITS);
limbo = limbo >> rhs;
return *this;
}
mp_limb_t operator-() {
return static_cast<mp_limb_t>((-limbo) & GMP_NUMB_MASK);
// mp_limb_t x; x.limbo = (-limbo) & GMP_NUMB_MASK; return x;
}
mp_limb_t operator~() {
return static_cast<mp_limb_t>((~limbo) & GMP_NUMB_MASK);
// mp_limb_t x; x.limbo = (~limbo) & GMP_NUMB_MASK; return x;
}
operator unsigned int() const { return limbo; }
operator int() const { return limbo; }
#define RELOP(op) \
inline bool operator op(const mp_limb_t rhs) { \
return limbo op rhs.limbo; \
}
RELOP(==)
RELOP(!=)
RELOP(<)
RELOP(>)
RELOP(<=)
RELOP(>=)
private:
mtype limbo;
};
#define BINOP2(op, type) \
inline mp_limb_t operator op(mp_limb_t lhs, const type& rhs) { \
lhs op##= rhs; \
return lhs; \
}
BINOP2(+, mp_limb_t)
BINOP2(-, mp_limb_t)
BINOP2(*, mp_limb_t)
BINOP2(/, mp_limb_t)
BINOP2(%, mp_limb_t)
BINOP2(&, mp_limb_t)
BINOP2(|, mp_limb_t)
BINOP2(^, mp_limb_t)
BINOP2(<<, unsigned int)
BINOP2(>>, unsigned int)

View File

@@ -0,0 +1,58 @@
/* GMP assertion failure handler.
THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST
CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
FUTURE GNU MP RELEASES.
Copyright 2000, 2001 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdio.h>
#include <stdlib.h>
#include "gmp-impl.h"
void
__gmp_assert_header (const char *filename, int linenum)
{
if (filename != NULL && filename[0] != '\0')
{
fprintf (stderr, "%s:", filename);
if (linenum != -1)
fprintf (stderr, "%d: ", linenum);
}
}
void
__gmp_assert_fail (const char *filename, int linenum,
const char *expr)
{
__gmp_assert_header (filename, linenum);
fprintf (stderr, "GNU MP assertion failed: %s\n", expr);
abort();
}

View File

@@ -0,0 +1,133 @@
/* Functions needed for bootstrapping the gmp build, based on mini-gmp.
Copyright 2001, 2002, 2004, 2011, 2012, 2015 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#define MINI_GMP_DONT_USE_FLOAT_H 1
#include "mini-gmp/mini-gmp.c"
#define MIN(l,o) ((l) < (o) ? (l) : (o))
#define PTR(x) ((x)->_mp_d)
#define SIZ(x) ((x)->_mp_size)
#define xmalloc gmp_default_alloc
int
isprime (unsigned long int t)
{
unsigned long int q, r, d;
if (t < 32)
return (0xa08a28acUL >> t) & 1;
if ((t & 1) == 0)
return 0;
if (t % 3 == 0)
return 0;
if (t % 5 == 0)
return 0;
if (t % 7 == 0)
return 0;
for (d = 11;;)
{
q = t / d;
r = t - q * d;
if (q < d)
return 1;
if (r == 0)
break;
d += 2;
q = t / d;
r = t - q * d;
if (q < d)
return 1;
if (r == 0)
break;
d += 4;
}
return 0;
}
int
log2_ceil (int n)
{
int e;
assert (n >= 1);
for (e = 0; ; e++)
if ((1 << e) >= n)
break;
return e;
}
/* Set inv to the inverse of d, in the style of invert_limb, ie. for
udiv_qrnnd_preinv. */
void
mpz_preinv_invert (mpz_t inv, const mpz_t d, int numb_bits)
{
mpz_t t;
int norm;
assert (SIZ(d) > 0);
norm = numb_bits - mpz_sizeinbase (d, 2);
assert (norm >= 0);
mpz_init (t);
mpz_setbit (t, 2*numb_bits - norm);
mpz_tdiv_q (inv, t, d);
mpz_clrbit (inv, numb_bits);
mpz_clear (t);
}
/* Calculate r satisfying r*a == 1 mod 2^n. */
void
mpz_invert_2exp (mpz_t r, const mpz_t a, unsigned long n)
{
mpz_t mod;
assert (mpz_odd_p (a));
mpz_init (mod);
mpz_setbit (mod, n);
mpz_invert (r, a, mod);
mpz_clear (mod);
}
/* Calculate inv satisfying r*a == 1 mod 2^n. */
void
mpz_invert_ui_2exp (mpz_t r, unsigned long a, unsigned long n)
{
mpz_t az;
mpz_init_set_ui (az, a);
mpz_invert_2exp (r, az, n);
mpz_clear (az);
}

View File

@@ -0,0 +1,59 @@
/* Old function entrypoints retained for binary compatibility.
Copyright 2000, 2001 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdio.h>
#include "gmp-impl.h"
/* mpn_divexact_by3 was a function in gmp 3.0.1, but as of gmp 3.1 it's a
macro calling mpn_divexact_by3c. */
mp_limb_t
__MPN (divexact_by3) (mp_ptr dst, mp_srcptr src, mp_size_t size)
{
return mpn_divexact_by3 (dst, src, size);
}
/* mpn_divmod_1 was a function in gmp 3.0.1 and earlier, but marked obsolete
in both gmp 2 and 3. As of gmp 3.1 it's a macro calling mpn_divrem_1. */
mp_limb_t
__MPN (divmod_1) (mp_ptr dst, mp_srcptr src, mp_size_t size, mp_limb_t divisor)
{
return mpn_divmod_1 (dst, src, size, divisor);
}
/* mpz_legendre was a separate function in gmp 3.1.1 and earlier, but as of
4.0 it's a #define alias for mpz_jacobi. */
int
__gmpz_legendre (mpz_srcptr a, mpz_srcptr b)
{
return mpz_jacobi (a, b);
}

347
blender-5.2.0/extern/gmp-source/compile vendored Executable file
View File

@@ -0,0 +1,347 @@
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2012-10-14.11; # UTC
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
if test -f "$dir/lib$lib.a"; then
found=yes
lib=$dir/lib$lib.a
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file 'INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
ofile=
cfile=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip '-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# '.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
# Create the lock directory.
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:

1203
blender-5.2.0/extern/gmp-source/config.guess vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,671 @@
/* config.in. Generated from configure.ac by autoheader. */
/*
Copyright 1996-2022 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/.
*/
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
/* The gmp-mparam.h file (a string) the tune program should suggest updating.
*/
#undef GMP_MPARAM_H_SUGGEST
/* Define to 1 if you have the `alarm' function. */
#undef HAVE_ALARM
/* Define to 1 if alloca() works (via gmp-impl.h). */
#undef HAVE_ALLOCA
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
*/
#undef HAVE_ALLOCA_H
/* Define to 1 if the compiler accepts gcc style __attribute__ ((const)) */
#undef HAVE_ATTRIBUTE_CONST
/* Define to 1 if the compiler accepts gcc style __attribute__ ((malloc)) */
#undef HAVE_ATTRIBUTE_MALLOC
/* Define to 1 if the compiler accepts gcc style __attribute__ ((mode (XX)))
*/
#undef HAVE_ATTRIBUTE_MODE
/* Define to 1 if the compiler accepts gcc style __attribute__ ((noreturn)) */
#undef HAVE_ATTRIBUTE_NORETURN
/* Define to 1 if you have the `attr_get' function. */
#undef HAVE_ATTR_GET
/* Define to 1 if tests/libtests has calling conventions checking for the CPU
*/
#undef HAVE_CALLING_CONVENTIONS
/* Define to 1 if you have the `clock' function. */
#undef HAVE_CLOCK
/* Define to 1 if you have the `clock_gettime' function */
#undef HAVE_CLOCK_GETTIME
/* Define to 1 if you have the `cputime' function. */
#undef HAVE_CPUTIME
/* Define to 1 if you have the declaration of `fgetc', and to 0 if you don't.
*/
#undef HAVE_DECL_FGETC
/* Define to 1 if you have the declaration of `fscanf', and to 0 if you don't.
*/
#undef HAVE_DECL_FSCANF
/* Define to 1 if you have the declaration of `optarg', and to 0 if you don't.
*/
#undef HAVE_DECL_OPTARG
/* Define to 1 if you have the declaration of `sys_errlist', and to 0 if you
don't. */
#undef HAVE_DECL_SYS_ERRLIST
/* Define to 1 if you have the declaration of `sys_nerr', and to 0 if you
don't. */
#undef HAVE_DECL_SYS_NERR
/* Define to 1 if you have the declaration of `ungetc', and to 0 if you don't.
*/
#undef HAVE_DECL_UNGETC
/* Define to 1 if you have the declaration of `vfprintf', and to 0 if you
don't. */
#undef HAVE_DECL_VFPRINTF
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define one of the following to 1 for the format of a `double'.
If your format is not among these choices, or you don't know what it is,
then leave all undefined.
IEEE_LITTLE_SWAPPED means little endian, but with the two 4-byte halves
swapped, as used by ARM CPUs in little endian mode. */
#undef HAVE_DOUBLE_IEEE_BIG_ENDIAN
#undef HAVE_DOUBLE_IEEE_LITTLE_ENDIAN
#undef HAVE_DOUBLE_IEEE_LITTLE_SWAPPED
#undef HAVE_DOUBLE_VAX_D
#undef HAVE_DOUBLE_VAX_G
#undef HAVE_DOUBLE_CRAY_CFP
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the <float.h> header file. */
#undef HAVE_FLOAT_H
/* Define to 1 if you have the `getpagesize' function. */
#undef HAVE_GETPAGESIZE
/* Define to 1 if you have the `getrusage' function. */
#undef HAVE_GETRUSAGE
/* Define to 1 if you have the `getsysinfo' function. */
#undef HAVE_GETSYSINFO
/* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
/* Define to 1 if the compiler accepts gcc style __attribute__ ((visibility))
and __attribute__ ((alias)) */
#undef HAVE_HIDDEN_ALIAS
/* Define one of these to 1 for the host CPU family.
If your CPU is not in any of these families, leave all undefined.
For an AMD64 chip, define "x86" in ABI=32, but not in ABI=64. */
#undef HAVE_HOST_CPU_FAMILY_alpha
#undef HAVE_HOST_CPU_FAMILY_m68k
#undef HAVE_HOST_CPU_FAMILY_power
#undef HAVE_HOST_CPU_FAMILY_powerpc
#undef HAVE_HOST_CPU_FAMILY_x86
#undef HAVE_HOST_CPU_FAMILY_x86_64
/* Define one of the following to 1 for the host CPU, as per the output of
./config.guess. If your CPU is not listed here, leave all undefined. */
#undef HAVE_HOST_CPU_alphaev67
#undef HAVE_HOST_CPU_alphaev68
#undef HAVE_HOST_CPU_alphaev7
#undef HAVE_HOST_CPU_m68020
#undef HAVE_HOST_CPU_m68030
#undef HAVE_HOST_CPU_m68040
#undef HAVE_HOST_CPU_m68060
#undef HAVE_HOST_CPU_m68360
#undef HAVE_HOST_CPU_powerpc604
#undef HAVE_HOST_CPU_powerpc604e
#undef HAVE_HOST_CPU_powerpc750
#undef HAVE_HOST_CPU_powerpc7400
#undef HAVE_HOST_CPU_supersparc
#undef HAVE_HOST_CPU_i386
#undef HAVE_HOST_CPU_i586
#undef HAVE_HOST_CPU_i686
#undef HAVE_HOST_CPU_pentium
#undef HAVE_HOST_CPU_pentiummmx
#undef HAVE_HOST_CPU_pentiumpro
#undef HAVE_HOST_CPU_pentium2
#undef HAVE_HOST_CPU_pentium3
#undef HAVE_HOST_CPU_pentium4
#undef HAVE_HOST_CPU_core2
#undef HAVE_HOST_CPU_nehalem
#undef HAVE_HOST_CPU_westmere
#undef HAVE_HOST_CPU_sandybridge
#undef HAVE_HOST_CPU_ivybridge
#undef HAVE_HOST_CPU_haswell
#undef HAVE_HOST_CPU_broadwell
#undef HAVE_HOST_CPU_skylake
#undef HAVE_HOST_CPU_silvermont
#undef HAVE_HOST_CPU_goldmont
#undef HAVE_HOST_CPU_tremont
#undef HAVE_HOST_CPU_k8
#undef HAVE_HOST_CPU_k10
#undef HAVE_HOST_CPU_bulldozer
#undef HAVE_HOST_CPU_piledriver
#undef HAVE_HOST_CPU_steamroller
#undef HAVE_HOST_CPU_excavator
#undef HAVE_HOST_CPU_zen
#undef HAVE_HOST_CPU_bobcat
#undef HAVE_HOST_CPU_jaguar
#undef HAVE_HOST_CPU_s390_z900
#undef HAVE_HOST_CPU_s390_z990
#undef HAVE_HOST_CPU_s390_z9
#undef HAVE_HOST_CPU_s390_z10
#undef HAVE_HOST_CPU_s390_z196
#undef HAVE_HOST_CPU_s390_z13
#undef HAVE_HOST_CPU_s390_z14
#undef HAVE_HOST_CPU_s390_z15
/* Define to 1 iff we have a s390 with 64-bit registers. */
#undef HAVE_HOST_CPU_s390_zarch
/* Define to 1 if the system has the type `intmax_t'. */
#undef HAVE_INTMAX_T
/* Define to 1 if the system has the type `intptr_t'. */
#undef HAVE_INTPTR_T
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <invent.h> header file. */
#undef HAVE_INVENT_H
/* Define to 1 if you have the <langinfo.h> header file. */
#undef HAVE_LANGINFO_H
/* Define one of these to 1 for the endianness of `mp_limb_t'.
If the endianness is not a simple big or little, or you don't know what
it is, then leave both undefined. */
#undef HAVE_LIMB_BIG_ENDIAN
#undef HAVE_LIMB_LITTLE_ENDIAN
/* Define to 1 if you have the `localeconv' function. */
#undef HAVE_LOCALECONV
/* Define to 1 if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define to 1 if the system has the type `long double'. */
#undef HAVE_LONG_DOUBLE
/* Define to 1 if the system has the type `long long'. */
#undef HAVE_LONG_LONG
/* Define to 1 if you have the <machine/hal_sysinfo.h> header file. */
#undef HAVE_MACHINE_HAL_SYSINFO_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET
/* Define to 1 if you have the `mmap' function. */
#undef HAVE_MMAP
/* Define to 1 if you have the `mprotect' function. */
#undef HAVE_MPROTECT
/* Define to 1 each of the following for which a native (ie. CPU specific)
implementation of the corresponding routine exists. */
#undef HAVE_NATIVE_mpn_add_n
#undef HAVE_NATIVE_mpn_add_n_sub_n
#undef HAVE_NATIVE_mpn_add_nc
#undef HAVE_NATIVE_mpn_addaddmul_1msb0
#undef HAVE_NATIVE_mpn_addlsh1_n
#undef HAVE_NATIVE_mpn_addlsh2_n
#undef HAVE_NATIVE_mpn_addlsh_n
#undef HAVE_NATIVE_mpn_addlsh1_nc
#undef HAVE_NATIVE_mpn_addlsh2_nc
#undef HAVE_NATIVE_mpn_addlsh_nc
#undef HAVE_NATIVE_mpn_addlsh1_n_ip1
#undef HAVE_NATIVE_mpn_addlsh2_n_ip1
#undef HAVE_NATIVE_mpn_addlsh_n_ip1
#undef HAVE_NATIVE_mpn_addlsh1_nc_ip1
#undef HAVE_NATIVE_mpn_addlsh2_nc_ip1
#undef HAVE_NATIVE_mpn_addlsh_nc_ip1
#undef HAVE_NATIVE_mpn_addlsh1_n_ip2
#undef HAVE_NATIVE_mpn_addlsh2_n_ip2
#undef HAVE_NATIVE_mpn_addlsh_n_ip2
#undef HAVE_NATIVE_mpn_addlsh1_nc_ip2
#undef HAVE_NATIVE_mpn_addlsh2_nc_ip2
#undef HAVE_NATIVE_mpn_addlsh_nc_ip2
#undef HAVE_NATIVE_mpn_addmul_1c
#undef HAVE_NATIVE_mpn_addmul_2
#undef HAVE_NATIVE_mpn_addmul_3
#undef HAVE_NATIVE_mpn_addmul_4
#undef HAVE_NATIVE_mpn_addmul_5
#undef HAVE_NATIVE_mpn_addmul_6
#undef HAVE_NATIVE_mpn_addmul_7
#undef HAVE_NATIVE_mpn_addmul_8
#undef HAVE_NATIVE_mpn_addmul_2s
#undef HAVE_NATIVE_mpn_and_n
#undef HAVE_NATIVE_mpn_andn_n
#undef HAVE_NATIVE_mpn_bdiv_dbm1c
#undef HAVE_NATIVE_mpn_bdiv_q_1
#undef HAVE_NATIVE_mpn_pi1_bdiv_q_1
#undef HAVE_NATIVE_mpn_cnd_add_n
#undef HAVE_NATIVE_mpn_cnd_sub_n
#undef HAVE_NATIVE_mpn_com
#undef HAVE_NATIVE_mpn_copyd
#undef HAVE_NATIVE_mpn_copyi
#undef HAVE_NATIVE_mpn_div_qr_1n_pi1
#undef HAVE_NATIVE_mpn_div_qr_2
#undef HAVE_NATIVE_mpn_divexact_1
#undef HAVE_NATIVE_mpn_divexact_by3c
#undef HAVE_NATIVE_mpn_divrem_1
#undef HAVE_NATIVE_mpn_divrem_1c
#undef HAVE_NATIVE_mpn_divrem_2
#undef HAVE_NATIVE_mpn_gcd_1
#undef HAVE_NATIVE_mpn_gcd_11
#undef HAVE_NATIVE_mpn_gcd_22
#undef HAVE_NATIVE_mpn_hamdist
#undef HAVE_NATIVE_mpn_invert_limb
#undef HAVE_NATIVE_mpn_ior_n
#undef HAVE_NATIVE_mpn_iorn_n
#undef HAVE_NATIVE_mpn_lshift
#undef HAVE_NATIVE_mpn_lshiftc
#undef HAVE_NATIVE_mpn_lshsub_n
#undef HAVE_NATIVE_mpn_mod_1
#undef HAVE_NATIVE_mpn_mod_1_1p
#undef HAVE_NATIVE_mpn_mod_1c
#undef HAVE_NATIVE_mpn_mod_1s_2p
#undef HAVE_NATIVE_mpn_mod_1s_4p
#undef HAVE_NATIVE_mpn_mod_34lsub1
#undef HAVE_NATIVE_mpn_modexact_1_odd
#undef HAVE_NATIVE_mpn_modexact_1c_odd
#undef HAVE_NATIVE_mpn_mul_1
#undef HAVE_NATIVE_mpn_mul_1c
#undef HAVE_NATIVE_mpn_mul_2
#undef HAVE_NATIVE_mpn_mul_3
#undef HAVE_NATIVE_mpn_mul_4
#undef HAVE_NATIVE_mpn_mul_5
#undef HAVE_NATIVE_mpn_mul_6
#undef HAVE_NATIVE_mpn_mul_basecase
#undef HAVE_NATIVE_mpn_mullo_basecase
#undef HAVE_NATIVE_mpn_nand_n
#undef HAVE_NATIVE_mpn_nior_n
#undef HAVE_NATIVE_mpn_popcount
#undef HAVE_NATIVE_mpn_preinv_divrem_1
#undef HAVE_NATIVE_mpn_preinv_mod_1
#undef HAVE_NATIVE_mpn_redc_1
#undef HAVE_NATIVE_mpn_redc_2
#undef HAVE_NATIVE_mpn_rsblsh1_n
#undef HAVE_NATIVE_mpn_rsblsh2_n
#undef HAVE_NATIVE_mpn_rsblsh_n
#undef HAVE_NATIVE_mpn_rsblsh1_nc
#undef HAVE_NATIVE_mpn_rsblsh2_nc
#undef HAVE_NATIVE_mpn_rsblsh_nc
#undef HAVE_NATIVE_mpn_rsh1add_n
#undef HAVE_NATIVE_mpn_rsh1add_nc
#undef HAVE_NATIVE_mpn_rsh1sub_n
#undef HAVE_NATIVE_mpn_rsh1sub_nc
#undef HAVE_NATIVE_mpn_rshift
#undef HAVE_NATIVE_mpn_sbpi1_bdiv_r
#undef HAVE_NATIVE_mpn_sqr_basecase
#undef HAVE_NATIVE_mpn_sqr_diagonal
#undef HAVE_NATIVE_mpn_sqr_diag_addlsh1
#undef HAVE_NATIVE_mpn_sub_n
#undef HAVE_NATIVE_mpn_sub_nc
#undef HAVE_NATIVE_mpn_sublsh1_n
#undef HAVE_NATIVE_mpn_sublsh2_n
#undef HAVE_NATIVE_mpn_sublsh_n
#undef HAVE_NATIVE_mpn_sublsh1_nc
#undef HAVE_NATIVE_mpn_sublsh2_nc
#undef HAVE_NATIVE_mpn_sublsh_nc
#undef HAVE_NATIVE_mpn_sublsh1_n_ip1
#undef HAVE_NATIVE_mpn_sublsh2_n_ip1
#undef HAVE_NATIVE_mpn_sublsh_n_ip1
#undef HAVE_NATIVE_mpn_sublsh1_nc_ip1
#undef HAVE_NATIVE_mpn_sublsh2_nc_ip1
#undef HAVE_NATIVE_mpn_sublsh_nc_ip1
#undef HAVE_NATIVE_mpn_submul_1c
#undef HAVE_NATIVE_mpn_tabselect
#undef HAVE_NATIVE_mpn_udiv_qrnnd
#undef HAVE_NATIVE_mpn_udiv_qrnnd_r
#undef HAVE_NATIVE_mpn_umul_ppmm
#undef HAVE_NATIVE_mpn_umul_ppmm_r
#undef HAVE_NATIVE_mpn_xor_n
#undef HAVE_NATIVE_mpn_xnor_n
/* Define to 1 if you have the `nl_langinfo' function. */
#undef HAVE_NL_LANGINFO
/* Define to 1 if you have the <nl_types.h> header file. */
#undef HAVE_NL_TYPES_H
/* Define to 1 if you have the `obstack_vprintf' function. */
#undef HAVE_OBSTACK_VPRINTF
/* Define to 1 if you have the `popen' function. */
#undef HAVE_POPEN
/* Define to 1 if you have the `processor_info' function. */
#undef HAVE_PROCESSOR_INFO
/* Define to 1 if <sys/pstat.h> `struct pst_processor' exists and contains
`psp_iticksperclktick'. */
#undef HAVE_PSP_ITICKSPERCLKTICK
/* Define to 1 if you have the `pstat_getprocessor' function. */
#undef HAVE_PSTAT_GETPROCESSOR
/* Define to 1 if the system has the type `ptrdiff_t'. */
#undef HAVE_PTRDIFF_T
/* Define to 1 if the system has the type `quad_t'. */
#undef HAVE_QUAD_T
/* Define to 1 if you have the `raise' function. */
#undef HAVE_RAISE
/* Define to 1 if you have the `read_real_time' function. */
#undef HAVE_READ_REAL_TIME
/* Define to 1 if you have the `sigaction' function. */
#undef HAVE_SIGACTION
/* Define to 1 if you have the `sigaltstack' function. */
#undef HAVE_SIGALTSTACK
/* Define to 1 if you have the `sigstack' function. */
#undef HAVE_SIGSTACK
/* Tune directory speed_cyclecounter, undef=none, 1=32bits, 2=64bits) */
#undef HAVE_SPEED_CYCLECOUNTER
/* Define to 1 if you have the <sstream> header file. */
#undef HAVE_SSTREAM
/* Define to 1 if the system has the type `stack_t'. */
#undef HAVE_STACK_T
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if the system has the type `std::locale'. */
#undef HAVE_STD__LOCALE
/* Define to 1 if you have the `strchr' function. */
#undef HAVE_STRCHR
/* Define to 1 if you have the `strerror' function. */
#undef HAVE_STRERROR
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strnlen' function. */
#undef HAVE_STRNLEN
/* Define to 1 if you have the `strtol' function. */
#undef HAVE_STRTOL
/* Define to 1 if you have the `strtoul' function. */
#undef HAVE_STRTOUL
/* Define to 1 if you have the `sysconf' function. */
#undef HAVE_SYSCONF
/* Define to 1 if you have the `sysctl' function. */
#undef HAVE_SYSCTL
/* Define to 1 if you have the `sysctlbyname' function. */
#undef HAVE_SYSCTLBYNAME
/* Define to 1 if you have the `syssgi' function. */
#undef HAVE_SYSSGI
/* Define to 1 if you have the <sys/attributes.h> header file. */
#undef HAVE_SYS_ATTRIBUTES_H
/* Define to 1 if you have the <sys/iograph.h> header file. */
#undef HAVE_SYS_IOGRAPH_H
/* Define to 1 if you have the <sys/mman.h> header file. */
#undef HAVE_SYS_MMAN_H
/* Define to 1 if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H
/* Define to 1 if you have the <sys/processor.h> header file. */
#undef HAVE_SYS_PROCESSOR_H
/* Define to 1 if you have the <sys/pstat.h> header file. */
#undef HAVE_SYS_PSTAT_H
/* Define to 1 if you have the <sys/resource.h> header file. */
#undef HAVE_SYS_RESOURCE_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/sysctl.h> header file. */
#undef HAVE_SYS_SYSCTL_H
/* Define to 1 if you have the <sys/sysinfo.h> header file. */
#undef HAVE_SYS_SYSINFO_H
/* Define to 1 if you have the <sys/syssgi.h> header file. */
#undef HAVE_SYS_SYSSGI_H
/* Define to 1 if you have the <sys/systemcfg.h> header file. */
#undef HAVE_SYS_SYSTEMCFG_H
/* Define to 1 if you have the <sys/times.h> header file. */
#undef HAVE_SYS_TIMES_H
/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the `times' function. */
#undef HAVE_TIMES
/* Define to 1 if the system has the type `uint_least32_t'. */
#undef HAVE_UINT_LEAST32_T
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the `vsnprintf' function and it works properly. */
#undef HAVE_VSNPRINTF
/* Define to 1 for Windos/64 */
#undef HOST_DOS64
/* Assembler local label prefix */
#undef LSYM_PREFIX
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#undef LT_OBJDIR
/* Define to 1 to disable the use of inline assembly */
#undef NO_ASM
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define as the return type of signal handlers (`int' or `void'). */
#undef RETSIGTYPE
/* The size of `mp_limb_t', as computed by sizeof. */
#undef SIZEOF_MP_LIMB_T
/* The size of `unsigned', as computed by sizeof. */
#undef SIZEOF_UNSIGNED
/* The size of `unsigned long', as computed by sizeof. */
#undef SIZEOF_UNSIGNED_LONG
/* The size of `unsigned short', as computed by sizeof. */
#undef SIZEOF_UNSIGNED_SHORT
/* The size of `void *', as computed by sizeof. */
#undef SIZEOF_VOID_P
/* Define to 1 if sscanf requires writable inputs */
#undef SSCANF_WRITABLE_INPUT
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Maximum size the tune program can test for SQR_TOOM2_THRESHOLD */
#undef TUNE_SQR_TOOM2_MAX
/* Version number of package */
#undef VERSION
/* Define to 1 to enable ASSERT checking, per --enable-assert */
#undef WANT_ASSERT
/* Define to 1 to enable GMP_CPU_TYPE faking cpuid, per --enable-fake-cpuid */
#undef WANT_FAKE_CPUID
/* Define to 1 when building a fat binary. */
#undef WANT_FAT_BINARY
/* Define to 1 to enable FFTs for multiplication, per --enable-fft */
#undef WANT_FFT
/* Define to 1 to enable old mpn_mul_fft_full for multiplication, per
--enable-old-fft-full */
#undef WANT_OLD_FFT_FULL
/* Define to 1 if --enable-profiling=gprof */
#undef WANT_PROFILING_GPROF
/* Define to 1 if --enable-profiling=instrument */
#undef WANT_PROFILING_INSTRUMENT
/* Define to 1 if --enable-profiling=prof */
#undef WANT_PROFILING_PROF
/* Define one of these to 1 for the desired temporary memory allocation
method, per --enable-alloca. */
#undef WANT_TMP_ALLOCA
#undef WANT_TMP_REENTRANT
#undef WANT_TMP_NOTREENTRANT
#undef WANT_TMP_DEBUG
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
# undef WORDS_BIGENDIAN
# endif
#endif
/* Define to 1 if the assembler understands the mulx instruction */
#undef X86_ASM_MULX
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
`char[]'. */
#undef YYTEXT_POINTER
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#undef inline
#endif
/* Define to the equivalent of the C99 'restrict' keyword, or to
nothing if this is not supported. Do not define if restrict is
supported directly. */
#undef restrict
/* Work around a bug in Sun C++: it does not support _Restrict or
__restrict__, even though the corresponding Sun C compiler ends up with
"#define restrict _Restrict" or "#define restrict __restrict__" in the
previous line. Perhaps some future version of Sun C++ will work with
restrict; if so, hopefully it defines __RESTRICT like Sun C does. */
#if defined __SUNPRO_CC && !defined __RESTRICT
# define _Restrict
# define __restrict__
#endif
/* Define to empty if the keyword `volatile' does not work. Warning: valid
code using `volatile' can become incorrect without. Disable with care. */
#undef volatile

165
blender-5.2.0/extern/gmp-source/config.sub vendored Executable file
View File

@@ -0,0 +1,165 @@
#! /bin/sh
#
# GMP config.sub wrapper.
# Copyright 2000-2003, 2006, 2009-2016 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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
# Usage: config.sub CPU-VENDOR-OS
# config.sub ALIAS
#
# Validate and canonicalize the given configuration name, with special
# handling for GMP extra CPU names.
#
# When the CPU isn't special the whole name is simply passed straight
# through to configfsf.sub.
#
# When the CPU is a GMP extra, configfsf.sub is run on a similar CPU that it
# will recognise. For example "athlon-pc-freebsd3.5" is validated using
# "i386-pc-freebsd3.5".
#
# Any canonicalizations made by configfsf.sub are preserved. For example
# given "athlon-linux", configfsf.sub is called with "i386-linux" and will
# give back "i386-pc-linux-gnu". "athlon" is then reinstated, so we print
# "athlon-pc-linux-gnu".
# Expect to find configfsf.sub in the same directory as this config.sub
configfsf_sub="`echo \"$0\" | sed 's/config.sub$/configfsf.sub/'`"
if test "$configfsf_sub" = "$0"; then
echo "Cannot derive configfsf.sub from $0" 1>&2
exit 1
fi
if test -f "$configfsf_sub"; then
:
else
echo "$configfsf_sub not found" 1>&2
exit 1
fi
# Always run configfsf.sub with $SHELL, like autoconf does for config.sub
SHELL=${CONFIG_SHELL-/bin/sh}
# Identify ourselves on --version, --help, etc
case "$1" in
"" | -*)
echo "(GNU MP wrapped config.sub)" 1>&2
$SHELL $configfsf_sub "$@"
exit
;;
esac
given_full="$1"
given_cpu=`echo "$given_full" | sed 's/-.*$//'`
given_rest=`echo "$given_full" | sed 's/^[^-]*//'`
# Aliases for GMP extras
case "$given_cpu" in
# configfsf.sub turns p5 into i586, instead use our exact cpu type
p5 | p54) given_cpu=pentium ;;
p55) given_cpu=pentiummmx ;;
# configfsf.sub turns p6, pentiumii and pentiumiii into i686, instead use
# our exact cpu types
p6) given_cpu=pentiumpro ;;
pentiumii) given_cpu=pentium2 ;;
pentiumiii) given_cpu=pentium3 ;;
esac
given_full="$given_cpu$given_rest"
# GMP extras and what to use for the config.sub test
case "$given_cpu" in
itanium | itanium2)
test_cpu=ia64 ;;
pentium | pentiummmx | pentiumpro | pentium[234m] | k[567] | k6[23] | geode | athlon | viac3*)
test_cpu=i386 ;;
athlon64 | atom | silvermont | goldmont | tremont | core2 | corei* | opteron | k[89] | k10 | bobcat | jaguar* | bulldozer* | piledriver* | steamroller* | excavator* | zen* | nano | nehalem | westmere | sandybridge* | ivybridge* | haswell* | broadwell* | skylake* | kabylake* | icelake* | rocketlake* | tigerlake* | alderlake* | raptorlake* | knightslanding)
test_cpu=x86_64 ;;
power[2-9] | power1[0-9] | power2sc)
test_cpu=power ;;
powerpc401 | powerpc403 | powerpc405 | \
powerpc505 | \
powerpc601 | powerpc602 | \
powerpc603 | powerpc603e | \
powerpc604 | powerpc604e | \
powerpc620 | powerpc630 | powerpc970 | \
powerpc740 | powerpc74[0-9][0-9] | powerpc750 | \
powerpc801 | powerpc821 | powerpc823 | powerpc860 | \
powerpc64)
test_cpu=powerpc ;;
sparcv8 | supersparc | microsparc | \
ultrasparc | ultrasparc2 | ultrasparc2i | ultrasparc3 | ultrasparct[12345])
test_cpu=sparc ;;
sh2)
test_cpu=sh ;;
z900 | z990 | z9 | z1[0-6] | z196)
test_cpu=s390x;;
z900esa | z990esa | z9esa | z1[0-6]esa | z196esa)
test_cpu=s390;;
armsa1 | armxscale | arm9tdmi | arm9te | \
arm10* | arm11mpcore | armsa1 | arm1136 | arm1156 | arm1176 | \
armcortex[arm][0-9] | armcortex[arm][0-9][0-9] | \
arm*neon | armxgene1 | armexynosm1 | armthunderx | applem[1-9])
test_cpu="arm";;
*)
# Don't need or want to change the given name, just run configfsf.sub
$SHELL $configfsf_sub "$given_full"
if test $? = 0; then
exit 0
else
echo "(GNU MP wrapped config.sub, testing \"$given_full\")"
exit 1
fi
esac
test_full="$test_cpu$given_rest"
canonical_full=`$SHELL $configfsf_sub "$test_full"`
if test $? = 0; then
:
else
echo "(GNU MP wrapped config.sub, testing \"$given_full\" as \"$test_full\")"
exit 1
fi
canonical_rest=`echo "$canonical_full" | sed 's/^[^-]*//'`
echo "$given_cpu$canonical_rest"
exit 0
# Local variables:
# fill-column: 76
# End:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

30583
blender-5.2.0/extern/gmp-source/configure vendored Executable file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,40 @@
## Process this file with automake to generate Makefile.in
# Copyright 2001-2003, 2012 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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
AM_CPPFLAGS = -D__GMP_WITHIN_GMPXX -I$(top_srcdir)
if WANT_CXX
noinst_LTLIBRARIES = libcxx.la
endif
libcxx_la_SOURCES = \
isfuns.cc ismpf.cc ismpq.cc ismpz.cc ismpznw.cc limits.cc \
osdoprnti.cc osfuns.cc osmpf.cc osmpq.cc osmpz.cc

View File

@@ -0,0 +1,643 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
# Copyright 2001-2003, 2012 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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = cxx
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libcxx_la_LIBADD =
am_libcxx_la_OBJECTS = isfuns.lo ismpf.lo ismpq.lo ismpz.lo ismpznw.lo \
limits.lo osdoprnti.lo osfuns.lo osmpf.lo osmpq.lo osmpz.lo
libcxx_la_OBJECTS = $(am_libcxx_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
@WANT_CXX_TRUE@am_libcxx_la_rpath =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp =
am__depfiles_maybe =
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
AM_V_CXX = $(am__v_CXX_@AM_V@)
am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
am__v_CXX_0 = @echo " CXX " $@;
am__v_CXX_1 =
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
am__v_CXXLD_0 = @echo " CXXLD " $@;
am__v_CXXLD_1 =
SOURCES = $(libcxx_la_SOURCES)
DIST_SOURCES = $(libcxx_la_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ABI = @ABI@
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AS = @AS@
ASMFLAGS = @ASMFLAGS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CALLING_CONVENTIONS_OBJS = @CALLING_CONVENTIONS_OBJS@
CC = @CC@
CCAS = @CCAS@
CC_FOR_BUILD = @CC_FOR_BUILD@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPP_FOR_BUILD = @CPP_FOR_BUILD@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFN_LONG_LONG_LIMB = @DEFN_LONG_LONG_LIMB@
DEFS = @DEFS@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@
FGREP = @FGREP@
GMP_LDFLAGS = @GMP_LDFLAGS@
GMP_LIMB_BITS = @GMP_LIMB_BITS@
GMP_NAIL_BITS = @GMP_NAIL_BITS@
GREP = @GREP@
HAVE_CLOCK_01 = @HAVE_CLOCK_01@
HAVE_CPUTIME_01 = @HAVE_CPUTIME_01@
HAVE_GETRUSAGE_01 = @HAVE_GETRUSAGE_01@
HAVE_GETTIMEOFDAY_01 = @HAVE_GETTIMEOFDAY_01@
HAVE_HOST_CPU_FAMILY_power = @HAVE_HOST_CPU_FAMILY_power@
HAVE_HOST_CPU_FAMILY_powerpc = @HAVE_HOST_CPU_FAMILY_powerpc@
HAVE_SIGACTION_01 = @HAVE_SIGACTION_01@
HAVE_SIGALTSTACK_01 = @HAVE_SIGALTSTACK_01@
HAVE_SIGSTACK_01 = @HAVE_SIGSTACK_01@
HAVE_STACK_T_01 = @HAVE_STACK_T_01@
HAVE_SYS_RESOURCE_H_01 = @HAVE_SYS_RESOURCE_H_01@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LIBCURSES = @LIBCURSES@
LIBGMPXX_LDFLAGS = @LIBGMPXX_LDFLAGS@
LIBGMP_DLL = @LIBGMP_DLL@
LIBGMP_LDFLAGS = @LIBGMP_LDFLAGS@
LIBM = @LIBM@
LIBM_FOR_BUILD = @LIBM_FOR_BUILD@
LIBOBJS = @LIBOBJS@
LIBREADLINE = @LIBREADLINE@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
M4 = @M4@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SPEED_CYCLECOUNTER_OBJ = @SPEED_CYCLECOUNTER_OBJ@
STRIP = @STRIP@
TAL_OBJECT = @TAL_OBJECT@
TUNE_LIBS = @TUNE_LIBS@
TUNE_SQR_OBJ = @TUNE_SQR_OBJ@
U_FOR_BUILD = @U_FOR_BUILD@
VERSION = @VERSION@
WITH_READLINE_01 = @WITH_READLINE_01@
YACC = @YACC@
YFLAGS = @YFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__leading_dot = @am__leading_dot@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
gmp_srclinks = @gmp_srclinks@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
mpn_objects = @mpn_objects@
mpn_objs_in_libgmp = @mpn_objs_in_libgmp@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CPPFLAGS = -D__GMP_WITHIN_GMPXX -I$(top_srcdir)
@WANT_CXX_TRUE@noinst_LTLIBRARIES = libcxx.la
libcxx_la_SOURCES = \
isfuns.cc ismpf.cc ismpq.cc ismpz.cc ismpznw.cc limits.cc \
osdoprnti.cc osfuns.cc osmpf.cc osmpq.cc osmpz.cc
all: all-am
.SUFFIXES:
.SUFFIXES: .cc .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps cxx/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu --ignore-deps cxx/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
clean-noinstLTLIBRARIES:
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
@list='$(noinst_LTLIBRARIES)'; \
locs=`for p in $$list; do echo $$p; done | \
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
sort -u`; \
test -z "$$locs" || { \
echo rm -f $${locs}; \
rm -f $${locs}; \
}
libcxx.la: $(libcxx_la_OBJECTS) $(libcxx_la_DEPENDENCIES) $(EXTRA_libcxx_la_DEPENDENCIES)
$(AM_V_CXXLD)$(CXXLINK) $(am_libcxx_la_rpath) $(libcxx_la_OBJECTS) $(libcxx_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
.cc.o:
$(AM_V_CXX)$(CXXCOMPILE) -c -o $@ $<
.cc.obj:
$(AM_V_CXX)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cc.lo:
$(AM_V_CXX)$(LTCXXCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES)
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
ctags-am distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@@ -0,0 +1,33 @@
/* Dummy file to make automake treat libgmpxx.la as C++.
Copyright 2002 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
/* some compilers reputedly dislike completely empty files */
typedef int foo;

View File

@@ -0,0 +1,115 @@
/* Auxiliary functions for C++-style input of GMP types.
Copyright 2001 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <cctype>
#include <iostream>
#include <string>
#include "gmp-impl.h"
using namespace std;
int
__gmp_istream_set_base (istream &i, char &c, bool &zero, bool &showbase)
{
int base;
zero = showbase = false;
switch (i.flags() & ios::basefield)
{
case ios::dec:
base = 10;
break;
case ios::hex:
base = 16;
break;
case ios::oct:
base = 8;
break;
default:
showbase = true; // look for initial "0" or "0x" or "0X"
if (c == '0')
{
if (! i.get(c))
c = 0; // reset or we might loop indefinitely
if (c == 'x' || c == 'X')
{
base = 16;
i.get(c);
}
else
{
base = 8;
zero = true; // if no other digit is read, the "0" counts
}
}
else
base = 10;
break;
}
return base;
}
void
__gmp_istream_set_digits (string &s, istream &i, char &c, bool &ok, int base)
{
switch (base)
{
case 10:
while (isdigit(c))
{
ok = true; // at least a valid digit was read
s += c;
if (! i.get(c))
break;
}
break;
case 8:
while (isdigit(c) && c != '8' && c != '9')
{
ok = true; // at least a valid digit was read
s += c;
if (! i.get(c))
break;
}
break;
case 16:
while (isxdigit(c))
{
ok = true; // at least a valid digit was read
s += c;
if (! i.get(c))
break;
}
break;
}
}

View File

@@ -0,0 +1,144 @@
/* operator>> -- C++-style input of mpf_t.
Copyright 2001, 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <cctype>
#include <iostream>
#include <string>
#include <clocale> // for localeconv
#include "gmp-impl.h"
using namespace std;
// For g++ libstdc++ parsing see num_get<chartype,initer>::_M_extract_float
// in include/bits/locale_facets.tcc.
//
// There are no plans to accept hex or octal floats, not unless the standard
// C++ library does so. Although such formats might be of use, it's
// considered more important to be compatible with what the normal
// operator>> does on "double"s etc.
istream &
operator>> (istream &i, mpf_ptr f)
{
int base;
char c = 0;
string s;
bool ok = false;
// C decimal point, as expected by mpf_set_str
const char *lconv_point = GMP_DECIMAL_POINT;
// C++ decimal point
#if HAVE_STD__LOCALE
const locale& loc = i.getloc();
char point_char = use_facet< numpunct<char> >(loc).decimal_point();
#else
const char *point = lconv_point;
char point_char = *point;
#endif
i.get(c); // start reading
if (i.flags() & ios::skipws) // skip initial whitespace
{
// C++ isspace
#if HAVE_STD__LOCALE
const ctype<char>& ct = use_facet< ctype<char> >(loc);
#define cxx_isspace(c) (ct.is(ctype_base::space,(c)))
#else
#define cxx_isspace(c) isspace(c)
#endif
while (cxx_isspace(c) && i.get(c))
;
}
if (c == '-' || c == '+') // sign
{
if (c == '-')
s = "-";
i.get(c);
}
base = 10;
__gmp_istream_set_digits(s, i, c, ok, base); // read the number
// look for the C++ radix point, but put the C one in for mpf_set_str
if (c == point_char)
{
#if HAVE_STD__LOCALE
i.get(c);
#else // lconv point can be multi-char
for (;;)
{
i.get(c);
point++;
if (*point == '\0')
break;
if (c != *point)
goto fail;
}
#endif
s += lconv_point;
__gmp_istream_set_digits(s, i, c, ok, base); // read the mantissa
}
if (ok && (c == 'e' || c == 'E')) // exponent
{
s += c;
i.get(c);
ok = false; // exponent is mandatory
if (c == '-' || c == '+') // sign
{
s += c;
i.get(c);
}
__gmp_istream_set_digits(s, i, c, ok, base); // read the exponent
}
if (i.good()) // last character read was non-numeric
i.putback(c);
else if (i.eof() && ok) // stopped just before eof
i.clear(ios::eofbit);
if (ok)
ASSERT_NOCARRY (mpf_set_str(f, s.c_str(), base)); // extract the number
else
{
fail:
i.setstate(ios::failbit); // read failed
}
return i;
}

View File

@@ -0,0 +1,66 @@
/* operator>> -- C++-style input of mpq_t.
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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <cctype>
#include <iostream>
#include <string>
#include "gmp-impl.h"
using namespace std;
istream &
operator>> (istream &i, mpq_ptr q)
{
if (! (i >> mpq_numref(q)))
return i;
char c = 0;
i.get(c); // start reading
if (c == '/')
{
// skip slash, read denominator
i.get(c);
return __gmpz_operator_in_nowhite (i, mpq_denref(q), c);
}
else
{
// no denominator, set 1
q->_mp_den._mp_size = 1;
q->_mp_den._mp_d[0] = 1;
if (i.good())
i.putback(c);
else if (i.eof())
i.clear(ios::eofbit);
}
return i;
}

View File

@@ -0,0 +1,62 @@
/* operator>> -- C++-style input of mpz_t.
Copyright 2001, 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <cctype>
#include <iostream>
#include <string>
#include "gmp-impl.h"
using namespace std;
// For g++ libstdc++ parsing see num_get<chartype,initer>::_M_extract_int in
// include/bits/locale_facets.tcc.
istream &
operator>> (istream &i, mpz_ptr z)
{
char c = 0;
i.get(c); // start reading
if (i.flags() & ios::skipws) // skip initial whitespace
{
#if HAVE_STD__LOCALE
const ctype<char>& ct = use_facet< ctype<char> >(i.getloc());
#define cxx_isspace(c) (ct.is(ctype_base::space,(c)))
#else
#define cxx_isspace(c) isspace(c)
#endif
while (cxx_isspace(c) && i.get(c))
;
}
return __gmpz_operator_in_nowhite (i, z, c);
}

View File

@@ -0,0 +1,72 @@
/* __gmpz_operator_in_nowhite -- C++-style input of mpz_t, no whitespace skip.
Copyright 2001, 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <cctype>
#include <iostream>
#include <string>
#include "gmp-impl.h"
using namespace std;
// For g++ libstdc++ parsing see num_get<chartype,initer>::_M_extract_int in
// include/bits/locale_facets.tcc.
istream &
__gmpz_operator_in_nowhite (istream &i, mpz_ptr z, char c)
{
int base;
string s;
bool ok = false, zero, showbase;
if (c == '-' || c == '+') // sign
{
if (c == '-') // mpz_set_str doesn't accept '+'
s = "-";
i.get(c);
}
base = __gmp_istream_set_base(i, c, zero, showbase); // select the base
__gmp_istream_set_digits(s, i, c, ok, base); // read the number
if (i.good()) // last character read was non-numeric
i.putback(c);
else if (i.eof() && (ok || zero)) // stopped just before eof
i.clear(ios::eofbit);
if (ok)
ASSERT_NOCARRY (mpz_set_str (z, s.c_str(), base)); // extract the number
else if (zero)
mpz_set_ui(z, 0);
else
i.setstate(ios::failbit); // read failed
return i;
}

View File

@@ -0,0 +1,62 @@
/* instantiation of numeric_limits specializations.
Copyright 2012 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmpxx.h"
namespace std {
#define GMPXX_INSTANTIATE_LIMITS(T) \
const bool numeric_limits<T>::is_specialized; \
const int numeric_limits<T>::digits; \
const int numeric_limits<T>::digits10; \
const int numeric_limits<T>::max_digits10; \
const bool numeric_limits<T>::is_signed; \
const bool numeric_limits<T>::is_integer; \
const bool numeric_limits<T>::is_exact; \
const int numeric_limits<T>::radix; \
const int numeric_limits<T>::min_exponent; \
const int numeric_limits<T>::min_exponent10; \
const int numeric_limits<T>::max_exponent; \
const int numeric_limits<T>::max_exponent10; \
const bool numeric_limits<T>::has_infinity; \
const bool numeric_limits<T>::has_quiet_NaN; \
const bool numeric_limits<T>::has_signaling_NaN; \
const float_denorm_style numeric_limits<T>::has_denorm; \
const bool numeric_limits<T>::has_denorm_loss; \
const bool numeric_limits<T>::is_iec559; \
const bool numeric_limits<T>::is_bounded; \
const bool numeric_limits<T>::is_modulo; \
const bool numeric_limits<T>::traps; \
const bool numeric_limits<T>::tinyness_before; \
const float_round_style numeric_limits<T>::round_style
GMPXX_INSTANTIATE_LIMITS(mpz_class);
GMPXX_INSTANTIATE_LIMITS(mpq_class);
GMPXX_INSTANTIATE_LIMITS(mpf_class);
}

View File

@@ -0,0 +1,67 @@
/* __gmp_doprnt_integer_ios -- integer formatted output to an ostream.
THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST
CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
FUTURE GNU MP RELEASES.
Copyright 2001 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <iostream>
#include <stdarg.h> /* for va_list and hence doprnt_funs_t */
#include <string.h> /* for strlen */
#include "gmp-impl.h"
using namespace std;
/* The gmp_asprintf support routines never give an error, so
__gmp_doprnt_integer shouldn't fail and it's return can just be checked
with an ASSERT. */
ostream&
__gmp_doprnt_integer_ostream (ostream &o, struct doprnt_params_t *p,
char *s)
{
struct gmp_asprintf_t d;
char *result;
int ret;
/* don't show leading zeros the way printf does */
p->prec = -1;
GMP_ASPRINTF_T_INIT (d, &result);
ret = __gmp_doprnt_integer (&__gmp_asprintf_funs_noformat, &d, p, s);
ASSERT (ret != -1);
__gmp_asprintf_final (&d);
(*__gmp_free_func) (s, strlen(s)+1);
gmp_allocated_string t (result);
return o.write (t.str, t.len);
}

View File

@@ -0,0 +1,123 @@
/* Support for operator<< routines.
THE FUNCTIONS IN THIS FILE ARE FOR INTERNAL USE ONLY. THEY'RE ALMOST
CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
FUTURE GNU MP RELEASES.
Copyright 2001 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <iostream>
#include <stdarg.h> /* for va_list and hence doprnt_funs_t */
#include <string.h>
#include "gmp-impl.h"
using namespace std;
/* Don't need "format" for operator<< routines, just "memory" and "reps".
Omitting gmp_asprintf_format lets us avoid dragging vsnprintf into the
link. __gmp_asprintf_final will be called directly and doesn't need to
be in the struct. */
const struct doprnt_funs_t __gmp_asprintf_funs_noformat = {
NULL,
(doprnt_memory_t) __gmp_asprintf_memory,
(doprnt_reps_t) __gmp_asprintf_reps,
NULL
};
void
__gmp_doprnt_params_from_ios (struct doprnt_params_t *p, ios &o)
{
if ((o.flags() & ios::basefield) == ios::hex)
{
p->expfmt = "@%c%02d";
p->base = (o.flags() & ios::uppercase ? -16 : 16);
}
else
{
p->expfmt = (o.flags() & ios::uppercase ? "E%c%02d" : "e%c%02d");
if ((o.flags() & ios::basefield) == ios::oct)
p->base = 8;
else
p->base = 10;
}
/* "general" if none or more than one bit set */
if ((o.flags() & ios::floatfield) == ios::fixed)
p->conv = DOPRNT_CONV_FIXED;
else if ((o.flags() & ios::floatfield) == ios::scientific)
p->conv = DOPRNT_CONV_SCIENTIFIC;
else
p->conv = DOPRNT_CONV_GENERAL;
p->exptimes4 = 0;
p->fill = o.fill();
/* "right" if more than one bit set */
if ((o.flags() & ios::adjustfield) == ios::left)
p->justify = DOPRNT_JUSTIFY_LEFT;
else if ((o.flags() & ios::adjustfield) == ios::internal)
p->justify = DOPRNT_JUSTIFY_INTERNAL;
else
p->justify = DOPRNT_JUSTIFY_RIGHT;
/* ios::fixed allows prec==0, others take 0 as the default 6.
Don't allow negatives (they do bad things to __gmp_doprnt_float_cxx). */
p->prec = MAX (0, o.precision());
if (p->prec == 0 && p->conv != DOPRNT_CONV_FIXED)
p->prec = 6;
/* for hex showbase is always, for octal only non-zero */
if (o.flags() & ios::showbase)
p->showbase = ((o.flags() & ios::basefield) == ios::hex
? DOPRNT_SHOWBASE_YES : DOPRNT_SHOWBASE_NONZERO);
else
p->showbase = DOPRNT_SHOWBASE_NO;
p->showpoint = ((o.flags() & ios::showpoint) != 0);
/* in fixed and scientific always show trailing zeros, in general format
show them if showpoint is set (or so it seems) */
if ((o.flags() & ios::floatfield) == ios::fixed
|| (o.flags() & ios::floatfield) == ios::scientific)
p->showtrailing = 1;
else
p->showtrailing = p->showpoint;
p->sign = (o.flags() & ios::showpos ? '+' : '\0');
p->width = o.width();
/* reset on each output */
o.width (0);
}

View File

@@ -0,0 +1,70 @@
/* operator<< -- mpf formatted output to an ostream.
Copyright 2001, 2002 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <clocale>
#include <iostream>
#include <stdarg.h> /* for va_list and hence doprnt_funs_t */
#include <string.h>
#include "gmp-impl.h"
using namespace std;
/* The gmp_asprintf support routines never give an error, so
__gmp_doprnt_mpf shouldn't fail and it's return can just be checked with
an ASSERT. */
ostream&
operator<< (ostream &o, mpf_srcptr f)
{
struct doprnt_params_t param;
struct gmp_asprintf_t d;
char *result;
int ret;
__gmp_doprnt_params_from_ios (&param, o);
#if HAVE_STD__LOCALE
char point[2];
point[0] = use_facet< numpunct<char> >(o.getloc()).decimal_point();
point[1] = '\0';
#else
const char *point = GMP_DECIMAL_POINT;
#endif
GMP_ASPRINTF_T_INIT (d, &result);
ret = __gmp_doprnt_mpf (&__gmp_asprintf_funs_noformat, &d, &param, point, f);
ASSERT (ret != -1);
__gmp_asprintf_final (&d);
gmp_allocated_string t (result);
return o.write (t.str, t.len);
}

View File

@@ -0,0 +1,47 @@
/* operator<< -- mpq formatted output to an ostream.
Copyright 2001 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <iostream>
#include <stdarg.h> /* for va_list and hence doprnt_funs_t */
#include <string.h>
#include "gmp-impl.h"
using namespace std;
ostream&
operator<< (ostream &o, mpq_srcptr q)
{
struct doprnt_params_t param;
__gmp_doprnt_params_from_ios (&param, o);
return __gmp_doprnt_integer_ostream (o, &param,
mpq_get_str (NULL, param.base, q));
}

View File

@@ -0,0 +1,47 @@
/* operator<< -- mpz formatted output to an ostream.
Copyright 2001 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <iostream>
#include <stdarg.h> /* for va_list and hence doprnt_funs_t */
#include <string.h>
#include "gmp-impl.h"
using namespace std;
ostream&
operator<< (ostream &o, mpz_srcptr z)
{
struct doprnt_params_t param;
__gmp_doprnt_params_from_ios (&param, o);
return __gmp_doprnt_integer_ostream (o, &param,
mpz_get_str (NULL, param.base, z));
}

View File

@@ -0,0 +1,50 @@
## Process this file with automake to generate Makefile.in
# Copyright 2000-2002, 2012 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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
SUBDIRS = calc expr
EXTRA_DIST = perl primes.h
AM_CPPFLAGS = -I$(top_srcdir)
LDADD = $(top_builddir)/libgmp.la
qcn_LDADD = $(LDADD) $(LIBM)
primes_LDADD = $(LDADD) $(LIBM)
# None of these programs are built by default, but "make <whatever>" will
# build them once libgmp.la is built.
#
EXTRA_PROGRAMS = factorize isprime pexpr primes qcn
CLEANFILES = $(EXTRA_PROGRAMS)
allprogs: $(EXTRA_PROGRAMS)
cd calc; $(MAKE) $(AM_MAKEFLAGS) allprogs
cd expr; $(MAKE) $(AM_MAKEFLAGS) allprogs

View File

@@ -0,0 +1,785 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
# Copyright 2000-2002, 2012 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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
EXTRA_PROGRAMS = factorize$(EXEEXT) isprime$(EXEEXT) pexpr$(EXEEXT) \
primes$(EXEEXT) qcn$(EXEEXT)
subdir = demos
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES = pexpr-config.h
CONFIG_CLEAN_VPATH_FILES =
factorize_SOURCES = factorize.c
factorize_OBJECTS = factorize.$(OBJEXT)
factorize_LDADD = $(LDADD)
factorize_DEPENDENCIES = $(top_builddir)/libgmp.la
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
isprime_SOURCES = isprime.c
isprime_OBJECTS = isprime.$(OBJEXT)
isprime_LDADD = $(LDADD)
isprime_DEPENDENCIES = $(top_builddir)/libgmp.la
pexpr_SOURCES = pexpr.c
pexpr_OBJECTS = pexpr.$(OBJEXT)
pexpr_LDADD = $(LDADD)
pexpr_DEPENDENCIES = $(top_builddir)/libgmp.la
primes_SOURCES = primes.c
primes_OBJECTS = primes.$(OBJEXT)
am__DEPENDENCIES_1 =
primes_DEPENDENCIES = $(LDADD) $(am__DEPENDENCIES_1)
qcn_SOURCES = qcn.c
qcn_OBJECTS = qcn.$(OBJEXT)
qcn_DEPENDENCIES = $(LDADD) $(am__DEPENDENCIES_1)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp =
am__depfiles_maybe =
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = factorize.c isprime.c pexpr.c primes.c qcn.c
DIST_SOURCES = factorize.c isprime.c pexpr.c primes.c qcn.c
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-recursive dvi-recursive html-recursive info-recursive \
install-data-recursive install-dvi-recursive \
install-exec-recursive install-html-recursive \
install-info-recursive install-pdf-recursive \
install-ps-recursive install-recursive installcheck-recursive \
installdirs-recursive pdf-recursive ps-recursive \
tags-recursive uninstall-recursive
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
am__recursive_targets = \
$(RECURSIVE_TARGETS) \
$(RECURSIVE_CLEAN_TARGETS) \
$(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
distdir
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/pexpr-config-h.in
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
am__relativize = \
dir0=`pwd`; \
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
sed_rest='s,^[^/]*/*,,'; \
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
sed_butlast='s,/*[^/]*$$,,'; \
while test -n "$$dir1"; do \
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
if test "$$first" != "."; then \
if test "$$first" = ".."; then \
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
else \
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
if test "$$first2" = "$$first"; then \
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
else \
dir2="../$$dir2"; \
fi; \
dir0="$$dir0"/"$$first"; \
fi; \
fi; \
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
done; \
reldir="$$dir2"
ABI = @ABI@
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AS = @AS@
ASMFLAGS = @ASMFLAGS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CALLING_CONVENTIONS_OBJS = @CALLING_CONVENTIONS_OBJS@
CC = @CC@
CCAS = @CCAS@
CC_FOR_BUILD = @CC_FOR_BUILD@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPP_FOR_BUILD = @CPP_FOR_BUILD@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFN_LONG_LONG_LIMB = @DEFN_LONG_LONG_LIMB@
DEFS = @DEFS@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@
FGREP = @FGREP@
GMP_LDFLAGS = @GMP_LDFLAGS@
GMP_LIMB_BITS = @GMP_LIMB_BITS@
GMP_NAIL_BITS = @GMP_NAIL_BITS@
GREP = @GREP@
HAVE_CLOCK_01 = @HAVE_CLOCK_01@
HAVE_CPUTIME_01 = @HAVE_CPUTIME_01@
HAVE_GETRUSAGE_01 = @HAVE_GETRUSAGE_01@
HAVE_GETTIMEOFDAY_01 = @HAVE_GETTIMEOFDAY_01@
HAVE_HOST_CPU_FAMILY_power = @HAVE_HOST_CPU_FAMILY_power@
HAVE_HOST_CPU_FAMILY_powerpc = @HAVE_HOST_CPU_FAMILY_powerpc@
HAVE_SIGACTION_01 = @HAVE_SIGACTION_01@
HAVE_SIGALTSTACK_01 = @HAVE_SIGALTSTACK_01@
HAVE_SIGSTACK_01 = @HAVE_SIGSTACK_01@
HAVE_STACK_T_01 = @HAVE_STACK_T_01@
HAVE_SYS_RESOURCE_H_01 = @HAVE_SYS_RESOURCE_H_01@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LIBCURSES = @LIBCURSES@
LIBGMPXX_LDFLAGS = @LIBGMPXX_LDFLAGS@
LIBGMP_DLL = @LIBGMP_DLL@
LIBGMP_LDFLAGS = @LIBGMP_LDFLAGS@
LIBM = @LIBM@
LIBM_FOR_BUILD = @LIBM_FOR_BUILD@
LIBOBJS = @LIBOBJS@
LIBREADLINE = @LIBREADLINE@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
M4 = @M4@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SPEED_CYCLECOUNTER_OBJ = @SPEED_CYCLECOUNTER_OBJ@
STRIP = @STRIP@
TAL_OBJECT = @TAL_OBJECT@
TUNE_LIBS = @TUNE_LIBS@
TUNE_SQR_OBJ = @TUNE_SQR_OBJ@
U_FOR_BUILD = @U_FOR_BUILD@
VERSION = @VERSION@
WITH_READLINE_01 = @WITH_READLINE_01@
YACC = @YACC@
YFLAGS = @YFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__leading_dot = @am__leading_dot@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
gmp_srclinks = @gmp_srclinks@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
mpn_objects = @mpn_objects@
mpn_objs_in_libgmp = @mpn_objs_in_libgmp@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = calc expr
EXTRA_DIST = perl primes.h
AM_CPPFLAGS = -I$(top_srcdir)
LDADD = $(top_builddir)/libgmp.la
qcn_LDADD = $(LDADD) $(LIBM)
primes_LDADD = $(LDADD) $(LIBM)
CLEANFILES = $(EXTRA_PROGRAMS)
all: all-recursive
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps demos/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu --ignore-deps demos/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
pexpr-config.h: $(top_builddir)/config.status $(srcdir)/pexpr-config-h.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
factorize$(EXEEXT): $(factorize_OBJECTS) $(factorize_DEPENDENCIES) $(EXTRA_factorize_DEPENDENCIES)
@rm -f factorize$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(factorize_OBJECTS) $(factorize_LDADD) $(LIBS)
isprime$(EXEEXT): $(isprime_OBJECTS) $(isprime_DEPENDENCIES) $(EXTRA_isprime_DEPENDENCIES)
@rm -f isprime$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(isprime_OBJECTS) $(isprime_LDADD) $(LIBS)
pexpr$(EXEEXT): $(pexpr_OBJECTS) $(pexpr_DEPENDENCIES) $(EXTRA_pexpr_DEPENDENCIES)
@rm -f pexpr$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(pexpr_OBJECTS) $(pexpr_LDADD) $(LIBS)
primes$(EXEEXT): $(primes_OBJECTS) $(primes_DEPENDENCIES) $(EXTRA_primes_DEPENDENCIES)
@rm -f primes$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(primes_OBJECTS) $(primes_LDADD) $(LIBS)
qcn$(EXEEXT): $(qcn_OBJECTS) $(qcn_DEPENDENCIES) $(EXTRA_qcn_DEPENDENCIES)
@rm -f qcn$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(qcn_OBJECTS) $(qcn_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
.c.o:
$(AM_V_CC)$(COMPILE) -c -o $@ $<
.c.obj:
$(AM_V_CC)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
$(AM_V_CC)$(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
# This directory's subdirectories are mostly independent; you can cd
# into them and run 'make' without going through this Makefile.
# To change the values of 'make' variables: instead of editing Makefiles,
# (1) if the variable is set in 'config.status', edit 'config.status'
# (which will cause the Makefiles to be regenerated when you run 'make');
# (2) otherwise, pass the desired values on the 'make' command line.
$(am__recursive_targets):
@fail=; \
if $(am__make_keepgoing); then \
failcom='fail=yes'; \
else \
failcom='exit 1'; \
fi; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-recursive
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-recursive
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-recursive
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
$(am__make_dryrun) \
|| test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
$(am__relativize); \
new_distdir=$$reldir; \
dir1=$$subdir; dir2="$(top_distdir)"; \
$(am__relativize); \
new_top_distdir=$$reldir; \
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
($(am__cd) $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$new_top_distdir" \
distdir="$$new_distdir" \
am__remove_distdir=: \
am__skip_length_check=: \
am__skip_mode_fix=: \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-recursive
all-am: Makefile
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-recursive
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
html-am:
info: info-recursive
info-am:
install-data-am:
install-dvi: install-dvi-recursive
install-dvi-am:
install-exec-am:
install-html: install-html-recursive
install-html-am:
install-info: install-info-recursive
install-info-am:
install-man:
install-pdf: install-pdf-recursive
install-pdf-am:
install-ps: install-ps-recursive
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am:
.MAKE: $(am__recursive_targets) install-am install-strip
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
check-am clean clean-generic clean-libtool cscopelist-am ctags \
ctags-am distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am
.PRECIOUS: Makefile
allprogs: $(EXTRA_PROGRAMS)
cd calc; $(MAKE) $(AM_MAKEFLAGS) allprogs
cd expr; $(MAKE) $(AM_MAKEFLAGS) allprogs
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@@ -0,0 +1,47 @@
## Process this file with automake to generate Makefile.in
# Copyright 2000-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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
AM_CPPFLAGS = -I$(top_srcdir)
# $(LEXLIB) is not actually needed for flex (which means the distributed
# calclex.c), but it's included here for the benefit of anyone rebuilding
# with some other lex.
#
LDADD = $(top_builddir)/libgmp.la $(LIBREADLINE) $(LIBCURSES) $(LEXLIB)
EXTRA_PROGRAMS = calc
AM_YFLAGS = -d
calc_SOURCES = calc.y calclex.l calcread.c calc-common.h
BUILT_SOURCES = calc.h
CLEANFILES = $(EXTRA_PROGRAMS)
allprogs: $(EXTRA_PROGRAMS)

View File

@@ -0,0 +1,677 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
# Copyright 2000-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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
EXTRA_PROGRAMS = calc$(EXEEXT)
subdir = demos/calc
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES = calc-config.h
CONFIG_CLEAN_VPATH_FILES =
am_calc_OBJECTS = calc.$(OBJEXT) calclex.$(OBJEXT) calcread.$(OBJEXT)
calc_OBJECTS = $(am_calc_OBJECTS)
calc_LDADD = $(LDADD)
am__DEPENDENCIES_1 =
calc_DEPENDENCIES = $(top_builddir)/libgmp.la $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp =
am__depfiles_maybe =
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
@MAINTAINER_MODE_FALSE@am__skiplex = test -f $@ ||
LEXCOMPILE = $(LEX) $(AM_LFLAGS) $(LFLAGS)
LTLEXCOMPILE = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(LEX) $(AM_LFLAGS) $(LFLAGS)
AM_V_LEX = $(am__v_LEX_@AM_V@)
am__v_LEX_ = $(am__v_LEX_@AM_DEFAULT_V@)
am__v_LEX_0 = @echo " LEX " $@;
am__v_LEX_1 =
YLWRAP = $(top_srcdir)/ylwrap
@MAINTAINER_MODE_FALSE@am__skipyacc = test -f $@ ||
am__yacc_c2h = sed -e s/cc$$/hh/ -e s/cpp$$/hpp/ -e s/cxx$$/hxx/ \
-e s/c++$$/h++/ -e s/c$$/h/
YACCCOMPILE = $(YACC) $(AM_YFLAGS) $(YFLAGS)
LTYACCCOMPILE = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(YACC) $(AM_YFLAGS) $(YFLAGS)
AM_V_YACC = $(am__v_YACC_@AM_V@)
am__v_YACC_ = $(am__v_YACC_@AM_DEFAULT_V@)
am__v_YACC_0 = @echo " YACC " $@;
am__v_YACC_1 =
SOURCES = $(calc_SOURCES)
DIST_SOURCES = $(calc_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/calc-config-h.in \
$(top_srcdir)/ylwrap README calc.c calc.h calclex.c
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ABI = @ABI@
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AS = @AS@
ASMFLAGS = @ASMFLAGS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CALLING_CONVENTIONS_OBJS = @CALLING_CONVENTIONS_OBJS@
CC = @CC@
CCAS = @CCAS@
CC_FOR_BUILD = @CC_FOR_BUILD@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPP_FOR_BUILD = @CPP_FOR_BUILD@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFN_LONG_LONG_LIMB = @DEFN_LONG_LONG_LIMB@
DEFS = @DEFS@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@
FGREP = @FGREP@
GMP_LDFLAGS = @GMP_LDFLAGS@
GMP_LIMB_BITS = @GMP_LIMB_BITS@
GMP_NAIL_BITS = @GMP_NAIL_BITS@
GREP = @GREP@
HAVE_CLOCK_01 = @HAVE_CLOCK_01@
HAVE_CPUTIME_01 = @HAVE_CPUTIME_01@
HAVE_GETRUSAGE_01 = @HAVE_GETRUSAGE_01@
HAVE_GETTIMEOFDAY_01 = @HAVE_GETTIMEOFDAY_01@
HAVE_HOST_CPU_FAMILY_power = @HAVE_HOST_CPU_FAMILY_power@
HAVE_HOST_CPU_FAMILY_powerpc = @HAVE_HOST_CPU_FAMILY_powerpc@
HAVE_SIGACTION_01 = @HAVE_SIGACTION_01@
HAVE_SIGALTSTACK_01 = @HAVE_SIGALTSTACK_01@
HAVE_SIGSTACK_01 = @HAVE_SIGSTACK_01@
HAVE_STACK_T_01 = @HAVE_STACK_T_01@
HAVE_SYS_RESOURCE_H_01 = @HAVE_SYS_RESOURCE_H_01@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LIBCURSES = @LIBCURSES@
LIBGMPXX_LDFLAGS = @LIBGMPXX_LDFLAGS@
LIBGMP_DLL = @LIBGMP_DLL@
LIBGMP_LDFLAGS = @LIBGMP_LDFLAGS@
LIBM = @LIBM@
LIBM_FOR_BUILD = @LIBM_FOR_BUILD@
LIBOBJS = @LIBOBJS@
LIBREADLINE = @LIBREADLINE@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
M4 = @M4@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SPEED_CYCLECOUNTER_OBJ = @SPEED_CYCLECOUNTER_OBJ@
STRIP = @STRIP@
TAL_OBJECT = @TAL_OBJECT@
TUNE_LIBS = @TUNE_LIBS@
TUNE_SQR_OBJ = @TUNE_SQR_OBJ@
U_FOR_BUILD = @U_FOR_BUILD@
VERSION = @VERSION@
WITH_READLINE_01 = @WITH_READLINE_01@
YACC = @YACC@
YFLAGS = @YFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__leading_dot = @am__leading_dot@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
gmp_srclinks = @gmp_srclinks@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
mpn_objects = @mpn_objects@
mpn_objs_in_libgmp = @mpn_objs_in_libgmp@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CPPFLAGS = -I$(top_srcdir)
# $(LEXLIB) is not actually needed for flex (which means the distributed
# calclex.c), but it's included here for the benefit of anyone rebuilding
# with some other lex.
#
LDADD = $(top_builddir)/libgmp.la $(LIBREADLINE) $(LIBCURSES) $(LEXLIB)
AM_YFLAGS = -d
calc_SOURCES = calc.y calclex.l calcread.c calc-common.h
BUILT_SOURCES = calc.h
CLEANFILES = $(EXTRA_PROGRAMS)
all: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
.SUFFIXES: .c .l .lo .o .obj .y
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps demos/calc/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu --ignore-deps demos/calc/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
calc-config.h: $(top_builddir)/config.status $(srcdir)/calc-config-h.in
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
calc.h: calc.c
@if test ! -f $@; then rm -f calc.c; else :; fi
@if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) calc.c; else :; fi
calc$(EXEEXT): $(calc_OBJECTS) $(calc_DEPENDENCIES) $(EXTRA_calc_DEPENDENCIES)
@rm -f calc$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(calc_OBJECTS) $(calc_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
.c.o:
$(AM_V_CC)$(COMPILE) -c -o $@ $<
.c.obj:
$(AM_V_CC)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
$(AM_V_CC)$(LTCOMPILE) -c -o $@ $<
.l.c:
$(AM_V_LEX)$(am__skiplex) $(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@ -- $(LEXCOMPILE)
.y.c:
$(AM_V_YACC)$(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h `echo $@ | $(am__yacc_c2h)` y.output $*.output -- $(YACCCOMPILE)
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) check-am
all-am: Makefile
installdirs:
install: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
-rm -f calc.c
-rm -f calc.h
-rm -f calclex.c
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: all check install install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
clean-libtool cscopelist-am ctags ctags-am distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am
.PRECIOUS: Makefile
allprogs: $(EXTRA_PROGRAMS)
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@@ -0,0 +1,65 @@
Copyright 2001 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see https://www.gnu.org/licenses/.
DEMONSTRATION CALCULATOR PROGRAM
This is a simple program, meant only to show one way to use GMP with yacc
and lex to make a calculator. Usage and comments on the implementation can
be found in calc.y.
Within a GMP build tree, the generated Makefile can be used to build the
program,
make calc
(or on a DOS system, "make calc.exe").
Elsewhere, once GMP has been installed, the program can be compiled with for
instance
gcc calc.c calclex.c -lgmp -o calc
Or if GNU readline is used then
gcc calc.c calclex.c calcread.c -lgmp -lreadline -o calc
(again, on a DOS system "-o calc.exe").
Readline support can be enabled or disabled in calc-config.h. That file is
created by the GMP ./configure based on the --with-readline option. The
default is --with-readline=detect, which means to use readline if available.
"yes" can be used to force it to be used, or "no" to not use it.
The supplied calc.c was generated by GNU bison, but a standard yacc should
work too.
The supplied calclex.c was generated by GNU flex, but a standard lex should
work too. The readline support may or may not work with a standard lex (see
comments with input() in calcread.c). Note also that a standard lex will
require its library "-ll" on the compile command line. "./configure" sets
this up in the GMP build tree Makefile.
----------------
Local variables:
mode: text
fill-column: 76
End:

View File

@@ -0,0 +1,35 @@
/* Prototypes etc for calc program.
Copyright 2001 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see https://www.gnu.org/licenses/. */
#include <stddef.h> /* for size_t */
#ifndef NO_CALC_H
#include "calc.h"
#endif
#include "calc-config.h"
struct calc_keywords_t {
char *name;
int value;
};
extern int calc_option_readline;
extern int calc_more_input;
extern const struct calc_keywords_t calc_keywords[];
int calc_input (char *buf, size_t max_size);
void calc_init_readline (void);

View File

@@ -0,0 +1,21 @@
/* Templates for calc program configuration. -*- mode:c -*-
Copyright 2001 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see https://www.gnu.org/licenses/. */
/* Define if GNU readline should be used. */
#define WITH_READLINE @WITH_READLINE_01@

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,146 @@
/* A Bison parser, made by GNU Bison 3.8.2. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
especially those whose name start with YY_ or yy_. They are
private implementation details that can be changed or removed. */
#ifndef YY_YY_CALC_H_INCLUDED
# define YY_YY_CALC_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
#endif
/* Token kinds. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
YYEMPTY = -2,
YYEOF = 0, /* "end of file" */
YYerror = 256, /* error */
YYUNDEF = 257, /* "invalid token" */
EOS = 258, /* EOS */
BAD = 259, /* BAD */
HELP = 260, /* HELP */
HEX = 261, /* HEX */
DECIMAL = 262, /* DECIMAL */
QUIT = 263, /* QUIT */
ABS = 264, /* ABS */
BIN = 265, /* BIN */
FIB = 266, /* FIB */
GCD = 267, /* GCD */
KRON = 268, /* KRON */
LCM = 269, /* LCM */
LUCNUM = 270, /* LUCNUM */
NEXTPRIME = 271, /* NEXTPRIME */
POWM = 272, /* POWM */
ROOT = 273, /* ROOT */
SQRT = 274, /* SQRT */
NUMBER = 275, /* NUMBER */
VARIABLE = 276, /* VARIABLE */
LOR = 277, /* LOR */
LAND = 278, /* LAND */
EQ = 279, /* EQ */
NE = 280, /* NE */
LE = 281, /* LE */
GE = 282, /* GE */
LSHIFT = 283, /* LSHIFT */
RSHIFT = 284, /* RSHIFT */
UMINUS = 285 /* UMINUS */
};
typedef enum yytokentype yytoken_kind_t;
#endif
/* Token kinds. */
#define YYEMPTY -2
#define YYEOF 0
#define YYerror 256
#define YYUNDEF 257
#define EOS 258
#define BAD 259
#define HELP 260
#define HEX 261
#define DECIMAL 262
#define QUIT 263
#define ABS 264
#define BIN 265
#define FIB 266
#define GCD 267
#define KRON 268
#define LCM 269
#define LUCNUM 270
#define NEXTPRIME 271
#define POWM 272
#define ROOT 273
#define SQRT 274
#define NUMBER 275
#define VARIABLE 276
#define LOR 277
#define LAND 278
#define EQ 279
#define NE 280
#define LE 281
#define GE 282
#define LSHIFT 283
#define RSHIFT 284
#define UMINUS 285
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
#line 142 "../../../gmp/demos/calc/calc.y"
char *str;
int var;
#line 132 "calc.h"
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE yylval;
int yyparse (void);
#endif /* !YY_YY_CALC_H_INCLUDED */

View File

@@ -0,0 +1,318 @@
%{
/* A simple integer desk calculator using yacc and gmp.
Copyright 2000-2002 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see https://www.gnu.org/licenses/. */
/* This is a simple program, meant only to show one way to use GMP for this
sort of thing. There's few features, and error checking is minimal.
Standard input is read, calc_help() below shows the inputs accepted.
Expressions are evaluated as they're read. If user defined functions
were wanted it'd be necessary to build a parse tree like pexpr.c does, or
a list of operations for a stack based evaluator. That would also make
it possible to detect and optimize evaluations "mod m" like pexpr.c does.
A stack is used for intermediate values in the expression evaluation,
separate from the yacc parser stack. This is simple, makes error
recovery easy, minimizes the junk around mpz calls in the rules, and
saves initializing or clearing "mpz_t"s during a calculation. A
disadvantage though is that variables must be copied to the stack to be
worked on. A more sophisticated calculator or language system might be
able to avoid that when executing a compiled or semi-compiled form.
Avoiding repeated initializing and clearing of "mpz_t"s is important. In
this program the time spent parsing is obviously much greater than any
possible saving from this, but a proper calculator or language should
take some trouble over it. Don't be surprised if an init/clear takes 3
or more times as long as a 10 limb addition, depending on the system (see
the mpz_init_realloc_clear example in tune/README). */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gmp.h"
#define NO_CALC_H /* because it conflicts with normal calc.c stuff */
#include "calc-common.h"
#define numberof(x) (sizeof (x) / sizeof ((x)[0]))
void
calc_help (void)
{
printf ("Examples:\n");
printf (" 2+3*4 expressions are evaluated\n");
printf (" x=5^6 variables a to z can be set and used\n");
printf ("Operators:\n");
printf (" + - * arithmetic\n");
printf (" / %% division and remainder (rounding towards negative infinity)\n");
printf (" ^ exponentiation\n");
printf (" ! factorial\n");
printf (" << >> left and right shifts\n");
printf (" <= >= > \\ comparisons, giving 1 if true, 0 if false\n");
printf (" == != < /\n");
printf (" && || logical and/or, giving 1 if true, 0 if false\n");
printf ("Functions:\n");
printf (" abs(n) absolute value\n");
printf (" bin(n,m) binomial coefficient\n");
printf (" fib(n) fibonacci number\n");
printf (" gcd(a,b,..) greatest common divisor\n");
printf (" kron(a,b) kronecker symbol\n");
printf (" lcm(a,b,..) least common multiple\n");
printf (" lucnum(n) lucas number\n");
printf (" nextprime(n) next prime after n\n");
printf (" powm(b,e,m) modulo powering, b^e%%m\n");
printf (" root(n,r) r-th root\n");
printf (" sqrt(n) square root\n");
printf ("Other:\n");
printf (" hex \\ set hex or decimal for input and output\n");
printf (" decimal / (\"0x\" can be used for hex too)\n");
printf (" quit exit program (EOF works too)\n");
printf (" ; statements are separated with a ; or newline\n");
printf (" \\ continue expressions with \\ before newline\n");
printf (" # xxx comments are # though to newline\n");
printf ("Hex numbers must be entered in upper case, to distinguish them from the\n");
printf ("variables a to f (like in bc).\n");
}
int ibase = 0;
int obase = 10;
/* The stack is a fixed size, which means there's a limit on the nesting
allowed in expressions. A more sophisticated program could let it grow
dynamically. */
mpz_t stack[100];
mpz_ptr sp = stack[0];
#define CHECK_OVERFLOW() \
if (sp >= stack[numberof(stack)]) /* FIXME */ \
{ \
fprintf (stderr, \
"Value stack overflow, too much nesting in expression\n"); \
YYERROR; \
}
#define CHECK_EMPTY() \
if (sp != stack[0]) \
{ \
fprintf (stderr, "Oops, expected the value stack to be empty\n"); \
sp = stack[0]; \
}
mpz_t variable[26];
#define CHECK_VARIABLE(var) \
if ((var) < 0 || (var) >= numberof (variable)) \
{ \
fprintf (stderr, "Oops, bad variable somehow: %d\n", var); \
YYERROR; \
}
#define CHECK_UI(name,z) \
if (! mpz_fits_ulong_p (z)) \
{ \
fprintf (stderr, "%s too big\n", name); \
YYERROR; \
}
%}
%union {
char *str;
int var;
}
%token EOS BAD
%token HELP HEX DECIMAL QUIT
%token ABS BIN FIB GCD KRON LCM LUCNUM NEXTPRIME POWM ROOT SQRT
%token <str> NUMBER
%token <var> VARIABLE
/* operators, increasing precedence */
%left LOR
%left LAND
%nonassoc '<' '>' EQ NE LE GE
%left LSHIFT RSHIFT
%left '+' '-'
%left '*' '/' '%'
%nonassoc UMINUS
%right '^'
%nonassoc '!'
%%
top:
statement
| statements statement;
statements:
statement EOS
| statements statement EOS
| error EOS { sp = stack[0]; yyerrok; };
statement:
/* empty */
| e {
mpz_out_str (stdout, obase, sp); putchar ('\n');
sp--;
CHECK_EMPTY ();
}
| VARIABLE '=' e {
CHECK_VARIABLE ($1);
mpz_swap (variable[$1], sp);
sp--;
CHECK_EMPTY ();
}
| HELP { calc_help (); }
| HEX { ibase = 16; obase = -16; }
| DECIMAL { ibase = 0; obase = 10; }
| QUIT { exit (0); };
/* "e" leaves it's value on the top of the mpz stack. A rule like "e '+' e"
will have done a reduction for the first "e" first and the second "e"
second, so the code receives the values in that order on the stack. */
e:
'(' e ')' /* value on stack */
| e '+' e { sp--; mpz_add (sp, sp, sp+1); }
| e '-' e { sp--; mpz_sub (sp, sp, sp+1); }
| e '*' e { sp--; mpz_mul (sp, sp, sp+1); }
| e '/' e { sp--; mpz_fdiv_q (sp, sp, sp+1); }
| e '%' e { sp--; mpz_fdiv_r (sp, sp, sp+1); }
| e '^' e { CHECK_UI ("Exponent", sp);
sp--; mpz_pow_ui (sp, sp, mpz_get_ui (sp+1)); }
| e LSHIFT e { CHECK_UI ("Shift count", sp);
sp--; mpz_mul_2exp (sp, sp, mpz_get_ui (sp+1)); }
| e RSHIFT e { CHECK_UI ("Shift count", sp);
sp--; mpz_fdiv_q_2exp (sp, sp, mpz_get_ui (sp+1)); }
| e '!' { CHECK_UI ("Factorial", sp);
mpz_fac_ui (sp, mpz_get_ui (sp)); }
| '-' e %prec UMINUS { mpz_neg (sp, sp); }
| e '<' e { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) < 0); }
| e LE e { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) <= 0); }
| e EQ e { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) == 0); }
| e NE e { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) != 0); }
| e GE e { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) >= 0); }
| e '>' e { sp--; mpz_set_ui (sp, mpz_cmp (sp, sp+1) > 0); }
| e LAND e { sp--; mpz_set_ui (sp, mpz_sgn (sp) && mpz_sgn (sp+1)); }
| e LOR e { sp--; mpz_set_ui (sp, mpz_sgn (sp) || mpz_sgn (sp+1)); }
| ABS '(' e ')' { mpz_abs (sp, sp); }
| BIN '(' e ',' e ')' { sp--; CHECK_UI ("Binomial base", sp+1);
mpz_bin_ui (sp, sp, mpz_get_ui (sp+1)); }
| FIB '(' e ')' { CHECK_UI ("Fibonacci", sp);
mpz_fib_ui (sp, mpz_get_ui (sp)); }
| GCD '(' gcdlist ')' /* value on stack */
| KRON '(' e ',' e ')' { sp--; mpz_set_si (sp,
mpz_kronecker (sp, sp+1)); }
| LCM '(' lcmlist ')' /* value on stack */
| LUCNUM '(' e ')' { CHECK_UI ("Lucas number", sp);
mpz_lucnum_ui (sp, mpz_get_ui (sp)); }
| NEXTPRIME '(' e ')' { mpz_nextprime (sp, sp); }
| POWM '(' e ',' e ',' e ')' { sp -= 2; mpz_powm (sp, sp, sp+1, sp+2); }
| ROOT '(' e ',' e ')' { sp--; CHECK_UI ("Nth-root", sp+1);
mpz_root (sp, sp, mpz_get_ui (sp+1)); }
| SQRT '(' e ')' { mpz_sqrt (sp, sp); }
| VARIABLE {
sp++;
CHECK_OVERFLOW ();
CHECK_VARIABLE ($1);
mpz_set (sp, variable[$1]);
}
| NUMBER {
sp++;
CHECK_OVERFLOW ();
if (mpz_set_str (sp, $1, ibase) != 0)
{
fprintf (stderr, "Invalid number: %s\n", $1);
YYERROR;
}
};
gcdlist:
e /* value on stack */
| gcdlist ',' e { sp--; mpz_gcd (sp, sp, sp+1); };
lcmlist:
e /* value on stack */
| lcmlist ',' e { sp--; mpz_lcm (sp, sp, sp+1); };
%%
yyerror (char *s)
{
fprintf (stderr, "%s\n", s);
}
int calc_option_readline = -1;
int
main (int argc, char *argv[])
{
int i;
for (i = 1; i < argc; i++)
{
if (strcmp (argv[i], "--readline") == 0)
calc_option_readline = 1;
else if (strcmp (argv[i], "--noreadline") == 0)
calc_option_readline = 0;
else if (strcmp (argv[i], "--help") == 0)
{
printf ("Usage: calc [--option]...\n");
printf (" --readline use readline\n");
printf (" --noreadline don't use readline\n");
printf (" --help this message\n");
printf ("Readline is only available when compiled in,\n");
printf ("and in that case it's the default on a tty.\n");
exit (0);
}
else
{
fprintf (stderr, "Unrecognised option: %s\n", argv[i]);
exit (1);
}
}
#if WITH_READLINE
calc_init_readline ();
#else
if (calc_option_readline == 1)
{
fprintf (stderr, "Readline support not available\n");
exit (1);
}
#endif
for (i = 0; i < numberof (variable); i++)
mpz_init (variable[i]);
for (i = 0; i < numberof (stack); i++)
mpz_init (stack[i]);
return yyparse ();
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,113 @@
/* Lexical analyzer for calc program.
Copyright 2000-2002 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see https://www.gnu.org/licenses/. */
%{
#include <string.h>
#include "calc-common.h"
#if WITH_READLINE
/* Let GNU flex use readline. See the calcread.c redefined input() for a
way that might work for a standard lex too. */
#define YY_INPUT(buf,result,max_size) \
result = calc_input (buf, max_size);
#endif
/* Non-zero when reading the second or subsequent line of an expression,
used to give a different prompt when using readline. */
int calc_more_input = 0;
const struct calc_keywords_t calc_keywords[] = {
{ "abs", ABS },
{ "bin", BIN },
{ "decimal", DECIMAL },
{ "fib", FIB },
{ "hex", HEX },
{ "help", HELP },
{ "gcd", GCD },
{ "kron", KRON },
{ "lcm", LCM },
{ "lucnum", LUCNUM },
{ "nextprime", NEXTPRIME },
{ "powm", POWM },
{ "quit", QUIT },
{ "root", ROOT },
{ "sqrt", SQRT },
{ NULL }
};
%}
%%
[ \t\f] { /* white space is skipped */ }
[;\n] { /* semicolon or newline separates statements */
calc_more_input = 0;
return EOS; }
\\\n { /* escaped newlines are skipped */ }
#(([^\\\n]*)\\)+\n {
/* comment through to escaped newline is skipped */ }
#[^\n]*\n { /* comment through to newline is a separator */
calc_more_input = 0;
return EOS; }
#[^\n]* { /* comment through to EOF skipped */ }
[-+*/%()<>^!=,] { return yytext[0]; }
"<=" { return LE; }
">=" { return GE; }
"==" { return EQ; }
"!=" { return NE; }
"<<" { return LSHIFT; }
">>" { return RSHIFT; }
"&&" { return LAND; }
"||" { return LOR; }
(0[xX])?[0-9A-F]+ {
yylval.str = yytext;
return NUMBER; }
[a-zA-Z][a-zA-Z0-9]* {
int i;
for (i = 0; calc_keywords[i].name != NULL; i++)
if (strcmp (yytext, calc_keywords[i].name) == 0)
return calc_keywords[i].value;
if (yytext[0] >= 'a' && yytext[0] <= 'z' && yytext[1] == '\0')
{
yylval.var = yytext[0] - 'a';
return VARIABLE;
}
return BAD;
}
. { return BAD; }
%%
int
yywrap ()
{
return 1;
}

View File

@@ -0,0 +1,146 @@
/* Readline support for calc program.
Copyright 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see https://www.gnu.org/licenses/. */
#include "calc-common.h"
#if WITH_READLINE
#include <stdio.h> /* for FILE for old versions of readline/readline.h */
#include <stdlib.h> /* for free */
#include <string.h> /* for strdup */
#include <unistd.h> /* for isatty */
#include <readline/readline.h>
#include <readline/history.h>
#include "gmp.h"
/* change this to "#define TRACE(x) x" for a few diagnostics */
#define TRACE(x)
#define MIN(x,y) ((x) < (y) ? (x) : (y))
char *
calc_completion_entry (const char *text, int state)
{
static int index, len;
char *name;
if (!state)
{
index = 0;
len = strlen (text);
}
TRACE (printf ("calc_completion_entry %s %d, index=%d len=%d\n",
text, state, index, len));
while ((name = calc_keywords[index].name) != NULL)
{
index++;
if (memcmp (name, text, len) == 0)
return (strdup (name));
}
return NULL;
}
void
calc_init_readline (void)
{
/* By default use readline when the input is a tty. It's a bit contrary
to the GNU interface conventions to make the behaviour depend on where
the input is coming from, but this is pretty convenient. */
if (calc_option_readline == -1)
{
calc_option_readline = isatty (fileno (stdin));
TRACE (printf ("calc_option_readline %d\n", calc_option_readline));
}
if (calc_option_readline)
{
printf ("GNU MP demo calculator program, gmp version %s\n", gmp_version);
printf ("Type \"help\" for help.\n");
rl_readline_name = "gmp-calc";
rl_completion_entry_function = calc_completion_entry;
}
}
/* This function is supposed to return YY_NULL to indicate EOF, but that
constant is only in calclex.c and we don't want to clutter calclex.l with
this readline stuff, so instead just hard code 0 for YY_NULL. That's
it's defined value on unix anyway. */
int
calc_input (char *buf, size_t max_size)
{
if (calc_option_readline)
{
static char *line = NULL;
static size_t line_size = 0;
static size_t upto = 0;
size_t copy_size;
if (upto >= line_size)
{
if (line != NULL)
free (line);
line = readline (calc_more_input ? "more> " : "> ");
calc_more_input = 1;
if (line == NULL)
return 0;
TRACE (printf ("readline: %s\n", line));
if (line[0] != '\0')
add_history (line);
line_size = strlen (line);
line[line_size] = '\n';
line_size++;
upto = 0;
}
copy_size = MIN (line_size-upto, max_size);
memcpy (buf, line+upto, copy_size);
upto += copy_size;
return copy_size;
}
else
{
/* not readline */
return fread (buf, 1, max_size, stdin);
}
}
/* This redefined input() might let a traditional lex use the readline
support here. Apparently POSIX doesn't specify whether an override like
this will work, so maybe it'll work or maybe it won't. This function is
also not particularly efficient, but don't worry about that, since flex
is the preferred parser. */
int
input (void)
{
char c;
if (calc_input (&c, 1) != 1)
return EOF;
else
return (int) c;
}
#endif /* WITH_READLINE */

View File

@@ -0,0 +1,54 @@
## Process this file with automake to generate Makefile.in
# Copyright 2001-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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/tests
# FIXME: This is a workaround for a bug in automake 1.8.4. When the only
# library is in EXTRA_LIBRARIES, $(ARFLAGS) is used but no default setting
# for that variable is established. We give an explicit ARFLAGS=cru the
# same as generated for lib_LIBRARIES or noinst_LIBRARIES.
#
ARFLAGS = cru
EXTRA_LIBRARIES = libexpr.a
libexpr_a_SOURCES = expr.h expr-impl.h \
expr.c exprv.c exprz.c exprza.c exprq.c exprqa.c exprf.c exprfa.c
EXTRA_PROGRAMS = run-expr t-expr
LDADD = libexpr.a $(top_builddir)/libgmp.la
t_expr_LDADD = $(top_builddir)/tests/libtests.la $(LDADD)
CLEANFILES = $(EXTRA_PROGRAMS) $(EXTRA_LIBRARIES)
allprogs: $(EXTRA_PROGRAMS)
$(top_builddir)/tests/libtests.la:
cd $(top_builddir)/tests; $(MAKE) $(AM_MAKEFLAGS) libtests.la

View File

@@ -0,0 +1,666 @@
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
# Copyright 2001-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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
EXTRA_PROGRAMS = run-expr$(EXEEXT) t-expr$(EXEEXT)
subdir = demos/expr
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
AM_V_AR = $(am__v_AR_@AM_V@)
am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@)
am__v_AR_0 = @echo " AR " $@;
am__v_AR_1 =
libexpr_a_AR = $(AR) $(ARFLAGS)
libexpr_a_LIBADD =
am_libexpr_a_OBJECTS = expr.$(OBJEXT) exprv.$(OBJEXT) exprz.$(OBJEXT) \
exprza.$(OBJEXT) exprq.$(OBJEXT) exprqa.$(OBJEXT) \
exprf.$(OBJEXT) exprfa.$(OBJEXT)
libexpr_a_OBJECTS = $(am_libexpr_a_OBJECTS)
run_expr_SOURCES = run-expr.c
run_expr_OBJECTS = run-expr.$(OBJEXT)
run_expr_LDADD = $(LDADD)
run_expr_DEPENDENCIES = libexpr.a $(top_builddir)/libgmp.la
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
t_expr_SOURCES = t-expr.c
t_expr_OBJECTS = t-expr.$(OBJEXT)
t_expr_DEPENDENCIES = $(top_builddir)/tests/libtests.la $(LDADD)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp =
am__depfiles_maybe =
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(libexpr_a_SOURCES) run-expr.c t-expr.c
DIST_SOURCES = $(libexpr_a_SOURCES) run-expr.c t-expr.c
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in README
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ABI = @ABI@
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AS = @AS@
ASMFLAGS = @ASMFLAGS@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CALLING_CONVENTIONS_OBJS = @CALLING_CONVENTIONS_OBJS@
CC = @CC@
CCAS = @CCAS@
CC_FOR_BUILD = @CC_FOR_BUILD@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CPP_FOR_BUILD = @CPP_FOR_BUILD@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFN_LONG_LONG_LIMB = @DEFN_LONG_LONG_LIMB@
DEFS = @DEFS@
DLLTOOL = @DLLTOOL@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
EXEEXT_FOR_BUILD = @EXEEXT_FOR_BUILD@
FGREP = @FGREP@
GMP_LDFLAGS = @GMP_LDFLAGS@
GMP_LIMB_BITS = @GMP_LIMB_BITS@
GMP_NAIL_BITS = @GMP_NAIL_BITS@
GREP = @GREP@
HAVE_CLOCK_01 = @HAVE_CLOCK_01@
HAVE_CPUTIME_01 = @HAVE_CPUTIME_01@
HAVE_GETRUSAGE_01 = @HAVE_GETRUSAGE_01@
HAVE_GETTIMEOFDAY_01 = @HAVE_GETTIMEOFDAY_01@
HAVE_HOST_CPU_FAMILY_power = @HAVE_HOST_CPU_FAMILY_power@
HAVE_HOST_CPU_FAMILY_powerpc = @HAVE_HOST_CPU_FAMILY_powerpc@
HAVE_SIGACTION_01 = @HAVE_SIGACTION_01@
HAVE_SIGALTSTACK_01 = @HAVE_SIGALTSTACK_01@
HAVE_SIGSTACK_01 = @HAVE_SIGSTACK_01@
HAVE_STACK_T_01 = @HAVE_STACK_T_01@
HAVE_SYS_RESOURCE_H_01 = @HAVE_SYS_RESOURCE_H_01@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LIBCURSES = @LIBCURSES@
LIBGMPXX_LDFLAGS = @LIBGMPXX_LDFLAGS@
LIBGMP_DLL = @LIBGMP_DLL@
LIBGMP_LDFLAGS = @LIBGMP_LDFLAGS@
LIBM = @LIBM@
LIBM_FOR_BUILD = @LIBM_FOR_BUILD@
LIBOBJS = @LIBOBJS@
LIBREADLINE = @LIBREADLINE@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIPO = @LIPO@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
M4 = @M4@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SPEED_CYCLECOUNTER_OBJ = @SPEED_CYCLECOUNTER_OBJ@
STRIP = @STRIP@
TAL_OBJECT = @TAL_OBJECT@
TUNE_LIBS = @TUNE_LIBS@
TUNE_SQR_OBJ = @TUNE_SQR_OBJ@
U_FOR_BUILD = @U_FOR_BUILD@
VERSION = @VERSION@
WITH_READLINE_01 = @WITH_READLINE_01@
YACC = @YACC@
YFLAGS = @YFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__leading_dot = @am__leading_dot@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
gmp_srclinks = @gmp_srclinks@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
mpn_objects = @mpn_objects@
mpn_objs_in_libgmp = @mpn_objs_in_libgmp@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/tests
# FIXME: This is a workaround for a bug in automake 1.8.4. When the only
# library is in EXTRA_LIBRARIES, $(ARFLAGS) is used but no default setting
# for that variable is established. We give an explicit ARFLAGS=cru the
# same as generated for lib_LIBRARIES or noinst_LIBRARIES.
#
ARFLAGS = cru
EXTRA_LIBRARIES = libexpr.a
libexpr_a_SOURCES = expr.h expr-impl.h \
expr.c exprv.c exprz.c exprza.c exprq.c exprqa.c exprf.c exprfa.c
LDADD = libexpr.a $(top_builddir)/libgmp.la
t_expr_LDADD = $(top_builddir)/tests/libtests.la $(LDADD)
CLEANFILES = $(EXTRA_PROGRAMS) $(EXTRA_LIBRARIES)
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu --ignore-deps demos/expr/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu --ignore-deps demos/expr/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
libexpr.a: $(libexpr_a_OBJECTS) $(libexpr_a_DEPENDENCIES) $(EXTRA_libexpr_a_DEPENDENCIES)
$(AM_V_at)-rm -f libexpr.a
$(AM_V_AR)$(libexpr_a_AR) libexpr.a $(libexpr_a_OBJECTS) $(libexpr_a_LIBADD)
$(AM_V_at)$(RANLIB) libexpr.a
run-expr$(EXEEXT): $(run_expr_OBJECTS) $(run_expr_DEPENDENCIES) $(EXTRA_run_expr_DEPENDENCIES)
@rm -f run-expr$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(run_expr_OBJECTS) $(run_expr_LDADD) $(LIBS)
t-expr$(EXEEXT): $(t_expr_OBJECTS) $(t_expr_DEPENDENCIES) $(EXTRA_t_expr_DEPENDENCIES)
@rm -f t-expr$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(t_expr_OBJECTS) $(t_expr_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
.c.o:
$(AM_V_CC)$(COMPILE) -c -o $@ $<
.c.obj:
$(AM_V_CC)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
$(AM_V_CC)$(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
clean-libtool cscopelist-am ctags ctags-am distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am
.PRECIOUS: Makefile
allprogs: $(EXTRA_PROGRAMS)
$(top_builddir)/tests/libtests.la:
cd $(top_builddir)/tests; $(MAKE) $(AM_MAKEFLAGS) libtests.la
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@@ -0,0 +1,501 @@
Copyright 2001, 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/.
GMP EXPRESSION EVALUATION
-------------------------
THIS CODE IS PRELIMINARY AND MAY BE SUBJECT TO INCOMPATIBLE CHANGES IN
FUTURE VERSIONS OF GMP.
The files in this directory implement a simple scheme of string based
expression parsing and evaluation, supporting mpz, mpq and mpf.
This will be slower than direct GMP library calls, but may be convenient in
various circumstances, such as while prototyping, or for letting a user
enter values in symbolic form. "2**5723-7" for example is a lot easier to
enter or maintain than the equivalent written out in decimal.
BUILDING
Nothing in this directory is a normal part of libgmp, and nothing is built
or installed, but various Makefile rules are available to compile
everything.
All the functions are available through a little library (there's no shared
library since upward binary compatibility is not guaranteed).
make libexpr.a
In a program, prototypes are available using
#include "expr.h"
run-expr.c is a sample program doing evaluations from the command line.
make run-expr
./run-expr '1+2*3'
t-expr.c is self-test program, it prints nothing if successful.
make t-expr
./t-expr
The expr*.c sources don't depend on gmp-impl.h and can be compiled with just
a standard installed GMP. This isn't true of t-expr though, since it uses
some of the internal tests/libtests.la.
SIMPLE USAGE
int mpz_expr (mpz_t res, int base, const char *e, ...);
int mpq_expr (mpq_t res, int base, const char *e, ...);
int mpf_expr (mpf_t res, int base, const char *e, ...);
These functions evaluate simple arithmetic expressions. For example,
mpz_expr (result, 0, "123+456", NULL);
Numbers are parsed by mpz_expr and mpq_expr the same as mpz_set_str with the
given base. mpf_expr follows mpf_set_str, but supporting an "0x" prefix for
hex when base==0.
mpz_expr (result, 0, "0xAAAA * 0x5555", NULL);
White space, as indicated by <ctype.h> isspace(), is ignored except for the
purpose of separating tokens.
Variables can be included in expressions by putting them in the stdarg list
after the string. "a", "b", "c" etc in the expression string designate
those values. For example,
mpq_t foo, bar;
...
mpq_expr (q, 10, "2/3 + 1/a + b/2", foo, bar, NULL);
Here "a" will be the value from foo and "b" from bar. Up to 26 variables
can be included this way. The NULL must be present to indicate the end of
the list.
Variables can also be written "$a", "$b" etc. This is necessary when using
bases greater than 10 since plain "a", "b" etc will otherwise be interpreted
as numbers. For example,
mpf_t quux;
mpf_expr (f, 16, "F00F@-6 * $a", quux, NULL);
All the standard C operators are available, with the usual precedences, plus
"**" for exponentiation at the highest precedence (and right associative).
Operators Precedence
** 220
~ ! - (unary) 210
* / % 200
+ - 190
<< >> 180
<= < >= > 170
== != 160
& 150
^ 140
| 130
&& 120
|| 110
? : 100/101
Currently only mpz_expr has the bitwise ~ % & ^ and | operators. The
precedence numbers are of interest in the advanced usage described below.
Various functions are available too. For example,
mpz_expr (res, 10, "gcd(123,456,789) * abs(a)", var, NULL);
The following is the full set of functions,
mpz_expr
abs bin clrbit cmp cmpabs congruent_p divisible_p even_p fib fac
gcd hamdist invert jacobi kronecker lcm lucnum max min nextprime
odd_p perfect_power_p perfect_square_p popcount powm
probab_prime_p root scan0 scan1 setbit sgn sqrt
mpq_expr
abs, cmp, den, max, min, num, sgn
mpf_expr
abs, ceil, cmp, eq, floor, integer_p, max, min, reldiff, sgn,
sqrt, trunc
All these are the same as the GMP library functions, except that min and max
don't exist in the library. Note also that min, max, gcd and lcm take any
number of arguments, not just two.
mpf_expr does all calculations to the precision of the destination variable.
Expression parsing can succeed or fail. The return value indicates this,
and will be one of the following
MPEXPR_RESULT_OK
MPEXPR_RESULT_BAD_VARIABLE
MPEXPR_RESULT_BAD_TABLE
MPEXPR_RESULT_PARSE_ERROR
MPEXPR_RESULT_NOT_UI
BAD_VARIABLE is when a variable is referenced that hasn't been provided.
For example if "c" is used when only two parameters have been passed.
BAD_TABLE is applicable to the advanced usage described below.
PARSE_ERROR is a general syntax error, returned for any mal-formed input
string.
NOT_UI is returned when an attempt is made to use an operand that's bigger
than an "unsigned long" with a function that's restricted to that range.
For example "fib" is mpz_fib_ui and only accepts an "unsigned long".
ADVANCED USAGE
int mpz_expr_a (const struct mpexpr_operator_t *table,
mpz_ptr res, int base, const char *e, size_t elen,
mpz_srcptr var[26])
int mpq_expr_a (const struct mpexpr_operator_t *table,
mpq_ptr res, int base, const char *e, size_t elen,
mpq_srcptr var[26])
int mpf_expr_a (const struct mpexpr_operator_t *table,
mpf_ptr res, int base, unsigned long prec,
const char *e, size_t elen,
mpf_srcptr var[26])
These functions are an advanced interface to expression parsing.
The string is taken as pointer and length. This makes it possible to parse
an expression in the middle of somewhere without copying and null
terminating it.
Variables are an array of 26 pointers to the appropriate operands, or NULL
for variables that are not available. Any combination of variables can be
given, for example just "x" and "y" (var[23] and var[24]) could be set.
Operators and functions are specified with a table. This makes it possible
to provide additional operators or functions, or to completely change the
syntax. The standard tables used by the simple functions above are
available as
const struct mpexpr_operator_t * const mpz_expr_standard_table;
const struct mpexpr_operator_t * const mpq_expr_standard_table;
const struct mpexpr_operator_t * const mpf_expr_standard_table;
struct mpexpr_operator_t is the following
struct mpexpr_operator_t {
const char *name;
mpexpr_fun_t fun;
int type;
int precedence;
};
typedef void (*mpexpr_fun_t) (void);
As an example, the standard mpz_expr table entry for multiplication is as
follows. See the source code for the full set of standard entries.
{ "*", (mpexpr_fun_t) mpz_mul, MPEXPR_TYPE_BINARY, 200 },
"name" is the string to parse, "fun" is the function to call for it, "type"
indicates what parameters the function takes (among other things), and
"precedence" sets its operator precedence.
A NULL for "name" indicates the end of the table, so for example an mpf
table with nothing but addition could be
struct mpexpr_operator_t table[] = {
{ "+", (mpexpr_fun_t) mpf_add, MPEXPR_TYPE_BINARY, 190 },
{ NULL }
};
A special type MPEXPR_TYPE_NEW_TABLE makes it possible to chain from one
table to another. For example the following would add a "mod" operator to
the standard mpz table,
struct mpexpr_operator_t table[] = {
{ "mod", (mpexpr_fun_t) mpz_fdiv_r, MPEXPR_TYPE_BINARY, 125 },
{ (const char *) mpz_expr_standard_table, NULL, MPEXPR_TYPE_NEW_TABLE }
};
Notice the low precedence on "mod", so that for instance "45+26 mod 7"
parses as "(45+26)mod7".
Functions are designated by a precedence of 0. They always occur as
"foo(expr)" and so have no need for a precedence level. mpq_abs in the
standard mpq table is
{ "abs", (mpexpr_fun_t) mpq_abs, MPEXPR_TYPE_UNARY },
Functions expecting no arguments as in "foo()" can be given with
MPEXPR_TYPE_0ARY, or actual constants to be parsed as just "foo" are
MPEXPR_TYPE_CONSTANT. For example if a "void mpf_const_pi(mpf_t f)"
function existed (which it doesn't) it could be,
{ "pi", (mpexpr_fun_t) mpf_const_pi, MPEXPR_TYPE_CONSTANT },
Parsing of operator names is done by seeking the table entry with the
longest matching name. So for instance operators "<" and "<=" exist, and
when presented with "x <= y" the parser matches "<=" because it's longer.
Parsing of function names, on the other hand, is done by requiring a whole
alphanumeric word to match. For example presented with "fib2zz(5)" the
parser will attempt to find a function called "fib2zz". A function "fib"
wouldn't be used because it doesn't match the whole word.
The flag MPEXPR_TYPE_WHOLEWORD can be ORed into an operator type to override
the default parsing style. Similarly MPEXPR_TYPE_OPERATOR into a function.
Binary operators are left associative by default, meaning they're evaluated
from left to right, so for example "1+2+3" is treated as "(1+2)+3".
MPEXPR_TYPE_RIGHTASSOC can be ORed into the operator type to work from right
to left as in "1+(2+3)". This is generally what's wanted for
exponentiation, and for example the standard mpz table has
{ "**", (mpexpr_fun_t) mpz_pow_ui,
MPEXPR_TYPE_BINARY_UI | MPEXPR_TYPE_RIGHTASSOC, 220 }
Unary operators are postfix by default. For example a factorial to be used
as "123!" might be
{ "!", (mpexpr_fun_t) mpz_fac_ui, MPEXPR_TYPE_UNARY_UI, 215 }
MPEXPR_TYPE_PREFIX can be ORed into the type to get a prefix operator. For
instance negation (unary minus) in the standard mpf table is
{ "-", (mpexpr_fun_t) mpf_neg,
MPEXPR_TYPE_UNARY | MPEXPR_TYPE_PREFIX, 210 },
The same operator can exist as a prefix unary and a binary, or as a prefix
and postfix unary, simply by putting two entries in the table. While
parsing the context determines which style is sought. But note that the
same operator can't be both a postfix unary and a binary, since the parser
doesn't try to look ahead to decide which ought to be used.
When there's two entries for an operator, both prefix or both postfix (or
binary), then the first in the table will be used. This makes it possible
to override an entry in a standard table, for example to change the function
it calls, or perhaps its precedence level. The following would change mpz
division from tdiv to cdiv,
struct mpexpr_operator_t table[] = {
{ "/", (mpexpr_fun_t) mpz_cdiv_q, MPEXPR_TYPE_BINARY, 200 },
{ "%", (mpexpr_fun_t) mpz_cdiv_r, MPEXPR_TYPE_BINARY, 200 },
{ (char *) mpz_expr_standard_table, NULL, MPEXPR_TYPE_NEW_TABLE }
};
The type field indicates what parameters the given function expects. The
following styles of functions are supported. mpz_t is shown, but of course
this is mpq_t for mpq_expr_a, mpf_t for mpf_expr_a, etc.
MPEXPR_TYPE_CONSTANT void func (mpz_t result);
MPEXPR_TYPE_0ARY void func (mpz_t result);
MPEXPR_TYPE_I_0ARY int func (void);
MPEXPR_TYPE_UNARY void func (mpz_t result, mpz_t op);
MPEXPR_TYPE_UNARY_UI void func (mpz_t result, unsigned long op);
MPEXPR_TYPE_I_UNARY int func (mpz_t op);
MPEXPR_TYPE_I_UNARY_UI int func (unsigned long op);
MPEXPR_TYPE_BINARY void func (mpz_t result, mpz_t op1, mpz_t op2);
MPEXPR_TYPE_BINARY_UI void func (mpz_t result,
mpz_t op1, unsigned long op2);
MPEXPR_TYPE_I_BINARY int func (mpz_t op1, mpz_t op2);
MPEXPR_TYPE_I_BINARY_UI int func (mpz_t op1, unsigned long op2);
MPEXPR_TYPE_TERNARY void func (mpz_t result,
mpz_t op1, mpz_t op2, mpz_t op3);
MPEXPR_TYPE_TERNARY_UI void func (mpz_t result, mpz_t op1, mpz_t op2,
unsigned long op3);
MPEXPR_TYPE_I_TERNARY int func (mpz_t op1, mpz_t op2, mpz_t op3);
MPEXPR_TYPE_I_TERNARY_UI int func (mpz_t op1, mpz_t op2,
unsigned long op3);
Notice the pattern of "UI" for the last parameter as an unsigned long, or
"I" for the result as an "int" return value.
It's important that the declared type for an operator or function matches
the function pointer given. Any mismatch will have unpredictable results.
For binary functions, a further type attribute is MPEXPR_TYPE_PAIRWISE which
indicates that any number of arguments should be accepted, and evaluated by
applying the given binary function to them pairwise. This is used by gcd,
lcm, min and max. For example the standard mpz gcd is
{ "gcd", (mpexpr_fun_t) mpz_gcd,
MPEXPR_TYPE_BINARY | MPEXPR_TYPE_PAIRWISE },
Some special types exist for comparison operators (or functions).
MPEXPR_TYPE_CMP_LT through MPEXPR_TYPE_CMP_GE expect an MPEXPR_TYPE_I_BINARY
function, returning positive, negative or zero like mpz_cmp and similar.
For example the standard mpf "!=" operator is
{ "!=", (mpexpr_fun_t) mpf_cmp, MPEXPR_TYPE_CMP_NE, 160 },
But there's no obligation to use these types, for instance the standard mpq
table just uses a plain MPEXPR_TYPE_I_BINARY and mpq_equal for "==".
Further special types MPEXPR_TYPE_MIN and MPEXPR_TYPE_MAX exist to implement
the min and max functions, and they take a function like mpf_cmp similarly.
The standard mpf max function is
{ "max", (mpexpr_fun_t) mpf_cmp,
MPEXPR_TYPE_MAX | MPEXPR_TYPE_PAIRWISE },
These can be used as operators too, for instance the following would be the
>? operator which is a feature of GNU C++,
{ ">?", (mpexpr_fun_t) mpf_cmp, MPEXPR_TYPE_MAX, 175 },
Other special types are used to define "(" ")" parentheses, "," function
argument separator, "!" through "||" logical booleans, ternary "?" ":", and
the "$" which introduces variables. See the sources for how they should be
used.
User definable operator tables will have various uses. For example,
- a subset of the C operators, to be rid of infrequently used things
- a more mathematical syntax like "." for multiply, "^" for powering,
and "!" for factorial
- a boolean evaluator with "^" for AND, "v" for OR
- variables introduced with "%" instead of "$"
- brackets as "[" and "]" instead of "(" and ")"
The only fixed parts of the parsing are the treatment of numbers, whitespace
and the two styles of operator/function name recognition.
As a final example, the following would be a complete mpz table implementing
some operators with a more mathematical syntax. Notice there's no need to
preserve the standard precedence values, anything can be used so long as
they're in the desired relation to each other. There's also no need to have
entries in precedence order, but it's convenient to do so to show what comes
where.
static const struct mpexpr_operator_t table[] = {
{ "^", (mpexpr_fun_t) mpz_pow_ui,
MPEXPR_TYPE_BINARY_UI | MPEXPR_TYPE_RIGHTASSOC, 9 },
{ "!", (mpexpr_fun_t) mpz_fac_ui, MPEXPR_TYPE_UNARY_UI, 8 },
{ "-", (mpexpr_fun_t) mpz_neg,
MPEXPR_TYPE_UNARY | MPEXPR_TYPE_PREFIX, 7 },
{ "*", (mpexpr_fun_t) mpz_mul, MPEXPR_TYPE_BINARY, 6 },
{ "/", (mpexpr_fun_t) mpz_fdiv_q, MPEXPR_TYPE_BINARY, 6 },
{ "+", (mpexpr_fun_t) mpz_add, MPEXPR_TYPE_BINARY, 5 },
{ "-", (mpexpr_fun_t) mpz_sub, MPEXPR_TYPE_BINARY, 5 },
{ "mod", (mpexpr_fun_t) mpz_mod, MPEXPR_TYPE_BINARY, 6 },
{ ")", NULL, MPEXPR_TYPE_CLOSEPAREN, 4 },
{ "(", NULL, MPEXPR_TYPE_OPENPAREN, 3 },
{ ",", NULL, MPEXPR_TYPE_ARGSEP, 2 },
{ "$", NULL, MPEXPR_TYPE_VARIABLE, 1 },
{ NULL }
};
INTERNALS
Operator precedence is implemented using a control and data stack, there's
no C recursion. When an expression like 1+2*3 is read the "+" is held on
the control stack and 1 on the data stack until "*" has been parsed and
applied to 2 and 3. This happens any time a higher precedence operator
follows a lower one, or when a right-associative operator like "**" is
repeated.
Parentheses are handled by making "(" a special prefix unary with a low
precedence so a whole following expression is read. The special operator
")" knows to discard the pending "(". Function arguments are handled
similarly, with the function pretending to be a low precedence prefix unary
operator, and with "," allowed within functions. The same special ")"
operator recognises a pending function and will invoke it appropriately.
The ternary "? :" operator is also handled using precedences. ":" is one
level higher than "?", so when a valid a?b:c is parsed the ":" finds a "?"
on the control stack. It's a parse error for ":" to find anything else.
FUTURE
The ternary "?:" operator evaluates the "false" side of its pair, which is
wasteful, though it ought to be harmless. It'd be better if it could
evaluate only the "true" side. Similarly for the logical booleans "&&" and
"||" if they know their result already.
Functions like MPEXPR_TYPE_BINARY could return a status indicating operand
out of range or whatever, to get an error back through mpz_expr etc. That
would want to be just an option, since plain mpz_add etc have no such
return.
Could have assignments like "a = b*c" modifying the input variables.
Assignment could be an operator attribute, making it expect an lvalue.
There would want to be a standard table without assignments available
though, so user input could be safely parsed.
The closing parenthesis table entry could specify the type of open paren it
expects, so that "(" and ")" could match and "[" and "]" match but not a
mixture of the two. Currently "[" and "]" can be added, but there's no
error on writing a mixed expression like "2*(3+4]". Maybe also there could
be a way to say that functions can only be written with one or the other
style of parens.
----------------
Local variables:
mode: text
fill-column: 76
End:

View File

@@ -0,0 +1,125 @@
/* Implementation specifics for expression evaluation.
Copyright 2000-2002, 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdarg.h>
#include "expr.h"
#define isasciidigit(c) (isascii (c) && isdigit (c))
#define isasciicsym(c) (isascii (c) && (isalnum(c) || (c) == '_'))
#define isasciidigit_in_base(c,base) \
(isascii (c) \
&& ((isdigit (c) && (c)-'0' < (base)) \
|| (isupper (c) && (c)-'A'+10 < (base)) \
|| (islower (c) && (c)-'a'+10 < (base))))
union mpX_t {
mpz_t z;
mpq_t q;
mpf_t f;
};
typedef union mpX_t *mpX_ptr;
typedef const union mpX_t *mpX_srcptr;
typedef void (*mpexpr_fun_one_t) (mpX_ptr);
typedef unsigned long (*mpexpr_fun_ui_one_t) (mpX_ptr);
typedef void (*mpexpr_fun_0ary_t) (mpX_ptr);
typedef int (*mpexpr_fun_i_0ary_t) (void);
typedef void (*mpexpr_fun_unary_t) (mpX_ptr, mpX_srcptr);
typedef void (*mpexpr_fun_unary_ui_t) (mpX_ptr, unsigned long);
typedef int (*mpexpr_fun_i_unary_t) (mpX_srcptr);
typedef int (*mpexpr_fun_i_unary_ui_t) (unsigned long);
typedef void (*mpexpr_fun_binary_t) (mpX_ptr, mpX_srcptr, mpX_srcptr);
typedef void (*mpexpr_fun_binary_ui_t) (mpX_ptr, mpX_srcptr, unsigned long);
typedef int (*mpexpr_fun_i_binary_t) (mpX_srcptr, mpX_srcptr);
typedef int (*mpexpr_fun_i_binary_ui_t) (mpX_srcptr, unsigned long);
typedef void (*mpexpr_fun_ternary_t) (mpX_ptr, mpX_srcptr, mpX_srcptr, mpX_srcptr);
typedef void (*mpexpr_fun_ternary_ui_t) (mpX_ptr, mpX_srcptr, mpX_srcptr, unsigned long);
typedef int (*mpexpr_fun_i_ternary_t) (mpX_srcptr, mpX_srcptr, mpX_srcptr);
typedef int (*mpexpr_fun_i_ternary_ui_t) (mpX_srcptr, mpX_srcptr, unsigned long);
typedef size_t (*mpexpr_fun_number_t) (mpX_ptr, const char *str, size_t len, int base);
typedef void (*mpexpr_fun_swap_t) (mpX_ptr, mpX_ptr);
typedef unsigned long (*mpexpr_fun_get_ui_t) (mpX_srcptr);
typedef void (*mpexpr_fun_set_si_t) (mpX_srcptr, long);
struct mpexpr_control_t {
const struct mpexpr_operator_t *op;
int argcount;
};
#define MPEXPR_VARIABLES 26
struct mpexpr_parse_t {
const struct mpexpr_operator_t *table;
mpX_ptr res;
int base;
unsigned long prec;
const char *e;
size_t elen;
mpX_srcptr *var;
int error_code;
int token;
const struct mpexpr_operator_t *token_op;
union mpX_t *data_stack;
int data_top;
int data_alloc;
int data_inited;
struct mpexpr_control_t *control_stack;
int control_top;
int control_alloc;
mpexpr_fun_0ary_t mpX_clear;
mpexpr_fun_i_unary_t mpX_ulong_p;
mpexpr_fun_get_ui_t mpX_get_ui;
mpexpr_fun_unary_ui_t mpX_init;
mpexpr_fun_number_t mpX_number;
mpexpr_fun_unary_t mpX_set;
mpexpr_fun_unary_t mpX_set_or_swap;
mpexpr_fun_set_si_t mpX_set_si;
mpexpr_fun_swap_t mpX_swap;
};
int mpexpr_evaluate (struct mpexpr_parse_t *p);
int mpexpr_va_to_var (void *var[], va_list ap);
size_t mpexpr_mpz_number (mpz_ptr res, const char *e, size_t elen, int base);

View File

@@ -0,0 +1,834 @@
/* mpexpr_evaluate -- shared code for simple expression evaluation
Copyright 2000-2002, 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include "gmp.h"
#include "expr-impl.h"
/* Change this to "#define TRACE(x) x" to get some traces. The trace
printfs junk up the code a bit, but it's very hard to tell what's going
on without them. Set MPX_TRACE to a suitable output function for the
mpz/mpq/mpf being run (if you have the wrong trace function it'll
probably segv). */
#define TRACE(x)
#define MPX_TRACE mpz_trace
/* A few helper macros copied from gmp-impl.h */
#define ALLOCATE_FUNC_TYPE(n,type) \
((type *) (*allocate_func) ((n) * sizeof (type)))
#define ALLOCATE_FUNC_LIMBS(n) ALLOCATE_FUNC_TYPE (n, mp_limb_t)
#define REALLOCATE_FUNC_TYPE(p, old_size, new_size, type) \
((type *) (*reallocate_func) \
(p, (old_size) * sizeof (type), (new_size) * sizeof (type)))
#define REALLOCATE_FUNC_LIMBS(p, old_size, new_size) \
REALLOCATE_FUNC_TYPE(p, old_size, new_size, mp_limb_t)
#define FREE_FUNC_TYPE(p,n,type) (*free_func) (p, (n) * sizeof (type))
#define FREE_FUNC_LIMBS(p,n) FREE_FUNC_TYPE (p, n, mp_limb_t)
#define ASSERT(x)
/* All the error strings are just for diagnostic traces. Only the error
code is actually returned. */
#define ERROR(str,code) \
{ \
TRACE (printf ("%s\n", str)); \
p->error_code = (code); \
goto done; \
}
#define REALLOC(ptr, alloc, incr, type) \
do { \
int new_alloc = (alloc) + (incr); \
ptr = REALLOCATE_FUNC_TYPE (ptr, alloc, new_alloc, type); \
(alloc) = new_alloc; \
} while (0)
/* data stack top element */
#define SP (p->data_stack + p->data_top)
/* Make sure there's room for another data element above current top.
reallocate_func is fetched for when this macro is used in lookahead(). */
#define DATA_SPACE() \
do { \
if (p->data_top + 1 >= p->data_alloc) \
{ \
void *(*reallocate_func) (void *, size_t, size_t); \
mp_get_memory_functions (NULL, &reallocate_func, NULL); \
TRACE (printf ("grow stack from %d\n", p->data_alloc)); \
REALLOC (p->data_stack, p->data_alloc, 20, union mpX_t); \
} \
ASSERT (p->data_top + 1 <= p->data_inited); \
if (p->data_top + 1 == p->data_inited) \
{ \
TRACE (printf ("initialize %d\n", p->data_top + 1)); \
(*p->mpX_init) (&p->data_stack[p->data_top + 1], p->prec); \
p->data_inited++; \
} \
} while (0)
#define DATA_PUSH() \
do { \
p->data_top++; \
ASSERT (p->data_top < p->data_alloc); \
ASSERT (p->data_top < p->data_inited); \
} while (0)
/* the last stack entry is never popped, so top>=0 will be true */
#define DATA_POP(n) \
do { \
p->data_top -= (n); \
ASSERT (p->data_top >= 0); \
} while (0)
/* lookahead() parses the next token. Return 1 if successful, with some
extra data. Return 0 if fail, with reason in p->error_code.
"prefix" is MPEXPR_TYPE_PREFIX if an operator with that attribute is
preferred, or 0 if an operator without is preferred. */
#define TOKEN_EOF -1 /* no extra data */
#define TOKEN_VALUE -2 /* pushed onto data stack */
#define TOKEN_OPERATOR -3 /* stored in p->token_op */
#define TOKEN_FUNCTION -4 /* stored in p->token_op */
#define TOKEN_NAME(n) \
((n) == TOKEN_EOF ? "TOKEN_EOF" \
: (n) == TOKEN_VALUE ? "TOKEN_VALUE" \
: (n) == TOKEN_OPERATOR ? "TOKEN_OPERATOR" \
: (n) == TOKEN_VALUE ? "TOKEN_FUNCTION" \
: "UNKNOWN TOKEN")
/* Functions default to being parsed as whole words, operators to match just
at the start of the string. The type flags override this. */
#define WHOLEWORD(op) \
(op->precedence == 0 \
? (! (op->type & MPEXPR_TYPE_OPERATOR)) \
: (op->type & MPEXPR_TYPE_WHOLEWORD))
#define isasciispace(c) (isascii (c) && isspace (c))
static int
lookahead (struct mpexpr_parse_t *p, int prefix)
{
const struct mpexpr_operator_t *op, *op_found;
size_t oplen, oplen_found, wlen;
int i;
/* skip white space */
while (p->elen > 0 && isasciispace (*p->e))
p->e++, p->elen--;
if (p->elen == 0)
{
TRACE (printf ("lookahead EOF\n"));
p->token = TOKEN_EOF;
return 1;
}
DATA_SPACE ();
/* Get extent of whole word. */
for (wlen = 0; wlen < p->elen; wlen++)
if (! isasciicsym (p->e[wlen]))
break;
TRACE (printf ("lookahead at: \"%.*s\" length %u, word %u\n",
(int) p->elen, p->e, p->elen, wlen));
op_found = NULL;
oplen_found = 0;
for (op = p->table; op->name != NULL; op++)
{
if (op->type == MPEXPR_TYPE_NEW_TABLE)
{
printf ("new\n");
op = (struct mpexpr_operator_t *) op->name - 1;
continue;
}
oplen = strlen (op->name);
if (! ((WHOLEWORD (op) ? wlen == oplen : p->elen >= oplen)
&& memcmp (p->e, op->name, oplen) == 0))
continue;
/* Shorter matches don't replace longer previous ones. */
if (op_found && oplen < oplen_found)
continue;
/* On a match of equal length to a previous one, the old match isn't
replaced if it has the preferred prefix, and if it doesn't then
it's not replaced if the new one also doesn't. */
if (op_found && oplen == oplen_found
&& ((op_found->type & MPEXPR_TYPE_PREFIX) == prefix
|| (op->type & MPEXPR_TYPE_PREFIX) != prefix))
continue;
/* This is now either the first match seen, or a longer than previous
match, or an equal to previous one but with a preferred prefix. */
op_found = op;
oplen_found = oplen;
}
if (op_found)
{
p->e += oplen_found, p->elen -= oplen_found;
if (op_found->type == MPEXPR_TYPE_VARIABLE)
{
if (p->elen == 0)
ERROR ("end of string expecting a variable",
MPEXPR_RESULT_PARSE_ERROR);
i = p->e[0] - 'a';
if (i < 0 || i >= MPEXPR_VARIABLES)
ERROR ("bad variable name", MPEXPR_RESULT_BAD_VARIABLE);
goto variable;
}
if (op_found->precedence == 0)
{
TRACE (printf ("lookahead function: %s\n", op_found->name));
p->token = TOKEN_FUNCTION;
p->token_op = op_found;
return 1;
}
else
{
TRACE (printf ("lookahead operator: %s\n", op_found->name));
p->token = TOKEN_OPERATOR;
p->token_op = op_found;
return 1;
}
}
oplen = (*p->mpX_number) (SP+1, p->e, p->elen, p->base);
if (oplen != 0)
{
p->e += oplen, p->elen -= oplen;
p->token = TOKEN_VALUE;
DATA_PUSH ();
TRACE (MPX_TRACE ("lookahead number", SP));
return 1;
}
/* Maybe an unprefixed one character variable */
i = p->e[0] - 'a';
if (wlen == 1 && i >= 0 && i < MPEXPR_VARIABLES)
{
variable:
p->e++, p->elen--;
if (p->var[i] == NULL)
ERROR ("NULL variable", MPEXPR_RESULT_BAD_VARIABLE);
TRACE (printf ("lookahead variable: var[%d] = ", i);
MPX_TRACE ("", p->var[i]));
p->token = TOKEN_VALUE;
DATA_PUSH ();
(*p->mpX_set) (SP, p->var[i]);
return 1;
}
ERROR ("no token matched", MPEXPR_RESULT_PARSE_ERROR);
done:
return 0;
}
/* control stack current top element */
#define CP (p->control_stack + p->control_top)
/* make sure there's room for another control element above current top */
#define CONTROL_SPACE() \
do { \
if (p->control_top + 1 >= p->control_alloc) \
{ \
TRACE (printf ("grow control stack from %d\n", p->control_alloc)); \
REALLOC (p->control_stack, p->control_alloc, 20, \
struct mpexpr_control_t); \
} \
} while (0)
/* Push an operator on the control stack, claiming currently to have the
given number of args ready. Local variable "op" is used in case opptr is
a reference through CP. */
#define CONTROL_PUSH(opptr,args) \
do { \
const struct mpexpr_operator_t *op = opptr; \
struct mpexpr_control_t *cp; \
CONTROL_SPACE (); \
p->control_top++; \
ASSERT (p->control_top < p->control_alloc); \
cp = CP; \
cp->op = op; \
cp->argcount = (args); \
TRACE_CONTROL("control stack push:"); \
} while (0)
/* The special operator_done is never popped, so top>=0 will hold. */
#define CONTROL_POP() \
do { \
p->control_top--; \
ASSERT (p->control_top >= 0); \
TRACE_CONTROL ("control stack pop:"); \
} while (0)
#define TRACE_CONTROL(str) \
TRACE ({ \
int i; \
printf ("%s depth %d:", str, p->control_top); \
for (i = 0; i <= p->control_top; i++) \
printf (" \"%s\"(%d)", \
p->control_stack[i].op->name, \
p->control_stack[i].argcount); \
printf ("\n"); \
});
#define LOOKAHEAD(prefix) \
do { \
if (! lookahead (p, prefix)) \
goto done; \
} while (0)
#define CHECK_UI(n) \
do { \
if (! (*p->mpX_ulong_p) (n)) \
ERROR ("operand doesn't fit ulong", MPEXPR_RESULT_NOT_UI); \
} while (0)
#define CHECK_ARGCOUNT(str,n) \
do { \
if (CP->argcount != (n)) \
{ \
TRACE (printf ("wrong number of arguments for %s, got %d want %d", \
str, CP->argcount, n)); \
ERROR ("", MPEXPR_RESULT_PARSE_ERROR); \
} \
} while (0)
/* There's two basic states here. In both p->token is the next token.
"another_expr" is when a whole expression should be parsed. This means a
literal or variable value possibly followed by an operator, or a function
or prefix operator followed by a further whole expression.
"another_operator" is when an expression has been parsed and its value is
on the top of the data stack (SP) and an optional further postfix or
infix operator should be parsed.
In "another_operator" precedences determine whether to push the operator
onto the control stack, or instead go to "apply_control" to reduce the
operator currently on top of the control stack.
When an operator has both a prefix and postfix/infix form, a LOOKAHEAD()
for "another_expr" will seek the prefix form, a LOOKAHEAD() for
"another_operator" will seek the postfix/infix form. The grammar is
simple enough that the next state is known before reading the next token.
Argument count checking guards against functions consuming the wrong
number of operands from the data stack. The same checks are applied to
operators, but will always pass since a UNARY or BINARY will only ever
parse with the correct operands. */
int
mpexpr_evaluate (struct mpexpr_parse_t *p)
{
void *(*allocate_func) (size_t);
void *(*reallocate_func) (void *, size_t, size_t);
void (*free_func) (void *, size_t);
mp_get_memory_functions (&allocate_func, &reallocate_func, &free_func);
TRACE (printf ("mpexpr_evaluate() base %d \"%.*s\"\n",
p->base, (int) p->elen, p->e));
/* "done" is a special sentinel at the bottom of the control stack,
precedence -1 is lower than any normal operator. */
{
static const struct mpexpr_operator_t operator_done
= { "DONE", NULL, MPEXPR_TYPE_DONE, -1 };
p->control_alloc = 20;
p->control_stack = ALLOCATE_FUNC_TYPE (p->control_alloc,
struct mpexpr_control_t);
p->control_top = 0;
CP->op = &operator_done;
CP->argcount = 1;
}
p->data_inited = 0;
p->data_alloc = 20;
p->data_stack = ALLOCATE_FUNC_TYPE (p->data_alloc, union mpX_t);
p->data_top = -1;
p->error_code = MPEXPR_RESULT_OK;
another_expr_lookahead:
LOOKAHEAD (MPEXPR_TYPE_PREFIX);
TRACE (printf ("another expr\n"));
/*another_expr:*/
switch (p->token) {
case TOKEN_VALUE:
goto another_operator_lookahead;
case TOKEN_OPERATOR:
TRACE (printf ("operator %s\n", p->token_op->name));
if (! (p->token_op->type & MPEXPR_TYPE_PREFIX))
ERROR ("expected a prefix operator", MPEXPR_RESULT_PARSE_ERROR);
CONTROL_PUSH (p->token_op, 1);
goto another_expr_lookahead;
case TOKEN_FUNCTION:
CONTROL_PUSH (p->token_op, 1);
if (p->token_op->type & MPEXPR_TYPE_CONSTANT)
goto apply_control_lookahead;
LOOKAHEAD (MPEXPR_TYPE_PREFIX);
if (! (p->token == TOKEN_OPERATOR
&& p->token_op->type == MPEXPR_TYPE_OPENPAREN))
ERROR ("expected open paren for function", MPEXPR_RESULT_PARSE_ERROR);
TRACE (printf ("open paren for function \"%s\"\n", CP->op->name));
if ((CP->op->type & MPEXPR_TYPE_MASK_ARGCOUNT) == MPEXPR_TYPE_NARY(0))
{
LOOKAHEAD (0);
if (! (p->token == TOKEN_OPERATOR
&& p->token_op->type == MPEXPR_TYPE_CLOSEPAREN))
ERROR ("expected close paren for 0ary function",
MPEXPR_RESULT_PARSE_ERROR);
goto apply_control_lookahead;
}
goto another_expr_lookahead;
}
ERROR ("unrecognised start of expression", MPEXPR_RESULT_PARSE_ERROR);
another_operator_lookahead:
LOOKAHEAD (0);
another_operator:
TRACE (printf ("another operator maybe: %s\n", TOKEN_NAME(p->token)));
switch (p->token) {
case TOKEN_EOF:
goto apply_control;
case TOKEN_OPERATOR:
/* The next operator is compared to the one on top of the control stack.
If the next is lower precedence, or the same precedence and not
right-associative, then reduce using the control stack and look at
the next operator again later. */
#define PRECEDENCE_TEST_REDUCE(tprec,cprec,ttype,ctype) \
((tprec) < (cprec) \
|| ((tprec) == (cprec) && ! ((ttype) & MPEXPR_TYPE_RIGHTASSOC)))
if (PRECEDENCE_TEST_REDUCE (p->token_op->precedence, CP->op->precedence,
p->token_op->type, CP->op->type))
{
TRACE (printf ("defer operator: %s (prec %d vs %d, type 0x%X)\n",
p->token_op->name,
p->token_op->precedence, CP->op->precedence,
p->token_op->type));
goto apply_control;
}
/* An argsep is a binary operator, but is never pushed on the control
stack, it just accumulates an extra argument for a function. */
if (p->token_op->type == MPEXPR_TYPE_ARGSEP)
{
if (CP->op->precedence != 0)
ERROR ("ARGSEP not in a function call", MPEXPR_RESULT_PARSE_ERROR);
TRACE (printf ("argsep for function \"%s\"(%d)\n",
CP->op->name, CP->argcount));
#define IS_PAIRWISE(type) \
(((type) & (MPEXPR_TYPE_MASK_ARGCOUNT | MPEXPR_TYPE_PAIRWISE)) \
== (MPEXPR_TYPE_BINARY | MPEXPR_TYPE_PAIRWISE))
if (IS_PAIRWISE (CP->op->type) && CP->argcount >= 2)
{
TRACE (printf (" will reduce pairwise now\n"));
CP->argcount--;
CONTROL_PUSH (CP->op, 2);
goto apply_control;
}
CP->argcount++;
goto another_expr_lookahead;
}
switch (p->token_op->type & MPEXPR_TYPE_MASK_ARGCOUNT) {
case MPEXPR_TYPE_NARY(1):
/* Postfix unary operators can always be applied immediately. The
easiest way to do this is just push it on the control stack and go
to the normal control stack reduction code. */
TRACE (printf ("postfix unary operator: %s\n", p->token_op->name));
if (p->token_op->type & MPEXPR_TYPE_PREFIX)
ERROR ("prefix unary operator used postfix",
MPEXPR_RESULT_PARSE_ERROR);
CONTROL_PUSH (p->token_op, 1);
goto apply_control_lookahead;
case MPEXPR_TYPE_NARY(2):
CONTROL_PUSH (p->token_op, 2);
goto another_expr_lookahead;
case MPEXPR_TYPE_NARY(3):
CONTROL_PUSH (p->token_op, 1);
goto another_expr_lookahead;
}
TRACE (printf ("unrecognised operator \"%s\" type: 0x%X",
CP->op->name, CP->op->type));
ERROR ("", MPEXPR_RESULT_PARSE_ERROR);
break;
default:
TRACE (printf ("expecting an operator, got token %d", p->token));
ERROR ("", MPEXPR_RESULT_PARSE_ERROR);
}
apply_control_lookahead:
LOOKAHEAD (0);
apply_control:
/* Apply the top element CP of the control stack. Data values are SP,
SP-1, etc. Result is left as stack top SP after popping consumed
values.
The use of sp as a duplicate of SP will help compilers that can't
otherwise recognise the various uses of SP as common subexpressions. */
TRACE (printf ("apply control: nested %d, \"%s\" 0x%X, %d args\n",
p->control_top, CP->op->name, CP->op->type, CP->argcount));
TRACE (printf ("apply 0x%X-ary\n",
CP->op->type & MPEXPR_TYPE_MASK_ARGCOUNT));
switch (CP->op->type & MPEXPR_TYPE_MASK_ARGCOUNT) {
case MPEXPR_TYPE_NARY(0):
{
mpX_ptr sp;
DATA_SPACE ();
DATA_PUSH ();
sp = SP;
switch (CP->op->type & MPEXPR_TYPE_MASK_ARGSTYLE) {
case 0:
(* (mpexpr_fun_0ary_t) CP->op->fun) (sp);
break;
case MPEXPR_TYPE_RESULT_INT:
(*p->mpX_set_si) (sp, (long) (* (mpexpr_fun_i_0ary_t) CP->op->fun) ());
break;
default:
ERROR ("unrecognised 0ary argument calling style",
MPEXPR_RESULT_BAD_TABLE);
}
}
break;
case MPEXPR_TYPE_NARY(1):
{
mpX_ptr sp = SP;
CHECK_ARGCOUNT ("unary", 1);
TRACE (MPX_TRACE ("before", sp));
switch (CP->op->type & MPEXPR_TYPE_MASK_SPECIAL) {
case 0:
/* not a special */
break;
case MPEXPR_TYPE_DONE & MPEXPR_TYPE_MASK_SPECIAL:
TRACE (printf ("special done\n"));
goto done;
case MPEXPR_TYPE_LOGICAL_NOT & MPEXPR_TYPE_MASK_SPECIAL:
TRACE (printf ("special logical not\n"));
(*p->mpX_set_si)
(sp, (long) ((* (mpexpr_fun_i_unary_t) CP->op->fun) (sp) == 0));
goto apply_control_done;
case MPEXPR_TYPE_CLOSEPAREN & MPEXPR_TYPE_MASK_SPECIAL:
CONTROL_POP ();
if (CP->op->type == MPEXPR_TYPE_OPENPAREN)
{
TRACE (printf ("close paren matching open paren\n"));
CONTROL_POP ();
goto another_operator;
}
if (CP->op->precedence == 0)
{
TRACE (printf ("close paren for function\n"));
goto apply_control;
}
ERROR ("unexpected close paren", MPEXPR_RESULT_PARSE_ERROR);
default:
TRACE (printf ("unrecognised special unary operator 0x%X",
CP->op->type & MPEXPR_TYPE_MASK_SPECIAL));
ERROR ("", MPEXPR_RESULT_BAD_TABLE);
}
switch (CP->op->type & MPEXPR_TYPE_MASK_ARGSTYLE) {
case 0:
(* (mpexpr_fun_unary_t) CP->op->fun) (sp, sp);
break;
case MPEXPR_TYPE_LAST_UI:
CHECK_UI (sp);
(* (mpexpr_fun_unary_ui_t) CP->op->fun)
(sp, (*p->mpX_get_ui) (sp));
break;
case MPEXPR_TYPE_RESULT_INT:
(*p->mpX_set_si)
(sp, (long) (* (mpexpr_fun_i_unary_t) CP->op->fun) (sp));
break;
case MPEXPR_TYPE_RESULT_INT | MPEXPR_TYPE_LAST_UI:
CHECK_UI (sp);
(*p->mpX_set_si)
(sp,
(long) (* (mpexpr_fun_i_unary_ui_t) CP->op->fun)
((*p->mpX_get_ui) (sp)));
break;
default:
ERROR ("unrecognised unary argument calling style",
MPEXPR_RESULT_BAD_TABLE);
}
}
break;
case MPEXPR_TYPE_NARY(2):
{
mpX_ptr sp;
/* pairwise functions are allowed to have just one argument */
if ((CP->op->type & MPEXPR_TYPE_PAIRWISE)
&& CP->op->precedence == 0
&& CP->argcount == 1)
goto apply_control_done;
CHECK_ARGCOUNT ("binary", 2);
DATA_POP (1);
sp = SP;
TRACE (MPX_TRACE ("lhs", sp);
MPX_TRACE ("rhs", sp+1));
if (CP->op->type & MPEXPR_TYPE_MASK_CMP)
{
int type = CP->op->type;
int cmp = (* (mpexpr_fun_i_binary_t) CP->op->fun)
(sp, sp+1);
(*p->mpX_set_si)
(sp,
(long)
(( (cmp < 0) & ((type & MPEXPR_TYPE_MASK_CMP_LT) != 0))
| ((cmp == 0) & ((type & MPEXPR_TYPE_MASK_CMP_EQ) != 0))
| ((cmp > 0) & ((type & MPEXPR_TYPE_MASK_CMP_GT) != 0))));
goto apply_control_done;
}
switch (CP->op->type & MPEXPR_TYPE_MASK_SPECIAL) {
case 0:
/* not a special */
break;
case MPEXPR_TYPE_QUESTION & MPEXPR_TYPE_MASK_SPECIAL:
ERROR ("'?' without ':'", MPEXPR_RESULT_PARSE_ERROR);
case MPEXPR_TYPE_COLON & MPEXPR_TYPE_MASK_SPECIAL:
TRACE (printf ("special colon\n"));
CONTROL_POP ();
if (CP->op->type != MPEXPR_TYPE_QUESTION)
ERROR ("':' without '?'", MPEXPR_RESULT_PARSE_ERROR);
CP->argcount--;
DATA_POP (1);
sp--;
TRACE (MPX_TRACE ("query", sp);
MPX_TRACE ("true", sp+1);
MPX_TRACE ("false", sp+2));
(*p->mpX_set)
(sp, (* (mpexpr_fun_i_unary_t) CP->op->fun) (sp)
? sp+1 : sp+2);
goto apply_control_done;
case MPEXPR_TYPE_LOGICAL_AND & MPEXPR_TYPE_MASK_SPECIAL:
TRACE (printf ("special logical and\n"));
(*p->mpX_set_si)
(sp,
(long)
((* (mpexpr_fun_i_unary_t) CP->op->fun) (sp)
&& (* (mpexpr_fun_i_unary_t) CP->op->fun) (sp+1)));
goto apply_control_done;
case MPEXPR_TYPE_LOGICAL_OR & MPEXPR_TYPE_MASK_SPECIAL:
TRACE (printf ("special logical and\n"));
(*p->mpX_set_si)
(sp,
(long)
((* (mpexpr_fun_i_unary_t) CP->op->fun) (sp)
|| (* (mpexpr_fun_i_unary_t) CP->op->fun) (sp+1)));
goto apply_control_done;
case MPEXPR_TYPE_MAX & MPEXPR_TYPE_MASK_SPECIAL:
TRACE (printf ("special max\n"));
if ((* (mpexpr_fun_i_binary_t) CP->op->fun) (sp, sp+1) < 0)
(*p->mpX_swap) (sp, sp+1);
goto apply_control_done;
case MPEXPR_TYPE_MIN & MPEXPR_TYPE_MASK_SPECIAL:
TRACE (printf ("special min\n"));
if ((* (mpexpr_fun_i_binary_t) CP->op->fun) (sp, sp+1) > 0)
(*p->mpX_swap) (sp, sp+1);
goto apply_control_done;
default:
ERROR ("unrecognised special binary operator",
MPEXPR_RESULT_BAD_TABLE);
}
switch (CP->op->type & MPEXPR_TYPE_MASK_ARGSTYLE) {
case 0:
(* (mpexpr_fun_binary_t) CP->op->fun) (sp, sp, sp+1);
break;
case MPEXPR_TYPE_LAST_UI:
CHECK_UI (sp+1);
(* (mpexpr_fun_binary_ui_t) CP->op->fun)
(sp, sp, (*p->mpX_get_ui) (sp+1));
break;
case MPEXPR_TYPE_RESULT_INT:
(*p->mpX_set_si)
(sp,
(long) (* (mpexpr_fun_i_binary_t) CP->op->fun) (sp, sp+1));
break;
case MPEXPR_TYPE_LAST_UI | MPEXPR_TYPE_RESULT_INT:
CHECK_UI (sp+1);
(*p->mpX_set_si)
(sp,
(long) (* (mpexpr_fun_i_binary_ui_t) CP->op->fun)
(sp, (*p->mpX_get_ui) (sp+1)));
break;
default:
ERROR ("unrecognised binary argument calling style",
MPEXPR_RESULT_BAD_TABLE);
}
}
break;
case MPEXPR_TYPE_NARY(3):
{
mpX_ptr sp;
CHECK_ARGCOUNT ("ternary", 3);
DATA_POP (2);
sp = SP;
TRACE (MPX_TRACE ("arg1", sp);
MPX_TRACE ("arg2", sp+1);
MPX_TRACE ("arg3", sp+1));
switch (CP->op->type & MPEXPR_TYPE_MASK_ARGSTYLE) {
case 0:
(* (mpexpr_fun_ternary_t) CP->op->fun) (sp, sp, sp+1, sp+2);
break;
case MPEXPR_TYPE_LAST_UI:
CHECK_UI (sp+2);
(* (mpexpr_fun_ternary_ui_t) CP->op->fun)
(sp, sp, sp+1, (*p->mpX_get_ui) (sp+2));
break;
case MPEXPR_TYPE_RESULT_INT:
(*p->mpX_set_si)
(sp,
(long) (* (mpexpr_fun_i_ternary_t) CP->op->fun)
(sp, sp+1, sp+2));
break;
case MPEXPR_TYPE_LAST_UI | MPEXPR_TYPE_RESULT_INT:
CHECK_UI (sp+2);
(*p->mpX_set_si)
(sp,
(long) (* (mpexpr_fun_i_ternary_ui_t) CP->op->fun)
(sp, sp+1, (*p->mpX_get_ui) (sp+2)));
break;
default:
ERROR ("unrecognised binary argument calling style",
MPEXPR_RESULT_BAD_TABLE);
}
}
break;
default:
TRACE (printf ("unrecognised operator type: 0x%X\n", CP->op->type));
ERROR ("", MPEXPR_RESULT_PARSE_ERROR);
}
apply_control_done:
TRACE (MPX_TRACE ("result", SP));
CONTROL_POP ();
goto another_operator;
done:
if (p->error_code == MPEXPR_RESULT_OK)
{
if (p->data_top != 0)
{
TRACE (printf ("data stack want top at 0, got %d\n", p->data_top));
p->error_code = MPEXPR_RESULT_PARSE_ERROR;
}
else
(*p->mpX_set_or_swap) (p->res, SP);
}
{
int i;
for (i = 0; i < p->data_inited; i++)
{
TRACE (printf ("clear %d\n", i));
(*p->mpX_clear) (p->data_stack+i);
}
}
FREE_FUNC_TYPE (p->data_stack, p->data_alloc, union mpX_t);
FREE_FUNC_TYPE (p->control_stack, p->control_alloc, struct mpexpr_control_t);
return p->error_code;
}

View File

@@ -0,0 +1,142 @@
/* Header for expression evaluation.
Copyright 2000-2002, 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#ifndef __EXPR_H__
#define __EXPR_H__
#define MPEXPR_RESULT_OK 0
#define MPEXPR_RESULT_BAD_VARIABLE 1
#define MPEXPR_RESULT_BAD_TABLE 2
#define MPEXPR_RESULT_PARSE_ERROR 3
#define MPEXPR_RESULT_NOT_UI 4
/* basic types */
#define MPEXPR_TYPE_NARY(n) ((n) * 0x0100)
#define MPEXPR_TYPE_MASK_ARGCOUNT MPEXPR_TYPE_NARY(0xF)
#define MPEXPR_TYPE_0ARY MPEXPR_TYPE_NARY(0)
#define MPEXPR_TYPE_UNARY MPEXPR_TYPE_NARY(1)
#define MPEXPR_TYPE_BINARY MPEXPR_TYPE_NARY(2)
#define MPEXPR_TYPE_TERNARY MPEXPR_TYPE_NARY(3)
/* options for all */
#define MPEXPR_TYPE_LAST_UI 0x0010
#define MPEXPR_TYPE_RESULT_INT 0x0020
#define MPEXPR_TYPE_MASK_ARGSTYLE 0x0030
#define MPEXPR_TYPE_UNARY_UI (MPEXPR_TYPE_UNARY | MPEXPR_TYPE_LAST_UI)
#define MPEXPR_TYPE_I_UNARY (MPEXPR_TYPE_UNARY | MPEXPR_TYPE_RESULT_INT)
#define MPEXPR_TYPE_I_UNARY_UI (MPEXPR_TYPE_I_UNARY | MPEXPR_TYPE_LAST_UI)
#define MPEXPR_TYPE_BINARY_UI (MPEXPR_TYPE_BINARY | MPEXPR_TYPE_LAST_UI)
#define MPEXPR_TYPE_I_BINARY (MPEXPR_TYPE_BINARY | MPEXPR_TYPE_RESULT_INT)
#define MPEXPR_TYPE_I_BINARY_UI (MPEXPR_TYPE_I_BINARY| MPEXPR_TYPE_LAST_UI)
#define MPEXPR_TYPE_TERNARY_UI (MPEXPR_TYPE_TERNARY | MPEXPR_TYPE_LAST_UI)
#define MPEXPR_TYPE_I_TERNARY (MPEXPR_TYPE_TERNARY | MPEXPR_TYPE_RESULT_INT)
#define MPEXPR_TYPE_I_TERNARY_UI (MPEXPR_TYPE_I_TERNARY|MPEXPR_TYPE_LAST_UI)
/* 0ary with options */
#define MPEXPR_TYPE_CONSTANT (MPEXPR_TYPE_0ARY | 0x0040)
/* unary options */
#define MPEXPR_TYPE_PREFIX 0x0040
/* binary options */
#define MPEXPR_TYPE_RIGHTASSOC 0x0040
#define MPEXPR_TYPE_PAIRWISE 0x0080
#define MPEXPR_TYPE_MASK_SPECIAL 0x000F
/* unary specials */
#define MPEXPR_TYPE_NEW_TABLE (MPEXPR_TYPE_UNARY | 0x001)
#define MPEXPR_TYPE_DONE (MPEXPR_TYPE_UNARY | 0x002)
#define MPEXPR_TYPE_VARIABLE (MPEXPR_TYPE_UNARY | 0x003)
#define MPEXPR_TYPE_LOGICAL_NOT (MPEXPR_TYPE_UNARY | 0x004)
#define MPEXPR_TYPE_CLOSEPAREN (MPEXPR_TYPE_UNARY | 0x005)
#define MPEXPR_TYPE_OPENPAREN (MPEXPR_TYPE_CLOSEPAREN | MPEXPR_TYPE_PREFIX)
/* binary specials */
#define MPEXPR_TYPE_LOGICAL_AND (MPEXPR_TYPE_BINARY | 0x001)
#define MPEXPR_TYPE_LOGICAL_OR (MPEXPR_TYPE_BINARY | 0x002)
#define MPEXPR_TYPE_ARGSEP (MPEXPR_TYPE_BINARY | 0x003)
#define MPEXPR_TYPE_QUESTION (MPEXPR_TYPE_BINARY | 0x004)
#define MPEXPR_TYPE_COLON (MPEXPR_TYPE_BINARY | 0x005)
#define MPEXPR_TYPE_MAX (MPEXPR_TYPE_BINARY | 0x006)
#define MPEXPR_TYPE_MIN (MPEXPR_TYPE_BINARY | 0x007)
#define MPEXPR_TYPE_MASK_CMP 0x008
#define MPEXPR_TYPE_MASK_CMP_LT 0x001
#define MPEXPR_TYPE_MASK_CMP_EQ 0x002
#define MPEXPR_TYPE_MASK_CMP_GT 0x004
#define MPEXPR_TYPE_CMP_LT (MPEXPR_TYPE_BINARY | MPEXPR_TYPE_MASK_CMP \
| MPEXPR_TYPE_MASK_CMP_LT)
#define MPEXPR_TYPE_CMP_EQ (MPEXPR_TYPE_BINARY | MPEXPR_TYPE_MASK_CMP \
| MPEXPR_TYPE_MASK_CMP_EQ)
#define MPEXPR_TYPE_CMP_GT (MPEXPR_TYPE_BINARY | MPEXPR_TYPE_MASK_CMP \
| MPEXPR_TYPE_MASK_CMP_GT)
#define MPEXPR_TYPE_CMP_LE (MPEXPR_TYPE_CMP_LT | MPEXPR_TYPE_MASK_CMP_EQ)
#define MPEXPR_TYPE_CMP_NE (MPEXPR_TYPE_CMP_LT | MPEXPR_TYPE_MASK_CMP_GT)
#define MPEXPR_TYPE_CMP_GE (MPEXPR_TYPE_CMP_GT | MPEXPR_TYPE_MASK_CMP_EQ)
/* parse options */
#define MPEXPR_TYPE_WHOLEWORD 0x1000
#define MPEXPR_TYPE_OPERATOR 0x2000
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*mpexpr_fun_t) (void);
struct mpexpr_operator_t {
const char *name;
mpexpr_fun_t fun;
int type;
int precedence;
};
int mpf_expr_a (const struct mpexpr_operator_t *, mpf_ptr, int,
unsigned long, const char *, size_t, mpf_srcptr [26]);
int mpf_expr (mpf_ptr, int, const char *, ...);
int mpq_expr_a (const struct mpexpr_operator_t *, mpq_ptr,
int, const char *, size_t, mpq_srcptr [26]);
int mpq_expr (mpq_ptr, int, const char *, ...);
int mpz_expr_a (const struct mpexpr_operator_t *, mpz_ptr, int,
const char *, size_t, mpz_srcptr [26]);
int mpz_expr (mpz_ptr, int, const char *, ...);
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif

View File

@@ -0,0 +1,123 @@
/* mpf expression evaluation
Copyright 2000-2002 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdio.h>
#include <string.h>
#include "gmp.h"
#include "expr-impl.h"
/* Change this to "#define TRACE(x) x" to get some traces. */
#define TRACE(x)
static int
e_mpf_sgn (mpf_srcptr x)
{
return mpf_sgn (x);
}
static const struct mpexpr_operator_t _mpf_expr_standard_table[] = {
{ "**", (mpexpr_fun_t) mpf_pow_ui,
MPEXPR_TYPE_BINARY_UI | MPEXPR_TYPE_RIGHTASSOC, 220 },
{ "!", (mpexpr_fun_t) e_mpf_sgn,
MPEXPR_TYPE_LOGICAL_NOT | MPEXPR_TYPE_PREFIX, 210 },
{ "-", (mpexpr_fun_t) mpf_neg,
MPEXPR_TYPE_UNARY | MPEXPR_TYPE_PREFIX, 210 },
{ "*", (mpexpr_fun_t) mpf_mul, MPEXPR_TYPE_BINARY, 200 },
{ "/", (mpexpr_fun_t) mpf_div, MPEXPR_TYPE_BINARY, 200 },
{ "+", (mpexpr_fun_t) mpf_add, MPEXPR_TYPE_BINARY, 190 },
{ "-", (mpexpr_fun_t) mpf_sub, MPEXPR_TYPE_BINARY, 190 },
{ "<<", (mpexpr_fun_t) mpf_mul_2exp, MPEXPR_TYPE_BINARY_UI, 180 },
{ ">>", (mpexpr_fun_t) mpf_div_2exp, MPEXPR_TYPE_BINARY_UI, 180 },
{ "<=", (mpexpr_fun_t) mpf_cmp, MPEXPR_TYPE_CMP_LE, 170 },
{ "<", (mpexpr_fun_t) mpf_cmp, MPEXPR_TYPE_CMP_LT, 170 },
{ ">=", (mpexpr_fun_t) mpf_cmp, MPEXPR_TYPE_CMP_GE, 170 },
{ ">", (mpexpr_fun_t) mpf_cmp, MPEXPR_TYPE_CMP_GT, 170 },
{ "==", (mpexpr_fun_t) mpf_cmp, MPEXPR_TYPE_CMP_EQ, 160 },
{ "!=", (mpexpr_fun_t) mpf_cmp, MPEXPR_TYPE_CMP_NE, 160 },
{ "&&", (mpexpr_fun_t) e_mpf_sgn, MPEXPR_TYPE_LOGICAL_AND, 120 },
{ "||", (mpexpr_fun_t) e_mpf_sgn, MPEXPR_TYPE_LOGICAL_OR, 110 },
{ ":", NULL, MPEXPR_TYPE_COLON, 101 },
{ "?", (mpexpr_fun_t) e_mpf_sgn, MPEXPR_TYPE_QUESTION, 100 },
{ ")", NULL, MPEXPR_TYPE_CLOSEPAREN, 4 },
{ "(", NULL, MPEXPR_TYPE_OPENPAREN, 3 },
{ ",", NULL, MPEXPR_TYPE_ARGSEP, 2 },
{ "$", NULL, MPEXPR_TYPE_VARIABLE, 1 },
{ "abs", (mpexpr_fun_t) mpf_abs, MPEXPR_TYPE_UNARY },
{ "ceil", (mpexpr_fun_t) mpf_ceil, MPEXPR_TYPE_UNARY },
{ "cmp", (mpexpr_fun_t) mpf_cmp, MPEXPR_TYPE_I_BINARY },
{ "eq", (mpexpr_fun_t) mpf_eq, MPEXPR_TYPE_I_TERNARY_UI },
{ "floor", (mpexpr_fun_t) mpf_floor, MPEXPR_TYPE_UNARY },
{ "integer_p",(mpexpr_fun_t) mpf_integer_p, MPEXPR_TYPE_I_UNARY },
{ "max", (mpexpr_fun_t) mpf_cmp, MPEXPR_TYPE_MAX | MPEXPR_TYPE_PAIRWISE },
{ "min", (mpexpr_fun_t) mpf_cmp, MPEXPR_TYPE_MIN | MPEXPR_TYPE_PAIRWISE },
{ "reldiff", (mpexpr_fun_t) mpf_reldiff, MPEXPR_TYPE_BINARY },
{ "sgn", (mpexpr_fun_t) e_mpf_sgn, MPEXPR_TYPE_I_UNARY },
{ "sqrt", (mpexpr_fun_t) mpf_sqrt, MPEXPR_TYPE_UNARY },
{ "trunc", (mpexpr_fun_t) mpf_trunc, MPEXPR_TYPE_UNARY },
{ NULL }
};
const struct mpexpr_operator_t * const mpf_expr_standard_table
= _mpf_expr_standard_table;
int
mpf_expr (mpf_ptr res, int base, const char *e, ...)
{
mpf_srcptr var[MPEXPR_VARIABLES];
va_list ap;
int ret;
va_start (ap, e);
TRACE (printf ("mpf_expr(): base %d, %s\n", base, e));
ret = mpexpr_va_to_var ((void **) var, ap);
va_end (ap);
if (ret != MPEXPR_RESULT_OK)
return ret;
return mpf_expr_a (mpf_expr_standard_table, res, base,
mpf_get_prec (res), e, strlen(e), var);
}

View File

@@ -0,0 +1,191 @@
/* mpf expression evaluation
Copyright 2000-2002, 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
/* Future: Bitwise "&", "|" and "&" could be done, if desired. Not sure
those functions would be much value though. */
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include "gmp.h"
#include "expr-impl.h"
/* Change this to "#define TRACE(x) x" to get some traces. */
#define TRACE(x)
static size_t
e_mpf_number (mpf_ptr res, const char *e, size_t elen, int base)
{
char *edup;
size_t i, ret, extra=0;
int mant_base, exp_base;
void *(*allocate_func) (size_t);
void (*free_func) (void *, size_t);
TRACE (printf ("mpf_number base=%d \"%.*s\"\n", base, (int) elen, e));
/* mpf_set_str doesn't currently accept 0x for hex in base==0, so do it
here instead. FIXME: Would prefer to let mpf_set_str handle this. */
if (base == 0 && elen >= 2 && e[0] == '0' && (e[1] == 'x' || e[1] == 'X'))
{
base = 16;
extra = 2;
e += extra;
elen -= extra;
}
if (base == 0)
mant_base = 10;
else if (base < 0)
mant_base = -base;
else
mant_base = base;
/* exponent in decimal if base is negative */
if (base < 0)
exp_base = 10;
else if (base == 0)
exp_base = 10;
else
exp_base = base;
#define IS_EXPONENT(c) \
(c == '@' || (base <= 10 && base >= -10 && (e[i] == 'e' || e[i] == 'E')))
i = 0;
for (;;)
{
if (i >= elen)
goto parsed;
if (e[i] == '.')
break;
if (IS_EXPONENT (e[i]))
goto exponent;
if (! isasciidigit_in_base (e[i], mant_base))
goto parsed;
i++;
}
/* fraction */
i++;
for (;;)
{
if (i >= elen)
goto parsed;
if (IS_EXPONENT (e[i]))
goto exponent;
if (! isasciidigit_in_base (e[i], mant_base))
goto parsed;
i++;
}
exponent:
i++;
if (i >= elen)
goto parsed;
if (e[i] == '-')
i++;
for (;;)
{
if (i >= elen)
goto parsed;
if (! isasciidigit_in_base (e[i], exp_base))
break;
i++;
}
parsed:
TRACE (printf (" parsed i=%u \"%.*s\"\n", i, (int) i, e));
mp_get_memory_functions (&allocate_func, NULL, &free_func);
edup = (*allocate_func) (i+1);
memcpy (edup, e, i);
edup[i] = '\0';
if (mpf_set_str (res, edup, base) == 0)
ret = i + extra;
else
ret = 0;
(*free_func) (edup, i+1);
return ret;
}
static int
e_mpf_ulong_p (mpf_srcptr f)
{
return mpf_integer_p (f) && mpf_fits_ulong_p (f);
}
/* Don't want to change the precision of w, can only do an actual swap when
w and x have the same precision. */
static void
e_mpf_set_or_swap (mpf_ptr w, mpf_ptr x)
{
if (mpf_get_prec (w) == mpf_get_prec (x))
mpf_swap (w, x);
else
mpf_set (w, x);
}
int
mpf_expr_a (const struct mpexpr_operator_t *table,
mpf_ptr res, int base, unsigned long prec,
const char *e, size_t elen,
mpf_srcptr var[26])
{
struct mpexpr_parse_t p;
p.table = table;
p.res = (mpX_ptr) res;
p.base = base;
p.prec = prec;
p.e = e;
p.elen = elen;
p.var = (mpX_srcptr *) var;
p.mpX_clear = (mpexpr_fun_one_t) mpf_clear;
p.mpX_ulong_p = (mpexpr_fun_i_unary_t) e_mpf_ulong_p;
p.mpX_get_ui = (mpexpr_fun_get_ui_t) mpf_get_ui;
p.mpX_init = (mpexpr_fun_unary_ui_t) mpf_init2;
p.mpX_number = (mpexpr_fun_number_t) e_mpf_number;
p.mpX_set = (mpexpr_fun_unary_t) mpf_set;
p.mpX_set_or_swap = (mpexpr_fun_unary_t) e_mpf_set_or_swap;
p.mpX_set_si = (mpexpr_fun_set_si_t) mpf_set_si;
p.mpX_swap = (mpexpr_fun_swap_t) mpf_swap;
return mpexpr_evaluate (&p);
}

View File

@@ -0,0 +1,155 @@
/* mpq expression evaluation
Copyright 2000-2002 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdio.h>
#include <string.h>
#include "gmp.h"
#include "expr-impl.h"
/* Change this to "#define TRACE(x) x" to get some traces. */
#define TRACE(x)
static void
e_mpq_pow_ui (mpq_ptr r, mpq_srcptr b, unsigned long e)
{
mpz_pow_ui (mpq_numref(r), mpq_numref(b), e);
mpz_pow_ui (mpq_denref(r), mpq_denref(b), e);
}
/* Wrapped because mpq_sgn is a macro. */
static int
e_mpq_sgn (mpq_srcptr x)
{
return mpq_sgn (x);
}
/* Wrapped because mpq_equal only guarantees a non-zero return, whereas we
want 1 or 0 for == and !=. */
static int
e_mpq_equal (mpq_srcptr x, mpq_srcptr y)
{
return mpq_equal (x, y) != 0;
}
static int
e_mpq_notequal (mpq_srcptr x, mpq_srcptr y)
{
return ! mpq_equal (x, y);
}
static void
e_mpq_num (mpq_ptr w, mpq_srcptr x)
{
if (w != x)
mpz_set (mpq_numref(w), mpq_numref(x));
mpz_set_ui (mpq_denref(w), 1L);
}
static void
e_mpq_den (mpq_ptr w, mpq_srcptr x)
{
if (w == x)
mpz_swap (mpq_numref(w), mpq_denref(w));
else
mpz_set (mpq_numref(w), mpq_denref(x));
mpz_set_ui (mpq_denref(w), 1L);
}
static const struct mpexpr_operator_t _mpq_expr_standard_table[] = {
{ "**", (mpexpr_fun_t) e_mpq_pow_ui,
MPEXPR_TYPE_BINARY_UI | MPEXPR_TYPE_RIGHTASSOC, 220 },
{ "!", (mpexpr_fun_t) e_mpq_sgn,
MPEXPR_TYPE_LOGICAL_NOT | MPEXPR_TYPE_PREFIX, 210 },
{ "-", (mpexpr_fun_t) mpq_neg,
MPEXPR_TYPE_UNARY | MPEXPR_TYPE_PREFIX, 210 },
{ "*", (mpexpr_fun_t) mpq_mul, MPEXPR_TYPE_BINARY, 200 },
{ "/", (mpexpr_fun_t) mpq_div, MPEXPR_TYPE_BINARY, 200 },
{ "+", (mpexpr_fun_t) mpq_add, MPEXPR_TYPE_BINARY, 190 },
{ "-", (mpexpr_fun_t) mpq_sub, MPEXPR_TYPE_BINARY, 190 },
{ "<<", (mpexpr_fun_t) mpq_mul_2exp, MPEXPR_TYPE_BINARY_UI, 180 },
{ ">>", (mpexpr_fun_t) mpq_div_2exp, MPEXPR_TYPE_BINARY_UI, 180 },
{ "<=", (mpexpr_fun_t) mpq_cmp, MPEXPR_TYPE_CMP_LE, 170 },
{ "<", (mpexpr_fun_t) mpq_cmp, MPEXPR_TYPE_CMP_LT, 170 },
{ ">=", (mpexpr_fun_t) mpq_cmp, MPEXPR_TYPE_CMP_GE, 170 },
{ ">", (mpexpr_fun_t) mpq_cmp, MPEXPR_TYPE_CMP_GT, 170 },
{ "==", (mpexpr_fun_t) e_mpq_equal, MPEXPR_TYPE_I_BINARY, 160 },
{ "!=", (mpexpr_fun_t) e_mpq_notequal, MPEXPR_TYPE_I_BINARY, 160 },
{ "&&", (mpexpr_fun_t) e_mpq_sgn, MPEXPR_TYPE_LOGICAL_AND, 120 },
{ "||", (mpexpr_fun_t) e_mpq_sgn, MPEXPR_TYPE_LOGICAL_OR, 110 },
{ ":", NULL, MPEXPR_TYPE_COLON, 101 },
{ "?", (mpexpr_fun_t) e_mpq_sgn, MPEXPR_TYPE_QUESTION, 100 },
{ ")", (mpexpr_fun_t) e_mpq_sgn, MPEXPR_TYPE_CLOSEPAREN, 4 },
{ "(", (mpexpr_fun_t) e_mpq_sgn, MPEXPR_TYPE_OPENPAREN, 3 },
{ ",", (mpexpr_fun_t) e_mpq_sgn, MPEXPR_TYPE_ARGSEP, 2 },
{ "$", NULL, MPEXPR_TYPE_VARIABLE, 1 },
{ "abs", (mpexpr_fun_t) mpq_abs, MPEXPR_TYPE_UNARY },
{ "cmp", (mpexpr_fun_t) mpq_cmp, MPEXPR_TYPE_I_BINARY },
{ "den", (mpexpr_fun_t) e_mpq_den, MPEXPR_TYPE_UNARY },
{ "max", (mpexpr_fun_t) mpq_cmp, MPEXPR_TYPE_MAX | MPEXPR_TYPE_PAIRWISE },
{ "min", (mpexpr_fun_t) mpq_cmp, MPEXPR_TYPE_MIN | MPEXPR_TYPE_PAIRWISE },
{ "num", (mpexpr_fun_t) e_mpq_num, MPEXPR_TYPE_UNARY },
{ "sgn", (mpexpr_fun_t) e_mpq_sgn, MPEXPR_TYPE_I_UNARY },
{ NULL }
};
const struct mpexpr_operator_t * const mpq_expr_standard_table
= _mpq_expr_standard_table;
int
mpq_expr (mpq_ptr res, int base, const char *e, ...)
{
mpq_srcptr var[MPEXPR_VARIABLES];
va_list ap;
int ret;
va_start (ap, e);
TRACE (printf ("mpq_expr(): base %d, %s\n", base, e));
ret = mpexpr_va_to_var ((void **) var, ap);
va_end (ap);
if (ret != MPEXPR_RESULT_OK)
return ret;
return mpq_expr_a (mpq_expr_standard_table, res, base, e, strlen(e), var);
}

View File

@@ -0,0 +1,100 @@
/* mpq expression evaluation
Copyright 2000, 2001, 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdio.h>
#include "gmp.h"
#include "expr-impl.h"
static int
e_mpq_ulong_p (mpq_srcptr q)
{
return mpz_fits_ulong_p (mpq_numref (q))
&& mpz_cmp_ui (mpq_denref (q), 1L) == 0;
}
/* get value as a ui, on the assumption it fits */
static int
e_mpq_get_ui_fits (mpq_srcptr q)
{
return mpz_get_ui (mpq_numref (q));
}
static void
e_mpq_set_si1 (mpq_ptr q, long num)
{
mpq_set_si (q, num, 1L);
}
/* The same as mpz, but putting the result in the numerator. Negatives and
fractions aren't parsed here because '-' and '/' are operators. */
static size_t
e_mpq_number (mpq_ptr res, const char *e, size_t elen, int base)
{
mpz_set_ui (mpq_denref (res), 1L);
return mpexpr_mpz_number (mpq_numref (res), e, elen, base);
}
/* ignoring prec */
static void
e_mpq_init (mpq_ptr q, unsigned long prec)
{
mpq_init (q);
}
int
mpq_expr_a (const struct mpexpr_operator_t *table,
mpq_ptr res, int base,
const char *e, size_t elen,
mpq_srcptr var[26])
{
struct mpexpr_parse_t p;
p.table = table;
p.res = (mpX_ptr) res;
p.base = base;
p.e = e;
p.elen = elen;
p.var = (mpX_srcptr *) var;
p.mpX_clear = (mpexpr_fun_one_t) mpq_clear;
p.mpX_ulong_p = (mpexpr_fun_i_unary_t) e_mpq_ulong_p;
p.mpX_get_ui = (mpexpr_fun_get_ui_t) e_mpq_get_ui_fits;
p.mpX_init = (mpexpr_fun_unary_ui_t) e_mpq_init;
p.mpX_number = (mpexpr_fun_number_t) e_mpq_number;
p.mpX_set = (mpexpr_fun_unary_t) mpq_set;
p.mpX_set_or_swap = (mpexpr_fun_unary_t) mpq_swap;
p.mpX_set_si = (mpexpr_fun_set_si_t) e_mpq_set_si1;
p.mpX_swap = (mpexpr_fun_swap_t) mpq_swap;
return mpexpr_evaluate (&p);
}

View File

@@ -0,0 +1,57 @@
/* mpz expression evaluation, simple part */
/*
Copyright 2000, 2001 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdio.h>
#include "gmp.h"
#include "expr-impl.h"
int
mpexpr_va_to_var (void *var[], va_list ap)
{
int i = 0;
void *v;
for (;;)
{
v = va_arg (ap, void *);
if (v == NULL)
break;
if (i >= MPEXPR_VARIABLES)
return MPEXPR_RESULT_BAD_VARIABLE;
var[i++] = v;
}
while (i < MPEXPR_VARIABLES)
var[i++] = NULL;
return MPEXPR_RESULT_OK;
}

View File

@@ -0,0 +1,206 @@
/* mpz expression evaluation, simple part
Copyright 2000-2002 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include "gmp.h"
#include "expr-impl.h"
/* Change this to "#define TRACE(x) x" to get some traces. */
#define TRACE(x)
/* These are macros, so need function wrappers. */
static int
e_mpz_sgn (mpz_srcptr x)
{
return mpz_sgn (x);
}
static int
e_mpz_odd_p (mpz_srcptr x)
{
return mpz_odd_p (x);
}
static int
e_mpz_even_p (mpz_srcptr x)
{
return mpz_even_p (x);
}
/* These wrapped because MPEXPR_TYPE_I_ functions are expected to return
"int" whereas these return "unsigned long". */
static void
e_mpz_hamdist (mpz_ptr w, mpz_srcptr x, mpz_srcptr y)
{
mpz_set_ui (w, mpz_hamdist (x, y));
}
static void
e_mpz_popcount (mpz_ptr w, mpz_srcptr x)
{
mpz_set_ui (w, mpz_popcount (x));
}
static void
e_mpz_scan0 (mpz_ptr w, mpz_srcptr x, unsigned long start)
{
mpz_set_ui (w, mpz_scan0 (x, start));
}
static void
e_mpz_scan1 (mpz_ptr w, mpz_srcptr x, unsigned long start)
{
mpz_set_ui (w, mpz_scan1 (x, start));
}
/* These wrapped because they're in-place whereas MPEXPR_TYPE_BINARY_UI
expects a separate source and destination. Actually the parser will
normally pass w==x anyway. */
static void
e_mpz_setbit (mpz_ptr w, mpz_srcptr x, unsigned long n)
{
if (w != x)
mpz_set (w, x);
mpz_setbit (w, n);
}
static void
e_mpz_clrbit (mpz_ptr w, mpz_srcptr x, unsigned long n)
{
if (w != x)
mpz_set (w, x);
mpz_clrbit (w, n);
}
static const struct mpexpr_operator_t _mpz_expr_standard_table[] = {
{ "**", (mpexpr_fun_t) mpz_pow_ui,
MPEXPR_TYPE_BINARY_UI | MPEXPR_TYPE_RIGHTASSOC, 220 },
{ "~", (mpexpr_fun_t) mpz_com,
MPEXPR_TYPE_UNARY | MPEXPR_TYPE_PREFIX, 210 },
{ "!", (mpexpr_fun_t) e_mpz_sgn,
MPEXPR_TYPE_LOGICAL_NOT | MPEXPR_TYPE_PREFIX, 210 },
{ "-", (mpexpr_fun_t) mpz_neg,
MPEXPR_TYPE_UNARY | MPEXPR_TYPE_PREFIX, 210 },
{ "*", (mpexpr_fun_t) mpz_mul, MPEXPR_TYPE_BINARY, 200 },
{ "/", (mpexpr_fun_t) mpz_tdiv_q, MPEXPR_TYPE_BINARY, 200 },
{ "%", (mpexpr_fun_t) mpz_tdiv_r, MPEXPR_TYPE_BINARY, 200 },
{ "+", (mpexpr_fun_t) mpz_add, MPEXPR_TYPE_BINARY, 190 },
{ "-", (mpexpr_fun_t) mpz_sub, MPEXPR_TYPE_BINARY, 190 },
{ "<<", (mpexpr_fun_t) mpz_mul_2exp, MPEXPR_TYPE_BINARY_UI, 180 },
{ ">>", (mpexpr_fun_t) mpz_tdiv_q_2exp, MPEXPR_TYPE_BINARY_UI, 180 },
{ "<=", (mpexpr_fun_t) mpz_cmp, MPEXPR_TYPE_CMP_LE, 170 },
{ "<", (mpexpr_fun_t) mpz_cmp, MPEXPR_TYPE_CMP_LT, 170 },
{ ">=", (mpexpr_fun_t) mpz_cmp, MPEXPR_TYPE_CMP_GE, 170 },
{ ">", (mpexpr_fun_t) mpz_cmp, MPEXPR_TYPE_CMP_GT, 170 },
{ "==", (mpexpr_fun_t) mpz_cmp, MPEXPR_TYPE_CMP_EQ, 160 },
{ "!=", (mpexpr_fun_t) mpz_cmp, MPEXPR_TYPE_CMP_NE, 160 },
{ "&", (mpexpr_fun_t) mpz_and, MPEXPR_TYPE_BINARY, 150 },
{ "^", (mpexpr_fun_t) mpz_xor, MPEXPR_TYPE_BINARY, 140 },
{ "|", (mpexpr_fun_t) mpz_ior, MPEXPR_TYPE_BINARY, 130 },
{ "&&", (mpexpr_fun_t) e_mpz_sgn, MPEXPR_TYPE_LOGICAL_AND, 120 },
{ "||", (mpexpr_fun_t) e_mpz_sgn, MPEXPR_TYPE_LOGICAL_OR, 110 },
{ ":", NULL, MPEXPR_TYPE_COLON, 101 },
{ "?", (mpexpr_fun_t) e_mpz_sgn, MPEXPR_TYPE_QUESTION, 100 },
{ ")", NULL, MPEXPR_TYPE_CLOSEPAREN, 4 },
{ "(", NULL, MPEXPR_TYPE_OPENPAREN, 3 },
{ ",", NULL, MPEXPR_TYPE_ARGSEP, 2 },
{ "$", NULL, MPEXPR_TYPE_VARIABLE, 1 },
{ "abs", (mpexpr_fun_t) mpz_abs, MPEXPR_TYPE_UNARY },
{ "bin", (mpexpr_fun_t) mpz_bin_ui, MPEXPR_TYPE_BINARY_UI },
{ "clrbit", (mpexpr_fun_t) e_mpz_clrbit, MPEXPR_TYPE_BINARY_UI },
{ "cmp", (mpexpr_fun_t) mpz_cmp, MPEXPR_TYPE_I_BINARY },
{ "cmpabs", (mpexpr_fun_t) mpz_cmpabs, MPEXPR_TYPE_I_BINARY },
{ "congruent_p",(mpexpr_fun_t)mpz_congruent_p, MPEXPR_TYPE_I_TERNARY },
{ "divisible_p",(mpexpr_fun_t)mpz_divisible_p, MPEXPR_TYPE_I_BINARY },
{ "even_p", (mpexpr_fun_t) e_mpz_even_p, MPEXPR_TYPE_I_UNARY },
{ "fib", (mpexpr_fun_t) mpz_fib_ui, MPEXPR_TYPE_UNARY_UI },
{ "fac", (mpexpr_fun_t) mpz_fac_ui, MPEXPR_TYPE_UNARY_UI },
{ "gcd", (mpexpr_fun_t) mpz_gcd, MPEXPR_TYPE_BINARY
| MPEXPR_TYPE_PAIRWISE },
{ "hamdist", (mpexpr_fun_t) e_mpz_hamdist, MPEXPR_TYPE_BINARY },
{ "invert", (mpexpr_fun_t) mpz_invert, MPEXPR_TYPE_BINARY },
{ "jacobi", (mpexpr_fun_t) mpz_jacobi, MPEXPR_TYPE_I_BINARY },
{ "kronecker", (mpexpr_fun_t) mpz_kronecker, MPEXPR_TYPE_I_BINARY },
{ "lcm", (mpexpr_fun_t) mpz_lcm, MPEXPR_TYPE_BINARY
| MPEXPR_TYPE_PAIRWISE },
{ "lucnum", (mpexpr_fun_t) mpz_lucnum_ui, MPEXPR_TYPE_UNARY_UI },
{ "max", (mpexpr_fun_t) mpz_cmp, MPEXPR_TYPE_MAX
| MPEXPR_TYPE_PAIRWISE },
{ "min", (mpexpr_fun_t) mpz_cmp, MPEXPR_TYPE_MIN
| MPEXPR_TYPE_PAIRWISE },
{ "nextprime", (mpexpr_fun_t) mpz_nextprime, MPEXPR_TYPE_UNARY },
{ "odd_p", (mpexpr_fun_t) e_mpz_odd_p, MPEXPR_TYPE_I_UNARY },
{ "perfect_power_p", (mpexpr_fun_t)mpz_perfect_power_p, MPEXPR_TYPE_I_UNARY},
{ "perfect_square_p",(mpexpr_fun_t)mpz_perfect_square_p,MPEXPR_TYPE_I_UNARY},
{ "popcount", (mpexpr_fun_t) e_mpz_popcount, MPEXPR_TYPE_UNARY },
{ "powm", (mpexpr_fun_t) mpz_powm, MPEXPR_TYPE_TERNARY },
{ "probab_prime_p", (mpexpr_fun_t)mpz_probab_prime_p, MPEXPR_TYPE_I_UNARY},
{ "root", (mpexpr_fun_t) mpz_root, MPEXPR_TYPE_BINARY_UI },
{ "scan0", (mpexpr_fun_t) e_mpz_scan0, MPEXPR_TYPE_BINARY_UI },
{ "scan1", (mpexpr_fun_t) e_mpz_scan1, MPEXPR_TYPE_BINARY_UI },
{ "setbit", (mpexpr_fun_t) e_mpz_setbit, MPEXPR_TYPE_BINARY_UI },
{ "tstbit", (mpexpr_fun_t) mpz_tstbit, MPEXPR_TYPE_I_BINARY_UI },
{ "sgn", (mpexpr_fun_t) e_mpz_sgn, MPEXPR_TYPE_I_UNARY },
{ "sqrt", (mpexpr_fun_t) mpz_sqrt, MPEXPR_TYPE_UNARY },
{ NULL }
};
/* The table is available globally only through a pointer, so the table size
can change without breaking binary compatibility. */
const struct mpexpr_operator_t * const mpz_expr_standard_table
= _mpz_expr_standard_table;
int
mpz_expr (mpz_ptr res, int base, const char *e, ...)
{
mpz_srcptr var[MPEXPR_VARIABLES];
va_list ap;
int ret;
va_start (ap, e);
TRACE (printf ("mpz_expr(): base %d, %s\n", base, e));
ret = mpexpr_va_to_var ((void **) var, ap);
va_end (ap);
if (ret != MPEXPR_RESULT_OK)
return ret;
return mpz_expr_a (mpz_expr_standard_table, res, base, e, strlen(e), var);
}

View File

@@ -0,0 +1,108 @@
/* mpz expression evaluation
Copyright 2000-2002, 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include "gmp.h"
#include "expr-impl.h"
/* No need to parse '-' since that's handled as an operator.
This function also by mpq_expr_a, so it's not static. */
size_t
mpexpr_mpz_number (mpz_ptr res, const char *e, size_t elen, int base)
{
char *edup;
size_t i, ret;
int base_effective = (base == 0 ? 10 : base);
void *(*allocate_func) (size_t);
void (*free_func) (void *, size_t);
i = 0;
if (e[i] == '0')
{
i++;
if (e[i] == 'x' || e[i] == 'b')
i++;
}
for ( ; i < elen; i++)
if (! isasciidigit_in_base (e[i], base_effective))
break;
mp_get_memory_functions (&allocate_func, NULL, &free_func);
edup = (*allocate_func) (i+1);
memcpy (edup, e, i);
edup[i] = '\0';
if (mpz_set_str (res, edup, base) == 0)
ret = i;
else
ret = 0;
(*free_func) (edup, i+1);
return ret;
}
/* ignoring prec */
static void
e_mpz_init (mpz_ptr z, unsigned long prec)
{
mpz_init (z);
}
int
mpz_expr_a (const struct mpexpr_operator_t *table,
mpz_ptr res, int base,
const char *e, size_t elen,
mpz_srcptr var[26])
{
struct mpexpr_parse_t p;
p.table = table;
p.res = (mpX_ptr) res;
p.base = base;
p.e = e;
p.elen = elen;
p.var = (mpX_srcptr *) var;
p.mpX_clear = (mpexpr_fun_one_t) mpz_clear;
p.mpX_ulong_p = (mpexpr_fun_i_unary_t) mpz_fits_ulong_p;
p.mpX_get_ui = (mpexpr_fun_get_ui_t) mpz_get_ui;
p.mpX_init = (mpexpr_fun_unary_ui_t) e_mpz_init;
p.mpX_number = (mpexpr_fun_number_t) mpexpr_mpz_number;
p.mpX_set = (mpexpr_fun_unary_t) mpz_set;
p.mpX_set_or_swap = (mpexpr_fun_unary_t) mpz_swap;
p.mpX_set_si = (mpexpr_fun_set_si_t) mpz_set_si;
p.mpX_swap = (mpexpr_fun_swap_t) mpz_swap;
return mpexpr_evaluate (&p);
}

View File

@@ -0,0 +1,242 @@
/* Demo program to run expression evaluation.
Copyright 2000-2002, 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
/* Usage: ./run-expr [-z] [-q] [-f] [-p prec] [-b base] expression...
Evaluate each argument as a simple expression. By default this is in mpz
integers, but -q selects mpq or -f selects mpf. For mpf the float
precision can be set with -p. In all cases the input base can be set
with -b, or the default is "0" meaning decimal with "0x" allowed.
This is a pretty trivial program, it's just an easy way to experiment
with the evaluation functions. */
#include <stdio.h>
#include <stdlib.h>
#include "gmp.h"
#include "expr.h"
void
run_expr (int type, int base, unsigned long prec, char *str)
{
int outbase = (base == 0 ? 10 : base);
int ret;
switch (type) {
case 'z':
default:
{
mpz_t res, var_a, var_b;
mpz_init (res);
mpz_init_set_ui (var_a, 55L);
mpz_init_set_ui (var_b, 99L);
ret = mpz_expr (res, base, str, var_a, var_b, NULL);
printf ("\"%s\" base %d: ", str, base);
if (ret == MPEXPR_RESULT_OK)
{
printf ("result ");
mpz_out_str (stdout, outbase, res);
printf ("\n");
}
else
printf ("invalid (return code %d)\n", ret);
mpz_clear (res);
mpz_clear (var_a);
mpz_clear (var_b);
}
break;
case 'q':
{
mpq_t res, var_a, var_b;
mpq_init (res);
mpq_init (var_a);
mpq_init (var_b);
mpq_set_ui (var_a, 55L, 1);
mpq_set_ui (var_b, 99L, 1);
ret = mpq_expr (res, base, str, var_a, var_b, NULL);
printf ("\"%s\" base %d: ", str, base);
if (ret == MPEXPR_RESULT_OK)
{
printf ("result ");
mpq_out_str (stdout, outbase, res);
printf ("\n");
}
else
printf ("invalid (return code %d)\n", ret);
mpq_clear (res);
mpq_clear (var_a);
mpq_clear (var_b);
}
break;
case 'f':
{
mpf_t res, var_a, var_b;
mpf_init2 (res, prec);
mpf_init_set_ui (var_a, 55L);
mpf_init_set_ui (var_b, 99L);
ret = mpf_expr (res, base, str, var_a, var_b, NULL);
printf ("\"%s\" base %d: ", str, base);
if (ret == MPEXPR_RESULT_OK)
{
printf ("result ");
mpf_out_str (stdout, outbase, (size_t) 0, res);
printf ("\n");
}
else
printf ("invalid (return code %d)\n", ret);
mpf_clear (res);
mpf_clear (var_a);
mpf_clear (var_b);
}
break;
}
}
int
main (int argc, char *argv[])
{
int type = 'z';
int base = 0;
unsigned long prec = 64;
int seen_expr = 0;
int opt;
char *arg;
for (;;)
{
argv++;
arg = argv[0];
if (arg == NULL)
break;
if (arg[0] == '-')
{
for (;;)
{
arg++;
opt = arg[0];
switch (opt) {
case '\0':
goto end_opt;
case 'f':
case 'q':
case 'z':
type = opt;
break;
case 'b':
arg++;
if (arg[0] == '\0')
{
argv++;
arg = argv[0];
if (arg == NULL)
{
need_arg:
fprintf (stderr, "Need argument for -%c\n", opt);
exit (1);
}
}
base = atoi (arg);
goto end_opt;
case 'p':
arg++;
if (arg[0] == '\0')
{
argv++;
arg = argv[0];
if (arg == NULL)
goto need_arg;
}
prec = atoi (arg);
goto end_opt;
case '-':
arg++;
if (arg[0] != '\0')
{
/* no "--foo" options */
fprintf (stderr, "Unrecognised option --%s\n", arg);
exit (1);
}
/* stop option interpretation at "--" */
for (;;)
{
argv++;
arg = argv[0];
if (arg == NULL)
goto done;
run_expr (type, base, prec, arg);
seen_expr = 1;
}
default:
fprintf (stderr, "Unrecognised option -%c\n", opt);
exit (1);
}
}
end_opt:
;
}
else
{
run_expr (type, base, prec, arg);
seen_expr = 1;
}
}
done:
if (! seen_expr)
{
printf ("Usage: %s [-z] [-q] [-f] [-p prec] [-b base] expression...\n", argv[0]);
exit (1);
}
return 0;
}

View File

@@ -0,0 +1,510 @@
/* Test expression evaluation (print nothing and exit 0 if successful).
Copyright 2000-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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdio.h>
#include <stdlib.h>
#include "gmp-impl.h"
#include "tests.h"
#include "expr-impl.h"
int option_trace = 0;
struct data_t {
int base;
const char *expr;
const char *want;
};
#define numberof(x) (sizeof (x) / sizeof ((x)[0]))
/* These data_xxx[] arrays are tables to be tested with one or more of the
mp?_t types. z=mpz_t, q=mpz_t, f=mpf_t. */
struct data_t data_zqf[] = {
/* various deliberately wrong expressions */
{ 0, "", NULL },
{ 0, "1+", NULL },
{ 0, "+2", NULL },
{ 0, "1,2", NULL },
{ 0, "foo(1,2)", NULL },
{ 0, "1+foo", NULL },
{ 10, "0fff", NULL },
{ 0, "!", NULL },
{ 0, "10!", NULL },
{ 0, "-10!", NULL },
{ 0, "gcd((4,6))", NULL },
{ 0, "()", NULL },
{ 0, "fac(2**1000)", NULL },
{ 0, "$", NULL },
{ 0, "$-", NULL },
/* some basics */
{ 10, "123", "123" },
{ 10, "-123", "-123" },
{ 10, "1+2", "3" },
{ 10, "1+2+3", "6" },
{ 10, "1+2*3", "7" },
{ 10, "3*2+1", "7" },
{ 10, "$a", "55" },
{ 10, "b", "99" },
{ 16, "b", "11" },
{ 10, "4**3 * 2 + 1", "129" },
{ 10, "1<2", "1" },
{ 10, "1>2", "0" },
{ 10, "(123)", "123" },
{ 10, "sgn(-123)", "-1" },
{ 10, "5-7", "-2" },
{ 0, "cmp(0,0)", "0" },
{ 0, "cmp(1,0)", "1" },
{ 0, "cmp(0,1)", "-1" },
{ 0, "cmp(-1,0)", "-1" },
{ 0, "cmp(0,-1)", "1" },
{ 10, "0 ? 123 : 456", "456" },
{ 10, "1 ? 4+5 : 6+7", "9" },
{ 10, "(123)", "123" },
{ 10, "(2+3)", "5" },
{ 10, "(4+5)*(5+6)", "99" },
{ 0, "1 << 16", "65536" },
{ 0, "256 >> 4", "16" },
{ 0, "-256 >> 4", "-16" },
{ 0, "!1", "0" },
{ 0, "!9", "0" },
{ 0, "!0", "1" },
{ 0, "2**2**2", "16" },
{ 0, "-2**2**2", "-16" },
{ 0, "0x100", "256" },
{ 10, "0x100", NULL },
{ 10, "0x 100", NULL },
{ 0, " max ( 1, 2, 3, 4, 5, 6, 7, 8)", "8" },
{ 0, " max ( 1, 9, 2, 3, 4, 5, 6, 7, 8)", "9" },
{ 0, " min ( 1, 9, 2, 3, 4, 5, 6, 7, 8)", "1" },
{ 10, "abs(123)", "123" },
{ 10, "abs(-123)", "123" },
{ 10, "abs(0)", "0" },
/* filling data stack */
{ 0, "1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+(1+1))))))))))))))", "16" },
/* filling control stack */
{ 0, "----------------------------------------------------1", "1" },
};
const struct data_t data_z[] = {
{ 0, "divisible_p(333,3)", "1" },
{ 0, "congruent_p(7,1,3)", "1" },
{ 0, "cmpabs(0,0)", "0" },
{ 0, "cmpabs(1,0)", "1" },
{ 0, "cmpabs(0,1)", "-1" },
{ 0, "cmpabs(-1,0)", "1" },
{ 0, "cmpabs(0,-1)", "-1" },
{ 0, "odd_p(1)", "1" },
{ 0, "odd_p(0)", "0" },
{ 0, "odd_p(-1)", "1" },
{ 0, "even_p(1)", "0" },
{ 0, "even_p(0)", "1" },
{ 0, "even_p(-1)", "0" },
{ 0, "fac(0)", "1" },
{ 0, "fac(1)", "1" },
{ 0, "fac(2)", "2" },
{ 0, "fac(3)", "6" },
{ 0, "fac(10)", "3628800" },
{ 10, "root(81,4)", "3" },
{ 10, "gcd(4,6)", "2" },
{ 10, "gcd(4,6,9)", "1" },
{ 10, "powm(3,2,9)", "0" },
{ 10, "powm(3,2,8)", "1" },
/* filling data stack */
{ 0, "1 ? 1 : 1 || 1 && 1 | 1 ^ 1 & 1 == 1 >= 1 << 1 - 1 * 1 ** 1", "1" },
/* filling control stack */
{ 0, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1", "1" },
{ 0, "fib(10)", "55" },
{ 0, "setbit(0,5)", "32" },
{ 0, "clrbit(32,5)", "0" },
{ 0, "tstbit(32,5)", "1" },
{ 0, "tstbit(32,4)", "0" },
{ 0, "scan0(7,0)", "3" },
{ 0, "scan1(7,0)", "0" },
};
const struct data_t data_zq[] = {
/* expecting failure */
{ 0, "1.2", NULL },
};
const struct data_t data_q[] = {
{ 10, "(1/2 + 1/3 + 1/4 + 1/5 + 1/6)*20", "29" },
{ 0, "num(5/9)", "5" },
{ 0, "den(5/9)", "9" },
};
const struct data_t data_zf[] = {
{ 10, "sqrt ( 49 )", "7" },
{ 10, "sqrt ( 49 ) + 1", "8" },
{ 10, "sqrt((49))", "7" },
{ 10, "sqrt((((((((49))))))))", "7" },
};
const struct data_t data_f[] = {
{ 0, "1@10", "10000000000" },
{ 0, "1.5@10", "15000000000" },
{ 0, "1000@-1", "100" },
{ 0, "10.00@-1", "1" },
{ 0, "1e10", "10000000000" },
{ 0, "1.5e10", "15000000000" },
{ 0, "1000e-1", "100" },
{ 0, "10.00e-1", "1" },
{ 16, "1@9", "68719476736" },
{ 16, "1@10", "18446744073709551616" },
{ -16, "1@10", "1099511627776" },
{ 0, "ceil(0)", "0" },
{ 0, "ceil(0.25)", "1" },
{ 0, "ceil(0.5)", "1" },
{ 0, "ceil(1.5)", "2" },
{ 0, "ceil(-0.5)", "0" },
{ 0, "ceil(-1.5)", "-1" },
/* only simple cases because mpf_eq currently only works on whole limbs */
{ 0, "eq(0xFFFFFFFFFFFFFFFF1111111111111111,0xFFFFFFFFFFFFFFFF2222222222222222,64)", "1" },
{ 0, "eq(0xFFFFFFFFFFFFFFFF1111111111111111,0xFFFFFFFFFFFFFFFF2222222222222222,128)", "0" },
{ 0, "floor(0)", "0" },
{ 0, "floor(0.25)", "0" },
{ 0, "floor(0.5)", "0" },
{ 0, "floor(1.5)", "1" },
{ 0, "floor(-0.5)", "-1" },
{ 0, "floor(-1.5)", "-2" },
{ 0, "integer_p(1)", "1" },
{ 0, "integer_p(0.5)", "0" },
{ 0, "trunc(0)", "0" },
{ 0, "trunc(0.25)", "0" },
{ 0, "trunc(0.5)", "0" },
{ 0, "trunc(1.5)", "1" },
{ 0, "trunc(-0.5)", "0" },
{ 0, "trunc(-1.5)", "-1" },
};
struct datalist_t {
const struct data_t *data;
int num;
};
#define DATALIST(data) { data, numberof (data) }
struct datalist_t list_z[] = {
DATALIST (data_z),
DATALIST (data_zq),
DATALIST (data_zf),
DATALIST (data_zqf),
};
struct datalist_t list_q[] = {
DATALIST (data_q),
DATALIST (data_zq),
DATALIST (data_zqf),
};
struct datalist_t list_f[] = {
DATALIST (data_zf),
DATALIST (data_zqf),
DATALIST (data_f),
};
void
check_z (void)
{
const struct data_t *data;
mpz_t a, b, got, want;
int l, i, ret;
mpz_init (got);
mpz_init (want);
mpz_init_set_ui (a, 55);
mpz_init_set_ui (b, 99);
for (l = 0; l < numberof (list_z); l++)
{
data = list_z[l].data;
for (i = 0; i < list_z[l].num; i++)
{
if (option_trace)
printf ("mpz_expr \"%s\"\n", data[i].expr);
ret = mpz_expr (got, data[i].base, data[i].expr, a, b, NULL);
if (data[i].want == NULL)
{
/* expect to fail */
if (ret == MPEXPR_RESULT_OK)
{
printf ("mpz_expr wrong return value, got %d, expected failure\n", ret);
goto error;
}
}
else
{
if (mpz_set_str (want, data[i].want, 0) != 0)
{
printf ("Cannot parse wanted value string\n");
goto error;
}
if (ret != MPEXPR_RESULT_OK)
{
printf ("mpz_expr failed unexpectedly\n");
printf (" return value %d\n", ret);
goto error;
}
if (mpz_cmp (got, want) != 0)
{
printf ("mpz_expr wrong result\n");
printf (" got "); mpz_out_str (stdout, 10, got);
printf ("\n");
printf (" want "); mpz_out_str (stdout, 10, want);
printf ("\n");
goto error;
}
}
}
}
mpz_clear (a);
mpz_clear (b);
mpz_clear (got);
mpz_clear (want);
return;
error:
printf (" base %d\n", data[i].base);
printf (" expr \"%s\"\n", data[i].expr);
if (data[i].want != NULL)
printf (" want \"%s\"\n", data[i].want);
abort ();
}
void
check_q (void)
{
const struct data_t *data;
mpq_t a, b, got, want;
int l, i, ret;
mpq_init (got);
mpq_init (want);
mpq_init (a);
mpq_init (b);
mpq_set_ui (a, 55, 1);
mpq_set_ui (b, 99, 1);
for (l = 0; l < numberof (list_q); l++)
{
data = list_q[l].data;
for (i = 0; i < list_q[l].num; i++)
{
if (option_trace)
printf ("mpq_expr \"%s\"\n", data[i].expr);
ret = mpq_expr (got, data[i].base, data[i].expr, a, b, NULL);
if (data[i].want == NULL)
{
/* expect to fail */
if (ret == MPEXPR_RESULT_OK)
{
printf ("mpq_expr wrong return value, got %d, expected failure\n", ret);
goto error;
}
}
else
{
if (mpz_set_str (mpq_numref(want), data[i].want, 0) != 0)
{
printf ("Cannot parse wanted value string\n");
goto error;
}
mpz_set_ui (mpq_denref(want), 1);
if (ret != MPEXPR_RESULT_OK)
{
printf ("mpq_expr failed unexpectedly\n");
printf (" return value %d\n", ret);
goto error;
}
if (mpq_cmp (got, want) != 0)
{
printf ("mpq_expr wrong result\n");
printf (" got "); mpq_out_str (stdout, 10, got);
printf ("\n");
printf (" want "); mpq_out_str (stdout, 10, want);
printf ("\n");
goto error;
}
}
}
}
mpq_clear (a);
mpq_clear (b);
mpq_clear (got);
mpq_clear (want);
return;
error:
printf (" base %d\n", data[i].base);
printf (" expr \"%s\"\n", data[i].expr);
if (data[i].want != NULL)
printf (" want \"%s\"\n", data[i].want);
abort ();
}
void
check_f (void)
{
const struct data_t *data;
mpf_t a, b, got, want;
int l, i, ret;
mpf_set_default_prec (200L);
mpf_init (got);
mpf_init (want);
mpf_init_set_ui (a, 55);
mpf_init_set_ui (b, 99);
for (l = 0; l < numberof (list_f); l++)
{
data = list_f[l].data;
for (i = 0; i < list_f[l].num; i++)
{
if (option_trace)
printf ("mpf_expr \"%s\"\n", data[i].expr);
ret = mpf_expr (got, data[i].base, data[i].expr, a, b, NULL);
if (data[i].want == NULL)
{
/* expect to fail */
if (ret == MPEXPR_RESULT_OK)
{
printf ("mpf_expr wrong return value, got %d, expected failure\n", ret);
goto error;
}
}
else
{
if (mpf_set_str (want, data[i].want, 0) != 0)
{
printf ("Cannot parse wanted value string\n");
goto error;
}
if (ret != MPEXPR_RESULT_OK)
{
printf ("mpf_expr failed unexpectedly\n");
printf (" return value %d\n", ret);
goto error;
}
if (mpf_cmp (got, want) != 0)
{
printf ("mpf_expr wrong result\n");
printf (" got "); mpf_out_str (stdout, 10, 20, got);
printf ("\n");
printf (" want "); mpf_out_str (stdout, 10, 20, want);
printf ("\n");
goto error;
}
}
}
}
mpf_clear (a);
mpf_clear (b);
mpf_clear (got);
mpf_clear (want);
return;
error:
printf (" base %d\n", data[i].base);
printf (" expr \"%s\"\n", data[i].expr);
if (data[i].want != NULL)
printf (" want \"%s\"\n", data[i].want);
abort ();
}
int
main (int argc, char *argv[])
{
tests_start ();
if (argc >= 2)
option_trace = 1;
check_z ();
check_q ();
check_f ();
tests_end ();
exit (0);
}

View File

@@ -0,0 +1,447 @@
/* Factoring with Pollard's rho method.
Copyright 1995, 1997-2003, 2005, 2009, 2012, 2015 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see https://www.gnu.org/licenses/. */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include "gmp.h"
static unsigned char primes_diff[] = {
#define P(a,b,c) a,
#include "primes.h"
#undef P
};
#define PRIMES_PTAB_ENTRIES (sizeof(primes_diff) / sizeof(primes_diff[0]))
int flag_verbose = 0;
/* Prove primality or run probabilistic tests. */
int flag_prove_primality = 1;
/* Number of Miller-Rabin tests to run when not proving primality. */
#define MR_REPS 25
struct factors
{
mpz_t *p;
unsigned long *e;
long nfactors;
};
void factor (mpz_t, struct factors *);
void
factor_init (struct factors *factors)
{
factors->p = malloc (1);
factors->e = malloc (1);
factors->nfactors = 0;
}
void
factor_clear (struct factors *factors)
{
int i;
for (i = 0; i < factors->nfactors; i++)
mpz_clear (factors->p[i]);
free (factors->p);
free (factors->e);
}
void
factor_insert (struct factors *factors, mpz_t prime)
{
long nfactors = factors->nfactors;
mpz_t *p = factors->p;
unsigned long *e = factors->e;
long i, j;
/* Locate position for insert new or increment e. */
for (i = nfactors - 1; i >= 0; i--)
{
if (mpz_cmp (p[i], prime) <= 0)
break;
}
if (i < 0 || mpz_cmp (p[i], prime) != 0)
{
p = realloc (p, (nfactors + 1) * sizeof p[0]);
e = realloc (e, (nfactors + 1) * sizeof e[0]);
mpz_init (p[nfactors]);
for (j = nfactors - 1; j > i; j--)
{
mpz_set (p[j + 1], p[j]);
e[j + 1] = e[j];
}
mpz_set (p[i + 1], prime);
e[i + 1] = 1;
factors->p = p;
factors->e = e;
factors->nfactors = nfactors + 1;
}
else
{
e[i] += 1;
}
}
void
factor_insert_ui (struct factors *factors, unsigned long prime)
{
mpz_t pz;
mpz_init_set_ui (pz, prime);
factor_insert (factors, pz);
mpz_clear (pz);
}
void
factor_using_division (mpz_t t, struct factors *factors)
{
mpz_t q;
unsigned long int p;
int i;
if (flag_verbose > 0)
{
printf ("[trial division] ");
}
mpz_init (q);
p = mpz_scan1 (t, 0);
mpz_fdiv_q_2exp (t, t, p);
while (p)
{
factor_insert_ui (factors, 2);
--p;
}
p = 3;
for (i = 1; i <= PRIMES_PTAB_ENTRIES;)
{
if (! mpz_divisible_ui_p (t, p))
{
p += primes_diff[i++];
if (mpz_cmp_ui (t, p * p) < 0)
break;
}
else
{
mpz_tdiv_q_ui (t, t, p);
factor_insert_ui (factors, p);
}
}
mpz_clear (q);
}
static int
mp_millerrabin (mpz_srcptr n, mpz_srcptr nm1, mpz_ptr x, mpz_ptr y,
mpz_srcptr q, unsigned long int k)
{
unsigned long int i;
mpz_powm (y, x, q, n);
if (mpz_cmp_ui (y, 1) == 0 || mpz_cmp (y, nm1) == 0)
return 1;
for (i = 1; i < k; i++)
{
mpz_powm_ui (y, y, 2, n);
if (mpz_cmp (y, nm1) == 0)
return 1;
if (mpz_cmp_ui (y, 1) == 0)
return 0;
}
return 0;
}
int
mp_prime_p (mpz_t n)
{
int k, r, is_prime;
mpz_t q, a, nm1, tmp;
struct factors factors;
if (mpz_cmp_ui (n, 1) <= 0)
return 0;
/* We have already casted out small primes. */
if (mpz_cmp_ui (n, (long) FIRST_OMITTED_PRIME * FIRST_OMITTED_PRIME) < 0)
return 1;
mpz_inits (q, a, nm1, tmp, NULL);
/* Precomputation for Miller-Rabin. */
mpz_sub_ui (nm1, n, 1);
/* Find q and k, where q is odd and n = 1 + 2**k * q. */
k = mpz_scan1 (nm1, 0);
mpz_tdiv_q_2exp (q, nm1, k);
mpz_set_ui (a, 2);
/* Perform a Miller-Rabin test, finds most composites quickly. */
if (!mp_millerrabin (n, nm1, a, tmp, q, k))
{
is_prime = 0;
goto ret2;
}
if (flag_prove_primality)
{
/* Factor n-1 for Lucas. */
mpz_set (tmp, nm1);
factor (tmp, &factors);
}
/* Loop until Lucas proves our number prime, or Miller-Rabin proves our
number composite. */
for (r = 0; r < PRIMES_PTAB_ENTRIES; r++)
{
int i;
if (flag_prove_primality)
{
is_prime = 1;
for (i = 0; i < factors.nfactors && is_prime; i++)
{
mpz_divexact (tmp, nm1, factors.p[i]);
mpz_powm (tmp, a, tmp, n);
is_prime = mpz_cmp_ui (tmp, 1) != 0;
}
}
else
{
/* After enough Miller-Rabin runs, be content. */
is_prime = (r == MR_REPS - 1);
}
if (is_prime)
goto ret1;
mpz_add_ui (a, a, primes_diff[r]); /* Establish new base. */
if (!mp_millerrabin (n, nm1, a, tmp, q, k))
{
is_prime = 0;
goto ret1;
}
}
fprintf (stderr, "Lucas prime test failure. This should not happen\n");
abort ();
ret1:
if (flag_prove_primality)
factor_clear (&factors);
ret2:
mpz_clears (q, a, nm1, tmp, NULL);
return is_prime;
}
void
factor_using_pollard_rho (mpz_t n, unsigned long a, struct factors *factors)
{
mpz_t x, z, y, P;
mpz_t t, t2;
unsigned long long k, l, i;
if (flag_verbose > 0)
{
printf ("[pollard-rho (%lu)] ", a);
}
mpz_inits (t, t2, NULL);
mpz_init_set_si (y, 2);
mpz_init_set_si (x, 2);
mpz_init_set_si (z, 2);
mpz_init_set_ui (P, 1);
k = 1;
l = 1;
while (mpz_cmp_ui (n, 1) != 0)
{
for (;;)
{
do
{
mpz_mul (t, x, x);
mpz_mod (x, t, n);
mpz_add_ui (x, x, a);
mpz_sub (t, z, x);
mpz_mul (t2, P, t);
mpz_mod (P, t2, n);
if (k % 32 == 1)
{
mpz_gcd (t, P, n);
if (mpz_cmp_ui (t, 1) != 0)
goto factor_found;
mpz_set (y, x);
}
}
while (--k != 0);
mpz_set (z, x);
k = l;
l = 2 * l;
for (i = 0; i < k; i++)
{
mpz_mul (t, x, x);
mpz_mod (x, t, n);
mpz_add_ui (x, x, a);
}
mpz_set (y, x);
}
factor_found:
do
{
mpz_mul (t, y, y);
mpz_mod (y, t, n);
mpz_add_ui (y, y, a);
mpz_sub (t, z, y);
mpz_gcd (t, t, n);
}
while (mpz_cmp_ui (t, 1) == 0);
mpz_divexact (n, n, t); /* divide by t, before t is overwritten */
if (!mp_prime_p (t))
{
if (flag_verbose > 0)
{
printf ("[composite factor--restarting pollard-rho] ");
}
factor_using_pollard_rho (t, a + 1, factors);
}
else
{
factor_insert (factors, t);
}
if (mp_prime_p (n))
{
factor_insert (factors, n);
break;
}
mpz_mod (x, x, n);
mpz_mod (z, z, n);
mpz_mod (y, y, n);
}
mpz_clears (P, t2, t, z, x, y, NULL);
}
void
factor (mpz_t t, struct factors *factors)
{
factor_init (factors);
if (mpz_sgn (t) != 0)
{
factor_using_division (t, factors);
if (mpz_cmp_ui (t, 1) != 0)
{
if (flag_verbose > 0)
{
printf ("[is number prime?] ");
}
if (mp_prime_p (t))
factor_insert (factors, t);
else
factor_using_pollard_rho (t, 1, factors);
}
}
}
int
main (int argc, char *argv[])
{
mpz_t t;
int i, j, k;
struct factors factors;
while (argc > 1)
{
if (!strcmp (argv[1], "-v"))
flag_verbose = 1;
else if (!strcmp (argv[1], "-w"))
flag_prove_primality = 0;
else
break;
argv++;
argc--;
}
mpz_init (t);
if (argc > 1)
{
for (i = 1; i < argc; i++)
{
mpz_set_str (t, argv[i], 0);
gmp_printf ("%Zd:", t);
factor (t, &factors);
for (j = 0; j < factors.nfactors; j++)
for (k = 0; k < factors.e[j]; k++)
gmp_printf (" %Zd", factors.p[j]);
puts ("");
factor_clear (&factors);
}
}
else
{
for (;;)
{
mpz_inp_str (t, stdin, 0);
if (feof (stdin))
break;
gmp_printf ("%Zd:", t);
factor (t, &factors);
for (j = 0; j < factors.nfactors; j++)
for (k = 0; k < factors.e[j]; k++)
gmp_printf (" %Zd", factors.p[j]);
puts ("");
factor_clear (&factors);
}
}
exit (0);
}

View File

@@ -0,0 +1,69 @@
/* Classify numbers as probable primes, primes or composites.
With -q return true if the following argument is a (probable) prime.
Copyright 1999, 2000, 2002, 2005, 2012 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see https://www.gnu.org/licenses/. */
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "gmp.h"
char *progname;
void
print_usage_and_exit ()
{
fprintf (stderr, "usage: %s -q nnn\n", progname);
fprintf (stderr, "usage: %s nnn ...\n", progname);
exit (-1);
}
int
main (int argc, char **argv)
{
mpz_t n;
int i;
progname = argv[0];
if (argc < 2)
print_usage_and_exit ();
mpz_init (n);
if (argc == 3 && strcmp (argv[1], "-q") == 0)
{
if (mpz_set_str (n, argv[2], 0) != 0)
print_usage_and_exit ();
exit (mpz_probab_prime_p (n, 25) == 0);
}
for (i = 1; i < argc; i++)
{
int class;
if (mpz_set_str (n, argv[i], 0) != 0)
print_usage_and_exit ();
class = mpz_probab_prime_p (n, 25);
mpz_out_str (stdout, 10, n);
if (class == 0)
puts (" is composite");
else if (class == 1)
puts (" is a probable prime");
else /* class == 2 */
puts (" is a prime");
}
exit (0);
}

View File

@@ -0,0 +1,671 @@
# GMP perl module
# Copyright 2001-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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
# [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.
package GMP;
require Symbol;
require Exporter;
require DynaLoader;
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw();
@EXPORT_OK = qw(version);
%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 = '2.00';
bootstrap GMP $VERSION;
# The format string is cut up into "%" specifiers so GMP types can be
# passed to GMP::sprintf_internal. Any "*"s are interpolated before
# calling sprintf_internal, which saves worrying about variable
# argument lists there.
#
# Because sprintf_internal is only called after the conversion and
# operand have been checked there won't be any crashes from a bad
# format string.
#
sub sprintf {
my $fmt = shift;
my $out = '';
my ($pre, $dummy, $pat, $rest);
while (($pre, $dummy, $pat, $rest) = ($fmt =~ /^((%%|[^%])*)(%[- +#.*hlLqv\d]*[bcdfeEgGinopsuxX])(.*)$/s)) {
$out .= $pre;
my $pat2 = $pat; # $pat with "*"s expanded
my @params = (); # arguments per "*"s
while ($pat2 =~ /[*]/) {
my $arg = shift;
$pat2 =~ s/[*]/$arg/;
push @params, $arg;
}
if (UNIVERSAL::isa($_[0],"GMP::Mpz")) {
if ($pat2 !~ /[dioxX]$/) {
die "GMP::sprintf: unsupported output format for mpz: $pat2\n";
}
$pat2 =~ s/(.)$/Z$1/;
$out .= sprintf_internal ($pat2, shift);
} elsif (UNIVERSAL::isa($_[0],"GMP::Mpq")) {
if ($pat2 !~ /[dioxX]$/) {
die "GMP::sprintf: unsupported output format for mpq: $pat2\n";
}
$pat2 =~ s/(.)$/Q$1/;
$out .= sprintf_internal ($pat2, shift);
} elsif (UNIVERSAL::isa($_[0],"GMP::Mpf")) {
if ($pat2 !~ /[eEfgG]$/) {
die "GMP::sprintf: unsupported output format for mpf: $pat2\n";
}
$pat2 =~ s/(.)$/F$1/;
$out .= sprintf_internal ($pat2, shift);
} elsif ($pat =~ /n$/) {
# do it this way so h, l or V type modifiers are respected, and use a
# dummy variable to avoid a warning about discarding the value
my $dummy = sprintf "%s$pat", $out, $_[0];
shift;
} else {
$out .= sprintf $pat, @params, shift;
}
$fmt = $rest;
}
$out .= $fmt;
return $out;
}
sub printf {
if (ref($_[0]) eq 'GLOB') {
my $h = Symbol::qualify_to_ref(shift, caller);
print $h GMP::sprintf(@_);
} else {
print STDOUT GMP::sprintf(@_);
}
}
1;
__END__
=head1 NAME
GMP - Perl interface to the GNU Multiple Precision Arithmetic Library
=head1 SYNOPSIS
use GMP;
use GMP::Mpz;
use GMP::Mpq;
use GMP::Mpf;
use GMP::Rand;
=head1 DESCRIPTION
This module provides access to GNU MP arbitrary precision integers,
rationals and floating point.
No functions are exported from these packages by default, but can be
selected in the usual way, or the tag :all for everything.
use GMP::Mpz qw(gcd, lcm); # just these functions
use GMP::Mpq qw(:all); # everything in mpq
=head2 GMP::Mpz
This class provides arbitrary precision integers. A new mpz can be
constructed with C<mpz>. The initial value can be an integer, float,
string, mpz, mpq or mpf. Floats, mpq and mpf will be automatically
truncated to an integer.
use GMP::Mpz qw(:all);
my $a = mpz(123);
my $b = mpz("0xFFFF");
my $c = mpz(1.5); # truncated
The following overloaded operators are available, and corresponding
assignment forms like C<+=>,
=over 4
=item
+ - * / % E<lt>E<lt> E<gt>E<gt> ** & | ^ ! E<lt> E<lt>= == != E<gt> E<gt>=
E<lt>=E<gt> abs not sqrt
=back
C</> and C<%> round towards zero (as per the C<tdiv> functions in GMP).
The following functions are available, behaving the same as the
corresponding GMP mpz functions,
=over 4
=item
bin, cdiv, cdiv_2exp, clrbit, combit, 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
C<cdiv>, C<fdiv> and C<tdiv> and their C<2exp> variants return a
quotient/remainder pair. C<fib2> returns a pair F[n] and F[n-1], similarly
C<lucnum2>. C<gcd> and C<lcm> accept a variable number of arguments (one or
more). C<gcdext> returns a triplet of gcd and two cofactors, for example
use GMP::Mpz qw(:all);
$a = 7257;
$b = 10701;
($g, $x, $y) = gcdext ($a, $b);
print "gcd($a,$b) is $g, and $g == $a*$x + $b*$y\n";
C<mpz_import> and C<mpz_export> are so named to avoid the C<import> keyword.
Their parameters are as follows,
$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/multiplicity 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> and C<rootrem> return a root/remainder pair.
C<clrbit>, C<combit> 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
$a = mpz(6);
$b = $a;
setbit ($a, 0); # $a becomes 7, $b stays at 6
C<scan0> and C<scan1> return ~0 if no 0 or 1 bit respectively is found.
=head2 GMP::Mpq
This class provides rationals with arbitrary precision numerators and
denominators. A new mpq can be constructed with C<mpq>. The initial value
can be an integer, float, string, mpz, mpq or mpf, or a pair of integers or
mpz's. No precision is lost when converting a float or mpf, the exact value
is retained.
use GMP::Mpq qw(:all);
$a = mpq(); # zero
$b = mpq(0.5); # gives 1/2
$b = mpq(14); # integer 14
$b = mpq(3,4); # fraction 3/4
$b = mpq("7/12"); # fraction 7/12
$b = mpq("0xFF/0x100"); # fraction 255/256
When a fraction is given, it should be in the canonical form specified in
the GMP manual, which is denominator positive, no common factors, and zero
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 3
canonicalize($q); # get rid of it
The following overloaded operators are available, and corresponding
assignment forms like C<+=>,
=over 4
=item
+ - * / E<lt>E<lt> E<gt>E<gt> ** ! E<lt> E<lt>= == != E<gt> E<gt>=
E<lt>=E<gt> abs not
=back
The following functions are available,
=over 4
=item
den, inv, num
=back
C<inv> calculates 1/q, as per the corresponding GMP function. C<num> and
C<den> return an mpz copy of the numerator or denominator respectively. In
the future C<num> and C<den> might give lvalues so the original mpq can be
modified through them, but this is not done currently.
=head2 GMP::Mpf
This class provides arbitrary precision floating point numbers. The
mantissa is an arbitrary user-selected precision and the exponent is a fixed
size (one machine word).
A new mpf can be constructed with C<mpf>. The initial value can be an
integer, float, string, mpz, mpq or mpf. The second argument specifies the
desired precision in bits, or if omitted then the default precision is used.
use GMP::Mpf qw(:all);
$a = mpf(); # zero
$b = mpf(-7.5); # default precision
$c = mpf(1.5, 500); # 500 bits precision
$d = mpf("1.0000000000000001");
The following overloaded operators are available, with the corresponding
assignment forms like C<+=>,
=over 4
=item
+ - * / E<lt>E<lt> E<gt>E<gt> ** ! E<lt> E<lt>= == != E<gt> E<gt>=
E<lt>=E<gt> abs not sqrt
=back
The following functions are available, behaving the same as the
corresponding GMP mpf functions,
=over 4
=item
ceil, floor, get_default_prec, get_prec, mpf_eq, set_default_prec, set_prec,
trunc
=back
C<mpf_eq> is so named to avoid clashing with the perl C<eq> operator.
C<set_prec> expects a variable which it 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 mpf object then a new copy is made of it.
If the variable isn't an mpf it will be coerced to one.
Results are the same precision as inputs, or if two mpf's are given to a
binary operator then the precision of the first is used. For example,
use GMP::Mpf qw(mpf);
$a = mpf(2.0, 100);
$b = mpf(2.0, 500);
$c = $a + $b; # gives 100 bits precision
Mpf to string conversion via "" or the usual string contexts uses C<$#> the
same as normal float to string conversions, or defaults to C<%.g> if C<$#>
is not defined. C<%.g> means all significant digits in the selected
precision.
=head2 GMP class
The following functions are available in the GMP class,
=over 4
=item
fits_slong_p, get_d, get_d_2exp, get_si, get_str, integer_p, printf, sgn,
sprintf, version
=back
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, 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);
use GMP::Mpf qw(:all);
($s, $e) = get_str(111.111111111, 10, 4);
printf ".$se$e\n"; # .1111e3
($s, $e) = get_str(1.625, 10);
print "0.$s*10^$e\n"; # 0.1625*10^1
($s, $e) = get_str(mpf(2)**20, 16);
printf ".%s@%x\n", $s, $e; # .1@14
C<printf> and C<sprintf> allow formatted output of GMP types. mpz and mpq
values can be used with integer conversions (d, o, x, X) and mpf with float
conversions (f, e, E, g, G). All the standard perl printf features are
available too. For example,
use GMP::Mpz qw(mpz);
use GMP::Mpf qw(mpf);
GMP::printf ("%d %d %s", 123, mpz(2)**128, 'foo');
GMP::printf STDERR "%.40f", mpf(1.234);
In perl 5.6.1 it doesn't seem to work to export C<printf>, the plain builtin
C<printf> is reached unless calls are C<&printf()> style. Explicit use of
C<GMP::printf> is suggested. C<sprintf> doesn't suffer this problem.
use GMP qw(sprintf);
use GMP::Mpq qw(mpq);
$s = sprintf "%x", mpq(15,16);
C<version> is not exported by default or by tag :all, calling it as
C<GMP::version()> is recommended. It returns the GMP library version
string, which is not to be confused with the module version number.
The other GMP module functions behave as per the corresponding GMP routines,
and accept any integer, string, float, mpz, mpq or mpf. For example,
use GMP qw(:all);
use GMP::Mpz qw(mpz);
$z = mpz(123);
print sgn($z); # gives 1
Because each of GMP::Mpz, GMP::Mpq and GMP::Mpf is a sub-class of GMP,
C<-E<gt>> style calls work too.
use GMP qw(:all);
use GMP::Mpq qw(mpf);
$q = mpq(-5,7);
if ($q->integer_p()) # false
...
=head2 GMP::Rand
This class provides objects holding an algorithm and state for random number
generation. C<randstate> creates a new object, for example,
use GMP::Rand qw(randstate);
$r = randstate();
$r = randstate('lc_2exp_size', 64);
$r = randstate('lc_2exp', 43840821, 1, 32);
$r = randstate('mt');
$r = randstate($another_r);
With no parameters this corresponds to the C function
C<gmp_randinit_default>, and is a compromise between speed and randomness.
'lc_2exp_size' corresponds to C<gmp_randinit_lc_2exp_size>, 'lc_2exp'
corresponds to C<gmp_randinit_lc_2exp>, and 'mt' corresponds to
C<gmp_randinit_mt>. Or when passed another randstate object, a copy of that
object is made.
'lc_2exp_size' can fail if the requested size is bigger than the internal
table provides for, in which case undef is returned. The maximum size
currently supported is 128. The other forms always succeed.
A randstate can be seeded with an integer or mpz, using the C<seed> method.
/dev/random might be a good source of randomness, or time() or
Time::HiRes::time() might be adequate, depending on the application.
$r->seed(time()));
Random numbers can be generated with the following functions,
=over 4
=item
mpf_urandomb, mpz_rrandomb, mpz_urandomb, mpz_urandomm,
gmp_urandomb_ui, gmp_urandomm_ui
=back
Each constructs a new mpz or mpf and with a distribution per the
corresponding GMP function. For example,
use GMP::Rand (:all);
$r = randstate();
$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
$f = gmp_urandomm_ui($r,56); # uniform int, 0 to 55
=head2 Coercion
Arguments to operators and functions are converted as necessary to the
appropriate type. For instance C<**> requires an unsigned integer exponent,
and an mpq argument will be converted, so long as it's an integer in the
appropriate range.
use GMP::Mpz (mpz);
use GMP::Mpq (mpq);
$p = mpz(3) ** mpq(45); # allowed, 45 is an integer
It's an error if a conversion to an integer or mpz would cause any
truncation. For example,
use GMP::Mpz (mpz);
$p = mpz(3) + 1.25; # not allowed
$p = mpz(3) + mpz(1.25); # allowed, explicit truncation
Comparisons, however, accept any combination of operands and are always done
exactly. For example,
use GMP::Mpz (mpz);
print mpz(3) < 3.1; # true
Variables used on the left of an assignment operator like C<+=> are subject
to coercion too. An integer, float or string will change type when an mpz,
mpq or mpf is applied to it. For example,
use GMP::Mpz (mpz);
$a = 1;
$a += mpz(1234); # $a becomes an mpz
=head2 Overloading
The rule for binary operators in the C<overload> mechanism is that if both
operands are class objects then the method from the first is used. This
determines the result type when mixing GMP classes. For example,
use GMP::Mpz (mpz);
use GMP::Mpq (mpq);
use GMP::Mpf (mpf);
$z = mpz(123);
$q = mpq(3,2);
$f = mpf(1.375)
print $q+$f; # gives an mpq
print $f+$z; # gives an mpf
print $z+$f; # not allowed, would lose precision
=head2 Constants
A special tag C<:constants> is recognised in the module exports list. It
doesn't select any functions, but indicates that perl constants should be
GMP objects. This can only be used on one of GMP::Mpz, GMP::Mpq or GMP::Mpf
at any one time, since they apply different rules.
GMP::Mpz will treat constants as mpz's if they're integers, or ordinary
floats if not. For example,
use GMP::Mpz qw(:constants);
print 764861287634126387126378128,"\n"; # an mpz
print 1.25,"\n"; # a float
GMP::Mpq is similar, treating integers as mpq's and leaving floats to the
normal perl handling. Something like 3/4 is read as two integer mpq's and a
division, but that's fine since it gives the intended fraction.
use GMP::Mpq qw(:constants);
print 3/4,"\n"; # an mpq
print 1.25,"\n"; # a float
GMP::Mpf will treat all constants as mpf's using the default precision.
BEGIN blocks can be used to set that precision while the code is parsed.
For example,
use GMP::Mpf qw(:constants);
BEGIN { GMP::Mpf::set_default_prec(256); }
print 1/3;
BEGIN { GMP::Mpf::set_default_prec(64); }
print 5/7;
A similar special tag :noconstants is recognised to turn off the constants
feature. For example,
use GMP::Mpz qw(:constants);
print 438249738748174928193,"\n"; # an mpz
use GMP::Mpz qw(:noconstants);
print 438249738748174928193,"\n"; # now a float
All three 'integer', 'binary' and 'float' constant methods are captured.
'float' is captured even for GMP::Mpz and GMP::Mpq since perl by default
treats integer strings as floats if they don't fit a plain integer.
=head1 SEE ALSO
GMP manual, L<perl>, L<overload>.
=head1 BUGS
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
not for mpf).
These modules are not reentrant or thread safe, due to the implementation of
the XSUBs.
Returning a new object from the various functions is convenient, but
assignment versions could avoid creating new objects. Perhaps they could be
named after the C language functions, eg. mpq_inv($q,$q);
It'd be good if C<num> and C<den> gave lvalues so the underlying mpq could
be manipulated.
C<printf> could usefully accept %b for mpz, mpq and mpf, and perhaps %x for
mpf too.
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
In usual perl object style, an mpz is a reference to an object blessed into
class C<GMP::Mpz>. The object holds a pointer to the C language C<mpz_t>
structure. Similarly for mpq, mpf and randstate.
A free list of mpz and mpq values is kept to avoid repeated initializing and
clearing when objects are created and destroyed. This aims to help speed,
but it's not clear whether it's really needed.
mpf doesn't use a free list because the precision of new objects can be
different each time.
No interface to C<mpf_set_prec_raw> is provided. It wouldn't be very useful
since there's no way to make an operation store its result in a particular
object. The plain C<set_prec> is useful though, for truncating to a lower
precision, or as a sort of directive that subsequent calculations involving
that variable should use a higher precision.
The overheads of perl dynamic typing (operator dispatch, operand type
checking or coercion) will mean this interface is slower than using C
directly.
Some assertion checking is available as a compile-time option.
=head1 COPYRIGHT
Copyright 2001-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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/.
=cut
# Local variables:
# perl-indent-level: 2
# fill-column: 76
# End:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,106 @@
# GMP mpf module.
# Copyright 2001, 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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
package GMP::Mpf;
require GMP;
require Exporter;
@ISA = qw(GMP Exporter);
@EXPORT = qw();
@EXPORT_OK = qw();
%EXPORT_TAGS = ('all' => [qw(
ceil floor get_default_prec get_prec mpf mpf_eq
reldiff set_default_prec set_prec trunc)],
'constants' => [@EXPORT],
'noconstants' => [@EXPORT]);
Exporter::export_ok_tags('all');
use overload
'+' => \&overload_add, '+=' => \&overload_addeq,
'-' => \&overload_sub, '-=' => \&overload_subeq,
'*' => \&overload_mul, '*=' => \&overload_muleq,
'/' => \&overload_div, '/=' => \&overload_diveq,
'**' => \&overload_pow, '**=' => \&overload_poweq,
'<<' => \&overload_lshift, '<<=' => \&overload_lshifteq,
'>>' => \&overload_rshift, '>>=' => \&overload_rshifteq,
'bool' => \&overload_bool,
'not' => \&overload_not,
'!' => \&overload_not,
'<=>' => \&overload_spaceship,
'++' => \&overload_inc,
'--' => \&overload_dec,
'abs' => \&overload_abs,
'neg' => \&overload_neg,
'sqrt' => \&overload_sqrt,
'=' => \&overload_copy,
'""' => \&overload_string;
sub import {
foreach (@_) {
if ($_ eq ':constants') {
overload::constant ('integer' => \&overload_constant,
'binary' => \&overload_constant,
'float' => \&overload_constant);
} elsif ($_ eq ':noconstants') {
overload::remove_constant ('integer' => \&overload_constant,
'binary' => \&overload_constant,
'float' => \&overload_constant);
}
}
goto &Exporter::import;
}
sub overload_string {
my $fmt;
BEGIN { $^W = 0; }
if (defined ($#)) {
$fmt = $#;
BEGIN { $^W = 1; }
# protect against calling sprintf_internal with a bad format
if ($fmt !~ /^((%%|[^%])*%[-+ .\d]*)([eEfgG](%%|[^%])*)$/) {
die "GMP::Mpf: invalid \$# format: $#\n";
}
$fmt = $1 . 'F' . $3;
} else {
$fmt = '%.Fg';
}
GMP::sprintf_internal ($fmt, $_[0]);
}
1;
__END__
# Local variables:
# perl-indent-level: 2
# End:

View File

@@ -0,0 +1,89 @@
# GMP mpq module.
# Copyright 2001 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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
package GMP::Mpq;
require GMP;
require Exporter;
@ISA = qw(GMP Exporter);
@EXPORT = qw();
@EXPORT_OK = qw();
%EXPORT_TAGS = ('all' => [qw(canonicalize den inv mpq num)],
'constants' => [@EXPORT],
'noconstants' => [@EXPORT] );
Exporter::export_ok_tags('all');
use overload
'+' => \&overload_add, '+=' => \&overload_addeq,
'-' => \&overload_sub, '-=' => \&overload_subeq,
'*' => \&overload_mul, '*=' => \&overload_muleq,
'/' => \&overload_div, '/=' => \&overload_diveq,
'**' => \&overload_pow, '**=' => \&overload_poweq,
'<<' => \&overload_lshift, '<<=' => \&overload_lshifteq,
'>>' => \&overload_rshift, '>>=' => \&overload_rshifteq,
'bool' => \&overload_bool,
'not' => \&overload_not,
'!' => \&overload_not,
'==' => \&overload_eq,
'!=' => \&overload_ne,
'<=>' => \&overload_spaceship,
'++' => \&overload_inc,
'--' => \&overload_dec,
'abs' => \&overload_abs,
'neg' => \&overload_neg,
'=' => \&overload_copy,
'""' => \&overload_string;
my $constants = { };
sub import {
foreach (@_) {
if ($_ eq ':constants') {
overload::constant ('integer' => \&overload_constant,
'binary' => \&overload_constant,
'float' => \&overload_constant);
} elsif ($_ eq ':noconstants') {
overload::remove_constant ('integer' => \&overload_constant,
'binary' => \&overload_constant,
'float' => \&overload_constant);
}
}
goto &Exporter::import;
}
1;
__END__
# Local variables:
# perl-indent-level: 2
# End:

View File

@@ -0,0 +1,101 @@
# GMP mpz module.
# Copyright 2001-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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
package GMP::Mpz;
require GMP;
require Exporter;
@ISA = qw(GMP Exporter);
@EXPORT = qw();
@EXPORT_OK = qw();
%EXPORT_TAGS = ('all' => [qw(
bin cdiv cdiv_2exp clrbit combit 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 mpz_export
mpz_import nextprime odd_p perfect_power_p
perfect_square_p popcount powm probab_prime_p
realloc remove root roote rootrem scan0 scan1
setbit sizeinbase sqrtrem tdiv tdiv_2exp
tstbit)],
'constants' => [@EXPORT],
'noconstants' => [@EXPORT]);
Exporter::export_ok_tags('all');
use overload
'+' => \&overload_add, '+=' => \&overload_addeq,
'-' => \&overload_sub, '-=' => \&overload_subeq,
'*' => \&overload_mul, '*=' => \&overload_muleq,
'/' => \&overload_div, '/=' => \&overload_diveq,
'%' => \&overload_rem, '%=' => \&overload_remeq,
'<<' => \&overload_lshift, '<<=' => \&overload_lshifteq,
'>>' => \&overload_rshift, '>>=' => \&overload_rshifteq,
'**' => \&overload_pow, '**=' => \&overload_poweq,
'&' => \&overload_and, '&=' => \&overload_andeq,
'|' => \&overload_ior, '|=' => \&overload_ioreq,
'^' => \&overload_xor, '^=' => \&overload_xoreq,
'bool' => \&overload_bool,
'not' => \&overload_not,
'!' => \&overload_not,
'~' => \&overload_com,
'<=>' => \&overload_spaceship,
'++' => \&overload_inc,
'--' => \&overload_dec,
'=' => \&overload_copy,
'abs' => \&overload_abs,
'neg' => \&overload_neg,
'sqrt' => \&overload_sqrt,
'""' => \&overload_string;
sub import {
foreach (@_) {
if ($_ eq ':constants') {
overload::constant ('integer' => \&overload_constant,
'binary' => \&overload_constant,
'float' => \&overload_constant);
} elsif ($_ eq ':noconstants') {
overload::remove_constant ('integer' => \&overload_constant,
'binary' => \&overload_constant,
'float' => \&overload_constant);
}
}
goto &Exporter::import;
}
1;
__END__
# Local variables:
# perl-indent-level: 2
# End:

View File

@@ -0,0 +1,44 @@
# GMP random numbers module.
# Copyright 2001, 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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
package GMP::Rand;
require GMP;
require Exporter;
@ISA = qw(GMP Exporter);
@EXPORT = qw();
%EXPORT_TAGS = ('all' => [qw(
randstate mpf_urandomb mpz_rrandomb
mpz_urandomb mpz_urandomm gmp_urandomb_ui
gmp_urandomm_ui)]);
Exporter::export_ok_tags('all');
1;
__END__

View File

@@ -0,0 +1,88 @@
Copyright 2001, 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/.
GMP PERL MODULE INSTALLATION
This module can be compiled within the GMP source directory or moved
elsewhere and compiled. An installed GMP can be used, or a specified
GMP build tree. Both static and shared GMP builds will work.
The simplest case is when GMP has been installed to a standard system
location
perl Makefile.PL
make
If not yet installed then the top-level GMP build directory must be
specified
perl Makefile.PL GMP_BUILDDIR=/my/gmp/build
make
In any case, with the module built, the sample program provided can be
run
perl -Iblib/arch sample.pl
If you built a shared version of libgmp but haven't yet installed it,
then it might be necessary to add a run-time path to it. For example
LD_LIBRARY_PATH=/my/gmp/build/.libs perl -Iblib/arch sample.pl
Documentation is provided in pod format in GMP.pm, and will have been
"man"-ified in the module build
man -l blib/man3/GMP.3pm
or
man -M`pwd`/blib GMP
A test script is provided, running a large number of more or less
trivial checks
make test
The module and its documentation can be installed in the usual way
make install
This will be into /usr/local or wherever the perl Config module
directs, but that can be controlled back at the Makefile.PL stage with
the usual ExtUtils::MakeMaker options.
Once installed, programs using the GMP module become simply
perl sample.pl
And the documentation read directly too
man GMP

View File

@@ -0,0 +1,82 @@
# Makefile for GMP perl module.
# Copyright 2001, 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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
# Bugs:
#
# When the generated Makefile re-runs "perl Makefile.PL" the GMP_BUILDDIR
# parameter is lost.
use ExtUtils::MakeMaker;
# Find and remove our parameters
@ARGV = map {
if (/^GMP_BUILDDIR=(.*)/) {
$GMP_BUILDDIR=$1; ();
} else {
$_;
}
} (@ARGV);
$INC = "";
$LIBS = "-lgmp";
$OBJECT = "GMP.o";
if (defined $GMP_BUILDDIR) {
if (! -f "$GMP_BUILDDIR/libgmp.la") {
die "$GMP_BUILDDIR doesn't contain libgmp.la\n" .
"if it's really a gmp build directory then go there and run \"make libgmp.la\"\n";
}
$INC = "-I$GMP_BUILDDIR $INC";
$LIBS = "-L$GMP_BUILDDIR/.libs $LIBS";
}
WriteMakefile(
NAME => 'GMP',
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',
}
);
# Local variables:
# perl-indent-level: 2
# End:

View File

@@ -0,0 +1,54 @@
#!/usr/bin/perl -w
# Some sample GMP module operations
# Copyright 2001, 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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
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";
use GMP::Mpq qw(:constants);
print "the 7th harmonic number is ", 1+1/2+1/3+1/4+1/5+1/6+1/7, "\n";
use GMP::Mpq qw(:noconstants);
use GMP::Mpf qw(mpf);
my $f = mpf(1,180);
$f >>= 180;
$f += 1;
print "a sample mpf is $f\n";

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,75 @@
# GMP perl module tests (part 2)
# Copyright 2001 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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
# The following uses of :constants seem to provoke segvs in perl 5.005_03,
# so they're kept separate file to be run only on suitable perl versions.
use GMP::Mpz qw(:constants);
{
my $a = 123;
ok (UNIVERSAL::isa ($a, "GMP::Mpz"));
}
use GMP::Mpz qw(:noconstants);
use GMP::Mpq qw(:constants);
{
my $a = 123;
ok (UNIVERSAL::isa ($a, "GMP::Mpq"));
}
use GMP::Mpq qw(:noconstants);
use GMP::Mpf qw(:constants);
{
my $a = 123;
ok (UNIVERSAL::isa ($a, "GMP::Mpf"));
}
use GMP::Mpf qw(:noconstants);
# compiled constants unchanged by clrbit etc when re-executed
foreach (0, 1, 2) {
use GMP::Mpz qw(:constants);
my $a = 15;
my $b = 6;
use GMP::Mpz qw(:noconstants);
clrbit ($a, 0);
ok ($a == 14);
setbit ($b, 0);
ok ($b == 7);
}
1;
# Local variables:
# perl-indent-level: 2
# End:

View File

@@ -0,0 +1,108 @@
# GMP module external subroutine type mappings.
# Copyright 2001, 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 either:
#
# * the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# or
#
# * the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any
# later version.
#
# or both in parallel, as here.
#
# 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 General Public License
# for more details.
#
# You should have received copies of the GNU General Public License and the
# GNU Lesser General Public License along with the GNU MP Library. If not,
# see https://www.gnu.org/licenses/.
TYPEMAP
const_string T_PV
const_string_assume CONST_STRING_ASSUME
mpz MPZ
mpq MPQ
mpf MPF
mpz_assume MPZ_ASSUME
mpq_assume MPQ_ASSUME
mpf_assume MPF_ASSUME
mpz_coerce MPZ_COERCE
mpq_coerce MPQ_COERCE
mpf_coerce_st0 MPF_COERCE_ST0
mpf_coerce_def MPF_COERCE_DEF
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
MPZ
class_or_croak ($arg, mpz_class); $var = SvMPZ($arg);
MPQ
class_or_croak ($arg, mpq_class); $var = SvMPQ($arg);
MPF
class_or_croak ($arg, mpf_class); $var = SvMPF($arg);
MPZ_ASSUME
MPZ_ASSUME ($var, $arg)
MPQ_ASSUME
MPQ_ASSUME ($var, $arg)
MPF_ASSUME
MPF_ASSUME ($var, $arg)
MPZ_COERCE
$var = coerce_mpz (tmp_mpz_${(my $stnum=$arg)=~s/[^0-9]//g;\$stnum}, $arg)
MPQ_COERCE
$var = coerce_mpq (tmp_mpq_${(my $stnum=$arg)=~s/[^0-9]//g;\$stnum}, $arg)
MPF_COERCE_ST0
/* precision follows ST(0) */
assert (sv_derived_from (ST(0), mpf_class));
$var = coerce_mpf (tmp_mpf_${(my $stnum=$arg)=~s/[^0-9]//g;\$stnum},
$arg, mpf_get_prec (SvMPF(ST(0))))
MPF_COERCE_DEF
/* default precision used */
$var = coerce_mpf (tmp_mpf_${(my $stnum=$arg)=~s/[^0-9]//g;\$stnum},
$arg, mpf_get_default_prec())
RANDSTATE
class_or_croak ($arg, rand_class); $var = SvRANDSTATE($arg);
ULONG_COERCE
$var = coerce_ulong ($arg)
ORDER_NOSWAP
assert ($arg != &PL_sv_yes);
DUMMY
/* dummy $var */
CONST_STRING_ASSUME
/* No need to check for SvPOKp and use SvPV, this mapping is
only used for overload_constant, which always gets literal
strings. */
assert (SvPOK ($arg));
$var = SvPVX ($arg);
OUTPUT
MPZ
sv_bless (sv_setref_pv ($arg, NULL, $var), mpz_class_hv);
MPQ
sv_bless (sv_setref_pv ($arg, NULL, $var), mpq_class_hv);
MPF
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

@@ -0,0 +1,45 @@
/* Templates for pexpr program configuration. -*- mode:c -*-
Copyright 2002 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see https://www.gnu.org/licenses/. */
/* Define if you have the <sys/resource.h> header file. */
#define HAVE_SYS_RESOURCE_H @HAVE_SYS_RESOURCE_H_01@
/* Define if you have the `clock' function. */
#define HAVE_CLOCK @HAVE_CLOCK_01@
/* Define if you have the `cputime' function. */
#define HAVE_CPUTIME @HAVE_CPUTIME_01@
/* Define if you have the `getrusage' function. */
#define HAVE_GETRUSAGE @HAVE_GETRUSAGE_01@
/* Define if you have the `gettimeofday' function. */
#define HAVE_GETTIMEOFDAY @HAVE_GETTIMEOFDAY_01@
/* Define if you have the `sigaction' function. */
#define HAVE_SIGACTION @HAVE_SIGACTION_01@
/* Define if you have the `sigaltstack' function. */
#define HAVE_SIGALTSTACK @HAVE_SIGALTSTACK_01@
/* Define if you have the `sigstack' function. */
#define HAVE_SIGSTACK @HAVE_SIGSTACK_01@
/* Define if the system has the type `stack_t'. */
#define HAVE_STACK_T @HAVE_STACK_T_01@

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,387 @@
/* List and count primes.
Written by tege while on holiday in Rodupp, August 2001.
Between 10 and 500 times faster than previous program.
Copyright 2001, 2002, 2006, 2012 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see https://www.gnu.org/licenses/. */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <assert.h>
/* IDEAS:
* Do not fill primes[] with real primes when the range [fr,to] is small,
when fr,to are relatively large. Fill primes[] with odd numbers instead.
[Probably a bad idea, since the primes[] array would become very large.]
* Separate small primes and large primes when sieving. Either the Montgomery
way (i.e., having a large array a multiple of L1 cache size), or just
separate loops for primes <= S and primes > S. The latter primes do not
require an inner loop, since they will touch the sieving array at most once.
* Pre-fill sieving array with an appropriately aligned ...00100100... pattern,
then omit 3 from primes array. (May require similar special handling of 3
as we now have for 2.)
* A large SIEVE_LIMIT currently implies very large memory usage, mainly due
to the sieving array in make_primelist, but also because of the primes[]
array. We might want to stage the program, using sieve_region/find_primes
to build primes[]. Make report() a function pointer, as part of achieving
this.
* Store primes[] as two arrays, one array with primes represented as delta
values using just 8 bits (if gaps are too big, store bogus primes!)
and one array with "rem" values. The latter needs 32-bit values.
* A new entry point, mpz_probab_prime_likely_p, would be useful.
* Improve command line syntax and versatility. "primes -f FROM -t TO",
allow either to be omitted for open interval. (But disallow
"primes -c -f FROM" since that would be infinity.) Allow printing a
limited *number* of primes using syntax like "primes -f FROM -n NUMBER".
* When looking for maxgaps, we should not perform any primality testing until
we find possible record gaps. Should speed up the searches tremendously.
*/
#include "gmp.h"
struct primes
{
unsigned int prime;
int rem;
};
struct primes *primes;
unsigned long n_primes;
void find_primes (unsigned char *, mpz_t, unsigned long, mpz_t);
void sieve_region (unsigned char *, mpz_t, unsigned long);
void make_primelist (unsigned long);
int flag_print = 1;
int flag_count = 0;
int flag_maxgap = 0;
unsigned long maxgap = 0;
unsigned long total_primes = 0;
void
report (mpz_t prime)
{
total_primes += 1;
if (flag_print)
{
mpz_out_str (stdout, 10, prime);
printf ("\n");
}
if (flag_maxgap)
{
static unsigned long prev_prime_low = 0;
unsigned long gap;
if (prev_prime_low != 0)
{
gap = mpz_get_ui (prime) - prev_prime_low;
if (maxgap < gap)
maxgap = gap;
}
prev_prime_low = mpz_get_ui (prime);
}
}
int
main (int argc, char *argv[])
{
char *progname = argv[0];
mpz_t fr, to;
mpz_t fr2, to2;
unsigned long sieve_lim;
unsigned long est_n_primes;
unsigned char *s;
mpz_t tmp;
mpz_t siev_sqr_lim;
while (argc != 1)
{
if (strcmp (argv[1], "-c") == 0)
{
flag_count = 1;
argv++;
argc--;
}
else if (strcmp (argv[1], "-p") == 0)
{
flag_print = 2;
argv++;
argc--;
}
else if (strcmp (argv[1], "-g") == 0)
{
flag_maxgap = 1;
argv++;
argc--;
}
else
break;
}
if (flag_count || flag_maxgap)
flag_print--; /* clear unless an explicit -p */
mpz_init (fr);
mpz_init (to);
mpz_init (fr2);
mpz_init (to2);
if (argc == 3)
{
mpz_set_str (fr, argv[1], 0);
if (argv[2][0] == '+')
{
mpz_set_str (to, argv[2] + 1, 0);
mpz_add (to, to, fr);
}
else
mpz_set_str (to, argv[2], 0);
}
else if (argc == 2)
{
mpz_set_ui (fr, 0);
mpz_set_str (to, argv[1], 0);
}
else
{
fprintf (stderr, "usage: %s [-c] [-p] [-g] [from [+]]to\n", progname);
exit (1);
}
mpz_set (fr2, fr);
if (mpz_cmp_ui (fr2, 3) < 0)
{
mpz_set_ui (fr2, 2);
report (fr2);
mpz_set_ui (fr2, 3);
}
mpz_setbit (fr2, 0); /* make odd */
mpz_sub_ui (to2, to, 1);
mpz_setbit (to2, 0); /* make odd */
mpz_init (tmp);
mpz_init (siev_sqr_lim);
mpz_sqrt (tmp, to2);
#define SIEVE_LIMIT 10000000
if (mpz_cmp_ui (tmp, SIEVE_LIMIT) < 0)
{
sieve_lim = mpz_get_ui (tmp);
}
else
{
sieve_lim = SIEVE_LIMIT;
mpz_sub (tmp, to2, fr2);
if (mpz_cmp_ui (tmp, sieve_lim) < 0)
sieve_lim = mpz_get_ui (tmp); /* limit sieving for small ranges */
}
mpz_set_ui (siev_sqr_lim, sieve_lim + 1);
mpz_mul_ui (siev_sqr_lim, siev_sqr_lim, sieve_lim + 1);
est_n_primes = (size_t) (sieve_lim / log((double) sieve_lim) * 1.13) + 10;
primes = malloc (est_n_primes * sizeof primes[0]);
make_primelist (sieve_lim);
assert (est_n_primes >= n_primes);
#if DEBUG
printf ("sieve_lim = %lu\n", sieve_lim);
printf ("n_primes = %lu (3..%u)\n",
n_primes, primes[n_primes - 1].prime);
#endif
#define S (1 << 15) /* FIXME: Figure out L1 cache size */
s = malloc (S/2);
while (mpz_cmp (fr2, to2) <= 0)
{
unsigned long rsize;
rsize = S;
mpz_add_ui (tmp, fr2, rsize);
if (mpz_cmp (tmp, to2) > 0)
{
mpz_sub (tmp, to2, fr2);
rsize = mpz_get_ui (tmp) + 2;
}
#if DEBUG
printf ("Sieving region ["); mpz_out_str (stdout, 10, fr2);
printf (","); mpz_add_ui (tmp, fr2, rsize - 2);
mpz_out_str (stdout, 10, tmp); printf ("]\n");
#endif
sieve_region (s, fr2, rsize);
find_primes (s, fr2, rsize / 2, siev_sqr_lim);
mpz_add_ui (fr2, fr2, S);
}
free (s);
if (flag_count)
printf ("Pi(interval) = %lu\n", total_primes);
if (flag_maxgap)
printf ("max gap: %lu\n", maxgap);
return 0;
}
/* Find primes in region [fr,fr+rsize). Requires that fr is odd and that
rsize is even. The sieving array s should be aligned for "long int" and
have rsize/2 entries, rounded up to the nearest multiple of "long int". */
void
sieve_region (unsigned char *s, mpz_t fr, unsigned long rsize)
{
unsigned long ssize = rsize / 2;
unsigned long start, start2, prime;
unsigned long i;
mpz_t tmp;
mpz_init (tmp);
#if 0
/* initialize sieving array */
for (ii = 0; ii < (ssize + sizeof (long) - 1) / sizeof (long); ii++)
((long *) s) [ii] = ~0L;
#else
{
long k;
long *se = (long *) (s + ((ssize + sizeof (long) - 1) & -sizeof (long)));
for (k = -((ssize + sizeof (long) - 1) / sizeof (long)); k < 0; k++)
se[k] = ~0L;
}
#endif
for (i = 0; i < n_primes; i++)
{
prime = primes[i].prime;
if (primes[i].rem >= 0)
{
start2 = primes[i].rem;
}
else
{
mpz_set_ui (tmp, prime);
mpz_mul_ui (tmp, tmp, prime);
if (mpz_cmp (fr, tmp) <= 0)
{
mpz_sub (tmp, tmp, fr);
if (mpz_cmp_ui (tmp, 2 * ssize) > 0)
break; /* avoid overflow at next line, also speedup */
start = mpz_get_ui (tmp);
}
else
{
start = (prime - mpz_tdiv_ui (fr, prime)) % prime;
if (start % 2 != 0)
start += prime; /* adjust if even divisible */
}
start2 = start / 2;
}
#if 0
for (ii = start2; ii < ssize; ii += prime)
s[ii] = 0;
primes[i].rem = ii - ssize;
#else
{
long k;
unsigned char *se = s + ssize; /* point just beyond sieving range */
for (k = start2 - ssize; k < 0; k += prime)
se[k] = 0;
primes[i].rem = k;
}
#endif
}
mpz_clear (tmp);
}
/* Find primes in region [fr,fr+rsize), using the previously sieved s[]. */
void
find_primes (unsigned char *s, mpz_t fr, unsigned long ssize,
mpz_t siev_sqr_lim)
{
unsigned long j, ij;
mpz_t tmp;
mpz_init (tmp);
for (j = 0; j < (ssize + sizeof (long) - 1) / sizeof (long); j++)
{
if (((long *) s) [j] != 0)
{
for (ij = 0; ij < sizeof (long); ij++)
{
if (s[j * sizeof (long) + ij] != 0)
{
if (j * sizeof (long) + ij >= ssize)
goto out;
mpz_add_ui (tmp, fr, (j * sizeof (long) + ij) * 2);
if (mpz_cmp (tmp, siev_sqr_lim) < 0 ||
mpz_probab_prime_p (tmp, 10))
report (tmp);
}
}
}
}
out:
mpz_clear (tmp);
}
/* Generate a list of primes and store in the global array primes[]. */
void
make_primelist (unsigned long maxprime)
{
#if 1
unsigned char *s;
unsigned long ssize = maxprime / 2;
unsigned long i, ii, j;
s = malloc (ssize);
memset (s, ~0, ssize);
for (i = 3; ; i += 2)
{
unsigned long isqr = i * i;
if (isqr >= maxprime)
break;
if (s[i * i / 2 - 1] == 0)
continue; /* only sieve with primes */
for (ii = i * i / 2 - 1; ii < ssize; ii += i)
s[ii] = 0;
}
n_primes = 0;
for (j = 0; j < ssize; j++)
{
if (s[j] != 0)
{
primes[n_primes].prime = j * 2 + 3;
primes[n_primes].rem = -1;
n_primes++;
}
}
/* FIXME: This should not be needed if fencepost errors were fixed... */
if (primes[n_primes - 1].prime > maxprime)
n_primes--;
free (s);
#else
unsigned long i;
n_primes = 0;
for (i = 3; i <= maxprime; i += 2)
{
if (i < 7 || (i % 3 != 0 && i % 5 != 0 && i % 7 != 0))
{
primes[n_primes].prime = i;
primes[n_primes].rem = -1;
n_primes++;
}
}
#endif
}

View File

@@ -0,0 +1,552 @@
P( 1, 0xaaaaaaaaaaaaaaabUL, 0x5555555555555555UL) /* 3 */
P( 2, 0xcccccccccccccccdUL, 0x3333333333333333UL) /* 5 */
P( 2, 0x6db6db6db6db6db7UL, 0x2492492492492492UL) /* 7 */
P( 4, 0x2e8ba2e8ba2e8ba3UL, 0x1745d1745d1745d1UL) /* 11 */
P( 2, 0x4ec4ec4ec4ec4ec5UL, 0x13b13b13b13b13b1UL) /* 13 */
P( 4, 0xf0f0f0f0f0f0f0f1UL, 0x0f0f0f0f0f0f0f0fUL) /* 17 */
P( 2, 0x86bca1af286bca1bUL, 0x0d79435e50d79435UL) /* 19 */
P( 4, 0xd37a6f4de9bd37a7UL, 0x0b21642c8590b216UL) /* 23 */
P( 6, 0x34f72c234f72c235UL, 0x08d3dcb08d3dcb08UL) /* 29 */
P( 2, 0xef7bdef7bdef7bdfUL, 0x0842108421084210UL) /* 31 */
P( 6, 0x14c1bacf914c1badUL, 0x06eb3e45306eb3e4UL) /* 37 */
P( 4, 0x8f9c18f9c18f9c19UL, 0x063e7063e7063e70UL) /* 41 */
P( 2, 0x82fa0be82fa0be83UL, 0x05f417d05f417d05UL) /* 43 */
P( 4, 0x51b3bea3677d46cfUL, 0x0572620ae4c415c9UL) /* 47 */
P( 6, 0x21cfb2b78c13521dUL, 0x04d4873ecade304dUL) /* 53 */
P( 6, 0xcbeea4e1a08ad8f3UL, 0x0456c797dd49c341UL) /* 59 */
P( 2, 0x4fbcda3ac10c9715UL, 0x04325c53ef368eb0UL) /* 61 */
P( 6, 0xf0b7672a07a44c6bUL, 0x03d226357e16ece5UL) /* 67 */
P( 4, 0x193d4bb7e327a977UL, 0x039b0ad12073615aUL) /* 71 */
P( 2, 0x7e3f1f8fc7e3f1f9UL, 0x0381c0e070381c0eUL) /* 73 */
P( 6, 0x9b8b577e613716afUL, 0x033d91d2a2067b23UL) /* 79 */
P( 4, 0xa3784a062b2e43dbUL, 0x03159721ed7e7534UL) /* 83 */
P( 6, 0xf47e8fd1fa3f47e9UL, 0x02e05c0b81702e05UL) /* 89 */
P( 8, 0xa3a0fd5c5f02a3a1UL, 0x02a3a0fd5c5f02a3UL) /* 97 */
P( 4, 0x3a4c0a237c32b16dUL, 0x0288df0cac5b3f5dUL) /* 101 */
P( 2, 0xdab7ec1dd3431b57UL, 0x027c45979c95204fUL) /* 103 */
P( 4, 0x77a04c8f8d28ac43UL, 0x02647c69456217ecUL) /* 107 */
P( 2, 0xa6c0964fda6c0965UL, 0x02593f69b02593f6UL) /* 109 */
P( 4, 0x90fdbc090fdbc091UL, 0x0243f6f0243f6f02UL) /* 113 */
P(14, 0x7efdfbf7efdfbf7fUL, 0x0204081020408102UL) /* 127 */
P( 4, 0x03e88cb3c9484e2bUL, 0x01f44659e4a42715UL) /* 131 */
P( 6, 0xe21a291c077975b9UL, 0x01de5d6e3f8868a4UL) /* 137 */
P( 2, 0x3aef6ca970586723UL, 0x01d77b654b82c339UL) /* 139 */
P(10, 0xdf5b0f768ce2cabdUL, 0x01b7d6c3dda338b2UL) /* 149 */
P( 2, 0x6fe4dfc9bf937f27UL, 0x01b2036406c80d90UL) /* 151 */
P( 6, 0x5b4fe5e92c0685b5UL, 0x01a16d3f97a4b01aUL) /* 157 */
P( 6, 0x1f693a1c451ab30bUL, 0x01920fb49d0e228dUL) /* 163 */
P( 4, 0x8d07aa27db35a717UL, 0x01886e5f0abb0499UL) /* 167 */
P( 6, 0x882383b30d516325UL, 0x017ad2208e0ecc35UL) /* 173 */
P( 6, 0xed6866f8d962ae7bUL, 0x016e1f76b4337c6cUL) /* 179 */
P( 2, 0x3454dca410f8ed9dUL, 0x016a13cd15372904UL) /* 181 */
P(10, 0x1d7ca632ee936f3fUL, 0x01571ed3c506b39aUL) /* 191 */
P( 2, 0x70bf015390948f41UL, 0x015390948f40feacUL) /* 193 */
P( 4, 0xc96bdb9d3d137e0dUL, 0x014cab88725af6e7UL) /* 197 */
P( 2, 0x2697cc8aef46c0f7UL, 0x0149539e3b2d066eUL) /* 199 */
P(12, 0xc0e8f2a76e68575bUL, 0x013698df3de07479UL) /* 211 */
P(12, 0x687763dfdb43bb1fUL, 0x0125e22708092f11UL) /* 223 */
P( 4, 0x1b10ea929ba144cbUL, 0x0120b470c67c0d88UL) /* 227 */
P( 2, 0x1d10c4c0478bbcedUL, 0x011e2ef3b3fb8744UL) /* 229 */
P( 4, 0x63fb9aeb1fdcd759UL, 0x0119453808ca29c0UL) /* 233 */
P( 6, 0x64afaa4f437b2e0fUL, 0x0112358e75d30336UL) /* 239 */
P( 2, 0xf010fef010fef011UL, 0x010fef010fef010fUL) /* 241 */
P(10, 0x28cbfbeb9a020a33UL, 0x0105197f7d734041UL) /* 251 */
P( 6, 0xff00ff00ff00ff01UL, 0x00ff00ff00ff00ffUL) /* 257 */
P( 6, 0xd624fd1470e99cb7UL, 0x00f92fb2211855a8UL) /* 263 */
P( 6, 0x8fb3ddbd6205b5c5UL, 0x00f3a0d52cba8723UL) /* 269 */
P( 2, 0xd57da36ca27acdefUL, 0x00f1d48bcee0d399UL) /* 271 */
P( 6, 0xee70c03b25e4463dUL, 0x00ec979118f3fc4dUL) /* 277 */
P( 4, 0xc5b1a6b80749cb29UL, 0x00e939651fe2d8d3UL) /* 281 */
P( 2, 0x47768073c9b97113UL, 0x00e79372e225fe30UL) /* 283 */
P(10, 0x2591e94884ce32adUL, 0x00dfac1f74346c57UL) /* 293 */
P(14, 0xf02806abc74be1fbUL, 0x00d578e97c3f5fe5UL) /* 307 */
P( 4, 0x7ec3e8f3a7198487UL, 0x00d2ba083b445250UL) /* 311 */
P( 2, 0x58550f8a39409d09UL, 0x00d161543e28e502UL) /* 313 */
P( 4, 0xec9e48ae6f71de15UL, 0x00cebcf8bb5b4169UL) /* 317 */
P(14, 0x2ff3a018bfce8063UL, 0x00c5fe740317f9d0UL) /* 331 */
P( 6, 0x7f9ec3fcf61fe7b1UL, 0x00c2780613c0309eUL) /* 337 */
P(10, 0x89f5abe570e046d3UL, 0x00bcdd535db1cc5bUL) /* 347 */
P( 2, 0xda971b23f1545af5UL, 0x00bbc8408cd63069UL) /* 349 */
P( 4, 0x79d5f00b9a7862a1UL, 0x00b9a7862a0ff465UL) /* 353 */
P( 6, 0x4dba1df32a128a57UL, 0x00b68d31340e4307UL) /* 359 */
P( 8, 0x87530217b7747d8fUL, 0x00b2927c29da5519UL) /* 367 */
P( 6, 0x30baae53bb5e06ddUL, 0x00afb321a1496fdfUL) /* 373 */
P( 6, 0xee70206c12e9b5b3UL, 0x00aceb0f891e6551UL) /* 379 */
P( 4, 0xcdde9462ec9dbe7fUL, 0x00ab1cbdd3e2970fUL) /* 383 */
P( 6, 0xafb64b05ec41cf4dUL, 0x00a87917088e262bUL) /* 389 */
P( 8, 0x02944ff5aec02945UL, 0x00a513fd6bb00a51UL) /* 397 */
P( 4, 0x2cb033128382df71UL, 0x00a36e71a2cb0331UL) /* 401 */
P( 8, 0x1ccacc0c84b1c2a9UL, 0x00a03c1688732b30UL) /* 409 */
P(10, 0x19a93db575eb3a0bUL, 0x009c69169b30446dUL) /* 419 */
P( 2, 0xcebeef94fa86fe2dUL, 0x009baade8e4a2f6eUL) /* 421 */
P(10, 0x6faa77fb3f8df54fUL, 0x00980e4156201301UL) /* 431 */
P( 2, 0x68a58af00975a751UL, 0x00975a750ff68a58UL) /* 433 */
P( 6, 0xd56e36d0c3efac07UL, 0x009548e4979e0829UL) /* 439 */
P( 4, 0xd8b44c47a8299b73UL, 0x0093efd1c50e726bUL) /* 443 */
P( 6, 0x02d9ccaf9ba70e41UL, 0x0091f5bcb8bb02d9UL) /* 449 */
P( 8, 0x0985e1c023d9e879UL, 0x008f67a1e3fdc261UL) /* 457 */
P( 4, 0x2a343316c494d305UL, 0x008e2917e0e702c6UL) /* 461 */
P( 2, 0x70cb7916ab67652fUL, 0x008d8be33f95d715UL) /* 463 */
P( 4, 0xd398f132fb10fe5bUL, 0x008c55841c815ed5UL) /* 467 */
P(12, 0x6f2a38a6bf54fa1fUL, 0x0088d180cd3a4133UL) /* 479 */
P( 8, 0x211df689b98f81d7UL, 0x00869222b1acf1ceUL) /* 487 */
P( 4, 0x0e994983e90f1ec3UL, 0x0085797b917765abUL) /* 491 */
P( 8, 0xad671e44bed87f3bUL, 0x008355ace3c897dbUL) /* 499 */
P( 4, 0xf9623a0516e70fc7UL, 0x00824a4e60b3262bUL) /* 503 */
P( 6, 0x4b7129be9dece355UL, 0x0080c121b28bd1baUL) /* 509 */
P(12, 0x190f3b7473f62c39UL, 0x007dc9f3397d4c29UL) /* 521 */
P( 2, 0x63dacc9aad46f9a3UL, 0x007d4ece8fe88139UL) /* 523 */
P(18, 0xc1108fda24e8d035UL, 0x0079237d65bcce50UL) /* 541 */
P( 6, 0xb77578472319bd8bUL, 0x0077cf53c5f7936cUL) /* 547 */
P(10, 0x473d20a1c7ed9da5UL, 0x0075a8accfbdd11eUL) /* 557 */
P( 6, 0xfbe85af0fea2c8fbUL, 0x007467ac557c228eUL) /* 563 */
P( 6, 0x58a1f7e6ce0f4c09UL, 0x00732d70ed8db8e9UL) /* 569 */
P( 2, 0x1a00e58c544986f3UL, 0x0072c62a24c3797fUL) /* 571 */
P( 6, 0x7194a17f55a10dc1UL, 0x007194a17f55a10dUL) /* 577 */
P(10, 0x7084944785e33763UL, 0x006fa549b41da7e7UL) /* 587 */
P( 6, 0xba10679bd84886b1UL, 0x006e8419e6f61221UL) /* 593 */
P( 6, 0xebe9c6bb31260967UL, 0x006d68b5356c207bUL) /* 599 */
P( 2, 0x97a3fe4bd1ff25e9UL, 0x006d0b803685c01bUL) /* 601 */
P( 6, 0x6c6388395b84d99fUL, 0x006bf790a8b2d207UL) /* 607 */
P( 6, 0x8c51da6a1335df6dUL, 0x006ae907ef4b96c2UL) /* 613 */
P( 4, 0x46f3234475d5add9UL, 0x006a37991a23aeadUL) /* 617 */
P( 2, 0x905605ca3c619a43UL, 0x0069dfbdd4295b66UL) /* 619 */
P(12, 0xcee8dff304767747UL, 0x0067dc4c45c8033eUL) /* 631 */
P(10, 0xff99c27f00663d81UL, 0x00663d80ff99c27fUL) /* 641 */
P( 2, 0xacca407f671ddc2bUL, 0x0065ec17e3559948UL) /* 643 */
P( 4, 0xe71298bac1e12337UL, 0x00654ac835cfba5cUL) /* 647 */
P( 6, 0xfa1e94309cd09045UL, 0x00645c854ae10772UL) /* 653 */
P( 6, 0xbebccb8e91496b9bUL, 0x006372990e5f901fUL) /* 659 */
P( 2, 0x312fa30cc7d7b8bdUL, 0x006325913c07beefUL) /* 661 */
P(12, 0x6160ff9e9f006161UL, 0x006160ff9e9f0061UL) /* 673 */
P( 4, 0x6b03673b5e28152dUL, 0x0060cdb520e5e88eUL) /* 677 */
P( 6, 0xfe802ffa00bfe803UL, 0x005ff4017fd005ffUL) /* 683 */
P( 8, 0xe66fe25c9e907c7bUL, 0x005ed79e31a4dccdUL) /* 691 */
P(10, 0x3f8b236c76528895UL, 0x005d7d42d48ac5efUL) /* 701 */
P( 8, 0xf6f923bf01ce2c0dUL, 0x005c6f35ccba5028UL) /* 709 */
P(10, 0x6c3d3d98bed7c42fUL, 0x005b2618ec6ad0a5UL) /* 719 */
P( 8, 0x30981efcd4b010e7UL, 0x005a2553748e42e7UL) /* 727 */
P( 6, 0x6f691fc81ebbe575UL, 0x0059686cf744cd5bUL) /* 733 */
P( 6, 0xb10480ddb47b52cbUL, 0x0058ae97bab79976UL) /* 739 */
P( 4, 0x74cd59ed64f3f0d7UL, 0x0058345f1876865fUL) /* 743 */
P( 8, 0x0105cb81316d6c0fUL, 0x005743d5bb24795aUL) /* 751 */
P( 6, 0x9be64c6d91c1195dUL, 0x005692c4d1ab74abUL) /* 757 */
P( 4, 0x71b3f945a27b1f49UL, 0x00561e46a4d5f337UL) /* 761 */
P( 8, 0x77d80d50e508fd01UL, 0x005538ed06533997UL) /* 769 */
P( 4, 0xa5eb778e133551cdUL, 0x0054c807f2c0bec2UL) /* 773 */
P(14, 0x18657d3c2d8a3f1bUL, 0x005345efbc572d36UL) /* 787 */
P(10, 0x2e40e220c34ad735UL, 0x00523a758f941345UL) /* 797 */
P(12, 0xa76593c70a714919UL, 0x005102370f816c89UL) /* 809 */
P( 2, 0x1eef452124eea383UL, 0x0050cf129fb94acfUL) /* 811 */
P(10, 0x38206dc242ba771dUL, 0x004fd31941cafdd1UL) /* 821 */
P( 2, 0x4cd4c35807772287UL, 0x004fa1704aa75945UL) /* 823 */
P( 4, 0x83de917d5e69ddf3UL, 0x004f3ed6d45a63adUL) /* 827 */
P( 2, 0x882ef0403b4a6c15UL, 0x004f0de57154ebedUL) /* 829 */
P(10, 0xf8fb6c51c606b677UL, 0x004e1cae8815f811UL) /* 839 */
P(14, 0xb4abaac446d3e1fdUL, 0x004cd47ba5f6ff19UL) /* 853 */
P( 4, 0xa9f83bbe484a14e9UL, 0x004c78ae734df709UL) /* 857 */
P( 2, 0x0bebbc0d1ce874d3UL, 0x004c4b19ed85cfb8UL) /* 859 */
P( 4, 0xbd418eaf0473189fUL, 0x004bf093221d1218UL) /* 863 */
P(14, 0x44e3af6f372b7e65UL, 0x004aba3c21dc633fUL) /* 877 */
P( 4, 0xc87fdace4f9e5d91UL, 0x004a6360c344de00UL) /* 881 */
P( 2, 0xec93479c446bd9bbUL, 0x004a383e9f74d68aUL) /* 883 */
P( 4, 0xdac4d592e777c647UL, 0x0049e28fbabb9940UL) /* 887 */
P(20, 0xa63ea8c8f61f0c23UL, 0x0048417b57c78cd7UL) /* 907 */
P( 4, 0xe476062ea5cbbb6fUL, 0x0047f043713f3a2bUL) /* 911 */
P( 8, 0xdf68761c69daac27UL, 0x00474ff2a10281cfUL) /* 919 */
P(10, 0xb813d737637aa061UL, 0x00468b6f9a978f91UL) /* 929 */
P( 8, 0xa3a77aac1fb15099UL, 0x0045f13f1caff2e2UL) /* 937 */
P( 4, 0x17f0c3e0712c5825UL, 0x0045a5228cec23e9UL) /* 941 */
P( 6, 0xfd912a70ff30637bUL, 0x0045342c556c66b9UL) /* 947 */
P( 6, 0xfbb3b5dc01131289UL, 0x0044c4a23feeced7UL) /* 953 */
P(14, 0x856d560a0f5acdf7UL, 0x0043c5c20d3c9fe6UL) /* 967 */
P( 4, 0x96472f314d3f89e3UL, 0x00437e494b239798UL) /* 971 */
P( 6, 0xa76f5c7ed2253531UL, 0x0043142d118e47cbUL) /* 977 */
P( 6, 0x816eae7c7bf69fe7UL, 0x0042ab5c73a13458UL) /* 983 */
P( 8, 0xb6a2bea4cfb1781fUL, 0x004221950db0f3dbUL) /* 991 */
P( 6, 0xa3900c53318e81edUL, 0x0041bbb2f80a4553UL) /* 997 */
P(12, 0x60aa7f5d9f148d11UL, 0x0040f391612c6680UL) /* 1009 */
P( 4, 0x6be8c0102c7a505dUL, 0x0040b1e94173fefdUL) /* 1013 */
P( 6, 0x8ff3f0ed28728f33UL, 0x004050647d9d0445UL) /* 1019 */
P( 2, 0x680e0a87e5ec7155UL, 0x004030241b144f3bUL) /* 1021 */
P(10, 0xbbf70fa49fe829b7UL, 0x003f90c2ab542cb1UL) /* 1031 */
P( 2, 0xd69d1e7b6a50ca39UL, 0x003f71412d59f597UL) /* 1033 */
P( 6, 0x1a1e0f46b6d26aefUL, 0x003f137701b98841UL) /* 1039 */
P(10, 0x7429f9a7a8251829UL, 0x003e79886b60e278UL) /* 1049 */
P( 2, 0xd9c2219d1b863613UL, 0x003e5b1916a7181dUL) /* 1051 */
P(10, 0x91406c1820d077adUL, 0x003dc4a50968f524UL) /* 1061 */
P( 2, 0x521f4ec02e3d2b97UL, 0x003da6e4c9550321UL) /* 1063 */
P( 6, 0xbb8283b63dc8eba5UL, 0x003d4e4f06f1def3UL) /* 1069 */
P(18, 0x431eda153229ebbfUL, 0x003c4a6bdd24f9a4UL) /* 1087 */
P( 4, 0xaf0bf78d7e01686bUL, 0x003c11d54b525c73UL) /* 1091 */
P( 2, 0xa9ced0742c086e8dUL, 0x003bf5b1c5721065UL) /* 1093 */
P( 4, 0xc26458ad9f632df9UL, 0x003bbdb9862f23b4UL) /* 1097 */
P( 6, 0xbbff1255dff892afUL, 0x003b6a8801db5440UL) /* 1103 */
P( 6, 0xcbd49a333f04d8fdUL, 0x003b183cf0fed886UL) /* 1109 */
P( 8, 0xec84ed6f9cfdeff5UL, 0x003aabe394bdc3f4UL) /* 1117 */
P( 6, 0x97980cc40bda9d4bUL, 0x003a5ba3e76156daUL) /* 1123 */
P( 6, 0x777f34d524f5cbd9UL, 0x003a0c3e953378dbUL) /* 1129 */
P(22, 0x2797051d94cbbb7fUL, 0x0038f03561320b1eUL) /* 1151 */
P( 2, 0xea769051b4f43b81UL, 0x0038d6ecaef5908aUL) /* 1153 */
P(10, 0xce7910f3034d4323UL, 0x003859cf221e6069UL) /* 1163 */
P( 8, 0x92791d1374f5b99bUL, 0x0037f7415dc9588aUL) /* 1171 */
P(10, 0x89a5645cc68ea1b5UL, 0x00377df0d3902626UL) /* 1181 */
P( 6, 0x5f8aacf796c0cf0bUL, 0x00373622136907faUL) /* 1187 */
P( 6, 0xf2e90a15e33edf99UL, 0x0036ef0c3b39b92fUL) /* 1193 */
P( 8, 0x8e99e5feb897c451UL, 0x0036915f47d55e6dUL) /* 1201 */
P(12, 0xaca2eda38fb91695UL, 0x0036072cf3f866fdUL) /* 1213 */
P( 4, 0x5d9b737be5ea8b41UL, 0x0035d9b737be5ea8UL) /* 1217 */
P( 6, 0x4aefe1db93fd7cf7UL, 0x0035961559cc81c7UL) /* 1223 */
P( 6, 0xa0994ef20b3f8805UL, 0x0035531c897a4592UL) /* 1229 */
P( 2, 0x103890bda912822fUL, 0x00353ceebd3e98a4UL) /* 1231 */
P( 6, 0xb441659d13a9147dUL, 0x0034fad381585e5eUL) /* 1237 */
P(12, 0x1e2134440c4c3f21UL, 0x00347884d1103130UL) /* 1249 */
P(10, 0x263a27727a6883c3UL, 0x00340dd3ac39bf56UL) /* 1259 */
P(18, 0x78e221472ab33855UL, 0x003351fdfecc140cUL) /* 1277 */
P( 2, 0x95eac88e82e6faffUL, 0x00333d72b089b524UL) /* 1279 */
P( 4, 0xf66c258317be8dabUL, 0x0033148d44d6b261UL) /* 1283 */
P( 6, 0x09ee202c7cb91939UL, 0x0032d7aef8412458UL) /* 1289 */
P( 2, 0x8d2fca1042a09ea3UL, 0x0032c3850e79c0f1UL) /* 1291 */
P( 6, 0x82779c856d8b8bf1UL, 0x00328766d59048a2UL) /* 1297 */
P( 4, 0x3879361cba8a223dUL, 0x00325fa18cb11833UL) /* 1301 */
P( 2, 0xf23f43639c3182a7UL, 0x00324bd659327e22UL) /* 1303 */
P( 4, 0xa03868fc474bcd13UL, 0x0032246e784360f4UL) /* 1307 */
P(12, 0x651e78b8c5311a97UL, 0x0031afa5f1a33a08UL) /* 1319 */
P( 2, 0x8ffce639c00c6719UL, 0x00319c63ff398e70UL) /* 1321 */
P( 6, 0xf7b460754b0b61cfUL, 0x003162f7519a86a7UL) /* 1327 */
P(34, 0x7b03f3359b8e63b1UL, 0x0030271fc9d3fc3cUL) /* 1361 */
P( 6, 0xa55c5326041eb667UL, 0x002ff104ae89750bUL) /* 1367 */
P( 6, 0x647f88ab896a76f5UL, 0x002fbb62a236d133UL) /* 1373 */
P( 8, 0x8fd971434a55a46dUL, 0x002f74997d2070b4UL) /* 1381 */
P(18, 0x9fbf969958046447UL, 0x002ed84aa8b6fce3UL) /* 1399 */
P(10, 0x9986feba69be3a81UL, 0x002e832df7a46dbdUL) /* 1409 */
P(14, 0xa668b3e6d053796fUL, 0x002e0e0846857cabUL) /* 1423 */
P( 4, 0x97694e6589f4e09bUL, 0x002decfbdfb55ee6UL) /* 1427 */
P( 2, 0x37890c00b7721dbdUL, 0x002ddc876f3ff488UL) /* 1429 */
P( 4, 0x5ac094a235f37ea9UL, 0x002dbbc1d4c482c4UL) /* 1433 */
P( 6, 0x31cff775f2d5d65fUL, 0x002d8af0e0de0556UL) /* 1439 */
P( 8, 0xddad8e6b36505217UL, 0x002d4a7b7d14b30aUL) /* 1447 */
P( 4, 0x5a27df897062cd03UL, 0x002d2a85073bcf4eUL) /* 1451 */
P( 2, 0xe2396fe0fdb5a625UL, 0x002d1a9ab13e8be4UL) /* 1453 */
P( 6, 0xb352a4957e82317bUL, 0x002ceb1eb4b9fd8bUL) /* 1459 */
P(12, 0xd8ab3f2c60c2ea3fUL, 0x002c8d503a79794cUL) /* 1471 */
P(10, 0x6893f702f0452479UL, 0x002c404d708784edUL) /* 1481 */
P( 2, 0x9686fdc182acf7e3UL, 0x002c31066315ec52UL) /* 1483 */
P( 4, 0x6854037173dce12fUL, 0x002c1297d80f2664UL) /* 1487 */
P( 2, 0x7f0ded1685c27331UL, 0x002c037044c55f6bUL) /* 1489 */
P( 4, 0xeeda72e1fe490b7dUL, 0x002be5404cd13086UL) /* 1493 */
P( 6, 0x9e7bfc959a8e6e53UL, 0x002bb845adaf0cceUL) /* 1499 */
P(12, 0x49b314d6d4753dd7UL, 0x002b5f62c639f16dUL) /* 1511 */
P(12, 0x2e8f8c5ac4aa1b3bUL, 0x002b07e6734f2b88UL) /* 1523 */
P( 8, 0xb8ef723481163d33UL, 0x002ace569d8342b7UL) /* 1531 */
P(12, 0x6a2ec96a594287b7UL, 0x002a791d5dbd4dcfUL) /* 1543 */
P( 6, 0xdba41c6d13aab8c5UL, 0x002a4eff8113017cUL) /* 1549 */
P( 4, 0xc2adbe648dc3aaf1UL, 0x002a3319e156df32UL) /* 1553 */
P( 6, 0x87a2bade565f91a7UL, 0x002a0986286526eaUL) /* 1559 */
P( 8, 0x4d6fe8798c01f5dfUL, 0x0029d29551d91e39UL) /* 1567 */
P( 4, 0x3791310c8c23d98bUL, 0x0029b7529e109f0aUL) /* 1571 */
P( 8, 0xf80e446b01228883UL, 0x00298137491ea465UL) /* 1579 */
P( 4, 0x9aed1436fbf500cfUL, 0x0029665e1eb9f9daUL) /* 1583 */
P(14, 0x7839b54cc8b24115UL, 0x002909752e019a5eUL) /* 1597 */
P( 4, 0xc128c646ad0309c1UL, 0x0028ef35e2e5efb0UL) /* 1601 */
P( 6, 0x14de631624a3c377UL, 0x0028c815aa4b8278UL) /* 1607 */
P( 2, 0x3f7b9fe68b0ecbf9UL, 0x0028bb1b867199daUL) /* 1609 */
P( 4, 0x284ffd75ec00a285UL, 0x0028a13ff5d7b002UL) /* 1613 */
P( 6, 0x37803cb80dea2ddbUL, 0x00287ab3f173e755UL) /* 1619 */
P( 2, 0x86b63f7c9ac4c6fdUL, 0x00286dead67713bdUL) /* 1621 */
P( 6, 0x8b6851d1bd99b9d3UL, 0x002847bfcda6503eUL) /* 1627 */
P(10, 0xb62fda77ca343b6dUL, 0x002808c1ea6b4777UL) /* 1637 */
P(20, 0x1f0dc009e34383c9UL, 0x00278d0e0f23ff61UL) /* 1657 */
P( 6, 0x496dc21ddd35b97fUL, 0x002768863c093c7fUL) /* 1663 */
P( 4, 0xb0e96ce17090f82bUL, 0x0027505115a73ca8UL) /* 1667 */
P( 2, 0xaadf05acdd7d024dUL, 0x00274441a61dc1b9UL) /* 1669 */
P(24, 0xcb138196746eafb5UL, 0x0026b5c166113cf0UL) /* 1693 */
P( 4, 0x347f523736755d61UL, 0x00269e65ad07b18eUL) /* 1697 */
P( 2, 0xd14a48a051f7dd0bUL, 0x002692c25f877560UL) /* 1699 */
P(10, 0x474d71b1ce914d25UL, 0x002658fa7523cd11UL) /* 1709 */
P(12, 0x386063f5e28c1f89UL, 0x0026148710cf0f9eUL) /* 1721 */
P( 2, 0x1db7325e32d04e73UL, 0x002609363b22524fUL) /* 1723 */
P(10, 0xfef748d3893b880dUL, 0x0025d1065a1c1122UL) /* 1733 */
P( 8, 0x2f3351506e935605UL, 0x0025a48a382b863fUL) /* 1741 */
P( 6, 0x7a3637fa2376415bUL, 0x0025837190eccdbcUL) /* 1747 */
P( 6, 0x4ac525d2baa21969UL, 0x00256292e95d510cUL) /* 1753 */
P( 6, 0x3a11c16b42cd351fUL, 0x002541eda98d068cUL) /* 1759 */
P(18, 0x6c7abde0049c2a11UL, 0x0024e15087fed8f5UL) /* 1777 */
P( 6, 0x54dad0303e069ac7UL, 0x0024c18b20979e5dUL) /* 1783 */
P( 4, 0xebf1ac9fdfe91433UL, 0x0024ac7b336de0c5UL) /* 1787 */
P( 2, 0xfafdda8237cec655UL, 0x0024a1fc478c60bbUL) /* 1789 */
P(12, 0xdce3ff6e71ffb739UL, 0x002463801231c009UL) /* 1801 */
P(10, 0xbed5737d6286db1bUL, 0x0024300fd506ed33UL) /* 1811 */
P(12, 0xe479e431fe08b4dfUL, 0x0023f314a494da81UL) /* 1823 */
P( 8, 0x9dd9b0dd7742f897UL, 0x0023cadedd2fad3aUL) /* 1831 */
P(16, 0x8f09d7402c5a5e87UL, 0x00237b7ed2664a03UL) /* 1847 */
P(14, 0x9216d5c4d958738dUL, 0x0023372967dbaf1dUL) /* 1861 */
P( 6, 0xb3139ba11d34ca63UL, 0x00231a308a371f20UL) /* 1867 */
P( 4, 0x47d54f7ed644afafUL, 0x002306fa63e1e600UL) /* 1871 */
P( 2, 0x92a81d85cf11a1b1UL, 0x0022fd6731575684UL) /* 1873 */
P( 4, 0x754b26533253bdfdUL, 0x0022ea507805749cUL) /* 1877 */
P( 2, 0xbbe0efc980bfd467UL, 0x0022e0cce8b3d720UL) /* 1879 */
P(10, 0xc0d8d594f024dca1UL, 0x0022b1887857d161UL) /* 1889 */
P(12, 0x8238d43bcaac1a65UL, 0x00227977fcc49cc0UL) /* 1901 */
P( 6, 0x27779c1fae6175bbUL, 0x00225db37b5e5f4fUL) /* 1907 */
P( 6, 0xa746ca9af708b2c9UL, 0x0022421b91322ed6UL) /* 1913 */
P(18, 0x93f3cd9f389be823UL, 0x0021f05b35f52102UL) /* 1931 */
P( 2, 0x5cb4a4c04c489345UL, 0x0021e75de5c70d60UL) /* 1933 */
P(16, 0xbf6047743e85b6b5UL, 0x0021a01d6c19be96UL) /* 1949 */
P( 2, 0x61c147831563545fUL, 0x0021974a6615c81aUL) /* 1951 */
P(22, 0xedb47c0ae62dee9dUL, 0x00213767697cf36aUL) /* 1973 */
P( 6, 0x0a3824386673a573UL, 0x00211d9f7fad35f1UL) /* 1979 */
P( 8, 0xa4a77d19e575a0ebUL, 0x0020fb7d9dd36c18UL) /* 1987 */
P( 6, 0xa2bee045e066c279UL, 0x0020e2123d661e0eUL) /* 1993 */
P( 4, 0xc23618de8ab43d05UL, 0x0020d135b66ae990UL) /* 1997 */
P( 2, 0x266b515216cb9f2fUL, 0x0020c8cded4d7a8eUL) /* 1999 */
P( 4, 0xe279edd9e9c2e85bUL, 0x0020b80b3f43ddbfUL) /* 2003 */
P( 8, 0xd0c591c221dc9c53UL, 0x002096b9180f46a6UL) /* 2011 */
P( 6, 0x06da8ee9c9ee7c21UL, 0x00207de7e28de5daUL) /* 2017 */
P(10, 0x9dfebcaf4c27e8c3UL, 0x002054dec8cf1fb3UL) /* 2027 */
P( 2, 0x49aeff9f19dd6de5UL, 0x00204cb630b3aab5UL) /* 2029 */
P(10, 0x86976a57a296e9c7UL, 0x00202428adc37bebUL) /* 2039 */
P(14, 0xa3b9abf4872b84cdUL, 0x001fec0c7834def4UL) /* 2053 */
P(10, 0x34fca6483895e6efUL, 0x001fc46fae98a1d0UL) /* 2063 */
P( 6, 0x34b5a333988f873dUL, 0x001facda430ff619UL) /* 2069 */
P(12, 0xd9dd4f19b5f17be1UL, 0x001f7e17dd8e15e5UL) /* 2081 */
P( 2, 0xb935b507fd0ce78bUL, 0x001f765a3556a4eeUL) /* 2083 */
P( 4, 0xb450f5540660e797UL, 0x001f66ea49d802f1UL) /* 2087 */
P( 2, 0x63ff82831ffc1419UL, 0x001f5f3800faf9c0UL) /* 2089 */
P(10, 0x8992f718c22a32fbUL, 0x001f38f4e6c0f1f9UL) /* 2099 */
P(12, 0x5f3253ad0d37e7bfUL, 0x001f0b8546752578UL) /* 2111 */
P( 2, 0x007c0ffe0fc007c1UL, 0x001f03ff83f001f0UL) /* 2113 */
P(16, 0x4d8ebadc0c0640b1UL, 0x001ec853b0a3883cUL) /* 2129 */
P( 2, 0xe2729af831037bdbUL, 0x001ec0ee573723ebUL) /* 2131 */
P( 6, 0xb8f64bf30feebfe9UL, 0x001eaad38e6f6894UL) /* 2137 */
P( 4, 0xda93124b544c0bf5UL, 0x001e9c28a765fe53UL) /* 2141 */
P( 2, 0x9cf7ff0b593c539fUL, 0x001e94d8758c2003UL) /* 2143 */
P(10, 0xd6bd8861fa0e07d9UL, 0x001e707ba8f65e68UL) /* 2153 */
P( 8, 0x5cfe75c0bd8ab891UL, 0x001e53a2a68f574eUL) /* 2161 */
P(18, 0x43e808757c2e862bUL, 0x001e1380a56b438dUL) /* 2179 */
P(24, 0x90caa96d595c9d93UL, 0x001dbf9f513a3802UL) /* 2203 */
P( 4, 0x8fd550625d07135fUL, 0x001db1d1d58bc600UL) /* 2207 */
P( 6, 0x76b010a86e209f2dUL, 0x001d9d358f53de38UL) /* 2213 */
P( 8, 0xecc0426447769b25UL, 0x001d81e6df6165c7UL) /* 2221 */
P(16, 0xe381339caabe3295UL, 0x001d4bdf7fd40e30UL) /* 2237 */
P( 2, 0xd1b190a2d0c7673fUL, 0x001d452c7a1c958dUL) /* 2239 */
P( 4, 0xc3bce3cf26b0e7ebUL, 0x001d37cf9b902659UL) /* 2243 */
P( 8, 0x5f87e76f56c61ce3UL, 0x001d1d3a5791e97bUL) /* 2251 */
P(16, 0xc06c6857a124b353UL, 0x001ce89fe6b47416UL) /* 2267 */
P( 2, 0x38c040fcba630f75UL, 0x001ce219f3235071UL) /* 2269 */
P( 4, 0xd078bc4fbd533b21UL, 0x001cd516dcf92139UL) /* 2273 */
P( 8, 0xde8e15c5dd354f59UL, 0x001cbb33bd1c2b8bUL) /* 2281 */
P( 6, 0xca61d53d7414260fUL, 0x001ca7e7d2546688UL) /* 2287 */
P( 6, 0xb56bf5ba8eae635dUL, 0x001c94b5c1b3dbd3UL) /* 2293 */
P( 4, 0x44a72cb0fb6e3949UL, 0x001c87f7f9c241c1UL) /* 2297 */
P(12, 0x879839a714f45bcdUL, 0x001c6202706c35a9UL) /* 2309 */
P( 2, 0x02a8994fde5314b7UL, 0x001c5bb8a9437632UL) /* 2311 */
P(22, 0xb971920cf2b90135UL, 0x001c174343b4111eUL) /* 2333 */
P( 6, 0x8a8fd0b7df9a6e8bUL, 0x001c04d0d3e46b42UL) /* 2339 */
P( 2, 0xb31f9a84c1c6eaadUL, 0x001bfeb00fbf4308UL) /* 2341 */
P( 6, 0x92293b02823c6d83UL, 0x001bec5dce0b202dUL) /* 2347 */
P( 4, 0xeee77ff20fe5ddcfUL, 0x001be03444620037UL) /* 2351 */
P( 6, 0x0e1ea0f6c496c11dUL, 0x001bce09c66f6fc3UL) /* 2357 */
P(14, 0xfdf2d3d6f88ccb6bUL, 0x001ba40228d02b30UL) /* 2371 */
P( 6, 0xfa9d74a3457738f9UL, 0x001b9225b1cf8919UL) /* 2377 */
P( 4, 0xefc3ca3db71a5785UL, 0x001b864a2ff3f53fUL) /* 2381 */
P( 2, 0x8e2071718d0d6dafUL, 0x001b80604150e49bUL) /* 2383 */
P( 6, 0xbc0fdbfeb6cfabfdUL, 0x001b6eb1aaeaacf3UL) /* 2389 */
P( 4, 0x1eeab613e5e5aee9UL, 0x001b62f48da3c8ccUL) /* 2393 */
P( 6, 0x2d2388e90e9e929fUL, 0x001b516babe96092UL) /* 2399 */
P(12, 0x81dbafba588ddb43UL, 0x001b2e9cef1e0c87UL) /* 2411 */
P( 6, 0x52eebc51c4799791UL, 0x001b1d56bedc849bUL) /* 2417 */
P( 6, 0x1c6bc4693b45a047UL, 0x001b0c267546aec0UL) /* 2423 */
P(14, 0x06eee0974498874dUL, 0x001ae45f62024fa0UL) /* 2437 */
P( 4, 0xd85b7377a9953cb9UL, 0x001ad917631b5f54UL) /* 2441 */
P( 6, 0x4b6df412d4caf56fUL, 0x001ac83d18cb608fUL) /* 2447 */
P(12, 0x6b8afbbb4a053493UL, 0x001aa6c7ad8c063fUL) /* 2459 */
P( 8, 0xcc5299c96ac7720bUL, 0x001a90a7b1228e2aUL) /* 2467 */
P( 6, 0xadce84b5c710aa99UL, 0x001a8027c03ba059UL) /* 2473 */
P( 4, 0x9d673f5aa3804225UL, 0x001a7533289deb89UL) /* 2477 */
P(26, 0xe6541268efbce7f7UL, 0x001a2ed7ce16b49fUL) /* 2503 */
P(18, 0xfcf41e76cf5be669UL, 0x0019fefc0a279a73UL) /* 2521 */
P(10, 0x5c3eb5dc31c383cbUL, 0x0019e4b0cd873b5fUL) /* 2531 */
P( 8, 0x301832d11d8ad6c3UL, 0x0019cfcdfd60e514UL) /* 2539 */
P( 4, 0x2e9c0942f1ce450fUL, 0x0019c56932d66c85UL) /* 2543 */
P( 6, 0x97f3f2be37a39a5dUL, 0x0019b5e1ab6fc7c2UL) /* 2549 */
P( 2, 0xe8b7d8a9654187c7UL, 0x0019b0b8a62f2a73UL) /* 2551 */
P( 6, 0xb5d024d7da5b1b55UL, 0x0019a149fc98942cUL) /* 2557 */
P(22, 0xb8ba9d6e7ae3501bUL, 0x001969517ec25b85UL) /* 2579 */
P(12, 0xf50865f71b90f1dfUL, 0x00194b3083360ba8UL) /* 2591 */
P( 2, 0x739c1682847df9e1UL, 0x00194631f4bebdc1UL) /* 2593 */
P(16, 0xc470a4d842b90ed1UL, 0x00191e84127268fdUL) /* 2609 */
P( 8, 0x1fb1be11698cc409UL, 0x00190adbb543984fUL) /* 2617 */
P( 4, 0xd8d5512a7cd35d15UL, 0x001901130bd18200UL) /* 2621 */
P(12, 0xa5496821723e07f9UL, 0x0018e3e6b889ac94UL) /* 2633 */
P(14, 0xbcc8c6d7abaa8167UL, 0x0018c233420e1ec1UL) /* 2647 */
P(10, 0x52c396c95eb619a1UL, 0x0018aa5872d92bd6UL) /* 2657 */
P( 2, 0x6eb7e380878ec74bUL, 0x0018a5989945ccf9UL) /* 2659 */
P( 4, 0x3d5513b504537157UL, 0x00189c1e60b57f60UL) /* 2663 */
P( 8, 0x314391f8862e948fUL, 0x0018893fbc8690b9UL) /* 2671 */
P( 6, 0xdc0b17cfcd81f5ddUL, 0x00187b2bb3e1041cUL) /* 2677 */
P( 6, 0x2f6bea3ec89044b3UL, 0x00186d27c9cdcfb8UL) /* 2683 */
P( 4, 0xce13a05869f1b57fUL, 0x001863d8bf4f2c1cUL) /* 2687 */
P( 2, 0x7593474e8ace3581UL, 0x00185f33e2ad7593UL) /* 2689 */
P( 4, 0x07fc329295a05e4dUL, 0x001855ef75973e13UL) /* 2693 */
P( 6, 0xb05377cba4908d23UL, 0x001848160153f134UL) /* 2699 */
P( 8, 0xe7b2131a628aa39bUL, 0x001835b72e6f0656UL) /* 2707 */
P( 4, 0x9031dbed7de01527UL, 0x00182c922d83eb39UL) /* 2711 */
P( 2, 0x76844b1c670aa9a9UL, 0x0018280243c0365aUL) /* 2713 */
P( 6, 0x6a03f4533b08915fUL, 0x00181a5cd5898e73UL) /* 2719 */
P(10, 0x1dbca579db0a3999UL, 0x001803c0961773aaUL) /* 2729 */
P( 2, 0x002ffe800bffa003UL, 0x0017ff4005ffd001UL) /* 2731 */
P(10, 0x478ab1a3e936139dUL, 0x0017e8d670433edbUL) /* 2741 */
P( 8, 0x66e722bc4c5cc095UL, 0x0017d7066cf4bb5dUL) /* 2749 */
P( 4, 0x7a8f63c717278541UL, 0x0017ce285b806b1fUL) /* 2753 */
P(14, 0xdf6eee24d292bc2fUL, 0x0017af52cdf27e02UL) /* 2767 */
P(10, 0x9fc20d17237dd569UL, 0x0017997d47d01039UL) /* 2777 */
P(12, 0xcdf9932356bda2edUL, 0x00177f7ec2c6d0baUL) /* 2789 */
P( 2, 0x97b5e332e80f68d7UL, 0x00177b2f3cd00756UL) /* 2791 */
P( 6, 0x46eee26fd875e2e5UL, 0x00176e4a22f692a0UL) /* 2797 */
P( 4, 0x3548a8e65157a611UL, 0x001765b94271e11bUL) /* 2801 */
P( 2, 0xc288d03be9b71e3bUL, 0x001761732b044ae4UL) /* 2803 */
P(16, 0x8151186db38937abUL, 0x00173f7a5300a2bcUL) /* 2819 */
P(14, 0x7800b910895a45f1UL, 0x001722112b48be1fUL) /* 2833 */
P( 4, 0xaee0b024182eec3dUL, 0x001719b7a16eb843UL) /* 2837 */
P( 6, 0x96323eda173b5713UL, 0x00170d3c99cc5052UL) /* 2843 */
P( 8, 0x0ed0dbd03ae77c8bUL, 0x0016fcad7aed3bb6UL) /* 2851 */
P( 6, 0xf73800b7828dc119UL, 0x0016f051b8231ffdUL) /* 2857 */
P( 4, 0x1b61715ec22b7ca5UL, 0x0016e81beae20643UL) /* 2861 */
P(18, 0xa8533a991ead64bfUL, 0x0016c3721584c1d8UL) /* 2879 */
P( 8, 0x7f6c7290e46c2e77UL, 0x0016b34c2ba09663UL) /* 2887 */
P(10, 0x6325e8d907b01db1UL, 0x00169f3ce292ddcdUL) /* 2897 */
P( 6, 0x28909f70152a1067UL, 0x00169344b2220a0dUL) /* 2903 */
P( 6, 0xea7077af0997a0f5UL, 0x001687592593c1b1UL) /* 2909 */
P( 8, 0x7e605cad10c32e6dUL, 0x00167787f1418ec9UL) /* 2917 */
P(10, 0x471b33570635b38fUL, 0x001663e190395ff2UL) /* 2927 */
P(12, 0xab559fa997a61bb3UL, 0x00164c7a4b6eb5b3UL) /* 2939 */
P(14, 0xad4bdae562bddab9UL, 0x0016316a061182fdUL) /* 2953 */
P( 4, 0x055e1b2f2ed62f45UL, 0x001629ba914584e4UL) /* 2957 */
P( 6, 0x03cd328b1a2dca9bUL, 0x00161e3d57de21b2UL) /* 2963 */
P( 6, 0xd28f4e08733218a9UL, 0x001612cc01b977f0UL) /* 2969 */
P( 2, 0xb6800b077f186293UL, 0x00160efe30c525ffUL) /* 2971 */
P(28, 0x6fbd138c3fd9c207UL, 0x0015da45249ec5deUL) /* 2999 */
P( 2, 0xb117ccd12ae88a89UL, 0x0015d68ab4acff92UL) /* 3001 */
P(10, 0x2f1a1a044046bcebUL, 0x0015c3f989d1eb15UL) /* 3011 */
P( 8, 0x548aba0b060541e3UL, 0x0015b535ad11b8f0UL) /* 3019 */
P( 4, 0xcf4e808cea111b2fUL, 0x0015addb3f424ec1UL) /* 3023 */
P(14, 0xdbec1b4fa855a475UL, 0x00159445cb91be6bUL) /* 3037 */
P( 4, 0xe3f794eb600d7821UL, 0x00158d0199771e63UL) /* 3041 */
P( 8, 0x34fae0d9a11f7c59UL, 0x00157e87d9b69e04UL) /* 3049 */
P(12, 0xf006b0ccbbac085dUL, 0x001568f58bc01ac3UL) /* 3061 */
P( 6, 0x3f45076dc3114733UL, 0x00155e3c993fda9bUL) /* 3067 */
P(12, 0xeef49bfa58a1a1b7UL, 0x001548eacc5e1e6eUL) /* 3079 */
P( 4, 0x12c4218bea691fa3UL, 0x001541d8f91ba6a7UL) /* 3083 */
P( 6, 0xbc7504e3bd5e64f1UL, 0x00153747060cc340UL) /* 3089 */
P(20, 0x4ee21c292bb92fadUL, 0x001514569f93f7c4UL) /* 3109 */
P(10, 0x34338b7327a4bacfUL, 0x00150309705d3d79UL) /* 3119 */
P( 2, 0x3fe5c0833d6fccd1UL, 0x0014ff97020cf5bfUL) /* 3121 */
P(16, 0xb1e70743535203c1UL, 0x0014e42c114cf47eUL) /* 3137 */
P(26, 0xefbb5dcdfb4e43d3UL, 0x0014b835bdcb6447UL) /* 3163 */
P( 4, 0xca68467ca5394f9fUL, 0x0014b182b53a9ab7UL) /* 3167 */
P( 2, 0x8c51c081408b97a1UL, 0x0014ae2ad094a3d3UL) /* 3169 */
P(12, 0x3275a899dfa5dd65UL, 0x00149a320ea59f96UL) /* 3181 */
P( 6, 0x9e674cb62e1b78bbUL, 0x001490441de1a2fbUL) /* 3187 */
P( 4, 0xa37ff5bb2a998d47UL, 0x001489aacce57200UL) /* 3191 */
P(12, 0x792a999db131a22bUL, 0x001475f82ad6ff99UL) /* 3203 */
P( 6, 0x1b48841bc30d29b9UL, 0x00146c2cfe53204fUL) /* 3209 */
P( 8, 0xf06721d2011d3471UL, 0x00145f2ca490d4a1UL) /* 3217 */
P( 4, 0x93fd2386dff85ebdUL, 0x001458b2aae0ec87UL) /* 3221 */
P( 8, 0x4ce72f54c07ed9b5UL, 0x00144bcb0a3a3150UL) /* 3229 */
P(22, 0xd6d0fd3e71dd827bUL, 0x001428a1e65441d4UL) /* 3251 */
P( 2, 0x856405fb1eed819dUL, 0x00142575a6c210d7UL) /* 3253 */
P( 4, 0x8ea8aceb7c443989UL, 0x00141f2025ba5c46UL) /* 3257 */
P( 2, 0x34a13026f62e5873UL, 0x00141bf6e35420fdUL) /* 3259 */
P(12, 0x1eea0208ec0af4f7UL, 0x001409141d1d313aUL) /* 3271 */
P(28, 0x63679853cea598cbUL, 0x0013dd8bc19c3513UL) /* 3299 */
P( 2, 0xc30b3ebd61f2d0edUL, 0x0013da76f714dc8fUL) /* 3301 */
P( 6, 0x7eb9037bc7f43bc3UL, 0x0013d13e50f8f49eUL) /* 3307 */
P( 6, 0xa583e6f6ce016411UL, 0x0013c80e37ca3819UL) /* 3313 */
P( 6, 0xf1938d895f1a74c7UL, 0x0013bee69fa99ccfUL) /* 3319 */
P( 4, 0x80cf1491c1e81e33UL, 0x0013b8d0ede55835UL) /* 3323 */
P( 6, 0x3c0f12886ba8f301UL, 0x0013afb7680bb054UL) /* 3329 */
P( 2, 0x0e4b786e0dfcc5abUL, 0x0013acb0c3841c96UL) /* 3331 */
P(12, 0x672684c93f2d41efUL, 0x00139a9c5f434fdeUL) /* 3343 */
P( 4, 0xe00757badb35c51bUL, 0x0013949cf33a0d9dUL) /* 3347 */
P(12, 0xd6d84afe66472edfUL, 0x001382b4a00c31b0UL) /* 3359 */
P( 2, 0xfbbc0eedcbbfb6e1UL, 0x00137fbbc0eedcbbUL) /* 3361 */
P(10, 0x250f43aa08a84983UL, 0x001370ecf047b069UL) /* 3371 */
P( 2, 0x04400e927b1acaa5UL, 0x00136df9790e3155UL) /* 3373 */
P(16, 0x56572be34b9d3215UL, 0x0013567dd8defd5bUL) /* 3389 */
P( 2, 0x87964ef7781c62bfUL, 0x0013539261fdbc34UL) /* 3391 */
P(16, 0x29ed84051c06e9afUL, 0x00133c564292d28aUL) /* 3407 */
P( 6, 0xb00acd11ed3f87fdUL, 0x001333ae178d6388UL) /* 3413 */
P(20, 0x06307881744152d9UL, 0x0013170ad00d1fd7UL) /* 3433 */
P(16, 0x7a786459f5c1ccc9UL, 0x0013005f01db0947UL) /* 3449 */
P( 8, 0x1308125d74563281UL, 0x0012f51d40342210UL) /* 3457 */
P( 4, 0x395310a480b3e34dUL, 0x0012ef815e4ed950UL) /* 3461 */
P( 2, 0x35985baa8b202837UL, 0x0012ecb4abccd827UL) /* 3463 */
P( 4, 0x96304a6e052b3223UL, 0x0012e71dc1d3d820UL) /* 3467 */
P( 2, 0xbd8265fc9af8fd45UL, 0x0012e45389a16495UL) /* 3469 */
P(22, 0x1b6d0b383ec58e0bUL, 0x0012c5d9226476ccUL) /* 3491 */
P( 8, 0xc21a7c3b68b28503UL, 0x0012badc391156fdUL) /* 3499 */
P(12, 0x236fa180fbfd6007UL, 0x0012aa78e412f522UL) /* 3511 */
P( 6, 0xc42accd440ed9595UL, 0x0012a251f5f47fd1UL) /* 3517 */
P(10, 0x7acf7128236ba3f7UL, 0x001294cb85c53534UL) /* 3527 */
P( 2, 0xf909367a987b9c79UL, 0x0012921963beb65eUL) /* 3529 */
P( 4, 0xb64efb252bfba705UL, 0x00128cb777c69ca8UL) /* 3533 */
P( 6, 0x980d4f5a7e4cd25bUL, 0x001284aa6cf07294UL) /* 3539 */
P( 2, 0xe1ecc4ef27b0c37dUL, 0x001281fcf6ac7f87UL) /* 3541 */
P( 6, 0x9111aebb81d72653UL, 0x001279f937367db9UL) /* 3547 */
P(10, 0x8951f985cb2c67edUL, 0x00126cad0488be94UL) /* 3557 */
P( 2, 0xc439d4fc54e0b5d7UL, 0x00126a06794646a2UL) /* 3559 */
P(12, 0xe857bf31896d533bUL, 0x00125a2f2bcd3e95UL) /* 3571 */
P(10, 0xb614bb4cb5023755UL, 0x00124d108389e6b1UL) /* 3581 */
P( 2, 0x938a89e5473bf1ffUL, 0x00124a73083771acUL) /* 3583 */
P(10, 0xeac481aca34de039UL, 0x00123d6acda0620aUL) /* 3593 */
P(14, 0x14b961badf4809a7UL, 0x00122b4b2917eafdUL) /* 3607 */
P( 6, 0x76784fecba352435UL, 0x00122391bfce1e2fUL) /* 3613 */
P( 4, 0xefa689bb58aef5e1UL, 0x00121e6f1ea579f2UL) /* 3617 */
P( 6, 0xb2b2c4db9c3a8197UL, 0x001216c09e471568UL) /* 3623 */
P( 8, 0x2503bc992279f8cfUL, 0x00120c8cb9d93909UL) /* 3631 */
P( 6, 0xd2ab9aec5ca1541dUL, 0x001204ed58e64ef9UL) /* 3637 */
P( 6, 0x3e78ba1460f99af3UL, 0x0011fd546578f00cUL) /* 3643 */
P(16, 0x0a01426572cfcb63UL, 0x0011e9310b8b4c9cUL) /* 3659 */
P(12, 0xbea857968f3cbd67UL, 0x0011da3405db9911UL) /* 3671 */
P( 2, 0x78db213eefe659e9UL, 0x0011d7b6f4eb055dUL) /* 3673 */
P( 4, 0x963e8541a74d35f5UL, 0x0011d2bee748c145UL) /* 3677 */
P(14, 0x9e22d152776f2e43UL, 0x0011c1706ddce7a7UL) /* 3691 */
P( 6, 0x05d10d39d1e1f291UL, 0x0011ba0fed2a4f14UL) /* 3697 */
P( 4, 0x374468dccaced1ddUL, 0x0011b528538ed64aUL) /* 3701 */
P( 8, 0x8d145c7d110c5ad5UL, 0x0011ab61404242acUL) /* 3709 */
P(10, 0x3251a39f5acb5737UL, 0x00119f378ce81d2fUL) /* 3719 */
P( 8, 0xa66e50171443506fUL, 0x001195889ece79daUL) /* 3727 */
P( 6, 0x124f69ad91dd4cbdUL, 0x00118e4c65387077UL) /* 3733 */
P( 6, 0xec24f8f2a61a2793UL, 0x001187161d70e725UL) /* 3739 */
P(22, 0xb472148e656b7a51UL, 0x00116cd6d1c85239UL) /* 3761 */
P( 6, 0x0adf9570e1142f07UL, 0x001165bbe7ce86b1UL) /* 3767 */
P( 2, 0x89bf33b065119789UL, 0x0011635ee344ce36UL) /* 3769 */
P(10, 0x8f0149803cb291ebUL, 0x0011579767b6d679UL) /* 3779 */
P(14, 0x8334b63afd190a31UL, 0x00114734711e2b54UL) /* 3793 */
P( 4, 0x920908d50d6aba7dUL, 0x0011428b90147f05UL) /* 3797 */
P( 6, 0x57d8b018c5a33d53UL, 0x00113b92f3021636UL) /* 3803 */
P(18, 0xea1773092dc27ee5UL, 0x001126cabc886884UL) /* 3821 */
P( 2, 0xcae5f38b7bf2e00fUL, 0x0011247eb1b85976UL) /* 3823 */
P(10, 0x2bd02df34f695349UL, 0x0011190bb01efd65UL) /* 3833 */
P(14, 0xddfecd5be62e2eb7UL, 0x0011091de0fd679cUL) /* 3847 */
P( 4, 0xdbf849ebec96c4a3UL, 0x001104963c7e4e0bUL) /* 3851 */
P( 2, 0xda31d4d0187357c5UL, 0x00110253516420b0UL) /* 3853 */
P(10, 0xe34e21cc2d5418a7UL, 0x0010f70db7c41797UL) /* 3863 */
P(14, 0x68ca5137a9e574adUL, 0x0010e75ee2bf9ecdUL) /* 3877 */
P( 4, 0x3eaa0d0f804bfd19UL, 0x0010e2e91c6e0676UL) /* 3881 */
P( 8, 0x554fb753cc20e9d1UL, 0x0010da049b9d428dUL) /* 3889 */
P(18, 0x797afcca1300756bUL, 0x0010c6248fe3b1a2UL) /* 3907 */
P( 4, 0x8b8d950b52eeea77UL, 0x0010c1c03ed690ebUL) /* 3911 */
P( 6, 0xfb6cd166acabc185UL, 0x0010bb2e1379e3a2UL) /* 3917 */
P( 2, 0x4eb6c5ed9437a7afUL, 0x0010b8fe7f61228eUL) /* 3919 */
P( 4, 0xd1eddbd91b790cdbUL, 0x0010b4a10d60a4f7UL) /* 3923 */
P( 6, 0x93d714ea4d8948e9UL, 0x0010ae192681ec0fUL) /* 3929 */
P( 2, 0x3ca13ed8145188d3UL, 0x0010abecfbe5b0aeUL) /* 3931 */
P(12, 0x829086016da89c57UL, 0x00109eefd568b96dUL) /* 3943 */
P( 4, 0xd7da1f432124a543UL, 0x00109a9ff178b40cUL) /* 3947 */
P(20, 0x7ead5581632fb07fUL, 0x00108531e22f9ff9UL) /* 3967 */
P(22, 0x35443837f63ec3bdUL, 0x00106ddec1af4417UL) /* 3989 */
#undef FIRST_OMITTED_PRIME
#define FIRST_OMITTED_PRIME 4001

View File

@@ -0,0 +1,172 @@
/* Use mpz_kronecker_ui() to calculate an estimate for the quadratic
class number h(d), for a given negative fundamental discriminant, using
Dirichlet's analytic formula.
Copyright 1999-2002 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see https://www.gnu.org/licenses/. */
/* Usage: qcn [-p limit] <discriminant>...
A fundamental discriminant means one of the form D or 4*D with D
square-free. Each argument is checked to see it's congruent to 0 or 1
mod 4 (as all discriminants must be), and that it's negative, but there's
no check on D being square-free.
This program is a bit of a toy, there are better methods for calculating
the class number and class group structure.
Reference:
Daniel Shanks, "Class Number, A Theory of Factorization, and Genera",
Proc. Symp. Pure Math., vol 20, 1970, pages 415-440.
*/
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "gmp.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
/* A simple but slow primality test. */
int
prime_p (unsigned long n)
{
unsigned long i, limit;
if (n == 2)
return 1;
if (n < 2 || !(n&1))
return 0;
limit = (unsigned long) floor (sqrt ((double) n));
for (i = 3; i <= limit; i+=2)
if ((n % i) == 0)
return 0;
return 1;
}
/* The formula is as follows, with d < 0.
w * sqrt(-d) inf p
h(d) = ------------ * product --------
2 * pi p=2 p - (d/p)
(d/p) is the Kronecker symbol and the product is over primes p. w is 6
when d=-3, 4 when d=-4, or 2 otherwise.
Calculating the product up to p=infinity would take a long time, so for
the estimate primes up to 132,000 are used. Shanks found this giving an
accuracy of about 1 part in 1000, in normal cases. */
unsigned long p_limit = 132000;
double
qcn_estimate (mpz_t d)
{
double h;
unsigned long p;
/* p=2 */
h = sqrt (-mpz_get_d (d)) / M_PI
* 2.0 / (2.0 - mpz_kronecker_ui (d, 2));
if (mpz_cmp_si (d, -3) == 0) h *= 3;
else if (mpz_cmp_si (d, -4) == 0) h *= 2;
for (p = 3; p <= p_limit; p += 2)
if (prime_p (p))
h *= (double) p / (double) (p - mpz_kronecker_ui (d, p));
return h;
}
void
qcn_str (char *num)
{
mpz_t z;
mpz_init_set_str (z, num, 0);
if (mpz_sgn (z) >= 0)
{
mpz_out_str (stdout, 0, z);
printf (" is not supported (negatives only)\n");
}
else if (mpz_fdiv_ui (z, 4) != 0 && mpz_fdiv_ui (z, 4) != 1)
{
mpz_out_str (stdout, 0, z);
printf (" is not a discriminant (must == 0 or 1 mod 4)\n");
}
else
{
printf ("h(");
mpz_out_str (stdout, 0, z);
printf (") approx %.1f\n", qcn_estimate (z));
}
mpz_clear (z);
}
int
main (int argc, char *argv[])
{
int i;
int saw_number = 0;
for (i = 1; i < argc; i++)
{
if (strcmp (argv[i], "-p") == 0)
{
i++;
if (i >= argc)
{
fprintf (stderr, "Missing argument to -p\n");
exit (1);
}
p_limit = atoi (argv[i]);
}
else
{
qcn_str (argv[i]);
saw_number = 1;
}
}
if (! saw_number)
{
/* some default output */
qcn_str ("-85702502803"); /* is 16259 */
qcn_str ("-328878692999"); /* is 1499699 */
qcn_str ("-928185925902146563"); /* is 52739552 */
qcn_str ("-84148631888752647283"); /* is 496652272 */
return 0;
}
return 0;
}

View File

@@ -0,0 +1,15 @@
# Documentation is removed from the Debian DFSG source archive used by the Web build.
all:
install:
install-data:
install-exec:
clean:
distclean:
check:

77
blender-5.2.0/extern/gmp-source/errno.c vendored Normal file
View File

@@ -0,0 +1,77 @@
/* gmp_errno, __gmp_exception -- exception handling and reporting.
THE FUNCTIONS IN THIS FILE, APART FROM gmp_errno, ARE FOR INTERNAL USE
ONLY. THEY'RE ALMOST CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR
DISAPPEAR COMPLETELY IN FUTURE GNU MP RELEASES.
Copyright 2000, 2001, 2003, 2021 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdlib.h>
#include <signal.h>
#include "gmp-impl.h"
int gmp_errno = 0;
/* Use SIGFPE on systems which have it. Otherwise, deliberate divide
by zero, which triggers an exception on most systems. On those
where it doesn't, for example power and powerpc, use abort instead. */
void
__gmp_exception (int error_bit)
{
gmp_errno |= error_bit;
#ifdef SIGFPE
raise (SIGFPE);
#else
__gmp_junk = 10 / __gmp_0;
#endif
abort ();
}
/* These functions minimize the amount of code required in functions raising
exceptions. Since they're "noreturn" and don't take any parameters, a
test and call might even come out as a simple conditional jump. */
void
__gmp_sqrt_of_negative (void)
{
__gmp_exception (GMP_ERROR_SQRT_OF_NEGATIVE);
}
void
__gmp_divide_by_zero (void)
{
__gmp_exception (GMP_ERROR_DIVISION_BY_ZERO);
}
void
__gmp_overflow_in_mpz (void)
{
__gmp_exception (GMP_ERROR_MPZ_OVERFLOW);
}

View File

@@ -0,0 +1,310 @@
/* __gmp_extract_double -- convert from double to array of mp_limb_t.
Copyright 1996, 1999-2002, 2006, 2012 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "gmp-impl.h"
#ifdef XDEBUG
#undef _GMP_IEEE_FLOATS
#endif
#ifndef _GMP_IEEE_FLOATS
#define _GMP_IEEE_FLOATS 0
#endif
/* Extract a non-negative double in d. */
int
__gmp_extract_double (mp_ptr rp, double d)
{
long exp;
unsigned sc;
#ifdef _LONG_LONG_LIMB
#define BITS_PER_PART 64 /* somewhat bogus */
unsigned long long int manl;
#else
#define BITS_PER_PART GMP_LIMB_BITS
unsigned long int manh, manl;
#endif
/* BUGS
1. Should handle Inf and NaN in IEEE specific code.
2. Handle Inf and NaN also in default code, to avoid hangs.
3. Generalize to handle all GMP_LIMB_BITS >= 32.
4. This lits is incomplete and misspelled.
*/
ASSERT (d >= 0.0);
if (d == 0.0)
{
MPN_ZERO (rp, LIMBS_PER_DOUBLE);
return 0;
}
#if _GMP_IEEE_FLOATS
{
#if defined (__alpha) && __GNUC__ == 2 && __GNUC_MINOR__ == 8
/* Work around alpha-specific bug in GCC 2.8.x. */
volatile
#endif
union ieee_double_extract x;
x.d = d;
exp = x.s.exp;
#if BITS_PER_PART == 64 /* generalize this to BITS_PER_PART > BITS_IN_MANTISSA */
manl = (((mp_limb_t) 1 << 63)
| ((mp_limb_t) x.s.manh << 43) | ((mp_limb_t) x.s.manl << 11));
if (exp == 0)
{
/* Denormalized number. Don't try to be clever about this,
since it is not an important case to make fast. */
exp = 1;
do
{
manl = manl << 1;
exp--;
}
while ((manl & GMP_LIMB_HIGHBIT) == 0);
}
#endif
#if BITS_PER_PART == 32
manh = ((mp_limb_t) 1 << 31) | (x.s.manh << 11) | (x.s.manl >> 21);
manl = x.s.manl << 11;
if (exp == 0)
{
/* Denormalized number. Don't try to be clever about this,
since it is not an important case to make fast. */
exp = 1;
do
{
manh = (manh << 1) | (manl >> 31);
manl = manl << 1;
exp--;
}
while ((manh & GMP_LIMB_HIGHBIT) == 0);
}
#endif
#if BITS_PER_PART != 32 && BITS_PER_PART != 64
You need to generalize the code above to handle this.
#endif
exp -= 1022; /* Remove IEEE bias. */
}
#else
{
/* Unknown (or known to be non-IEEE) double format. */
exp = 0;
if (d >= 1.0)
{
ASSERT_ALWAYS (d * 0.5 != d);
while (d >= 32768.0)
{
d *= (1.0 / 65536.0);
exp += 16;
}
while (d >= 1.0)
{
d *= 0.5;
exp += 1;
}
}
else if (d < 0.5)
{
while (d < (1.0 / 65536.0))
{
d *= 65536.0;
exp -= 16;
}
while (d < 0.5)
{
d *= 2.0;
exp -= 1;
}
}
d *= (4.0 * ((unsigned long int) 1 << (BITS_PER_PART - 2)));
#if BITS_PER_PART == 64
manl = d;
#endif
#if BITS_PER_PART == 32
manh = d;
manl = (d - manh) * (4.0 * ((unsigned long int) 1 << (BITS_PER_PART - 2)));
#endif
}
#endif /* IEEE */
sc = (unsigned) (exp + 64 * GMP_NUMB_BITS) % GMP_NUMB_BITS;
/* We add something here to get rounding right. */
exp = (exp + 64 * GMP_NUMB_BITS) / GMP_NUMB_BITS - 64 * GMP_NUMB_BITS / GMP_NUMB_BITS + 1;
#if BITS_PER_PART == 64 && LIMBS_PER_DOUBLE == 2
#if GMP_NAIL_BITS == 0
if (sc != 0)
{
rp[1] = manl >> (GMP_LIMB_BITS - sc);
rp[0] = manl << sc;
}
else
{
rp[1] = manl;
rp[0] = 0;
exp--;
}
#else
if (sc > GMP_NAIL_BITS)
{
rp[1] = manl >> (GMP_LIMB_BITS - sc);
rp[0] = (manl << (sc - GMP_NAIL_BITS)) & GMP_NUMB_MASK;
}
else
{
if (sc == 0)
{
rp[1] = manl >> GMP_NAIL_BITS;
rp[0] = (manl << GMP_NUMB_BITS - GMP_NAIL_BITS) & GMP_NUMB_MASK;
exp--;
}
else
{
rp[1] = manl >> (GMP_LIMB_BITS - sc);
rp[0] = (manl >> (GMP_NAIL_BITS - sc)) & GMP_NUMB_MASK;
}
}
#endif
#endif
#if BITS_PER_PART == 64 && LIMBS_PER_DOUBLE == 3
if (sc > GMP_NAIL_BITS)
{
rp[2] = manl >> (GMP_LIMB_BITS - sc);
rp[1] = (manl << sc - GMP_NAIL_BITS) & GMP_NUMB_MASK;
if (sc >= 2 * GMP_NAIL_BITS)
rp[0] = 0;
else
rp[0] = (manl << GMP_NUMB_BITS - GMP_NAIL_BITS + sc) & GMP_NUMB_MASK;
}
else
{
if (sc == 0)
{
rp[2] = manl >> GMP_NAIL_BITS;
rp[1] = (manl << GMP_NUMB_BITS - GMP_NAIL_BITS) & GMP_NUMB_MASK;
rp[0] = 0;
exp--;
}
else
{
rp[2] = manl >> (GMP_LIMB_BITS - sc);
rp[1] = (manl >> GMP_NAIL_BITS - sc) & GMP_NUMB_MASK;
rp[0] = (manl << GMP_NUMB_BITS - GMP_NAIL_BITS + sc) & GMP_NUMB_MASK;
}
}
#endif
#if BITS_PER_PART == 32 && LIMBS_PER_DOUBLE == 3
#if GMP_NAIL_BITS == 0
if (sc != 0)
{
rp[2] = manh >> (GMP_LIMB_BITS - sc);
rp[1] = (manh << sc) | (manl >> (GMP_LIMB_BITS - sc));
rp[0] = manl << sc;
}
else
{
rp[2] = manh;
rp[1] = manl;
rp[0] = 0;
exp--;
}
#else
if (sc > GMP_NAIL_BITS)
{
rp[2] = (manh >> (GMP_LIMB_BITS - sc));
rp[1] = ((manh << (sc - GMP_NAIL_BITS)) |
(manl >> (GMP_LIMB_BITS - sc + GMP_NAIL_BITS))) & GMP_NUMB_MASK;
if (sc >= 2 * GMP_NAIL_BITS)
rp[0] = (manl << sc - 2 * GMP_NAIL_BITS) & GMP_NUMB_MASK;
else
rp[0] = manl >> (2 * GMP_NAIL_BITS - sc) & GMP_NUMB_MASK;
}
else
{
if (sc == 0)
{
rp[2] = manh >> GMP_NAIL_BITS;
rp[1] = ((manh << GMP_NUMB_BITS - GMP_NAIL_BITS) | (manl >> 2 * GMP_NAIL_BITS)) & GMP_NUMB_MASK;
rp[0] = (manl << GMP_NUMB_BITS - 2 * GMP_NAIL_BITS) & GMP_NUMB_MASK;
exp--;
}
else
{
rp[2] = (manh >> (GMP_LIMB_BITS - sc));
rp[1] = (manh >> (GMP_NAIL_BITS - sc)) & GMP_NUMB_MASK;
rp[0] = ((manh << (GMP_NUMB_BITS - GMP_NAIL_BITS + sc))
| (manl >> (GMP_LIMB_BITS - (GMP_NUMB_BITS - GMP_NAIL_BITS + sc)))) & GMP_NUMB_MASK;
}
}
#endif
#endif
#if BITS_PER_PART == 32 && LIMBS_PER_DOUBLE > 3
if (sc == 0)
{
int i;
for (i = LIMBS_PER_DOUBLE - 1; i >= 0; i--)
{
rp[i] = manh >> (BITS_PER_ULONG - GMP_NUMB_BITS);
manh = ((manh << GMP_NUMB_BITS)
| (manl >> (BITS_PER_ULONG - GMP_NUMB_BITS)));
manl = manl << GMP_NUMB_BITS;
}
exp--;
}
else
{
int i;
rp[LIMBS_PER_DOUBLE - 1] = (manh >> (GMP_LIMB_BITS - sc));
manh = (manh << sc) | (manl >> (GMP_LIMB_BITS - sc));
manl = (manl << sc);
for (i = LIMBS_PER_DOUBLE - 2; i >= 0; i--)
{
rp[i] = manh >> (BITS_PER_ULONG - GMP_NUMB_BITS);
manh = ((manh << GMP_NUMB_BITS)
| (manl >> (BITS_PER_ULONG - GMP_NUMB_BITS)));
manl = manl << GMP_NUMB_BITS;
}
}
#endif
return exp;
}

View File

@@ -0,0 +1,265 @@
/* Generate mp_bases data.
Copyright 1991, 1993, 1994, 1996, 2000, 2002, 2004, 2011, 2012,
2015-2018 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include "bootstrap.c"
int chars_per_limb;
int big_base_ctz;
mpz_t big_base;
int normalization_steps;
mpz_t big_base_inverted;
mpz_t big_base_binverted;
mpz_t t;
#define POW2_P(n) (((n) & ((n) - 1)) == 0)
unsigned int
ulog2 (unsigned int x)
{
unsigned int i;
for (i = 0; x != 0; i++)
x >>= 1;
return i;
}
void
binvert (int numb_bits)
{
mpz_t bbo;
mpz_init_set (bbo, big_base);
big_base_ctz = mpz_make_odd (bbo);
mpz_invert_2exp (big_base_binverted, bbo, numb_bits);
}
void
generate (int limb_bits, int nail_bits, int base)
{
int numb_bits = limb_bits - nail_bits;
mpz_set_ui (t, 1L);
mpz_mul_2exp (t, t, numb_bits);
mpz_set_ui (big_base, (long) base);
chars_per_limb = 0;
while (mpz_cmp (big_base, t) <= 0)
{
mpz_mul_ui (big_base, big_base, (long) base);
chars_per_limb++;
}
mpz_ui_pow_ui (big_base, (long) base, (long) chars_per_limb);
normalization_steps = limb_bits - mpz_sizeinbase (big_base, 2);
mpz_set_ui (t, 1L);
mpz_mul_2exp (t, t, 2*limb_bits - normalization_steps);
mpz_tdiv_q (big_base_inverted, t, big_base);
mpz_clrbit (big_base_inverted, limb_bits);
binvert (numb_bits);
}
void
header (int limb_bits, int nail_bits)
{
int numb_bits = limb_bits - nail_bits;
generate (limb_bits, nail_bits, 10);
printf ("/* This file generated by gen-bases.c - DO NOT EDIT. */\n");
printf ("\n");
printf ("#if GMP_NUMB_BITS != %d\n", numb_bits);
printf ("Error, error, this data is for %d bits\n", numb_bits);
printf ("#endif\n");
printf ("\n");
printf ("/* mp_bases[10] data, as literal values */\n");
printf ("#define MP_BASES_CHARS_PER_LIMB_10 %d\n", chars_per_limb);
printf ("#define MP_BASES_BIG_BASE_CTZ_10 %d\n", big_base_ctz);
printf ("#define MP_BASES_BIG_BASE_10 CNST_LIMB(0x");
mpz_out_str (stdout, 16, big_base);
printf (")\n");
printf ("#define MP_BASES_BIG_BASE_INVERTED_10 CNST_LIMB(0x");
mpz_out_str (stdout, 16, big_base_inverted);
printf (")\n");
printf ("#define MP_BASES_BIG_BASE_BINVERTED_10 CNST_LIMB(0x");
mpz_out_str (stdout, 16, big_base_binverted);
printf (")\n");
printf ("#define MP_BASES_NORMALIZATION_STEPS_10 %d\n", normalization_steps);
}
#define EXTRA 16
/* Compute log(2)/log(b) as a fixnum. */
void
mp_2logb (mpz_t r, int bi, int prec)
{
mpz_t t, t2, two, b;
int i;
mpz_init (t);
mpz_setbit (t, prec + EXTRA);
mpz_init (t2);
mpz_init (two);
mpz_setbit (two, prec + EXTRA + 1);
mpz_set_ui (r, 0);
mpz_init_set_ui (b, bi);
mpz_mul_2exp (b, b, prec+EXTRA);
for (i = prec-1; i >= 0; i--)
{
mpz_mul_2exp (b, b, prec+EXTRA);
mpz_sqrt (b, b);
mpz_mul (t2, t, b);
mpz_tdiv_q_2exp (t2, t2, prec+EXTRA);
if (mpz_cmp (t2, two) < 0) /* not too large? */
{
mpz_setbit (r, i); /* set next less significant bit */
mpz_swap (t, t2); /* new value acceptable */
}
}
mpz_clear (t);
mpz_clear (t2);
mpz_clear (two);
mpz_clear (b);
}
void
table (int limb_bits, int nail_bits)
{
int numb_bits = limb_bits - nail_bits;
int base;
mpz_t r, t, logb2, log2b;
mpz_init (r);
mpz_init (t);
mpz_init (logb2);
mpz_init (log2b);
printf ("/* This file generated by gen-bases.c - DO NOT EDIT. */\n");
printf ("\n");
printf ("#include \"gmp-impl.h\"\n");
printf ("\n");
printf ("#if GMP_NUMB_BITS != %d\n", numb_bits);
printf ("Error, error, this data is for %d bits\n", numb_bits);
printf ("#endif\n");
printf ("\n");
puts ("const struct bases mp_bases[257] =\n{");
puts (" /* 0 */ { 0, 0, 0, 0, 0 },");
puts (" /* 1 */ { 0, 0, 0, 0, 0 },");
for (base = 2; base <= 256; base++)
{
generate (limb_bits, nail_bits, base);
mp_2logb (r, base, limb_bits + 8);
mpz_tdiv_q_2exp (logb2, r, 8);
mpz_set_ui (t, 1);
mpz_mul_2exp (t, t, 2*limb_bits + 5);
mpz_sub_ui (t, t, 1);
mpz_add_ui (r, r, 1);
mpz_tdiv_q (log2b, t, r);
printf (" /* %3u */ { ", base);
if (POW2_P (base))
{
mpz_set_ui (big_base, ulog2 (base) - 1);
mpz_set_ui (big_base_inverted, 0);
}
printf ("%u,", chars_per_limb);
printf (" CNST_LIMB(0x");
mpz_out_str (stdout, 16, logb2);
printf ("), CNST_LIMB(0x");
mpz_out_str (stdout, 16, log2b);
printf ("), CNST_LIMB(0x");
mpz_out_str (stdout, 16, big_base);
printf ("), CNST_LIMB(0x");
mpz_out_str (stdout, 16, big_base_inverted);
printf (") },\n");
}
puts ("};");
mpz_clear (r);
mpz_clear (t);
mpz_clear (logb2);
mpz_clear (log2b);
}
int
main (int argc, char **argv)
{
int limb_bits, nail_bits;
mpz_init (big_base);
mpz_init (big_base_inverted);
mpz_init (big_base_binverted);
mpz_init (t);
if (argc != 4)
{
fprintf (stderr, "Usage: gen-bases <header|table> <limbbits> <nailbits>\n");
exit (1);
}
limb_bits = atoi (argv[2]);
nail_bits = atoi (argv[3]);
if (limb_bits <= 0
|| nail_bits < 0
|| nail_bits >= limb_bits)
{
fprintf (stderr, "Invalid limb/nail bits: %d %d\n",
limb_bits, nail_bits);
exit (1);
}
if (strcmp (argv[1], "header") == 0)
header (limb_bits, nail_bits);
else if (strcmp (argv[1], "table") == 0)
table (limb_bits, nail_bits);
else
{
fprintf (stderr, "Invalid header/table choice: %s\n", argv[1]);
exit (1);
}
return 0;
}

View File

@@ -0,0 +1,285 @@
/* Generate data for combinatorics: fac_ui, bin_uiui, ...
Copyright 2002, 2011-2016 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdio.h>
#include <stdlib.h>
#include "bootstrap.c"
int
mpz_remove_twos (mpz_t x)
{
mp_bitcnt_t r = mpz_scan1(x, 0);
mpz_tdiv_q_2exp (x, x, r);
return r;
}
/* returns 0 on success */
int
gen_consts (unsigned numb, unsigned limb)
{
mpz_t x, mask, y, last;
unsigned long a, b;
unsigned long ofl, ofe;
printf ("/* This file is automatically generated by gen-fac.c */\n\n");
printf ("#if GMP_NUMB_BITS != %u\n", numb);
printf ("Error , error this data is for %u GMP_NUMB_BITS only\n", numb);
printf ("#endif\n");
#if 0
printf ("#if GMP_LIMB_BITS != %u\n", limb);
printf ("Error , error this data is for %u GMP_LIMB_BITS only\n", limb);
printf ("#endif\n");
#endif
printf
("/* This table is 0!,1!,2!,3!,...,n! where n! has <= GMP_NUMB_BITS bits */\n");
printf
("#define ONE_LIMB_FACTORIAL_TABLE CNST_LIMB(0x1),CNST_LIMB(0x1");
mpz_init_set_ui (x, 1);
mpz_init (last);
for (b = 2;; b++)
{
mpz_mul_ui (x, x, b); /* so b!=a */
if (mpz_sizeinbase (x, 2) > numb)
break;
printf ("),CNST_LIMB(0x");
mpz_out_str (stdout, 16, x);
}
printf (")\n");
printf
("\n/* This table is 0!,1!,2!/2,3!/2,...,n!/2^sn where n!/2^sn is an */\n");
printf
("/* odd integer for each n, and n!/2^sn has <= GMP_NUMB_BITS bits */\n");
printf
("#define ONE_LIMB_ODD_FACTORIAL_TABLE CNST_LIMB(0x1),CNST_LIMB(0x1),CNST_LIMB(0x1");
mpz_set_ui (x, 1);
for (b = 3;; b++)
{
for (a = b; (a & 1) == 0; a >>= 1);
mpz_swap (last, x);
mpz_mul_ui (x, last, a);
if (mpz_sizeinbase (x, 2) > numb)
break;
printf ("),CNST_LIMB(0x");
mpz_out_str (stdout, 16, x);
}
printf (")\n");
printf
("#define ODD_FACTORIAL_TABLE_MAX CNST_LIMB(0x");
mpz_out_str (stdout, 16, last);
printf (")\n");
ofl = b - 1;
printf
("#define ODD_FACTORIAL_TABLE_LIMIT (%lu)\n", ofl);
mpz_init (mask);
mpz_setbit (mask, numb);
mpz_sub_ui (mask, mask, 1);
printf
("\n/* Previous table, continued, values modulo 2^GMP_NUMB_BITS */\n");
printf
("#define ONE_LIMB_ODD_FACTORIAL_EXTTABLE CNST_LIMB(0x");
mpz_and (x, x, mask);
mpz_out_str (stdout, 16, x);
mpz_init (y);
mpz_bin_uiui (y, b, b/2);
b++;
for (;; b++)
{
for (a = b; (a & 1) == 0; a >>= 1);
if (a == b) {
mpz_divexact_ui (y, y, a/2+1);
mpz_mul_ui (y, y, a);
} else
mpz_mul_2exp (y, y, 1);
if (mpz_sizeinbase (y, 2) > numb)
break;
mpz_mul_ui (x, x, a);
mpz_and (x, x, mask);
printf ("),CNST_LIMB(0x");
mpz_out_str (stdout, 16, x);
}
printf (")\n");
ofe = b - 1;
printf
("#define ODD_FACTORIAL_EXTTABLE_LIMIT (%lu)\n", ofe);
printf
("\n/* This table is 1!!,3!!,...,(2n+1)!! where (2n+1)!! has <= GMP_NUMB_BITS bits */\n");
printf
("#define ONE_LIMB_ODD_DOUBLEFACTORIAL_TABLE CNST_LIMB(0x1");
mpz_set_ui (x, 1);
for (b = 3;; b+=2)
{
mpz_swap (last, x);
mpz_mul_ui (x, last, b);
if (mpz_sizeinbase (x, 2) > numb)
break;
printf ("),CNST_LIMB(0x");
mpz_out_str (stdout, 16, x);
}
printf (")\n");
printf
("#define ODD_DOUBLEFACTORIAL_TABLE_MAX CNST_LIMB(0x");
mpz_out_str (stdout, 16, last);
printf (")\n");
printf
("#define ODD_DOUBLEFACTORIAL_TABLE_LIMIT (%lu)\n", b - 2);
printf
("\n/* This table x_1, x_2,... contains values s.t. x_n^n has <= GMP_NUMB_BITS bits */\n");
printf
("#define NTH_ROOT_NUMB_MASK_TABLE (GMP_NUMB_MASK");
for (b = 2;b <= 8; b++)
{
mpz_root (x, mask, b);
printf ("),CNST_LIMB(0x");
mpz_out_str (stdout, 16, x);
}
printf (")\n");
mpz_add_ui (mask, mask, 1);
printf
("\n/* This table contains inverses of odd factorials, modulo 2^GMP_NUMB_BITS */\n");
printf
("\n/* It begins with (2!/2)^-1=1 */\n");
printf
("#define ONE_LIMB_ODD_FACTORIAL_INVERSES_TABLE CNST_LIMB(0x1");
mpz_set_ui (x, 1);
for (b = 3;b <= ofe - 2; b++)
{
for (a = b; (a & 1) == 0; a >>= 1);
mpz_mul_ui (x, x, a);
mpz_invert (y, x, mask);
printf ("),CNST_LIMB(0x");
mpz_out_str (stdout, 16, y);
}
printf (")\n");
ofe = (ofe / 16 + 1) * 16;
printf
("\n/* This table contains 2n-popc(2n) for small n */\n");
printf
("\n/* It begins with 2-1=1 (n=1) */\n");
printf
("#define TABLE_2N_MINUS_POPC_2N 1");
for (b = 4; b <= ofe; b += 2)
{
mpz_set_ui (x, b);
printf (",%lu",b - mpz_popcount (x));
}
printf ("\n");
printf
("#define TABLE_LIMIT_2N_MINUS_POPC_2N %lu\n", ofe + 1);
ofl = (ofl + 1) / 2;
printf
("#define ODD_CENTRAL_BINOMIAL_OFFSET (%lu)\n", ofl);
printf
("\n/* This table contains binomial(2k,k)/2^t */\n");
printf
("\n/* It begins with ODD_CENTRAL_BINOMIAL_TABLE_MIN */\n");
printf
("#define ONE_LIMB_ODD_CENTRAL_BINOMIAL_TABLE ");
for (b = ofl;; b++)
{
mpz_bin_uiui (x, 2 * b, b);
mpz_remove_twos (x);
if (mpz_sizeinbase (x, 2) > numb)
break;
if (b != ofl)
printf ("),");
printf("CNST_LIMB(0x");
mpz_out_str (stdout, 16, x);
}
printf (")\n");
ofe = b - 1;
printf
("#define ODD_CENTRAL_BINOMIAL_TABLE_LIMIT (%lu)\n", ofe);
printf
("\n/* This table contains the inverses of elements in the previous table. */\n");
printf
("#define ONE_LIMB_ODD_CENTRAL_BINOMIAL_INVERSE_TABLE CNST_LIMB(0x");
for (b = ofl; b <= ofe; b++)
{
mpz_bin_uiui (x, 2 * b, b);
mpz_remove_twos (x);
mpz_invert (x, x, mask);
mpz_out_str (stdout, 16, x);
if (b != ofe)
printf ("),CNST_LIMB(0x");
}
printf (")\n");
printf
("\n/* This table contains the values t in the formula binomial(2k,k)/2^t */\n");
printf
("#define CENTRAL_BINOMIAL_2FAC_TABLE ");
for (b = ofl; b <= ofe; b++)
{
mpz_bin_uiui (x, 2 * b, b);
printf ("%d", mpz_remove_twos (x));
if (b != ofe)
printf (",");
}
printf ("\n");
return 0;
}
int
main (int argc, char *argv[])
{
int nail_bits, limb_bits, numb_bits;
if (argc != 3)
{
fprintf (stderr, "Usage: gen-fac limbbits nailbits\n");
exit (1);
}
limb_bits = atoi (argv[1]);
nail_bits = atoi (argv[2]);
numb_bits = limb_bits - nail_bits;
if (limb_bits < 2 || nail_bits < 0 || numb_bits < 1)
{
fprintf (stderr, "Invalid limb/nail bits %d,%d\n", limb_bits,
nail_bits);
exit (1);
}
gen_consts (numb_bits, limb_bits);
return 0;
}

View File

@@ -0,0 +1,156 @@
/* Generate Fibonacci table data.
Copyright 2001, 2002, 2004, 2012, 2014, 2015 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdio.h>
#include "bootstrap.c"
mpz_t *f;
int fnum, fib_limit, luc_limit;
void
generate (int numb_bits)
{
mpz_t limit, l;
int falloc, i;
mpz_init2 (limit, numb_bits + 1);
mpz_setbit (limit, numb_bits);
/* fib(2n) > 2^n, so use 2n as a limit for the table size */
falloc = 2 * numb_bits;
f = (mpz_t*) xmalloc (falloc * sizeof (*f));
mpz_init_set_ui (f[0], 1L); /* F[-1] */
mpz_init_set_ui (f[1], 0L); /* F[0] */
mpz_init (l);
for (i = 2; ; i++)
{
assert (i < falloc);
/* F[i] = F[i-1] + F[i-2] */
mpz_init (f[i]);
mpz_add (f[i], f[i-1], f[i-2]);
if (mpz_cmp (f[i], limit) >= 0)
break;
fnum = i+1;
fib_limit = i-1;
/* L[i] = F[i]+2*F[i-1] */
mpz_add (l, f[i], f[i-1]);
mpz_add (l, l, f[i-1]);
if (mpz_cmp (l, limit) < 0)
luc_limit = i-1;
}
mpz_clear (limit);
}
void
header (int numb_bits)
{
printf ("/* This file generated by gen-fib.c - DO NOT EDIT. */\n");
printf ("\n");
printf ("#if GMP_NUMB_BITS != %d\n", numb_bits);
printf ("Error, error, this data is for %d bits\n", numb_bits);
printf ("#endif\n");
printf ("\n");
printf ("#define FIB_TABLE_LIMIT %d\n", fib_limit);
printf ("#define FIB_TABLE_LUCNUM_LIMIT %d\n", luc_limit);
}
void
table (int numb_bits)
{
int i;
printf ("/* This file generated by gen-fib.c - DO NOT EDIT. */\n");
printf ("\n");
printf ("#include \"gmp.h\"\n");
printf ("#include \"gmp-impl.h\"\n");
printf ("\n");
printf ("#if GMP_NUMB_BITS != %d\n", numb_bits);
printf ("Error, error, this data is for %d bits\n", numb_bits);
printf ("#endif\n");
printf ("\n");
printf ("const mp_limb_t\n");
printf ("__gmp_fib_table[FIB_TABLE_LIMIT+2] = {\n");
for (i = 0; i < fnum; i++)
{
printf (" CNST_LIMB (0x");
mpz_out_str (stdout, 16, f[i]);
printf ("), /* %d */\n", i-1);
}
printf ("};\n");
}
int
main (int argc, char *argv[])
{
int limb_bits, nail_bits, numb_bits;
if (argc != 4)
{
fprintf (stderr, "Usage: gen-fib <header|table> <limbbits> <nailbits>\n");
exit (1);
}
limb_bits = atoi (argv[2]);
nail_bits = atoi (argv[3]);
if (limb_bits <= 0
|| nail_bits < 0
|| nail_bits >= limb_bits)
{
fprintf (stderr, "Invalid limb/nail bits: %d %d\n",
limb_bits, nail_bits);
exit (1);
}
numb_bits = limb_bits - nail_bits;
generate (numb_bits);
if (strcmp (argv[1], "header") == 0)
header (numb_bits);
else if (strcmp (argv[1], "table") == 0)
table (numb_bits);
else
{
fprintf (stderr, "Invalid header/table choice: %s\n", argv[1]);
exit (1);
}
return 0;
}

View File

@@ -0,0 +1,128 @@
/* gen-jacobi.c
Contributed to the GNU project by Niels Möller.
Copyright 2010 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
/* Generate the lookup table needed for fast left-to-right computation
of the Jacobi symbol. */
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
static const struct
{
unsigned char a;
unsigned char b;
} decode_table[13] = {
/* 0 */ { 0, 1 },
/* 1 */ { 0, 3 },
/* 2 */ { 1, 1 },
/* 3 */ { 1, 3 },
/* 4 */ { 2, 1 },
/* 5 */ { 2, 3 },
/* 6 */ { 3, 1 },
/* 7 */ { 3, 3 }, /* d = 1 */
/* 8 */ { 1, 0 },
/* 9 */ { 1, 2 },
/* 10 */ { 3, 0 },
/* 11 */ { 3, 2 },
/* 12 */ { 3, 3 }, /* d = 0 */
};
#define JACOBI_A(bits) (decode_table[(bits)>>1].a)
#define JACOBI_B(bits) (decode_table[(bits)>>1].b)
#define JACOBI_E(bits) ((bits) & 1)
#define JACOBI_D(bits) (((bits)>>1) == 7) /* Gives 0 for don't care states. */
static unsigned
encode (unsigned a, unsigned b, unsigned d)
{
unsigned i;
assert (d < 2);
assert (a < 4);
assert (b < 4);
assert ( (a | b ) & 1);
if (a == 3 && b == 3)
return d ? 7 : 12;
for (i = 0; i < 12; i++)
if (decode_table[i].a == a
&& decode_table[i].b == b)
return i;
abort ();
}
int
main (int argc, char **argv)
{
unsigned bits;
for (bits = 0; bits < 208; bits++)
{
unsigned e, a, b, d_old, d, q;
if (bits && !(bits & 0xf))
printf("\n");
q = bits & 3;
d = (bits >> 2) & 1;
e = JACOBI_E (bits >> 3);
a = JACOBI_A (bits >> 3);
b = JACOBI_B (bits >> 3);
d_old = JACOBI_D (bits >> 3);
if (d != d_old && a == 3 && b == 3)
e ^= 1;
if (d == 1)
{
if (b == 2)
e ^= (q & (a >> 1)) ^ (q >> 1);
a = (a - q * b) & 3;
}
else
{
if (a == 2)
e ^= (q & (b >> 1)) ^ (q >> 1);
b = (b - q * a) & 3;
}
printf("%2d,", (encode (a, b, d) << 1) | e);
}
printf("\n");
return 0;
}

View File

@@ -0,0 +1,585 @@
/* Generate perfect square testing data.
Copyright 2002-2004, 2012, 2014 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdio.h>
#include <stdlib.h>
#include "bootstrap.c"
/* The aim of this program is to choose either mpn_mod_34lsub1 or mpn_mod_1
(plus a PERFSQR_PP modulus), and generate tables indicating quadratic
residues and non-residues modulo small factors of that modulus.
For the usual 32 or 64 bit cases mpn_mod_34lsub1 gets used. That
function exists specifically because 2^24-1 and 2^48-1 have nice sets of
prime factors. For other limb sizes it's considered, but if it doesn't
have good factors then mpn_mod_1 will be used instead.
When mpn_mod_1 is used, the modulus PERFSQR_PP is created from a
selection of small primes, chosen to fill PERFSQR_MOD_BITS of a limb,
with that bit count chosen so (2*GMP_LIMB_BITS)*2^PERFSQR_MOD_BITS <=
GMP_LIMB_MAX, allowing PERFSQR_MOD_IDX in mpn/generic/perfsqr.c to do its
calculation within a single limb.
In either case primes can be combined to make divisors. The table data
then effectively indicates remainders which are quadratic residues mod
all the primes. This sort of combining reduces the number of steps
needed after mpn_mod_34lsub1 or mpn_mod_1, saving code size and time.
Nothing is gained or lost in terms of detections, the same total fraction
of non-residues will be identified.
Nothing particularly sophisticated is attempted for combining factors to
make divisors. This is probably a kind of knapsack problem so it'd be
too hard to attempt anything completely general. For the usual 32 and 64
bit limbs we get a good enough result just pairing the biggest and
smallest which fit together, repeatedly.
Another aim is to get powerful combinations, ie. divisors which identify
biggest fraction of non-residues, and have those run first. Again for
the usual 32 and 64 bits it seems good enough just to pair for big
divisors then sort according to the resulting fraction of non-residues
identified.
Also in this program, a table sq_res_0x100 of residues modulo 256 is
generated. This simply fills bits into limbs of the appropriate
build-time GMP_LIMB_BITS each.
*/
/* Normally we aren't using const in gen*.c programs, so as not to have to
bother figuring out if it works, but using it with f_cmp_divisor and
f_cmp_fraction avoids warnings from the qsort calls. */
/* Same tests as gmp.h. */
#if defined (__STDC__) \
|| defined (__cplusplus) \
|| defined (_AIX) \
|| defined (__DECC) \
|| (defined (__mips) && defined (_SYSTYPE_SVR4)) \
|| defined (_MSC_VER) \
|| defined (_WIN32)
#define HAVE_CONST 1
#endif
#if ! HAVE_CONST
#define const
#endif
mpz_t *sq_res_0x100; /* table of limbs */
int nsq_res_0x100; /* elements in sq_res_0x100 array */
int sq_res_0x100_num; /* squares in sq_res_0x100 */
double sq_res_0x100_fraction; /* sq_res_0x100_num / 256 */
int mod34_bits; /* 3*GMP_NUMB_BITS/4 */
int mod_bits; /* bits from PERFSQR_MOD_34 or MOD_PP */
int max_divisor; /* all divisors <= max_divisor */
int max_divisor_bits; /* ceil(log2(max_divisor)) */
double total_fraction; /* of squares */
mpz_t pp; /* product of primes, or 0 if mod_34lsub1 used */
mpz_t pp_norm; /* pp shifted so NUMB high bit set */
mpz_t pp_inverted; /* invert_limb style inverse */
mpz_t mod_mask; /* 2^mod_bits-1 */
char mod34_excuse[128]; /* why mod_34lsub1 not used (if it's not) */
/* raw list of divisors of 2^mod34_bits-1 or pp, just to show in a comment */
struct rawfactor_t {
int divisor;
int multiplicity;
};
struct rawfactor_t *rawfactor;
int nrawfactor;
/* factors of 2^mod34_bits-1 or pp and associated data, after combining etc */
struct factor_t {
int divisor;
mpz_t inverse; /* 1/divisor mod 2^mod_bits */
mpz_t mask; /* indicating squares mod divisor */
double fraction; /* squares/total */
};
struct factor_t *factor;
int nfactor; /* entries in use in factor array */
int factor_alloc; /* entries allocated to factor array */
int
f_cmp_divisor (const void *parg, const void *qarg)
{
const struct factor_t *p, *q;
p = (const struct factor_t *) parg;
q = (const struct factor_t *) qarg;
if (p->divisor > q->divisor)
return 1;
else if (p->divisor < q->divisor)
return -1;
else
return 0;
}
int
f_cmp_fraction (const void *parg, const void *qarg)
{
const struct factor_t *p, *q;
p = (const struct factor_t *) parg;
q = (const struct factor_t *) qarg;
if (p->fraction > q->fraction)
return 1;
else if (p->fraction < q->fraction)
return -1;
else
return 0;
}
/* Remove array[idx] by copying the remainder down, and adjust narray
accordingly. */
#define COLLAPSE_ELEMENT(array, idx, narray) \
do { \
memmove (&(array)[idx], \
&(array)[idx+1], \
((narray)-((idx)+1)) * sizeof (array[0])); \
(narray)--; \
} while (0)
/* return n*2^p mod m */
int
mul_2exp_mod (int n, int p, int m)
{
while (--p >= 0)
n = (2 * n) % m;
return n;
}
/* return -n mod m */
int
neg_mod (int n, int m)
{
assert (n >= 0 && n < m);
return (n == 0 ? 0 : m-n);
}
/* Set "mask" to a value such that "mask & (1<<idx)" is non-zero if
"-(idx<<mod_bits)" can be a square modulo m. */
void
square_mask (mpz_t mask, int m)
{
int p, i, r, idx;
p = mul_2exp_mod (1, mod_bits, m);
p = neg_mod (p, m);
mpz_set_ui (mask, 0L);
for (i = 0; i < m; i++)
{
r = (i * i) % m;
idx = (r * p) % m;
mpz_setbit (mask, (unsigned long) idx);
}
}
void
generate_sq_res_0x100 (int limb_bits)
{
int i, res;
nsq_res_0x100 = (0x100 + limb_bits - 1) / limb_bits;
sq_res_0x100 = (mpz_t *) xmalloc (nsq_res_0x100 * sizeof (*sq_res_0x100));
for (i = 0; i < nsq_res_0x100; i++)
mpz_init_set_ui (sq_res_0x100[i], 0L);
for (i = 0; i < 0x100; i++)
{
res = (i * i) % 0x100;
mpz_setbit (sq_res_0x100[res / limb_bits],
(unsigned long) (res % limb_bits));
}
sq_res_0x100_num = 0;
for (i = 0; i < nsq_res_0x100; i++)
sq_res_0x100_num += mpz_popcount (sq_res_0x100[i]);
sq_res_0x100_fraction = (double) sq_res_0x100_num / 256.0;
}
void
generate_mod (int limb_bits, int nail_bits)
{
int numb_bits = limb_bits - nail_bits;
int i, divisor;
mpz_init_set_ui (pp, 0L);
mpz_init_set_ui (pp_norm, 0L);
mpz_init_set_ui (pp_inverted, 0L);
/* no more than limb_bits many factors in a one limb modulus (and of
course in reality nothing like that many) */
factor_alloc = limb_bits;
factor = (struct factor_t *) xmalloc (factor_alloc * sizeof (*factor));
rawfactor = (struct rawfactor_t *) xmalloc (factor_alloc * sizeof (*rawfactor));
if (numb_bits % 4 != 0)
{
strcpy (mod34_excuse, "GMP_NUMB_BITS % 4 != 0");
goto use_pp;
}
max_divisor = 2*limb_bits;
max_divisor_bits = log2_ceil (max_divisor);
if (numb_bits / 4 < max_divisor_bits)
{
/* Wind back to one limb worth of max_divisor, if that will let us use
mpn_mod_34lsub1. */
max_divisor = limb_bits;
max_divisor_bits = log2_ceil (max_divisor);
if (numb_bits / 4 < max_divisor_bits)
{
strcpy (mod34_excuse, "GMP_NUMB_BITS / 4 too small");
goto use_pp;
}
}
{
/* Can use mpn_mod_34lsub1, find small factors of 2^mod34_bits-1. */
mpz_t m, q, r;
int multiplicity;
mod34_bits = (numb_bits / 4) * 3;
/* mpn_mod_34lsub1 returns a full limb value, PERFSQR_MOD_34 folds it at
the mod34_bits mark, adding the two halves for a remainder of at most
mod34_bits+1 many bits */
mod_bits = mod34_bits + 1;
mpz_init_set_ui (m, 1L);
mpz_mul_2exp (m, m, mod34_bits);
mpz_sub_ui (m, m, 1L);
mpz_init (q);
mpz_init (r);
for (i = 3; i <= max_divisor; i+=2)
{
if (! isprime (i))
continue;
mpz_tdiv_qr_ui (q, r, m, (unsigned long) i);
if (mpz_sgn (r) != 0)
continue;
/* if a repeated prime is found it's used as an i^n in one factor */
divisor = 1;
multiplicity = 0;
do
{
if (divisor > max_divisor / i)
break;
multiplicity++;
mpz_set (m, q);
mpz_tdiv_qr_ui (q, r, m, (unsigned long) i);
}
while (mpz_sgn (r) == 0);
assert (nrawfactor < factor_alloc);
rawfactor[nrawfactor].divisor = i;
rawfactor[nrawfactor].multiplicity = multiplicity;
nrawfactor++;
}
mpz_clear (m);
mpz_clear (q);
mpz_clear (r);
}
if (nrawfactor <= 2)
{
mpz_t new_pp;
sprintf (mod34_excuse, "only %d small factor%s",
nrawfactor, nrawfactor == 1 ? "" : "s");
use_pp:
/* reset to two limbs of max_divisor, in case the mpn_mod_34lsub1 code
tried with just one */
max_divisor = 2*limb_bits;
max_divisor_bits = log2_ceil (max_divisor);
mpz_init (new_pp);
nrawfactor = 0;
mod_bits = MIN (numb_bits, limb_bits - max_divisor_bits);
/* one copy of each small prime */
mpz_set_ui (pp, 1L);
for (i = 3; i <= max_divisor; i+=2)
{
if (! isprime (i))
continue;
mpz_mul_ui (new_pp, pp, (unsigned long) i);
if (mpz_sizeinbase (new_pp, 2) > mod_bits)
break;
mpz_set (pp, new_pp);
assert (nrawfactor < factor_alloc);
rawfactor[nrawfactor].divisor = i;
rawfactor[nrawfactor].multiplicity = 1;
nrawfactor++;
}
/* Plus an extra copy of one or more of the primes selected, if that
still fits in max_divisor and the total in mod_bits. Usually only
3 or 5 will be candidates */
for (i = nrawfactor-1; i >= 0; i--)
{
if (rawfactor[i].divisor > max_divisor / rawfactor[i].divisor)
continue;
mpz_mul_ui (new_pp, pp, (unsigned long) rawfactor[i].divisor);
if (mpz_sizeinbase (new_pp, 2) > mod_bits)
continue;
mpz_set (pp, new_pp);
rawfactor[i].multiplicity++;
}
mod_bits = mpz_sizeinbase (pp, 2);
mpz_set (pp_norm, pp);
while (mpz_sizeinbase (pp_norm, 2) < numb_bits)
mpz_add (pp_norm, pp_norm, pp_norm);
mpz_preinv_invert (pp_inverted, pp_norm, numb_bits);
mpz_clear (new_pp);
}
/* start the factor array */
for (i = 0; i < nrawfactor; i++)
{
int j;
assert (nfactor < factor_alloc);
factor[nfactor].divisor = 1;
for (j = 0; j < rawfactor[i].multiplicity; j++)
factor[nfactor].divisor *= rawfactor[i].divisor;
nfactor++;
}
combine:
/* Combine entries in the factor array. Combine the smallest entry with
the biggest one that will fit with it (ie. under max_divisor), then
repeat that with the new smallest entry. */
qsort (factor, nfactor, sizeof (factor[0]), f_cmp_divisor);
for (i = nfactor-1; i >= 1; i--)
{
if (factor[i].divisor <= max_divisor / factor[0].divisor)
{
factor[0].divisor *= factor[i].divisor;
COLLAPSE_ELEMENT (factor, i, nfactor);
goto combine;
}
}
total_fraction = 1.0;
for (i = 0; i < nfactor; i++)
{
mpz_init (factor[i].inverse);
mpz_invert_ui_2exp (factor[i].inverse,
(unsigned long) factor[i].divisor,
(unsigned long) mod_bits);
mpz_init (factor[i].mask);
square_mask (factor[i].mask, factor[i].divisor);
/* fraction of possible squares */
factor[i].fraction = (double) mpz_popcount (factor[i].mask)
/ factor[i].divisor;
/* total fraction of possible squares */
total_fraction *= factor[i].fraction;
}
/* best tests first (ie. smallest fraction) */
qsort (factor, nfactor, sizeof (factor[0]), f_cmp_fraction);
}
void
print (int limb_bits, int nail_bits)
{
int i;
mpz_t mhi, mlo;
printf ("/* This file generated by gen-psqr.c - DO NOT EDIT. */\n");
printf ("\n");
printf ("#if GMP_LIMB_BITS != %d || GMP_NAIL_BITS != %d\n",
limb_bits, nail_bits);
printf ("Error, error, this data is for %d bit limb and %d bit nail\n",
limb_bits, nail_bits);
printf ("#endif\n");
printf ("\n");
printf ("/* Non-zero bit indicates a quadratic residue mod 0x100.\n");
printf (" This test identifies %.2f%% as non-squares (%d/256). */\n",
(1.0 - sq_res_0x100_fraction) * 100.0,
0x100 - sq_res_0x100_num);
printf ("static const mp_limb_t\n");
printf ("sq_res_0x100[%d] = {\n", nsq_res_0x100);
for (i = 0; i < nsq_res_0x100; i++)
{
printf (" CNST_LIMB(0x");
mpz_out_str (stdout, 16, sq_res_0x100[i]);
printf ("),\n");
}
printf ("};\n");
printf ("\n");
if (mpz_sgn (pp) != 0)
{
printf ("/* mpn_mod_34lsub1 not used due to %s */\n", mod34_excuse);
printf ("/* PERFSQR_PP = ");
}
else
printf ("/* 2^%d-1 = ", mod34_bits);
for (i = 0; i < nrawfactor; i++)
{
if (i != 0)
printf (" * ");
printf ("%d", rawfactor[i].divisor);
if (rawfactor[i].multiplicity != 1)
printf ("^%d", rawfactor[i].multiplicity);
}
printf (" %s*/\n", mpz_sgn (pp) == 0 ? "... " : "");
printf ("#define PERFSQR_MOD_BITS %d\n", mod_bits);
if (mpz_sgn (pp) != 0)
{
printf ("#define PERFSQR_PP CNST_LIMB(0x");
mpz_out_str (stdout, 16, pp);
printf (")\n");
printf ("#define PERFSQR_PP_NORM CNST_LIMB(0x");
mpz_out_str (stdout, 16, pp_norm);
printf (")\n");
printf ("#define PERFSQR_PP_INVERTED CNST_LIMB(0x");
mpz_out_str (stdout, 16, pp_inverted);
printf (")\n");
}
printf ("\n");
mpz_init (mhi);
mpz_init (mlo);
printf ("/* This test identifies %.2f%% as non-squares. */\n",
(1.0 - total_fraction) * 100.0);
printf ("#define PERFSQR_MOD_TEST(up, usize) \\\n");
printf (" do { \\\n");
printf (" mp_limb_t r; \\\n");
if (mpz_sgn (pp) != 0)
printf (" PERFSQR_MOD_PP (r, up, usize); \\\n");
else
printf (" PERFSQR_MOD_34 (r, up, usize); \\\n");
for (i = 0; i < nfactor; i++)
{
printf (" \\\n");
printf (" /* %5.2f%% */ \\\n",
(1.0 - factor[i].fraction) * 100.0);
printf (" PERFSQR_MOD_%d (r, CNST_LIMB(%2d), CNST_LIMB(0x",
factor[i].divisor <= limb_bits ? 1 : 2,
factor[i].divisor);
mpz_out_str (stdout, 16, factor[i].inverse);
printf ("), \\\n");
printf (" CNST_LIMB(0x");
if ( factor[i].divisor <= limb_bits)
{
mpz_out_str (stdout, 16, factor[i].mask);
}
else
{
mpz_tdiv_r_2exp (mlo, factor[i].mask, (unsigned long) limb_bits);
mpz_tdiv_q_2exp (mhi, factor[i].mask, (unsigned long) limb_bits);
mpz_out_str (stdout, 16, mhi);
printf ("), CNST_LIMB(0x");
mpz_out_str (stdout, 16, mlo);
}
printf (")); \\\n");
}
printf (" } while (0)\n");
printf ("\n");
printf ("/* Grand total sq_res_0x100 and PERFSQR_MOD_TEST, %.2f%% non-squares. */\n",
(1.0 - (total_fraction * 44.0/256.0)) * 100.0);
printf ("\n");
printf ("/* helper for tests/mpz/t-perfsqr.c */\n");
printf ("#define PERFSQR_DIVISORS { 256,");
for (i = 0; i < nfactor; i++)
printf (" %d,", factor[i].divisor);
printf (" }\n");
mpz_clear (mhi);
mpz_clear (mlo);
}
int
main (int argc, char *argv[])
{
int limb_bits, nail_bits;
if (argc != 3)
{
fprintf (stderr, "Usage: gen-psqr <limbbits> <nailbits>\n");
exit (1);
}
limb_bits = atoi (argv[1]);
nail_bits = atoi (argv[2]);
if (limb_bits <= 0
|| nail_bits < 0
|| nail_bits >= limb_bits)
{
fprintf (stderr, "Invalid limb/nail bits: %d %d\n",
limb_bits, nail_bits);
exit (1);
}
generate_sq_res_0x100 (limb_bits);
generate_mod (limb_bits, nail_bits);
print (limb_bits, nail_bits);
return 0;
}

View File

@@ -0,0 +1,194 @@
/* Generate primesieve data.
Contributed to the GNU project by Marco Bodrato.
Copyright 2021, 2022 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
#include <stdio.h>
#include "bootstrap.c"
static int
bit_to_n (int bit) { return (bit*3+4)|1; }
int
generate (int limb_bits, int limit)
{
mpz_t limb;
int i, lb, pc, c, totpc, maxprime;
mpz_init (limb);
printf ("/* This file generated by gen-sieve.c - DO NOT EDIT. */\n");
printf ("\n");
printf ("#if GMP_LIMB_BITS != %d\n", limb_bits);
printf ("Error, error, this data is for %d bits\n", limb_bits);
printf ("#endif\n");
printf ("\n");
printf ("#define PRIMESIEVE_INIT_TABLE ");
maxprime = 3;
lb = pc = c = totpc = 0;
for (i = 0; i < limit; i++)
{
if (! isprime (bit_to_n (i)))
mpz_setbit (limb, lb);
else
maxprime = bit_to_n (i), ++pc;
++lb;
if (lb == limb_bits)
{
++c;
printf ("\\\n\tCNST_LIMB (0x");
mpz_out_str (stdout, -16, limb);
printf ("),\t/* %d - %d (%d primes) */\t", bit_to_n (i + 1 - limb_bits),
bit_to_n (i + 1) - 1, pc);
totpc += pc;
lb = pc = 0;
mpz_set_ui (limb, 0);
}
}
if ((mpz_sgn (limb) | lb | pc) != 0)
{
printf ("\ngen-sieve: Internal error, during generate (%d, %d).\n", limb_bits, limit);
abort();
}
mpz_clear (limb);
printf ("\n");
printf ("#define PRIMESIEVE_NUMBEROF_TABLE %d\n", c);
printf ("/* #define PRIMESIEVE_PRIMES_IN_TABLE %d */\n", totpc);
printf ("#define PRIMESIEVE_HIGHEST_PRIME %d\n", maxprime);
printf ("/* #define PRIMESIEVE_FIRST_UNCHECKED %d */\n", bit_to_n (limit));
return c;
}
void
setmask (mpz_t mask, int a, int b)
{
mpz_set_ui (mask, 0);
for (unsigned i = 0; i < 2 * a * b; ++i)
if ((bit_to_n (i) % a == 0) || (bit_to_n (i) % b == 0))
mpz_setbit (mask, i);
}
void
gen_sieve_masks (int limb_bits) {
mpz_t mask, limb;
mpz_init (mask);
mpz_init (limb);
printf ("\n");
if (limb_bits > 60 && limb_bits < 91)
{
setmask (mask, 5, 11);
mpz_tdiv_r_2exp (limb, mask, limb_bits);
printf ("#define SIEVE_MASK1 CNST_LIMB(0x");
mpz_out_str (stdout, -16, limb);
printf (")\n");
mpz_tdiv_q_2exp (limb, mask, limb_bits);
printf ("#define SIEVE_MASKT CNST_LIMB(0x");
mpz_out_str (stdout, -16, limb);
printf (")\n");
setmask (mask, 7, 13);
mpz_tdiv_r_2exp (limb, mask, limb_bits);
printf ("#define SIEVE_2MSK1 CNST_LIMB(0x");
mpz_out_str (stdout, -16, limb);
printf (")\n");
mpz_tdiv_q_2exp (mask, mask, limb_bits);
mpz_tdiv_r_2exp (limb, mask, limb_bits);
printf ("#define SIEVE_2MSK2 CNST_LIMB(0x");
mpz_out_str (stdout, -16, limb);
printf (")\n");
mpz_tdiv_q_2exp (limb, mask, limb_bits);
printf ("#define SIEVE_2MSKT CNST_LIMB(0x");
mpz_out_str (stdout, -16, limb);
printf (")\n");
}
else if (limb_bits > 23 && limb_bits < 36)
{
setmask (mask, 5, 7);
mpz_tdiv_r_2exp (limb, mask, limb_bits);
printf ("#define SIEVE_MASK1 CNST_LIMB(0x");
mpz_out_str (stdout, -16, limb);
printf (")\n");
mpz_tdiv_q_2exp (mask, mask, limb_bits);
mpz_tdiv_r_2exp (limb, mask, limb_bits);
printf ("#define SIEVE_MASK2 CNST_LIMB(0x");
mpz_out_str (stdout, -16, limb);
printf (")\n");
mpz_tdiv_q_2exp (limb, mask, limb_bits);
printf ("#define SIEVE_MASKT CNST_LIMB(0x");
mpz_out_str (stdout, -16, limb);
printf (")\n");
}
printf ("\n");
mpz_clear (limb);
mpz_clear (mask);
}
/* 5*2 = 10
7*2 = 14
5*7*2 = 70 (2*35, 3*24, 4*18, 5*14...)
5*11*2 = 110 (2*55, 3*37, 4*28, 5*22...)
5*13*2 = 130 (2*65, 3*44, 4*33, 5*26...)
7*11*2 = 154 (2*77, 3*52, 4*39, 5*31...)
7*13*2 = 182 (2*91, 3*61, 4*46, 5*37...)
*/
int
main (int argc, char *argv[])
{
int limb_bits, limit;
if (argc != 2)
{
fprintf (stderr, "Usage: gen-sieve <limbbits>\n");
exit (1);
}
limb_bits = atoi (argv[1]);
limit = 64 * 28; /* bits in the presieved sieve */
if (limit % limb_bits != 0)
limit += limb_bits - limit % limb_bits;
generate (limb_bits, limit);
gen_sieve_masks (limb_bits);
return 0;
}

View File

@@ -0,0 +1,301 @@
/* gen-trialdivtab.c
Contributed to the GNU project by Torbjorn Granlund.
Copyright 2009, 2012, 2013, 2016, 2018 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 either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
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 General Public License
for more details.
You should have received copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */
/*
Generate tables for fast, division-free trial division for GMP.
There is one main table, ptab. It contains primes, multiplied together, and
several types of pre-computed inverses. It refers to tables of the type
dtab, via the last two indices. That table contains the individual primes in
the range, except that the primes are not actually included in the table (see
the P macro; it sneakingly excludes the primes themselves). Instead, the
dtab tables contains tuples for each prime (modular-inverse, limit) used for
divisibility checks.
This interface is not intended for division of very many primes, since then
other algorithms apply.
*/
#include <stdlib.h>
#include <stdio.h>
#include "bootstrap.c"
int sumspills (mpz_t, mpz_t *, int);
void mpn_mod_1s_4p_cps (mpz_t [7], mpz_t);
int limb_bits;
mpz_t B;
int
main (int argc, char *argv[])
{
int t, p;
mpz_t ppp, acc, inv, gmp_numb_max, tmp, Bhalf;
mpz_t pre[7];
int i;
int start_p, end_p, interval_start, interval_end, omitted_p;
const char *endtok;
int stop;
int np, start_idx;
if (argc < 2)
{
fprintf (stderr, "usage: %s bits endprime\n", argv[0]);
exit (1);
}
limb_bits = atoi (argv[1]);
end_p = 1290; /* default end prime */
if (argc == 3)
end_p = atoi (argv[2]);
printf ("#if GMP_LIMB_BITS != %d\n", limb_bits);
printf ("#error This table is for GMP_LIMB_BITS = %d\n", limb_bits);
printf ("#endif\n\n");
printf ("#if GMP_NAIL_BITS != 0\n");
printf ("#error This table does not support nails\n");
printf ("#endif\n\n");
for (i = 0; i < 7; i++)
mpz_init (pre[i]);
mpz_init (B);
mpz_setbit (B, limb_bits);
mpz_init_set (gmp_numb_max, B);
mpz_sub_ui (gmp_numb_max, gmp_numb_max, 1);
mpz_init (tmp);
mpz_init (inv);
mpz_init (Bhalf);
mpz_setbit (Bhalf, limb_bits - 1);
start_p = 3;
mpz_init_set_ui (ppp, 1);
mpz_init (acc);
interval_start = start_p;
omitted_p = 3;
interval_end = 0;
/* printf ("static struct gmp_primes_dtab gmp_primes_dtab[] = {\n"); */
printf ("#ifdef WANT_dtab\n");
for (t = start_p; t <= end_p; t += 2)
{
if (! isprime (t))
continue;
mpz_mul_ui (acc, ppp, t);
stop = mpz_cmp (acc, Bhalf) >= 0;
if (!stop)
{
mpn_mod_1s_4p_cps (pre, acc);
stop = sumspills (acc, pre + 2, 5);
}
if (stop)
{
for (p = interval_start; p <= interval_end; p += 2)
{
if (! isprime (p))
continue;
printf (" P(%d,", (int) p);
mpz_invert_ui_2exp (inv, p, limb_bits);
printf ("CNST_LIMB(0x"); mpz_out_str (stdout, 16, inv); printf ("),");
mpz_tdiv_q_ui (tmp, gmp_numb_max, p);
printf ("CNST_LIMB(0x"); mpz_out_str (stdout, 16, tmp);
printf (")),\n");
}
mpz_set_ui (ppp, t);
interval_start = t;
omitted_p = t;
}
else
{
mpz_set (ppp, acc);
}
interval_end = t;
}
printf ("#define SMALLEST_OMITTED_PRIME %d\n", (int) omitted_p);
printf ("#endif\n");
printf ("#ifdef WANT_ptab\n");
/* printf ("static struct gmp_primes_ptab gmp_primes_ptab[] = {\n"); */
endtok = "";
mpz_set_ui (ppp, 1);
interval_start = start_p;
interval_end = 0;
np = 0;
start_idx = 0;
for (t = start_p; t <= end_p; t += 2)
{
if (! isprime (t))
continue;
mpz_mul_ui (acc, ppp, t);
stop = mpz_cmp (acc, Bhalf) >= 0;
if (!stop)
{
mpn_mod_1s_4p_cps (pre, acc);
stop = sumspills (acc, pre + 2, 5);
}
if (stop)
{
mpn_mod_1s_4p_cps (pre, ppp);
printf ("%s", endtok);
printf (" {CNST_LIMB(0x"); mpz_out_str (stdout, 16, ppp);
printf ("),{CNST_LIMB(0x"); mpz_out_str (stdout, 16, pre[0]);
printf ("),%d", (int) PTR(pre[1])[0]);
for (i = 0; i < 5; i++)
{
printf (",");
printf ("CNST_LIMB(0x"); mpz_out_str (stdout, 16, pre[2 + i]);
printf (")");
}
printf ("},");
printf ("%d,", start_idx);
printf ("%d}", np - start_idx);
endtok = ",\n";
mpz_set_ui (ppp, t);
interval_start = t;
start_idx = np;
}
else
{
mpz_set (ppp, acc);
}
interval_end = t;
np++;
}
printf ("\n");
printf ("#endif\n");
return 0;
}
unsigned long
mpz_log2 (mpz_t x)
{
return mpz_sgn (x) ? mpz_sizeinbase (x, 2) : 0;
}
void
mpn_mod_1s_4p_cps (mpz_t cps[7], mpz_t bparm)
{
mpz_t b, bi;
mpz_t B1modb, B2modb, B3modb, B4modb, B5modb;
mpz_t t;
int cnt;
mpz_init_set (b, bparm);
cnt = limb_bits - mpz_log2 (b);
mpz_init (bi);
mpz_init (t);
mpz_init (B1modb);
mpz_init (B2modb);
mpz_init (B3modb);
mpz_init (B4modb);
mpz_init (B5modb);
mpz_set_ui (t, 1);
mpz_mul_2exp (t, t, limb_bits - cnt);
mpz_sub (t, t, b);
mpz_mul_2exp (t, t, limb_bits);
mpz_tdiv_q (bi, t, b); /* bi = B^2/b, except msb */
mpz_set_ui (t, 1);
mpz_mul_2exp (t, t, limb_bits); /* t = B */
mpz_tdiv_r (B1modb, t, b);
mpz_mul_2exp (t, B1modb, limb_bits);
mpz_tdiv_r (B2modb, t, b);
mpz_mul_2exp (t, B2modb, limb_bits);
mpz_tdiv_r (B3modb, t, b);
mpz_mul_2exp (t, B3modb, limb_bits);
mpz_tdiv_r (B4modb, t, b);
mpz_mul_2exp (t, B4modb, limb_bits);
mpz_tdiv_r (B5modb, t, b);
mpz_set (cps[0], bi);
mpz_set_ui (cps[1], cnt);
mpz_tdiv_q_2exp (cps[2], B1modb, 0);
mpz_tdiv_q_2exp (cps[3], B2modb, 0);
mpz_tdiv_q_2exp (cps[4], B3modb, 0);
mpz_tdiv_q_2exp (cps[5], B4modb, 0);
mpz_tdiv_q_2exp (cps[6], B5modb, 0);
mpz_clear (b);
mpz_clear (bi);
mpz_clear (t);
mpz_clear (B1modb);
mpz_clear (B2modb);
mpz_clear (B3modb);
mpz_clear (B4modb);
mpz_clear (B5modb);
}
int
sumspills (mpz_t ppp, mpz_t *a, int n)
{
mpz_t s;
int i, ret;
mpz_init_set (s, a[0]);
for (i = 1; i < n; i++)
{
mpz_add (s, s, a[i]);
}
ret = mpz_cmp (s, B) >= 0;
mpz_clear (s);
return ret;
}

2344
blender-5.2.0/extern/gmp-source/gmp-h.in vendored Normal file

File diff suppressed because it is too large Load Diff

5346
blender-5.2.0/extern/gmp-source/gmp-impl.h vendored Normal file

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More