libdfp-1.0.12/000077500000000000000000000000001261375163000130375ustar00rootroot00000000000000libdfp-1.0.12/.gitignore000066400000000000000000000003051261375163000150250ustar00rootroot00000000000000*~ *.a *.cache *.jmprel *.log *.map *.o *.os *.out *.so *.so.* *.symlist *.tmp config.h config.status configure.scan Makefile libdfp-test-ulps.h stamp-h* sysd-versions Versions.all Versions.sysdepslibdfp-1.0.12/CONTRIBUTING000066400000000000000000000042441261375163000146750ustar00rootroot00000000000000Contribution Statement: Since Libdfp is a Free Software Foundation project any 'legally significant' contribution requires that the contributor go through the FSF Copyright Assignment process. This webpage describes the copyright assignment requirements: http://www.gnu.org/prep/maintain/maintain.html#Legally-Significant The maintainer of this library also requires that each individual change be accompanied by a DCO that is outlined as follows. Process For Accepting Third Party Code Contributions: To improve tracking of contributions to this project we will use a process modeled on the modified Developers Certificate of Origin (DCO 1.1) and use a "sign-off" procedure on patches that are being emailed around or contributed in any other way. The sign-off is a simple line at the end of the explanation for the patch, which certifies that you wrote it or otherwise have the right to pass it on as an open-source patch. The rules are pretty simple: if you can certify the below: By making a contribution to this project, I certify that: (a)The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b)The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source License and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c)The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d)The contribution is made free of any other party's intellectual property claims or rights. (e)I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. Then you just add a line saying: Signed-off-by: Random J Developer random@developer.org> libdfp-1.0.12/CONTRIBUTORS000066400000000000000000000013511261375163000147170ustar00rootroot00000000000000Maintainers: Base: Tulio Magno Quites Machado Filho PowerPC: Tulio Magno Quites Machado Filho s390: x86(64): Tulio Magno Quites Machado Filho Contributors: Ryan S. Arnold Peter Eberlein Joseph Kerian Andreas Krebbel Carlos Eduardo Seo Luis Machado Adhemerval Zanella Tulio Magno Quites Machado Filho Rajalakshmi Srinivasaraghavan Paul E. Murphy Gabriel F. T. Gomes libdfp-1.0.12/COPYING.txt000066400000000000000000000577711261375163000147310ustar00rootroot00000000000000GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991-2015 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. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that 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 and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an 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 distribute a copy of this License along with the Library. 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 Library or any portion of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. * b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. * c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. * d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, 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 Library, 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 Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you 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. If distribution of 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 satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: * a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) * b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. * c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. * d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. * e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be 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. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: * a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. * b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library 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. 9. 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 Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or 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 Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library 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 Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. 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. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the 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 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 Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is 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 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. 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 LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS libdfp-1.0.12/Makefile.in000066400000000000000000000473431261375163000151170ustar00rootroot00000000000000ifneq (,) This Makefile requires GNU Make. endif top_srcdir := @top_srcdir@ top_builddir = . prefix = @prefix@ exec_prefix = @exec_prefix@ libdir = @libdir@ includedir = @includedir@ docdir = @docdir@ # Where to install the library and object files. ifndef libdir libdir = $(exec_prefix)/lib endif inst_libdir = $(install_root)$(libdir) # Where to install the header files. ifndef includedir includedir = $(prefix)/include endif inst_includedir = $(install_root)$(includedir) # Where to install the README document ifndef docdir docdir = $(prefix)/share/doc/ endif inst_docdir = $(install_root)$(docdir) dfp_name = @PACKAGE_NAME@ dfp_version = @PACKAGE_VERSION@ STATIC_LIB = @PACKAGE_NAME@.a # The real library code: e.g. libdfp-1.0.0.so. SHARED_REALNAME_LIB = @PACKAGE_NAME@-@PACKAGE_VERSION@.so # The soname that symlinks to the real library code: e.g. libdfp.so.1. # Traditionally the version number on the soname defined the 'interface' # version. Since this library intends to use symbol versioning there # probably isn't ever a reason to move to .so.2 or later but we'll follow the # precedent. SHARED_SONAME_LIB = @PACKAGE_NAME@.so.1 # The linkername that symlinks to the soname: e.g. libdfp.so. The linker looks for this name. SHARED_LINKERNAME_LIB = @PACKAGE_NAME@.so CC = @CC@ CXX = @CXX@ LDD = @LDD@ OBJDUMP = @OBJDUMP@ READELF = @READELF@ GDB = @GDB@ CXXFLAGS = @CXXFLAGS@ # This may be naive CPPFLAGS = @CPPFLAGS@ RANLIB = @RANLIB@ AWK = @AWK@ LDFLAGS = @LDFLAGS@ INSTALL := install # libdecnumber or libbid dfp_backend = @dfp_backend@ dfp_backend_lib = @dfp_backend@.a # dpd or bid dfp_encoding = @enable_decimal_float@ # e.g. powerpc base_machine = @base_machine@ # e.g. powerpc32 machine = @machine@ # e.g. power6 submachine = @submachine@ # e.g. -mcpu=power6 libdfp_cv_submachine_opt = @libdfp_cv_submachine_opt@ # Necessary for z9-ec and z10 s390 platforms. mzarch = @mzarch@ ifdef libdfp_cv_submachine_opt cflags-cpu = $(libdfp_cv_submachine_opt) asflags-cpu = $(libdfp_cv_submachine_opt) endif picflag = @picflag@ # Yes this is a bit of a hack, but gcc/libdecnumber/Makefile won't allow # CFLAGS to be overridden on a submake invocation. BACKEND_CFLAGS= ifeq (libdecnumber, $(dfp_backend)) BACKEND_CFLAGS=$(cflags-cpu) $(picflag) endif cxxdecimal = @cxxdecimal@ default_cflags := @CFLAGS@ default_asflags := @ASFLAGS@ ifndef +cflags # Remove -I stuff from CFLAGS. +cflags := $(filter-out -I%,$(default_cflags)) endif # Add -mcpu= targets and -f[pic|PIC]. +cflags += $(cflags-cpu) $(picflag) # Don't duplicate options. +cflags := $(sort $(+cflags)) override CFLAGS = $(gnu-inline-CFLAGS) $(+cflags) # These are the flags given to the compiler to tell it what sort of # optimization and/or debugging output to do for .S files. ifndef +asflags # Remove -I stuff from ASFLAGS. +asflags := $(filter-out -I%,$(default_asflags)) endif # This makes sure -mcpu=CPU gets used when gcc is invoked against .S files. # Also pull in CFLAGS so we get -m options set by the configuration. +asflags += $(asflags-cpu) $(filter -g%,$(CFLAGS)) $(filter -m%,$(CFLAGS)) # Don't duplicate options. +asflags := $(sort $(+asflags)) override ASFLAGS = $(+asflags) sysdep_dirs = @sysdep_dirs@ # This is the precedence ordered list of subdirectories that configure # selected for searching based upon submachine, machine, base_machine, # dfp_encoding, and dfp_backend. Add the ieee754r and decNumberMath # convenience directories to the list. # Find each sysdep directory or convenience directory with a Makefile in it. makefile_dirs := $(foreach odir,$(sysdep_dirs), $(dir $(wildcard $(top_srcdir)/$(odir)/Makefile))) $(top_srcdir)/decNumberMath/ $(top_srcdir)/ieee754r/ $(top_srcdir)/base-math # Like $makefile_dirs but add the $(top_srcdir) reference and strip out the redundant spaces. # This has to be = assigned. all_srcdirs = $(strip $(foreach dir,$(sysdep_dirs), $(top_srcdir)/$(dir))) $(top_srcdir)/decNumberMath/ $(top_srcdir)/ieee754r/ $(top_srcdir)/base-math $(top_srcdir)/ $(top_srcdir)/tests # We need to add the $(dfp_backend) directories to the search path in order to # pick up header files in those directories. ifeq ($(dfp_backend),libdecnumber) # libdecnumber/bid or libdecnumber/dpd holds header files. backend_headers := $(dfp_backend)/$(dfp_encoding) $(dfp_backend) else # libbid # TODO implement backend_headers := endif # For header files we want to search every directory that is relevant. We # have to include $(top_builddir) in order to pick up the configure generated # config.h. system_header_dirs := dfp dfp/decimal header_dirs := $(strip include $(system_header_dirs) $(backend_headers) $(sysdep_dirs) decNumberMath/ ieee754/ base-math/) header_search_dirs := $(header_dirs:%=$(top_srcdir)/%) $(top_srcdir) $(top_builddir) # GNU Make hack to reference a ' ' (space) character as the `from' function parameter in $(subst from,to,...). sp := sp += # VPATH only needs to know the directory that source files are in. Headers # are searched based on -I precedence during the compilation invocation. VPATH := $(subst $(sp),:,$(all_srcdirs)) # Files common to the $(top_srcdir). These may be overriden in the sysdep # directories and this list may have additional files added by sysdeps # directory Makefiles which are included (not recursively invoked). libdfp_files := dfptypeconv mapround decode fmt_d32 fmt_d64 fmt_d128 fe_decround \ strtod32 strtod64 strtod128 wcstod32 wcstod64 wcstod128 \ printf_dfp init_dfp libdfp-version # The sysdeps subdirs aren't recursively invoked, they're included so that # they can add files to the libdfp_files list. include $(foreach dir,$(makefile_dirs), $(dir)/Makefile ) # Libdfp has a dependency on the backend so build that first. all: first $(dfp_backend)/$(dfp_backend_lib) libdfp # Fake rule to output the VPATH before we build anything. Don't use .PHONY # because we want this printed each time. first: @echo VPATH=$(VPATH) @echo Processing Makefiles: $(makefile_dirs) # Configure will have generated the Makefile for the selected backend. Let's # add it to the subdir list so it gets recursively invoked by Make. Don't pass # -e to make or it could pull unwanted variables from the environment. # Yes, passing $(BACKEND_CFLAGS) in -DEFS is a hack, but since the # libdecnumber maintainers won't allow CFLAGS to be overridden and the libdfp # maintainer doesn't want to use libtool this hack will have to stand. $(dfp_backend)/$(dfp_backend_lib): @echo "+Building DFP backend $@" DEFS="-D__STDC_DEC_FP__=200704L $(mzarch) $(BACKEND_CFLAGS)" $(MAKE) -C $(dfp_backend) libdfp: @enable_static@ @enable_shared@ static: $(top_builddir)/$(STATIC_LIB) # Create the actual file with the version, the .so linker symlink and its # SONAME symlink. shared: $(top_builddir)/$(SHARED_REALNAME_LIB) \ $(top_builddir)/$(SHARED_LINKERNAME_LIB) \ $(top_builddir)/$(SHARED_SONAME_LIB) @echo +Building shared lib and symlinks: $(notdir $^) WARNS := -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -Wno-long-long C_DEFINES := -D__STDC_DEC_FP__=200704L -D__STDC_WANT_DEC_FP__=1 -DOPTION_EGLIBC_LOCALE_CODE=1 -std=gnu99 -D_ISOC99_SOURCE ASM_DEFINES := -D__ELF__ -D__ASSEMBLER__ -DASSEMBLER -D__STDC_DEC_FP__=200704L -D__STDC_WANT_DEC_FP__=1 -DOPTION_EGLIBC_LOCALE_CODE=1 CXX_DEFINES := -D__STDC_DEC_FP__=200704L -D__STDC_WANT_DEC_FP__=1 -DOPTION_EGLIBC_LOCALE_CODE=1 -D_ISOC99_SOURCE CXX_WARNS := -W -Wall -Wwrite-strings -Wmissing-format-attribute -Wno-long-long # Build the static object files. .c.o: $(CC) $(CFLAGS) $(CPPFLAGS) $(mzarch) -c $< $(C_DEFINES) $(WARNS) -include $(top_srcdir)/include/libdfp-symbols.h -include $(top_builddir)/config.h $(foreach dir, $(header_search_dirs), -I$(dir)) -o $@ .S.o: $(CC) $(CFLAGS) $(ASFLAGS) $(mzarch) -c $< $(ASM_DEFINES) $(WARNS) -include $(top_srcdir)/include/libdfp-symbols.h -include $(top_builddir)/config.h $(foreach dir, $(header_search_dirs), -I$(dir)) -o $@ # Build the shared object files. .c.os: $(CC) $(CFLAGS) $(CPPFLAGS) $(mzarch) -c $< $(C_DEFINES) $(WARNS) -include $(top_srcdir)/include/libdfp-symbols.h -include $(top_builddir)/config.h $(foreach dir, $(header_search_dirs), -I$(dir)) -o $@ .S.os: $(CC) $(CFLAGS) $(ASFLAGS) $(mzarch) -c $< $(ASM_DEFINES) $(WARNS) -include $(top_srcdir)/include/libdfp-symbols.h -include $(top_builddir)/config.h $(foreach dir, $(header_search_dirs), -I$(dir)) -o $@ # C++ compatibility test cases. .cpp.os: $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(mzarch) -c $< $(CXX_DEFINES) $(CXX_WARNS) -include $(top_srcdir)/include/libdfp-symbols.h -include $(top_builddir)/config.h $(foreach dir, $(header_search_dirs), -I$(dir)) -o $@ # Archive the static library and include all of the .o files from the backend # archive. IF the backend has more than the base directory the .o detection # mechanism will need to be more robust than this. $(top_builddir)/$(STATIC_LIB): $(dfp_backend)/$(dfp_backend_lib) $(addsuffix .o,$(libdfp_files)) @echo +Creating static library $@ $(AR) rc $@ $(wordlist 2,$(words $^),$^) $(top_builddir)/$(dfp_backend)/*.o @ranlibpath=`which $(RANLIB)`; \ if test -x "$$ranlibpath"; \ then $(RANLIB) $@; fi; # Create libdfp.so -> libdfp.so.1 symlink. $(top_builddir)/$(SHARED_LINKERNAME_LIB): $(top_builddir)/$(SHARED_REALNAME_LIB) @echo "+Creating linker .so symlink $(notdir $@) -> $(notdir $<)" ln -f -s $< $@ # Create libdfp.so.1 -> libdfp-1.0.1.so symlink. $(top_builddir)/$(SHARED_SONAME_LIB): $(top_builddir)/$(SHARED_REALNAME_LIB) @echo "+Create the library compat symlink $(notdir $@) -> $(notdir $<)" ln -f -s $(notdir $<) $@ # Build the version tagged 'realname' shared object. This requires that the # $(dfp_name).map file be composed out of individual Versions files. The # -bsymbolic switch makes the library avoid using the PLT for intra-library # calls. $(top_builddir)/$(SHARED_REALNAME_LIB): $(top_builddir)/$(dfp_name).map $(dfp_backend)/$(dfp_backend_lib) $(addsuffix .os,$(libdfp_files)) @echo +Linking shared object files into $@. $(CC) $(CFLAGS) $(LDFLAGS) $(mzarch) -shared -Wl,-soname,$(SHARED_SONAME_LIB) -Bsymbolic -Wl,--whole-archive $(dfp_backend)/$(dfp_backend_lib) -Wl,--no-whole-archive -Wl,--version-script,$(dfp_name).map -Wl,-entry=__libdfp_version $(addsuffix .os,$(libdfp_files)) -o $@ -lm -shared-libgcc # The LIBDFP version script support is strongly based upon the GLIBC version # script Makefile foo. Thank you Roland McGrath and Ulrich Drepper! # Versions.def defines the package versions. $(top_builddir)/Versions.all: $(..)scripts/firstversions.awk \ $(top_srcdir)/Versions.def @echo +Creating $@ by running $(word 1,$^) against $(word 2,$^). { cat $(word 2,$^); } | LC_ALL=C $(AWK) -f $< > $@T mv -f $@T $@ # Versions.sysdeps is a concatenation of all of the sysdep directory Versions # files (that accompany a Makefile) and run through sed to strip comments. We # use the wildcard function to verify that there actually is a Versions file # accompanying a Makefile before we set it as a dependency. Some sysdeps dirs # only add internal interfaces. $(top_builddir)/Versions.sysdeps: $(top_srcdir)/Versions $(wildcard $(makefile_dirs:%=%Versions)) @echo +Scrubbing the following Versions files for comments and concatenating into a single $@ file. sed '/^[ ]*%/!s/#.*$$//;/^[ ]*$$/d;s/^[ ]*%/#/' $^ > $@T mv -f $@T $@ move-if-change = $(SHELL) $(top_srcdir)/scripts/move-if-change # This runs versions.awk and generates libdfp.map from the Versions.all and # Versions.sysdeps files. $(top_builddir)/sysd-versions: $(top_builddir)/Versions.all \ $(top_builddir)/Versions.sysdeps \ $(..)scripts/versions.awk @echo +The following invocation of $(word 3,$^) outputs $(dfp_name).map automagically. ( echo 'sysd-versions-subdirs = $(strip $(top_srcdir)/ $(makefile_dirs))'; \ cat $(top_builddir)/$(word 2,$^) \ | LC_ALL=C $(AWK) -v buildroot="$(top_builddir)/" -v defsfile=$< \ -v move_if_change='$(move-if-change)' \ -f $(word 3,$^) \ ) > $@T mv $@T $@ # This rule causes sysd-versions to be generated, which in turn invokes # versions.awk which generates libdfp.map implicitly. $(top_builddir)/libdfp.map: $(top_builddir)/sysd-versions GLIBC_LIBS := -lc -lm libdfp_c_tests = test-printf test-amort test-decode \ test-strtod test-numdigits test-get_digits \ test-fenv test-bfp-conversions test-wchar \ test-getexp test-setexp test-left_justify \ test-fpclassify-d32 test-fpclassify-d64 test-fpclassify-d128 \ test-fabs-d32 test-fabs-d64 test-fabs-d128 \ test-copysign-d32 test-copysign-d64 test-copysign-d128 \ test-quantum-d32 test-quantum-d64 test-quantum-d128 \ test-quantize-d32 test-quantize-d64 test-quantize-d128 \ test-samequantum-d32 test-samequantum-d64 test-samequantum-d128 \ test-exp-d32 test-exp-d64 test-exp-d128 \ test-log-d32 test-log-d64 test-log-d128 \ test-log1p-d32 test-log1p-d64 test-log1p-d128 \ test-logb-d32 test-logb-d64 test-logb-d128 \ test-log10-d32 test-log10-d64 test-log10-d128 \ test-llquantexp-d32 test-llquantexp-d64 test-llquantexp-d128 \ test-isnan-d32 test-isnan-d64 test-isnan-d128 \ test-isinf-d32 test-isinf-d64 test-isinf-d128 \ test-isfinite-d32 test-isfinite-d64 test-isfinite-d128 \ test-issignaling-d32 test-issignaling-d64 test-issignaling-d128 \ test-ilogb-d32 test-ilogb-d64 test-ilogb-d128 \ test-llogb-d32 test-llogb-d64 test-llogb-d128 \ test-ceil-d32 test-ceil-d64 test-ceil-d128 \ test-floor-d32 test-floor-d64 test-floor-d128 \ test-nearbyint-d32 test-nearbyint-d64 test-nearbyint-d128 \ test-round-d32 test-round-d64 test-round-d128 \ test-roundeven-d32 test-roundeven-d64 test-roundeven-d128 \ test-trunc-d32 test-trunc-d64 test-trunc-d128 \ test-isgreater-d32 test-isgreater-d64 test-isgreater-d128 \ test-isgreaterequal-d32 test-isgreaterequal-d64 test-isgreaterequal-d128 \ test-isless-d32 test-isless-d64 test-isless-d128 \ test-islessequal-d32 test-islessequal-d64 test-islessequal-d128 # Only enable C++ tests if compiler supports std::decimal (GCC 4.5+), # otherwise just skip them. ifeq ($(cxxdecimal), yes) libdfp_cxx_tests = test-ostream test-ostream-g-spec test-istream endif libdfp_tests = $(libdfp_c_tests) $(libdfp_cxx_tests) test-printf.os: $(top_builddir)/printf_dfp.os test-strtod.os: $(top_builddir)/strtod32.os $(top_builddir)/strtod64.os $(top_builddir)/strtod128.os # Empty rule which simply makes the libdfp_tests .so's dependent on # tests/libdfp-test.c so that when the libdfp-test file changes all of the test .so # files are rebuilt since almost all of them depend on the scaffold anyway. $(addsuffix .os, $(libdfp_tests)): $(top_srcdir)/tests/libdfp-test.c # The CPP test rely on the header. If that changes then they # need to be rebuilt. $(addsuffix .os, $(libdfp_cxx_tests)): $(top_srcdir)/dfp/decimal/decimal $(top_srcdir)/dfp/float.h # Add the ULP file generation explicity rule $(addprefix $(objpfx), $(libdfp_tests)): $(top_builddir)/libdfp-test-ulps.h ulps-file = $(shell find $(sysdep_dirs:%=$(top_srcdir)/%/libdfp-test-ulps)) $(top_builddir)/libdfp-test-ulps.h: $(ulps-file) $(top_srcdir)/tests/gen-libdfp-ulps.py $< -o $@ # Explicitly link against the uninstalled GLIBC and the libdfp.so.1 we just # built. $(libdfp_c_tests): CFLAGS += -DNOT_IN_libdfp -I$(top_srcdir)/tests -Wl,--no-as-needed $(libdfp_c_tests): %:%.os $(top_builddir)/$(SHARED_SONAME_LIB) $(CC) $(CFLAGS) $(mzarch) $(top_builddir)/$(addsuffix .os,$@) -o $@ $(GLIBC_LIBS) -L$(top_builddir)/ -ldfp # Explicitly link against the uninstalled GLIBC and the Libdfp.so.1 we just # built. $(libdfp_cxx_tests): CXXFLAGS += -DNOT_IN_libdfp -I$(top_srcdir)/tests -Wl,--no-as-needed $(libdfp_cxx_tests): %:%.os $(top_builddir)/$(SHARED_SONAME_LIB) $(CXX) $(CXXFLAGS) $(mzarch) $(top_builddir)/$(addsuffix .os,$@) -o $@ $(GLIBC_LIBS) -L$(top_builddir)/ -ldfp test-%-d%: $(addsuffix .os,$@) $(CC) $(CFLAGS) $(mzarch) $(GLIBC_LIBS) -L$(top_builddir)/ -ldfp $(top_builddir)/$^ -o $@ test-%-d32.c: %.input $(top_srcdir)/tests/gen-libdfp-tests.py -t decimal32 $^ > $(top_builddir)/$@ test-%-d64.c: %.input $(top_srcdir)/tests/gen-libdfp-tests.py -t decimal64 $^ > $(top_builddir)/$@ test-%-d128.c: %.input $(top_srcdir)/tests/gen-libdfp-tests.py -t decimal128 $^ > $(top_builddir)/$@ # Make check main rule $(addsuffix .out,$(libdfp_tests)): %.out:% LD_LIBRARY_PATH=$(top_builddir)/:$$LD_LIBRARY_PATH $(top_builddir)/$(patsubst %.out,%,$@) 2> $(top_builddir)/$@ 1> /dev/null # Check ABI rules .PRECIOUS: %.symlist generated += $(extra-libs:=.symlist) vpath %.abilist $(+sysdeps_dirs) check-abi: check-abi-libdfp.out $(warning $@) check-abi-libdfp.out: libdfp.abilist libdfp.symlist diff -p -U 0 $(filter %.abilist,$^) $(filter %.symlist,$^) > $@ %.symlist: $(top_srcdir)/scripts/abilist.awk %.dynsym LC_ALL=C $(AWK) -f $^ > $@T mv -f $@T $@ %.dynsym: %.so LC_ALL=C $(OBJDUMP) --dynamic-syms $< > $@T mv -f $@T $@ # Check local PLT calls check-localplt: check-localplt.out vpath localplt.data $(+sysdep_dirs) check-localplt.out: $(top_srcdir)/scripts/check-localplt.awk \ $(top_srcdir)/scripts/localplt.awk \ libdfp.so.jmprel \ localplt.data LC_ALL=C $(AWK) -f $(filter-out $< %localplt.data,$^) | \ LC_ALL=C $(AWK) -f $< $(filter %localplt.data,$^) - \ > $@ libdfp.so.jmprel: libdfp.so @rm -f $@T LC_ALL=C $(READELF) -W -S -d -r $< > $@T test -s $@T mv -f $@T $@ # The .out files are predicated in another rule on the actual test executables, so # those are built from those rules. check: $(addsuffix .out,$(libdfp_tests)) check-abi check-localplt @echo +Completed make check .PHONY: check clean: rm -f *.o rm -f *.os rm -f $(STATIC_LIB) rm -f $(SHARED_LINKERNAME_LIB) rm -f $(SHARED_SONAME_LIB) rm -f $(SHARED_REALNAME_LIB) rm -f Versions.all rm -f Versions.sysdeps rm -f libdfp.map $(SHARED_LINKERNAME_LIB).jmprel libdfp.symlist rm -f Versions.tmp rm -f sysd-versions rm -f check-abi-libdfp.out check-localplt.out rm -f $(addsuffix .out,$(libdfp_tests)) rm -f $(addsuffix .conf,$(libdfp_tests)) rm -f $(libdfp_tests) rm -f libdfp-test-ulps.h rm -f $(top_builddir)/$(dfp_backend)/*.o rm -f $(top_builddir)/$(dfp_backend)/*.a .PHONY: clean # distclean cleans up the files added by configure. distclean: rm -f $(top_builddir)/config.h rm -f $(top_builddir)/config.log rm -f $(top_builddir)/config.status rm -f $(top_builddir)/Makefile rm -f $(top_builddir)/$(dfp_backend)/config.h rm -f $(top_builddir)/$(dfp_backend)/config.log rm -f $(top_builddir)/$(dfp_backend)/config.status rm -f $(top_builddir)/$(dfp_backend)/gstdint.h rm -f $(top_builddir)/$(dfp_backend)/Makefile rm -f $(top_builddir)/$(dfp_backend)/stamp-h1 .PHONY: distclean install: all install-doc install-headers $(INSTALL) -d $(inst_libdir) ifeq ("@enable_static@","static") $(INSTALL) -t $(inst_libdir) $(top_builddir)/$(STATIC_LIB) endif $(INSTALL) -t $(inst_libdir) $(top_builddir)/$(SHARED_REALNAME_LIB) ln -f -s $(SHARED_REALNAME_LIB) $(inst_libdir)/$(SHARED_LINKERNAME_LIB) ln -f -s $(SHARED_REALNAME_LIB) $(inst_libdir)/$(SHARED_SONAME_LIB) .PHONY: install install-headers: $(INSTALL) -d $(inst_includedir) $(INSTALL) -d $(inst_includedir)/dfp $(INSTALL) -d $(inst_includedir)/dfp/decimal $(INSTALL) -t $(inst_includedir)/dfp $(top_srcdir)/dfp/*.h $(INSTALL) -t $(inst_includedir)/dfp/decimal/ $(top_srcdir)/dfp/decimal/* .PHONY: install-headers install-doc: $(top_srcdir)/ChangeLog.md $(INSTALL) -d $(inst_docdir)dfp/ $(INSTALL) -t $(inst_docdir)dfp/ $(top_srcdir)/README.user mv $(inst_docdir)dfp/README.user $(inst_docdir)dfp/README $(INSTALL) -t $(inst_docdir)dfp/ $(top_srcdir)/ChangeLog.md .PHONY: install-doc $(top_srcdir)/ChangeLog.md: cd $(top_srcdir) && ./generate-changelog.sh > $(top_srcdir)/ChangeLog.md # Clean out the existing .SUFFIXES setting. .SUFFIXES: # Prioritize .S over .c when searching for target files. The .os suffix # is used for shared object file and the .o suffix is for static object files. .SUFFIXES: .S .c .cpp .o .os libdfp-1.0.12/NEWS000066400000000000000000000050771261375163000135470ustar00rootroot00000000000000Decimal Floating Point C Library - history of user-visible changes. Copyright (C) 2014-2015 Free Software Foundation, Inc. See the end for copyright conditions. Version 1.0.10 * Added BID support for x86_64 and x86. * Fixes to avoid external PLT calls to internal supplied symbols. * Add optimized fabsd[32|64|128], and copysignd[32|64|128] for PowerPC with DFP hardware support. ---------------------------------------------------------------------- Version 1.0.9 * Support for powerpc64le has beed added. * Various fixes for LE build. * Support for configure with --with-cpu=power8 has been added. * Fix for isinfd[32|64|128]: it now follow GLIBC convention and returns 1 for plus infinity and -1 for minus infinity. * Fix finited result to return a positive argument for any normal number. * New macro named issignaling to check for a signaling NaN (sNaN). It is based on draft TS 18661. * New llogbd[32|64|128] implementation to return the logb result as long int. * New roundevend[32|64|128] implementation that rounds its argument to the nearest integer value in floating-point format, rounding halfway cases to even (that is, to the nearest value whose least significant bit 0), regardless of the current rounding direction. It is based on draft 18661-2. * Add optimized ceild[32|64|128], truncd[32|64|128], floord[32|64|128], nearbyintd[32|64|128], roundd[32|64|128], and roundevend[32|64|128] for PowerPC with DFP hardware support. * New quantumd[32|64|128] implementation that compute the quantum of a finite argument. It is based on draft 18661-2. * Add optimized quantumd[32|64|128] and samequantumd[32|64|128] implementation for PowerPC with DFP hardware support. ---------------------------------------------------------------------- Copyright information: Copyright (C) 2007-2014 Free Software Foundation, Inc. he Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. libdfp-1.0.12/README.developer000066400000000000000000000623551261375163000157160ustar00rootroot00000000000000=========================================================================== Libdfp The "Decimal Floating Point C Library" Developer's Guide for the GNU/Linux OS and GLIBC 2.10 Contributed by IBM Corporation Copyright (C) 2009-2014 Free Software Foundation =========================================================================== NOTE:Eight space tabs are the optimum editor setting for reading this file. =========================================================================== Author(s) : Ryan S. Arnold Andreas Krebbel Date Created: July 14, 2009 Last Changed: January 21, 2010 --------------------------------------------------------------------------- Table of Contents: 1. Introduction 1.1. ISO/IEC TR 24732 1.2. IEEE 754-2008 (DPD & BID Encodings) 1.3. Backends (libdecnumber & libbid) 2. Availability 3. Compliance With ISO/IEC TR 24732 3.1 __STDC_WANT_DEC_FP__ 3.2 scanf 4. Dependencies 4.1 GNU/Linux OS 4.2 GLIBC Minimum Version 4.3 GLIBC Headers 4.4 libdecnumber 4.5 GCC With --enable-decimal-float Support 4.6 Autoconf & GNU Make 5. Configuration 5.1 Configure Switches 6. Source Tree Layout 7. Make Rules 8. Adding New Functions (API changes) (TODO) 8. Precision (TODO) 9. Testing (make check) (TODO) 10. Contribution Checklist (TODO) 11. Coding Style (TODO) 12. DFP ABI (TODO) 13. Division of Responsibility With GCC (TODO) A. History B. Acknowledgements --------------------------------------------------------------------------- 1. Introduction The "Decimal Floating Point C Library" is an implementation of ISO/IEC Technical report "ISO/IEC TR 24732" which describes the C-Language library routines necessary to provide the C library runtime support for decimal floating point data types introduced in IEEE 754-2008, namely _Decimal32, _Decimal64, and _Decimal128. --------------------------------------------------------------------------- 1.1. ISO/IEC TR 24732 The latest description of ISO/IEC TR 24732 at the time of this writing can be found here: http://www.open-std.org/JTC1/SC22/wg14/www/docs/n1312.pdf A rationale can be found here: http://www.open-std.org/JTC1/SC22/wg14/www/docs/n1242.pdf And the last draft for new standard can be found at: http://www.open-std.org/JTC1/SC22/wg14/www/docs/n1775.pdf --------------------------------------------------------------------------- 1.2. IEEE754-2008 (DPD & BID Encodings) IEEE 754-2008 defines two different encodings for the decimal floating point data types. These are DPD and BID. DPD (Densely Packed Decimal) - IBM sponsored encoding (implemented in hardware). BID (Binary Integer Decimal) - Intel sponsored encoding. A simple explanation of the general overview of Decimal Floaing Point can be found at http://speleotrove.com/decimal/decbits.pdf The BID format encoding general explanation can be found at BID - Binary-Integer Decimal Encoding for Decimal Floating Point | Ping Tak Peter Tang http://m1.archiveorange.com/m/att/KGyKy/ArchiveOrange_Ps0PWkD0ZgCLBVQYnJEcnXblPpEa.pdf Both encodings can be investigated in the draft IEEE754r: http://754r.ucbtest.org/drafts/archive/2006-10-04.pdf --------------------------------------------------------------------------- 1.3. Backends (libdecnumber & libbid) Libdfp use of "libdecnumber" backend library for software emulation. Libdecnumber was written by Mike Cowlishaw (IBM) and a form of the library was donated to the FSF where it was subsumed into GCC. The Free Software Foundation assigned GCC as the owner of libdecnumber and now any project that needs to include libdecnumber statically needs to pull it from the GCC source trees. All patches to libdecnumber should be sent to GCC. This library's copy of libdecnumber should be periodically synced with upstream GCC's version. This syncing is the responsibility of the Libdfp maintainer. --------------------------------------------------------------------------- 2. Availability Libdfp attempts to provide an encoding agnostic API to users based upon the _Decimal32, _Decimal64, and _Decimal128 data-types. Libdfp is available to be configured in the following combinations: Arch HW|SW Backend Encoding ------------------------------------------------- ppc970 SW libdecnumber DPD POWER4 SW libdecnumber DPD POWER SW libdecnumber DPD POWER6 HW libdecnumber DPD POWER7 HW libdecnumber DPD S/390 z9-109 SW libdecnumber DPD S/390 z9-ec HW libdecnumber DPD S/390 z10 HW libdecnumber DPD TODO: ------------------------------------------------- x86 SW libdecnumber DPD | BID x86_64 SW libdecnumber DPD | BID The selection of a backend and/or an encoding is made at configuration time by the distro maintainer or person building libdfp using configuration flags described in the section entitled "Configuration". A summary with information regarding "libdecnumber" and Decimal Floating Point in general can be found at: http://speleotrove.com/decimal/ --------------------------------------------------------------------------- 3. Compliance With ISO/IEC TR 24732 This section covers issues related to compliance with ISO/IEC TR 24732. --------------------------------------------------------------------------- 3.1 __STDC_WANT_DEC_FP__ The standard ISO/IEC TR 24732 indicates that programs that wish to use Decimal Floating Point should define the following macro: __STDC_WANT_DEC_FP__ There is no set value for this macro. Simply passing -D__STDC_WANT_DEC_FP__ on compilation, or defining it in your program should suffice: #define __STDC_WANT_DEC_FP__ This macro is REQUIRED when including dfp/math.h dfp/fenv.h, etc to pick up the DFP function prototypes and data types defined in these headers. --------------------------------------------------------------------------- 3.2 scanf Libdfp does not, and will not comply with the TR 24732 requirement for the addition of scanf in support of decimal floating point data types. The strtod[32|64|128] functions can be used for the same purpose without the implications of scanf. This is main due the fact GLIBC does not support scanf hooks as it does for printf. --------------------------------------------------------------------------- 3.3 printf Libdfp supports the addition of the printf format codes indicated by TR 24732. GLIBC proper owns the printf implementation. Libdfp utilizes the printf-hooks mechanism provided by GLIBC to register support of the DFP format codes. The fully functional printf-hooks mechanism was debuted in GLIBC 2.10. --------------------------------------------------------------------------- 4. Dependencies --------------------------------------------------------------------------- 4.1 GNU/Linux OS Libdfp is only enabled to work on the GNU/Linux OS. --------------------------------------------------------------------------- 4.2 GLIBC Minimum Version Libdfp version 1.0.0 relies upon a minimum GLIBC 2.10 for printf-hooks support. The libdfp configure stage will check the libc that it is linked against for the printf-hook support and will warn if it is not found. --------------------------------------------------------------------------- 4.4 libdecnumber The libdecnumber library has it's own configure and Makefile fragments. This is so that it can be built from within any source tree simply by passing the necessary configure flags. In reality it's a bit more complicated. The libdecnumber library requires the --enable-decimal-float flag when being configured. This pushes this requirement upon the top level Libdfp 'configure'. Sadly this is necessary because Autoconf doesn't allow passing flags to AC_CONFIG_SUBDIRS. It only passes the --with and --enable flags of the parent configure fragment to the child, therefore the parent needs to have all the flags used by the child. We used the --enable-decimal-float flag to indicate which encoding to use, DPD or BID. The following are valid: --enable-decimal-float=dpd --enable-decimal-float=bid --enable-decimal-float=yes {uses the host default encoding} Specifying --enable-decimal-float=no simply defaults to the host default encoding as well. Some of the files in the Libdfp top directory are symlinked to the actual files in the ./scripts directory. This is because libdecnumber lives in the GCC source tree and GCC doesn't use AC_CONFIG_AUX_DIR([scripts]) but Libdfp DOES. This is required so that libdecnumber/configure.ac -> configure works properly. --------------------------------------------------------------------------- 4.5 GCC With --enable-decimal-float Support There's a dependency on a version of GCC which supports Decimal Floating Point. Use the following to determine if your compiler supports it: gcc -v 2>&1 | grep "\-\-enable\-decimal\-float" If decimal floating point support is not available in your compiler the libdfp configure stage will fail with a warning. Between GCC 4.3 and GCC 4.5 the compiler exported constant __DEC32_DENORMAL_MIN__ was changed to __DEC32_SUBNORMAL_MIN__. Libdfp now uses __DEC32_SUBNORMAL_MIN__. If you see errors like the following then you need to upgrade your compiler: error: '__DEC32_SUBNORMAL_MIN__' undeclared (first use in this function) --------------------------------------------------------------------------- 4.6 Autoconf & GNU Make This Library uses Autoconf to generate GNU Makefiles from Makefile.in templates and NOT Automake because Automake is incapable of selecting .S or .c source files from an override directory. Automake is poorly suited for system libraries which require flexibility based on assembler code overrides and submachine architecture overrides. Automake demands that the target file list be statically defined. If you need to re-run autoreconf -i you need to use Autoconf version 2.59 because libdecnumber explicitly requires it. Here's a hint on how to use a particular autoconf version: PATH=/usr/local/autoconf-2.59/bin/:$PATH autoreconf -i This of course requires that you've installed Autoconf version 2.59 with --prefix=/usr/local/autoconf-2.59/ Some of the Makefile machinery was inspired by the GLIBC Makefiles, beautifully written by Roland McGrath since this library was originally a GLIBC add-on. --------------------------------------------------------------------------- 5. Configuration Standalone libdfp requires that your build directory be separate from the source directory. Invoke the source directory's 'configure' script from within the build directory, e.g. /home/$USER/stage_libdfp/build/$ ../libdfp/configure --------------------------------------------------------------------------- 5.1 Configure Switches Environment Variables PATH Set the PATH environment variable. If this is specified and paths to CC, CXX, OBJDUMP, LDD, and GDB aren't defined, libdfp configure will search in $PATH for these binaries. CC [OPTIONAL: Picked up from $PATH if not specified.] Specify the C compiler to use to build libdfp and test cases. CXX [OPTIONAL: Picked up from $PATH if not specified.] Specify the C++ compiler to use for the Libdfp C++ compatibility tests cases. CFLAGS="-m64 -O2 -g" Since the default bitness of the compiler's generated binaries varies between Linux distros, and on some architectures the Kernel has a different bitness than the default user env it is recommended that the -m[31|32|64] flags be passed. These should accompany sympathetic --build switch described below, e.g. powerpc-linux-gnu for -m32 powerpc64-linux-gnu for -m64 For System Z (s390), depending on the cpu, Libdfp's configure.ac will append a -mzarch flag onto CFLAGS automatically. This is a special flag required to enable hardware DFP on some System Z cpus. ASFLAGS Libdfp's Makefile.in will pull -g or -m[31|32|64] into ASFLAGS if it is specified in CFLAGS. If you need anything else, pass it in here and it'll be added. CXXFLAGS [Only needed for the C++ compatibility test suite.] This should generally match the CFLAGS (for the most part). CPPFLAGS Use this to pass specific flags to the C Preprocessor. OBJDUMP [OPTIONAL: Picked up from $PATH if not specified.] Specify the objdump binary to use to generate the debug scripts. LDD [OPTIONAL: Picked up from $PATH if not specified.] Specify the ldd to use to generate the debug scripts. GDB [OPTIONAL: Picked up from $PATH if not specified.] Specify the gdb to use to debug the test cases. Libdfp's default configure will be based on whatever bitness the user environment is. In order to build 32-bit libdfp you can pass the following switch: --build=powerpc-linux-gnu In order to build 64-bit libdfp you can pass the following switch: --build=powerpc64-linux-gnu The following switches define the DFP backend. --with-backend={libdecnumber|libbid} [OPTIONAL] Defaults to host default. Libbid is not valid on PowerPC or s390 hardware. --enable-decimal-float={yes|dpd|bid} [REQUIRED if --with-backend=libdecnumber] If --with-backend=libbid then anything other than 'bid' or 'yes' is invalid. 'bid' is not valid on PowerPC or s390 hardware. Valid Combinations: --with-backend=libdecnumber --enable-decimal-float=dpd --with-backend=libdecnumber --enable-decimal-float=bid --with-backend=libbid --enable-decimal-float=bid --prefix=/opt/foo [OPTIONAL] Override the default system prefix, e.g. if you want to install into /opt/ for some reason specify: --prefix=/opt/libdfp/. --libdir=/usr/lib64 [REQUIRED if you want to install 64-bit libs into lib64/] [OPTIONAL] Override the default '/lib' library path on installation. If you've already used --prefix=/opt/foo and you need t install a 64-bit libdfp into lib64/ then you need: --prefix=/opt/foo --libdir=/opt/foo/lib64/ In otherwords, libdir REPLACES the path "/lib" on installation it doesn't concatenate onto "" --with-glibc-headers=/home/$USER/stage_libdfp/glibc-2.10-headers [REQUIRED if your toolchain has GLIBC version less than 2.10] --with-glibc-build=/home/$USER/stage_glibc/build/glibc64_power6/ [OPTIONAL] If you want to run make check but your system GLIBC isn't version 2.10 you need to pass the location of a temporary GLIBC build-dir (not install dir) where that GLIBC meets or exceeds version 2.10. Not passing this switch tells the make check system to simply use the system GLIBC. WARNING: Make sure you link to a GLIBC build that supports the same configure options as how you're configuring libdfp, e.g. if you're configuring for 'power6' 64-bit, make sure that the GLIBC build you link against is a 64-bit. It doesn't have to be tuned for power6 but it should be able to execute properly. --with-cpu={power5|power6|power7|} [OPTIONAL] Use this if you want the compiler to optimize the generated code for a particular processor. This also causes the libdfp build infrastructure to choose architecture specific overrides from the sysdeps tree. Here are some easy-case configurations of libdfp using PATH: PATH=/opt/at4.0/bin:$PATH \ CXXFLAGS="-m32 -O2 -g" CFLAGS="-m32 -O2 -g" \ ../libdfp-decimal/configure --with-backend=libdecnumber \ --enable-decimal-float=dpd --build=powerpc-linux-gnu \ --with-cpu=power6 2>&1 | tee _configure32_power6 PATH=/opt/at4.0/bin:$PATH \ CXXFLAGS="-m64 -O2 -g" CFLAGS="-m64 -O2 -g" \ ../libdfp-decimal/configure --with-backend=libdecnumber \ --enable-decimal-float=dpd --build=powerpc64-linux-gnu \ --with-cpu=power6 2>&1 | tee _configure64_power6 Here are some more complicated configurations of libdfp linking an alternate GLIBC: 64-bit PowerPC (soft-dfp) using the libdecnumber backend and dpd encoding: CC=/opt/at4.0/bin/gcc CFLAGS="-m64 -O2 -g" \ CXX=/opt/at4.0/bin/gcc CXXFLAGS="-m64 -O2 -g" \ ~/eglibc/eglibc/libdfp/trunk/configure \ --with-backend=libdecnumber --enable-decimal-float=dpd \ --libdir=/usr/lib64/ \ --with-glibc-headers=~/ppc64-tc-utils/trunk/libdfp/include-2.10/ \ --build=powerpc64-linux-gnu \ --with-glibc-build=~/glibc-2.11/build/glibc64_power5 \ 2>&1 | tee _configure64_power5 64-bit PowerPC POWER6 (hard-dfp) using libdecnumber backend and dpd encoding: We only need the --with-cpu=power6 flag for power6 support and hardware-dfp: CC=/opt/at4.0/bin/gcc CFLAGS="-m64 -O2 -g" \ CXX=/opt/at4.0/bin/gcc CXXFLAGS="-m64 -O2 -g" \ ~/eglibc/eglibc/libdfp/trunk/configure \ --with-backend=libdecnumber --enable-decimal-float=dpd \ --libdir=/usr/lib64/ \ --with-glibc-headers=~/ppc64-tc-utils/trunk/libdfp/include-2.10/ \ --build=powerpc64-linux-gnu \ --with-glibc-build=~/glibc-2.11/build/glibc64_power6 \ --with-cpu=power6 2>&1 | tee _configure64_power6 64-bit PowerPC POWER7 (hard-dfp) using libdecnumber backend and dpd encoding: We only need the --with-cpu=power7 flag for power7 support and hardware-dfp: CC=/opt/at4.0/bin/gcc CFLAGS="-m64 -O2 -g" \ CXX=/opt/at4.0/bin/gcc CXXFLAGS="-m64 -O2 -g" \ ~/eglibc/eglibc/libdfp/trunk/configure \ --with-backend=libdecnumber --enable-decimal-float=dpd \ --libdir=/usr/lib64/ \ --with-glibc-headers=~/ppc64-tc-utils/trunk/libdfp/include-2.10/ \ --build=powerpc64-linux-gnu \ --with-glibc-build=~/glibc-2.11/build/glibc64_power7 \ --with-cpu=power7 2>&1 | tee _configure64_power7 32-bit PowerPC (soft-dfp) using the libdecnumber backend and dpd encoding: CC=/opt/at4.0/bin/gcc CFLAGS="-m32 -O2 -g" \ CXX=/opt/at4.0/bin/gcc CXXFLAGS="-m32 -O2 -g" \ ~/eglibc/eglibc/libdfp/trunk/configure \ --with-backend=libdecnumber --enable-decimal-float=dpd \ --with-glibc-headers=~/ppc64-tc-utils/trunk/libdfp/include-2.10/ \ --build=powerpc-linux-gnu \ --with-glibc-build=~/glibc-2.11/build/glibc32_power5 \ 2>&1 | tee _configure32_power5 Or 32-bit POWER6 (hard-dfp): CC=/opt/at4.0/bin/gcc CFLAGS="-m32 -O2 -g" \ CXX=/opt/at4.0/bin/gcc CXXFLAGS="-m32 -O2 -g" \ ~/eglibc/eglibc/libdfp/trunk/configure \ --with-backend=libdecnumber --enable-decimal-float=dpd \ --with-glibc-headers=~/ppc64-tc-utils/trunk/libdfp/include-2.10/ \ --build=powerpc-linux-gnu \ --with-glibc-build=~/glibc-2.11/build/glibc32_power6 \ --with-cpu=power6 2>&1 | tee _configure32_power6 Or 32-bit POWER7 (hard-dfp): CC=/opt/at4.0/bin/gcc CFLAGS="-m32 -O2 -g" \ CXX=/opt/at4.0/bin/gcc CXXFLAGS="-m32 -O2 -g" \ ~/eglibc/eglibc/libdfp/trunk/configure \ --with-backend=libdecnumber --enable-decimal-float=dpd \ --with-glibc-headers=~/ppc64-tc-utils/trunk/libdfp/include-2.10/ \ --build=powerpc-linux-gnu \ --with-glibc-build=~/glibc-2.11/build/glibc32_power7 \ --with-cpu=power7 2>&1 | tee _configure32_power7 --------------------------------------------------------------------------- 6. Source Tree Layout The Libdfp configure script is responsible for building the search order that is used by the Make system for selecting files out of the source tree. The configure script automatically knows how to search for base_machine (e.g. powerpc) machine (e.g. powerpc32) submachine (e.g. power6, power7) It also recognizes the following special directories when they show up following any of the previous *machine directories: fpu nofpu dfpu bits It hard-searches for the following sysdep directories based upon configuration settings: bid dpd soft-dfp And it knows how to find the common files stored in the convenience directories: ieee754r base-math The top of the search list is the commond libdfp internal header files: ${srcdir}/include. Anything in these directories should be ABSOLUTELY COMMON since you can't get a header earlier than in the ${srcdir}/include directory. If you need to override something in ${srcdir}/include then you may need to move the headers out of this directory and into the sysdeps tree. Header files that are used when building libdfp, but also provided by libdfp and installed in the prefix directory are in the following directory: ${srcdir}/dfp The sysdeps tree is searched and relevant directory depth takes precedence. ${srcdir}/include [internal libdfp headers] ${srcdir}/libdecnumber/dpd [libdecnumber headers] ${srcdir}/libdecnumber/bid [libdecnumber headers] ${srcdir}/libbid/? [libbid headers] [MACHINE/SUBMACHINE] ${srcdir}/sysdeps/powerpc/powerpc64/power7/fpu [platform directories] ${srcdir}/sysdeps/powerpc/powerpc64/power7/ ${srcdir}/sysdeps/powerpc/powerpc64/power6/fpu [platform directories] ${srcdir}/sysdeps/powerpc/powerpc64/power6/ ${srcdir}/sysdeps/powerpc/powerpc64/ ${srcdir}/sysdeps/powerpc/powerpc32/power6/fpu [platform directories] ${srcdir}/sysdeps/powerpc/powerpc32/power6/ ${srcdir}/sysdeps/powerpc/powerpc32/ [BASE_MACHINE/[FPU|NOFPU|BITS]] ${srcdir}/sysdeps/powerpc/fpu ${srcdir}/sysdeps/powerpc/fpu/bits ${srcdir}/sysdeps/powerpc/nofpu ${srcdir}/sysdeps/powerpc/nofpu/bits [BASE_MACHINE] ${srcdir}/sysdeps/powerpc/ ${srcdir}/sysdeps/i386/ [ENCODING] ${srcdir}/sysdeps/dpd [dpd specific implementations] ${srcdir}/sysdeps/bid [bid specific implementations] [SOFT-DFP ENCODING OVERRIDES[DPD|BID]] ${srcdir}/sysdeps/soft-dfp/dpd [soft-dfp dpd arithmetic, conversion, and comparison fns] ${srcdir}/sysdeps/soft-dfp/bid [soft-dfp bid arithmetic, conversion, and comparison fns] ${srcdir}/sysdeps/soft-dfp [soft-dfp arithmetic, conversion, and comparison fns] ${srcdir}/dfp [headers files that will be installed. These follow the sysdep overrides so that sysdeps override directories show up before the install headers in #include_next
. ${srcdir}/ieee754r [ISO C Draft TR functions] ${srcdir}/base-math [Arithmetic, Conversion, and Comparison Routines.] ${srcdir}/[common libdfp framework code & common headers for the backends.] Out of Tree Sources ${srcdir}/libdecnumber [third-party GCC sources] ${srcdir}/libbid [third-party libBID sources] --------------------------------------------------------------------------- 7. Make Rules make [all (default)] DEPENDENCIES: GLIBC headers: The location of the companion GLIBC 2.10 (or greater) headers as passed to configure using the --with-glibc-headers switch. make check DEPENDENCIES: GLIBC build: The location of a companion GLIBC 2.10 (or greater) build (prior to make install) that is to be linked against during the make check run. This is required because the printf-hooks feature that is necessary for printing _Decimal[32|64|128] numbers is only in GLIBC 2.10 and later. This isn't necessary if the system GLIBC is version 2.10 or later. The path to the build was passed to configure using the --with-glibc-build switch. make install [install_root=] [install_root] (Optional) : Install to /$prefix. This is used by libdfp developers and distro builders so that they can build libdfp and install it to an alternate location in preparation for packaging. make install-headers [install_root=] [install_root] (Optional) : Install libdfp headers into /$prefix/include/dfp. This is used by application or library developers whose projects depend on libdfp who don't want to install libdfp proper or may not have permission to do so. make clean [TODO] make distclean --------------------------------------------------------------------------- 8. Adding New Functions (API changes) (TODO) Libdfp versioning uses the following convention: major.minor.revision New functions must ALWAYS be added to the next revision number of the library. For instance, if the maintainer has designated the current release at 1.0.8 new function should be added to 1.0.9. Then, when the maintainer increments the library to 1.0.9 the new functions will become available. --------------------------------------------------------------------------- Appendices --------------------------------------------------------------------------- A. History Libdfp was designed by Ryan S. Arnold (IBM), Janis Johnson (IBM), and Steven J. Munroe (IBM) in 2006. Libdfp was originally written as a GLIBC add-on by Ryan S. Arnold and Joseph Kerian in 2006 and contributed to the Free Software Foundation by IBM in 2007. Janis Johnson provided the initial versions of the arithmetic, conversion, and comparison routines. The libdecnumber library was originaly contributed to GCC by IBM and written by Mike Cowlishaw. Its inclusion into GCC was negotiated in 2005/2006 and it was pulled into Libdfp as a utility library shortly thereafter. GLIBC proper declined to include Libdfp upstream on the grounds that ratification of the DFP technical report had not taken place so... Libdfp was ported to EGLIBC by Pete Eberlein in 2007. System 390 support was added by Andreas Krebbel starting in 2008. Ryan S. Arnold (with the help of Andreas Krebbel) ported Libdfp into a stand-alone library in 2009. --------------------------------------------------------------------------- B. Acknowledgements Thanks to Ulrich Drepper and the GLIBC folks since we used much of the GLIBC macro black magic, math routines, string-to-float conversions, and printf_fp code as a basis for the corresponding decimal floating point forms. Thanks to Roland McGrath for his wild Makefile foo in GLIBC. Ryan used a lot of that as inspiration for Libdfp's Makefiles. Thanks to everyone at IBM (past and present) who worked on Libdfp. Thanks to Jeff Bailey for helping Ryan grok Autoconf and GNU Make. His examples on SUFFIXES rules were invaluable in getting the stand-alone Libdfp make files into a functional form. Thanks to EGLIBC (eglibc.org) for hosting Libdfp when it was a GLIBC add-on and for hosting the stand alone version as well. Thanks to Michael Matz (SuSE) for help getting the initial packaging for Libdfp straightened out. libdfp-1.0.12/README.maintainer000066400000000000000000000036521261375163000160530ustar00rootroot00000000000000=========================================================================== Libdfp The "Decimal Floating Point C Library" Maintainer's Guide for the GNU/Linux OS and GLIBC 2.10+ Contributed by IBM Corporation Copyright (C) 2011-2014 Free Software Foundation =========================================================================== NOTE:Eight space tabs are the optimum editor setting for reading this file. =========================================================================== Author(s) : Ryan S. Arnold Date Created: February 9, 2011 --------------------------------------------------------------------------- Table of Contents: 1. Introduction 2. Libdfp API Changes 3. Libdfp ABI Changes 4. Versioning 5. Contributing --------------------------------------------------------------------------- 2. Libdfp API Changes When new functions or interfaces are added to Libdfp then the API has changed and the library version must change. For guidelines on adding new symbols to a particular version see README.developer. --------------------------------------------------------------------------- 3. Libdfp API Changes TODO --------------------------------------------------------------------------- 4. Versioning TODO --------------------------------------------------------------------------- 5. Contributing Libdfp is developed now using GIT SCM at github. Main site is: https://github.com/libdfp/libdfp General developement follows the simple guideline: 1. Make sure you have a GitHub account 2. Fork the repository to your account. 3. Make the changes and run the testcases. We only take pull requests with passing tests. 4. If it is applicable, improve or add the current testcases to cover for the new functionality. 5. Libdfp also uses the ChangeLog with the same format and rules as the GLIBC one. 6. Push to your fork and submit a pull request. libdfp-1.0.12/README.user000066400000000000000000000575661261375163000147170ustar00rootroot00000000000000=========================================================================== Libdfp The "Decimal Floating Point C Library" User's Guide for the GNU/Linux OS and GLIBC 2.10+ Contributed by IBM Corporation Copyright (C) 2010 - 2014 Free Software Foundation =========================================================================== NOTE:Eight space tabs are the optimum editor setting for reading this file. =========================================================================== Author(s) : Ryan S. Arnold Date Created: January 27, 2010 Last Changed: August 8, 2012 --------------------------------------------------------------------------- Table of Contents: 1. Introduction 1.1. ISO/IEC TR 24732 1.2. ISO/IEC DTR 24733 1.3. IEEE 754-2008 (DPD & BID Encodings) 1.4. Backends (libdecnumber & libbid) 2. Availability 3. Compliance With ISO/IEC TR 24732 3.1 __STDC_DEC_FP__ 3.2 __STDC_WANT_DEC_FP__ 3.3 GNU99 Compatibility 3.4 _Decimal[32|64|128] Data Types 3.4.1 _Decimal[32|64|128] Encoding 3.5 scanf Support 3.6 printf Support 3.5.1 printf "a,A" Conversion Specifier 4. Compliance With ISO/IEC DTR 24733 4.1 C++ decimal[32|64|128] Types Compatibility 4.2 C++ decimal[32|64|128] operator<< and operator>> Support 4.3 Printing decimal[32|64|128] Types and Precision 5. Dependencies 5.1 GNU/Linux OS 5.2 GLIBC Minimum Version 5.3 GCC With --enable-decimal-float Support 6. DFP Headers 7. Compile and Link 8. Unsupported/Non-Standard Additions 9. Known Limitations --------------------------------------------------------------------------- 1. Introduction The "Decimal Floating Point C Library" is an implementation of ISO/IEC Technical report "ISO/IEC TR 24732" which describes the C-Language library routines necessary to provide the C library runtime support for decimal floating point data types introduced in IEEE 754-2008, namely _Decimal32, _Decimal64, and _Decimal128. --------------------------------------------------------------------------- 1.1. ISO/IEC TR 24732 The decimal floating point extension to the C programming language is described in the ratified ISO/IEC Technical Report 24732. The latest description of ISO/IEC TR 24732 at the time of this writing can be found here: http://www.open-std.org/JTC1/SC22/wg14/www/docs/n1312.pdf A rationale can be found here: http://www.open-std.org/JTC1/SC22/wg14/www/docs/n1242.pdf And the last draft for new standard can be found at: http://www.open-std.org/JTC1/SC22/wg14/www/docs/n1775.pdf --------------------------------------------------------------------------- 1.2. ISO/IEC DTR 24733 The decimal floating point extension to the C++ programming language is described in ISO/IEC DRAFT Technical Report 24733. The latest description of ISO/IEC DTR 24733 at the time of this writing can be found here: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2849.pdf --------------------------------------------------------------------------- 1.3. IEEE754-2008 (DPD & BID Encodings) IEEE 754-2008 defines two different encodings for the decimal floating point data types. These are DPD and BID. DPD (Densely Packed Decimal) - IBM sponsored encoding (implemented in hardware). BID (Binary Integer Decimal) - Intel sponsored encoding. A simple explanation of the general overview of Decimal Floaing Point can be found at http://speleotrove.com/decimal/decbits.pdf The BID format encoding general explanation can be found at BID - Binary-Integer Decimal Encoding for Decimal Floating Point | Ping Tak Peter Tang http://m1.archiveorange.com/m/att/KGyKy/ArchiveOrange_Ps0PWkD0ZgCLBVQYnJEcnXblPpEa.pdf Both encodings can be investigated in the draft IEEE754r: http://754r.ucbtest.org/drafts/archive/2006-10-04.pdf --------------------------------------------------------------------------- 1.4. Backends (libdecnumber & libbid) Libdfp use of "libdecnumber" backend library for software emulation. And for the most part, a user of libdfp should not have to be concerned with the libdfp backend. The user's interface is that defined by ISO/IEC TR 24732, i.e. the Decimal Floating Point addition to the C Language specification. --------------------------------------------------------------------------- 2. Availability Libdfp attempts to provide an encoding agnostic API to users based upon the _Decimal32, _Decimal64, and _Decimal128 data-types and the proposed C-Language extension for Decimal Floating Point Types. --------------------------------------------------------------------------- 3. Compliance With ISO/IEC TR 24732 This section covers issues related to compliance with ISO/IEC TR 24732, the ratified ISO C DFP Technical Report. --------------------------------------------------------------------------- 3.1 __STDC_DEC_FP__ The draft standard ISO/IEC TR 24732 specifies the macro __STDC_DEC_FP__ as integer constant 200805L to indicate conformance to the technical report. This macro describes properties of the compiler and library that together satisfy the technical report. The intention is that user applications may check for conformance with the following: #ifdef __STDC_DEC_FP__ /* Select implementation conforming to the TR. */ #else /* Select non-conforming DFP emulation library. */ #endif Since __STDC_DEC_FP__ is a property fulfilled by both the compiler and library the compiler can't predefine this macro without know if the user is using libdfp. There is currently no mechanism for the compiler to determine this early in the translation unit. This will eventually be provided, once a mechanism is added into GLIBC and GCC for identifying stdc predefines as highlighted in this email: http://sourceware.org/ml/libc-alpha/2009-04/msg00005.html At that point libdfp will provide __STDC_DEC_FP__ for GLIBC versions greater than FOO and GCC versions greater than BAR. --------------------------------------------------------------------------- 3.2 __STDC_WANT_DEC_FP__ The standard ISO/IEC TR 24732 indicates that programs that wish to use Decimal Floating Point should define the following macro: __STDC_WANT_DEC_FP__ There is no set value for this macro. Simply passing -D__STDC_WANT_DEC_FP__ on compilation, or defining it in your program should suffice: #define __STDC_WANT_DEC_FP__ This macro is REQUIRED when including dfp/math.h dfp/fenv.h, etc to pick up the DFP function prototypes and data types defined in these headers. --------------------------------------------------------------------------- 3.3 GNU99 Compatibility GNU99 compatibility is required to pick up some DFP prototypes that are similar to the binary floating point prototypes guarded in by __USE_ISOC99 and others. It will define __USE_ISOC99. Use the following compilation flag: -std=gnu99 NOTE: -std=gnu99 IS NOT THE SAME AS __USE_ISOC99 though -std=gnu99 DOES DEFINE __USE_ISOC99! Additionally, simply using -std=c99 isn't enough! NOTE: If you forget to use -std=gnu99 you may notice that you will get very screwy results when you call dfp math functions. If the compiler can't find the prototypes (due to missing defines) it will attempt to create a default prototype which will have an incorrect return type. Compile with -Wall to pick up undefined prototype warnings. --------------------------------------------------------------------------- 3.4 _Decimal* Data Types The Decimal Floating Point data types are as follows: _Decimal32 _Decimal64 _Decimal128 The floating point suffix for DFP constants follows: 'DF' for _Decimal32, e.g. _Decimal32 d32 = 1.045DF; 'DD' for _Decimal64, e.g. _Decimal64 d64 = 1.4738273DD; 'DL' for _Decimal128, e.g. _Decimal128 d128 = 1.0823382394823945DL; NOTE: Assigning a naked constant to a DFP variable will actually be performing a binary to decimal conversion and, depending on the precision, can assign an incorrect number. Always use the decimal floating point suffix, e.g., _Decimal64 d64 = 1.0DD; The following will result in a binary float to decimal float conversion: _Decimal64 d64 = 1.0; --------------------------------------------------------------------------- 3.4.1 _Decimal[32|64|128] Encoding Consider the following _Decimal64 values and encodings (displayed in declet triples): /* Encoded as "+1,000,000,000,000,000e+285" */ _Decimal64 d64 = 1.000000000000000e300DD; /* Encoded as "+0,000,000,000,000,001e+300" */ _Decimal64 e64 = 1e300DD; These values are equivalent in comparison but there is inherently more precision in the first value and this should be preserved when the value is printed. As described in section 3.6.1, the a/A conversion specifier is used to direct printf to use the precision encoded in the actual value for the output string precision. --------------------------------------------------------------------------- 3.5 scanf Support Libdfp does not, and will not comply with the TR 24732 requirement for the addition of scanf in support of decimal floating point data types. The strtod[32|64|128] functions can be used for the same purpose without the implications of scanf. This is main due the fact GLIBC does not support scanf hooks as it does for printf. --------------------------------------------------------------------------- 3.6 printf Support Libdfp supports the addition of the printf format codes indicated by TR 24732. GLIBC proper owns the printf implementation. Libdfp utilizes the printf-hooks mechanism provided by GLIBC to register support of the DFP format codes. The fully functional printf-hooks mechanism was debuted in GLIBC 2.10. Libdfp has a library constructor which registers the Libdfp printf handlers with the libc. If the version of GLIBC that is loaded when your application is executed is too old (pre-2.10) and doesn't have the printf-hooks interface you will get an undefined reference error against GLIBC. When libdfp is loaded printf will recognize the following length modifiers: %H - for _Decimal32 %D - for _Decimal64 %DD - for _Decimal128 It will recognize the following conversion specifier 'spec' characters: e,E f,F g,G a,A (as debuted in ISO/IEC TR 24732) Therefore, any combination of DFP length modifiers and spec characters is supported. 3.6.1 printf "a,A" Conversion Specifier --------------------------------------------------------------------------- The ISO-C DFP specification adds "a/A" as a printf conversion specifier. This conversion specifier is unique in that when it is used the precision of the output string includes as many of the significant digits in the mantissa in the as possible unless there are fewer digits in the mantissa than in the specified precision. Following are some examples to demonstrate the use of the a/A conversion specifier. printf("Result: %.1HaDF\n", 6543.00DF); Result: 7E+3DF printf("Result: %.5HaDF\n", 6543.00DF); Result: 6543.0DF printf("Result: %.4HaDF\n", 6543.00DF); Result: 6543DF /* Example where the implicit number of digits is less than the * explicit precision. */ printf("Result: %.8HaDF\n", 6543.00DF); Result: 6543.00DF If your compiler is being pedantic you may get the following warning (due to -Wformat) when using the a/A conversion specifier with the H/D/DD length modifiers. warning: use of ‘H’ length modifier with ‘A’ type character [-Wformat] This is not a real problem. It simply hints at the issue described in section 3.1. When the compiler and library are able to define __STDC_DEC_FP__ then the compiler can detect that libdfp is available and that a/A conv specifier is a valid combination with the H/D?DD length modifiers. --------------------------------------------------------------------------- 4. Compliance With ISO/IEC DTR 24733 This section covers issues related to compliance with ISO/IEC DTR 24733, the ISO C++ DFP Draft Technical Report. 4.1 C++ decimal[32|64|128] Types Compatibility --------------------------------------------------------------------------- Your C++ compiler may not yet provide the ISO C DFP _Decimal[32|64|128] types. Per the C++ DFP specification: ISO/IEC JTC1 SC22 WG21 N2732 "Extension for the programming language C++ to support decimal floating point arithmetic", the header float.h shall include the following C-compatibility convenience typedefs: typedef std::decimal::decimal32 _Decimal32; typedef std::decimal::decimal64 _Decimal64; typedef std::decimal::decimal128 _Decimal128; This allows C++ programs, which use the native decimal32, decimal64, and decimal128 types to use the _Decimal32, _Decimal64, and_Decimal128 types. Your compiler may or may not yet have this defined in float.h. As a matter of convenience, libdfp has provided these headers in the libdfp headers directory include/dfp/float.h 4.2 C++ decimal[32|64|128] operator<< and operator>> Support --------------------------------------------------------------------------- Your C++ compiler may not provide operator<< and operator>> support for std::decimal::decimal[32|64|128] data types. Per the C++ DFP specification: ISO/IEC JTC1 SC22 WG21 N2732 "Extension for the programming language C++ to support decimal floating point arithmetic", the header shall provide the following operator overloads. namespace std { namespace decimal { template std::basic_istream & operator>>(std::basic_istream & is, decimal32 & d); template std::basic_istream & operator>>(std::basic_istream & is, decimal64 & d); template std::basic_istream & operator>>(std::basic_istream & is, decimal128 & d); template std::basic_ostream & operator<<(std::basic_ostream & os, decimal32 d); template std::basic_ostream & operator<<(std::basic_ostream & os, decimal64 d); template std::basic_ostream & operator<<(std::basic_ostream & os, decimal128 d); }} Per http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51486, since C++ decimal support is defined in a technical report and not ratified into the actual C++ standard the header shouldn't be located in the default headers include directory. As a result the header is located in the include/decimal directory. Therefore, in order to include the decimal header implicitly use the following in applications: #include 4.3 Printing decimal[32|64|128] Types and Precision --------------------------------------------------------------------------- Libdfp provides two mechanisms for printing decimal floating-point data types in string representation. These are via the C++ ostream operator "<<" for decimal[32|64|128] data types and the ISO C printf interface (described in section 3.6) for _Decimal[32|64|128] data types. The ISO C DFP Technical Report provides well described extensions to the printf interface for decimal floating-point types. Unfortunately, the DFP C++ Draft Technical Report simply describes the ostream operator that needs to be provided for string formatting but does not fully describe the procedure for printing full precision decimal types considering the fully encoded precision in decimal types. Please refer to section 3.4.1 for a discussion of the encoding. The base C++ specification describes ostream operator support for floating-point types as equivalent to corresponding ISO C printf conversion specifiers (as described in the following table): C++ ios_base::fmtflags | ISO C printf equivalent conv spec -----------------------------|----------------------------------------- | g ios::fixed | f ios::scientific | e ios::fixed | ios::scientific | a ios::upper | G/F/E/A ios::lower | g/f/e/a Since the DFP C++ Draft Technical Report makes no explicit provisions for format codes specific to decimal floating-point types the Libdfp implementation falls back on the equivalency to printf conversion specifiers described in this table. Under binary floating-point the a/A spec is used to print hexadecimal representation of floating point values, which is why no precision is allowed to convert (truncate and round) the output string representation. The C++ specification indicates that a/A is specified by passing ios::fixed | ios::scientific in the ios_base::fmtflags for the stream. When this combination of flags is specified the precision set in the ostream (whether the default or user specified) is not honored or used in the printing of the type. As described in section 3.5.1, the overridden a/A conversion specifier is the most desireable conversion specifier used with printf for decimal floating-point types since it preserves the encoded precision in the output string representation by default (when no explicit precision is specified). Since there is no interface specified in the DFP C or C++ specifications for querying the number of significant digits in a decimal floating-point value the user should most often use the a/A conversion specifier in order to preserve significant digits. The caveat, of course, is that since the C++ specification does not provide a way to programmatically determine whether the queried stream precision is the default of '6', or a value set by the user, nor does the C++ specification allow stream precision to be considered when printing the a/A style conversion, this ostream operator implementation can not pass the stream precision on to the printf function. Therefore, all use of (ios::fixed | ios::scientific) will result in full precision output and it will not honor the output precision specified in the stream. --------------------------------------------------------------------------- 5. Dependencies --------------------------------------------------------------------------- 5.1 GNU/Linux OS Libdfp is only enabled to work on the GNU/Linux OS. --------------------------------------------------------------------------- 5.2 GLIBC Minimum Version Libdfp version 1.0.0 relies upon a minimum GLIBC 2.10 for printf-hooks support. The libdfp configure stage will check the libc that it is linked against for the printf-hook support and will warn if it is not found. --------------------------------------------------------------------------- 5.3 GCC With --enable-decimal-float Support There's a dependency on a version of GCC which supports Decimal Floating Point. Use the following to determine if your compiler supports it: gcc -v 2>&1 | grep "\-\-enable\-decimal\-float" If decimal floating point support is not available in your compiler the libdfp configure stage will fail with a warning. --------------------------------------------------------------------------- 6. DFP Headers The following Libdfp headers extend the existing system headers. If the path to the Libdfp headers is included in the search path then these will be picked up prior to the system headers. dfp/fenv.h dfp/math.h dfp/stdlib.h dfp/wchar.h dfp/float.h dfp/decimal/decimal Each of these headers uses the GCC construct #include_next in order to pick up the system header as well, e.g., dfp/math.h will #include_next dfp/decimal/decimal will #include_next This mechanism allows Libdfp to add the Decimal interfaces required by the specification to the aforementioned headers. In order to pick up the Libdfp prototypes and classification macro overrides compile with the following: -I/pathto/include/dfp/ -D__STDC_WANT_DEC_FP__=1 Using -I instead of -isystem is suggested because -I indicates that the specified headers are picked up BEFORE the system headers, which is what we want. Then in the application source simply using the following include will pick up both /pathto/include/dfp/.h and /usr/include/.h: #include #include #include #include /* And for C++ programs */ #include #include Due to the use of #include_next in the DFP headers (in order to wrap the default system headers with DFP prototypes) the methodology of including "dfp/" in the include path, and then excluding -I/pathto/include/dfp/ is NOT supported. DO NOT DO THE FOLLOWING: #include #include #include #include #include #include --------------------------------------------------------------------------- 7. Compile and Link A compilation and link for a DFP program will look like the following: $(CC) -Wall test_dfp.c -o test_dfp -D__STDC_WANT_DEC_FP__ \ -std=gnu99 -ldfp --------------------------------------------------------------------------- 8. Unsupported/Non-Standard Additions Libdfp provides a non-standard method for output of the decoded Densely Packed Decimal representation using the decoded[32|64|128]() functions. The output format is: [sign][MSD],[decoded-declet-1], ...,[decoded-declet-n][E][+|-][decoded exponent] Examples: +0,000,000E+0 = decoded32(0DF) +0,000,000,000,001,000E-1 = decoded64(100.0DD) -0,000,000,000,000,000,000,000,000,039,654,003E-3 = decoded128(-39654.003DL) +9,876,543E+22 = decoded32(9.876543E+28DF) WARNING: Do NOT rely on these methods for user space code. They're only provided for toolchain development debug support. A header file providing the prototype for these functions is not provided by the Advance Toolchain to discourage you from using them. If you MUST use them define the following prototypes in your program: /* char * should ref a 14 byte char array, * +0,000,000E+0\0 */ extern char * decoded32 (_Decimal32, char*); /* char * should ref a 26 byte char array, * +0,000,000,000,000,000E+0\0 */ extern char * decoded64 (_Decimal64, char*); /* char * should ref a 50 byte char array, * +0,000,000,000,000,000,000,000,000,000,000,000E+0\0 */ extern char * decoded128 (_Decimal128, char*); --------------------------------------------------------------------------- 9. Known Limitations IEEE754r currently has an addendum awaiting vote whereby the default quantum for conversions involving zero will go to a zero exponent (e.g. 0 equals 0.0). The current IEEE754r specification dictates that the quantum shall go to the largest supported by the data type, e.g. _Decimal32 0.0E191; _Decimal64 0.0E767, _Decimal128 0.0E12287. Observation of the advance toolchain results will show that we don't follow any particular convention. This may change in the future. For the following examples notice the DPD encoding on both power6[x] and non-power6: _Decimal32 d32 = 0.0DF; _Decimal64 d64 = 0.0DD; _Decimal128 d128 = 0.0DL; (_Decimal128)0.0DF: [+0,000,000E+0] (_Decimal128)0.0DD: [+0,000,000,000,000,000E+0] (_Decimal128)0.0DL: [+0,000,000,000,000,000,000,000,000,000,000,000E+0] On power6[x] notice the representation of zero after an [int|long|long long] conversion to _Decimal[32|64|128] respectively: (_Decimal32)0DF = (int)0: [+0,000,000E+0] (_Decimal32)0.0DF = (float)0.000000: [+0,000,000E+0] (_Decimal64)0DD = (long)0: [+0,000,000,000,000,000E+0] (_Decimal64)0.0DD = (double)0.000000: [+0,000,000,000,000,000E+0] (_Decimal128)0DL = (long long)0: [+0,000,000,000,000,000,000,000,000,000,000,000E+0] (_Decimal128)0.0DL = (long double)0.000000: [+0,000,000,000,000,000,000,000,000,000,000,000E+0] Notice the difference with soft-dfp: (_Decimal32)0.0DF = (int)0: [+0,000,000E-1] (_Decimal32)0.0DF = (float)0.000000: [+0,000,000E+0] (_Decimal64)0.0DD = (long)0: [+0,000,000,000,000,000E-1] (_Decimal64)0.0DD = (double)0.000000: [+0,000,000,000,000,000E+0] (_Decimal128)0.0DL = (long long)0: [+0,000,000,000,000,000,000,000,000,000,000,000E-1] (_Decimal128)0.0DL = (long double)0.000000: [+0,000,000,000,000,000,000,000,000,000,000,000E+0] Namely the negative sign of the exponent with soft-dfp for int to _Decimal conversions. libdfp-1.0.12/TODO000066400000000000000000000031061261375163000135270ustar00rootroot00000000000000Add tests/test-getexp to determine whether the hardware dfp version stores the proper sign of the exponent with the stfiwx call. Make get_digits calls use getexp_d* rather than computing the exponent directly. Upgrade libdecnumber version. Upgrade autoconf version Add @docdir@ to Makefile (supported in autoconf 2.6.0). test make install headers with dfp/decimal/ headers. Add testcase to verify soft-dfp TLS version of rounding mode functions. Add printf_dfp test which change the rounding mode. Add --with-cross feature to prevent the make check suite from being executed on the build machine. Add --export-test feature to export the test-suite into stand-alone static test cases. Finish make check test suite. Clear up symbols and hidden symbol usage and export and make sure we aren't using the PLT from within libdfp. Optimize the math routines for hardware dfp support. Implement dpd backend for x86 and x86_64. Prototype versioned symbols support. Implement libbid backend for x86_64. Write Man Page Write User's guide in docbook format, .i.e. info file. [DONE] Configure runtime test for decimal floating point support in compiler. [DONE] Configure test for glibc 2.10 headers. [DONE] Configure runtime test for glibc 2.10 based on register_printf_type() function.. [DONE] Write User's guide [DONE] If system glibc is 2.10 then make check shouldn't need all the GLIBC build scaffolding for executing and debugging tests. [DONE] Clear up make clean [DONE] Work on make distclean. [DONE] Clear up dependency issue so that libdfp.so.1 is rebuilt when a .c file changes. libdfp-1.0.12/Versions000066400000000000000000000012251261375163000145720ustar00rootroot00000000000000libdfp { LIBDFP_1.0.0 { decoded32; decoded64; decoded128; # These are the old callbacks. They don't work anymore. # fmt_d32; # fmt_d64; # fmt_d128; fe_dec_getround; fe_dec_setround; register_printf_dfp; printf_dfp; strtod32; strtod64; strtod128; wcstod32; wcstod64; wcstod128; } LIBDFP_PRIVATE { __decoded32; __decoded64; __decoded128; __fmt_d32; __fmt_d64; __fmt_d128; __host_to_ieee_32; __ieee_32_to_host; __host_to_ieee_64; __ieee_64_to_host; __host_to_ieee_128; __ieee_128_to_host; __fe_dec_getround; __fe_dec_setround; } } libdfp-1.0.12/Versions.def000066400000000000000000000002631261375163000153300ustar00rootroot00000000000000libdfp { LIBDFP_1.0.0 LIBDFP_1.0.2 LIBDFP_1.0.3 LIBDFP_1.0.4 LIBDFP_1.0.5 LIBDFP_1.0.6 LIBDFP_1.0.7 LIBDFP_1.0.8 LIBDFP_1.0.9 LIBDFP_1.0.10 LIBDFP_PRIVATE } libdfp-1.0.12/base-math/000077500000000000000000000000001261375163000147005ustar00rootroot00000000000000libdfp-1.0.12/base-math/Makefile000066400000000000000000000033271261375163000163450ustar00rootroot00000000000000# Copyright (C) 2015 Free Software Foundation, Inc. # # This file is part of the Decimal Floating Point C Library. # # The Decimal Floating Point C Library is free software; you can # redistribute it and/or modify it under the terms of the GNU Lesser # General Public License version 2.1. # # The Decimal Floating Point C Library is distributed in the hope that # it will be useful, but WITHOUT ANY WARRANTY; without even the implied # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See # the GNU Lesser General Public License version 2.1 for more details. # # You should have received a copy of the GNU Lesser General Public # License version 2.1 along with the Decimal Floating Point C Library; # if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA. # # Please see libdfp/COPYING.txt for more information. */ libdfp_files += addsd3 adddd3 addtd3 \ divsd3 divdd3 divtd3 \ eqsd2 eqdd2 eqtd2 \ extendsddd2 extendsdtd2 extendddtd2 \ extendsfsd extendsddf extendsdtf \ extendsfdd extenddfdd extendddtf \ extendsftd extenddftd extendtftd \ fixsdsi fixddsi fixtdsi \ fixsddi fixdddi fixtddi \ fixunssdsi fixunsddsi fixunstdsi \ fixunssddi fixunsdddi fixunstddi \ floatsisd floatsidd floatsitd \ floatdisd floatdidd floatditd \ floatunssisd floatunssidd floatunssitd \ floatunsdisd floatunsdidd floatunsditd \ gesd2 gedd2 getd2 \ gtsd2 gtdd2 gttd2 \ lesd2 ledd2 letd2 \ ltsd2 ltdd2 lttd2 \ mulsd3 muldd3 multd3 \ nesd2 nedd2 netd2 \ subsd3 subdd3 subtd3 \ truncddsd2 trunctddd2 trunctdsd2 \ truncsdsf truncdfsd trunctfsd \ truncddsf truncdddf trunctfdd \ trunctdsf trunctddf trunctdtf \ unordsd2 unorddd2 unordtd2 \ classify libdfp-1.0.12/base-math/README000066400000000000000000000004411261375163000155570ustar00rootroot00000000000000These functions match what is implemented as part of libgcc for DFP. They are intended to be compiled with DFP hardware support in order to override the software DFP libgcc.a symbols. This set doesn't provide overrides for binary->decimal and decimal->binary trunc and extend functions. libdfp-1.0.12/base-math/Versions000066400000000000000000000003431261375163000164330ustar00rootroot00000000000000# Since the symbols in base-math are prefixed with either __dpd_ or __bid_ the # Versions files in sysdeps/dpd/ and sysdeps/bid are used for the functions # defined in this directory. So don't define any symbols in this file. libdfp-1.0.12/base-math/adddd3.c000066400000000000000000000021651261375163000161730ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal64 __BACKEND_(adddd3) (_Decimal64 x, _Decimal64 y) { return x + y; } libdfp-1.0.12/base-math/addsd3.c000066400000000000000000000022151261375163000162060ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal32 __BACKEND_(addsd3) (_Decimal32 x, _Decimal32 y) { return (_Decimal32)((_Decimal64)x + (_Decimal64)y); } libdfp-1.0.12/base-math/addtd3.c000066400000000000000000000021701261375163000162070ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal128 __BACKEND_(addtd3) (_Decimal128 x, _Decimal128 y) { return x + y; } libdfp-1.0.12/base-math/classify.c000066400000000000000000000033111261375163000166570ustar00rootroot00000000000000/* Classification functions for binary floating point types Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include "convert.h" extern int __dfp_classify_sf (float a); int __dfp_classify_sf (float a) { uint32_t wx; if (a == 0.0f) return FP_ZERO; GET_FLOAT_WORD (wx, a); wx = wx & 0x7fffffff; if (wx >= 0x7f800000) return (wx > 0x7f800000) ? FP_NAN : FP_INFINITE; return FP_NORMAL; } extern int __dfp_classify_df (double a); int __dfp_classify_df (double a) { uint64_t wx; if (a == 0.0) return FP_ZERO; EXTRACT_WORDS64 (wx, a); wx = wx & UINT64_C(0x7fffffffffffffff); if (wx >= UINT64_C(0x7FF0000000000000)) return (wx > UINT64_C(0x7FF0000000000000)) ? FP_NAN : FP_INFINITE; return FP_NORMAL; } libdfp-1.0.12/base-math/divdd3.c000066400000000000000000000021651261375163000162250ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal64 __BACKEND_(divdd3) (_Decimal64 x, _Decimal64 y) { return x / y; } libdfp-1.0.12/base-math/divsd3.c000066400000000000000000000022151261375163000162400ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal32 __BACKEND_(divsd3) (_Decimal32 x, _Decimal32 y) { return (_Decimal32)((_Decimal64)x / (_Decimal64)y); } libdfp-1.0.12/base-math/divtd3.c000066400000000000000000000021701261375163000162410ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal128 __BACKEND_(divtd3) (_Decimal128 x, _Decimal128 y) { return x / y; } libdfp-1.0.12/base-math/eqdd2.c000066400000000000000000000021661261375163000160500ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(eqdd2) (_Decimal64 x, _Decimal64 y) { return x == y ? 0 : 1; } libdfp-1.0.12/base-math/eqsd2.c000066400000000000000000000022001261375163000160540ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(eqsd2) (_Decimal32 x, _Decimal32 y) { return (_Decimal64)x == (_Decimal64)y ? 0 : 1; } libdfp-1.0.12/base-math/eqtd2.c000066400000000000000000000021701261375163000160630ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(eqtd2) (_Decimal128 x, _Decimal128 y) { return x == y ? 0 : 1; } libdfp-1.0.12/base-math/extendddtd2.c000066400000000000000000000021661261375163000172620ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal128 __BACKEND_(extendddtd2) (_Decimal64 x) { return (_Decimal128)x; } libdfp-1.0.12/base-math/extendddtf.c000066400000000000000000000033311261375163000171750ustar00rootroot00000000000000/* Handle conversion from Decimal64 to binary long double (128) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef DECIMAL_TO_BINARY #define DECIMAL_TO_BINARY #define SRC 64 #define DEST 128 #define NAME extend #endif #include "dfpacc.h" #include "convert.h" CONVERT_WRAPPER( // extendddtf, trunctdtf volatile double df_part1, df_part2; SRC_TYPE dd_part1, dd_part2; df_part1 = a; /* TD -> DF */ dd_part1 = df_part1; /* DF -> DD./TD. */ dd_part2 = a - dd_part1; /* DD./TD. */ df_part2 = dd_part2; /* DD/TD -> DF. */ result = df_part1; result += df_part2; /* Clear inexact exception raised by DFP arithmetic. */ if (DFP_EXCEPTIONS_ENABLED && DFP_TEST_EXCEPTIONS (FE_OVERFLOW|FE_UNDERFLOW) == 0) DFP_CLEAR_EXCEPTIONS (FE_INEXACT); ) hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/base-math/extenddfdd.c000066400000000000000000000040111261375163000171510ustar00rootroot00000000000000/* Handle conversion from binary double (64) to Decimal64 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define BINARY_TO_DECIMAL #define SRC 64 #define DEST 64 #define NAME extend #include "dfpacc.h" #include "convert.h" #include /* To pick up __DBL_MANT_DIG__ */ CONVERT_WRAPPER( // truncdfsd, extenddfdd, extenddftd _Decimal128 temp; /* Needs to be big enough so that temp = mant doesn't round. */ double a_norm; long long mant; int exp, sexp; a_norm = FREXPDF (a, &exp); mant = a_norm * 9007199254740992.0; /* 53 bits of mantissa. */ //sexp = exp - 53; /* Exponent adjusted for mantissa. */ sexp = exp - __DBL_MANT_DIG__; /* Exponent adjusted for mantissa. */ temp = mant; /* DI -> TD. */ if (sexp > 0) temp *= DECPOWOF2[sexp]; else if (sexp < 0) temp /= DECPOWOF2[-sexp]; result = (DEST_TYPE)temp; /* Cast to the resultant type. */ /* Clear inexact exception raised by DFP arithmetic. */ if (DFP_EXCEPTIONS_ENABLED && DFP_TEST_EXCEPTIONS (FE_OVERFLOW|FE_UNDERFLOW) == 0) DFP_CLEAR_EXCEPTIONS (FE_INEXACT); ) hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/base-math/extenddftd.c000066400000000000000000000040121261375163000171720ustar00rootroot00000000000000/* Handle conversion from binary double (64) to Decimal128 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define BINARY_TO_DECIMAL #define SRC 64 #define DEST 128 #define NAME extend #include "dfpacc.h" #include "convert.h" #include /* To pick up __DBL_MANT_DIG__ */ CONVERT_WRAPPER( // truncdfsd, extenddfdd, extenddftd _Decimal128 temp; /* Needs to be big enough so that temp = mant doesn't round. */ double a_norm; long long mant; int exp, sexp; a_norm = FREXPDF (a, &exp); mant = a_norm * 9007199254740992.0; /* 53 bits of mantissa. */ //sexp = exp - 53; /* Exponent adjusted for mantissa. */ sexp = exp - __DBL_MANT_DIG__; /* Exponent adjusted for mantissa. */ temp = mant; /* DI -> TD. */ if (sexp > 0) temp *= DECPOWOF2[sexp]; else if (sexp < 0) temp /= DECPOWOF2[-sexp]; result = (DEST_TYPE)temp; /* Cast to the resultant type. */ /* Clear inexact exception raised by DFP arithmetic. */ if (DFP_EXCEPTIONS_ENABLED && DFP_TEST_EXCEPTIONS (FE_OVERFLOW|FE_UNDERFLOW) == 0) DFP_CLEAR_EXCEPTIONS (FE_INEXACT); ) hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/base-math/extendsddd2.c000066400000000000000000000021461261375163000172570ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal64 __BACKEND_(extendsddd2) (_Decimal32 x) { return (_Decimal64)x; } libdfp-1.0.12/base-math/extendsddf.c000066400000000000000000000030671261375163000172020ustar00rootroot00000000000000/* Handle conversion from Decimal32 to binary double (64) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_BINARY #define SRC 32 #define DEST 64 #define NAME extend #include "dfpacc.h" #include "convert.h" CONVERT_WRAPPER( // truncsdsf, extendsddf double temp; SRC_TYPE a_norm; long long mant; int exp, sexp; a_norm = FREXPD32 (a, &exp); mant = a_norm * 1E+7DF; /* 7 digits of mantissa. */ sexp = exp - 7; /* Exponent adjusted for mantissa. */ temp = mant; if (sexp > 0) temp *= BINPOWOF10[sexp]; else if (sexp < 0) temp /= BINPOWOF10[-sexp]; result = temp; ) hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/base-math/extendsdtd2.c000066400000000000000000000021501261375163000172720ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal128 __BACKEND_(extendsdtd2) (_Decimal32 x) { return (_Decimal128)x; } libdfp-1.0.12/base-math/extendsdtf.c000066400000000000000000000030141261375163000172120ustar00rootroot00000000000000/* Handle conversion from Decimal32 to binary long double (128) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef DECIMAL_TO_BINARY #define DECIMAL_TO_BINARY #define SRC 32 #define DEST 128 #define NAME extend #endif #include "dfpacc.h" #include "convert.h" CONVERT_WRAPPER( volatile double df_part1, df_part2; _Decimal32 sd_part1, sd_part2; df_part1 = a; /* TD -> DF */ sd_part1 = df_part1; /* DF -> SD (not exact) */ sd_part2 = a - sd_part1; /* SD */ df_part2 = sd_part2; /* SD -> DF (trunc) */ result = df_part1; result += df_part2; ) hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/base-math/extendsfdd.c000066400000000000000000000022071261375163000171750ustar00rootroot00000000000000/* Handle conversion from binary float (32) to Decimal64 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define BINARY_TO_DECIMAL #define SRC 32 #define DEST 64 #define NAME extend #include "extendsfsd.c" libdfp-1.0.12/base-math/extendsfsd.c000066400000000000000000000037571261375163000172270ustar00rootroot00000000000000/* Handle conversion from binary float (32) to Decimal32 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef BINARY_TO_DECIMAL #define BINARY_TO_DECIMAL #define SRC 32 #define DEST 32 #define NAME extend #endif #include "dfpacc.h" #include "convert.h" #include /* To pick up __FLT_MANT_DIG__ */ #if DEST==32 #define TEMP_TYPE _Decimal64 #else #define TEMP_TYPE _Decimal128 #endif CONVERT_WRAPPER( // extendsfsd, extendsfdd, extendsftd TEMP_TYPE temp; float a_norm; long long mant; int exp, sexp; a_norm = FREXPSF (a, &exp); mant = a_norm * 16777216.0; /* 24 bits of mantissa. */ //sexp = exp - 24; /* Exponent adjusted for mantissa. */ sexp = exp - __FLT_MANT_DIG__; /* Exponent adjusted for mantissa. */ temp = mant; if (sexp > 0) result = temp * DECPOWOF2[sexp]; else if (sexp < 0) result = temp / DECPOWOF2[-sexp]; /* Clear inexact exception raised by DFP arithmetic. */ if (DFP_EXCEPTIONS_ENABLED && DFP_TEST_EXCEPTIONS (FE_OVERFLOW|FE_UNDERFLOW) == 0) DFP_CLEAR_EXCEPTIONS (FE_INEXACT); ) hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/base-math/extendsftd.c000066400000000000000000000022111261375163000172100ustar00rootroot00000000000000/* Handle conversion from binary float (32) to Decimal128 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define BINARY_TO_DECIMAL #define SRC 32 #define DEST 128 #define NAME extend #include "extendsfsd.c" libdfp-1.0.12/base-math/extendtftd.c000066400000000000000000000022271261375163000172200ustar00rootroot00000000000000/* Handle conversion from binary long double (dual 64bit) to Decimal128 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define BINARY_TO_DECIMAL #define SRC 128 #define DEST 128 #define NAME extend #include "trunctfsd.c" libdfp-1.0.12/base-math/fixdddi.c000066400000000000000000000021561261375163000164630ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include long long __BACKEND_(fixdddi) (_Decimal64 x) { return (long long)x; } libdfp-1.0.12/base-math/fixddsi.c000066400000000000000000000021421261375163000164750ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(fixddsi) (_Decimal64 x) { return (int)x; } libdfp-1.0.12/base-math/fixsddi.c000066400000000000000000000021561261375163000165020ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include long long __BACKEND_(fixsddi) (_Decimal32 x) { return (long long)((_Decimal64)x); } libdfp-1.0.12/base-math/fixsdsi.c000066400000000000000000000021421261375163000165140ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(fixsdsi) (_Decimal32 x) { return (int)((_Decimal64)x); } libdfp-1.0.12/base-math/fixtddi.c000066400000000000000000000021571261375163000165040ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include long long __BACKEND_(fixtddi) (_Decimal128 x) { return (long long)x; } libdfp-1.0.12/base-math/fixtdsi.c000066400000000000000000000021431261375163000165160ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(fixtdsi) (_Decimal128 x) { return (int)x; } libdfp-1.0.12/base-math/fixunsdddi.c000066400000000000000000000022031261375163000172020ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include unsigned long long __BACKEND_(fixunsdddi) (_Decimal64 x) { return (unsigned long long)x; } libdfp-1.0.12/base-math/fixunsddsi.c000066400000000000000000000021671261375163000172320ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include unsigned int __BACKEND_(fixunsddsi) (_Decimal64 x) { return (unsigned int)x; } libdfp-1.0.12/base-math/fixunssddi.c000066400000000000000000000022031261375163000172210ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include unsigned long long __BACKEND_(fixunssddi) (_Decimal32 x) { return (unsigned long long)((_Decimal64)x); } libdfp-1.0.12/base-math/fixunssdsi.c000066400000000000000000000021671261375163000172510ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include unsigned int __BACKEND_(fixunssdsi) (_Decimal32 x) { return (unsigned int)((_Decimal64)x); } libdfp-1.0.12/base-math/fixunstddi.c000066400000000000000000000022041261375163000172230ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include unsigned long long __BACKEND_(fixunstddi) (_Decimal128 x) { return (unsigned long long)x; } libdfp-1.0.12/base-math/fixunstdsi.c000066400000000000000000000021701261375163000172440ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include unsigned int __BACKEND_(fixunstdsi) (_Decimal128 x) { return (unsigned int)x; } libdfp-1.0.12/base-math/floatdidd.c000066400000000000000000000021611261375163000167760ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal64 __BACKEND_(floatdidd) (long long x) { return (_Decimal64)x; } libdfp-1.0.12/base-math/floatdisd.c000066400000000000000000000021431261375163000170150ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal32 __BACKEND_(floatdisd) (long long x) { return (_Decimal32)x; } libdfp-1.0.12/base-math/floatditd.c000066400000000000000000000021631261375163000170200ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal128 __BACKEND_(floatditd) (long long x) { return (_Decimal128)x; } libdfp-1.0.12/base-math/floatsidd.c000066400000000000000000000021531261375163000170160ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal64 __BACKEND_(floatsidd) (int x) { return (_Decimal64)x; } libdfp-1.0.12/base-math/floatsisd.c000066400000000000000000000021351261375163000170350ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal32 __BACKEND_(floatsisd) (int x) { return (_Decimal32)x; } libdfp-1.0.12/base-math/floatsitd.c000066400000000000000000000021551261375163000170400ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal128 __BACKEND_(floatsitd) (int x) { return (_Decimal128)x; } libdfp-1.0.12/base-math/floatunsdidd.c000066400000000000000000000021751261375163000175310ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal64 __BACKEND_(floatunsdidd) (unsigned long long x) { return (_Decimal64)x; } libdfp-1.0.12/base-math/floatunsdisd.c000066400000000000000000000021571261375163000175500ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal32 __BACKEND_(floatunsdisd) (unsigned long long x) { return (_Decimal32)x; } libdfp-1.0.12/base-math/floatunsditd.c000066400000000000000000000021771261375163000175530ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal128 __BACKEND_(floatunsditd) (unsigned long long x) { return (_Decimal128)x; } libdfp-1.0.12/base-math/floatunssidd.c000066400000000000000000000021671261375163000175510ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal64 __BACKEND_(floatunssidd) (unsigned int x) { return (_Decimal64)x; } libdfp-1.0.12/base-math/floatunssisd.c000066400000000000000000000021511261375163000175610ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal32 __BACKEND_(floatunssisd) (unsigned int x) { return (_Decimal32)x; } libdfp-1.0.12/base-math/floatunssitd.c000066400000000000000000000021711261375163000175640ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal128 __BACKEND_(floatunssitd) (unsigned int x) { return (_Decimal128)x; } libdfp-1.0.12/base-math/gedd2.c000066400000000000000000000021671261375163000160370ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(gedd2) (_Decimal64 x, _Decimal64 y) { return x >= y ? 1 : -1; } libdfp-1.0.12/base-math/gesd2.c000066400000000000000000000022011261375163000160430ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(gesd2) (_Decimal32 x, _Decimal32 y) { return (_Decimal64)x >= (_Decimal64)y ? 1 : -1; } libdfp-1.0.12/base-math/getd2.c000066400000000000000000000021711261375163000160520ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(getd2) (_Decimal128 x, _Decimal128 y) { return x >= y ? 1 : -1; } libdfp-1.0.12/base-math/gtdd2.c000066400000000000000000000021651261375163000160540ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(gtdd2) (_Decimal64 x, _Decimal64 y) { return x > y ? 1: -1; } libdfp-1.0.12/base-math/gtsd2.c000066400000000000000000000021771261375163000160760ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(gtsd2) (_Decimal32 x, _Decimal32 y) { return (_Decimal64)x > (_Decimal64)y ? 1: -1; } libdfp-1.0.12/base-math/gttd2.c000066400000000000000000000021701261375163000160700ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(gttd2) (_Decimal128 x, _Decimal128 y) { return x > y ? 1 : -1; } libdfp-1.0.12/base-math/ledd2.c000066400000000000000000000021661261375163000160430ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(ledd2) (_Decimal64 x, _Decimal64 y) { return x <= y ? 0 : 1; } libdfp-1.0.12/base-math/lesd2.c000066400000000000000000000022001261375163000160470ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(lesd2) (_Decimal32 x, _Decimal32 y) { return (_Decimal64)x <= (_Decimal64)y ? 0 : 1; } libdfp-1.0.12/base-math/letd2.c000066400000000000000000000021701261375163000160560ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(letd2) (_Decimal128 x, _Decimal128 y) { return x <= y ? 0 : 1; } libdfp-1.0.12/base-math/ltdd2.c000066400000000000000000000021661261375163000160620ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(ltdd2) (_Decimal64 x, _Decimal64 y) { return x < y ? -1 : 1; } libdfp-1.0.12/base-math/ltsd2.c000066400000000000000000000022001261375163000160660ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(ltsd2) (_Decimal32 x, _Decimal32 y) { return (_Decimal64)x < (_Decimal64)y ? -1 : 1; } libdfp-1.0.12/base-math/lttd2.c000066400000000000000000000021701261375163000160750ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(lttd2) (_Decimal128 x, _Decimal128 y) { return x < y ? -1 : 1; } libdfp-1.0.12/base-math/muldd3.c000066400000000000000000000021651261375163000162400ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal64 __BACKEND_(muldd3) (_Decimal64 x, _Decimal64 y) { return x * y; } libdfp-1.0.12/base-math/mulsd3.c000066400000000000000000000022151261375163000162530ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal32 __BACKEND_(mulsd3) (_Decimal32 x, _Decimal32 y) { return (_Decimal32)((_Decimal64)x * (_Decimal64)y); } libdfp-1.0.12/base-math/multd3.c000066400000000000000000000021701261375163000162540ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal128 __BACKEND_(multd3) (_Decimal128 x, _Decimal128 y) { return x * y; } libdfp-1.0.12/base-math/nedd2.c000066400000000000000000000021561261375163000160440ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(nedd2) (_Decimal64 x, _Decimal64 y) { return x != y; } libdfp-1.0.12/base-math/nesd2.c000066400000000000000000000021701261375163000160570ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(nesd2) (_Decimal32 x, _Decimal32 y) { return (_Decimal64)x != (_Decimal64)y; } libdfp-1.0.12/base-math/netd2.c000066400000000000000000000021601261375163000160570ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __BACKEND_(netd2) (_Decimal128 x, _Decimal128 y) { return x != y; } libdfp-1.0.12/base-math/subdd3.c000066400000000000000000000021651261375163000162340ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal64 __BACKEND_(subdd3) (_Decimal64 x, _Decimal64 y) { return x - y; } libdfp-1.0.12/base-math/subsd3.c000066400000000000000000000022151261375163000162470ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal32 __BACKEND_(subsd3) (_Decimal32 x, _Decimal32 y) { return (_Decimal32)((_Decimal64)x - (_Decimal64)y); } libdfp-1.0.12/base-math/subtd3.c000066400000000000000000000021701261375163000162500ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal128 __BACKEND_(subtd3) (_Decimal128 x, _Decimal128 y) { return x - y; } libdfp-1.0.12/base-math/truncdddf.c000066400000000000000000000051301261375163000170200ustar00rootroot00000000000000/* Handle conversion from Decimal64 to binary double (64) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_BINARY #define SRC 64 #define DEST 64 #define NAME trunc #include "dfpacc.h" #include "convert.h" CONVERT_WRAPPER( // truncdddf long double temp; SRC_TYPE a_norm; long long mant; int exp, sexp; a_norm = FREXPD64 (a, &exp); /* Avoid going beyond the bounds of the table, which would also mean an overflow or underflow. */ /* The +1 is necessary because of the one digit after the decimal point. */ if (exp > BINPOWOF10_LIMIT + 1) /* Obvious overflow. */ { if (DFP_EXCEPTIONS_ENABLED) DFP_HANDLE_EXCEPTIONS (FE_OVERFLOW|FE_INEXACT); return SIGNBIT(a) ? -INFINITY : INFINITY; } else if (exp < -BINPOWOF10_LIMIT) /* Obvious underflow. */ { if (DFP_EXCEPTIONS_ENABLED) DFP_HANDLE_EXCEPTIONS (FE_UNDERFLOW|FE_INEXACT); return SIGNBIT(a) ? -0.0 : 0.0; } mant = a_norm * 1.E+16DD; /* 16 digits of mantissa. */ sexp = exp - 16; /* Exponent adjusted for mantissa. */ temp = mant; /* mantissa as TF */ if (sexp > 0) result = temp * BINPOWOF10[sexp]; else if (sexp < 0) { /* Avoid going beyond the bounds of the exponent table for negative exponents. */ if (sexp < -BINPOWOF10_LIMIT) { temp /= BINPOWOF10[BINPOWOF10_LIMIT]; sexp += BINPOWOF10_LIMIT; } result = temp / BINPOWOF10[-sexp]; } else result = temp; /* Clear inexact exception raised by DFP arithmetic. */ if (DFP_EXCEPTIONS_ENABLED && DFP_TEST_EXCEPTIONS (FE_OVERFLOW|FE_UNDERFLOW) == 0) DFP_CLEAR_EXCEPTIONS (FE_INEXACT); ) hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/base-math/truncddsd2.c000066400000000000000000000021451261375163000171220ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal32 __BACKEND_(truncddsd2) (_Decimal64 x) { return (_Decimal32)x; } libdfp-1.0.12/base-math/truncddsf.c000066400000000000000000000040261261375163000170420ustar00rootroot00000000000000/* Handle conversion from Decimal64 to binary float (32) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_BINARY #define SRC 64 #define DEST 32 #define NAME trunc #include "dfpacc.h" #include "convert.h" CONVERT_WRAPPER( // truncddsf double temp; _Decimal64 a_norm; long long mant; int exp, sexp; a_norm = FREXPD64 (a, &exp); /* Check for values that would overflow the exponent table, which would be obvious overflow and underflow. */ if (exp > 39) /* Obvious overflow. */ { if (DFP_EXCEPTIONS_ENABLED) DFP_HANDLE_EXCEPTIONS (FE_OVERFLOW|FE_INEXACT); return SIGNBIT(a) ? -INFINITY : INFINITY; } else if (exp < -39) /* Obvious underflow. */ { if (DFP_EXCEPTIONS_ENABLED) DFP_HANDLE_EXCEPTIONS (FE_UNDERFLOW|FE_INEXACT); return SIGNBIT(a) ? -0.0 : 0.0; } mant = a_norm * 1.E+16DD; /* 16 digits of mantissa. */ sexp = exp - 16; /* Exponent adjusted for mantissa. */ temp = mant; if (sexp > 0) temp *= BINPOWOF10[sexp]; else if (sexp < 0) temp /= BINPOWOF10[-sexp]; result = temp; ) hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/base-math/truncdfsd.c000066400000000000000000000040501261375163000170370ustar00rootroot00000000000000/* Handle conversion from binary double (64) to Decimal32 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef BINARY_TO_DECIMAL #define BINARY_TO_DECIMAL #define SRC 64 #define DEST 32 #define NAME trunc #endif #include "dfpacc.h" #include "convert.h" #include /* To pick up __DBL_MANT_DIG__ */ CONVERT_WRAPPER( // truncdfsd, extenddfdd, extenddftd _Decimal128 temp; /* Needs to be big enough so that temp = mant doesn't round. */ double a_norm; long long mant; int exp, sexp; a_norm = FREXPDF (a, &exp); mant = a_norm * 9007199254740992.0; /* 53 bits of mantissa. */ //sexp = exp - 53; /* Exponent adjusted for mantissa. */ sexp = exp - __DBL_MANT_DIG__; /* Exponent adjusted for mantissa. */ temp = mant; /* DI -> TD. */ if (sexp > 0) temp *= DECPOWOF2[sexp]; else if (sexp < 0) temp /= DECPOWOF2[-sexp]; result = (DEST_TYPE)temp; /* Cast to the resultant type. */ /* Clear inexact exception raised by DFP arithmetic. */ if (DFP_EXCEPTIONS_ENABLED && DFP_TEST_EXCEPTIONS (FE_OVERFLOW|FE_UNDERFLOW) == 0) DFP_CLEAR_EXCEPTIONS (FE_INEXACT); ) hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/base-math/truncsdsf.c000066400000000000000000000031261261375163000170610ustar00rootroot00000000000000/* Handle conversion from Decimal32 to binary float (32) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef DECIMAL_TO_BINARY #define DECIMAL_TO_BINARY #define SRC 32 #define DEST 32 #define NAME trunc #endif #include "dfpacc.h" #include "convert.h" CONVERT_WRAPPER( // truncsdsf, extendsddf double temp; SRC_TYPE a_norm; long long mant; int exp, sexp; a_norm = FREXPD32 (a, &exp); mant = a_norm * 1E+7DF; /* 7 digits of mantissa. */ sexp = exp - 7; /* Exponent adjusted for mantissa. */ temp = mant; if (sexp > 0) temp *= BINPOWOF10[sexp]; else if (sexp < 0) temp /= BINPOWOF10[-sexp]; result = temp; ) hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/base-math/trunctddd2.c000066400000000000000000000021641261375163000171240ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal64 __BACKEND_(trunctddd2) (_Decimal128 x) { return (_Decimal64)x; } libdfp-1.0.12/base-math/trunctddf.c000066400000000000000000000047421261375163000170500ustar00rootroot00000000000000/* Handle conversion from Decimal128 to binary double (64) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_BINARY #define SRC 128 #define DEST 64 #define NAME trunc #include "dfpacc.h" #include "convert.h" CONVERT_WRAPPER( // trunctddf long double temp; /* Need at least 16 decimal digits of accuracy. */ SRC_TYPE a_norm; long long mant; int exp, sexp; a_norm = FREXPD128 (a, &exp); /* Avoid going beyond the bounds of the exponent table. */ if (exp > BINPOWOF10_LIMIT) /* Obvious overflow. */ { if (DFP_EXCEPTIONS_ENABLED) DFP_HANDLE_EXCEPTIONS (FE_OVERFLOW|FE_INEXACT); return SIGNBIT(a) ? -INFINITY : INFINITY; } else if (exp < -BINPOWOF10_LIMIT) /* Obvious underflow. */ { if (DFP_EXCEPTIONS_ENABLED) DFP_HANDLE_EXCEPTIONS (FE_UNDERFLOW|FE_INEXACT); return SIGNBIT(a) ? -0.0 : 0.0; } mant = a_norm * 1.E+17DL; /* 17 digits of mantissa. */ sexp = exp - 17; /* Exponent adjusted for mantissa. */ temp = mant; if (sexp > 0) temp *= BINPOWOF10[sexp]; else if (sexp < 0) { /* Avoid going beyond the bounds of the exponent table for negative exponents. */ if (sexp < -BINPOWOF10_LIMIT) { temp /= BINPOWOF10[BINPOWOF10_LIMIT]; sexp += BINPOWOF10_LIMIT; } temp /= BINPOWOF10[-sexp]; } result = temp; /* Clear inexact exception raised by DFP arithmetic. */ if (DFP_EXCEPTIONS_ENABLED && DFP_TEST_EXCEPTIONS (FE_OVERFLOW|FE_UNDERFLOW) == 0) DFP_CLEAR_EXCEPTIONS (FE_INEXACT); ) hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/base-math/trunctdsd2.c000066400000000000000000000022371261375163000171440ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include _Decimal32 __BACKEND_(trunctdsd2) (_Decimal128 x) { return (_Decimal32)x; } hidden_def (__BACKEND_(trunctdsd2)) libdfp-1.0.12/base-math/trunctdsf.c000066400000000000000000000040221261375163000170560ustar00rootroot00000000000000/* Handle conversion from Decimal128 to binary float (32) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_BINARY #define SRC 128 #define DEST 32 #define NAME trunc #include "dfpacc.h" #include "convert.h" CONVERT_WRAPPER( // trunctdsf double temp; SRC_TYPE a_norm; long long mant; int exp, sexp; a_norm = FREXPD128 (a, &exp); /* Handle obvious overflow and underflow to avoid going beyond the bounds of the exponent table. */ if (exp > 39) /* Obvious overflow. */ { if (DFP_EXCEPTIONS_ENABLED) DFP_HANDLE_EXCEPTIONS (FE_OVERFLOW|FE_INEXACT); return SIGNBIT(a) ? -INFINITY : INFINITY; } else if (exp < -39) /* Obvious underflow. */ { if (DFP_EXCEPTIONS_ENABLED) DFP_HANDLE_EXCEPTIONS (FE_UNDERFLOW|FE_INEXACT); return SIGNBIT(a) ? -0.0 : 0.0; } mant = a_norm * 1E+15DL; /* 15 digits of mantissa. */ sexp = exp - 15; /* Exponent adjusted for mantissa. */ temp = mant; if (sexp > 0) temp *= BINPOWOF10[sexp]; else if (sexp < 0) temp /= BINPOWOF10[-sexp]; result = temp; ) hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/base-math/trunctdtf.c000066400000000000000000000023511261375163000170620ustar00rootroot00000000000000/* Handle conversion from Decimal128 to binary long double (dual 64bit) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_BINARY #define SRC 128 #define DEST 128 #define NAME trunc extern double __trunctddf(_Decimal128); extern _Decimal128 __extenddftd(double); #include "extendddtf.c" libdfp-1.0.12/base-math/trunctfdd.c000066400000000000000000000022661261375163000170470ustar00rootroot00000000000000/* Handle conversion from binary long double (128) to Decimal64 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define BINARY_TO_DECIMAL #define SRC 128 #define DEST 64 #define NAME trunc extern _Decimal64 __extenddfdd(double); #include "trunctfsd.c" libdfp-1.0.12/base-math/trunctfsd.c000066400000000000000000000031511261375163000170600ustar00rootroot00000000000000/* Handle conversion from binary long double (128) to Decimal32 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef BINARY_TO_DECIMAL #define BINARY_TO_DECIMAL #define SRC 128 #define DEST 32 #define NAME trunc #endif #include "dfpacc.h" #include "convert.h" CONVERT_WRAPPER( // truncdfsd, extenddfdd, extenddftd DEST_TYPE temp; union { SRC_TYPE ld; double d[2]; } ldd; ldd.ld = a; temp = ldd.d[0]; result = temp; temp = ldd.d[1]; result += temp; /* Clear inexact exception raised by DFP arithmetic. */ if (DFP_EXCEPTIONS_ENABLED && DFP_TEST_EXCEPTIONS (FE_OVERFLOW|FE_UNDERFLOW) == 0) DFP_CLEAR_EXCEPTIONS (FE_INEXACT); ) hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/base-math/unorddd2.c000066400000000000000000000022331261375163000165650ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include int __BACKEND_(unorddd2) (_Decimal64 x, _Decimal64 y) { return __isnand64 (x) || isnand64 (y); } libdfp-1.0.12/base-math/unordsd2.c000066400000000000000000000022471261375163000166110ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include int __BACKEND_(unordsd2) (_Decimal32 x, _Decimal32 y) { return __isnand64 ((_Decimal64)x) || __isnand64 ((_Decimal64)y); } libdfp-1.0.12/base-math/unordtd2.c000066400000000000000000000022411261375163000166040ustar00rootroot00000000000000/* Decimal Floating Point function intended to override the libgcc version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include int __BACKEND_(unordtd2) (_Decimal128 x, _Decimal128 y) { return __isnand128 (x) || __isnand128 (y); } libdfp-1.0.12/bootstrap000077500000000000000000000000531261375163000150000ustar00rootroot00000000000000#!/bin/sh set -e autoreconf -f -i autoscan libdfp-1.0.12/config.guess000077500000000000000000001261341261375163000153660ustar00rootroot00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992-2015 Free Software Foundation, Inc. timestamp='2006-02-27' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner . # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit build system type. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerppc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm:riscos:*:*|arm:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep __LP64__ >/dev/null then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) case ${UNAME_MACHINE} in pc98) echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:MSYS_NT-*:*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; x86:Interix*:[345]*) echo i586-pc-interix${UNAME_RELEASE} exit ;; EM64T:Interix*:[345]*) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo cris-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo crisv32-axis-linux-gnu exit ;; frv:Linux:*:*) echo frv-unknown-linux-gnu exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips #undef mipsel #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mipsel #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips #else CPU= #endif #endif EOF eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' /^CPU/{ s: ::g p }'`" test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips64 #undef mips64el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mips64el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips64 #else CPU= #endif #endif EOF eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' /^CPU/{ s: ::g p }'`" test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo or32-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; ppcle:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; ppc64le:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. # Set LC_ALL=C to ensure ld outputs messages in English. ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g s/.*supported targets: *// s/ .*// p'` case "$ld_supported_targets" in elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" exit ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. echo "${UNAME_MACHINE}-pc-linux-gnuoldld" exit ;; esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 LIBC=gnu # else LIBC=gnulibc1 # endif # else LIBC=gnulibc1 # endif #else #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__sun) LIBC=gnu #else LIBC=gnuaout #endif #endif #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' /^LIBC/{ s: ::g p }'`" test x"${LIBC}" != x && { echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit } test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: libdfp-1.0.12/config.h.in000066400000000000000000000127211261375163000150650ustar00rootroot00000000000000/* config.h.in. Generated from configure.ac by autoheader. */ /* "Define to the name of the assembler's directive for declaring a symbol global (default `.globl')." */ #undef ASM_GLOBAL_DIRECTIVE /* "Define to the prefix before `object' or `function' in the assembler's `.type' directive */ #undef ASM_TYPE_DIRECTIVE_PREFIX /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. */ #undef CRAY_STACKSEG_END /* Define to 1 if using `alloca.c'. */ #undef C_ALLOCA /* Define to 1 if you have `alloca', as a function or macro. */ #undef HAVE_ALLOCA /* Define to 1 if you have and it should be used (not on Ultrix). */ #undef HAVE_ALLOCA_H /* Define to 1 if you have the header file. */ #undef HAVE_FENV_H /* Define to 1 if you have the header file. */ #undef HAVE_FLOAT_H /* Define to 1 if you have the `floor' function. */ #undef HAVE_FLOOR /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_LANGINFO_H /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H /* Define to 1 if you have the header file. */ #undef HAVE_LOCALE_H /* Define to 1 if your system has a GNU libc compatible `malloc' function, and to 0 otherwise. */ #undef HAVE_MALLOC /* Define to 1 if mbrtowc and mbstate_t are properly declared. */ #undef HAVE_MBRTOWC /* Define to 1 if you have the 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 `nl_langinfo' function. */ #undef HAVE_NL_LANGINFO /* Define to 1 if you have the `setlocale' function. */ #undef HAVE_SETLOCALE /* Define to 1 if you have the `sqrt' function. */ #undef HAVE_SQRT /* Define to 1 if you have the header file. */ #undef HAVE_STDDEF_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strchr' function. */ #undef HAVE_STRCHR /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strtol' function. */ #undef HAVE_STRTOL /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* "Have __uint128_t type" */ #undef HAVE_UINT128_T /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the header file. */ #undef HAVE_WCHAR_H /* Define to 1 if you have the header file. */ #undef HAVE_WCTYPE_H /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL /* The loader to use in direct DSO call */ #undef LIBDFP_RUNTIME_LOADER /* 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 /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at runtime. STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown */ #undef STACK_DIRECTION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* "Defined if BID is the backend designated by configure." */ #undef _BID_BACKEND /* "Defined if DPD is the backend designated by configure." */ #undef _DPD_BACKEND /* Define for Solaris 2.5.1 so the uint32_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT32_T /* Define for Solaris 2.5.1 so the uint64_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT64_T /* 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 type of a signed integer type of width exactly 32 bits if such a type exists and the standard includes do not define it. */ #undef int32_t /* Define to rpl_malloc if the replacement function should be used. */ #undef malloc /* Define to `unsigned int' if does not define. */ #undef size_t /* Define to the type of an unsigned integer type of width exactly 32 bits if such a type exists and the standard includes do not define it. */ #undef uint32_t /* Define to the type of an unsigned integer type of width exactly 64 bits if such a type exists and the standard includes do not define it. */ #undef uint64_t libdfp-1.0.12/config.sub000077500000000000000000000772061261375163000150360ustar00rootroot00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992-2015 Free Software Foundation, Inc. timestamp='2006-02-27' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray) os= basic_machine=$1 ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | m32r | m32rle | m68000 | m68k | m88k | maxq | mb | microblaze | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64vr | mips64vrel \ | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | mt \ | msp430 \ | nios | nios2 \ | ns16k | ns32k \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc64v2 | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sparcv9v2 \ | strongarm \ | tahoe | thumb | tic4x | tic80 | tron \ | v850 | v850e \ | we32k \ | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ | z8k) basic_machine=$basic_machine-unknown ;; m32c) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64vr-* | mips64vrel-* \ | mips64orion-* | mips64orionel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc64v2-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sparcv9v2-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ | xstormy16-* | xtensa-* \ | ymp-* \ | z8k-*) ;; m32c-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; c90) basic_machine=c90-cray os=-unicos ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16c) basic_machine=cr16c-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tic55x | c55x*) basic_machine=tic55x-unknown os=-coff ;; tic6x | c6x*) basic_machine=tic6x-unknown os=-coff ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sparcv9v2) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: libdfp-1.0.12/config/000077500000000000000000000000001261375163000143045ustar00rootroot00000000000000libdfp-1.0.12/config/README000066400000000000000000000002071261375163000151630ustar00rootroot00000000000000The contents of this directory are synced from the GCC source directory since libdecnumber comes from GCC and override.m4 is required. libdfp-1.0.12/config/dfp.m4000066400000000000000000000027421261375163000153240ustar00rootroot00000000000000dnl @synopsis GCC_AC_ENABLE_DECIMAL_FLOAT([target triplet]) dnl dnl Enable C extension for decimal float if target supports it. dnl dnl @author Andreas Krebbel AC_DEFUN([GCC_AC_ENABLE_DECIMAL_FLOAT], [ AC_ARG_ENABLE(decimal-float, [ --enable-decimal-float={no,yes,bid,dpd} enable decimal float extension to C. Selecting 'bid' or 'dpd' choses which decimal floating point format to use], [ case $enable_decimal_float in yes | no | bid | dpd) default_decimal_float=$enable_decimal_float ;; *) AC_MSG_ERROR(['$enable_decimal_float' is an invalid value for --enable-decimal-float. Valid choices are 'yes', 'bid', 'dpd', and 'no'.]) ;; esac ], [ case $1 in powerpc*-*-linux* | i?86*-*-linux* | x86_64*-*-linux* | s390*-*-linux* | \ i?86*-*-gnu* | \ i?86*-*-mingw* | x86_64*-*-mingw* | \ i?86*-*-cygwin* | x86_64*-*-cygwin*) enable_decimal_float=yes ;; *) AC_MSG_WARN([decimal float is not supported for this target, ignored]) enable_decimal_float=no ;; esac ]) # x86's use BID format instead of DPD case x$enable_decimal_float in xyes) case $1 in i?86*-*-* | x86_64*-*-*) enable_decimal_float=bid ;; *) enable_decimal_float=dpd ;; esac default_decimal_float=$enable_decimal_float ;; xno) # ENABLE_DECIMAL_FLOAT is set to 0. But we have to have proper # dependency on libdecnumber. default_decimal_float=dpd ;; esac AC_SUBST(enable_decimal_float) ]) libdfp-1.0.12/config/override.m4000066400000000000000000000212101261375163000163610ustar00rootroot00000000000000dnl Fix Autoconf-2.59 bugs: by overriding broken internal dnl Autoconf macros with backports of the 2.60+ fix. dnl - AC_CONFIG_SUBDIRS whitespace mangling, dnl - more lenient precious variable checks dnl - better configure error message dnl - reliance on non-Posix m4wrap (M4 1.6 or newer implement FIFO) dnl dnl The override bits of this file should be a no-op for the newest dnl Autoconf version, which means they can be removed once the complete dnl tree has moved to a new enough Autoconf version. dnl dnl The _GCC_AUTOCONF_VERSION_TEST ensures that exactly the desired dnl Autoconf version is used. It should be kept for consistency. dnl m4_PACKAGE_VERSION is an undocumented Autoconf macro. dnl We use it because this fix is intended for 2.59 only. dnl A feature test for the broken AC_CONFIG_SUBDIRS instead dnl would be better but is tricky. dnl dnl Use ifdef/ifelse over m4_ifdef/m4_ifelse to be clean for 2.13. dnl Redefine AC_CONFIG_SUBDIRS so aclocal pulls in this file dnl when needed. ifdef([m4_PACKAGE_VERSION], [dnl AC_DEFUN a commonly used macro so this file is picked up. m4_copy_force([AC_PREREQ], [_AC_PREREQ]) AC_DEFUN([AC_PREREQ], [frob]) m4_copy_force([_AC_PREREQ], [AC_PREREQ]) dnl Ensure exactly this Autoconf version is used dnl m4_ifndef([_GCC_AUTOCONF_VERSION], dnl [m4_define([_GCC_AUTOCONF_VERSION], [2.59])]) dnl Test for the exact version when AC_INIT is expanded. dnl This allows to update the tree in steps (for testing) dnl by putting dnl m4_define([_GCC_AUTOCONF_VERSION], [X.Y]) dnl in configure.ac before AC_INIT, dnl without rewriting this file. dnl Or for updating the whole tree at once with the definition above. dnl AC_DEFUN([_GCC_AUTOCONF_VERSION_CHECK], dnl [m4_if(m4_defn([_GCC_AUTOCONF_VERSION]), dnl m4_defn([m4_PACKAGE_VERSION]), [], dnl [m4_fatal([Please use exactly Autoconf ]_GCC_AUTOCONF_VERSION[ instead of ]m4_defn([m4_PACKAGE_VERSION])[.])]) dnl ]) dnl m4_define([AC_INIT], m4_defn([AC_INIT])[ dnl _GCC_AUTOCONF_VERSION_CHECK dnl ]) m4_version_prereq([2.60],, [ dnl We use $ac_pwd in some of the overrides below; ensure its definition m4_divert_push([PARSE_ARGS])dnl ac_pwd=`pwd` m4_divert_pop([PARSE_ARGS])dnl ]) m4_version_prereq([2.60],, [ # _AC_OUTPUT_SUBDIRS # ------------------ # This is a subroutine of AC_OUTPUT, but it does not go into # config.status, rather, it is called after running config.status. m4_define([_AC_OUTPUT_SUBDIRS], [ # # CONFIG_SUBDIRS section, as fixed in confsubdir.m4. # if test "$no_recursion" != yes; then # Remove --cache-file and --srcdir arguments so they do not pile up. ac_sub_configure_args= ac_prev= eval "set x $ac_configure_args" shift for ac_arg do if test -n "$ac_prev"; then ac_prev= continue fi case $ac_arg in -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \ | --c=*) ;; --config-cache | -C) ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) ;; *) case $ac_arg in *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac ac_sub_configure_args="$ac_sub_configure_args '$ac_arg'" ;; esac done # Always prepend --prefix to ensure using the same prefix # in subdir configurations. ac_arg="--prefix=$prefix" case $ac_arg in *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac ac_sub_configure_args="$ac_arg $ac_sub_configure_args" ac_popdir=`pwd` for ac_dir in : $subdirs; do test "x$ac_dir" = x: && continue # Do not complain, so a configure script can configure whichever # parts of a large source tree are present. test -d "$srcdir/$ac_dir" || continue AC_MSG_NOTICE([configuring in $ac_dir]) AS_MKDIR_P(["$ac_dir"]) _AC_SRCPATHS(["$ac_dir"]) cd "$ac_dir" # Check for guested configure; otherwise get Cygnus style configure. if test -f "$ac_srcdir/configure.gnu"; then ac_sub_configure=$ac_srcdir/configure.gnu elif test -f "$ac_srcdir/configure"; then ac_sub_configure=$ac_srcdir/configure elif test -f "$ac_srcdir/configure.in"; then # This should be Cygnus configure. ac_sub_configure=$ac_aux_dir/configure else AC_MSG_WARN([no configuration information is in $ac_dir]) ac_sub_configure= fi # The recursion is here. if test -n "$ac_sub_configure"; then # Make the cache file name correct relative to the subdirectory. case $cache_file in [[\\/]]* | ?:[[\\/]]* ) ac_sub_cache_file=$cache_file ;; *) # Relative path. ac_sub_cache_file=$ac_top_builddir$cache_file ;; esac AC_MSG_NOTICE([running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir]) # The eval makes quoting arguments work. eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \ --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" || AC_MSG_ERROR([$ac_sub_configure failed for $ac_dir]) fi cd "$ac_popdir" done fi ])# _AC_OUTPUT_SUBDIRS ]) m4_version_prereq([2.63],, [ # _AC_ARG_VAR_VALIDATE # -------------------- # The code is the same as autoconf 2.59, but with a more lenient check # on precious variables and an output of pwd that have been added in # autoconf 2.62. m4_define([_AC_ARG_VAR_VALIDATE], [m4_divert_text([INIT_PREPARE], [# Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in `(set) 2>&1 | sed -n 's/^ac_env_\([[a-zA-Z_0-9]]*\)_set=.*/\1/p'`; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val="\$ac_cv_env_${ac_var}_value" eval ac_new_val="\$ac_env_${ac_var}_value" case $ac_old_set,$ac_new_set in set,) AS_MESSAGE([error: `$ac_var' was set to `$ac_old_val' in the previous run], 2) ac_cache_corrupted=: ;; ,set) AS_MESSAGE([error: `$ac_var' was not set in the previous run], 2) ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then AS_MESSAGE([error: `$ac_var' has changed since the previous run:], 2) ac_cache_corrupted=: else AS_MESSAGE([warning: ignoring whitespace changes in `$ac_var' since the previous run:], 2) eval $ac_var=\$ac_old_val fi AS_MESSAGE([ former value: `$ac_old_val'], 2) AS_MESSAGE([ current value: `$ac_new_val'], 2) fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in dnl If you change this globbing pattern, test it on an old shell -- dnl it's sensitive. Putting any kind of quote in it causes syntax errors. [ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)] ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then AS_MESSAGE([error: in `$ac_pwd':], 2) AS_MESSAGE([error: changes in the environment can compromise the build], 2) AS_ERROR([run `make distclean' and/or `rm $cache_file' and start over]) fi])dnl ])# _AC_ARG_VAR_VALIDATE ]) m4_version_prereq([2.63],, [ # AC_MSG_FAILURE(ERROR, [EXIT-STATUS = 1]) # ---------------------------------------- # This is the same code as in 2.59 and 2.61, except it also outputs pwd. m4_define([AC_MSG_FAILURE], [{ AS_MESSAGE([error: in `$ac_pwd':], 2) AC_MSG_ERROR([$1 See `config.log' for more details.], [$2]); }]) ]) ]) m4_version_prereq([2.60],, [ dnl M4 1.6 and newer implement m4wrap using FIFO semantics, as required dnl by Posix; earlier versions used LIFO semantics. Unfortunately, dnl Autoconf versions before 2.60 require those LIFO semantics, so dnl make sure to give it to them. m4_define([m4_wrap], [m4_ifdef([_$0_text], [m4_define([_$0_text], [$1]m4_defn([_$0_text]))], [m4_define([_$0_text], [$1])m4_builtin([m4wrap], [m4_default(m4_defn([_$0_text])m4_undefine([_$0_text]))])])]) ]) libdfp-1.0.12/config/stdint.m4000066400000000000000000000363261261375163000160650ustar00rootroot00000000000000dnl @synopsis GCC_HEADER_STDINT [( HEADER-TO-GENERATE [, HEADERS-TO-CHECK])] dnl dnl the "ISO C9X: 7.18 Integer types " section requires the dnl existence of an include file that defines a set of dnl typedefs, especially uint8_t,int32_t,uintptr_t. dnl Many older installations will not provide this file, but some will dnl have the very same definitions in . In other enviroments dnl we can use the inet-types in which would define the dnl typedefs int8_t and u_int8_t respectivly. dnl dnl This macros will create a local "_stdint.h" or the headerfile given as dnl an argument. In many cases that file will pick the definition from a dnl "#include " or "#include " statement, while dnl in other environments it will provide the set of basic 'stdint's defined: dnl int8_t,uint8_t,int16_t,uint16_t,int32_t,uint32_t,intptr_t,uintptr_t dnl int_least32_t.. int_fast32_t.. intmax_t dnl which may or may not rely on the definitions of other files. dnl dnl Sometimes the stdint.h or inttypes.h headers conflict with sys/types.h, dnl so we test the headers together with sys/types.h and always include it dnl into the generated header (to match the tests with the generated file). dnl Hopefully this is not a big annoyance. dnl dnl If your installed header files require the stdint-types you will want to dnl create an installable file mylib-int.h that all your other installable dnl header may include. So, for a library package named "mylib", just use dnl GCC_HEADER_STDINT(mylib-int.h) dnl in configure.in and install that header file in Makefile.am along with dnl the other headers (mylib.h). The mylib-specific headers can simply dnl use "#include " to obtain the stdint-types. dnl dnl Remember, if the system already had a valid , the generated dnl file will include it directly. No need for fuzzy HAVE_STDINT_H things... dnl dnl @author Guido Draheim , Paolo Bonzini AC_DEFUN([GCC_HEADER_STDINT], [m4_define(_GCC_STDINT_H, m4_ifval($1, $1, _stdint.h)) inttype_headers=`echo inttypes.h sys/inttypes.h $2 | sed -e 's/,/ /g'` acx_cv_header_stdint=stddef.h acx_cv_header_stdint_kind="(already complete)" for i in stdint.h $inttype_headers; do unset ac_cv_type_uintptr_t unset ac_cv_type_uintmax_t unset ac_cv_type_int_least32_t unset ac_cv_type_int_fast32_t unset ac_cv_type_uint64_t _AS_ECHO_N([looking for a compliant stdint.h in $i, ]) AC_CHECK_TYPE(uintmax_t,[acx_cv_header_stdint=$i],continue,[#include #include <$i>]) AC_CHECK_TYPE(uintptr_t,,[acx_cv_header_stdint_kind="(mostly complete)"], [#include #include <$i>]) AC_CHECK_TYPE(int_least32_t,,[acx_cv_header_stdint_kind="(mostly complete)"], [#include #include <$i>]) AC_CHECK_TYPE(int_fast32_t,,[acx_cv_header_stdint_kind="(mostly complete)"], [#include #include <$i>]) AC_CHECK_TYPE(uint64_t,,[acx_cv_header_stdint_kind="(lacks uint64_t)"], [#include #include <$i>]) break done if test "$acx_cv_header_stdint" = stddef.h; then acx_cv_header_stdint_kind="(lacks uintmax_t)" for i in stdint.h $inttype_headers; do unset ac_cv_type_uintptr_t unset ac_cv_type_uint32_t unset ac_cv_type_uint64_t _AS_ECHO_N([looking for an incomplete stdint.h in $i, ]) AC_CHECK_TYPE(uint32_t,[acx_cv_header_stdint=$i],continue,[#include #include <$i>]) AC_CHECK_TYPE(uint64_t,,,[#include #include <$i>]) AC_CHECK_TYPE(uintptr_t,,,[#include #include <$i>]) break done fi if test "$acx_cv_header_stdint" = stddef.h; then acx_cv_header_stdint_kind="(u_intXX_t style)" for i in sys/types.h $inttype_headers; do unset ac_cv_type_u_int32_t unset ac_cv_type_u_int64_t _AS_ECHO_N([looking for u_intXX_t types in $i, ]) AC_CHECK_TYPE(u_int32_t,[acx_cv_header_stdint=$i],continue,[#include #include <$i>]) AC_CHECK_TYPE(u_int64_t,,,[#include #include <$i>]) break done fi if test "$acx_cv_header_stdint" = stddef.h; then acx_cv_header_stdint_kind="(using manual detection)" fi test -z "$ac_cv_type_uintptr_t" && ac_cv_type_uintptr_t=no test -z "$ac_cv_type_uint64_t" && ac_cv_type_uint64_t=no test -z "$ac_cv_type_u_int64_t" && ac_cv_type_u_int64_t=no test -z "$ac_cv_type_int_least32_t" && ac_cv_type_int_least32_t=no test -z "$ac_cv_type_int_fast32_t" && ac_cv_type_int_fast32_t=no # ----------------- Summarize what we found so far AC_MSG_CHECKING([what to include in _GCC_STDINT_H]) case `AS_BASENAME(_GCC_STDINT_H)` in stdint.h) AC_MSG_WARN([are you sure you want it there?]) ;; inttypes.h) AC_MSG_WARN([are you sure you want it there?]) ;; *) ;; esac AC_MSG_RESULT($acx_cv_header_stdint $acx_cv_header_stdint_kind) # ----------------- done included file, check C basic types -------- # Lacking an uintptr_t? Test size of void * case "$acx_cv_header_stdint:$ac_cv_type_uintptr_t" in stddef.h:* | *:no) AC_CHECK_SIZEOF(void *) ;; esac # Lacking an uint64_t? Test size of long case "$acx_cv_header_stdint:$ac_cv_type_uint64_t:$ac_cv_type_u_int64_t" in stddef.h:*:* | *:no:no) AC_CHECK_SIZEOF(long) ;; esac if test $acx_cv_header_stdint = stddef.h; then # Lacking a good header? Test size of everything and deduce all types. AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(char) AC_MSG_CHECKING(for type equivalent to int8_t) case "$ac_cv_sizeof_char" in 1) acx_cv_type_int8_t=char ;; *) AC_MSG_ERROR(no 8-bit type, please report a bug) esac AC_MSG_RESULT($acx_cv_type_int8_t) AC_MSG_CHECKING(for type equivalent to int16_t) case "$ac_cv_sizeof_int:$ac_cv_sizeof_short" in 2:*) acx_cv_type_int16_t=int ;; *:2) acx_cv_type_int16_t=short ;; *) AC_MSG_ERROR(no 16-bit type, please report a bug) esac AC_MSG_RESULT($acx_cv_type_int16_t) AC_MSG_CHECKING(for type equivalent to int32_t) case "$ac_cv_sizeof_int:$ac_cv_sizeof_long" in 4:*) acx_cv_type_int32_t=int ;; *:4) acx_cv_type_int32_t=long ;; *) AC_MSG_ERROR(no 32-bit type, please report a bug) esac AC_MSG_RESULT($acx_cv_type_int32_t) fi # These tests are here to make the output prettier if test "$ac_cv_type_uint64_t" != yes && test "$ac_cv_type_u_int64_t" != yes; then case "$ac_cv_sizeof_long" in 8) acx_cv_type_int64_t=long ;; esac AC_MSG_CHECKING(for type equivalent to int64_t) AC_MSG_RESULT(${acx_cv_type_int64_t-'using preprocessor symbols'}) fi # Now we can use the above types if test "$ac_cv_type_uintptr_t" != yes; then AC_MSG_CHECKING(for type equivalent to intptr_t) case $ac_cv_sizeof_void_p in 2) acx_cv_type_intptr_t=int16_t ;; 4) acx_cv_type_intptr_t=int32_t ;; 8) acx_cv_type_intptr_t=int64_t ;; *) AC_MSG_ERROR(no equivalent for intptr_t, please report a bug) esac AC_MSG_RESULT($acx_cv_type_intptr_t) fi # ----------------- done all checks, emit header ------------- AC_CONFIG_COMMANDS(_GCC_STDINT_H, [ if test "$GCC" = yes; then echo "/* generated for " `$CC --version | sed 1q` "*/" > tmp-stdint.h else echo "/* generated for $CC */" > tmp-stdint.h fi sed 's/^ *//' >> tmp-stdint.h < EOF if test "$acx_cv_header_stdint" != stdint.h; then echo "#include " >> tmp-stdint.h fi if test "$acx_cv_header_stdint" != stddef.h; then echo "#include <$acx_cv_header_stdint>" >> tmp-stdint.h fi sed 's/^ *//' >> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <= 199901L #ifndef _INT64_T #define _INT64_T #ifndef __int64_t_defined typedef long long int64_t; #endif #endif #ifndef _UINT64_T #define _UINT64_T typedef unsigned long long uint64_t; #endif #elif defined __GNUC__ && defined (__STDC__) && __STDC__-0 /* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and does not implement __extension__. But that compiler doesn't define __GNUC_MINOR__. */ # if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__) # define __extension__ # endif # ifndef _INT64_T # define _INT64_T __extension__ typedef long long int64_t; # endif # ifndef _UINT64_T # define _UINT64_T __extension__ typedef unsigned long long uint64_t; # endif #elif !defined __STRICT_ANSI__ # if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__ # ifndef _INT64_T # define _INT64_T typedef __int64 int64_t; # endif # ifndef _UINT64_T # define _UINT64_T typedef unsigned __int64 uint64_t; # endif # endif /* compiler */ #endif /* ANSI version */ EOF fi # ------------- done int64_t types, emit intptr types ------------ if test "$ac_cv_type_uintptr_t" != yes; then sed 's/^ *//' >> tmp-stdint.h <> tmp-stdint.h < 1. dnl Fix when strange machines are reported. sed 's/^ *//' >> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <. # ACX_PROG_CC_WARNING_OPTS(WARNINGS, [VARIABLE = WARN_CFLAGS) # Sets @VARIABLE@ to the subset of the given options which the # compiler accepts. AC_DEFUN([ACX_PROG_CC_WARNING_OPTS], [AC_REQUIRE([AC_PROG_CC])dnl m4_pushdef([acx_Var], [m4_default([$2], [WARN_CFLAGS])])dnl AC_SUBST(acx_Var)dnl m4_expand_once([acx_Var= ],m4_quote(acx_Var=))dnl save_CFLAGS="$CFLAGS" for option in $1; do AS_VAR_PUSHDEF([acx_Woption], [acx_cv_prog_cc_warning_$option]) AC_CACHE_CHECK([whether $CC supports $option], acx_Woption, [CFLAGS="$option" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], [AS_VAR_SET(acx_Woption, yes)], [AS_VAR_SET(acx_Woption, no)]) ]) AS_IF([test AS_VAR_GET(acx_Woption) = yes], [acx_Var="$acx_Var${acx_Var:+ }$option"]) AS_VAR_POPDEF([acx_Woption])dnl done CFLAGS="$save_CFLAGS" m4_popdef([acx_Var])dnl ])# ACX_PROG_CC_WARNING_OPTS # ACX_PROG_CC_WARNING_ALMOST_PEDANTIC(WARNINGS, [VARIABLE = WARN_PEDANTIC) # Append to VARIABLE "-pedantic" + the argument, if the compiler is GCC # and accepts all of those options simultaneously, otherwise to nothing. AC_DEFUN([ACX_PROG_CC_WARNING_ALMOST_PEDANTIC], [AC_REQUIRE([AC_PROG_CC])dnl m4_pushdef([acx_Var], [m4_default([$2], [WARN_PEDANTIC])])dnl AC_SUBST(acx_Var)dnl m4_expand_once([acx_Var= ],m4_quote(acx_Var=))dnl AS_VAR_PUSHDEF([acx_Pedantic], [acx_cv_prog_cc_pedantic_$1])dnl AS_IF([test "$GCC" = yes], [AC_CACHE_CHECK([whether $CC supports -pedantic $1], acx_Pedantic, [save_CFLAGS="$CFLAGS" CFLAGS="-pedantic $1" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], [AS_VAR_SET(acx_Pedantic, yes)], [AS_VAR_SET(acx_Pedantic, no)]) CFLAGS="$save_CFLAGS"]) AS_IF([test AS_VAR_GET(acx_Pedantic) = yes], [acx_Var="$acx_Var${acx_Var:+ }-pedantic $1"]) ]) AS_VAR_POPDEF([acx_Pedantic])dnl m4_popdef([acx_Var])dnl ])# ACX_PROG_CC_WARNING_ALMOST_PEDANTIC # ACX_PROG_CC_WARNINGS_ARE_ERRORS([x.y.z], [VARIABLE = WERROR]) # sets @VARIABLE@ to "-Werror" if the compiler is GCC >=x.y.z, or if # --enable-werror-always was given on the command line, otherwise # to nothing. # If the argument is the word "manual" instead of a version number, # then @VARIABLE@ will be set to -Werror only if --enable-werror-always # appeared on the configure command line. AC_DEFUN([ACX_PROG_CC_WARNINGS_ARE_ERRORS], [AC_REQUIRE([AC_PROG_CC])dnl m4_pushdef([acx_Var], [m4_default([$2], [WERROR])])dnl AC_SUBST(acx_Var)dnl m4_expand_once([acx_Var= ],m4_quote(acx_Var=))dnl AC_ARG_ENABLE(werror-always, AS_HELP_STRING([--enable-werror-always], [enable -Werror despite compiler version]), [], [enable_werror_always=no]) AS_IF([test $enable_werror_always = yes], [acx_Var="$acx_Var${acx_Var:+ }-Werror"]) m4_if($1, [manual],, [AS_VAR_PUSHDEF([acx_GCCvers], [acx_cv_prog_cc_gcc_$1_or_newer])dnl AC_CACHE_CHECK([whether $CC is GCC >=$1], acx_GCCvers, [set fnord `echo $1 | tr '.' ' '` shift AC_PREPROC_IFELSE( [#if __GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ \ < [$]1 * 10000 + [$]2 * 100 + [$]3 #error insufficient #endif], [AS_VAR_SET(acx_GCCvers, yes)], [AS_VAR_SET(acx_GCCvers, no)])]) AS_IF([test AS_VAR_GET(acx_GCCvers) = yes], [acx_Var="$acx_Var${acx_Var:+ }-Werror"]) AS_VAR_POPDEF([acx_GCCvers])]) m4_popdef([acx_Var])dnl ])# ACX_PROG_CC_WARNINGS_ARE_ERRORS libdfp-1.0.12/configure000077500000000000000000006241211261375163000147540ustar00rootroot00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for libdfp 1.0.12. # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and tulioqm@br.ibm.com $0: about your system, including any error possibly output $0: before this message. Then install a modern shell, or $0: manually run the script under such a shell if you do $0: have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libdfp' PACKAGE_TARNAME='libdfp' PACKAGE_VERSION='1.0.12' PACKAGE_STRING='libdfp 1.0.12' PACKAGE_BUGREPORT='tulioqm@br.ibm.com' PACKAGE_URL='' ac_unique_file="printf_dfp.c" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" enable_option_checking=no ac_subst_vars='LTLIBOBJS subdirs LIBOBJS ALLOCA EGREP GREP CPP sysdep_dirs libdfp_cv_submachine_opt submachine picflag enable_shared enable_static cxxdecimal libdfp_cv_cc_with_decimal_float machine base_machine with_fp mzarch with_dfp ASFLAGS LDD GDB READELF OBJDUMP RANLIB AWK SET_MAKE LN_S INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM ac_ct_CXX CXXFLAGS CXX OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC dfp_backend enable_decimal_float host_os host_vendor host_cpu host build_os build_vendor build_cpu build target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_decimal_float with_backend with_cpu with_fp enable_static enable_shared ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CXX CXXFLAGS CCC OBJDUMP READELF GDB LDD CPP' ac_subdirs_all='libdecnumber libbid' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures libdfp 1.0.12 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/libdfp] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of libdfp 1.0.12:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-decimal-float=[yes|bid|dpd] This indicates the IEEE754r Decimal Floating point type encoding to be used by libdfp. Select yes or [DPD|dpd] or [BID|bid] [default=dpd] for powerpc[64] [default=dpd] for s390[x] [default=bid] for x86[_64]. --enable-static build static library [default] --enable-shared build shared library [default] Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-backend=[libdecnumber|libbid] This indicates which backend library to use in conjunction with the DFP type encoding specified by --enable-decimal-float: [default=libdecnumber] for DPD [optional=libbid] for BID [default=libbid] for BID libdecnumber will also work with the BID Decimal Floating Point types encoding. libbid will NOT work with the DPD Decimal Floating Point types encoding. --with-cpu=CPU Select the CPU to run on. Accepted values are similar to those accepted by gcc's -mcpu option. power6 and newer, and some z processors are supported. no is also accepted to indicate software only dfp should be used. If this option is not specified, configure will attempt to guess the latest powerpc processor supported by the toolchain, or use the soft dfp implementation. --with-fp if using floating point hardware [default=yes] Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CXX C++ compiler command CXXFLAGS C++ compiler flags OBJDUMP The path to the objdump used by the debug scripts. Defaults to that found in $$PATH READELF The path to the readelf used by test scripts. Defaults to that found in $$PATH GDB The path to the gdb used by the debug scripts. Defaults to that found in $$PATH LDD The path to the ldd used by the debug scripts. Defaults to that found in $$PATH CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF libdfp configure 1.0.12 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## --------------------------------- ## ## Report this to tulioqm@br.ibm.com ## ## --------------------------------- ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_find_intX_t LINENO BITS VAR # ----------------------------------- # Finds a signed integer type with width BITS, setting cache variable VAR # accordingly. ac_fn_c_find_intX_t () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for int$2_t" >&5 $as_echo_n "checking for int$2_t... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" # Order is important - never check a type that is potentially smaller # than half of the expected target width. for ac_type in int$2_t 'int' 'long int' \ 'long long int' 'short int' 'signed char'; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default enum { N = $2 / 2 - 1 }; int main () { static int test_array [1 - 2 * !(0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default enum { N = $2 / 2 - 1 }; int main () { static int test_array [1 - 2 * !(($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1) < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 2))]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else case $ac_type in #( int$2_t) : eval "$3=yes" ;; #( *) : eval "$3=\$ac_type" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if eval test \"x\$"$3"\" = x"no"; then : else break fi done fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_find_intX_t # ac_fn_c_find_uintX_t LINENO BITS VAR # ------------------------------------ # Finds an unsigned integer type with width BITS, setting cache variable VAR # accordingly. ac_fn_c_find_uintX_t () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 $as_echo_n "checking for uint$2_t... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" # Order is important - never check a type that is potentially smaller # than half of the expected target width. for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ 'unsigned long long int' 'unsigned short int' 'unsigned char'; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : case $ac_type in #( uint$2_t) : eval "$3=yes" ;; #( *) : eval "$3=\$ac_type" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if eval test \"x\$"$3"\" = x"no"; then : else break fi done fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_find_uintX_t cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by libdfp $as_me 1.0.12, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # We don't use Automake so this is necessary. ac_config_headers="$ac_config_headers config.h" # This indicates where config.guess and config.sub are located. Those scripts # are used by the AC_CANONICAL_* macros to determine platform specific data. ac_aux_dir= for ac_dir in scripts "$srcdir"/scripts; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in scripts \"$srcdir\"/scripts" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Defines host_cpu, host_vendor, and host_os variables. This is where the # code will run. # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac config_os=$host_os machine=$host_cpu # Only allow a Linux host OS. We don't support building libdfp on non-Linux # systems. if test "$config_os" != linux-gnu; then as_fn_error $? "'linux-gnu' is the only allowed host OS" "$LINENO" 5 fi ## This will fail on a pcc64 system where we're configuring for ppc. #if test "$host_cpi" != "$target_cpu"; then # AC_MSG_ERROR([${PACKAGE_NAME} does not yet support cross-compliation.]) #fi # PowerPC[64] defaults to DPD encoded DFP. x86[_64] defaults to BID encoded DFP. default_encoding= case "$host_cpu" in s390|s390x) default_encoding=dpd ;; powerpc*|powerpc64*) default_encoding=dpd ;; *) default_encoding=bid ;; esac # This clones what's in libdecnumber because autoconf doesn't # support passing unique flags to subdir configure.ac invocations # because it is brain dead. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for decimal floating point type encoding" >&5 $as_echo_n "checking for decimal floating point type encoding... " >&6; } # Check whether --enable-decimal-float was given. if test "${enable_decimal_float+set}" = set; then : enableval=$enable_decimal_float; case "$enable_decimal_float" in DPD|dpd) ;; BID|bid) if test "$host_cpu" = powerpc || test "$host_cpu" = powerpc64; then as_fn_error $? "The BID encoding isn't a valid encoding for PowerPC[64]" "$LINENO" 5 elif test "$host_cpu" = s390 || test "$host_cpu" = s390x; then as_fn_error $? "The BID encoding isn't a valid encoding for s390[x]" "$LINENO" 5 fi ;; yes|*) enable_decimal_float="$default_encoding" { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: no argument specified" >&5 $as_echo "$as_me: WARNING: no argument specified" >&2;} ;; esac else enable_decimal_float="$default_encoding" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_decimal_float" >&5 $as_echo "$enable_decimal_float" >&6; } # Some code may need to have conditional guards based on the backend. Give the # developers _DPD_BACKEND or _BID_BACKEND. Try avoiding this as much as # possible and use sysdep file overrides. A good place to use it is in the # tests/ directory. if test $enable_decimal_float = dpd; then cat >>confdefs.h <<_ACEOF #define _DPD_BACKEND 1 _ACEOF else cat >>confdefs.h <<_ACEOF #define _BID_BACKEND 1 _ACEOF fi # Now we know how to chose the desired backend directory, e.g. # src/backend/libdecnumber or src/backend/libbid when we build our search # path. "libdecnumber" is an external project sucked into this library. It # is an API that can use either the DPD or BID DFP data-type encoding. # Because the 'libdecnumber' and 'libbid' source code are out of tree they # have historical names and aren't simply 'dpd' and 'bid', so we map a # variable to their name based upon $enable_decimal_float. default_backend= case "$enable_decimal_float" in dpd) default_backend=libdecnumber ;; bid) default_backend=libdecnumber ;; *) default_backend=libdecnumber ;; esac dfp_backend= # Check whether --with-backend was given. if test "${with_backend+set}" = set; then : withval=$with_backend; case "$withval" in libbid) if test "$enable_decimal_float" = dpd; then as_fn_error $? "The DPD encoding can not be used with libbid." "$LINENO" 5 else dfp_backend=libbid fi ;; libdecnumber|*) dfp_backend=libdecnumber ;; esac else dfp_backend=$default_backend fi # Ensure basic toolchain tools are available. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else case $OBJDUMP in [\\/]* | ?:[\\/]*) ac_cv_path_OBJDUMP="$OBJDUMP" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_OBJDUMP="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi OBJDUMP=$ac_cv_path_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "readelf", so it can be a program name with args. set dummy readelf; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_READELF+:} false; then : $as_echo_n "(cached) " >&6 else case $READELF in [\\/]* | ?:[\\/]*) ac_cv_path_READELF="$READELF" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_READELF="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi READELF=$ac_cv_path_READELF if test -n "$READELF"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $READELF" >&5 $as_echo "$READELF" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "gdb", so it can be a program name with args. set dummy gdb; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_GDB+:} false; then : $as_echo_n "(cached) " >&6 else case $GDB in [\\/]* | ?:[\\/]*) ac_cv_path_GDB="$GDB" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_GDB="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi GDB=$ac_cv_path_GDB if test -n "$GDB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GDB" >&5 $as_echo "$GDB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # Extract the first word of "ldd", so it can be a program name with args. set dummy ldd; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_LDD+:} false; then : $as_echo_n "(cached) " >&6 else case $LDD in [\\/]* | ?:[\\/]*) ac_cv_path_LDD="$LDD" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_LDD="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi LDD=$ac_cv_path_LDD if test -n "$LDD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LDD" >&5 $as_echo "$LDD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # This will invoke the sysdeps/$machine// machinery. mzarch= submachine= with_dfp= # This tells us whether we know we have a hardware decimal floating point # unit. We know this based upon the submachine. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for hardware decimal floating point unit" >&5 $as_echo_n "checking for hardware decimal floating point unit... " >&6; } # Check whether --with-cpu was given. if test "${with_cpu+set}" = set; then : withval=$with_cpu; case "$withval" in yes|'') as_fn_error $? "--with-cpu requires an argument" "$LINENO" 5 ;; no) with_dfp=no ;; power8) submachine="$withval" { $as_echo "$as_me:${as_lineno-$LINENO}: configuring for the $submachine processor" >&5 $as_echo "$as_me: configuring for the $submachine processor" >&6;} with_dfp=yes ;; power7) submachine="$withval" { $as_echo "$as_me:${as_lineno-$LINENO}: configuring for the $submachine processor" >&5 $as_echo "$as_me: configuring for the $submachine processor" >&6;} with_dfp=yes ;; power6) submachine="$withval" { $as_echo "$as_me:${as_lineno-$LINENO}: configuring for the $submachine processor" >&5 $as_echo "$as_me: configuring for the $submachine processor" >&6;} with_dfp=yes ;; power6x) submachine="$withval" { $as_echo "$as_me:${as_lineno-$LINENO}: configuring for the $submachine processor" >&5 $as_echo "$as_me: configuring for the $submachine processor" >&6;} with_dfp=yes ;; z9-ec) submachine="$withval" # Warning, -mzarch won't get passed to libecnumber/configure mzarch="-mzarch" { $as_echo "$as_me:${as_lineno-$LINENO}: configuring for the $submachine processor" >&5 $as_echo "$as_me: configuring for the $submachine processor" >&6;} with_dfp=yes ;; z10) submachine="$withval" # Warning, -mzarch won't get passed to libecnumber/configure mzarch="-mzarch" { $as_echo "$as_me:${as_lineno-$LINENO}: configuring for the $submachine processor" >&5 $as_echo "$as_me: configuring for the $submachine processor" >&6;} with_dfp=yes ;; *) submachine="$withval" { $as_echo "$as_me:${as_lineno-$LINENO}: configuring for the $submachine processor" >&5 $as_echo "$as_me: configuring for the $submachine processor" >&6;} with_dfp=no ;; esac else case "$host_cpu" in powerpc*) # Test successively newer processors and select the # best implementation. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef _ARCH_PWR6 # error "Support for hardware dfp isn't available" #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : with_dfp=yes; submachine=power6 else with_dfp=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef _ARCH_PWR6X # error "POWER6X not supported" #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : submachine=power6x fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef _ARCH_PWR7 # error "POWER7 not supported" #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : submachine=power7 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef _ARCH_PWR8 # error "POWER8 not supported" #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : submachine=power8 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ;; *) with_dfp=no ;; esac fi # If building for a soft dfp, we must explicitly # prevent the compiler from emitting hardware # instructions. Otherwise, unexpected behavior # will occur. # # Test to the toolchain to see if it supports the # option to disable hard dfp, and if so, disable it. # This should work for s390 and power. if test "$with_dfp" == "no"; then cflags_tmp="$CFLAGS" CFLAGS="$CFLAGS -mno-hard-dfp" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else CFLAGS="$cflags_tmp" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_dfp" >&5 $as_echo "$with_dfp" >&6; } if test -n "$submachine"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for compiler option for CPU variant" >&5 $as_echo_n "checking for compiler option for CPU variant... " >&6; } if ${libdfp_cv_submachine_opt+:} false; then : $as_echo_n "(cached) " >&6 else libdfp_cv_submachine_opt=no for opt in "-march=$submachine" "-mcpu=$submachine"; do if { ac_try='${CC-cc} $opt -xc /dev/null -S -o /dev/null' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 (eval $ac_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then libdfp_cv_submachine_opt="$opt" break fi done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libdfp_cv_submachine_opt" >&5 $as_echo "$libdfp_cv_submachine_opt" >&6; } if test "x$libdfp_cv_submachine_opt" = xno; then as_fn_error $? "${CC-cc} does not support $submachine" "$LINENO" 5 fi fi # Unless the system is a s390 variant this is most likely empty. # Check whether --with-fp was given. if test "${with_fp+set}" = set; then : withval=$with_fp; with_fp=$withval else with_fp=yes fi case "$machine" in powerpc|powerpcle) base_machine=powerpc machine=powerpc/powerpc32 ;; powerpc64|powerpc64le) base_machine=powerpc machine=powerpc/powerpc64 ;; s390) base_machine=s390 machine=s390/s390-32 ;; s390x) base_machine=s390 machine=s390/s390-64 ;; i[34567]86) base_machine=i386 machine=i386/$machine ;; *) base_machine=$machine ;; esac # Don't even bother configuring if the compiler can't handle Decimal # Floating Point data types. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for decimal-float-support in compiler" >&5 $as_echo_n "checking for decimal-float-support in compiler... " >&6; } if ${libdfp_cv_cc_with_decimal_float+:} false; then : $as_echo_n "(cached) " >&6 else cat > conftest.c <&1 >/dev/null | grep -q " '_Decimal64' undeclared "; then libdfp_cv_cc_with_decimal_float=no { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: CC is ${CC}" >&5 $as_echo "$as_me: WARNING: CC is ${CC}" >&2;} as_fn_error $? "${PACKAGE_NAME} requires a compiler configured and built with --enable-decimal-float." "$LINENO" 5 else libdfp_cv_cc_with_decimal_float=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libdfp_cv_cc_with_decimal_float" >&5 $as_echo "$libdfp_cv_cc_with_decimal_float" >&6; } if test $libdfp_cv_cc_with_decimal_float = yes; then cat >> confdefs.h <<\EOF #define __STDC_DEC_FP__ 200704L EOF fi # Check for GLIBC 2.10 headers have_glibc_2_10_headers=yes { $as_echo "$as_me:${as_lineno-$LINENO}: checking for printf-hook register_printf_type() in printf.h to verify GLIBC 2.10" >&5 $as_echo_n "checking for printf-hook register_printf_type() in printf.h to verify GLIBC 2.10... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include "printf.h" int main () { static int foo; void foo_va (void *mem, va_list *ap) { return; } foo = register_printf_type (foo_va); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; }; have_glibc_2_10_headers=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test x$have_glibc_2_10_headers != xyes; then as_fn_error $? "Building Libdfp requires a GLIBC printf.h header that provides the register_printf_type() function which is available in GLIBC Version 2.10 or later." "$LINENO" 5 fi # Check for __uint128_t compiler support { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __uint128_t" >&5 $as_echo_n "checking for __uint128_t... " >&6; } if ${libdfp_cv_uint128_t+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { __uint128_t u = 0; return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : libdfp_cv_uint128_t=yes else libdfp_cv_uint128_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libdfp_cv_uint128_t" >&5 $as_echo "$libdfp_cv_uint128_t" >&6; } if test x$libdfp_cv_uint128_t = xyes; then cat >>confdefs.h <<_ACEOF #define HAVE_UINT128_T 1 _ACEOF fi # Check for std::decimal compiler support { $as_echo "$as_me:${as_lineno-$LINENO}: checking for std::decimal" >&5 $as_echo_n "checking for std::decimal... " >&6; } if ${libdfp_cv_cxxdecimal+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { std::decimal::decimal64 x = 0.0000006E-90DD; ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : libdfp_cv_cxxdecimal=yes else libdfp_cv_cxxdecimal=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libdfp_cv_cxxdecimal" >&5 $as_echo "$libdfp_cv_cxxdecimal" >&6; } cxxdecimal="$libdfp_cv_cxxdecimal" # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; case "$enableval" in yes) enable_static=static { $as_echo "$as_me:${as_lineno-$LINENO}: enabling support for a static library." >&5 $as_echo "$as_me: enabling support for a static library." >&6;};; no) enable_static= { $as_echo "$as_me:${as_lineno-$LINENO}: disabling support for a static library." >&5 $as_echo "$as_me: disabling support for a static library." >&6;};; *) enable_static=static { $as_echo "$as_me:${as_lineno-$LINENO}: enabling support for a static library." >&5 $as_echo "$as_me: enabling support for a static library." >&6;};; esac else enable_static=static fi # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; case "$enableval" in yes) enable_shared=shared { $as_echo "$as_me:${as_lineno-$LINENO}: enabling support for a shared library." >&5 $as_echo "$as_me: enabling support for a shared library." >&6;};; no) enable_shared= { $as_echo "$as_me:${as_lineno-$LINENO}: disabling support for a shared library." >&5 $as_echo "$as_me: disabling support for a shared library." >&6;};; *) enable_shared= { $as_echo "$as_me:${as_lineno-$LINENO}: enabling support for a shared library." >&5 $as_echo "$as_me: enabling support for a shared library." >&6;};; esac else enable_shared=shared fi # Should be ok if we build static with this turned on. If the linker # complains that the GOT is too big this may need to be upgraded to -fPIC so # we get full addressibility. picflag="-fpic -DSHARED" { $as_echo "$as_me:${as_lineno-$LINENO}: configuring with \"$picflag\"" >&5 $as_echo "$as_me: configuring with \"$picflag\"" >&6;} # Compute the list of sysdeps directories. { $as_echo "$as_me:${as_lineno-$LINENO}: checking sysdep dirs" >&5 $as_echo_n "checking sysdep dirs... " >&6; } # Build a search list based on this precedence: # ${srcdir}/include [internal libdfp headers] # ${srcdir}/libdecnumber/dpd [libdecnumber headers] # ${srcdir}/libdecnumber/bid [libdecnumber headers] # ${srcdir}/libbid/? [libbid headers] # [MACHINE/SUBMACHINE] # ${srcdir}/sysdeps/powerpc/powerpc64/power7/fpu [platform directories] # ${srcdir}/sysdeps/powerpc/powerpc64/power7/ # ${srcdir}/sysdeps/powerpc/powerpc64/power6/fpu [platform directories] # ${srcdir}/sysdeps/powerpc/powerpc64/power6/ # ${srcdir}/sysdeps/powerpc/powerpc64/ # ${srcdir}/sysdeps/powerpc/powerpc32/power6/fpu [platform directories] # ${srcdir}/sysdeps/powerpc/powerpc32/power6/ # ${srcdir}/sysdeps/powerpc/powerpc32/ # [BASE_MACHINE/[FPU|NOFPU] # ${srcdir}/sysdeps/powerpc/dfpu # ${srcdir}/sysdeps/powerpc/dfpu/bits # ${srcdir}/sysdeps/powerpc/fpu # ${srcdir}/sysdeps/powerpc/fpu/bits # ${srcdir}/sysdeps/powerpc/nofpu # ${srcdir}/sysdeps/powerpc/nofpu/bits # [BASE_MACHINE] # ${srcdir}/sysdeps/powerpc/ # ${srcdir}/sysdeps/i386/ # [ENCODING] # ${srcdir}/sysdeps/dpd [dpd specific implementations] # ${srcdir}/sysdeps/bid [bid specific implementations] # ${srcdir}/sysdeps/soft-dfp/dpd [soft-dfp dpd arithmetic, conversion, and comparison fns] # ${srcdir}/sysdeps/soft-dfp/bid [soft-dfp bid arithmetic, conversion, and comparison fns] # ${srcdir}/sysdeps/soft-dfp [soft-dfp arithmetic, conversion, and comparison fns] # ${srcdir}/dfp [headers files that will be installed. These follow the # sysdep overrides so that sysdeps override directories show up # before the install headers in #include_next
. # ${srcdir}/ieee754r [ISO C Draft TR functions] # ${srcdir}/base-math [Arithmetic, Conversion, and Comparison Routines.] # ${srcdir}/[common libdfp framework code & common headers for the backends.] # Out of Tree Sources # ${srcdir}/libdecnumber [third-party GCC sources] # ${srcdir}/libbid [third-party libBID sources] # We only assume Linux support so we don't worry about all the os stuff that # GLIBC does. tail=$machine${submachine:+/$submachine} # Build the list of dfpu|fpu|nofpu directories. while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do set $m # Only look for 'dfpu' directory if the system supports hardware dfp. if test "$with_dfp" = yes; then mach="$mach /$1/dfpu/bits /$1/dfpu" #mach="$mach /$1/dfpu" fi # Prepend the machine's FPU directory unless --without-fp. if test "$with_fp" = yes; then mach="$mach /$1/fpu/bits /$1/fpu" #mach="$mach /$1/fpu" else mach="$mach /$1/fpu/bits /$1/nofpu" #mach="$mach /$1/nofpu" fi mach="$mach /$1" tail="$2" done # Thankfully we don't support add-ons or non-Linux operating systems so this # is relatively simple compared to what it could be. We also don't care if # the machine or submachine don't show up in the sysdeps directory. The base # configuration doesn't require it. sysnames= try_srcdir="${srcdir}/" for m in $mach ''; do # We don't want to add /src/sysdeps yet. if test -n "$m"; then try="sysdeps${m}" if test -d "${try_srcdir}${try}"; then sysnames="$sysnames $try" fi fi done if test "$with_dfp" = no; then # Add src/sysdeps/soft-dfp and src/sysdeps/soft-dfp/dpd or # src/sysdeps/soft-dfp/bid to the search path. if test -d "${try_srcdir}/sysdeps/soft-dfp/"; then if test -d "${try_srcdir}/sysdeps/soft-dfp/${enable_decimal_float}"; then sysnames="$sysnames `echo sysdeps/soft-dfp/${enable_decimal_float} | sed -e 's,//,/,g'`" fi sysnames="$sysnames `echo sysdeps/soft-dfp | sed -e 's,//,/,g'`" fi fi # Add src/sysdeps/dpd or src/sysdeps/bid to the search path. if test -d "${try_srcdir}/sysdeps/${enable_decimal_float}"; then sysnames="$sysnames `echo sysdeps/${enable_decimal_float} | sed -e 's,//,/,g'`" fi # Close out the sysdeps directory. #sysnames="$sysnames sysdeps" # Add the default directories. default_sysnames="sysdeps/generic" sysnames="$sysnames $default_sysnames" set $sysnames names= while test $# -gt 0; do name=$1 shift case " $names " in *" $name "*) # Already in the list. continue esac case $name in /*) xsrcdir=;; *) xsrcdir=$srcdir/ ;; esac if test -f $xsrcdir$name/Implies; then implied_candidate="`sed 's/#.*$//' < $xsrcdir$name/Implies`" implied= for x in $implied_candidate; do found=no if test -d $xsrcdir/$x; then implied="$implied $x"; found=yes fi if test $found = no; then echo "$name/Implies specifies nonexistent $x" fi done else implied= fi names="$names $name" parent="`echo $name | sed -n -e 's=/^/*$==' -e '/sysdeps$/q' -e p`" sysnames="`echo $implied $* $parent`" test -n "$sysnames" && set $sysnames done sysdep_dirs="$names" # Just the directories in the sysdeps tree. { $as_echo "$as_me:${as_lineno-$LINENO}: result: $sysdep_dirs" >&5 $as_echo "$sysdep_dirs" >&6; } # Taken from GLIBC's configure.in { $as_echo "$as_me:${as_lineno-$LINENO}: checking for assembler global-symbol directive" >&5 $as_echo_n "checking for assembler global-symbol directive... " >&6; } if ${libc_cv_asm_global_directive+:} false; then : $as_echo_n "(cached) " >&6 else libc_cv_asm_global_directive=UNKNOWN for ac_globl in .globl .global .EXPORT; do cat > conftest.s <&5 (eval $ac_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then libc_cv_asm_global_directive=${ac_globl} fi rm -f conftest* test $libc_cv_asm_global_directive != UNKNOWN && break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_asm_global_directive" >&5 $as_echo "$libc_cv_asm_global_directive" >&6; } if test $libc_cv_asm_global_directive = UNKNOWN; then as_fn_error $? "cannot determine asm global directive" "$LINENO" 5 else cat >>confdefs.h <<_ACEOF #define ASM_GLOBAL_DIRECTIVE ${libc_cv_asm_global_directive} _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for assembler .type directive prefix" >&5 $as_echo_n "checking for assembler .type directive prefix... " >&6; } if ${libc_cv_asm_type_prefix+:} false; then : $as_echo_n "(cached) " >&6 else libc_cv_asm_type_prefix=no for ac_try_prefix in '@' '%' '#'; do cat > conftest.s <&5 (eval $ac_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then libc_cv_asm_type_prefix=${ac_try_prefix} fi rm -f conftest* test "x$libc_cv_asm_type_prefix" != xno && break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_asm_type_prefix" >&5 $as_echo "$libc_cv_asm_type_prefix" >&6; } if test "x$libc_cv_asm_type_prefix" != xno; then cat >>confdefs.h <<_ACEOF #define ASM_TYPE_DIRECTIVE_PREFIX ${libc_cv_asm_type_prefix} _ACEOF fi # Check which is the loader libdfp_cv_loader=` cat > conftest.c <>confdefs.h <<_ACEOF #define LIBDFP_RUNTIME_LOADER "$libdfp_cv_loader" _ACEOF # Checks for libraries. # Checks for header files. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 $as_echo_n "checking for working alloca.h... " >&6; } if ${ac_cv_working_alloca_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { char *p = (char *) alloca (2 * sizeof (int)); if (p) return 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_working_alloca_h=yes else ac_cv_working_alloca_h=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 $as_echo "$ac_cv_working_alloca_h" >&6; } if test $ac_cv_working_alloca_h = yes; then $as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 $as_echo_n "checking for alloca... " >&6; } if ${ac_cv_func_alloca_works+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __GNUC__ # define alloca __builtin_alloca #else # ifdef _MSC_VER # include # define alloca _alloca # else # ifdef HAVE_ALLOCA_H # include # else # ifdef _AIX #pragma alloca # else # ifndef alloca /* predefined by HP cc +Olibcalls */ void *alloca (size_t); # endif # endif # endif # endif #endif int main () { char *p = (char *) alloca (1); if (p) return 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_func_alloca_works=yes else ac_cv_func_alloca_works=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 $as_echo "$ac_cv_func_alloca_works" >&6; } if test $ac_cv_func_alloca_works = yes; then $as_echo "#define HAVE_ALLOCA 1" >>confdefs.h else # The SVR3 libPW and SVR4 libucb both contain incompatible functions # that cause trouble. Some versions do not even contain alloca or # contain a buggy version. If you still want to use their alloca, # use ar to extract alloca.o from them instead of compiling alloca.c. ALLOCA=\${LIBOBJDIR}alloca.$ac_objext $as_echo "#define C_ALLOCA 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 $as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } if ${ac_cv_os_cray+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined CRAY && ! defined CRAY2 webecray #else wenotbecray #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "webecray" >/dev/null 2>&1; then : ac_cv_os_cray=yes else ac_cv_os_cray=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5 $as_echo "$ac_cv_os_cray" >&6; } if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define CRAY_STACKSEG_END $ac_func _ACEOF break fi done fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 $as_echo_n "checking stack direction for C alloca... " >&6; } if ${ac_cv_c_stack_direction+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_c_stack_direction=0 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int find_stack_direction (int *addr, int depth) { int dir, dummy = 0; if (! addr) addr = &dummy; *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1; dir = depth ? find_stack_direction (addr, depth - 1) : 0; return dir + dummy; } int main (int argc, char **argv) { return find_stack_direction (0, argc + !argv + 20) < 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_stack_direction=1 else ac_cv_c_stack_direction=-1 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 $as_echo "$ac_cv_c_stack_direction" >&6; } cat >>confdefs.h <<_ACEOF #define STACK_DIRECTION $ac_cv_c_stack_direction _ACEOF fi for ac_header in fenv.h float.h langinfo.h limits.h locale.h stddef.h stdint.h stdlib.h string.h sys/time.h unistd.h wchar.h wctype.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Checks for typedefs, structures, and compiler characteristics. # Checks for typedefs, structures, and compiler characteristics. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 $as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } if ${ac_cv_header_stdbool_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef bool "error: bool is not defined" #endif #ifndef false "error: false is not defined" #endif #if false "error: false is not 0" #endif #ifndef true "error: true is not defined" #endif #if true != 1 "error: true is not 1" #endif #ifndef __bool_true_false_are_defined "error: __bool_true_false_are_defined is not defined" #endif struct s { _Bool s: 1; _Bool t; } s; char a[true == 1 ? 1 : -1]; char b[false == 0 ? 1 : -1]; char c[__bool_true_false_are_defined == 1 ? 1 : -1]; char d[(bool) 0.5 == true ? 1 : -1]; /* See body of main program for 'e'. */ char f[(_Bool) 0.0 == false ? 1 : -1]; char g[true]; char h[sizeof (_Bool)]; char i[sizeof s.t]; enum { j = false, k = true, l = false * true, m = true * 256 }; /* The following fails for HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ _Bool n[m]; char o[sizeof n == m * sizeof n[0] ? 1 : -1]; char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; /* Catch a bug in an HP-UX C compiler. See http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html */ _Bool q = true; _Bool *pq = &q; int main () { bool e = &s; *pq |= q; *pq |= ! q; /* Refer to every declared value, to avoid compiler optimizations. */ return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + !m + !n + !o + !p + !q + !pq); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdbool_h=yes else ac_cv_header_stdbool_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 $as_echo "$ac_cv_header_stdbool_h" >&6; } ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" if test "x$ac_cv_type__Bool" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE__BOOL 1 _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } if ${ac_cv_c_inline+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; static $ac_kw foo_t static_foo () {return 0; } $ac_kw foo_t foo () {return 0; } #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_inline=$ac_kw fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 $as_echo "$ac_cv_c_inline" >&6; } case $ac_cv_c_inline in inline | yes) ;; *) case $ac_cv_c_inline in no) ac_val=;; *) ac_val=$ac_cv_c_inline;; esac cat >>confdefs.h <<_ACEOF #ifndef __cplusplus #define inline $ac_val #endif _ACEOF ;; esac ac_fn_c_find_intX_t "$LINENO" "32" "ac_cv_c_int32_t" case $ac_cv_c_int32_t in #( no|yes) ;; #( *) cat >>confdefs.h <<_ACEOF #define int32_t $ac_cv_c_int32_t _ACEOF ;; esac ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" case $ac_cv_c_uint32_t in #( no|yes) ;; #( *) $as_echo "#define _UINT32_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define uint32_t $ac_cv_c_uint32_t _ACEOF ;; esac ac_fn_c_find_uintX_t "$LINENO" "64" "ac_cv_c_uint64_t" case $ac_cv_c_uint64_t in #( no|yes) ;; #( *) $as_echo "#define _UINT64_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define uint64_t $ac_cv_c_uint64_t _ACEOF ;; esac # Checks for library functions. for ac_header in stdlib.h do : ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" if test "x$ac_cv_header_stdlib_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDLIB_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5 $as_echo_n "checking for GNU libc compatible malloc... " >&6; } if ${ac_cv_func_malloc_0_nonnull+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_malloc_0_nonnull=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined STDC_HEADERS || defined HAVE_STDLIB_H # include #else char *malloc (); #endif int main () { return ! malloc (0); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_malloc_0_nonnull=yes else ac_cv_func_malloc_0_nonnull=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5 $as_echo "$ac_cv_func_malloc_0_nonnull" >&6; } if test $ac_cv_func_malloc_0_nonnull = yes; then : $as_echo "#define HAVE_MALLOC 1" >>confdefs.h else $as_echo "#define HAVE_MALLOC 0" >>confdefs.h case " $LIBOBJS " in *" malloc.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS malloc.$ac_objext" ;; esac $as_echo "#define malloc rpl_malloc" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc and mbstate_t are properly declared" >&5 $as_echo_n "checking whether mbrtowc and mbstate_t are properly declared... " >&6; } if ${ac_cv_func_mbrtowc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { wchar_t wc; char const s[] = ""; size_t n = 1; mbstate_t state; return ! (sizeof state && (mbrtowc) (&wc, s, n, &state)); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_func_mbrtowc=yes else ac_cv_func_mbrtowc=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mbrtowc" >&5 $as_echo "$ac_cv_func_mbrtowc" >&6; } if test $ac_cv_func_mbrtowc = yes; then $as_echo "#define HAVE_MBRTOWC 1" >>confdefs.h fi for ac_func in floor gettimeofday memset nl_langinfo setlocale sqrt strchr strtol do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done # Wherever there's a standalone configure fragment we need to tell the top # level configure to recurse into it. if test "$dfp_backend" = libdecnumber; then subdirs="$subdirs libdecnumber" else subdirs="$subdirs libbid" fi # This tells autoconf to generate Makefile from the Makefile.in. This is the # top level Makefile for the project. This Makefile will then recurse into # the fragment Makefiles in the sysdeps directories. ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by libdfp $as_me 1.0.12, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ libdfp config.status 1.0.12 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi # # CONFIG_SUBDIRS section. # if test "$no_recursion" != yes; then # Remove --cache-file, --srcdir, and --disable-option-checking arguments # so they do not pile up. ac_sub_configure_args= ac_prev= eval "set x $ac_configure_args" shift for ac_arg do if test -n "$ac_prev"; then ac_prev= continue fi case $ac_arg in -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \ | --c=*) ;; --config-cache | -C) ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) ;; --disable-option-checking) ;; *) case $ac_arg in *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append ac_sub_configure_args " '$ac_arg'" ;; esac done # Always prepend --prefix to ensure using the same prefix # in subdir configurations. ac_arg="--prefix=$prefix" case $ac_arg in *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac ac_sub_configure_args="'$ac_arg' $ac_sub_configure_args" # Pass --silent if test "$silent" = yes; then ac_sub_configure_args="--silent $ac_sub_configure_args" fi # Always prepend --disable-option-checking to silence warnings, since # different subdirs can have different --enable and --with options. ac_sub_configure_args="--disable-option-checking $ac_sub_configure_args" ac_popdir=`pwd` for ac_dir in : $subdirs; do test "x$ac_dir" = x: && continue # Do not complain, so a configure script can configure whichever # parts of a large source tree are present. test -d "$srcdir/$ac_dir" || continue ac_msg="=== configuring in $ac_dir (`pwd`/$ac_dir)" $as_echo "$as_me:${as_lineno-$LINENO}: $ac_msg" >&5 $as_echo "$ac_msg" >&6 as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" # Check for guested configure; otherwise get Cygnus style configure. if test -f "$ac_srcdir/configure.gnu"; then ac_sub_configure=$ac_srcdir/configure.gnu elif test -f "$ac_srcdir/configure"; then ac_sub_configure=$ac_srcdir/configure elif test -f "$ac_srcdir/configure.in"; then # This should be Cygnus configure. ac_sub_configure=$ac_aux_dir/configure else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: no configuration information is in $ac_dir" >&5 $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2;} ac_sub_configure= fi # The recursion is here. if test -n "$ac_sub_configure"; then # Make the cache file name correct relative to the subdirectory. case $cache_file in [\\/]* | ?:[\\/]* ) ac_sub_cache_file=$cache_file ;; *) # Relative name. ac_sub_cache_file=$ac_top_build_prefix$cache_file ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&5 $as_echo "$as_me: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&6;} # The eval makes quoting arguments work. eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \ --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" || as_fn_error $? "$ac_sub_configure failed for $ac_dir" "$LINENO" 5 fi cd "$ac_popdir" done fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi libdfp-1.0.12/configure.ac000066400000000000000000000520451261375163000153330ustar00rootroot00000000000000# Process this file with autoconf to produce a configure script. AC_PREREQ([2.69]) AC_INIT([libdfp],[1.0.12],[tulioqm@br.ibm.com]) AC_CONFIG_SRCDIR([printf_dfp.c]) # We don't use Automake so this is necessary. AC_CONFIG_HEADER([config.h]) # This indicates where config.guess and config.sub are located. Those scripts # are used by the AC_CANONICAL_* macros to determine platform specific data. AC_CONFIG_AUX_DIR([scripts]) # Defines host_cpu, host_vendor, and host_os variables. This is where the # code will run. AC_CANONICAL_HOST config_os=$host_os machine=$host_cpu # Only allow a Linux host OS. We don't support building libdfp on non-Linux # systems. if test "$config_os" != linux-gnu; then AC_MSG_ERROR(['linux-gnu' is the only allowed host OS]) fi ## This will fail on a pcc64 system where we're configuring for ppc. #if test "$host_cpi" != "$target_cpu"; then # AC_MSG_ERROR([${PACKAGE_NAME} does not yet support cross-compliation.]) #fi # PowerPC[64] defaults to DPD encoded DFP. x86[_64] defaults to BID encoded DFP. default_encoding= case "$host_cpu" in s390|s390x) default_encoding=dpd ;; powerpc*|powerpc64*) default_encoding=dpd ;; *) default_encoding=bid ;; esac # This clones what's in libdecnumber because autoconf doesn't # support passing unique flags to subdir configure.ac invocations # because it is brain dead. AC_MSG_CHECKING([for decimal floating point type encoding]) AC_ARG_ENABLE([decimal-float], AS_HELP_STRING([--enable-decimal-float=@<:@yes|bid|dpd@:>@], [This indicates the IEEE754r Decimal Floating point type encoding to be used by libdfp. Select yes or @<:@DPD|dpd@:>@ or @<:@BID|bid@:>@ @<:@default=dpd@:>@ for powerpc@<:@64@:>@ @<:@default=dpd@:>@ for s390@<:@x@:>@ @<:@default=bid@:>@ for x86@<:@_64@:>@. ]), [dnl case "$enable_decimal_float" in DPD|dpd) ;; BID|bid) if test "$host_cpu" = powerpc || test "$host_cpu" = powerpc64; then AC_MSG_ERROR([The BID encoding isn't a valid encoding for PowerPC@<:@64@:>@]) elif test "$host_cpu" = s390 || test "$host_cpu" = s390x; then AC_MSG_ERROR([The BID encoding isn't a valid encoding for s390@<:@x@:>@]) fi ;; yes|*) enable_decimal_float="$default_encoding" AC_MSG_WARN(no argument specified, using host default encoding "$default_encoding".) ;; esac], [enable_decimal_float="$default_encoding"]) AC_SUBST(enable_decimal_float) AC_MSG_RESULT($enable_decimal_float) # Some code may need to have conditional guards based on the backend. Give the # developers _DPD_BACKEND or _BID_BACKEND. Try avoiding this as much as # possible and use sysdep file overrides. A good place to use it is in the # tests/ directory. if test $enable_decimal_float = dpd; then AC_DEFINE_UNQUOTED([_DPD_BACKEND], [1], ["Defined if DPD is the backend designated by configure."]) else AC_DEFINE_UNQUOTED([_BID_BACKEND], [1], ["Defined if BID is the backend designated by configure."]) fi # Now we know how to chose the desired backend directory, e.g. # src/backend/libdecnumber or src/backend/libbid when we build our search # path. "libdecnumber" is an external project sucked into this library. It # is an API that can use either the DPD or BID DFP data-type encoding. # Because the 'libdecnumber' and 'libbid' source code are out of tree they # have historical names and aren't simply 'dpd' and 'bid', so we map a # variable to their name based upon $enable_decimal_float. default_backend= case "$enable_decimal_float" in dpd) default_backend=libdecnumber ;; bid) default_backend=libdecnumber ;; *) default_backend=libdecnumber ;; esac dfp_backend= AC_ARG_WITH([backend], AS_HELP_STRING([--with-backend=@<:@libdecnumber|libbid@:>@], [This indicates which backend library to use in conjunction with the DFP type encoding specified by --enable-decimal-float: @<:@default=libdecnumber@:>@ for DPD @<:@optional=libbid@:>@ for BID @<:@default=libbid@:>@ for BID libdecnumber will also work with the BID Decimal Floating Point types encoding. libbid will NOT work with the DPD Decimal Floating Point types encoding.]), [dnl case "$withval" in libbid) if test "$enable_decimal_float" = dpd; then AC_MSG_ERROR([The DPD encoding can not be used with libbid.]) else dfp_backend=libbid fi ;; libdecnumber|*) dfp_backend=libdecnumber ;; esac], [dfp_backend=$default_backend]) AC_SUBST(dfp_backend) # Ensure basic toolchain tools are available. AC_PROG_CC AC_PROG_CXX AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_MAKE_SET AC_PROG_AWK AC_PROG_RANLIB AC_PATH_PROG([OBJDUMP], [objdump]) AC_ARG_VAR(OBJDUMP,The path to the objdump used by the debug scripts. Defaults to that found in $$PATH) AC_PATH_PROG([READELF], [readelf]) AC_ARG_VAR(READELF,The path to the readelf used by test scripts. Defaults to that found in $$PATH) AC_PATH_PROG([GDB], [gdb]) AC_ARG_VAR(GDB,The path to the gdb used by the debug scripts. Defaults to that found in $$PATH) AC_PATH_PROG([LDD], [ldd]) AC_ARG_VAR(LDD,The path to the ldd used by the debug scripts. Defaults to that found in $$PATH) AC_SUBST(CFLAGS) AC_SUBST(CXXFLAGS) AC_SUBST(CPPFLAGS) AC_SUBST(ASFLAGS) # This will invoke the sysdeps/$machine// machinery. mzarch= submachine= with_dfp= # This tells us whether we know we have a hardware decimal floating point # unit. We know this based upon the submachine. AC_MSG_CHECKING([for hardware decimal floating point unit]) AC_ARG_WITH([cpu], AS_HELP_STRING([--with-cpu=CPU], [Select the CPU to run on. Accepted values are similar to those accepted by gcc's -mcpu option. power6 and newer, and some z processors are supported. no is also accepted to indicate software only dfp should be used. If this option is not specified, configure will attempt to guess the latest powerpc processor supported by the toolchain, or use the soft dfp implementation.]), [dnl case "$withval" in yes|'') AC_MSG_ERROR([--with-cpu requires an argument]) ;; no) with_dfp=no ;; power8) submachine="$withval" AC_MSG_NOTICE(configuring for the $submachine processor) with_dfp=yes ;; power7) submachine="$withval" AC_MSG_NOTICE(configuring for the $submachine processor) with_dfp=yes ;; power6) submachine="$withval" AC_MSG_NOTICE(configuring for the $submachine processor) with_dfp=yes ;; power6x) submachine="$withval" AC_MSG_NOTICE(configuring for the $submachine processor) with_dfp=yes ;; z9-ec) submachine="$withval" # Warning, -mzarch won't get passed to libecnumber/configure mzarch="-mzarch" AC_MSG_NOTICE(configuring for the $submachine processor) with_dfp=yes ;; z10) submachine="$withval" # Warning, -mzarch won't get passed to libecnumber/configure mzarch="-mzarch" AC_MSG_NOTICE(configuring for the $submachine processor) with_dfp=yes ;; *) submachine="$withval" AC_MSG_NOTICE(configuring for the $submachine processor) with_dfp=no ;; esac ],[ case "$host_cpu" in powerpc*) # Test successively newer processors and select the # best implementation. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #ifndef _ARCH_PWR6 # error "Support for hardware dfp isn't available" #endif ]])], [with_dfp=yes; submachine=power6], [with_dfp=no]) AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #ifndef _ARCH_PWR6X # error "POWER6X not supported" #endif ]])], [submachine=power6x], []) AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #ifndef _ARCH_PWR7 # error "POWER7 not supported" #endif ]])], [submachine=power7], []) AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ #ifndef _ARCH_PWR8 # error "POWER8 not supported" #endif ]])], [submachine=power8], []) ;; *) with_dfp=no ;; esac ]) # If building for a soft dfp, we must explicitly # prevent the compiler from emitting hardware # instructions. Otherwise, unexpected behavior # will occur. # # Test to the toolchain to see if it supports the # option to disable hard dfp, and if so, disable it. # This should work for s390 and power. if test "$with_dfp" == "no"; then cflags_tmp="$CFLAGS" CFLAGS="$CFLAGS -mno-hard-dfp" AC_COMPILE_IFELSE([AC_LANG_SOURCE([[]])],[],[CFLAGS="$cflags_tmp"]) fi AC_SUBST(with_dfp) AC_MSG_RESULT($with_dfp) if test -n "$submachine"; then AC_CACHE_CHECK([for compiler option for CPU variant], libdfp_cv_submachine_opt, [dnl libdfp_cv_submachine_opt=no for opt in "-march=$submachine" "-mcpu=$submachine"; do if AC_TRY_COMMAND([${CC-cc} $opt -xc /dev/null -S -o /dev/null]); then libdfp_cv_submachine_opt="$opt" break fi done]) if test "x$libdfp_cv_submachine_opt" = xno; then AC_MSG_ERROR([${CC-cc} does not support $submachine]) fi fi # Unless the system is a s390 variant this is most likely empty. AC_SUBST(mzarch) AC_ARG_WITH([fp], AS_HELP_STRING([--with-fp], [if using floating point hardware @<:@default=yes@:>@]), [with_fp=$withval], [with_fp=yes]) AC_SUBST(with_fp) dnl We need to use [ and ] for other purposes for a while now. changequote(,)dnl case "$machine" in powerpc|powerpcle) base_machine=powerpc machine=powerpc/powerpc32 ;; powerpc64|powerpc64le) base_machine=powerpc machine=powerpc/powerpc64 ;; s390) base_machine=s390 machine=s390/s390-32 ;; s390x) base_machine=s390 machine=s390/s390-64 ;; i[34567]86) base_machine=i386 machine=i386/$machine ;; *) base_machine=$machine ;; esac changequote([,])dnl AC_SUBST(base_machine) AC_SUBST(machine) # Don't even bother configuring if the compiler can't handle Decimal # Floating Point data types. AC_CACHE_CHECK(for decimal-float-support in compiler, libdfp_cv_cc_with_decimal_float, [ cat > conftest.c <&1 >/dev/null | grep -q " '_Decimal64' undeclared "; then libdfp_cv_cc_with_decimal_float=no AC_MSG_WARN([CC is ${CC}]) AC_MSG_ERROR([${PACKAGE_NAME} requires a compiler configured and built with --enable-decimal-float.]) else libdfp_cv_cc_with_decimal_float=yes fi rm -f conftest*]) AC_SUBST(libdfp_cv_cc_with_decimal_float) if test $libdfp_cv_cc_with_decimal_float = yes; then cat >> confdefs.h <<\EOF #define __STDC_DEC_FP__ 200704L EOF fi # Check for GLIBC 2.10 headers have_glibc_2_10_headers=yes AC_MSG_CHECKING([for printf-hook register_printf_type() in printf.h to verify GLIBC 2.10]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include "printf.h"]], [[ static int foo; void foo_va (void *mem, va_list *ap) { return; } foo = register_printf_type (foo_va); ]])],[AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no]); have_glibc_2_10_headers=no]) if test x$have_glibc_2_10_headers != xyes; then AC_MSG_ERROR([Building Libdfp requires a GLIBC printf.h header that provides the register_printf_type() function which is available in GLIBC Version 2.10 or later.]) fi # Check for __uint128_t compiler support AC_CACHE_CHECK(for __uint128_t, libdfp_cv_uint128_t, AC_TRY_COMPILE([ ], [ __uint128_t u = 0; return 0; ], [ libdfp_cv_uint128_t=yes ], [ libdfp_cv_uint128_t=no ]) ) if test x$libdfp_cv_uint128_t = xyes; then AC_DEFINE_UNQUOTED([HAVE_UINT128_T], [1], ["Have __uint128_t type"]) fi # Check for std::decimal compiler support AC_CACHE_CHECK(for std::decimal, libdfp_cv_cxxdecimal, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE( [ #include ], [ std::decimal::decimal64 x = 0.0000006E-90DD; ], [ libdfp_cv_cxxdecimal=yes ], [ libdfp_cv_cxxdecimal=no ]) AC_LANG_RESTORE] ) cxxdecimal="$libdfp_cv_cxxdecimal" AC_SUBST(cxxdecimal) AC_ARG_ENABLE([static], AS_HELP_STRING([--enable-static], [build static library @<:@default@:>@]), [case "$enableval" in yes) enable_static=static AC_MSG_NOTICE(enabling support for a static library.);; no) enable_static= AC_MSG_NOTICE(disabling support for a static library.);; *) enable_static=static AC_MSG_NOTICE(enabling support for a static library.);; esac], enable_static=static) AC_SUBST(enable_static) AC_ARG_ENABLE([shared], AS_HELP_STRING([--enable-shared], [build shared library @<:@default@:>@]), [case "$enableval" in yes) enable_shared=shared AC_MSG_NOTICE(enabling support for a shared library.);; no) enable_shared= AC_MSG_NOTICE(disabling support for a shared library.);; *) enable_shared= AC_MSG_NOTICE(enabling support for a shared library.);; esac], enable_shared=shared ) AC_SUBST(enable_shared) # Should be ok if we build static with this turned on. If the linker # complains that the GOT is too big this may need to be upgraded to -fPIC so # we get full addressibility. picflag="-fpic -DSHARED" AC_MSG_NOTICE(configuring with "$picflag") AC_SUBST(picflag) # Compute the list of sysdeps directories. AC_MSG_CHECKING(sysdep dirs) # Build a search list based on this precedence: # ${srcdir}/include [internal libdfp headers] # ${srcdir}/libdecnumber/dpd [libdecnumber headers] # ${srcdir}/libdecnumber/bid [libdecnumber headers] # ${srcdir}/libbid/? [libbid headers] # [MACHINE/SUBMACHINE] # ${srcdir}/sysdeps/powerpc/powerpc64/power7/fpu [platform directories] # ${srcdir}/sysdeps/powerpc/powerpc64/power7/ # ${srcdir}/sysdeps/powerpc/powerpc64/power6/fpu [platform directories] # ${srcdir}/sysdeps/powerpc/powerpc64/power6/ # ${srcdir}/sysdeps/powerpc/powerpc64/ # ${srcdir}/sysdeps/powerpc/powerpc32/power6/fpu [platform directories] # ${srcdir}/sysdeps/powerpc/powerpc32/power6/ # ${srcdir}/sysdeps/powerpc/powerpc32/ # [BASE_MACHINE/[FPU|NOFPU] # ${srcdir}/sysdeps/powerpc/dfpu # ${srcdir}/sysdeps/powerpc/dfpu/bits # ${srcdir}/sysdeps/powerpc/fpu # ${srcdir}/sysdeps/powerpc/fpu/bits # ${srcdir}/sysdeps/powerpc/nofpu # ${srcdir}/sysdeps/powerpc/nofpu/bits # [BASE_MACHINE] # ${srcdir}/sysdeps/powerpc/ # ${srcdir}/sysdeps/i386/ # [ENCODING] # ${srcdir}/sysdeps/dpd [dpd specific implementations] # ${srcdir}/sysdeps/bid [bid specific implementations] # ${srcdir}/sysdeps/soft-dfp/dpd [soft-dfp dpd arithmetic, conversion, and comparison fns] # ${srcdir}/sysdeps/soft-dfp/bid [soft-dfp bid arithmetic, conversion, and comparison fns] # ${srcdir}/sysdeps/soft-dfp [soft-dfp arithmetic, conversion, and comparison fns] # ${srcdir}/dfp [headers files that will be installed. These follow the # sysdep overrides so that sysdeps override directories show up # before the install headers in #include_next
. # ${srcdir}/ieee754r [ISO C Draft TR functions] # ${srcdir}/base-math [Arithmetic, Conversion, and Comparison Routines.] # ${srcdir}/[common libdfp framework code & common headers for the backends.] # Out of Tree Sources # ${srcdir}/libdecnumber [third-party GCC sources] # ${srcdir}/libbid [third-party libBID sources] # We only assume Linux support so we don't worry about all the os stuff that # GLIBC does. dnl We need to use [ and ] for other purposes for a while now. changequote(,)dnl tail=$machine${submachine:+/$submachine} # Build the list of dfpu|fpu|nofpu directories. while m=`echo $tail | sed 's@^\(.*\)/\([^/]*\)$@& \1@'`; test -n "$m"; do set $m # Only look for 'dfpu' directory if the system supports hardware dfp. if test "$with_dfp" = yes; then mach="$mach /$1/dfpu/bits /$1/dfpu" #mach="$mach /$1/dfpu" fi # Prepend the machine's FPU directory unless --without-fp. if test "$with_fp" = yes; then mach="$mach /$1/fpu/bits /$1/fpu" #mach="$mach /$1/fpu" else mach="$mach /$1/fpu/bits /$1/nofpu" #mach="$mach /$1/nofpu" fi mach="$mach /$1" tail="$2" done dnl We are done with glob and regexp uses of [ and ]; return to autoconf. changequote([,])dnl # Thankfully we don't support add-ons or non-Linux operating systems so this # is relatively simple compared to what it could be. We also don't care if # the machine or submachine don't show up in the sysdeps directory. The base # configuration doesn't require it. sysnames= try_srcdir="${srcdir}/" for m in $mach ''; do # We don't want to add /src/sysdeps yet. if test -n "$m"; then try="sysdeps${m}" if test -d "${try_srcdir}${try}"; then sysnames="$sysnames $try" fi fi done AC_SUBST(submachine) AC_SUBST(libdfp_cv_submachine_opt) if test "$with_dfp" = no; then # Add src/sysdeps/soft-dfp and src/sysdeps/soft-dfp/dpd or # src/sysdeps/soft-dfp/bid to the search path. if test -d "${try_srcdir}/sysdeps/soft-dfp/"; then if test -d "${try_srcdir}/sysdeps/soft-dfp/${enable_decimal_float}"; then sysnames="$sysnames `echo sysdeps/soft-dfp/${enable_decimal_float} | sed -e 's,//,/,g'`" fi sysnames="$sysnames `echo sysdeps/soft-dfp | sed -e 's,//,/,g'`" fi fi # Add src/sysdeps/dpd or src/sysdeps/bid to the search path. if test -d "${try_srcdir}/sysdeps/${enable_decimal_float}"; then sysnames="$sysnames `echo sysdeps/${enable_decimal_float} | sed -e 's,//,/,g'`" fi # Close out the sysdeps directory. #sysnames="$sysnames sysdeps" # Add the default directories. default_sysnames="sysdeps/generic" sysnames="$sysnames $default_sysnames" set $sysnames names= while test $# -gt 0; do name=$1 shift case " $names " in *" $name "*) # Already in the list. continue esac case $name in /*) xsrcdir=;; *) xsrcdir=$srcdir/ ;; esac if test -f $xsrcdir$name/Implies; then implied_candidate="`sed 's/#.*$//' < $xsrcdir$name/Implies`" implied= for x in $implied_candidate; do found=no if test -d $xsrcdir/$x; then implied="$implied $x"; found=yes fi if test $found = no; then echo "$name/Implies specifies nonexistent $x" fi done else implied= fi names="$names $name" parent="`echo $name | sed -n -e 's=/[^/]*$==' -e '/sysdeps$/q' -e p`" sysnames="`echo $implied $* $parent`" test -n "$sysnames" && set $sysnames done sysdep_dirs="$names" # Just the directories in the sysdeps tree. AC_SUBST(sysdep_dirs) AC_MSG_RESULT($sysdep_dirs) # Taken from GLIBC's configure.in AC_CACHE_CHECK(for assembler global-symbol directive, libc_cv_asm_global_directive, [dnl libc_cv_asm_global_directive=UNKNOWN for ac_globl in .globl .global .EXPORT; do cat > conftest.s <&AS_MESSAGE_LOG_FD); then libc_cv_asm_global_directive=${ac_globl} fi rm -f conftest* test $libc_cv_asm_global_directive != UNKNOWN && break done]) if test $libc_cv_asm_global_directive = UNKNOWN; then AC_MSG_ERROR(cannot determine asm global directive) else AC_DEFINE_UNQUOTED(ASM_GLOBAL_DIRECTIVE, ${libc_cv_asm_global_directive},"Define to the name of the assembler's directive for declaring a symbol global (default `.globl').") fi AC_CACHE_CHECK(for assembler .type directive prefix, libc_cv_asm_type_prefix, [dnl libc_cv_asm_type_prefix=no for ac_try_prefix in '@' '%' '#'; do cat > conftest.s <&AS_MESSAGE_LOG_FD); then libc_cv_asm_type_prefix=${ac_try_prefix} fi rm -f conftest* test "x$libc_cv_asm_type_prefix" != xno && break done]) if test "x$libc_cv_asm_type_prefix" != xno; then AC_DEFINE_UNQUOTED(ASM_TYPE_DIRECTIVE_PREFIX, ${libc_cv_asm_type_prefix}, "Define to the prefix before `object' or `function' in the assembler's `.type' directive, if it has one.") fi # Check which is the loader libdfp_cv_loader=` cat > conftest.c < // for printf #include // for malloc/free #include // for tolower #include #define E "2.7182818284590452353602874713526624977572470936999595749669676277240766303535" #define PI "3.1415926535897932384626433832795028841971693993751058209749445923078164062862" //Flags #define DIVIDE 0x80 #define REMAINDER 0x40 #define DIVIDEINT 0x20 #define REMNEAR 0x10 #define COMPARE 0x01 #define COMPMAX 0x02 #define COMPMIN 0x03 #define COMPNAN 0x04 #define BADINT (Int)0x80000000 #define DIVIDE_BY_10(x) x.exponent-- // ---------------------------------------------------------------------- // Basic Functions // ---------------------------------------------------------------------- // Return the largest integer less than or equal to x static decNumber* decNumberFloor (decNumber *result, decNumber *x, decContext *set) { int round = set->round; set->round = DEC_ROUND_DOWN; decNumberToIntegralValue (result, x, set); set->round = round; return result; } /* decNumberFloor */ static int decNumberIsEqual (decNumber *x, decNumber *y, decContext *set) { decNumber diff; decNumberSubtract (&diff, x, y, set); return decNumberIsZero (&diff); } /* decNumberIsEqual */ static int decNumberIsInteger (decNumber *x, decContext *set) { decNumber y; decNumberToIntegralValue (&y, x, set); return decNumberIsEqual (x, &y, set); } /* decNumberIsInteger */ // Modulo function static decNumber* decNumberMod (decNumber *result, decNumber *x, decNumber *y, decContext *set) { // x mod y = x - k*y where k = floor(x/y) decNumber k; decNumberDivide (&k, x, y, set); decNumberFloor (&k, &k, set); decNumberMultiply (&k, &k, y, set); decNumberSubtract (result, x, &k, set); return result; } /* decNumberMod */ // ---------------------------------------------------------------------- // Exponential Function // ---------------------------------------------------------------------- decNumber* decNumberPow (decNumber *result, decNumber *x, decNumber *y, decContext *set) { decNumber tmp; if (decNumberIsInteger (y, set)) { return decNumberPower (result, x, y, set); } // y is not an integer. if (decNumberIsNegative (x)) { // result would be a complex number. decNumberFromString (result, "NaN", set); return result; } // x^y = exp (y*ln(x)) decNumberLn(&tmp, x, set); decNumberMultiply (&tmp, &tmp, y, set); decNumberExp (result, &tmp, set); return result; } /* decNumberPow */ /* ------------------------------------------------------------------ */ /* decNumberSquareRoot -- square root operator */ /* */ /* This computes C = squareroot(A) */ /* */ /* res is C, the result. C may be A */ /* rhs is A */ /* set is the context; note that rounding mode has no effect */ /* */ /* C must have space for set->digits digits. */ /* ------------------------------------------------------------------ */ /* This uses the following varying-precision algorithm in: */ /* */ /* Properly Rounded Variable Precision Square Root, T. E. Hull and */ /* A. Abrham, ACM Transactions on Mathematical Software, Vol 11 #3, */ /* pp229-237, ACM, September 1985. */ /* */ /* % [Reformatted original Numerical Turing source code follows.] */ /* function sqrt(x : real) : real */ /* % sqrt(x) returns the properly rounded approximation to the square */ /* % root of x, in the precision of the calling environment, or it */ /* % fails if x < 0. */ /* % t e hull and a abrham, august, 1984 */ /* if x <= 0 then */ /* if x < 0 then */ /* assert false */ /* else */ /* result 0 */ /* end if */ /* end if */ /* var f := setexp(x, 0) % fraction part of x [0.1 <= x < 1] */ /* var e := getexp(x) % exponent part of x */ /* var approx : real */ /* if e mod 2 = 0 then */ /* approx := .259 + .819 * f % approx to root of f */ /* else */ /* f := f/l0 % adjustments */ /* e := e + 1 % for odd */ /* approx := .0819 + 2.59 * f % exponent */ /* end if */ /* */ /* var p:= 3 */ /* const maxp := currentprecision + 2 */ /* loop */ /* p := min(2*p - 2, maxp) % p = 4,6,10, . . . , maxp */ /* precision p */ /* approx := .5 * (approx + f/approx) */ /* exit when p = maxp */ /* end loop */ /* */ /* % approx is now within 1 ulp of the properly rounded square root */ /* % of f; to ensure proper rounding, compare squares of (approx - */ /* % l/2 ulp) and (approx + l/2 ulp) with f. */ /* p := currentprecision */ /* begin */ /* precision p + 2 */ /* const approxsubhalf := approx - setexp(.5, -p) */ /* if mulru(approxsubhalf, approxsubhalf) > f then */ /* approx := approx - setexp(.l, -p + 1) */ /* else */ /* const approxaddhalf := approx + setexp(.5, -p) */ /* if mulrd(approxaddhalf, approxaddhalf) < f then */ /* approx := approx + setexp(.l, -p + 1) */ /* end if */ /* end if */ /* end */ /* result setexp(approx, e div 2) % fix exponent */ /* end sqrt */ /* ------------------------------------------------------------------ */ /*decNumber * decNumberSquareRoot(decNumber *res, decNumber *rhs, decContext *set) { decContext workset, approxset; // work contexts decNumber dzero; // used for constant zero Int maxp=set->digits+2; // largest working precision Int residue=0; // rounding residue uInt status=0, ignore=0; // status accumulators Int exp; // working exponent Int ideal; // ideal (preferred) exponent Int needbytes; // work Int dropped; // .. decNumber *allocrhs=NULL; // non-NULL if rounded rhs allocated // buffer for f [needs +1 in case DECBUFFER 0] uByte buff[sizeof(decNumber)+(D2U(DECBUFFER+1)-1)*sizeof(Unit)]; // buffer for a [needs +2 to match maxp] uByte bufa[sizeof(decNumber)+(D2U(DECBUFFER+2)-1)*sizeof(Unit)]; // buffer for temporary, b [must be same size as a] uByte bufb[sizeof(decNumber)+(D2U(DECBUFFER+2)-1)*sizeof(Unit)]; decNumber *allocbuff=NULL; // -> allocated buff, iff allocated decNumber *allocbufa=NULL; // -> allocated bufa, iff allocated decNumber *allocbufb=NULL; // -> allocated bufb, iff allocated decNumber *f=(decNumber *)buff; // reduced fraction decNumber *a=(decNumber *)bufa; // approximation to result decNumber *b=(decNumber *)bufb; // intermediate result // buffer for temporary variable, up to 3 digits uByte buft[sizeof(decNumber)+(D2U(3)-1)*sizeof(Unit)]; decNumber *t=(decNumber *)buft; // up-to-3-digit constant or work #if DECCHECK if (decCheckOperands(res, DECUNUSED, rhs, set)) return res; #endif do { // protect allocated storage #if DECSUBSET if (!set->extended) { // reduce operand and set lostDigits status, as needed if (rhs->digits>set->digits) { allocrhs=decRoundOperand(rhs, set, &status); if (allocrhs==NULL) break; // [Note: 'f' allocation below could reuse this buffer if // used, but as this is rare we keep them separate for clarity.] rhs=allocrhs; } } #endif // [following code does not require input rounding] // handle infinities and NaNs if (rhs->bits & DECSPECIAL) { if (decNumberIsInfinite(rhs)) { // an infinity if (decNumberIsNegative(rhs)) status|=DEC_Invalid_operation; else decNumberCopy(res, rhs); // +Infinity } else decNaNs(res, rhs, NULL, &status); // a NaN break; } // calculate the ideal (preferred) exponent [floor(exp/2)] // [We would like to write: ideal=rhs->exponent>>1, but this // generates a compiler warning. Generated code is the same.] ideal=(rhs->exponent&~1)/2; // target // handle zeros if (ISZERO(rhs)) { decNumberCopy(res, rhs); // could be 0 or -0 res->exponent=ideal; // use the ideal [safe] break; } // any other -x is an oops if (decNumberIsNegative(rhs)) { status|=DEC_Invalid_operation; break; } // we need space for three working variables // f -- the same precision as the RHS, reduced to 0.01->0.99... // a -- Hull's approx -- precision, when assigned, is // currentprecision (we allow +2 for use as temporary) // b -- intermediate temporary result // if any is too long for local storage, then allocate needbytes=sizeof(decNumber)+(D2U(rhs->digits)-1)*sizeof(Unit); if (needbytes>sizeof(buff)) { allocbuff=(decNumber *)malloc(needbytes); if (allocbuff==NULL) { // hopeless -- abandon status|=DEC_Insufficient_storage; break;} f=allocbuff; // use the allocated space } // a and b both need to be able to hold a maxp-length number needbytes=sizeof(decNumber)+(D2U(maxp)-1)*sizeof(Unit); if (needbytes>sizeof(bufa)) { // [same applies to b] allocbufa=(decNumber *)malloc(needbytes); allocbufb=(decNumber *)malloc(needbytes); if (allocbufa==NULL || allocbufb==NULL) { // hopeless status|=DEC_Insufficient_storage; break;} a=allocbufa; // use the allocated space b=allocbufb; // .. } // copy rhs -> f, save exponent, and reduce so 0.1 <= f < 1 decNumberCopy(f, rhs); exp=f->exponent+f->digits; // adjusted to Hull rules f->exponent=-(f->digits); // to range // set up working contexts (the second is used for Numerical // Turing assignment) decContextDefault(&workset, DEC_INIT_DECIMAL64); decContextDefault(&approxset, DEC_INIT_DECIMAL64); approxset.digits=set->digits; // approx's length // [Until further notice, no error is possible and status bits // (Rounded, etc.) should be ignored, not accumulated.] // Calculate initial approximation, and allow for odd exponent workset.digits=set->digits; // p for initial calculation t->bits=0; t->digits=3; a->bits=0; a->digits=3; if ((exp & 1)==0) { // even exponent // Set t=0.259, a=0.819 t->exponent=-3; a->exponent=-3; #if DECDPUN>=3 t->lsu[0]=259; a->lsu[0]=819; #elif DECDPUN==2 t->lsu[0]=59; t->lsu[1]=2; a->lsu[0]=19; a->lsu[1]=8; #else t->lsu[0]=9; t->lsu[1]=5; t->lsu[2]=2; a->lsu[0]=9; a->lsu[1]=1; a->lsu[2]=8; #endif } else { // odd exponent // Set t=0.0819, a=2.59 f->exponent--; // f=f/10 exp++; // e=e+1 t->exponent=-4; a->exponent=-2; #if DECDPUN>=3 t->lsu[0]=819; a->lsu[0]=259; #elif DECDPUN==2 t->lsu[0]=19; t->lsu[1]=8; a->lsu[0]=59; a->lsu[1]=2; #else t->lsu[0]=9; t->lsu[1]=1; t->lsu[2]=8; a->lsu[0]=9; a->lsu[1]=5; a->lsu[2]=2; #endif } decMultiplyOp(a, a, f, &workset, &ignore); // a=a*f decAddOp(a, a, t, &workset, 0, &ignore); // ..+t // [a is now the initial approximation for sqrt(f), calculated with // currentprecision, which is also a's precision.] // the main calculation loop decNumberZero(&dzero); // make 0 decNumberZero(t); // set t = 0.5 t->lsu[0]=5; // .. t->exponent=-1; // .. workset.digits=3; // initial p for (;;) { // set p to min(2*p - 2, maxp) [hence 3; or: 4, 6, 10, ... , maxp] workset.digits=workset.digits*2-2; if (workset.digits>maxp) workset.digits=maxp; // a = 0.5 * (a + f/a) // [calculated at p then rounded to currentprecision] decDivideOp(b, f, a, &workset, DIVIDE, &ignore); // b=f/a decAddOp(b, b, a, &workset, 0, &ignore); // b=b+a decMultiplyOp(a, b, t, &workset, &ignore);// a=b*0.5 // assign to approx [round to length] decAddOp(a, &dzero, a, &approxset, 0, &ignore); if (workset.digits==maxp) break; // just did final } // loop // a is now at currentprecision and within 1 ulp of the properly // rounded square root of f; to ensure proper rounding, compare // squares of (a - l/2 ulp) and (a + l/2 ulp) with f. // Here workset.digits=maxp and t=0.5 workset.digits--; // maxp-1 is OK now t->exponent=-set->digits-1; // make 0.5 ulp decNumberCopy(b, a); decAddOp(b, b, t, &workset, DECNEG, &ignore); // b = a - 0.5 ulp workset.round=DEC_ROUND_UP; decMultiplyOp(b, b, b, &workset, &ignore); // b = mulru(b, b) decNumberCompare(b, f, b, &workset); // b ? f, reversed if (decNumberIsNegative(b)) { // f < b [i.e., b > f] // this is the more common adjustment, though both are rare t->exponent++; // make 1.0 ulp t->lsu[0]=1; // .. decAddOp(a, a, t, &workset, DECNEG, &ignore); // a = a - 1 ulp // assign to approx [round to length] decAddOp(a, &dzero, a, &approxset, 0, &ignore); } else { decNumberCopy(b, a); decAddOp(b, b, t, &workset, 0, &ignore); // b = a + 0.5 ulp workset.round=DEC_ROUND_DOWN; decMultiplyOp(b, b, b, &workset, &ignore);// b = mulrd(b, b) decNumberCompare(b, b, f, &workset); // b ? f if (decNumberIsNegative(b)) { // b < f t->exponent++; // make 1.0 ulp t->lsu[0]=1; // .. decAddOp(a, a, t, &workset, 0, &ignore);// a = a + 1 ulp // assign to approx [round to length] decAddOp(a, &dzero, a, &approxset, 0, &ignore); } } // [no errors are possible in the above, and rounding/inexact during // estimation are irrelevant, so status was not accumulated] // Here, 0.1 <= a < 1 [Hull] a->exponent+=exp/2; // set correct exponent // Process Subnormals decFinalize(a, set, &residue, &status); // count dropable zeros [after any subnormal rounding] decNumberCopy(b, a); decTrim(b, 1, &dropped); // [drops trailing zeros] // Finally set Inexact and Rounded. The answer can only be exact if // it is short enough so that squaring it could fit in set->digits, // so this is the only (relatively rare) time we have to check // carefully if (b->digits*2-1 > set->digits) { // cannot fit status|=DEC_Inexact|DEC_Rounded; } else { // could be exact/unrounded uInt mstatus=0; // local status decMultiplyOp(b, b, b, &workset, &mstatus); // try the multiply if (mstatus!=0) { // result won't fit status|=DEC_Inexact|DEC_Rounded; } else { // plausible decNumberCompare(t, b, rhs, &workset); // b ? rhs if (!ISZERO(t)) { status|=DEC_Inexact|DEC_Rounded; } else { // is Exact // here, dropped is the count of trailing zeros in 'a' // use closest exponent to ideal... Int todrop=ideal-a->exponent; // most we can drop if (todrop<0) { // ideally would add 0s status|=DEC_Rounded; } else { // unrounded if (dropped0) { // OK, some to drop decShiftToLeast(a->lsu, D2U(a->digits), todrop); a->exponent+=todrop; // maintain numerical value a->digits-=todrop; // new length } } } } } decNumberCopy(res, a); // assume this is the result } while(0); // end protected if (allocbuff!=NULL) free(allocbuff); // drop any storage we used if (allocbufa!=NULL) free(allocbufa); // .. if (allocbufb!=NULL) free(allocbufb); // .. if (allocrhs !=NULL) free(allocrhs); // .. if (status!=0) decStatus(res, status, set);// then report status return res; }*/ /* decNumberSquareRoot */ // ---------------------------------------------------------------------- // Hyperbolic Functions // ---------------------------------------------------------------------- decNumber* decNumberSinh (decNumber *result, decNumber *x, decContext *set) { // sinh x = (e^x - e^-x)/2 decNumber ex, emx, mx, two; decNumberExp (&ex, x, set); decNumberMinus (&mx, x, set); decNumberExp (&emx, &mx, set); decNumberSubtract (result, &ex, &emx, set); decNumberFromString (&two, "2", set); decNumberDivide (result, result, &two, set); return result; } decNumber* decNumberCosh (decNumber *result, decNumber *x, decContext *set) { // cosh x = (e^x + e^-x)/2 decNumber ex, emx, mx, two; decNumberExp (&ex, x, set); decNumberMinus (&mx, x, set); decNumberExp (&emx, &mx, set); decNumberAdd (result, &ex, &emx, set); decNumberFromString (&two, "2", set); decNumberDivide (result, result, &two, set); return result; } /* decNumberCosh */ decNumber* decNumberTanh (decNumber *result, decNumber *x, decContext *set) { // tanh x = sinh x / cosh x = (e^x - e^-x) / (e^x + e^-x) decNumber ex, emx, mx, denominator; decNumberExp (&ex, x, set); decNumberMinus (&mx, x, set); decNumberExp (&emx, &mx, set); decNumberSubtract (result, &ex, &emx, set); decNumberAdd (&denominator, &ex, &emx, set); decNumberDivide (result, result, &denominator, set); return result; } /* decNumberTanh */ // ---------------------------------------------------------------------- // Trigonometric Functions // ---------------------------------------------------------------------- decNumber* decNumberSin (decNumber *result, decNumber *y, decContext *set) { decNumber pi, pi2, zero, one, two, x, cnt, term, cmp; int i; int negate = 0; decNumberFromString (&zero,"0", set); decNumberFromString (&one, "1", set); decNumberFromString (&two, "2", set); decNumberFromString (&pi, PI , set); // Copy the argument y, so we can modify it. decNumberCopy (&x, y); // sin -x = - sin x /* if (decCompare (&x, &zero) < 0) { */ if (decNumberIsNegative (&x)) { // x < 0 decNumberMinus (&x, &x, set); negate = 1; } // We now have x >= 0 decNumberMultiply (&pi2, &pi, &two, set); // pi2 = 2*pi decNumberMod (&x, &x, &pi2, set); // We now have 0 <= x < 2*pi /*if (decCompare (&x, &pi) >= 0) {*/ decNumberCompare (&cmp, &x, &pi, set); if (!decNumberIsNegative (&cmp)) { // x >= pi decNumberSubtract (&x, &x, &pi, set); negate = 1-negate; } // We now have 0 <= x < pi decNumberDivide (&pi2, &pi, &two, set); // pi2 = pi/2 /*if (decCompare (&x, &pi2) >= 0) {*/ decNumberCompare (&cmp, &x, &pi2, set); if (!decNumberIsNegative (&cmp)) { // x >= pi/2, so let x = pi-x decNumberSubtract (&x, &pi, &x, set); } // We now have 0 <= x <= pi/2. // x^3 x^5 x^7 // sin x = x - --- + --- - ---- + ... // 6 120 5040 // // term(0) = x // term(i) = - term(i-1) * x^2 / ((2*i)*(2*i+1)) decNumberCopy (&cnt, &two); decNumberCopy (&term, &x); decNumberCopy (result, &x); // DECNUMDIGITS+3 terms are enough to achieve the required precision. for (i=0; i= 0 decNumberMultiply (&pi2, &pi, &two, set); // pi2 = 2*pi decNumberMod (&x, &x, &pi2, set); // We now have 0 <= x < 2*pi /*if (decCompare (&x, &pi) >= 0) {*/ decNumberCompare (&cmp, &x, &pi, set); if (!decNumberIsNegative (&cmp)) { // x >= pi decNumberSubtract (&x, &pi2, &x, set); } // We now have 0 <= x < pi decNumberDivide (&pi2, &pi, &two, set); // pi2 = pi/2 /*if (decCompare (&x, &pi2) >= 0) {*/ decNumberCompare (&cmp, &x, &pi2, set); if (!decNumberIsNegative (&cmp)) { // x >= pi/2, so let x = pi-x decNumberSubtract (&x, &pi, &x, set); negate = 1; } // We now have 0 <= x <= pi/2. // x^2 x^4 x^6 // cos x = 1 - --- + --- - --- + ... // 2 24 720 // // term(0) = 1 // term(i) = - term(i-1) * x^2 / ((2*i-1)*(2*i)) decNumberCopy (&cnt, &one); decNumberCopy (&term, &one); decNumberCopy (result, &one); // DECNUMDIGITS+3 terms are enough to achieve the required precision. for (i=0; i/include/dfp/ libdfp-1.0.12/dfp/decimal/000077500000000000000000000000001261375163000152065ustar00rootroot00000000000000libdfp-1.0.12/dfp/decimal/decimal000066400000000000000000000166101261375163000165330ustar00rootroot00000000000000/* for libdfp and redirect to system Copyright (C) 2011-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _LIBDFP_DECIMAL_H #define _LIBDFP_DECIMAL_H 1 #ifdef _GLIBCXX_DECIMAL_IMPL # error "dfp/ should be #included before the system header." #endif #ifdef __cplusplus /* This needs to be declared before #include_next so that * _Decimal types are declared when the system pulls in * other headers which are overloaded by libdfp, e.g., wchar.h. */ #include /* Pick up _Decimal[32|64|128] typedefs. */ /* Pick up the system . Since C++ DFP support is currently only a * technical report the decimal header is in the non-default search path so * must be used. */ #include_next using namespace std::decimal; #pragma GCC system_header #include using std::ostream; #include using std::istream; #include using std::string; #include using namespace std; #include /* Pick up the strtod[32|64|128] prototypes. */ #include /* Pick up the sprintf prototype. */ #include /* For CHAR_MAX. */ #include /* For memset. */ template struct FIND_DEC_MANT_DIG { enum {RESULT = 0}; static inline std::string get_fmt(char conv) { std::string spec = ""; return spec; } }; template <> struct FIND_DEC_MANT_DIG<4> { enum {RESULT = (__DEC32_MANT_DIG__) }; static inline std::string get_fmt(char conv) { std::string spec = "H"; return spec.append(1,conv); } }; template <> struct FIND_DEC_MANT_DIG<8> { enum {RESULT = (__DEC64_MANT_DIG__) }; static inline std::string get_fmt(char conv) { std::string spec = "D"; return spec.append(1,conv); } }; template <> struct FIND_DEC_MANT_DIG<16> { enum {RESULT = (__DEC128_MANT_DIG__) }; static inline std::string get_fmt(char conv) { std::string spec = "DD"; return spec.append(1,conv); } }; /* Template meta-programming so we only have to write this code once for use * with each of the _Decimal[32|64|128] types. */ template class LIBDFP_META { private: public: static inline ostream & decimal_to_string(std::ostream &os, decimal_type &d) { /* If strbuf is big enough for a _Decimal128, it is big enough for the * other types as well, so just use the same size for all of them. * 1 (leading zero) * + 1 (.) * + 34 (__DEC128_MANT_DIG__) * + 1 (e) * + 1 (+/-) * + 4 (digits in __DEC128_MAX_EXP__) * + 1 "\n" * = 43 -> round up to a power of 2 = 64. */ char strbuf[64]; ios_base::fmtflags flags = os.flags(); unsigned int precision = os.precision(); /* Anything over DEC_MANT_DIG can't be represented anyway. */ if (precision > DEC_MANT_DIG) precision = DEC_MANT_DIG; char conv = 'g'; std::string fmtstr = "%"; /* A strict reading of the draft DFP C++ spec indicates that a/A conv specifier can't be accompanied by a precision specifier. */ if (flags & ios::fixed && flags & ios::scientific) conv = flags & ios::uppercase ? 'A' : 'a'; else { if (flags & ios::fixed) /* Only used for "NAN" and "INF" rather than "nan" and "inf" for * "%.*Df". */ conv = flags & ios::uppercase ? 'F' : 'f'; else if (flags & ios::scientific) conv = flags & ios::uppercase ? 'E' : 'e'; else if (flags & ios::uppercase) conv = 'G'; fmtstr.append(".*"); } /* Get the conv spec and length modifier based on size of the type. */ fmtstr.append(FIND_DEC_MANT_DIG<(sizeof(decimal_type))>::get_fmt(conv)); /* Per the confusing reading of the draft DFP C++ Specification, a/A type are never passed with an accompanying precision. This causes the implicit precision in the type to be used for printing. */ if (flags & ios::fixed && flags & ios::scientific) sprintf (strbuf, fmtstr.c_str(), d.__getval()); else sprintf (strbuf, fmtstr.c_str(), precision, d.__getval()); os << strbuf; return os; } enum {DEC_MANT_DIG = FIND_DEC_MANT_DIG<(sizeof(decimal_type))>::RESULT}; }; /* Per ISO/IEC JTC1 SC22 WG21 N2732 - TR 24733: "Extension for the programming * language C++ to support decimal floating point arithmetic" define the * ostream and istream operators. These are included in libdfp and NOT * libstdc++ because the ostream and istream operators rely upon libdfp * printf and strtod[32|64|128] support provided by libdfp. */ namespace std { namespace decimal { //ISO/IEC TR 24733 - 3.2.11 Formatted output: template inline std::basic_ostream & operator<<(std::basic_ostream & os, decimal32 d) { LIBDFP_META::decimal_to_string(os, d); return os; } template inline std::basic_ostream & operator<<(std::basic_ostream & os, decimal64 d) { LIBDFP_META::decimal_to_string(os, d); return os; } template inline std::basic_ostream & operator<<(std::basic_ostream & os, decimal128 d) { LIBDFP_META::decimal_to_string(os, d); return os; } // ISO/IEC TR 27433 - 3.2.11 Formatted input: template inline std::basic_istream & operator>>(std::basic_istream & is, decimal32 & d) { char buf[CHAR_MAX]; memset(buf, '\0', CHAR_MAX); is.read(buf,CHAR_MAX); d.__setval(strtod32(buf, NULL)); return is; } template inline std::basic_istream & operator>>(std::basic_istream & is, decimal64 & d) { char buf[CHAR_MAX]; memset(buf, '\0', CHAR_MAX); is.read(buf,CHAR_MAX); d.__setval(strtod64(buf, NULL)); return is; } template inline std::basic_istream & operator>>(std::basic_istream & is, decimal128 & d) { char buf[CHAR_MAX]; memset(buf, '\0', CHAR_MAX); is.read(buf,CHAR_MAX); d.__setval(strtod128(buf, NULL)); return is; } } /* namespace decimal */ } /* namespace std */ #else # warning "dfp/ should only be #included by C++ programs." #endif /* __cplusplus */ #endif /* _LIBDFP_DECIMAL_H */ libdfp-1.0.12/dfp/fenv.h000066400000000000000000000046061261375163000147250ustar00rootroot00000000000000/* fenv.h for libdfp and redirect to system fenv.h. Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DFP_FENV_H #define _DFP_FENV_H 1 /* #ifdef _FENV_H # error "dfp/ should be included before the system fenv.h." #endif */ #ifdef __STDC_WANT_DEC_FP__ #include /* Power6[x] chips support all five of the defined rounding modes [and then * some]. We use the bit pattern in the Power6[x] FPSCR as the values for the * appropriate macros. In order to map these to decNumber rounding modes a * conversion will have to take place. */ enum { /* Corresponds to DEC_ROUND_* */ FE_DEC_TONEAREST, /* DEC_ROUND_HALF_EVEN : 3 */ #define FE_DEC_TONEAREST FE_DEC_TONEAREST FE_DEC_TOWARDZERO, /* DEC_ROUND_DOWN : 5 */ #define FE_DEC_TOWARDZERO FE_DEC_TOWARDZERO FE_DEC_UPWARD, /* DEC_ROUND_CEILING : 0 */ #define FE_DEC_UPWARD FE_DEC_UPWARD FE_DEC_DOWNWARD, /* DEC_ROUND_FLOOR : 6 */ #define FE_DEC_DOWNWARD FE_DEC_DOWNWARD FE_DEC_TONEARESTFROMZERO, /* DEC_ROUND_HALF_UP : 2 */ #define FE_DEC_TONEARESTFROMZERO FE_DEC_TONEARESTFROMZERO }; __BEGIN_DECLS /* Establish the rounding direction for decimal floating point operations */ extern int fe_dec_setround(int __rounding_direction) __THROW; /* Get current decimal floating point rounding direction. */ extern int fe_dec_getround(void) __THROW; __END_DECLS #endif /* __STDC_WANT_DEC_FP__ */ #endif /* _DFP_FENV_H */ /* Pick up the system fenv.h. */ #include_next libdfp-1.0.12/dfp/float.h000066400000000000000000000042231261375163000150670ustar00rootroot00000000000000/* for libdfp and redirect to system Copyright (C) 2011-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ /* This uses a bit of circular including in order to get std::decimal defined. * without error such that we can typedef _Decimal types to decimal types. */ #include_next #ifndef _LIBDFP_FLOAT_H #define _LIBDFP_FLOAT_H 1 #pragma GCC system_header #ifdef __cplusplus /* If _Decimal64 is defined we don't need to do any of this. */ #ifndef _Decimal64 /* Per ISO/IEC TR 24733 the following typedefs SHOULD be defined in float.h * * typedef std::decimal::decimal32 _Decimal32; * typedef std::decimal::decimal64 _Decimal64; * typedef std::decimal::decimal128 _Decimal128; * * Depending on the compiler version they may NOT be, so we'll define them * as a service if they are not defined in the system float.h. */ /* Because of how these are declared in the system decimal/decimal header the * declarations specified by the TR don't work. We need to define these in * the same way decimal/decimal does for compatibility. */ typedef float _Decimal32 __attribute__((mode(SD))); typedef float _Decimal64 __attribute__((mode(DD))); typedef float _Decimal128 __attribute__((mode(TD))); #endif /* _Decimal64 */ #endif /* __cplusplus */ #endif /* _LIBDFP_FLOAT_H */ libdfp-1.0.12/dfp/math.h000066400000000000000000001233621261375163000147210ustar00rootroot00000000000000/* math.h for libdfp and redirect to system math.h. This also replaces the system math.h classification macros. Copyright (C) 2006 IBM Corporation. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DFP_MATH_H #define _DFP_MATH_H 1 #ifdef _MATH_H # error "dfp/ should be included before the system math.h." #endif /* Include the system math.h first so that we can undef and redefine the * classification functions to select for _Decimal[32|64|128] types. */ #include_next /* Include this after the #include_next so that if the user has * -I//include/dfp/ on their compilation line but doesn't define * __STDC_WANT_DEC_FPP that they still get the system math.h. */ #ifdef __STDC_WANT_DEC_FP__ #include __BEGIN_DECLS #define DEC_INFINITY __builtin_infd32() #define DEC_NAN __builtin_nand32("") #define HUGE_VAL_D32 __builtin_infd32() #define HUGE_VAL_D64 __builtin_infd64() #define HUGE_VAL_D128 __builtin_infd128() /* This method works for both the GCC and the XLC compilers for detecting * whether a value is a Decimal Floating Point type. */ #define __dfp_compatible(X) ((_Decimal128)(__typeof__(X))1.E-50DL == 1.E-50DL) /* Some useful constants for DFP support (with the DL specifier). Proper * truncation to DD and DF will be handled by GCC. */ # define M_Edl 2.7182818284590452353602874713526625DL /* e */ # define M_LOG2Edl 1.4426950408889634073599246810018921DL /* log_2 e */ # define M_LOG10Edl 0.4342944819032518276511289189166051DL /* log_10 e */ # define M_LN2dl 0.6931471805599453094172321214581766DL /* log_e 2 */ # define M_LN10dl 2.3025850929940456840179914546843642DL /* log_e 10 */ # define M_PIdl 3.1415926535897932384626433832795029DL /* pi */ # define M_PI_2dl 1.5707963267948966192313216916397514DL /* pi/2 */ # define M_PI_4dl 0.7853981633974483096156608458198757DL /* pi/4 */ # define M_1_PIdl 0.3183098861837906715377675267450287DL /* 1/pi */ # define M_2_PIdl 0.6366197723675813430755350534900574DL /* 2/pi */ # define M_2_SQRTPIdl 1.1283791670955125738961589031215452DL /* 2/sqrt(pi) */ # define M_SQRT2dl 1.4142135623730950488016887242096981DL /* sqrt(2) */ # define M_SQRT1_2dl 0.7071067811865475244008443621048490DL /* 1/sqrt(2) */ /* We need the definition of _Bool. */ #include #ifndef FP_LLOGB0 # define FP_LLOGB0 LONG_MIN+1 #endif #ifndef FP_LLOGBNAN # define FP_LLOGBNAN LONG_MAX #endif extern _Decimal32 acosd32 (_Decimal32 __x) __THROW; extern _Decimal32 __acosd32 (_Decimal32 __x) __THROW; extern _Decimal32 asind32 (_Decimal32 __x) __THROW; extern _Decimal32 __asind32 (_Decimal32 __x) __THROW; extern _Decimal32 atand32 (_Decimal32 __x) __THROW; extern _Decimal32 __atand32 (_Decimal32 __x) __THROW; extern _Decimal32 atan2d32 (_Decimal32 __y, _Decimal32 __x) __THROW; extern _Decimal32 __atan2d32 (_Decimal32 __y, _Decimal32 __x) __THROW; extern _Decimal32 cosd32 (_Decimal32 __x) __THROW; extern _Decimal32 __cosd32 (_Decimal32 __x) __THROW; extern _Decimal32 sind32 (_Decimal32 __x) __THROW; extern _Decimal32 __sind32 (_Decimal32 __x) __THROW; extern _Decimal32 tand32 (_Decimal32 __x) __THROW; extern _Decimal32 __tand32 (_Decimal32 __x) __THROW; extern _Decimal32 coshd32 (_Decimal32 __x) __THROW; extern _Decimal32 __coshd32 (_Decimal32 __x) __THROW; extern _Decimal32 sinhd32 (_Decimal32 __x) __THROW; extern _Decimal32 __sinhd32 (_Decimal32 __x) __THROW; extern _Decimal32 tanhd32 (_Decimal32 __x) __THROW; extern _Decimal32 __tanhd32 (_Decimal32 __x) __THROW; extern _Decimal32 acoshd32 (_Decimal32 __x) __THROW; extern _Decimal32 __acoshd32 (_Decimal32 __x) __THROW; extern _Decimal32 asinhd32 (_Decimal32 __x) __THROW; extern _Decimal32 __asinhd32 (_Decimal32 __x) __THROW; extern _Decimal32 atanhd32 (_Decimal32 __x) __THROW; extern _Decimal32 __atanhd32 (_Decimal32 __x) __THROW; extern _Decimal32 expd32 (_Decimal32 __x) __THROW; extern _Decimal32 __expd32 (_Decimal32 __x) __THROW; extern _Decimal32 frexpd32 (_Decimal32 __x, int *__exponent) __THROW; extern _Decimal32 __frexpd32 (_Decimal32 __x, int *__exponent) __THROW; extern _Decimal32 ldexpd32 (_Decimal32 __x, int __exponent) __THROW; extern _Decimal32 __ldexpd32 (_Decimal32 __x, int __exponent) __THROW; extern _Decimal32 logd32 (_Decimal32 __x) __THROW; extern _Decimal32 __logd32 (_Decimal32 __x) __THROW; extern _Decimal32 log10d32 (_Decimal32 __x) __THROW; extern _Decimal32 __log10d32 (_Decimal32 __x) __THROW; extern _Decimal32 modfd32 (_Decimal32 __x, _Decimal32 *__iptr) __THROW; extern _Decimal32 __modfd32 (_Decimal32 __x, _Decimal32 *__iptr) __THROW; extern _Decimal32 expm1d32 (_Decimal32 __x) __THROW; extern _Decimal32 __expm1d32 (_Decimal32 __x) __THROW; extern _Decimal32 log1pd32 (_Decimal32 __x) __THROW; extern _Decimal32 __log1pd32 (_Decimal32 __x) __THROW; extern _Decimal32 logbd32 (_Decimal32 __x) __THROW; extern _Decimal32 __logbd32 (_Decimal32 __x) __THROW; extern _Decimal32 exp2d32 (_Decimal32 __x) __THROW; extern _Decimal32 __exp2d32 (_Decimal32 __x) __THROW; extern _Decimal32 log2d32 (_Decimal32 __x) __THROW; extern _Decimal32 __log2d32 (_Decimal32 __x) __THROW; extern _Decimal32 powd32 (_Decimal32 __x, _Decimal32 __y) __THROW; extern _Decimal32 __powd32 (_Decimal32 __x, _Decimal32 __y) __THROW; extern _Decimal32 sqrtd32 (_Decimal32 __x) __THROW; extern _Decimal32 __sqrtd32 (_Decimal32 __x) __THROW; extern _Decimal32 hypotd32 (_Decimal32 __x, _Decimal32 __y) __THROW; extern _Decimal32 __hypotd32 (_Decimal32 __x, _Decimal32 __y) __THROW; extern _Decimal32 cbrtd32 (_Decimal32 __x) __THROW; extern _Decimal32 __cbrtd32 (_Decimal32 __x) __THROW; extern _Decimal32 ceild32 (_Decimal32 __x) __THROW __attribute__ ((__const__)); extern _Decimal32 __ceild32 (_Decimal32 __x) __THROW __attribute__ ((__const__)); extern _Decimal32 fabsd32 (_Decimal32 __x) __THROW __attribute__ ((__const__)); extern _Decimal32 __fabsd32 (_Decimal32 __x) __THROW __attribute__ ((__const__)); extern _Decimal32 floord32 (_Decimal32 __x) __THROW __attribute__ ((__const__)); extern _Decimal32 __floord32 (_Decimal32 __x) __THROW __attribute__ ((__const__)); extern _Decimal32 fmodd32 (_Decimal32 __x, _Decimal32 __y) __THROW; extern _Decimal32 __fmodd32 (_Decimal32 __x, _Decimal32 __y) __THROW; extern int isinfd32 (_Decimal32 __value) __THROW __attribute__ ((__const__)); extern int __isinfd32 (_Decimal32 __value) __THROW __attribute__ ((__const__)); extern int isfinited32 (_Decimal32 __value) __THROW __attribute__ ((__const__)); extern int __isfinited32 (_Decimal32 __value) __THROW __attribute__ ((__const__)); extern int __issignalingd32 (_Decimal32 __value) __THROW __attribute__ ((__const__)); extern int issignalingd32 (_Decimal32 __value) __THROW __attribute__ ((__const__)); extern int fpclassifyd32 (_Decimal32 __value) __THROW __attribute__ ((__const__)); extern int __fpclassifyd32 (_Decimal32 __value) __THROW __attribute__ ((__const__)); /* Deprecated but older uses of math.h may have invocations of these if they * used the polymorphic finite(). */ extern int finited32 (_Decimal32 __value) __THROW __attribute__ ((__const__)); extern int __finited32 (_Decimal32 __value) __THROW __attribute__ ((__const__)); extern _Decimal32 dremd32 (_Decimal32 __x, _Decimal32 __y) __THROW; extern _Decimal32 __dremd32 (_Decimal32 __x, _Decimal32 __y) __THROW; extern _Decimal32 significandd32 (_Decimal32 __x) __THROW; extern _Decimal32 __significandd32 (_Decimal32 __x) __THROW; extern _Decimal32 copysignd32 (_Decimal32 __x, _Decimal32 __y) __THROW __attribute__ ((__const__)); extern _Decimal32 __copysignd32 (_Decimal32 __x, _Decimal32 __y) __THROW __attribute__ ((__const__)); extern _Decimal32 nand32 (__const char *__tagb) __THROW __attribute__ ((__const__)); extern _Decimal32 __nand32 (__const char *__tagb) __THROW __attribute__ ((__const__)); extern int isnand32 (_Decimal32 __value) __THROW __attribute__ ((__const__)); extern int __isnand32 (_Decimal32 __value) __THROW __attribute__ ((__const__)); extern int isnormald32 (_Decimal32 __value) __THROW __attribute__ ((__const__)); extern int isgreaterd32(_Decimal32 x, _Decimal32 y) __THROW __attribute__ ((__const__)); extern int isgreaterequald32(_Decimal32 x, _Decimal32 y) __THROW __attribute__ ((__const__)); extern int islessd32(_Decimal32 x, _Decimal32 y) __THROW __attribute__ ((__const__)); extern int islessequald32(_Decimal32 x, _Decimal32 y) __THROW __attribute__ ((__const__)); extern int islessgreaterd32(_Decimal32 x, _Decimal32 y) __THROW __attribute__ ((__const__)); extern int isunorderedd32 (_Decimal32 x, _Decimal32 y) __THROW __attribute__ ((__const__)); extern int __signbitd32 (_Decimal32 __value) __THROW __attribute__ ((__const__)); extern _Decimal32 j0d32 (_Decimal32) __THROW; extern _Decimal32 __j0d32 (_Decimal32) __THROW; extern _Decimal32 j1d32 (_Decimal32) __THROW; extern _Decimal32 __j1d32 (_Decimal32) __THROW; extern _Decimal32 jnd32 (int, _Decimal32) __THROW; extern _Decimal32 __jnd32 (int, _Decimal32) __THROW; extern _Decimal32 y0d32 (_Decimal32) __THROW; extern _Decimal32 __y0d32 (_Decimal32) __THROW; extern _Decimal32 y1d32 (_Decimal32) __THROW; extern _Decimal32 __y1d32 (_Decimal32) __THROW; extern _Decimal32 ynd32 (int, _Decimal32) __THROW; extern _Decimal32 __ynd32 (int, _Decimal32) __THROW; extern _Decimal32 erfd32 (_Decimal32) __THROW; extern _Decimal32 __erfd32 (_Decimal32) __THROW; extern _Decimal32 erfcd32 (_Decimal32) __THROW; extern _Decimal32 __erfcd32 (_Decimal32) __THROW; extern _Decimal32 lgammad32 (_Decimal32) __THROW; extern _Decimal32 __lgammad32 (_Decimal32) __THROW; extern _Decimal32 tgammad32 (_Decimal32) __THROW; extern _Decimal32 __tgammad32 (_Decimal32) __THROW; extern _Decimal32 gammad32 (_Decimal32) __THROW; extern _Decimal32 __gammad32 (_Decimal32) __THROW; extern _Decimal32 lgammad32_r (_Decimal32, int *__signgamp) __THROW; extern _Decimal32 __lgammad32_r (_Decimal32, int *__signgamp) __THROW; extern _Decimal32 rintd32 (_Decimal32 __x) __THROW; extern _Decimal32 __rintd32 (_Decimal32 __x) __THROW; extern _Decimal32 nextafterd32 (_Decimal32 __x, _Decimal32 __y) __THROW __attribute__ ((__const__)); extern _Decimal32 __nextafterd32 (_Decimal32 __x, _Decimal32 __y) __THROW __attribute__ ((__const__)); extern _Decimal32 nexttowardd32 (_Decimal32 __x, _Decimal128 __y) __THROW __attribute__ ((__const__)); extern _Decimal32 __nexttowardd32 (_Decimal32 __x, _Decimal128 __y) __THROW __attribute__ ((__const__)); extern _Decimal32 remainderd32 (_Decimal32 __x, _Decimal32 __y) __THROW; extern _Decimal32 __remainderd32 (_Decimal32 __x, _Decimal32 __y) __THROW; extern _Decimal32 scalbnd32 (_Decimal32 __x, int __n) __THROW; extern _Decimal32 __scalbnd32 (_Decimal32 __x, int __n) __THROW; extern int ilogbd32 (_Decimal32 __x) __THROW; extern int __ilogbd32 (_Decimal32 __x) __THROW; extern long int llogbd32 (_Decimal32 __x) __THROW; extern long int __llogbd32 (_Decimal32 __x) __THROW; extern long long int llquantexpd32 (_Decimal32 x) __THROW; extern long long int __llquantexpd32 (_Decimal32 x) __THROW; extern _Decimal32 scalblnd32 (_Decimal32 __x, long int __n) __THROW; extern _Decimal32 __scalblnd32 (_Decimal32 __x, long int __n) __THROW; extern _Decimal32 nearbyintd32 (_Decimal32 __x) __THROW; extern _Decimal32 __nearbyintd32 (_Decimal32 __x) __THROW; extern _Decimal32 roundd32 (_Decimal32 __x) __THROW __attribute__ ((__const__)); extern _Decimal32 __roundd32 (_Decimal32 __x) __THROW __attribute__ ((__const__)); extern _Decimal32 roundevend32 (_Decimal32 __x) __THROW __attribute__ ((__const__)); extern _Decimal32 __roundevend32 (_Decimal32 __x) __THROW __attribute__ ((__const__)); extern _Decimal32 truncd32 (_Decimal32 __x) __THROW __attribute__ ((__const__)); extern _Decimal32 __truncd32 (_Decimal32 __x) __THROW __attribute__ ((__const__)); extern _Decimal32 remquod32 (_Decimal32 __x, _Decimal32 __y, int *__quo) __THROW; extern _Decimal32 __remquod32 (_Decimal32 __x, _Decimal32 __y, int *__quo) __THROW; extern long int lrintd32 (_Decimal32 __x) __THROW; extern long int __lrintd32 (_Decimal32 __x) __THROW; extern long long int llrintd32 (_Decimal32 __x) __THROW; extern long long int __llrintd32 (_Decimal32 __x) __THROW; extern long int lroundd32 (_Decimal32 __x) __THROW; extern long int __lroundd32 (_Decimal32 __x) __THROW; extern long long int llroundd32 (_Decimal32 __x) __THROW; extern long long int __llroundd32 (_Decimal32 __x) __THROW; extern _Decimal32 fdimd32 (_Decimal32 __x, _Decimal32 __y) __THROW; extern _Decimal32 __fdimd32 (_Decimal32 __x, _Decimal32 __y) __THROW; extern _Decimal32 fmaxd32 (_Decimal32 __x, _Decimal32 __y) __THROW; extern _Decimal32 __fmaxd32 (_Decimal32 __x, _Decimal32 __y) __THROW; extern _Decimal32 fmind32 (_Decimal32 __x, _Decimal32 __y) __THROW; extern _Decimal32 __fmind32 (_Decimal32 __x, _Decimal32 __y) __THROW; extern _Decimal32 fmad32 (_Decimal32 __x, _Decimal32 __y, _Decimal32 __z) __THROW; extern _Decimal32 __fmad32 (_Decimal32 __x, _Decimal32 __y, _Decimal32 __z) __THROW; extern _Decimal32 scalbd32 (_Decimal32 __x, _Decimal32 __n) __THROW; extern _Decimal32 __scalbd32 (_Decimal32 __x, _Decimal32 __n) __THROW; extern _Decimal32 quantized32 (_Decimal32 __x, _Decimal32 __y) __THROW; extern _Decimal32 __quantized32 (_Decimal32 __x, _Decimal32 __y) __THROW; extern _Decimal32 quantumd32 (_Decimal32 __x) __THROW; extern _Decimal32 __quantumd32 (_Decimal32 __x) __THROW; extern _Bool samequantumd32 (_Decimal32 __x, _Decimal32 __y) __THROW; extern _Bool __samequantumd32 (_Decimal32 __x, _Decimal32 __y) __THROW; extern _Decimal64 acosd64 (_Decimal64 __x) __THROW; extern _Decimal64 __acosd64 (_Decimal64 __x) __THROW; extern _Decimal64 asind64 (_Decimal64 __x) __THROW; extern _Decimal64 __asind64 (_Decimal64 __x) __THROW; extern _Decimal64 atand64 (_Decimal64 __x) __THROW; extern _Decimal64 __atand64 (_Decimal64 __x) __THROW; extern _Decimal64 atan2d64 (_Decimal64 __y, _Decimal64 __x) __THROW; extern _Decimal64 __atan2d64 (_Decimal64 __y, _Decimal64 __x) __THROW; extern _Decimal64 cosd64 (_Decimal64 __x) __THROW; extern _Decimal64 __cosd64 (_Decimal64 __x) __THROW; extern _Decimal64 sind64 (_Decimal64 __x) __THROW; extern _Decimal64 __sind64 (_Decimal64 __x) __THROW; extern _Decimal64 tand64 (_Decimal64 __x) __THROW; extern _Decimal64 __tand64 (_Decimal64 __x) __THROW; extern _Decimal64 coshd64 (_Decimal64 __x) __THROW; extern _Decimal64 __coshd64 (_Decimal64 __x) __THROW; extern _Decimal64 sinhd64 (_Decimal64 __x) __THROW; extern _Decimal64 __sinhd64 (_Decimal64 __x) __THROW; extern _Decimal64 tanhd64 (_Decimal64 __x) __THROW; extern _Decimal64 __tanhd64 (_Decimal64 __x) __THROW; extern _Decimal64 acoshd64 (_Decimal64 __x) __THROW; extern _Decimal64 __acoshd64 (_Decimal64 __x) __THROW; extern _Decimal64 asinhd64 (_Decimal64 __x) __THROW; extern _Decimal64 __asinhd64 (_Decimal64 __x) __THROW; extern _Decimal64 atanhd64 (_Decimal64 __x) __THROW; extern _Decimal64 __atanhd64 (_Decimal64 __x) __THROW; extern _Decimal64 expd64 (_Decimal64 __x) __THROW; extern _Decimal64 __expd64 (_Decimal64 __x) __THROW; extern _Decimal64 frexpd64 (_Decimal64 __x, int *__exponent) __THROW; extern _Decimal64 __frexpd64 (_Decimal64 __x, int *__exponent) __THROW; extern _Decimal64 ldexpd64 (_Decimal64 __x, int __exponent) __THROW; extern _Decimal64 __ldexpd64 (_Decimal64 __x, int __exponent) __THROW; extern _Decimal64 logd64 (_Decimal64 __x) __THROW; extern _Decimal64 __logd64 (_Decimal64 __x) __THROW; extern _Decimal64 log10d64 (_Decimal64 __x) __THROW; extern _Decimal64 __log10d64 (_Decimal64 __x) __THROW; extern _Decimal64 modfd64 (_Decimal64 __x, _Decimal64 *__iptr) __THROW; extern _Decimal64 __modfd64 (_Decimal64 __x, _Decimal64 *__iptr) __THROW; extern _Decimal64 expm1d64 (_Decimal64 __x) __THROW; extern _Decimal64 __expm1d64 (_Decimal64 __x) __THROW; extern _Decimal64 log1pd64 (_Decimal64 __x) __THROW; extern _Decimal64 __log1pd64 (_Decimal64 __x) __THROW; extern _Decimal64 logbd64 (_Decimal64 __x) __THROW; extern _Decimal64 __logbd64 (_Decimal64 __x) __THROW; extern _Decimal64 exp2d64 (_Decimal64 __x) __THROW; extern _Decimal64 __exp2d64 (_Decimal64 __x) __THROW; extern _Decimal64 log2d64 (_Decimal64 __x) __THROW; extern _Decimal64 __log2d64 (_Decimal64 __x) __THROW; extern _Decimal64 powd64 (_Decimal64 __x, _Decimal64 __y) __THROW; extern _Decimal64 __powd64 (_Decimal64 __x, _Decimal64 __y) __THROW; extern _Decimal64 sqrtd64 (_Decimal64 __x) __THROW; extern _Decimal64 __sqrtd64 (_Decimal64 __x) __THROW; extern _Decimal64 hypotd64 (_Decimal64 __x, _Decimal64 __y) __THROW; extern _Decimal64 __hypotd64 (_Decimal64 __x, _Decimal64 __y) __THROW; extern _Decimal64 cbrtd64 (_Decimal64 __x) __THROW; extern _Decimal64 __cbrtd64 (_Decimal64 __x) __THROW; extern _Decimal64 ceild64 (_Decimal64 __x) __THROW __attribute__ ((__const__)); extern _Decimal64 __ceild64 (_Decimal64 __x) __THROW __attribute__ ((__const__)); extern _Decimal64 fabsd64 (_Decimal64 __x) __THROW __attribute__ ((__const__)); extern _Decimal64 __fabsd64 (_Decimal64 __x) __THROW __attribute__ ((__const__)); extern _Decimal64 floord64 (_Decimal64 __x) __THROW __attribute__ ((__const__)); extern _Decimal64 __floord64 (_Decimal64 __x) __THROW __attribute__ ((__const__)); extern _Decimal64 fmodd64 (_Decimal64 __x, _Decimal64 __y) __THROW; extern _Decimal64 __fmodd64 (_Decimal64 __x, _Decimal64 __y) __THROW; extern int isinfd64 (_Decimal64 __value) __THROW __attribute__ ((__const__)); extern int __isinfd64 (_Decimal64 __value) __THROW __attribute__ ((__const__)); extern int isfinited64 (_Decimal64 __value) __THROW __attribute__ ((__const__)); extern int __isfinited64 (_Decimal64 __value) __THROW __attribute__ ((__const__)); extern int __issignalingd64 (_Decimal64 __value) __THROW __attribute__ ((__const__)); extern int issignalingd64 (_Decimal64 __value) __THROW __attribute__ ((__const__)); extern int fpclassifyd64 (_Decimal64 __value) __THROW __attribute__ ((__const__)); extern int __fpclassifyd64 (_Decimal64 __value) __THROW __attribute__ ((__const__)); /* Deprecated but older uses of math.h may have invocations of these if they * used the polymorphic finite(). */ extern int finited64 (_Decimal64 __value) __THROW __attribute__ ((__const__)); extern int __finited64 (_Decimal64 __value) __THROW __attribute__ ((__const__)); extern _Decimal64 dremd64 (_Decimal64 __x, _Decimal64 __y) __THROW; extern _Decimal64 __dremd64 (_Decimal64 __x, _Decimal64 __y) __THROW; extern _Decimal64 significandd64 (_Decimal64 __x) __THROW; extern _Decimal64 __significandd64 (_Decimal64 __x) __THROW; extern _Decimal64 copysignd64 (_Decimal64 __x, _Decimal64 __y) __THROW __attribute__ ((__const__)); extern _Decimal64 __copysignd64 (_Decimal64 __x, _Decimal64 __y) __THROW __attribute__ ((__const__)); extern _Decimal64 nand64 (__const char *__tagb) __THROW __attribute__ ((__const__)); extern _Decimal64 __nand64 (__const char *__tagb) __THROW __attribute__ ((__const__)); extern int isnand64 (_Decimal64 __value) __THROW __attribute__ ((__const__)); extern int __isnand64 (_Decimal64 __value) __THROW __attribute__ ((__const__)); extern int isnormald64(_Decimal64 __value) __THROW __attribute__ ((__const__)); extern int isgreaterd64(_Decimal64 x, _Decimal64 y) __THROW __attribute__ ((__const__)); extern int isgreaterequald64(_Decimal64 x, _Decimal64 y) __THROW __attribute__ ((__const__)); extern int islessd64(_Decimal64 x, _Decimal64 y) __THROW __attribute__ ((__const__)); extern int islessequald64(_Decimal64 x, _Decimal64 y) __THROW __attribute__ ((__const__)); extern int islessgreaterd64(_Decimal64 x, _Decimal64 y) __THROW __attribute__ ((__const__)); extern int isunorderedd64 (_Decimal64 x, _Decimal64 y) __THROW __attribute__ ((__const__)); extern int __signbitd64 (_Decimal64 __value) __THROW __attribute__ ((__const__)); extern _Decimal64 j0d64 (_Decimal64) __THROW; extern _Decimal64 __j0d64 (_Decimal64) __THROW; extern _Decimal64 j1d64 (_Decimal64) __THROW; extern _Decimal64 __j1d64 (_Decimal64) __THROW; extern _Decimal64 jnd64 (int, _Decimal64) __THROW; extern _Decimal64 __jnd64 (int, _Decimal64) __THROW; extern _Decimal64 y0d64 (_Decimal64) __THROW; extern _Decimal64 __y0d64 (_Decimal64) __THROW; extern _Decimal64 y1d64 (_Decimal64) __THROW; extern _Decimal64 __y1d64 (_Decimal64) __THROW; extern _Decimal64 ynd64 (int, _Decimal64) __THROW; extern _Decimal64 __ynd64 (int, _Decimal64) __THROW; extern _Decimal64 erfd64 (_Decimal64) __THROW; extern _Decimal64 __erfd64 (_Decimal64) __THROW; extern _Decimal64 erfcd64 (_Decimal64) __THROW; extern _Decimal64 __erfcd64 (_Decimal64) __THROW; extern _Decimal64 lgammad64 (_Decimal64) __THROW; extern _Decimal64 __lgammad64 (_Decimal64) __THROW; extern _Decimal64 tgammad64 (_Decimal64) __THROW; extern _Decimal64 __tgammad64 (_Decimal64) __THROW; extern _Decimal64 gammad64 (_Decimal64) __THROW; extern _Decimal64 __gammad64 (_Decimal64) __THROW; extern _Decimal64 lgammad64_r (_Decimal64, int *__signgamp) __THROW; extern _Decimal64 __lgammad64_r (_Decimal64, int *__signgamp) __THROW; extern _Decimal64 rintd64 (_Decimal64 __x) __THROW; extern _Decimal64 __rintd64 (_Decimal64 __x) __THROW; extern _Decimal64 nextafterd64 (_Decimal64 __x, _Decimal64 __y) __THROW __attribute__ ((__const__)); extern _Decimal64 __nextafterd64 (_Decimal64 __x, _Decimal64 __y) __THROW __attribute__ ((__const__)); extern _Decimal64 nexttowardd64 (_Decimal64 __x, _Decimal128 __y) __THROW __attribute__ ((__const__)); extern _Decimal64 __nexttowardd64 (_Decimal64 __x, _Decimal128 __y) __THROW __attribute__ ((__const__)); extern _Decimal64 remainderd64 (_Decimal64 __x, _Decimal64 __y) __THROW; extern _Decimal64 __remainderd64 (_Decimal64 __x, _Decimal64 __y) __THROW; extern _Decimal64 scalbnd64 (_Decimal64 __x, int __n) __THROW; extern _Decimal64 __scalbnd64 (_Decimal64 __x, int __n) __THROW; extern int ilogbd64 (_Decimal64 __x) __THROW; extern int __ilogbd64 (_Decimal64 __x) __THROW; extern long int llogbd64 (_Decimal64 __x) __THROW; extern long int __llogbd64 (_Decimal64 __x) __THROW; extern long long int llquantexpd64 (_Decimal64 x) __THROW; extern long long int __llquantexpd64 (_Decimal64 x) __THROW; extern _Decimal64 scalblnd64 (_Decimal64 __x, long int __n) __THROW; extern _Decimal64 __scalblnd64 (_Decimal64 __x, long int __n) __THROW; extern _Decimal64 nearbyintd64 (_Decimal64 __x) __THROW; extern _Decimal64 __nearbyintd64 (_Decimal64 __x) __THROW; extern _Decimal64 roundd64 (_Decimal64 __x) __THROW __attribute__ ((__const__)); extern _Decimal64 __roundd64 (_Decimal64 __x) __THROW __attribute__ ((__const__)); extern _Decimal64 roundevend64 (_Decimal64 __x) __THROW __attribute__ ((__const__)); extern _Decimal64 __roundevend64 (_Decimal64 __x) __THROW __attribute__ ((__const__)); extern _Decimal64 truncd64 (_Decimal64 __x) __THROW __attribute__ ((__const__)); extern _Decimal64 __truncd64 (_Decimal64 __x) __THROW __attribute__ ((__const__)); extern _Decimal64 remquod64 (_Decimal64 __x, _Decimal64 __y, int *__quo) __THROW; extern _Decimal64 __remquod64 (_Decimal64 __x, _Decimal64 __y, int *__quo) __THROW; extern long int lrintd64 (_Decimal64 __x) __THROW; extern long int __lrintd64 (_Decimal64 __x) __THROW; extern long long int llrintd64 (_Decimal64 __x) __THROW; extern long long int __llrintd64 (_Decimal64 __x) __THROW; extern long int lroundd64 (_Decimal64 __x) __THROW; extern long int __lroundd64 (_Decimal64 __x) __THROW; extern long long int llroundd64 (_Decimal64 __x) __THROW; extern long long int __llroundd64 (_Decimal64 __x) __THROW; extern _Decimal64 fdimd64 (_Decimal64 __x, _Decimal64 __y) __THROW; extern _Decimal64 __fdimd64 (_Decimal64 __x, _Decimal64 __y) __THROW; extern _Decimal64 fmaxd64 (_Decimal64 __x, _Decimal64 __y) __THROW; extern _Decimal64 __fmaxd64 (_Decimal64 __x, _Decimal64 __y) __THROW; extern _Decimal64 fmind64 (_Decimal64 __x, _Decimal64 __y) __THROW; extern _Decimal64 __fmind64 (_Decimal64 __x, _Decimal64 __y) __THROW; extern _Decimal64 fmad64 (_Decimal64 __x, _Decimal64 __y, _Decimal64 __z) __THROW; extern _Decimal64 __fmad64 (_Decimal64 __x, _Decimal64 __y, _Decimal64 __z) __THROW; extern _Decimal64 scalbd64 (_Decimal64 __x, _Decimal64 __n) __THROW; extern _Decimal64 __scalbd64 (_Decimal64 __x, _Decimal64 __n) __THROW; extern _Decimal64 quantized64 (_Decimal64 __x, _Decimal64 __y) __THROW; extern _Decimal64 __quantized64 (_Decimal64 __x, _Decimal64 __y) __THROW; extern _Decimal64 quantumd64 (_Decimal64 __x) __THROW; extern _Decimal64 __quantumd64 (_Decimal64 __x) __THROW; extern _Bool samequantumd64 (_Decimal64 __x, _Decimal64 __y) __THROW; extern _Bool __samequantumd64 (_Decimal64 __x, _Decimal64 __y) __THROW; extern _Decimal128 acosd128 (_Decimal128 __x) __THROW; extern _Decimal128 __acosd128 (_Decimal128 __x) __THROW; extern _Decimal128 asind128 (_Decimal128 __x) __THROW; extern _Decimal128 __asind128 (_Decimal128 __x) __THROW; extern _Decimal128 atand128 (_Decimal128 __x) __THROW; extern _Decimal128 __atand128 (_Decimal128 __x) __THROW; extern _Decimal128 atan2d128 (_Decimal128 __y, _Decimal128 __x) __THROW; extern _Decimal128 __atan2d128 (_Decimal128 __y, _Decimal128 __x) __THROW; extern _Decimal128 cosd128 (_Decimal128 __x) __THROW; extern _Decimal128 __cosd128 (_Decimal128 __x) __THROW; extern _Decimal128 sind128 (_Decimal128 __x) __THROW; extern _Decimal128 __sind128 (_Decimal128 __x) __THROW; extern _Decimal128 tand128 (_Decimal128 __x) __THROW; extern _Decimal128 __tand128 (_Decimal128 __x) __THROW; extern _Decimal128 coshd128 (_Decimal128 __x) __THROW; extern _Decimal128 __coshd128 (_Decimal128 __x) __THROW; extern _Decimal128 sinhd128 (_Decimal128 __x) __THROW; extern _Decimal128 __sinhd128 (_Decimal128 __x) __THROW; extern _Decimal128 tanhd128 (_Decimal128 __x) __THROW; extern _Decimal128 __tanhd128 (_Decimal128 __x) __THROW; extern _Decimal128 acoshd128 (_Decimal128 __x) __THROW; extern _Decimal128 __acoshd128 (_Decimal128 __x) __THROW; extern _Decimal128 asinhd128 (_Decimal128 __x) __THROW; extern _Decimal128 __asinhd128 (_Decimal128 __x) __THROW; extern _Decimal128 atanhd128 (_Decimal128 __x) __THROW; extern _Decimal128 __atanhd128 (_Decimal128 __x) __THROW; extern _Decimal128 expd128 (_Decimal128 __x) __THROW; extern _Decimal128 __expd128 (_Decimal128 __x) __THROW; extern _Decimal128 frexpd128 (_Decimal128 __x, int *__exponent) __THROW; extern _Decimal128 __frexpd128 (_Decimal128 __x, int *__exponent) __THROW; extern _Decimal128 ldexpd128 (_Decimal128 __x, int __exponent) __THROW; extern _Decimal128 __ldexpd128 (_Decimal128 __x, int __exponent) __THROW; extern _Decimal128 logd128 (_Decimal128 __x) __THROW; extern _Decimal128 __logd128 (_Decimal128 __x) __THROW; extern _Decimal128 log10d128 (_Decimal128 __x) __THROW; extern _Decimal128 __log10d128 (_Decimal128 __x) __THROW; extern _Decimal128 modfd128 (_Decimal128 __x, _Decimal128 *__iptr) __THROW; extern _Decimal128 __modfd128 (_Decimal128 __x, _Decimal128 *__iptr) __THROW; extern _Decimal128 expm1d128 (_Decimal128 __x) __THROW; extern _Decimal128 __expm1d128 (_Decimal128 __x) __THROW; extern _Decimal128 log1pd128 (_Decimal128 __x) __THROW; extern _Decimal128 __log1pd128 (_Decimal128 __x) __THROW; extern _Decimal128 logbd128 (_Decimal128 __x) __THROW; extern _Decimal128 __logbd128 (_Decimal128 __x) __THROW; extern _Decimal128 exp2d128 (_Decimal128 __x) __THROW; extern _Decimal128 __exp2d128 (_Decimal128 __x) __THROW; extern _Decimal128 log2d128 (_Decimal128 __x) __THROW; extern _Decimal128 __log2d128 (_Decimal128 __x) __THROW; extern _Decimal128 powd128 (_Decimal128 __x, _Decimal128 __y) __THROW; extern _Decimal128 __powd128 (_Decimal128 __x, _Decimal128 __y) __THROW; extern _Decimal128 sqrtd128 (_Decimal128 __x) __THROW; extern _Decimal128 __sqrtd128 (_Decimal128 __x) __THROW; extern _Decimal128 hypotd128 (_Decimal128 __x, _Decimal128 __y) __THROW; extern _Decimal128 __hypotd128 (_Decimal128 __x, _Decimal128 __y) __THROW; extern _Decimal128 cbrtd128 (_Decimal128 __x) __THROW; extern _Decimal128 __cbrtd128 (_Decimal128 __x) __THROW; extern _Decimal128 ceild128 (_Decimal128 __x) __THROW __attribute__ ((__const__)); extern _Decimal128 __ceild128 (_Decimal128 __x) __THROW __attribute__ ((__const__)); extern _Decimal128 fabsd128 (_Decimal128 __x) __THROW __attribute__ ((__const__)); extern _Decimal128 __fabsd128 (_Decimal128 __x) __THROW __attribute__ ((__const__)); extern _Decimal128 floord128 (_Decimal128 __x) __THROW __attribute__ ((__const__)); extern _Decimal128 __floord128 (_Decimal128 __x) __THROW __attribute__ ((__const__)); extern _Decimal128 fmodd128 (_Decimal128 __x, _Decimal128 __y) __THROW; extern _Decimal128 __fmodd128 (_Decimal128 __x, _Decimal128 __y) __THROW; extern int isinfd128 (_Decimal128 __value) __THROW __attribute__ ((__const__)); extern int __isinfd128 (_Decimal128 __value) __THROW __attribute__ ((__const__)); extern int isfinited128 (_Decimal128 __value) __THROW __attribute__ ((__const__)); extern int __isfinited128 (_Decimal128 __value) __THROW __attribute__ ((__const__)); extern int __issignalingd128 (_Decimal128 __value) __THROW __attribute__ ((__const__)); extern int issignalingd128 (_Decimal128 __value) __THROW __attribute__ ((__const__)); extern int fpclassifyd128 (_Decimal128 __value) __THROW __attribute__ ((__const__)); extern int __fpclassifyd128 (_Decimal128 __value) __THROW __attribute__ ((__const__)); /* Deprecated but older uses of math.h may have invocations of these if they * used the polymorphic finite(). */ extern int finited128 (_Decimal128 __value) __THROW __attribute__ ((__const__)); extern int __finited128 (_Decimal128 __value) __THROW __attribute__ ((__const__)); extern _Decimal128 dremd128 (_Decimal128 __x, _Decimal128 __y) __THROW; extern _Decimal128 __dremd128 (_Decimal128 __x, _Decimal128 __y) __THROW; extern _Decimal128 significandd128 (_Decimal128 __x) __THROW; extern _Decimal128 __significandd128 (_Decimal128 __x) __THROW; extern _Decimal128 copysignd128 (_Decimal128 __x, _Decimal128 __y) __THROW __attribute__ ((__const__)); extern _Decimal128 __copysignd128 (_Decimal128 __x, _Decimal128 __y) __THROW __attribute__ ((__const__)); extern _Decimal128 nand128 (__const char *__tagb) __THROW __attribute__ ((__const__)); extern _Decimal128 __nand128 (__const char *__tagb) __THROW __attribute__ ((__const__)); extern int isnand128 (_Decimal128 __value) __THROW __attribute__ ((__const__)); extern int __isnand128 (_Decimal128 __value) __THROW __attribute__ ((__const__)); extern int isnormald128 (_Decimal128 __value) __THROW __attribute__ ((__const__)); extern int isgreaterd128(_Decimal128 x, _Decimal128 y) __THROW __attribute__ ((__const__)); extern int isgreaterequald128(_Decimal128 x, _Decimal128 y) __THROW __attribute__ ((__const__)); extern int islessd128(_Decimal128 x, _Decimal128 y) __THROW __attribute__ ((__const__)); extern int islessequald128(_Decimal128 x, _Decimal128 y) __THROW __attribute__ ((__const__)); extern int islessgreaterd128(_Decimal128 x, _Decimal128 y) __THROW __attribute__ ((__const__)); extern int isunorderedd128 (_Decimal128 x, _Decimal128 y) __THROW __attribute__ ((__const__)); extern int __signbitd128 (_Decimal128 __value) __THROW __attribute__ ((__const__)); extern _Decimal128 j0d128 (_Decimal128) __THROW; extern _Decimal128 __j0d128 (_Decimal128) __THROW; extern _Decimal128 j1d128 (_Decimal128) __THROW; extern _Decimal128 __j1d128 (_Decimal128) __THROW; extern _Decimal128 jnd128 (int, _Decimal128) __THROW; extern _Decimal128 __jnd128 (int, _Decimal128) __THROW; extern _Decimal128 y0d128 (_Decimal128) __THROW; extern _Decimal128 __y0d128 (_Decimal128) __THROW; extern _Decimal128 y1d128 (_Decimal128) __THROW; extern _Decimal128 __y1d128 (_Decimal128) __THROW; extern _Decimal128 ynd128 (int, _Decimal128) __THROW; extern _Decimal128 __ynd128 (int, _Decimal128) __THROW; extern _Decimal128 erfd128 (_Decimal128) __THROW; extern _Decimal128 __erfd128 (_Decimal128) __THROW; extern _Decimal128 erfcd128 (_Decimal128) __THROW; extern _Decimal128 __erfcd128 (_Decimal128) __THROW; extern _Decimal128 lgammad128 (_Decimal128) __THROW; extern _Decimal128 __lgammad128 (_Decimal128) __THROW; extern _Decimal128 tgammad128 (_Decimal128) __THROW; extern _Decimal128 __tgammad128 (_Decimal128) __THROW; extern _Decimal128 gammad128 (_Decimal128) __THROW; extern _Decimal128 __gammad128 (_Decimal128) __THROW; extern _Decimal128 lgammad128_r (_Decimal128, int *__signgamp) __THROW; extern _Decimal128 __lgammad128_r (_Decimal128, int *__signgamp) __THROW; extern _Decimal128 rintd128 (_Decimal128 __x) __THROW; extern _Decimal128 __rintd128 (_Decimal128 __x) __THROW; extern _Decimal128 nextafterd128 (_Decimal128 __x, _Decimal128 __y) __THROW __attribute__ ((__const__)); extern _Decimal128 __nextafterd128 (_Decimal128 __x, _Decimal128 __y) __THROW __attribute__ ((__const__)); extern _Decimal128 nexttowardd128 (_Decimal128 __x, _Decimal128 __y) __THROW __attribute__ ((__const__)); extern _Decimal128 __nexttowardd128 (_Decimal128 __x, _Decimal128 __y) __THROW __attribute__ ((__const__)); extern _Decimal128 remainderd128 (_Decimal128 __x, _Decimal128 __y) __THROW; extern _Decimal128 __remainderd128 (_Decimal128 __x, _Decimal128 __y) __THROW; extern _Decimal128 scalbnd128 (_Decimal128 __x, int __n) __THROW; extern _Decimal128 __scalbnd128 (_Decimal128 __x, int __n) __THROW; extern int ilogbd128 (_Decimal128 __x) __THROW; extern int __ilogbd128 (_Decimal128 __x) __THROW; extern long int llogbd128 (_Decimal128 __x) __THROW; extern long int __llogbd128 (_Decimal128 __x) __THROW; extern long long int llquantexpd128 (_Decimal128 x) __THROW; extern long long int __llquantexpd128 (_Decimal128 x) __THROW; extern _Decimal128 scalblnd128 (_Decimal128 __x, long int __n) __THROW; extern _Decimal128 __scalblnd128 (_Decimal128 __x, long int __n) __THROW; extern _Decimal128 nearbyintd128 (_Decimal128 __x) __THROW; extern _Decimal128 __nearbyintd128 (_Decimal128 __x) __THROW; extern _Decimal128 roundd128 (_Decimal128 __x) __THROW __attribute__ ((__const__)); extern _Decimal128 __roundd128 (_Decimal128 __x) __THROW __attribute__ ((__const__)); extern _Decimal128 roundevend128 (_Decimal128 __x) __THROW __attribute__ ((__const__)); extern _Decimal128 __roundevend128 (_Decimal128 __x) __THROW __attribute__ ((__const__)); extern _Decimal128 truncd128 (_Decimal128 __x) __THROW __attribute__ ((__const__)); extern _Decimal128 __truncd128 (_Decimal128 __x) __THROW __attribute__ ((__const__)); extern _Decimal128 remquod128 (_Decimal128 __x, _Decimal128 __y, int *__quo) __THROW; extern _Decimal128 __remquod128 (_Decimal128 __x, _Decimal128 __y, int *__quo) __THROW; extern long int lrintd128 (_Decimal128 __x) __THROW; extern long int __lrintd128 (_Decimal128 __x) __THROW; extern long long int llrintd128 (_Decimal128 __x) __THROW; extern long long int __llrintd128 (_Decimal128 __x) __THROW; extern long int lroundd128 (_Decimal128 __x) __THROW; extern long int __lroundd128 (_Decimal128 __x) __THROW; extern long long int llroundd128 (_Decimal128 __x) __THROW; extern long long int __llroundd128 (_Decimal128 __x) __THROW; extern _Decimal128 fdimd128 (_Decimal128 __x, _Decimal128 __y) __THROW; extern _Decimal128 __fdimd128 (_Decimal128 __x, _Decimal128 __y) __THROW; extern _Decimal128 fmaxd128 (_Decimal128 __x, _Decimal128 __y) __THROW; extern _Decimal128 __fmaxd128 (_Decimal128 __x, _Decimal128 __y) __THROW; extern _Decimal128 fmind128 (_Decimal128 __x, _Decimal128 __y) __THROW; extern _Decimal128 __fmind128 (_Decimal128 __x, _Decimal128 __y) __THROW; extern _Decimal128 fmad128 (_Decimal128 __x, _Decimal128 __y, _Decimal128 __z) __THROW; extern _Decimal128 __fmad128 (_Decimal128 __x, _Decimal128 __y, _Decimal128 __z) __THROW; extern _Decimal128 scalbd128 (_Decimal128 __x, _Decimal128 __n) __THROW; extern _Decimal128 __scalbd128 (_Decimal128 __x, _Decimal128 __n) __THROW; extern _Decimal128 quantized128 (_Decimal128 __x, _Decimal128 __y) __THROW; extern _Decimal128 __quantized128 (_Decimal128 __x, _Decimal128 __y) __THROW; extern _Decimal128 quantumd128 (_Decimal128 __x) __THROW; extern _Decimal128 __quantumd128 (_Decimal128 __x) __THROW; extern _Bool samequantumd128 (_Decimal128 __x, _Decimal128 __y) __THROW; extern _Bool __samequantumd128 (_Decimal128 __x, _Decimal128 __y) __THROW; /* Classification functions. We undefine those defined by the system math.h * so that we can add the _Decimal[32|64|128] types recognition to the macros. */ #ifdef fpclassify # undef fpclassify #endif /* Return number of classification appropriate for X. */ # ifdef __NO_LONG_DOUBLE_MATH # define ____fpclassify(x) \ (sizeof (x) == sizeof (float) ? __fpclassifyf (x) : __fpclassify (x)) # else # define ____fpclassify(x) \ (sizeof (x) == sizeof (float) \ ? __fpclassifyf (x) \ : sizeof (x) == sizeof (double) \ ? __fpclassify (x) : __fpclassifyl (x)) # endif #define fpclassify(x) \ ( \ (!__dfp_compatible(x)? (____fpclassify(x)) : \ (sizeof (x) == sizeof (_Decimal128)? __fpclassifyd128(x): \ (sizeof (x) == sizeof (_Decimal64)? __fpclassifyd64(x): \ __fpclassifyd32(x) \ ) \ ) \ ) \ ) #ifdef signbit # undef signbit #endif /* Return nonzero value if sign of X is negative. */ # ifdef __NO_LONG_DOUBLE_MATH # define ____signbit(x) \ (sizeof (x) == sizeof (float) ? __signbitf (x) : __signbit (x)) # else # define ____signbit(x) \ (sizeof (x) == sizeof (float) \ ? __signbitf (x) \ : sizeof (x) == sizeof (double) \ ? __signbit (x) : __signbitl (x)) # endif #define signbit(x) \ ( \ (!__dfp_compatible(x)? (____signbit(x)) : \ (sizeof (x) == sizeof (_Decimal128)? __signbitd128(x): \ (sizeof (x) == sizeof (_Decimal64)? __signbitd64(x): \ __signbitd32(x) \ ) \ ) \ ) \ ) #ifdef isfinite # undef isfinite #endif /* Return nonzero value if X is not +-Inf or NaN. */ # ifdef __NO_LONG_DOUBLE_MATH # define ____isfinite(x) \ (sizeof (x) == sizeof (float) ? __finitef (x) : __finite (x)) # else # define ____isfinite(x) \ (sizeof (x) == sizeof (float) \ ? __finitef (x) \ : sizeof (x) == sizeof (double) \ ? __finite (x) : __finitel (x)) # endif #define isfinite(x) \ ( \ (!__dfp_compatible(x)? (____isfinite(x)) : \ (sizeof (x) == sizeof (_Decimal128)? __isfinited128(x): \ (sizeof (x) == sizeof (_Decimal64)? __isfinited64(x): \ __isfinited32(x) \ ) \ ) \ ) \ ) /* We redefine this here in-case the math.h inclusion resulted in some * macro expansions. */ #ifdef isnormal # undef isnormal #endif /* Return nonzero value if X is neither zero, subnormal, Inf, nor NaN. */ #define isnormal(x) (fpclassify (x) == FP_NORMAL) #ifdef isinf # undef isinf #endif /* Return nonzero value is X is positive or negative infinity. */ # ifdef __NO_LONG_DOUBLE_MATH # define _____isinf(x) \ (sizeof (x) == sizeof (float) ? __isinff (x) : __isinf (x)) # else # define ____isinf(x) \ (sizeof (x) == sizeof (float) \ ? __isinff (x) \ : sizeof (x) == sizeof (double) \ ? __isinf (x) : __isinfl (x)) # endif #define isinf(x) \ ( \ (!__dfp_compatible(x)? (____isinf(x)) : \ (sizeof (x) == sizeof (_Decimal128)? __isinfd128(x): \ (sizeof (x) == sizeof (_Decimal64)? __isinfd64(x): \ __isinfd32(x) \ ) \ ) \ ) \ ) #ifdef fabs # undef fabs #endif #define fabs(x) \ ( \ (sizeof (x) == sizeof (_Decimal128)? __fabsd128(x): \ (sizeof (x) == sizeof (_Decimal64)? __fabsd64(x): \ __fabsd32(x) \ ) \ ) \ ) #ifdef isnan # undef isnan #endif /* Return nonzero value if X is a NaN. We could use `fpclassify' but we already have this functions `__isnan' and it is faster. */ # ifdef __NO_LONG_DOUBLE_MATH # define ____isnan(x) \ (sizeof (x) == sizeof (float) ? __isnanf (x) : __isnan (x)) # else # define ____isnan(x) \ (sizeof (x) == sizeof (float) \ ? __isnanf (x) \ : sizeof (x) == sizeof (double) \ ? __isnan (x) : __isnanl (x)) # endif #define isnan(x) \ (!__dfp_compatible(x) \ ? (____isnan(x)) \ : (sizeof (x) == sizeof (_Decimal128) \ ? __isnand128(x) \ : (sizeof (x) == sizeof (_Decimal64) \ ? __isnand64(x) \ : __isnand32(x))) \ ) /* Return nonzero value if X is a sNaN. */ #ifdef issignaling # undef issignaling # ifdef __NO_LONG_DOUBLE_MATH # define ____issignaling(x) \ (sizeof (x) == sizeof (float) ? __issignalingf (x) \ : __issignaling (x)) # else # define ____issignaling(x) \ (sizeof (x) == sizeof (float) \ ? __issignalingf (x) \ : sizeof (x) == sizeof (double) \ ? __issignaling (x) : __issignalingl (x)) # endif #else # define ____issignaling(x) x #endif #define issignaling(x) \ (!__dfp_compatible(x) \ ? (____issignaling(x)) \ : (sizeof (x) == sizeof (_Decimal128) \ ? __issignalingd128(x) \ : (sizeof (x) == sizeof (_Decimal64) \ ? __issignalingd64(x) \ : __issignalingd32(x))) \ ) __END_DECLS #endif /* __STDC_WANT_DEC_FP__ */ #endif /* _DFP_MATH_H */ libdfp-1.0.12/dfp/stdlib.h000066400000000000000000000035621261375163000152500ustar00rootroot00000000000000/* stdlib.h for libdfp and redirect to system stdlib.h Copyright (C) 2006 IBM Corporation. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DFP_STDLIB_H #define _DFP_STDLIB_H 1 #ifdef __STDC_WANT_DEC_FP__ #include #include __BEGIN_DECLS /* Convert a string to a _Decimal32 number. */ extern _Decimal32 strtod32 (__const char *__restrict __nptr, char **__restrict __endptr) __THROW __nonnull ((1)) __wur; /* Convert a string to a _Decimal64 number. */ extern _Decimal64 strtod64 (__const char *__restrict __nptr, char **__restrict __endptr) __THROW __nonnull ((1)) __wur; /* Convert a string to a _Decimal128 number. */ extern _Decimal128 strtod128 (__const char *__restrict __nptr, char **__restrict __endptr) __THROW __nonnull ((1)) __wur; __END_DECLS #endif /* __STDC_WANT_DEC_FP__ */ #endif /* _DFP_STDLIB_H */ /* Pick up the system stdlib.h. */ #include_next libdfp-1.0.12/dfp/wchar.h000066400000000000000000000030631261375163000150670ustar00rootroot00000000000000/* wchar.h for libdfp and redirect to system wchar.h. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DFP_WCHAR_H #define _DFP_WCHAR_H 1 #ifdef __STDC_WANT_DEC_FP__ #include #include __BEGIN_DECLS extern _Decimal32 wcstod32 (__const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr) __THROW; extern _Decimal64 wcstod64 (__const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr) __THROW; extern _Decimal128 wcstod128 (__const wchar_t *__restrict __nptr, wchar_t **__restrict __endptr) __THROW; __END_DECLS #endif /* __STDC_WANT_DEC_FP__ */ #endif /* _DFP_WCHAR_H */ /* Pick up the system fenv.h. */ #include_next libdfp-1.0.12/dfptypeconv.c000066400000000000000000000051001261375163000155400ustar00rootroot00000000000000/* DFP_C_TYPE to/from IEEE DFP type conversion routines definitions Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include "dfptypeconv128.h" #include "dfptypeconv64.h" #include "dfptypeconv32.h" #include static inline void __copy32 (uint32_t * src, uint32_t * dst) { #if __BYTE_ORDER == __BIG_ENDIAN *dst = *src; #else *dst = __builtin_bswap32 (*src); #endif } static inline void __copy64 (uint64_t * src, uint64_t * dst) { #if __BYTE_ORDER == __BIG_ENDIAN *dst = *src; #else *dst = __builtin_bswap64 (*src); #endif } static inline void __copy128 (uint64_t * src, uint64_t * dst) { #if __BYTE_ORDER == __BIG_ENDIAN *dst = *src; *(dst + 1) = *(src + 1); #else *dst = __builtin_bswap64 (*(src + 1)); *(dst + 1) = __builtin_bswap64 (*src); #endif } void ___host_to_ieee_32 (_Decimal32 * src, decimal32 * dest) { __copy32 ((uint32_t *) src, (uint32_t *) dest); } void ___host_to_ieee_64 (_Decimal64 * src, decimal64 * dest) { __copy64 ((uint64_t *) src, (uint64_t *) dest); } void ___host_to_ieee_128 (_Decimal128 * src, decimal128 * dest) { __copy128 ((uint64_t *) src, (uint64_t *) dest); } void ___ieee_32_to_host (decimal32 * src, _Decimal32 * dest) { __copy32 ((uint32_t *) src, (uint32_t *) dest); } void ___ieee_64_to_host (decimal64 * src, _Decimal64 * dest) { __copy64 ((uint64_t *) src, (uint64_t *) dest); } void ___ieee_128_to_host (decimal128 * src, _Decimal128 * dest) { __copy128 ((uint64_t *) src, (uint64_t *) dest); } hidden_def (___host_to_ieee_32) hidden_def (___host_to_ieee_64) hidden_def (___host_to_ieee_128) hidden_def (___ieee_32_to_host) hidden_def (___ieee_64_to_host) hidden_def (___ieee_128_to_host) libdfp-1.0.12/dfptypeconv128.h000066400000000000000000000035001261375163000160020ustar00rootroot00000000000000/* DFP_C_TYPE to/from IEEE DFP type conversion routine prototypes Copyright (C) 2006 IBM Corporation. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ /* The decNumber library utilizes the IEEE 754r proposed types of decimal32, decimal64, and decimal128 which are structs of byte arrays. The GLIBC supported types are based upon the ANSI C Standards body WG14 1176 Technical Report and are types _Decimal32, _Decimal64, _Decimal128. This header files provides prototypes for converting to and from both types. */ #ifndef _DFP_TYPE_CONV128_H #define _DFP_TYPE_CONV128_H 1 #include /* These shouldn't be exposed externally. The users shouldn't care about the IEEE 754r types. */ extern void ___host_to_ieee_128 (_Decimal128 *, decimal128 *); extern void ___ieee_128_to_host (decimal128 *, _Decimal128 *); hidden_proto(___host_to_ieee_128) hidden_proto(___ieee_128_to_host) #endif /* _DFP_TYPE_CONV128_H */ libdfp-1.0.12/dfptypeconv32.h000066400000000000000000000034641261375163000157250ustar00rootroot00000000000000/* DFP_C_TYPE to/from IEEE DFP type conversion routine prototypes Copyright (C) 2006 IBM Corporation. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ /* The decNumber library utilizes the IEEE 754r proposed types of decimal32, decimal64, and decimal128 which are structs of byte arrays. The GLIBC supported types are based upon the ANSI C Standards body WG14 1176 Technical Report and are types _Decimal32, _Decimal64, _Decimal128. This header files provides prototypes for converting to and from both types. */ #ifndef _DFP_TYPE_CONV32_H #define _DFP_TYPE_CONV32_H 1 #include /* These shouldn't be exposed externally. The users shouldn't care about the IEEE 754r types. */ extern void ___host_to_ieee_32 (_Decimal32 *, decimal32 *); extern void ___ieee_32_to_host (decimal32 *, _Decimal32 *); hidden_proto(___host_to_ieee_32) hidden_proto(___ieee_32_to_host) #endif /* _DFP_TYPE_CONV32_H */ libdfp-1.0.12/dfptypeconv64.h000066400000000000000000000034641261375163000157320ustar00rootroot00000000000000/* DFP_C_TYPE to/from IEEE DFP type conversion routine prototypes Copyright (C) 2006 IBM Corporation. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ /* The decNumber library utilizes the IEEE 754r proposed types of decimal32, decimal64, and decimal128 which are structs of byte arrays. The GLIBC supported types are based upon the ANSI C Standards body WG14 1176 Technical Report and are types _Decimal32, _Decimal64, _Decimal128. This header files provides prototypes for converting to and from both types. */ #ifndef _DFP_TYPE_CONV64_H #define _DFP_TYPE_CONV64_H 1 #include /* These shouldn't be exposed externally. The users shouldn't care about the IEEE 754r types. */ extern void ___host_to_ieee_64 (_Decimal64 *, decimal64 *); extern void ___ieee_64_to_host (decimal64 *, _Decimal64 *); hidden_proto(___host_to_ieee_64) hidden_proto(___ieee_64_to_host) #endif /* _DFP_TYPE_CONV64_H */ libdfp-1.0.12/fmt_d128.c000066400000000000000000000022221261375163000145250ustar00rootroot00000000000000/* Macroized version of the decimal floatiing point string formatting functions. Copyright (C) 2007 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include #include "fmt_d32.c" libdfp-1.0.12/fmt_d32.c000066400000000000000000000133771261375163000144540ustar00rootroot00000000000000/* Macroized version of the decimal floating point string formatting functions. Copyright (C) 2007 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 /* needed to pick up DECNUMDIGITS before including decNumber.h */ # include # include #endif #include #define FUNCTION_NAME fmt_ #include #include #include #include #include #include /* DECIMAL128_Pmax + 14 (where '14' represents all the extra characters present * in the output string). Defined here so we avoid including . */ #define MAX_DECIMAL128_STRING 48 /* Thirty-five array indices will account for the available number of digits of * precision for a _Decimal128. */ static _Decimal128 powof10 [] = { 1.e0dl, 1.e1dl, 1.e2dl, 1.e3dl, 1.e4dl, 1.e5dl, 1.e6dl, 1.e7dl, 1.e8dl, 1.e9dl, 1.e10dl, 1.e11dl, 1.e12dl, 1.e13dl, 1.e14dl, 1.e15dl, 1.e16dl, 1.e17dl, 1.e18dl, 1.e19dl, 1.e20dl, 1.e21dl, 1.e22dl, 1.e23dl, 1.e24dl, 1.e25dl, 1.e26dl, 1.e27dl, 1.e28dl, 1.e29dl, 1.e30dl, 1.e31dl, 1.e32dl, 1.e33dl, 1.e34dl }; static _Decimal128 negpowof10 [] = { 1.e0dl, 1.e-1dl, 1.e-2dl, 1.e-3dl, 1.e-4dl, 1.e-5dl, 1.e-6dl, 1.e-7dl, 1.e-8dl, 1.e-9dl, 1.e-10dl, 1.e-11dl, 1.e-12dl, 1.e-13dl, 1.e-14dl, 1.e-15dl, 1.e-16dl, 1.e-17dl, 1.e-18dl, 1.e-19dl, 1.e-20dl, 1.e-21dl, 1.e-22dl, 1.e-23dl, 1.e-24dl, 1.e-25dl, 1.e-26dl, 1.e-27dl, 1.e-28dl, 1.e-29dl, 1.e-30dl, 1.e-31dl, 1.e-32dl, 1.e-33dl, 1.e-34dl }; /* Stripped down ldexpd128 without NaN or Infinity detection. */ static _Decimal128 __dfp_printf_ldexpd128 (_Decimal128 x, int y) { if (y == 0) return x; if (y > 0) return (x * (10 * powof10[y])); else return (x * (10 * negpowof10[-(y)])); } static _Decimal128 __dfp_adjust_precision(_Decimal128 x, int prec) { _Decimal128 deconst; _Decimal128 y = x; int powof10 = (34 - prec); if (x==0.0DL || __isnand128(x) || __isinfd128(x)) return x; /* Get a number which, when added to 'x' causes the bits outside of the * desired precision to be outside of the representable number of digits * for a _Decimal128 (i.e. 34 digits). e.g. * 0.01235 with a requested precision of '4' expects 0.0124 * 100000000000000000000000000000.0000|<- precision boundary for _Decimal128 * + 0.01235<- guard digit causes rounding * ----------------------------------- * 100000000000000000000000000000.0124 * - 100000000000000000000000000000.0000 * ----------------------------------- * 0.0124 */ deconst = __dfp_printf_ldexpd128(0.01DL, powof10); if (x<0.0DL) deconst = -(deconst); /* reverse the forthcoming operation. */ /* exceed the number of available digits, the guard digit causes rounding. */ x += deconst; x -= deconst; if (x==0.0DL && y < 0.0DL) return (-0.0DL); /* Explicitly return -0.0 because GCC is too smart. */ return x; } /* slen should be DECIMAL128_Pmax + 14 + info->width + 1 (for '\0') */ char * INTERNAL_FUNCTION_NAME ( const struct printf_info *info, const void *const *args, char * str, int slen) { DEC_TYPE *y = *(DEC_TYPE **)args[0]; DEC_TYPE z; /* Used if we need to adjust the precision. */ char dtos[MAX_DECIMAL128_STRING]; int dtoslen = 0; char * padded = str; /* Used if there is extra width padding necessary. */ if (!str || slen <= 0) return NULL; memset(dtos, 0x0, MAX_DECIMAL128_STRING); /* Overwrite 'z' with a precision adjusted _Decimal[32|64|128] per the printf * format precision flag. */ if (info->prec > 0) z = (DEC_TYPE)__dfp_adjust_precision((DEC_TYPE)*y, info->prec); else z = *y; if (info->spec == 'E' || info->spec == 'e') { IEEE_DECIMAL_TO_ENG_STRING(&z, dtos); } else IEEE_DECIMAL_TO_STRING(&z, dtos); dtoslen = strlen(dtos); /* We don't need to pad if dtoslen exceeds the width flag, or if no width flag * is set. */ if (info->width && (dtoslen < info->width)) { wchar_t pad = ' '; /* default padding */ int padnum; if (info->pad) pad = info->pad; padnum = info->width - dtoslen; /* Justification indicates where padding is placed. */ if (!info->left) { memset(str, pad, padnum); padded = str + padnum; } else memset(str + dtoslen, pad, padnum); /* No need in this case to adjust 'padded' from the beginning of 'str'. */ str[info->width] = 0x0; } else /* Set the null terminator before copying the string. */ str[dtoslen] = 0x0; strncpy(padded, dtos, dtoslen); memset(dtos, 0x0, MAX_DECIMAL128_STRING); return str; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) hidden_def(INTERNAL_FUNCTION_NAME) libdfp-1.0.12/fmt_d64.c000066400000000000000000000022161261375163000144470ustar00rootroot00000000000000/* Macroized version of the decimal floating point string formatting functions. Copyright (C) 2007 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include #include "fmt_d32.c" libdfp-1.0.12/ieee754r/000077500000000000000000000000001261375163000143705ustar00rootroot00000000000000libdfp-1.0.12/ieee754r/Makefile000066400000000000000000000066101261375163000160330ustar00rootroot00000000000000# Copyright (C) 2015 Free Software Foundation, Inc. # # This file is part of the Decimal Floating Point C Library. # # The Decimal Floating Point C Library is free software; you can # redistribute it and/or modify it under the terms of the GNU Lesser # General Public License version 2.1. # # The Decimal Floating Point C Library is distributed in the hope that # it will be useful, but WITHOUT ANY WARRANTY; without even the implied # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See # the GNU Lesser General Public License version 2.1 for more details. # # You should have received a copy of the GNU Lesser General Public # License version 2.1 along with the Decimal Floating Point C Library; # if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA. # # Please see libdfp/COPYING.txt for more information. */ libdfp_files += acosd32 acosd64 acosd128 \ acoshd32 acoshd64 acoshd128 \ asind32 asind64 asind128 \ asinhd32 asinhd64 asinhd128 \ atan2d32 atan2d64 atan2d128 \ atand32 atand64 atand128 \ atanhd32 atanhd64 atanhd128 \ cbrtd32 cbrtd64 cbrtd128 \ ceild32 ceild64 ceild128 \ copysignd32 copysignd64 copysignd128 \ cosd32 cosd64 cosd128 \ coshd32 coshd64 coshd128 \ erfd32 erfd64 erfd128 \ exp2d32 exp2d64 exp2d128 \ expd32 expd64 expd128 \ expm1d32 expm1d64 expm1d128 \ fabsd32 fabsd64 fabsd128 \ fdimd32 fdimd64 fdimd128 \ isfinited32 isfinited64 isfinited128 \ issignalingd32 issignalingd64 issignalingd128 \ floord32 floord64 floord128 \ fmad32 fmad64 fmad128 \ fmaxd32 fmaxd64 fmaxd128 \ fmind32 fmind64 fmind128 \ fmodd32 fmodd64 fmodd128 \ fpclassifyd32 fpclassifyd64 fpclassifyd128 \ frexpd32 frexpd64 frexpd128 \ hypotd32 hypotd64 hypotd128 \ ilogbd32 ilogbd64 ilogbd128 \ llogbd32 llogbd64 llogbd128 \ isgreaterd32 isgreaterd64 isgreaterd128 \ isgreaterequald32 isgreaterequald64 isgreaterequald128 \ isinfd32 isinfd64 isinfd128 \ islessd32 islessd64 islessd128 \ islessequald32 islessequald64 islessequald128 \ islessgreaterd32 islessgreaterd64 islessgreaterd128 \ isnand32 isnand64 isnand128 \ isnormald32 isnormald64 isnormald128 \ isunorderedd32 isunorderedd64 isunorderedd128 \ ldexpd32 ldexpd64 ldexpd128 \ lgammad32 lgammad64 lgammad128 \ llquantexpd32 llquantexpd64 llquantexpd128 \ llrintd32 llrintd64 llrintd128 \ llroundd32 llroundd64 llroundd128 \ log10d32 log10d64 log10d128 \ log1pd32 log1pd64 log1pd128 \ log2d32 log2d64 log2d128 \ logbd32 logbd64 logbd128 \ logd32 logd64 logd128 \ lrintd32 lrintd64 lrintd128 \ lroundd32 lroundd64 lroundd128 \ modfd32 modfd64 modfd128 \ nand32 nand64 nand128 \ nearbyintd32 nearbyintd64 nearbyintd128 \ nextafterd32 nextafterd64 nextafterd128 \ nexttowardd32 nexttowardd64 nexttowardd128 \ powd32 powd64 powd128 \ quantized32 quantized64 quantized128 \ quantumd32 quantumd64 quantumd128 \ remainderd32 remainderd64 remainderd128 \ rintd32 rintd64 rintd128 \ roundd32 roundd64 roundd128 \ roundevend32 roundevend64 roundevend128 \ samequantumd32 samequantumd64 samequantumd128 \ scalblnd32 scalblnd64 scalblnd128 \ scalbnd32 scalbnd64 scalbnd128 \ signbitd32 signbitd64 signbitd128 \ sind32 sind64 sind128 \ sinhd32 sinhd64 sinhd128 \ sqrtd32 sqrtd64 sqrtd128 \ tand32 tand64 tand128 \ tanhd32 tanhd64 tanhd128 \ tgammad32 tgammad64 tgammad128 \ truncd32 truncd64 truncd128 libdfp-1.0.12/ieee754r/Versions000066400000000000000000000101661261375163000161270ustar00rootroot00000000000000libdfp { LIBDFP_1.0.0 { acosd32; acosd64; acosd128; acoshd32; acoshd64; acoshd128; asind32; asind64; asind128; asinhd32; asinhd64; asinhd128; atan2d32; atan2d64; atan2d128; atand32; atand64; atand128; atanhd32; atanhd64; atanhd128; cbrtd32; cbrtd64; cbrtd128; ceild32; ceild64; ceild128; copysignd32; copysignd64; copysignd128; cosd32; cosd64; cosd128; coshd32; coshd64; coshd128; erfd32; erfd64; erfd128; erfcd32; erfcd64; erfcd128; exp2d32; exp2d64; exp2d128; expd32; expd64; expd128; expm1d32; expm1d64; expm1d128; fabsd32; fabsd64; fabsd128; fdimd32; fdimd64; fdimd128; finited32; finited64; finited128; floord32; floord64; floord128; fmad32; fmad64; fmad128; fmaxd32; fmaxd64; fmaxd128; fmind32; fmind64; fmind128; fmodd32; fmodd64; fmodd128; fpclassifyd32; fpclassifyd64; fpclassifyd128; frexpd32; frexpd64; frexpd128; hypotd32; hypotd64; hypotd128; ilogbd32; ilogbd64; ilogbd128; isgreaterd32; isgreaterd64; isgreaterd128; isgreaterequald32; isgreaterequald64; isgreaterequald128; isinfd32; isinfd64; isinfd128; islessd32; islessd64; islessd128; islessequald32; islessequald64; islessequald128; islessgreaterd32; islessgreaterd64; islessgreaterd128; isnand32; isnand64; isnand128; isnormald32; isnormald64; isnormald128; isunorderedd32; isunorderedd64; isunorderedd128; ldexpd32; ldexpd64; ldexpd128; lgammad32; lgammad64; lgammad128; llrintd32; llrintd64; llrintd128; llroundd32; llroundd64; llroundd128; log10d32; log10d64; log10d128; log1pd32; log1pd64; log1pd128; log2d32; log2d64; log2d128; logbd32; logbd64; logbd128; logd32; logd64; logd128; lrintd32; lrintd64; lrintd128; lroundd32; lroundd64; lroundd128; modfd32; modfd64; modfd128; nand32; nand64; nand128; nearbyintd32; nearbyintd64; nearbyintd128; nextafterd32; nextafterd64; nextafterd128; nexttowardd32; nexttowardd64; nexttowardd128; powd32; powd64; powd128; quantized32; quantized64; quantized128; remainderd32; remainderd64; remainderd128; rintd32; rintd64; rintd128; roundd32; roundd64; roundd128; samequantumd32; samequantumd64; samequantumd128; scalblnd32; scalblnd64; scalblnd128; scalbnd32; scalbnd64; scalbnd128; signbitd32; signbitd64; signbitd128; sind32; sind64; sind128; sinhd32; sinhd64; sinhd128; sqrtd32; sqrtd64; sqrtd128; tand32; tand64; tand128; tanhd32; tanhd64; tanhd128; tgammad32; tgammad64; tgammad128; truncd32; truncd64; truncd128; } LIBDFP_1.0.2 { __isnand32; __isnand64; __isnand128; __isinfd32; __isinfd64; __isinfd128; } LIBDFP_1.0.3 { # finited* and friends is deprecated but at some point we published math.h # with polymorphic isfinite() pointing to them so keep them around. They # are just aliases. __finited32; __finited64; __finited128; isfinited32; isfinited64; isfinited128; __isfinited32; __isfinited64; __isfinited128; # Polymorphic signbit support. __signbitd32; __signbitd64; __signbitd128; __fabsd32; __fabsd64; __fabsd128; __fpclassifyd32; __fpclassifyd64; __fpclassifyd128; } LIBDFP_1.0.9 { issignalingd32; __issignalingd32; issignalingd64; __issignalingd64; issignalingd128; __issignalingd128; llogbd32; llogbd64; llogbd128; llquantexpd32; llquantexpd64; llquantexpd128; roundevend32; roundevend64; roundevend128; quantumd32; quantumd64; quantumd128; } } libdfp-1.0.12/ieee754r/acosd128.c000066400000000000000000000021051261375163000160560ustar00rootroot00000000000000/* Calculates the arccos(x) Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "acosd32.c" libdfp-1.0.12/ieee754r/acosd32.c000066400000000000000000000246601261375163000160020ustar00rootroot00000000000000/* Calculates the arccos(x) Copyright (C) 2001 Stephen L. Moshier Copyright (C) 2006 IBM Corporation. Copyright (C) 2001-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 #endif #include #include #include /* Portions of this code are: * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunPro, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. * ==================================================== * * This was adapted for glibc in 2001. * This was adapted for Libdfp in 2006, and those changes donated to the FSF in * 2007. * * __ieee754_acosl(x) * Method : * acos(x) = pi/2 - asin(x) * acos(-x) = pi/2 + asin(x) * For |x| <= 0.375 * acos(x) = pi/2 - asin(x) * Between .375 and .5 the approximation is * acos(0.4375 + x) = acos(0.4375) + x P(x) / Q(x) * Between .5 and .625 the approximation is * acos(0.5625 + x) = acos(0.5625) + x rS(x) / sS(x) * For x > 0.625, * acos(x) = 2 asin(sqrt((1-x)/2)) * computed with an extended precision square root in the leading term. * For x < -0.625 * acos(x) = pi - 2 asin(sqrt((1-|x|)/2)) * * Special cases: * if x is NaN, return x itself; * if |x|>1, return NaN with invalid signal. * * Functions needed: __ieee754_sqrtl. */ #ifdef __STDC__ static const _Decimal128 #else static _Decimal128 #endif one = 1.0DL, pio2_hi = 1.5707963267948966192313216916397514420986DL, pio2_lo = 4.3359050650618905123985220130216759843812E-35DL, /* acos(0.5625 + x) = acos(0.5625) + x rS(x) / sS(x) -0.0625 <= x <= 0.0625 peak relative error 3.3e-35 */ rS0 = 5.619049346208901520945464704848780243887E0DL, rS1 = -4.460504162777731472539175700169871920352E1DL, rS2 = 1.317669505315409261479577040530751477488E2DL, rS3 = -1.626532582423661989632442410808596009227E2DL, rS4 = 3.144806644195158614904369445440583873264E1DL, rS5 = 9.806674443470740708765165604769099559553E1DL, rS6 = -5.708468492052010816555762842394927806920E1DL, rS7 = -1.396540499232262112248553357962639431922E1DL, rS8 = 1.126243289311910363001762058295832610344E1DL, rS9 = 4.956179821329901954211277873774472383512E-1DL, rS10 = -3.313227657082367169241333738391762525780E-1DL, sS0 = -4.645814742084009935700221277307007679325E0DL, sS1 = 3.879074822457694323970438316317961918430E1DL, sS2 = -1.221986588013474694623973554726201001066E2DL, sS3 = 1.658821150347718105012079876756201905822E2DL, sS4 = -4.804379630977558197953176474426239748977E1DL, sS5 = -1.004296417397316948114344573811562952793E2DL, sS6 = 7.530281592861320234941101403870010111138E1DL, sS7 = 1.270735595411673647119592092304357226607E1DL, sS8 = -1.815144839646376500705105967064792930282E1DL, sS9 = -7.821597334910963922204235247786840828217E-2DL, /* 1.000000000000000000000000000000000000000E0 */ acosr5625 = 9.7338991014954640492751132535550279812151E-1DL, pimacosr5625 = 2.1682027434402468335351320579240000860757E0DL, /* acos(0.4375 + x) = acos(0.4375) + x rS(x) / sS(x) -0.0625 <= x <= 0.0625 peak relative error 2.1e-35 */ P0 = 2.177690192235413635229046633751390484892E0DL, P1 = -2.848698225706605746657192566166142909573E1DL, P2 = 1.040076477655245590871244795403659880304E2DL, P3 = -1.400087608918906358323551402881238180553E2DL, P4 = 2.221047917671449176051896400503615543757E1DL, P5 = 9.643714856395587663736110523917499638702E1DL, P6 = -5.158406639829833829027457284942389079196E1DL, P7 = -1.578651828337585944715290382181219741813E1DL, P8 = 1.093632715903802870546857764647931045906E1DL, P9 = 5.448925479898460003048760932274085300103E-1DL, P10 = -3.315886001095605268470690485170092986337E-1DL, Q0 = -1.958219113487162405143608843774587557016E0DL, Q1 = 2.614577866876185080678907676023269360520E1DL, Q2 = -9.990858606464150981009763389881793660938E1DL, Q3 = 1.443958741356995763628660823395334281596E2DL, Q4 = -3.206441012484232867657763518369723873129E1DL, Q5 = -1.048560885341833443564920145642588991492E2DL, Q6 = 6.745883931909770880159915641984874746358E1DL, Q7 = 1.806809656342804436118449982647641392951E1DL, Q8 = -1.770150690652438294290020775359580915464E1DL, Q9 = -5.659156469628629327045433069052560211164E-1DL, /* 1.000000000000000000000000000000000000000E0 */ acosr4375 = 1.1179797320499710475919903296900511518755E0DL, pimacosr4375 = 2.0236129215398221908706530535894517323217E0DL, /* asin(x) = x + x^3 pS(x^2) / qS(x^2) 0 <= x <= 0.5 peak relative error 1.9e-35 */ pS0 = -8.358099012470680544198472400254596543711E2DL, pS1 = 3.674973957689619490312782828051860366493E3DL, pS2 = -6.730729094812979665807581609853656623219E3DL, pS3 = 6.643843795209060298375552684423454077633E3DL, pS4 = -3.817341990928606692235481812252049415993E3DL, pS5 = 1.284635388402653715636722822195716476156E3DL, pS6 = -2.410736125231549204856567737329112037867E2DL, pS7 = 2.219191969382402856557594215833622156220E1DL, pS8 = -7.249056260830627156600112195061001036533E-1DL, pS9 = 1.055923570937755300061509030361395604448E-3DL, qS0 = -5.014859407482408326519083440151745519205E3DL, qS1 = 2.430653047950480068881028451580393430537E4DL, qS2 = -4.997904737193653607449250593976069726962E4DL, qS3 = 5.675712336110456923807959930107347511086E4DL, qS4 = -3.881523118339661268482937768522572588022E4DL, qS5 = 1.634202194895541569749717032234510811216E4DL, qS6 = -4.151452662440709301601820849901296953752E3DL, qS7 = 5.956050864057192019085175976175695342168E2DL, qS8 = -4.175375777334867025769346564600396877176E1DL; /* 1.000000000000000000000000000000000000000E0 */ #include #define FUNCTION_NAME acos #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { _Decimal128 z, r, w, p, q, s, t, f2, ix; int32_t sign; if(isnan(x)) return x+x; sign = (x > 0.0DL)?0:1; ix = FUNC_D(__fabs) (x); if (ix >= 1.0DL) /* |x| >= 1 */ { if (ix == 1.0DL) { /* |x| == 1 */ if (sign == 0) return (DEC_TYPE)(0.0DL); /* acos(1) = 0 */ else return (DEC_TYPE)((2.0DL * pio2_hi) + (2.0DL * pio2_lo)); /* acos(-1)= pi */ } /* acos(|x| > 1) is NaN */ DFP_EXCEPT (FE_INVALID); return DFP_NAN; } else if (ix < 0.5DL) /* |x| < 0.5 */ { /* |x| < 2**-57 */ if (ix < 0.000000000000000000000000000000000000000000000000000000002DL) return (DEC_TYPE)(pio2_hi + pio2_lo); //Should raise INEXACT if (ix < 0.4375DL) /* |x| < .4375 */ { /* Arcsine of x. */ z = x * x; p = (((((((((pS9 * z + pS8) * z + pS7) * z + pS6) * z + pS5) * z + pS4) * z + pS3) * z + pS2) * z + pS1) * z + pS0) * z; q = (((((((( z + qS8) * z + qS7) * z + qS6) * z + qS5) * z + qS4) * z + qS3) * z + qS2) * z + qS1) * z + qS0; r = x + x * p / q; z = pio2_hi - (r - pio2_lo); return (DEC_TYPE)z; } /* .4375 <= |x| < .5 */ t = ix - 0.4375DL; p = ((((((((((P10 * t + P9) * t + P8) * t + P7) * t + P6) * t + P5) * t + P4) * t + P3) * t + P2) * t + P1) * t + P0) * t; q = (((((((((t + Q9) * t + Q8) * t + Q7) * t + Q6) * t + Q5) * t + Q4) * t + Q3) * t + Q2) * t + Q1) * t + Q0; r = p / q; if (sign) r = pimacosr4375 - r; else r = acosr4375 + r; return (DEC_TYPE)r; } else if (ix < 0.625DL) /* |x| < 0.625 */ { t = ix - 0.5625DL; p = ((((((((((rS10 * t + rS9) * t + rS8) * t + rS7) * t + rS6) * t + rS5) * t + rS4) * t + rS3) * t + rS2) * t + rS1) * t + rS0) * t; q = (((((((((t + sS9) * t + sS8) * t + sS7) * t + sS6) * t + sS5) * t + sS4) * t + sS3) * t + sS2) * t + sS1) * t + sS0; if (sign) r = pimacosr5625 - p / q; else r = acosr5625 + p / q; return (DEC_TYPE)r; } else { /* |x| >= .625 */ z = (one - ix) * 0.5DL; s = __sqrtd128 (z); /* Compute an extended precision square root from the Newton iteration s -> 0.5 * (s + z / s). The change w from s to the improved value is w = 0.5 * (s + z / s) - s = (s^2 + z)/2s - s = (z - s^2)/2s. Express s = f1 + f2 where f1 * f1 is exactly representable. w = (z - s^2)/2s = (z - f1^2 - 2 f1 f2 - f2^2)/2s . s + w has extended precision. */ p = s; /* u.value = s; u.parts32.w2 = 0; u.parts32.w3 = 0; */ f2 = s - p; w = z - p * p; w = w - 2.0DL * p * f2; w = w - f2 * f2; w = w / (2.0DL * s); /* Arcsine of s. */ p = (((((((((pS9 * z + pS8) * z + pS7) * z + pS6) * z + pS5) * z + pS4) * z + pS3) * z + pS2) * z + pS1) * z + pS0) * z; q = (((((((( z + qS8) * z + qS7) * z + qS6) * z + qS5) * z + qS4) * z + qS3) * z + qS2) * z + qS1) * z + qS0; r = s + (w + s * p / q); if (sign) w = pio2_hi + (pio2_lo - r); else w = r; return (DEC_TYPE)(2.0DL * w); } } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); if (x > DFP_CONSTANT(1.0) || x < DFP_CONSTANT(-1.0)) DFP_ERRNO (EDOM); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/acosd64.c000066400000000000000000000021031261375163000157730ustar00rootroot00000000000000/* Calculates the arccos(x) Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "acosd32.c" libdfp-1.0.12/ieee754r/acoshd128.c000066400000000000000000000021631261375163000162320ustar00rootroot00000000000000/* Calculates the arc that has the given tangent for a _Decimal128 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "acoshd32.c" libdfp-1.0.12/ieee754r/acoshd32.c000066400000000000000000000055351261375163000161520ustar00rootroot00000000000000/* Returns the hyperbolic arc cosine of a _Decimal32 type argument Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #define FUNCTION_NAME acosh #include #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result, one; decNumber dn_x, dn_one; one=DFP_CONSTANT(1.0); FUNC_CONVERT_TO_DN (&one, &dn_one); FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x)) return x+x; if (x The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "acoshd32.c" libdfp-1.0.12/ieee754r/asind128.c000066400000000000000000000021051261375163000160630ustar00rootroot00000000000000/* Calculates the arccos(x) Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "asind32.c" libdfp-1.0.12/ieee754r/asind32.c000066400000000000000000000202551261375163000160030ustar00rootroot00000000000000/* Calculates the arcsin(x) Copyright (C) 2001 Stephen L. Moshier Copyright (C) 2006 IBM Corporation. Copyright (C) 2001-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s) Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 #endif #include #include #include /* Portions of this code are: * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunPro, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. * ==================================================== * * This was adapted for glibc in 2001. * This was adapted for Libdfp in 2006, and those changes donated to the FSF in * 2007. * * __ieee754_asin(x) * Method : * Since asin(x) = x + x^3/6 + x^5*3/40 + x^7*15/336 + ... * we approximate asin(x) on [0,0.5] by * asin(x) = x + x*x^2*R(x^2) * Between .5 and .625 the approximation is * asin(0.5625 + x) = asin(0.5625) + x rS(x) / sS(x) * For x in [0.625,1] * asin(x) = pi/2-2*asin(sqrt((1-x)/2)) * Let y = (1-x), z = y/2, s := sqrt(z), and pio2_hi+pio2_lo=pi/2; * then for x>0.98 * asin(x) = pi/2 - 2*(s+s*z*R(z)) * = pio2_hi - (2*(s+s*z*R(z)) - pio2_lo) * For x<=0.98, let pio4_hi = pio2_hi/2, then * f = hi part of s; * c = sqrt(z) - f = (z-f*f)/(s+f) ...f+c=sqrt(z) * and * asin(x) = pi/2 - 2*(s+s*z*R(z)) * = pio4_hi+(pio4-2s)-(2s*z*R(z)-pio2_lo) * = pio4_hi+(pio4-2f)-(2s*z*R(z)-(pio2_lo+2c)) * * Special cases: * if x is NaN, return x itself; * if |x|>1, return NaN with invalid signal. * */ #ifdef __STDC__ static const _Decimal128 #else static _Decimal128 #endif one = 1.0DL, huge = 1.0e+300DL, pio2_hi = 1.5707963267948966192313216916397514420986DL, pio2_lo = 4.3359050650618905123985220130216759843812E-35DL, pio4_hi = 7.8539816339744830961566084581987569936977E-1DL, /* coefficient for R(x^2) */ /* asin(x) = x + x^3 pS(x^2) / qS(x^2) 0 <= x <= 0.5 peak relative error 1.9e-35 */ pS0 = -8.358099012470680544198472400254596543711E2DL, pS1 = 3.674973957689619490312782828051860366493E3DL, pS2 = -6.730729094812979665807581609853656623219E3DL, pS3 = 6.643843795209060298375552684423454077633E3DL, pS4 = -3.817341990928606692235481812252049415993E3DL, pS5 = 1.284635388402653715636722822195716476156E3DL, pS6 = -2.410736125231549204856567737329112037867E2DL, pS7 = 2.219191969382402856557594215833622156220E1DL, pS8 = -7.249056260830627156600112195061001036533E-1DL, pS9 = 1.055923570937755300061509030361395604448E-3DL, qS0 = -5.014859407482408326519083440151745519205E3DL, qS1 = 2.430653047950480068881028451580393430537E4DL, qS2 = -4.997904737193653607449250593976069726962E4DL, qS3 = 5.675712336110456923807959930107347511086E4DL, qS4 = -3.881523118339661268482937768522572588022E4DL, qS5 = 1.634202194895541569749717032234510811216E4DL, qS6 = -4.151452662440709301601820849901296953752E3DL, qS7 = 5.956050864057192019085175976175695342168E2DL, qS8 = -4.175375777334867025769346564600396877176E1DL, /* 1.000000000000000000000000000000000000000E0 */ /* asin(0.5625 + x) = asin(0.5625) + x rS(x) / sS(x) -0.0625 <= x <= 0.0625 peak relative error 3.3e-35 */ rS0 = -5.619049346208901520945464704848780243887E0DL, rS1 = 4.460504162777731472539175700169871920352E1DL, rS2 = -1.317669505315409261479577040530751477488E2DL, rS3 = 1.626532582423661989632442410808596009227E2DL, rS4 = -3.144806644195158614904369445440583873264E1DL, rS5 = -9.806674443470740708765165604769099559553E1DL, rS6 = 5.708468492052010816555762842394927806920E1DL, rS7 = 1.396540499232262112248553357962639431922E1DL, rS8 = -1.126243289311910363001762058295832610344E1DL, rS9 = -4.956179821329901954211277873774472383512E-1DL, rS10 = 3.313227657082367169241333738391762525780E-1DL, sS0 = -4.645814742084009935700221277307007679325E0DL, sS1 = 3.879074822457694323970438316317961918430E1DL, sS2 = -1.221986588013474694623973554726201001066E2DL, sS3 = 1.658821150347718105012079876756201905822E2DL, sS4 = -4.804379630977558197953176474426239748977E1DL, sS5 = -1.004296417397316948114344573811562952793E2DL, sS6 = 7.530281592861320234941101403870010111138E1DL, sS7 = 1.270735595411673647119592092304357226607E1DL, sS8 = -1.815144839646376500705105967064792930282E1DL, sS9 = -7.821597334910963922204235247786840828217E-2DL, /* 1.000000000000000000000000000000000000000E0 */ asinr5625 = 5.9740641664535021430381036628424864397707E-1DL; #include #define FUNCTION_NAME asin #include //#include "math_private.h" //long double sqrtl (long double); static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { _Decimal128 t, w, p, q, c, r, s, ix; int32_t sign, flag; if(isnan(x)) return x+x; flag = 0; sign = (x < 0.0DL)?1:0; ix = FUNC_D(__fabs) (x); if (ix >= 1.0DL) /* |x|>= 1 */ { /* asin(1)=+-pi/2 with inexact */ if (ix == 1.0DL) return (DEC_TYPE)(x * pio2_hi + x * pio2_lo); /* asin(|x|>1) is NaN */ DFP_EXCEPT (FE_INVALID); return DFP_NAN; } else if (ix < 0.5DL) /* |x| < 0.5 */ { if (ix < 0.000000000000000000000000000000000000000000000000000000002DL) /* |x| < 2**-57 */ { if (huge + x > one) return x; /* return x with inexact if x!=0 */ t = 0.0DL; } else { t = x * x; /* Mark to use pS, qS later on. */ flag = 1; } } else if (ix < 0.625DL) /* 0.625 */ { t = ix - 0.5625DL; p = ((((((((((rS10 * t + rS9) * t + rS8) * t + rS7) * t + rS6) * t + rS5) * t + rS4) * t + rS3) * t + rS2) * t + rS1) * t + rS0) * t; q = ((((((((( t + sS9) * t + sS8) * t + sS7) * t + sS6) * t + sS5) * t + sS4) * t + sS3) * t + sS2) * t + sS1) * t + sS0; t = asinr5625 + p / q; if (sign == 0) return (DEC_TYPE)t; else return (DEC_TYPE)(-t); } else { /* 1 > |x| >= 0.625 */ w = one - ix; t = w * 0.5DL; } p = (((((((((pS9 * t + pS8) * t + pS7) * t + pS6) * t + pS5) * t + pS4) * t + pS3) * t + pS2) * t + pS1) * t + pS0) * t; q = (((((((( t + qS8) * t + qS7) * t + qS6) * t + qS5) * t + qS4) * t + qS3) * t + qS2) * t + qS1) * t + qS0; if (flag) /* 2^-57 < |x| < 0.5 */ { w = p / q; return (DEC_TYPE)(x + x * w); } s = __sqrtd128 (t); if (ix >= 0.975DL) /* |x| > 0.975 */ { w = p / q; t = pio2_hi - (2.0DL * (s + s * w) - pio2_lo); } else { w = s; /* Look into the reason this code was here u.value = s; u.parts32.w3 = 0; u.parts32.w2 = 0; w = u.value; */ c = (t - w * w) / (s + w); r = p / q; p = 2.0DL * s * r - (pio2_lo - 2.0DL * c); q = pio4_hi - 2.0DL * w; t = pio4_hi - (p - q); } if (sign == 0) return (DEC_TYPE)t; else return (DEC_TYPE)(-t); } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); if (x > DFP_CONSTANT(1.0) || x < DFP_CONSTANT(-1.0)) DFP_ERRNO (EDOM); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/asind64.c000066400000000000000000000021031261375163000160000ustar00rootroot00000000000000/* Calculates the arccos(x) Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "asind32.c" libdfp-1.0.12/ieee754r/asinhd128.c000066400000000000000000000021471261375163000162410ustar00rootroot00000000000000/* Calculates for a _Decimal128 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "asinhd32.c" libdfp-1.0.12/ieee754r/asinhd32.c000066400000000000000000000042061261375163000161510ustar00rootroot00000000000000/* Returns the hyperbolic arc sine of a _Decimal32 type argument Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #define FUNCTION_NAME asinh #include DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result, one; decNumber dn_x, dn_one; one = DFP_CONSTANT(1.0); FUNC_CONVERT_TO_DN (&one, &dn_one); FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x) || decNumberIsZero (&dn_x) || decNumberIsInfinite (&dn_x)) { return x + x; } decContextDefault (&context, DEFAULT_CONTEXT); /* using trig identity: acosh(x) = log(x+sqrt(x*x-1)) */ decNumberMultiply (&dn_result, &dn_x, &dn_x, &context); decNumberAdd (&dn_result, &dn_result, &dn_one, &context); decNumberSquareRoot (&dn_result, &dn_result, &context); decNumberAdd (&dn_result, &dn_result, &dn_x, &context); decNumberLn (&dn_result, &dn_result, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/asinhd64.c000066400000000000000000000021451261375163000161560ustar00rootroot00000000000000/* Calculates for a _Decimal64 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "asinhd32.c" libdfp-1.0.12/ieee754r/atan2d128.c000066400000000000000000000021631261375163000161420ustar00rootroot00000000000000/* Calculates the arc that has the given tangent for a _Decimal128 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "atan2d32.c" libdfp-1.0.12/ieee754r/atan2d32.c000066400000000000000000000066411261375163000160610ustar00rootroot00000000000000/* Calculates the arc that has the given tangent for a _Decimal32 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #define FUNCTION_NAME atan2 #include DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE y, DEC_TYPE x) { /* This needs to be kept in the range of _Decimal32, and only added * to fairly large numbers (sizeable fractions of pi) */ const DEC_TYPE generate_inexact = DFP_CONSTANT(1e-94); decContext context; decNumber dn_result, dn_temp; DEC_TYPE result; decNumber dn_x, dn_y; FUNC_CONVERT_TO_DN (&x, &dn_x); FUNC_CONVERT_TO_DN (&y, &dn_y); /* If either argument is NaN, return NaN */ if (decNumberIsNaN (&dn_x) || decNumberIsNaN (&dn_y)) return x+y; /* If x,y are both non-inf, non-NaN, non-zero, calculate as normal */ if (!decNumberIsInfinite (&dn_x) && !decNumberIsZero (&dn_y) && !decNumberIsInfinite (&dn_y) && !decNumberIsZero (&dn_x)) { decContextDefault (&context, DEFAULT_CONTEXT); decNumberDivide (&dn_temp, &dn_y, &dn_x, &context); decNumberAtan (&dn_result, &dn_temp, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); /* decNumberAtan doesn't quite return the values in the ranges we * want for x < 0. So we need to do some correction */ if (decNumberIsNegative (&dn_x)) { if (decNumberIsNegative (&dn_y)) return result - M_PIdl; else return result + M_PIdl; } else return result; } /* If x and y are both inf, the result depends on the sign of x */ if (decNumberIsInfinite (&dn_y) && decNumberIsInfinite (&dn_x)) { if (decNumberIsNegative (&dn_x) ) result = (DEC_TYPE)(3.0DL * M_PI_4dl) + generate_inexact; else result = (DEC_TYPE) M_PI_4dl + generate_inexact; } /* If y is non-zero and x is non-inf, the result is +-pi/2 */ else if (!decNumberIsZero (&dn_y) && !decNumberIsInfinite (&dn_x) ) result = (DEC_TYPE)M_PI_2dl; else /* Otherwise it is +0 if x is positive, +pi if x is neg */ { if (decNumberIsNegative (&dn_x)) result = ((DEC_TYPE) M_PIdl) - generate_inexact; else result = DFP_CONSTANT (0.0); } /* Atan2 will be negative if y<0 */ if (decNumberIsNegative (&dn_y)) return -result; else return result; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/atan2d64.c000066400000000000000000000021601261375163000160560ustar00rootroot00000000000000/* Calculates the arc that has the given tangent for a _Decimal64 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "atan2d32.c" libdfp-1.0.12/ieee754r/atand128.c000066400000000000000000000021611261375163000160560ustar00rootroot00000000000000/* Calculates the arc that has the given tangent for a _Decimal128 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "atand32.c" libdfp-1.0.12/ieee754r/atand32.c000066400000000000000000000035141261375163000157730ustar00rootroot00000000000000/* Calculates the arc that has the given tangent for a _Decimal32 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #define FUNCTION_NAME atan #include DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; FUNC_CONVERT_TO_DN (&x, &dn_x); decContextDefault (&context, DEFAULT_CONTEXT); if (decNumberIsInfinite (&dn_x)) { if (decNumberIsNegative (&dn_x)) result = -M_PI_2dl; else result = M_PI_2dl; } else { decNumberAtan (&dn_result, &dn_x, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); } return result; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/atand64.c000066400000000000000000000021561261375163000160010ustar00rootroot00000000000000/* Calculates the arc that has the given tangent for a _Decimal64 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "atand32.c" libdfp-1.0.12/ieee754r/atanhd128.c000066400000000000000000000021631261375163000162300ustar00rootroot00000000000000/* Calculates the hyperbolic arc tangent (atanh) for a _Decimal128 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "atanhd32.c" libdfp-1.0.12/ieee754r/atanhd32.c000066400000000000000000000066531261375163000161520ustar00rootroot00000000000000/* Calculate the hyperbolic arc tangent (atanh) for _Decimal32 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #include #define FUNCTION_NAME atanh #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result, one, temp; decNumber dn_x, dn_temp, dn_one; /* int comp;*/ one=DFP_CONSTANT(1.0); FUNC_CONVERT_TO_DN (&one, &dn_one); FUNC_CONVERT_TO_DN (&x, &dn_x); /* Handle NaN and early exit for x==0 */ if (decNumberIsNaN (&dn_x) || decNumberIsZero (&dn_x)) return x + x; decContextDefault (&context, DEFAULT_CONTEXT); decNumberAbs (&dn_temp, &dn_x, &context); FUNC_CONVERT_FROM_DN (&dn_temp, &temp, &context); if(temp==one) { /* |x| == 1 -> Pole Error */ DFP_EXCEPT (FE_DIVBYZERO); return decNumberIsNegative(&dn_x) ? -DFP_HUGE_VAL:DFP_HUGE_VAL; } else if (temp>one) { /* |x| > 1 -> Domain Error (this handles +-Inf too) */ DFP_EXCEPT (FE_INVALID); return DFP_NAN; } // comp = decCompare (&dn_temp, &dn_one); // switch (comp) // { // case 0: /* |x| == 1 -> Pole Error */ // DFP_EXCEPT (FE_DIVBYZERO); // return decNumberIsNegative(&dn_x) ? -DFP_HUGE_VAL:DFP_HUGE_VAL; // case 1: /* |x| > 1 -> Domain Error (this handles +-Inf too) */ // DFP_EXCEPT (FE_INVALID); // return DFP_NAN; // } /* Using trig identity: atanh(x) = 1/2 * log((1+x)/(1-x)) */ decNumberAdd (&dn_result, &dn_one, &dn_x, &context); decNumberSubtract (&dn_temp, &dn_one, &dn_x, &context); decNumberDivide (&dn_result, &dn_result, &dn_temp, &context); decNumberLn (&dn_result, &dn_result, &context); decNumberAdd (&dn_temp, &dn_one, &dn_one, &context); /* 2 */ decNumberDivide (&dn_result, &dn_result, &dn_temp, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); if (x < DFP_CONSTANT(-1.0) || x > DFP_CONSTANT(1.0)) DFP_ERRNO (EDOM); /* The normal glibc ieee754 k_standard.c file does not follow c99 or POSIX * with regard to atanh pole errors. atan(+-1.0) [the binary version] will * set errno to EDOM. Hopefully this will get worked out soon. */ if (x == DFP_CONSTANT(-1.0) || x == DFP_CONSTANT(1.0)) DFP_ERRNO (ERANGE); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/atanhd64.c000066400000000000000000000021601261375163000161440ustar00rootroot00000000000000/* Calculates the hyperbolic arc tangent (atanh) for a _Decimal64 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "atanhd32.c" libdfp-1.0.12/ieee754r/cbrtd128.c000066400000000000000000000020631261375163000160660ustar00rootroot00000000000000/* Calculates the cube root function of _Decimal128 type x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "cbrtd32.c" libdfp-1.0.12/ieee754r/cbrtd32.c000066400000000000000000000107341261375163000160040ustar00rootroot00000000000000/* Calculates the cube root function of _Decimal32 type x Copyright (C) 1984, 1991 Stephen L. Moshier. Copyright (C) 2006 IBM Corporation. Copyright (C) 2001-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 #endif #include #include #define FUNCTION_NAME cbrt #include /* * Provided by the Cephes Math Library Release 2.2: January, 1991 * By Stephen L. Moshier * Adapted for glibc October, 2001. * Adapted for libdfp 2006, and donated to the FSF in 2007. * * DESCRIPTION: * Returns the cube root of the argument, which may be negative. * * Range reduction involves determining the power of 2 of * the argument. A polynomial of degree 2 applied to the * mantissa, and multiplication by the cube root of 1, 2, or 4 * approximates the root to within about 0.1%. Then Newton's * iteration is used three times to converge to an accurate * result. * * ACCURACY: * Relative error: * arithmetic domain # trials peak rms * IEEE -8,8 100000 1.3e-34 3.9e-35 * IEEE exp(+-707) 100000 1.3e-34 4.3e-35 */ /* Replace with: * cbrt(10) and cbrt(100) * and * cbrt(-10) and cbrt(-100) * * used 'bc' to get these and then trunced by hand. * echo 'scale=44;e(1/3*(l(10)))' | bc -l * echo 'scale=44;e(1/3*(l(100)))' | bc -l * echo 'scale=45;e(1/3*(l(1/10)))' | bc -l * echo 'scale=45;e(1/3*(l(1/100)))' | bc -l */ static const _Decimal128 CBRT10 = 2.154434690031883721759293566519350495259345DL, CBRT100 = 4.641588833612778892410076350919446576551349DL, CBRT10I = 0.4641588833612778892410076350919446576551349DL, CBRT100I = 0.2154434690031883721759293566519350495259345DL; // CBRT2 = 1.259921049894873164767210607278228350570251DL, // CBRT4 = 1.587401051968199474751705639272308260391493DL, // CBRT2I= 0.7937005259840997373758528196361541301957467DL, // CBRT4I= 0.6299605249474365823836053036391141752851257DL; DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { int e, rem, sign; _Decimal128 z; if (! FUNC_D(__isfinite) (x)) /* cbrt(x:x=inf/nan/-inf) = x+x (for sNaN) */ return x + x; if (x == DFP_CONSTANT(0.0)) /* cbrt(0) = 0 */ return (x); if (x > DFP_CONSTANT(0.0)) sign = 1; else { sign = -1; x = -x; } z = x; /* extract power of 2, leaving mantissa between 0.5 and 1 */ x = FUNC_D(__frexp) (x, &e); /* Approximate cube root of number between .5 and 1, peak relative error = 1.2e-6 */ x = ((((1.3584464340920900529734e-1DL * x - 6.3986917220457538402318e-1DL) * x + 1.2875551670318751538055e0DL) * x - 1.4897083391357284957891e0DL) * x + 1.3304961236013647092521e0DL) * x + 3.7568280825958912391243e-1DL; /* exponent divided by 3 */ if (e >= 0) { rem = e; e /= 3; rem -= 3 * e; if (rem == 1) //x *= CBRT2; x *= CBRT10; else if (rem == 2) //x *= CBRT4; x *= CBRT100; } else { /* argument less than 1 */ e = -e; rem = e; e /= 3; rem -= 3 * e; if (rem == 1) //x *= CBRT2I; x *= CBRT10I; else if (rem == 2) //x *= CBRT4I; x *= CBRT100I; e = -e; } /* multiply by power of 2 */ x = FUNC_D(__ldexp) (x, e); /* Newton iteration */ x -= (x - (z / (x * x))) * 0.3333333333333333333333333333333333333333DL; x -= (x - (z / (x * x))) * 0.3333333333333333333333333333333333333333DL; x -= (x - (z / (x * x))) * 0.3333333333333333333333333333333333333333DL; if (sign < 0) x = -x; return (x); } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/cbrtd64.c000066400000000000000000000021411261375163000160020ustar00rootroot00000000000000/* Calculates the cube root function of _Decimal64 type x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "cbrtd32.c" libdfp-1.0.12/ieee754r/ceild128.c000066400000000000000000000021231261375163000160450ustar00rootroot00000000000000/* Ceiling function for _Decimal128 types Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "ceild32.c" libdfp-1.0.12/ieee754r/ceild32.c000066400000000000000000000033731261375163000157670ustar00rootroot00000000000000/* Ceiling function for _Decimal32 types Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #define FUNCTION_NAME ceil #include DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x) || decNumberIsInfinite (&dn_x) || decNumberIsZero (&dn_x) ) return x+x; decContextDefault (&context, DEFAULT_CONTEXT); context.round = DEC_ROUND_CEILING; decNumberToIntegralValue (&dn_result, &dn_x, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/ceild64.c000066400000000000000000000021201261375163000157610ustar00rootroot00000000000000/* Ceiling function for _Decimal64 types Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "ceild32.c" libdfp-1.0.12/ieee754r/copysignd128.c000066400000000000000000000021461261375163000167710ustar00rootroot00000000000000/* Copies the sign from the second argument to the first Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "copysignd32.c" libdfp-1.0.12/ieee754r/copysignd32.c000066400000000000000000000033771261375163000167120ustar00rootroot00000000000000/* Copies the sign from the second argument to the first Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #define FUNCTION_NAME copysign #include #define decNumberNegate(dn) (((dn)->bits)^=DECNEG) DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decContext context; DEC_TYPE result; decNumber dn_x; decNumber dn_y; FUNC_CONVERT_TO_DN (&x, &dn_x); FUNC_CONVERT_TO_DN (&y, &dn_y); if(decNumberIsNegative (&dn_x) != decNumberIsNegative (&dn_y)) decNumberNegate (&dn_x); decContextDefault (&context, DEFAULT_CONTEXT); FUNC_CONVERT_FROM_DN (&dn_x, &result, &context); return result; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/copysignd64.c000066400000000000000000000021441261375163000167060ustar00rootroot00000000000000/* Copies the sign from the second argument to the first Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "copysignd32.c" libdfp-1.0.12/ieee754r/cosd128.c000066400000000000000000000021331261375163000157160ustar00rootroot00000000000000/* Calculate the cos(x) for a _Decimal128 format x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "cosd32.c" libdfp-1.0.12/ieee754r/cosd32.c000066400000000000000000000040231261375163000156300ustar00rootroot00000000000000/* Calculate the cos(x) for a _Decimal32 format x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #include #include #define FUNCTION_NAME cos #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x)) return x+x; if (decNumberIsZero (&dn_x)) return DFP_CONSTANT(1.0); if (decNumberIsInfinite (&dn_x)) { DFP_EXCEPT (FE_INVALID); return DFP_NAN; } decContextDefault (&context, DEFAULT_CONTEXT); decNumberCos (&dn_result, &dn_x, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); if (isinf(x)) DFP_ERRNO (EDOM); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/cosd64.c000066400000000000000000000021301261375163000156320ustar00rootroot00000000000000/* Calculate the cos(x) for a _Decimal64 format x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "cosd32.c" libdfp-1.0.12/ieee754r/coshd128.c000066400000000000000000000021451261375163000160710ustar00rootroot00000000000000/* Calculate the hyperbolic cos (cosh) for _Decimal128 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "coshd32.c" libdfp-1.0.12/ieee754r/coshd32.c000066400000000000000000000042031261375163000160000ustar00rootroot00000000000000/* Calculate the hyperbolic cos (cosh) for _Decimal32 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #include #include #define FUNCTION_NAME cosh #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x)) return x+x; if (decNumberIsZero (&dn_x)) return DFP_CONSTANT(1.0); decContextDefault (&context, DEFAULT_CONTEXT); if (decNumberIsInfinite (&dn_x)) decNumberAbs (&dn_result, &dn_x, &context); else decNumberCosh (&dn_result, &dn_x, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); if (context.status & DEC_Overflow) DFP_EXCEPT(FE_OVERFLOW); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); if (FUNC_D(__isfinite)(x) && !FUNC_D(__isfinite)(z)) DFP_ERRNO (ERANGE); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/coshd64.c000066400000000000000000000021421261375163000160050ustar00rootroot00000000000000/* Calculate the hyperbolic cos (cosh) for _Decimal64 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "coshd32.c" libdfp-1.0.12/ieee754r/erfd128.c000066400000000000000000000021131261375163000157040ustar00rootroot00000000000000/* Returns the error function of x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "erfd32.c" libdfp-1.0.12/ieee754r/erfd32.c000066400000000000000000000743711261375163000156350ustar00rootroot00000000000000/* erfd32 Copyright (C) 2001 Stephen L. Moshier Copyright (C) 2006 IBM Corporation. Copyright (C) 2001-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 #endif #include #include #define FUNCTION_NAME erf /* * Portions of this code are: * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunPro, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. * ==================================================== * * This was adapted for GLIBC in 2001. * This was adapted for libdfp in 2006 and dontated to the FSF in 2007. * * * double erf(double x) * double erfc(double x) * x * 2 |\ * erf(x) = --------- | exp(-t*t)dt * sqrt(pi) \| * 0 * * erfc(x) = 1-erf(x) * Note that * erf(-x) = -erf(x) * erfc(-x) = 2 - erfc(x) * * Method: * 1. erf(x) = x + x*R(x^2) for |x| in [0, 7/8] * Remark. The formula is derived by noting * erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....) * and that * 2/sqrt(pi) = 1.128379167095512573896158903121545171688 * is close to one. * * 1a. erf(x) = 1 - erfc(x), for |x| > 1.0 * erfc(x) = 1 - erf(x) if |x| < 1/4 * * 2. For |x| in [7/8, 1], let s = |x| - 1, and * c = 0.84506291151 rounded to single (24 bits) * erf(s + c) = sign(x) * (c + P1(s)/Q1(s)) * Remark: here we use the taylor series expansion at x=1. * erf(1+s) = erf(1) + s*Poly(s) * = 0.845.. + P1(s)/Q1(s) * Note that |P1/Q1|< 0.078 for x in [0.84375,1.25] * * 3. For x in [1/4, 5/4], * erfc(s + const) = erfc(const) + s P1(s)/Q1(s) * for const = 1/4, 3/8, ..., 9/8 * and 0 <= s <= 1/8 . * * 4. For x in [5/4, 107], * erfc(x) = (1/x)*exp(-x*x-0.5625 + R(z)) * z=1/x^2 * The interval is partitioned into several segments * of width 1/8 in 1/x. * * Note1: * To compute exp(-x*x-0.5625+R/S), let s be a single * precision number and s := x; then * -x*x = -s*s + (s-x)*(s+x) * exp(-x*x-0.5626+R/S) = * exp(-s*s-0.5625)*exp((s-x)*(s+x)+R/S); * Note2: * Here 4 and 5 make use of the asymptotic series * exp(-x*x) * erfc(x) ~ ---------- * ( 1 + Poly(1/x^2) ) * x*sqrt(pi) * * 5. For inf > x >= 107 * erf(x) = sign(x) *(1 - tiny) (raise inexact) * erfc(x) = tiny*tiny (raise underflow) if x > 0 * = 2 - tiny if x<0 * * 7. Special case: * erf(0) = 0, erf(inf) = 1, erf(-inf) = -1, * erfc(0) = 1, erfc(inf) = 0, erfc(-inf) = 2, * erfc/erf(NaN) is NaN */ #include /* Evaluate P[n] x^n + P[n-1] x^(n-1) + ... + P[0] */ static _Decimal128 neval (_Decimal128 x, const _Decimal128 *p, int n) { _Decimal128 y; p += n; y = *p--; do { y = y * x + *p--; } while (--n > 0); return y; } /* Evaluate x^n+1 + P[n] x^(n) + P[n-1] x^(n-1) + ... + P[0] */ static _Decimal128 deval (_Decimal128 x, const _Decimal128 *p, int n) { _Decimal128 y; p += n; y = x + *p--; do { y = y * x + *p--; } while (--n > 0); return y; } static const _Decimal128 tiny = 1e-4931DL, half = 0.5DL, one = 1.0DL, two = 2.0DL, /* 2/sqrt(pi) - 1 */ efx = 1.2837916709551257389615890312154517168810E-1DL, /* 8 * (2/sqrt(pi) - 1) */ efx8 = 1.0270333367641005911692712249723613735048E0DL; /* erf(x) = x + x R(x^2) 0 <= x <= 7/8 Peak relative error 1.8e-35 */ #define NTN1 8 static const _Decimal128 TN1[NTN1 + 1] = { -3.858252324254637124543172907442106422373E10DL, 9.580319248590464682316366876952214879858E10DL, 1.302170519734879977595901236693040544854E10DL, 2.922956950426397417800321486727032845006E9DL, 1.764317520783319397868923218385468729799E8DL, 1.573436014601118630105796794840834145120E7DL, 4.028077380105721388745632295157816229289E5DL, 1.644056806467289066852135096352853491530E4DL, 3.390868480059991640235675479463287886081E1DL }; #define NTD1 8 static const _Decimal128 TD1[NTD1 + 1] = { -3.005357030696532927149885530689529032152E11DL, -1.342602283126282827411658673839982164042E11DL, -2.777153893355340961288511024443668743399E10DL, -3.483826391033531996955620074072768276974E9DL, -2.906321047071299585682722511260895227921E8DL, -1.653347985722154162439387878512427542691E7DL, -6.245520581562848778466500301865173123136E5DL, -1.402124304177498828590239373389110545142E4DL, -1.209368072473510674493129989468348633579E2DL /* 1.0E0 */ }; /* erf(z+1) = erf_const + P(z)/Q(z) -.125 <= z <= 0 Peak relative error 7.3e-36 */ static const _Decimal128 erf_const = 0.845062911510467529296875DL; #define NTN2 8 static const _Decimal128 TN2[NTN2 + 1] = { -4.088889697077485301010486931817357000235E1DL, 7.157046430681808553842307502826960051036E3DL, -2.191561912574409865550015485451373731780E3DL, 2.180174916555316874988981177654057337219E3DL, 2.848578658049670668231333682379720943455E2DL, 1.630362490952512836762810462174798925274E2DL, 6.317712353961866974143739396865293596895E0DL, 2.450441034183492434655586496522857578066E1DL, 5.127662277706787664956025545897050896203E-1DL }; #define NTD2 8 static const _Decimal128 TD2[NTD2 + 1] = { 1.731026445926834008273768924015161048885E4DL, 1.209682239007990370796112604286048173750E4DL, 1.160950290217993641320602282462976163857E4DL, 5.394294645127126577825507169061355698157E3DL, 2.791239340533632669442158497532521776093E3DL, 8.989365571337319032943005387378993827684E2DL, 2.974016493766349409725385710897298069677E2DL, 6.148192754590376378740261072533527271947E1DL, 1.178502892490738445655468927408440847480E1DL /* 1.0E0 */ }; /* erfc(x + 0.25) = erfc(0.25) + x R(x) 0 <= x < 0.125 Peak relative error 1.4e-35 */ #define NRNr13 8 static const _Decimal128 RNr13[NRNr13 + 1] = { -2.353707097641280550282633036456457014829E3DL, 3.871159656228743599994116143079870279866E2DL, -3.888105134258266192210485617504098426679E2DL, -2.129998539120061668038806696199343094971E1DL, -8.125462263594034672468446317145384108734E1DL, 8.151549093983505810118308635926270319660E0DL, -5.033362032729207310462422357772568553670E0DL, -4.253956621135136090295893547735851168471E-2DL, -8.098602878463854789780108161581050357814E-2DL }; #define NRDr13 7 static const _Decimal128 RDr13[NRDr13 + 1] = { 2.220448796306693503549505450626652881752E3DL, 1.899133258779578688791041599040951431383E2DL, 1.061906712284961110196427571557149268454E3DL, 7.497086072306967965180978101974566760042E1DL, 2.146796115662672795876463568170441327274E2DL, 1.120156008362573736664338015952284925592E1DL, 2.211014952075052616409845051695042741074E1DL, 6.469655675326150785692908453094054988938E-1DL /* 1.0E0 */ }; /* erfc(0.25) = C13a + C13b to extra precision. */ static const _Decimal128 C13a = 0.723663330078125DL; static const _Decimal128 C13b = 1.0279753638067014931732235184287934646022E-5DL; /* erfc(x + 0.375) = erfc(0.375) + x R(x) 0 <= x < 0.125 Peak relative error 1.2e-35 */ #define NRNr14 8 static const _Decimal128 RNr14[NRNr14 + 1] = { -2.446164016404426277577283038988918202456E3DL, 6.718753324496563913392217011618096698140E2DL, -4.581631138049836157425391886957389240794E2DL, -2.382844088987092233033215402335026078208E1DL, -7.119237852400600507927038680970936336458E1DL, 1.313609646108420136332418282286454287146E1DL, -6.188608702082264389155862490056401365834E0DL, -2.787116601106678287277373011101132659279E-2DL, -2.230395570574153963203348263549700967918E-2DL }; #define NRDr14 7 static const _Decimal128 RDr14[NRDr14 + 1] = { 2.495187439241869732696223349840963702875E3DL, 2.503549449872925580011284635695738412162E2DL, 1.159033560988895481698051531263861842461E3DL, 9.493751466542304491261487998684383688622E1DL, 2.276214929562354328261422263078480321204E2DL, 1.367697521219069280358984081407807931847E1DL, 2.276988395995528495055594829206582732682E1DL, 7.647745753648996559837591812375456641163E-1DL /* 1.0E0 */ }; /* erfc(0.375) = C14a + C14b to extra precision. */ static const _Decimal128 C14a = 0.5958709716796875DL; static const _Decimal128 C14b = 1.2118885490201676174914080878232469565953E-5DL; /* erfc(x + 0.5) = erfc(0.5) + x R(x) 0 <= x < 0.125 Peak relative error 4.7e-36 */ #define NRNr15 8 static const _Decimal128 RNr15[NRNr15 + 1] = { -2.624212418011181487924855581955853461925E3DL, 8.473828904647825181073831556439301342756E2DL, -5.286207458628380765099405359607331669027E2DL, -3.895781234155315729088407259045269652318E1DL, -6.200857908065163618041240848728398496256E1DL, 1.469324610346924001393137895116129204737E1DL, -6.961356525370658572800674953305625578903E0DL, 5.145724386641163809595512876629030548495E-3DL, 1.990253655948179713415957791776180406812E-2DL }; #define NRDr15 7 static const _Decimal128 RDr15[NRDr15 + 1] = { 2.986190760847974943034021764693341524962E3DL, 5.288262758961073066335410218650047725985E2DL, 1.363649178071006978355113026427856008978E3DL, 1.921707975649915894241864988942255320833E2DL, 2.588651100651029023069013885900085533226E2DL, 2.628752920321455606558942309396855629459E1DL, 2.455649035885114308978333741080991380610E1DL, 1.378826653595128464383127836412100939126E0DL /* 1.0E0 */ }; /* erfc(0.5) = C15a + C15b to extra precision. */ static const _Decimal128 C15a = 0.4794921875DL; static const _Decimal128 C15b = 7.9346869534623172533461080354712635484242E-6DL; /* erfc(x + 0.625) = erfc(0.625) + x R(x) 0 <= x < 0.125 Peak relative error 5.1e-36 */ #define NRNr16 8 static const _Decimal128 RNr16[NRNr16 + 1] = { -2.347887943200680563784690094002722906820E3DL, 8.008590660692105004780722726421020136482E2DL, -5.257363310384119728760181252132311447963E2DL, -4.471737717857801230450290232600243795637E1DL, -4.849540386452573306708795324759300320304E1DL, 1.140885264677134679275986782978655952843E1DL, -6.731591085460269447926746876983786152300E0DL, 1.370831653033047440345050025876085121231E-1DL, 2.022958279982138755020825717073966576670E-2DL, }; #define NRDr16 7 static const _Decimal128 RDr16[NRDr16 + 1] = { 3.075166170024837215399323264868308087281E3DL, 8.730468942160798031608053127270430036627E2DL, 1.458472799166340479742581949088453244767E3DL, 3.230423687568019709453130785873540386217E2DL, 2.804009872719893612081109617983169474655E2DL, 4.465334221323222943418085830026979293091E1DL, 2.612723259683205928103787842214809134746E1DL, 2.341526751185244109722204018543276124997E0DL, /* 1.0E0 */ }; /* erfc(0.625) = C16a + C16b to extra precision. */ static const _Decimal128 C16a = 0.3767547607421875DL; static const _Decimal128 C16b = 4.3570693945275513594941232097252997287766E-6DL; /* erfc(x + 0.75) = erfc(0.75) + x R(x) 0 <= x < 0.125 Peak relative error 1.7e-35 */ #define NRNr17 8 static const _Decimal128 RNr17[NRNr17 + 1] = { -1.767068734220277728233364375724380366826E3DL, 6.693746645665242832426891888805363898707E2DL, -4.746224241837275958126060307406616817753E2DL, -2.274160637728782675145666064841883803196E1DL, -3.541232266140939050094370552538987982637E1DL, 6.988950514747052676394491563585179503865E0DL, -5.807687216836540830881352383529281215100E0DL, 3.631915988567346438830283503729569443642E-1DL, -1.488945487149634820537348176770282391202E-2DL }; #define NRDr17 7 static const _Decimal128 RDr17[NRDr17 + 1] = { 2.748457523498150741964464942246913394647E3DL, 1.020213390713477686776037331757871252652E3DL, 1.388857635935432621972601695296561952738E3DL, 3.903363681143817750895999579637315491087E2DL, 2.784568344378139499217928969529219886578E2DL, 5.555800830216764702779238020065345401144E1DL, 2.646215470959050279430447295801291168941E1DL, 2.984905282103517497081766758550112011265E0DL, /* 1.0E0 */ }; /* erfc(0.75) = C17a + C17b to extra precision. */ static const _Decimal128 C17a = 0.2888336181640625DL; static const _Decimal128 C17b = 1.0748182422368401062165408589222625794046E-5DL; /* erfc(x + 0.875) = erfc(0.875) + x R(x) 0 <= x < 0.125 Peak relative error 2.2e-35 */ #define NRNr18 8 static const _Decimal128 RNr18[NRNr18 + 1] = { -1.342044899087593397419622771847219619588E3DL, 6.127221294229172997509252330961641850598E2DL, -4.519821356522291185621206350470820610727E2DL, 1.223275177825128732497510264197915160235E1DL, -2.730789571382971355625020710543532867692E1DL, 4.045181204921538886880171727755445395862E0DL, -4.925146477876592723401384464691452700539E0DL, 5.933878036611279244654299924101068088582E-1DL, -5.557645435858916025452563379795159124753E-2DL }; #define NRDr18 7 static const _Decimal128 RDr18[NRDr18 + 1] = { 2.557518000661700588758505116291983092951E3DL, 1.070171433382888994954602511991940418588E3DL, 1.344842834423493081054489613250688918709E3DL, 4.161144478449381901208660598266288188426E2DL, 2.763670252219855198052378138756906980422E2DL, 5.998153487868943708236273854747564557632E1DL, 2.657695108438628847733050476209037025318E1DL, 3.252140524394421868923289114410336976512E0DL, /* 1.0E0 */ }; /* erfc(0.875) = C18a + C18b to extra precision. */ static const _Decimal128 C18a = 0.215911865234375DL; static const _Decimal128 C18b = 1.3073705765341685464282101150637224028267E-5DL; /* erfc(x + 1.0) = erfc(1.0) + x R(x) 0 <= x < 0.125 Peak relative error 1.6e-35 */ #define NRNr19 8 static const _Decimal128 RNr19[NRNr19 + 1] = { -1.139180936454157193495882956565663294826E3DL, 6.134903129086899737514712477207945973616E2DL, -4.628909024715329562325555164720732868263E2DL, 4.165702387210732352564932347500364010833E1DL, -2.286979913515229747204101330405771801610E1DL, 1.870695256449872743066783202326943667722E0DL, -4.177486601273105752879868187237000032364E0DL, 7.533980372789646140112424811291782526263E-1DL, -8.629945436917752003058064731308767664446E-2DL }; #define NRDr19 7 static const _Decimal128 RDr19[NRDr19 + 1] = { 2.744303447981132701432716278363418643778E3DL, 1.266396359526187065222528050591302171471E3DL, 1.466739461422073351497972255511919814273E3DL, 4.868710570759693955597496520298058147162E2DL, 2.993694301559756046478189634131722579643E2DL, 6.868976819510254139741559102693828237440E1DL, 2.801505816247677193480190483913753613630E1DL, 3.604439909194350263552750347742663954481E0DL, /* 1.0E0 */ }; /* erfc(1.0) = C19a + C19b to extra precision. */ static const _Decimal128 C19a = 0.15728759765625DL; static const _Decimal128 C19b = 1.1609394035130658779364917390740703933002E-5DL; /* erfc(x + 1.125) = erfc(1.125) + x R(x) 0 <= x < 0.125 Peak relative error 3.6e-36 */ #define NRNr20 8 static const _Decimal128 RNr20[NRNr20 + 1] = { -9.652706916457973956366721379612508047640E2DL, 5.577066396050932776683469951773643880634E2DL, -4.406335508848496713572223098693575485978E2DL, 5.202893466490242733570232680736966655434E1DL, -1.931311847665757913322495948705563937159E1DL, -9.364318268748287664267341457164918090611E-2DL, -3.306390351286352764891355375882586201069E0DL, 7.573806045289044647727613003096916516475E-1DL, -9.611744011489092894027478899545635991213E-2DL }; #define NRDr20 7 static const _Decimal128 RDr20[NRDr20 + 1] = { 3.032829629520142564106649167182428189014E3DL, 1.659648470721967719961167083684972196891E3DL, 1.703545128657284619402511356932569292535E3DL, 6.393465677731598872500200253155257708763E2DL, 3.489131397281030947405287112726059221934E2DL, 8.848641738570783406484348434387611713070E1DL, 3.132269062552392974833215844236160958502E1DL, 4.430131663290563523933419966185230513168E0DL /* 1.0E0 */ }; /* erfc(1.125) = C20a + C20b to extra precision. */ static const _Decimal128 C20a = 0.111602783203125DL; static const _Decimal128 C20b = 8.9850951672359304215530728365232161564636E-6DL; /* erfc(1/x) = 1/x exp (-1/x^2 - 0.5625 + R(1/x^2)) 7/8 <= 1/x < 1 Peak relative error 1.4e-35 */ #define NRNr8 9 static const _Decimal128 RNr8[NRNr8 + 1] = { 3.587451489255356250759834295199296936784E1DL, 5.406249749087340431871378009874875889602E2DL, 2.931301290625250886238822286506381194157E3DL, 7.359254185241795584113047248898753470923E3DL, 9.201031849810636104112101947312492532314E3DL, 5.749697096193191467751650366613289284777E3DL, 1.710415234419860825710780802678697889231E3DL, 2.150753982543378580859546706243022719599E2DL, 8.740953582272147335100537849981160931197E0DL, 4.876422978828717219629814794707963640913E-2DL }; #define NRDr8 8 static const _Decimal128 RDr8[NRDr8 + 1] = { 6.358593134096908350929496535931630140282E1DL, 9.900253816552450073757174323424051765523E2DL, 5.642928777856801020545245437089490805186E3DL, 1.524195375199570868195152698617273739609E4DL, 2.113829644500006749947332935305800887345E4DL, 1.526438562626465706267943737310282977138E4DL, 5.561370922149241457131421914140039411782E3DL, 9.394035530179705051609070428036834496942E2DL, 6.147019596150394577984175188032707343615E1DL /* 1.0E0 */ }; /* erfc(1/x) = 1/x exp (-1/x^2 - 0.5625 + R(1/x^2)) 0.75 <= 1/x <= 0.875 Peak relative error 2.0e-36 */ #define NRNr7 9 static const _Decimal128 RNr7[NRNr7 + 1] = { 1.686222193385987690785945787708644476545E1DL, 1.178224543567604215602418571310612066594E3DL, 1.764550584290149466653899886088166091093E4DL, 1.073758321890334822002849369898232811561E5DL, 3.132840749205943137619839114451290324371E5DL, 4.607864939974100224615527007793867585915E5DL, 3.389781820105852303125270837910972384510E5DL, 1.174042187110565202875011358512564753399E5DL, 1.660013606011167144046604892622504338313E4DL, 6.700393957480661937695573729183733234400E2DL }; #define NRDr7 9 static const _Decimal128 RDr7[NRDr7 + 1] = { -1.709305024718358874701575813642933561169E3DL, -3.280033887481333199580464617020514788369E4DL, -2.345284228022521885093072363418750835214E5DL, -8.086758123097763971926711729242327554917E5DL, -1.456900414510108718402423999575992450138E6DL, -1.391654264881255068392389037292702041855E6DL, -6.842360801869939983674527468509852583855E5DL, -1.597430214446573566179675395199807533371E5DL, -1.488876130609876681421645314851760773480E4DL, -3.511762950935060301403599443436465645703E2DL /* 1.0E0 */ }; /* erfc(1/x) = 1/x exp(-1/x^2 - 0.5625 + R(1/x^2)) 5/8 <= 1/x < 3/4 Peak relative error 1.9e-35 */ #define NRNr6 9 static const _Decimal128 RNr6[NRNr6 + 1] = { 1.642076876176834390623842732352935761108E0DL, 1.207150003611117689000664385596211076662E2DL, 2.119260779316389904742873816462800103939E3DL, 1.562942227734663441801452930916044224174E4DL, 5.656779189549710079988084081145693580479E4DL, 1.052166241021481691922831746350942786299E5DL, 9.949798524786000595621602790068349165758E4DL, 4.491790734080265043407035220188849562856E4DL, 8.377074098301530326270432059434791287601E3DL, 4.506934806567986810091824791963991057083E2DL }; #define NRDr6 9 static const _Decimal128 RDr6[NRDr6 + 1] = { -1.664557643928263091879301304019826629067E2DL, -3.800035902507656624590531122291160668452E3DL, -3.277028191591734928360050685359277076056E4DL, -1.381359471502885446400589109566587443987E5DL, -3.082204287382581873532528989283748656546E5DL, -3.691071488256738343008271448234631037095E5DL, -2.300482443038349815750714219117566715043E5DL, -6.873955300927636236692803579555752171530E4DL, -8.262158817978334142081581542749986845399E3DL, -2.517122254384430859629423488157361983661E2DL /* 1.00 */ }; /* erfc(1/x) = 1/x exp(-1/x^2 - 0.5625 + R(1/x^2)) 1/2 <= 1/x < 5/8 Peak relative error 4.6e-36 */ #define NRNr5 10 static const _Decimal128 RNr5[NRNr5 + 1] = { -3.332258927455285458355550878136506961608E-3DL, -2.697100758900280402659586595884478660721E-1DL, -6.083328551139621521416618424949137195536E0DL, -6.119863528983308012970821226810162441263E1DL, -3.176535282475593173248810678636522589861E2DL, -8.933395175080560925809992467187963260693E2DL, -1.360019508488475978060917477620199499560E3DL, -1.075075579828188621541398761300910213280E3DL, -4.017346561586014822824459436695197089916E2DL, -5.857581368145266249509589726077645791341E1DL, -2.077715925587834606379119585995758954399E0DL }; #define NRDr5 9 static const _Decimal128 RDr5[NRDr5 + 1] = { 3.377879570417399341550710467744693125385E-1DL, 1.021963322742390735430008860602594456187E1DL, 1.200847646592942095192766255154827011939E2DL, 7.118915528142927104078182863387116942836E2DL, 2.318159380062066469386544552429625026238E3DL, 4.238729853534009221025582008928765281620E3DL, 4.279114907284825886266493994833515580782E3DL, 2.257277186663261531053293222591851737504E3DL, 5.570475501285054293371908382916063822957E2DL, 5.142189243856288981145786492585432443560E1DL /* 1.0E0 */ }; /* erfc(1/x) = 1/x exp(-1/x^2 - 0.5625 + R(1/x^2)) 3/8 <= 1/x < 1/2 Peak relative error 2.0e-36 */ #define NRNr4 10 static const _Decimal128 RNr4[NRNr4 + 1] = { 3.258530712024527835089319075288494524465E-3DL, 2.987056016877277929720231688689431056567E-1DL, 8.738729089340199750734409156830371528862E0DL, 1.207211160148647782396337792426311125923E2DL, 8.997558632489032902250523945248208224445E2DL, 3.798025197699757225978410230530640879762E3DL, 9.113203668683080975637043118209210146846E3DL, 1.203285891339933238608683715194034900149E4DL, 8.100647057919140328536743641735339740855E3DL, 2.383888249907144945837976899822927411769E3DL, 2.127493573166454249221983582495245662319E2DL }; #define NRDr4 10 static const _Decimal128 RDr4[NRDr4 + 1] = { -3.303141981514540274165450687270180479586E-1DL, -1.353768629363605300707949368917687066724E1DL, -2.206127630303621521950193783894598987033E2DL, -1.861800338758066696514480386180875607204E3DL, -8.889048775872605708249140016201753255599E3DL, -2.465888106627948210478692168261494857089E4DL, -3.934642211710774494879042116768390014289E4DL, -3.455077258242252974937480623730228841003E4DL, -1.524083977439690284820586063729912653196E4DL, -2.810541887397984804237552337349093953857E3DL, -1.343929553541159933824901621702567066156E2DL /* 1.0E0 */ }; /* erfc(1/x) = 1/x exp(-1/x^2 - 0.5625 + R(1/x^2)) 1/4 <= 1/x < 3/8 Peak relative error 8.4e-37 */ #define NRNr3 11 static const _Decimal128 RNr3[NRNr3 + 1] = { -1.952401126551202208698629992497306292987E-6DL, -2.130881743066372952515162564941682716125E-4DL, -8.376493958090190943737529486107282224387E-3DL, -1.650592646560987700661598877522831234791E-1DL, -1.839290818933317338111364667708678163199E0DL, -1.216278715570882422410442318517814388470E1DL, -4.818759344462360427612133632533779091386E1DL, -1.120994661297476876804405329172164436784E2DL, -1.452850765662319264191141091859300126931E2DL, -9.485207851128957108648038238656777241333E1DL, -2.563663855025796641216191848818620020073E1DL, -1.787995944187565676837847610706317833247E0DL }; #define NRDr3 10 static const _Decimal128 RDr3[NRDr3 + 1] = { 1.979130686770349481460559711878399476903E-4DL, 1.156941716128488266238105813374635099057E-2DL, 2.752657634309886336431266395637285974292E-1DL, 3.482245457248318787349778336603569327521E0DL, 2.569347069372696358578399521203959253162E1DL, 1.142279000180457419740314694631879921561E2DL, 3.056503977190564294341422623108332700840E2DL, 4.780844020923794821656358157128719184422E2DL, 4.105972727212554277496256802312730410518E2DL, 1.724072188063746970865027817017067646246E2DL, 2.815939183464818198705278118326590370435E1DL /* 1.0E0 */ }; /* erfc(1/x) = 1/x exp(-1/x^2 - 0.5625 + R(1/x^2)) 1/8 <= 1/x < 1/4 Peak relative error 1.5e-36 */ #define NRNr2 11 static const _Decimal128 RNr2[NRNr2 + 1] = { -2.638914383420287212401687401284326363787E-8DL, -3.479198370260633977258201271399116766619E-6DL, -1.783985295335697686382487087502222519983E-4DL, -4.777876933122576014266349277217559356276E-3DL, -7.450634738987325004070761301045014986520E-2DL, -7.068318854874733315971973707247467326619E-1DL, -4.113919921935944795764071670806867038732E0DL, -1.440447573226906222417767283691888875082E1DL, -2.883484031530718428417168042141288943905E1DL, -2.990886974328476387277797361464279931446E1DL, -1.325283914915104866248279787536128997331E1DL, -1.572436106228070195510230310658206154374E0DL }; #define NRDr2 10 static const _Decimal128 RDr2[NRDr2 + 1] = { 2.675042728136731923554119302571867799673E-6DL, 2.170997868451812708585443282998329996268E-4DL, 7.249969752687540289422684951196241427445E-3DL, 1.302040375859768674620410563307838448508E-1DL, 1.380202483082910888897654537144485285549E0DL, 8.926594113174165352623847870299170069350E0DL, 3.521089584782616472372909095331572607185E1DL, 8.233547427533181375185259050330809105570E1DL, 1.072971579885803033079469639073292840135E2DL, 6.943803113337964469736022094105143158033E1DL, 1.775695341031607738233608307835017282662E1DL /* 1.0E0 */ }; /* erfc(1/x) = 1/x exp(-1/x^2 - 0.5625 + R(1/x^2)) 1/128 <= 1/x < 1/8 Peak relative error 2.2e-36 */ #define NRNr1 9 static const _Decimal128 RNr1[NRNr1 + 1] = { -4.250780883202361946697751475473042685782E-8DL, -5.375777053288612282487696975623206383019E-6DL, -2.573645949220896816208565944117382460452E-4DL, -6.199032928113542080263152610799113086319E-3DL, -8.262721198693404060380104048479916247786E-2DL, -6.242615227257324746371284637695778043982E-1DL, -2.609874739199595400225113299437099626386E0DL, -5.581967563336676737146358534602770006970E0DL, -5.124398923356022609707490956634280573882E0DL, -1.290865243944292370661544030414667556649E0DL }; #define NRDr1 8 static const _Decimal128 RDr1[NRDr1 + 1] = { 4.308976661749509034845251315983612976224E-6DL, 3.265390126432780184125233455960049294580E-4DL, 9.811328839187040701901866531796570418691E-3DL, 1.511222515036021033410078631914783519649E-1DL, 1.289264341917429958858379585970225092274E0DL, 6.147640356182230769548007536914983522270E0DL, 1.573966871337739784518246317003956180750E1DL, 1.955534123435095067199574045529218238263E1DL, 9.472613121363135472247929109615785855865E0DL /* 1.0E0 */ }; DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { _Decimal128 a, y, z; int32_t sign; sign = (x < 0.0DL); a = FUNC_D(__fabs) (x); if (a >= 0x7fff0000) /* erf(nan)=nan */ return (DEC_TYPE) ((1 - (sign<<1)) + one / x); /* erf(+-inf)=+-1 */ if (a >= 1.0DL) /* |x| >= 1.0 */ { y = FUNC_D(__erfc) (x); return (one - y); /* return (one - __erfcl (x)); */ } z = x * x; if (a < 0.875DL) /* a < 0.875 */ { if (a < 2.0E-57DL) /* |x|<2**-57 */ { if (a < 0x00080000) //TODO:What is this number? return (DEC_TYPE)(0.125DL * (8.0DL * x + efx8 * x)); /*avoid underflow */ return (DEC_TYPE)(x + efx * x); } y = a + a * neval (z, TN1, NTN1) / deval (z, TD1, NTD1); } else { a = a - one; y = erf_const + neval (a, TN2, NTN2) / deval (a, TD2, NTD2); } if (sign) /* x < 0 */ y = -y; return( (DEC_TYPE)y ); } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) /* This is a bit sloppy, but it works */ #undef FUNCTION_NAME #define FUNCTION_NAME erfc #include DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { _Decimal128 y=0.0DL, z, p, r, ix; int32_t i, sign; sign = (x < 0.0DL); ix = FUNC_D(__fabs) (x); if (ix >= 0x7fff0000) { /* erfc(nan)=nan */ /* erfc(+-inf)=0,2 */ return (DEC_TYPE) ((sign << 1) + one / x); } if (ix < 0.25DL) /* |x| <1/4 */ { if (ix < 2.0E-114DL) /* |x|<2**-114 */ return (DEC_TYPE)(one - x); return (DEC_TYPE)(one - FUNC_D(__erf) (x)); } x = ix; if (ix < 1.25DL) /* 1.25 */ { i = 8.0DF * x; switch (i) { case 2: z = x - 0.25DL; y = C13b + z * neval (z, RNr13, NRNr13) / deval (z, RDr13, NRDr13); y += C13a; break; case 3: z = x - 0.375DL; y = C14b + z * neval (z, RNr14, NRNr14) / deval (z, RDr14, NRDr14); y += C14a; break; case 4: z = x - 0.5DL; y = C15b + z * neval (z, RNr15, NRNr15) / deval (z, RDr15, NRDr15); y += C15a; break; case 5: z = x - 0.625DL; y = C16b + z * neval (z, RNr16, NRNr16) / deval (z, RDr16, NRDr16); y += C16a; break; case 6: z = x - 0.75DL; y = C17b + z * neval (z, RNr17, NRNr17) / deval (z, RDr17, NRDr17); y += C17a; break; case 7: z = x - 0.875DL; y = C18b + z * neval (z, RNr18, NRNr18) / deval (z, RDr18, NRDr18); y += C18a; break; case 8: z = x - 1.0DL; y = C19b + z * neval (z, RNr19, NRNr19) / deval (z, RDr19, NRDr19); y += C19a; break; case 9: z = x - 1.125DL; y = C20b + z * neval (z, RNr20, NRNr20) / deval (z, RDr20, NRDr20); y += C20a; break; } if (sign) y = 2.0DF - y; return y; } /* 1.25 < |x| < 107 */ if (ix < 107.0DF) { /* x < -9 */ if (x > 9.0DF && sign) return two - tiny; z = one / (x * x); i = 8.0DF / x; switch (i) { default: case 0: p = neval (z, RNr1, NRNr1) / deval (z, RDr1, NRDr1); break; case 1: p = neval (z, RNr2, NRNr2) / deval (z, RDr2, NRDr2); break; case 2: p = neval (z, RNr3, NRNr3) / deval (z, RDr3, NRDr3); break; case 3: p = neval (z, RNr4, NRNr4) / deval (z, RDr4, NRDr4); break; case 4: p = neval (z, RNr5, NRNr5) / deval (z, RDr5, NRDr5); break; case 5: p = neval (z, RNr6, NRNr6) / deval (z, RDr6, NRDr6); break; case 6: p = neval (z, RNr7, NRNr7) / deval (z, RDr7, NRDr7); break; case 7: p = neval (z, RNr8, NRNr8) / deval (z, RDr8, NRDr8); break; } /* Trim the value? u.value = x; u.parts32.w3 = 0; u.parts32.w2 &= 0xfe000000; z = u.value; */ z = ix; r = __expd128 (-z * z - 0.5625DF) * __expd128 ((z - x) * (z + x) + p); if (!sign) return (DEC_TYPE)(r / x); else return (DEC_TYPE)(two - r / x); } else { if (!sign) return (DEC_TYPE)(tiny * tiny); else return (DEC_TYPE)(two - tiny); } } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/erfd64.c000066400000000000000000000021111261375163000156210ustar00rootroot00000000000000/* Returns the error function of x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "erfd32.c" libdfp-1.0.12/ieee754r/exp2d128.c000066400000000000000000000021341261375163000160110ustar00rootroot00000000000000/* Returns the value of 2 raised to the power of x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "exp2d32.c" libdfp-1.0.12/ieee754r/exp2d32.c000066400000000000000000000043551261375163000157320ustar00rootroot00000000000000/* Returns the value of 2 raised to the power of x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 #endif #include #include #include #include #include #include #define FUNCTION_NAME exp2 #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; decNumber dn_two; DEC_TYPE two = DFP_CONSTANT(2.0); FUNC_CONVERT_TO_DN (&two, &dn_two); FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x)) return x+x; if (decNumberIsInfinite (&dn_x) ) return decNumberIsNegative (&dn_x) ? DFP_CONSTANT(0.0) : x; decContextDefault (&context, DEFAULT_CONTEXT); /* decNumberPow (&dn_result, &dn_two, &dn_x, &context); */ decNumberPower (&dn_result, &dn_two, &dn_x, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); if(context.status & DEC_Overflow) DFP_EXCEPT (FE_OVERFLOW); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); if (!FUNC_D(__isfinite) (z) && FUNC_D(__isfinite) (x)) DFP_ERRNO (ERANGE); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/exp2d64.c000066400000000000000000000021321261375163000157260ustar00rootroot00000000000000/* Returns the value of 2 raised to the power of x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "exp2d32.c" libdfp-1.0.12/ieee754r/expd128.c000066400000000000000000000021411261375163000157250ustar00rootroot00000000000000/* Calculate e^x, where x is the given _Decimal128 value Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "expd32.c" libdfp-1.0.12/ieee754r/expd32.c000066400000000000000000000044171261375163000156470ustar00rootroot00000000000000/* Calculate e^x, where x is the given _Decimal32 value Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 /* needed to pick up DECNUMDIGITS before including decNumber.h */ # include #endif #include #include #include #include #include #include #define FUNCTION_NAME exp #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; FUNC_CONVERT_TO_DN(&x, &dn_x); decContextDefault(&context, DEFAULT_CONTEXT); if (decNumberIsInfinite(&dn_x)) { if (decNumberIsNegative(&dn_x)) { decNumberZero(&dn_result); /* exp(-inf) = 0 */ } else { dn_result = dn_x; /* exp(inf) = inf */ } } else { decNumberExp(&dn_result, &dn_x, &context); } FUNC_CONVERT_FROM_DN(&dn_result, &result, &context); if (context.status & DEC_Overflow) DFP_EXCEPT (FE_OVERFLOW); if (context.status & DEC_Underflow) DFP_EXCEPT (FE_UNDERFLOW); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); if (!FUNC_D(__isfinite) (z) && FUNC_D(__isfinite) (x)) DFP_ERRNO (ERANGE); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/expd64.c000066400000000000000000000021361261375163000156500ustar00rootroot00000000000000/* Calculate e^x, where x is the given _Decimal64 value Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "expd32.c" libdfp-1.0.12/ieee754r/expm1d128.c000066400000000000000000000021261261375163000161660ustar00rootroot00000000000000/* Returns a value equivelent to exp(x) - 1 Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "expm1d32.c" libdfp-1.0.12/ieee754r/expm1d32.c000066400000000000000000000043651261375163000161070ustar00rootroot00000000000000/* Returns a value equivelent to exp(x) - 1 Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 #endif #include #include #include #include #include #include #define FUNCTION_NAME expm1 #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; decNumber dn_one; decNumber dn_exponent; DEC_TYPE one = DFP_CONSTANT(1.0); FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&one, &dn_one); if (decNumberIsNaN (&dn_x)) return x+x; if (decNumberIsInfinite (&dn_x)) return decNumberIsNegative (&dn_x) ? DFP_CONSTANT(-1.0) : x; decContextDefault(&context, DEFAULT_CONTEXT); decNumberExp(&dn_exponent, &dn_x, &context); decNumberSubtract(&dn_result, &dn_exponent, &dn_one, &context); FUNC_CONVERT_FROM_DN(&dn_result, &result, &context); if (context.status & DEC_Overflow) DFP_EXCEPT (FE_OVERFLOW); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); if (!FUNC_D(__isfinite) (z) && FUNC_D(__isfinite) (x)) DFP_ERRNO (ERANGE); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/expm1d64.c000066400000000000000000000021241261375163000161030ustar00rootroot00000000000000/* Returns a value equivelent to exp(x) - 1 Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "expm1d32.c" libdfp-1.0.12/ieee754r/fabsd128.c000066400000000000000000000021401261375163000160430ustar00rootroot00000000000000/* Calculate the absolute value for a _Decimal128 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "fabsd32.c" libdfp-1.0.12/ieee754r/fabsd32.c000066400000000000000000000032551261375163000157650ustar00rootroot00000000000000/* Calculate the absolute value for a _Decimal32 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #define FUNCTION_NAME fabs #include DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; FUNC_CONVERT_TO_DN (&x, &dn_x); decContextDefault (&context, DEFAULT_CONTEXT); decNumberAbs (&dn_result, &dn_x, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } hidden_def (INTERNAL_FUNCTION_NAME) weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/fabsd64.c000066400000000000000000000021351261375163000157660ustar00rootroot00000000000000/* Calculate the absolute value for a _Decimal64 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "fabsd32.c" libdfp-1.0.12/ieee754r/fdimd128.c000066400000000000000000000021631261375163000160540ustar00rootroot00000000000000/* Returns the positive difference between the _Decimal128 type arguments Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "fdimd32.c" libdfp-1.0.12/ieee754r/fdimd32.c000066400000000000000000000050101261375163000157600ustar00rootroot00000000000000/* Returns the positive difference between the _Decimal32 type arguments Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #include #define FUNCTION_NAME fdim #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; decNumber dn_y; decNumber dn_diff; DEC_TYPE temp_diff; DEC_TYPE temp_result; FUNC_CONVERT_TO_DN (&x, &dn_x); FUNC_CONVERT_TO_DN (&y, &dn_y); if(decNumberIsNaN (&dn_x) || decNumberIsNaN (&dn_y)) return x; decContextDefault (&context, DEFAULT_CONTEXT); decNumberSubtract (&dn_diff, &dn_x, &dn_y, &context); decNumberSubtract (&dn_result, &dn_x, &dn_x, &context); FUNC_CONVERT_FROM_DN (&dn_diff, &temp_diff, &context); FUNC_CONVERT_FROM_DN (&dn_result, &temp_result, &context); if(temp_diff>temp_result) decNumberAdd (&dn_result,&dn_result,&dn_diff,&context); /* if(decCompare (&dn_diff,&dn_result) == 1) decNumberAdd (&dn_result,&dn_result,&dn_diff,&context); */ FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); if (context.status & DEC_Overflow) DFP_EXCEPT (FE_OVERFLOW); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { DEC_TYPE z = IEEE_FUNCTION_NAME (x, y); if (!FUNC_D(__isfinite) (z) && FUNC_D(__isfinite) (x)) DFP_ERRNO (ERANGE); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/fdimd64.c000066400000000000000000000021601261375163000157700ustar00rootroot00000000000000/* Returns the positive difference between the _Decimal64 type arguments Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "fdimd32.c" libdfp-1.0.12/ieee754r/floord128.c000066400000000000000000000021221261375163000162510ustar00rootroot00000000000000/* Floor function for _Decimal128 types Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "floord32.c" libdfp-1.0.12/ieee754r/floord32.c000066400000000000000000000033701261375163000161710ustar00rootroot00000000000000/* Floor function for _Decimal32 types Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #define FUNCTION_NAME floor #include DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x) || decNumberIsInfinite (&dn_x) || decNumberIsZero (&dn_x) ) return x+x; decContextDefault (&context, DEFAULT_CONTEXT); context.round = DEC_ROUND_FLOOR; decNumberToIntegralValue (&dn_result, &dn_x, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/floord64.c000066400000000000000000000021171261375163000161740ustar00rootroot00000000000000/* Floor function for _Decimal64 types Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "floord32.c" libdfp-1.0.12/ieee754r/fmad128.c000066400000000000000000000021271261375163000157000ustar00rootroot00000000000000/* Floating point multiply and add (x * y + z) Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "fmad32.c" libdfp-1.0.12/ieee754r/fmad32.c000066400000000000000000000061701261375163000156140ustar00rootroot00000000000000/* Floating point multiply and add (x * y + z) Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 #endif #include #include #include #include #include #include #define FUNCTION_NAME fma #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y, DEC_TYPE z) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; decNumber dn_y; decNumber dn_product; decNumber dn_z; FUNC_CONVERT_TO_DN (&x, &dn_x); FUNC_CONVERT_TO_DN (&y, &dn_y); FUNC_CONVERT_TO_DN (&z, &dn_z); /* If x or y is NaN, return NaN */ if (decNumberIsNaN (&dn_x) || decNumberIsNaN (&dn_y)) return x+y; /* Domain error if x or y is Inf, the other is 0 */ if ( (decNumberIsInfinite (&dn_x) && decNumberIsZero (&dn_y)) || (decNumberIsInfinite (&dn_y) && decNumberIsZero (&dn_x)) ) { DFP_EXCEPT (FE_INVALID); return DFP_NAN; } /* If x and y are not 0,Inf or Inf,0, and z is NaN, return NaN */ if (decNumberIsNaN (&dn_z)) return z+z; decContextDefault (&context, DEFAULT_CONTEXT); decNumberMultiply (&dn_product, &dn_x, &dn_y, &context); /* Domain error if x*y = Inf and z=Inf (with opposite signs) */ if (decNumberIsInfinite (&dn_product) && decNumberIsInfinite (&dn_z) && (decNumberIsNegative (&dn_product) != decNumberIsNegative (&dn_z))) { DFP_EXCEPT (FE_INVALID); return DFP_NAN; } decNumberAdd (&dn_result, &dn_product, &dn_z, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y, DEC_TYPE z) { DEC_TYPE r = IEEE_FUNCTION_NAME (x, y, z); if ( (FUNC_D(__isinf) (x) && y == DFP_CONSTANT(0.0)) || (FUNC_D(__isinf) (y) && x == DFP_CONSTANT(0.0)) ) DFP_ERRNO(EDOM); else if (FUNC_D (__isinf) (z)) { int isneg = FUNC_D(__signbit) (x) ^ FUNC_D(__signbit) (y); int inf = FUNC_D(__isinf) (x) | FUNC_D(__isinf) (y); if ( inf && FUNC_D (__signbit) (z) != isneg) DFP_ERRNO (EDOM); } return r; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/fmad64.c000066400000000000000000000021251261375163000156150ustar00rootroot00000000000000/* Floating point multiply and add (x * y + z) Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "fmad32.c" libdfp-1.0.12/ieee754r/fmaxd128.c000066400000000000000000000021331261375163000160650ustar00rootroot00000000000000/* Determine the maximum of two _Decimal128 types Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "fmaxd32.c" libdfp-1.0.12/ieee754r/fmaxd32.c000066400000000000000000000034131261375163000160010ustar00rootroot00000000000000/* Determine the maximum of two _Decimal32 types Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 /* needed to pick up DECNUMDIGITS before including decNumber.h */ # include #endif #include #include #include #include #define FUNCTION_NAME fmax #include DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; decNumber dn_y; FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&y, &dn_y); decContextDefault(&context, DEFAULT_CONTEXT); decNumberMax(&dn_result, &dn_x, &dn_y, &context); FUNC_CONVERT_FROM_DN(&dn_result, &result, &context); return result; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/fmaxd64.c000066400000000000000000000021301261375163000160010ustar00rootroot00000000000000/* Determine the maximum of two _Decimal64 types Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "fmaxd32.c" libdfp-1.0.12/ieee754r/fmind128.c000066400000000000000000000021331261375163000160630ustar00rootroot00000000000000/* Determine the minimum of two _Decimal128 types Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "fmind32.c" libdfp-1.0.12/ieee754r/fmind32.c000066400000000000000000000034131261375163000157770ustar00rootroot00000000000000/* Determine the minimum of two _Decimal32 types Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 /* needed to pick up DECNUMDIGITS before including decNumber.h */ # include #endif #include #include #include #include #define FUNCTION_NAME fmin #include DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; decNumber dn_y; FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&y, &dn_y); decContextDefault(&context, DEFAULT_CONTEXT); decNumberMin(&dn_result, &dn_x, &dn_y, &context); FUNC_CONVERT_FROM_DN(&dn_result, &result, &context); return result; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/fmind64.c000066400000000000000000000021301261375163000157770ustar00rootroot00000000000000/* Determine the minimum of two _Decimal64 types Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "fmind32.c" libdfp-1.0.12/ieee754r/fmodd128.c000066400000000000000000000021371261375163000160630ustar00rootroot00000000000000/* Returns the remainder of a floating point division Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "fmodd32.c" libdfp-1.0.12/ieee754r/fmodd32.c000066400000000000000000000050151261375163000157730ustar00rootroot00000000000000/* Returns the remainder of a floating point division Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 #endif #include #include #include #include #include #define FUNCTION_NAME fmod #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decContext context; decNumber dn_result; /* decNumber dn_mult; */ /* decNumber dn_rounded; */ DEC_TYPE result; decNumber dn_x; decNumber dn_y; FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&y, &dn_y); if (decNumberIsNaN (&dn_x) || decNumberIsNaN (&dn_y) ) return x+y; if (decNumberIsZero (&dn_y) || decNumberIsInfinite (&dn_x)) { DFP_EXCEPT (FE_INVALID); return DFP_NAN; } if (decNumberIsZero (&dn_x) || decNumberIsInfinite (&dn_y)) return x; decContextDefault (&context, DEFAULT_CONTEXT); /* decNumberDivide (&dn_mult, &dn_x, &dn_y, &context); context.round = DEC_ROUND_DOWN; decNumberToIntegralValue (&dn_rounded, &dn_mult, &context); decNumberMultiply (&dn_mult, &dn_rounded, &dn_y, &context); decNumberSubtract (&dn_result, &dn_x, &dn_mult, &context); */ decNumberRemainder(&dn_result, &dn_x, &dn_y, &context); FUNC_CONVERT_FROM_DN(&dn_result, &result, &context); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { DEC_TYPE z = IEEE_FUNCTION_NAME (x, y); if (!FUNC_D(__isinf) (x) || y == DFP_CONSTANT(0.0)) DFP_ERRNO (EDOM); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/fmodd64.c000066400000000000000000000021351261375163000160000ustar00rootroot00000000000000/* Returns the remainder of a floating point division Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "fmodd32.c" libdfp-1.0.12/ieee754r/fpclassifyd128.c000066400000000000000000000040021261375163000172720ustar00rootroot00000000000000/* Returns the type of floating point number from a _Decimal128 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include #define _DECIMAL_SIZE 128 #include #include int __fpclassifyd128 (_Decimal128 x) { decNumber dn_x; decContext context; FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x)) return FP_NAN; else if (decNumberIsInfinite (&dn_x)) return FP_INFINITE; else if (decNumberIsZero (&dn_x)) return FP_ZERO; /* Since DFP value are not normalized, checking the exponent for normal/subnormal is not suffice. For instance, the value 10e-96 will result in a expoenent below the minimum, however it is still a FP_NORMAL number due implicit normalization. TO avoid such traps the check relies on runtime comparisons. */ decContextDefault (&context, DEC_INIT_DECIMAL128); if (decNumberIsSubnormal (&dn_x, &context)) return FP_SUBNORMAL; return FP_NORMAL; } hidden_def (__fpclassifyd128) weak_alias (__fpclassifyd128, fpclassifyd128) libdfp-1.0.12/ieee754r/fpclassifyd32.c000066400000000000000000000037071261375163000172170ustar00rootroot00000000000000/* Returns the type of floating point number from a _Decimal32 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include #define _DECIMAL_SIZE 32 #include #include int __fpclassifyd32 (_Decimal32 x) { decNumber dn_x; decContext context; FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x)) return FP_NAN; else if (decNumberIsInfinite (&dn_x)) return FP_INFINITE; else if (decNumberIsZero (&dn_x)) return FP_ZERO; /* Since DFP value are not normalized, checking the exponent for normal/subnormal is not suffice. For instance, the value 10e-96 will result in a expoenent below the minimum, however it is still a FP_NORMAL number due implicit normalization. TO avoid such traps the check relies on runtime comparisons. */ decContextDefault (&context, DEC_INIT_DECIMAL32); if (decNumberIsSubnormal (&dn_x, &context)) return FP_SUBNORMAL; return FP_NORMAL; } hidden_def (__fpclassifyd32) weak_alias (__fpclassifyd32, fpclassifyd32) libdfp-1.0.12/ieee754r/fpclassifyd64.c000066400000000000000000000037711261375163000172250ustar00rootroot00000000000000/* Returns the type of floating point number from a _Decimal64 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include #define _DECIMAL_SIZE 64 #include #include int __fpclassifyd64 (_Decimal64 x) { decNumber dn_x; decContext context; FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x)) return FP_NAN; else if (decNumberIsInfinite (&dn_x)) return FP_INFINITE; else if (decNumberIsZero (&dn_x)) return FP_ZERO; /* Since DFP value are not normalized, checking the exponent for normal/subnormal is not suffice. For instance, the value 10e-96 will result in a expoenent below the minimum, however it is still a FP_NORMAL number due implicit normalization. TO avoid such traps the check relies on runtime comparisons. */ decContextDefault (&context, DEC_INIT_DECIMAL64); if (decNumberIsSubnormal (&dn_x, &context)) return FP_SUBNORMAL; return FP_NORMAL; } hidden_def (__fpclassifyd64) weak_alias (__fpclassifyd64, fpclassifyd64) libdfp-1.0.12/ieee754r/frexpd128.c000066400000000000000000000021741261375163000162630ustar00rootroot00000000000000/* Break floating point number into normalized fraction and integral power of two Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "frexpd32.c" libdfp-1.0.12/ieee754r/frexpd32.c000066400000000000000000000052261261375163000161760ustar00rootroot00000000000000/* Break dfp number into normalized fraction and integral power of two Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #include #define FUNCTION_NAME frexp #include #include DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x, int *y) { /* GCC isn't smart enough to realize that the else block sets this in the * FUNC_CONVERT_FROM_DN macro so simply initialize it to NaN to silence the * warnings. */ DEC_TYPE result = DEC_NAN; #if NUMDIGITS_SUPPORT==1 int digits, exponent; if (FUNC_D (__isinf) (x) || FUNC_D (__isnan) (x)) return x+x; // Given 3.1e0 is encoded as 31e-1 and we want .31e1 // We have 2 'digits'. // Given 30.0e0 is encoded as 300e-1 and we want .300e2 // We have 3 'digits'. // Given .003e0 is encoded as 3e3 and we want .3e-2 // We have 1 'digits'. digits = FUNC_D (numdigits) (x); // We have -1 exponent. // We have -1 exponent. // We have -3 exponent. exponent = FUNC_D (getexp) (x); *y = digits + exponent; result = FUNC_D(setexp) (x, -digits); //2 + (-1) = 1 0 //3 + (-1) = 2 0 //1 + (-3) = -2 #else decNumber dn_x; decContext context; *y = 0; FUNC_CONVERT_TO_DN(&x, &dn_x); if (___decNumberIsNaN (&dn_x) || ___decNumberIsInfinite (&dn_x) || ___decNumberIsZero (&dn_x)) return x+x; *y = dn_x.digits + dn_x.exponent; dn_x.exponent = -dn_x.digits; decContextDefault(&context, DEFAULT_CONTEXT); FUNC_CONVERT_FROM_DN (&dn_x, &result, &context); #endif return result; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/frexpd64.c000066400000000000000000000021721261375163000162000ustar00rootroot00000000000000/* Break floating point number into normalized fraction and integral power of two Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "frexpd32.c" libdfp-1.0.12/ieee754r/hypotd128.c000066400000000000000000000021031261375163000162720ustar00rootroot00000000000000/* Returns sqrt(x*x+y*y) Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "hypotd32.c" libdfp-1.0.12/ieee754r/hypotd32.c000066400000000000000000000046201261375163000162120ustar00rootroot00000000000000/* Returns sqrt(x*x+y*y) Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 #endif #include #include #include #include #include #include #define FUNCTION_NAME hypot #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; decNumber dn_xx; decNumber dn_y; decNumber dn_yy; decNumber dn_sum; FUNC_CONVERT_TO_DN (&x, &dn_x); FUNC_CONVERT_TO_DN (&y, &dn_y); if (decNumberIsInfinite (&dn_x)) return x; if (decNumberIsInfinite (&dn_y)) return y; if (decNumberIsNaN (&dn_x) || decNumberIsNaN (&dn_y)) return x+y; decContextDefault (&context, DEFAULT_CONTEXT); decNumberMultiply (&dn_xx, &dn_x, &dn_x, &context); decNumberMultiply (&dn_yy, &dn_y, &dn_y, &context); decNumberAdd (&dn_sum, &dn_xx, &dn_yy, &context); decNumberSquareRoot (&dn_result, &dn_sum, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); if (context.status & DEC_Overflow) DFP_EXCEPT (FE_OVERFLOW); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { DEC_TYPE z = IEEE_FUNCTION_NAME (x, y); if (!FUNC_D(__isfinite) (z) && FUNC_D(__isfinite) (x) && FUNC_D(__isfinite) (y)) DFP_ERRNO (ERANGE); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/hypotd64.c000066400000000000000000000021011261375163000162070ustar00rootroot00000000000000/* Returns sqrt(x*x+y*y) Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "hypotd32.c" libdfp-1.0.12/ieee754r/ilogbd128.c000066400000000000000000000021651261375163000162330ustar00rootroot00000000000000/* Returns the unbiased exponent of the passed _Decimal128 value as an int Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "ilogbd32.c" libdfp-1.0.12/ieee754r/ilogbd32.c000066400000000000000000000063541261375163000161510ustar00rootroot00000000000000/* Returns the unbiased exponent of the passed _Decimal32 value as an int Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 #endif #ifndef _RETURN_TYPE # define _RETURN_TYPE int #endif #ifndef _MAX_VALUE # define _MAX_VALUE INT_MAX #endif #ifndef _MIN_VALUE # define _MIN_VALUE INT_MIN #endif #ifndef _FBLOG0 # define _FBLOG0 FP_ILOGB0 #endif #ifndef _FBLOGNAN # define _FBLOGNAN FP_ILOGBNAN #endif #include #include #include #include #include #include #ifndef FUNCTION_NAME # define FUNCTION_NAME ilogb #endif #include _RETURN_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE result; decContext context; decNumber dn_result; decNumber dn_x; decNumber dn_absx; decNumber dn_logx; decNumber dn_one; decNumber dn_cmp; enum rounding round; FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsZero (&dn_x)) { DFP_EXCEPT (FE_INVALID); DFP_ERRNO (EDOM); return _FBLOG0; } if (decNumberIsInfinite (&dn_x)) { DFP_EXCEPT (FE_INVALID); DFP_ERRNO (EDOM); return decNumberIsNegative (&dn_x) ? _MIN_VALUE : _MAX_VALUE; } if (decNumberIsNaN (&dn_x)) { DFP_EXCEPT (FE_INVALID); DFP_ERRNO (EDOM); return _FBLOGNAN; } decContextDefault (&context, DEFAULT_CONTEXT); decNumberAbs (&dn_absx, &dn_x, &context); /* For DFP, we use radix 10 instead of whatever FLT_RADIX happens to be */ decNumberLog10 (&dn_logx, &dn_absx, &context); /* Capture the case where truncation will return the wrong result, by rounding up if -1.0 < x < 1.0 */ round = DEC_ROUND_DOWN; decNumberFromInt32 (&dn_one, 1); decNumberCompare (&dn_cmp, &dn_x, &dn_one, &context); if (-decNumberIsNegative(&dn_cmp)) { decNumberFromInt32 (&dn_one, -1); decNumberCompare (&dn_cmp, &dn_x, &dn_one, &context); if (!decNumberIsNegative(&dn_cmp) && !decNumberIsZero(&dn_cmp)) round = DEC_ROUND_UP; } context.round = round; decNumberToIntegralValue (&dn_result, &dn_logx, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); /* Use _Decimal* to int casting. */ return (_RETURN_TYPE) result; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/ilogbd64.c000066400000000000000000000021621261375163000161470ustar00rootroot00000000000000/* Returns the unbiased exponent of the passed _Decimal64 value as an int Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "ilogbd32.c" libdfp-1.0.12/ieee754r/isfinited128.c000066400000000000000000000033171261375163000167510ustar00rootroot00000000000000/* Returns non-zero if the _Decimal128 is non-infinite Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include int __isfinited128 (_Decimal128 x) { uint64_t hx; GET_DEC128_HIGH_WORD64 (hx, x); if (((hx & DEC128_NAN_MASK64) == DEC128_NAN_MASK64) || ((hx & DEC128_INF_MASK64) == DEC128_INF_MASK64)) return 0; return 1; } hidden_def (__isfinited128) weak_alias (__isfinited128, isfinited128) /* We erroneously published a version of math.h which used 'finite' instead of * 'isfinite' and math.h contained a polymorphic 'isfinite()' function which * inlined calles to 'finited*' so we've created aliases for compatability. */ strong_alias (__isfinited128, finited128) strong_alias (__isfinited128, __finited128) libdfp-1.0.12/ieee754r/isfinited32.c000066400000000000000000000033371261375163000166650ustar00rootroot00000000000000/* Returns non-zero if the _Decimal32 is non-infinite Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include int __isfinited32 (_Decimal32 x) { uint32_t hx; GET_DEC32_WORD (hx, x); if (((hx & DEC32_NAN_MASK) == DEC32_NAN_MASK) || ((hx & DEC32_INF_MASK) == DEC32_INF_MASK)) return 0; return 1; } hidden_def (__isfinited32) weak_alias (__isfinited32, isfinited32) /* We erroneously published a version of math.h which used 'finite' instead of * 'isfinite' and math.h contained a polymorphic 'isfinite()' function which * inlined calles to 'finited*' so we've created aliases for compatability. */ strong_alias (__isfinited32, finited32) strong_alias (__isfinited32, __finited32) libdfp-1.0.12/ieee754r/isfinited64.c000066400000000000000000000032731261375163000166710ustar00rootroot00000000000000/* Returns non-zero if the _Decimal64 is non-infinite Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include int __isfinited64 (_Decimal64 x) { uint64_t hx; GET_DEC64_WORD64 (hx, x); if (((hx & DEC64_NAN_MASK64) == DEC64_NAN_MASK64) || ((hx & DEC64_INF_MASK64) == DEC64_INF_MASK64)) return 0; return 1; } hidden_def (__isfinited64) weak_alias (__isfinited64, isfinited64) /* We erroneously published a version of math.h which used 'finite' instead of * 'isfinite' and math.h contained a polymorphic 'isfinite()' function which * inlined calles to 'finited*' so we've created aliases for compatability. */ strong_alias (__isfinited64, finited64) strong_alias (__isfinited64, __finited64) libdfp-1.0.12/ieee754r/isgreaterd128.c000066400000000000000000000021131261375163000171150ustar00rootroot00000000000000/* Implements > for _Decimal Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "isgreaterd32.c" libdfp-1.0.12/ieee754r/isgreaterd32.c000066400000000000000000000034031261375163000170320ustar00rootroot00000000000000/* Implements > for _Decimal32 Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 /* needed to pick up DECNUMDIGITS before including decNumber.h */ # include #endif #include #include #include #define FUNCTION_NAME isgreater #include #include int INTERNAL_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decNumber dn_x; decNumber dn_y; decNumber dn_result; decContext context; FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&y, &dn_y); if(decNumberIsNaN(&dn_x) || decNumberIsNaN(&dn_y)) return 0; decNumberCompare (&dn_result, &dn_x, &dn_y, &context); return !decNumberIsNegative (&dn_result) && !decNumberIsZero(&dn_result); } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/isgreaterd64.c000066400000000000000000000021111261375163000170320ustar00rootroot00000000000000/* Implements > for _Decimal Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "isgreaterd32.c" libdfp-1.0.12/ieee754r/isgreaterequald128.c000066400000000000000000000021211261375163000201440ustar00rootroot00000000000000/* Implements >= for _Decimal Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "isgreaterequald32.c" libdfp-1.0.12/ieee754r/isgreaterequald32.c000066400000000000000000000034211261375163000200620ustar00rootroot00000000000000/* Implements >= for _Decimal32 Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 /* needed to pick up DECNUMDIGITS before including decNumber.h */ # include #endif #include #include #include #define FUNCTION_NAME isgreaterequal #include #include int INTERNAL_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decNumber dn_x; decNumber dn_y; decNumber result; decContext context; FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&y, &dn_y); if (decNumberIsNaN(&dn_x) || decNumberIsNaN(&dn_y)) return 0; decContextDefault (&context, DEFAULT_CONTEXT); decNumberCompare (&result, &dn_x, &dn_y, &context); return !decNumberIsNegative(&result); } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/isgreaterequald64.c000066400000000000000000000021171261375163000200700ustar00rootroot00000000000000/* Implements >= for _Decimal Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "isgreaterequald32.c" libdfp-1.0.12/ieee754r/isinfd128.c000066400000000000000000000026031261375163000162440ustar00rootroot00000000000000/* Returns non-zero if the _Decimal128 is infinite Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include int __isinfd128 (_Decimal128 x) { uint64_t hx; GET_DEC128_HIGH_WORD64 (hx, x); /* 0 1111000 ... == sINF */ return ((hx & DEC128_NAN_MASK64) == DEC128_INF_MASK64) ? ((hx & UINT64_C(0x8000000000000000)) ? -1 : 1) : 0; } hidden_def (__isinfd128) weak_alias (__isinfd128, isinfd128) libdfp-1.0.12/ieee754r/isinfd32.c000066400000000000000000000025351261375163000161620ustar00rootroot00000000000000/* Returns non-zero if the _Decimal32 is infinite Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include int __isinfd32 (_Decimal32 x) { uint32_t hx; GET_DEC32_WORD (hx, x); /* 0 1111000 ... == sINF */ return ((hx & DEC32_NAN_MASK) == DEC32_INF_MASK) ? ((hx & 0x80000000) ? -1 : 1) : 0; } hidden_def (__isinfd32) weak_alias (__isinfd32, isinfd32) libdfp-1.0.12/ieee754r/isinfd64.c000066400000000000000000000025651261375163000161720ustar00rootroot00000000000000/* Returns non-zero if the _Decimal64 is infinite Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include int __isinfd64 (_Decimal64 x) { uint64_t hx; GET_DEC64_WORD64 (hx, x); /* 0 1111000 ... == sINF */ return ((hx & DEC64_NAN_MASK64) == DEC64_INF_MASK64) ? ((hx & UINT64_C(0x8000000000000000)) ? -1 : 1) : 0; } hidden_def (__isinfd64) weak_alias (__isinfd64, isinfd64) libdfp-1.0.12/ieee754r/islessd128.c000066400000000000000000000021101261375163000164270ustar00rootroot00000000000000/* Implements < for _Decimal Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "islessd32.c" libdfp-1.0.12/ieee754r/islessd32.c000066400000000000000000000034201261375163000163460ustar00rootroot00000000000000/* Implements < for _Decimal32 Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 /* needed to pick up DECNUMDIGITS before including decNumber.h */ # include #endif #include #include #include #define FUNCTION_NAME isless #include #include int INTERNAL_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decNumber dn_x; decNumber dn_y; decNumber dn_result; decContext context; FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&y, &dn_y); if (decNumberIsNaN(&dn_x) || decNumberIsNaN(&dn_y)) return 0; decContextDefault (&context, DEFAULT_CONTEXT); decNumberCompare (&dn_result, &dn_x, &dn_y, &context); return decNumberIsNegative(&dn_result); } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/islessd64.c000066400000000000000000000021061261375163000163530ustar00rootroot00000000000000/* Implements < for _Decimal Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "islessd32.c" libdfp-1.0.12/ieee754r/islessequald128.c000066400000000000000000000021161261375163000174650ustar00rootroot00000000000000/* Implements <= for _Decimal Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "islessequald32.c" libdfp-1.0.12/ieee754r/islessequald32.c000066400000000000000000000034461261375163000174060ustar00rootroot00000000000000/* Implements <= for _Decimal32 Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 /* needed to pick up DECNUMDIGITS before including decNumber.h */ # include #endif #include #include #include #define FUNCTION_NAME islessequal #include #include int INTERNAL_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decNumber dn_x; decNumber dn_y; decNumber result; decContext context; FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&y, &dn_y); if(decNumberIsNaN(&dn_x) || decNumberIsNaN(&dn_y)) return 0; decContextDefault(&context, DEFAULT_CONTEXT); decNumberCompare(&result, &dn_x, &dn_y, &context); return decNumberIsNegative(&result) || decNumberIsZero(&result); } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/islessequald64.c000066400000000000000000000021141261375163000174020ustar00rootroot00000000000000/* Implements <= for _Decimal Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "islessequald32.c" libdfp-1.0.12/ieee754r/islessgreaterd128.c000066400000000000000000000021201261375163000200020ustar00rootroot00000000000000/* Implements <> for _Decimal Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "islessgreaterd32.c" libdfp-1.0.12/ieee754r/islessgreaterd32.c000066400000000000000000000034641261375163000177300ustar00rootroot00000000000000/* Implements <> for _Decimal32 Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 /* needed to pick up DECNUMDIGITS before including decNumber.h */ # include #endif #include #include #include #define FUNCTION_NAME islessgreater #include #include int INTERNAL_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decNumber dn_x; decNumber dn_y; decNumber dn_result; decContext context; FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&y, &dn_y); if(decNumberIsNaN(&dn_x) || decNumberIsNaN(&dn_y)) return 0; decNumberCompare (&dn_result, &dn_x, &dn_y, &context); return (-decNumberIsNegative (&dn_result)) || (!decNumberIsNegative (&dn_result) && !decNumberIsZero (&dn_result)); } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/islessgreaterd64.c000066400000000000000000000021161261375163000177260ustar00rootroot00000000000000/* Implements <> for _Decimal Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "islessgreaterd32.c" libdfp-1.0.12/ieee754r/isnand128.c000066400000000000000000000025051261375163000162450ustar00rootroot00000000000000/* Returns non-zero if the _Decimal128 is nan Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include int __isnand128 (_Decimal128 x) { uint64_t hx; GET_DEC128_HIGH_WORD64 (hx, x); /* 0 11111 10 ... == sNaN */ return (hx & DEC128_NAN_MASK64) == DEC128_NAN_MASK64; } hidden_def (__isnand128) weak_alias (__isnand128, isnand128) libdfp-1.0.12/ieee754r/isnand32.c000066400000000000000000000024611261375163000161600ustar00rootroot00000000000000/* Returns non-zero if the _Decimal32 is nan Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include int __isnand32 (_Decimal32 x) { uint32_t hx; GET_DEC32_WORD (hx, x); /* 0 11111 10 ... == sNaN */ return (hx & DEC32_NAN_MASK) == DEC32_NAN_MASK; } hidden_def (__isnand32) weak_alias (__isnand32, isnand32) libdfp-1.0.12/ieee754r/isnand64.c000066400000000000000000000024671261375163000161730ustar00rootroot00000000000000/* Returns non-zero if the _Decimal64 is nan Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include int __isnand64 (_Decimal64 x) { uint64_t hx; GET_DEC64_WORD64 (hx, x); /* 0 11111 10 ... == sNaN */ return (hx & DEC64_NAN_MASK64) == DEC64_NAN_MASK64; } hidden_def (__isnand64) weak_alias (__isnand64, isnand64) libdfp-1.0.12/ieee754r/isnormald128.c000066400000000000000000000021421261375163000167560ustar00rootroot00000000000000/* Returns non-zero if the _Decimal128 is normalized Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "isnormald32.c" libdfp-1.0.12/ieee754r/isnormald32.c000066400000000000000000000037041261375163000166750ustar00rootroot00000000000000/* Returns non-zero if the _Decimal32 is normalized Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include /* Includes definitions of DEC##_MIN */ #define FUNCTION_NAME isnormal #include #include int INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE min = DFP_MIN; DEC_TYPE result; /*decNumber dn_min; */ decContext context; decNumber dn_x; decNumber dn_result; /* FUNC_CONVERT_TO_DN(&min, &dn_min); */ FUNC_CONVERT_TO_DN(&x, &dn_x); if(decNumberIsNaN(&dn_x) || decNumberIsInfinite(&dn_x) || decNumberIsZero(&dn_x)) return 0; decContextDefault(&context, DEFAULT_CONTEXT); decNumberAbs(&dn_result, &dn_x, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); if(result The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "isnormald32.c" libdfp-1.0.12/ieee754r/issignalingd128.c000066400000000000000000000023251261375163000174440ustar00rootroot00000000000000/* Returns non-zero if the _Decimal128 is a signaling nan Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include int __issignalingd128 (_Decimal128 x) { uint64_t hx; GET_DEC128_HIGH_WORD64 (hx, x); /* 0 11111 10 ... == sNaN */ return (hx & DEC128_SNAN_MASK64) == DEC128_SNAN_MASK64; } weak_alias (__issignalingd128, issignalingd128) libdfp-1.0.12/ieee754r/issignalingd32.c000066400000000000000000000023021261375163000173510ustar00rootroot00000000000000/* Returns non-zero if the _Decimal32 is a signaling nan Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include int __issignalingd32 (_Decimal32 x) { uint32_t hx; GET_DEC32_WORD (hx, x); /* 0 11111 10 ... == sNaN */ return (hx & DEC32_SNAN_MASK) == DEC32_SNAN_MASK; } weak_alias (__issignalingd32, issignalingd32) libdfp-1.0.12/ieee754r/issignalingd64.c000066400000000000000000000023101261375163000173550ustar00rootroot00000000000000/* Returns non-zero if the _Decimal64 is a signaling nan Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include int __issignalingd64 (_Decimal64 x) { uint64_t hx; GET_DEC64_WORD64 (hx, x); /* 0 11111 10 ... == sNaN */ return (hx & DEC64_SNAN_MASK64) == DEC64_SNAN_MASK64; } weak_alias (__issignalingd64, issignalingd64) libdfp-1.0.12/ieee754r/isunorderedd128.c000066400000000000000000000021351261375163000174570ustar00rootroot00000000000000/* Returns true if either _Decimal128 is NaN Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "isunorderedd32.c" libdfp-1.0.12/ieee754r/isunorderedd32.c000066400000000000000000000026421261375163000173740ustar00rootroot00000000000000/* Returns true if either _Decimal32 is NaN Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #define FUNCTION_NAME isunordered #include #include /* This isn't used explicity externally. */ int INTERNAL_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { return FUNC_D(__isnan) (x) || FUNC_D(__isnan) (y); } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/isunorderedd64.c000066400000000000000000000021321261375163000173730ustar00rootroot00000000000000/* Returns true if either _Decimal64 is NaN Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "isunorderedd32.c" libdfp-1.0.12/ieee754r/ldexpd128.c000066400000000000000000000021431261375163000162470ustar00rootroot00000000000000/* Returns the _Decimal128 value * 2^ the integral value Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "ldexpd32.c" libdfp-1.0.12/ieee754r/ldexpd32.c000066400000000000000000000052531261375163000161660ustar00rootroot00000000000000/* Returns the _Decimal32 value * 2^ the integral value Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 #endif #include #include #include #include #include #define FUNCTION_NAME ldexp #include #include #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x, int y) { DEC_TYPE result; long newexp; #if NUMDIGITS_SUPPORT==1 newexp = FUNC_D (getexp) (x) + y + 1; if (newexp > PASTE(DECIMAL,PASTE(_DECIMAL_SIZE,_Emax))) { result = DFP_HUGE_VAL; DFP_EXCEPT (FE_OVERFLOW); } else if (newexp < PASTE(DECIMAL,PASTE(_DECIMAL_SIZE,_Emin))) { result = -DFP_HUGE_VAL; DFP_EXCEPT (FE_OVERFLOW); } else result = FUNC_D(setexp) (x, newexp); #else decContext context; decNumber dn_x; FUNC_CONVERT_TO_DN (&x, &dn_x); if (___decNumberIsNaN (&dn_x) || ___decNumberIsZero (&dn_x) || ___decNumberIsInfinite (&dn_x)) return x+x; if (y == 0) return x; /* ldexp(x,y) is just x*10**y, which is equivalent to increasing the exponent * by y + 1. */ newexp = dn_x.exponent + y + 1; if(newexp > INT_MAX) newexp = INT_MAX; if(newexp < -INT_MAX) newexp = -INT_MAX; dn_x.exponent = newexp; decContextDefault (&context, DEFAULT_CONTEXT); FUNC_CONVERT_FROM_DN (&dn_x, &result, &context); if (context.status & DEC_Overflow) DFP_EXCEPT (FE_OVERFLOW); #endif return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x, int y) { DEC_TYPE z = IEEE_FUNCTION_NAME (x, y); if (!FUNC_D(__isfinite) (z) && FUNC_D(__isfinite) (x)) DFP_ERRNO (ERANGE); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/ldexpd64.c000066400000000000000000000021401261375163000161630ustar00rootroot00000000000000/* Returns the _Decimal64 value * 2^ the integral value Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "ldexpd32.c" libdfp-1.0.12/ieee754r/lgammad128.c000066400000000000000000000021751261375163000163760ustar00rootroot00000000000000/* Returns the natural logarithm of the absolute value of the Gamma function of x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "lgammad32.c" libdfp-1.0.12/ieee754r/lgammad32.c000066400000000000000000001024071261375163000163070ustar00rootroot00000000000000/* Natural logarithm of gamma function Copyright (C) 2001 Stephen L. Moshier Copyright (C) 2006 IBM Corporation. Copyright (C) 2001-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 #endif #include #include #include #include #include #include #define FUNCTION_NAME lgamma /* Adapted for libdfp from glibc in 2006 and donated to the FSF in 2007. * * lgammad32 * * Natural logarithm of gamma function * * * * SYNOPSIS: * * _Decimal128 x, y, lgamma32(); * extern int sgngam; * * y = lgammad32(x); * * * * DESCRIPTION: * * Returns the base e (2.718...) logarithm of the absolute * value of the gamma function of the argument. * The sign (+1 or -1) of the gamma function is returned in a * global (extern) variable named sgngam. * * The positive domain is partitioned into numerous segments for approximation. * For x > 10, * log gamma(x) = (x - 0.5) log(x) - x + log sqrt(2 pi) + 1/x R(1/x^2) * Near the minimum at x = x0 = 1.46... the approximation is * log gamma(x0 + z) = log gamma(x0) + z^2 P(z)/Q(z) * for small z. * Elsewhere between 0 and 10, * log gamma(n + z) = log gamma(n) + z P(z)/Q(z) * for various selected n and small z. * * The cosecant reflection formula is employed for negative arguments. * * * * ACCURACY: * * * arithmetic domain # trials peak rms * Relative error: * IEEE 10, 30 100000 3.9e-34 9.8e-35 * IEEE 0, 10 100000 3.8e-34 5.3e-35 * Absolute error: * IEEE -10, 0 100000 8.0e-34 8.0e-35 * IEEE -30, -10 100000 4.4e-34 1.0e-34 * IEEE -100, 100 100000 1.0e-34 * * The absolute error criterion is the same as relative error * when the function magnitude is greater than one but it is absolute * when the magnitude is less than one. * */ #include #include static const _Decimal128 PIDL = 3.1415926535897932384626433832795028841972E0DL; static const _Decimal128 MAXDLGM = 1.0485738685148938358098967157129705071571E4928DL; static const _Decimal128 one = 1.0DL; static const _Decimal128 zero = 0.0DL; static const _Decimal128 huge = 1.0e4000DL; /* log gamma(x) = ( x - 0.5 ) * log(x) - x + DLS2PI + 1/x P(1/x^2) 1/x <= 0.0741 (x >= 13.495...) Peak relative error 1.5e-36 */ static const _Decimal128 ls2pi = 9.1893853320467274178032973640561763986140E-1DL; #define NRASY 12 static const _Decimal128 RASY[NRASY + 1] = { 8.333333333333333333333333333310437112111E-2DL, -2.777777777777777777777774789556228296902E-3DL, 7.936507936507936507795933938448586499183E-4DL, -5.952380952380952041799269756378148574045E-4DL, 8.417508417507928904209891117498524452523E-4DL, -1.917526917481263997778542329739806086290E-3DL, 6.410256381217852504446848671499409919280E-3DL, -2.955064066900961649768101034477363301626E-2DL, 1.796402955865634243663453415388336954675E-1DL, -1.391522089007758553455753477688592767741E0DL, 1.326130089598399157988112385013829305510E1DL, -1.420412699593782497803472576479997819149E2DL, 1.218058922427762808938869872528846787020E3DL }; /* log gamma(x+13) = log gamma(13) + x P(x)/Q(x) -0.5 <= x <= 0.5 12.5 <= x+13 <= 13.5 Peak relative error 1.1e-36 */ static const _Decimal128 lgam13a = 1.9987213134765625E1DL; static const _Decimal128 lgam13b = 1.3608962611495173623870550785125024484248E-6DL; #define NRN13 7 static const _Decimal128 RN13[NRN13 + 1] = { 8.591478354823578150238226576156275285700E11DL, 2.347931159756482741018258864137297157668E11DL, 2.555408396679352028680662433943000804616E10DL, 1.408581709264464345480765758902967123937E9DL, 4.126759849752613822953004114044451046321E7DL, 6.133298899622688505854211579222889943778E5DL, 3.929248056293651597987893340755876578072E3DL, 6.850783280018706668924952057996075215223E0DL }; #define NRD13 6 static const _Decimal128 RD13[NRD13 + 1] = { 3.401225382297342302296607039352935541669E11DL, 8.756765276918037910363513243563234551784E10DL, 8.873913342866613213078554180987647243903E9DL, 4.483797255342763263361893016049310017973E8DL, 1.178186288833066430952276702931512870676E7DL, 1.519928623743264797939103740132278337476E5DL, 7.989298844938119228411117593338850892311E2DL /* 1.0E0DL */ }; /* log gamma(x+12) = log gamma(12) + x P(x)/Q(x) -0.5 <= x <= 0.5 11.5 <= x+12 <= 12.5 Peak relative error 4.1e-36 */ static const _Decimal128 lgam12a = 1.75023040771484375E1DL; static const _Decimal128 lgam12b = 3.7687254483392876529072161996717039575982E-6DL; #define NRN12 7 static const _Decimal128 RN12[NRN12 + 1] = { 4.709859662695606986110997348630997559137E11DL, 1.398713878079497115037857470168777995230E11DL, 1.654654931821564315970930093932954900867E10DL, 9.916279414876676861193649489207282144036E8DL, 3.159604070526036074112008954113411389879E7DL, 5.109099197547205212294747623977502492861E5DL, 3.563054878276102790183396740969279826988E3DL, 6.769610657004672719224614163196946862747E0DL }; #define NRD12 6 static const _Decimal128 RD12[NRD12 + 1] = { 1.928167007860968063912467318985802726613E11DL, 5.383198282277806237247492369072266389233E10DL, 5.915693215338294477444809323037871058363E9DL, 3.241438287570196713148310560147925781342E8DL, 9.236680081763754597872713592701048455890E6DL, 1.292246897881650919242713651166596478850E5DL, 7.366532445427159272584194816076600211171E2DL /* 1.0E0DL */ }; /* log gamma(x+11) = log gamma(11) + x P(x)/Q(x) -0.5 <= x <= 0.5 10.5 <= x+11 <= 11.5 Peak relative error 1.8e-35 */ static const _Decimal128 lgam11a = 1.5104400634765625E1DL; static const _Decimal128 lgam11b = 1.1938309890295225709329251070371882250744E-5DL; #define NRN11 7 static const _Decimal128 RN11[NRN11 + 1] = { 2.446960438029415837384622675816736622795E11DL, 7.955444974446413315803799763901729640350E10DL, 1.030555327949159293591618473447420338444E10DL, 6.765022131195302709153994345470493334946E8DL, 2.361892792609204855279723576041468347494E7DL, 4.186623629779479136428005806072176490125E5DL, 3.202506022088912768601325534149383594049E3DL, 6.681356101133728289358838690666225691363E0DL }; #define NRD11 6 static const _Decimal128 RD11[NRD11 + 1] = { 1.040483786179428590683912396379079477432E11DL, 3.172251138489229497223696648369823779729E10DL, 3.806961885984850433709295832245848084614E9DL, 2.278070344022934913730015420611609620171E8DL, 7.089478198662651683977290023829391596481E6DL, 1.083246385105903533237139380509590158658E5DL, 6.744420991491385145885727942219463243597E2DL /* 1.0E0DL */ }; /* log gamma(x+10) = log gamma(10) + x P(x)/Q(x) -0.5 <= x <= 0.5 9.5 <= x+10 <= 10.5 Peak relative error 5.4e-37 */ static const _Decimal128 lgam10a = 1.280181884765625E1DL; static const _Decimal128 lgam10b = 8.6324252196112077178745667061642811492557E-6DL; #define NRN10 7 static const _Decimal128 RN10[NRN10 + 1] = { -1.239059737177249934158597996648808363783E14DL, -4.725899566371458992365624673357356908719E13DL, -7.283906268647083312042059082837754850808E12DL, -5.802855515464011422171165179767478794637E11DL, -2.532349691157548788382820303182745897298E10DL, -5.884260178023777312587193693477072061820E8DL, -6.437774864512125749845840472131829114906E6DL, -2.350975266781548931856017239843273049384E4DL }; #define NRD10 7 static const _Decimal128 RD10[NRD10 + 1] = { -5.502645997581822567468347817182347679552E13DL, -1.970266640239849804162284805400136473801E13DL, -2.819677689615038489384974042561531409392E12DL, -2.056105863694742752589691183194061265094E11DL, -8.053670086493258693186307810815819662078E9DL, -1.632090155573373286153427982504851867131E8DL, -1.483575879240631280658077826889223634921E6DL, -4.002806669713232271615885826373550502510E3DL /* 1.0E0DL */ }; /* log gamma(x+9) = log gamma(9) + x P(x)/Q(x) -0.5 <= x <= 0.5 8.5 <= x+9 <= 9.5 Peak relative error 3.6e-36 */ static const _Decimal128 lgam9a = 1.06045989990234375E1DL; static const _Decimal128 lgam9b = 3.9037218127284172274007216547549861681400E-6DL; #define NRN9 7 static const _Decimal128 RN9[NRN9 + 1] = { -4.936332264202687973364500998984608306189E13DL, -2.101372682623700967335206138517766274855E13DL, -3.615893404644823888655732817505129444195E12DL, -3.217104993800878891194322691860075472926E11DL, -1.568465330337375725685439173603032921399E10DL, -4.073317518162025744377629219101510217761E8DL, -4.983232096406156139324846656819246974500E6DL, -2.036280038903695980912289722995505277253E4DL }; #define NRD9 7 static const _Decimal128 RD9[NRD9 + 1] = { -2.306006080437656357167128541231915480393E13DL, -9.183606842453274924895648863832233799950E12DL, -1.461857965935942962087907301194381010380E12DL, -1.185728254682789754150068652663124298303E11DL, -5.166285094703468567389566085480783070037E9DL, -1.164573656694603024184768200787835094317E8DL, -1.177343939483908678474886454113163527909E6DL, -3.529391059783109732159524500029157638736E3DL /* 1.0E0DL */ }; /* log gamma(x+8) = log gamma(8) + x P(x)/Q(x) -0.5 <= x <= 0.5 7.5 <= x+8 <= 8.5 Peak relative error 2.4e-37 */ static const _Decimal128 lgam8a = 8.525146484375E0DL; static const _Decimal128 lgam8b = 1.4876690414300165531036347125050759667737E-5DL; #define NRN8 8 static const _Decimal128 RN8[NRN8 + 1] = { 6.600775438203423546565361176829139703289E11DL, 3.406361267593790705240802723914281025800E11DL, 7.222460928505293914746983300555538432830E10DL, 8.102984106025088123058747466840656458342E9DL, 5.157620015986282905232150979772409345927E8DL, 1.851445288272645829028129389609068641517E7DL, 3.489261702223124354745894067468953756656E5DL, 2.892095396706665774434217489775617756014E3DL, 6.596977510622195827183948478627058738034E0DL }; #define NRD8 7 static const _Decimal128 RD8[NRD8 + 1] = { 3.274776546520735414638114828622673016920E11DL, 1.581811207929065544043963828487733970107E11DL, 3.108725655667825188135393076860104546416E10DL, 3.193055010502912617128480163681842165730E9DL, 1.830871482669835106357529710116211541839E8DL, 5.790862854275238129848491555068073485086E6DL, 9.305213264307921522842678835618803553589E4DL, 6.216974105861848386918949336819572333622E2DL /* 1.0E0DL */ }; /* log gamma(x+7) = log gamma(7) + x P(x)/Q(x) -0.5 <= x <= 0.5 6.5 <= x+7 <= 7.5 Peak relative error 3.2e-36 */ static const _Decimal128 lgam7a = 6.5792388916015625E0DL; static const _Decimal128 lgam7b = 1.2320408538495060178292903945321122583007E-5DL; #define NRN7 8 static const _Decimal128 RN7[NRN7 + 1] = { 2.065019306969459407636744543358209942213E11DL, 1.226919919023736909889724951708796532847E11DL, 2.996157990374348596472241776917953749106E10DL, 3.873001919306801037344727168434909521030E9DL, 2.841575255593761593270885753992732145094E8DL, 1.176342515359431913664715324652399565551E7DL, 2.558097039684188723597519300356028511547E5DL, 2.448525238332609439023786244782810774702E3DL, 6.460280377802030953041566617300902020435E0DL }; #define NRD7 7 static const _Decimal128 RD7[NRD7 + 1] = { 1.102646614598516998880874785339049304483E11DL, 6.099297512712715445879759589407189290040E10DL, 1.372898136289611312713283201112060238351E10DL, 1.615306270420293159907951633566635172343E9DL, 1.061114435798489135996614242842561967459E8DL, 3.845638971184305248268608902030718674691E6DL, 7.081730675423444975703917836972720495507E4DL, 5.423122582741398226693137276201344096370E2DL /* 1.0E0DL */ }; /* log gamma(x+6) = log gamma(6) + x P(x)/Q(x) -0.5 <= x <= 0.5 5.5 <= x+6 <= 6.5 Peak relative error 6.2e-37 */ static const _Decimal128 lgam6a = 4.7874908447265625E0DL; static const _Decimal128 lgam6b = 8.9805548349424770093452324304839959231517E-7DL; #define NRN6 8 static const _Decimal128 RN6[NRN6 + 1] = { -3.538412754670746879119162116819571823643E13DL, -2.613432593406849155765698121483394257148E13DL, -8.020670732770461579558867891923784753062E12DL, -1.322227822931250045347591780332435433420E12DL, -1.262809382777272476572558806855377129513E11DL, -7.015006277027660872284922325741197022467E9DL, -2.149320689089020841076532186783055727299E8DL, -3.167210585700002703820077565539658995316E6DL, -1.576834867378554185210279285358586385266E4DL }; #define NRD6 8 static const _Decimal128 RD6[NRD6 + 1] = { -2.073955870771283609792355579558899389085E13DL, -1.421592856111673959642750863283919318175E13DL, -4.012134994918353924219048850264207074949E12DL, -6.013361045800992316498238470888523722431E11DL, -5.145382510136622274784240527039643430628E10DL, -2.510575820013409711678540476918249524123E9DL, -6.564058379709759600836745035871373240904E7DL, -7.861511116647120540275354855221373571536E5DL, -2.821943442729620524365661338459579270561E3DL /* 1.0E0DL */ }; /* log gamma(x+5) = log gamma(5) + x P(x)/Q(x) -0.5 <= x <= 0.5 4.5 <= x+5 <= 5.5 Peak relative error 3.4e-37 */ static const _Decimal128 lgam5a = 3.17803955078125E0DL; static const _Decimal128 lgam5b = 1.4279566695619646941601297055408873990961E-5DL; #define NRN5 9 static const _Decimal128 RN5[NRN5 + 1] = { 2.010952885441805899580403215533972172098E11DL, 1.916132681242540921354921906708215338584E11DL, 7.679102403710581712903937970163206882492E10DL, 1.680514903671382470108010973615268125169E10DL, 2.181011222911537259440775283277711588410E9DL, 1.705361119398837808244780667539728356096E8DL, 7.792391565652481864976147945997033946360E6DL, 1.910741381027985291688667214472560023819E5DL, 2.088138241893612679762260077783794329559E3DL, 6.330318119566998299106803922739066556550E0DL }; #define NRD5 8 static const _Decimal128 RD5[NRD5 + 1] = { 1.335189758138651840605141370223112376176E11DL, 1.174130445739492885895466097516530211283E11DL, 4.308006619274572338118732154886328519910E10DL, 8.547402888692578655814445003283720677468E9DL, 9.934628078575618309542580800421370730906E8DL, 6.847107420092173812998096295422311820672E7DL, 2.698552646016599923609773122139463150403E6DL, 5.526516251532464176412113632726150253215E4DL, 4.772343321713697385780533022595450486932E2DL /* 1.0E0DL */ }; /* log gamma(x+4) = log gamma(4) + x P(x)/Q(x) -0.5 <= x <= 0.5 3.5 <= x+4 <= 4.5 Peak relative error 6.7e-37 */ static const _Decimal128 lgam4a = 1.791748046875E0DL; static const _Decimal128 lgam4b = 1.1422353055000812477358380702272722990692E-5DL; #define NRN4 9 static const _Decimal128 RN4[NRN4 + 1] = { -1.026583408246155508572442242188887829208E13DL, -1.306476685384622809290193031208776258809E13DL, -7.051088602207062164232806511992978915508E12DL, -2.100849457735620004967624442027793656108E12DL, -3.767473790774546963588549871673843260569E11DL, -4.156387497364909963498394522336575984206E10DL, -2.764021460668011732047778992419118757746E9DL, -1.036617204107109779944986471142938641399E8DL, -1.895730886640349026257780896972598305443E6DL, -1.180509051468390914200720003907727988201E4DL }; #define NRD4 9 static const _Decimal128 RD4[NRD4 + 1] = { -8.172669122056002077809119378047536240889E12DL, -9.477592426087986751343695251801814226960E12DL, -4.629448850139318158743900253637212801682E12DL, -1.237965465892012573255370078308035272942E12DL, -1.971624313506929845158062177061297598956E11DL, -1.905434843346570533229942397763361493610E10DL, -1.089409357680461419743730978512856675984E9DL, -3.416703082301143192939774401370222822430E7DL, -4.981791914177103793218433195857635265295E5DL, -2.192507743896742751483055798411231453733E3DL /* 1.0E0DL */ }; /* log gamma(x+3) = log gamma(3) + x P(x)/Q(x) -0.25 <= x <= 0.5 2.75 <= x+3 <= 3.5 Peak relative error 6.0e-37 */ static const _Decimal128 lgam3a = 6.93145751953125E-1DL; static const _Decimal128 lgam3b = 1.4286068203094172321214581765680755001344E-6DL; #define NRN3 9 static const _Decimal128 RN3[NRN3 + 1] = { -4.813901815114776281494823863935820876670E11DL, -8.425592975288250400493910291066881992620E11DL, -6.228685507402467503655405482985516909157E11DL, -2.531972054436786351403749276956707260499E11DL, -6.170200796658926701311867484296426831687E10DL, -9.211477458528156048231908798456365081135E9DL, -8.251806236175037114064561038908691305583E8DL, -4.147886355917831049939930101151160447495E7DL, -1.010851868928346082547075956946476932162E6DL, -8.333374463411801009783402800801201603736E3DL }; #define NRD3 9 static const _Decimal128 RD3[NRD3 + 1] = { -5.216713843111675050627304523368029262450E11DL, -8.014292925418308759369583419234079164391E11DL, -5.180106858220030014546267824392678611990E11DL, -1.830406975497439003897734969120997840011E11DL, -3.845274631904879621945745960119924118925E10DL, -4.891033385370523863288908070309417710903E9DL, -3.670172254411328640353855768698287474282E8DL, -1.505316381525727713026364396635522516989E7DL, -2.856327162923716881454613540575964890347E5DL, -1.622140448015769906847567212766206894547E3DL /* 1.0E0DL */ }; /* log gamma(x+2.5) = log gamma(2.5) + x P(x)/Q(x) -0.125 <= x <= 0.25 2.375 <= x+2.5 <= 2.75 */ static const _Decimal128 lgam2r5a = 2.8466796875E-1DL; static const _Decimal128 lgam2r5b = 1.4901722919159632494669682701924320137696E-5DL; #define NRN2r5 8 static const _Decimal128 RN2r5[NRN2r5 + 1] = { -4.676454313888335499356699817678862233205E9DL, -9.361888347911187924389905984624216340639E9DL, -7.695353600835685037920815799526540237703E9DL, -3.364370100981509060441853085968900734521E9DL, -8.449902011848163568670361316804900559863E8DL, -1.225249050950801905108001246436783022179E8DL, -9.732972931077110161639900388121650470926E6DL, -3.695711763932153505623248207576425983573E5DL, -4.717341584067827676530426007495274711306E3DL }; #define NRD2r5 8 static const _Decimal128 RD2r5[NRD2r5 + 1] = { -6.650657966618993679456019224416926875619E9DL, -1.099511409330635807899718829033488771623E10DL, -7.482546968307837168164311101447116903148E9DL, -2.702967190056506495988922973755870557217E9DL, -5.570008176482922704972943389590409280950E8DL, -6.536934032192792470926310043166993233231E7DL, -4.101991193844953082400035444146067511725E6DL, -1.174082735875715802334430481065526664020E5DL, -9.932840389994157592102947657277692978511E2DL /* 1.0E0DL */ }; /* log gamma(x+2) = x P(x)/Q(x) -0.125 <= x <= +0.375 1.875 <= x+2 <= 2.375 Peak relative error 4.6e-36 */ #define NRN2 9 static const _Decimal128 RN2[NRN2 + 1] = { -3.716661929737318153526921358113793421524E9DL, -1.138816715030710406922819131397532331321E10DL, -1.421017419363526524544402598734013569950E10DL, -9.510432842542519665483662502132010331451E9DL, -3.747528562099410197957514973274474767329E9DL, -8.923565763363912474488712255317033616626E8DL, -1.261396653700237624185350402781338231697E8DL, -9.918402520255661797735331317081425749014E6DL, -3.753996255897143855113273724233104768831E5DL, -4.778761333044147141559311805999540765612E3DL }; #define NRD2 9 static const _Decimal128 RD2[NRD2 + 1] = { -8.790916836764308497770359421351673950111E9DL, -2.023108608053212516399197678553737477486E10DL, -1.958067901852022239294231785363504458367E10DL, -1.035515043621003101254252481625188704529E10DL, -3.253884432621336737640841276619272224476E9DL, -6.186383531162456814954947669274235815544E8DL, -6.932557847749518463038934953605969951466E7DL, -4.240731768287359608773351626528479703758E6DL, -1.197343995089189188078944689846348116630E5DL, -1.004622911670588064824904487064114090920E3DL /* 1.0E0 */ }; /* log gamma(x+1.75) = log gamma(1.75) + x P(x)/Q(x) -0.125 <= x <= +0.125 1.625 <= x+1.75 <= 1.875 Peak relative error 9.2e-37 */ static const _Decimal128 lgam1r75a = -8.441162109375E-2DL; static const _Decimal128 lgam1r75b = 1.0500073264444042213965868602268256157604E-5DL; #define NRN1r75 8 static const _Decimal128 RN1r75[NRN1r75 + 1] = { -5.221061693929833937710891646275798251513E7DL, -2.052466337474314812817883030472496436993E8DL, -2.952718275974940270675670705084125640069E8DL, -2.132294039648116684922965964126389017840E8DL, -8.554103077186505960591321962207519908489E7DL, -1.940250901348870867323943119132071960050E7DL, -2.379394147112756860769336400290402208435E6DL, -1.384060879999526222029386539622255797389E5DL, -2.698453601378319296159355612094598695530E3DL }; #define NRD1r75 8 static const _Decimal128 RD1r75[NRD1r75 + 1] = { -2.109754689501705828789976311354395393605E8DL, -5.036651829232895725959911504899241062286E8DL, -4.954234699418689764943486770327295098084E8DL, -2.589558042412676610775157783898195339410E8DL, -7.731476117252958268044969614034776883031E7DL, -1.316721702252481296030801191240867486965E7DL, -1.201296501404876774861190604303728810836E6DL, -5.007966406976106636109459072523610273928E4DL, -6.155817990560743422008969155276229018209E2DL /* 1.0E0DL */ }; /* log gamma(x+x0) = y0 + x^2 P(x)/Q(x) -0.0867 <= x <= +0.1634 1.374932... <= x+x0 <= 1.625032... Peak relative error 4.0e-36 */ static const _Decimal128 x0a = 1.4616241455078125DL; static const _Decimal128 x0b = 7.9994605498412626595423257213002588621246E-6DL; static const _Decimal128 y0a = -1.21490478515625E-1DL; static const _Decimal128 y0b = 4.1879797753919044854428223084178486438269E-6DL; #define NRN1r5 8 static const _Decimal128 RN1r5[NRN1r5 + 1] = { 6.827103657233705798067415468881313128066E5DL, 1.910041815932269464714909706705242148108E6DL, 2.194344176925978377083808566251427771951E6DL, 1.332921400100891472195055269688876427962E6DL, 4.589080973377307211815655093824787123508E5DL, 8.900334161263456942727083580232613796141E4DL, 9.053840838306019753209127312097612455236E3DL, 4.053367147553353374151852319743594873771E2DL, 5.040631576303952022968949605613514584950E0DL }; #define NRD1r5 8 static const _Decimal128 RD1r5[NRD1r5 + 1] = { 1.411036368843183477558773688484699813355E6DL, 4.378121767236251950226362443134306184849E6DL, 5.682322855631723455425929877581697918168E6DL, 3.999065731556977782435009349967042222375E6DL, 1.653651390456781293163585493620758410333E6DL, 4.067774359067489605179546964969435858311E5DL, 5.741463295366557346748361781768833633256E4DL, 4.226404539738182992856094681115746692030E3DL, 1.316980975410327975566999780608618774469E2DL, /* 1.0E0DL */ }; /* log gamma(x+1.25) = log gamma(1.25) + x P(x)/Q(x) -.125 <= x <= +.125 1.125 <= x+1.25 <= 1.375 Peak relative error = 4.9e-36 */ static const _Decimal128 lgam1r25a = -9.82818603515625E-2DL; static const _Decimal128 lgam1r25b = 1.0023929749338536146197303364159774377296E-5DL; #define NRN1r25 9 static const _Decimal128 RN1r25[NRN1r25 + 1] = { -9.054787275312026472896002240379580536760E4DL, -8.685076892989927640126560802094680794471E4DL, 2.797898965448019916967849727279076547109E5DL, 6.175520827134342734546868356396008898299E5DL, 5.179626599589134831538516906517372619641E5DL, 2.253076616239043944538380039205558242161E5DL, 5.312653119599957228630544772499197307195E4DL, 6.434329437514083776052669599834938898255E3DL, 3.385414416983114598582554037612347549220E2DL, 4.907821957946273805080625052510832015792E0DL }; #define NRD1r25 8 static const _Decimal128 RD1r25[NRD1r25 + 1] = { 3.980939377333448005389084785896660309000E5DL, 1.429634893085231519692365775184490465542E6DL, 2.145438946455476062850151428438668234336E6DL, 1.743786661358280837020848127465970357893E6DL, 8.316364251289743923178092656080441655273E5DL, 2.355732939106812496699621491135458324294E5DL, 3.822267399625696880571810137601310855419E4DL, 3.228463206479133236028576845538387620856E3DL, 1.152133170470059555646301189220117965514E2DL /* 1.0E0DL */ }; /* log gamma(x + 1) = x P(x)/Q(x) 0.0 <= x <= +0.125 1.0 <= x+1 <= 1.125 Peak relative error 1.1e-35 */ #define NRN1 8 static const _Decimal128 RN1[NRN1 + 1] = { -9.987560186094800756471055681088744738818E3DL, -2.506039379419574361949680225279376329742E4DL, -1.386770737662176516403363873617457652991E4DL, 1.439445846078103202928677244188837130744E4DL, 2.159612048879650471489449668295139990693E4DL, 1.047439813638144485276023138173676047079E4DL, 2.250316398054332592560412486630769139961E3DL, 1.958510425467720733041971651126443864041E2DL, 4.516830313569454663374271993200291219855E0DL }; #define NRD1 7 static const _Decimal128 RD1[NRD1 + 1] = { 1.730299573175751778863269333703788214547E4DL, 6.807080914851328611903744668028014678148E4DL, 1.090071629101496938655806063184092302439E5DL, 9.124354356415154289343303999616003884080E4DL, 4.262071638655772404431164427024003253954E4DL, 1.096981664067373953673982635805821283581E4DL, 1.431229503796575892151252708527595787588E3DL, 7.734110684303689320830401788262295992921E1DL /* 1.0E0 */ }; /* log gamma(x + 1) = x P(x)/Q(x) -0.125 <= x <= 0 0.875 <= x+1 <= 1.0 Peak relative error 7.0e-37 */ #define NRNr9 8 static const _Decimal128 RNr9[NRNr9 + 1] = { 4.441379198241760069548832023257571176884E5DL, 1.273072988367176540909122090089580368732E6DL, 9.732422305818501557502584486510048387724E5DL, -5.040539994443998275271644292272870348684E5DL, -1.208719055525609446357448132109723786736E6DL, -7.434275365370936547146540554419058907156E5DL, -2.075642969983377738209203358199008185741E5DL, -2.565534860781128618589288075109372218042E4DL, -1.032901669542994124131223797515913955938E3DL, }; #define NRDr9 8 static const _Decimal128 RDr9[NRDr9 + 1] = { -7.694488331323118759486182246005193998007E5DL, -3.301918855321234414232308938454112213751E6DL, -5.856830900232338906742924836032279404702E6DL, -5.540672519616151584486240871424021377540E6DL, -3.006530901041386626148342989181721176919E6DL, -9.350378280513062139466966374330795935163E5DL, -1.566179100031063346901755685375732739511E5DL, -1.205016539620260779274902967231510804992E4DL, -2.724583156305709733221564484006088794284E2DL /* 1.0E0 */ }; /* Evaluate P[n] x^n + P[n-1] x^(n-1) + ... + P[0] */ static _Decimal128 neval (_Decimal128 x, const _Decimal128 *p, int n) { _Decimal128 y; p += n; y = *p--; do { y = y * x + *p--; } while (--n > 0); return y; } /* Evaluate x^n+1 + P[n] x^(n) + P[n-1] x^(n-1) + ... + P[0] */ static _Decimal128 deval (_Decimal128 x, const _Decimal128 *p, int n) { _Decimal128 y; p += n; y = x + *p--; do { y = y * x + *p--; } while (--n > 0); return y; } /* The 128bit version is used by all three sizes */ /* extern _Decimal128 __lgamma_rd128 (_Decimal128, int *); */ /* extern DEC_TYPE FUNC_D (__lgamma_r) (DEC_TYPE x, int *signgamp); */ DEC_TYPE FUNC_D (__lgamma_r) (DEC_TYPE x, int *signgamp) { _Decimal128 p, q, w, z, nx; int i, nn; *signgamp = 1; if (FUNC_D(__isinf) (x) || FUNC_D(__isnan) (x)) return x * x; if (x < 0.0DL) { q = -x; p = __floord128 (q); /* Argument is a negative Integer: Pole Error */ if (p == q) { DFP_EXCEPT (FE_DIVBYZERO); return DFP_HUGE_VAL; } i = p; if ((i & 1) == 0) *signgamp = -1; z = q - p; if (z > 0.5DL) { p += 1.0DL; z = p - q; } z = q * __sind128 (M_PIdl * z); if (z == 0.0DL) { DFP_EXCEPT (FE_OVERFLOW); return (DEC_TYPE)(*signgamp * huge * huge); } w = __lgamma_rd128 (q, &i); z = __logd128 (M_PIdl / z) - w; return (DEC_TYPE)(z); } if (x < 13.5DL) { p = 0.0DL; nx = (x + 0.5DL); nn = nx; switch (nn) { case 0: /* log gamma (x + 1) = log(x) + log gamma(x) */ if (x <= 0.125DL) { p = x * neval (x, RN1, NRN1) / deval (x, RD1, NRD1); } else if (x <= 0.375DL) { z = x - 0.25DL; p = z * neval (z, RN1r25, NRN1r25) / deval (z, RD1r25, NRD1r25); p += lgam1r25b; p += lgam1r25a; } else if (x <= 0.625DL) { z = x + (1.0DL - x0a); z = z - x0b; p = neval (z, RN1r5, NRN1r5) / deval (z, RD1r5, NRD1r5); p = p * z * z; p = p + y0b; p = p + y0a; } else if (x <= 0.875DL) { z = x - 0.75DL; p = z * neval (z, RN1r75, NRN1r75) / deval (z, RD1r75, NRD1r75); p += lgam1r75b; p += lgam1r75a; } else { z = x - 1.0DL; p = z * neval (z, RN2, NRN2) / deval (z, RD2, NRD2); } p = p - FUNC_D(__log) (x); break; case 1: if (x < 0.875DL) { if (x <= 0.625DL) { z = x + (1.0DL - x0a); z = z - x0b; p = neval (z, RN1r5, NRN1r5) / deval (z, RD1r5, NRD1r5); p = p * z * z; p = p + y0b; p = p + y0a; } else if (x <= 0.875DL) { z = x - 0.75DL; p = z * neval (z, RN1r75, NRN1r75) / deval (z, RD1r75, NRD1r75); p += lgam1r75b; p += lgam1r75a; } else { z = x - 1.0DL; p = z * neval (z, RN2, NRN2) / deval (z, RD2, NRD2); } p = p - FUNC_D(__log) (x); } else if (x < 1.0DL) { z = x - 1.0DL; p = z * neval (z, RNr9, NRNr9) / deval (z, RDr9, NRDr9); } else if (x == 1.0DL) p = 0.0DL; else if (x <= 1.125DL) { z = x - 1.0DL; p = z * neval (z, RN1, NRN1) / deval (z, RD1, NRD1); } else if (x <= 1.375DL) { z = x - 1.25DL; p = z * neval (z, RN1r25, NRN1r25) / deval (z, RD1r25, NRD1r25); p += lgam1r25b; p += lgam1r25a; } else { /* 1.375 <= x+x0 <= 1.625 */ z = x - x0a; z = z - x0b; p = neval (z, RN1r5, NRN1r5) / deval (z, RD1r5, NRD1r5); p = p * z * z; p = p + y0b; p = p + y0a; } break; case 2: if (x < 1.625DL) { z = x - x0a; z = z - x0b; p = neval (z, RN1r5, NRN1r5) / deval (z, RD1r5, NRD1r5); p = p * z * z; p = p + y0b; p = p + y0a; } else if (x < 1.875DL) { z = x - 1.75DL; p = z * neval (z, RN1r75, NRN1r75) / deval (z, RD1r75, NRD1r75); p += lgam1r75b; p += lgam1r75a; } else if (x == 2.0DL) p = 0.0DL; else if (x < 2.375DL) { z = x - 2.0DL; p = z * neval (z, RN2, NRN2) / deval (z, RD2, NRD2); } else { z = x - 2.5DL; p = z * neval (z, RN2r5, NRN2r5) / deval (z, RD2r5, NRD2r5); p += lgam2r5b; p += lgam2r5a; } break; case 3: if (x < 2.75DL) { z = x - 2.5DL; p = z * neval (z, RN2r5, NRN2r5) / deval (z, RD2r5, NRD2r5); p += lgam2r5b; p += lgam2r5a; } else { z = x - 3.0DL; p = z * neval (z, RN3, NRN3) / deval (z, RD3, NRD3); p += lgam3b; p += lgam3a; } break; case 4: z = x - 4.0DL; p = z * neval (z, RN4, NRN4) / deval (z, RD4, NRD4); p += lgam4b; p += lgam4a; break; case 5: z = x - 5.0DL; p = z * neval (z, RN5, NRN5) / deval (z, RD5, NRD5); p += lgam5b; p += lgam5a; break; case 6: z = x - 6.0DL; p = z * neval (z, RN6, NRN6) / deval (z, RD6, NRD6); p += lgam6b; p += lgam6a; break; case 7: z = x - 7.0DL; p = z * neval (z, RN7, NRN7) / deval (z, RD7, NRD7); p += lgam7b; p += lgam7a; break; case 8: z = x - 8.0DL; p = z * neval (z, RN8, NRN8) / deval (z, RD8, NRD8); p += lgam8b; p += lgam8a; break; case 9: z = x - 9.0DL; p = z * neval (z, RN9, NRN9) / deval (z, RD9, NRD9); p += lgam9b; p += lgam9a; break; case 10: z = x - 10.0DL; p = z * neval (z, RN10, NRN10) / deval (z, RD10, NRD10); p += lgam10b; p += lgam10a; break; case 11: z = x - 11.0DL; p = z * neval (z, RN11, NRN11) / deval (z, RD11, NRD11); p += lgam11b; p += lgam11a; break; case 12: z = x - 12.0DL; p = z * neval (z, RN12, NRN12) / deval (z, RD12, NRD12); p += lgam12b; p += lgam12a; break; case 13: z = x - 13.0DL; p = z * neval (z, RN13, NRN13) / deval (z, RD13, NRD13); p += lgam13b; p += lgam13a; break; } return (DEC_TYPE) p; } if (x >= (DEC_TYPE)DEC_INFINITY) { DFP_EXCEPT (FE_OVERFLOW); return (DEC_TYPE)(*signgamp * huge * huge); } q = ls2pi - x; q = (x - 0.5DL) * FUNC_D(__log) (x) + q; if (x <= 1.0e18DL) { p = 1.0DL / (x * x); q += neval (p, RASY, NRASY) / x; } return (DEC_TYPE)(q); } static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { int local_signgam; DEC_TYPE retval; retval = FUNC_D (__lgamma_r) (x,&local_signgam); return retval; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); /* For this particular case, both the Pole and Overflow error make the same * finite x -> infinite z result, and both generate an ERANGE errno */ if (!FUNC_D(__isfinite) (z) && FUNC_D(__isfinite) (x)) DFP_ERRNO (ERANGE); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/lgammad64.c000066400000000000000000000021731261375163000163130ustar00rootroot00000000000000/* Returns the natural logarithm of the absolute value of the Gamma function of x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "lgammad32.c" libdfp-1.0.12/ieee754r/llogbd128.c000066400000000000000000000023501261375163000162320ustar00rootroot00000000000000/* Returns the unbiased exponent of the passed _Decimal128 value as an long int. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _RETURN_TYPE long int #define FUNCTION_NAME llogb #define _MAX_VALUE LONG_MAX #define _MIN_VALUE LONG_MIN #define _FBLOG0 FP_LLOGB0 #define _FBLOGNAN FP_LLOGBNAN #define _DECIMAL_SIZE 128 #include #include "ilogbd32.c" libdfp-1.0.12/ieee754r/llogbd32.c000066400000000000000000000022601261375163000161440ustar00rootroot00000000000000/* Returns the unbiased exponent of the passed _Decimal32 value as an long int. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _RETURN_TYPE long int #define FUNCTION_NAME llogb #define _MAX_VALUE LONG_MAX #define _MIN_VALUE LONG_MIN #define _FBLOG0 FP_LLOGB0 #define _FBLOGNAN FP_LLOGBNAN #include "ilogbd32.c" libdfp-1.0.12/ieee754r/llogbd64.c000066400000000000000000000023451261375163000161550ustar00rootroot00000000000000/* Returns the unbiased exponent of the passed _Decimal64 value as an long int. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _RETURN_TYPE long int #define FUNCTION_NAME llogb #define _MAX_VALUE LONG_MAX #define _MIN_VALUE LONG_MIN #define _FBLOG0 FP_LLOGB0 #define _FBLOGNAN FP_LLOGBNAN #define _DECIMAL_SIZE 64 #include #include "ilogbd32.c" libdfp-1.0.12/ieee754r/llquantexpd128.c000066400000000000000000000020141261375163000173250ustar00rootroot00000000000000/* Compute the quantum exponend of a finite argument. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "llquantexpd32.c" libdfp-1.0.12/ieee754r/llquantexpd32.c000066400000000000000000000030531261375163000172430ustar00rootroot00000000000000/* Compute the quantum exponend of a finite argument as long long int. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #include #define FUNCTION_NAME llquantexp #include #include long long int INTERNAL_FUNCTION_NAME (DEC_TYPE x) { decNumber dn_x; FUNC_CONVERT_TO_DN(&x, &dn_x); if (decNumberIsNaN (&dn_x) || decNumberIsInfinite (&dn_x)) { DFP_ERRNO (EDOM); return LLONG_MIN; } return (long long int)dn_x.exponent; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/llquantexpd64.c000066400000000000000000000020121261375163000172420ustar00rootroot00000000000000/* Compute the quantum exponend of a finite argument. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "llquantexpd32.c" libdfp-1.0.12/ieee754r/llrintd128.c000066400000000000000000000021341261375163000164370ustar00rootroot00000000000000/* Rounds to the nearest (long long int) integer Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "llrintd32.c" libdfp-1.0.12/ieee754r/llrintd32.c000066400000000000000000000024151261375163000163530ustar00rootroot00000000000000/* Rounds to the nearest (long long int) integer Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #define FUNCTION_NAME llrint #include #define __ROUND_MODE __dn_getround() #include "llroundd32.c" libdfp-1.0.12/ieee754r/llrintd64.c000066400000000000000000000021321261375163000163540ustar00rootroot00000000000000/* Rounds to the nearest (long long int) integer Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "llrintd32.c" libdfp-1.0.12/ieee754r/llroundd128.c000066400000000000000000000021611261375163000166120ustar00rootroot00000000000000/* Rounds to the nearest long long int value, ignoring rounding mode Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "llroundd32.c" libdfp-1.0.12/ieee754r/llroundd32.c000066400000000000000000000050531261375163000165270ustar00rootroot00000000000000/* Rounds to the nearest long long int value, ignoring rounding mode Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #include #include #include #ifndef FUNCTION_NAME # define FUNCTION_NAME llround #endif #include #ifndef __ROUND_RETURN_TYPE # define __ROUND_RETURN_TYPE long long int # define __MIN_VALUE LLONG_MIN # define __MAX_VALUE LLONG_MAX #endif #ifndef __ROUND_MODE # define __ROUND_MODE DEC_ROUND_HALF_UP #endif static __ROUND_RETURN_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE result; decContext context; decNumber dn_result; decNumber dn_x; FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x) || decNumberIsInfinite (&dn_x) || x > __MAX_VALUE || x < __MIN_VALUE) { DFP_EXCEPT (FE_INVALID); return (__ROUND_RETURN_TYPE) x; } decContextDefault (&context, DEFAULT_CONTEXT); context.round = __ROUND_MODE; decNumberToIntegralValue (&dn_result,&dn_x,&context); FUNC_CONVERT_FROM_DN(&dn_result, &result, &context); /* Use _Decimal* to __ROUND_RETURN_TYPE casting. */ return (__ROUND_RETURN_TYPE)result; /* return (__ROUND_RETURN_TYPE)decNumberToInteger (&dn_result); */ } __ROUND_RETURN_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { __ROUND_RETURN_TYPE z = IEEE_FUNCTION_NAME (x); if (FUNC_D(__isnan) (x) || FUNC_D(__isinf) (x) || x > __MAX_VALUE || x < __MIN_VALUE) DFP_ERRNO (EDOM); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/llroundd64.c000066400000000000000000000021571261375163000165360ustar00rootroot00000000000000/* Rounds to the nearest long long int value, ignoring rounding mode Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "llroundd32.c" libdfp-1.0.12/ieee754r/log10d128.c000066400000000000000000000021461261375163000160600ustar00rootroot00000000000000/* Calculate the Log (base 10) of a given _Decimal128 value Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "log10d32.c" libdfp-1.0.12/ieee754r/log10d32.c000066400000000000000000000043331261375163000157720ustar00rootroot00000000000000/* Calculate the Log (base 10) of a given _Decimal32 value Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #include #define FUNCTION_NAME log10 #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x)) return x+x; if (decNumberIsZero (&dn_x)) /* If x == 0: Pole Error */ { DFP_EXCEPT (FE_DIVBYZERO); return -DFP_HUGE_VAL; } if (decNumberIsNegative (&dn_x)) /* If x < 0: Domain Error */ { DFP_EXCEPT (FE_INVALID); return DFP_NAN; } if (decNumberIsInfinite (&dn_x)) return x; decContextDefault (&context, DEFAULT_CONTEXT); decNumberLog10 (&dn_result, &dn_x, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); if (x < DFP_CONSTANT(0.0)) DFP_ERRNO (EDOM); if (x == DFP_CONSTANT(0.0)) DFP_ERRNO (ERANGE); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/log10d64.c000066400000000000000000000021431261375163000157740ustar00rootroot00000000000000/* Calculate the Log (base 10) of a given _Decimal64 value Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "log10d32.c" libdfp-1.0.12/ieee754r/log1pd128.c000066400000000000000000000021521261375163000161550ustar00rootroot00000000000000/* Calculate the Natural Log of a given a _Decimal128 value + 1 Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "log1pd32.c" libdfp-1.0.12/ieee754r/log1pd32.c000066400000000000000000000047301261375163000160730ustar00rootroot00000000000000/* Calculate the Natural Log of (a _Decimal32 value + 1) Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #include #define FUNCTION_NAME log1p #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; decNumber dn_sum; decNumber dn_one; DEC_TYPE one = DFP_CONSTANT(1.0); FUNC_CONVERT_TO_DN (&x, &dn_x); FUNC_CONVERT_TO_DN (&one, &dn_one); /* For NaN, 0, or +Inf, just return x */ if (decNumberIsNaN (&dn_x) || decNumberIsZero (&dn_x) || (decNumberIsInfinite (&dn_x) && !decNumberIsNegative (&dn_x))) return x+x; decContextDefault(&context, DEFAULT_CONTEXT); decNumberAdd(&dn_sum, &dn_x, &dn_one, &context); if (decNumberIsZero(&dn_sum)) /* Pole Error if x was -1 */ { DFP_EXCEPT (FE_DIVBYZERO); return -DFP_HUGE_VAL; } if (decNumberIsNegative(&dn_sum)) /* Domain Error if x < -1 */ { DFP_EXCEPT (FE_INVALID); return DFP_NAN; } decNumberLn(&dn_result, &dn_sum, &context); FUNC_CONVERT_FROM_DN(&dn_result, &result, &context); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); if (x == DFP_CONSTANT(-1.0)) DFP_ERRNO (ERANGE); if (x < DFP_CONSTANT(-1.0)) DFP_ERRNO (EDOM); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/log1pd64.c000066400000000000000000000021471261375163000161000ustar00rootroot00000000000000/* Calculate the Natural Log of a given a _Decimal64 value + 1 Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "log1pd32.c" libdfp-1.0.12/ieee754r/log2d128.c000066400000000000000000000021311261375163000157730ustar00rootroot00000000000000/* Returns the base 2 logarithmic function of x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "log2d32.c" libdfp-1.0.12/ieee754r/log2d32.c000066400000000000000000000047631261375163000157220ustar00rootroot00000000000000/* Returns the base 2 logarithmic function of x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 #endif #include #include #include #include #include #define FUNCTION_NAME log2 #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; decNumber dn_two; decNumber dn_logtwo; decNumber dn_logx; DEC_TYPE two = DFP_CONSTANT(2.0); FUNC_CONVERT_TO_DN (&x, &dn_x); FUNC_CONVERT_TO_DN (&two, &dn_two); if (decNumberIsNaN (&dn_x)) return x+x; if (decNumberIsZero (&dn_x)) /* If x == 0: Pole Error */ { DFP_EXCEPT (FE_DIVBYZERO); return -DFP_HUGE_VAL; } if (decNumberIsNegative (&dn_x)) /* If x < 0,: Domain Error */ { DFP_EXCEPT (FE_INVALID); return DFP_NAN; } if (decNumberIsInfinite (&dn_x)) return x; decContextDefault (&context, DEFAULT_CONTEXT); // log_2 (x) = log_10 (x) / log_10 (2) decNumberLog10 (&dn_logx, &dn_x, &context); decNumberLog10 (&dn_logtwo, &dn_two, &context); decNumberDivide (&dn_result, &dn_logx, &dn_logtwo, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); if (x == DFP_CONSTANT(0.0)) DFP_ERRNO (ERANGE); if (x < DFP_CONSTANT(0.0)) DFP_ERRNO (EDOM); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/log2d64.c000066400000000000000000000021271261375163000157170ustar00rootroot00000000000000/* Returns the base 2 logarithmic function of x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "log2d32.c" libdfp-1.0.12/ieee754r/logbd128.c000066400000000000000000000021521261375163000160560ustar00rootroot00000000000000/* Returns the unbiased exponent of the passed _Decimal128 value Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "logbd32.c" libdfp-1.0.12/ieee754r/logbd32.c000066400000000000000000000054501261375163000157740ustar00rootroot00000000000000/* Returns the unbiased exponent of the passed _Decimal32 value Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 #endif #include #include #include #include #include #define FUNCTION_NAME logb #include DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; decNumber dn_tmp; decNumber dn_log10; decNumber dn_one; decNumber dn_cmp; enum rounding round; FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x)) return x+x; if (decNumberIsInfinite (&dn_x)) /* +-Inf: Inf */ return DEC_INFINITY; if (decNumberIsZero (&dn_x)) /* Pole Error if x==0 */ { DFP_ERRNO (ERANGE); DFP_EXCEPT (FE_DIVBYZERO); return -DFP_HUGE_VAL; } if (decNumberIsInfinite (&dn_x) && decNumberIsNegative (&dn_x)) return -x; decContextDefault (&context, DEFAULT_CONTEXT); decNumberAbs (&dn_tmp, &dn_x, &context); /* For DFP, we use radix 10 instead of whatever FLT_RADIX happens to be */ decNumberLog10 (&dn_log10, &dn_tmp, &context); /* Capture the case where truncation will return the wrong result, by rounding up if -1.0 < x < 1.0 */ round = DEC_ROUND_DOWN; decNumberFromInt32 (&dn_one, 1); decNumberCompare (&dn_cmp, &dn_x, &dn_one, &context); if (-decNumberIsNegative(&dn_cmp)) { decNumberFromInt32 (&dn_one, -1); decNumberCompare (&dn_cmp, &dn_x, &dn_one, &context); if (!decNumberIsNegative(&dn_cmp) && !decNumberIsZero(&dn_cmp)) round = DEC_ROUND_UP; } context.round = round; decNumberToIntegralValue (&dn_result, &dn_log10, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/logbd64.c000066400000000000000000000021471261375163000160010ustar00rootroot00000000000000/* Returns the unbiased exponent of the passed _Decimal64 value Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "logbd32.c" libdfp-1.0.12/ieee754r/logd128.c000066400000000000000000000021441261375163000157150ustar00rootroot00000000000000/* Calculate the Natural Log of a given a _Decimal128 value Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "logd32.c" libdfp-1.0.12/ieee754r/logd32.c000066400000000000000000000044311261375163000156300ustar00rootroot00000000000000/* Calculate the Natural Log of a given a _Decimal32 value Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 /* needed to pick up DECNUMDIGITS before including decNumber.h */ # include #endif #include #include #include #include #include #define FUNCTION_NAME log #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; FUNC_CONVERT_TO_DN(&x, &dn_x); if (decNumberIsNaN (&dn_x)) return x+x; if (decNumberIsZero (&dn_x)) /* If x == 0: Pole Error */ { DFP_EXCEPT (FE_DIVBYZERO); return -DFP_HUGE_VAL; } if (decNumberIsNegative (&dn_x)) /* If x < 0,: Domain Error */ { DFP_EXCEPT (FE_INVALID); return DFP_NAN; } if (decNumberIsInfinite (&dn_x)) return x; decContextDefault (&context, DEFAULT_CONTEXT); decNumberLn(&dn_result, &dn_x, &context); FUNC_CONVERT_FROM_DN(&dn_result, &result, &context); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); if (x == DFP_CONSTANT(0.0)) DFP_ERRNO (ERANGE); if (x < DFP_CONSTANT(0.0)) DFP_ERRNO (EDOM); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/logd64.c000066400000000000000000000021411261375163000156310ustar00rootroot00000000000000/* Calculate the Natural Log of a given a _Decimal64 value Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "logd32.c" libdfp-1.0.12/ieee754r/lrintd128.c000066400000000000000000000021261261375163000162640ustar00rootroot00000000000000/* Rounds to the nearest (long int) integer Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "lrintd32.c" libdfp-1.0.12/ieee754r/lrintd32.c000066400000000000000000000025231261375163000161770ustar00rootroot00000000000000/* Rounds to the nearest (long int) integer Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #define FUNCTION_NAME lrint #define __ROUND_RETURN_TYPE long int #define __MIN_VALUE LONG_MIN #define __MAX_VALUE LONG_MAX #include #define __ROUND_MODE __dn_getround() #include "llroundd32.c" libdfp-1.0.12/ieee754r/lrintd64.c000066400000000000000000000021241261375163000162010ustar00rootroot00000000000000/* Rounds to the nearest (long int) integer Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "lrintd32.c" libdfp-1.0.12/ieee754r/lroundd128.c000066400000000000000000000021541261375163000164400ustar00rootroot00000000000000/* Rounds to the nearest long int value, ignoring rounding mode. Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "lroundd32.c" libdfp-1.0.12/ieee754r/lroundd32.c000066400000000000000000000025251261375163000163540ustar00rootroot00000000000000/* Rounds to the nearest long int value, ignoring rounding mode. Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #define FUNCTION_NAME lround #define __ROUND_RETURN_TYPE long int #define __MIN_VALUE LONG_MIN #define __MAX_VALUE LONG_MAX //Implementation is done in llround #include "llroundd32.c" libdfp-1.0.12/ieee754r/lroundd64.c000066400000000000000000000021521261375163000163550ustar00rootroot00000000000000/* Rounds to the nearest long int value, ignoring rounding mode. Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "lroundd32.c" libdfp-1.0.12/ieee754r/modfd128.c000066400000000000000000000021721261375163000160620ustar00rootroot00000000000000/* Breaks the argument into integral and fractional parts for a _Decimal128 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "modfd32.c" libdfp-1.0.12/ieee754r/modfd32.c000066400000000000000000000037411261375163000157770ustar00rootroot00000000000000/* Breaks the argument into integral and fractional parts for a _Decimal32 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #define FUNCTION_NAME modf #include DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE *y) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; decNumber dn_y; FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x)) { *y = x; return x+x; } if (decNumberIsInfinite (&dn_x)) return DFP_CONSTANT(0.0)/x; decContextDefault (&context, DEFAULT_CONTEXT); context.round = DEC_ROUND_DOWN; /* round towards zero */ decNumberToIntegralValue (&dn_result, &dn_x, &context); decNumberSubtract (&dn_y, &dn_x, &dn_result, &context); FUNC_CONVERT_FROM_DN (&dn_result, y, &context); FUNC_CONVERT_FROM_DN (&dn_y, &result, &context); return result; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/modfd64.c000066400000000000000000000021671261375163000160050ustar00rootroot00000000000000/* Breaks the argument into integral and fractional parts for a _Decimal64 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "modfd32.c" libdfp-1.0.12/ieee754r/nand128.c000066400000000000000000000021431261375163000157070ustar00rootroot00000000000000/* Returns a reprentation of NaN in the _Decimal128 format Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "nand32.c" libdfp-1.0.12/ieee754r/nand32.c000066400000000000000000000034561261375163000156310ustar00rootroot00000000000000/* Returns a reprentation of NaN in the _Decimal32 format Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 /* needed to pick up DECNUMDIGITS before including decNumber.h */ # include #endif #include #include #include #define FUNCTION_NAME nan #include /* `unused' is a GCC extension to disable warnings on intentionally unused * parameters. */ DEC_TYPE INTERNAL_FUNCTION_NAME (const char *tagp __attribute__ ((unused))) { /* decContext context; decNumber dn_result; DEC_TYPE result; ___decContextDefault(&context, DEFAULT_CONTEXT); ___decNumberFromString(&dn_result, x, &context); dn_result.bits |= DECNAN; FUNC_CONVERT_FROM_DN(&dn_result, &result, &context); */ return (DEC_TYPE)DEC_NAN; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/nand64.c000066400000000000000000000021401261375163000156230ustar00rootroot00000000000000/* Returns a reprentation of NaN in the _Decimal64 format Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "nand32.c" libdfp-1.0.12/ieee754r/nearbyintd128.c000066400000000000000000000021331261375163000171250ustar00rootroot00000000000000/* Round to nearest integer _Decimal128 form Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "nearbyintd32.c" libdfp-1.0.12/ieee754r/nearbyintd32.c000066400000000000000000000040631261375163000170430ustar00rootroot00000000000000/* Round to nearest integer _Decimal32 form Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #include #include #include #define FUNCTION_NAME nearbyint #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { decNumber dn_x,dn_result; decContext context; DEC_TYPE result; FUNC_CONVERT_TO_DN (&x, &dn_x); decContextDefault (&context,DEFAULT_CONTEXT); if (decNumberIsNaN (&dn_x) || decNumberIsInfinite (&dn_x) || decNumberIsZero (&dn_x)) return x+x; context.round = __dn_getround(); decNumberToIntegralValue (&dn_result,&dn_x,&context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); if (context.status & DEC_Overflow) DFP_EXCEPT (FE_OVERFLOW); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); if (!__isfinited32 (z) && __isfinited32 (x)) DFP_ERRNO (ERANGE); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/nearbyintd64.c000066400000000000000000000021301261375163000170410ustar00rootroot00000000000000/* Round to nearest integer _Decimal64 form Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "nearbyintd32.c" libdfp-1.0.12/ieee754r/nextafterd128.c000066400000000000000000000021641261375163000171360ustar00rootroot00000000000000/* Returns the next representable neighbor of x in the direction of y Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "nextafterd32.c" libdfp-1.0.12/ieee754r/nextafterd32.c000066400000000000000000000051631261375163000170520ustar00rootroot00000000000000/* Returns the next representable neighbor of x in the direction of y Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 #endif #include #include #include #include #include #include #define FUNCTION_NAME nextafter #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decContext context; decNumber dn_result; DEC_TYPE result; DEC_TYPE epsilon; decNumber dn_x; decNumber dn_y; decNumber dn_epsilon; /* int comparison;*/ FUNC_CONVERT_TO_DN (&x, &dn_x); FUNC_CONVERT_TO_DN (&y, &dn_y); /* Early exit for nan's */ if (decNumberIsNaN (&dn_x)) return x+x; if (decNumberIsNaN (&dn_y)) return y+y; /*comparison = decCompare (&dn_x, &dn_y); */ /* Early exit for equal values */ /*if (comparison == 0) */ if (x==y) return x; epsilon = DFP_EPSILON; FUNC_CONVERT_TO_DN (&epsilon, &dn_epsilon); dn_epsilon.exponent += dn_x.digits+dn_x.exponent-1; decContextDefault (&context, DEFAULT_CONTEXT); /* if (comparison > 0)*/ if (x>y) decNumberSubtract (&dn_result,&dn_x,&dn_epsilon,&context); else decNumberAdd (&dn_result,&dn_x,&dn_epsilon,&context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); if (context.status & DEC_Overflow) DFP_EXCEPT (FE_OVERFLOW); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { DEC_TYPE z = IEEE_FUNCTION_NAME (x, y); if (!FUNC_D(__isfinite) (z) && FUNC_D(__isfinite) (x)) DFP_ERRNO (ERANGE); /* TODO: Handle underflow here */ return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/nextafterd64.c000066400000000000000000000021621261375163000170530ustar00rootroot00000000000000/* Returns the next representable neighbor of x in the direction of y Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "nextafterd32.c" libdfp-1.0.12/ieee754r/nexttowardd128.c000066400000000000000000000022211261375163000173270ustar00rootroot00000000000000/* Returns the next representable neighbor of x in the direction of y Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include #include "nexttowardd32.c" libdfp-1.0.12/ieee754r/nexttowardd32.c000066400000000000000000000053671261375163000172570ustar00rootroot00000000000000/* Returns the next representable neighbor of x in the direction of y Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE /* Always include this since we need a _Decimal128 converted to a decNumber */ # include # include # include # define _DECIMAL_SIZE 32 #endif #include #include #include #include #include #include #define FUNCTION_NAME nexttoward #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x, _Decimal128 y) { decContext context; decNumber dn_result; DEC_TYPE result; DEC_TYPE epsilon; decNumber dn_x; decNumber dn_y; decNumber dn_epsilon; /* int comparison; */ FUNC_CONVERT_TO_DN(&x, &dn_x); __DECIMAL_TO_DECNUMBER(&y, &dn_y, 128); /* Early exit for nan's */ if (decNumberIsNaN(&dn_x)) return x; if (decNumberIsNaN(&dn_y)) return y; /*comparison = decCompare(&dn_x, &dn_y); */ /* Early exit for equal values */ /*if (comparison == 0) */ if (x==y) return x; epsilon = DFP_EPSILON; FUNC_CONVERT_TO_DN(&epsilon, &dn_epsilon); dn_epsilon.exponent += dn_x.digits+dn_x.exponent-1; decContextDefault(&context, DEFAULT_CONTEXT); /*if (comparison > 0)*/ if (x>y) decNumberSubtract(&dn_result,&dn_x,&dn_epsilon,&context); else decNumberAdd(&dn_result,&dn_x,&dn_epsilon,&context); FUNC_CONVERT_FROM_DN(&dn_result, &result, &context); if (context.status & DEC_Overflow) DFP_EXCEPT (FE_OVERFLOW); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x, _Decimal128 y) { DEC_TYPE z = IEEE_FUNCTION_NAME (x, y); if (!FUNC_D(__isfinite) (z) && FUNC_D(__isfinite) (x)) DFP_ERRNO (ERANGE); /* TODO: Handle underflow */ return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/nexttowardd64.c000066400000000000000000000023671261375163000172610ustar00rootroot00000000000000/* Returns the next representable neighbor of x in the direction of y Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 /* Always include this since we need a _Decimal128 converted to a decNumber */ #include #include #include #include "nexttowardd32.c" libdfp-1.0.12/ieee754r/powd128.c000066400000000000000000000021361261375163000157420ustar00rootroot00000000000000/* Calculate x^y, where x and y are _Decimal128 types Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "powd32.c" libdfp-1.0.12/ieee754r/powd32.c000066400000000000000000000115571261375163000156630ustar00rootroot00000000000000/* Calculate x^y, where x and y are _Decimal32 types Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #include #include #define FUNCTION_NAME pow #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decContext context; decNumber dn_result; DEC_TYPE result; DEC_TYPE absx; decNumber dn_x; decNumber dn_absx; decNumber dn_y; decNumber dn_one; decNumber dn_two; decNumber dn_temp; decNumber dn_temp2; decNumber dn_temp3; int y_is_int; int y_is_oddint=0; int abs_x_vs_1; DEC_TYPE one = DFP_CONSTANT(1.0); DEC_TYPE two = DFP_CONSTANT(2.0); FUNC_CONVERT_TO_DN (&x, &dn_x); FUNC_CONVERT_TO_DN (&y, &dn_y); FUNC_CONVERT_TO_DN (&one, &dn_one); decContextDefault (&context, DEFAULT_CONTEXT); if (decNumberIsZero (&dn_y)) return one; if (decNumberIsNaN (&dn_x)) return x+x; decNumberAbs (&dn_absx, &dn_x, &context); FUNC_CONVERT_FROM_DN (&dn_absx, &absx, &context); if(absx The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "powd32.c" libdfp-1.0.12/ieee754r/quantized128.c000066400000000000000000000021711261375163000167740ustar00rootroot00000000000000/* Set the exponent of x to the exp of y, trying to preserve the value of x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "quantized32.c" libdfp-1.0.12/ieee754r/quantized32.c000066400000000000000000000035361261375163000167140ustar00rootroot00000000000000/* Set the exponent of x to the exp of y, trying to preserve the value of x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 /* needed to pick up DECNUMDIGITS before including decNumber.h */ # include #endif #include #include #include #include #include #define FUNCTION_NAME quantize #include DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; decNumber dn_y; FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&y, &dn_y); decContextDefault(&context, DEFAULT_CONTEXT); context.round = __dn_getround(); decNumberQuantize(&dn_result, &dn_x, &dn_y, &context); FUNC_CONVERT_FROM_DN(&dn_result, &result, &context); return result; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/quantized64.c000066400000000000000000000021671261375163000167200ustar00rootroot00000000000000/* Set the exponent of x to the exp of y, trying to preserve the value of x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "quantized32.c" libdfp-1.0.12/ieee754r/quantumd128.c000066400000000000000000000034101261375163000166230ustar00rootroot00000000000000/* Compute the quantum exponend of a finite argument. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include #include #define _DECIMAL_SIZE 128 #include _Decimal128 __quantumd128 (_Decimal128 x) { decNumber dn_x; decNumber dn_result; decContext context; _Decimal128 result; FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x) || decNumberIsZero (&dn_x)) return x; if (decNumberIsInfinite (&dn_x)) return DEC_INFINITY; /* The quantum of a finite number is defined as 1 x 10^exponent, so first get input absolute value and then sets its coefficient to 1. */ decContextDefault (&context, DEFAULT_CONTEXT); decNumberAbs (&dn_result, &dn_x, &context); dn_result.digits = 1; dn_result.lsu[0] = 1; FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } weak_alias (__quantumd128, quantumd128) libdfp-1.0.12/ieee754r/quantumd32.c000066400000000000000000000034001261375163000165340ustar00rootroot00000000000000/* Compute the quantum exponend of a finite argument. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include #include #define _DECIMAL_SIZE 32 #include _Decimal32 __quantumd32 (_Decimal32 x) { decNumber dn_x; decNumber dn_result; decContext context; _Decimal32 result; FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x) || decNumberIsZero (&dn_x)) return x; if (decNumberIsInfinite (&dn_x)) return DEC_INFINITY; /* The quantum of a finite number is defined as 1 x 10^exponent, so first get input absolute value and then sets its coefficient to 1. */ decContextDefault (&context, DEFAULT_CONTEXT); decNumberAbs (&dn_result, &dn_x, &context); dn_result.digits = 1; dn_result.lsu[0] = 1; FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } weak_alias (__quantumd32, quantumd32) libdfp-1.0.12/ieee754r/quantumd64.c000066400000000000000000000034001261375163000165410ustar00rootroot00000000000000/* Compute the quantum exponend of a finite argument. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include #include #define _DECIMAL_SIZE 64 #include _Decimal64 __quantumd64 (_Decimal64 x) { decNumber dn_x; decNumber dn_result; decContext context; _Decimal64 result; FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x) || decNumberIsZero (&dn_x)) return x; if (decNumberIsInfinite (&dn_x)) return DEC_INFINITY; /* The quantum of a finite number is defined as 1 x 10^exponent, so first get input absolute value and then sets its coefficient to 1. */ decContextDefault (&context, DEFAULT_CONTEXT); decNumberAbs (&dn_result, &dn_x, &context); dn_result.digits = 1; dn_result.lsu[0] = 1; FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } weak_alias (__quantumd64, quantumd64) libdfp-1.0.12/ieee754r/remainderd128.c000066400000000000000000000021471261375163000171050ustar00rootroot00000000000000/* Returns the result of x - ((int-round_even)(x/y)) * y Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "remainderd32.c" libdfp-1.0.12/ieee754r/remainderd32.c000066400000000000000000000047471261375163000170270ustar00rootroot00000000000000/* Returns the result of x - ((int-round_even)(x/y)) * y Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 #endif #include #include #include #include #include #define FUNCTION_NAME remainder #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; decNumber dn_y; decNumber dn_mult; decNumber dn_rounded; FUNC_CONVERT_TO_DN (&x, &dn_x); FUNC_CONVERT_TO_DN (&y, &dn_y); if (decNumberIsNaN (&dn_x) || decNumberIsNaN (&dn_y)) return x+y; /* Domain Error: x = +-Inf, or y = +-0 and x is non-NaN */ if (decNumberIsInfinite (&dn_x) || decNumberIsZero (&dn_y)) { DFP_EXCEPT (FE_INVALID); return (x - x) / (x - x); } decContextDefault (&context, DEFAULT_CONTEXT); decNumberDivide (&dn_mult, &dn_x, &dn_y, &context); context.round = DEC_ROUND_HALF_EVEN; decNumberToIntegralValue (&dn_rounded, &dn_mult, &context); decNumberMultiply (&dn_mult, &dn_rounded, &dn_y, &context); decNumberSubtract (&dn_result, &dn_x, &dn_mult, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { DEC_TYPE z = IEEE_FUNCTION_NAME (x, y); if (!FUNC_D(__isinf) (x) || (!FUNC_D(__isnan) (x) && y == DFP_CONSTANT(0.0))) DFP_ERRNO (EDOM); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/remainderd64.c000066400000000000000000000021451261375163000170220ustar00rootroot00000000000000/* Returns the result of x - ((int-round_even)(x/y)) * y Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "remainderd32.c" libdfp-1.0.12/ieee754r/rintd128.c000066400000000000000000000021121261375163000161030ustar00rootroot00000000000000/* Rounds to the nearest integer Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "rintd32.c" libdfp-1.0.12/ieee754r/rintd32.c000066400000000000000000000023011261375163000160150ustar00rootroot00000000000000/* Rounds to the nearest integer Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #define FUNCTION_NAME rint #include #define __ROUND_MODE __dn_getround() #include "roundd32.c" libdfp-1.0.12/ieee754r/rintd64.c000066400000000000000000000021101261375163000160200ustar00rootroot00000000000000/* Rounds to the nearest integer Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "rintd32.c" libdfp-1.0.12/ieee754r/roundd128.c000066400000000000000000000021501261375163000162600ustar00rootroot00000000000000/* Rounds to the nearest integer value, ignores rounding mode Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "roundd32.c" libdfp-1.0.12/ieee754r/roundd32.c000066400000000000000000000041521261375163000161760ustar00rootroot00000000000000/* Rounds to the nearest integer value, ignores rounding mode Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #include #ifndef FUNCTION_NAME # define FUNCTION_NAME round # define __ROUND_MODE DEC_ROUND_HALF_UP #endif #include DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x) || decNumberIsInfinite (&dn_x) || decNumberIsZero (&dn_x)) return x+x; decContextDefault (&context, DEFAULT_CONTEXT); context.round = __ROUND_MODE; decNumberToIntegralValue (&dn_result, &dn_x, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); if (context.status & DEC_Overflow) DFP_EXCEPT (FE_OVERFLOW); return result; } /* Regarding errno's: * Although they are specified in the relevent specs, Overflow errors cannot * actually occur with dfp types, therefore no errno wrappers are provided */ weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/roundd64.c000066400000000000000000000021461261375163000162040ustar00rootroot00000000000000/* Rounds to the nearest integer value, ignores rounding mode Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "roundd32.c" libdfp-1.0.12/ieee754r/roundevend128.c000066400000000000000000000020621261375163000171400ustar00rootroot00000000000000/* Round a _Decimal128 type to the nearest integer value, rounding halfway cases to even. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "roundevend32.c" libdfp-1.0.12/ieee754r/roundevend32.c000066400000000000000000000033321261375163000170530ustar00rootroot00000000000000/* Round a _Decimal32 type to the nearest integer value, rounding halfway cases to even. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #define FUNCTION_NAME roundeven #include DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; FUNC_CONVERT_TO_DN (&x, &dn_x); decContextDefault (&context, DEFAULT_CONTEXT); decContextDefault (&context, DEFAULT_CONTEXT); context.round = DEC_ROUND_HALF_EVEN; decNumberToIntegralValue (&dn_result, &dn_x, &context); decNumberToIntegralValue (&dn_result, &dn_x, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/roundevend64.c000066400000000000000000000020571261375163000170630ustar00rootroot00000000000000/* Round a _Decimal64 type to the nearest integer value, rounding halfway cases to even. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "roundevend32.c" libdfp-1.0.12/ieee754r/samequantumd128.c000066400000000000000000000021421261375163000174720ustar00rootroot00000000000000/* Returns true if x and y have the same exponent Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "samequantumd32.c" libdfp-1.0.12/ieee754r/samequantumd32.c000066400000000000000000000034321261375163000174070ustar00rootroot00000000000000/* Returns true if x and y have the same exponent Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 #endif #include #include #include #define FUNCTION_NAME samequantum #include _Bool INTERNAL_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decNumber dn_x; decNumber dn_y; FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&y, &dn_y); if(decNumberIsNaN(&dn_x) && decNumberIsNaN(&dn_y)) return true; if(decNumberIsNaN(&dn_x) || decNumberIsNaN(&dn_y)) return false; if(decNumberIsInfinite(&dn_x) && decNumberIsInfinite(&dn_y)) return true; if(decNumberIsInfinite(&dn_x) || decNumberIsInfinite(&dn_y)) return false; return (dn_x.exponent == dn_y.exponent); } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/samequantumd64.c000066400000000000000000000021401261375163000174070ustar00rootroot00000000000000/* Returns true if x and y have the same exponent Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "samequantumd32.c" libdfp-1.0.12/ieee754r/scalblnd128.c000066400000000000000000000021611261375163000165510ustar00rootroot00000000000000/* Returns x * FLT_RADIX^y without computing the right side directly Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "scalblnd32.c" libdfp-1.0.12/ieee754r/scalblnd32.c000066400000000000000000000051611261375163000164660ustar00rootroot00000000000000/* Returns x * FLT_RADIX^y without computing the right side directly Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 #endif #include #include #include #include #include #define FUNCTION_NAME scalbln #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x, long y) { decContext context; DEC_TYPE result; decNumber dn_x, dn_y; /* long long int sum=0LL; */ /* uint32_t temp2 = 0; */ /* Otherwise this may pass a bad residue to decFinalize which can result in * rounding error. */ /* int32_t temp = 0; */ FUNC_CONVERT_TO_DN(&x, &dn_x); if (decNumberIsNaN (&dn_x)) return x+x; if (decNumberIsInfinite (&dn_x) || decNumberIsZero (&dn_x) || y==0L) return x; decContextDefault(&context, DEFAULT_CONTEXT); // sum = dn_x.exponent + y; // if(sum >= 1000000000LL || sum <= -2000000000LL // || y >= 1000000000L || y <= -2000000000L) // ; /** definite overflow */ // else // dn_x.exponent = sum; // // decFinalize(&dn_x, &context, &temp, &temp2); if (y >= 1000000000L || y <= -2000000000L) context.status |= DEC_Overflow; else { decNumberFromInt32(&dn_y, (int)y); decNumberScaleB(&dn_x, &dn_x, &dn_y, &context); } FUNC_CONVERT_FROM_DN(&dn_x, &result, &context); if (context.status & DEC_Overflow) DFP_EXCEPT (FE_OVERFLOW); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x, long y) { DEC_TYPE z = IEEE_FUNCTION_NAME (x, y); if (!FUNC_D(__isfinite) (z) && FUNC_D(__isfinite) (x)) DFP_ERRNO (ERANGE); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/scalblnd64.c000066400000000000000000000021571261375163000164750ustar00rootroot00000000000000/* Returns x * FLT_RADIX^y without computing the right side directly Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "scalblnd32.c" libdfp-1.0.12/ieee754r/scalbnd128.c000066400000000000000000000021601261375163000163740ustar00rootroot00000000000000/* Returns x * FLT_RADIX^y without computing the right side directly Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "scalbnd32.c" libdfp-1.0.12/ieee754r/scalbnd32.c000066400000000000000000000047331261375163000163160ustar00rootroot00000000000000/* Returns x * FLT_RADIX^y without computing the right side directly Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 #endif #include #include #include #include #include #define FUNCTION_NAME scalbn #include #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x, int y) { decContext context; DEC_TYPE result; decNumber dn_x, dn_y; /* long int sum = 0L; */ /* uint32_t temp2 = 0; */ /* Otherwise this may pass a bad residue to decFinalize which can result in * rounding error. */ /* int32_t temp =0; */ FUNC_CONVERT_TO_DN(&x, &dn_x); if (decNumberIsNaN (&dn_x)) return x+x; if (decNumberIsInfinite (&dn_x) || decNumberIsZero (&dn_x) || y==0L) return x; decContextDefault(&context, DEFAULT_CONTEXT); // sum = dn_x.exponent + y; // if(sum >= 1000000000L || sum <= -2000000000LL) // ; /** definite overflow */ // else // dn_x.exponent = sum; // // decFinalize(&dn_x, &context, &temp, &temp2); decNumberFromInt32(&dn_y, y); decNumberScaleB(&dn_x, &dn_x, &dn_y, &context); FUNC_CONVERT_FROM_DN(&dn_x, &result, &context); if (context.status & DEC_Overflow) DFP_EXCEPT (FE_OVERFLOW); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x, int y) { DEC_TYPE z = IEEE_FUNCTION_NAME (x, y); if (!FUNC_D(__isfinite) (z) && FUNC_D(__isfinite) (x)) DFP_ERRNO (ERANGE); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/scalbnd64.c000066400000000000000000000021561261375163000163200ustar00rootroot00000000000000/* Returns x * FLT_RADIX^y without computing the right side directly Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "scalbnd32.c" libdfp-1.0.12/ieee754r/signbitd128.c000066400000000000000000000021331261375163000165710ustar00rootroot00000000000000/* Returns non-zero if _Decimal128 is negative Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "signbitd32.c" libdfp-1.0.12/ieee754r/signbitd32.c000066400000000000000000000030431261375163000165040ustar00rootroot00000000000000/* Returns non-zero if _Decimal32 is negative Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 /* needed to pick up DECNUMDIGITS before including decNumber.h */ # include #endif #include #include #include #include #define FUNCTION_NAME signbit #include int INTERNAL_FUNCTION_NAME (DEC_TYPE x) { decNumber dn_x; FUNC_CONVERT_TO_DN(&x, &dn_x); return decNumberIsNegative(&dn_x); } hidden_def (INTERNAL_FUNCTION_NAME) weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/signbitd64.c000066400000000000000000000021301261375163000165050ustar00rootroot00000000000000/* Returns non-zero if _Decimal64 is negative Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "signbitd32.c" libdfp-1.0.12/ieee754r/sind128.c000066400000000000000000000021331261375163000157230ustar00rootroot00000000000000/* Calculate the sin(x) for a _Decimal128 format x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "sind32.c" libdfp-1.0.12/ieee754r/sind32.c000066400000000000000000000037701261375163000156450ustar00rootroot00000000000000/* Calculate the sin(x) for a _Decimal32 format x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #include #include #define FUNCTION_NAME sin #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x) || decNumberIsZero (&dn_x)) return x+x; if (decNumberIsInfinite (&dn_x)) { DFP_EXCEPT (FE_INVALID); return DFP_NAN; } decContextDefault (&context, DEFAULT_CONTEXT); decNumberSin (&dn_result, &dn_x, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); if (FUNC_D(__isinf) (x)) DFP_ERRNO (EDOM); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/sind64.c000066400000000000000000000021301261375163000156370ustar00rootroot00000000000000/* Calculate the sin(x) for a _Decimal64 format x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "sind32.c" libdfp-1.0.12/ieee754r/sinhd128.c000066400000000000000000000021471261375163000161000ustar00rootroot00000000000000/* Calculate the hyperbolic sin (sinh) for a _Decimal128 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "sinhd32.c" libdfp-1.0.12/ieee754r/sinhd32.c000066400000000000000000000041731261375163000160130ustar00rootroot00000000000000/* Calculate the hyperbolic sin (sinh) for a _Decimal32 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #include #include #define FUNCTION_NAME sinh #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x) || decNumberIsZero (&dn_x) || decNumberIsInfinite (&dn_x) ) return x+x; decContextDefault (&context, DEFAULT_CONTEXT); decNumberSinh (&dn_result, &dn_x, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); if (context.status & DEC_Overflow) DFP_EXCEPT (FE_OVERFLOW); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); if (!FUNC_D(__isfinite) (z) && FUNC_D(__isfinite) (x)) { DFP_ERRNO (ERANGE); return (z > DFP_CONSTANT(0.0) ? DFP_HUGE_VAL : -DFP_HUGE_VAL ); } return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/sinhd64.c000066400000000000000000000021441261375163000160140ustar00rootroot00000000000000/* Calculate the hyperbolic sin (sinh) for a _Decimal64 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "sinhd32.c" libdfp-1.0.12/ieee754r/sqrtd128.c000066400000000000000000000021431261375163000161240ustar00rootroot00000000000000/* Returns the square root of a _Decimal128 type argument Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "sqrtd32.c" libdfp-1.0.12/ieee754r/sqrtd32.c000066400000000000000000000040541261375163000160410ustar00rootroot00000000000000/* Returns the square root of a _Decimal32 type argument Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #include #define FUNCTION_NAME sqrt #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; FUNC_CONVERT_TO_DN(&x, &dn_x); if (decNumberIsNaN (&dn_x)) return x+x; if (decNumberIsZero (&dn_x)) return x; if (decNumberIsNegative (&dn_x)) { DFP_EXCEPT (FE_INVALID); return DFP_NAN; } if (decNumberIsInfinite (&dn_x)) return x; decContextDefault(&context, DEFAULT_CONTEXT); decNumberSquareRoot(&dn_result, &dn_x, &context); FUNC_CONVERT_FROM_DN(&dn_result, &result, &context); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); if (x < DFP_CONSTANT(0.0)) DFP_ERRNO (EDOM); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/sqrtd64.c000066400000000000000000000021401261375163000160400ustar00rootroot00000000000000/* Returns the square root of a _Decimal64 type argument Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "sqrtd32.c" libdfp-1.0.12/ieee754r/tand128.c000066400000000000000000000021311261375163000157120ustar00rootroot00000000000000/* Calculate the tan(x) for _Decimal128 format x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "tand32.c" libdfp-1.0.12/ieee754r/tand32.c000066400000000000000000000042131261375163000156270ustar00rootroot00000000000000/* Calculate the tan(x) for _Decimal32 format x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #include #include #define FUNCTION_NAME tan #include static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x) || decNumberIsZero (&dn_x)) return x+x; if (decNumberIsInfinite (&dn_x)) { DFP_EXCEPT (FE_INVALID); return DFP_NAN; } decContextDefault (&context, DEFAULT_CONTEXT); decNumberTan (&dn_result, &dn_x, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); if (context.status & DEC_Overflow) DFP_EXCEPT (FE_OVERFLOW); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); if (FUNC_D(__isinf) (x)) DFP_ERRNO (EDOM); if (!FUNC_D(__isfinite) (z) && FUNC_D(__isfinite) (x)) DFP_ERRNO (ERANGE); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/tand64.c000066400000000000000000000021261261375163000156350ustar00rootroot00000000000000/* Calculate the tan(x) for _Decimal64 format x Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "tand32.c" libdfp-1.0.12/ieee754r/tanhd128.c000066400000000000000000000021471261375163000160710ustar00rootroot00000000000000/* Calculate the hyperbolic tan (tanh) for a _Decimal128 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "tanhd32.c" libdfp-1.0.12/ieee754r/tanhd32.c000066400000000000000000000035161261375163000160040ustar00rootroot00000000000000/* Calculate the hyperbolic tan (tanh) for a _Decimal32 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 # include #endif #include #include #include #include #define FUNCTION_NAME tanh #include DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; FUNC_CONVERT_TO_DN (&x, &dn_x); if (decNumberIsNaN (&dn_x) || decNumberIsZero (&dn_x)) return x+x; if (decNumberIsInfinite (&dn_x)) return decNumberIsNegative (&dn_x) ? DFP_CONSTANT(-1.0) : DFP_CONSTANT(1.0); decContextDefault (&context, DEFAULT_CONTEXT); decNumberTanh (&dn_result, &dn_x, &context); FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/tanhd64.c000066400000000000000000000021441261375163000160050ustar00rootroot00000000000000/* Calculate the hyperbolic tan (tanh) for a _Decimal64 type Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "tanhd32.c" libdfp-1.0.12/ieee754r/tgammad128.c000066400000000000000000000021541261375163000164030ustar00rootroot00000000000000/* Returns the result of integral[0->inf, t**(x-1) * e**(-t) dt] Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "tgammad32.c" libdfp-1.0.12/ieee754r/tgammad32.c000066400000000000000000000045021261375163000163140ustar00rootroot00000000000000/* Returns the result of integral[0->inf, t**(x-1) * e**(-t) dt] Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 #endif #include #include #include #include #include #define FUNCTION_NAME tgamma #include extern DEC_TYPE FUNC_D (__lgamma_r) (DEC_TYPE, int *); //extern int //FUNC_D (__builtin_signbit) (DEC_TYPE); static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE result, gamma; int local_signgam; if (x == DFP_CONSTANT(0.0)) /* Pole error if x== +-0 */ { DFP_EXCEPT (FE_DIVBYZERO); // return FUNC_D (__builtin_signbit) (x) ? -DFP_HUGE_VAL : DFP_HUGE_VAL; return (x<0) ? -DFP_HUGE_VAL : DFP_HUGE_VAL; } if (x < DFP_CONSTANT(0.0) && (!FUNC_D (__isinf) (x) && FUNC_D (__rint) (x) == x) ) { DFP_EXCEPT (FE_INVALID); return DFP_NAN; } gamma = FUNC_D(__lgamma_r) (x,&local_signgam); result = local_signgam * FUNC_D(__exp) (gamma); return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); if (!FUNC_D(__isfinite) (z) && FUNC_D(__isfinite) (x)) DFP_ERRNO (ERANGE); if (x < DFP_CONSTANT(0.0) && (FUNC_D (__isinf) (x) && FUNC_D (__rint) (x) == x) ) DFP_ERRNO (EDOM); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/tgammad64.c000066400000000000000000000021521261375163000163200ustar00rootroot00000000000000/* Returns the result of integral[0->inf, t**(x-1) * e**(-t) dt] Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "tgammad32.c" libdfp-1.0.12/ieee754r/truncd128.c000066400000000000000000000021451261375163000162700ustar00rootroot00000000000000/* Round a _Decimal128 type to the nearest but <= argument Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #include #include "truncd32.c" libdfp-1.0.12/ieee754r/truncd32.c000066400000000000000000000033411261375163000162010ustar00rootroot00000000000000/* Round a _Decimal32 type to the nearest but <= argument Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 /* needed to pick up DECNUMDIGITS before including decNumber.h */ # include #endif #include #include #include #define FUNCTION_NAME trunc #include DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { decContext context; decNumber dn_result; DEC_TYPE result; decNumber dn_x; FUNC_CONVERT_TO_DN(&x, &dn_x); decContextDefault(&context, DEFAULT_CONTEXT); context.round = DEC_ROUND_DOWN; decNumberToIntegralValue(&dn_result, &dn_x, &context); FUNC_CONVERT_FROM_DN(&dn_result, &result, &context); return result; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/ieee754r/truncd64.c000066400000000000000000000021421261375163000162040ustar00rootroot00000000000000/* Round a _Decimal64 type to the nearest but <= argument Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #include #include "truncd32.c" libdfp-1.0.12/include/000077500000000000000000000000001261375163000144625ustar00rootroot00000000000000libdfp-1.0.12/include/README000066400000000000000000000001101261375163000153320ustar00rootroot00000000000000# These are include files common to libdfp. These are not distributed. libdfp-1.0.12/include/convert.h000066400000000000000000000210421261375163000163120ustar00rootroot00000000000000/* Handle conversion from binary integers, floats and decimal types Copyright (C) 2007,2008 IBM Corporation. Copyright (C) 2014-2015 Free Software Foundation, Inc. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #include #include #include /* decimal source */ #if defined DECIMAL_TO_INTEGER || defined DECIMAL_TO_BINARY || defined DECIMAL_TO_DECIMAL #if SRC==32 # define SRC_TYPE _Decimal32 # define IEEE_SRC_TYPE decimal32 # define SRC_LITERAL(n) n##DF # define SRC_KIND sd # define SIGNBIT __signbitd32 # define CLASSIFY __fpclassifyd32 #endif #if SRC==64 # define SRC_TYPE _Decimal64 # define IEEE_SRC_TYPE decimal64 # define SRC_LITERAL(n) n##DD # define SRC_KIND dd # define SIGNBIT __signbitd64 # define CLASSIFY __fpclassifyd64 #endif #if SRC==128 # define SRC_TYPE _Decimal128 # define IEEE_SRC_TYPE decimal128 # define SRC_LITERAL(n) n##DL # define SRC_KIND td # define SIGNBIT __signbitd128 # define CLASSIFY __fpclassifyd128 #endif extern int SIGNBIT (SRC_TYPE); #define DECIMAL_SIZE SRC #endif //DECIMAL_TO_INTEGER || DECIMAL_TO_BINARY || DECIMAL_TO_DECIMAL /* float source */ #if defined BINARY_TO_DECIMAL #if SRC==32 #define SRC_TYPE float #define SRC_LITERAL(n) n##f #define SRC_KIND sf #define SIGNBIT __builtin_signbitf //extern int __dfp_classify_sf (float a); #define CLASSIFY __dfp_classify_sf #endif #if SRC==64 #define SRC_TYPE double #define SRC_LITERAL(n) n##d #define SRC_KIND df #define SIGNBIT __builtin_signbit //extern int __dfp_classify_df (double a); #define CLASSIFY __dfp_classify_df #endif #if SRC==128 #define SRC_TYPE long double #define SRC_LITERAL(n) n##l #define SRC_KIND tf #define SIGNBIT __builtin_signbitl //extern int __dfp_classify_df (double a); /* For IBM 128-bit long double we use the double version. */ #define CLASSIFY __dfp_classify_df #endif extern int SIGNBIT (SRC_TYPE); extern int CLASSIFY (SRC_TYPE); #endif // BINARY_TO_DECIMAL /* integer source */ #if defined INTEGER_TO_DECIMAL #if SRC==32 #if defined UNSIGNED #define SRC_TYPE unsigned int #define INT_FMT "%u" #define CAST_FOR_FMT(A) (unsigned int)A #else #define SRC_TYPE int #define INT_FMT "%d" #define CAST_FOR_FMT(A) (int)A #endif #define SRC_LITERAL(n) n #define SRC_KIND si #endif #if SRC==64 #if defined UNSIGNED #define SRC_TYPE unsigned long long #define INT_FMT "%llu" #define CAST_FOR_FMT(A) (unsigned long long)A #else #define SRC_TYPE long long #define INT_FMT "%lld" #define CAST_FOR_FMT(A) (long long)A #endif #define SRC_LITERAL(n) n #define SRC_KIND di #endif #endif // INTEGER_TO_DECIMAL /* decimal dest */ #if defined DECIMAL_TO_DECIMAL || defined INTEGER_TO_DECIMAL || defined BINARY_TO_DECIMAL #if DEST==32 #define DEST_TYPE _Decimal32 #define IEEE_DEST_TYPE decimal32 #define DEST_LITERAL(n) n##DF #define DEST_KIND sd #endif #if DEST==64 #define DEST_TYPE _Decimal64 #define IEEE_DEST_TYPE decimal64 #define DEST_LITERAL(n) n##DD #define DEST_KIND dd #endif #if DEST==128 #define DEST_TYPE _Decimal128 #define IEEE_DEST_TYPE decimal128 #define DEST_LITERAL(n) n##DL #define DEST_KIND td #endif #define DEST_INFINITY DEC_INFINITY #define DEST_NAN DEC_NAN #if defined DECIMAL_SIZE #if DECIMAL_SIZE < DEST #undef DECIMAL_SIZE #define DECIMAL_SIZE DEST #endif #endif #define CONTEXT_INIT PASTE(DEC_INIT_DECIMAL,DEST) #endif //DECIMAL_TO_DECIMAL || INTEGER_TO_DECIMAL || BINARY_TO_DECIMAL /* float dest */ #if defined DECIMAL_TO_BINARY #if DEST==32 #define DEST_TYPE float #define DEST_LITERAL(n) n##F #define DEST_KIND sf #define DEST_INFINITY __builtin_inff () #define DEST_NAN __builtin_nanf ("") #endif #if DEST==64 #define DEST_TYPE double #define DEST_LITERAL(n) n #define DEST_KIND df #define DEST_INFINITY __builtin_inf () #define DEST_NAN __builtin_nan ("") #endif #if DEST==128 #define DEST_TYPE long double #define DEST_LITERAL(n) n##L #define DEST_KIND tf #define DEST_INFINITY __builtin_infl () #define DEST_NAN __builtin_nanl ("") #endif #endif //DECIMAL_TO_BINARY /* integer dest */ #if defined DECIMAL_TO_INTEGER #if DEST==32 #if defined UNSIGNED #define DEST_TYPE unsigned int #define STR_TO_INT strtoul #else #define DEST_TYPE int #define STR_TO_INT strtol #endif #define DEST_LITERAL(n) n #define DEST_KIND si #endif #if DEST==64 #if defined UNSIGNED #define DEST_TYPE unsigned long long #define STR_TO_INT strtoull #else #define DEST_TYPE long long #define STR_TO_INT strtoll #endif #define DEST_LITERAL(n) n #define DEST_KIND di #endif #endif //DECIMAL_TO_INTEGER extern long double binpowof10[]; extern const _Decimal128 decpowof2[]; #define BINPOWOF10 binpowof10 #define BINPOWOF10_LIMIT 308 #define DECPOWOF2 decpowof2 #define FREXPSF __builtin_frexpf #define FREXPDF __builtin_frexp #define FREXPTF __builtin_frexpl #define FREXPD32 __frexpd32 #define FREXPD64 __frexpd64 #define FREXPD128 __frexpd128 #ifndef PASTE # define PASTE(a,b) PASTE2(a,b) # define PASTE2(x,y) x##y #endif #define PASTE4(a,b,c,d) PASTE(PASTE(a,b),PASTE(c,d)) #define PASTE5(a,b,c,d,e) PASTE(PASTE4(a,b,c,d),e) #if defined DECIMAL_TO_DECIMAL #define FUNCTION_NAME PASTE4(NAME,SRC_KIND,DEST_KIND,2) #else #define FUNCTION_NAME PASTE4(NAME,SRC_KIND,DEST_KIND,) #endif /* Functions will need to be prefixed with __bid_ or __dpd_ depending on * how GCC was configured. --enable-decimal-float=[bid,dpd] */ #if __DECIMAL_BID_FORMAT__==1 #define PREFIXED_FUNCTION_NAME PASTE(__bid_,FUNCTION_NAME) #else /* #define PREFIXED_FUNCTION_NAME PASTE(__dfp_,FUNCTION_NAME) */ #define PREFIXED_FUNCTION_NAME PASTE(__dpd_,FUNCTION_NAME) #endif #if (SRC == 128 && (defined DECIMAL_TO_DECIMAL || defined DECIMAL_TO_INTEGER)) || \ (DEST == 128 && (defined DECIMAL_TO_DECIMAL || defined INTEGER_TO_DECIMAL)) #include "decimal128.h" #include #endif #if (SRC == 64 && (defined DECIMAL_TO_DECIMAL || defined DECIMAL_TO_INTEGER)) || \ (DEST == 64 && (defined DECIMAL_TO_DECIMAL || defined INTEGER_TO_DECIMAL)) #include "decimal64.h" #include #endif #if (SRC == 32 && (defined DECIMAL_TO_DECIMAL || defined DECIMAL_TO_INTEGER)) || \ (DEST == 32 && (defined DECIMAL_TO_DECIMAL || defined INTEGER_TO_DECIMAL)) #include "decimal32.h" #include #endif #define DFP_EXCEPTIONS_ENABLED 1 #define DFP_IEEE_FLAGS(status) ( \ (((status) & DEC_IEEE_854_Division_by_zero) ? FE_DIVBYZERO : 0) | \ (((status) & DEC_IEEE_854_Inexact) ? FE_INEXACT : 0) | \ (((status) & DEC_IEEE_854_Invalid_operation) ? FE_INVALID : 0) | \ (((status) & DEC_IEEE_854_Overflow) ? FE_OVERFLOW : 0) | \ (((status) & DEC_IEEE_854_Underflow) ? FE_UNDERFLOW : 0)) #ifdef fegetenv_register # include # define DFP_TEST_EXCEPTIONS(status) ({ \ fenv_union_t u; \ u.fenv = fegetenv_register(); \ u.l & (status); \ }) # define DFP_CLEAR_EXCEPTIONS(status) { \ fenv_union_t u; \ u.fenv = fegetenv_register(); \ u.l &= ~status; \ fesetenv_register(u.fenv); \ } #else # include /* Non-register targets might want to use the standard functions. * Note that it is necessary to include these symbols in libdfp * to avoid libm dependencies. */ # define DFP_TEST_EXCEPTIONS(status) fetestexcept (status) # define DFP_CLEAR_EXCEPTIONS(status) feclearexcept (status) #endif #define DFP_HANDLE_EXCEPTIONS(status) feraiseexcept(status) #define CONVERT_WRAPPER(...) \ DEST_TYPE \ PREFIXED_FUNCTION_NAME (SRC_TYPE a) \ { \ DEST_TYPE result = DEST_LITERAL(0.0); \ \ switch (CLASSIFY (a)) { \ case FP_ZERO: \ result = SIGNBIT(a) ? \ DEST_LITERAL(-0.0) : \ DEST_LITERAL(0.0); \ break; \ case FP_INFINITE: \ result = SIGNBIT(a) ? \ -DEST_INFINITY : \ DEST_INFINITY; \ break; \ case FP_NAN: \ result = DEST_NAN; \ break; \ default: { \ __VA_ARGS__ \ } \ } \ return result; \ } libdfp-1.0.12/include/decode.h000066400000000000000000000031331261375163000160560ustar00rootroot00000000000000/* Prototype for converting a _Decimal* into a string showing the declets. Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #ifndef _DECODE_DECIMAL_H #define _DECODE_DECIMAL_H 1 #include __BEGIN_DECLS /* char * should ref 14 bytes, +0,000,000E+0\0 */ extern char * __decoded32 (_Decimal32, char*); /* char * should ref 26 bytes, +0,000,000,000,000,000E+0\0 */ extern char * __decoded64 (_Decimal64, char*); /* char * should ref 50 bytes, * +0,000,000,000,000,000,000,000,000,000,000,000E+0\0 */ extern char * __decoded128 (_Decimal128, char*); hidden_proto(__decoded32) hidden_proto(__decoded64) hidden_proto(__decoded128) __END_DECLS #endif /* _DECODE_DECIMAL_H */ libdfp-1.0.12/include/dfp.h000066400000000000000000000025721261375163000154120ustar00rootroot00000000000000/* Prototypes for libdfp specific functions not defined by any standard. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DFP_H #define _DFP_H #include __BEGIN_DECLS /* In order to inform libc that a decimal floating point type needs to be * printed libdfp needs to inform libc, prior to the first invocation of printf, * that it has printf callbacks available for decimal floating point types. */ extern int register_printf_dfp (void); __END_DECLS #endif /* _DFP_H */ libdfp-1.0.12/include/dfpacc.h000066400000000000000000000200411261375163000160500ustar00rootroot00000000000000/* DFP Arithmetic, Conversion, and Comparison routines w/ exceptions. Copyright (C) 2009 IBM Corporation. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #ifndef _DFPACC_PRIVATE_H #define _DFPACC_PRIVATE_H 1 #ifndef PASTE # define PASTE(x,y) PASTE2(x,y) # define PASTE2(x,y) x##y #endif #if _BID_BACKEND == 1 # define __BACKEND_(x) PASTE(__bid_,x) # define hidden_proto_enc(name, attrs...) \ __hidden_proto (__bid_##name, __GI___bid_##name, ##attrs) #elif _DPD_BACKEND == 1 # define __BACKEND_(x) PASTE(__dpd_,x) # define hidden_proto_enc(name, attrs...) \ __hidden_proto (__dpd_##name, __GI___dpd_##name, ##attrs) #endif /* This file contains the prototypes for the DFP arithmetic, conversion, and * comparison routines. These also exist in libgcc, but these versions * support decimal floating point rounding control and exception support * whilst those in libgcc do not. GCC will place these in the code in * soft-dfp in place of arithmetic, conversion, or comparison functions, e.g. * _Decimal128 foo = bar + bat; * will be replaced with: * _Decima128 = __dpd_addtd3(bar,bat); */ _Decimal32 __BACKEND_(addsd3) (_Decimal32,_Decimal32); hidden_proto_enc (addsd3) _Decimal64 __BACKEND_(adddd3) (_Decimal64,_Decimal64); hidden_proto_enc (adddd3) _Decimal128 __BACKEND_(addtd3) (_Decimal128,_Decimal128); hidden_proto_enc (addtd3) _Decimal32 __BACKEND_(divsd3) (_Decimal32,_Decimal32); hidden_proto_enc (divsd3) _Decimal64 __BACKEND_(divdd3) (_Decimal64,_Decimal64); hidden_proto_enc (divdd3) _Decimal128 __BACKEND_(divtd3) (_Decimal128,_Decimal128); hidden_proto_enc (divtd3) int __BACKEND_(eqsd2) (_Decimal32,_Decimal32); hidden_proto_enc (eqsd2) int __BACKEND_(eqdd2) (_Decimal64,_Decimal64); hidden_proto_enc (eqdd2) int __BACKEND_(eqtd2) (_Decimal128,_Decimal128); hidden_proto_enc (eqtd2) _Decimal64 __BACKEND_(extendsddd2) (_Decimal32); hidden_proto_enc (extendsddd2) _Decimal128 __BACKEND_(extendsdtd2) (_Decimal32); hidden_proto_enc (extendsdtd2) _Decimal128 __BACKEND_(extendddtd2) (_Decimal64); hidden_proto_enc (extendddtd2) _Decimal32 __BACKEND_(extendsfsd) (float); hidden_proto_enc (extendsfsd) double __BACKEND_(extendsddf) (_Decimal32); hidden_proto_enc (extendsddf) long double __BACKEND_(extendsdtf) (_Decimal32); hidden_proto_enc (extendsdtf) _Decimal64 __BACKEND_(extendsfdd) (float); hidden_proto_enc (extendsfdd) _Decimal64 __BACKEND_(extenddfdd) (double); hidden_proto_enc (extenddfdd) long double __BACKEND_(extendddtf) (_Decimal64); hidden_proto_enc (extendddtf) _Decimal128 __BACKEND_(extendsftd) (float); hidden_proto_enc (extendsftd) _Decimal128 __BACKEND_(extenddftd) (double); hidden_proto_enc (extenddftd) _Decimal128 __BACKEND_(extendtftd) (long double); hidden_proto_enc (extendtftd) int __BACKEND_(fixsdsi) (_Decimal32); hidden_proto_enc (fixsdsi) int __BACKEND_(fixddsi) (_Decimal64); hidden_proto_enc (fixddsi) int __BACKEND_(fixtdsi) (_Decimal128); hidden_proto_enc (fixtdsi) long long __BACKEND_(fixsddi) (_Decimal32); hidden_proto_enc (fixsddi) long long __BACKEND_(fixdddi) (_Decimal64); hidden_proto_enc (fixdddi) long long __BACKEND_(fixtddi) (_Decimal128); hidden_proto_enc (fixtddi) unsigned int __BACKEND_(fixunssdsi) (_Decimal32); hidden_proto_enc (fixunssdsi) unsigned int __BACKEND_(fixunsddsi) (_Decimal64); hidden_proto_enc (fixunsddsi) unsigned int __BACKEND_(fixunstdsi) (_Decimal128); hidden_proto_enc (fixunstdsi) unsigned long long __BACKEND_(fixunssddi) (_Decimal32); hidden_proto_enc (fixunssddi) unsigned long long __BACKEND_(fixunsdddi) (_Decimal64); hidden_proto_enc (fixunsdddi) unsigned long long __BACKEND_(fixunstddi) (_Decimal128); hidden_proto_enc (fixunstddi) _Decimal64 __BACKEND_(floatdidd) (long long); hidden_proto_enc (floatdidd) _Decimal32 __BACKEND_(floatdisd) (long long); hidden_proto_enc (floatdisd) _Decimal128 __BACKEND_(floatditd) (long long); hidden_proto_enc (floatditd) _Decimal64 __BACKEND_(floatsidd) (int); hidden_proto_enc (floatsidd) _Decimal32 __BACKEND_(floatsisd) (int); hidden_proto_enc (floatsisd) _Decimal128 __BACKEND_(floatsitd) (int); hidden_proto_enc (floatsitd) _Decimal64 __BACKEND_(floatunsdidd) (unsigned long long); hidden_proto_enc (floatunsdidd) _Decimal32 __BACKEND_(floatunsdisd) (unsigned long long); hidden_proto_enc (floatunsdisd) _Decimal128 __BACKEND_(floatunsditd) (unsigned long long); hidden_proto_enc (floatunsditd) _Decimal64 __BACKEND_(floatunssidd) (unsigned int); hidden_proto_enc (floatunssidd) _Decimal32 __BACKEND_(floatunssisd) (unsigned int); hidden_proto_enc (floatunssisd) _Decimal128 __BACKEND_(floatunssitd) (unsigned int); hidden_proto_enc (floatunssitd) int __BACKEND_(gesd2) (_Decimal32,_Decimal32); hidden_proto_enc (gesd2) int __BACKEND_(gedd2) (_Decimal64,_Decimal64); hidden_proto_enc (gedd2) int __BACKEND_(getd2) (_Decimal128,_Decimal128); hidden_proto_enc (getd2) int __BACKEND_(gtsd2) (_Decimal32,_Decimal32); hidden_proto_enc (gtsd2) int __BACKEND_(gtdd2) (_Decimal64,_Decimal64); hidden_proto_enc (gtdd2) int __BACKEND_(gttd2) (_Decimal128,_Decimal128); hidden_proto_enc (gttd2) int __BACKEND_(lesd2) (_Decimal32,_Decimal32); hidden_proto_enc (lesd2) int __BACKEND_(ledd2) (_Decimal64,_Decimal64); hidden_proto_enc (ledd2) int __BACKEND_(letd2) (_Decimal128,_Decimal128); hidden_proto_enc (letd2) int __BACKEND_(ltsd2) (_Decimal32,_Decimal32); hidden_proto_enc (ltsd2) int __BACKEND_(ltdd2) (_Decimal64,_Decimal64); hidden_proto_enc (ltdd2) int __BACKEND_(lttd2) (_Decimal128,_Decimal128); hidden_proto_enc (lttd2) _Decimal32 __BACKEND_(mulsd3) (_Decimal32,_Decimal32); hidden_proto_enc (mulsd3) _Decimal64 __BACKEND_(muldd3) (_Decimal64,_Decimal64); hidden_proto_enc (muldd3) _Decimal128 __BACKEND_(multd3) (_Decimal128,_Decimal128); hidden_proto_enc (multd3) int __BACKEND_(nesd2) (_Decimal32,_Decimal32); hidden_proto_enc (nesd2) int __BACKEND_(nedd2) (_Decimal64,_Decimal64); hidden_proto_enc (nedd2) int __BACKEND_(netd2) (_Decimal128,_Decimal128); hidden_proto_enc (netd2) _Decimal32 __BACKEND_(subsd3) (_Decimal32,_Decimal32); hidden_proto_enc (subsd3) _Decimal64 __BACKEND_(subdd3) (_Decimal64,_Decimal64); hidden_proto_enc (subdd3) _Decimal128 __BACKEND_(subtd3) (_Decimal128,_Decimal128); hidden_proto_enc (subtd3) _Decimal32 __BACKEND_(trunctdsd2) (_Decimal128); hidden_proto_enc (trunctdsd2) _Decimal32 __BACKEND_(truncddsd2) (_Decimal64); hidden_proto_enc (truncddsd2) _Decimal64 __BACKEND_(trunctddd2) (_Decimal128); hidden_proto_enc (trunctddd2) float __BACKEND_(truncsdsf) (_Decimal32); hidden_proto_enc (truncsdsf) _Decimal32 __BACKEND_(truncdfsd) (double); hidden_proto_enc (truncdfsd) _Decimal32 __BACKEND_(trunctfsd) (long double); hidden_proto_enc (trunctfsd) float __BACKEND_(truncddsf) (_Decimal64); hidden_proto_enc (truncddsf) double __BACKEND_(truncdddf) (_Decimal64); hidden_proto_enc (truncdddf) _Decimal64 __BACKEND_(trunctfdd) (long double); hidden_proto_enc (trunctfdd) float __BACKEND_(trunctdsf) (_Decimal128); hidden_proto_enc (trunctdsf) double __BACKEND_(trunctddf) (_Decimal128); hidden_proto_enc (trunctddf) long double __BACKEND_(trunctdtf) (_Decimal128); hidden_proto_enc (trunctdtf) int __BACKEND_(unordsd2) (_Decimal32,_Decimal32); int __BACKEND_(unorddd2) (_Decimal64,_Decimal64); int __BACKEND_(unordtd2) (_Decimal128,_Decimal128); #endif /* _DFPACC_PRIVATE_H */ libdfp-1.0.12/include/dfpfenv_private.h000066400000000000000000000024271261375163000200220ustar00rootroot00000000000000/* Internal prototypes for fetching/changing the decimal rounding mode Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #ifndef _DFPFENV_PRIVATE_H #define _DFPFENV_PRIVATE_H extern int __fe_dec_setround(int __rounding_direction); extern int __fe_dec_getround(void); hidden_proto(__fe_dec_setround) hidden_proto(__fe_dec_getround) #endif /* _DFPFENV_PRIVATE_H */ libdfp-1.0.12/include/dfpmacro.h000066400000000000000000000131451261375163000164320ustar00rootroot00000000000000/* Macros that are used as a set of wrappers for function utilities Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ /* Necessary to pull in inlined feraiseexcept */ #ifndef __OPTIMIZE__ # define __OPTIMIZE__ 1 #endif #include /* When this file is #include'd, _DECIMAL_SIZE and FUNCTION_NAME * _DECIMAL_SIZE : 32, 64, 128 - Used for type definition * FUNCTION_NAME : fabs, ceil - Does not include _DECIMAL_SIZE suffix * should already be #define'd */ /* There is a subtle bug that can occur if headers are not included in the * right order in d32's *.c files. The order needs to be: * #include * #include + decContext.h + decWhatever.h * #include "dfpmacro.h" * * The reason for this is that decNumber sets some type dependent sizes * according to values set in decimalX.h. dfptypeconv.h (included below) * includes all three of the decimalX.h headers */ #if !defined( _DECIMAL_SIZE ) #error Including dfpmacro without defining _DECIMAL_SIZE is invalid #endif #if _DECIMAL_SIZE == 128 #include #elif _DECIMAL_SIZE == 64 #include #else #include #endif /* Data type to use for the generic function implementations */ #define DEC_TYPE PASTE(_Decimal,_DECIMAL_SIZE) /* Use these "functions" for variable preperation */ /* They use functions provided in decimal32/64/128.c and dfptypeconv.c */ #define FUNC_CONVERT_TO_DN(dec,dn) \ __DECIMAL_TO_DECNUMBER(dec,dn,_DECIMAL_SIZE) #define __DECIMAL_TO_DECNUMBER(dec,dn,SIZE) \ do { \ PASTE(decimal,SIZE) decimal; \ PASTE(___host_to_ieee_,SIZE) ((dec), &decimal); \ PASTE(PASTE(decimal,SIZE),ToNumber) (&decimal,(dn)); \ }while (0) #define FUNC_CONVERT_FROM_DN(dn,dec,context) \ do { \ PASTE(decimal,_DECIMAL_SIZE) decimal; \ PASTE(PASTE(decimal,_DECIMAL_SIZE),FromNumber) \ (&decimal, (dn), (context)); \ PASTE(PASTE(___ieee_,_DECIMAL_SIZE),_to_host) (&decimal, (dec));\ }while(0) #define IEEE_DECIMAL_TO_STRING(host, str) \ do { \ PASTE(decimal, _DECIMAL_SIZE) decimal; \ PASTE(___host_to_ieee_,_DECIMAL_SIZE)(host, &decimal); \ PASTE(decimal, PASTE(_DECIMAL_SIZE,ToString)) \ (&decimal, str); \ }while(0) #define IEEE_DECIMAL_TO_ENG_STRING(host, str) \ do { \ PASTE(decimal, _DECIMAL_SIZE) decimal; \ PASTE(___host_to_ieee_,_DECIMAL_SIZE)(host, &decimal); \ PASTE(decimal, PASTE(_DECIMAL_SIZE,ToEngString)) \ (&decimal, str); \ }while(0) #define DEFAULT_CONTEXT PASTE(DEC_INIT_DECIMAL,_DECIMAL_SIZE) /* Use this as function internal and external names */ #define EXTERNAL_FUNCTION_NAME FUNC_D(FUNCTION_NAME) #define INTERNAL_FUNCTION_NAME PASTE(__,EXTERNAL_FUNCTION_NAME) /* For functions that have both errno wrappers and exception throwing * implementations, this version is the exception throwing version, while * the INTERNAL_FUNCTION_NAME will be the errno wrapper */ #define IEEE_FUNCTION_NAME PASTE(__ieee743r_,EXTERNAL_FUNCTION_NAME) /* Functions will need to be prefixed with __bid_ or __dpd_ depending on * how GCC was configured. --enable-decimal-float=[bid,dpd] */ #if __DECIMAL_BID_FORMAT__==1 #define PREFIXED_FUNCTION_NAME PASTE(__bid_,ACTUAL_FUNCTION_NAME) #else /* #define PREFIXED_FUNCTION_NAME PASTE(__dfp_,ACTUAL_FUNCTION_NAME) */ #define PREFIXED_FUNCTION_NAME PASTE(__dpd_,ACTUAL_FUNCTION_NAME) #endif /* Use this if you need to refer to the type appropriate function * elswhere. For example FUNC_D (fabs) (x) may be needed in asin * FUNC_D(fabs) (x) will resolve to fabsd32 (x) in the 32 bit version */ #define FUNC_D(x) PASTE(x,PASTE(d,_DECIMAL_SIZE)) /* These can simply be called, and will check if it's appropriate * to throw the exception/errno before doing so */ /* If the compiler/glibc supports math_errhandling, we'll use it * in the future */ #define DFP_MATH_ERRHANDLING MATH_ERREXCEPT #include #define DFP_ERRNO(the_errno) *__errno_location() = the_errno #define DFP_EXCEPT(the_exception) \ do { \ if((DFP_MATH_ERRHANDLING & MATH_ERREXCEPT) > 0) \ feraiseexcept( (the_exception) ); \ } while(0) /* Useful for generating constants */ #if _DECIMAL_SIZE == 32 #define DEC_SUFFIX DF #elif _DECIMAL_SIZE == 64 #define DEC_SUFFIX DD #elif _DECIMAL_SIZE == 128 #define DEC_SUFFIX DL #endif #define DFP_CONSTANT(x) PASTE(x,DEC_SUFFIX) #define DFP_MIN PASTE(__DEC,PASTE(_DECIMAL_SIZE,_MIN__)) #define DFP_EPSILON PASTE(__DEC,PASTE(_DECIMAL_SIZE,_EPSILON__)) /* Some useful (falsely generic) constants */ #define DFP_HUGE_VAL PASTE(HUGE_VAL_D,_DECIMAL_SIZE) #define DFP_NAN (DEC_TYPE)DEC_NAN #ifndef PASTE /* Ideally these shouldn't need to be used elsewhere outside of this file */ # define PASTE(x,y) PASTE2(x,y) # define PASTE2(x,y) x##y #endif libdfp-1.0.12/include/dfpstdlib_private.h000066400000000000000000000040561261375163000203450ustar00rootroot00000000000000/* Internal function prototypes for string-to-decimal conversions Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #ifndef _DFPSTDLIB_PRIVATE_H #define _DFPSTDLIB_PRIVATE_H 1 #include extern _Decimal32 __strtod32_internal (const char * __restrict nptr, char ** __restrict endptr, int group); extern _Decimal64 __strtod64_internal (const char * __restrict nptr, char ** __restrict endptr, int group); extern _Decimal128 __strtod128_internal (const char * __restrict nptr, char ** __restrict endptr, int group); hidden_proto (__strtod32_internal) hidden_proto (__strtod64_internal) hidden_proto (__strtod128_internal) extern _Decimal32 __strtod32_l_internal (const char * __restrict nptr, char ** __restrict endptr, int group, locale_t loc); extern _Decimal64 __strtod64_l_internal (const char * __restrict nptr, char ** __restrict endptr, int group, locale_t loc); extern _Decimal128 __strtod128_l_internal (const char * __restrict nptr, char ** __restrict endptr, int group, locale_t loc); hidden_proto (__strtod32_l_internal) hidden_proto (__strtod64_l_internal) hidden_proto (__strtod128_l_internal) #endif /* _DFPSTDLIB_PRIVATE_H */ libdfp-1.0.12/include/dfpwchar_private.h000066400000000000000000000040531261375163000201650ustar00rootroot00000000000000/* Internal interfaces for wcstod[32|64|128] functions. Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #ifndef _DFPWCHAR_PRIVATE_H #define _DFPWCHAR_PRIVATE_H extern _Decimal32 __wcstod32_internal (const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int group); extern _Decimal64 __wcstod64_internal (const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int group); extern _Decimal128 __wcstod128_internal (const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int group); hidden_proto (__wcstod32_internal) hidden_proto (__wcstod64_internal) hidden_proto (__wcstod128_internal) extern _Decimal32 __wcstod32_l_internal (const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int group, locale_t loc); extern _Decimal64 __wcstod64_l_internal (const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int group, locale_t loc); extern _Decimal128 __wcstod128_l_internal (const wchar_t * __restrict nptr, wchar_t ** __restrict endptr, int group, locale_t loc); hidden_proto (__wcstod32_l_internal) hidden_proto (__wcstod64_l_internal) hidden_proto (__wcstod128_l_internal) #endif /* _DFPWCHAR_PRIVATE_H */ libdfp-1.0.12/include/fmt_dfp.h000066400000000000000000000031131261375163000162500ustar00rootroot00000000000000/* Prototype for converting a _Decimal* number into a string Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #ifndef _FMT_DFP_H #define _FMT_DFP_H 1 #include #include __BEGIN_DECLS extern char * __fmt_d32 ( const struct printf_info *info, const void *const *args, char * str, int slen); extern char * __fmt_d64 ( const struct printf_info *info, const void *const *args, char * str, int slen); extern char * __fmt_d128 ( const struct printf_info *info, const void *const *args, char * str, int slen); hidden_proto(__fmt_d32) hidden_proto(__fmt_d64) hidden_proto(__fmt_d128) __END_DECLS #endif libdfp-1.0.12/include/get_digits.h000066400000000000000000000027221261375163000167600ustar00rootroot00000000000000/* Prototype for getting the number of digits in a _Decimal[32|64|128] Copyright (C) 2009 IBM Corporation. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #ifndef _GET_DIGITS_H #define _GET_DIGITS_H 1 /* Define the number of digits necessary to store a DEC_TYPE in a string. */ #define NDIGITS_32 8 #define NDIGITS_64 17 #define NDIGITS_128 35 void __get_digits_d32 (_Decimal32, char*, int*, int*, int *, int *); void __get_digits_d64 (_Decimal64, char*, int*, int*, int *, int *); void __get_digits_d128 (_Decimal128, char*, int*, int*, int *, int *); #endif /* _GET_DIGITS_H */ libdfp-1.0.12/include/gstdint.h000066400000000000000000000021601261375163000163060ustar00rootroot00000000000000/* Internal function prototypes for string-to-decimal conversions Copyright (C) 2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ /* This header is necessary because libdecnumber in GCC makes a requirement of * it and it normally resides outside of the libdecnumber directory. */ #include libdfp-1.0.12/include/ieee754r_private.h000066400000000000000000000057461261375163000177320ustar00rootroot00000000000000/* Internal ieee754r function prototypes used by libdfp. Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #ifndef _DFP_IEEE754R_PRIVATE_H #define _DFP_IEEE754R_PRIVATE_H 1 /* Maybe just have libdfp use the __builtin_ functions in the future? */ extern int __isgreaterd32(_Decimal32 x, _Decimal32 y); extern int __isgreaterequald32(_Decimal32 x, _Decimal32 y); extern int __islessd32(_Decimal32 x, _Decimal32 y); extern int __islessequald32(_Decimal32 x, _Decimal32 y); extern int __islessgreaterd32(_Decimal32 x, _Decimal32 y); extern int __isunorderedd32 (_Decimal32 x, _Decimal32 y); extern int __isgreaterd64(_Decimal64 x, _Decimal64 y); extern int __isgreaterequald64(_Decimal64 x, _Decimal64 y); extern int __islessd64(_Decimal64 x, _Decimal64 y); extern int __islessequald64(_Decimal64 x, _Decimal64 y); extern int __islessgreaterd64(_Decimal64 x, _Decimal64 y); extern int __isunorderedd64 (_Decimal64 x, _Decimal64 y); extern int __isgreaterd128(_Decimal128 x, _Decimal128 y); extern int __isgreaterequald128(_Decimal128 x, _Decimal128 y); extern int __islessd128(_Decimal128 x, _Decimal128 y); extern int __islessequald128(_Decimal128 x, _Decimal128 y); extern int __islessgreaterd128(_Decimal128 x, _Decimal128 y); extern int __isunorderedd128 (_Decimal128 x, _Decimal128 y); extern _Decimal32 __lgamma_rd32 (_Decimal32, int *); extern _Decimal64 __lgamma_rd64 (_Decimal64, int *); extern _Decimal128 __lgamma_rd128 (_Decimal128, int *); extern int __isnormald32 (_Decimal32 x); extern int __isnormald64 (_Decimal64 x); extern int __isnormald128 (_Decimal128 x); hidden_proto(__isnand32) hidden_proto(__isnand64) hidden_proto(__isnand128) hidden_proto(__isinfd32) hidden_proto(__isinfd64) hidden_proto(__isinfd128) hidden_proto(__isfinited32) hidden_proto(__isfinited64) hidden_proto(__isfinited128) hidden_proto(__fpclassifyd32) hidden_proto(__fpclassifyd64) hidden_proto(__fpclassifyd128) hidden_proto(__fabsd32) hidden_proto(__fabsd64) hidden_proto(__fabsd128) hidden_proto(__signbitd32) hidden_proto(__signbitd64) hidden_proto(__signbitd128) #endif /* _IEEE754R_PRIVATE_H */ libdfp-1.0.12/include/init_dfp.h000066400000000000000000000020531261375163000164270ustar00rootroot00000000000000/* Libdfp constructor prototype. Copyright (C) 2010-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #ifndef _INIT_DFP_H #define _INIT_DFP_H 1 extern void __libdfp_init (void); #endif libdfp-1.0.12/include/libdfp-symbols.h000066400000000000000000000120401261375163000175560ustar00rootroot00000000000000/* Support macros for making weak and strong aliases for symbols. Copyright (C) 1995-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #ifndef _LIBDFP_SYMBOLS_H #define _LIBDFP_SYMBOLS_H 1 /* Define a macro we can use to construct the asm name for a C symbol. */ #ifndef LABEL # define LABEL(name) name##: #endif /* LABEL */ #define MIN(a,b) (((a)<(b))?(a):(b)) /* Define ALIASNAME as a strong alias for NAME. */ #ifndef __ASSEMBLER__ # define strong_alias(name, aliasname) _strong_alias(name, aliasname) # define _strong_alias(name, aliasname) \ extern __typeof (name) aliasname __attribute__ ((alias (#name))); #else # define strong_alias(original, alias) \ .globl alias; \ .set alias, original # define strong_data_alias(original, alias) strong_alias(original, alias) #endif /* Define ALIASNAME as a weak alias for NAME. If weak aliases are not available, this defines a strong alias. */ #ifndef __ASSEMBLER__ # define weak_alias(name, aliasname) _weak_alias (name, aliasname) # define _weak_alias(name, aliasname) \ extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))); #else # define weak_alias(original, alias) \ .weak alias; \ alias = original #endif /* Same as WEAK_ALIAS, but mark symbol as hidden. */ #define weak_hidden_alias(name, aliasname) \ _weak_hidden_alias (name, aliasname) #define _weak_hidden_alias(name, aliasname) \ extern __typeof (name) aliasname \ __attribute__ ((weak, alias (#name), __visibility__ ("hidden"))); /* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined). */ #define weak_extern(symbol) _weak_extern (weak symbol) #define _weak_extern(expr) _Pragma (#expr) /* We don't need hidden visibility with the static library libdfp.a */ #ifdef SHARED # define attribute_hidden __attribute__ ((visibility ("hidden"))) #else # define attribute_hidden #endif /* SHARED */ /* Add versioned symbol macros when necessary. */ /* Macros to avoid PLT calls within libdfp. */ #ifdef SHARED # ifndef __ASSEMBLER__ # define __hidden_proto_hiddenattr(attrs...) \ __attribute__ ((visibility ("hidden"), ##attrs)) # define hidden_proto(name, attrs...) \ __hidden_proto (name, __GI_##name, ##attrs) # define __hidden_proto(name, internal, attrs...) \ extern __typeof (name) name __asm__ (__hidden_asmname (#internal)) \ __hidden_proto_hiddenattr (attrs); # define __hidden_asmname(name) \ __hidden_asmname1 (__USER_LABEL_PREFIX__, name) # define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name) # define __hidden_asmname2(prefix, name) #prefix name # define __hidden_ver1(local, internal, name) \ extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \ extern __typeof (name) __EI_##name \ __attribute__((alias (__hidden_asmname (#local)))) # define hidden_ver(local, name) __hidden_ver1(local, __GI_##name, name); # define hidden_data_ver(local, name) hidden_ver(local, name) # define hidden_def(name) _hidden_def(name) # define _hidden_def(name) __hidden_ver1(__GI_##name, name, name); # define hidden_data_def(name) hidden_def(name) # define hidden_weak(name) \ __hidden_ver1(__GI_##name, name, name) __attribute__((weak)); # define hidden_data_weak(name) hidden_weak(name) # else /* __ASSEMBLER__ */ # define hidden_def(name) strong_alias (name, __GI_##name) # define hidden_weak(name) hidden_def (name) # define hidden_ver(local, name) strong_alias (local, __GI_##name) # define hidden_data_def(name) strong_data_alias (name, __GI_##name) # define hidden_data_weak(name) hidden_data_def (name) # define hidden_data_ver(local, name) strong_data_alias (local, __GI_##name) # endif #else # define hidden_proto(name, attrs...) # define hidden_weak(name) # define hidden_def(name) # define hidden_ver(local, name) # define hidden_data_weak(name) # define hidden_data_def(name) # define hidden_data_ver(local, name) #endif /* SHARED */ /* Get some dirty hacks. */ #include /* C++ needs to know that types and declarations are C, not C++. */ #ifdef __cplusplus # define __BEGIN_DECLS extern "C" { # define __END_DECL } #else # define __BEGIN_DECLS # define __END_DECLS #endif #endif /* _LIBDFP_SYMBOLS_H */ libdfp-1.0.12/include/printf_dfp.h000066400000000000000000000034461261375163000167750ustar00rootroot00000000000000/* Function prototypes to convert DFP values to strings Copyright (C) 2006, 2009 IBM Corporation. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #ifndef _PRINTF_DFP_H #define _PRINTF_DFP_H 1 #include #define DFP_FLAG_DECIMAL_32 (1<<16) #define DFP_FLAG_DECIMAL_64 (1<<17) #define DFP_FLAG_DECIMAL_128 (1<<18) #include /* Internal entry point for formatting DFP. */ extern int __printf_dfp (FILE *, const struct printf_info *, const void *const *); hidden_proto (__printf_dfp) extern void __d128_va (void *mem, va_list *ap); hidden_proto (__d128_va) extern void __d64_va (void *mem, va_list *ap); hidden_proto (__d64_va) extern void __d32_va (void *mem, va_list *ap); hidden_proto (__d32_va) extern int __dfp_ais (const struct printf_info *info, size_t n, int *argtype, int *size); hidden_proto (__dfp_ais) extern int __register_printf_dfp (void); hidden_proto(__register_printf_dfp) #endif libdfp-1.0.12/include/sysdep.h000066400000000000000000000034701261375163000161460ustar00rootroot00000000000000/* Some constructs used by asm files. Copyright (C) 2009 IBM Corporation. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #define cfi_startproc .cfi_startproc #define cfi_endproc .cfi_endproc #define cfi_def_cfa(reg, off) .cfi_def_cfa reg, off #define cfi_def_cfa_register(reg) .cfi_def_cfa_register reg #define cfi_def_cfa_offset(off) .cfi_def_cfa_offset off #define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off #define cfi_offset(reg, off) .cfi_offset reg, off #define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off #define cfi_register(r1, r2) .cfi_register r1, r2 #define cfi_return_column(reg) .cfi_return_column reg #define cfi_restore(reg) .cfi_restore reg #define cfi_same_value(reg) .cfi_same_value reg #define cfi_undefined(reg) .cfi_undefined reg #define cfi_remember_state .cfi_remember_state #define cfi_restore_state .cfi_restore_state #define cfi_window_save .cfi_window_save #include_next libdfp-1.0.12/init_dfp.c000066400000000000000000000023341261375163000150010ustar00rootroot00000000000000/* Libdfp constructor and destructor functions. Copyright (C) 2010-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include void __attribute__ ((constructor)) __attribute__((visibility ("hidden"))) __libdfp_init (void) { /* At present this doesn't ever fail so we don't care about a return code. */ register_printf_dfp(); } libdfp-1.0.12/install-sh000077500000000000000000000220211261375163000150400ustar00rootroot00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2005-05-14.22 # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" chmodcmd="$chmodprog 0755" chowncmd= chgrpcmd= stripcmd= rmcmd="$rmprog -f" mvcmd="$mvprog" src= dst= dir_arg= dstarg= no_target_directory= usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: -c (ignored) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. --help display this help and exit. --version display version info and exit. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test -n "$1"; do case $1 in -c) shift continue;; -d) dir_arg=true shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; --help) echo "$usage"; exit $?;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -s) stripcmd=$stripprog shift continue;; -t) dstarg=$2 shift shift continue;; -T) no_target_directory=true shift continue;; --version) echo "$0 $scriptversion"; exit $?;; *) # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. test -n "$dir_arg$dstarg" && break # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dstarg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dstarg" shift # fnord fi shift # arg dstarg=$arg done break;; esac done if test -z "$1"; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi for src do # Protect names starting with `-'. case $src in -*) src=./$src ;; esac if test -n "$dir_arg"; then dst=$src src= if test -d "$dst"; then mkdircmd=: chmodcmd= else mkdircmd=$mkdirprog fi else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dstarg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dstarg # Protect names starting with `-'. case $dst in -*) dst=./$dst ;; esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dstarg: Is a directory" >&2 exit 1 fi dst=$dst/`basename "$src"` fi fi # This sed command emulates the dirname command. dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'` # Make sure that the destination directory exists. # Skip lots of stat calls in the usual case. if test ! -d "$dstdir"; then defaultIFS=' ' IFS="${IFS-$defaultIFS}" oIFS=$IFS # Some sh's can't handle IFS=/ for some reason. IFS='%' set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` shift IFS=$oIFS pathcomp= while test $# -ne 0 ; do pathcomp=$pathcomp$1 shift if test ! -d "$pathcomp"; then $mkdirprog "$pathcomp" # mkdir can fail with a `File exist' error in case several # install-sh are creating the directory concurrently. This # is OK. test -d "$pathcomp" || exit fi pathcomp=$pathcomp/ done fi if test -n "$dir_arg"; then $doit $mkdircmd "$dst" \ && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; } else dstfile=`basename "$dst"` # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 trap '(exit $?); exit' 1 2 13 15 # Copy the file name to the temp name. $doit $cpprog "$src" "$dsttmp" && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && # Now rename the file to the real destination. { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \ || { # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { if test -f "$dstdir/$dstfile"; then $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ || { echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 (exit 1); exit 1 } else : fi } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" } } fi || { (exit 1); exit 1; } done # The final little trick to "correctly" pass the exit status to the exit trap. { (exit 0); exit 0 } # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-end: "$" # End: libdfp-1.0.12/libbid/000077500000000000000000000000001261375163000142645ustar00rootroot00000000000000libdfp-1.0.12/libbid/README000066400000000000000000000000551261375163000151440ustar00rootroot00000000000000No one has implemented libbid in libdfp yet. libdfp-1.0.12/libbid/configure.ac000066400000000000000000000000371261375163000165520ustar00rootroot00000000000000#Stub to make autoreconf happy libdfp-1.0.12/libdecnumber/000077500000000000000000000000001261375163000154725ustar00rootroot00000000000000libdfp-1.0.12/libdecnumber/.gitignore000066400000000000000000000000111261375163000174520ustar00rootroot00000000000000gstdint.hlibdfp-1.0.12/libdecnumber/ChangeLog000066400000000000000000000455621261375163000172600ustar00rootroot000000000000002014-01-23 Marek Polacek PR c/59871 * decNumberLocal.h (UBFROMUS, UBFROMUI): Remove last argument. 2014-01-02 Richard Sandiford Update copyright years 2013-10-15 David Malcolm * Makefile.in (PICFLAG): New. (ALL_CFLAGS): Add PICFLAG. * configure.ac: Add --enable-host-shared, setting up new PICFLAG variable. * configure: Regenerate. 2013-07-09 Simon Baldwin * configure.ac: Add AC_CONFIG_AUX_DIR. * configure: Regenerated. 2013-03-27 Kai Tietz * configure: Regenerated. 2013-02-06 Richard Sandiford Update copyright years. 2012-11-04 Thomas Schwinge * configure: Regenerate. 2011-12-20 Andreas Schwab * configure: Regenerate. 2011-12-19 Andreas Schwab * configure: Regenerate. 2011-04-20 Jim Meyering * decNumber.c (decNumberFromString): Remove useless if-before-free test. (decNumberCompareTotalMag, decNumberExp, decNumberFMA): Likewise. (decNumberLn, decNumberLog10, decNumberPower): Likewise. (decNumberReduce, decNumberSquareRoot, decAddOp): Likewise. (decDivideOp, NEEDTWO, decExpOp, LN2): Likewise. 2011-03-28 Mike Frysinger * .gitignore: New file. 2010-11-24 Nathan Froyd * dconfig.h (LIBGCC2_FLOAT_WORDS_BIG_ENDIAN): Delete. (WORDS_BIG_ENDIAN): Define based on value of __FLOAT_WORD_ORDER__. 2010-10-23 Nathan Froyd * dconfig.h (LIBGCC2_WORDS_BIG_ENDIAN): Delete. (LIBGCC2_FLOAT_WORDS_BIG_ENDIAN): Test __BYTE_ORDER__. 2010-09-10 Kai Tietz * configure: Regenerated. 2010-09-08 Tristan Gingold PR 44001 * Makefile.in (objext): New variable. (bid_OBJS): Use $(objext) for extension. (libdecnumber_a_OBJS): Ditto. (mostlyclean): Ditto (.c.o): Ditto. Update dependencies. 2010-09-06 H.J. Lu PR target/45524 * configure.ac (enable_decimal_float): Set to $default_decimal_float. * configure: Regenerated. 2010-09-06 Andreas Schwab * configure: Regenerate. 2010-09-03 Andreas Krebbel * configure.ac: Use the GCC_AC_ENABLE_DECIMAL_FLOAT macro. * Makefile.in: Add aclocal.m4 dependency to dfp.m4. * configure: Regenerate. * aclocal.m4: Regenerate. 2010-08-21 Ralf Wildenhues * configure: Regenerate. 2010-04-02 Ralf Wildenhues * aclocal.m4: Regenerate. 2010-01-05 Rainer Orth * configure: Regenerate. 2009-11-28 Jakub Jelinek * decContext.c (decContextTestEndian): Move adj definition into #if DECCHECK guarded code. 2009-09-09 Paolo Bonzini * configure: Regenerate. 2009-09-08 Paolo Bonzini * configure: Regenerate. 2009-08-24 Ralf Wildenhues * configure.ac (AC_PREREQ): Bump to 2.64. 2009-08-22 Ralf Wildenhues * aclocal.m4: Regenerate. * configure: Regenerate. * config.in: Regenerate. 2009-08-13 Janis Johnson PR c/41046 * decContext.c (decContextTestEndian): Call printf only if DECCHECK. * decCommon.c ( decFloatShow): Define function only for DECCHECK or DECTRACE. 2009-07-30 Ralf Wildenhues * Makefile.in (aclocal_deps): New variable. ($(srcdir)/aclocal.m4): Use it, for portable makefile syntax. 2009-05-31 Ian Lance Taylor * decContext.h: Add extern "C" if compiling with C++. * decDPD.h: Likewise. * decNumber.h: Likewise. * dpd/decimal32.h: Likewise. * dpd/decimal64.h: Likewise. * dpd/decimal128.h: Likewise. 2009-04-09 Nick Clifton * decRound.c: Change copyright header to refer to version 3 of the GNU General Public License with version 3.1 of the GCC Runtime Library Exception and to point readers at the COPYING3 and COPYING3.RUNTIME files and the FSF's license web page. * bid/bid-dpd.h: Likewise. * bid/bid2dpd_dpd2bid.c: Likewise. * bid/bid2dpd_dpd2bid.h: Likewise. * bid/decimal128.c: Likewise. * bid/decimal32.c: Likewise. * bid/decimal64.c: Likewise. * bid/host-ieee128.c: Likewise. * bid/host-ieee32.c: Likewise. * bid/host-ieee64.c: Likewise. * dconfig.h: Likewise. * decBasic.c: Likewise. * decCommon.c: Likewise. * decContext.c: Likewise. * decContext.h: Likewise. * decDPD.h: Likewise. * decDouble.c: Likewise. * decDouble.h: Likewise. * decExcept.c: Likewise. * decExcept.h: Likewise. * decLibrary.c: Likewise. * decNumber.c: Likewise. * decNumber.h: Likewise. * decNumberLocal.h: Likewise. * decPacked.c: Likewise. * decPacked.h: Likewise. * decQuad.c: Likewise. * decQuad.h: Likewise. * decRound.h: Likewise. * decSingle.c: Likewise. * decSingle.h: Likewise. * dpd/decimal128.c: Likewise. * dpd/decimal128.h: Likewise. * dpd/decimal128Local.h: Likewise. * dpd/decimal32.c: Likewise. * dpd/decimal32.h: Likewise. * dpd/decimal64.c: Likewise. * dpd/decimal64.h: Likewise. 2009-04-09 Jakub Jelinek * Makefile.in: Change copyright header to refer to version 3 of the GNU General Public License and to point readers at the COPYING3 file and the FSF's license web page. * configure.ac: Likewise. 2009-04-01 Ben Elliston * decContext.h: Include gstdint.h instead of . 2009-03-30 Ben Elliston * decNumber.c, decNumber.h, decNumberLocal.h, decDouble.c, decDouble.h, decSingle.c, decContext.c, decSingle.h, decPacked.c, decCommon.c, decContext.h, decQuad.c, decPacked.h, decQuad.h, decDPD.h, decBasic.c: Upgrade to decNumber 3.61. * dpd/decimal128.h, dpd/decimal32.c, dpd/decimal32.h, dpd/decimal64.c, dpd/decimal128.c, dpd/decimal64.h: Likewise. 2009-02-10 Joseph Myers * Makefile.in (clean): Don't remove makedepend$(EXEEXT). 2008-10-27 Janis Johnson PR other/37897 * decDouble.h (decDouble): Replace struct with union accessible by more types. * decSingle.h (decSingle): Ditto. * decQuad.h (decQuad): Ditto. * decNumberLocal.h (DFWORD, DFBYTE, DFWWORD): access decFloat via new members. * decBasic.c (decFloatCompareTotal): Avoid type-pun violation. (decNumberCompare): Ditto. 2008-06-17 Ralf Wildenhues * Makefile.in ($(srcdir)/aclocal.m4): Update dependencies. * configure: Regenerate. 2008-06-16 Ralf Wildenhues * Makefile.in (datarootdir): New variable. 2008-06-10 Joseph Myers * dconfig.h: New. * decContext.c, decExcept.c, decExcept.h, decLibrary.c, decNumber.c, decNumberLocal.h, decRound.c, dpd/decimal128.c, dpd/decimal32.c, dpd/decimal64.c: Include dconfig.h not config.h. * dpd/decimal128Local.h (decimal128SetSign, decimal128ClearSign, decimal128FlipSign): Use WORDS_BIGENDIAN not FLOAT_WORDS_BIG_ENDIAN. * bid/host-ieee128.c: Include dconfig.h. (__host_to_ieee_128, __ieee_to_host_128): Swap 64-bit halves of value if WORDS_BIGENDIAN. 2008-04-18 Paolo Bonzini PR bootstrap/35457 * aclocal.m4: Regenerate. * configure: Regenerate. 2008-04-18 Ben Elliston * Makefile.in (distclean): Add gstdint.h. 2008-01-25 Janis Johnson * decCommonSymbols.h: Commit. * decDPDSybmols.h: Commit. * Makefile.in (libdecnumber_a_SOURCES): List Symbols headers. * decCommonSymbols.h: New file. * decCommon.c: Include it. * decDPDSymbols.h: New file. * decDPD.h: Include it. * decNumberLocal.h: Include the two new files. * decContextSymbols.h (DECPOWERS, DECSTICKYTAB): New. * decNumberSymbols.h (LNnn, d2utable): New. * dpd/decimal32Symbols.h (COMBEXP, COMBMSD, DPD2BIN, BIN2DPD): New. * dpd/decimal64Symbols.h (COMBEXP, COMBMSD, DPD2BIN, BIN2DPD): New. * dpd/decimal128Symbols.h (COMBEXP, COMBMSD, DPD2BIN, BIN2DPD): New. * dpd/decimal32.c: Remove redefine of DPD2BIN, BIN2DPD. * dpd/decimal64.c: Ditto. * dpd/decimal128.c: Ditto. 2007-11-26 Thiago Jung Bauermann * Makefile.in (decimal32.o): Prepend $(srcdir) to dependencies and substitute $< for the source file in compilation command. (decimal64.o): Likewise. (decimal128.o): Likewise. (bid2dpd_dpd2bid.o): Likewise. (host-ieee32.o): Likewise. (host-ieee64.o): Likewise. (host-ieee128.o): Likewise. 2007-10-31 Thiago Jung Bauermann * configure.ac: Add ADDITIONAL_OBJS variable. * Makefile.in (bid_OBS): New. (libdecnumber_a_OBJS): Add ADDITIONAL_OBJS, remove condition on enable_decimal_float. * configure: Regenerate. 2007-09-10 Janis Johnson Ben Elliston * Makefile.in (libdecnumber_a_OBJS): Remove decUtility.o (dependencies): Add Symbols headers. * decContext.c: Upgrade to decNumber 3.53. * decContext.h: Ditto. * decDPD.h: Ditto. * decNumber.c: Ditto. * decNumber.h: Ditto. * decNumberLocal.h: Ditto. * decBasic.c: New file from decNumber 3.53. * decCommon.c: Ditto. * decDouble.c: Ditto. * decDouble.h: Ditto. * decQuad.c: Ditto. * decQuad.h: Ditto. * decSingle.c: Ditto. * decSingle.h: Ditto. * decPacked.c: Ditto. * decPacked.h: Ditto. * dpd/decimal128.c: Upgrade to decNumber 3.53. * dpd/decimal128.h: Ditto. * dpd/decimal32.c: Ditto. * dpd/decimal32.h: Ditto. * dpd/decimal64.c: Ditto. * dpd/decimal64.h: Ditto. * decLibrary.c (__dec_byte_swap): Remove. * decContextSymbols.h: New file. * decDoubleSymbols.h: New file. * decNumberSymbols.h: New file. * decPackedSymbols.h: New file. * decQuadSymbols.h: New file. * decSingleSymbols.h: New file. * decUtility.c: Delete file. * decUtility.h: Delete file. * bid/decimal128Symbols.h: New file. * bid/decimal128Local.h: New file. * bid/decimal32Symbols.h: New file. * bid/decimal64Symbols.h: New file. * bid/host-ieee128.c (__swap128): Remove. (__host_to_ieee_128, __ieee_to_host_128): Don't handle endianness. * bid/host-ieee32.c (__dec_type_swap): Remove. (__host_to_ieee_32, __ieee_to_host_32): Don't handle endianness. * bid/host-ieee64.c (__swap64): Remove. (__host_to_ieee_64, __ieee_to_host_64): Don't handle endianness. * dpd/decimal32Symbols.h: New file. * dpd/decimal64Symbols.h: New file. * dpd/decimal128Symbols.h: New file. * dpd/decimal128Local.h: New file. 2007-06-18 Martin Michlmayr H.J. Lu * configure.ac: Add AC_CANONICAL_TARGET. * configure: Regenerated. 2007-04-16 H.J. Lu * Makefile.in (aclocal.m4): Depend on stdint.m4 instead of acx.m4. * aclocal.m4: Regenerated by aclocal 1.9.6. 2007-04-11 Kai Tietz * configure: Regenerate. 2007-03-23 Michael Meissner H.J. Lu Marius Cornea * Makefile.in (enable_decimal_float): New. (libdecnumber_a_OBJS): Add bid2dpd_dpd2bid.o, host-ieee32.o, host-ieee64.o and host-ieee128.o for BID. (libdecnumber_a_SOURCES): Support DPD and BID. (decimal32.o): Support dependency for both DPD and BID. (decimal64.o): Likewise. (decimal128.o): Likewise. (bid2dpd_dpd2bid.o): New target. (host-ieee32.o): Likewise. (host-ieee64.o): Likewise. (host-ieee128.o): Likewise. * bid/bid-dpd.h: New file. * bid/decimal128.c: Likewise. * bid/decimal128.h: Likewise. * bid/decimal32.c: Likewise. * bid/decimal32.h: Likewise. * bid/decimal64.c: Likewise. * bid/decimal64.h: Likewise. * bid/host-ieee128.c: Likewise. * bid/host-ieee32.c: Likewise. * bid/host-ieee64.c: Likewise. * bid/bid2dpd_dpd2bid.c: Likewise. * bid/bid2dpd_dpd2bid.h: Likewise. * decimal128.c: Moved to ... * dpd/decimal128.c: This. * decimal128.h: Moved to ... * dpd/decimal128.h: This. * decimal32.c: Moved to ... * dpd/decimal32.c: This. * decimal32.h: Moved to ... * dpd/decimal32.h: This. * decimal64.c: Moved to ... * dpd/decimal64.c: This. * decimal64.h: Moved to ... * dpd/decimal64.h: This. * configure.ac: Support * --enable-decimal-float={no,yes,bid,dpd}. Add AC_C_BIGENDIAN. Substitute enable_decimal_float. * config.in: Add decimal support variables. * configure: Regenerate. PR other/30530 * decimal128.h (decimal128ClearSign): New. (decimal128FlipSign): Likewise. * decimal32.h: (decimal32ClearSign): New. (decimal32FlipSign): Likewise. * decimal64.h (decimal64ClearSign): New. (decimal64FlipSign): Likewise. 2007-03-08 Ben Elliston * decContext.c, decContext.h, decDPD.h, decimal128.c, decimal128.h, decimal32.c, decimal32.h, decimal64.c, decimal64.h, decLibrary.c, decNumber.c, decNumber.h, decNumberLocal.h, decRound.c, decRound.h, decUtility.c, decUtility.h: Add libgcc-style license exception clause. 2007-03-01 Brooks Moses * Makefile.in: Add dummy install-pdf target. 2007-01-29 Janis Johnson * decExcept.c: New. * decExcept.h: New. 2006-11-29 Janis Johnson * decRound.c: Move declarations to new file, update comments. * decRound.h: New file. 2006-11-21 Janis Johnson * decLibrary.c (__dec_type_swap): Add prototype. (__dfp_enable_traps, dfp_raise): Delete. * Makefile.in: Don't include decRound in library used by compiler. 2006-10-10 Brooks Moses * Makefile.in: Added empty "pdf" target. 2006-09-15 Kaveh R. Ghazi * decNumber.c (decNumberPower): Constify. * decNumber.h (decNumberPower): Likewise. 2006-09-07 Kaveh R. Ghazi * configure.ac (ACX_PROG_CC_WARNING_OPTS): Add -Wcast-qual. * configure, config.in: Regenerate. * decContext.c (decContextStatusToString): Constify. * decContext.h (decContextStatusToString): Likewise. * decNumber.c (decNumberToString, decNumberToEngString, decNumberAbs, decNumberAdd, decNumberCompare, decNumberDivide, decNumberDivideInteger, decNumberMax, decNumberMin, decNumberMinus, decNumberPlus, decNumberMultiply, decNumberNormalize, decNumberQuantize, decNumberRescale, decNumberRemainder, decNumberRemainderNear, decNumberSameQuantum, decNumberSquareRoot, decNumberSubtract, decNumberToIntegralValue, decNumberCopy, decToString, decAddOp, decDivideOp, decMultiplyOp, decQuantizeOp, decCompareOp, decCompare, decUnitCompare, decUnitAddSub, decRoundOperand, decCopyFit, decSetCoeff, decGetInt, decNaNs, decGetDigits, decNumberShow, decDumpAr, decCheckOperands, decCheckNumber): Likewise. * decNumber.h (decNumberToString, decNumberToEngString, decNumberAbs, decNumberAdd, decNumberCompare, decNumberDivide, decNumberDivideInteger, decNumberMax, decNumberMin, decNumberMinus, decNumberMultiply, decNumberNormalize, decNumberPlus, decNumberQuantize, decNumberRemainder, decNumberRemainderNear, decNumberRescale, decNumberSameQuantum, decNumberSquareRoot, decNumberSubtract, decNumberToIntegralValue, decNumberCopy): Likewise. * decUtility.c (decDensePackCoeff, decDenseUnpackCoeff): Likewise. * decUtility.h (decDensePackCoeff, decDenseUnpackCoeff): Likewise. * decimal128.c (decimal128FromNumber, decimal128ToNumber, decimal128ToString, decimal128ToEngString, decimal128Show): Likewise. * decimal128.h (decimal128ToString, decimal128ToEngString, decimal128FromNumber, decimal128ToNumber): Likewise. * decimal32.c (decimal32FromNumber, decimal32ToNumber, decimal32ToString, decimal32ToEngString, decimal32Show): Likewise. * decimal32.h (decimal32ToString, decimal32ToEngString, decimal32FromNumber, decimal32ToNumber): Likewise. * decimal64.c (decimal64FromNumber, decimal64ToNumber, decimal64ToString, decimal64ToEngString, decimal64Show): Likewise. * decimal64.h (decimal64ToString, decimal64ToEngString, decimal64FromNumber, decimal64ToNumber): Likewise. 2006-08-21 Kaveh R. Ghazi * decContext.c (decContextSetStatusFromString): Constify. * decContext.h (decContextSetStatusFromString): Likewise. * decNumber.c (decNumberFromString): Likewise. * decNumber.h (decNumberFromString): Likewise. * decimal128.c (decimal128FromString): Likewise. * decimal128.h (decimal128FromString): Likewise. * decimal32.c (decimal32FromString): Likewise. * decimal32.h (decimal32FromString): Likewise. * decimal64.c (decimal64FromString): Likewise. * decimal64.h (decimal64FromString): Likewise. 2006-07-25 Paolo Bonzini PR build/26188 * configure: Regenerate. 2006-06-23 Ben Elliston * decNumber.h (decNumberNegate): Remove. 2006-05-23 Carlos O'Donell * Makefile.in: Add install-html target. Add install-html to .PHONY 2006-02-06 Ben Elliston * decLibrary.c (__dec_byte_swap): Use uint32_t for argument and return types. 2006-01-03 Roger Sayle Kaveh R. Ghazi * decNumber.c (__NO_STRING_INLINES): Define to prevent glibc macro definition of strcpy from generating compilation warnings. 2006-01-02 Paolo Bonzini PR target/25259 * configure.ac: Use GCC_HEADER_STDINT. * decContext.h: Include gstdint.h. * aclocal.m4: Regenerate. * configure: Regenerate. 2005-12-20 Roger Sayle * decNumber.c (decStrEq): Cast string contents to unsigned char instead of int before calling tolower. 2005-12-20 Roger Sayle * decNumber.c (decStrEq): Cast operands to int before calling tolower to avoid compilation warnings on Tru64. 2005-12-05 Ben Elliston * Makefile.in (clean): Remove stray reference to libcpp.a. * decimal128.h, decContext.c, decRound.c, decimal32.c, decNumber.c, decContext.h, decimal64.c, decimal32.h, decNumber.h, decimal64.h, decUtility.c, decLibrary.c, configure.ac, decNumberLocal.h, decUtility.h, decDPD.h, decimal128.c: Update FSF office address. 2005-12-01 Ben Elliston * Makefile.in (libdecnumber_a_SOURCES): Drop decLibrary.c. * decUtility.c (__dec_byte_swap): Move from here .. * decLibrary.c: .. to here. 2005-11-23 Gerald Pfeifer * decContext.h: Properly guard inclusion of stdint.h * decContext.c: Include config.h * decLibrary.c: Ditto. * decNumber.c: Ditto. * decRound.c: Ditto. * decUtility.c: Ditto. * decimal32.c: Ditto. * decimal64.c: Ditto. * decimal128.c: Ditto. 2005-11-29 Ben Elliston * decUtility.c: Remove redundant #includes. * decUtility.h (__dec_byte_swap): Remove prototype. 2005-11-29 Ben Elliston * configure.ac: New file. * aclocal.m4: Likewise. * Makefile.in: Likewise. * configure: Generate. * config.in: Likewise. 2005-11-29 Ben Elliston * decimal32.h, decimal64.h, decimal128.h: New. * decimal32.c, decimal64.c, decimal128.c: Likewise. * decContext.c, decContext.h: Likewise. * decUtility.c, decUtility.h: Likewise. * decNumber.c, decNumber.h, decNumberLocal.h: Likewise. * decDPD.h: Likewise. * decLibrary.c, decRound.c: Likewise. libdfp-1.0.12/libdecnumber/Makefile.in000066400000000000000000000114511261375163000175410ustar00rootroot00000000000000# @configure_input@ # Makefile for libdecnumber. Run 'configure' to generate Makefile from Makefile.in # Copyright (C) 2005-2015 Free Software Foundation, Inc. #This file is part of GCC. #GCC 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, or (at your option) #any later version. #GCC 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 GCC; see the file COPYING3. If not see #. @SET_MAKE@ srcdir = @srcdir@ top_builddir = . VPATH = @srcdir@ INSTALL = @INSTALL@ AR = ar ARFLAGS = cru ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ CC = @CC@ CFLAGS = @CFLAGS@ WARN_CFLAGS = @WARN_CFLAGS@ @WARN_PEDANTIC@ @WERROR@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBICONV = @LIBICONV@ PACKAGE = @PACKAGE@ PICFLAG = @PICFLAG@ RANLIB = @RANLIB@ SHELL = @SHELL@ objext = @OBJEXT@ datarootdir = @datarootdir@ datadir = @datadir@ exec_prefix = @prefix@ libdir = @libdir@ localedir = $(datadir)/locale prefix = @prefix@ ADDITIONAL_OBJS = @ADDITIONAL_OBJS@ enable_decimal_float= @enable_decimal_float@ INCLUDES = -I$(srcdir) -I. ALL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(INCLUDES) $(CPPFLAGS) $(PICFLAG) -fPIC libdecnumber_a_OBJS = decNumber.$(objext) decContext.$(objext) \ decimal32.$(objext) decimal64.$(objext) decimal128.$(objext) \ $(ADDITIONAL_OBJS) libdecnumber_a_SOURCES = decContext.c decContext.h decDPD.h \ decNumber.c decNumber.h decNumberLocal.h \ decimal32.h decimal64.h decimal128.h \ dpd/decimal32.c dpd/decimal64.c dpd/decimal128.c \ bid/decimal32.c bid/decimal64.c bid/decimal128.c \ decDebug64.h all: libdecnumber.a .SUFFIXES: .SUFFIXES: .c .o .obj libdecnumber.a: $(libdecnumber_a_OBJS) -rm -f $@ $(AR) $(ARFLAGS) $@ $(libdecnumber_a_OBJS) $(RANLIB) $@ # Rules to rebuild the configuration Makefile: $(srcdir)/Makefile.in config.status $(SHELL) ./config.status Makefile config.status: $(srcdir)/configure $(SHELL) ./config.status --recheck $(srcdir)/configure: @MAINT@ $(srcdir)/aclocal.m4 cd $(srcdir) && $(AUTOCONF) aclocal_deps = \ $(srcdir)/../config/stdint.m4 \ $(srcdir)/../config/warnings.m4 \ $(srcdir)/../config/override.m4 \ $(srcdir)/../config/dfp.m4 \ $(srcdir)/configure.ac $(srcdir)/aclocal.m4: @MAINT@ $(aclocal_deps) cd $(srcdir) && $(ACLOCAL) -I ../config config.h: stamp-h1 test -f config.h || (rm -f stamp-h1 && $(MAKE) stamp-h1) stamp-h1: $(srcdir)/config.in config.status -rm -f stamp-h1 $(SHELL) ./config.status config.h $(srcdir)/config.in: @MAINT@ $(srcdir)/configure cd $(srcdir) && $(AUTOHEADER) -rm -f stamp-h1 # Dependencies. decContext.$(objext): decContext.c decContext.h decNumberLocal.h decNumber.$(objext): decNumber.c decNumber.h decContext.h decNumberLocal.h decimal32.$(objext): $(srcdir)/$(enable_decimal_float)/decimal32.c \ $(srcdir)/decimal32.h \ decNumber.h decContext.h decNumberLocal.h $(COMPILE) $(srcdir)/$(enable_decimal_float)/decimal32.c decimal64.$(objext): $(srcdir)/$(enable_decimal_float)/decimal64.c \ $(srcdir)/decimal64.h \ decNumber.h decContext.h decNumberLocal.h $(COMPILE) $(srcdir)/$(enable_decimal_float)/decimal64.c decimal128.$(objext): $(srcdir)/$(enable_decimal_float)/decimal128.c \ $(srcdir)/decimal128.h \ $(srcdir)/decimal128Local.h\ decNumber.h decContext.h decNumberLocal.h $(COMPILE) $(srcdir)/$(enable_decimal_float)/decimal128.c # Other miscellaneous targets. mostlyclean: -rm -f *.$(objext) clean: mostlyclean -rm -rf libdecnumber.a $(srcdir)/autom4te.cache distclean: clean -rm -f config.h stamp-h1 config.status config.cache config.log \ configure.lineno configure.status.lineno Makefile localedir.h \ localedir.hs gstdint.h maintainer-clean: distclean @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -rm -f $(srcdir)/configure $(srcdir)/aclocal.m4 check: installcheck: dvi: pdf: html: info: install-info: install-pdf: install-man: install-html: install: .PHONY: installdirs install install-strip mostlyclean clean distclean \ maintainer-clean check installcheck dvi pdf html info install-info \ install-pdf install-man update-po install-html COMPILE = source='$<' object='$@' libtool=no $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(ALL_CFLAGS) -c # Implicit rules .c.$(objext): $(COMPILE) $< # 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: libdfp-1.0.12/libdecnumber/aclocal.m4000066400000000000000000000013771261375163000173420ustar00rootroot00000000000000# generated automatically by aclocal 1.14.1 -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # This file 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. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_include([../config/dfp.m4]) m4_include([../config/stdint.m4]) m4_include([../config/warnings.m4]) libdfp-1.0.12/libdecnumber/bid/000077500000000000000000000000001261375163000162305ustar00rootroot00000000000000libdfp-1.0.12/libdecnumber/bid/bid-coeffbits.h000066400000000000000000000062471261375163000211120ustar00rootroot00000000000000/* Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef BID_COEFFBITS_H # define BID_COEFFBITS_H /* ------------------------------------------------------------------- */ /* Return required number of bits to represent a binary uInt (32-bits) */ /* value using a fast log2 implementation using Bruijn sequences. */ /* ------------------------------------------------------------------- */ static inline Int bid_required_bits_32 (uInt value) { #if __GNUC__ >=3 && __GNUC_MINOR__ >= 2 return value == 0 ? 0 : (32 - __builtin_clz (value)); #else /* Lookup table to count leading zeros. More info on how to construct it: http://supertech.csail.mit.edu/papers/debruijn.pdf */ static const Int tab32[] = { 31, 22, 30, 21, 18, 10, 29, 2, 20, 17, 15, 13, 9, 6, 28, 1, 23, 19, 11, 3, 16, 14, 7, 24, 12, 4, 8, 25, 5, 26, 27, 0 }; uInt hash; value |= value >> 1; value |= value >> 2; value |= value >> 4; value |= value >> 8; value |= value >> 16; hash = ((value * 0x07c4acddU) & 0xffffffffU) >> 27; return 32 - tab32[hash]; #endif } /* -------------------------------------------------------------------- */ /* Return required number of bits to represent a binary uLong (64-bits) */ /* value using a fast log2 implementation using Bruijn sequences. */ /* -------------------------------------------------------------------- */ static inline Int bid_required_bits_64 (uLong value) { #if __GNUC__ >=3 && __GNUC_MINOR__ >= 2 return (value == 0UL ? 0 : 64 - __builtin_clzll (value)); #else Int ret; uInt hi = (value >> 32); if ((ret = bid_required_bits_32 (hi)) == 0) { uLong lo = (value & 0xFFFFFFFFU); return bid_required_bits_32 (lo); } return ret + 32; #endif } # ifdef DECUSE128 /* ------------------------------------------------------------------ */ /* Return required bits to represent a binary uQuad (128-bits) value. */ /* ------------------------------------------------------------------ */ static inline Int bid_required_bits_128 (uQuad value) { /* Use 64-bits operations to keep it simple, another solution would * be to construct a lookup table for int128. */ Int ret; uLong hi = uQuadHi64 (value); if ((ret = bid_required_bits_64 (hi)) == 0) { uLong lo = uQuadLo64 (value); return bid_required_bits_64 (lo); } return ret + 64; } # endif #endif libdfp-1.0.12/libdecnumber/bid/bid-dpd.h000066400000000000000000000026751261375163000177160ustar00rootroot00000000000000/* Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ typedef unsigned int UINT32; typedef unsigned long long UINT64; typedef struct { UINT64 w[2]; } UINT128; #ifndef IN_LIBGCC2 #define _Decimal32 UINT32 #define _Decimal64 UINT64 #define _Decimal128 UINT128 #endif void _bid_to_dpd32 (_Decimal32 *, _Decimal32 *); void _dpd_to_bid32 (_Decimal32 *, _Decimal32 *); void _bid_to_dpd64 (_Decimal64 *, _Decimal64 *); void _dpd_to_bid64 (_Decimal64 *, _Decimal64 *); void _bid_to_dpd128 (_Decimal128 *, _Decimal128 *); void _dpd_to_bid128 (_Decimal128 *, _Decimal128 *); libdfp-1.0.12/libdecnumber/bid/bid2dpd_dpd2bid.c000066400000000000000000000342331261375163000213010ustar00rootroot00000000000000/* Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ #undef IN_LIBGCC2 #include "bid-dpd.h" /* get full 64x64bit product */ #define __mul_64x64_to_128(P, CX, CY) \ { \ UINT64 CXH, CXL, CYH,CYL,PL,PH,PM,PM2; \ CXH = (CX) >> 32; \ CXL = (UINT32)(CX); \ CYH = (CY) >> 32; \ CYL = (UINT32)(CY); \ \ PM = CXH*CYL; \ PH = CXH*CYH; \ PL = CXL*CYL; \ PM2 = CXL*CYH; \ PH += (PM>>32); \ PM = (UINT64)((UINT32)PM)+PM2+(PL>>32); \ \ (P).w[1] = PH + (PM>>32); \ (P).w[0] = (PM<<32)+(UINT32)PL; \ } /* add 64-bit value to 128-bit */ #define __add_128_64(R128, A128, B64) \ { \ UINT64 R64H; \ R64H = (A128).w[1]; \ (R128).w[0] = (B64) + (A128).w[0]; \ if((R128).w[0] < (B64)) R64H ++; \ (R128).w[1] = R64H; \ } /* add 128-bit value to 128-bit (assume no carry-out) */ #define __add_128_128(R128, A128, B128) \ { \ UINT128 Q128; \ Q128.w[1] = (A128).w[1]+(B128).w[1]; \ Q128.w[0] = (B128).w[0] + (A128).w[0]; \ if(Q128.w[0] < (B128).w[0]) Q128.w[1] ++; \ (R128).w[1] = Q128.w[1]; \ (R128).w[0] = Q128.w[0]; \ } #define __mul_128x128_high(Q, A, B) \ { \ UINT128 ALBL, ALBH, AHBL, AHBH, QM, QM2; \ \ __mul_64x64_to_128(ALBH, (A).w[0], (B).w[1]); \ __mul_64x64_to_128(AHBL, (B).w[0], (A).w[1]); \ __mul_64x64_to_128(ALBL, (A).w[0], (B).w[0]); \ __mul_64x64_to_128(AHBH, (A).w[1],(B).w[1]); \ \ __add_128_128(QM, ALBH, AHBL); \ __add_128_64(QM2, QM, ALBL.w[1]); \ __add_128_64((Q), AHBH, QM2.w[1]); \ } #include "bid2dpd_dpd2bid.h" static const unsigned int dm103[] = { 0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000 }; void _bid_to_dpd32 (_Decimal32 *, _Decimal32 *); void _bid_to_dpd32 (_Decimal32 *pres, _Decimal32 *px) { unsigned int sign, coefficient_x, exp, dcoeff; unsigned int b2, b1, b0, b01, res; _Decimal32 x = *px; sign = (x & 0x80000000); if ((x & 0x60000000ul) == 0x60000000ul) { /* special encodings */ if ((x & 0x78000000ul) == 0x78000000ul) { *pres = x; /* NaN or Infinity */ return; } /* coefficient */ coefficient_x = (x & 0x001ffffful) | 0x00800000ul; if (coefficient_x >= 10000000) coefficient_x = 0; /* get exponent */ exp = (x >> 21) & 0xff; } else { exp = (x >> 23) & 0xff; coefficient_x = (x & 0x007ffffful); } b01 = coefficient_x / 1000; b2 = coefficient_x - 1000 * b01; b0 = b01 / 1000; b1 = b01 - 1000 * b0; dcoeff = b2d[b2] | b2d2[b1]; if (b0 >= 8) { /* is b0 8 or 9? */ res = sign | ((0x600 | ((exp >> 6) << 7) | ((b0 & 1) << 6) | (exp & 0x3f)) << 20) | dcoeff; } else { /* else b0 is 0..7 */ res = sign | ((((exp >> 6) << 9) | (b0 << 6) | (exp & 0x3f)) << 20) | dcoeff; } *pres = res; } void _dpd_to_bid32 (_Decimal32 *, _Decimal32 *); void _dpd_to_bid32 (_Decimal32 *pres, _Decimal32 *px) { unsigned int r; unsigned int sign, exp, bcoeff; UINT64 trailing; unsigned int d0, d1, d2; _Decimal32 x = *px; sign = (x & 0x80000000); trailing = (x & 0x000fffff); if ((x & 0x78000000) == 0x78000000) { *pres = x; return; } else { /* normal number */ if ((x & 0x60000000) == 0x60000000) { /* G0..G1 = 11 -> d0 = 8 + G4 */ d0 = d2b3[((x >> 26) & 1) | 8]; /* d0 = (comb & 0x0100 ? 9 : 8); */ exp = (x >> 27) & 3; /* exp leading bits are G2..G3 */ } else { d0 = d2b3[(x >> 26) & 0x7]; exp = (x >> 29) & 3; /* exp loading bits are G0..G1 */ } d1 = d2b2[(trailing >> 10) & 0x3ff]; d2 = d2b[(trailing) & 0x3ff]; bcoeff = d2 + d1 + d0; exp = (exp << 6) + ((x >> 20) & 0x3f); if (bcoeff < (1 << 23)) { r = exp; r <<= 23; r |= (bcoeff | sign); } else { r = exp; r <<= 21; r |= (sign | 0x60000000ul); /* add coeff, without leading bits */ r |= (((unsigned int) bcoeff) & 0x1fffff); } } *pres = r; } void _bid_to_dpd64 (_Decimal64 *, _Decimal64 *); void _bid_to_dpd64 (_Decimal64 *pres, _Decimal64 *px) { UINT64 res; UINT64 sign, comb, exp, B34, B01; UINT64 d103, D61; UINT64 b0, b2, b3, b5; unsigned int b1, b4; UINT64 bcoeff; UINT64 dcoeff; unsigned int yhi, ylo; _Decimal64 x = *px; sign = (x & 0x8000000000000000ull); comb = (x & 0x7ffc000000000000ull) >> 51; if ((comb & 0xf00) == 0xf00) { *pres = x; return; } else { /* Normal number */ if ((comb & 0xc00) == 0xc00) { /* G0..G1 = 11 -> exp is G2..G11 */ exp = (comb) & 0x3ff; bcoeff = (x & 0x0007ffffffffffffull) | 0x0020000000000000ull; } else { exp = (comb >> 2) & 0x3ff; bcoeff = (x & 0x001fffffffffffffull); } D61 = 2305843009ull; /* Floor(2^61 / 10^9) */ /* Multiply the binary coefficient by ceil(2^64 / 1000), and take the upper 64-bits in order to compute a division by 1000. */ yhi = (D61 * (UINT64)(bcoeff >> (UINT64)27)) >> (UINT64)34; ylo = bcoeff - 1000000000ull * yhi; if (ylo >= 1000000000) { ylo = ylo - 1000000000; yhi = yhi + 1; } d103 = 0x4189374c; B34 = ((UINT64) ylo * d103) >> (32 + 8); B01 = ((UINT64) yhi * d103) >> (32 + 8); b5 = ylo - B34 * 1000; b2 = yhi - B01 * 1000; b3 = ((UINT64) B34 * d103) >> (32 + 8); b0 = ((UINT64) B01 * d103) >> (32 + 8); b4 = (unsigned int) B34 - (unsigned int) b3 *1000; b1 = (unsigned int) B01 - (unsigned int) dm103[b0]; dcoeff = b2d[b5] | b2d2[b4] | b2d3[b3] | b2d4[b2] | b2d5[b1]; if (b0 >= 8) /* is b0 8 or 9? */ res = sign | ((0x1800 | ((exp >> 8) << 9) | ((b0 & 1) << 8) | (exp & 0xff)) << 50) | dcoeff; else /* else b0 is 0..7 */ res = sign | ((((exp >> 8) << 11) | (b0 << 8) | (exp & 0xff)) << 50) | dcoeff; } *pres = res; } void _dpd_to_bid64 (_Decimal64 *, _Decimal64 *); void _dpd_to_bid64 (_Decimal64 *pres, _Decimal64 *px) { UINT64 res; UINT64 sign, comb, exp; UINT64 trailing; UINT64 d0, d1, d2; unsigned int d3, d4, d5; UINT64 bcoeff, mask; _Decimal64 x = *px; sign = (x & 0x8000000000000000ull); comb = (x & 0x7ffc000000000000ull) >> 50; trailing = (x & 0x0003ffffffffffffull); if ((comb & 0x1e00) == 0x1e00) { if ((comb & 0x1f00) == 0x1f00) { /* G0..G4 = 11111 -> NaN */ if (comb & 0x0100) { /* G5 = 1 -> sNaN */ *pres = x; } else { /* G5 = 0 -> qNaN */ *pres = x; } } else { /*if ((comb & 0x1e00) == 0x1e00); G0..G4 = 11110 -> INF */ *pres = x; } return; } else { /* normal number */ if ((comb & 0x1800) == 0x1800) { /* G0..G1 = 11 -> d0 = 8 + G4 */ d0 = d2b6[((comb >> 8) & 1) | 8]; /* d0 = (comb & 0x0100 ? 9 : 8); */ exp = (comb & 0x600) >> 1; /* exp = (comb & 0x0400 ? 1 : 0) * 0x200 + (comb & 0x0200 ? 1 : 0) * 0x100; exp leading bits are G2..G3 */ } else { d0 = d2b6[(comb >> 8) & 0x7]; exp = (comb & 0x1800) >> 3; /* exp = (comb & 0x1000 ? 1 : 0) * 0x200 + (comb & 0x0800 ? 1 : 0) * 0x100; exp loading bits are G0..G1 */ } d1 = d2b5[(trailing >> 40) & 0x3ff]; d2 = d2b4[(trailing >> 30) & 0x3ff]; d3 = d2b3[(trailing >> 20) & 0x3ff]; d4 = d2b2[(trailing >> 10) & 0x3ff]; d5 = d2b[(trailing) & 0x3ff]; bcoeff = (d5 + d4 + d3) + d2 + d1 + d0; exp += (comb & 0xff); mask = 1; mask <<= 53; if (bcoeff < mask) { /* check whether coefficient fits in 10*5+3 bits */ res = exp; res <<= 53; res |= (bcoeff | sign); *pres = res; return; } /* special format */ res = (exp << 51) | (sign | 0x6000000000000000ull); /* add coeff, without leading bits */ mask = (mask >> 2) - 1; bcoeff &= mask; res |= bcoeff; } *pres = res; } void _bid_to_dpd128 (_Decimal128 *, _Decimal128 *); void _bid_to_dpd128 (_Decimal128 *pres, _Decimal128 *px) { UINT128 res; UINT128 sign; unsigned int comb; UINT128 bcoeff; UINT128 dcoeff; UINT128 BH, d1018, BT2, BT1; UINT64 exp, BL, d109; UINT64 d106, d103; UINT64 k1, k2, k4, k5, k7, k8, k10, k11; unsigned int BHH32, BLL32, BHL32, BLH32, k0, k3, k6, k9, amount; _Decimal128 x = *px; sign.w[1] = (x.w[1] & 0x8000000000000000ull); sign.w[0] = 0; comb = (x.w[1] /*& 0x7fffc00000000000ull */ ) >> 46; exp = 0; if ((comb & 0x1e000) == 0x1e000) { if ((comb & 0x1f000) == 0x1f000) { /* G0..G4 = 11111 -> NaN */ if (comb & 0x01000) { /* G5 = 1 -> sNaN */ res = x; } else { /* G5 = 0 -> qNaN */ res = x; } } else { /* G0..G4 = 11110 -> INF */ res = x; } } else { /* normal number */ exp = ((x.w[1] & 0x7fff000000000000ull) >> 49) & 0x3fff; bcoeff.w[1] = (x.w[1] & 0x0001ffffffffffffull); bcoeff.w[0] = x.w[0]; d1018 = reciprocals10_128[18]; __mul_128x128_high (BH, bcoeff, d1018); amount = recip_scale[18]; BH.w[0] = (BH.w[0] >> amount) | (BH.w[1] << (64 - amount)); BL = bcoeff.w[0] - BH.w[0] * 1000000000000000000ull; d109 = reciprocals10_64[9]; __mul_64x64_to_128 (BT1, BH.w[0], d109); BHH32 = (unsigned int) (BT1.w[1] >> short_recip_scale[9]); BHL32 = (unsigned int) BH.w[0] - BHH32 * 1000000000; __mul_64x64_to_128 (BT2, BL, d109); BLH32 = (unsigned int) (BT2.w[1] >> short_recip_scale[9]); BLL32 = (unsigned int) BL - BLH32 * 1000000000; d106 = 0x431BDE83; d103 = 0x4189374c; k0 = ((UINT64) BHH32 * d106) >> (32 + 18); BHH32 -= (unsigned int) k0 *1000000; k1 = ((UINT64) BHH32 * d103) >> (32 + 8); k2 = BHH32 - (unsigned int) k1 *1000; k3 = ((UINT64) BHL32 * d106) >> (32 + 18); BHL32 -= (unsigned int) k3 *1000000; k4 = ((UINT64) BHL32 * d103) >> (32 + 8); k5 = BHL32 - (unsigned int) k4 *1000; k6 = ((UINT64) BLH32 * d106) >> (32 + 18); BLH32 -= (unsigned int) k6 *1000000; k7 = ((UINT64) BLH32 * d103) >> (32 + 8); k8 = BLH32 - (unsigned int) k7 *1000; k9 = ((UINT64) BLL32 * d106) >> (32 + 18); BLL32 -= (unsigned int) k9 *1000000; k10 = ((UINT64) BLL32 * d103) >> (32 + 8); k11 = BLL32 - (unsigned int) k10 *1000; dcoeff.w[1] = (b2d[k5] >> 4) | (b2d[k4] << 6) | (b2d[k3] << 16) | (b2d[k2] << 26) | (b2d[k1] << 36); dcoeff.w[0] = b2d[k11] | (b2d[k10] << 10) | (b2d[k9] << 20) | (b2d[k8] << 30) | (b2d[k7] << 40) | (b2d[k6] << 50) | (b2d[k5] << 60); res.w[0] = dcoeff.w[0]; if (k0 >= 8) { res.w[1] = sign.w[1] | ((0x18000 | ((exp >> 12) << 13) | ((k0 & 1) << 12) | (exp & 0xfff)) << 46) | dcoeff.w[1]; } else { res.w[1] = sign.w[1] | ((((exp >> 12) << 15) | (k0 << 12) | (exp & 0xfff)) << 46) | dcoeff.w[1]; } } *pres = res; } void _dpd_to_bid128 (_Decimal128 *, _Decimal128 *); void _dpd_to_bid128 (_Decimal128 *pres, _Decimal128 *px) { UINT128 res; UINT128 sign; UINT64 exp, comb; UINT128 trailing; UINT64 d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11; UINT128 bcoeff; UINT64 tl, th; _Decimal128 x = *px; sign.w[1] = (x.w[1] & 0x8000000000000000ull); sign.w[0] = 0; comb = (x.w[1] & 0x7fffc00000000000ull) >> 46; trailing.w[1] = x.w[1]; trailing.w[0] = x.w[0]; if ((comb & 0x1e000) == 0x1e000) { if ((comb & 0x1f000) == 0x1f000) { /* G0..G4 = 11111 -> NaN */ if (comb & 0x01000) { /* G5 = 1 -> sNaN */ *pres = x; } else { /* G5 = 0 -> qNaN */ *pres = x; } } else { /* G0..G4 = 11110 -> INF */ *pres = x; } return; } else { /* Normal number */ if ((comb & 0x18000) == 0x18000) { /* G0..G1 = 11 -> d0 = 8 + G4 */ d0 = d2b6[8 + ((comb & 0x01000) >> 12)]; exp = (comb & 0x06000) >> 1; /* exp leading bits are G2..G3 */ } else { d0 = d2b6[((comb & 0x07000) >> 12)]; exp = (comb & 0x18000) >> 3; /* exp loading bits are G0..G1 */ } d11 = d2b[(trailing.w[0]) & 0x3ff]; d10 = d2b2[(trailing.w[0] >> 10) & 0x3ff]; d9 = d2b3[(trailing.w[0] >> 20) & 0x3ff]; d8 = d2b4[(trailing.w[0] >> 30) & 0x3ff]; d7 = d2b5[(trailing.w[0] >> 40) & 0x3ff]; d6 = d2b6[(trailing.w[0] >> 50) & 0x3ff]; d5 = d2b[(trailing.w[0] >> 60) | ((trailing.w[1] & 0x3f) << 4)]; d4 = d2b2[(trailing.w[1] >> 6) & 0x3ff]; d3 = d2b3[(trailing.w[1] >> 16) & 0x3ff]; d2 = d2b4[(trailing.w[1] >> 26) & 0x3ff]; d1 = d2b5[(trailing.w[1] >> 36) & 0x3ff]; tl = d11 + d10 + d9 + d8 + d7 + d6; th = d5 + d4 + d3 + d2 + d1 + d0; __mul_64x64_to_128 (bcoeff, th, 1000000000000000000ull); __add_128_64 (bcoeff, bcoeff, tl); exp += (comb & 0xfff); res.w[0] = bcoeff.w[0]; res.w[1] = (exp << 49) | sign.w[1] | bcoeff.w[1]; } *pres = res; } libdfp-1.0.12/libdecnumber/bid/bid2dpd_dpd2bid.h000066400000000000000000006342751261375163000213220ustar00rootroot00000000000000/* Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ static const UINT128 reciprocals10_128[] = { { { 0ull, 0ull } }, /* 0 extra digits */ { { 0x3333333333333334ull ,0x3333333333333333ull } }, /* 1 extra digit */ { { 0x51eb851eb851eb86ull ,0x051eb851eb851eb8ull } }, /* 2 extra digits */ { { 0x3b645a1cac083127ull, 0x0083126e978d4fdfull } }, /* 3 extra digits */ { { 0x4af4f0d844d013aaULL, 0x00346dc5d6388659ULL } }, /* 10^(-4) * 2^131 */ { { 0x08c3f3e0370cdc88ULL, 0x0029f16b11c6d1e1ULL } }, /* 10^(-5) * 2^134 */ { { 0x6d698fe69270b06dULL, 0x00218def416bdb1aULL } }, /* 10^(-6) * 2^137 */ { { 0xaf0f4ca41d811a47ULL, 0x0035afe535795e90ULL } }, /* 10^(-7) * 2^141 */ { { 0xbf3f70834acdaea0ULL, 0x002af31dc4611873ULL } }, /* 10^(-8) * 2^144 */ { { 0x65cc5a02a23e254dULL, 0x00225c17d04dad29ULL } }, /* 10^(-9) * 2^147 */ { { 0x6fad5cd10396a214ULL, 0x0036f9bfb3af7b75ULL } }, /* 10^(-10) * 2^151 */ { { 0xbfbde3da69454e76ULL, 0x002bfaffc2f2c92aULL } }, /* 10^(-11) * 2^154 */ { { 0x32fe4fe1edd10b92ULL, 0x00232f33025bd422ULL } }, /* 10^(-12) * 2^157 */ { { 0x84ca19697c81ac1cULL, 0x00384b84d092ed03ULL } }, /* 10^(-13) * 2^161 */ { { 0x03d4e1213067bce4ULL, 0x002d09370d425736ULL } }, /* 10^(-14) * 2^164 */ { { 0x3643e74dc052fd83ULL, 0x0024075f3dceac2bULL } }, /* 10^(-15) * 2^167 */ { { 0x56d30baf9a1e626bULL, 0x0039a5652fb11378ULL } }, /* 10^(-16) * 2^171 */ { { 0x12426fbfae7eb522ULL, 0x002e1dea8c8da92dULL } }, /* 10^(-17) * 2^174 */ { { 0x41cebfcc8b9890e8ULL, 0x0024e4bba3a48757ULL } }, /* 10^(-18) * 2^177 */ { { 0x694acc7a78f41b0dULL, 0x003b07929f6da558ULL } }, /* 10^(-19) * 2^181 */ { { 0xbaa23d2ec729af3eULL, 0x002f394219248446ULL } }, /* 10^(-20) * 2^184 */ { { 0xfbb4fdbf05baf298ULL, 0x0025c768141d369eULL } }, /* 10^(-21) * 2^187 */ { { 0x2c54c931a2c4b759ULL, 0x003c7240202ebdcbULL } }, /* 10^(-22) * 2^191 */ { { 0x89dd6dc14f03c5e1ULL, 0x00305b66802564a2ULL } }, /* 10^(-23) * 2^194 */ { { 0xd4b1249aa59c9e4eULL, 0x0026af8533511d4eULL } }, /* 10^(-24) * 2^197 */ { { 0x544ea0f76f60fd49ULL, 0x003de5a1ebb4fbb1ULL } }, /* 10^(-25) * 2^201 */ { { 0x76a54d92bf80caa1ULL, 0x00318481895d9627ULL } }, /* 10^(-26) * 2^204 */ { { 0x921dd7a89933d54eULL, 0x00279d346de4781fULL } }, /* 10^(-27) * 2^207 */ { { 0x8362f2a75b862215ULL, 0x003f61ed7ca0c032ULL } }, /* 10^(-28) * 2^211 */ { { 0xcf825bb91604e811ULL, 0x0032b4bdfd4d668eULL } }, /* 10^(-29) * 2^214 */ { { 0x0c684960de6a5341ULL, 0x00289097fdd7853fULL } }, /* 10^(-30) * 2^217 */ { { 0x3d203ab3e521dc34ULL, 0x002073accb12d0ffULL } }, /* 10^(-31) * 2^220 */ { { 0x2e99f7863b696053ULL, 0x0033ec47ab514e65ULL } }, /* 10^(-32) * 2^224 */ { { 0x587b2c6b62bab376ULL, 0x002989d2ef743eb7ULL } }, /* 10^(-33) * 2^227 */ { { 0xad2f56bc4efbc2c5ULL, 0x00213b0f25f69892ULL } }, /* 10^(-34) * 2^230 */ { { 0x0f2abc9d8c9689d1ull, 0x01a95a5b7f87a0efull } } /* 35 extra digits */ }; static const int recip_scale[] = { 129 - 128, /* 1 */ 129 - 128, /* 1/10 */ 129 - 128, /* 1/10^2 */ 129 - 128, /* 1/10^3 */ 3, /* 131 - 128 */ 6, /* 134 - 128 */ 9, /* 137 - 128 */ 13, /* 141 - 128 */ 16, /* 144 - 128 */ 19, /* 147 - 128 */ 23, /* 151 - 128 */ 26, /* 154 - 128 */ 29, /* 157 - 128 */ 33, /* 161 - 128 */ 36, /* 164 - 128 */ 39, /* 167 - 128 */ 43, /* 171 - 128 */ 46, /* 174 - 128 */ 49, /* 177 - 128 */ 53, /* 181 - 128 */ 56, /* 184 - 128 */ 59, /* 187 - 128 */ 63, /* 191 - 128 */ 66, /* 194 - 128 */ 69, /* 197 - 128 */ 73, /* 201 - 128 */ 76, /* 204 - 128 */ 79, /* 207 - 128 */ 83, /* 211 - 128 */ 86, /* 214 - 128 */ 89, /* 217 - 128 */ 92, /* 220 - 128 */ 96, /* 224 - 128 */ 99, /* 227 - 128 */ 102, /* 230 - 128 */ 237 - 128, /* 1/10^35 */ }; static const int short_recip_scale[] = { 1, 65 - 64, 69 - 64, 71 - 64, 75 - 64, 78 - 64, 81 - 64, 85 - 64, 88 - 64, 91 - 64, 95 - 64, 98 - 64, 101 - 64, 105 - 64, 108 - 64, 111 - 64, 115 - 64, /* 114 - 64 */ 118 - 64 }; static const unsigned long long reciprocals10_64[] = { 1ull, /* dummy value for 0 extra digits */ 0x3333333333333334ull, /* 1 extra digit */ 0x51eb851eb851eb86ull, 0x20c49ba5e353f7cfull, 0x346dc5d63886594bull, 0x29f16b11c6d1e109ull, 0x218def416bdb1a6eull, 0x35afe535795e90b0ull, 0x2af31dc4611873c0ull, 0x225c17d04dad2966ull, 0x36f9bfb3af7b7570ull, 0x2bfaffc2f2c92ac0ull, 0x232f33025bd42233ull, 0x384b84d092ed0385ull, 0x2d09370d42573604ull, 0x24075f3dceac2b37ull, 0x39a5652fb1137857ull, 0x2e1dea8c8da92d13ull }; static const UINT64 d2b[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 80, 81, 800, 801, 880, 881, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 90, 91, 810, 811, 890, 891, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 82, 83, 820, 821, 808, 809, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 92, 93, 830, 831, 818, 819, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 84, 85, 840, 841, 88, 89, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 94, 95, 850, 851, 98, 99, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 86, 87, 860, 861, 888, 889, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 96, 97, 870, 871, 898, 899, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 180, 181, 900, 901, 980, 981, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 190, 191, 910, 911, 990, 991, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 182, 183, 920, 921, 908, 909, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 192, 193, 930, 931, 918, 919, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 184, 185, 940, 941, 188, 189, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 194, 195, 950, 951, 198, 199, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 186, 187, 960, 961, 988, 989, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 196, 197, 970, 971, 998, 999, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 280, 281, 802, 803, 882, 883, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 290, 291, 812, 813, 892, 893, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 282, 283, 822, 823, 828, 829, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 292, 293, 832, 833, 838, 839, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 284, 285, 842, 843, 288, 289, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 294, 295, 852, 853, 298, 299, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 286, 287, 862, 863, 888, 889, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 296, 297, 872, 873, 898, 899, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 380, 381, 902, 903, 982, 983, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 390, 391, 912, 913, 992, 993, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 382, 383, 922, 923, 928, 929, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 392, 393, 932, 933, 938, 939, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 384, 385, 942, 943, 388, 389, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 394, 395, 952, 953, 398, 399, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 386, 387, 962, 963, 988, 989, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 396, 397, 972, 973, 998, 999, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 480, 481, 804, 805, 884, 885, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 490, 491, 814, 815, 894, 895, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 482, 483, 824, 825, 848, 849, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 492, 493, 834, 835, 858, 859, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 484, 485, 844, 845, 488, 489, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 494, 495, 854, 855, 498, 499, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 486, 487, 864, 865, 888, 889, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 496, 497, 874, 875, 898, 899, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 580, 581, 904, 905, 984, 985, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 590, 591, 914, 915, 994, 995, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 582, 583, 924, 925, 948, 949, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 592, 593, 934, 935, 958, 959, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 584, 585, 944, 945, 588, 589, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 594, 595, 954, 955, 598, 599, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 586, 587, 964, 965, 988, 989, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 596, 597, 974, 975, 998, 999, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 680, 681, 806, 807, 886, 887, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 690, 691, 816, 817, 896, 897, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 682, 683, 826, 827, 868, 869, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 692, 693, 836, 837, 878, 879, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 684, 685, 846, 847, 688, 689, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 694, 695, 856, 857, 698, 699, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 686, 687, 866, 867, 888, 889, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 696, 697, 876, 877, 898, 899, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 780, 781, 906, 907, 986, 987, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 790, 791, 916, 917, 996, 997, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 782, 783, 926, 927, 968, 969, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 792, 793, 936, 937, 978, 979, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 784, 785, 946, 947, 788, 789, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 794, 795, 956, 957, 798, 799, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 786, 787, 966, 967, 988, 989, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 796, 797, 976, 977, 998, 999 }; static const UINT64 d2b2[] = { 0000ull, 1000ull, 2000ull, 3000ull, 4000ull, 5000ull, 6000ull, 7000ull, 8000ull, 9000ull, 80000ull, 81000ull, 800000ull, 801000ull, 880000ull, 881000ull, 10000ull, 11000ull, 12000ull, 13000ull, 14000ull, 15000ull, 16000ull, 17000ull, 18000ull, 19000ull, 90000ull, 91000ull, 810000ull, 811000ull, 890000ull, 891000ull, 20000ull, 21000ull, 22000ull, 23000ull, 24000ull, 25000ull, 26000ull, 27000ull, 28000ull, 29000ull, 82000ull, 83000ull, 820000ull, 821000ull, 808000ull, 809000ull, 30000ull, 31000ull, 32000ull, 33000ull, 34000ull, 35000ull, 36000ull, 37000ull, 38000ull, 39000ull, 92000ull, 93000ull, 830000ull, 831000ull, 818000ull, 819000ull, 40000ull, 41000ull, 42000ull, 43000ull, 44000ull, 45000ull, 46000ull, 47000ull, 48000ull, 49000ull, 84000ull, 85000ull, 840000ull, 841000ull, 88000ull, 89000ull, 50000ull, 51000ull, 52000ull, 53000ull, 54000ull, 55000ull, 56000ull, 57000ull, 58000ull, 59000ull, 94000ull, 95000ull, 850000ull, 851000ull, 98000ull, 99000ull, 60000ull, 61000ull, 62000ull, 63000ull, 64000ull, 65000ull, 66000ull, 67000ull, 68000ull, 69000ull, 86000ull, 87000ull, 860000ull, 861000ull, 888000ull, 889000ull, 70000ull, 71000ull, 72000ull, 73000ull, 74000ull, 75000ull, 76000ull, 77000ull, 78000ull, 79000ull, 96000ull, 97000ull, 870000ull, 871000ull, 898000ull, 899000ull, 100000ull, 101000ull, 102000ull, 103000ull, 104000ull, 105000ull, 106000ull, 107000ull, 108000ull, 109000ull, 180000ull, 181000ull, 900000ull, 901000ull, 980000ull, 981000ull, 110000ull, 111000ull, 112000ull, 113000ull, 114000ull, 115000ull, 116000ull, 117000ull, 118000ull, 119000ull, 190000ull, 191000ull, 910000ull, 911000ull, 990000ull, 991000ull, 120000ull, 121000ull, 122000ull, 123000ull, 124000ull, 125000ull, 126000ull, 127000ull, 128000ull, 129000ull, 182000ull, 183000ull, 920000ull, 921000ull, 908000ull, 909000ull, 130000ull, 131000ull, 132000ull, 133000ull, 134000ull, 135000ull, 136000ull, 137000ull, 138000ull, 139000ull, 192000ull, 193000ull, 930000ull, 931000ull, 918000ull, 919000ull, 140000ull, 141000ull, 142000ull, 143000ull, 144000ull, 145000ull, 146000ull, 147000ull, 148000ull, 149000ull, 184000ull, 185000ull, 940000ull, 941000ull, 188000ull, 189000ull, 150000ull, 151000ull, 152000ull, 153000ull, 154000ull, 155000ull, 156000ull, 157000ull, 158000ull, 159000ull, 194000ull, 195000ull, 950000ull, 951000ull, 198000ull, 199000ull, 160000ull, 161000ull, 162000ull, 163000ull, 164000ull, 165000ull, 166000ull, 167000ull, 168000ull, 169000ull, 186000ull, 187000ull, 960000ull, 961000ull, 988000ull, 989000ull, 170000ull, 171000ull, 172000ull, 173000ull, 174000ull, 175000ull, 176000ull, 177000ull, 178000ull, 179000ull, 196000ull, 197000ull, 970000ull, 971000ull, 998000ull, 999000ull, 200000ull, 201000ull, 202000ull, 203000ull, 204000ull, 205000ull, 206000ull, 207000ull, 208000ull, 209000ull, 280000ull, 281000ull, 802000ull, 803000ull, 882000ull, 883000ull, 210000ull, 211000ull, 212000ull, 213000ull, 214000ull, 215000ull, 216000ull, 217000ull, 218000ull, 219000ull, 290000ull, 291000ull, 812000ull, 813000ull, 892000ull, 893000ull, 220000ull, 221000ull, 222000ull, 223000ull, 224000ull, 225000ull, 226000ull, 227000ull, 228000ull, 229000ull, 282000ull, 283000ull, 822000ull, 823000ull, 828000ull, 829000ull, 230000ull, 231000ull, 232000ull, 233000ull, 234000ull, 235000ull, 236000ull, 237000ull, 238000ull, 239000ull, 292000ull, 293000ull, 832000ull, 833000ull, 838000ull, 839000ull, 240000ull, 241000ull, 242000ull, 243000ull, 244000ull, 245000ull, 246000ull, 247000ull, 248000ull, 249000ull, 284000ull, 285000ull, 842000ull, 843000ull, 288000ull, 289000ull, 250000ull, 251000ull, 252000ull, 253000ull, 254000ull, 255000ull, 256000ull, 257000ull, 258000ull, 259000ull, 294000ull, 295000ull, 852000ull, 853000ull, 298000ull, 299000ull, 260000ull, 261000ull, 262000ull, 263000ull, 264000ull, 265000ull, 266000ull, 267000ull, 268000ull, 269000ull, 286000ull, 287000ull, 862000ull, 863000ull, 888000ull, 889000ull, 270000ull, 271000ull, 272000ull, 273000ull, 274000ull, 275000ull, 276000ull, 277000ull, 278000ull, 279000ull, 296000ull, 297000ull, 872000ull, 873000ull, 898000ull, 899000ull, 300000ull, 301000ull, 302000ull, 303000ull, 304000ull, 305000ull, 306000ull, 307000ull, 308000ull, 309000ull, 380000ull, 381000ull, 902000ull, 903000ull, 982000ull, 983000ull, 310000ull, 311000ull, 312000ull, 313000ull, 314000ull, 315000ull, 316000ull, 317000ull, 318000ull, 319000ull, 390000ull, 391000ull, 912000ull, 913000ull, 992000ull, 993000ull, 320000ull, 321000ull, 322000ull, 323000ull, 324000ull, 325000ull, 326000ull, 327000ull, 328000ull, 329000ull, 382000ull, 383000ull, 922000ull, 923000ull, 928000ull, 929000ull, 330000ull, 331000ull, 332000ull, 333000ull, 334000ull, 335000ull, 336000ull, 337000ull, 338000ull, 339000ull, 392000ull, 393000ull, 932000ull, 933000ull, 938000ull, 939000ull, 340000ull, 341000ull, 342000ull, 343000ull, 344000ull, 345000ull, 346000ull, 347000ull, 348000ull, 349000ull, 384000ull, 385000ull, 942000ull, 943000ull, 388000ull, 389000ull, 350000ull, 351000ull, 352000ull, 353000ull, 354000ull, 355000ull, 356000ull, 357000ull, 358000ull, 359000ull, 394000ull, 395000ull, 952000ull, 953000ull, 398000ull, 399000ull, 360000ull, 361000ull, 362000ull, 363000ull, 364000ull, 365000ull, 366000ull, 367000ull, 368000ull, 369000ull, 386000ull, 387000ull, 962000ull, 963000ull, 988000ull, 989000ull, 370000ull, 371000ull, 372000ull, 373000ull, 374000ull, 375000ull, 376000ull, 377000ull, 378000ull, 379000ull, 396000ull, 397000ull, 972000ull, 973000ull, 998000ull, 999000ull, 400000ull, 401000ull, 402000ull, 403000ull, 404000ull, 405000ull, 406000ull, 407000ull, 408000ull, 409000ull, 480000ull, 481000ull, 804000ull, 805000ull, 884000ull, 885000ull, 410000ull, 411000ull, 412000ull, 413000ull, 414000ull, 415000ull, 416000ull, 417000ull, 418000ull, 419000ull, 490000ull, 491000ull, 814000ull, 815000ull, 894000ull, 895000ull, 420000ull, 421000ull, 422000ull, 423000ull, 424000ull, 425000ull, 426000ull, 427000ull, 428000ull, 429000ull, 482000ull, 483000ull, 824000ull, 825000ull, 848000ull, 849000ull, 430000ull, 431000ull, 432000ull, 433000ull, 434000ull, 435000ull, 436000ull, 437000ull, 438000ull, 439000ull, 492000ull, 493000ull, 834000ull, 835000ull, 858000ull, 859000ull, 440000ull, 441000ull, 442000ull, 443000ull, 444000ull, 445000ull, 446000ull, 447000ull, 448000ull, 449000ull, 484000ull, 485000ull, 844000ull, 845000ull, 488000ull, 489000ull, 450000ull, 451000ull, 452000ull, 453000ull, 454000ull, 455000ull, 456000ull, 457000ull, 458000ull, 459000ull, 494000ull, 495000ull, 854000ull, 855000ull, 498000ull, 499000ull, 460000ull, 461000ull, 462000ull, 463000ull, 464000ull, 465000ull, 466000ull, 467000ull, 468000ull, 469000ull, 486000ull, 487000ull, 864000ull, 865000ull, 888000ull, 889000ull, 470000ull, 471000ull, 472000ull, 473000ull, 474000ull, 475000ull, 476000ull, 477000ull, 478000ull, 479000ull, 496000ull, 497000ull, 874000ull, 875000ull, 898000ull, 899000ull, 500000ull, 501000ull, 502000ull, 503000ull, 504000ull, 505000ull, 506000ull, 507000ull, 508000ull, 509000ull, 580000ull, 581000ull, 904000ull, 905000ull, 984000ull, 985000ull, 510000ull, 511000ull, 512000ull, 513000ull, 514000ull, 515000ull, 516000ull, 517000ull, 518000ull, 519000ull, 590000ull, 591000ull, 914000ull, 915000ull, 994000ull, 995000ull, 520000ull, 521000ull, 522000ull, 523000ull, 524000ull, 525000ull, 526000ull, 527000ull, 528000ull, 529000ull, 582000ull, 583000ull, 924000ull, 925000ull, 948000ull, 949000ull, 530000ull, 531000ull, 532000ull, 533000ull, 534000ull, 535000ull, 536000ull, 537000ull, 538000ull, 539000ull, 592000ull, 593000ull, 934000ull, 935000ull, 958000ull, 959000ull, 540000ull, 541000ull, 542000ull, 543000ull, 544000ull, 545000ull, 546000ull, 547000ull, 548000ull, 549000ull, 584000ull, 585000ull, 944000ull, 945000ull, 588000ull, 589000ull, 550000ull, 551000ull, 552000ull, 553000ull, 554000ull, 555000ull, 556000ull, 557000ull, 558000ull, 559000ull, 594000ull, 595000ull, 954000ull, 955000ull, 598000ull, 599000ull, 560000ull, 561000ull, 562000ull, 563000ull, 564000ull, 565000ull, 566000ull, 567000ull, 568000ull, 569000ull, 586000ull, 587000ull, 964000ull, 965000ull, 988000ull, 989000ull, 570000ull, 571000ull, 572000ull, 573000ull, 574000ull, 575000ull, 576000ull, 577000ull, 578000ull, 579000ull, 596000ull, 597000ull, 974000ull, 975000ull, 998000ull, 999000ull, 600000ull, 601000ull, 602000ull, 603000ull, 604000ull, 605000ull, 606000ull, 607000ull, 608000ull, 609000ull, 680000ull, 681000ull, 806000ull, 807000ull, 886000ull, 887000ull, 610000ull, 611000ull, 612000ull, 613000ull, 614000ull, 615000ull, 616000ull, 617000ull, 618000ull, 619000ull, 690000ull, 691000ull, 816000ull, 817000ull, 896000ull, 897000ull, 620000ull, 621000ull, 622000ull, 623000ull, 624000ull, 625000ull, 626000ull, 627000ull, 628000ull, 629000ull, 682000ull, 683000ull, 826000ull, 827000ull, 868000ull, 869000ull, 630000ull, 631000ull, 632000ull, 633000ull, 634000ull, 635000ull, 636000ull, 637000ull, 638000ull, 639000ull, 692000ull, 693000ull, 836000ull, 837000ull, 878000ull, 879000ull, 640000ull, 641000ull, 642000ull, 643000ull, 644000ull, 645000ull, 646000ull, 647000ull, 648000ull, 649000ull, 684000ull, 685000ull, 846000ull, 847000ull, 688000ull, 689000ull, 650000ull, 651000ull, 652000ull, 653000ull, 654000ull, 655000ull, 656000ull, 657000ull, 658000ull, 659000ull, 694000ull, 695000ull, 856000ull, 857000ull, 698000ull, 699000ull, 660000ull, 661000ull, 662000ull, 663000ull, 664000ull, 665000ull, 666000ull, 667000ull, 668000ull, 669000ull, 686000ull, 687000ull, 866000ull, 867000ull, 888000ull, 889000ull, 670000ull, 671000ull, 672000ull, 673000ull, 674000ull, 675000ull, 676000ull, 677000ull, 678000ull, 679000ull, 696000ull, 697000ull, 876000ull, 877000ull, 898000ull, 899000ull, 700000ull, 701000ull, 702000ull, 703000ull, 704000ull, 705000ull, 706000ull, 707000ull, 708000ull, 709000ull, 780000ull, 781000ull, 906000ull, 907000ull, 986000ull, 987000ull, 710000ull, 711000ull, 712000ull, 713000ull, 714000ull, 715000ull, 716000ull, 717000ull, 718000ull, 719000ull, 790000ull, 791000ull, 916000ull, 917000ull, 996000ull, 997000ull, 720000ull, 721000ull, 722000ull, 723000ull, 724000ull, 725000ull, 726000ull, 727000ull, 728000ull, 729000ull, 782000ull, 783000ull, 926000ull, 927000ull, 968000ull, 969000ull, 730000ull, 731000ull, 732000ull, 733000ull, 734000ull, 735000ull, 736000ull, 737000ull, 738000ull, 739000ull, 792000ull, 793000ull, 936000ull, 937000ull, 978000ull, 979000ull, 740000ull, 741000ull, 742000ull, 743000ull, 744000ull, 745000ull, 746000ull, 747000ull, 748000ull, 749000ull, 784000ull, 785000ull, 946000ull, 947000ull, 788000ull, 789000ull, 750000ull, 751000ull, 752000ull, 753000ull, 754000ull, 755000ull, 756000ull, 757000ull, 758000ull, 759000ull, 794000ull, 795000ull, 956000ull, 957000ull, 798000ull, 799000ull, 760000ull, 761000ull, 762000ull, 763000ull, 764000ull, 765000ull, 766000ull, 767000ull, 768000ull, 769000ull, 786000ull, 787000ull, 966000ull, 967000ull, 988000ull, 989000ull, 770000ull, 771000ull, 772000ull, 773000ull, 774000ull, 775000ull, 776000ull, 777000ull, 778000ull, 779000ull, 796000ull, 797000ull, 976000ull, 977000ull, 998000ull, 999000ull }; static const UINT64 d2b3[] = { 0000000ull, 1000000ull, 2000000ull, 3000000ull, 4000000ull, 5000000ull, 6000000ull, 7000000ull, 8000000ull, 9000000ull, 80000000ull, 81000000ull, 800000000ull, 801000000ull, 880000000ull, 881000000ull, 10000000ull, 11000000ull, 12000000ull, 13000000ull, 14000000ull, 15000000ull, 16000000ull, 17000000ull, 18000000ull, 19000000ull, 90000000ull, 91000000ull, 810000000ull, 811000000ull, 890000000ull, 891000000ull, 20000000ull, 21000000ull, 22000000ull, 23000000ull, 24000000ull, 25000000ull, 26000000ull, 27000000ull, 28000000ull, 29000000ull, 82000000ull, 83000000ull, 820000000ull, 821000000ull, 808000000ull, 809000000ull, 30000000ull, 31000000ull, 32000000ull, 33000000ull, 34000000ull, 35000000ull, 36000000ull, 37000000ull, 38000000ull, 39000000ull, 92000000ull, 93000000ull, 830000000ull, 831000000ull, 818000000ull, 819000000ull, 40000000ull, 41000000ull, 42000000ull, 43000000ull, 44000000ull, 45000000ull, 46000000ull, 47000000ull, 48000000ull, 49000000ull, 84000000ull, 85000000ull, 840000000ull, 841000000ull, 88000000ull, 89000000ull, 50000000ull, 51000000ull, 52000000ull, 53000000ull, 54000000ull, 55000000ull, 56000000ull, 57000000ull, 58000000ull, 59000000ull, 94000000ull, 95000000ull, 850000000ull, 851000000ull, 98000000ull, 99000000ull, 60000000ull, 61000000ull, 62000000ull, 63000000ull, 64000000ull, 65000000ull, 66000000ull, 67000000ull, 68000000ull, 69000000ull, 86000000ull, 87000000ull, 860000000ull, 861000000ull, 888000000ull, 889000000ull, 70000000ull, 71000000ull, 72000000ull, 73000000ull, 74000000ull, 75000000ull, 76000000ull, 77000000ull, 78000000ull, 79000000ull, 96000000ull, 97000000ull, 870000000ull, 871000000ull, 898000000ull, 899000000ull, 100000000ull, 101000000ull, 102000000ull, 103000000ull, 104000000ull, 105000000ull, 106000000ull, 107000000ull, 108000000ull, 109000000ull, 180000000ull, 181000000ull, 900000000ull, 901000000ull, 980000000ull, 981000000ull, 110000000ull, 111000000ull, 112000000ull, 113000000ull, 114000000ull, 115000000ull, 116000000ull, 117000000ull, 118000000ull, 119000000ull, 190000000ull, 191000000ull, 910000000ull, 911000000ull, 990000000ull, 991000000ull, 120000000ull, 121000000ull, 122000000ull, 123000000ull, 124000000ull, 125000000ull, 126000000ull, 127000000ull, 128000000ull, 129000000ull, 182000000ull, 183000000ull, 920000000ull, 921000000ull, 908000000ull, 909000000ull, 130000000ull, 131000000ull, 132000000ull, 133000000ull, 134000000ull, 135000000ull, 136000000ull, 137000000ull, 138000000ull, 139000000ull, 192000000ull, 193000000ull, 930000000ull, 931000000ull, 918000000ull, 919000000ull, 140000000ull, 141000000ull, 142000000ull, 143000000ull, 144000000ull, 145000000ull, 146000000ull, 147000000ull, 148000000ull, 149000000ull, 184000000ull, 185000000ull, 940000000ull, 941000000ull, 188000000ull, 189000000ull, 150000000ull, 151000000ull, 152000000ull, 153000000ull, 154000000ull, 155000000ull, 156000000ull, 157000000ull, 158000000ull, 159000000ull, 194000000ull, 195000000ull, 950000000ull, 951000000ull, 198000000ull, 199000000ull, 160000000ull, 161000000ull, 162000000ull, 163000000ull, 164000000ull, 165000000ull, 166000000ull, 167000000ull, 168000000ull, 169000000ull, 186000000ull, 187000000ull, 960000000ull, 961000000ull, 988000000ull, 989000000ull, 170000000ull, 171000000ull, 172000000ull, 173000000ull, 174000000ull, 175000000ull, 176000000ull, 177000000ull, 178000000ull, 179000000ull, 196000000ull, 197000000ull, 970000000ull, 971000000ull, 998000000ull, 999000000ull, 200000000ull, 201000000ull, 202000000ull, 203000000ull, 204000000ull, 205000000ull, 206000000ull, 207000000ull, 208000000ull, 209000000ull, 280000000ull, 281000000ull, 802000000ull, 803000000ull, 882000000ull, 883000000ull, 210000000ull, 211000000ull, 212000000ull, 213000000ull, 214000000ull, 215000000ull, 216000000ull, 217000000ull, 218000000ull, 219000000ull, 290000000ull, 291000000ull, 812000000ull, 813000000ull, 892000000ull, 893000000ull, 220000000ull, 221000000ull, 222000000ull, 223000000ull, 224000000ull, 225000000ull, 226000000ull, 227000000ull, 228000000ull, 229000000ull, 282000000ull, 283000000ull, 822000000ull, 823000000ull, 828000000ull, 829000000ull, 230000000ull, 231000000ull, 232000000ull, 233000000ull, 234000000ull, 235000000ull, 236000000ull, 237000000ull, 238000000ull, 239000000ull, 292000000ull, 293000000ull, 832000000ull, 833000000ull, 838000000ull, 839000000ull, 240000000ull, 241000000ull, 242000000ull, 243000000ull, 244000000ull, 245000000ull, 246000000ull, 247000000ull, 248000000ull, 249000000ull, 284000000ull, 285000000ull, 842000000ull, 843000000ull, 288000000ull, 289000000ull, 250000000ull, 251000000ull, 252000000ull, 253000000ull, 254000000ull, 255000000ull, 256000000ull, 257000000ull, 258000000ull, 259000000ull, 294000000ull, 295000000ull, 852000000ull, 853000000ull, 298000000ull, 299000000ull, 260000000ull, 261000000ull, 262000000ull, 263000000ull, 264000000ull, 265000000ull, 266000000ull, 267000000ull, 268000000ull, 269000000ull, 286000000ull, 287000000ull, 862000000ull, 863000000ull, 888000000ull, 889000000ull, 270000000ull, 271000000ull, 272000000ull, 273000000ull, 274000000ull, 275000000ull, 276000000ull, 277000000ull, 278000000ull, 279000000ull, 296000000ull, 297000000ull, 872000000ull, 873000000ull, 898000000ull, 899000000ull, 300000000ull, 301000000ull, 302000000ull, 303000000ull, 304000000ull, 305000000ull, 306000000ull, 307000000ull, 308000000ull, 309000000ull, 380000000ull, 381000000ull, 902000000ull, 903000000ull, 982000000ull, 983000000ull, 310000000ull, 311000000ull, 312000000ull, 313000000ull, 314000000ull, 315000000ull, 316000000ull, 317000000ull, 318000000ull, 319000000ull, 390000000ull, 391000000ull, 912000000ull, 913000000ull, 992000000ull, 993000000ull, 320000000ull, 321000000ull, 322000000ull, 323000000ull, 324000000ull, 325000000ull, 326000000ull, 327000000ull, 328000000ull, 329000000ull, 382000000ull, 383000000ull, 922000000ull, 923000000ull, 928000000ull, 929000000ull, 330000000ull, 331000000ull, 332000000ull, 333000000ull, 334000000ull, 335000000ull, 336000000ull, 337000000ull, 338000000ull, 339000000ull, 392000000ull, 393000000ull, 932000000ull, 933000000ull, 938000000ull, 939000000ull, 340000000ull, 341000000ull, 342000000ull, 343000000ull, 344000000ull, 345000000ull, 346000000ull, 347000000ull, 348000000ull, 349000000ull, 384000000ull, 385000000ull, 942000000ull, 943000000ull, 388000000ull, 389000000ull, 350000000ull, 351000000ull, 352000000ull, 353000000ull, 354000000ull, 355000000ull, 356000000ull, 357000000ull, 358000000ull, 359000000ull, 394000000ull, 395000000ull, 952000000ull, 953000000ull, 398000000ull, 399000000ull, 360000000ull, 361000000ull, 362000000ull, 363000000ull, 364000000ull, 365000000ull, 366000000ull, 367000000ull, 368000000ull, 369000000ull, 386000000ull, 387000000ull, 962000000ull, 963000000ull, 988000000ull, 989000000ull, 370000000ull, 371000000ull, 372000000ull, 373000000ull, 374000000ull, 375000000ull, 376000000ull, 377000000ull, 378000000ull, 379000000ull, 396000000ull, 397000000ull, 972000000ull, 973000000ull, 998000000ull, 999000000ull, 400000000ull, 401000000ull, 402000000ull, 403000000ull, 404000000ull, 405000000ull, 406000000ull, 407000000ull, 408000000ull, 409000000ull, 480000000ull, 481000000ull, 804000000ull, 805000000ull, 884000000ull, 885000000ull, 410000000ull, 411000000ull, 412000000ull, 413000000ull, 414000000ull, 415000000ull, 416000000ull, 417000000ull, 418000000ull, 419000000ull, 490000000ull, 491000000ull, 814000000ull, 815000000ull, 894000000ull, 895000000ull, 420000000ull, 421000000ull, 422000000ull, 423000000ull, 424000000ull, 425000000ull, 426000000ull, 427000000ull, 428000000ull, 429000000ull, 482000000ull, 483000000ull, 824000000ull, 825000000ull, 848000000ull, 849000000ull, 430000000ull, 431000000ull, 432000000ull, 433000000ull, 434000000ull, 435000000ull, 436000000ull, 437000000ull, 438000000ull, 439000000ull, 492000000ull, 493000000ull, 834000000ull, 835000000ull, 858000000ull, 859000000ull, 440000000ull, 441000000ull, 442000000ull, 443000000ull, 444000000ull, 445000000ull, 446000000ull, 447000000ull, 448000000ull, 449000000ull, 484000000ull, 485000000ull, 844000000ull, 845000000ull, 488000000ull, 489000000ull, 450000000ull, 451000000ull, 452000000ull, 453000000ull, 454000000ull, 455000000ull, 456000000ull, 457000000ull, 458000000ull, 459000000ull, 494000000ull, 495000000ull, 854000000ull, 855000000ull, 498000000ull, 499000000ull, 460000000ull, 461000000ull, 462000000ull, 463000000ull, 464000000ull, 465000000ull, 466000000ull, 467000000ull, 468000000ull, 469000000ull, 486000000ull, 487000000ull, 864000000ull, 865000000ull, 888000000ull, 889000000ull, 470000000ull, 471000000ull, 472000000ull, 473000000ull, 474000000ull, 475000000ull, 476000000ull, 477000000ull, 478000000ull, 479000000ull, 496000000ull, 497000000ull, 874000000ull, 875000000ull, 898000000ull, 899000000ull, 500000000ull, 501000000ull, 502000000ull, 503000000ull, 504000000ull, 505000000ull, 506000000ull, 507000000ull, 508000000ull, 509000000ull, 580000000ull, 581000000ull, 904000000ull, 905000000ull, 984000000ull, 985000000ull, 510000000ull, 511000000ull, 512000000ull, 513000000ull, 514000000ull, 515000000ull, 516000000ull, 517000000ull, 518000000ull, 519000000ull, 590000000ull, 591000000ull, 914000000ull, 915000000ull, 994000000ull, 995000000ull, 520000000ull, 521000000ull, 522000000ull, 523000000ull, 524000000ull, 525000000ull, 526000000ull, 527000000ull, 528000000ull, 529000000ull, 582000000ull, 583000000ull, 924000000ull, 925000000ull, 948000000ull, 949000000ull, 530000000ull, 531000000ull, 532000000ull, 533000000ull, 534000000ull, 535000000ull, 536000000ull, 537000000ull, 538000000ull, 539000000ull, 592000000ull, 593000000ull, 934000000ull, 935000000ull, 958000000ull, 959000000ull, 540000000ull, 541000000ull, 542000000ull, 543000000ull, 544000000ull, 545000000ull, 546000000ull, 547000000ull, 548000000ull, 549000000ull, 584000000ull, 585000000ull, 944000000ull, 945000000ull, 588000000ull, 589000000ull, 550000000ull, 551000000ull, 552000000ull, 553000000ull, 554000000ull, 555000000ull, 556000000ull, 557000000ull, 558000000ull, 559000000ull, 594000000ull, 595000000ull, 954000000ull, 955000000ull, 598000000ull, 599000000ull, 560000000ull, 561000000ull, 562000000ull, 563000000ull, 564000000ull, 565000000ull, 566000000ull, 567000000ull, 568000000ull, 569000000ull, 586000000ull, 587000000ull, 964000000ull, 965000000ull, 988000000ull, 989000000ull, 570000000ull, 571000000ull, 572000000ull, 573000000ull, 574000000ull, 575000000ull, 576000000ull, 577000000ull, 578000000ull, 579000000ull, 596000000ull, 597000000ull, 974000000ull, 975000000ull, 998000000ull, 999000000ull, 600000000ull, 601000000ull, 602000000ull, 603000000ull, 604000000ull, 605000000ull, 606000000ull, 607000000ull, 608000000ull, 609000000ull, 680000000ull, 681000000ull, 806000000ull, 807000000ull, 886000000ull, 887000000ull, 610000000ull, 611000000ull, 612000000ull, 613000000ull, 614000000ull, 615000000ull, 616000000ull, 617000000ull, 618000000ull, 619000000ull, 690000000ull, 691000000ull, 816000000ull, 817000000ull, 896000000ull, 897000000ull, 620000000ull, 621000000ull, 622000000ull, 623000000ull, 624000000ull, 625000000ull, 626000000ull, 627000000ull, 628000000ull, 629000000ull, 682000000ull, 683000000ull, 826000000ull, 827000000ull, 868000000ull, 869000000ull, 630000000ull, 631000000ull, 632000000ull, 633000000ull, 634000000ull, 635000000ull, 636000000ull, 637000000ull, 638000000ull, 639000000ull, 692000000ull, 693000000ull, 836000000ull, 837000000ull, 878000000ull, 879000000ull, 640000000ull, 641000000ull, 642000000ull, 643000000ull, 644000000ull, 645000000ull, 646000000ull, 647000000ull, 648000000ull, 649000000ull, 684000000ull, 685000000ull, 846000000ull, 847000000ull, 688000000ull, 689000000ull, 650000000ull, 651000000ull, 652000000ull, 653000000ull, 654000000ull, 655000000ull, 656000000ull, 657000000ull, 658000000ull, 659000000ull, 694000000ull, 695000000ull, 856000000ull, 857000000ull, 698000000ull, 699000000ull, 660000000ull, 661000000ull, 662000000ull, 663000000ull, 664000000ull, 665000000ull, 666000000ull, 667000000ull, 668000000ull, 669000000ull, 686000000ull, 687000000ull, 866000000ull, 867000000ull, 888000000ull, 889000000ull, 670000000ull, 671000000ull, 672000000ull, 673000000ull, 674000000ull, 675000000ull, 676000000ull, 677000000ull, 678000000ull, 679000000ull, 696000000ull, 697000000ull, 876000000ull, 877000000ull, 898000000ull, 899000000ull, 700000000ull, 701000000ull, 702000000ull, 703000000ull, 704000000ull, 705000000ull, 706000000ull, 707000000ull, 708000000ull, 709000000ull, 780000000ull, 781000000ull, 906000000ull, 907000000ull, 986000000ull, 987000000ull, 710000000ull, 711000000ull, 712000000ull, 713000000ull, 714000000ull, 715000000ull, 716000000ull, 717000000ull, 718000000ull, 719000000ull, 790000000ull, 791000000ull, 916000000ull, 917000000ull, 996000000ull, 997000000ull, 720000000ull, 721000000ull, 722000000ull, 723000000ull, 724000000ull, 725000000ull, 726000000ull, 727000000ull, 728000000ull, 729000000ull, 782000000ull, 783000000ull, 926000000ull, 927000000ull, 968000000ull, 969000000ull, 730000000ull, 731000000ull, 732000000ull, 733000000ull, 734000000ull, 735000000ull, 736000000ull, 737000000ull, 738000000ull, 739000000ull, 792000000ull, 793000000ull, 936000000ull, 937000000ull, 978000000ull, 979000000ull, 740000000ull, 741000000ull, 742000000ull, 743000000ull, 744000000ull, 745000000ull, 746000000ull, 747000000ull, 748000000ull, 749000000ull, 784000000ull, 785000000ull, 946000000ull, 947000000ull, 788000000ull, 789000000ull, 750000000ull, 751000000ull, 752000000ull, 753000000ull, 754000000ull, 755000000ull, 756000000ull, 757000000ull, 758000000ull, 759000000ull, 794000000ull, 795000000ull, 956000000ull, 957000000ull, 798000000ull, 799000000ull, 760000000ull, 761000000ull, 762000000ull, 763000000ull, 764000000ull, 765000000ull, 766000000ull, 767000000ull, 768000000ull, 769000000ull, 786000000ull, 787000000ull, 966000000ull, 967000000ull, 988000000ull, 989000000ull, 770000000ull, 771000000ull, 772000000ull, 773000000ull, 774000000ull, 775000000ull, 776000000ull, 777000000ull, 778000000ull, 779000000ull, 796000000ull, 797000000ull, 976000000ull, 977000000ull, 998000000ull, 999000000ull }; static const UINT64 d2b4[] = { 0000000000ull, 1000000000ull, 2000000000ull, 3000000000ull, 4000000000ull, 5000000000ull, 6000000000ull, 7000000000ull, 8000000000ull, 9000000000ull, 80000000000ull, 81000000000ull, 800000000000ull, 801000000000ull, 880000000000ull, 881000000000ull, 10000000000ull, 11000000000ull, 12000000000ull, 13000000000ull, 14000000000ull, 15000000000ull, 16000000000ull, 17000000000ull, 18000000000ull, 19000000000ull, 90000000000ull, 91000000000ull, 810000000000ull, 811000000000ull, 890000000000ull, 891000000000ull, 20000000000ull, 21000000000ull, 22000000000ull, 23000000000ull, 24000000000ull, 25000000000ull, 26000000000ull, 27000000000ull, 28000000000ull, 29000000000ull, 82000000000ull, 83000000000ull, 820000000000ull, 821000000000ull, 808000000000ull, 809000000000ull, 30000000000ull, 31000000000ull, 32000000000ull, 33000000000ull, 34000000000ull, 35000000000ull, 36000000000ull, 37000000000ull, 38000000000ull, 39000000000ull, 92000000000ull, 93000000000ull, 830000000000ull, 831000000000ull, 818000000000ull, 819000000000ull, 40000000000ull, 41000000000ull, 42000000000ull, 43000000000ull, 44000000000ull, 45000000000ull, 46000000000ull, 47000000000ull, 48000000000ull, 49000000000ull, 84000000000ull, 85000000000ull, 840000000000ull, 841000000000ull, 88000000000ull, 89000000000ull, 50000000000ull, 51000000000ull, 52000000000ull, 53000000000ull, 54000000000ull, 55000000000ull, 56000000000ull, 57000000000ull, 58000000000ull, 59000000000ull, 94000000000ull, 95000000000ull, 850000000000ull, 851000000000ull, 98000000000ull, 99000000000ull, 60000000000ull, 61000000000ull, 62000000000ull, 63000000000ull, 64000000000ull, 65000000000ull, 66000000000ull, 67000000000ull, 68000000000ull, 69000000000ull, 86000000000ull, 87000000000ull, 860000000000ull, 861000000000ull, 888000000000ull, 889000000000ull, 70000000000ull, 71000000000ull, 72000000000ull, 73000000000ull, 74000000000ull, 75000000000ull, 76000000000ull, 77000000000ull, 78000000000ull, 79000000000ull, 96000000000ull, 97000000000ull, 870000000000ull, 871000000000ull, 898000000000ull, 899000000000ull, 100000000000ull, 101000000000ull, 102000000000ull, 103000000000ull, 104000000000ull, 105000000000ull, 106000000000ull, 107000000000ull, 108000000000ull, 109000000000ull, 180000000000ull, 181000000000ull, 900000000000ull, 901000000000ull, 980000000000ull, 981000000000ull, 110000000000ull, 111000000000ull, 112000000000ull, 113000000000ull, 114000000000ull, 115000000000ull, 116000000000ull, 117000000000ull, 118000000000ull, 119000000000ull, 190000000000ull, 191000000000ull, 910000000000ull, 911000000000ull, 990000000000ull, 991000000000ull, 120000000000ull, 121000000000ull, 122000000000ull, 123000000000ull, 124000000000ull, 125000000000ull, 126000000000ull, 127000000000ull, 128000000000ull, 129000000000ull, 182000000000ull, 183000000000ull, 920000000000ull, 921000000000ull, 908000000000ull, 909000000000ull, 130000000000ull, 131000000000ull, 132000000000ull, 133000000000ull, 134000000000ull, 135000000000ull, 136000000000ull, 137000000000ull, 138000000000ull, 139000000000ull, 192000000000ull, 193000000000ull, 930000000000ull, 931000000000ull, 918000000000ull, 919000000000ull, 140000000000ull, 141000000000ull, 142000000000ull, 143000000000ull, 144000000000ull, 145000000000ull, 146000000000ull, 147000000000ull, 148000000000ull, 149000000000ull, 184000000000ull, 185000000000ull, 940000000000ull, 941000000000ull, 188000000000ull, 189000000000ull, 150000000000ull, 151000000000ull, 152000000000ull, 153000000000ull, 154000000000ull, 155000000000ull, 156000000000ull, 157000000000ull, 158000000000ull, 159000000000ull, 194000000000ull, 195000000000ull, 950000000000ull, 951000000000ull, 198000000000ull, 199000000000ull, 160000000000ull, 161000000000ull, 162000000000ull, 163000000000ull, 164000000000ull, 165000000000ull, 166000000000ull, 167000000000ull, 168000000000ull, 169000000000ull, 186000000000ull, 187000000000ull, 960000000000ull, 961000000000ull, 988000000000ull, 989000000000ull, 170000000000ull, 171000000000ull, 172000000000ull, 173000000000ull, 174000000000ull, 175000000000ull, 176000000000ull, 177000000000ull, 178000000000ull, 179000000000ull, 196000000000ull, 197000000000ull, 970000000000ull, 971000000000ull, 998000000000ull, 999000000000ull, 200000000000ull, 201000000000ull, 202000000000ull, 203000000000ull, 204000000000ull, 205000000000ull, 206000000000ull, 207000000000ull, 208000000000ull, 209000000000ull, 280000000000ull, 281000000000ull, 802000000000ull, 803000000000ull, 882000000000ull, 883000000000ull, 210000000000ull, 211000000000ull, 212000000000ull, 213000000000ull, 214000000000ull, 215000000000ull, 216000000000ull, 217000000000ull, 218000000000ull, 219000000000ull, 290000000000ull, 291000000000ull, 812000000000ull, 813000000000ull, 892000000000ull, 893000000000ull, 220000000000ull, 221000000000ull, 222000000000ull, 223000000000ull, 224000000000ull, 225000000000ull, 226000000000ull, 227000000000ull, 228000000000ull, 229000000000ull, 282000000000ull, 283000000000ull, 822000000000ull, 823000000000ull, 828000000000ull, 829000000000ull, 230000000000ull, 231000000000ull, 232000000000ull, 233000000000ull, 234000000000ull, 235000000000ull, 236000000000ull, 237000000000ull, 238000000000ull, 239000000000ull, 292000000000ull, 293000000000ull, 832000000000ull, 833000000000ull, 838000000000ull, 839000000000ull, 240000000000ull, 241000000000ull, 242000000000ull, 243000000000ull, 244000000000ull, 245000000000ull, 246000000000ull, 247000000000ull, 248000000000ull, 249000000000ull, 284000000000ull, 285000000000ull, 842000000000ull, 843000000000ull, 288000000000ull, 289000000000ull, 250000000000ull, 251000000000ull, 252000000000ull, 253000000000ull, 254000000000ull, 255000000000ull, 256000000000ull, 257000000000ull, 258000000000ull, 259000000000ull, 294000000000ull, 295000000000ull, 852000000000ull, 853000000000ull, 298000000000ull, 299000000000ull, 260000000000ull, 261000000000ull, 262000000000ull, 263000000000ull, 264000000000ull, 265000000000ull, 266000000000ull, 267000000000ull, 268000000000ull, 269000000000ull, 286000000000ull, 287000000000ull, 862000000000ull, 863000000000ull, 888000000000ull, 889000000000ull, 270000000000ull, 271000000000ull, 272000000000ull, 273000000000ull, 274000000000ull, 275000000000ull, 276000000000ull, 277000000000ull, 278000000000ull, 279000000000ull, 296000000000ull, 297000000000ull, 872000000000ull, 873000000000ull, 898000000000ull, 899000000000ull, 300000000000ull, 301000000000ull, 302000000000ull, 303000000000ull, 304000000000ull, 305000000000ull, 306000000000ull, 307000000000ull, 308000000000ull, 309000000000ull, 380000000000ull, 381000000000ull, 902000000000ull, 903000000000ull, 982000000000ull, 983000000000ull, 310000000000ull, 311000000000ull, 312000000000ull, 313000000000ull, 314000000000ull, 315000000000ull, 316000000000ull, 317000000000ull, 318000000000ull, 319000000000ull, 390000000000ull, 391000000000ull, 912000000000ull, 913000000000ull, 992000000000ull, 993000000000ull, 320000000000ull, 321000000000ull, 322000000000ull, 323000000000ull, 324000000000ull, 325000000000ull, 326000000000ull, 327000000000ull, 328000000000ull, 329000000000ull, 382000000000ull, 383000000000ull, 922000000000ull, 923000000000ull, 928000000000ull, 929000000000ull, 330000000000ull, 331000000000ull, 332000000000ull, 333000000000ull, 334000000000ull, 335000000000ull, 336000000000ull, 337000000000ull, 338000000000ull, 339000000000ull, 392000000000ull, 393000000000ull, 932000000000ull, 933000000000ull, 938000000000ull, 939000000000ull, 340000000000ull, 341000000000ull, 342000000000ull, 343000000000ull, 344000000000ull, 345000000000ull, 346000000000ull, 347000000000ull, 348000000000ull, 349000000000ull, 384000000000ull, 385000000000ull, 942000000000ull, 943000000000ull, 388000000000ull, 389000000000ull, 350000000000ull, 351000000000ull, 352000000000ull, 353000000000ull, 354000000000ull, 355000000000ull, 356000000000ull, 357000000000ull, 358000000000ull, 359000000000ull, 394000000000ull, 395000000000ull, 952000000000ull, 953000000000ull, 398000000000ull, 399000000000ull, 360000000000ull, 361000000000ull, 362000000000ull, 363000000000ull, 364000000000ull, 365000000000ull, 366000000000ull, 367000000000ull, 368000000000ull, 369000000000ull, 386000000000ull, 387000000000ull, 962000000000ull, 963000000000ull, 988000000000ull, 989000000000ull, 370000000000ull, 371000000000ull, 372000000000ull, 373000000000ull, 374000000000ull, 375000000000ull, 376000000000ull, 377000000000ull, 378000000000ull, 379000000000ull, 396000000000ull, 397000000000ull, 972000000000ull, 973000000000ull, 998000000000ull, 999000000000ull, 400000000000ull, 401000000000ull, 402000000000ull, 403000000000ull, 404000000000ull, 405000000000ull, 406000000000ull, 407000000000ull, 408000000000ull, 409000000000ull, 480000000000ull, 481000000000ull, 804000000000ull, 805000000000ull, 884000000000ull, 885000000000ull, 410000000000ull, 411000000000ull, 412000000000ull, 413000000000ull, 414000000000ull, 415000000000ull, 416000000000ull, 417000000000ull, 418000000000ull, 419000000000ull, 490000000000ull, 491000000000ull, 814000000000ull, 815000000000ull, 894000000000ull, 895000000000ull, 420000000000ull, 421000000000ull, 422000000000ull, 423000000000ull, 424000000000ull, 425000000000ull, 426000000000ull, 427000000000ull, 428000000000ull, 429000000000ull, 482000000000ull, 483000000000ull, 824000000000ull, 825000000000ull, 848000000000ull, 849000000000ull, 430000000000ull, 431000000000ull, 432000000000ull, 433000000000ull, 434000000000ull, 435000000000ull, 436000000000ull, 437000000000ull, 438000000000ull, 439000000000ull, 492000000000ull, 493000000000ull, 834000000000ull, 835000000000ull, 858000000000ull, 859000000000ull, 440000000000ull, 441000000000ull, 442000000000ull, 443000000000ull, 444000000000ull, 445000000000ull, 446000000000ull, 447000000000ull, 448000000000ull, 449000000000ull, 484000000000ull, 485000000000ull, 844000000000ull, 845000000000ull, 488000000000ull, 489000000000ull, 450000000000ull, 451000000000ull, 452000000000ull, 453000000000ull, 454000000000ull, 455000000000ull, 456000000000ull, 457000000000ull, 458000000000ull, 459000000000ull, 494000000000ull, 495000000000ull, 854000000000ull, 855000000000ull, 498000000000ull, 499000000000ull, 460000000000ull, 461000000000ull, 462000000000ull, 463000000000ull, 464000000000ull, 465000000000ull, 466000000000ull, 467000000000ull, 468000000000ull, 469000000000ull, 486000000000ull, 487000000000ull, 864000000000ull, 865000000000ull, 888000000000ull, 889000000000ull, 470000000000ull, 471000000000ull, 472000000000ull, 473000000000ull, 474000000000ull, 475000000000ull, 476000000000ull, 477000000000ull, 478000000000ull, 479000000000ull, 496000000000ull, 497000000000ull, 874000000000ull, 875000000000ull, 898000000000ull, 899000000000ull, 500000000000ull, 501000000000ull, 502000000000ull, 503000000000ull, 504000000000ull, 505000000000ull, 506000000000ull, 507000000000ull, 508000000000ull, 509000000000ull, 580000000000ull, 581000000000ull, 904000000000ull, 905000000000ull, 984000000000ull, 985000000000ull, 510000000000ull, 511000000000ull, 512000000000ull, 513000000000ull, 514000000000ull, 515000000000ull, 516000000000ull, 517000000000ull, 518000000000ull, 519000000000ull, 590000000000ull, 591000000000ull, 914000000000ull, 915000000000ull, 994000000000ull, 995000000000ull, 520000000000ull, 521000000000ull, 522000000000ull, 523000000000ull, 524000000000ull, 525000000000ull, 526000000000ull, 527000000000ull, 528000000000ull, 529000000000ull, 582000000000ull, 583000000000ull, 924000000000ull, 925000000000ull, 948000000000ull, 949000000000ull, 530000000000ull, 531000000000ull, 532000000000ull, 533000000000ull, 534000000000ull, 535000000000ull, 536000000000ull, 537000000000ull, 538000000000ull, 539000000000ull, 592000000000ull, 593000000000ull, 934000000000ull, 935000000000ull, 958000000000ull, 959000000000ull, 540000000000ull, 541000000000ull, 542000000000ull, 543000000000ull, 544000000000ull, 545000000000ull, 546000000000ull, 547000000000ull, 548000000000ull, 549000000000ull, 584000000000ull, 585000000000ull, 944000000000ull, 945000000000ull, 588000000000ull, 589000000000ull, 550000000000ull, 551000000000ull, 552000000000ull, 553000000000ull, 554000000000ull, 555000000000ull, 556000000000ull, 557000000000ull, 558000000000ull, 559000000000ull, 594000000000ull, 595000000000ull, 954000000000ull, 955000000000ull, 598000000000ull, 599000000000ull, 560000000000ull, 561000000000ull, 562000000000ull, 563000000000ull, 564000000000ull, 565000000000ull, 566000000000ull, 567000000000ull, 568000000000ull, 569000000000ull, 586000000000ull, 587000000000ull, 964000000000ull, 965000000000ull, 988000000000ull, 989000000000ull, 570000000000ull, 571000000000ull, 572000000000ull, 573000000000ull, 574000000000ull, 575000000000ull, 576000000000ull, 577000000000ull, 578000000000ull, 579000000000ull, 596000000000ull, 597000000000ull, 974000000000ull, 975000000000ull, 998000000000ull, 999000000000ull, 600000000000ull, 601000000000ull, 602000000000ull, 603000000000ull, 604000000000ull, 605000000000ull, 606000000000ull, 607000000000ull, 608000000000ull, 609000000000ull, 680000000000ull, 681000000000ull, 806000000000ull, 807000000000ull, 886000000000ull, 887000000000ull, 610000000000ull, 611000000000ull, 612000000000ull, 613000000000ull, 614000000000ull, 615000000000ull, 616000000000ull, 617000000000ull, 618000000000ull, 619000000000ull, 690000000000ull, 691000000000ull, 816000000000ull, 817000000000ull, 896000000000ull, 897000000000ull, 620000000000ull, 621000000000ull, 622000000000ull, 623000000000ull, 624000000000ull, 625000000000ull, 626000000000ull, 627000000000ull, 628000000000ull, 629000000000ull, 682000000000ull, 683000000000ull, 826000000000ull, 827000000000ull, 868000000000ull, 869000000000ull, 630000000000ull, 631000000000ull, 632000000000ull, 633000000000ull, 634000000000ull, 635000000000ull, 636000000000ull, 637000000000ull, 638000000000ull, 639000000000ull, 692000000000ull, 693000000000ull, 836000000000ull, 837000000000ull, 878000000000ull, 879000000000ull, 640000000000ull, 641000000000ull, 642000000000ull, 643000000000ull, 644000000000ull, 645000000000ull, 646000000000ull, 647000000000ull, 648000000000ull, 649000000000ull, 684000000000ull, 685000000000ull, 846000000000ull, 847000000000ull, 688000000000ull, 689000000000ull, 650000000000ull, 651000000000ull, 652000000000ull, 653000000000ull, 654000000000ull, 655000000000ull, 656000000000ull, 657000000000ull, 658000000000ull, 659000000000ull, 694000000000ull, 695000000000ull, 856000000000ull, 857000000000ull, 698000000000ull, 699000000000ull, 660000000000ull, 661000000000ull, 662000000000ull, 663000000000ull, 664000000000ull, 665000000000ull, 666000000000ull, 667000000000ull, 668000000000ull, 669000000000ull, 686000000000ull, 687000000000ull, 866000000000ull, 867000000000ull, 888000000000ull, 889000000000ull, 670000000000ull, 671000000000ull, 672000000000ull, 673000000000ull, 674000000000ull, 675000000000ull, 676000000000ull, 677000000000ull, 678000000000ull, 679000000000ull, 696000000000ull, 697000000000ull, 876000000000ull, 877000000000ull, 898000000000ull, 899000000000ull, 700000000000ull, 701000000000ull, 702000000000ull, 703000000000ull, 704000000000ull, 705000000000ull, 706000000000ull, 707000000000ull, 708000000000ull, 709000000000ull, 780000000000ull, 781000000000ull, 906000000000ull, 907000000000ull, 986000000000ull, 987000000000ull, 710000000000ull, 711000000000ull, 712000000000ull, 713000000000ull, 714000000000ull, 715000000000ull, 716000000000ull, 717000000000ull, 718000000000ull, 719000000000ull, 790000000000ull, 791000000000ull, 916000000000ull, 917000000000ull, 996000000000ull, 997000000000ull, 720000000000ull, 721000000000ull, 722000000000ull, 723000000000ull, 724000000000ull, 725000000000ull, 726000000000ull, 727000000000ull, 728000000000ull, 729000000000ull, 782000000000ull, 783000000000ull, 926000000000ull, 927000000000ull, 968000000000ull, 969000000000ull, 730000000000ull, 731000000000ull, 732000000000ull, 733000000000ull, 734000000000ull, 735000000000ull, 736000000000ull, 737000000000ull, 738000000000ull, 739000000000ull, 792000000000ull, 793000000000ull, 936000000000ull, 937000000000ull, 978000000000ull, 979000000000ull, 740000000000ull, 741000000000ull, 742000000000ull, 743000000000ull, 744000000000ull, 745000000000ull, 746000000000ull, 747000000000ull, 748000000000ull, 749000000000ull, 784000000000ull, 785000000000ull, 946000000000ull, 947000000000ull, 788000000000ull, 789000000000ull, 750000000000ull, 751000000000ull, 752000000000ull, 753000000000ull, 754000000000ull, 755000000000ull, 756000000000ull, 757000000000ull, 758000000000ull, 759000000000ull, 794000000000ull, 795000000000ull, 956000000000ull, 957000000000ull, 798000000000ull, 799000000000ull, 760000000000ull, 761000000000ull, 762000000000ull, 763000000000ull, 764000000000ull, 765000000000ull, 766000000000ull, 767000000000ull, 768000000000ull, 769000000000ull, 786000000000ull, 787000000000ull, 966000000000ull, 967000000000ull, 988000000000ull, 989000000000ull, 770000000000ull, 771000000000ull, 772000000000ull, 773000000000ull, 774000000000ull, 775000000000ull, 776000000000ull, 777000000000ull, 778000000000ull, 779000000000ull, 796000000000ull, 797000000000ull, 976000000000ull, 977000000000ull, 998000000000ull, 999000000000ull }; static const UINT64 d2b5[] = { 0000000000000ull, 1000000000000ull, 2000000000000ull, 3000000000000ull, 4000000000000ull, 5000000000000ull, 6000000000000ull, 7000000000000ull, 8000000000000ull, 9000000000000ull, 80000000000000ull, 81000000000000ull, 800000000000000ull, 801000000000000ull, 880000000000000ull, 881000000000000ull, 10000000000000ull, 11000000000000ull, 12000000000000ull, 13000000000000ull, 14000000000000ull, 15000000000000ull, 16000000000000ull, 17000000000000ull, 18000000000000ull, 19000000000000ull, 90000000000000ull, 91000000000000ull, 810000000000000ull, 811000000000000ull, 890000000000000ull, 891000000000000ull, 20000000000000ull, 21000000000000ull, 22000000000000ull, 23000000000000ull, 24000000000000ull, 25000000000000ull, 26000000000000ull, 27000000000000ull, 28000000000000ull, 29000000000000ull, 82000000000000ull, 83000000000000ull, 820000000000000ull, 821000000000000ull, 808000000000000ull, 809000000000000ull, 30000000000000ull, 31000000000000ull, 32000000000000ull, 33000000000000ull, 34000000000000ull, 35000000000000ull, 36000000000000ull, 37000000000000ull, 38000000000000ull, 39000000000000ull, 92000000000000ull, 93000000000000ull, 830000000000000ull, 831000000000000ull, 818000000000000ull, 819000000000000ull, 40000000000000ull, 41000000000000ull, 42000000000000ull, 43000000000000ull, 44000000000000ull, 45000000000000ull, 46000000000000ull, 47000000000000ull, 48000000000000ull, 49000000000000ull, 84000000000000ull, 85000000000000ull, 840000000000000ull, 841000000000000ull, 88000000000000ull, 89000000000000ull, 50000000000000ull, 51000000000000ull, 52000000000000ull, 53000000000000ull, 54000000000000ull, 55000000000000ull, 56000000000000ull, 57000000000000ull, 58000000000000ull, 59000000000000ull, 94000000000000ull, 95000000000000ull, 850000000000000ull, 851000000000000ull, 98000000000000ull, 99000000000000ull, 60000000000000ull, 61000000000000ull, 62000000000000ull, 63000000000000ull, 64000000000000ull, 65000000000000ull, 66000000000000ull, 67000000000000ull, 68000000000000ull, 69000000000000ull, 86000000000000ull, 87000000000000ull, 860000000000000ull, 861000000000000ull, 888000000000000ull, 889000000000000ull, 70000000000000ull, 71000000000000ull, 72000000000000ull, 73000000000000ull, 74000000000000ull, 75000000000000ull, 76000000000000ull, 77000000000000ull, 78000000000000ull, 79000000000000ull, 96000000000000ull, 97000000000000ull, 870000000000000ull, 871000000000000ull, 898000000000000ull, 899000000000000ull, 100000000000000ull, 101000000000000ull, 102000000000000ull, 103000000000000ull, 104000000000000ull, 105000000000000ull, 106000000000000ull, 107000000000000ull, 108000000000000ull, 109000000000000ull, 180000000000000ull, 181000000000000ull, 900000000000000ull, 901000000000000ull, 980000000000000ull, 981000000000000ull, 110000000000000ull, 111000000000000ull, 112000000000000ull, 113000000000000ull, 114000000000000ull, 115000000000000ull, 116000000000000ull, 117000000000000ull, 118000000000000ull, 119000000000000ull, 190000000000000ull, 191000000000000ull, 910000000000000ull, 911000000000000ull, 990000000000000ull, 991000000000000ull, 120000000000000ull, 121000000000000ull, 122000000000000ull, 123000000000000ull, 124000000000000ull, 125000000000000ull, 126000000000000ull, 127000000000000ull, 128000000000000ull, 129000000000000ull, 182000000000000ull, 183000000000000ull, 920000000000000ull, 921000000000000ull, 908000000000000ull, 909000000000000ull, 130000000000000ull, 131000000000000ull, 132000000000000ull, 133000000000000ull, 134000000000000ull, 135000000000000ull, 136000000000000ull, 137000000000000ull, 138000000000000ull, 139000000000000ull, 192000000000000ull, 193000000000000ull, 930000000000000ull, 931000000000000ull, 918000000000000ull, 919000000000000ull, 140000000000000ull, 141000000000000ull, 142000000000000ull, 143000000000000ull, 144000000000000ull, 145000000000000ull, 146000000000000ull, 147000000000000ull, 148000000000000ull, 149000000000000ull, 184000000000000ull, 185000000000000ull, 940000000000000ull, 941000000000000ull, 188000000000000ull, 189000000000000ull, 150000000000000ull, 151000000000000ull, 152000000000000ull, 153000000000000ull, 154000000000000ull, 155000000000000ull, 156000000000000ull, 157000000000000ull, 158000000000000ull, 159000000000000ull, 194000000000000ull, 195000000000000ull, 950000000000000ull, 951000000000000ull, 198000000000000ull, 199000000000000ull, 160000000000000ull, 161000000000000ull, 162000000000000ull, 163000000000000ull, 164000000000000ull, 165000000000000ull, 166000000000000ull, 167000000000000ull, 168000000000000ull, 169000000000000ull, 186000000000000ull, 187000000000000ull, 960000000000000ull, 961000000000000ull, 988000000000000ull, 989000000000000ull, 170000000000000ull, 171000000000000ull, 172000000000000ull, 173000000000000ull, 174000000000000ull, 175000000000000ull, 176000000000000ull, 177000000000000ull, 178000000000000ull, 179000000000000ull, 196000000000000ull, 197000000000000ull, 970000000000000ull, 971000000000000ull, 998000000000000ull, 999000000000000ull, 200000000000000ull, 201000000000000ull, 202000000000000ull, 203000000000000ull, 204000000000000ull, 205000000000000ull, 206000000000000ull, 207000000000000ull, 208000000000000ull, 209000000000000ull, 280000000000000ull, 281000000000000ull, 802000000000000ull, 803000000000000ull, 882000000000000ull, 883000000000000ull, 210000000000000ull, 211000000000000ull, 212000000000000ull, 213000000000000ull, 214000000000000ull, 215000000000000ull, 216000000000000ull, 217000000000000ull, 218000000000000ull, 219000000000000ull, 290000000000000ull, 291000000000000ull, 812000000000000ull, 813000000000000ull, 892000000000000ull, 893000000000000ull, 220000000000000ull, 221000000000000ull, 222000000000000ull, 223000000000000ull, 224000000000000ull, 225000000000000ull, 226000000000000ull, 227000000000000ull, 228000000000000ull, 229000000000000ull, 282000000000000ull, 283000000000000ull, 822000000000000ull, 823000000000000ull, 828000000000000ull, 829000000000000ull, 230000000000000ull, 231000000000000ull, 232000000000000ull, 233000000000000ull, 234000000000000ull, 235000000000000ull, 236000000000000ull, 237000000000000ull, 238000000000000ull, 239000000000000ull, 292000000000000ull, 293000000000000ull, 832000000000000ull, 833000000000000ull, 838000000000000ull, 839000000000000ull, 240000000000000ull, 241000000000000ull, 242000000000000ull, 243000000000000ull, 244000000000000ull, 245000000000000ull, 246000000000000ull, 247000000000000ull, 248000000000000ull, 249000000000000ull, 284000000000000ull, 285000000000000ull, 842000000000000ull, 843000000000000ull, 288000000000000ull, 289000000000000ull, 250000000000000ull, 251000000000000ull, 252000000000000ull, 253000000000000ull, 254000000000000ull, 255000000000000ull, 256000000000000ull, 257000000000000ull, 258000000000000ull, 259000000000000ull, 294000000000000ull, 295000000000000ull, 852000000000000ull, 853000000000000ull, 298000000000000ull, 299000000000000ull, 260000000000000ull, 261000000000000ull, 262000000000000ull, 263000000000000ull, 264000000000000ull, 265000000000000ull, 266000000000000ull, 267000000000000ull, 268000000000000ull, 269000000000000ull, 286000000000000ull, 287000000000000ull, 862000000000000ull, 863000000000000ull, 888000000000000ull, 889000000000000ull, 270000000000000ull, 271000000000000ull, 272000000000000ull, 273000000000000ull, 274000000000000ull, 275000000000000ull, 276000000000000ull, 277000000000000ull, 278000000000000ull, 279000000000000ull, 296000000000000ull, 297000000000000ull, 872000000000000ull, 873000000000000ull, 898000000000000ull, 899000000000000ull, 300000000000000ull, 301000000000000ull, 302000000000000ull, 303000000000000ull, 304000000000000ull, 305000000000000ull, 306000000000000ull, 307000000000000ull, 308000000000000ull, 309000000000000ull, 380000000000000ull, 381000000000000ull, 902000000000000ull, 903000000000000ull, 982000000000000ull, 983000000000000ull, 310000000000000ull, 311000000000000ull, 312000000000000ull, 313000000000000ull, 314000000000000ull, 315000000000000ull, 316000000000000ull, 317000000000000ull, 318000000000000ull, 319000000000000ull, 390000000000000ull, 391000000000000ull, 912000000000000ull, 913000000000000ull, 992000000000000ull, 993000000000000ull, 320000000000000ull, 321000000000000ull, 322000000000000ull, 323000000000000ull, 324000000000000ull, 325000000000000ull, 326000000000000ull, 327000000000000ull, 328000000000000ull, 329000000000000ull, 382000000000000ull, 383000000000000ull, 922000000000000ull, 923000000000000ull, 928000000000000ull, 929000000000000ull, 330000000000000ull, 331000000000000ull, 332000000000000ull, 333000000000000ull, 334000000000000ull, 335000000000000ull, 336000000000000ull, 337000000000000ull, 338000000000000ull, 339000000000000ull, 392000000000000ull, 393000000000000ull, 932000000000000ull, 933000000000000ull, 938000000000000ull, 939000000000000ull, 340000000000000ull, 341000000000000ull, 342000000000000ull, 343000000000000ull, 344000000000000ull, 345000000000000ull, 346000000000000ull, 347000000000000ull, 348000000000000ull, 349000000000000ull, 384000000000000ull, 385000000000000ull, 942000000000000ull, 943000000000000ull, 388000000000000ull, 389000000000000ull, 350000000000000ull, 351000000000000ull, 352000000000000ull, 353000000000000ull, 354000000000000ull, 355000000000000ull, 356000000000000ull, 357000000000000ull, 358000000000000ull, 359000000000000ull, 394000000000000ull, 395000000000000ull, 952000000000000ull, 953000000000000ull, 398000000000000ull, 399000000000000ull, 360000000000000ull, 361000000000000ull, 362000000000000ull, 363000000000000ull, 364000000000000ull, 365000000000000ull, 366000000000000ull, 367000000000000ull, 368000000000000ull, 369000000000000ull, 386000000000000ull, 387000000000000ull, 962000000000000ull, 963000000000000ull, 988000000000000ull, 989000000000000ull, 370000000000000ull, 371000000000000ull, 372000000000000ull, 373000000000000ull, 374000000000000ull, 375000000000000ull, 376000000000000ull, 377000000000000ull, 378000000000000ull, 379000000000000ull, 396000000000000ull, 397000000000000ull, 972000000000000ull, 973000000000000ull, 998000000000000ull, 999000000000000ull, 400000000000000ull, 401000000000000ull, 402000000000000ull, 403000000000000ull, 404000000000000ull, 405000000000000ull, 406000000000000ull, 407000000000000ull, 408000000000000ull, 409000000000000ull, 480000000000000ull, 481000000000000ull, 804000000000000ull, 805000000000000ull, 884000000000000ull, 885000000000000ull, 410000000000000ull, 411000000000000ull, 412000000000000ull, 413000000000000ull, 414000000000000ull, 415000000000000ull, 416000000000000ull, 417000000000000ull, 418000000000000ull, 419000000000000ull, 490000000000000ull, 491000000000000ull, 814000000000000ull, 815000000000000ull, 894000000000000ull, 895000000000000ull, 420000000000000ull, 421000000000000ull, 422000000000000ull, 423000000000000ull, 424000000000000ull, 425000000000000ull, 426000000000000ull, 427000000000000ull, 428000000000000ull, 429000000000000ull, 482000000000000ull, 483000000000000ull, 824000000000000ull, 825000000000000ull, 848000000000000ull, 849000000000000ull, 430000000000000ull, 431000000000000ull, 432000000000000ull, 433000000000000ull, 434000000000000ull, 435000000000000ull, 436000000000000ull, 437000000000000ull, 438000000000000ull, 439000000000000ull, 492000000000000ull, 493000000000000ull, 834000000000000ull, 835000000000000ull, 858000000000000ull, 859000000000000ull, 440000000000000ull, 441000000000000ull, 442000000000000ull, 443000000000000ull, 444000000000000ull, 445000000000000ull, 446000000000000ull, 447000000000000ull, 448000000000000ull, 449000000000000ull, 484000000000000ull, 485000000000000ull, 844000000000000ull, 845000000000000ull, 488000000000000ull, 489000000000000ull, 450000000000000ull, 451000000000000ull, 452000000000000ull, 453000000000000ull, 454000000000000ull, 455000000000000ull, 456000000000000ull, 457000000000000ull, 458000000000000ull, 459000000000000ull, 494000000000000ull, 495000000000000ull, 854000000000000ull, 855000000000000ull, 498000000000000ull, 499000000000000ull, 460000000000000ull, 461000000000000ull, 462000000000000ull, 463000000000000ull, 464000000000000ull, 465000000000000ull, 466000000000000ull, 467000000000000ull, 468000000000000ull, 469000000000000ull, 486000000000000ull, 487000000000000ull, 864000000000000ull, 865000000000000ull, 888000000000000ull, 889000000000000ull, 470000000000000ull, 471000000000000ull, 472000000000000ull, 473000000000000ull, 474000000000000ull, 475000000000000ull, 476000000000000ull, 477000000000000ull, 478000000000000ull, 479000000000000ull, 496000000000000ull, 497000000000000ull, 874000000000000ull, 875000000000000ull, 898000000000000ull, 899000000000000ull, 500000000000000ull, 501000000000000ull, 502000000000000ull, 503000000000000ull, 504000000000000ull, 505000000000000ull, 506000000000000ull, 507000000000000ull, 508000000000000ull, 509000000000000ull, 580000000000000ull, 581000000000000ull, 904000000000000ull, 905000000000000ull, 984000000000000ull, 985000000000000ull, 510000000000000ull, 511000000000000ull, 512000000000000ull, 513000000000000ull, 514000000000000ull, 515000000000000ull, 516000000000000ull, 517000000000000ull, 518000000000000ull, 519000000000000ull, 590000000000000ull, 591000000000000ull, 914000000000000ull, 915000000000000ull, 994000000000000ull, 995000000000000ull, 520000000000000ull, 521000000000000ull, 522000000000000ull, 523000000000000ull, 524000000000000ull, 525000000000000ull, 526000000000000ull, 527000000000000ull, 528000000000000ull, 529000000000000ull, 582000000000000ull, 583000000000000ull, 924000000000000ull, 925000000000000ull, 948000000000000ull, 949000000000000ull, 530000000000000ull, 531000000000000ull, 532000000000000ull, 533000000000000ull, 534000000000000ull, 535000000000000ull, 536000000000000ull, 537000000000000ull, 538000000000000ull, 539000000000000ull, 592000000000000ull, 593000000000000ull, 934000000000000ull, 935000000000000ull, 958000000000000ull, 959000000000000ull, 540000000000000ull, 541000000000000ull, 542000000000000ull, 543000000000000ull, 544000000000000ull, 545000000000000ull, 546000000000000ull, 547000000000000ull, 548000000000000ull, 549000000000000ull, 584000000000000ull, 585000000000000ull, 944000000000000ull, 945000000000000ull, 588000000000000ull, 589000000000000ull, 550000000000000ull, 551000000000000ull, 552000000000000ull, 553000000000000ull, 554000000000000ull, 555000000000000ull, 556000000000000ull, 557000000000000ull, 558000000000000ull, 559000000000000ull, 594000000000000ull, 595000000000000ull, 954000000000000ull, 955000000000000ull, 598000000000000ull, 599000000000000ull, 560000000000000ull, 561000000000000ull, 562000000000000ull, 563000000000000ull, 564000000000000ull, 565000000000000ull, 566000000000000ull, 567000000000000ull, 568000000000000ull, 569000000000000ull, 586000000000000ull, 587000000000000ull, 964000000000000ull, 965000000000000ull, 988000000000000ull, 989000000000000ull, 570000000000000ull, 571000000000000ull, 572000000000000ull, 573000000000000ull, 574000000000000ull, 575000000000000ull, 576000000000000ull, 577000000000000ull, 578000000000000ull, 579000000000000ull, 596000000000000ull, 597000000000000ull, 974000000000000ull, 975000000000000ull, 998000000000000ull, 999000000000000ull, 600000000000000ull, 601000000000000ull, 602000000000000ull, 603000000000000ull, 604000000000000ull, 605000000000000ull, 606000000000000ull, 607000000000000ull, 608000000000000ull, 609000000000000ull, 680000000000000ull, 681000000000000ull, 806000000000000ull, 807000000000000ull, 886000000000000ull, 887000000000000ull, 610000000000000ull, 611000000000000ull, 612000000000000ull, 613000000000000ull, 614000000000000ull, 615000000000000ull, 616000000000000ull, 617000000000000ull, 618000000000000ull, 619000000000000ull, 690000000000000ull, 691000000000000ull, 816000000000000ull, 817000000000000ull, 896000000000000ull, 897000000000000ull, 620000000000000ull, 621000000000000ull, 622000000000000ull, 623000000000000ull, 624000000000000ull, 625000000000000ull, 626000000000000ull, 627000000000000ull, 628000000000000ull, 629000000000000ull, 682000000000000ull, 683000000000000ull, 826000000000000ull, 827000000000000ull, 868000000000000ull, 869000000000000ull, 630000000000000ull, 631000000000000ull, 632000000000000ull, 633000000000000ull, 634000000000000ull, 635000000000000ull, 636000000000000ull, 637000000000000ull, 638000000000000ull, 639000000000000ull, 692000000000000ull, 693000000000000ull, 836000000000000ull, 837000000000000ull, 878000000000000ull, 879000000000000ull, 640000000000000ull, 641000000000000ull, 642000000000000ull, 643000000000000ull, 644000000000000ull, 645000000000000ull, 646000000000000ull, 647000000000000ull, 648000000000000ull, 649000000000000ull, 684000000000000ull, 685000000000000ull, 846000000000000ull, 847000000000000ull, 688000000000000ull, 689000000000000ull, 650000000000000ull, 651000000000000ull, 652000000000000ull, 653000000000000ull, 654000000000000ull, 655000000000000ull, 656000000000000ull, 657000000000000ull, 658000000000000ull, 659000000000000ull, 694000000000000ull, 695000000000000ull, 856000000000000ull, 857000000000000ull, 698000000000000ull, 699000000000000ull, 660000000000000ull, 661000000000000ull, 662000000000000ull, 663000000000000ull, 664000000000000ull, 665000000000000ull, 666000000000000ull, 667000000000000ull, 668000000000000ull, 669000000000000ull, 686000000000000ull, 687000000000000ull, 866000000000000ull, 867000000000000ull, 888000000000000ull, 889000000000000ull, 670000000000000ull, 671000000000000ull, 672000000000000ull, 673000000000000ull, 674000000000000ull, 675000000000000ull, 676000000000000ull, 677000000000000ull, 678000000000000ull, 679000000000000ull, 696000000000000ull, 697000000000000ull, 876000000000000ull, 877000000000000ull, 898000000000000ull, 899000000000000ull, 700000000000000ull, 701000000000000ull, 702000000000000ull, 703000000000000ull, 704000000000000ull, 705000000000000ull, 706000000000000ull, 707000000000000ull, 708000000000000ull, 709000000000000ull, 780000000000000ull, 781000000000000ull, 906000000000000ull, 907000000000000ull, 986000000000000ull, 987000000000000ull, 710000000000000ull, 711000000000000ull, 712000000000000ull, 713000000000000ull, 714000000000000ull, 715000000000000ull, 716000000000000ull, 717000000000000ull, 718000000000000ull, 719000000000000ull, 790000000000000ull, 791000000000000ull, 916000000000000ull, 917000000000000ull, 996000000000000ull, 997000000000000ull, 720000000000000ull, 721000000000000ull, 722000000000000ull, 723000000000000ull, 724000000000000ull, 725000000000000ull, 726000000000000ull, 727000000000000ull, 728000000000000ull, 729000000000000ull, 782000000000000ull, 783000000000000ull, 926000000000000ull, 927000000000000ull, 968000000000000ull, 969000000000000ull, 730000000000000ull, 731000000000000ull, 732000000000000ull, 733000000000000ull, 734000000000000ull, 735000000000000ull, 736000000000000ull, 737000000000000ull, 738000000000000ull, 739000000000000ull, 792000000000000ull, 793000000000000ull, 936000000000000ull, 937000000000000ull, 978000000000000ull, 979000000000000ull, 740000000000000ull, 741000000000000ull, 742000000000000ull, 743000000000000ull, 744000000000000ull, 745000000000000ull, 746000000000000ull, 747000000000000ull, 748000000000000ull, 749000000000000ull, 784000000000000ull, 785000000000000ull, 946000000000000ull, 947000000000000ull, 788000000000000ull, 789000000000000ull, 750000000000000ull, 751000000000000ull, 752000000000000ull, 753000000000000ull, 754000000000000ull, 755000000000000ull, 756000000000000ull, 757000000000000ull, 758000000000000ull, 759000000000000ull, 794000000000000ull, 795000000000000ull, 956000000000000ull, 957000000000000ull, 798000000000000ull, 799000000000000ull, 760000000000000ull, 761000000000000ull, 762000000000000ull, 763000000000000ull, 764000000000000ull, 765000000000000ull, 766000000000000ull, 767000000000000ull, 768000000000000ull, 769000000000000ull, 786000000000000ull, 787000000000000ull, 966000000000000ull, 967000000000000ull, 988000000000000ull, 989000000000000ull, 770000000000000ull, 771000000000000ull, 772000000000000ull, 773000000000000ull, 774000000000000ull, 775000000000000ull, 776000000000000ull, 777000000000000ull, 778000000000000ull, 779000000000000ull, 796000000000000ull, 797000000000000ull, 976000000000000ull, 977000000000000ull, 998000000000000ull, 999000000000000ull }; static const UINT64 d2b6[] = { 0000000000000000ull, 1000000000000000ull, 2000000000000000ull, 3000000000000000ull, 4000000000000000ull, 5000000000000000ull, 6000000000000000ull, 7000000000000000ull, 8000000000000000ull, 9000000000000000ull, 80000000000000000ull, 81000000000000000ull, 800000000000000000ull, 801000000000000000ull, 880000000000000000ull, 881000000000000000ull, 10000000000000000ull, 11000000000000000ull, 12000000000000000ull, 13000000000000000ull, 14000000000000000ull, 15000000000000000ull, 16000000000000000ull, 17000000000000000ull, 18000000000000000ull, 19000000000000000ull, 90000000000000000ull, 91000000000000000ull, 810000000000000000ull, 811000000000000000ull, 890000000000000000ull, 891000000000000000ull, 20000000000000000ull, 21000000000000000ull, 22000000000000000ull, 23000000000000000ull, 24000000000000000ull, 25000000000000000ull, 26000000000000000ull, 27000000000000000ull, 28000000000000000ull, 29000000000000000ull, 82000000000000000ull, 83000000000000000ull, 820000000000000000ull, 821000000000000000ull, 808000000000000000ull, 809000000000000000ull, 30000000000000000ull, 31000000000000000ull, 32000000000000000ull, 33000000000000000ull, 34000000000000000ull, 35000000000000000ull, 36000000000000000ull, 37000000000000000ull, 38000000000000000ull, 39000000000000000ull, 92000000000000000ull, 93000000000000000ull, 830000000000000000ull, 831000000000000000ull, 818000000000000000ull, 819000000000000000ull, 40000000000000000ull, 41000000000000000ull, 42000000000000000ull, 43000000000000000ull, 44000000000000000ull, 45000000000000000ull, 46000000000000000ull, 47000000000000000ull, 48000000000000000ull, 49000000000000000ull, 84000000000000000ull, 85000000000000000ull, 840000000000000000ull, 841000000000000000ull, 88000000000000000ull, 89000000000000000ull, 50000000000000000ull, 51000000000000000ull, 52000000000000000ull, 53000000000000000ull, 54000000000000000ull, 55000000000000000ull, 56000000000000000ull, 57000000000000000ull, 58000000000000000ull, 59000000000000000ull, 94000000000000000ull, 95000000000000000ull, 850000000000000000ull, 851000000000000000ull, 98000000000000000ull, 99000000000000000ull, 60000000000000000ull, 61000000000000000ull, 62000000000000000ull, 63000000000000000ull, 64000000000000000ull, 65000000000000000ull, 66000000000000000ull, 67000000000000000ull, 68000000000000000ull, 69000000000000000ull, 86000000000000000ull, 87000000000000000ull, 860000000000000000ull, 861000000000000000ull, 888000000000000000ull, 889000000000000000ull, 70000000000000000ull, 71000000000000000ull, 72000000000000000ull, 73000000000000000ull, 74000000000000000ull, 75000000000000000ull, 76000000000000000ull, 77000000000000000ull, 78000000000000000ull, 79000000000000000ull, 96000000000000000ull, 97000000000000000ull, 870000000000000000ull, 871000000000000000ull, 898000000000000000ull, 899000000000000000ull, 100000000000000000ull, 101000000000000000ull, 102000000000000000ull, 103000000000000000ull, 104000000000000000ull, 105000000000000000ull, 106000000000000000ull, 107000000000000000ull, 108000000000000000ull, 109000000000000000ull, 180000000000000000ull, 181000000000000000ull, 900000000000000000ull, 901000000000000000ull, 980000000000000000ull, 981000000000000000ull, 110000000000000000ull, 111000000000000000ull, 112000000000000000ull, 113000000000000000ull, 114000000000000000ull, 115000000000000000ull, 116000000000000000ull, 117000000000000000ull, 118000000000000000ull, 119000000000000000ull, 190000000000000000ull, 191000000000000000ull, 910000000000000000ull, 911000000000000000ull, 990000000000000000ull, 991000000000000000ull, 120000000000000000ull, 121000000000000000ull, 122000000000000000ull, 123000000000000000ull, 124000000000000000ull, 125000000000000000ull, 126000000000000000ull, 127000000000000000ull, 128000000000000000ull, 129000000000000000ull, 182000000000000000ull, 183000000000000000ull, 920000000000000000ull, 921000000000000000ull, 908000000000000000ull, 909000000000000000ull, 130000000000000000ull, 131000000000000000ull, 132000000000000000ull, 133000000000000000ull, 134000000000000000ull, 135000000000000000ull, 136000000000000000ull, 137000000000000000ull, 138000000000000000ull, 139000000000000000ull, 192000000000000000ull, 193000000000000000ull, 930000000000000000ull, 931000000000000000ull, 918000000000000000ull, 919000000000000000ull, 140000000000000000ull, 141000000000000000ull, 142000000000000000ull, 143000000000000000ull, 144000000000000000ull, 145000000000000000ull, 146000000000000000ull, 147000000000000000ull, 148000000000000000ull, 149000000000000000ull, 184000000000000000ull, 185000000000000000ull, 940000000000000000ull, 941000000000000000ull, 188000000000000000ull, 189000000000000000ull, 150000000000000000ull, 151000000000000000ull, 152000000000000000ull, 153000000000000000ull, 154000000000000000ull, 155000000000000000ull, 156000000000000000ull, 157000000000000000ull, 158000000000000000ull, 159000000000000000ull, 194000000000000000ull, 195000000000000000ull, 950000000000000000ull, 951000000000000000ull, 198000000000000000ull, 199000000000000000ull, 160000000000000000ull, 161000000000000000ull, 162000000000000000ull, 163000000000000000ull, 164000000000000000ull, 165000000000000000ull, 166000000000000000ull, 167000000000000000ull, 168000000000000000ull, 169000000000000000ull, 186000000000000000ull, 187000000000000000ull, 960000000000000000ull, 961000000000000000ull, 988000000000000000ull, 989000000000000000ull, 170000000000000000ull, 171000000000000000ull, 172000000000000000ull, 173000000000000000ull, 174000000000000000ull, 175000000000000000ull, 176000000000000000ull, 177000000000000000ull, 178000000000000000ull, 179000000000000000ull, 196000000000000000ull, 197000000000000000ull, 970000000000000000ull, 971000000000000000ull, 998000000000000000ull, 999000000000000000ull, 200000000000000000ull, 201000000000000000ull, 202000000000000000ull, 203000000000000000ull, 204000000000000000ull, 205000000000000000ull, 206000000000000000ull, 207000000000000000ull, 208000000000000000ull, 209000000000000000ull, 280000000000000000ull, 281000000000000000ull, 802000000000000000ull, 803000000000000000ull, 882000000000000000ull, 883000000000000000ull, 210000000000000000ull, 211000000000000000ull, 212000000000000000ull, 213000000000000000ull, 214000000000000000ull, 215000000000000000ull, 216000000000000000ull, 217000000000000000ull, 218000000000000000ull, 219000000000000000ull, 290000000000000000ull, 291000000000000000ull, 812000000000000000ull, 813000000000000000ull, 892000000000000000ull, 893000000000000000ull, 220000000000000000ull, 221000000000000000ull, 222000000000000000ull, 223000000000000000ull, 224000000000000000ull, 225000000000000000ull, 226000000000000000ull, 227000000000000000ull, 228000000000000000ull, 229000000000000000ull, 282000000000000000ull, 283000000000000000ull, 822000000000000000ull, 823000000000000000ull, 828000000000000000ull, 829000000000000000ull, 230000000000000000ull, 231000000000000000ull, 232000000000000000ull, 233000000000000000ull, 234000000000000000ull, 235000000000000000ull, 236000000000000000ull, 237000000000000000ull, 238000000000000000ull, 239000000000000000ull, 292000000000000000ull, 293000000000000000ull, 832000000000000000ull, 833000000000000000ull, 838000000000000000ull, 839000000000000000ull, 240000000000000000ull, 241000000000000000ull, 242000000000000000ull, 243000000000000000ull, 244000000000000000ull, 245000000000000000ull, 246000000000000000ull, 247000000000000000ull, 248000000000000000ull, 249000000000000000ull, 284000000000000000ull, 285000000000000000ull, 842000000000000000ull, 843000000000000000ull, 288000000000000000ull, 289000000000000000ull, 250000000000000000ull, 251000000000000000ull, 252000000000000000ull, 253000000000000000ull, 254000000000000000ull, 255000000000000000ull, 256000000000000000ull, 257000000000000000ull, 258000000000000000ull, 259000000000000000ull, 294000000000000000ull, 295000000000000000ull, 852000000000000000ull, 853000000000000000ull, 298000000000000000ull, 299000000000000000ull, 260000000000000000ull, 261000000000000000ull, 262000000000000000ull, 263000000000000000ull, 264000000000000000ull, 265000000000000000ull, 266000000000000000ull, 267000000000000000ull, 268000000000000000ull, 269000000000000000ull, 286000000000000000ull, 287000000000000000ull, 862000000000000000ull, 863000000000000000ull, 888000000000000000ull, 889000000000000000ull, 270000000000000000ull, 271000000000000000ull, 272000000000000000ull, 273000000000000000ull, 274000000000000000ull, 275000000000000000ull, 276000000000000000ull, 277000000000000000ull, 278000000000000000ull, 279000000000000000ull, 296000000000000000ull, 297000000000000000ull, 872000000000000000ull, 873000000000000000ull, 898000000000000000ull, 899000000000000000ull, 300000000000000000ull, 301000000000000000ull, 302000000000000000ull, 303000000000000000ull, 304000000000000000ull, 305000000000000000ull, 306000000000000000ull, 307000000000000000ull, 308000000000000000ull, 309000000000000000ull, 380000000000000000ull, 381000000000000000ull, 902000000000000000ull, 903000000000000000ull, 982000000000000000ull, 983000000000000000ull, 310000000000000000ull, 311000000000000000ull, 312000000000000000ull, 313000000000000000ull, 314000000000000000ull, 315000000000000000ull, 316000000000000000ull, 317000000000000000ull, 318000000000000000ull, 319000000000000000ull, 390000000000000000ull, 391000000000000000ull, 912000000000000000ull, 913000000000000000ull, 992000000000000000ull, 993000000000000000ull, 320000000000000000ull, 321000000000000000ull, 322000000000000000ull, 323000000000000000ull, 324000000000000000ull, 325000000000000000ull, 326000000000000000ull, 327000000000000000ull, 328000000000000000ull, 329000000000000000ull, 382000000000000000ull, 383000000000000000ull, 922000000000000000ull, 923000000000000000ull, 928000000000000000ull, 929000000000000000ull, 330000000000000000ull, 331000000000000000ull, 332000000000000000ull, 333000000000000000ull, 334000000000000000ull, 335000000000000000ull, 336000000000000000ull, 337000000000000000ull, 338000000000000000ull, 339000000000000000ull, 392000000000000000ull, 393000000000000000ull, 932000000000000000ull, 933000000000000000ull, 938000000000000000ull, 939000000000000000ull, 340000000000000000ull, 341000000000000000ull, 342000000000000000ull, 343000000000000000ull, 344000000000000000ull, 345000000000000000ull, 346000000000000000ull, 347000000000000000ull, 348000000000000000ull, 349000000000000000ull, 384000000000000000ull, 385000000000000000ull, 942000000000000000ull, 943000000000000000ull, 388000000000000000ull, 389000000000000000ull, 350000000000000000ull, 351000000000000000ull, 352000000000000000ull, 353000000000000000ull, 354000000000000000ull, 355000000000000000ull, 356000000000000000ull, 357000000000000000ull, 358000000000000000ull, 359000000000000000ull, 394000000000000000ull, 395000000000000000ull, 952000000000000000ull, 953000000000000000ull, 398000000000000000ull, 399000000000000000ull, 360000000000000000ull, 361000000000000000ull, 362000000000000000ull, 363000000000000000ull, 364000000000000000ull, 365000000000000000ull, 366000000000000000ull, 367000000000000000ull, 368000000000000000ull, 369000000000000000ull, 386000000000000000ull, 387000000000000000ull, 962000000000000000ull, 963000000000000000ull, 988000000000000000ull, 989000000000000000ull, 370000000000000000ull, 371000000000000000ull, 372000000000000000ull, 373000000000000000ull, 374000000000000000ull, 375000000000000000ull, 376000000000000000ull, 377000000000000000ull, 378000000000000000ull, 379000000000000000ull, 396000000000000000ull, 397000000000000000ull, 972000000000000000ull, 973000000000000000ull, 998000000000000000ull, 999000000000000000ull, 400000000000000000ull, 401000000000000000ull, 402000000000000000ull, 403000000000000000ull, 404000000000000000ull, 405000000000000000ull, 406000000000000000ull, 407000000000000000ull, 408000000000000000ull, 409000000000000000ull, 480000000000000000ull, 481000000000000000ull, 804000000000000000ull, 805000000000000000ull, 884000000000000000ull, 885000000000000000ull, 410000000000000000ull, 411000000000000000ull, 412000000000000000ull, 413000000000000000ull, 414000000000000000ull, 415000000000000000ull, 416000000000000000ull, 417000000000000000ull, 418000000000000000ull, 419000000000000000ull, 490000000000000000ull, 491000000000000000ull, 814000000000000000ull, 815000000000000000ull, 894000000000000000ull, 895000000000000000ull, 420000000000000000ull, 421000000000000000ull, 422000000000000000ull, 423000000000000000ull, 424000000000000000ull, 425000000000000000ull, 426000000000000000ull, 427000000000000000ull, 428000000000000000ull, 429000000000000000ull, 482000000000000000ull, 483000000000000000ull, 824000000000000000ull, 825000000000000000ull, 848000000000000000ull, 849000000000000000ull, 430000000000000000ull, 431000000000000000ull, 432000000000000000ull, 433000000000000000ull, 434000000000000000ull, 435000000000000000ull, 436000000000000000ull, 437000000000000000ull, 438000000000000000ull, 439000000000000000ull, 492000000000000000ull, 493000000000000000ull, 834000000000000000ull, 835000000000000000ull, 858000000000000000ull, 859000000000000000ull, 440000000000000000ull, 441000000000000000ull, 442000000000000000ull, 443000000000000000ull, 444000000000000000ull, 445000000000000000ull, 446000000000000000ull, 447000000000000000ull, 448000000000000000ull, 449000000000000000ull, 484000000000000000ull, 485000000000000000ull, 844000000000000000ull, 845000000000000000ull, 488000000000000000ull, 489000000000000000ull, 450000000000000000ull, 451000000000000000ull, 452000000000000000ull, 453000000000000000ull, 454000000000000000ull, 455000000000000000ull, 456000000000000000ull, 457000000000000000ull, 458000000000000000ull, 459000000000000000ull, 494000000000000000ull, 495000000000000000ull, 854000000000000000ull, 855000000000000000ull, 498000000000000000ull, 499000000000000000ull, 460000000000000000ull, 461000000000000000ull, 462000000000000000ull, 463000000000000000ull, 464000000000000000ull, 465000000000000000ull, 466000000000000000ull, 467000000000000000ull, 468000000000000000ull, 469000000000000000ull, 486000000000000000ull, 487000000000000000ull, 864000000000000000ull, 865000000000000000ull, 888000000000000000ull, 889000000000000000ull, 470000000000000000ull, 471000000000000000ull, 472000000000000000ull, 473000000000000000ull, 474000000000000000ull, 475000000000000000ull, 476000000000000000ull, 477000000000000000ull, 478000000000000000ull, 479000000000000000ull, 496000000000000000ull, 497000000000000000ull, 874000000000000000ull, 875000000000000000ull, 898000000000000000ull, 899000000000000000ull, 500000000000000000ull, 501000000000000000ull, 502000000000000000ull, 503000000000000000ull, 504000000000000000ull, 505000000000000000ull, 506000000000000000ull, 507000000000000000ull, 508000000000000000ull, 509000000000000000ull, 580000000000000000ull, 581000000000000000ull, 904000000000000000ull, 905000000000000000ull, 984000000000000000ull, 985000000000000000ull, 510000000000000000ull, 511000000000000000ull, 512000000000000000ull, 513000000000000000ull, 514000000000000000ull, 515000000000000000ull, 516000000000000000ull, 517000000000000000ull, 518000000000000000ull, 519000000000000000ull, 590000000000000000ull, 591000000000000000ull, 914000000000000000ull, 915000000000000000ull, 994000000000000000ull, 995000000000000000ull, 520000000000000000ull, 521000000000000000ull, 522000000000000000ull, 523000000000000000ull, 524000000000000000ull, 525000000000000000ull, 526000000000000000ull, 527000000000000000ull, 528000000000000000ull, 529000000000000000ull, 582000000000000000ull, 583000000000000000ull, 924000000000000000ull, 925000000000000000ull, 948000000000000000ull, 949000000000000000ull, 530000000000000000ull, 531000000000000000ull, 532000000000000000ull, 533000000000000000ull, 534000000000000000ull, 535000000000000000ull, 536000000000000000ull, 537000000000000000ull, 538000000000000000ull, 539000000000000000ull, 592000000000000000ull, 593000000000000000ull, 934000000000000000ull, 935000000000000000ull, 958000000000000000ull, 959000000000000000ull, 540000000000000000ull, 541000000000000000ull, 542000000000000000ull, 543000000000000000ull, 544000000000000000ull, 545000000000000000ull, 546000000000000000ull, 547000000000000000ull, 548000000000000000ull, 549000000000000000ull, 584000000000000000ull, 585000000000000000ull, 944000000000000000ull, 945000000000000000ull, 588000000000000000ull, 589000000000000000ull, 550000000000000000ull, 551000000000000000ull, 552000000000000000ull, 553000000000000000ull, 554000000000000000ull, 555000000000000000ull, 556000000000000000ull, 557000000000000000ull, 558000000000000000ull, 559000000000000000ull, 594000000000000000ull, 595000000000000000ull, 954000000000000000ull, 955000000000000000ull, 598000000000000000ull, 599000000000000000ull, 560000000000000000ull, 561000000000000000ull, 562000000000000000ull, 563000000000000000ull, 564000000000000000ull, 565000000000000000ull, 566000000000000000ull, 567000000000000000ull, 568000000000000000ull, 569000000000000000ull, 586000000000000000ull, 587000000000000000ull, 964000000000000000ull, 965000000000000000ull, 988000000000000000ull, 989000000000000000ull, 570000000000000000ull, 571000000000000000ull, 572000000000000000ull, 573000000000000000ull, 574000000000000000ull, 575000000000000000ull, 576000000000000000ull, 577000000000000000ull, 578000000000000000ull, 579000000000000000ull, 596000000000000000ull, 597000000000000000ull, 974000000000000000ull, 975000000000000000ull, 998000000000000000ull, 999000000000000000ull, 600000000000000000ull, 601000000000000000ull, 602000000000000000ull, 603000000000000000ull, 604000000000000000ull, 605000000000000000ull, 606000000000000000ull, 607000000000000000ull, 608000000000000000ull, 609000000000000000ull, 680000000000000000ull, 681000000000000000ull, 806000000000000000ull, 807000000000000000ull, 886000000000000000ull, 887000000000000000ull, 610000000000000000ull, 611000000000000000ull, 612000000000000000ull, 613000000000000000ull, 614000000000000000ull, 615000000000000000ull, 616000000000000000ull, 617000000000000000ull, 618000000000000000ull, 619000000000000000ull, 690000000000000000ull, 691000000000000000ull, 816000000000000000ull, 817000000000000000ull, 896000000000000000ull, 897000000000000000ull, 620000000000000000ull, 621000000000000000ull, 622000000000000000ull, 623000000000000000ull, 624000000000000000ull, 625000000000000000ull, 626000000000000000ull, 627000000000000000ull, 628000000000000000ull, 629000000000000000ull, 682000000000000000ull, 683000000000000000ull, 826000000000000000ull, 827000000000000000ull, 868000000000000000ull, 869000000000000000ull, 630000000000000000ull, 631000000000000000ull, 632000000000000000ull, 633000000000000000ull, 634000000000000000ull, 635000000000000000ull, 636000000000000000ull, 637000000000000000ull, 638000000000000000ull, 639000000000000000ull, 692000000000000000ull, 693000000000000000ull, 836000000000000000ull, 837000000000000000ull, 878000000000000000ull, 879000000000000000ull, 640000000000000000ull, 641000000000000000ull, 642000000000000000ull, 643000000000000000ull, 644000000000000000ull, 645000000000000000ull, 646000000000000000ull, 647000000000000000ull, 648000000000000000ull, 649000000000000000ull, 684000000000000000ull, 685000000000000000ull, 846000000000000000ull, 847000000000000000ull, 688000000000000000ull, 689000000000000000ull, 650000000000000000ull, 651000000000000000ull, 652000000000000000ull, 653000000000000000ull, 654000000000000000ull, 655000000000000000ull, 656000000000000000ull, 657000000000000000ull, 658000000000000000ull, 659000000000000000ull, 694000000000000000ull, 695000000000000000ull, 856000000000000000ull, 857000000000000000ull, 698000000000000000ull, 699000000000000000ull, 660000000000000000ull, 661000000000000000ull, 662000000000000000ull, 663000000000000000ull, 664000000000000000ull, 665000000000000000ull, 666000000000000000ull, 667000000000000000ull, 668000000000000000ull, 669000000000000000ull, 686000000000000000ull, 687000000000000000ull, 866000000000000000ull, 867000000000000000ull, 888000000000000000ull, 889000000000000000ull, 670000000000000000ull, 671000000000000000ull, 672000000000000000ull, 673000000000000000ull, 674000000000000000ull, 675000000000000000ull, 676000000000000000ull, 677000000000000000ull, 678000000000000000ull, 679000000000000000ull, 696000000000000000ull, 697000000000000000ull, 876000000000000000ull, 877000000000000000ull, 898000000000000000ull, 899000000000000000ull, 700000000000000000ull, 701000000000000000ull, 702000000000000000ull, 703000000000000000ull, 704000000000000000ull, 705000000000000000ull, 706000000000000000ull, 707000000000000000ull, 708000000000000000ull, 709000000000000000ull, 780000000000000000ull, 781000000000000000ull, 906000000000000000ull, 907000000000000000ull, 986000000000000000ull, 987000000000000000ull, 710000000000000000ull, 711000000000000000ull, 712000000000000000ull, 713000000000000000ull, 714000000000000000ull, 715000000000000000ull, 716000000000000000ull, 717000000000000000ull, 718000000000000000ull, 719000000000000000ull, 790000000000000000ull, 791000000000000000ull, 916000000000000000ull, 917000000000000000ull, 996000000000000000ull, 997000000000000000ull, 720000000000000000ull, 721000000000000000ull, 722000000000000000ull, 723000000000000000ull, 724000000000000000ull, 725000000000000000ull, 726000000000000000ull, 727000000000000000ull, 728000000000000000ull, 729000000000000000ull, 782000000000000000ull, 783000000000000000ull, 926000000000000000ull, 927000000000000000ull, 968000000000000000ull, 969000000000000000ull, 730000000000000000ull, 731000000000000000ull, 732000000000000000ull, 733000000000000000ull, 734000000000000000ull, 735000000000000000ull, 736000000000000000ull, 737000000000000000ull, 738000000000000000ull, 739000000000000000ull, 792000000000000000ull, 793000000000000000ull, 936000000000000000ull, 937000000000000000ull, 978000000000000000ull, 979000000000000000ull, 740000000000000000ull, 741000000000000000ull, 742000000000000000ull, 743000000000000000ull, 744000000000000000ull, 745000000000000000ull, 746000000000000000ull, 747000000000000000ull, 748000000000000000ull, 749000000000000000ull, 784000000000000000ull, 785000000000000000ull, 946000000000000000ull, 947000000000000000ull, 788000000000000000ull, 789000000000000000ull, 750000000000000000ull, 751000000000000000ull, 752000000000000000ull, 753000000000000000ull, 754000000000000000ull, 755000000000000000ull, 756000000000000000ull, 757000000000000000ull, 758000000000000000ull, 759000000000000000ull, 794000000000000000ull, 795000000000000000ull, 956000000000000000ull, 957000000000000000ull, 798000000000000000ull, 799000000000000000ull, 760000000000000000ull, 761000000000000000ull, 762000000000000000ull, 763000000000000000ull, 764000000000000000ull, 765000000000000000ull, 766000000000000000ull, 767000000000000000ull, 768000000000000000ull, 769000000000000000ull, 786000000000000000ull, 787000000000000000ull, 966000000000000000ull, 967000000000000000ull, 988000000000000000ull, 989000000000000000ull, 770000000000000000ull, 771000000000000000ull, 772000000000000000ull, 773000000000000000ull, 774000000000000000ull, 775000000000000000ull, 776000000000000000ull, 777000000000000000ull, 778000000000000000ull, 779000000000000000ull, 796000000000000000ull, 797000000000000000ull, 976000000000000000ull, 977000000000000000ull, 998000000000000000ull, 999000000000000000ull }; static const UINT64 b2d[] = { 0x000ull, 0x001ull, 0x002ull, 0x003ull, 0x004ull, 0x005ull, 0x006ull, 0x007ull, 0x008ull, 0x009ull, 0x010ull, 0x011ull, 0x012ull, 0x013ull, 0x014ull, 0x015ull, 0x016ull, 0x017ull, 0x018ull, 0x019ull, 0x020ull, 0x021ull, 0x022ull, 0x023ull, 0x024ull, 0x025ull, 0x026ull, 0x027ull, 0x028ull, 0x029ull, 0x030ull, 0x031ull, 0x032ull, 0x033ull, 0x034ull, 0x035ull, 0x036ull, 0x037ull, 0x038ull, 0x039ull, 0x040ull, 0x041ull, 0x042ull, 0x043ull, 0x044ull, 0x045ull, 0x046ull, 0x047ull, 0x048ull, 0x049ull, 0x050ull, 0x051ull, 0x052ull, 0x053ull, 0x054ull, 0x055ull, 0x056ull, 0x057ull, 0x058ull, 0x059ull, 0x060ull, 0x061ull, 0x062ull, 0x063ull, 0x064ull, 0x065ull, 0x066ull, 0x067ull, 0x068ull, 0x069ull, 0x070ull, 0x071ull, 0x072ull, 0x073ull, 0x074ull, 0x075ull, 0x076ull, 0x077ull, 0x078ull, 0x079ull, 0x00aull, 0x00bull, 0x02aull, 0x02bull, 0x04aull, 0x04bull, 0x06aull, 0x06bull, 0x04eull, 0x04full, 0x01aull, 0x01bull, 0x03aull, 0x03bull, 0x05aull, 0x05bull, 0x07aull, 0x07bull, 0x05eull, 0x05full, 0x080ull, 0x081ull, 0x082ull, 0x083ull, 0x084ull, 0x085ull, 0x086ull, 0x087ull, 0x088ull, 0x089ull, 0x090ull, 0x091ull, 0x092ull, 0x093ull, 0x094ull, 0x095ull, 0x096ull, 0x097ull, 0x098ull, 0x099ull, 0x0a0ull, 0x0a1ull, 0x0a2ull, 0x0a3ull, 0x0a4ull, 0x0a5ull, 0x0a6ull, 0x0a7ull, 0x0a8ull, 0x0a9ull, 0x0b0ull, 0x0b1ull, 0x0b2ull, 0x0b3ull, 0x0b4ull, 0x0b5ull, 0x0b6ull, 0x0b7ull, 0x0b8ull, 0x0b9ull, 0x0c0ull, 0x0c1ull, 0x0c2ull, 0x0c3ull, 0x0c4ull, 0x0c5ull, 0x0c6ull, 0x0c7ull, 0x0c8ull, 0x0c9ull, 0x0d0ull, 0x0d1ull, 0x0d2ull, 0x0d3ull, 0x0d4ull, 0x0d5ull, 0x0d6ull, 0x0d7ull, 0x0d8ull, 0x0d9ull, 0x0e0ull, 0x0e1ull, 0x0e2ull, 0x0e3ull, 0x0e4ull, 0x0e5ull, 0x0e6ull, 0x0e7ull, 0x0e8ull, 0x0e9ull, 0x0f0ull, 0x0f1ull, 0x0f2ull, 0x0f3ull, 0x0f4ull, 0x0f5ull, 0x0f6ull, 0x0f7ull, 0x0f8ull, 0x0f9ull, 0x08aull, 0x08bull, 0x0aaull, 0x0abull, 0x0caull, 0x0cbull, 0x0eaull, 0x0ebull, 0x0ceull, 0x0cfull, 0x09aull, 0x09bull, 0x0baull, 0x0bbull, 0x0daull, 0x0dbull, 0x0faull, 0x0fbull, 0x0deull, 0x0dfull, 0x100ull, 0x101ull, 0x102ull, 0x103ull, 0x104ull, 0x105ull, 0x106ull, 0x107ull, 0x108ull, 0x109ull, 0x110ull, 0x111ull, 0x112ull, 0x113ull, 0x114ull, 0x115ull, 0x116ull, 0x117ull, 0x118ull, 0x119ull, 0x120ull, 0x121ull, 0x122ull, 0x123ull, 0x124ull, 0x125ull, 0x126ull, 0x127ull, 0x128ull, 0x129ull, 0x130ull, 0x131ull, 0x132ull, 0x133ull, 0x134ull, 0x135ull, 0x136ull, 0x137ull, 0x138ull, 0x139ull, 0x140ull, 0x141ull, 0x142ull, 0x143ull, 0x144ull, 0x145ull, 0x146ull, 0x147ull, 0x148ull, 0x149ull, 0x150ull, 0x151ull, 0x152ull, 0x153ull, 0x154ull, 0x155ull, 0x156ull, 0x157ull, 0x158ull, 0x159ull, 0x160ull, 0x161ull, 0x162ull, 0x163ull, 0x164ull, 0x165ull, 0x166ull, 0x167ull, 0x168ull, 0x169ull, 0x170ull, 0x171ull, 0x172ull, 0x173ull, 0x174ull, 0x175ull, 0x176ull, 0x177ull, 0x178ull, 0x179ull, 0x10aull, 0x10bull, 0x12aull, 0x12bull, 0x14aull, 0x14bull, 0x16aull, 0x16bull, 0x14eull, 0x14full, 0x11aull, 0x11bull, 0x13aull, 0x13bull, 0x15aull, 0x15bull, 0x17aull, 0x17bull, 0x15eull, 0x15full, 0x180ull, 0x181ull, 0x182ull, 0x183ull, 0x184ull, 0x185ull, 0x186ull, 0x187ull, 0x188ull, 0x189ull, 0x190ull, 0x191ull, 0x192ull, 0x193ull, 0x194ull, 0x195ull, 0x196ull, 0x197ull, 0x198ull, 0x199ull, 0x1a0ull, 0x1a1ull, 0x1a2ull, 0x1a3ull, 0x1a4ull, 0x1a5ull, 0x1a6ull, 0x1a7ull, 0x1a8ull, 0x1a9ull, 0x1b0ull, 0x1b1ull, 0x1b2ull, 0x1b3ull, 0x1b4ull, 0x1b5ull, 0x1b6ull, 0x1b7ull, 0x1b8ull, 0x1b9ull, 0x1c0ull, 0x1c1ull, 0x1c2ull, 0x1c3ull, 0x1c4ull, 0x1c5ull, 0x1c6ull, 0x1c7ull, 0x1c8ull, 0x1c9ull, 0x1d0ull, 0x1d1ull, 0x1d2ull, 0x1d3ull, 0x1d4ull, 0x1d5ull, 0x1d6ull, 0x1d7ull, 0x1d8ull, 0x1d9ull, 0x1e0ull, 0x1e1ull, 0x1e2ull, 0x1e3ull, 0x1e4ull, 0x1e5ull, 0x1e6ull, 0x1e7ull, 0x1e8ull, 0x1e9ull, 0x1f0ull, 0x1f1ull, 0x1f2ull, 0x1f3ull, 0x1f4ull, 0x1f5ull, 0x1f6ull, 0x1f7ull, 0x1f8ull, 0x1f9ull, 0x18aull, 0x18bull, 0x1aaull, 0x1abull, 0x1caull, 0x1cbull, 0x1eaull, 0x1ebull, 0x1ceull, 0x1cfull, 0x19aull, 0x19bull, 0x1baull, 0x1bbull, 0x1daull, 0x1dbull, 0x1faull, 0x1fbull, 0x1deull, 0x1dfull, 0x200ull, 0x201ull, 0x202ull, 0x203ull, 0x204ull, 0x205ull, 0x206ull, 0x207ull, 0x208ull, 0x209ull, 0x210ull, 0x211ull, 0x212ull, 0x213ull, 0x214ull, 0x215ull, 0x216ull, 0x217ull, 0x218ull, 0x219ull, 0x220ull, 0x221ull, 0x222ull, 0x223ull, 0x224ull, 0x225ull, 0x226ull, 0x227ull, 0x228ull, 0x229ull, 0x230ull, 0x231ull, 0x232ull, 0x233ull, 0x234ull, 0x235ull, 0x236ull, 0x237ull, 0x238ull, 0x239ull, 0x240ull, 0x241ull, 0x242ull, 0x243ull, 0x244ull, 0x245ull, 0x246ull, 0x247ull, 0x248ull, 0x249ull, 0x250ull, 0x251ull, 0x252ull, 0x253ull, 0x254ull, 0x255ull, 0x256ull, 0x257ull, 0x258ull, 0x259ull, 0x260ull, 0x261ull, 0x262ull, 0x263ull, 0x264ull, 0x265ull, 0x266ull, 0x267ull, 0x268ull, 0x269ull, 0x270ull, 0x271ull, 0x272ull, 0x273ull, 0x274ull, 0x275ull, 0x276ull, 0x277ull, 0x278ull, 0x279ull, 0x20aull, 0x20bull, 0x22aull, 0x22bull, 0x24aull, 0x24bull, 0x26aull, 0x26bull, 0x24eull, 0x24full, 0x21aull, 0x21bull, 0x23aull, 0x23bull, 0x25aull, 0x25bull, 0x27aull, 0x27bull, 0x25eull, 0x25full, 0x280ull, 0x281ull, 0x282ull, 0x283ull, 0x284ull, 0x285ull, 0x286ull, 0x287ull, 0x288ull, 0x289ull, 0x290ull, 0x291ull, 0x292ull, 0x293ull, 0x294ull, 0x295ull, 0x296ull, 0x297ull, 0x298ull, 0x299ull, 0x2a0ull, 0x2a1ull, 0x2a2ull, 0x2a3ull, 0x2a4ull, 0x2a5ull, 0x2a6ull, 0x2a7ull, 0x2a8ull, 0x2a9ull, 0x2b0ull, 0x2b1ull, 0x2b2ull, 0x2b3ull, 0x2b4ull, 0x2b5ull, 0x2b6ull, 0x2b7ull, 0x2b8ull, 0x2b9ull, 0x2c0ull, 0x2c1ull, 0x2c2ull, 0x2c3ull, 0x2c4ull, 0x2c5ull, 0x2c6ull, 0x2c7ull, 0x2c8ull, 0x2c9ull, 0x2d0ull, 0x2d1ull, 0x2d2ull, 0x2d3ull, 0x2d4ull, 0x2d5ull, 0x2d6ull, 0x2d7ull, 0x2d8ull, 0x2d9ull, 0x2e0ull, 0x2e1ull, 0x2e2ull, 0x2e3ull, 0x2e4ull, 0x2e5ull, 0x2e6ull, 0x2e7ull, 0x2e8ull, 0x2e9ull, 0x2f0ull, 0x2f1ull, 0x2f2ull, 0x2f3ull, 0x2f4ull, 0x2f5ull, 0x2f6ull, 0x2f7ull, 0x2f8ull, 0x2f9ull, 0x28aull, 0x28bull, 0x2aaull, 0x2abull, 0x2caull, 0x2cbull, 0x2eaull, 0x2ebull, 0x2ceull, 0x2cfull, 0x29aull, 0x29bull, 0x2baull, 0x2bbull, 0x2daull, 0x2dbull, 0x2faull, 0x2fbull, 0x2deull, 0x2dfull, 0x300ull, 0x301ull, 0x302ull, 0x303ull, 0x304ull, 0x305ull, 0x306ull, 0x307ull, 0x308ull, 0x309ull, 0x310ull, 0x311ull, 0x312ull, 0x313ull, 0x314ull, 0x315ull, 0x316ull, 0x317ull, 0x318ull, 0x319ull, 0x320ull, 0x321ull, 0x322ull, 0x323ull, 0x324ull, 0x325ull, 0x326ull, 0x327ull, 0x328ull, 0x329ull, 0x330ull, 0x331ull, 0x332ull, 0x333ull, 0x334ull, 0x335ull, 0x336ull, 0x337ull, 0x338ull, 0x339ull, 0x340ull, 0x341ull, 0x342ull, 0x343ull, 0x344ull, 0x345ull, 0x346ull, 0x347ull, 0x348ull, 0x349ull, 0x350ull, 0x351ull, 0x352ull, 0x353ull, 0x354ull, 0x355ull, 0x356ull, 0x357ull, 0x358ull, 0x359ull, 0x360ull, 0x361ull, 0x362ull, 0x363ull, 0x364ull, 0x365ull, 0x366ull, 0x367ull, 0x368ull, 0x369ull, 0x370ull, 0x371ull, 0x372ull, 0x373ull, 0x374ull, 0x375ull, 0x376ull, 0x377ull, 0x378ull, 0x379ull, 0x30aull, 0x30bull, 0x32aull, 0x32bull, 0x34aull, 0x34bull, 0x36aull, 0x36bull, 0x34eull, 0x34full, 0x31aull, 0x31bull, 0x33aull, 0x33bull, 0x35aull, 0x35bull, 0x37aull, 0x37bull, 0x35eull, 0x35full, 0x380ull, 0x381ull, 0x382ull, 0x383ull, 0x384ull, 0x385ull, 0x386ull, 0x387ull, 0x388ull, 0x389ull, 0x390ull, 0x391ull, 0x392ull, 0x393ull, 0x394ull, 0x395ull, 0x396ull, 0x397ull, 0x398ull, 0x399ull, 0x3a0ull, 0x3a1ull, 0x3a2ull, 0x3a3ull, 0x3a4ull, 0x3a5ull, 0x3a6ull, 0x3a7ull, 0x3a8ull, 0x3a9ull, 0x3b0ull, 0x3b1ull, 0x3b2ull, 0x3b3ull, 0x3b4ull, 0x3b5ull, 0x3b6ull, 0x3b7ull, 0x3b8ull, 0x3b9ull, 0x3c0ull, 0x3c1ull, 0x3c2ull, 0x3c3ull, 0x3c4ull, 0x3c5ull, 0x3c6ull, 0x3c7ull, 0x3c8ull, 0x3c9ull, 0x3d0ull, 0x3d1ull, 0x3d2ull, 0x3d3ull, 0x3d4ull, 0x3d5ull, 0x3d6ull, 0x3d7ull, 0x3d8ull, 0x3d9ull, 0x3e0ull, 0x3e1ull, 0x3e2ull, 0x3e3ull, 0x3e4ull, 0x3e5ull, 0x3e6ull, 0x3e7ull, 0x3e8ull, 0x3e9ull, 0x3f0ull, 0x3f1ull, 0x3f2ull, 0x3f3ull, 0x3f4ull, 0x3f5ull, 0x3f6ull, 0x3f7ull, 0x3f8ull, 0x3f9ull, 0x38aull, 0x38bull, 0x3aaull, 0x3abull, 0x3caull, 0x3cbull, 0x3eaull, 0x3ebull, 0x3ceull, 0x3cfull, 0x39aull, 0x39bull, 0x3baull, 0x3bbull, 0x3daull, 0x3dbull, 0x3faull, 0x3fbull, 0x3deull, 0x3dfull, 0x00cull, 0x00dull, 0x10cull, 0x10dull, 0x20cull, 0x20dull, 0x30cull, 0x30dull, 0x02eull, 0x02full, 0x01cull, 0x01dull, 0x11cull, 0x11dull, 0x21cull, 0x21dull, 0x31cull, 0x31dull, 0x03eull, 0x03full, 0x02cull, 0x02dull, 0x12cull, 0x12dull, 0x22cull, 0x22dull, 0x32cull, 0x32dull, 0x12eull, 0x12full, 0x03cull, 0x03dull, 0x13cull, 0x13dull, 0x23cull, 0x23dull, 0x33cull, 0x33dull, 0x13eull, 0x13full, 0x04cull, 0x04dull, 0x14cull, 0x14dull, 0x24cull, 0x24dull, 0x34cull, 0x34dull, 0x22eull, 0x22full, 0x05cull, 0x05dull, 0x15cull, 0x15dull, 0x25cull, 0x25dull, 0x35cull, 0x35dull, 0x23eull, 0x23full, 0x06cull, 0x06dull, 0x16cull, 0x16dull, 0x26cull, 0x26dull, 0x36cull, 0x36dull, 0x32eull, 0x32full, 0x07cull, 0x07dull, 0x17cull, 0x17dull, 0x27cull, 0x27dull, 0x37cull, 0x37dull, 0x33eull, 0x33full, 0x00eull, 0x00full, 0x10eull, 0x10full, 0x20eull, 0x20full, 0x30eull, 0x30full, 0x06eull, 0x06full, 0x01eull, 0x01full, 0x11eull, 0x11full, 0x21eull, 0x21full, 0x31eull, 0x31full, 0x07eull, 0x07full, 0x08cull, 0x08dull, 0x18cull, 0x18dull, 0x28cull, 0x28dull, 0x38cull, 0x38dull, 0x0aeull, 0x0afull, 0x09cull, 0x09dull, 0x19cull, 0x19dull, 0x29cull, 0x29dull, 0x39cull, 0x39dull, 0x0beull, 0x0bfull, 0x0acull, 0x0adull, 0x1acull, 0x1adull, 0x2acull, 0x2adull, 0x3acull, 0x3adull, 0x1aeull, 0x1afull, 0x0bcull, 0x0bdull, 0x1bcull, 0x1bdull, 0x2bcull, 0x2bdull, 0x3bcull, 0x3bdull, 0x1beull, 0x1bfull, 0x0ccull, 0x0cdull, 0x1ccull, 0x1cdull, 0x2ccull, 0x2cdull, 0x3ccull, 0x3cdull, 0x2aeull, 0x2afull, 0x0dcull, 0x0ddull, 0x1dcull, 0x1ddull, 0x2dcull, 0x2ddull, 0x3dcull, 0x3ddull, 0x2beull, 0x2bfull, 0x0ecull, 0x0edull, 0x1ecull, 0x1edull, 0x2ecull, 0x2edull, 0x3ecull, 0x3edull, 0x3aeull, 0x3afull, 0x0fcull, 0x0fdull, 0x1fcull, 0x1fdull, 0x2fcull, 0x2fdull, 0x3fcull, 0x3fdull, 0x3beull, 0x3bfull, 0x08eull, 0x08full, 0x18eull, 0x18full, 0x28eull, 0x28full, 0x38eull, 0x38full, 0x0eeull, 0x0efull, 0x09eull, 0x09full, 0x19eull, 0x19full, 0x29eull, 0x29full, 0x39eull, 0x39full, 0x0feull, 0x0ffull }; static const UINT64 b2d2[] = { 0x000ull << 10, 0x001ull << 10, 0x002ull << 10, 0x003ull << 10, 0x004ull << 10, 0x005ull << 10, 0x006ull << 10, 0x007ull << 10, 0x008ull << 10, 0x009ull << 10, 0x010ull << 10, 0x011ull << 10, 0x012ull << 10, 0x013ull << 10, 0x014ull << 10, 0x015ull << 10, 0x016ull << 10, 0x017ull << 10, 0x018ull << 10, 0x019ull << 10, 0x020ull << 10, 0x021ull << 10, 0x022ull << 10, 0x023ull << 10, 0x024ull << 10, 0x025ull << 10, 0x026ull << 10, 0x027ull << 10, 0x028ull << 10, 0x029ull << 10, 0x030ull << 10, 0x031ull << 10, 0x032ull << 10, 0x033ull << 10, 0x034ull << 10, 0x035ull << 10, 0x036ull << 10, 0x037ull << 10, 0x038ull << 10, 0x039ull << 10, 0x040ull << 10, 0x041ull << 10, 0x042ull << 10, 0x043ull << 10, 0x044ull << 10, 0x045ull << 10, 0x046ull << 10, 0x047ull << 10, 0x048ull << 10, 0x049ull << 10, 0x050ull << 10, 0x051ull << 10, 0x052ull << 10, 0x053ull << 10, 0x054ull << 10, 0x055ull << 10, 0x056ull << 10, 0x057ull << 10, 0x058ull << 10, 0x059ull << 10, 0x060ull << 10, 0x061ull << 10, 0x062ull << 10, 0x063ull << 10, 0x064ull << 10, 0x065ull << 10, 0x066ull << 10, 0x067ull << 10, 0x068ull << 10, 0x069ull << 10, 0x070ull << 10, 0x071ull << 10, 0x072ull << 10, 0x073ull << 10, 0x074ull << 10, 0x075ull << 10, 0x076ull << 10, 0x077ull << 10, 0x078ull << 10, 0x079ull << 10, 0x00aull << 10, 0x00bull << 10, 0x02aull << 10, 0x02bull << 10, 0x04aull << 10, 0x04bull << 10, 0x06aull << 10, 0x06bull << 10, 0x04eull << 10, 0x04full << 10, 0x01aull << 10, 0x01bull << 10, 0x03aull << 10, 0x03bull << 10, 0x05aull << 10, 0x05bull << 10, 0x07aull << 10, 0x07bull << 10, 0x05eull << 10, 0x05full << 10, 0x080ull << 10, 0x081ull << 10, 0x082ull << 10, 0x083ull << 10, 0x084ull << 10, 0x085ull << 10, 0x086ull << 10, 0x087ull << 10, 0x088ull << 10, 0x089ull << 10, 0x090ull << 10, 0x091ull << 10, 0x092ull << 10, 0x093ull << 10, 0x094ull << 10, 0x095ull << 10, 0x096ull << 10, 0x097ull << 10, 0x098ull << 10, 0x099ull << 10, 0x0a0ull << 10, 0x0a1ull << 10, 0x0a2ull << 10, 0x0a3ull << 10, 0x0a4ull << 10, 0x0a5ull << 10, 0x0a6ull << 10, 0x0a7ull << 10, 0x0a8ull << 10, 0x0a9ull << 10, 0x0b0ull << 10, 0x0b1ull << 10, 0x0b2ull << 10, 0x0b3ull << 10, 0x0b4ull << 10, 0x0b5ull << 10, 0x0b6ull << 10, 0x0b7ull << 10, 0x0b8ull << 10, 0x0b9ull << 10, 0x0c0ull << 10, 0x0c1ull << 10, 0x0c2ull << 10, 0x0c3ull << 10, 0x0c4ull << 10, 0x0c5ull << 10, 0x0c6ull << 10, 0x0c7ull << 10, 0x0c8ull << 10, 0x0c9ull << 10, 0x0d0ull << 10, 0x0d1ull << 10, 0x0d2ull << 10, 0x0d3ull << 10, 0x0d4ull << 10, 0x0d5ull << 10, 0x0d6ull << 10, 0x0d7ull << 10, 0x0d8ull << 10, 0x0d9ull << 10, 0x0e0ull << 10, 0x0e1ull << 10, 0x0e2ull << 10, 0x0e3ull << 10, 0x0e4ull << 10, 0x0e5ull << 10, 0x0e6ull << 10, 0x0e7ull << 10, 0x0e8ull << 10, 0x0e9ull << 10, 0x0f0ull << 10, 0x0f1ull << 10, 0x0f2ull << 10, 0x0f3ull << 10, 0x0f4ull << 10, 0x0f5ull << 10, 0x0f6ull << 10, 0x0f7ull << 10, 0x0f8ull << 10, 0x0f9ull << 10, 0x08aull << 10, 0x08bull << 10, 0x0aaull << 10, 0x0abull << 10, 0x0caull << 10, 0x0cbull << 10, 0x0eaull << 10, 0x0ebull << 10, 0x0ceull << 10, 0x0cfull << 10, 0x09aull << 10, 0x09bull << 10, 0x0baull << 10, 0x0bbull << 10, 0x0daull << 10, 0x0dbull << 10, 0x0faull << 10, 0x0fbull << 10, 0x0deull << 10, 0x0dfull << 10, 0x100ull << 10, 0x101ull << 10, 0x102ull << 10, 0x103ull << 10, 0x104ull << 10, 0x105ull << 10, 0x106ull << 10, 0x107ull << 10, 0x108ull << 10, 0x109ull << 10, 0x110ull << 10, 0x111ull << 10, 0x112ull << 10, 0x113ull << 10, 0x114ull << 10, 0x115ull << 10, 0x116ull << 10, 0x117ull << 10, 0x118ull << 10, 0x119ull << 10, 0x120ull << 10, 0x121ull << 10, 0x122ull << 10, 0x123ull << 10, 0x124ull << 10, 0x125ull << 10, 0x126ull << 10, 0x127ull << 10, 0x128ull << 10, 0x129ull << 10, 0x130ull << 10, 0x131ull << 10, 0x132ull << 10, 0x133ull << 10, 0x134ull << 10, 0x135ull << 10, 0x136ull << 10, 0x137ull << 10, 0x138ull << 10, 0x139ull << 10, 0x140ull << 10, 0x141ull << 10, 0x142ull << 10, 0x143ull << 10, 0x144ull << 10, 0x145ull << 10, 0x146ull << 10, 0x147ull << 10, 0x148ull << 10, 0x149ull << 10, 0x150ull << 10, 0x151ull << 10, 0x152ull << 10, 0x153ull << 10, 0x154ull << 10, 0x155ull << 10, 0x156ull << 10, 0x157ull << 10, 0x158ull << 10, 0x159ull << 10, 0x160ull << 10, 0x161ull << 10, 0x162ull << 10, 0x163ull << 10, 0x164ull << 10, 0x165ull << 10, 0x166ull << 10, 0x167ull << 10, 0x168ull << 10, 0x169ull << 10, 0x170ull << 10, 0x171ull << 10, 0x172ull << 10, 0x173ull << 10, 0x174ull << 10, 0x175ull << 10, 0x176ull << 10, 0x177ull << 10, 0x178ull << 10, 0x179ull << 10, 0x10aull << 10, 0x10bull << 10, 0x12aull << 10, 0x12bull << 10, 0x14aull << 10, 0x14bull << 10, 0x16aull << 10, 0x16bull << 10, 0x14eull << 10, 0x14full << 10, 0x11aull << 10, 0x11bull << 10, 0x13aull << 10, 0x13bull << 10, 0x15aull << 10, 0x15bull << 10, 0x17aull << 10, 0x17bull << 10, 0x15eull << 10, 0x15full << 10, 0x180ull << 10, 0x181ull << 10, 0x182ull << 10, 0x183ull << 10, 0x184ull << 10, 0x185ull << 10, 0x186ull << 10, 0x187ull << 10, 0x188ull << 10, 0x189ull << 10, 0x190ull << 10, 0x191ull << 10, 0x192ull << 10, 0x193ull << 10, 0x194ull << 10, 0x195ull << 10, 0x196ull << 10, 0x197ull << 10, 0x198ull << 10, 0x199ull << 10, 0x1a0ull << 10, 0x1a1ull << 10, 0x1a2ull << 10, 0x1a3ull << 10, 0x1a4ull << 10, 0x1a5ull << 10, 0x1a6ull << 10, 0x1a7ull << 10, 0x1a8ull << 10, 0x1a9ull << 10, 0x1b0ull << 10, 0x1b1ull << 10, 0x1b2ull << 10, 0x1b3ull << 10, 0x1b4ull << 10, 0x1b5ull << 10, 0x1b6ull << 10, 0x1b7ull << 10, 0x1b8ull << 10, 0x1b9ull << 10, 0x1c0ull << 10, 0x1c1ull << 10, 0x1c2ull << 10, 0x1c3ull << 10, 0x1c4ull << 10, 0x1c5ull << 10, 0x1c6ull << 10, 0x1c7ull << 10, 0x1c8ull << 10, 0x1c9ull << 10, 0x1d0ull << 10, 0x1d1ull << 10, 0x1d2ull << 10, 0x1d3ull << 10, 0x1d4ull << 10, 0x1d5ull << 10, 0x1d6ull << 10, 0x1d7ull << 10, 0x1d8ull << 10, 0x1d9ull << 10, 0x1e0ull << 10, 0x1e1ull << 10, 0x1e2ull << 10, 0x1e3ull << 10, 0x1e4ull << 10, 0x1e5ull << 10, 0x1e6ull << 10, 0x1e7ull << 10, 0x1e8ull << 10, 0x1e9ull << 10, 0x1f0ull << 10, 0x1f1ull << 10, 0x1f2ull << 10, 0x1f3ull << 10, 0x1f4ull << 10, 0x1f5ull << 10, 0x1f6ull << 10, 0x1f7ull << 10, 0x1f8ull << 10, 0x1f9ull << 10, 0x18aull << 10, 0x18bull << 10, 0x1aaull << 10, 0x1abull << 10, 0x1caull << 10, 0x1cbull << 10, 0x1eaull << 10, 0x1ebull << 10, 0x1ceull << 10, 0x1cfull << 10, 0x19aull << 10, 0x19bull << 10, 0x1baull << 10, 0x1bbull << 10, 0x1daull << 10, 0x1dbull << 10, 0x1faull << 10, 0x1fbull << 10, 0x1deull << 10, 0x1dfull << 10, 0x200ull << 10, 0x201ull << 10, 0x202ull << 10, 0x203ull << 10, 0x204ull << 10, 0x205ull << 10, 0x206ull << 10, 0x207ull << 10, 0x208ull << 10, 0x209ull << 10, 0x210ull << 10, 0x211ull << 10, 0x212ull << 10, 0x213ull << 10, 0x214ull << 10, 0x215ull << 10, 0x216ull << 10, 0x217ull << 10, 0x218ull << 10, 0x219ull << 10, 0x220ull << 10, 0x221ull << 10, 0x222ull << 10, 0x223ull << 10, 0x224ull << 10, 0x225ull << 10, 0x226ull << 10, 0x227ull << 10, 0x228ull << 10, 0x229ull << 10, 0x230ull << 10, 0x231ull << 10, 0x232ull << 10, 0x233ull << 10, 0x234ull << 10, 0x235ull << 10, 0x236ull << 10, 0x237ull << 10, 0x238ull << 10, 0x239ull << 10, 0x240ull << 10, 0x241ull << 10, 0x242ull << 10, 0x243ull << 10, 0x244ull << 10, 0x245ull << 10, 0x246ull << 10, 0x247ull << 10, 0x248ull << 10, 0x249ull << 10, 0x250ull << 10, 0x251ull << 10, 0x252ull << 10, 0x253ull << 10, 0x254ull << 10, 0x255ull << 10, 0x256ull << 10, 0x257ull << 10, 0x258ull << 10, 0x259ull << 10, 0x260ull << 10, 0x261ull << 10, 0x262ull << 10, 0x263ull << 10, 0x264ull << 10, 0x265ull << 10, 0x266ull << 10, 0x267ull << 10, 0x268ull << 10, 0x269ull << 10, 0x270ull << 10, 0x271ull << 10, 0x272ull << 10, 0x273ull << 10, 0x274ull << 10, 0x275ull << 10, 0x276ull << 10, 0x277ull << 10, 0x278ull << 10, 0x279ull << 10, 0x20aull << 10, 0x20bull << 10, 0x22aull << 10, 0x22bull << 10, 0x24aull << 10, 0x24bull << 10, 0x26aull << 10, 0x26bull << 10, 0x24eull << 10, 0x24full << 10, 0x21aull << 10, 0x21bull << 10, 0x23aull << 10, 0x23bull << 10, 0x25aull << 10, 0x25bull << 10, 0x27aull << 10, 0x27bull << 10, 0x25eull << 10, 0x25full << 10, 0x280ull << 10, 0x281ull << 10, 0x282ull << 10, 0x283ull << 10, 0x284ull << 10, 0x285ull << 10, 0x286ull << 10, 0x287ull << 10, 0x288ull << 10, 0x289ull << 10, 0x290ull << 10, 0x291ull << 10, 0x292ull << 10, 0x293ull << 10, 0x294ull << 10, 0x295ull << 10, 0x296ull << 10, 0x297ull << 10, 0x298ull << 10, 0x299ull << 10, 0x2a0ull << 10, 0x2a1ull << 10, 0x2a2ull << 10, 0x2a3ull << 10, 0x2a4ull << 10, 0x2a5ull << 10, 0x2a6ull << 10, 0x2a7ull << 10, 0x2a8ull << 10, 0x2a9ull << 10, 0x2b0ull << 10, 0x2b1ull << 10, 0x2b2ull << 10, 0x2b3ull << 10, 0x2b4ull << 10, 0x2b5ull << 10, 0x2b6ull << 10, 0x2b7ull << 10, 0x2b8ull << 10, 0x2b9ull << 10, 0x2c0ull << 10, 0x2c1ull << 10, 0x2c2ull << 10, 0x2c3ull << 10, 0x2c4ull << 10, 0x2c5ull << 10, 0x2c6ull << 10, 0x2c7ull << 10, 0x2c8ull << 10, 0x2c9ull << 10, 0x2d0ull << 10, 0x2d1ull << 10, 0x2d2ull << 10, 0x2d3ull << 10, 0x2d4ull << 10, 0x2d5ull << 10, 0x2d6ull << 10, 0x2d7ull << 10, 0x2d8ull << 10, 0x2d9ull << 10, 0x2e0ull << 10, 0x2e1ull << 10, 0x2e2ull << 10, 0x2e3ull << 10, 0x2e4ull << 10, 0x2e5ull << 10, 0x2e6ull << 10, 0x2e7ull << 10, 0x2e8ull << 10, 0x2e9ull << 10, 0x2f0ull << 10, 0x2f1ull << 10, 0x2f2ull << 10, 0x2f3ull << 10, 0x2f4ull << 10, 0x2f5ull << 10, 0x2f6ull << 10, 0x2f7ull << 10, 0x2f8ull << 10, 0x2f9ull << 10, 0x28aull << 10, 0x28bull << 10, 0x2aaull << 10, 0x2abull << 10, 0x2caull << 10, 0x2cbull << 10, 0x2eaull << 10, 0x2ebull << 10, 0x2ceull << 10, 0x2cfull << 10, 0x29aull << 10, 0x29bull << 10, 0x2baull << 10, 0x2bbull << 10, 0x2daull << 10, 0x2dbull << 10, 0x2faull << 10, 0x2fbull << 10, 0x2deull << 10, 0x2dfull << 10, 0x300ull << 10, 0x301ull << 10, 0x302ull << 10, 0x303ull << 10, 0x304ull << 10, 0x305ull << 10, 0x306ull << 10, 0x307ull << 10, 0x308ull << 10, 0x309ull << 10, 0x310ull << 10, 0x311ull << 10, 0x312ull << 10, 0x313ull << 10, 0x314ull << 10, 0x315ull << 10, 0x316ull << 10, 0x317ull << 10, 0x318ull << 10, 0x319ull << 10, 0x320ull << 10, 0x321ull << 10, 0x322ull << 10, 0x323ull << 10, 0x324ull << 10, 0x325ull << 10, 0x326ull << 10, 0x327ull << 10, 0x328ull << 10, 0x329ull << 10, 0x330ull << 10, 0x331ull << 10, 0x332ull << 10, 0x333ull << 10, 0x334ull << 10, 0x335ull << 10, 0x336ull << 10, 0x337ull << 10, 0x338ull << 10, 0x339ull << 10, 0x340ull << 10, 0x341ull << 10, 0x342ull << 10, 0x343ull << 10, 0x344ull << 10, 0x345ull << 10, 0x346ull << 10, 0x347ull << 10, 0x348ull << 10, 0x349ull << 10, 0x350ull << 10, 0x351ull << 10, 0x352ull << 10, 0x353ull << 10, 0x354ull << 10, 0x355ull << 10, 0x356ull << 10, 0x357ull << 10, 0x358ull << 10, 0x359ull << 10, 0x360ull << 10, 0x361ull << 10, 0x362ull << 10, 0x363ull << 10, 0x364ull << 10, 0x365ull << 10, 0x366ull << 10, 0x367ull << 10, 0x368ull << 10, 0x369ull << 10, 0x370ull << 10, 0x371ull << 10, 0x372ull << 10, 0x373ull << 10, 0x374ull << 10, 0x375ull << 10, 0x376ull << 10, 0x377ull << 10, 0x378ull << 10, 0x379ull << 10, 0x30aull << 10, 0x30bull << 10, 0x32aull << 10, 0x32bull << 10, 0x34aull << 10, 0x34bull << 10, 0x36aull << 10, 0x36bull << 10, 0x34eull << 10, 0x34full << 10, 0x31aull << 10, 0x31bull << 10, 0x33aull << 10, 0x33bull << 10, 0x35aull << 10, 0x35bull << 10, 0x37aull << 10, 0x37bull << 10, 0x35eull << 10, 0x35full << 10, 0x380ull << 10, 0x381ull << 10, 0x382ull << 10, 0x383ull << 10, 0x384ull << 10, 0x385ull << 10, 0x386ull << 10, 0x387ull << 10, 0x388ull << 10, 0x389ull << 10, 0x390ull << 10, 0x391ull << 10, 0x392ull << 10, 0x393ull << 10, 0x394ull << 10, 0x395ull << 10, 0x396ull << 10, 0x397ull << 10, 0x398ull << 10, 0x399ull << 10, 0x3a0ull << 10, 0x3a1ull << 10, 0x3a2ull << 10, 0x3a3ull << 10, 0x3a4ull << 10, 0x3a5ull << 10, 0x3a6ull << 10, 0x3a7ull << 10, 0x3a8ull << 10, 0x3a9ull << 10, 0x3b0ull << 10, 0x3b1ull << 10, 0x3b2ull << 10, 0x3b3ull << 10, 0x3b4ull << 10, 0x3b5ull << 10, 0x3b6ull << 10, 0x3b7ull << 10, 0x3b8ull << 10, 0x3b9ull << 10, 0x3c0ull << 10, 0x3c1ull << 10, 0x3c2ull << 10, 0x3c3ull << 10, 0x3c4ull << 10, 0x3c5ull << 10, 0x3c6ull << 10, 0x3c7ull << 10, 0x3c8ull << 10, 0x3c9ull << 10, 0x3d0ull << 10, 0x3d1ull << 10, 0x3d2ull << 10, 0x3d3ull << 10, 0x3d4ull << 10, 0x3d5ull << 10, 0x3d6ull << 10, 0x3d7ull << 10, 0x3d8ull << 10, 0x3d9ull << 10, 0x3e0ull << 10, 0x3e1ull << 10, 0x3e2ull << 10, 0x3e3ull << 10, 0x3e4ull << 10, 0x3e5ull << 10, 0x3e6ull << 10, 0x3e7ull << 10, 0x3e8ull << 10, 0x3e9ull << 10, 0x3f0ull << 10, 0x3f1ull << 10, 0x3f2ull << 10, 0x3f3ull << 10, 0x3f4ull << 10, 0x3f5ull << 10, 0x3f6ull << 10, 0x3f7ull << 10, 0x3f8ull << 10, 0x3f9ull << 10, 0x38aull << 10, 0x38bull << 10, 0x3aaull << 10, 0x3abull << 10, 0x3caull << 10, 0x3cbull << 10, 0x3eaull << 10, 0x3ebull << 10, 0x3ceull << 10, 0x3cfull << 10, 0x39aull << 10, 0x39bull << 10, 0x3baull << 10, 0x3bbull << 10, 0x3daull << 10, 0x3dbull << 10, 0x3faull << 10, 0x3fbull << 10, 0x3deull << 10, 0x3dfull << 10, 0x00cull << 10, 0x00dull << 10, 0x10cull << 10, 0x10dull << 10, 0x20cull << 10, 0x20dull << 10, 0x30cull << 10, 0x30dull << 10, 0x02eull << 10, 0x02full << 10, 0x01cull << 10, 0x01dull << 10, 0x11cull << 10, 0x11dull << 10, 0x21cull << 10, 0x21dull << 10, 0x31cull << 10, 0x31dull << 10, 0x03eull << 10, 0x03full << 10, 0x02cull << 10, 0x02dull << 10, 0x12cull << 10, 0x12dull << 10, 0x22cull << 10, 0x22dull << 10, 0x32cull << 10, 0x32dull << 10, 0x12eull << 10, 0x12full << 10, 0x03cull << 10, 0x03dull << 10, 0x13cull << 10, 0x13dull << 10, 0x23cull << 10, 0x23dull << 10, 0x33cull << 10, 0x33dull << 10, 0x13eull << 10, 0x13full << 10, 0x04cull << 10, 0x04dull << 10, 0x14cull << 10, 0x14dull << 10, 0x24cull << 10, 0x24dull << 10, 0x34cull << 10, 0x34dull << 10, 0x22eull << 10, 0x22full << 10, 0x05cull << 10, 0x05dull << 10, 0x15cull << 10, 0x15dull << 10, 0x25cull << 10, 0x25dull << 10, 0x35cull << 10, 0x35dull << 10, 0x23eull << 10, 0x23full << 10, 0x06cull << 10, 0x06dull << 10, 0x16cull << 10, 0x16dull << 10, 0x26cull << 10, 0x26dull << 10, 0x36cull << 10, 0x36dull << 10, 0x32eull << 10, 0x32full << 10, 0x07cull << 10, 0x07dull << 10, 0x17cull << 10, 0x17dull << 10, 0x27cull << 10, 0x27dull << 10, 0x37cull << 10, 0x37dull << 10, 0x33eull << 10, 0x33full << 10, 0x00eull << 10, 0x00full << 10, 0x10eull << 10, 0x10full << 10, 0x20eull << 10, 0x20full << 10, 0x30eull << 10, 0x30full << 10, 0x06eull << 10, 0x06full << 10, 0x01eull << 10, 0x01full << 10, 0x11eull << 10, 0x11full << 10, 0x21eull << 10, 0x21full << 10, 0x31eull << 10, 0x31full << 10, 0x07eull << 10, 0x07full << 10, 0x08cull << 10, 0x08dull << 10, 0x18cull << 10, 0x18dull << 10, 0x28cull << 10, 0x28dull << 10, 0x38cull << 10, 0x38dull << 10, 0x0aeull << 10, 0x0afull << 10, 0x09cull << 10, 0x09dull << 10, 0x19cull << 10, 0x19dull << 10, 0x29cull << 10, 0x29dull << 10, 0x39cull << 10, 0x39dull << 10, 0x0beull << 10, 0x0bfull << 10, 0x0acull << 10, 0x0adull << 10, 0x1acull << 10, 0x1adull << 10, 0x2acull << 10, 0x2adull << 10, 0x3acull << 10, 0x3adull << 10, 0x1aeull << 10, 0x1afull << 10, 0x0bcull << 10, 0x0bdull << 10, 0x1bcull << 10, 0x1bdull << 10, 0x2bcull << 10, 0x2bdull << 10, 0x3bcull << 10, 0x3bdull << 10, 0x1beull << 10, 0x1bfull << 10, 0x0ccull << 10, 0x0cdull << 10, 0x1ccull << 10, 0x1cdull << 10, 0x2ccull << 10, 0x2cdull << 10, 0x3ccull << 10, 0x3cdull << 10, 0x2aeull << 10, 0x2afull << 10, 0x0dcull << 10, 0x0ddull << 10, 0x1dcull << 10, 0x1ddull << 10, 0x2dcull << 10, 0x2ddull << 10, 0x3dcull << 10, 0x3ddull << 10, 0x2beull << 10, 0x2bfull << 10, 0x0ecull << 10, 0x0edull << 10, 0x1ecull << 10, 0x1edull << 10, 0x2ecull << 10, 0x2edull << 10, 0x3ecull << 10, 0x3edull << 10, 0x3aeull << 10, 0x3afull << 10, 0x0fcull << 10, 0x0fdull << 10, 0x1fcull << 10, 0x1fdull << 10, 0x2fcull << 10, 0x2fdull << 10, 0x3fcull << 10, 0x3fdull << 10, 0x3beull << 10, 0x3bfull << 10, 0x08eull << 10, 0x08full << 10, 0x18eull << 10, 0x18full << 10, 0x28eull << 10, 0x28full << 10, 0x38eull << 10, 0x38full << 10, 0x0eeull << 10, 0x0efull << 10, 0x09eull << 10, 0x09full << 10, 0x19eull << 10, 0x19full << 10, 0x29eull << 10, 0x29full << 10, 0x39eull << 10, 0x39full << 10, 0x0feull << 10, 0x0ffull << 10 }; static const UINT64 b2d3[] = { 0x000ull << 20, 0x001ull << 20, 0x002ull << 20, 0x003ull << 20, 0x004ull << 20, 0x005ull << 20, 0x006ull << 20, 0x007ull << 20, 0x008ull << 20, 0x009ull << 20, 0x010ull << 20, 0x011ull << 20, 0x012ull << 20, 0x013ull << 20, 0x014ull << 20, 0x015ull << 20, 0x016ull << 20, 0x017ull << 20, 0x018ull << 20, 0x019ull << 20, 0x020ull << 20, 0x021ull << 20, 0x022ull << 20, 0x023ull << 20, 0x024ull << 20, 0x025ull << 20, 0x026ull << 20, 0x027ull << 20, 0x028ull << 20, 0x029ull << 20, 0x030ull << 20, 0x031ull << 20, 0x032ull << 20, 0x033ull << 20, 0x034ull << 20, 0x035ull << 20, 0x036ull << 20, 0x037ull << 20, 0x038ull << 20, 0x039ull << 20, 0x040ull << 20, 0x041ull << 20, 0x042ull << 20, 0x043ull << 20, 0x044ull << 20, 0x045ull << 20, 0x046ull << 20, 0x047ull << 20, 0x048ull << 20, 0x049ull << 20, 0x050ull << 20, 0x051ull << 20, 0x052ull << 20, 0x053ull << 20, 0x054ull << 20, 0x055ull << 20, 0x056ull << 20, 0x057ull << 20, 0x058ull << 20, 0x059ull << 20, 0x060ull << 20, 0x061ull << 20, 0x062ull << 20, 0x063ull << 20, 0x064ull << 20, 0x065ull << 20, 0x066ull << 20, 0x067ull << 20, 0x068ull << 20, 0x069ull << 20, 0x070ull << 20, 0x071ull << 20, 0x072ull << 20, 0x073ull << 20, 0x074ull << 20, 0x075ull << 20, 0x076ull << 20, 0x077ull << 20, 0x078ull << 20, 0x079ull << 20, 0x00aull << 20, 0x00bull << 20, 0x02aull << 20, 0x02bull << 20, 0x04aull << 20, 0x04bull << 20, 0x06aull << 20, 0x06bull << 20, 0x04eull << 20, 0x04full << 20, 0x01aull << 20, 0x01bull << 20, 0x03aull << 20, 0x03bull << 20, 0x05aull << 20, 0x05bull << 20, 0x07aull << 20, 0x07bull << 20, 0x05eull << 20, 0x05full << 20, 0x080ull << 20, 0x081ull << 20, 0x082ull << 20, 0x083ull << 20, 0x084ull << 20, 0x085ull << 20, 0x086ull << 20, 0x087ull << 20, 0x088ull << 20, 0x089ull << 20, 0x090ull << 20, 0x091ull << 20, 0x092ull << 20, 0x093ull << 20, 0x094ull << 20, 0x095ull << 20, 0x096ull << 20, 0x097ull << 20, 0x098ull << 20, 0x099ull << 20, 0x0a0ull << 20, 0x0a1ull << 20, 0x0a2ull << 20, 0x0a3ull << 20, 0x0a4ull << 20, 0x0a5ull << 20, 0x0a6ull << 20, 0x0a7ull << 20, 0x0a8ull << 20, 0x0a9ull << 20, 0x0b0ull << 20, 0x0b1ull << 20, 0x0b2ull << 20, 0x0b3ull << 20, 0x0b4ull << 20, 0x0b5ull << 20, 0x0b6ull << 20, 0x0b7ull << 20, 0x0b8ull << 20, 0x0b9ull << 20, 0x0c0ull << 20, 0x0c1ull << 20, 0x0c2ull << 20, 0x0c3ull << 20, 0x0c4ull << 20, 0x0c5ull << 20, 0x0c6ull << 20, 0x0c7ull << 20, 0x0c8ull << 20, 0x0c9ull << 20, 0x0d0ull << 20, 0x0d1ull << 20, 0x0d2ull << 20, 0x0d3ull << 20, 0x0d4ull << 20, 0x0d5ull << 20, 0x0d6ull << 20, 0x0d7ull << 20, 0x0d8ull << 20, 0x0d9ull << 20, 0x0e0ull << 20, 0x0e1ull << 20, 0x0e2ull << 20, 0x0e3ull << 20, 0x0e4ull << 20, 0x0e5ull << 20, 0x0e6ull << 20, 0x0e7ull << 20, 0x0e8ull << 20, 0x0e9ull << 20, 0x0f0ull << 20, 0x0f1ull << 20, 0x0f2ull << 20, 0x0f3ull << 20, 0x0f4ull << 20, 0x0f5ull << 20, 0x0f6ull << 20, 0x0f7ull << 20, 0x0f8ull << 20, 0x0f9ull << 20, 0x08aull << 20, 0x08bull << 20, 0x0aaull << 20, 0x0abull << 20, 0x0caull << 20, 0x0cbull << 20, 0x0eaull << 20, 0x0ebull << 20, 0x0ceull << 20, 0x0cfull << 20, 0x09aull << 20, 0x09bull << 20, 0x0baull << 20, 0x0bbull << 20, 0x0daull << 20, 0x0dbull << 20, 0x0faull << 20, 0x0fbull << 20, 0x0deull << 20, 0x0dfull << 20, 0x100ull << 20, 0x101ull << 20, 0x102ull << 20, 0x103ull << 20, 0x104ull << 20, 0x105ull << 20, 0x106ull << 20, 0x107ull << 20, 0x108ull << 20, 0x109ull << 20, 0x110ull << 20, 0x111ull << 20, 0x112ull << 20, 0x113ull << 20, 0x114ull << 20, 0x115ull << 20, 0x116ull << 20, 0x117ull << 20, 0x118ull << 20, 0x119ull << 20, 0x120ull << 20, 0x121ull << 20, 0x122ull << 20, 0x123ull << 20, 0x124ull << 20, 0x125ull << 20, 0x126ull << 20, 0x127ull << 20, 0x128ull << 20, 0x129ull << 20, 0x130ull << 20, 0x131ull << 20, 0x132ull << 20, 0x133ull << 20, 0x134ull << 20, 0x135ull << 20, 0x136ull << 20, 0x137ull << 20, 0x138ull << 20, 0x139ull << 20, 0x140ull << 20, 0x141ull << 20, 0x142ull << 20, 0x143ull << 20, 0x144ull << 20, 0x145ull << 20, 0x146ull << 20, 0x147ull << 20, 0x148ull << 20, 0x149ull << 20, 0x150ull << 20, 0x151ull << 20, 0x152ull << 20, 0x153ull << 20, 0x154ull << 20, 0x155ull << 20, 0x156ull << 20, 0x157ull << 20, 0x158ull << 20, 0x159ull << 20, 0x160ull << 20, 0x161ull << 20, 0x162ull << 20, 0x163ull << 20, 0x164ull << 20, 0x165ull << 20, 0x166ull << 20, 0x167ull << 20, 0x168ull << 20, 0x169ull << 20, 0x170ull << 20, 0x171ull << 20, 0x172ull << 20, 0x173ull << 20, 0x174ull << 20, 0x175ull << 20, 0x176ull << 20, 0x177ull << 20, 0x178ull << 20, 0x179ull << 20, 0x10aull << 20, 0x10bull << 20, 0x12aull << 20, 0x12bull << 20, 0x14aull << 20, 0x14bull << 20, 0x16aull << 20, 0x16bull << 20, 0x14eull << 20, 0x14full << 20, 0x11aull << 20, 0x11bull << 20, 0x13aull << 20, 0x13bull << 20, 0x15aull << 20, 0x15bull << 20, 0x17aull << 20, 0x17bull << 20, 0x15eull << 20, 0x15full << 20, 0x180ull << 20, 0x181ull << 20, 0x182ull << 20, 0x183ull << 20, 0x184ull << 20, 0x185ull << 20, 0x186ull << 20, 0x187ull << 20, 0x188ull << 20, 0x189ull << 20, 0x190ull << 20, 0x191ull << 20, 0x192ull << 20, 0x193ull << 20, 0x194ull << 20, 0x195ull << 20, 0x196ull << 20, 0x197ull << 20, 0x198ull << 20, 0x199ull << 20, 0x1a0ull << 20, 0x1a1ull << 20, 0x1a2ull << 20, 0x1a3ull << 20, 0x1a4ull << 20, 0x1a5ull << 20, 0x1a6ull << 20, 0x1a7ull << 20, 0x1a8ull << 20, 0x1a9ull << 20, 0x1b0ull << 20, 0x1b1ull << 20, 0x1b2ull << 20, 0x1b3ull << 20, 0x1b4ull << 20, 0x1b5ull << 20, 0x1b6ull << 20, 0x1b7ull << 20, 0x1b8ull << 20, 0x1b9ull << 20, 0x1c0ull << 20, 0x1c1ull << 20, 0x1c2ull << 20, 0x1c3ull << 20, 0x1c4ull << 20, 0x1c5ull << 20, 0x1c6ull << 20, 0x1c7ull << 20, 0x1c8ull << 20, 0x1c9ull << 20, 0x1d0ull << 20, 0x1d1ull << 20, 0x1d2ull << 20, 0x1d3ull << 20, 0x1d4ull << 20, 0x1d5ull << 20, 0x1d6ull << 20, 0x1d7ull << 20, 0x1d8ull << 20, 0x1d9ull << 20, 0x1e0ull << 20, 0x1e1ull << 20, 0x1e2ull << 20, 0x1e3ull << 20, 0x1e4ull << 20, 0x1e5ull << 20, 0x1e6ull << 20, 0x1e7ull << 20, 0x1e8ull << 20, 0x1e9ull << 20, 0x1f0ull << 20, 0x1f1ull << 20, 0x1f2ull << 20, 0x1f3ull << 20, 0x1f4ull << 20, 0x1f5ull << 20, 0x1f6ull << 20, 0x1f7ull << 20, 0x1f8ull << 20, 0x1f9ull << 20, 0x18aull << 20, 0x18bull << 20, 0x1aaull << 20, 0x1abull << 20, 0x1caull << 20, 0x1cbull << 20, 0x1eaull << 20, 0x1ebull << 20, 0x1ceull << 20, 0x1cfull << 20, 0x19aull << 20, 0x19bull << 20, 0x1baull << 20, 0x1bbull << 20, 0x1daull << 20, 0x1dbull << 20, 0x1faull << 20, 0x1fbull << 20, 0x1deull << 20, 0x1dfull << 20, 0x200ull << 20, 0x201ull << 20, 0x202ull << 20, 0x203ull << 20, 0x204ull << 20, 0x205ull << 20, 0x206ull << 20, 0x207ull << 20, 0x208ull << 20, 0x209ull << 20, 0x210ull << 20, 0x211ull << 20, 0x212ull << 20, 0x213ull << 20, 0x214ull << 20, 0x215ull << 20, 0x216ull << 20, 0x217ull << 20, 0x218ull << 20, 0x219ull << 20, 0x220ull << 20, 0x221ull << 20, 0x222ull << 20, 0x223ull << 20, 0x224ull << 20, 0x225ull << 20, 0x226ull << 20, 0x227ull << 20, 0x228ull << 20, 0x229ull << 20, 0x230ull << 20, 0x231ull << 20, 0x232ull << 20, 0x233ull << 20, 0x234ull << 20, 0x235ull << 20, 0x236ull << 20, 0x237ull << 20, 0x238ull << 20, 0x239ull << 20, 0x240ull << 20, 0x241ull << 20, 0x242ull << 20, 0x243ull << 20, 0x244ull << 20, 0x245ull << 20, 0x246ull << 20, 0x247ull << 20, 0x248ull << 20, 0x249ull << 20, 0x250ull << 20, 0x251ull << 20, 0x252ull << 20, 0x253ull << 20, 0x254ull << 20, 0x255ull << 20, 0x256ull << 20, 0x257ull << 20, 0x258ull << 20, 0x259ull << 20, 0x260ull << 20, 0x261ull << 20, 0x262ull << 20, 0x263ull << 20, 0x264ull << 20, 0x265ull << 20, 0x266ull << 20, 0x267ull << 20, 0x268ull << 20, 0x269ull << 20, 0x270ull << 20, 0x271ull << 20, 0x272ull << 20, 0x273ull << 20, 0x274ull << 20, 0x275ull << 20, 0x276ull << 20, 0x277ull << 20, 0x278ull << 20, 0x279ull << 20, 0x20aull << 20, 0x20bull << 20, 0x22aull << 20, 0x22bull << 20, 0x24aull << 20, 0x24bull << 20, 0x26aull << 20, 0x26bull << 20, 0x24eull << 20, 0x24full << 20, 0x21aull << 20, 0x21bull << 20, 0x23aull << 20, 0x23bull << 20, 0x25aull << 20, 0x25bull << 20, 0x27aull << 20, 0x27bull << 20, 0x25eull << 20, 0x25full << 20, 0x280ull << 20, 0x281ull << 20, 0x282ull << 20, 0x283ull << 20, 0x284ull << 20, 0x285ull << 20, 0x286ull << 20, 0x287ull << 20, 0x288ull << 20, 0x289ull << 20, 0x290ull << 20, 0x291ull << 20, 0x292ull << 20, 0x293ull << 20, 0x294ull << 20, 0x295ull << 20, 0x296ull << 20, 0x297ull << 20, 0x298ull << 20, 0x299ull << 20, 0x2a0ull << 20, 0x2a1ull << 20, 0x2a2ull << 20, 0x2a3ull << 20, 0x2a4ull << 20, 0x2a5ull << 20, 0x2a6ull << 20, 0x2a7ull << 20, 0x2a8ull << 20, 0x2a9ull << 20, 0x2b0ull << 20, 0x2b1ull << 20, 0x2b2ull << 20, 0x2b3ull << 20, 0x2b4ull << 20, 0x2b5ull << 20, 0x2b6ull << 20, 0x2b7ull << 20, 0x2b8ull << 20, 0x2b9ull << 20, 0x2c0ull << 20, 0x2c1ull << 20, 0x2c2ull << 20, 0x2c3ull << 20, 0x2c4ull << 20, 0x2c5ull << 20, 0x2c6ull << 20, 0x2c7ull << 20, 0x2c8ull << 20, 0x2c9ull << 20, 0x2d0ull << 20, 0x2d1ull << 20, 0x2d2ull << 20, 0x2d3ull << 20, 0x2d4ull << 20, 0x2d5ull << 20, 0x2d6ull << 20, 0x2d7ull << 20, 0x2d8ull << 20, 0x2d9ull << 20, 0x2e0ull << 20, 0x2e1ull << 20, 0x2e2ull << 20, 0x2e3ull << 20, 0x2e4ull << 20, 0x2e5ull << 20, 0x2e6ull << 20, 0x2e7ull << 20, 0x2e8ull << 20, 0x2e9ull << 20, 0x2f0ull << 20, 0x2f1ull << 20, 0x2f2ull << 20, 0x2f3ull << 20, 0x2f4ull << 20, 0x2f5ull << 20, 0x2f6ull << 20, 0x2f7ull << 20, 0x2f8ull << 20, 0x2f9ull << 20, 0x28aull << 20, 0x28bull << 20, 0x2aaull << 20, 0x2abull << 20, 0x2caull << 20, 0x2cbull << 20, 0x2eaull << 20, 0x2ebull << 20, 0x2ceull << 20, 0x2cfull << 20, 0x29aull << 20, 0x29bull << 20, 0x2baull << 20, 0x2bbull << 20, 0x2daull << 20, 0x2dbull << 20, 0x2faull << 20, 0x2fbull << 20, 0x2deull << 20, 0x2dfull << 20, 0x300ull << 20, 0x301ull << 20, 0x302ull << 20, 0x303ull << 20, 0x304ull << 20, 0x305ull << 20, 0x306ull << 20, 0x307ull << 20, 0x308ull << 20, 0x309ull << 20, 0x310ull << 20, 0x311ull << 20, 0x312ull << 20, 0x313ull << 20, 0x314ull << 20, 0x315ull << 20, 0x316ull << 20, 0x317ull << 20, 0x318ull << 20, 0x319ull << 20, 0x320ull << 20, 0x321ull << 20, 0x322ull << 20, 0x323ull << 20, 0x324ull << 20, 0x325ull << 20, 0x326ull << 20, 0x327ull << 20, 0x328ull << 20, 0x329ull << 20, 0x330ull << 20, 0x331ull << 20, 0x332ull << 20, 0x333ull << 20, 0x334ull << 20, 0x335ull << 20, 0x336ull << 20, 0x337ull << 20, 0x338ull << 20, 0x339ull << 20, 0x340ull << 20, 0x341ull << 20, 0x342ull << 20, 0x343ull << 20, 0x344ull << 20, 0x345ull << 20, 0x346ull << 20, 0x347ull << 20, 0x348ull << 20, 0x349ull << 20, 0x350ull << 20, 0x351ull << 20, 0x352ull << 20, 0x353ull << 20, 0x354ull << 20, 0x355ull << 20, 0x356ull << 20, 0x357ull << 20, 0x358ull << 20, 0x359ull << 20, 0x360ull << 20, 0x361ull << 20, 0x362ull << 20, 0x363ull << 20, 0x364ull << 20, 0x365ull << 20, 0x366ull << 20, 0x367ull << 20, 0x368ull << 20, 0x369ull << 20, 0x370ull << 20, 0x371ull << 20, 0x372ull << 20, 0x373ull << 20, 0x374ull << 20, 0x375ull << 20, 0x376ull << 20, 0x377ull << 20, 0x378ull << 20, 0x379ull << 20, 0x30aull << 20, 0x30bull << 20, 0x32aull << 20, 0x32bull << 20, 0x34aull << 20, 0x34bull << 20, 0x36aull << 20, 0x36bull << 20, 0x34eull << 20, 0x34full << 20, 0x31aull << 20, 0x31bull << 20, 0x33aull << 20, 0x33bull << 20, 0x35aull << 20, 0x35bull << 20, 0x37aull << 20, 0x37bull << 20, 0x35eull << 20, 0x35full << 20, 0x380ull << 20, 0x381ull << 20, 0x382ull << 20, 0x383ull << 20, 0x384ull << 20, 0x385ull << 20, 0x386ull << 20, 0x387ull << 20, 0x388ull << 20, 0x389ull << 20, 0x390ull << 20, 0x391ull << 20, 0x392ull << 20, 0x393ull << 20, 0x394ull << 20, 0x395ull << 20, 0x396ull << 20, 0x397ull << 20, 0x398ull << 20, 0x399ull << 20, 0x3a0ull << 20, 0x3a1ull << 20, 0x3a2ull << 20, 0x3a3ull << 20, 0x3a4ull << 20, 0x3a5ull << 20, 0x3a6ull << 20, 0x3a7ull << 20, 0x3a8ull << 20, 0x3a9ull << 20, 0x3b0ull << 20, 0x3b1ull << 20, 0x3b2ull << 20, 0x3b3ull << 20, 0x3b4ull << 20, 0x3b5ull << 20, 0x3b6ull << 20, 0x3b7ull << 20, 0x3b8ull << 20, 0x3b9ull << 20, 0x3c0ull << 20, 0x3c1ull << 20, 0x3c2ull << 20, 0x3c3ull << 20, 0x3c4ull << 20, 0x3c5ull << 20, 0x3c6ull << 20, 0x3c7ull << 20, 0x3c8ull << 20, 0x3c9ull << 20, 0x3d0ull << 20, 0x3d1ull << 20, 0x3d2ull << 20, 0x3d3ull << 20, 0x3d4ull << 20, 0x3d5ull << 20, 0x3d6ull << 20, 0x3d7ull << 20, 0x3d8ull << 20, 0x3d9ull << 20, 0x3e0ull << 20, 0x3e1ull << 20, 0x3e2ull << 20, 0x3e3ull << 20, 0x3e4ull << 20, 0x3e5ull << 20, 0x3e6ull << 20, 0x3e7ull << 20, 0x3e8ull << 20, 0x3e9ull << 20, 0x3f0ull << 20, 0x3f1ull << 20, 0x3f2ull << 20, 0x3f3ull << 20, 0x3f4ull << 20, 0x3f5ull << 20, 0x3f6ull << 20, 0x3f7ull << 20, 0x3f8ull << 20, 0x3f9ull << 20, 0x38aull << 20, 0x38bull << 20, 0x3aaull << 20, 0x3abull << 20, 0x3caull << 20, 0x3cbull << 20, 0x3eaull << 20, 0x3ebull << 20, 0x3ceull << 20, 0x3cfull << 20, 0x39aull << 20, 0x39bull << 20, 0x3baull << 20, 0x3bbull << 20, 0x3daull << 20, 0x3dbull << 20, 0x3faull << 20, 0x3fbull << 20, 0x3deull << 20, 0x3dfull << 20, 0x00cull << 20, 0x00dull << 20, 0x10cull << 20, 0x10dull << 20, 0x20cull << 20, 0x20dull << 20, 0x30cull << 20, 0x30dull << 20, 0x02eull << 20, 0x02full << 20, 0x01cull << 20, 0x01dull << 20, 0x11cull << 20, 0x11dull << 20, 0x21cull << 20, 0x21dull << 20, 0x31cull << 20, 0x31dull << 20, 0x03eull << 20, 0x03full << 20, 0x02cull << 20, 0x02dull << 20, 0x12cull << 20, 0x12dull << 20, 0x22cull << 20, 0x22dull << 20, 0x32cull << 20, 0x32dull << 20, 0x12eull << 20, 0x12full << 20, 0x03cull << 20, 0x03dull << 20, 0x13cull << 20, 0x13dull << 20, 0x23cull << 20, 0x23dull << 20, 0x33cull << 20, 0x33dull << 20, 0x13eull << 20, 0x13full << 20, 0x04cull << 20, 0x04dull << 20, 0x14cull << 20, 0x14dull << 20, 0x24cull << 20, 0x24dull << 20, 0x34cull << 20, 0x34dull << 20, 0x22eull << 20, 0x22full << 20, 0x05cull << 20, 0x05dull << 20, 0x15cull << 20, 0x15dull << 20, 0x25cull << 20, 0x25dull << 20, 0x35cull << 20, 0x35dull << 20, 0x23eull << 20, 0x23full << 20, 0x06cull << 20, 0x06dull << 20, 0x16cull << 20, 0x16dull << 20, 0x26cull << 20, 0x26dull << 20, 0x36cull << 20, 0x36dull << 20, 0x32eull << 20, 0x32full << 20, 0x07cull << 20, 0x07dull << 20, 0x17cull << 20, 0x17dull << 20, 0x27cull << 20, 0x27dull << 20, 0x37cull << 20, 0x37dull << 20, 0x33eull << 20, 0x33full << 20, 0x00eull << 20, 0x00full << 20, 0x10eull << 20, 0x10full << 20, 0x20eull << 20, 0x20full << 20, 0x30eull << 20, 0x30full << 20, 0x06eull << 20, 0x06full << 20, 0x01eull << 20, 0x01full << 20, 0x11eull << 20, 0x11full << 20, 0x21eull << 20, 0x21full << 20, 0x31eull << 20, 0x31full << 20, 0x07eull << 20, 0x07full << 20, 0x08cull << 20, 0x08dull << 20, 0x18cull << 20, 0x18dull << 20, 0x28cull << 20, 0x28dull << 20, 0x38cull << 20, 0x38dull << 20, 0x0aeull << 20, 0x0afull << 20, 0x09cull << 20, 0x09dull << 20, 0x19cull << 20, 0x19dull << 20, 0x29cull << 20, 0x29dull << 20, 0x39cull << 20, 0x39dull << 20, 0x0beull << 20, 0x0bfull << 20, 0x0acull << 20, 0x0adull << 20, 0x1acull << 20, 0x1adull << 20, 0x2acull << 20, 0x2adull << 20, 0x3acull << 20, 0x3adull << 20, 0x1aeull << 20, 0x1afull << 20, 0x0bcull << 20, 0x0bdull << 20, 0x1bcull << 20, 0x1bdull << 20, 0x2bcull << 20, 0x2bdull << 20, 0x3bcull << 20, 0x3bdull << 20, 0x1beull << 20, 0x1bfull << 20, 0x0ccull << 20, 0x0cdull << 20, 0x1ccull << 20, 0x1cdull << 20, 0x2ccull << 20, 0x2cdull << 20, 0x3ccull << 20, 0x3cdull << 20, 0x2aeull << 20, 0x2afull << 20, 0x0dcull << 20, 0x0ddull << 20, 0x1dcull << 20, 0x1ddull << 20, 0x2dcull << 20, 0x2ddull << 20, 0x3dcull << 20, 0x3ddull << 20, 0x2beull << 20, 0x2bfull << 20, 0x0ecull << 20, 0x0edull << 20, 0x1ecull << 20, 0x1edull << 20, 0x2ecull << 20, 0x2edull << 20, 0x3ecull << 20, 0x3edull << 20, 0x3aeull << 20, 0x3afull << 20, 0x0fcull << 20, 0x0fdull << 20, 0x1fcull << 20, 0x1fdull << 20, 0x2fcull << 20, 0x2fdull << 20, 0x3fcull << 20, 0x3fdull << 20, 0x3beull << 20, 0x3bfull << 20, 0x08eull << 20, 0x08full << 20, 0x18eull << 20, 0x18full << 20, 0x28eull << 20, 0x28full << 20, 0x38eull << 20, 0x38full << 20, 0x0eeull << 20, 0x0efull << 20, 0x09eull << 20, 0x09full << 20, 0x19eull << 20, 0x19full << 20, 0x29eull << 20, 0x29full << 20, 0x39eull << 20, 0x39full << 20, 0x0feull << 20, 0x0ffull << 20 }; static const UINT64 b2d4[] = { 0x000ull << 30, 0x001ull << 30, 0x002ull << 30, 0x003ull << 30, 0x004ull << 30, 0x005ull << 30, 0x006ull << 30, 0x007ull << 30, 0x008ull << 30, 0x009ull << 30, 0x010ull << 30, 0x011ull << 30, 0x012ull << 30, 0x013ull << 30, 0x014ull << 30, 0x015ull << 30, 0x016ull << 30, 0x017ull << 30, 0x018ull << 30, 0x019ull << 30, 0x020ull << 30, 0x021ull << 30, 0x022ull << 30, 0x023ull << 30, 0x024ull << 30, 0x025ull << 30, 0x026ull << 30, 0x027ull << 30, 0x028ull << 30, 0x029ull << 30, 0x030ull << 30, 0x031ull << 30, 0x032ull << 30, 0x033ull << 30, 0x034ull << 30, 0x035ull << 30, 0x036ull << 30, 0x037ull << 30, 0x038ull << 30, 0x039ull << 30, 0x040ull << 30, 0x041ull << 30, 0x042ull << 30, 0x043ull << 30, 0x044ull << 30, 0x045ull << 30, 0x046ull << 30, 0x047ull << 30, 0x048ull << 30, 0x049ull << 30, 0x050ull << 30, 0x051ull << 30, 0x052ull << 30, 0x053ull << 30, 0x054ull << 30, 0x055ull << 30, 0x056ull << 30, 0x057ull << 30, 0x058ull << 30, 0x059ull << 30, 0x060ull << 30, 0x061ull << 30, 0x062ull << 30, 0x063ull << 30, 0x064ull << 30, 0x065ull << 30, 0x066ull << 30, 0x067ull << 30, 0x068ull << 30, 0x069ull << 30, 0x070ull << 30, 0x071ull << 30, 0x072ull << 30, 0x073ull << 30, 0x074ull << 30, 0x075ull << 30, 0x076ull << 30, 0x077ull << 30, 0x078ull << 30, 0x079ull << 30, 0x00aull << 30, 0x00bull << 30, 0x02aull << 30, 0x02bull << 30, 0x04aull << 30, 0x04bull << 30, 0x06aull << 30, 0x06bull << 30, 0x04eull << 30, 0x04full << 30, 0x01aull << 30, 0x01bull << 30, 0x03aull << 30, 0x03bull << 30, 0x05aull << 30, 0x05bull << 30, 0x07aull << 30, 0x07bull << 30, 0x05eull << 30, 0x05full << 30, 0x080ull << 30, 0x081ull << 30, 0x082ull << 30, 0x083ull << 30, 0x084ull << 30, 0x085ull << 30, 0x086ull << 30, 0x087ull << 30, 0x088ull << 30, 0x089ull << 30, 0x090ull << 30, 0x091ull << 30, 0x092ull << 30, 0x093ull << 30, 0x094ull << 30, 0x095ull << 30, 0x096ull << 30, 0x097ull << 30, 0x098ull << 30, 0x099ull << 30, 0x0a0ull << 30, 0x0a1ull << 30, 0x0a2ull << 30, 0x0a3ull << 30, 0x0a4ull << 30, 0x0a5ull << 30, 0x0a6ull << 30, 0x0a7ull << 30, 0x0a8ull << 30, 0x0a9ull << 30, 0x0b0ull << 30, 0x0b1ull << 30, 0x0b2ull << 30, 0x0b3ull << 30, 0x0b4ull << 30, 0x0b5ull << 30, 0x0b6ull << 30, 0x0b7ull << 30, 0x0b8ull << 30, 0x0b9ull << 30, 0x0c0ull << 30, 0x0c1ull << 30, 0x0c2ull << 30, 0x0c3ull << 30, 0x0c4ull << 30, 0x0c5ull << 30, 0x0c6ull << 30, 0x0c7ull << 30, 0x0c8ull << 30, 0x0c9ull << 30, 0x0d0ull << 30, 0x0d1ull << 30, 0x0d2ull << 30, 0x0d3ull << 30, 0x0d4ull << 30, 0x0d5ull << 30, 0x0d6ull << 30, 0x0d7ull << 30, 0x0d8ull << 30, 0x0d9ull << 30, 0x0e0ull << 30, 0x0e1ull << 30, 0x0e2ull << 30, 0x0e3ull << 30, 0x0e4ull << 30, 0x0e5ull << 30, 0x0e6ull << 30, 0x0e7ull << 30, 0x0e8ull << 30, 0x0e9ull << 30, 0x0f0ull << 30, 0x0f1ull << 30, 0x0f2ull << 30, 0x0f3ull << 30, 0x0f4ull << 30, 0x0f5ull << 30, 0x0f6ull << 30, 0x0f7ull << 30, 0x0f8ull << 30, 0x0f9ull << 30, 0x08aull << 30, 0x08bull << 30, 0x0aaull << 30, 0x0abull << 30, 0x0caull << 30, 0x0cbull << 30, 0x0eaull << 30, 0x0ebull << 30, 0x0ceull << 30, 0x0cfull << 30, 0x09aull << 30, 0x09bull << 30, 0x0baull << 30, 0x0bbull << 30, 0x0daull << 30, 0x0dbull << 30, 0x0faull << 30, 0x0fbull << 30, 0x0deull << 30, 0x0dfull << 30, 0x100ull << 30, 0x101ull << 30, 0x102ull << 30, 0x103ull << 30, 0x104ull << 30, 0x105ull << 30, 0x106ull << 30, 0x107ull << 30, 0x108ull << 30, 0x109ull << 30, 0x110ull << 30, 0x111ull << 30, 0x112ull << 30, 0x113ull << 30, 0x114ull << 30, 0x115ull << 30, 0x116ull << 30, 0x117ull << 30, 0x118ull << 30, 0x119ull << 30, 0x120ull << 30, 0x121ull << 30, 0x122ull << 30, 0x123ull << 30, 0x124ull << 30, 0x125ull << 30, 0x126ull << 30, 0x127ull << 30, 0x128ull << 30, 0x129ull << 30, 0x130ull << 30, 0x131ull << 30, 0x132ull << 30, 0x133ull << 30, 0x134ull << 30, 0x135ull << 30, 0x136ull << 30, 0x137ull << 30, 0x138ull << 30, 0x139ull << 30, 0x140ull << 30, 0x141ull << 30, 0x142ull << 30, 0x143ull << 30, 0x144ull << 30, 0x145ull << 30, 0x146ull << 30, 0x147ull << 30, 0x148ull << 30, 0x149ull << 30, 0x150ull << 30, 0x151ull << 30, 0x152ull << 30, 0x153ull << 30, 0x154ull << 30, 0x155ull << 30, 0x156ull << 30, 0x157ull << 30, 0x158ull << 30, 0x159ull << 30, 0x160ull << 30, 0x161ull << 30, 0x162ull << 30, 0x163ull << 30, 0x164ull << 30, 0x165ull << 30, 0x166ull << 30, 0x167ull << 30, 0x168ull << 30, 0x169ull << 30, 0x170ull << 30, 0x171ull << 30, 0x172ull << 30, 0x173ull << 30, 0x174ull << 30, 0x175ull << 30, 0x176ull << 30, 0x177ull << 30, 0x178ull << 30, 0x179ull << 30, 0x10aull << 30, 0x10bull << 30, 0x12aull << 30, 0x12bull << 30, 0x14aull << 30, 0x14bull << 30, 0x16aull << 30, 0x16bull << 30, 0x14eull << 30, 0x14full << 30, 0x11aull << 30, 0x11bull << 30, 0x13aull << 30, 0x13bull << 30, 0x15aull << 30, 0x15bull << 30, 0x17aull << 30, 0x17bull << 30, 0x15eull << 30, 0x15full << 30, 0x180ull << 30, 0x181ull << 30, 0x182ull << 30, 0x183ull << 30, 0x184ull << 30, 0x185ull << 30, 0x186ull << 30, 0x187ull << 30, 0x188ull << 30, 0x189ull << 30, 0x190ull << 30, 0x191ull << 30, 0x192ull << 30, 0x193ull << 30, 0x194ull << 30, 0x195ull << 30, 0x196ull << 30, 0x197ull << 30, 0x198ull << 30, 0x199ull << 30, 0x1a0ull << 30, 0x1a1ull << 30, 0x1a2ull << 30, 0x1a3ull << 30, 0x1a4ull << 30, 0x1a5ull << 30, 0x1a6ull << 30, 0x1a7ull << 30, 0x1a8ull << 30, 0x1a9ull << 30, 0x1b0ull << 30, 0x1b1ull << 30, 0x1b2ull << 30, 0x1b3ull << 30, 0x1b4ull << 30, 0x1b5ull << 30, 0x1b6ull << 30, 0x1b7ull << 30, 0x1b8ull << 30, 0x1b9ull << 30, 0x1c0ull << 30, 0x1c1ull << 30, 0x1c2ull << 30, 0x1c3ull << 30, 0x1c4ull << 30, 0x1c5ull << 30, 0x1c6ull << 30, 0x1c7ull << 30, 0x1c8ull << 30, 0x1c9ull << 30, 0x1d0ull << 30, 0x1d1ull << 30, 0x1d2ull << 30, 0x1d3ull << 30, 0x1d4ull << 30, 0x1d5ull << 30, 0x1d6ull << 30, 0x1d7ull << 30, 0x1d8ull << 30, 0x1d9ull << 30, 0x1e0ull << 30, 0x1e1ull << 30, 0x1e2ull << 30, 0x1e3ull << 30, 0x1e4ull << 30, 0x1e5ull << 30, 0x1e6ull << 30, 0x1e7ull << 30, 0x1e8ull << 30, 0x1e9ull << 30, 0x1f0ull << 30, 0x1f1ull << 30, 0x1f2ull << 30, 0x1f3ull << 30, 0x1f4ull << 30, 0x1f5ull << 30, 0x1f6ull << 30, 0x1f7ull << 30, 0x1f8ull << 30, 0x1f9ull << 30, 0x18aull << 30, 0x18bull << 30, 0x1aaull << 30, 0x1abull << 30, 0x1caull << 30, 0x1cbull << 30, 0x1eaull << 30, 0x1ebull << 30, 0x1ceull << 30, 0x1cfull << 30, 0x19aull << 30, 0x19bull << 30, 0x1baull << 30, 0x1bbull << 30, 0x1daull << 30, 0x1dbull << 30, 0x1faull << 30, 0x1fbull << 30, 0x1deull << 30, 0x1dfull << 30, 0x200ull << 30, 0x201ull << 30, 0x202ull << 30, 0x203ull << 30, 0x204ull << 30, 0x205ull << 30, 0x206ull << 30, 0x207ull << 30, 0x208ull << 30, 0x209ull << 30, 0x210ull << 30, 0x211ull << 30, 0x212ull << 30, 0x213ull << 30, 0x214ull << 30, 0x215ull << 30, 0x216ull << 30, 0x217ull << 30, 0x218ull << 30, 0x219ull << 30, 0x220ull << 30, 0x221ull << 30, 0x222ull << 30, 0x223ull << 30, 0x224ull << 30, 0x225ull << 30, 0x226ull << 30, 0x227ull << 30, 0x228ull << 30, 0x229ull << 30, 0x230ull << 30, 0x231ull << 30, 0x232ull << 30, 0x233ull << 30, 0x234ull << 30, 0x235ull << 30, 0x236ull << 30, 0x237ull << 30, 0x238ull << 30, 0x239ull << 30, 0x240ull << 30, 0x241ull << 30, 0x242ull << 30, 0x243ull << 30, 0x244ull << 30, 0x245ull << 30, 0x246ull << 30, 0x247ull << 30, 0x248ull << 30, 0x249ull << 30, 0x250ull << 30, 0x251ull << 30, 0x252ull << 30, 0x253ull << 30, 0x254ull << 30, 0x255ull << 30, 0x256ull << 30, 0x257ull << 30, 0x258ull << 30, 0x259ull << 30, 0x260ull << 30, 0x261ull << 30, 0x262ull << 30, 0x263ull << 30, 0x264ull << 30, 0x265ull << 30, 0x266ull << 30, 0x267ull << 30, 0x268ull << 30, 0x269ull << 30, 0x270ull << 30, 0x271ull << 30, 0x272ull << 30, 0x273ull << 30, 0x274ull << 30, 0x275ull << 30, 0x276ull << 30, 0x277ull << 30, 0x278ull << 30, 0x279ull << 30, 0x20aull << 30, 0x20bull << 30, 0x22aull << 30, 0x22bull << 30, 0x24aull << 30, 0x24bull << 30, 0x26aull << 30, 0x26bull << 30, 0x24eull << 30, 0x24full << 30, 0x21aull << 30, 0x21bull << 30, 0x23aull << 30, 0x23bull << 30, 0x25aull << 30, 0x25bull << 30, 0x27aull << 30, 0x27bull << 30, 0x25eull << 30, 0x25full << 30, 0x280ull << 30, 0x281ull << 30, 0x282ull << 30, 0x283ull << 30, 0x284ull << 30, 0x285ull << 30, 0x286ull << 30, 0x287ull << 30, 0x288ull << 30, 0x289ull << 30, 0x290ull << 30, 0x291ull << 30, 0x292ull << 30, 0x293ull << 30, 0x294ull << 30, 0x295ull << 30, 0x296ull << 30, 0x297ull << 30, 0x298ull << 30, 0x299ull << 30, 0x2a0ull << 30, 0x2a1ull << 30, 0x2a2ull << 30, 0x2a3ull << 30, 0x2a4ull << 30, 0x2a5ull << 30, 0x2a6ull << 30, 0x2a7ull << 30, 0x2a8ull << 30, 0x2a9ull << 30, 0x2b0ull << 30, 0x2b1ull << 30, 0x2b2ull << 30, 0x2b3ull << 30, 0x2b4ull << 30, 0x2b5ull << 30, 0x2b6ull << 30, 0x2b7ull << 30, 0x2b8ull << 30, 0x2b9ull << 30, 0x2c0ull << 30, 0x2c1ull << 30, 0x2c2ull << 30, 0x2c3ull << 30, 0x2c4ull << 30, 0x2c5ull << 30, 0x2c6ull << 30, 0x2c7ull << 30, 0x2c8ull << 30, 0x2c9ull << 30, 0x2d0ull << 30, 0x2d1ull << 30, 0x2d2ull << 30, 0x2d3ull << 30, 0x2d4ull << 30, 0x2d5ull << 30, 0x2d6ull << 30, 0x2d7ull << 30, 0x2d8ull << 30, 0x2d9ull << 30, 0x2e0ull << 30, 0x2e1ull << 30, 0x2e2ull << 30, 0x2e3ull << 30, 0x2e4ull << 30, 0x2e5ull << 30, 0x2e6ull << 30, 0x2e7ull << 30, 0x2e8ull << 30, 0x2e9ull << 30, 0x2f0ull << 30, 0x2f1ull << 30, 0x2f2ull << 30, 0x2f3ull << 30, 0x2f4ull << 30, 0x2f5ull << 30, 0x2f6ull << 30, 0x2f7ull << 30, 0x2f8ull << 30, 0x2f9ull << 30, 0x28aull << 30, 0x28bull << 30, 0x2aaull << 30, 0x2abull << 30, 0x2caull << 30, 0x2cbull << 30, 0x2eaull << 30, 0x2ebull << 30, 0x2ceull << 30, 0x2cfull << 30, 0x29aull << 30, 0x29bull << 30, 0x2baull << 30, 0x2bbull << 30, 0x2daull << 30, 0x2dbull << 30, 0x2faull << 30, 0x2fbull << 30, 0x2deull << 30, 0x2dfull << 30, 0x300ull << 30, 0x301ull << 30, 0x302ull << 30, 0x303ull << 30, 0x304ull << 30, 0x305ull << 30, 0x306ull << 30, 0x307ull << 30, 0x308ull << 30, 0x309ull << 30, 0x310ull << 30, 0x311ull << 30, 0x312ull << 30, 0x313ull << 30, 0x314ull << 30, 0x315ull << 30, 0x316ull << 30, 0x317ull << 30, 0x318ull << 30, 0x319ull << 30, 0x320ull << 30, 0x321ull << 30, 0x322ull << 30, 0x323ull << 30, 0x324ull << 30, 0x325ull << 30, 0x326ull << 30, 0x327ull << 30, 0x328ull << 30, 0x329ull << 30, 0x330ull << 30, 0x331ull << 30, 0x332ull << 30, 0x333ull << 30, 0x334ull << 30, 0x335ull << 30, 0x336ull << 30, 0x337ull << 30, 0x338ull << 30, 0x339ull << 30, 0x340ull << 30, 0x341ull << 30, 0x342ull << 30, 0x343ull << 30, 0x344ull << 30, 0x345ull << 30, 0x346ull << 30, 0x347ull << 30, 0x348ull << 30, 0x349ull << 30, 0x350ull << 30, 0x351ull << 30, 0x352ull << 30, 0x353ull << 30, 0x354ull << 30, 0x355ull << 30, 0x356ull << 30, 0x357ull << 30, 0x358ull << 30, 0x359ull << 30, 0x360ull << 30, 0x361ull << 30, 0x362ull << 30, 0x363ull << 30, 0x364ull << 30, 0x365ull << 30, 0x366ull << 30, 0x367ull << 30, 0x368ull << 30, 0x369ull << 30, 0x370ull << 30, 0x371ull << 30, 0x372ull << 30, 0x373ull << 30, 0x374ull << 30, 0x375ull << 30, 0x376ull << 30, 0x377ull << 30, 0x378ull << 30, 0x379ull << 30, 0x30aull << 30, 0x30bull << 30, 0x32aull << 30, 0x32bull << 30, 0x34aull << 30, 0x34bull << 30, 0x36aull << 30, 0x36bull << 30, 0x34eull << 30, 0x34full << 30, 0x31aull << 30, 0x31bull << 30, 0x33aull << 30, 0x33bull << 30, 0x35aull << 30, 0x35bull << 30, 0x37aull << 30, 0x37bull << 30, 0x35eull << 30, 0x35full << 30, 0x380ull << 30, 0x381ull << 30, 0x382ull << 30, 0x383ull << 30, 0x384ull << 30, 0x385ull << 30, 0x386ull << 30, 0x387ull << 30, 0x388ull << 30, 0x389ull << 30, 0x390ull << 30, 0x391ull << 30, 0x392ull << 30, 0x393ull << 30, 0x394ull << 30, 0x395ull << 30, 0x396ull << 30, 0x397ull << 30, 0x398ull << 30, 0x399ull << 30, 0x3a0ull << 30, 0x3a1ull << 30, 0x3a2ull << 30, 0x3a3ull << 30, 0x3a4ull << 30, 0x3a5ull << 30, 0x3a6ull << 30, 0x3a7ull << 30, 0x3a8ull << 30, 0x3a9ull << 30, 0x3b0ull << 30, 0x3b1ull << 30, 0x3b2ull << 30, 0x3b3ull << 30, 0x3b4ull << 30, 0x3b5ull << 30, 0x3b6ull << 30, 0x3b7ull << 30, 0x3b8ull << 30, 0x3b9ull << 30, 0x3c0ull << 30, 0x3c1ull << 30, 0x3c2ull << 30, 0x3c3ull << 30, 0x3c4ull << 30, 0x3c5ull << 30, 0x3c6ull << 30, 0x3c7ull << 30, 0x3c8ull << 30, 0x3c9ull << 30, 0x3d0ull << 30, 0x3d1ull << 30, 0x3d2ull << 30, 0x3d3ull << 30, 0x3d4ull << 30, 0x3d5ull << 30, 0x3d6ull << 30, 0x3d7ull << 30, 0x3d8ull << 30, 0x3d9ull << 30, 0x3e0ull << 30, 0x3e1ull << 30, 0x3e2ull << 30, 0x3e3ull << 30, 0x3e4ull << 30, 0x3e5ull << 30, 0x3e6ull << 30, 0x3e7ull << 30, 0x3e8ull << 30, 0x3e9ull << 30, 0x3f0ull << 30, 0x3f1ull << 30, 0x3f2ull << 30, 0x3f3ull << 30, 0x3f4ull << 30, 0x3f5ull << 30, 0x3f6ull << 30, 0x3f7ull << 30, 0x3f8ull << 30, 0x3f9ull << 30, 0x38aull << 30, 0x38bull << 30, 0x3aaull << 30, 0x3abull << 30, 0x3caull << 30, 0x3cbull << 30, 0x3eaull << 30, 0x3ebull << 30, 0x3ceull << 30, 0x3cfull << 30, 0x39aull << 30, 0x39bull << 30, 0x3baull << 30, 0x3bbull << 30, 0x3daull << 30, 0x3dbull << 30, 0x3faull << 30, 0x3fbull << 30, 0x3deull << 30, 0x3dfull << 30, 0x00cull << 30, 0x00dull << 30, 0x10cull << 30, 0x10dull << 30, 0x20cull << 30, 0x20dull << 30, 0x30cull << 30, 0x30dull << 30, 0x02eull << 30, 0x02full << 30, 0x01cull << 30, 0x01dull << 30, 0x11cull << 30, 0x11dull << 30, 0x21cull << 30, 0x21dull << 30, 0x31cull << 30, 0x31dull << 30, 0x03eull << 30, 0x03full << 30, 0x02cull << 30, 0x02dull << 30, 0x12cull << 30, 0x12dull << 30, 0x22cull << 30, 0x22dull << 30, 0x32cull << 30, 0x32dull << 30, 0x12eull << 30, 0x12full << 30, 0x03cull << 30, 0x03dull << 30, 0x13cull << 30, 0x13dull << 30, 0x23cull << 30, 0x23dull << 30, 0x33cull << 30, 0x33dull << 30, 0x13eull << 30, 0x13full << 30, 0x04cull << 30, 0x04dull << 30, 0x14cull << 30, 0x14dull << 30, 0x24cull << 30, 0x24dull << 30, 0x34cull << 30, 0x34dull << 30, 0x22eull << 30, 0x22full << 30, 0x05cull << 30, 0x05dull << 30, 0x15cull << 30, 0x15dull << 30, 0x25cull << 30, 0x25dull << 30, 0x35cull << 30, 0x35dull << 30, 0x23eull << 30, 0x23full << 30, 0x06cull << 30, 0x06dull << 30, 0x16cull << 30, 0x16dull << 30, 0x26cull << 30, 0x26dull << 30, 0x36cull << 30, 0x36dull << 30, 0x32eull << 30, 0x32full << 30, 0x07cull << 30, 0x07dull << 30, 0x17cull << 30, 0x17dull << 30, 0x27cull << 30, 0x27dull << 30, 0x37cull << 30, 0x37dull << 30, 0x33eull << 30, 0x33full << 30, 0x00eull << 30, 0x00full << 30, 0x10eull << 30, 0x10full << 30, 0x20eull << 30, 0x20full << 30, 0x30eull << 30, 0x30full << 30, 0x06eull << 30, 0x06full << 30, 0x01eull << 30, 0x01full << 30, 0x11eull << 30, 0x11full << 30, 0x21eull << 30, 0x21full << 30, 0x31eull << 30, 0x31full << 30, 0x07eull << 30, 0x07full << 30, 0x08cull << 30, 0x08dull << 30, 0x18cull << 30, 0x18dull << 30, 0x28cull << 30, 0x28dull << 30, 0x38cull << 30, 0x38dull << 30, 0x0aeull << 30, 0x0afull << 30, 0x09cull << 30, 0x09dull << 30, 0x19cull << 30, 0x19dull << 30, 0x29cull << 30, 0x29dull << 30, 0x39cull << 30, 0x39dull << 30, 0x0beull << 30, 0x0bfull << 30, 0x0acull << 30, 0x0adull << 30, 0x1acull << 30, 0x1adull << 30, 0x2acull << 30, 0x2adull << 30, 0x3acull << 30, 0x3adull << 30, 0x1aeull << 30, 0x1afull << 30, 0x0bcull << 30, 0x0bdull << 30, 0x1bcull << 30, 0x1bdull << 30, 0x2bcull << 30, 0x2bdull << 30, 0x3bcull << 30, 0x3bdull << 30, 0x1beull << 30, 0x1bfull << 30, 0x0ccull << 30, 0x0cdull << 30, 0x1ccull << 30, 0x1cdull << 30, 0x2ccull << 30, 0x2cdull << 30, 0x3ccull << 30, 0x3cdull << 30, 0x2aeull << 30, 0x2afull << 30, 0x0dcull << 30, 0x0ddull << 30, 0x1dcull << 30, 0x1ddull << 30, 0x2dcull << 30, 0x2ddull << 30, 0x3dcull << 30, 0x3ddull << 30, 0x2beull << 30, 0x2bfull << 30, 0x0ecull << 30, 0x0edull << 30, 0x1ecull << 30, 0x1edull << 30, 0x2ecull << 30, 0x2edull << 30, 0x3ecull << 30, 0x3edull << 30, 0x3aeull << 30, 0x3afull << 30, 0x0fcull << 30, 0x0fdull << 30, 0x1fcull << 30, 0x1fdull << 30, 0x2fcull << 30, 0x2fdull << 30, 0x3fcull << 30, 0x3fdull << 30, 0x3beull << 30, 0x3bfull << 30, 0x08eull << 30, 0x08full << 30, 0x18eull << 30, 0x18full << 30, 0x28eull << 30, 0x28full << 30, 0x38eull << 30, 0x38full << 30, 0x0eeull << 30, 0x0efull << 30, 0x09eull << 30, 0x09full << 30, 0x19eull << 30, 0x19full << 30, 0x29eull << 30, 0x29full << 30, 0x39eull << 30, 0x39full << 30, 0x0feull << 30, 0x0ffull << 30 }; static const UINT64 b2d5[] = { 0x000ull << 40, 0x001ull << 40, 0x002ull << 40, 0x003ull << 40, 0x004ull << 40, 0x005ull << 40, 0x006ull << 40, 0x007ull << 40, 0x008ull << 40, 0x009ull << 40, 0x010ull << 40, 0x011ull << 40, 0x012ull << 40, 0x013ull << 40, 0x014ull << 40, 0x015ull << 40, 0x016ull << 40, 0x017ull << 40, 0x018ull << 40, 0x019ull << 40, 0x020ull << 40, 0x021ull << 40, 0x022ull << 40, 0x023ull << 40, 0x024ull << 40, 0x025ull << 40, 0x026ull << 40, 0x027ull << 40, 0x028ull << 40, 0x029ull << 40, 0x030ull << 40, 0x031ull << 40, 0x032ull << 40, 0x033ull << 40, 0x034ull << 40, 0x035ull << 40, 0x036ull << 40, 0x037ull << 40, 0x038ull << 40, 0x039ull << 40, 0x040ull << 40, 0x041ull << 40, 0x042ull << 40, 0x043ull << 40, 0x044ull << 40, 0x045ull << 40, 0x046ull << 40, 0x047ull << 40, 0x048ull << 40, 0x049ull << 40, 0x050ull << 40, 0x051ull << 40, 0x052ull << 40, 0x053ull << 40, 0x054ull << 40, 0x055ull << 40, 0x056ull << 40, 0x057ull << 40, 0x058ull << 40, 0x059ull << 40, 0x060ull << 40, 0x061ull << 40, 0x062ull << 40, 0x063ull << 40, 0x064ull << 40, 0x065ull << 40, 0x066ull << 40, 0x067ull << 40, 0x068ull << 40, 0x069ull << 40, 0x070ull << 40, 0x071ull << 40, 0x072ull << 40, 0x073ull << 40, 0x074ull << 40, 0x075ull << 40, 0x076ull << 40, 0x077ull << 40, 0x078ull << 40, 0x079ull << 40, 0x00aull << 40, 0x00bull << 40, 0x02aull << 40, 0x02bull << 40, 0x04aull << 40, 0x04bull << 40, 0x06aull << 40, 0x06bull << 40, 0x04eull << 40, 0x04full << 40, 0x01aull << 40, 0x01bull << 40, 0x03aull << 40, 0x03bull << 40, 0x05aull << 40, 0x05bull << 40, 0x07aull << 40, 0x07bull << 40, 0x05eull << 40, 0x05full << 40, 0x080ull << 40, 0x081ull << 40, 0x082ull << 40, 0x083ull << 40, 0x084ull << 40, 0x085ull << 40, 0x086ull << 40, 0x087ull << 40, 0x088ull << 40, 0x089ull << 40, 0x090ull << 40, 0x091ull << 40, 0x092ull << 40, 0x093ull << 40, 0x094ull << 40, 0x095ull << 40, 0x096ull << 40, 0x097ull << 40, 0x098ull << 40, 0x099ull << 40, 0x0a0ull << 40, 0x0a1ull << 40, 0x0a2ull << 40, 0x0a3ull << 40, 0x0a4ull << 40, 0x0a5ull << 40, 0x0a6ull << 40, 0x0a7ull << 40, 0x0a8ull << 40, 0x0a9ull << 40, 0x0b0ull << 40, 0x0b1ull << 40, 0x0b2ull << 40, 0x0b3ull << 40, 0x0b4ull << 40, 0x0b5ull << 40, 0x0b6ull << 40, 0x0b7ull << 40, 0x0b8ull << 40, 0x0b9ull << 40, 0x0c0ull << 40, 0x0c1ull << 40, 0x0c2ull << 40, 0x0c3ull << 40, 0x0c4ull << 40, 0x0c5ull << 40, 0x0c6ull << 40, 0x0c7ull << 40, 0x0c8ull << 40, 0x0c9ull << 40, 0x0d0ull << 40, 0x0d1ull << 40, 0x0d2ull << 40, 0x0d3ull << 40, 0x0d4ull << 40, 0x0d5ull << 40, 0x0d6ull << 40, 0x0d7ull << 40, 0x0d8ull << 40, 0x0d9ull << 40, 0x0e0ull << 40, 0x0e1ull << 40, 0x0e2ull << 40, 0x0e3ull << 40, 0x0e4ull << 40, 0x0e5ull << 40, 0x0e6ull << 40, 0x0e7ull << 40, 0x0e8ull << 40, 0x0e9ull << 40, 0x0f0ull << 40, 0x0f1ull << 40, 0x0f2ull << 40, 0x0f3ull << 40, 0x0f4ull << 40, 0x0f5ull << 40, 0x0f6ull << 40, 0x0f7ull << 40, 0x0f8ull << 40, 0x0f9ull << 40, 0x08aull << 40, 0x08bull << 40, 0x0aaull << 40, 0x0abull << 40, 0x0caull << 40, 0x0cbull << 40, 0x0eaull << 40, 0x0ebull << 40, 0x0ceull << 40, 0x0cfull << 40, 0x09aull << 40, 0x09bull << 40, 0x0baull << 40, 0x0bbull << 40, 0x0daull << 40, 0x0dbull << 40, 0x0faull << 40, 0x0fbull << 40, 0x0deull << 40, 0x0dfull << 40, 0x100ull << 40, 0x101ull << 40, 0x102ull << 40, 0x103ull << 40, 0x104ull << 40, 0x105ull << 40, 0x106ull << 40, 0x107ull << 40, 0x108ull << 40, 0x109ull << 40, 0x110ull << 40, 0x111ull << 40, 0x112ull << 40, 0x113ull << 40, 0x114ull << 40, 0x115ull << 40, 0x116ull << 40, 0x117ull << 40, 0x118ull << 40, 0x119ull << 40, 0x120ull << 40, 0x121ull << 40, 0x122ull << 40, 0x123ull << 40, 0x124ull << 40, 0x125ull << 40, 0x126ull << 40, 0x127ull << 40, 0x128ull << 40, 0x129ull << 40, 0x130ull << 40, 0x131ull << 40, 0x132ull << 40, 0x133ull << 40, 0x134ull << 40, 0x135ull << 40, 0x136ull << 40, 0x137ull << 40, 0x138ull << 40, 0x139ull << 40, 0x140ull << 40, 0x141ull << 40, 0x142ull << 40, 0x143ull << 40, 0x144ull << 40, 0x145ull << 40, 0x146ull << 40, 0x147ull << 40, 0x148ull << 40, 0x149ull << 40, 0x150ull << 40, 0x151ull << 40, 0x152ull << 40, 0x153ull << 40, 0x154ull << 40, 0x155ull << 40, 0x156ull << 40, 0x157ull << 40, 0x158ull << 40, 0x159ull << 40, 0x160ull << 40, 0x161ull << 40, 0x162ull << 40, 0x163ull << 40, 0x164ull << 40, 0x165ull << 40, 0x166ull << 40, 0x167ull << 40, 0x168ull << 40, 0x169ull << 40, 0x170ull << 40, 0x171ull << 40, 0x172ull << 40, 0x173ull << 40, 0x174ull << 40, 0x175ull << 40, 0x176ull << 40, 0x177ull << 40, 0x178ull << 40, 0x179ull << 40, 0x10aull << 40, 0x10bull << 40, 0x12aull << 40, 0x12bull << 40, 0x14aull << 40, 0x14bull << 40, 0x16aull << 40, 0x16bull << 40, 0x14eull << 40, 0x14full << 40, 0x11aull << 40, 0x11bull << 40, 0x13aull << 40, 0x13bull << 40, 0x15aull << 40, 0x15bull << 40, 0x17aull << 40, 0x17bull << 40, 0x15eull << 40, 0x15full << 40, 0x180ull << 40, 0x181ull << 40, 0x182ull << 40, 0x183ull << 40, 0x184ull << 40, 0x185ull << 40, 0x186ull << 40, 0x187ull << 40, 0x188ull << 40, 0x189ull << 40, 0x190ull << 40, 0x191ull << 40, 0x192ull << 40, 0x193ull << 40, 0x194ull << 40, 0x195ull << 40, 0x196ull << 40, 0x197ull << 40, 0x198ull << 40, 0x199ull << 40, 0x1a0ull << 40, 0x1a1ull << 40, 0x1a2ull << 40, 0x1a3ull << 40, 0x1a4ull << 40, 0x1a5ull << 40, 0x1a6ull << 40, 0x1a7ull << 40, 0x1a8ull << 40, 0x1a9ull << 40, 0x1b0ull << 40, 0x1b1ull << 40, 0x1b2ull << 40, 0x1b3ull << 40, 0x1b4ull << 40, 0x1b5ull << 40, 0x1b6ull << 40, 0x1b7ull << 40, 0x1b8ull << 40, 0x1b9ull << 40, 0x1c0ull << 40, 0x1c1ull << 40, 0x1c2ull << 40, 0x1c3ull << 40, 0x1c4ull << 40, 0x1c5ull << 40, 0x1c6ull << 40, 0x1c7ull << 40, 0x1c8ull << 40, 0x1c9ull << 40, 0x1d0ull << 40, 0x1d1ull << 40, 0x1d2ull << 40, 0x1d3ull << 40, 0x1d4ull << 40, 0x1d5ull << 40, 0x1d6ull << 40, 0x1d7ull << 40, 0x1d8ull << 40, 0x1d9ull << 40, 0x1e0ull << 40, 0x1e1ull << 40, 0x1e2ull << 40, 0x1e3ull << 40, 0x1e4ull << 40, 0x1e5ull << 40, 0x1e6ull << 40, 0x1e7ull << 40, 0x1e8ull << 40, 0x1e9ull << 40, 0x1f0ull << 40, 0x1f1ull << 40, 0x1f2ull << 40, 0x1f3ull << 40, 0x1f4ull << 40, 0x1f5ull << 40, 0x1f6ull << 40, 0x1f7ull << 40, 0x1f8ull << 40, 0x1f9ull << 40, 0x18aull << 40, 0x18bull << 40, 0x1aaull << 40, 0x1abull << 40, 0x1caull << 40, 0x1cbull << 40, 0x1eaull << 40, 0x1ebull << 40, 0x1ceull << 40, 0x1cfull << 40, 0x19aull << 40, 0x19bull << 40, 0x1baull << 40, 0x1bbull << 40, 0x1daull << 40, 0x1dbull << 40, 0x1faull << 40, 0x1fbull << 40, 0x1deull << 40, 0x1dfull << 40, 0x200ull << 40, 0x201ull << 40, 0x202ull << 40, 0x203ull << 40, 0x204ull << 40, 0x205ull << 40, 0x206ull << 40, 0x207ull << 40, 0x208ull << 40, 0x209ull << 40, 0x210ull << 40, 0x211ull << 40, 0x212ull << 40, 0x213ull << 40, 0x214ull << 40, 0x215ull << 40, 0x216ull << 40, 0x217ull << 40, 0x218ull << 40, 0x219ull << 40, 0x220ull << 40, 0x221ull << 40, 0x222ull << 40, 0x223ull << 40, 0x224ull << 40, 0x225ull << 40, 0x226ull << 40, 0x227ull << 40, 0x228ull << 40, 0x229ull << 40, 0x230ull << 40, 0x231ull << 40, 0x232ull << 40, 0x233ull << 40, 0x234ull << 40, 0x235ull << 40, 0x236ull << 40, 0x237ull << 40, 0x238ull << 40, 0x239ull << 40, 0x240ull << 40, 0x241ull << 40, 0x242ull << 40, 0x243ull << 40, 0x244ull << 40, 0x245ull << 40, 0x246ull << 40, 0x247ull << 40, 0x248ull << 40, 0x249ull << 40, 0x250ull << 40, 0x251ull << 40, 0x252ull << 40, 0x253ull << 40, 0x254ull << 40, 0x255ull << 40, 0x256ull << 40, 0x257ull << 40, 0x258ull << 40, 0x259ull << 40, 0x260ull << 40, 0x261ull << 40, 0x262ull << 40, 0x263ull << 40, 0x264ull << 40, 0x265ull << 40, 0x266ull << 40, 0x267ull << 40, 0x268ull << 40, 0x269ull << 40, 0x270ull << 40, 0x271ull << 40, 0x272ull << 40, 0x273ull << 40, 0x274ull << 40, 0x275ull << 40, 0x276ull << 40, 0x277ull << 40, 0x278ull << 40, 0x279ull << 40, 0x20aull << 40, 0x20bull << 40, 0x22aull << 40, 0x22bull << 40, 0x24aull << 40, 0x24bull << 40, 0x26aull << 40, 0x26bull << 40, 0x24eull << 40, 0x24full << 40, 0x21aull << 40, 0x21bull << 40, 0x23aull << 40, 0x23bull << 40, 0x25aull << 40, 0x25bull << 40, 0x27aull << 40, 0x27bull << 40, 0x25eull << 40, 0x25full << 40, 0x280ull << 40, 0x281ull << 40, 0x282ull << 40, 0x283ull << 40, 0x284ull << 40, 0x285ull << 40, 0x286ull << 40, 0x287ull << 40, 0x288ull << 40, 0x289ull << 40, 0x290ull << 40, 0x291ull << 40, 0x292ull << 40, 0x293ull << 40, 0x294ull << 40, 0x295ull << 40, 0x296ull << 40, 0x297ull << 40, 0x298ull << 40, 0x299ull << 40, 0x2a0ull << 40, 0x2a1ull << 40, 0x2a2ull << 40, 0x2a3ull << 40, 0x2a4ull << 40, 0x2a5ull << 40, 0x2a6ull << 40, 0x2a7ull << 40, 0x2a8ull << 40, 0x2a9ull << 40, 0x2b0ull << 40, 0x2b1ull << 40, 0x2b2ull << 40, 0x2b3ull << 40, 0x2b4ull << 40, 0x2b5ull << 40, 0x2b6ull << 40, 0x2b7ull << 40, 0x2b8ull << 40, 0x2b9ull << 40, 0x2c0ull << 40, 0x2c1ull << 40, 0x2c2ull << 40, 0x2c3ull << 40, 0x2c4ull << 40, 0x2c5ull << 40, 0x2c6ull << 40, 0x2c7ull << 40, 0x2c8ull << 40, 0x2c9ull << 40, 0x2d0ull << 40, 0x2d1ull << 40, 0x2d2ull << 40, 0x2d3ull << 40, 0x2d4ull << 40, 0x2d5ull << 40, 0x2d6ull << 40, 0x2d7ull << 40, 0x2d8ull << 40, 0x2d9ull << 40, 0x2e0ull << 40, 0x2e1ull << 40, 0x2e2ull << 40, 0x2e3ull << 40, 0x2e4ull << 40, 0x2e5ull << 40, 0x2e6ull << 40, 0x2e7ull << 40, 0x2e8ull << 40, 0x2e9ull << 40, 0x2f0ull << 40, 0x2f1ull << 40, 0x2f2ull << 40, 0x2f3ull << 40, 0x2f4ull << 40, 0x2f5ull << 40, 0x2f6ull << 40, 0x2f7ull << 40, 0x2f8ull << 40, 0x2f9ull << 40, 0x28aull << 40, 0x28bull << 40, 0x2aaull << 40, 0x2abull << 40, 0x2caull << 40, 0x2cbull << 40, 0x2eaull << 40, 0x2ebull << 40, 0x2ceull << 40, 0x2cfull << 40, 0x29aull << 40, 0x29bull << 40, 0x2baull << 40, 0x2bbull << 40, 0x2daull << 40, 0x2dbull << 40, 0x2faull << 40, 0x2fbull << 40, 0x2deull << 40, 0x2dfull << 40, 0x300ull << 40, 0x301ull << 40, 0x302ull << 40, 0x303ull << 40, 0x304ull << 40, 0x305ull << 40, 0x306ull << 40, 0x307ull << 40, 0x308ull << 40, 0x309ull << 40, 0x310ull << 40, 0x311ull << 40, 0x312ull << 40, 0x313ull << 40, 0x314ull << 40, 0x315ull << 40, 0x316ull << 40, 0x317ull << 40, 0x318ull << 40, 0x319ull << 40, 0x320ull << 40, 0x321ull << 40, 0x322ull << 40, 0x323ull << 40, 0x324ull << 40, 0x325ull << 40, 0x326ull << 40, 0x327ull << 40, 0x328ull << 40, 0x329ull << 40, 0x330ull << 40, 0x331ull << 40, 0x332ull << 40, 0x333ull << 40, 0x334ull << 40, 0x335ull << 40, 0x336ull << 40, 0x337ull << 40, 0x338ull << 40, 0x339ull << 40, 0x340ull << 40, 0x341ull << 40, 0x342ull << 40, 0x343ull << 40, 0x344ull << 40, 0x345ull << 40, 0x346ull << 40, 0x347ull << 40, 0x348ull << 40, 0x349ull << 40, 0x350ull << 40, 0x351ull << 40, 0x352ull << 40, 0x353ull << 40, 0x354ull << 40, 0x355ull << 40, 0x356ull << 40, 0x357ull << 40, 0x358ull << 40, 0x359ull << 40, 0x360ull << 40, 0x361ull << 40, 0x362ull << 40, 0x363ull << 40, 0x364ull << 40, 0x365ull << 40, 0x366ull << 40, 0x367ull << 40, 0x368ull << 40, 0x369ull << 40, 0x370ull << 40, 0x371ull << 40, 0x372ull << 40, 0x373ull << 40, 0x374ull << 40, 0x375ull << 40, 0x376ull << 40, 0x377ull << 40, 0x378ull << 40, 0x379ull << 40, 0x30aull << 40, 0x30bull << 40, 0x32aull << 40, 0x32bull << 40, 0x34aull << 40, 0x34bull << 40, 0x36aull << 40, 0x36bull << 40, 0x34eull << 40, 0x34full << 40, 0x31aull << 40, 0x31bull << 40, 0x33aull << 40, 0x33bull << 40, 0x35aull << 40, 0x35bull << 40, 0x37aull << 40, 0x37bull << 40, 0x35eull << 40, 0x35full << 40, 0x380ull << 40, 0x381ull << 40, 0x382ull << 40, 0x383ull << 40, 0x384ull << 40, 0x385ull << 40, 0x386ull << 40, 0x387ull << 40, 0x388ull << 40, 0x389ull << 40, 0x390ull << 40, 0x391ull << 40, 0x392ull << 40, 0x393ull << 40, 0x394ull << 40, 0x395ull << 40, 0x396ull << 40, 0x397ull << 40, 0x398ull << 40, 0x399ull << 40, 0x3a0ull << 40, 0x3a1ull << 40, 0x3a2ull << 40, 0x3a3ull << 40, 0x3a4ull << 40, 0x3a5ull << 40, 0x3a6ull << 40, 0x3a7ull << 40, 0x3a8ull << 40, 0x3a9ull << 40, 0x3b0ull << 40, 0x3b1ull << 40, 0x3b2ull << 40, 0x3b3ull << 40, 0x3b4ull << 40, 0x3b5ull << 40, 0x3b6ull << 40, 0x3b7ull << 40, 0x3b8ull << 40, 0x3b9ull << 40, 0x3c0ull << 40, 0x3c1ull << 40, 0x3c2ull << 40, 0x3c3ull << 40, 0x3c4ull << 40, 0x3c5ull << 40, 0x3c6ull << 40, 0x3c7ull << 40, 0x3c8ull << 40, 0x3c9ull << 40, 0x3d0ull << 40, 0x3d1ull << 40, 0x3d2ull << 40, 0x3d3ull << 40, 0x3d4ull << 40, 0x3d5ull << 40, 0x3d6ull << 40, 0x3d7ull << 40, 0x3d8ull << 40, 0x3d9ull << 40, 0x3e0ull << 40, 0x3e1ull << 40, 0x3e2ull << 40, 0x3e3ull << 40, 0x3e4ull << 40, 0x3e5ull << 40, 0x3e6ull << 40, 0x3e7ull << 40, 0x3e8ull << 40, 0x3e9ull << 40, 0x3f0ull << 40, 0x3f1ull << 40, 0x3f2ull << 40, 0x3f3ull << 40, 0x3f4ull << 40, 0x3f5ull << 40, 0x3f6ull << 40, 0x3f7ull << 40, 0x3f8ull << 40, 0x3f9ull << 40, 0x38aull << 40, 0x38bull << 40, 0x3aaull << 40, 0x3abull << 40, 0x3caull << 40, 0x3cbull << 40, 0x3eaull << 40, 0x3ebull << 40, 0x3ceull << 40, 0x3cfull << 40, 0x39aull << 40, 0x39bull << 40, 0x3baull << 40, 0x3bbull << 40, 0x3daull << 40, 0x3dbull << 40, 0x3faull << 40, 0x3fbull << 40, 0x3deull << 40, 0x3dfull << 40, 0x00cull << 40, 0x00dull << 40, 0x10cull << 40, 0x10dull << 40, 0x20cull << 40, 0x20dull << 40, 0x30cull << 40, 0x30dull << 40, 0x02eull << 40, 0x02full << 40, 0x01cull << 40, 0x01dull << 40, 0x11cull << 40, 0x11dull << 40, 0x21cull << 40, 0x21dull << 40, 0x31cull << 40, 0x31dull << 40, 0x03eull << 40, 0x03full << 40, 0x02cull << 40, 0x02dull << 40, 0x12cull << 40, 0x12dull << 40, 0x22cull << 40, 0x22dull << 40, 0x32cull << 40, 0x32dull << 40, 0x12eull << 40, 0x12full << 40, 0x03cull << 40, 0x03dull << 40, 0x13cull << 40, 0x13dull << 40, 0x23cull << 40, 0x23dull << 40, 0x33cull << 40, 0x33dull << 40, 0x13eull << 40, 0x13full << 40, 0x04cull << 40, 0x04dull << 40, 0x14cull << 40, 0x14dull << 40, 0x24cull << 40, 0x24dull << 40, 0x34cull << 40, 0x34dull << 40, 0x22eull << 40, 0x22full << 40, 0x05cull << 40, 0x05dull << 40, 0x15cull << 40, 0x15dull << 40, 0x25cull << 40, 0x25dull << 40, 0x35cull << 40, 0x35dull << 40, 0x23eull << 40, 0x23full << 40, 0x06cull << 40, 0x06dull << 40, 0x16cull << 40, 0x16dull << 40, 0x26cull << 40, 0x26dull << 40, 0x36cull << 40, 0x36dull << 40, 0x32eull << 40, 0x32full << 40, 0x07cull << 40, 0x07dull << 40, 0x17cull << 40, 0x17dull << 40, 0x27cull << 40, 0x27dull << 40, 0x37cull << 40, 0x37dull << 40, 0x33eull << 40, 0x33full << 40, 0x00eull << 40, 0x00full << 40, 0x10eull << 40, 0x10full << 40, 0x20eull << 40, 0x20full << 40, 0x30eull << 40, 0x30full << 40, 0x06eull << 40, 0x06full << 40, 0x01eull << 40, 0x01full << 40, 0x11eull << 40, 0x11full << 40, 0x21eull << 40, 0x21full << 40, 0x31eull << 40, 0x31full << 40, 0x07eull << 40, 0x07full << 40, 0x08cull << 40, 0x08dull << 40, 0x18cull << 40, 0x18dull << 40, 0x28cull << 40, 0x28dull << 40, 0x38cull << 40, 0x38dull << 40, 0x0aeull << 40, 0x0afull << 40, 0x09cull << 40, 0x09dull << 40, 0x19cull << 40, 0x19dull << 40, 0x29cull << 40, 0x29dull << 40, 0x39cull << 40, 0x39dull << 40, 0x0beull << 40, 0x0bfull << 40, 0x0acull << 40, 0x0adull << 40, 0x1acull << 40, 0x1adull << 40, 0x2acull << 40, 0x2adull << 40, 0x3acull << 40, 0x3adull << 40, 0x1aeull << 40, 0x1afull << 40, 0x0bcull << 40, 0x0bdull << 40, 0x1bcull << 40, 0x1bdull << 40, 0x2bcull << 40, 0x2bdull << 40, 0x3bcull << 40, 0x3bdull << 40, 0x1beull << 40, 0x1bfull << 40, 0x0ccull << 40, 0x0cdull << 40, 0x1ccull << 40, 0x1cdull << 40, 0x2ccull << 40, 0x2cdull << 40, 0x3ccull << 40, 0x3cdull << 40, 0x2aeull << 40, 0x2afull << 40, 0x0dcull << 40, 0x0ddull << 40, 0x1dcull << 40, 0x1ddull << 40, 0x2dcull << 40, 0x2ddull << 40, 0x3dcull << 40, 0x3ddull << 40, 0x2beull << 40, 0x2bfull << 40, 0x0ecull << 40, 0x0edull << 40, 0x1ecull << 40, 0x1edull << 40, 0x2ecull << 40, 0x2edull << 40, 0x3ecull << 40, 0x3edull << 40, 0x3aeull << 40, 0x3afull << 40, 0x0fcull << 40, 0x0fdull << 40, 0x1fcull << 40, 0x1fdull << 40, 0x2fcull << 40, 0x2fdull << 40, 0x3fcull << 40, 0x3fdull << 40, 0x3beull << 40, 0x3bfull << 40, 0x08eull << 40, 0x08full << 40, 0x18eull << 40, 0x18full << 40, 0x28eull << 40, 0x28full << 40, 0x38eull << 40, 0x38full << 40, 0x0eeull << 40, 0x0efull << 40, 0x09eull << 40, 0x09full << 40, 0x19eull << 40, 0x19full << 40, 0x29eull << 40, 0x29full << 40, 0x39eull << 40, 0x39full << 40, 0x0feull << 40, 0x0ffull << 40 }; libdfp-1.0.12/libdecnumber/bid/decimal128.c000066400000000000000000000353071261375163000202350ustar00rootroot00000000000000/* Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include "dconfig.h" /* GCC definitions */ #define DECNUMDIGITS 34 /* make decNumbers with space for 16 */ #include "decNumber.h" /* base number library */ #define DECUSE128 1 #include "decNumberLocal.h" /* decNumber local types, etc. */ #include "decimal128.h" /* our primary include */ #include "bid-coeffbits.h" #if DECDPUN != 3 # error "_Decimal128 BID implementation only support DECDPUN==3" #endif decimal128 *decimal128FromString (decimal128 *, const char *, decContext *); char *decimal128ToString (const decimal128 *, char *); char *decimal128ToEngString (const decimal128 *, char *); decimal128 *decimal128FromNumber (decimal128 *, const decNumber *, decContext *); decNumber *decimal128ToNumber (const decimal128 *, decNumber *); static void decDigitsFromBID (decNumber *dn, uInt sourhi, uInt sourmh, uInt sourml, uInt sourlo); static void decDigitsToBID (const decNumber *dn, uInt *sourhi, uInt *sourmh, uInt *sourml, uInt *sourlo); /* ------------------------------------------------------------------ */ /* BID special encoding definitions. */ /* ------------------------------------------------------------------ */ #define BID_SIGN_MASK 0x80000000 #define BID_INF_ENC_MASK 0x78000000 #define BID_NAN_ENC_MASK 0x7C000000 #define BID_SNAN_ENC_MASK 0x7E000000 #define BID_EXPONENT_ENC_MASK 0x60000000 #define BID_EXP_MASK128 0x3fff #define BID_EXP_SHIFT_LARGE128 15 #define BID_EXP_SHIFT_SMALL128 17 /* ------------------------------------------------------------------ */ /* Decimal 128-bit format module */ /* ------------------------------------------------------------------ */ /* This module comprises the routines for decimal128 format numbers. */ /* Conversions are supplied to and from decNumber and String. */ /* */ /* This is used when decNumber provides operations, either for all */ /* operations or as a proxy between decNumber and decSingle. */ /* */ /* Error handling is the same as decNumber (qv.). */ /* ------------------------------------------------------------------ */ decimal128 * decimal128FromNumber (decimal128 *d128, const decNumber *dn, decContext *set) { uInt status = 0; Int ae; /* adjusted exponent */ decNumber dw; decContext dc; uInt exp; uInt uiwork; uInt targhi = 0; uInt targmh = 0; uInt targml = 0; uInt targlo = 0; Int shift; /* If the number has too many digits, or the exponent could be out of range then reduce the number under the appropriate constraints. This could push the number to Infinity or zero, so this check and rounding must be done before generating the decimal128. */ ae = dn->exponent + dn->digits - 1; /* [0 if special] */ if (dn->digits > DECIMAL128_Pmax /* too many digits */ || ae > DECIMAL128_Emax /* likely overflow */ || ae < DECIMAL128_Emin) { /* likely underflow */ decContextDefault (&dc, DEC_INIT_DECIMAL128); dc.round = set->round; decNumberPlus (&dw, dn, &dc); /* (round and check) */ /* [this changes -0 to 0, so enforce the sign...] */ dw.bits |= dn->bits & DECNEG; status = dc.status; dn = &dw; } if (dn->bits & DECSPECIAL) { if (dn->bits & DECINF) targhi = DECIMAL_Inf << 24; else { /* sNaN or qNaN */ if ((*dn->lsu != 0 || dn->digits > 1) /* non-zero coefficient */ && (dn->digits < DECIMAL128_Pmax)) decDigitsToBID (dn, &targhi, &targmh, &targml, &targlo); if (dn->bits & DECNAN) targhi |= DECIMAL_NaN << 24; else targhi |= DECIMAL_sNaN << 24; } } else { /* is finite */ if (decNumberIsZero (dn)) { /* set and clamp exponent */ if (dn->exponent < -DECIMAL128_Bias) { exp = 0; status |= DEC_Clamped; } else { exp = dn->exponent + DECIMAL128_Bias; if (exp > DECIMAL128_Ehigh) { exp = DECIMAL128_Ehigh; status |= DEC_Clamped; } } } else { /* non-zero finite number */ exp = (uInt) (dn->exponent + DECIMAL128_Bias); if (exp > DECIMAL128_Ehigh) { exp = DECIMAL128_Ehigh; status |= DEC_Clamped; } decDigitsToBID (dn, &targhi, &targmh, &targml, &targlo); } /* Exponent is enconded as: - If coefficient fits in 113 bits: | sign - 1bit | exponent - 14 bits | coefficient - 113 bits | - Otherwise | sign - 1bit | 11 | exponent - 14 bits | coefficient - 111 bits | Since decDigitsToBID will set the '11' mask if coefficient does not fit 113 bits, we check it to adjust the exponent shift in higher word. */ if ((targhi & BID_EXPONENT_ENC_MASK) == BID_EXPONENT_ENC_MASK) shift = BID_EXP_SHIFT_LARGE128; else shift = BID_EXP_SHIFT_SMALL128; targhi |= (exp & BID_EXP_MASK128) << shift; } if (dn->bits & DECNEG) targhi |= BID_SIGN_MASK; /* now write to storage; this is now always endian */ UBFROMUIBW(d128->bytes, targhi); UBFROMUIBW(d128->bytes+4, targmh); UBFROMUIBW(d128->bytes+8, targml); UBFROMUIBW(d128->bytes+12, targlo); if (status != 0) decContextSetStatus (set, status); /*decimal128Show(d128);*/ return d128; } /* ------------------------------------------------------------------ */ /* decimal128ToNumber -- convert decimal128 to decNumber */ /* d128 is the source decimal128 */ /* dn is the target number, with appropriate space */ /* ------------------------------------------------------------------ */ decNumber * decimal128ToNumber (const decimal128 *d128, decNumber *dn) { uInt uiwork; uInt sourhi; uInt sourmh; uInt sourml; uInt sourlo; Int shift; /* load source from storage; this is endian */ sourhi = UBTOUIBW(d128->bytes ); sourmh = UBTOUIBW(d128->bytes+4); sourml = UBTOUIBW(d128->bytes+8); sourlo = UBTOUIBW(d128->bytes+12); decNumberZero(dn); if (sourhi & BID_SIGN_MASK) dn->bits |= DECNEG; /* Infinities and NaN are encoded just like DPD: s 11 110 0.... 0 00 ... 00 -> canonical infinites s 11 110 any any -> infinites s 11 1110 0 .... 0 payloads -> canonical qNaN s 11 1110 any any -> qNaN s 11 1111 0 .... 0 payloads -> canonical sNaN s 11 1111 any any -> sNaN */ if ((sourhi & BID_SNAN_ENC_MASK) == BID_SNAN_ENC_MASK) dn->bits |= DECSNAN; else if ((sourhi & BID_NAN_ENC_MASK) == BID_NAN_ENC_MASK) dn->bits |= DECNAN; else if ((sourhi & BID_INF_ENC_MASK) == BID_INF_ENC_MASK) { dn->bits |= DECINF; return dn; /* no coefficient needed */ } else { /* The exponent is decoded as: E = binary decode (bL−2 bL−3 · · · bL−w−1 ) if (bL−2 bL−3 ) != 11 \_ decimal128 (w=14) -> bL-2 bL-3 ... bL-11 binary decode (bL−4 bL−5 · · · bL−w−3 ) if (bL−2 bL−3 ) == 11 \_ decimal128 (w=14) -> bl-4 bl-5 ... bl-13 The 0x60000000 is binary mask to check if bL-2, bL-3 are set. */ if ((sourhi & BID_EXPONENT_ENC_MASK) == BID_EXPONENT_ENC_MASK) shift = BID_EXP_SHIFT_LARGE128; else shift = BID_EXP_SHIFT_SMALL128; dn->exponent = ((sourhi >> shift) & BID_EXP_MASK128) - DECIMAL128_Bias; } decDigitsFromBID(dn, sourhi, sourmh, sourml, sourlo); /*decNumberShow (dn);*/ return dn; } /* ------------------------------------------------------------------ */ /* to-scientific-string -- conversion to numeric string */ /* to-engineering-string -- conversion to numeric string */ /* */ /* decimal128ToString(d128, string); */ /* decimal128ToEngString(d128, string); */ /* */ /* d128 is the decimal128 format number to convert */ /* string is the string where the result will be laid out */ /* */ /* string must be at least 24 characters */ /* */ /* No error is possible, and no status can be set. */ /* ------------------------------------------------------------------ */ char * decimal128ToString (const decimal128 *d128, char *string) { decNumber dn; decimal128ToNumber (d128, &dn); decNumberToString (&dn, string); return string; } char * decimal128ToEngString (const decimal128 *d128, char *string) { decNumber dn; decimal128ToNumber (d128, &dn); decNumberToEngString (&dn, string); return string; } /* ------------------------------------------------------------------ */ /* to-number -- conversion from numeric string */ /* */ /* decimal128FromString(result, string, set); */ /* */ /* result is the decimal128 format number which gets the result of */ /* the conversion */ /* *string is the character string which should contain a valid */ /* number (which may be a special value) */ /* set is the context */ /* */ /* The context is supplied to this routine is used for error handling */ /* (setting of status and traps) and for the rounding mode, only. */ /* If an error occurs, the result will be a valid decimal128 NaN. */ /* ------------------------------------------------------------------ */ decimal128 * decimal128FromString (decimal128 *result, const char *string, decContext *set) { decContext dc; decNumber dn; decContextDefault (&dc, DEC_INIT_DECIMAL128); dc.round = set->round; decNumberFromString (&dn, string, &dc); decimal128FromNumber (result, &dn, &dc); if (dc.status != 0) decContextSetStatus (set, dc.status); return result; } /* ------------------------------------------------------------------ */ /* decDigitsToBID -- pack coefficient into BID form */ /* */ /* dn is the source number (assumed valid, max DECMAX754 digits) */ /* sourhi is the higher word in binary form */ /* sourlo is the lower word in binary form */ /* ------------------------------------------------------------------ */ static void decDigitsToBID (const decNumber *dn, uInt *sourhi, uInt *sourmh, uInt *sourml, uInt *sourlo) { const Unit *uin=dn->lsu; /* -> current output unit (uint16_t) */ uQuad coeff; uQuad mult; Int digits; Int n; /* Convert the decNumber internal format to binary representation. The number -2.718281828459045, for instance, will be represented internally as: dn::lsu = [ 45, 459, 828, 281, 718, 2 ] and to transform to a binary representation it just need to calculate: ( 45 * 1) + (459 * 1000) + (828 * 1000000) + (281 * 1000000000) + (718 * 1000000000000) + ( 2 * 1000000000000000) */ uQuadInit (coeff); uQuadSetUInt (coeff, 0); uQuadInit (mult); uQuadSetUInt (mult, 1); for (n = 0, digits = 1; digits <= dn->digits; ++n, digits += 3) { /* coeff += uin[n] * mult; */ uQuad tmp; uQuadInit (tmp); uQuadMulUInt (mult, uin[n], tmp); uQuadAddQuad (coeff, tmp, coeff); /* mult = mult * 1000; */ uQuadMulUInt (mult, 1000, mult); } /* BID coefficient encoding is defined as: - If it fits on 113 bits (10*J + 3, with J=11): | 1bit (sign) | 14bits binary_encode(exp) | 113bits binary_encode (coeff) | - Otherwise: | 1bit (sign) | 2bits - 11 | 14bits binary_encode(exp) | 113 bits lsbs binary_encode (coeff) | */ if (bid_required_bits_128 (coeff) <= 113) *sourhi = uQuadHi(coeff) & 0x0001FFFF; else *sourhi = 0x60020000U | (uQuadHi(coeff) & 0x00007FFFU); *sourmh = uQuadMh(coeff); *sourml = uQuadMl(coeff); *sourlo = uQuadLo(coeff); } /* ------------------------------------------------------------------ */ /* decDigitsFromDPD -- unpack a format's coefficient */ /* */ /* dn is the target number, with 7, 16, or 34-digit space. */ /* sourhi is the higher word in binary form */ /* sourlo is the lower word in binary form */ /* */ /* dn->digits is set, but not the sign or exponent. */ /* ------------------------------------------------------------------ */ static void decDigitsFromBID (decNumber *dn, uInt sourhi, uInt sourmh, uInt sourml, uInt sourlo) { Int n; Unit *uout = dn->lsu; /* -> current output unit (uint16_t) */ Unit *last = uout; /* will be unit containing msd */ uQuad bin; /* The BID coefficient is defined as: y = binary decode(b10J+2 b10J+1 ... b0 ) if (bL−2 bL−3 ) != (11) \_ decimal128 (j=11): 112 ... 0 binary decode(1 0 0 b10J b10J-1 ... b0 ) if (bL−2 bL−3 ) == (11) \_ decimal128 (j=11): 110 ... 0 And for _Decimal128: | 1 bit (sign) | 14 bits (exponent) | 113 bits (coefficient) | */ if ((sourhi & BID_EXPONENT_ENC_MASK) == BID_EXPONENT_ENC_MASK) sourhi = 0x00020000 | (sourhi & 0x00007FFF); else sourhi &= 0x0001FFFF; uQuadInit (bin); uQuadInitFromUInt (bin, sourhi, sourmh, sourml, sourlo); for (n = DECNUMUNITS; uQuadNEUInt(bin, 0) && (n >= 0); n--) { uQuad tmp; uQuadInit (tmp); /* *uout = bin % 1000; */ uQuadModUInt (bin, 1000, tmp); uQuadToUInt (tmp, *uout); /* bin /= 1000; */ uQuadDivUInt (bin, 1000, bin); last = uout; uout++; } /* 'last' points to the most significant unit with digits. Inspect it to get the final digit count. */ dn->digits = (last-dn->lsu) * DECDPUN + 1; /* floor of digits, plus 1 */ if (*last < 10) /* common odd digit or 0 */ return; dn->digits++; /* must be 2 at least */ if (*last < 100) /* 10-99 */ return; dn->digits++; /* must be 3 at least */ if (*last < 1000) /* 100-999 */ return; dn->digits++; /* must be 4 at least */ return; } libdfp-1.0.12/libdecnumber/bid/decimal32.c000066400000000000000000000273211261375163000201440ustar00rootroot00000000000000/* Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include "dconfig.h" /* GCC definitions */ #define DECNUMDIGITS 7 /* make decNumbers with space for 7 */ #include "decNumber.h" /* base number library */ #include "decNumberLocal.h" /* decNumber local types, etc. */ #include "decimal32.h" /* our primary include */ #include "bid-coeffbits.h" /* for bid_required_bits */ #if DECDPUN != 3 # error "_Decimal32 BID implementation only support DECDPUN==3" #endif decimal32 *decimal32FromString (decimal32 *, const char *, decContext *); char *decimal32ToString (const decimal32 *, char *); char *decimal32ToEngString (const decimal32 *, char *); decimal32 *decimal32FromNumber (decimal32 *, const decNumber *, decContext *); decNumber *decimal32ToNumber (const decimal32 *, decNumber *); static void decDigitsFromBID (decNumber *dn, uInt sour); static void decDigitsToBID (const decNumber *dn, uInt *sour); /* ------------------------------------------------------------------ */ /* BID special encoding definitions. */ /* ------------------------------------------------------------------ */ #define BID_SIGN_MASK 0x80000000 #define BID_INF_ENC_MASK 0x78000000 #define BID_NAN_ENC_MASK 0x7C000000 #define BID_SNAN_ENC_MASK 0x7E000000 #define BID_EXPONENT_ENC_MASK 0x60000000 #define BID_EXP_MASK32 0xff #define BID_EXP_SHIFT_LARGE32 21 #define BID_EXP_SHIFT_SMALL32 23 /* ------------------------------------------------------------------ */ /* Decimal 32-bit format module */ /* ------------------------------------------------------------------ */ /* This module comprises the routines for decimal32 format numbers. */ /* Conversions are supplied to and from decNumber and String. */ /* */ /* This is used when decNumber provides operations, either for all */ /* operations or as a proxy between decNumber and decSingle. */ /* */ /* Error handling is the same as decNumber (qv.). */ /* ------------------------------------------------------------------ */ decimal32 * decimal32FromNumber (decimal32 *d32, const decNumber *dn, decContext *set) { uInt status = 0; Int ae; /* adjusted exponent */ decNumber dw; decContext dc; uInt exp; uInt uiwork; uInt targ = 0; Int shift; /* If the number has too many digits, or the exponent could be out of range then reduce the number under the appropriate constraints. This could push the number to Infinity or zero, so this check and rounding must be done before generating the decimal32. */ ae = dn->exponent + dn->digits - 1; /* [0 if special] */ if (dn->digits > DECIMAL32_Pmax /* too many digits */ || ae > DECIMAL32_Emax /* likely overflow */ || ae < DECIMAL32_Emin) { /* likely underflow */ decContextDefault (&dc, DEC_INIT_DECIMAL32); dc.round = set->round; decNumberPlus (&dw, dn, &dc); /* (round and check) */ /* [this changes -0 to 0, so enforce the sign...] */ dw.bits |= dn->bits & DECNEG; status = dc.status; dn = &dw; } if (dn->bits & DECSPECIAL) { if (dn->bits & DECINF) targ = DECIMAL_Inf << 24; else { /* sNaN or qNaN */ if ((*dn->lsu != 0 || dn->digits > 1) /* non-zero coefficient */ && (dn->digits < DECIMAL32_Pmax)) decDigitsToBID (dn, &targ); if (dn->bits & DECNAN) targ |= DECIMAL_NaN << 24; else targ |= DECIMAL_sNaN << 24; } } else { /* is finite */ if (decNumberIsZero (dn)) { /* set and clamp exponent */ if (dn->exponent < -DECIMAL32_Bias) { exp = 0; status |= DEC_Clamped; } else { exp = dn->exponent + DECIMAL32_Bias; if (exp > DECIMAL32_Ehigh) { exp = DECIMAL32_Ehigh; status |= DEC_Clamped; } } } else { /* non-zero finite number */ exp = (uInt) (dn->exponent + DECIMAL32_Bias); if (exp > DECIMAL32_Ehigh) { exp = DECIMAL32_Ehigh; status |= DEC_Clamped; } decDigitsToBID (dn, &targ); } /* Exponent is enconded as: - If coefficient fits in 23 bits: | sign - 1bit | exponent - 8 bits | coefficient - 23 bits | - Otherwise: | sign - 1bit | 11 | exponent - 8 bits | coefficient - 21 bits | Since decDigitsToBID will set '11' mask if coefficient does not fit 53 bits, we check it to adjust the exponent shift in higher word. */ if ((targ & BID_EXPONENT_ENC_MASK) == BID_EXPONENT_ENC_MASK) shift = BID_EXP_SHIFT_LARGE32; else shift = BID_EXP_SHIFT_SMALL32; targ |= (exp & BID_EXP_MASK32) << shift; } if (dn->bits & DECNEG) targ |= BID_SIGN_MASK; /* now write to storage; this is now always endian */ UBFROMUIBW (d32->bytes, targ); if (status != 0) decContextSetStatus (set, status); /*decimal32Show(d32);*/ return d32; } /* ------------------------------------------------------------------ */ /* decimal32ToNumber -- convert decimal32 to decNumber */ /* d32 is the source decimal32 */ /* dn is the target number, with appropriate space */ /* No error is possible. */ /* ------------------------------------------------------------------ */ decNumber * decimal32ToNumber (const decimal32 *d32, decNumber *dn) { uInt uiwork; uInt sour; Int shift; /* load source from storage; this is endian */ sour = UBTOUIBW(d32->bytes); decNumberZero(dn); if (sour & BID_SIGN_MASK) dn->bits |= DECNEG; /* Infinities and NaN are encoded just like DPD: s 11 110 0.... 0 00 ... 00 -> canonical infinites s 11 110 any any -> infinites s 11 1110 0 .... 0 payloads -> canonical qNaN s 11 1110 any any -> qNaN s 11 1111 0 .... 0 payloads -> canonical sNaN s 11 1111 any any -> sNaN */ if ((sour & BID_SNAN_ENC_MASK) == BID_SNAN_ENC_MASK) dn->bits |= DECSNAN; else if ((sour & BID_NAN_ENC_MASK) == BID_NAN_ENC_MASK) dn->bits |= DECNAN; else if ((sour & BID_INF_ENC_MASK) == BID_INF_ENC_MASK) { dn->bits |= DECINF; return dn; /* no coefficient needed */ } else { /* The exponent is decoded as: E = binary decode (bL−2 bL−3 · · · bL−w−1 ) if (bL−2 bL−3 ) != 11 \_ decimal32 (w=10) -> bL-2 bL-3 ... bL-11 binary decode (bL−4 bL−5 · · · bL−w−3 ) if (bL−2 bL−3 ) == 11 \_ decimal32 (w=10) -> bl-4 bl-5 ... bl-13 The 0x60000000 is binary mask to check if bL-2, bL-3 are set. */ if ((sour & BID_EXPONENT_ENC_MASK) == BID_EXPONENT_ENC_MASK) shift = BID_EXP_SHIFT_LARGE32; else shift = BID_EXP_SHIFT_SMALL32; dn->exponent = ((sour >> shift) & BID_EXP_MASK32) - DECIMAL32_Bias; } decDigitsFromBID(dn, sour); /*decNumberShow (dn);*/ return dn; } char * decimal32ToString (const decimal32 *d32, char *string) { decNumber dn; decimal32ToNumber (d32, &dn); decNumberToString (&dn, string); return string; } char * decimal32ToEngString (const decimal32 *d32, char *string) { decNumber dn; decimal32ToNumber (d32, &dn); decNumberToEngString (&dn, string); return string; } decimal32 * decimal32FromString (decimal32 *result, const char *string, decContext *set) { decContext dc; decNumber dn; decContextDefault (&dc, DEC_INIT_DECIMAL32); dc.round = set->round; decNumberFromString (&dn, string, &dc); decimal32FromNumber (result, &dn, &dc); if (dc.status != 0) decContextSetStatus (set, dc.status); return result; } /* ------------------------------------------------------------------ */ /* decDigitsToBID -- pack coefficient into BID form */ /* */ /* dn is the source number (assumed valid, max DECMAX754 digits) */ /* sour is the word in binary form */ /* ------------------------------------------------------------------ */ static void decDigitsToBID (const decNumber *dn, uInt *sour) { const Unit *uin=dn->lsu; /* -> current output unit (uint16_t) */ uInt coeff = 0; uInt mult; Int digits; Int n; /* Convert the decNumber internal format to binary representation. The number -2.718281, for instance, will be represented internally as: dn::lsu = [ 281, 718, 2 ] and to transform to a binary representation it just need to calculate: (281 * 1) + (718 * 1000) + ( 2 * 1000000) */ for (n = 0, mult = 1, digits = 1; digits <= dn->digits; ++n, mult *= 1000, digits += 3) { coeff += uin[n] * mult; } /* BID coefficient encoding is defined as: - If it fits on 23 bits (10*J + 3, with J=2): | 1bit (sign) | 8bits binary_encode(exp) | 23bits binary_encode (coeff) | - Otherwise: | 1bit (sign) | 2bits - 11 | 8bits binary_encode(exp) | 21 bits lsbs binary_encode (coeff) | */ if (bid_required_bits_32 (coeff) <= 23) *sour = coeff & 0x007FFFFFU; else *sour = 0x60800000U | (coeff & 0x001FFFFFU); } /* ------------------------------------------------------------------ */ /* decDigitsFromDPD -- unpack a format's coefficient */ /* */ /* dn is the target number, with 7, 16, or 34-digit space. */ /* sour is the word in binary form */ /* */ /* dn->digits is set, but not the sign or exponent. */ /* ------------------------------------------------------------------ */ static void decDigitsFromBID (decNumber *dn, uInt sour) { Int n; Unit *uout = dn->lsu; /* -> current output unit (uint16_t) */ Unit *last = uout; /* will be unit containing msd */ uInt bin; /* The BID coefficient is defined as: y = binary decode(b10J+2 b10J+1 ... b0 ) if (bL−2 bL−3 ) != (11) \_ decimal32 (j=2): 22 ... 0 binary decode(1 0 0 b10J b10J-1 ... b0 ) if (bL−2 bL−3 ) == (11) \_ decimal32 (j=2): 20 ... 0 And for _Decimal32: | 1 bit (sign) | 8 bits (exponent) | 23 bits (coefficient) | */ if ((sour & BID_EXPONENT_ENC_MASK) == BID_EXPONENT_ENC_MASK) sour = 0x00800000 | (sour & 0x001FFFFF); else sour &= 0x007FFFFF; bin = sour; for (n = DECNUMUNITS; (bin != 0) && (n >= 0); n--) { *uout = bin % 1000; bin /= 1000; last = uout; uout++; } /* 'last' points to the most significant unit with digits. Inspect it to get the final digit count. */ dn->digits = (last-dn->lsu) * DECDPUN +1; /* floor of digits, plus 1 */ if (*last < 10) /* common odd digit or 0 */ return; dn->digits++; /* must be 2 at least */ if (*last < 100) /* 10-99 */ return; dn->digits++; /* must be 3 at least */ if (*last < 1000) /* 100-999 */ return; dn->digits++; /* must be 4 at least */ return; } libdfp-1.0.12/libdecnumber/bid/decimal64.c000066400000000000000000000333611261375163000201520ustar00rootroot00000000000000/* Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include "dconfig.h" /* GCC definitions */ #define DECNUMDIGITS 16 /* make decNumbers with space for 16 */ #include "decNumber.h" /* base number library */ #include "decNumberLocal.h" /* decNumber local types, etc. */ #include "decimal64.h" /* our primary include */ #include "bid-coeffbits.h" /* for bid_required_bits */ #if DECDPUN != 3 # error "_Decimal64 BID implementation only support DECDPUN==3" #endif decimal64 *decimal64FromString (decimal64 *, const char *, decContext *); char *decimal64ToString (const decimal64 *, char *); char *decimal64ToEngString (const decimal64 *, char *); decimal64 *decimal64FromNumber (decimal64 *, const decNumber *, decContext *); decNumber *decimal64ToNumber (const decimal64 *, decNumber *); static void decDigitsFromBID (decNumber *dn, uInt sourhi, uInt sourlo); static void decDigitsToBID (const decNumber *dn, uInt *sourhi, uInt *sourlo); /* ------------------------------------------------------------------ */ /* BID special encoding definitions. */ /* ------------------------------------------------------------------ */ #define BID_SIGN_MASK 0x80000000 #define BID_INF_ENC_MASK 0x78000000 #define BID_NAN_ENC_MASK 0x7C000000 #define BID_SNAN_ENC_MASK 0x7E000000 #define BID_EXPONENT_ENC_MASK 0x60000000 #define BID_EXP_MASK64 0x3ff #define BID_EXP_SHIFT_LARGE64 19 #define BID_EXP_SHIFT_SMALL64 21 /* ------------------------------------------------------------------ */ /* Decimal 64-bit format module */ /* ------------------------------------------------------------------ */ /* This module comprises the routines for decimal64 format numbers. */ /* Conversions are supplied to and from decNumber and String. */ /* */ /* This is used when decNumber provides operations, either for all */ /* operations or as a proxy between decNumber and decSingle. */ /* */ /* Error handling is the same as decNumber (qv.). */ /* ------------------------------------------------------------------ */ decimal64 * decimal64FromNumber (decimal64 * d64, const decNumber *dn, decContext *set) { uInt status = 0; Int ae; /* adjusted exponent */ decNumber dw; decContext dc; uInt exp; uInt uiwork; uInt targhi = 0; uInt targlo = 0; Int shift; /* If the number has too many digits, or the exponent could be out of range then reduce the number under the appropriate constraints. This could push the number to Infinity or zero, so this check and rounding must be done before generating the decimal64. */ ae = dn->exponent + dn->digits - 1; /* [0 if special] */ if (dn->digits > DECIMAL64_Pmax /* too many digits */ || ae > DECIMAL64_Emax /* likely overflow */ || ae < DECIMAL64_Emin) { /* likely underflow */ decContextDefault (&dc, DEC_INIT_DECIMAL64); dc.round = set->round; decNumberPlus (&dw, dn, &dc); /* (round and check) */ /* [this changes -0 to 0, so enforce the sign...] */ dw.bits |= dn->bits & DECNEG; status = dc.status; dn = &dw; } if (dn->bits & DECSPECIAL) { if (dn->bits & DECINF) targhi = DECIMAL_Inf << 24; else { /* sNaN or qNaN */ if ((*dn->lsu != 0 || dn->digits > 1) /* non-zero coefficient */ && (dn->digits < DECIMAL64_Pmax)) decDigitsToBID (dn, &targhi, &targlo); if (dn->bits & DECNAN) targhi |= DECIMAL_NaN << 24; else targhi |= DECIMAL_sNaN << 24; } } else { /* is finite */ if (decNumberIsZero (dn)) { /* set and clamp exponent */ if (dn->exponent < -DECIMAL64_Bias) { exp = 0; status |= DEC_Clamped; } else { exp = dn->exponent + DECIMAL64_Bias; if (exp > DECIMAL64_Ehigh) { exp = DECIMAL64_Ehigh; status |= DEC_Clamped; } } } else { /* non-zero finite number */ exp = (uInt) (dn->exponent + DECIMAL64_Bias); if (exp > DECIMAL64_Ehigh) { exp = DECIMAL64_Ehigh; status |= DEC_Clamped; } decDigitsToBID (dn, &targhi, &targlo); } /* Exponent is enconded as: - If coefficient fits in 53 bits: | sign - 1bit | exponent - 10 bits | coefficient - 53 bits | - Otherwise | sign - 1bit | 11 | exponent - 10 bits | coefficient - 51 bits | Since decDigitsToBID will set '11' mask if coefficient does not fit 53 bits, we check it to adjust the exponent shift in higher word. */ if ((targhi & BID_EXPONENT_ENC_MASK) == BID_EXPONENT_ENC_MASK) shift = BID_EXP_SHIFT_LARGE64; else shift = BID_EXP_SHIFT_SMALL64; targhi |= (exp & BID_EXP_MASK64) << shift; } if (dn->bits & DECNEG) targhi |= BID_SIGN_MASK; /* now write to storage; this is now always endian */ UBFROMUIBW (d64->bytes, targhi); UBFROMUIBW (d64->bytes + 4, targlo); if (status != 0) decContextSetStatus (set, status); /*decimal64Show(d64);*/ return d64; } /* ------------------------------------------------------------------ */ /* decimal64ToNumber -- convert decimal64 to decNumber */ /* d64 is the source decimal64 */ /* dn is the target number, with appropriate space */ /* No error is possible. */ /* ------------------------------------------------------------------ */ decNumber * decimal64ToNumber (const decimal64 *d64, decNumber *dn) { uInt uiwork; uInt sourhi; uInt sourlo; Int shift; /* load source from storage; this is endian */ sourhi = UBTOUIBW(d64->bytes ); sourlo = UBTOUIBW(d64->bytes+4); decNumberZero(dn); if (sourhi & BID_SIGN_MASK) dn->bits |= DECNEG; /* Infinities and NaN are encoded just like DPD: s 11 110 0.... 0 00 ... 00 -> canonical infinites s 11 110 any any -> infinites s 11 1110 0 .... 0 payloads -> canonical qNaN s 11 1110 any any -> qNaN s 11 1111 0 .... 0 payloads -> canonical sNaN s 11 1111 any any -> sNaN */ if ((sourhi & BID_SNAN_ENC_MASK) == BID_SNAN_ENC_MASK) dn->bits |= DECSNAN; else if ((sourhi & BID_NAN_ENC_MASK) == BID_NAN_ENC_MASK) dn->bits |= DECNAN; else if ((sourhi & BID_INF_ENC_MASK) == BID_INF_ENC_MASK) { dn->bits |= DECINF; return dn; /* no coefficient needed */ } else { /* The exponent is decoded as: E = binary decode (bL−2 bL−3 · · · bL−w−1 ) if (bL−2 bL−3 ) != 11 \_ decimal64 (w=10) -> bL-2 bL-3 ... bL-11 binary decode (bL−4 bL−5 · · · bL−w−3 ) if (bL−2 bL−3 ) == 11 \_ decimal64 (w=10) -> bl-4 bl-5 ... bl-13 The 0x60000000 is binary mask to check if bL-2, bL-3 are set. */ if ((sourhi & BID_EXPONENT_ENC_MASK) == BID_EXPONENT_ENC_MASK) shift = BID_EXP_SHIFT_LARGE64; else shift = BID_EXP_SHIFT_SMALL64; dn->exponent = ((sourhi >> shift) & BID_EXP_MASK64) - DECIMAL64_Bias; } decDigitsFromBID(dn, sourhi, sourlo); /*decNumberShow (dn);*/ return dn; } /* ------------------------------------------------------------------ */ /* to-scientific-string -- conversion to numeric string */ /* to-engineering-string -- conversion to numeric string */ /* */ /* decimal64ToString(d64, string); */ /* decimal64ToEngString(d64, string); */ /* */ /* d64 is the decimal64 format number to convert */ /* string is the string where the result will be laid out */ /* */ /* string must be at least 24 characters */ /* */ /* No error is possible, and no status can be set. */ /* ------------------------------------------------------------------ */ char * decimal64ToString (const decimal64 * d64, char *string) { decNumber dn; decimal64ToNumber (d64, &dn); decNumberToString (&dn, string); return string; } char * decimal64ToEngString (const decimal64 * d64, char *string) { decNumber dn; decimal64ToNumber (d64, &dn); decNumberToEngString (&dn, string); return string; } /* ------------------------------------------------------------------ */ /* to-number -- conversion from numeric string */ /* */ /* decimal64FromString(result, string, set); */ /* */ /* result is the decimal64 format number which gets the result of */ /* the conversion */ /* *string is the character string which should contain a valid */ /* number (which may be a special value) */ /* set is the context */ /* */ /* The context is supplied to this routine is used for error handling */ /* (setting of status and traps) and for the rounding mode, only. */ /* If an error occurs, the result will be a valid decimal64 NaN. */ /* ------------------------------------------------------------------ */ decimal64 * decimal64FromString (decimal64 * result, const char *string, decContext * set) { decContext dc; decNumber dn; decContextDefault (&dc, DEC_INIT_DECIMAL64); dc.round = set->round; decNumberFromString (&dn, string, &dc); decimal64FromNumber (result, &dn, &dc); if (dc.status != 0) decContextSetStatus (set, dc.status); return result; } /* ------------------------------------------------------------------ */ /* decDigitsToBID -- pack coefficient into BID form */ /* */ /* dn is the source number (assumed valid, max DECMAX754 digits) */ /* sourhi is the higher word in binary form */ /* sourlo is the lower word in binary form */ /* ------------------------------------------------------------------ */ static void decDigitsToBID (const decNumber *dn, uInt *sourhi, uInt *sourlo) { const Unit *uin=dn->lsu; /* -> current output unit (uint16_t) */ uLong coeff = 0; uLong mult; Int digits; Int n; /* Convert the decNumber internal format to binary representation. The number -2.718281828459045, for instance, will be represented internally as: dn::lsu = [ 45, 459, 828, 281, 718, 2 ] and to transform to a binary representation it just need to calculate: ( 45 * 1) + (459 * 1000) + (828 * 1000000) + (281 * 1000000000) + (718 * 1000000000000) + ( 2 * 1000000000000000) */ for (n = 0, mult = 1, digits = 1; digits <= dn->digits; ++n, mult *= 1000, digits += 3) { coeff += uin[n] * mult; } /* BID coefficient encoding is defined as: - If it fits on 53 bits (10*J + 3, with J=10): | 1bit (sign) | 10bits binary_encode(exp) | 53bits binary_encode (coeff) | - Otherwise: | 1bit (sign) | 2bits - 11 | 10bits binary_encode(exp) | 51 bits lsbs binary_encode (coeff) | */ if (bid_required_bits_64 (coeff) <= 53) *sourhi = (coeff >> 32) & 0x001FFFFFU; else *sourhi = 0x60200000U | ((coeff >> 32) & 0x0007FFFFU); *sourlo = coeff & 0xFFFFFFFFU; } /* ------------------------------------------------------------------ */ /* decDigitsFromDPD -- unpack a format's coefficient */ /* */ /* dn is the target number, with 7, 16, or 34-digit space. */ /* sourhi is the higher word in binary form */ /* sourlo is the lower word in binary form */ /* */ /* dn->digits is set, but not the sign or exponent. */ /* ------------------------------------------------------------------ */ static void decDigitsFromBID (decNumber *dn, uInt sourhi, uInt sourlo) { Int n; Unit *uout = dn->lsu; /* -> current output unit (uint16_t) */ Unit *last = uout; /* will be unit containing msd */ uLong bin; /* The BID coefficient is defined as: y = binary decode(b10J+2 b10J+1 ... b0 ) if (bL−2 bL−3 ) != (11) \_ decimal64 (j=5): 52 ... 0 binary decode(1 0 0 b10J b10J-1 ... b0 ) if (bL−2 bL−3 ) == (11) \_ decimal64 (j=5): 50 ... 0 And for _Decimal64: | 1 bit (sign) | 10 bits (exponent) | 52 bits (coefficient) | */ if ((sourhi & BID_EXPONENT_ENC_MASK) == BID_EXPONENT_ENC_MASK) sourhi = 0x00200000 | (sourhi & 0x0007FFFF); else sourhi &= 0x001FFFFF; bin = ((uLong)sourhi << 32) | sourlo; for (n = DECNUMUNITS; (bin != 0) && (n >= 0); n--) { *uout = bin % 1000; bin /= 1000; last = uout; uout++; } /* 'last' points to the most significant unit with digits. Inspect it to get the final digit count. */ dn->digits = (last-dn->lsu) * DECDPUN +1; /* floor of digits, plus 1 */ if (*last < 10) /* common odd digit or 0 */ return; dn->digits++; /* must be 2 at least */ if (*last < 100) /* 10-99 */ return; dn->digits++; /* must be 3 at least */ if (*last < 1000) /* 100-999 */ return; dn->digits++; /* must be 4 at least */ return; } libdfp-1.0.12/libdecnumber/config.in000066400000000000000000000047641261375163000173020ustar00rootroot00000000000000/* config.in. Generated from configure.ac by autoheader. */ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* Define to 1 if you have the header file. */ #undef HAVE_CTYPE_H /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the header file. */ #undef HAVE_STDDEF_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDIO_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* "Have __uint128_t type" */ #undef HAVE_UINT128_T /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* 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 /* The size of `char', as computed by sizeof. */ #undef SIZEOF_CHAR /* The size of `int', as computed by sizeof. */ #undef SIZEOF_INT /* The size of `long', as computed by sizeof. */ #undef SIZEOF_LONG /* The size of `short', as computed by sizeof. */ #undef SIZEOF_SHORT /* The size of `void *', as computed by sizeof. */ #undef SIZEOF_VOID_P /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* 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 empty if `const' does not conform to ANSI C. */ #undef const /* Define to `long int' if does not define. */ #undef off_t libdfp-1.0.12/libdecnumber/configure000077500000000000000000005572631261375163000174230ustar00rootroot00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for libdecnumber . # # Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: gcc-bugs@gcc.gnu.org about your system, including any $0: error possibly output before this message. Then install $0: a modern shell, or manually run the script under such a $0: shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libdecnumber' PACKAGE_TARNAME='libdecnumber' PACKAGE_VERSION=' ' PACKAGE_STRING='libdecnumber ' PACKAGE_BUGREPORT='gcc-bugs@gcc.gnu.org' PACKAGE_URL='' ac_unique_file="decNumber.h" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='LTLIBOBJS LIBOBJS PICFLAG ADDITIONAL_OBJS enable_decimal_float target_os target_vendor target_cpu target host_os host_vendor host_cpu host build_os build_vendor build_cpu build MAINT EGREP GREP CPP WERROR WARN_PEDANTIC WARN_CFLAGS AUTOHEADER AUTOCONF ACLOCAL RANLIB OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC SET_MAKE target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_werror_always enable_maintainer_mode enable_decimal_float enable_host_shared ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures libdecnumber to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/libdecnumber] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] --target=TARGET configure for building compilers for TARGET [HOST] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of libdecnumber :";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-werror-always enable -Werror despite compiler version --enable-maintainer-mode enable rules only needed by maintainers --enable-decimal-float={no,yes,bid,dpd} enable decimal float extension to C. Selecting 'bid' or 'dpd' choses which decimal floating point format to use --enable-host-shared build host code as shared libraries Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF libdecnumber configure generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ----------------------------------- ## ## Report this to gcc-bugs@gcc.gnu.org ## ## ----------------------------------- ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES # -------------------------------------------- # Tries to find the compile-time value of EXPR in a program that includes # INCLUDES, setting VAR accordingly. Returns whether the value could be # computed ac_fn_c_compute_int () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= 0)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=0 ac_mid=0 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid; break else as_fn_arith $ac_mid + 1 && ac_lo=$as_val if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) < 0)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=-1 ac_mid=-1 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=$ac_mid; break else as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid else as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in #(( ?*) eval "$3=\$ac_lo"; ac_retval=0 ;; '') ac_retval=1 ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 static long int longval () { return $2; } static unsigned long int ulongval () { return $2; } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (($2) < 0) { long int i = longval (); if (i != ($2)) return 1; fprintf (f, "%ld", i); } else { unsigned long int i = ulongval (); if (i != ($2)) return 1; fprintf (f, "%lu", i); } /* Do not output a trailing newline, as this causes \r\n confusion on some platforms. */ return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : echo >>conftest.val; read $3 config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by libdecnumber $as_me , which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in .. "$srcdir"/..; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in .. \"$srcdir\"/.." "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Checks for programs. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing for ac_prog in aclocal do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ACLOCAL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ACLOCAL"; then ac_cv_prog_ACLOCAL="$ACLOCAL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ACLOCAL="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ACLOCAL=$ac_cv_prog_ACLOCAL if test -n "$ACLOCAL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ACLOCAL" >&5 $as_echo "$ACLOCAL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ACLOCAL" && break done test -n "$ACLOCAL" || ACLOCAL="$MISSING aclocal" for ac_prog in autoconf do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AUTOCONF+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AUTOCONF"; then ac_cv_prog_AUTOCONF="$AUTOCONF" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AUTOCONF="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AUTOCONF=$ac_cv_prog_AUTOCONF if test -n "$AUTOCONF"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AUTOCONF" >&5 $as_echo "$AUTOCONF" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AUTOCONF" && break done test -n "$AUTOCONF" || AUTOCONF="$MISSING autoconf" for ac_prog in autoheader do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AUTOHEADER+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AUTOHEADER"; then ac_cv_prog_AUTOHEADER="$AUTOHEADER" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AUTOHEADER="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AUTOHEADER=$ac_cv_prog_AUTOHEADER if test -n "$AUTOHEADER"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AUTOHEADER" >&5 $as_echo "$AUTOHEADER" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AUTOHEADER" && break done test -n "$AUTOHEADER" || AUTOHEADER="$MISSING autoheader" # Figure out what compiler warnings we can enable. # See config/warnings.m4 for details. WARN_CFLAGS= save_CFLAGS="$CFLAGS" for option in -W -Wall -Wwrite-strings -Wstrict-prototypes \ -Wmissing-prototypes -Wold-style-definition \ -Wmissing-format-attribute; do as_acx_Woption=`$as_echo "acx_cv_prog_cc_warning_$option" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports $option" >&5 $as_echo_n "checking whether $CC supports $option... " >&6; } if eval \${$as_acx_Woption+:} false; then : $as_echo_n "(cached) " >&6 else CFLAGS="$option" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$as_acx_Woption=yes" else eval "$as_acx_Woption=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$as_acx_Woption { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } if test `eval 'as_val=${'$as_acx_Woption'};$as_echo "$as_val"'` = yes; then : WARN_CFLAGS="$WARN_CFLAGS${WARN_CFLAGS:+ }$option" fi done CFLAGS="$save_CFLAGS" WARN_PEDANTIC= if test "$GCC" = yes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -pedantic -Wno-long-long" >&5 $as_echo_n "checking whether $CC supports -pedantic -Wno-long-long... " >&6; } if ${acx_cv_prog_cc_pedantic__Wno_long_long+:} false; then : $as_echo_n "(cached) " >&6 else save_CFLAGS="$CFLAGS" CFLAGS="-pedantic -Wno-long-long" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : acx_cv_prog_cc_pedantic__Wno_long_long=yes else acx_cv_prog_cc_pedantic__Wno_long_long=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_prog_cc_pedantic__Wno_long_long" >&5 $as_echo "$acx_cv_prog_cc_pedantic__Wno_long_long" >&6; } if test $acx_cv_prog_cc_pedantic__Wno_long_long = yes; then : WARN_PEDANTIC="$WARN_PEDANTIC${WARN_PEDANTIC:+ }-pedantic -Wno-long-long" fi fi # Only enable with --enable-werror-always until existing warnings are # corrected. WERROR= # Check whether --enable-werror-always was given. if test "${enable_werror_always+set}" = set; then : enableval=$enable_werror_always; else enable_werror_always=no fi if test $enable_werror_always = yes; then : WERROR="$WERROR${WERROR:+ }-Werror" fi # Checks for header files. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in ctype.h stddef.h string.h stdio.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done inttype_headers=`echo inttypes.h sys/inttypes.h | sed -e 's/,/ /g'` acx_cv_header_stdint=stddef.h acx_cv_header_stdint_kind="(already complete)" for i in stdint.h $inttype_headers; do unset ac_cv_type_uintptr_t unset ac_cv_type_uintmax_t unset ac_cv_type_int_least32_t unset ac_cv_type_int_fast32_t unset ac_cv_type_uint64_t $as_echo_n "looking for a compliant stdint.h in $i, " >&6 ac_fn_c_check_type "$LINENO" "uintmax_t" "ac_cv_type_uintmax_t" "#include #include <$i> " if test "x$ac_cv_type_uintmax_t" = xyes; then : acx_cv_header_stdint=$i else continue fi ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "#include #include <$i> " if test "x$ac_cv_type_uintptr_t" = xyes; then : else acx_cv_header_stdint_kind="(mostly complete)" fi ac_fn_c_check_type "$LINENO" "int_least32_t" "ac_cv_type_int_least32_t" "#include #include <$i> " if test "x$ac_cv_type_int_least32_t" = xyes; then : else acx_cv_header_stdint_kind="(mostly complete)" fi ac_fn_c_check_type "$LINENO" "int_fast32_t" "ac_cv_type_int_fast32_t" "#include #include <$i> " if test "x$ac_cv_type_int_fast32_t" = xyes; then : else acx_cv_header_stdint_kind="(mostly complete)" fi ac_fn_c_check_type "$LINENO" "uint64_t" "ac_cv_type_uint64_t" "#include #include <$i> " if test "x$ac_cv_type_uint64_t" = xyes; then : else acx_cv_header_stdint_kind="(lacks uint64_t)" fi break done if test "$acx_cv_header_stdint" = stddef.h; then acx_cv_header_stdint_kind="(lacks uintmax_t)" for i in stdint.h $inttype_headers; do unset ac_cv_type_uintptr_t unset ac_cv_type_uint32_t unset ac_cv_type_uint64_t $as_echo_n "looking for an incomplete stdint.h in $i, " >&6 ac_fn_c_check_type "$LINENO" "uint32_t" "ac_cv_type_uint32_t" "#include #include <$i> " if test "x$ac_cv_type_uint32_t" = xyes; then : acx_cv_header_stdint=$i else continue fi ac_fn_c_check_type "$LINENO" "uint64_t" "ac_cv_type_uint64_t" "#include #include <$i> " if test "x$ac_cv_type_uint64_t" = xyes; then : fi ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "#include #include <$i> " if test "x$ac_cv_type_uintptr_t" = xyes; then : fi break done fi if test "$acx_cv_header_stdint" = stddef.h; then acx_cv_header_stdint_kind="(u_intXX_t style)" for i in sys/types.h $inttype_headers; do unset ac_cv_type_u_int32_t unset ac_cv_type_u_int64_t $as_echo_n "looking for u_intXX_t types in $i, " >&6 ac_fn_c_check_type "$LINENO" "u_int32_t" "ac_cv_type_u_int32_t" "#include #include <$i> " if test "x$ac_cv_type_u_int32_t" = xyes; then : acx_cv_header_stdint=$i else continue fi ac_fn_c_check_type "$LINENO" "u_int64_t" "ac_cv_type_u_int64_t" "#include #include <$i> " if test "x$ac_cv_type_u_int64_t" = xyes; then : fi break done fi if test "$acx_cv_header_stdint" = stddef.h; then acx_cv_header_stdint_kind="(using manual detection)" fi test -z "$ac_cv_type_uintptr_t" && ac_cv_type_uintptr_t=no test -z "$ac_cv_type_uint64_t" && ac_cv_type_uint64_t=no test -z "$ac_cv_type_u_int64_t" && ac_cv_type_u_int64_t=no test -z "$ac_cv_type_int_least32_t" && ac_cv_type_int_least32_t=no test -z "$ac_cv_type_int_fast32_t" && ac_cv_type_int_fast32_t=no # ----------------- Summarize what we found so far { $as_echo "$as_me:${as_lineno-$LINENO}: checking what to include in gstdint.h" >&5 $as_echo_n "checking what to include in gstdint.h... " >&6; } case `$as_basename -- gstdint.h || $as_expr X/gstdint.h : '.*/\([^/][^/]*\)/*$' \| \ Xgstdint.h : 'X\(//\)$' \| \ Xgstdint.h : 'X\(/\)' \| . 2>/dev/null || $as_echo X/gstdint.h | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` in stdint.h) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: are you sure you want it there?" >&5 $as_echo "$as_me: WARNING: are you sure you want it there?" >&2;} ;; inttypes.h) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: are you sure you want it there?" >&5 $as_echo "$as_me: WARNING: are you sure you want it there?" >&2;} ;; *) ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_header_stdint $acx_cv_header_stdint_kind" >&5 $as_echo "$acx_cv_header_stdint $acx_cv_header_stdint_kind" >&6; } # ----------------- done included file, check C basic types -------- # Lacking an uintptr_t? Test size of void * case "$acx_cv_header_stdint:$ac_cv_type_uintptr_t" in stddef.h:* | *:no) # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void *" >&5 $as_echo_n "checking size of void *... " >&6; } if ${ac_cv_sizeof_void_p+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void *))" "ac_cv_sizeof_void_p" "$ac_includes_default"; then : else if test "$ac_cv_type_void_p" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (void *) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_void_p=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_void_p" >&5 $as_echo "$ac_cv_sizeof_void_p" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_VOID_P $ac_cv_sizeof_void_p _ACEOF ;; esac # Lacking an uint64_t? Test size of long case "$acx_cv_header_stdint:$ac_cv_type_uint64_t:$ac_cv_type_u_int64_t" in stddef.h:*:* | *:no:no) # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5 $as_echo_n "checking size of long... " >&6; } if ${ac_cv_sizeof_long+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then : else if test "$ac_cv_type_long" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (long) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_long=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5 $as_echo "$ac_cv_sizeof_long" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG $ac_cv_sizeof_long _ACEOF ;; esac if test $acx_cv_header_stdint = stddef.h; then # Lacking a good header? Test size of everything and deduce all types. # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 $as_echo_n "checking size of int... " >&6; } if ${ac_cv_sizeof_int+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then : else if test "$ac_cv_type_int" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (int) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_int=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5 $as_echo "$ac_cv_sizeof_int" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_INT $ac_cv_sizeof_int _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5 $as_echo_n "checking size of short... " >&6; } if ${ac_cv_sizeof_short+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short" "$ac_includes_default"; then : else if test "$ac_cv_type_short" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (short) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_short=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5 $as_echo "$ac_cv_sizeof_short" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_SHORT $ac_cv_sizeof_short _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of char" >&5 $as_echo_n "checking size of char... " >&6; } if ${ac_cv_sizeof_char+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char))" "ac_cv_sizeof_char" "$ac_includes_default"; then : else if test "$ac_cv_type_char" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (char) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_char=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_char" >&5 $as_echo "$ac_cv_sizeof_char" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_CHAR $ac_cv_sizeof_char _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for type equivalent to int8_t" >&5 $as_echo_n "checking for type equivalent to int8_t... " >&6; } case "$ac_cv_sizeof_char" in 1) acx_cv_type_int8_t=char ;; *) as_fn_error please report a bug "no 8-bit type" "$LINENO" 5 esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_type_int8_t" >&5 $as_echo "$acx_cv_type_int8_t" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for type equivalent to int16_t" >&5 $as_echo_n "checking for type equivalent to int16_t... " >&6; } case "$ac_cv_sizeof_int:$ac_cv_sizeof_short" in 2:*) acx_cv_type_int16_t=int ;; *:2) acx_cv_type_int16_t=short ;; *) as_fn_error please report a bug "no 16-bit type" "$LINENO" 5 esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_type_int16_t" >&5 $as_echo "$acx_cv_type_int16_t" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for type equivalent to int32_t" >&5 $as_echo_n "checking for type equivalent to int32_t... " >&6; } case "$ac_cv_sizeof_int:$ac_cv_sizeof_long" in 4:*) acx_cv_type_int32_t=int ;; *:4) acx_cv_type_int32_t=long ;; *) as_fn_error please report a bug "no 32-bit type" "$LINENO" 5 esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_type_int32_t" >&5 $as_echo "$acx_cv_type_int32_t" >&6; } fi # These tests are here to make the output prettier if test "$ac_cv_type_uint64_t" != yes && test "$ac_cv_type_u_int64_t" != yes; then case "$ac_cv_sizeof_long" in 8) acx_cv_type_int64_t=long ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for type equivalent to int64_t" >&5 $as_echo_n "checking for type equivalent to int64_t... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${acx_cv_type_int64_t-'using preprocessor symbols'}" >&5 $as_echo "${acx_cv_type_int64_t-'using preprocessor symbols'}" >&6; } fi # Now we can use the above types if test "$ac_cv_type_uintptr_t" != yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for type equivalent to intptr_t" >&5 $as_echo_n "checking for type equivalent to intptr_t... " >&6; } case $ac_cv_sizeof_void_p in 2) acx_cv_type_intptr_t=int16_t ;; 4) acx_cv_type_intptr_t=int32_t ;; 8) acx_cv_type_intptr_t=int64_t ;; *) as_fn_error please report a bug "no equivalent for intptr_t" "$LINENO" 5 esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_type_intptr_t" >&5 $as_echo "$acx_cv_type_intptr_t" >&6; } fi # ----------------- done all checks, emit header ------------- ac_config_commands="$ac_config_commands gstdint.h" # Checks for typedefs, structures, and compiler characteristics. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __cplusplus /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this sort of thing. */ char tx; char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; } bx; struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then $as_echo "#define const /**/" >>confdefs.h fi ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default" if test "x$ac_cv_type_off_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define off_t long int _ACEOF fi # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 $as_echo_n "checking size of int... " >&6; } if ${ac_cv_sizeof_int+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then : else if test "$ac_cv_type_int" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (int) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_int=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5 $as_echo "$ac_cv_sizeof_int" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_INT $ac_cv_sizeof_int _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5 $as_echo_n "checking size of long... " >&6; } if ${ac_cv_sizeof_long+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then : else if test "$ac_cv_type_long" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (long) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_long=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5 $as_echo "$ac_cv_sizeof_long" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG $ac_cv_sizeof_long _ACEOF # Check for __uint128_t compiler support { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __uint128_t" >&5 $as_echo_n "checking for __uint128_t... " >&6; } if ${libdecnumber_cv_uint128_t+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { __uint128_t u = 0; return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : libdecnumber_cv_uint128_t=yes else libdecnumber_cv_uint128_t=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libdecnumber_cv_uint128_t" >&5 $as_echo "$libdecnumber_cv_uint128_t" >&6; } if test x$libdecnumber_cv_uint128_t = xyes; then cat >>confdefs.h <<_ACEOF #define HAVE_UINT128_T 1 _ACEOF fi # Checks for library functions. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # Check whether --enable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then : enableval=$enable_maintainer_mode; else enable_maintainer_mode=no fi if test "x$enable_maintainer_mode" = xno; then MAINT='#' else MAINT= fi # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 $as_echo_n "checking target system type... " >&6; } if ${ac_cv_target+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$target_alias" = x; then ac_cv_target=$ac_cv_host else ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 $as_echo "$ac_cv_target" >&6; } case $ac_cv_target in *-*-*) ;; *) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;; esac target=$ac_cv_target ac_save_IFS=$IFS; IFS='-' set x $ac_cv_target shift target_cpu=$1 target_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: target_os=$* IFS=$ac_save_IFS case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac # The aliases save the names the user supplied, while $host etc. # will get canonicalized. test -n "$target_alias" && test "$program_prefix$program_suffix$program_transform_name" = \ NONENONEs,x,x, && program_prefix=${target_alias}- # Default decimal format # If you change the defaults here, be sure to change them in the GCC directory also { $as_echo "$as_me:${as_lineno-$LINENO}: checking for decimal floating point" >&5 $as_echo_n "checking for decimal floating point... " >&6; } # Check whether --enable-decimal-float was given. if test "${enable_decimal_float+set}" = set; then : enableval=$enable_decimal_float; case $enable_decimal_float in yes | no | bid | dpd) default_decimal_float=$enable_decimal_float ;; *) as_fn_error $? "'$enable_decimal_float' is an invalid value for --enable-decimal-float. Valid choices are 'yes', 'bid', 'dpd', and 'no'." "$LINENO" 5 ;; esac else case $target in powerpc*-*-linux* | i?86*-*-linux* | x86_64*-*-linux* | s390*-*-linux* | \ i?86*-*-gnu* | \ i?86*-*-mingw* | x86_64*-*-mingw* | \ i?86*-*-cygwin* | x86_64*-*-cygwin*) enable_decimal_float=yes ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: decimal float is not supported for this target, ignored" >&5 $as_echo "$as_me: WARNING: decimal float is not supported for this target, ignored" >&2;} enable_decimal_float=no ;; esac fi # x86's use BID format instead of DPD case x$enable_decimal_float in xyes) case $target in i?86*-*-* | x86_64*-*-*) enable_decimal_float=bid ;; *) enable_decimal_float=dpd ;; esac default_decimal_float=$enable_decimal_float ;; xno) # ENABLE_DECIMAL_FLOAT is set to 0. But we have to have proper # dependency on libdecnumber. default_decimal_float=dpd ;; esac # Use default_decimal_float for dependency. enable_decimal_float=$default_decimal_float # If BID is being used, additional objects should be linked in. if test x$enable_decimal_float = xbid; then ADDITIONAL_OBJS="$ADDITIONAL_OBJS \$(bid_OBJS)" else ADDITIONAL_OBJS= fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_decimal_float" >&5 $as_echo "$enable_decimal_float" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) as_fn_error $? "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac # Enable --enable-host-shared. # Check whether --enable-host-shared was given. if test "${enable_host_shared+set}" = set; then : enableval=$enable_host_shared; PICFLAG=-fPIC else PICFLAG= fi # Output. ac_config_headers="$ac_config_headers config.h:config.in" ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by libdecnumber $as_me , which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ libdecnumber config.status configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # GCC="$GCC" CC="$CC" acx_cv_header_stdint="$acx_cv_header_stdint" acx_cv_type_int8_t="$acx_cv_type_int8_t" acx_cv_type_int16_t="$acx_cv_type_int16_t" acx_cv_type_int32_t="$acx_cv_type_int32_t" acx_cv_type_int64_t="$acx_cv_type_int64_t" acx_cv_type_intptr_t="$acx_cv_type_intptr_t" ac_cv_type_uintmax_t="$ac_cv_type_uintmax_t" ac_cv_type_uintptr_t="$ac_cv_type_uintptr_t" ac_cv_type_uint64_t="$ac_cv_type_uint64_t" ac_cv_type_u_int64_t="$ac_cv_type_u_int64_t" ac_cv_type_u_int32_t="$ac_cv_type_u_int32_t" ac_cv_type_int_least32_t="$ac_cv_type_int_least32_t" ac_cv_type_int_fast32_t="$ac_cv_type_int_fast32_t" ac_cv_sizeof_void_p="$ac_cv_sizeof_void_p" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "gstdint.h") CONFIG_COMMANDS="$CONFIG_COMMANDS gstdint.h" ;; "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "gstdint.h":C) if test "$GCC" = yes; then echo "/* generated for " `$CC --version | sed 1q` "*/" > tmp-stdint.h else echo "/* generated for $CC */" > tmp-stdint.h fi sed 's/^ *//' >> tmp-stdint.h < EOF if test "$acx_cv_header_stdint" != stdint.h; then echo "#include " >> tmp-stdint.h fi if test "$acx_cv_header_stdint" != stddef.h; then echo "#include <$acx_cv_header_stdint>" >> tmp-stdint.h fi sed 's/^ *//' >> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <= 199901L #ifndef _INT64_T #define _INT64_T #ifndef __int64_t_defined typedef long long int64_t; #endif #endif #ifndef _UINT64_T #define _UINT64_T typedef unsigned long long uint64_t; #endif #elif defined __GNUC__ && defined (__STDC__) && __STDC__-0 /* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and does not implement __extension__. But that compiler doesn't define __GNUC_MINOR__. */ # if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__) # define __extension__ # endif # ifndef _INT64_T # define _INT64_T __extension__ typedef long long int64_t; # endif # ifndef _UINT64_T # define _UINT64_T __extension__ typedef unsigned long long uint64_t; # endif #elif !defined __STRICT_ANSI__ # if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__ # ifndef _INT64_T # define _INT64_T typedef __int64 int64_t; # endif # ifndef _UINT64_T # define _UINT64_T typedef unsigned __int64 uint64_t; # endif # endif /* compiler */ #endif /* ANSI version */ EOF fi # ------------- done int64_t types, emit intptr types ------------ if test "$ac_cv_type_uintptr_t" != yes; then sed 's/^ *//' >> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h <> tmp-stdint.h < stamp-h1 ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi libdfp-1.0.12/libdecnumber/configure.ac000066400000000000000000000066701261375163000177710ustar00rootroot00000000000000# configure.ac for libdecnumber -*- Autoconf -*- # Process this file with autoconf to generate a configuration script. # Copyright (C) 2005-2015 Free Software Foundation, Inc. # This file is part of GCC. # GCC 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, or (at your option) any # later #version. # GCC 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 GCC; see the file COPYING3. If not see # . AC_INIT(libdecnumber, [ ], gcc-bugs@gcc.gnu.org, libdecnumber) AC_CONFIG_SRCDIR(decNumber.h) AC_CONFIG_MACRO_DIR(../config) AC_CONFIG_AUX_DIR(..) # Checks for programs. AC_PROG_MAKE_SET AC_PROG_CC AC_PROG_RANLIB MISSING=`cd $ac_aux_dir && ${PWDCMD-pwd}`/missing AC_CHECK_PROGS([ACLOCAL], [aclocal], [$MISSING aclocal]) AC_CHECK_PROGS([AUTOCONF], [autoconf], [$MISSING autoconf]) AC_CHECK_PROGS([AUTOHEADER], [autoheader], [$MISSING autoheader]) # Figure out what compiler warnings we can enable. # See config/warnings.m4 for details. ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \ -Wmissing-prototypes -Wold-style-definition \ -Wmissing-format-attribute]) ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([-Wno-long-long]) # Only enable with --enable-werror-always until existing warnings are # corrected. ACX_PROG_CC_WARNINGS_ARE_ERRORS([manual]) # Checks for header files. AC_CHECK_HEADERS(ctype.h stddef.h string.h stdio.h) GCC_HEADER_STDINT(gstdint.h) # Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_OFF_T AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) # Check for __uint128_t compiler support AC_CACHE_CHECK(for __uint128_t, libdecnumber_cv_uint128_t, AC_TRY_COMPILE([ ], [ __uint128_t u = 0; return 0; ], [ libdecnumber_cv_uint128_t=yes ], [ libdecnumber_cv_uint128_t=no ]) ) if test x$libdecnumber_cv_uint128_t = xyes; then AC_DEFINE_UNQUOTED([HAVE_UINT128_T], [1], ["Have __uint128_t type"]) fi # Checks for library functions. AC_HEADER_STDC AC_ARG_ENABLE(maintainer-mode, [ --enable-maintainer-mode enable rules only needed by maintainers],, enable_maintainer_mode=no) if test "x$enable_maintainer_mode" = xno; then MAINT='#' else MAINT= fi AC_SUBST(MAINT) AC_CANONICAL_TARGET # Default decimal format # If you change the defaults here, be sure to change them in the GCC directory also AC_MSG_CHECKING([for decimal floating point]) GCC_AC_ENABLE_DECIMAL_FLOAT([$target]) # Use default_decimal_float for dependency. enable_decimal_float=$default_decimal_float # If BID is being used, additional objects should be linked in. if test x$enable_decimal_float = xbid; then ADDITIONAL_OBJS="$ADDITIONAL_OBJS \$(bid_OBJS)" else ADDITIONAL_OBJS= fi AC_MSG_RESULT($enable_decimal_float) AC_SUBST(enable_decimal_float) AC_SUBST(ADDITIONAL_OBJS) AC_C_BIGENDIAN # Enable --enable-host-shared. AC_ARG_ENABLE(host-shared, [AS_HELP_STRING([--enable-host-shared], [build host code as shared libraries])], [PICFLAG=-fPIC], [PICFLAG=]) AC_SUBST(PICFLAG) # Output. AC_CONFIG_HEADERS(config.h:config.in, [echo timestamp > stamp-h1]) AC_CONFIG_FILES(Makefile) AC_OUTPUT libdfp-1.0.12/libdecnumber/dconfig.h000066400000000000000000000023171261375163000172570ustar00rootroot00000000000000/* Configure decNumber for either host or target. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ #ifdef IN_LIBGCC2 #include "tconfig.h" #include "coretypes.h" #include "tm.h" #if __FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__ #define WORDS_BIGENDIAN 1 #endif #else #include "config.h" #endif libdfp-1.0.12/libdecnumber/decBasic.c000066400000000000000000004713231261375163000173450ustar00rootroot00000000000000/* Common base code for the decNumber C Library. Copyright (C) 2007-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------ */ /* decBasic.c -- common base code for Basic decimal types */ /* ------------------------------------------------------------------ */ /* This module comprises code that is shared between decDouble and */ /* decQuad (but not decSingle). The main arithmetic operations are */ /* here (Add, Subtract, Multiply, FMA, and Division operators). */ /* */ /* Unlike decNumber, parameterization takes place at compile time */ /* rather than at runtime. The parameters are set in the decDouble.c */ /* (etc.) files, which then include this one to produce the compiled */ /* code. The functions here, therefore, are code shared between */ /* multiple formats. */ /* */ /* This must be included after decCommon.c. */ /* ------------------------------------------------------------------ */ /* Names here refer to decFloat rather than to decDouble, etc., and */ /* the functions are in strict alphabetical order. */ /* The compile-time flags SINGLE, DOUBLE, and QUAD are set up in */ /* decCommon.c */ #if !defined(QUAD) #error decBasic.c must be included after decCommon.c #endif #if SINGLE #error Routines in decBasic.c are for decDouble and decQuad only #endif /* Private constants */ #define DIVIDE 0x80000000 /* Divide operations [as flags] */ #define REMAINDER 0x40000000 /* .. */ #define DIVIDEINT 0x20000000 /* .. */ #define REMNEAR 0x10000000 /* .. */ /* Private functions (local, used only by routines in this module) */ static decFloat *decDivide(decFloat *, const decFloat *, const decFloat *, decContext *, uInt); static decFloat *decCanonical(decFloat *, const decFloat *); static void decFiniteMultiply(bcdnum *, uByte *, const decFloat *, const decFloat *); static decFloat *decInfinity(decFloat *, const decFloat *); static decFloat *decInvalid(decFloat *, decContext *); static decFloat *decNaNs(decFloat *, const decFloat *, const decFloat *, decContext *); static Int decNumCompare(const decFloat *, const decFloat *, Flag); static decFloat *decToIntegral(decFloat *, const decFloat *, decContext *, enum rounding, Flag); static uInt decToInt32(const decFloat *, decContext *, enum rounding, Flag, Flag); /* ------------------------------------------------------------------ */ /* decCanonical -- copy a decFloat, making canonical */ /* */ /* result gets the canonicalized df */ /* df is the decFloat to copy and make canonical */ /* returns result */ /* */ /* This is exposed via decFloatCanonical for Double and Quad only. */ /* This works on specials, too; no error or exception is possible. */ /* ------------------------------------------------------------------ */ static decFloat * decCanonical(decFloat *result, const decFloat *df) { uInt encode, precode, dpd; /* work */ uInt inword, uoff, canon; /* .. */ Int n; /* counter (down) */ if (df!=result) *result=*df; /* effect copy if needed */ if (DFISSPECIAL(result)) { if (DFISINF(result)) return decInfinity(result, df); /* clean Infinity */ /* is a NaN */ DFWORD(result, 0)&=~ECONNANMASK; /* clear ECON except selector */ if (DFISCCZERO(df)) return result; /* coefficient continuation is 0 */ /* drop through to check payload */ } /* return quickly if the coefficient continuation is canonical */ { /* declare block */ #if DOUBLE uInt sourhi=DFWORD(df, 0); uInt sourlo=DFWORD(df, 1); if (CANONDPDOFF(sourhi, 8) && CANONDPDTWO(sourhi, sourlo, 30) && CANONDPDOFF(sourlo, 20) && CANONDPDOFF(sourlo, 10) && CANONDPDOFF(sourlo, 0)) return result; #elif QUAD uInt sourhi=DFWORD(df, 0); uInt sourmh=DFWORD(df, 1); uInt sourml=DFWORD(df, 2); uInt sourlo=DFWORD(df, 3); if (CANONDPDOFF(sourhi, 4) && CANONDPDTWO(sourhi, sourmh, 26) && CANONDPDOFF(sourmh, 16) && CANONDPDOFF(sourmh, 6) && CANONDPDTWO(sourmh, sourml, 28) && CANONDPDOFF(sourml, 18) && CANONDPDOFF(sourml, 8) && CANONDPDTWO(sourml, sourlo, 30) && CANONDPDOFF(sourlo, 20) && CANONDPDOFF(sourlo, 10) && CANONDPDOFF(sourlo, 0)) return result; #endif } /* block */ /* Loop to repair a non-canonical coefficent, as needed */ inword=DECWORDS-1; /* current input word */ uoff=0; /* bit offset of declet */ encode=DFWORD(result, inword); for (n=DECLETS-1; n>=0; n--) { /* count down declets of 10 bits */ dpd=encode>>uoff; uoff+=10; if (uoff>32) { /* crossed uInt boundary */ inword--; encode=DFWORD(result, inword); uoff-=32; dpd|=encode<<(10-uoff); /* get pending bits */ } dpd&=0x3ff; /* clear uninteresting bits */ if (dpd<0x16e) continue; /* must be canonical */ canon=BIN2DPD[DPD2BIN[dpd]]; /* determine canonical declet */ if (canon==dpd) continue; /* have canonical declet */ /* need to replace declet */ if (uoff>=10) { /* all within current word */ encode&=~(0x3ff<<(uoff-10)); /* clear the 10 bits ready for replace */ encode|=canon<<(uoff-10); /* insert the canonical form */ DFWORD(result, inword)=encode; /* .. and save */ continue; } /* straddled words */ precode=DFWORD(result, inword+1); /* get previous */ precode&=0xffffffff>>(10-uoff); /* clear top bits */ DFWORD(result, inword+1)=precode|(canon<<(32-(10-uoff))); encode&=0xffffffff<>(10-uoff); /* insert canonical */ DFWORD(result, inword)=encode; /* .. and save */ } /* n */ return result; } /* decCanonical */ /* ------------------------------------------------------------------ */ /* decDivide -- divide operations */ /* */ /* result gets the result of dividing dfl by dfr: */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* set is the context */ /* op is the operation selector */ /* returns result */ /* */ /* op is one of DIVIDE, REMAINDER, DIVIDEINT, or REMNEAR. */ /* ------------------------------------------------------------------ */ #define DIVCOUNT 0 /* 1 to instrument subtractions counter */ #define DIVBASE ((uInt)BILLION) /* the base used for divide */ #define DIVOPLEN DECPMAX9 /* operand length ('digits' base 10**9) */ #define DIVACCLEN (DIVOPLEN*3) /* accumulator length (ditto) */ static decFloat * decDivide(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set, uInt op) { decFloat quotient; /* for remainders */ bcdnum num; /* for final conversion */ uInt acc[DIVACCLEN]; /* coefficent in base-billion .. */ uInt div[DIVOPLEN]; /* divisor in base-billion .. */ uInt quo[DIVOPLEN+1]; /* quotient in base-billion .. */ uByte bcdacc[(DIVOPLEN+1)*9+2]; /* for quotient in BCD, +1, +1 */ uInt *msua, *msud, *msuq; /* -> msu of acc, div, and quo */ Int divunits, accunits; /* lengths */ Int quodigits; /* digits in quotient */ uInt *lsua, *lsuq; /* -> current acc and quo lsus */ Int length, multiplier; /* work */ uInt carry, sign; /* .. */ uInt *ua, *ud, *uq; /* .. */ uByte *ub; /* .. */ uInt uiwork; /* for macros */ uInt divtop; /* top unit of div adjusted for estimating */ #if DIVCOUNT static uInt maxcount=0; /* worst-seen subtractions count */ uInt divcount=0; /* subtractions count [this divide] */ #endif /* calculate sign */ num.sign=(DFWORD(dfl, 0)^DFWORD(dfr, 0)) & DECFLOAT_Sign; if (DFISSPECIAL(dfl) || DFISSPECIAL(dfr)) { /* either is special? */ /* NaNs are handled as usual */ if (DFISNAN(dfl) || DFISNAN(dfr)) return decNaNs(result, dfl, dfr, set); /* one or two infinities */ if (DFISINF(dfl)) { if (DFISINF(dfr)) return decInvalid(result, set); /* Two infinities bad */ if (op&(REMAINDER|REMNEAR)) return decInvalid(result, set); /* as is rem */ /* Infinity/x is infinite and quiet, even if x=0 */ DFWORD(result, 0)=num.sign; return decInfinity(result, result); } /* must be x/Infinity -- remainders are lhs */ if (op&(REMAINDER|REMNEAR)) return decCanonical(result, dfl); /* divides: return zero with correct sign and exponent depending */ /* on op (Etiny for divide, 0 for divideInt) */ decFloatZero(result); if (op==DIVIDEINT) DFWORD(result, 0)|=num.sign; /* add sign */ else DFWORD(result, 0)=num.sign; /* zeros the exponent, too */ return result; } /* next, handle zero operands (x/0 and 0/x) */ if (DFISZERO(dfr)) { /* x/0 */ if (DFISZERO(dfl)) { /* 0/0 is undefined */ decFloatZero(result); DFWORD(result, 0)=DECFLOAT_qNaN; set->status|=DEC_Division_undefined; return result; } if (op&(REMAINDER|REMNEAR)) return decInvalid(result, set); /* bad rem */ set->status|=DEC_Division_by_zero; DFWORD(result, 0)=num.sign; return decInfinity(result, result); /* x/0 -> signed Infinity */ } num.exponent=GETEXPUN(dfl)-GETEXPUN(dfr); /* ideal exponent */ if (DFISZERO(dfl)) { /* 0/x (x!=0) */ /* if divide, result is 0 with ideal exponent; divideInt has */ /* exponent=0, remainders give zero with lower exponent */ if (op&DIVIDEINT) { decFloatZero(result); DFWORD(result, 0)|=num.sign; /* add sign */ return result; } if (!(op&DIVIDE)) { /* a remainder */ /* exponent is the minimum of the operands */ num.exponent=MINI(GETEXPUN(dfl), GETEXPUN(dfr)); /* if the result is zero the sign shall be sign of dfl */ num.sign=DFWORD(dfl, 0)&DECFLOAT_Sign; } bcdacc[0]=0; num.msd=bcdacc; /* -> 0 */ num.lsd=bcdacc; /* .. */ return decFinalize(result, &num, set); /* [divide may clamp exponent] */ } /* 0/x */ /* [here, both operands are known to be finite and non-zero] */ /* extract the operand coefficents into 'units' which are */ /* base-billion; the lhs is high-aligned in acc and the msu of both */ /* acc and div is at the right-hand end of array (offset length-1); */ /* the quotient can need one more unit than the operands as digits */ /* in it are not necessarily aligned neatly; further, the quotient */ /* may not start accumulating until after the end of the initial */ /* operand in acc if that is small (e.g., 1) so the accumulator */ /* must have at least that number of units extra (at the ls end) */ GETCOEFFBILL(dfl, acc+DIVACCLEN-DIVOPLEN); GETCOEFFBILL(dfr, div); /* zero the low uInts of acc */ acc[0]=0; acc[1]=0; acc[2]=0; acc[3]=0; #if DOUBLE #if DIVOPLEN!=2 #error Unexpected Double DIVOPLEN #endif #elif QUAD acc[4]=0; acc[5]=0; acc[6]=0; acc[7]=0; #if DIVOPLEN!=4 #error Unexpected Quad DIVOPLEN #endif #endif /* set msu and lsu pointers */ msua=acc+DIVACCLEN-1; /* [leading zeros removed below] */ msuq=quo+DIVOPLEN; /*[loop for div will terminate because operands are non-zero] */ for (msud=div+DIVOPLEN-1; *msud==0;) msud--; /* the initial least-significant unit of acc is set so acc appears */ /* to have the same length as div. */ /* This moves one position towards the least possible for each */ /* iteration */ divunits=(Int)(msud-div+1); /* precalculate */ lsua=msua-divunits+1; /* initial working lsu of acc */ lsuq=msuq; /* and of quo */ /* set up the estimator for the multiplier; this is the msu of div, */ /* plus two bits from the unit below (if any) rounded up by one if */ /* there are any non-zero bits or units below that [the extra two */ /* bits makes for a much better estimate when the top unit is small] */ divtop=*msud<<2; if (divunits>1) { uInt *um=msud-1; uInt d=*um; if (d>=750000000) {divtop+=3; d-=750000000;} else if (d>=500000000) {divtop+=2; d-=500000000;} else if (d>=250000000) {divtop++; d-=250000000;} if (d) divtop++; else for (um--; um>=div; um--) if (*um) { divtop++; break; } } /* >1 unit */ #if DECTRACE {Int i; printf("----- div="); for (i=divunits-1; i>=0; i--) printf("%09ld ", (LI)div[i]); printf("\n");} #endif /* now collect up to DECPMAX+1 digits in the quotient (this may */ /* need OPLEN+1 uInts if unaligned) */ quodigits=0; /* no digits yet */ for (;; lsua--) { /* outer loop -- each input position */ #if DECCHECK if (lsua=lsua;) msua--; accunits=(Int)(msua-lsua+1); /* [maybe 0] */ /* subtraction is only necessary and possible if there are as */ /* least as many units remaining in acc for this iteration as */ /* there are in div */ if (accunitsdiv: subtraction necessary at this position */ for (ud=msud, ua=msua; ud>div; ud--, ua--) if (*ud!=*ua) break; /* [now at first mismatch or lsu] */ if (*ud>*ua) break; /* next time... */ if (*ud==*ua) { /* all compared equal */ *lsuq+=1; /* increment result */ msua=lsua; /* collapse acc units */ *msua=0; /* .. to a zero */ break; } /* subtraction necessary; estimate multiplier [see above] */ /* if both *msud and *msua are small it is cost-effective to */ /* bring in part of the following units (if any) to get a */ /* better estimate (assume some other non-zero in div) */ #define DIVLO 1000000U #define DIVHI (DIVBASE/DIVLO) #if DECUSE64 if (divunits>1) { /* there cannot be a *(msud-2) for DECDOUBLE so next is */ /* an exact calculation unless DECQUAD (which needs to */ /* assume bits out there if divunits>2) */ uLong mul=(uLong)*msua * DIVBASE + *(msua-1); uLong div=(uLong)*msud * DIVBASE + *(msud-1); #if QUAD if (divunits>2) div++; #endif mul/=div; multiplier=(Int)mul; } else multiplier=*msua/(*msud); #else if (divunits>1 && *msuadivunits */ /* msud is one unit 'lower' than msua, so estimate differently */ #if DECUSE64 uLong mul; /* as before, bring in extra digits if possible */ if (divunits>1 && *msua>DIVSHIFTA); carry=(uInt)(((uLong)hop*DIVMAGIC)>>DIVSHIFTB); /* the estimate is now in hi; now calculate sub-hi*10**9 */ /* to get the remainder (which will be =DIVBASE) { lo-=DIVBASE; /* correct by +1 */ carry++; } } #else /* 32-bit */ uInt hi; /* calculate multiplier*(*ud) into hi and lo */ LONGMUL32HI(hi, *ud, multiplier); /* get the high word */ lo=multiplier*(*ud); /* .. and the low */ lo+=carry; /* add the old hi */ carry=hi+(lo=DIVBASE) { /* split is needed */ hop=(carry<<3)+(lo>>DIVSHIFTA); /* hi:lo/2**29 */ LONGMUL32HI(carry, hop, DIVMAGIC); /* only need the high word */ /* [DIVSHIFTB is 32, so carry can be used directly] */ /* the estimate is now in carry; now calculate hi:lo-est*10**9; */ /* happily the top word of the result is irrelevant because it */ /* will always be zero so this needs only one multiplication */ lo-=(carry*DIVBASE); /* the correction here will be at most +1; do it */ if (lo>=DIVBASE) { lo-=DIVBASE; carry++; } } #endif if (lo>*ua) { /* borrow needed */ *ua+=DIVBASE; carry++; } *ua-=lo; } /* ud loop */ if (carry) *ua-=carry; /* accdigits>divdigits [cannot borrow] */ } /* inner loop */ /* the outer loop terminates when there is either an exact result */ /* or enough digits; first update the quotient digit count and */ /* pointer (if any significant digits) */ #if DECTRACE if (*lsuq || quodigits) printf("*lsuq=%09ld\n", (LI)*lsuq); #endif if (quodigits) { quodigits+=9; /* had leading unit earlier */ lsuq--; if (quodigits>DECPMAX+1) break; /* have enough */ } else if (*lsuq) { /* first quotient digits */ const uInt *pow; for (pow=DECPOWERS; *lsuq>=*pow; pow++) quodigits++; lsuq--; /* [cannot have >DECPMAX+1 on first unit] */ } if (*msua!=0) continue; /* not an exact result */ /* acc is zero iff used all of original units and zero down to lsua */ /* (must also continue to original lsu for correct quotient length) */ if (lsua>acc+DIVACCLEN-DIVOPLEN) continue; for (; msua>lsua && *msua==0;) msua--; if (*msua==0 && msua==lsua) break; } /* outer loop */ /* all of the original operand in acc has been covered at this point */ /* quotient now has at least DECPMAX+2 digits */ /* *msua is now non-0 if inexact and sticky bits */ /* lsuq is one below the last uint of the quotient */ lsuq++; /* set -> true lsu of quo */ if (*msua) *lsuq|=1; /* apply sticky bit */ /* quo now holds the (unrounded) quotient in base-billion; one */ /* base-billion 'digit' per uInt. */ #if DECTRACE printf("DivQuo:"); for (uq=msuq; uq>=lsuq; uq--) printf(" %09ld", (LI)*uq); printf("\n"); #endif /* Now convert to BCD for rounding and cleanup, starting from the */ /* most significant end [offset by one into bcdacc to leave room */ /* for a possible carry digit if rounding for REMNEAR is needed] */ for (uq=msuq, ub=bcdacc+1; uq>=lsuq; uq--, ub+=9) { uInt top, mid, rem; /* work */ if (*uq==0) { /* no split needed */ UBFROMUI(ub, 0); /* clear 9 BCD8s */ UBFROMUI(ub+4, 0); /* .. */ *(ub+8)=0; /* .. */ continue; } /* *uq is non-zero -- split the base-billion digit into */ /* hi, mid, and low three-digits */ #define divsplit9 1000000 /* divisor */ #define divsplit6 1000 /* divisor */ /* The splitting is done by simple divides and remainders, */ /* assuming the compiler will optimize these [GCC does] */ top=*uq/divsplit9; rem=*uq%divsplit9; mid=rem/divsplit6; rem=rem%divsplit6; /* lay out the nine BCD digits (plus one unwanted byte) */ UBFROMUI(ub, UBTOUI(&BIN2BCD8[top*4])); UBFROMUI(ub+3, UBTOUI(&BIN2BCD8[mid*4])); UBFROMUI(ub+6, UBTOUI(&BIN2BCD8[rem*4])); } /* BCD conversion loop */ ub--; /* -> lsu */ /* complete the bcdnum; quodigits is correct, so the position of */ /* the first non-zero is known */ num.msd=bcdacc+1+(msuq-lsuq+1)*9-quodigits; num.lsd=ub; /* make exponent adjustments, etc */ if (lsuamaxcount) { /* new high-water nark */ maxcount=divcount; printf("DivNewMaxCount: %ld\n", (LI)maxcount); } #endif if (op&DIVIDE) return decFinalize(result, &num, set); /* all done */ /* Is DIVIDEINT or a remainder; there is more to do -- first form */ /* the integer (this is done 'after the fact', unlike as in */ /* decNumber, so as not to tax DIVIDE) */ /* The first non-zero digit will be in the first 9 digits, known */ /* from quodigits and num.msd, so there is always space for DECPMAX */ /* digits */ length=(Int)(num.lsd-num.msd+1); /*printf("Length exp: %ld %ld\n", (LI)length, (LI)num.exponent); */ if (length+num.exponent>DECPMAX) { /* cannot fit */ decFloatZero(result); DFWORD(result, 0)=DECFLOAT_qNaN; set->status|=DEC_Division_impossible; return result; } if (num.exponent>=0) { /* already an int, or need pad zeros */ for (ub=num.lsd+1; ub<=num.lsd+num.exponent; ub++) *ub=0; num.lsd+=num.exponent; } else { /* too long: round or truncate needed */ Int drop=-num.exponent; if (!(op&REMNEAR)) { /* simple truncate */ num.lsd-=drop; if (num.lsd re-round digit */ uByte reround; /* reround value */ *(num.msd-1)=0; /* in case of left carry, or make 0 */ if (drop 0] */ reround=*roundat; for (ub=roundat+1; ub<=num.lsd; ub++) { if (*ub!=0) { reround=DECSTICKYTAB[reround]; break; } } /* check stickies */ if (roundat>num.msd) num.lsd=roundat-1; else { num.msd--; /* use the 0 .. */ num.lsd=num.msd; /* .. at the new MSD place */ } if (reround!=0) { /* discarding non-zero */ uInt bump=0; /* rounding is DEC_ROUND_HALF_EVEN always */ if (reround>5) bump=1; /* >0.5 goes up */ else if (reround==5) /* exactly 0.5000 .. */ bump=*(num.lsd) & 0x01; /* .. up iff [new] lsd is odd */ if (bump!=0) { /* need increment */ /* increment the coefficient; this might end up with 1000... */ ub=num.lsd; for (; UBTOUI(ub-3)==0x09090909; ub-=4) UBFROMUI(ub-3, 0); for (; *ub==9; ub--) *ub=0; /* at most 3 more */ *ub+=1; if (ub9 #error Exponent may overflow when doubled for Multiply #endif #if MULACCLEN!=(MULACCLEN/4)*4 /* This assumption is used below only for initialization */ #error MULACCLEN is not a multiple of 4 #endif static void decFiniteMultiply(bcdnum *num, uByte *bcdacc, const decFloat *dfl, const decFloat *dfr) { uInt bufl[MULOPLEN]; /* left coefficient (base-billion) */ uInt bufr[MULOPLEN]; /* right coefficient (base-billion) */ uInt *ui, *uj; /* work */ uByte *ub; /* .. */ uInt uiwork; /* for macros */ #if DECUSE64 uLong accl[MULACCLEN]; /* lazy accumulator (base-billion+) */ uLong *pl; /* work -> lazy accumulator */ uInt acc[MULACCLEN]; /* coefficent in base-billion .. */ #else uInt acc[MULACCLEN*2]; /* accumulator in base-billion .. */ #endif uInt *pa; /* work -> accumulator */ /*printf("Base10**9: OpLen=%d MulAcclen=%d\n", OPLEN, MULACCLEN); */ /* Calculate sign and exponent */ num->sign=(DFWORD(dfl, 0)^DFWORD(dfr, 0)) & DECFLOAT_Sign; num->exponent=GETEXPUN(dfl)+GETEXPUN(dfr); /* [see assertion above] */ /* Extract the coefficients and prepare the accumulator */ /* the coefficients of the operands are decoded into base-billion */ /* numbers in uInt arrays (bufl and bufr, LSD at offset 0) of the */ /* appropriate size. */ GETCOEFFBILL(dfl, bufl); GETCOEFFBILL(dfr, bufr); #if DECTRACE && 0 printf("CoeffbL:"); for (ui=bufl+MULOPLEN-1; ui>=bufl; ui--) printf(" %08lx", (LI)*ui); printf("\n"); printf("CoeffbR:"); for (uj=bufr+MULOPLEN-1; uj>=bufr; uj--) printf(" %08lx", (LI)*uj); printf("\n"); #endif /* start the 64-bit/32-bit differing paths... */ #if DECUSE64 /* zero the accumulator */ #if MULACCLEN==4 accl[0]=0; accl[1]=0; accl[2]=0; accl[3]=0; #else /* use a loop */ /* MULACCLEN is a multiple of four, asserted above */ for (pl=accl; pl1 may be */ /* needed. Values of A and B are chosen to satisfy the constraints */ /* just mentioned while minimizing the maximum error (and hence the */ /* maximum correction), as shown in the following table: */ /* */ /* Type OPLEN A B maxX maxError maxCorrection */ /* --------------------------------------------------------- */ /* DOUBLE 2 29 32 <2*10**18 0.63 1 */ /* QUAD 4 30 31 <4*10**18 1.17 2 */ /* */ /* In the OPLEN==2 case there is most choice, but the value for B */ /* of 32 has a big advantage as then the calculation of the */ /* estimate requires no shifting; the compiler can extract the high */ /* word directly after multiplying magic*hop. */ #define MULMAGIC 2305843009U /* 2**61/10**9 [both cases] */ #if DOUBLE #define MULSHIFTA 29 #define MULSHIFTB 32 #elif QUAD #define MULSHIFTA 30 #define MULSHIFTB 31 #else #error Unexpected type #endif #if DECTRACE printf("MulAccl:"); for (pl=accl+MULACCLEN-1; pl>=accl; pl--) printf(" %08lx:%08lx", (LI)(*pl>>32), (LI)(*pl&0xffffffff)); printf("\n"); #endif for (pl=accl, pa=acc; pl=MULTBASE) { /* *pl holds a binary number which needs to be split */ hop=(uInt)(*pl>>MULSHIFTA); est=(uInt)(((uLong)hop*MULMAGIC)>>MULSHIFTB); /* the estimate is now in est; now calculate hi:lo-est*10**9; */ /* happily the top word of the result is irrelevant because it */ /* will always be zero so this needs only one multiplication */ lo=(uInt)(*pl-((uLong)est*MULTBASE)); /* low word of result */ /* If QUAD, the correction here could be +2 */ if (lo>=MULTBASE) { lo-=MULTBASE; /* correct by +1 */ est++; #if QUAD /* may need to correct by +2 */ if (lo>=MULTBASE) { lo-=MULTBASE; est++; } #endif } /* finally place lo as the new coefficient 'digit' and add est to */ /* the next place up [this is safe because this path is never */ /* taken on the final iteration as *pl will fit] */ *pa=lo; *(pl+1)+=est; } /* *pl needed split */ else { /* *pl1 may be */ /* needed. Values of A and B are chosen to satisfy the constraints */ /* just mentioned while minimizing the maximum error (and hence the */ /* maximum correction), as shown in the following table: */ /* */ /* Type OPLEN A B maxX maxError maxCorrection */ /* --------------------------------------------------------- */ /* DOUBLE 2 29 32 <2*10**18 0.63 1 */ /* QUAD 4 30 31 <4*10**18 1.17 2 */ /* */ /* In the OPLEN==2 case there is most choice, but the value for B */ /* of 32 has a big advantage as then the calculation of the */ /* estimate requires no shifting; the high word is simply */ /* calculated from multiplying magic*hop. */ #define MULMAGIC 2305843009U /* 2**61/10**9 [both cases] */ #if DOUBLE #define MULSHIFTA 29 #define MULSHIFTB 32 #elif QUAD #define MULSHIFTA 30 #define MULSHIFTB 31 #else #error Unexpected type #endif #if DECTRACE printf("MulHiLo:"); for (pa=acc+MULACCLEN-1; pa>=acc; pa--) printf(" %08lx:%08lx", (LI)*(pa+MULACCLEN), (LI)*pa); printf("\n"); #endif for (pa=acc;; pa++) { /* each low uInt */ uInt hi, lo; /* words of exact multiply result */ uInt hop, estlo; /* work */ #if QUAD uInt esthi; /* .. */ #endif lo=*pa; hi=*(pa+MULACCLEN); /* top 32 bits */ /* hi and lo now hold a binary number which needs to be split */ #if DOUBLE hop=(hi<<3)+(lo>>MULSHIFTA); /* hi:lo/2**29 */ LONGMUL32HI(estlo, hop, MULMAGIC);/* only need the high word */ /* [MULSHIFTB is 32, so estlo can be used directly] */ /* the estimate is now in estlo; now calculate hi:lo-est*10**9; */ /* happily the top word of the result is irrelevant because it */ /* will always be zero so this needs only one multiplication */ lo-=(estlo*MULTBASE); /* esthi=0; // high word is ignored below */ /* the correction here will be at most +1; do it */ if (lo>=MULTBASE) { lo-=MULTBASE; estlo++; } #elif QUAD hop=(hi<<2)+(lo>>MULSHIFTA); /* hi:lo/2**30 */ LONGMUL32HI(esthi, hop, MULMAGIC);/* shift will be 31 .. */ estlo=hop*MULMAGIC; /* .. so low word needed */ estlo=(esthi<<1)+(estlo>>MULSHIFTB); /* [just the top bit] */ /* esthi=0; // high word is ignored below */ lo-=(estlo*MULTBASE); /* as above */ /* the correction here could be +1 or +2 */ if (lo>=MULTBASE) { lo-=MULTBASE; estlo++; } if (lo>=MULTBASE) { lo-=MULTBASE; estlo++; } #else #error Unexpected type #endif /* finally place lo as the new accumulator digit and add est to */ /* the next place up; this latter add could cause a carry of 1 */ /* to the high word of the next place */ *pa=lo; *(pa+1)+=estlo; /* esthi is always 0 for DOUBLE and QUAD so this is skipped */ /* *(pa+1+MULACCLEN)+=esthi; */ if (*(pa+1)=acc; pa--) printf(" %09ld", (LI)*pa); printf("\n"); #endif /* Now convert to BCD for rounding and cleanup, starting from the */ /* most significant end */ pa=acc+MULACCLEN-1; if (*pa!=0) num->msd=bcdacc+LEADZEROS;/* drop known lead zeros */ else { /* >=1 word of leading zeros */ num->msd=bcdacc; /* known leading zeros are gone */ pa--; /* skip first word .. */ for (; *pa==0; pa--) if (pa==acc) break; /* .. and any more leading 0s */ } for (ub=bcdacc;; pa--, ub+=9) { if (*pa!=0) { /* split(s) needed */ uInt top, mid, rem; /* work */ /* *pa is non-zero -- split the base-billion acc digit into */ /* hi, mid, and low three-digits */ #define mulsplit9 1000000 /* divisor */ #define mulsplit6 1000 /* divisor */ /* The splitting is done by simple divides and remainders, */ /* assuming the compiler will optimize these where useful */ /* [GCC does] */ top=*pa/mulsplit9; rem=*pa%mulsplit9; mid=rem/mulsplit6; rem=rem%mulsplit6; /* lay out the nine BCD digits (plus one unwanted byte) */ UBFROMUI(ub, UBTOUI(&BIN2BCD8[top*4])); UBFROMUI(ub+3, UBTOUI(&BIN2BCD8[mid*4])); UBFROMUI(ub+6, UBTOUI(&BIN2BCD8[rem*4])); } else { /* *pa==0 */ UBFROMUI(ub, 0); /* clear 9 BCD8s */ UBFROMUI(ub+4, 0); /* .. */ *(ub+8)=0; /* .. */ } if (pa==acc) break; } /* BCD conversion loop */ num->lsd=ub+8; /* complete the bcdnum .. */ #if DECTRACE decShowNum(num, "postmult"); decFloatShow(dfl, "dfl"); decFloatShow(dfr, "dfr"); #endif return; } /* decFiniteMultiply */ /* ------------------------------------------------------------------ */ /* decFloatAbs -- absolute value, heeding NaNs, etc. */ /* */ /* result gets the canonicalized df with sign 0 */ /* df is the decFloat to abs */ /* set is the context */ /* returns result */ /* */ /* This has the same effect as decFloatPlus unless df is negative, */ /* in which case it has the same effect as decFloatMinus. The */ /* effect is also the same as decFloatCopyAbs except that NaNs are */ /* handled normally (the sign of a NaN is not affected, and an sNaN */ /* will signal) and the result will be canonical. */ /* ------------------------------------------------------------------ */ decFloat * decFloatAbs(decFloat *result, const decFloat *df, decContext *set) { if (DFISNAN(df)) return decNaNs(result, df, NULL, set); decCanonical(result, df); /* copy and check */ DFBYTE(result, 0)&=~0x80; /* zero sign bit */ return result; } /* decFloatAbs */ /* ------------------------------------------------------------------ */ /* decFloatAdd -- add two decFloats */ /* */ /* result gets the result of adding dfl and dfr: */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* set is the context */ /* returns result */ /* */ /* ------------------------------------------------------------------ */ #if QUAD /* Table for testing MSDs for fastpath elimination; returns the MSD of */ /* a decDouble or decQuad (top 6 bits tested) ignoring the sign. */ /* Infinities return -32 and NaNs return -128 so that summing the two */ /* MSDs also allows rapid tests for the Specials (see code below). */ const Int DECTESTMSD[64]={ 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 9, 8, 9, -32, -128, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 9, 8, 9, -32, -128}; #else /* The table for testing MSDs is shared between the modules */ extern const Int DECTESTMSD[64]; #endif decFloat * decFloatAdd(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { bcdnum num; /* for final conversion */ Int bexpl, bexpr; /* left and right biased exponents */ uByte *ub, *us, *ut; /* work */ uInt uiwork; /* for macros */ #if QUAD uShort uswork; /* .. */ #endif uInt sourhil, sourhir; /* top words from source decFloats */ /* [valid only through end of */ /* fastpath code -- before swap] */ uInt diffsign; /* non-zero if signs differ */ uInt carry; /* carry: 0 or 1 before add loop */ Int overlap; /* coefficient overlap (if full) */ Int summ; /* sum of the MSDs */ /* the following buffers hold coefficients with various alignments */ /* (see commentary and diagrams below) */ uByte acc[4+2+DECPMAX*3+8]; uByte buf[4+2+DECPMAX*2]; uByte *umsd, *ulsd; /* local MSD and LSD pointers */ #if DECLITEND #define CARRYPAT 0x01000000 /* carry=1 pattern */ #else #define CARRYPAT 0x00000001 /* carry=1 pattern */ #endif /* Start decoding the arguments */ /* The initial exponents are placed into the opposite Ints to */ /* that which might be expected; there are two sets of data to */ /* keep track of (each decFloat and the corresponding exponent), */ /* and this scheme means that at the swap point (after comparing */ /* exponents) only one pair of words needs to be swapped */ /* whichever path is taken (thereby minimising worst-case path). */ /* The calculated exponents will be nonsense when the arguments are */ /* Special, but are not used in that path */ sourhil=DFWORD(dfl, 0); /* LHS top word */ summ=DECTESTMSD[sourhil>>26]; /* get first MSD for testing */ bexpr=DECCOMBEXP[sourhil>>26]; /* get exponent high bits (in place) */ bexpr+=GETECON(dfl); /* .. + continuation */ sourhir=DFWORD(dfr, 0); /* RHS top word */ summ+=DECTESTMSD[sourhir>>26]; /* sum MSDs for testing */ bexpl=DECCOMBEXP[sourhir>>26]; bexpl+=GETECON(dfr); /* here bexpr has biased exponent from lhs, and vice versa */ diffsign=(sourhil^sourhir)&DECFLOAT_Sign; /* now determine whether to take a fast path or the full-function */ /* slow path. The slow path must be taken when: */ /* -- both numbers are finite, and: */ /* the exponents are different, or */ /* the signs are different, or */ /* the sum of the MSDs is >8 (hence might overflow) */ /* specialness and the sum of the MSDs can be tested at once using */ /* the summ value just calculated, so the test for specials is no */ /* longer on the worst-case path (as of 3.60) */ if (summ<=8) { /* MSD+MSD is good, or there is a special */ if (summ<0) { /* there is a special */ /* Inf+Inf would give -64; Inf+finite is -32 or higher */ if (summ<-64) return decNaNs(result, dfl, dfr, set); /* one or two NaNs */ /* two infinities with different signs is invalid */ if (summ==-64 && diffsign) return decInvalid(result, set); if (DFISINF(dfl)) return decInfinity(result, dfl); /* LHS is infinite */ return decInfinity(result, dfr); /* RHS must be Inf */ } /* Here when both arguments are finite; fast path is possible */ /* (currently only for aligned and same-sign) */ if (bexpr==bexpl && !diffsign) { uInt tac[DECLETS+1]; /* base-1000 coefficient */ uInt encode; /* work */ /* Get one coefficient as base-1000 and add the other */ GETCOEFFTHOU(dfl, tac); /* least-significant goes to [0] */ ADDCOEFFTHOU(dfr, tac); /* here the sum of the MSDs (plus any carry) will be <10 due to */ /* the fastpath test earlier */ /* construct the result; low word is the same for both formats */ encode =BIN2DPD[tac[0]]; encode|=BIN2DPD[tac[1]]<<10; encode|=BIN2DPD[tac[2]]<<20; encode|=BIN2DPD[tac[3]]<<30; DFWORD(result, (DECBYTES/4)-1)=encode; /* collect next two declets (all that remains, for Double) */ encode =BIN2DPD[tac[3]]>>2; encode|=BIN2DPD[tac[4]]<<8; #if QUAD /* complete and lay out middling words */ encode|=BIN2DPD[tac[5]]<<18; encode|=BIN2DPD[tac[6]]<<28; DFWORD(result, 2)=encode; encode =BIN2DPD[tac[6]]>>4; encode|=BIN2DPD[tac[7]]<<6; encode|=BIN2DPD[tac[8]]<<16; encode|=BIN2DPD[tac[9]]<<26; DFWORD(result, 1)=encode; /* and final two declets */ encode =BIN2DPD[tac[9]]>>6; encode|=BIN2DPD[tac[10]]<<4; #endif /* add exponent continuation and sign (from either argument) */ encode|=sourhil & (ECONMASK | DECFLOAT_Sign); /* create lookup index = MSD + top two bits of biased exponent <<4 */ tac[DECLETS]|=(bexpl>>DECECONL)<<4; encode|=DECCOMBFROM[tac[DECLETS]]; /* add constructed combination field */ DFWORD(result, 0)=encode; /* complete */ /* decFloatShow(result, ">"); */ return result; } /* fast path OK */ /* drop through to slow path */ } /* low sum or Special(s) */ /* Slow path required -- arguments are finite and might overflow, */ /* or require alignment, or might have different signs */ /* now swap either exponents or argument pointers */ if (bexpl<=bexpr) { /* original left is bigger */ Int bexpswap=bexpl; bexpl=bexpr; bexpr=bexpswap; /* printf("left bigger\n"); */ } else { const decFloat *dfswap=dfl; dfl=dfr; dfr=dfswap; /* printf("right bigger\n"); */ } /* [here dfl and bexpl refer to the datum with the larger exponent, */ /* of if the exponents are equal then the original LHS argument] */ /* if lhs is zero then result will be the rhs (now known to have */ /* the smaller exponent), which also may need to be tested for zero */ /* for the weird IEEE 754 sign rules */ if (DFISZERO(dfl)) { decCanonical(result, dfr); /* clean copy */ /* "When the sum of two operands with opposite signs is */ /* exactly zero, the sign of that sum shall be '+' in all */ /* rounding modes except round toward -Infinity, in which */ /* mode that sign shall be '-'." */ if (diffsign && DFISZERO(result)) { DFWORD(result, 0)&=~DECFLOAT_Sign; /* assume sign 0 */ if (set->round==DEC_ROUND_FLOOR) DFWORD(result, 0)|=DECFLOAT_Sign; } return result; } /* numfl is zero */ /* [here, LHS is non-zero; code below assumes that] */ /* Coefficients layout during the calculations to follow: */ /* */ /* Overlap case: */ /* +------------------------------------------------+ */ /* acc: |0000| coeffa | tail B | | */ /* +------------------------------------------------+ */ /* buf: |0000| pad0s | coeffb | | */ /* +------------------------------------------------+ */ /* */ /* Touching coefficients or gap: */ /* +------------------------------------------------+ */ /* acc: |0000| coeffa | gap | coeffb | */ /* +------------------------------------------------+ */ /* [buf not used or needed; gap clamped to Pmax] */ /* lay out lhs coefficient into accumulator; this starts at acc+4 */ /* for decDouble or acc+6 for decQuad so the LSD is word- */ /* aligned; the top word gap is there only in case a carry digit */ /* is prefixed after the add -- it does not need to be zeroed */ #if DOUBLE #define COFF 4 /* offset into acc */ #elif QUAD UBFROMUS(acc+4, 0); /* prefix 00 */ #define COFF 6 /* offset into acc */ #endif GETCOEFF(dfl, acc+COFF); /* decode from decFloat */ ulsd=acc+COFF+DECPMAX-1; umsd=acc+4; /* [having this here avoids */ #if DECTRACE {bcdnum tum; tum.msd=umsd; tum.lsd=ulsd; tum.exponent=bexpl-DECBIAS; tum.sign=DFWORD(dfl, 0) & DECFLOAT_Sign; decShowNum(&tum, "dflx");} #endif /* if signs differ, take ten's complement of lhs (here the */ /* coefficient is subtracted from all-nines; the 1 is added during */ /* the later add cycle -- zeros to the right do not matter because */ /* the complement of zero is zero); these are fixed-length inverts */ /* where the lsd is known to be at a 4-byte boundary (so no borrow */ /* possible) */ carry=0; /* assume no carry */ if (diffsign) { carry=CARRYPAT; /* for +1 during add */ UBFROMUI(acc+ 4, 0x09090909-UBTOUI(acc+ 4)); UBFROMUI(acc+ 8, 0x09090909-UBTOUI(acc+ 8)); UBFROMUI(acc+12, 0x09090909-UBTOUI(acc+12)); UBFROMUI(acc+16, 0x09090909-UBTOUI(acc+16)); #if QUAD UBFROMUI(acc+20, 0x09090909-UBTOUI(acc+20)); UBFROMUI(acc+24, 0x09090909-UBTOUI(acc+24)); UBFROMUI(acc+28, 0x09090909-UBTOUI(acc+28)); UBFROMUI(acc+32, 0x09090909-UBTOUI(acc+32)); UBFROMUI(acc+36, 0x09090909-UBTOUI(acc+36)); #endif } /* diffsign */ /* now process the rhs coefficient; if it cannot overlap lhs then */ /* it can be put straight into acc (with an appropriate gap, if */ /* needed) because no actual addition will be needed (except */ /* possibly to complete ten's complement) */ overlap=DECPMAX-(bexpl-bexpr); #if DECTRACE printf("exps: %ld %ld\n", (LI)(bexpl-DECBIAS), (LI)(bexpr-DECBIAS)); printf("Overlap=%ld carry=%08lx\n", (LI)overlap, (LI)carry); #endif if (overlap<=0) { /* no overlap possible */ uInt gap; /* local work */ /* since a full addition is not needed, a ten's complement */ /* calculation started above may need to be completed */ if (carry) { for (ub=ulsd; *ub==9; ub--) *ub=0; *ub+=1; carry=0; /* taken care of */ } /* up to DECPMAX-1 digits of the final result can extend down */ /* below the LSD of the lhs, so if the gap is >DECPMAX then the */ /* rhs will be simply sticky bits. In this case the gap is */ /* clamped to DECPMAX and the exponent adjusted to suit [this is */ /* safe because the lhs is non-zero]. */ gap=-overlap; if (gap>DECPMAX) { bexpr+=gap-1; gap=DECPMAX; } ub=ulsd+gap+1; /* where MSD will go */ /* Fill the gap with 0s; note that there is no addition to do */ ut=acc+COFF+DECPMAX; /* start of gap */ for (; ut DECPMAX */ *ub=(uByte)(!DFISZERO(dfr)); /* make sticky digit */ } else { /* need full coefficient */ GETCOEFF(dfr, ub); /* decode from decFloat */ ub+=DECPMAX-1; /* new LSD... */ } ulsd=ub; /* save new LSD */ } /* no overlap possible */ else { /* overlap>0 */ /* coefficients overlap (perhaps completely, although also */ /* perhaps only where zeros) */ if (overlap==DECPMAX) { /* aligned */ ub=buf+COFF; /* where msd will go */ #if QUAD UBFROMUS(buf+4, 0); /* clear quad's 00 */ #endif GETCOEFF(dfr, ub); /* decode from decFloat */ } else { /* unaligned */ ub=buf+COFF+DECPMAX-overlap; /* where MSD will go */ /* Fill the prefix gap with 0s; 8 will cover most common */ /* unalignments, so start with direct assignments (a loop is */ /* then used for any remaining -- the loop (and the one in a */ /* moment) is not then on the critical path because the number */ /* of additions is reduced by (at least) two in this case) */ UBFROMUI(buf+4, 0); /* [clears decQuad 00 too] */ UBFROMUI(buf+8, 0); if (ub>buf+12) { ut=buf+12; /* start any remaining */ for (; ut=acc+4; ut-=4, us-=4) { /* big-endian add loop */ /* bcd8 add */ carry+=UBTOUI(us); /* rhs + carry */ if (carry==0) continue; /* no-op */ carry+=UBTOUI(ut); /* lhs */ /* Big-endian BCD adjust (uses internal carry) */ carry+=0x76f6f6f6; /* note top nibble not all bits */ /* apply BCD adjust and save */ UBFROMUI(ut, (carry & 0x0f0f0f0f) - ((carry & 0x60606060)>>4)); carry>>=31; /* true carry was at far left */ } /* add loop */ #else for (; ut>=acc+4; ut-=4, us-=4) { /* little-endian add loop */ /* bcd8 add */ carry+=UBTOUI(us); /* rhs + carry */ if (carry==0) continue; /* no-op [common if unaligned] */ carry+=UBTOUI(ut); /* lhs */ /* Little-endian BCD adjust; inter-digit carry must be manual */ /* because the lsb from the array will be in the most-significant */ /* byte of carry */ carry+=0x76767676; /* note no inter-byte carries */ carry+=(carry & 0x80000000)>>15; carry+=(carry & 0x00800000)>>15; carry+=(carry & 0x00008000)>>15; carry-=(carry & 0x60606060)>>4; /* BCD adjust back */ UBFROMUI(ut, carry & 0x0f0f0f0f); /* clear debris and save */ /* here, final carry-out bit is at 0x00000080; move it ready */ /* for next word-add (i.e., to 0x01000000) */ carry=(carry & 0x00000080)<<17; } /* add loop */ #endif #if DECTRACE {bcdnum tum; printf("Add done, carry=%08lx, diffsign=%ld\n", (LI)carry, (LI)diffsign); tum.msd=umsd; /* acc+4; */ tum.lsd=ulsd; tum.exponent=0; tum.sign=0; decShowNum(&tum, "dfadd");} #endif } /* overlap possible */ /* ordering here is a little strange in order to have slowest path */ /* first in GCC asm listing */ if (diffsign) { /* subtraction */ if (!carry) { /* no carry out means RHS=umsd+BNEXT) { /* unaligned */ /* eight will handle most unaligments for Double; 16 for Quad */ UBFROMUI(umsd+BNEXT, 0x09090909-UBTOUI(umsd+BNEXT)); UBFROMUI(umsd+BNEXT+4, 0x09090909-UBTOUI(umsd+BNEXT+4)); #if DOUBLE #define BNEXTY (BNEXT+8) #elif QUAD UBFROMUI(umsd+BNEXT+8, 0x09090909-UBTOUI(umsd+BNEXT+8)); UBFROMUI(umsd+BNEXT+12, 0x09090909-UBTOUI(umsd+BNEXT+12)); #define BNEXTY (BNEXT+16) #endif if (ulsd>=umsd+BNEXTY) { /* very unaligned */ ut=umsd+BNEXTY; /* -> continue */ for (;;ut+=4) { UBFROMUI(ut, 0x09090909-UBTOUI(ut)); /* invert four digits */ if (ut>=ulsd-3) break; /* all done */ } } } /* complete the ten's complement by adding 1 */ for (ub=ulsd; *ub==9; ub--) *ub=0; *ub+=1; } /* borrowed */ else { /* carry out means RHS>=LHS */ num.sign=DFWORD(dfr, 0) & DECFLOAT_Sign; /* all done except for the special IEEE 754 exact-zero-result */ /* rule (see above); while testing for zero, strip leading */ /* zeros (which will save decFinalize doing it) (this is in */ /* diffsign path, so carry impossible and true umsd is */ /* acc+COFF) */ /* Check the initial coefficient area using the fast macro; */ /* this will often be all that needs to be done (as on the */ /* worst-case path when the subtraction was aligned and */ /* full-length) */ if (ISCOEFFZERO(acc+COFF)) { umsd=acc+COFF+DECPMAX-1; /* so far, so zero */ if (ulsd>umsd) { /* more to check */ umsd++; /* to align after checked area */ for (; UBTOUI(umsd)==0 && umsd+3round==DEC_ROUND_FLOOR) num.sign=DECFLOAT_Sign; } } /* [else was not zero, might still have leading zeros] */ } /* subtraction gave positive result */ } /* diffsign */ else { /* same-sign addition */ num.sign=DFWORD(dfl, 0)&DECFLOAT_Sign; #if DOUBLE if (carry) { /* only possible with decDouble */ *(acc+3)=1; /* [Quad has leading 00] */ umsd=acc+3; } #endif } /* same sign */ num.msd=umsd; /* set MSD .. */ num.lsd=ulsd; /* .. and LSD */ num.exponent=bexpr-DECBIAS; /* set exponent to smaller, unbiassed */ #if DECTRACE decFloatShow(dfl, "dfl"); decFloatShow(dfr, "dfr"); decShowNum(&num, "postadd"); #endif return decFinalize(result, &num, set); /* round, check, and lay out */ } /* decFloatAdd */ /* ------------------------------------------------------------------ */ /* decFloatAnd -- logical digitwise AND of two decFloats */ /* */ /* result gets the result of ANDing dfl and dfr */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* set is the context */ /* returns result, which will be canonical with sign=0 */ /* */ /* The operands must be positive, finite with exponent q=0, and */ /* comprise just zeros and ones; if not, Invalid operation results. */ /* ------------------------------------------------------------------ */ decFloat * decFloatAnd(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { if (!DFISUINT01(dfl) || !DFISUINT01(dfr) || !DFISCC01(dfl) || !DFISCC01(dfr)) return decInvalid(result, set); /* the operands are positive finite integers (q=0) with just 0s and 1s */ #if DOUBLE DFWORD(result, 0)=ZEROWORD |((DFWORD(dfl, 0) & DFWORD(dfr, 0))&0x04009124); DFWORD(result, 1)=(DFWORD(dfl, 1) & DFWORD(dfr, 1))&0x49124491; #elif QUAD DFWORD(result, 0)=ZEROWORD |((DFWORD(dfl, 0) & DFWORD(dfr, 0))&0x04000912); DFWORD(result, 1)=(DFWORD(dfl, 1) & DFWORD(dfr, 1))&0x44912449; DFWORD(result, 2)=(DFWORD(dfl, 2) & DFWORD(dfr, 2))&0x12449124; DFWORD(result, 3)=(DFWORD(dfl, 3) & DFWORD(dfr, 3))&0x49124491; #endif return result; } /* decFloatAnd */ /* ------------------------------------------------------------------ */ /* decFloatCanonical -- copy a decFloat, making canonical */ /* */ /* result gets the canonicalized df */ /* df is the decFloat to copy and make canonical */ /* returns result */ /* */ /* This works on specials, too; no error or exception is possible. */ /* ------------------------------------------------------------------ */ decFloat * decFloatCanonical(decFloat *result, const decFloat *df) { return decCanonical(result, df); } /* decFloatCanonical */ /* ------------------------------------------------------------------ */ /* decFloatClass -- return the class of a decFloat */ /* */ /* df is the decFloat to test */ /* returns the decClass that df falls into */ /* ------------------------------------------------------------------ */ enum decClass decFloatClass(const decFloat *df) { Int exp; /* exponent */ if (DFISSPECIAL(df)) { if (DFISQNAN(df)) return DEC_CLASS_QNAN; if (DFISSNAN(df)) return DEC_CLASS_SNAN; /* must be an infinity */ if (DFISSIGNED(df)) return DEC_CLASS_NEG_INF; return DEC_CLASS_POS_INF; } if (DFISZERO(df)) { /* quite common */ if (DFISSIGNED(df)) return DEC_CLASS_NEG_ZERO; return DEC_CLASS_POS_ZERO; } /* is finite and non-zero; similar code to decFloatIsNormal, here */ /* [this could be speeded up slightly by in-lining decFloatDigits] */ exp=GETEXPUN(df) /* get unbiased exponent .. */ +decFloatDigits(df)-1; /* .. and make adjusted exponent */ if (exp>=DECEMIN) { /* is normal */ if (DFISSIGNED(df)) return DEC_CLASS_NEG_NORMAL; return DEC_CLASS_POS_NORMAL; } /* is subnormal */ if (DFISSIGNED(df)) return DEC_CLASS_NEG_SUBNORMAL; return DEC_CLASS_POS_SUBNORMAL; } /* decFloatClass */ /* ------------------------------------------------------------------ */ /* decFloatClassString -- return the class of a decFloat as a string */ /* */ /* df is the decFloat to test */ /* returns a constant string describing the class df falls into */ /* ------------------------------------------------------------------ */ const char *decFloatClassString(const decFloat *df) { enum decClass eclass=decFloatClass(df); if (eclass==DEC_CLASS_POS_NORMAL) return DEC_ClassString_PN; if (eclass==DEC_CLASS_NEG_NORMAL) return DEC_ClassString_NN; if (eclass==DEC_CLASS_POS_ZERO) return DEC_ClassString_PZ; if (eclass==DEC_CLASS_NEG_ZERO) return DEC_ClassString_NZ; if (eclass==DEC_CLASS_POS_SUBNORMAL) return DEC_ClassString_PS; if (eclass==DEC_CLASS_NEG_SUBNORMAL) return DEC_ClassString_NS; if (eclass==DEC_CLASS_POS_INF) return DEC_ClassString_PI; if (eclass==DEC_CLASS_NEG_INF) return DEC_ClassString_NI; if (eclass==DEC_CLASS_QNAN) return DEC_ClassString_QN; if (eclass==DEC_CLASS_SNAN) return DEC_ClassString_SN; return DEC_ClassString_UN; /* Unknown */ } /* decFloatClassString */ /* ------------------------------------------------------------------ */ /* decFloatCompare -- compare two decFloats; quiet NaNs allowed */ /* */ /* result gets the result of comparing dfl and dfr */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* set is the context */ /* returns result, which may be -1, 0, 1, or NaN (Unordered) */ /* ------------------------------------------------------------------ */ decFloat * decFloatCompare(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { Int comp; /* work */ /* NaNs are handled as usual */ if (DFISNAN(dfl) || DFISNAN(dfr)) return decNaNs(result, dfl, dfr, set); /* numeric comparison needed */ comp=decNumCompare(dfl, dfr, 0); decFloatZero(result); if (comp==0) return result; DFBYTE(result, DECBYTES-1)=0x01; /* LSD=1 */ if (comp<0) DFBYTE(result, 0)|=0x80; /* set sign bit */ return result; } /* decFloatCompare */ /* ------------------------------------------------------------------ */ /* decFloatCompareSignal -- compare two decFloats; all NaNs signal */ /* */ /* result gets the result of comparing dfl and dfr */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* set is the context */ /* returns result, which may be -1, 0, 1, or NaN (Unordered) */ /* ------------------------------------------------------------------ */ decFloat * decFloatCompareSignal(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { Int comp; /* work */ /* NaNs are handled as usual, except that all NaNs signal */ if (DFISNAN(dfl) || DFISNAN(dfr)) { set->status|=DEC_Invalid_operation; return decNaNs(result, dfl, dfr, set); } /* numeric comparison needed */ comp=decNumCompare(dfl, dfr, 0); decFloatZero(result); if (comp==0) return result; DFBYTE(result, DECBYTES-1)=0x01; /* LSD=1 */ if (comp<0) DFBYTE(result, 0)|=0x80; /* set sign bit */ return result; } /* decFloatCompareSignal */ /* ------------------------------------------------------------------ */ /* decFloatCompareTotal -- compare two decFloats with total ordering */ /* */ /* result gets the result of comparing dfl and dfr */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* returns result, which may be -1, 0, or 1 */ /* ------------------------------------------------------------------ */ decFloat * decFloatCompareTotal(decFloat *result, const decFloat *dfl, const decFloat *dfr) { Int comp; /* work */ uInt uiwork; /* for macros */ #if QUAD uShort uswork; /* .. */ #endif if (DFISNAN(dfl) || DFISNAN(dfr)) { Int nanl, nanr; /* work */ /* morph NaNs to +/- 1 or 2, leave numbers as 0 */ nanl=DFISSNAN(dfl)+DFISQNAN(dfl)*2; /* quiet > signalling */ if (DFISSIGNED(dfl)) nanl=-nanl; nanr=DFISSNAN(dfr)+DFISQNAN(dfr)*2; if (DFISSIGNED(dfr)) nanr=-nanr; if (nanl>nanr) comp=+1; else if (nanl*uc) comp=sigl; /* difference found */ else comp=-sigl; /* .. */ break; } } } /* same NaN type and sign */ } else { /* numeric comparison needed */ comp=decNumCompare(dfl, dfr, 1); /* total ordering */ } decFloatZero(result); if (comp==0) return result; DFBYTE(result, DECBYTES-1)=0x01; /* LSD=1 */ if (comp<0) DFBYTE(result, 0)|=0x80; /* set sign bit */ return result; } /* decFloatCompareTotal */ /* ------------------------------------------------------------------ */ /* decFloatCompareTotalMag -- compare magnitudes with total ordering */ /* */ /* result gets the result of comparing abs(dfl) and abs(dfr) */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* returns result, which may be -1, 0, or 1 */ /* ------------------------------------------------------------------ */ decFloat * decFloatCompareTotalMag(decFloat *result, const decFloat *dfl, const decFloat *dfr) { decFloat a, b; /* for copy if needed */ /* copy and redirect signed operand(s) */ if (DFISSIGNED(dfl)) { decFloatCopyAbs(&a, dfl); dfl=&a; } if (DFISSIGNED(dfr)) { decFloatCopyAbs(&b, dfr); dfr=&b; } return decFloatCompareTotal(result, dfl, dfr); } /* decFloatCompareTotalMag */ /* ------------------------------------------------------------------ */ /* decFloatCopy -- copy a decFloat as-is */ /* */ /* result gets the copy of dfl */ /* dfl is the decFloat to copy */ /* returns result */ /* */ /* This is a bitwise operation; no errors or exceptions are possible. */ /* ------------------------------------------------------------------ */ decFloat * decFloatCopy(decFloat *result, const decFloat *dfl) { if (dfl!=result) *result=*dfl; /* copy needed */ return result; } /* decFloatCopy */ /* ------------------------------------------------------------------ */ /* decFloatCopyAbs -- copy a decFloat as-is and set sign bit to 0 */ /* */ /* result gets the copy of dfl with sign bit 0 */ /* dfl is the decFloat to copy */ /* returns result */ /* */ /* This is a bitwise operation; no errors or exceptions are possible. */ /* ------------------------------------------------------------------ */ decFloat * decFloatCopyAbs(decFloat *result, const decFloat *dfl) { if (dfl!=result) *result=*dfl; /* copy needed */ DFBYTE(result, 0)&=~0x80; /* zero sign bit */ return result; } /* decFloatCopyAbs */ /* ------------------------------------------------------------------ */ /* decFloatCopyNegate -- copy a decFloat as-is with inverted sign bit */ /* */ /* result gets the copy of dfl with sign bit inverted */ /* dfl is the decFloat to copy */ /* returns result */ /* */ /* This is a bitwise operation; no errors or exceptions are possible. */ /* ------------------------------------------------------------------ */ decFloat * decFloatCopyNegate(decFloat *result, const decFloat *dfl) { if (dfl!=result) *result=*dfl; /* copy needed */ DFBYTE(result, 0)^=0x80; /* invert sign bit */ return result; } /* decFloatCopyNegate */ /* ------------------------------------------------------------------ */ /* decFloatCopySign -- copy a decFloat with the sign of another */ /* */ /* result gets the result of copying dfl with the sign of dfr */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* returns result */ /* */ /* This is a bitwise operation; no errors or exceptions are possible. */ /* ------------------------------------------------------------------ */ decFloat * decFloatCopySign(decFloat *result, const decFloat *dfl, const decFloat *dfr) { uByte sign=(uByte)(DFBYTE(dfr, 0)&0x80); /* save sign bit */ if (dfl!=result) *result=*dfl; /* copy needed */ DFBYTE(result, 0)&=~0x80; /* clear sign .. */ DFBYTE(result, 0)=(uByte)(DFBYTE(result, 0)|sign); /* .. and set saved */ return result; } /* decFloatCopySign */ /* ------------------------------------------------------------------ */ /* decFloatDigits -- return the number of digits in a decFloat */ /* */ /* df is the decFloat to investigate */ /* returns the number of significant digits in the decFloat; a */ /* zero coefficient returns 1 as does an infinity (a NaN returns */ /* the number of digits in the payload) */ /* ------------------------------------------------------------------ */ /* private macro to extract a declet according to provided formula */ /* (form), and if it is non-zero then return the calculated digits */ /* depending on the declet number (n), where n=0 for the most */ /* significant declet; uses uInt dpd for work */ #define dpdlenchk(n, form) {dpd=(form)&0x3ff; \ if (dpd) return (DECPMAX-1-3*(n))-(3-DPD2BCD8[dpd*4+3]);} /* next one is used when it is known that the declet must be */ /* non-zero, or is the final zero declet */ #define dpdlendun(n, form) {dpd=(form)&0x3ff; \ if (dpd==0) return 1; \ return (DECPMAX-1-3*(n))-(3-DPD2BCD8[dpd*4+3]);} uInt decFloatDigits(const decFloat *df) { uInt dpd; /* work */ uInt sourhi=DFWORD(df, 0); /* top word from source decFloat */ #if QUAD uInt sourmh, sourml; #endif uInt sourlo; if (DFISINF(df)) return 1; /* A NaN effectively has an MSD of 0; otherwise if non-zero MSD */ /* then the coefficient is full-length */ if (!DFISNAN(df) && DECCOMBMSD[sourhi>>26]) return DECPMAX; #if DOUBLE if (sourhi&0x0003ffff) { /* ends in first */ dpdlenchk(0, sourhi>>8); sourlo=DFWORD(df, 1); dpdlendun(1, (sourhi<<2) | (sourlo>>30)); } /* [cannot drop through] */ sourlo=DFWORD(df, 1); /* sourhi not involved now */ if (sourlo&0xfff00000) { /* in one of first two */ dpdlenchk(1, sourlo>>30); /* very rare */ dpdlendun(2, sourlo>>20); } /* [cannot drop through] */ dpdlenchk(3, sourlo>>10); dpdlendun(4, sourlo); /* [cannot drop through] */ #elif QUAD if (sourhi&0x00003fff) { /* ends in first */ dpdlenchk(0, sourhi>>4); sourmh=DFWORD(df, 1); dpdlendun(1, ((sourhi)<<6) | (sourmh>>26)); } /* [cannot drop through] */ sourmh=DFWORD(df, 1); if (sourmh) { dpdlenchk(1, sourmh>>26); dpdlenchk(2, sourmh>>16); dpdlenchk(3, sourmh>>6); sourml=DFWORD(df, 2); dpdlendun(4, ((sourmh)<<4) | (sourml>>28)); } /* [cannot drop through] */ sourml=DFWORD(df, 2); if (sourml) { dpdlenchk(4, sourml>>28); dpdlenchk(5, sourml>>18); dpdlenchk(6, sourml>>8); sourlo=DFWORD(df, 3); dpdlendun(7, ((sourml)<<2) | (sourlo>>30)); } /* [cannot drop through] */ sourlo=DFWORD(df, 3); if (sourlo&0xfff00000) { /* in one of first two */ dpdlenchk(7, sourlo>>30); /* very rare */ dpdlendun(8, sourlo>>20); } /* [cannot drop through] */ dpdlenchk(9, sourlo>>10); dpdlendun(10, sourlo); /* [cannot drop through] */ #endif } /* decFloatDigits */ /* ------------------------------------------------------------------ */ /* decFloatDivide -- divide a decFloat by another */ /* */ /* result gets the result of dividing dfl by dfr: */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* set is the context */ /* returns result */ /* */ /* ------------------------------------------------------------------ */ /* This is just a wrapper. */ decFloat * decFloatDivide(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { return decDivide(result, dfl, dfr, set, DIVIDE); } /* decFloatDivide */ /* ------------------------------------------------------------------ */ /* decFloatDivideInteger -- integer divide a decFloat by another */ /* */ /* result gets the result of dividing dfl by dfr: */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* set is the context */ /* returns result */ /* */ /* ------------------------------------------------------------------ */ decFloat * decFloatDivideInteger(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { return decDivide(result, dfl, dfr, set, DIVIDEINT); } /* decFloatDivideInteger */ /* ------------------------------------------------------------------ */ /* decFloatFMA -- multiply and add three decFloats, fused */ /* */ /* result gets the result of (dfl*dfr)+dff with a single rounding */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* dff is the final decFloat (fhs) */ /* set is the context */ /* returns result */ /* */ /* ------------------------------------------------------------------ */ decFloat * decFloatFMA(decFloat *result, const decFloat *dfl, const decFloat *dfr, const decFloat *dff, decContext *set) { /* The accumulator has the bytes needed for FiniteMultiply, plus */ /* one byte to the left in case of carry, plus DECPMAX+2 to the */ /* right for the final addition (up to full fhs + round & sticky) */ #define FMALEN (ROUNDUP4(1+ (DECPMAX9*18+1) +DECPMAX+2)) uByte acc[FMALEN]; /* for multiplied coefficient in BCD */ /* .. and for final result */ bcdnum mul; /* for multiplication result */ bcdnum fin; /* for final operand, expanded */ uByte coe[ROUNDUP4(DECPMAX)]; /* dff coefficient in BCD */ bcdnum *hi, *lo; /* bcdnum with higher/lower exponent */ uInt diffsign; /* non-zero if signs differ */ uInt hipad; /* pad digit for hi if needed */ Int padding; /* excess exponent */ uInt carry; /* +1 for ten's complement and during add */ uByte *ub, *uh, *ul; /* work */ uInt uiwork; /* for macros */ /* handle all the special values [any special operand leads to a */ /* special result] */ if (DFISSPECIAL(dfl) || DFISSPECIAL(dfr) || DFISSPECIAL(dff)) { decFloat proxy; /* multiplication result proxy */ /* NaNs are handled as usual, giving priority to sNaNs */ if (DFISSNAN(dfl) || DFISSNAN(dfr)) return decNaNs(result, dfl, dfr, set); if (DFISSNAN(dff)) return decNaNs(result, dff, NULL, set); if (DFISNAN(dfl) || DFISNAN(dfr)) return decNaNs(result, dfl, dfr, set); if (DFISNAN(dff)) return decNaNs(result, dff, NULL, set); /* One or more of the three is infinite */ /* infinity times zero is bad */ decFloatZero(&proxy); if (DFISINF(dfl)) { if (DFISZERO(dfr)) return decInvalid(result, set); decInfinity(&proxy, &proxy); } else if (DFISINF(dfr)) { if (DFISZERO(dfl)) return decInvalid(result, set); decInfinity(&proxy, &proxy); } /* compute sign of multiplication and place in proxy */ DFWORD(&proxy, 0)|=(DFWORD(dfl, 0)^DFWORD(dfr, 0))&DECFLOAT_Sign; if (!DFISINF(dff)) return decFloatCopy(result, &proxy); /* dff is Infinite */ if (!DFISINF(&proxy)) return decInfinity(result, dff); /* both sides of addition are infinite; different sign is bad */ if ((DFWORD(dff, 0)&DECFLOAT_Sign)!=(DFWORD(&proxy, 0)&DECFLOAT_Sign)) return decInvalid(result, set); return decFloatCopy(result, &proxy); } /* Here when all operands are finite */ /* First multiply dfl*dfr */ decFiniteMultiply(&mul, acc+1, dfl, dfr); /* The multiply is complete, exact and unbounded, and described in */ /* mul with the coefficient held in acc[1...] */ /* now add in dff; the algorithm is essentially the same as */ /* decFloatAdd, but the code is different because the code there */ /* is highly optimized for adding two numbers of the same size */ fin.exponent=GETEXPUN(dff); /* get dff exponent and sign */ fin.sign=DFWORD(dff, 0)&DECFLOAT_Sign; diffsign=mul.sign^fin.sign; /* note if signs differ */ fin.msd=coe; fin.lsd=coe+DECPMAX-1; GETCOEFF(dff, coe); /* extract the coefficient */ /* now set hi and lo so that hi points to whichever of mul and fin */ /* has the higher exponent and lo points to the other [don't care, */ /* if the same]. One coefficient will be in acc, the other in coe. */ if (mul.exponent>=fin.exponent) { hi=&mul; lo=&fin; } else { hi=&fin; lo=&mul; } /* remove leading zeros on both operands; this will save time later */ /* and make testing for zero trivial (tests are safe because acc */ /* and coe are rounded up to uInts) */ for (; UBTOUI(hi->msd)==0 && hi->msd+3lsd;) hi->msd+=4; for (; *hi->msd==0 && hi->msdlsd;) hi->msd++; for (; UBTOUI(lo->msd)==0 && lo->msd+3lsd;) lo->msd+=4; for (; *lo->msd==0 && lo->msdlsd;) lo->msd++; /* if hi is zero then result will be lo (which has the smaller */ /* exponent), which also may need to be tested for zero for the */ /* weird IEEE 754 sign rules */ if (*hi->msd==0) { /* hi is zero */ /* "When the sum of two operands with opposite signs is */ /* exactly zero, the sign of that sum shall be '+' in all */ /* rounding modes except round toward -Infinity, in which */ /* mode that sign shall be '-'." */ if (diffsign) { if (*lo->msd==0) { /* lo is zero */ lo->sign=0; if (set->round==DEC_ROUND_FLOOR) lo->sign=DECFLOAT_Sign; } /* diffsign && lo=0 */ } /* diffsign */ return decFinalize(result, lo, set); /* may need clamping */ } /* numfl is zero */ /* [here, both are minimal length and hi is non-zero] */ /* (if lo is zero then padding with zeros may be needed, below) */ /* if signs differ, take the ten's complement of hi (zeros to the */ /* right do not matter because the complement of zero is zero); the */ /* +1 is done later, as part of the addition, inserted at the */ /* correct digit */ hipad=0; carry=0; if (diffsign) { hipad=9; carry=1; /* exactly the correct number of digits must be inverted */ for (uh=hi->msd; uhlsd-3; uh+=4) UBFROMUI(uh, 0x09090909-UBTOUI(uh)); for (; uh<=hi->lsd; uh++) *uh=(uByte)(0x09-*uh); } /* ready to add; note that hi has no leading zeros so gap */ /* calculation does not have to be as pessimistic as in decFloatAdd */ /* (this is much more like the arbitrary-precision algorithm in */ /* Rexx and decNumber) */ /* padding is the number of zeros that would need to be added to hi */ /* for its lsd to be aligned with the lsd of lo */ padding=hi->exponent-lo->exponent; /* printf("FMA pad %ld\n", (LI)padding); */ /* the result of the addition will be built into the accumulator, */ /* starting from the far right; this could be either hi or lo, and */ /* will be aligned */ ub=acc+FMALEN-1; /* where lsd of result will go */ ul=lo->lsd; /* lsd of rhs */ if (padding!=0) { /* unaligned */ /* if the msd of lo is more than DECPMAX+2 digits to the right of */ /* the original msd of hi then it can be reduced to a single */ /* digit at the right place, as it stays clear of hi digits */ /* [it must be DECPMAX+2 because during a subtraction the msd */ /* could become 0 after a borrow from 1.000 to 0.9999...] */ Int hilen=(Int)(hi->lsd-hi->msd+1); /* length of hi */ Int lolen=(Int)(lo->lsd-lo->msd+1); /* and of lo */ if (hilen+padding-lolen > DECPMAX+2) { /* can reduce lo to single */ /* make sure it is virtually at least DECPMAX from hi->msd, at */ /* least to right of hi->lsd (in case of destructive subtract), */ /* and separated by at least two digits from either of those */ /* (the tricky DOUBLE case is when hi is a 1 that will become a */ /* 0.9999... by subtraction: */ /* hi: 1 E+16 */ /* lo: .................1000000000000000 E-16 */ /* which for the addition pads to: */ /* hi: 1000000000000000000 E-16 */ /* lo: .................1000000000000000 E-16 */ Int newexp=MINI(hi->exponent, hi->exponent+hilen-DECPMAX)-3; /* printf("FMA reduce: %ld\n", (LI)reduce); */ lo->lsd=lo->msd; /* to single digit [maybe 0] */ lo->exponent=newexp; /* new lowest exponent */ padding=hi->exponent-lo->exponent; /* recalculate */ ul=lo->lsd; /* .. and repoint */ } /* padding is still > 0, but will fit in acc (less leading carry slot) */ #if DECCHECK if (padding<=0) printf("FMA low padding: %ld\n", (LI)padding); if (hilen+padding+1>FMALEN) printf("FMA excess hilen+padding: %ld+%ld \n", (LI)hilen, (LI)padding); /* printf("FMA padding: %ld\n", (LI)padding); */ #endif /* padding digits can now be set in the result; one or more of */ /* these will come from lo; others will be zeros in the gap */ for (; ul-3>=lo->msd && padding>3; padding-=4, ul-=4, ub-=4) { UBFROMUI(ub-3, UBTOUI(ul-3)); /* [cannot overlap] */ } for (; ul>=lo->msd && padding>0; padding--, ul--, ub--) *ub=*ul; for (;padding>0; padding--, ub--) *ub=0; /* mind the gap */ } /* addition now complete to the right of the rightmost digit of hi */ uh=hi->lsd; /* dow do the add from hi->lsd to the left */ /* [bytewise, because either operand can run out at any time] */ /* carry was set up depending on ten's complement above */ /* first assume both operands have some digits */ for (;; ub--) { if (uhmsd || ulmsd) break; *ub=(uByte)(carry+(*uh--)+(*ul--)); carry=0; if (*ub<10) continue; *ub-=10; carry=1; } /* both loop */ if (ulmsd) { /* to left of lo */ for (;; ub--) { if (uhmsd) break; *ub=(uByte)(carry+(*uh--)); /* [+0] */ carry=0; if (*ub<10) continue; *ub-=10; carry=1; } /* hi loop */ } else { /* to left of hi */ for (;; ub--) { if (ulmsd) break; *ub=(uByte)(carry+hipad+(*ul--)); carry=0; if (*ub<10) continue; *ub-=10; carry=1; } /* lo loop */ } /* addition complete -- now handle carry, borrow, etc. */ /* use lo to set up the num (its exponent is already correct, and */ /* sign usually is) */ lo->msd=ub+1; lo->lsd=acc+FMALEN-1; /* decShowNum(lo, "lo"); */ if (!diffsign) { /* same-sign addition */ if (carry) { /* carry out */ *ub=1; /* place the 1 .. */ lo->msd--; /* .. and update */ } } /* same sign */ else { /* signs differed (subtraction) */ if (!carry) { /* no carry out means hisign=hi->sign; /* sign is lhs sign */ for (ul=lo->msd; ullsd-3; ul+=4) UBFROMUI(ul, 0x09090909-UBTOUI(ul)); for (; ul<=lo->lsd; ul++) *ul=(uByte)(0x09-*ul); /* [leaves ul at lsd+1] */ /* complete the ten's complement by adding 1 [cannot overrun] */ for (ul--; *ul==9; ul--) *ul=0; *ul+=1; } /* borrowed */ else { /* carry out means hi>=lo */ /* sign to use is lo->sign */ /* all done except for the special IEEE 754 exact-zero-result */ /* rule (see above); while testing for zero, strip leading */ /* zeros (which will save decFinalize doing it) */ for (; UBTOUI(lo->msd)==0 && lo->msd+3lsd;) lo->msd+=4; for (; *lo->msd==0 && lo->msdlsd;) lo->msd++; if (*lo->msd==0) { /* must be true zero (and diffsign) */ lo->sign=0; /* assume + */ if (set->round==DEC_ROUND_FLOOR) lo->sign=DECFLOAT_Sign; } /* [else was not zero, might still have leading zeros] */ } /* subtraction gave positive result */ } /* diffsign */ #if DECCHECK /* assert no left underrun */ if (lo->msdmsd)); } #endif return decFinalize(result, lo, set); /* round, check, and lay out */ } /* decFloatFMA */ /* ------------------------------------------------------------------ */ /* decFloatFromInt -- initialise a decFloat from an Int */ /* */ /* result gets the converted Int */ /* n is the Int to convert */ /* returns result */ /* */ /* The result is Exact; no errors or exceptions are possible. */ /* ------------------------------------------------------------------ */ decFloat * decFloatFromInt32(decFloat *result, Int n) { uInt u=(uInt)n; /* copy as bits */ uInt encode; /* work */ DFWORD(result, 0)=ZEROWORD; /* always */ #if QUAD DFWORD(result, 1)=0; DFWORD(result, 2)=0; #endif if (n<0) { /* handle -n with care */ /* [This can be done without the test, but is then slightly slower] */ u=(~u)+1; DFWORD(result, 0)|=DECFLOAT_Sign; } /* Since the maximum value of u now is 2**31, only the low word of */ /* result is affected */ encode=BIN2DPD[u%1000]; u/=1000; encode|=BIN2DPD[u%1000]<<10; u/=1000; encode|=BIN2DPD[u%1000]<<20; u/=1000; /* now 0, 1, or 2 */ encode|=u<<30; DFWORD(result, DECWORDS-1)=encode; return result; } /* decFloatFromInt32 */ /* ------------------------------------------------------------------ */ /* decFloatFromUInt -- initialise a decFloat from a uInt */ /* */ /* result gets the converted uInt */ /* n is the uInt to convert */ /* returns result */ /* */ /* The result is Exact; no errors or exceptions are possible. */ /* ------------------------------------------------------------------ */ decFloat * decFloatFromUInt32(decFloat *result, uInt u) { uInt encode; /* work */ DFWORD(result, 0)=ZEROWORD; /* always */ #if QUAD DFWORD(result, 1)=0; DFWORD(result, 2)=0; #endif encode=BIN2DPD[u%1000]; u/=1000; encode|=BIN2DPD[u%1000]<<10; u/=1000; encode|=BIN2DPD[u%1000]<<20; u/=1000; /* now 0 -> 4 */ encode|=u<<30; DFWORD(result, DECWORDS-1)=encode; DFWORD(result, DECWORDS-2)|=u>>2; /* rarely non-zero */ return result; } /* decFloatFromUInt32 */ /* ------------------------------------------------------------------ */ /* decFloatInvert -- logical digitwise INVERT of a decFloat */ /* */ /* result gets the result of INVERTing df */ /* df is the decFloat to invert */ /* set is the context */ /* returns result, which will be canonical with sign=0 */ /* */ /* The operand must be positive, finite with exponent q=0, and */ /* comprise just zeros and ones; if not, Invalid operation results. */ /* ------------------------------------------------------------------ */ decFloat * decFloatInvert(decFloat *result, const decFloat *df, decContext *set) { uInt sourhi=DFWORD(df, 0); /* top word of dfs */ if (!DFISUINT01(df) || !DFISCC01(df)) return decInvalid(result, set); /* the operand is a finite integer (q=0) */ #if DOUBLE DFWORD(result, 0)=ZEROWORD|((~sourhi)&0x04009124); DFWORD(result, 1)=(~DFWORD(df, 1)) &0x49124491; #elif QUAD DFWORD(result, 0)=ZEROWORD|((~sourhi)&0x04000912); DFWORD(result, 1)=(~DFWORD(df, 1)) &0x44912449; DFWORD(result, 2)=(~DFWORD(df, 2)) &0x12449124; DFWORD(result, 3)=(~DFWORD(df, 3)) &0x49124491; #endif return result; } /* decFloatInvert */ /* ------------------------------------------------------------------ */ /* decFloatIs -- decFloat tests (IsSigned, etc.) */ /* */ /* df is the decFloat to test */ /* returns 0 or 1 in a uInt */ /* */ /* Many of these could be macros, but having them as real functions */ /* is a little cleaner (and they can be referred to here by the */ /* generic names) */ /* ------------------------------------------------------------------ */ uInt decFloatIsCanonical(const decFloat *df) { if (DFISSPECIAL(df)) { if (DFISINF(df)) { if (DFWORD(df, 0)&ECONMASK) return 0; /* exponent continuation */ if (!DFISCCZERO(df)) return 0; /* coefficient continuation */ return 1; } /* is a NaN */ if (DFWORD(df, 0)&ECONNANMASK) return 0; /* exponent continuation */ if (DFISCCZERO(df)) return 1; /* coefficient continuation */ /* drop through to check payload */ } { /* declare block */ #if DOUBLE uInt sourhi=DFWORD(df, 0); uInt sourlo=DFWORD(df, 1); if (CANONDPDOFF(sourhi, 8) && CANONDPDTWO(sourhi, sourlo, 30) && CANONDPDOFF(sourlo, 20) && CANONDPDOFF(sourlo, 10) && CANONDPDOFF(sourlo, 0)) return 1; #elif QUAD uInt sourhi=DFWORD(df, 0); uInt sourmh=DFWORD(df, 1); uInt sourml=DFWORD(df, 2); uInt sourlo=DFWORD(df, 3); if (CANONDPDOFF(sourhi, 4) && CANONDPDTWO(sourhi, sourmh, 26) && CANONDPDOFF(sourmh, 16) && CANONDPDOFF(sourmh, 6) && CANONDPDTWO(sourmh, sourml, 28) && CANONDPDOFF(sourml, 18) && CANONDPDOFF(sourml, 8) && CANONDPDTWO(sourml, sourlo, 30) && CANONDPDOFF(sourlo, 20) && CANONDPDOFF(sourlo, 10) && CANONDPDOFF(sourlo, 0)) return 1; #endif } /* block */ return 0; /* a declet is non-canonical */ } uInt decFloatIsFinite(const decFloat *df) { return !DFISSPECIAL(df); } uInt decFloatIsInfinite(const decFloat *df) { return DFISINF(df); } uInt decFloatIsInteger(const decFloat *df) { return DFISINT(df); } uInt decFloatIsNaN(const decFloat *df) { return DFISNAN(df); } uInt decFloatIsNormal(const decFloat *df) { Int exp; /* exponent */ if (DFISSPECIAL(df)) return 0; if (DFISZERO(df)) return 0; /* is finite and non-zero */ exp=GETEXPUN(df) /* get unbiased exponent .. */ +decFloatDigits(df)-1; /* .. and make adjusted exponent */ return (exp>=DECEMIN); /* < DECEMIN is subnormal */ } uInt decFloatIsSignaling(const decFloat *df) { return DFISSNAN(df); } uInt decFloatIsSignalling(const decFloat *df) { return DFISSNAN(df); } uInt decFloatIsSigned(const decFloat *df) { return DFISSIGNED(df); } uInt decFloatIsSubnormal(const decFloat *df) { if (DFISSPECIAL(df)) return 0; /* is finite */ if (decFloatIsNormal(df)) return 0; /* it is Use |A| */ /* A=0 -> -Infinity (Division by zero) */ /* A=Infinite -> +Infinity (Exact) */ /* A=1 exactly -> 0 (Exact) */ /* NaNs are propagated as usual */ /* ------------------------------------------------------------------ */ decFloat * decFloatLogB(decFloat *result, const decFloat *df, decContext *set) { Int ae; /* adjusted exponent */ if (DFISNAN(df)) return decNaNs(result, df, NULL, set); if (DFISINF(df)) { DFWORD(result, 0)=0; /* need +ve */ return decInfinity(result, result); /* canonical +Infinity */ } if (DFISZERO(df)) { set->status|=DEC_Division_by_zero; /* as per 754 */ DFWORD(result, 0)=DECFLOAT_Sign; /* make negative */ return decInfinity(result, result); /* canonical -Infinity */ } ae=GETEXPUN(df) /* get unbiased exponent .. */ +decFloatDigits(df)-1; /* .. and make adjusted exponent */ /* ae has limited range (3 digits for DOUBLE and 4 for QUAD), so */ /* it is worth using a special case of decFloatFromInt32 */ DFWORD(result, 0)=ZEROWORD; /* always */ if (ae<0) { DFWORD(result, 0)|=DECFLOAT_Sign; /* -0 so far */ ae=-ae; } #if DOUBLE DFWORD(result, 1)=BIN2DPD[ae]; /* a single declet */ #elif QUAD DFWORD(result, 1)=0; DFWORD(result, 2)=0; DFWORD(result, 3)=(ae/1000)<<10; /* is <10, so need no DPD encode */ DFWORD(result, 3)|=BIN2DPD[ae%1000]; #endif return result; } /* decFloatLogB */ /* ------------------------------------------------------------------ */ /* decFloatMax -- return maxnum of two operands */ /* */ /* result gets the chosen decFloat */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* set is the context */ /* returns result */ /* */ /* If just one operand is a quiet NaN it is ignored. */ /* ------------------------------------------------------------------ */ decFloat * decFloatMax(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { Int comp; if (DFISNAN(dfl)) { /* sNaN or both NaNs leads to normal NaN processing */ if (DFISNAN(dfr) || DFISSNAN(dfl)) return decNaNs(result, dfl, dfr, set); return decCanonical(result, dfr); /* RHS is numeric */ } if (DFISNAN(dfr)) { /* sNaN leads to normal NaN processing (both NaN handled above) */ if (DFISSNAN(dfr)) return decNaNs(result, dfl, dfr, set); return decCanonical(result, dfl); /* LHS is numeric */ } /* Both operands are numeric; numeric comparison needed -- use */ /* total order for a well-defined choice (and +0 > -0) */ comp=decNumCompare(dfl, dfr, 1); if (comp>=0) return decCanonical(result, dfl); return decCanonical(result, dfr); } /* decFloatMax */ /* ------------------------------------------------------------------ */ /* decFloatMaxMag -- return maxnummag of two operands */ /* */ /* result gets the chosen decFloat */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* set is the context */ /* returns result */ /* */ /* Returns according to the magnitude comparisons if both numeric and */ /* unequal, otherwise returns maxnum */ /* ------------------------------------------------------------------ */ decFloat * decFloatMaxMag(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { Int comp; decFloat absl, absr; if (DFISNAN(dfl) || DFISNAN(dfr)) return decFloatMax(result, dfl, dfr, set); decFloatCopyAbs(&absl, dfl); decFloatCopyAbs(&absr, dfr); comp=decNumCompare(&absl, &absr, 0); if (comp>0) return decCanonical(result, dfl); if (comp<0) return decCanonical(result, dfr); return decFloatMax(result, dfl, dfr, set); } /* decFloatMaxMag */ /* ------------------------------------------------------------------ */ /* decFloatMin -- return minnum of two operands */ /* */ /* result gets the chosen decFloat */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* set is the context */ /* returns result */ /* */ /* If just one operand is a quiet NaN it is ignored. */ /* ------------------------------------------------------------------ */ decFloat * decFloatMin(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { Int comp; if (DFISNAN(dfl)) { /* sNaN or both NaNs leads to normal NaN processing */ if (DFISNAN(dfr) || DFISSNAN(dfl)) return decNaNs(result, dfl, dfr, set); return decCanonical(result, dfr); /* RHS is numeric */ } if (DFISNAN(dfr)) { /* sNaN leads to normal NaN processing (both NaN handled above) */ if (DFISSNAN(dfr)) return decNaNs(result, dfl, dfr, set); return decCanonical(result, dfl); /* LHS is numeric */ } /* Both operands are numeric; numeric comparison needed -- use */ /* total order for a well-defined choice (and +0 > -0) */ comp=decNumCompare(dfl, dfr, 1); if (comp<=0) return decCanonical(result, dfl); return decCanonical(result, dfr); } /* decFloatMin */ /* ------------------------------------------------------------------ */ /* decFloatMinMag -- return minnummag of two operands */ /* */ /* result gets the chosen decFloat */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* set is the context */ /* returns result */ /* */ /* Returns according to the magnitude comparisons if both numeric and */ /* unequal, otherwise returns minnum */ /* ------------------------------------------------------------------ */ decFloat * decFloatMinMag(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { Int comp; decFloat absl, absr; if (DFISNAN(dfl) || DFISNAN(dfr)) return decFloatMin(result, dfl, dfr, set); decFloatCopyAbs(&absl, dfl); decFloatCopyAbs(&absr, dfr); comp=decNumCompare(&absl, &absr, 0); if (comp<0) return decCanonical(result, dfl); if (comp>0) return decCanonical(result, dfr); return decFloatMin(result, dfl, dfr, set); } /* decFloatMinMag */ /* ------------------------------------------------------------------ */ /* decFloatMinus -- negate value, heeding NaNs, etc. */ /* */ /* result gets the canonicalized 0-df */ /* df is the decFloat to minus */ /* set is the context */ /* returns result */ /* */ /* This has the same effect as 0-df where the exponent of the zero is */ /* the same as that of df (if df is finite). */ /* The effect is also the same as decFloatCopyNegate except that NaNs */ /* are handled normally (the sign of a NaN is not affected, and an */ /* sNaN will signal), the result is canonical, and zero gets sign 0. */ /* ------------------------------------------------------------------ */ decFloat * decFloatMinus(decFloat *result, const decFloat *df, decContext *set) { if (DFISNAN(df)) return decNaNs(result, df, NULL, set); decCanonical(result, df); /* copy and check */ if (DFISZERO(df)) DFBYTE(result, 0)&=~0x80; /* turn off sign bit */ else DFBYTE(result, 0)^=0x80; /* flip sign bit */ return result; } /* decFloatMinus */ /* ------------------------------------------------------------------ */ /* decFloatMultiply -- multiply two decFloats */ /* */ /* result gets the result of multiplying dfl and dfr: */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* set is the context */ /* returns result */ /* */ /* ------------------------------------------------------------------ */ decFloat * decFloatMultiply(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { bcdnum num; /* for final conversion */ uByte bcdacc[DECPMAX9*18+1]; /* for coefficent in BCD */ if (DFISSPECIAL(dfl) || DFISSPECIAL(dfr)) { /* either is special? */ /* NaNs are handled as usual */ if (DFISNAN(dfl) || DFISNAN(dfr)) return decNaNs(result, dfl, dfr, set); /* infinity times zero is bad */ if (DFISINF(dfl) && DFISZERO(dfr)) return decInvalid(result, set); if (DFISINF(dfr) && DFISZERO(dfl)) return decInvalid(result, set); /* both infinite; return canonical infinity with computed sign */ DFWORD(result, 0)=DFWORD(dfl, 0)^DFWORD(dfr, 0); /* compute sign */ return decInfinity(result, result); } /* Here when both operands are finite */ decFiniteMultiply(&num, bcdacc, dfl, dfr); return decFinalize(result, &num, set); /* round, check, and lay out */ } /* decFloatMultiply */ /* ------------------------------------------------------------------ */ /* decFloatNextMinus -- next towards -Infinity */ /* */ /* result gets the next lesser decFloat */ /* dfl is the decFloat to start with */ /* set is the context */ /* returns result */ /* */ /* This is 754 nextdown; Invalid is the only status possible (from */ /* an sNaN). */ /* ------------------------------------------------------------------ */ decFloat * decFloatNextMinus(decFloat *result, const decFloat *dfl, decContext *set) { decFloat delta; /* tiny increment */ uInt savestat; /* saves status */ enum rounding saveround; /* .. and mode */ /* +Infinity is the special case */ if (DFISINF(dfl) && !DFISSIGNED(dfl)) { DFSETNMAX(result); return result; /* [no status to set] */ } /* other cases are effected by sutracting a tiny delta -- this */ /* should be done in a wider format as the delta is unrepresentable */ /* here (but can be done with normal add if the sign of zero is */ /* treated carefully, because no Inexactitude is interesting); */ /* rounding to -Infinity then pushes the result to next below */ decFloatZero(&delta); /* set up tiny delta */ DFWORD(&delta, DECWORDS-1)=1; /* coefficient=1 */ DFWORD(&delta, 0)=DECFLOAT_Sign; /* Sign=1 + biased exponent=0 */ /* set up for the directional round */ saveround=set->round; /* save mode */ set->round=DEC_ROUND_FLOOR; /* .. round towards -Infinity */ savestat=set->status; /* save status */ decFloatAdd(result, dfl, &delta, set); /* Add rules mess up the sign when going from +Ntiny to 0 */ if (DFISZERO(result)) DFWORD(result, 0)^=DECFLOAT_Sign; /* correct */ set->status&=DEC_Invalid_operation; /* preserve only sNaN status */ set->status|=savestat; /* restore pending flags */ set->round=saveround; /* .. and mode */ return result; } /* decFloatNextMinus */ /* ------------------------------------------------------------------ */ /* decFloatNextPlus -- next towards +Infinity */ /* */ /* result gets the next larger decFloat */ /* dfl is the decFloat to start with */ /* set is the context */ /* returns result */ /* */ /* This is 754 nextup; Invalid is the only status possible (from */ /* an sNaN). */ /* ------------------------------------------------------------------ */ decFloat * decFloatNextPlus(decFloat *result, const decFloat *dfl, decContext *set) { uInt savestat; /* saves status */ enum rounding saveround; /* .. and mode */ decFloat delta; /* tiny increment */ /* -Infinity is the special case */ if (DFISINF(dfl) && DFISSIGNED(dfl)) { DFSETNMAX(result); DFWORD(result, 0)|=DECFLOAT_Sign; /* make negative */ return result; /* [no status to set] */ } /* other cases are effected by sutracting a tiny delta -- this */ /* should be done in a wider format as the delta is unrepresentable */ /* here (but can be done with normal add if the sign of zero is */ /* treated carefully, because no Inexactitude is interesting); */ /* rounding to +Infinity then pushes the result to next above */ decFloatZero(&delta); /* set up tiny delta */ DFWORD(&delta, DECWORDS-1)=1; /* coefficient=1 */ DFWORD(&delta, 0)=0; /* Sign=0 + biased exponent=0 */ /* set up for the directional round */ saveround=set->round; /* save mode */ set->round=DEC_ROUND_CEILING; /* .. round towards +Infinity */ savestat=set->status; /* save status */ decFloatAdd(result, dfl, &delta, set); /* Add rules mess up the sign when going from -Ntiny to -0 */ if (DFISZERO(result)) DFWORD(result, 0)^=DECFLOAT_Sign; /* correct */ set->status&=DEC_Invalid_operation; /* preserve only sNaN status */ set->status|=savestat; /* restore pending flags */ set->round=saveround; /* .. and mode */ return result; } /* decFloatNextPlus */ /* ------------------------------------------------------------------ */ /* decFloatNextToward -- next towards a decFloat */ /* */ /* result gets the next decFloat */ /* dfl is the decFloat to start with */ /* dfr is the decFloat to move toward */ /* set is the context */ /* returns result */ /* */ /* This is 754-1985 nextafter, as modified during revision (dropped */ /* from 754-2008); status may be set unless the result is a normal */ /* number. */ /* ------------------------------------------------------------------ */ decFloat * decFloatNextToward(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { decFloat delta; /* tiny increment or decrement */ decFloat pointone; /* 1e-1 */ uInt savestat; /* saves status */ enum rounding saveround; /* .. and mode */ uInt deltatop; /* top word for delta */ Int comp; /* work */ if (DFISNAN(dfl) || DFISNAN(dfr)) return decNaNs(result, dfl, dfr, set); /* Both are numeric, so Invalid no longer a possibility */ comp=decNumCompare(dfl, dfr, 0); if (comp==0) return decFloatCopySign(result, dfl, dfr); /* equal */ /* unequal; do NextPlus or NextMinus but with different status rules */ if (comp<0) { /* lhsround; /* save mode */ set->round=DEC_ROUND_CEILING; /* .. round towards +Infinity */ deltatop=0; /* positive delta */ } else { /* lhs>rhs, do NextMinus, see above for commentary */ if (DFISINF(dfl) && !DFISSIGNED(dfl)) { /* +Infinity special case */ DFSETNMAX(result); return result; } saveround=set->round; /* save mode */ set->round=DEC_ROUND_FLOOR; /* .. round towards -Infinity */ deltatop=DECFLOAT_Sign; /* negative delta */ } savestat=set->status; /* save status */ /* Here, Inexact is needed where appropriate (and hence Underflow, */ /* etc.). Therefore the tiny delta which is otherwise */ /* unrepresentable (see NextPlus and NextMinus) is constructed */ /* using the multiplication of FMA. */ decFloatZero(&delta); /* set up tiny delta */ DFWORD(&delta, DECWORDS-1)=1; /* coefficient=1 */ DFWORD(&delta, 0)=deltatop; /* Sign + biased exponent=0 */ decFloatFromString(&pointone, "1E-1", set); /* set up multiplier */ decFloatFMA(result, &delta, &pointone, dfl, set); /* [Delta is truly tiny, so no need to correct sign of zero] */ /* use new status unless the result is normal */ if (decFloatIsNormal(result)) set->status=savestat; /* else goes forward */ set->round=saveround; /* restore mode */ return result; } /* decFloatNextToward */ /* ------------------------------------------------------------------ */ /* decFloatOr -- logical digitwise OR of two decFloats */ /* */ /* result gets the result of ORing dfl and dfr */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* set is the context */ /* returns result, which will be canonical with sign=0 */ /* */ /* The operands must be positive, finite with exponent q=0, and */ /* comprise just zeros and ones; if not, Invalid operation results. */ /* ------------------------------------------------------------------ */ decFloat * decFloatOr(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { if (!DFISUINT01(dfl) || !DFISUINT01(dfr) || !DFISCC01(dfl) || !DFISCC01(dfr)) return decInvalid(result, set); /* the operands are positive finite integers (q=0) with just 0s and 1s */ #if DOUBLE DFWORD(result, 0)=ZEROWORD |((DFWORD(dfl, 0) | DFWORD(dfr, 0))&0x04009124); DFWORD(result, 1)=(DFWORD(dfl, 1) | DFWORD(dfr, 1))&0x49124491; #elif QUAD DFWORD(result, 0)=ZEROWORD |((DFWORD(dfl, 0) | DFWORD(dfr, 0))&0x04000912); DFWORD(result, 1)=(DFWORD(dfl, 1) | DFWORD(dfr, 1))&0x44912449; DFWORD(result, 2)=(DFWORD(dfl, 2) | DFWORD(dfr, 2))&0x12449124; DFWORD(result, 3)=(DFWORD(dfl, 3) | DFWORD(dfr, 3))&0x49124491; #endif return result; } /* decFloatOr */ /* ------------------------------------------------------------------ */ /* decFloatPlus -- add value to 0, heeding NaNs, etc. */ /* */ /* result gets the canonicalized 0+df */ /* df is the decFloat to plus */ /* set is the context */ /* returns result */ /* */ /* This has the same effect as 0+df where the exponent of the zero is */ /* the same as that of df (if df is finite). */ /* The effect is also the same as decFloatCopy except that NaNs */ /* are handled normally (the sign of a NaN is not affected, and an */ /* sNaN will signal), the result is canonical, and zero gets sign 0. */ /* ------------------------------------------------------------------ */ decFloat * decFloatPlus(decFloat *result, const decFloat *df, decContext *set) { if (DFISNAN(df)) return decNaNs(result, df, NULL, set); decCanonical(result, df); /* copy and check */ if (DFISZERO(df)) DFBYTE(result, 0)&=~0x80; /* turn off sign bit */ return result; } /* decFloatPlus */ /* ------------------------------------------------------------------ */ /* decFloatQuantize -- quantize a decFloat */ /* */ /* result gets the result of quantizing dfl to match dfr */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs), which sets the exponent */ /* set is the context */ /* returns result */ /* */ /* Unless there is an error or the result is infinite, the exponent */ /* of result is guaranteed to be the same as that of dfr. */ /* ------------------------------------------------------------------ */ decFloat * decFloatQuantize(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { Int explb, exprb; /* left and right biased exponents */ uByte *ulsd; /* local LSD pointer */ uByte *ub, *uc; /* work */ Int drop; /* .. */ uInt dpd; /* .. */ uInt encode; /* encoding accumulator */ uInt sourhil, sourhir; /* top words from source decFloats */ uInt uiwork; /* for macros */ #if QUAD uShort uswork; /* .. */ #endif /* the following buffer holds the coefficient for manipulation */ uByte buf[4+DECPMAX*3+2*QUAD]; /* + space for zeros to left or right */ #if DECTRACE bcdnum num; /* for trace displays */ #endif /* Start decoding the arguments */ sourhil=DFWORD(dfl, 0); /* LHS top word */ explb=DECCOMBEXP[sourhil>>26]; /* get exponent high bits (in place) */ sourhir=DFWORD(dfr, 0); /* RHS top word */ exprb=DECCOMBEXP[sourhir>>26]; if (EXPISSPECIAL(explb | exprb)) { /* either is special? */ /* NaNs are handled as usual */ if (DFISNAN(dfl) || DFISNAN(dfr)) return decNaNs(result, dfl, dfr, set); /* one infinity but not both is bad */ if (DFISINF(dfl)!=DFISINF(dfr)) return decInvalid(result, set); /* both infinite; return canonical infinity with sign of LHS */ return decInfinity(result, dfl); } /* Here when both arguments are finite */ /* complete extraction of the exponents [no need to unbias] */ explb+=GETECON(dfl); /* + continuation */ exprb+=GETECON(dfr); /* .. */ /* calculate the number of digits to drop from the coefficient */ drop=exprb-explb; /* 0 if nothing to do */ if (drop==0) return decCanonical(result, dfl); /* return canonical */ /* the coefficient is needed; lay it out into buf, offset so zeros */ /* can be added before or after as needed -- an extra heading is */ /* added so can safely pad Quad DECPMAX-1 zeros to the left by */ /* fours */ #define BUFOFF (buf+4+DECPMAX) GETCOEFF(dfl, BUFOFF); /* decode from decFloat */ /* [now the msd is at BUFOFF and the lsd is at BUFOFF+DECPMAX-1] */ #if DECTRACE num.msd=BUFOFF; num.lsd=BUFOFF+DECPMAX-1; num.exponent=explb-DECBIAS; num.sign=sourhil & DECFLOAT_Sign; decShowNum(&num, "dfl"); #endif if (drop>0) { /* [most common case] */ /* (this code is very similar to that in decFloatFinalize, but */ /* has many differences so is duplicated here -- so any changes */ /* may need to be made there, too) */ uByte *roundat; /* -> re-round digit */ uByte reround; /* reround value */ /* printf("Rounding; drop=%ld\n", (LI)drop); */ /* there is at least one zero needed to the left, in all but one */ /* exceptional (all-nines) case, so place four zeros now; this is */ /* needed almost always and makes rounding all-nines by fours safe */ UBFROMUI(BUFOFF-4, 0); /* Three cases here: */ /* 1. new LSD is in coefficient (almost always) */ /* 2. new LSD is digit to left of coefficient (so MSD is */ /* round-for-reround digit) */ /* 3. new LSD is to left of case 2 (whole coefficient is sticky) */ /* Note that leading zeros can safely be treated as useful digits */ /* [duplicate check-stickies code to save a test] */ /* [by-digit check for stickies as runs of zeros are rare] */ if (dropstatus|=DEC_Inexact; /* next decide whether to increment the coefficient */ if (set->round==DEC_ROUND_HALF_EVEN) { /* fastpath slowest case */ if (reround>5) bump=1; /* >0.5 goes up */ else if (reround==5) /* exactly 0.5000 .. */ bump=*ulsd & 0x01; /* .. up iff [new] lsd is odd */ } /* r-h-e */ else switch (set->round) { case DEC_ROUND_DOWN: { /* no change */ break;} /* r-d */ case DEC_ROUND_HALF_DOWN: { if (reround>5) bump=1; break;} /* r-h-d */ case DEC_ROUND_HALF_UP: { if (reround>=5) bump=1; break;} /* r-h-u */ case DEC_ROUND_UP: { if (reround>0) bump=1; break;} /* r-u */ case DEC_ROUND_CEILING: { /* same as _UP for positive numbers, and as _DOWN for negatives */ if (!(sourhil&DECFLOAT_Sign) && reround>0) bump=1; break;} /* r-c */ case DEC_ROUND_FLOOR: { /* same as _UP for negative numbers, and as _DOWN for positive */ /* [negative reround cannot occur on 0] */ if (sourhil&DECFLOAT_Sign && reround>0) bump=1; break;} /* r-f */ case DEC_ROUND_05UP: { if (reround>0) { /* anything out there is 'sticky' */ /* bump iff lsd=0 or 5; this cannot carry so it could be */ /* effected immediately with no bump -- but the code */ /* is clearer if this is done the same way as the others */ if (*ulsd==0 || *ulsd==5) bump=1; } break;} /* r-r */ default: { /* e.g., DEC_ROUND_MAX */ set->status|=DEC_Invalid_context; #if DECCHECK printf("Unknown rounding mode: %ld\n", (LI)set->round); #endif break;} } /* switch (not r-h-e) */ /* printf("ReRound: %ld bump: %ld\n", (LI)reround, (LI)bump); */ if (bump!=0) { /* need increment */ /* increment the coefficient; this could give 1000... (after */ /* the all nines case) */ ub=ulsd; for (; UBTOUI(ub-3)==0x09090909; ub-=4) UBFROMUI(ub-3, 0); /* now at most 3 digits left to non-9 (usually just the one) */ for (; *ub==9; ub--) *ub=0; *ub+=1; /* [the all-nines case will have carried one digit to the */ /* left of the original MSD -- just where it is needed] */ } /* bump needed */ } /* inexact rounding */ /* now clear zeros to the left so exactly DECPMAX digits will be */ /* available in the coefficent -- the first word to the left was */ /* cleared earlier for safe carry; now add any more needed */ if (drop>4) { UBFROMUI(BUFOFF-8, 0); /* must be at least 5 */ for (uc=BUFOFF-12; uc>ulsd-DECPMAX-3; uc-=4) UBFROMUI(uc, 0); } } /* need round (drop>0) */ else { /* drop<0; padding with -drop digits is needed */ /* This is the case where an error can occur if the padded */ /* coefficient will not fit; checking for this can be done in the */ /* same loop as padding for zeros if the no-hope and zero cases */ /* are checked first */ if (-drop>DECPMAX-1) { /* cannot fit unless 0 */ if (!ISCOEFFZERO(BUFOFF)) return decInvalid(result, set); /* a zero can have any exponent; just drop through and use it */ ulsd=BUFOFF+DECPMAX-1; } else { /* padding will fit (but may still be too long) */ /* final-word mask depends on endianess */ #if DECLITEND static const uInt dmask[]={0, 0x000000ff, 0x0000ffff, 0x00ffffff}; #else static const uInt dmask[]={0, 0xff000000, 0xffff0000, 0xffffff00}; #endif /* note that here zeros to the right are added by fours, so in */ /* the Quad case this could write 36 zeros if the coefficient has */ /* fewer than three significant digits (hence the +2*QUAD for buf) */ for (uc=BUFOFF+DECPMAX;; uc+=4) { UBFROMUI(uc, 0); if (UBTOUI(uc-DECPMAX)!=0) { /* could be bad */ /* if all four digits should be zero, definitely bad */ if (uc<=BUFOFF+DECPMAX+(-drop)-4) return decInvalid(result, set); /* must be a 1- to 3-digit sequence; check more carefully */ if ((UBTOUI(uc-DECPMAX)&dmask[(-drop)%4])!=0) return decInvalid(result, set); break; /* no need for loop end test */ } if (uc>=BUFOFF+DECPMAX+(-drop)-4) break; /* done */ } ulsd=BUFOFF+DECPMAX+(-drop)-1; } /* pad and check leading zeros */ } /* drop<0 */ #if DECTRACE num.msd=ulsd-DECPMAX+1; num.lsd=ulsd; num.exponent=explb-DECBIAS; num.sign=sourhil & DECFLOAT_Sign; decShowNum(&num, "res"); #endif /*------------------------------------------------------------------*/ /* At this point the result is DECPMAX digits, ending at ulsd, so */ /* fits the encoding exactly; there is no possibility of error */ /*------------------------------------------------------------------*/ encode=((exprb>>DECECONL)<<4) + *(ulsd-DECPMAX+1); /* make index */ encode=DECCOMBFROM[encode]; /* indexed by (0-2)*16+msd */ /* the exponent continuation can be extracted from the original RHS */ encode|=sourhir & ECONMASK; encode|=sourhil&DECFLOAT_Sign; /* add the sign from LHS */ /* finally encode the coefficient */ /* private macro to encode a declet; this version can be used */ /* because all coefficient digits exist */ #define getDPD3q(dpd, n) ub=ulsd-(3*(n))-2; \ dpd=BCD2DPD[(*ub*256)+(*(ub+1)*16)+*(ub+2)]; #if DOUBLE getDPD3q(dpd, 4); encode|=dpd<<8; getDPD3q(dpd, 3); encode|=dpd>>2; DFWORD(result, 0)=encode; encode=dpd<<30; getDPD3q(dpd, 2); encode|=dpd<<20; getDPD3q(dpd, 1); encode|=dpd<<10; getDPD3q(dpd, 0); encode|=dpd; DFWORD(result, 1)=encode; #elif QUAD getDPD3q(dpd,10); encode|=dpd<<4; getDPD3q(dpd, 9); encode|=dpd>>6; DFWORD(result, 0)=encode; encode=dpd<<26; getDPD3q(dpd, 8); encode|=dpd<<16; getDPD3q(dpd, 7); encode|=dpd<<6; getDPD3q(dpd, 6); encode|=dpd>>4; DFWORD(result, 1)=encode; encode=dpd<<28; getDPD3q(dpd, 5); encode|=dpd<<18; getDPD3q(dpd, 4); encode|=dpd<<8; getDPD3q(dpd, 3); encode|=dpd>>2; DFWORD(result, 2)=encode; encode=dpd<<30; getDPD3q(dpd, 2); encode|=dpd<<20; getDPD3q(dpd, 1); encode|=dpd<<10; getDPD3q(dpd, 0); encode|=dpd; DFWORD(result, 3)=encode; #endif return result; } /* decFloatQuantize */ /* ------------------------------------------------------------------ */ /* decFloatReduce -- reduce finite coefficient to minimum length */ /* */ /* result gets the reduced decFloat */ /* df is the source decFloat */ /* set is the context */ /* returns result, which will be canonical */ /* */ /* This removes all possible trailing zeros from the coefficient; */ /* some may remain when the number is very close to Nmax. */ /* Special values are unchanged and no status is set unless df=sNaN. */ /* Reduced zero has an exponent q=0. */ /* ------------------------------------------------------------------ */ decFloat * decFloatReduce(decFloat *result, const decFloat *df, decContext *set) { bcdnum num; /* work */ uByte buf[DECPMAX], *ub; /* coefficient and pointer */ if (df!=result) *result=*df; /* copy, if needed */ if (DFISNAN(df)) return decNaNs(result, df, NULL, set); /* sNaN */ /* zeros and infinites propagate too */ if (DFISINF(df)) return decInfinity(result, df); /* canonical */ if (DFISZERO(df)) { uInt sign=DFWORD(df, 0)&DECFLOAT_Sign; decFloatZero(result); DFWORD(result, 0)|=sign; return result; /* exponent dropped, sign OK */ } /* non-zero finite */ GETCOEFF(df, buf); ub=buf+DECPMAX-1; /* -> lsd */ if (*ub) return result; /* no trailing zeros */ for (ub--; *ub==0;) ub--; /* terminates because non-zero */ /* *ub is the first non-zero from the right */ num.sign=DFWORD(df, 0)&DECFLOAT_Sign; /* set up number... */ num.exponent=GETEXPUN(df)+(Int)(buf+DECPMAX-1-ub); /* adjusted exponent */ num.msd=buf; num.lsd=ub; return decFinalize(result, &num, set); } /* decFloatReduce */ /* ------------------------------------------------------------------ */ /* decFloatRemainder -- integer divide and return remainder */ /* */ /* result gets the remainder of dividing dfl by dfr: */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* set is the context */ /* returns result */ /* */ /* ------------------------------------------------------------------ */ decFloat * decFloatRemainder(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { return decDivide(result, dfl, dfr, set, REMAINDER); } /* decFloatRemainder */ /* ------------------------------------------------------------------ */ /* decFloatRemainderNear -- integer divide to nearest and remainder */ /* */ /* result gets the remainder of dividing dfl by dfr: */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* set is the context */ /* returns result */ /* */ /* This is the IEEE remainder, where the nearest integer is used. */ /* ------------------------------------------------------------------ */ decFloat * decFloatRemainderNear(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { return decDivide(result, dfl, dfr, set, REMNEAR); } /* decFloatRemainderNear */ /* ------------------------------------------------------------------ */ /* decFloatRotate -- rotate the coefficient of a decFloat left/right */ /* */ /* result gets the result of rotating dfl */ /* dfl is the source decFloat to rotate */ /* dfr is the count of digits to rotate, an integer (with q=0) */ /* set is the context */ /* returns result */ /* */ /* The digits of the coefficient of dfl are rotated to the left (if */ /* dfr is positive) or to the right (if dfr is negative) without */ /* adjusting the exponent or the sign of dfl. */ /* */ /* dfr must be in the range -DECPMAX through +DECPMAX. */ /* NaNs are propagated as usual. An infinite dfl is unaffected (but */ /* dfr must be valid). No status is set unless dfr is invalid or an */ /* operand is an sNaN. The result is canonical. */ /* ------------------------------------------------------------------ */ #define PHALF (ROUNDUP(DECPMAX/2, 4)) /* half length, rounded up */ decFloat * decFloatRotate(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { Int rotate; /* dfr as an Int */ uByte buf[DECPMAX+PHALF]; /* coefficient + half */ uInt digits, savestat; /* work */ bcdnum num; /* .. */ uByte *ub; /* .. */ if (DFISNAN(dfl)||DFISNAN(dfr)) return decNaNs(result, dfl, dfr, set); if (!DFISINT(dfr)) return decInvalid(result, set); digits=decFloatDigits(dfr); /* calculate digits */ if (digits>2) return decInvalid(result, set); /* definitely out of range */ rotate=DPD2BIN[DFWORD(dfr, DECWORDS-1)&0x3ff]; /* is in bottom declet */ if (rotate>DECPMAX) return decInvalid(result, set); /* too big */ /* [from here on no error or status change is possible] */ if (DFISINF(dfl)) return decInfinity(result, dfl); /* canonical */ /* handle no-rotate cases */ if (rotate==0 || rotate==DECPMAX) return decCanonical(result, dfl); /* a real rotate is needed: 0 < rotate < DECPMAX */ /* reduce the rotation to no more than half to reduce copying later */ /* (for QUAD in fact half + 2 digits) */ if (DFISSIGNED(dfr)) rotate=-rotate; if (abs(rotate)>PHALF) { if (rotate<0) rotate=DECPMAX+rotate; else rotate=rotate-DECPMAX; } /* now lay out the coefficient, leaving room to the right or the */ /* left depending on the direction of rotation */ ub=buf; if (rotate<0) ub+=PHALF; /* rotate right, so space to left */ GETCOEFF(dfl, ub); /* copy half the digits to left or right, and set num.msd */ if (rotate<0) { memcpy(buf, buf+DECPMAX, PHALF); num.msd=buf+PHALF+rotate; } else { memcpy(buf+DECPMAX, buf, PHALF); num.msd=buf+rotate; } /* fill in rest of num */ num.lsd=num.msd+DECPMAX-1; num.sign=DFWORD(dfl, 0)&DECFLOAT_Sign; num.exponent=GETEXPUN(dfl); savestat=set->status; /* record */ decFinalize(result, &num, set); set->status=savestat; /* restore */ return result; } /* decFloatRotate */ /* ------------------------------------------------------------------ */ /* decFloatSameQuantum -- test decFloats for same quantum */ /* */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* returns 1 if the operands have the same quantum, 0 otherwise */ /* */ /* No error is possible and no status results. */ /* ------------------------------------------------------------------ */ uInt decFloatSameQuantum(const decFloat *dfl, const decFloat *dfr) { if (DFISSPECIAL(dfl) || DFISSPECIAL(dfr)) { if (DFISNAN(dfl) && DFISNAN(dfr)) return 1; if (DFISINF(dfl) && DFISINF(dfr)) return 1; return 0; /* any other special mixture gives false */ } if (GETEXP(dfl)==GETEXP(dfr)) return 1; /* biased exponents match */ return 0; } /* decFloatSameQuantum */ /* ------------------------------------------------------------------ */ /* decFloatScaleB -- multiply by a power of 10, as per 754 */ /* */ /* result gets the result of the operation */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs), am integer (with q=0) */ /* set is the context */ /* returns result */ /* */ /* This computes result=dfl x 10**dfr where dfr is an integer in the */ /* range +/-2*(emax+pmax), typically resulting from LogB. */ /* Underflow and Overflow (with Inexact) may occur. NaNs propagate */ /* as usual. */ /* ------------------------------------------------------------------ */ #define SCALEBMAX 2*(DECEMAX+DECPMAX) /* D=800, Q=12356 */ decFloat * decFloatScaleB(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { uInt digits; /* work */ Int expr; /* dfr as an Int */ if (DFISNAN(dfl)||DFISNAN(dfr)) return decNaNs(result, dfl, dfr, set); if (!DFISINT(dfr)) return decInvalid(result, set); digits=decFloatDigits(dfr); /* calculate digits */ #if DOUBLE if (digits>3) return decInvalid(result, set); /* definitely out of range */ expr=DPD2BIN[DFWORD(dfr, 1)&0x3ff]; /* must be in bottom declet */ #elif QUAD if (digits>5) return decInvalid(result, set); /* definitely out of range */ expr=DPD2BIN[DFWORD(dfr, 3)&0x3ff] /* in bottom 2 declets .. */ +DPD2BIN[(DFWORD(dfr, 3)>>10)&0x3ff]*1000; /* .. */ #endif if (expr>SCALEBMAX) return decInvalid(result, set); /* oops */ /* [from now on no error possible] */ if (DFISINF(dfl)) return decInfinity(result, dfl); /* canonical */ if (DFISSIGNED(dfr)) expr=-expr; /* dfl is finite and expr is valid */ *result=*dfl; /* copy to target */ return decFloatSetExponent(result, set, GETEXPUN(result)+expr); } /* decFloatScaleB */ /* ------------------------------------------------------------------ */ /* decFloatShift -- shift the coefficient of a decFloat left or right */ /* */ /* result gets the result of shifting dfl */ /* dfl is the source decFloat to shift */ /* dfr is the count of digits to shift, an integer (with q=0) */ /* set is the context */ /* returns result */ /* */ /* The digits of the coefficient of dfl are shifted to the left (if */ /* dfr is positive) or to the right (if dfr is negative) without */ /* adjusting the exponent or the sign of dfl. */ /* */ /* dfr must be in the range -DECPMAX through +DECPMAX. */ /* NaNs are propagated as usual. An infinite dfl is unaffected (but */ /* dfr must be valid). No status is set unless dfr is invalid or an */ /* operand is an sNaN. The result is canonical. */ /* ------------------------------------------------------------------ */ decFloat * decFloatShift(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { Int shift; /* dfr as an Int */ uByte buf[DECPMAX*2]; /* coefficient + padding */ uInt digits, savestat; /* work */ bcdnum num; /* .. */ uInt uiwork; /* for macros */ if (DFISNAN(dfl)||DFISNAN(dfr)) return decNaNs(result, dfl, dfr, set); if (!DFISINT(dfr)) return decInvalid(result, set); digits=decFloatDigits(dfr); /* calculate digits */ if (digits>2) return decInvalid(result, set); /* definitely out of range */ shift=DPD2BIN[DFWORD(dfr, DECWORDS-1)&0x3ff]; /* is in bottom declet */ if (shift>DECPMAX) return decInvalid(result, set); /* too big */ /* [from here on no error or status change is possible] */ if (DFISINF(dfl)) return decInfinity(result, dfl); /* canonical */ /* handle no-shift and all-shift (clear to zero) cases */ if (shift==0) return decCanonical(result, dfl); if (shift==DECPMAX) { /* zero with sign */ uByte sign=(uByte)(DFBYTE(dfl, 0)&0x80); /* save sign bit */ decFloatZero(result); /* make +0 */ DFBYTE(result, 0)=(uByte)(DFBYTE(result, 0)|sign); /* and set sign */ /* [cannot safely use CopySign] */ return result; } /* a real shift is needed: 0 < shift < DECPMAX */ num.sign=DFWORD(dfl, 0)&DECFLOAT_Sign; num.exponent=GETEXPUN(dfl); num.msd=buf; GETCOEFF(dfl, buf); if (DFISSIGNED(dfr)) { /* shift right */ /* edge cases are taken care of, so this is easy */ num.lsd=buf+DECPMAX-shift-1; } else { /* shift left -- zero padding needed to right */ UBFROMUI(buf+DECPMAX, 0); /* 8 will handle most cases */ UBFROMUI(buf+DECPMAX+4, 0); /* .. */ if (shift>8) memset(buf+DECPMAX+8, 0, 8+QUAD*18); /* all other cases */ num.msd+=shift; num.lsd=num.msd+DECPMAX-1; } savestat=set->status; /* record */ decFinalize(result, &num, set); set->status=savestat; /* restore */ return result; } /* decFloatShift */ /* ------------------------------------------------------------------ */ /* decFloatSubtract -- subtract a decFloat from another */ /* */ /* result gets the result of subtracting dfr from dfl: */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* set is the context */ /* returns result */ /* */ /* ------------------------------------------------------------------ */ decFloat * decFloatSubtract(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { decFloat temp; /* NaNs must propagate without sign change */ if (DFISNAN(dfr)) return decFloatAdd(result, dfl, dfr, set); temp=*dfr; /* make a copy */ DFBYTE(&temp, 0)^=0x80; /* flip sign */ return decFloatAdd(result, dfl, &temp, set); /* and add to the lhs */ } /* decFloatSubtract */ /* ------------------------------------------------------------------ */ /* decFloatToInt -- round to 32-bit binary integer (4 flavours) */ /* */ /* df is the decFloat to round */ /* set is the context */ /* round is the rounding mode to use */ /* returns a uInt or an Int, rounded according to the name */ /* */ /* Invalid will always be signaled if df is a NaN, is Infinite, or is */ /* outside the range of the target; Inexact will not be signaled for */ /* simple rounding unless 'Exact' appears in the name. */ /* ------------------------------------------------------------------ */ uInt decFloatToUInt32(const decFloat *df, decContext *set, enum rounding round) { return decToInt32(df, set, round, 0, 1);} uInt decFloatToUInt32Exact(const decFloat *df, decContext *set, enum rounding round) { return decToInt32(df, set, round, 1, 1);} Int decFloatToInt32(const decFloat *df, decContext *set, enum rounding round) { return (Int)decToInt32(df, set, round, 0, 0);} Int decFloatToInt32Exact(const decFloat *df, decContext *set, enum rounding round) { return (Int)decToInt32(df, set, round, 1, 0);} /* ------------------------------------------------------------------ */ /* decFloatToIntegral -- round to integral value (two flavours) */ /* */ /* result gets the result */ /* df is the decFloat to round */ /* set is the context */ /* round is the rounding mode to use */ /* returns result */ /* */ /* No exceptions, even Inexact, are raised except for sNaN input, or */ /* if 'Exact' appears in the name. */ /* ------------------------------------------------------------------ */ decFloat * decFloatToIntegralValue(decFloat *result, const decFloat *df, decContext *set, enum rounding round) { return decToIntegral(result, df, set, round, 0);} decFloat * decFloatToIntegralExact(decFloat *result, const decFloat *df, decContext *set) { return decToIntegral(result, df, set, set->round, 1);} /* ------------------------------------------------------------------ */ /* decFloatXor -- logical digitwise XOR of two decFloats */ /* */ /* result gets the result of XORing dfl and dfr */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) */ /* set is the context */ /* returns result, which will be canonical with sign=0 */ /* */ /* The operands must be positive, finite with exponent q=0, and */ /* comprise just zeros and ones; if not, Invalid operation results. */ /* ------------------------------------------------------------------ */ decFloat * decFloatXor(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { if (!DFISUINT01(dfl) || !DFISUINT01(dfr) || !DFISCC01(dfl) || !DFISCC01(dfr)) return decInvalid(result, set); /* the operands are positive finite integers (q=0) with just 0s and 1s */ #if DOUBLE DFWORD(result, 0)=ZEROWORD |((DFWORD(dfl, 0) ^ DFWORD(dfr, 0))&0x04009124); DFWORD(result, 1)=(DFWORD(dfl, 1) ^ DFWORD(dfr, 1))&0x49124491; #elif QUAD DFWORD(result, 0)=ZEROWORD |((DFWORD(dfl, 0) ^ DFWORD(dfr, 0))&0x04000912); DFWORD(result, 1)=(DFWORD(dfl, 1) ^ DFWORD(dfr, 1))&0x44912449; DFWORD(result, 2)=(DFWORD(dfl, 2) ^ DFWORD(dfr, 2))&0x12449124; DFWORD(result, 3)=(DFWORD(dfl, 3) ^ DFWORD(dfr, 3))&0x49124491; #endif return result; } /* decFloatXor */ /* ------------------------------------------------------------------ */ /* decInvalid -- set Invalid_operation result */ /* */ /* result gets a canonical NaN */ /* set is the context */ /* returns result */ /* */ /* status has Invalid_operation added */ /* ------------------------------------------------------------------ */ static decFloat *decInvalid(decFloat *result, decContext *set) { decFloatZero(result); DFWORD(result, 0)=DECFLOAT_qNaN; set->status|=DEC_Invalid_operation; return result; } /* decInvalid */ /* ------------------------------------------------------------------ */ /* decInfinity -- set canonical Infinity with sign from a decFloat */ /* */ /* result gets a canonical Infinity */ /* df is source decFloat (only the sign is used) */ /* returns result */ /* */ /* df may be the same as result */ /* ------------------------------------------------------------------ */ static decFloat *decInfinity(decFloat *result, const decFloat *df) { uInt sign=DFWORD(df, 0); /* save source signword */ decFloatZero(result); /* clear everything */ DFWORD(result, 0)=DECFLOAT_Inf | (sign & DECFLOAT_Sign); return result; } /* decInfinity */ /* ------------------------------------------------------------------ */ /* decNaNs -- handle NaN argument(s) */ /* */ /* result gets the result of handling dfl and dfr, one or both of */ /* which is a NaN */ /* dfl is the first decFloat (lhs) */ /* dfr is the second decFloat (rhs) -- may be NULL for a single- */ /* operand operation */ /* set is the context */ /* returns result */ /* */ /* Called when one or both operands is a NaN, and propagates the */ /* appropriate result to res. When an sNaN is found, it is changed */ /* to a qNaN and Invalid operation is set. */ /* ------------------------------------------------------------------ */ static decFloat *decNaNs(decFloat *result, const decFloat *dfl, const decFloat *dfr, decContext *set) { /* handle sNaNs first */ if (dfr!=NULL && DFISSNAN(dfr) && !DFISSNAN(dfl)) dfl=dfr; /* use RHS */ if (DFISSNAN(dfl)) { decCanonical(result, dfl); /* propagate canonical sNaN */ DFWORD(result, 0)&=~(DECFLOAT_qNaN ^ DECFLOAT_sNaN); /* quiet */ set->status|=DEC_Invalid_operation; return result; } /* one or both is a quiet NaN */ if (!DFISNAN(dfl)) dfl=dfr; /* RHS must be NaN, use it */ return decCanonical(result, dfl); /* propagate canonical qNaN */ } /* decNaNs */ /* ------------------------------------------------------------------ */ /* decNumCompare -- numeric comparison of two decFloats */ /* */ /* dfl is the left-hand decFloat, which is not a NaN */ /* dfr is the right-hand decFloat, which is not a NaN */ /* tot is 1 for total order compare, 0 for simple numeric */ /* returns -1, 0, or +1 for dfldfr */ /* */ /* No error is possible; status and mode are unchanged. */ /* ------------------------------------------------------------------ */ static Int decNumCompare(const decFloat *dfl, const decFloat *dfr, Flag tot) { Int sigl, sigr; /* LHS and RHS non-0 signums */ Int shift; /* shift needed to align operands */ uByte *ub, *uc; /* work */ uInt uiwork; /* for macros */ /* buffers +2 if Quad (36 digits), need double plus 4 for safe padding */ uByte bufl[DECPMAX*2+QUAD*2+4]; /* for LHS coefficient + padding */ uByte bufr[DECPMAX*2+QUAD*2+4]; /* for RHS coefficient + padding */ sigl=1; if (DFISSIGNED(dfl)) { if (!DFISSIGNED(dfr)) { /* -LHS +RHS */ if (DFISZERO(dfl) && DFISZERO(dfr) && !tot) return 0; return -1; /* RHS wins */ } sigl=-1; } if (DFISSIGNED(dfr)) { if (!DFISSIGNED(dfl)) { /* +LHS -RHS */ if (DFISZERO(dfl) && DFISZERO(dfr) && !tot) return 0; return +1; /* LHS wins */ } } /* signs are the same; operand(s) could be zero */ sigr=-sigl; /* sign to return if abs(RHS) wins */ if (DFISINF(dfl)) { if (DFISINF(dfr)) return 0; /* both infinite & same sign */ return sigl; /* inf > n */ } if (DFISINF(dfr)) return sigr; /* n < inf [dfl is finite] */ /* here, both are same sign and finite; calculate their offset */ shift=GETEXP(dfl)-GETEXP(dfr); /* [0 means aligned] */ /* [bias can be ignored -- the absolute exponent is not relevant] */ if (DFISZERO(dfl)) { if (!DFISZERO(dfr)) return sigr; /* LHS=0, RHS!=0 */ /* both are zero, return 0 if both same exponent or numeric compare */ if (shift==0 || !tot) return 0; if (shift>0) return sigl; return sigr; /* [shift<0] */ } else { /* LHS!=0 */ if (DFISZERO(dfr)) return sigl; /* LHS!=0, RHS=0 */ } /* both are known to be non-zero at this point */ /* if the exponents are so different that the coefficients do not */ /* overlap (by even one digit) then a full comparison is not needed */ if (abs(shift)>=DECPMAX) { /* no overlap */ /* coefficients are known to be non-zero */ if (shift>0) return sigl; return sigr; /* [shift<0] */ } /* decode the coefficients */ /* (shift both right two if Quad to make a multiple of four) */ #if QUAD UBFROMUI(bufl, 0); UBFROMUI(bufr, 0); #endif GETCOEFF(dfl, bufl+QUAD*2); /* decode from decFloat */ GETCOEFF(dfr, bufr+QUAD*2); /* .. */ if (shift==0) { /* aligned; common and easy */ /* all multiples of four, here */ for (ub=bufl, uc=bufr; ub*uc) return sigl; /* difference found */ if (*ub<*uc) return sigr; /* .. */ } } } /* aligned */ else if (shift>0) { /* lhs to left */ ub=bufl; /* RHS pointer */ /* pad bufl so right-aligned; most shifts will fit in 8 */ UBFROMUI(bufl+DECPMAX+QUAD*2, 0); /* add eight zeros */ UBFROMUI(bufl+DECPMAX+QUAD*2+4, 0); /* .. */ if (shift>8) { /* more than eight; fill the rest, and also worth doing the */ /* lead-in by fours */ uByte *up; /* work */ uByte *upend=bufl+DECPMAX+QUAD*2+shift; for (up=bufl+DECPMAX+QUAD*2+8; upbufl+shift-4) break; } } /* check remaining leading digits */ for (; ub*uc) return sigl; /* difference found */ if (*ub<*uc) return sigr; /* .. */ } } /* mismatch */ if (uc==bufr+QUAD*2+DECPMAX-4) break; /* all checked */ } } /* shift>0 */ else { /* shift<0) .. RHS is to left of LHS; mirror shift>0 */ uc=bufr; /* RHS pointer */ /* pad bufr so right-aligned; most shifts will fit in 8 */ UBFROMUI(bufr+DECPMAX+QUAD*2, 0); /* add eight zeros */ UBFROMUI(bufr+DECPMAX+QUAD*2+4, 0); /* .. */ if (shift<-8) { /* more than eight; fill the rest, and also worth doing the */ /* lead-in by fours */ uByte *up; /* work */ uByte *upend=bufr+DECPMAX+QUAD*2-shift; for (up=bufr+DECPMAX+QUAD*2+8; upbufr-shift-4) break; } } /* check remaining leading digits */ for (; uc*uc) return sigl; /* difference found */ if (*ub<*uc) return sigr; /* .. */ } } /* mismatch */ if (ub==bufl+QUAD*2+DECPMAX-4) break; /* all checked */ } } /* shift<0 */ /* Here when compare equal */ if (!tot) return 0; /* numerically equal */ /* total ordering .. exponent matters */ if (shift>0) return sigl; /* total order by exponent */ if (shift<0) return sigr; /* .. */ return 0; } /* decNumCompare */ /* ------------------------------------------------------------------ */ /* decToInt32 -- local routine to effect ToInteger conversions */ /* */ /* df is the decFloat to convert */ /* set is the context */ /* rmode is the rounding mode to use */ /* exact is 1 if Inexact should be signalled */ /* unsign is 1 if the result a uInt, 0 if an Int (cast to uInt) */ /* returns 32-bit result as a uInt */ /* */ /* Invalid is set is df is a NaN, is infinite, or is out-of-range; in */ /* these cases 0 is returned. */ /* ------------------------------------------------------------------ */ static uInt decToInt32(const decFloat *df, decContext *set, enum rounding rmode, Flag exact, Flag unsign) { Int exp; /* exponent */ uInt sourhi, sourpen, sourlo; /* top word from source decFloat .. */ uInt hi, lo; /* .. penultimate, least, etc. */ decFloat zero, result; /* work */ Int i; /* .. */ /* Start decoding the argument */ sourhi=DFWORD(df, 0); /* top word */ exp=DECCOMBEXP[sourhi>>26]; /* get exponent high bits (in place) */ if (EXPISSPECIAL(exp)) { /* is special? */ set->status|=DEC_Invalid_operation; /* signal */ return 0; } /* Here when the argument is finite */ if (GETEXPUN(df)==0) result=*df; /* already a true integer */ else { /* need to round to integer */ enum rounding saveround; /* saver */ uInt savestatus; /* .. */ saveround=set->round; /* save rounding mode .. */ savestatus=set->status; /* .. and status */ set->round=rmode; /* set mode */ decFloatZero(&zero); /* make 0E+0 */ set->status=0; /* clear */ decFloatQuantize(&result, df, &zero, set); /* [this may fail] */ set->round=saveround; /* restore rounding mode .. */ if (exact) set->status|=savestatus; /* include Inexact */ else set->status=savestatus; /* .. or just original status */ } /* only the last four declets of the coefficient can contain */ /* non-zero; check for others (and also NaN or Infinity from the */ /* Quantize) first (see DFISZERO for explanation): */ /* decFloatShow(&result, "sofar"); */ #if DOUBLE if ((DFWORD(&result, 0)&0x1c03ff00)!=0 || (DFWORD(&result, 0)&0x60000000)==0x60000000) { #elif QUAD if ((DFWORD(&result, 2)&0xffffff00)!=0 || DFWORD(&result, 1)!=0 || (DFWORD(&result, 0)&0x1c003fff)!=0 || (DFWORD(&result, 0)&0x60000000)==0x60000000) { #endif set->status|=DEC_Invalid_operation; /* Invalid or out of range */ return 0; } /* get last twelve digits of the coefficent into hi & ho, base */ /* 10**9 (see GETCOEFFBILL): */ sourlo=DFWORD(&result, DECWORDS-1); lo=DPD2BIN0[sourlo&0x3ff] +DPD2BINK[(sourlo>>10)&0x3ff] +DPD2BINM[(sourlo>>20)&0x3ff]; sourpen=DFWORD(&result, DECWORDS-2); hi=DPD2BIN0[((sourpen<<2) | (sourlo>>30))&0x3ff]; /* according to request, check range carefully */ if (unsign) { if (hi>4 || (hi==4 && lo>294967295) || (hi+lo!=0 && DFISSIGNED(&result))) { set->status|=DEC_Invalid_operation; /* out of range */ return 0; } return hi*BILLION+lo; } /* signed */ if (hi>2 || (hi==2 && lo>147483647)) { /* handle the usual edge case */ if (lo==147483648 && hi==2 && DFISSIGNED(&result)) return 0x80000000; set->status|=DEC_Invalid_operation; /* truly out of range */ return 0; } i=hi*BILLION+lo; if (DFISSIGNED(&result)) i=-i; return (uInt)i; } /* decToInt32 */ /* ------------------------------------------------------------------ */ /* decToIntegral -- local routine to effect ToIntegral value */ /* */ /* result gets the result */ /* df is the decFloat to round */ /* set is the context */ /* rmode is the rounding mode to use */ /* exact is 1 if Inexact should be signalled */ /* returns result */ /* ------------------------------------------------------------------ */ static decFloat * decToIntegral(decFloat *result, const decFloat *df, decContext *set, enum rounding rmode, Flag exact) { Int exp; /* exponent */ uInt sourhi; /* top word from source decFloat */ enum rounding saveround; /* saver */ uInt savestatus; /* .. */ decFloat zero; /* work */ /* Start decoding the argument */ sourhi=DFWORD(df, 0); /* top word */ exp=DECCOMBEXP[sourhi>>26]; /* get exponent high bits (in place) */ if (EXPISSPECIAL(exp)) { /* is special? */ /* NaNs are handled as usual */ if (DFISNAN(df)) return decNaNs(result, df, NULL, set); /* must be infinite; return canonical infinity with sign of df */ return decInfinity(result, df); } /* Here when the argument is finite */ /* complete extraction of the exponent */ exp+=GETECON(df)-DECBIAS; /* .. + continuation and unbias */ if (exp>=0) return decCanonical(result, df); /* already integral */ saveround=set->round; /* save rounding mode .. */ savestatus=set->status; /* .. and status */ set->round=rmode; /* set mode */ decFloatZero(&zero); /* make 0E+0 */ decFloatQuantize(result, df, &zero, set); /* 'integrate'; cannot fail */ set->round=saveround; /* restore rounding mode .. */ if (!exact) set->status=savestatus; /* .. and status, unless exact */ return result; } /* decToIntegral */ libdfp-1.0.12/libdecnumber/decCommon.c000066400000000000000000002215261261375163000175520ustar00rootroot00000000000000/* Common code for fixed-size types in the decNumber C Library. Copyright (C) 2007-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------ */ /* decCommon.c -- common code for all three fixed-size types */ /* ------------------------------------------------------------------ */ /* This module comprises code that is shared between all the formats */ /* (decSingle, decDouble, and decQuad); it includes set and extract */ /* of format components, widening, narrowing, and string conversions. */ /* */ /* Unlike decNumber, parameterization takes place at compile time */ /* rather than at runtime. The parameters are set in the decDouble.c */ /* (etc.) files, which then include this one to produce the compiled */ /* code. The functions here, therefore, are code shared between */ /* multiple formats. */ /* ------------------------------------------------------------------ */ /* Names here refer to decFloat rather than to decDouble, etc., and */ /* the functions are in strict alphabetical order. */ /* Constants, tables, and debug function(s) are included only for QUAD */ /* (which will always be compiled if DOUBLE or SINGLE are used). */ /* */ /* Whenever a decContext is used, only the status may be set (using */ /* OR) or the rounding mode read; all other fields are ignored and */ /* untouched. */ #include "decCommonSymbols.h" /* names for simpler testing and default context */ #if DECPMAX==7 #define SINGLE 1 #define DOUBLE 0 #define QUAD 0 #define DEFCONTEXT DEC_INIT_DECIMAL32 #elif DECPMAX==16 #define SINGLE 0 #define DOUBLE 1 #define QUAD 0 #define DEFCONTEXT DEC_INIT_DECIMAL64 #elif DECPMAX==34 #define SINGLE 0 #define DOUBLE 0 #define QUAD 1 #define DEFCONTEXT DEC_INIT_DECIMAL128 #else #error Unexpected DECPMAX value #endif /* Assertions */ #if DECPMAX!=7 && DECPMAX!=16 && DECPMAX!=34 #error Unexpected Pmax (DECPMAX) value for this module #endif /* Assert facts about digit characters, etc. */ #if ('9'&0x0f)!=9 #error This module assumes characters are of the form 0b....nnnn /* where .... are don't care 4 bits and nnnn is 0000 through 1001 */ #endif #if ('9'&0xf0)==('.'&0xf0) #error This module assumes '.' has a different mask than a digit #endif /* Assert ToString lay-out conditions */ #if DECSTRING DECSTRING #error Exponent form can be too long for ToString to lay out safely #endif #if DECEMAXD > 4 #error Exponent form is too long for ToString to lay out /* Note: code for up to 9 digits exists in archives [decOct] */ #endif /* Private functions used here and possibly in decBasic.c, etc. */ static decFloat * decFinalize(decFloat *, bcdnum *, decContext *); static Flag decBiStr(const char *, const char *, const char *); /* Macros and private tables; those which are not format-dependent */ /* are only included if decQuad is being built. */ /* ------------------------------------------------------------------ */ /* Combination field lookup tables (uInts to save measurable work) */ /* */ /* DECCOMBEXP - 2 most-significant-bits of exponent (00, 01, or */ /* 10), shifted left for format, or DECFLOAT_Inf/NaN */ /* DECCOMBWEXP - The same, for the next-wider format (unless QUAD) */ /* DECCOMBMSD - 4-bit most-significant-digit */ /* [0 if the index is a special (Infinity or NaN)] */ /* DECCOMBFROM - 5-bit combination field from EXP top bits and MSD */ /* (placed in uInt so no shift is needed) */ /* */ /* DECCOMBEXP, DECCOMBWEXP, and DECCOMBMSD are indexed by the sign */ /* and 5-bit combination field (0-63, the second half of the table */ /* identical to the first half) */ /* DECCOMBFROM is indexed by expTopTwoBits*16 + msd */ /* */ /* DECCOMBMSD and DECCOMBFROM are not format-dependent and so are */ /* only included once, when QUAD is being built */ /* ------------------------------------------------------------------ */ static const uInt DECCOMBEXP[64]={ 0, 0, 0, 0, 0, 0, 0, 0, 1< DPD */ #define DEC_BIN2DPD 1 /* 0-999 -> DPD */ #define DEC_BIN2BCD8 1 /* 0-999 -> ddd, len */ #define DEC_DPD2BCD8 1 /* DPD -> ddd, len */ #define DEC_DPD2BIN 1 /* DPD -> 0-999 */ #define DEC_DPD2BINK 1 /* DPD -> 0-999000 */ #define DEC_DPD2BINM 1 /* DPD -> 0-999000000 */ #include "decDPD.h" /* source of the lookup tables */ #endif /* ----------------------------------------------------------------- */ /* decBiStr -- compare string with pairwise options */ /* */ /* targ is the string to compare */ /* str1 is one of the strings to compare against (length may be 0) */ /* str2 is the other; it must be the same length as str1 */ /* */ /* returns 1 if strings compare equal, (that is, targ is the same */ /* length as str1 and str2, and each character of targ is in one */ /* of str1 or str2 in the corresponding position), or 0 otherwise */ /* */ /* This is used for generic caseless compare, including the awkward */ /* case of the Turkish dotted and dotless Is. Use as (for example): */ /* if (decBiStr(test, "mike", "MIKE")) ... */ /* ----------------------------------------------------------------- */ static Flag decBiStr(const char *targ, const char *str1, const char *str2) { for (;;targ++, str1++, str2++) { if (*targ!=*str1 && *targ!=*str2) return 0; /* *targ has a match in one (or both, if terminator) */ if (*targ=='\0') break; } /* forever */ return 1; } /* decBiStr */ /* ------------------------------------------------------------------ */ /* decFinalize -- adjust and store a final result */ /* */ /* df is the decFloat format number which gets the final result */ /* num is the descriptor of the number to be checked and encoded */ /* [its values, including the coefficient, may be modified] */ /* set is the context to use */ /* returns df */ /* */ /* The num descriptor may point to a bcd8 string of any length; this */ /* string may have leading insignificant zeros. If it has more than */ /* DECPMAX digits then the final digit can be a round-for-reround */ /* digit (i.e., it may include a sticky bit residue). */ /* */ /* The exponent (q) may be one of the codes for a special value and */ /* can be up to 999999999 for conversion from string. */ /* */ /* No error is possible, but Inexact, Underflow, and/or Overflow may */ /* be set. */ /* ------------------------------------------------------------------ */ /* Constant whose size varies with format; also the check for surprises */ static uByte allnines[DECPMAX]= #if SINGLE {9, 9, 9, 9, 9, 9, 9}; #elif DOUBLE {9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9}; #elif QUAD {9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9}; #endif static decFloat * decFinalize(decFloat *df, bcdnum *num, decContext *set) { uByte *ub; /* work */ uInt dpd; /* .. */ uInt uiwork; /* for macros */ uByte *umsd=num->msd; /* local copy */ uByte *ulsd=num->lsd; /* .. */ uInt encode; /* encoding accumulator */ Int length; /* coefficient length */ #if DECCHECK Int clen=ulsd-umsd+1; #if QUAD #define COEXTRA 2 /* extra-long coefficent */ #else #define COEXTRA 0 #endif if (clen<1 || clen>DECPMAX*3+2+COEXTRA) printf("decFinalize: suspect coefficient [length=%ld]\n", (LI)clen); if (num->sign!=0 && num->sign!=DECFLOAT_Sign) printf("decFinalize: bad sign [%08lx]\n", (LI)num->sign); if (!EXPISSPECIAL(num->exponent) && (num->exponent>1999999999 || num->exponent<-1999999999)) printf("decFinalize: improbable exponent [%ld]\n", (LI)num->exponent); /* decShowNum(num, "final"); */ #endif /* A special will have an 'exponent' which is very positive and a */ /* coefficient < DECPMAX */ length=(uInt)(ulsd-umsd+1); /* coefficient length */ if (!NUMISSPECIAL(num)) { Int drop; /* digits to be dropped */ /* skip leading insignificant zeros to calculate an exact length */ /* [this is quite expensive] */ if (*umsd==0) { for (; umsd+3exponent); /* drop can now be > digits for bottom-clamp (subnormal) cases */ if (drop>0) { /* rounding needed */ /* (decFloatQuantize has very similar code to this, so any */ /* changes may need to be made there, too) */ uByte *roundat; /* -> re-round digit */ uByte reround; /* reround value */ /* printf("Rounding; drop=%ld\n", (LI)drop); */ num->exponent+=drop; /* always update exponent */ /* Three cases here: */ /* 1. new LSD is in coefficient (almost always) */ /* 2. new LSD is digit to left of coefficient (so MSD is */ /* round-for-reround digit) */ /* 3. new LSD is to left of case 2 (whole coefficient is sticky) */ /* [duplicate check-stickies code to save a test] */ /* [by-digit check for stickies as runs of zeros are rare] */ if (dropstatus|=DEC_Inexact; /* if adjusted exponent [exp+digits-1] is < EMIN then num is */ /* subnormal -- so raise Underflow */ if (num->exponentexponent+(ulsd-umsd+1)-1)status|=DEC_Underflow; /* next decide whether increment of the coefficient is needed */ if (set->round==DEC_ROUND_HALF_EVEN) { /* fastpath slowest case */ if (reround>5) bump=1; /* >0.5 goes up */ else if (reround==5) /* exactly 0.5000 .. */ bump=*ulsd & 0x01; /* .. up iff [new] lsd is odd */ } /* r-h-e */ else switch (set->round) { case DEC_ROUND_DOWN: { /* no change */ break;} /* r-d */ case DEC_ROUND_HALF_DOWN: { if (reround>5) bump=1; break;} /* r-h-d */ case DEC_ROUND_HALF_UP: { if (reround>=5) bump=1; break;} /* r-h-u */ case DEC_ROUND_UP: { if (reround>0) bump=1; break;} /* r-u */ case DEC_ROUND_CEILING: { /* same as _UP for positive numbers, and as _DOWN for negatives */ if (!num->sign && reround>0) bump=1; break;} /* r-c */ case DEC_ROUND_FLOOR: { /* same as _UP for negative numbers, and as _DOWN for positive */ /* [negative reround cannot occur on 0] */ if (num->sign && reround>0) bump=1; break;} /* r-f */ case DEC_ROUND_05UP: { if (reround>0) { /* anything out there is 'sticky' */ /* bump iff lsd=0 or 5; this cannot carry so it could be */ /* effected immediately with no bump -- but the code */ /* is clearer if this is done the same way as the others */ if (*ulsd==0 || *ulsd==5) bump=1; } break;} /* r-r */ default: { /* e.g., DEC_ROUND_MAX */ set->status|=DEC_Invalid_context; #if DECCHECK printf("Unknown rounding mode: %ld\n", (LI)set->round); #endif break;} } /* switch (not r-h-e) */ /* printf("ReRound: %ld bump: %ld\n", (LI)reround, (LI)bump); */ if (bump!=0) { /* need increment */ /* increment the coefficient; this might end up with 1000... */ /* (after the all nines case) */ ub=ulsd; for(; ub-3>=umsd && UBTOUI(ub-3)==0x09090909; ub-=4) { UBFROMUI(ub-3, 0); /* to 00000000 */ } /* [note ub could now be to left of msd, and it is not safe */ /* to write to the the left of the msd] */ /* now at most 3 digits left to non-9 (usually just the one) */ for (; ub>=umsd; *ub=0, ub--) { if (*ub==9) continue; /* carry */ *ub+=1; break; } if (ubexponent++; } else { /* if coefficient is shorter than Pmax then num is */ /* subnormal, so extend it; this is safe as drop>0 */ /* (or, if the coefficient was supplied above, it could */ /* not be 9); this may make the result normal. */ ulsd++; *ulsd=0; /* [exponent unchanged] */ #if DECCHECK if (num->exponent!=DECQTINY) /* sanity check */ printf("decFinalize: bad all-nines extend [^%ld, %ld]\n", (LI)num->exponent, (LI)(ulsd-umsd+1)); #endif } /* subnormal extend */ } /* had all-nines */ } /* bump needed */ } /* inexact rounding */ length=ulsd-umsd+1; /* recalculate (may be 0) */ /* The coefficient will now fit and has final length unless overflow */ /* decShowNum(num, "rounded"); */ /* if exponent is >=emax may have to clamp, overflow, or fold-down */ if (num->exponent>DECEMAX-(DECPMAX-1)) { /* is edge case */ /* printf("overflow checks...\n"); */ if (*ulsd==0 && ulsd==umsd) { /* have zero */ num->exponent=DECEMAX-(DECPMAX-1); /* clamp to max */ } else if ((num->exponent+length-1)>DECEMAX) { /* > Nmax */ /* Overflow -- these could go straight to encoding, here, but */ /* instead num is adjusted to keep the code cleaner */ Flag needmax=0; /* 1 for finite result */ set->status|=(DEC_Overflow | DEC_Inexact); switch (set->round) { case DEC_ROUND_DOWN: { needmax=1; /* never Infinity */ break;} /* r-d */ case DEC_ROUND_05UP: { needmax=1; /* never Infinity */ break;} /* r-05 */ case DEC_ROUND_CEILING: { if (num->sign) needmax=1; /* Infinity iff non-negative */ break;} /* r-c */ case DEC_ROUND_FLOOR: { if (!num->sign) needmax=1; /* Infinity iff negative */ break;} /* r-f */ default: break; /* Infinity in all other cases */ } if (!needmax) { /* easy .. set Infinity */ num->exponent=DECFLOAT_Inf; *umsd=0; /* be clean: coefficient to 0 */ ulsd=umsd; /* .. */ } else { /* return Nmax */ umsd=allnines; /* use constant array */ ulsd=allnines+DECPMAX-1; num->exponent=DECEMAX-(DECPMAX-1); } } else { /* no overflow but non-zero and may have to fold-down */ Int shift=num->exponent-(DECEMAX-(DECPMAX-1)); if (shift>0) { /* fold-down needed */ /* fold down needed; must copy to buffer in order to pad */ /* with zeros safely; fortunately this is not the worst case */ /* path because cannot have had a round */ uByte buffer[ROUNDUP(DECPMAX+3, 4)]; /* [+3 allows uInt padding] */ uByte *s=umsd; /* source */ uByte *t=buffer; /* safe target */ uByte *tlsd=buffer+(ulsd-umsd)+shift; /* target LSD */ /* printf("folddown shift=%ld\n", (LI)shift); */ for (; s<=ulsd; s+=4, t+=4) UBFROMUI(t, UBTOUI(s)); for (t=tlsd-shift+1; t<=tlsd; t+=4) UBFROMUI(t, 0); /* pad 0s */ num->exponent-=shift; umsd=buffer; ulsd=tlsd; } } /* fold-down? */ length=ulsd-umsd+1; /* recalculate length */ } /* high-end edge case */ } /* finite number */ /*------------------------------------------------------------------*/ /* At this point the result will properly fit the decFloat */ /* encoding, and it can be encoded with no possibility of error */ /*------------------------------------------------------------------*/ /* Following code does not alter coefficient (could be allnines array) */ /* fast path possible when DECPMAX digits */ if (length==DECPMAX) { return decFloatFromBCD(df, num->exponent, umsd, num->sign); } /* full-length */ /* slower path when not a full-length number; must care about length */ /* [coefficient length here will be < DECPMAX] */ if (!NUMISSPECIAL(num)) { /* is still finite */ /* encode the combination field and exponent continuation */ uInt uexp=(uInt)(num->exponent+DECBIAS); /* biased exponent */ uInt code=(uexp>>DECECONL)<<4; /* top two bits of exp */ /* [msd==0] */ /* look up the combination field and make high word */ encode=DECCOMBFROM[code]; /* indexed by (0-2)*16+msd */ encode|=(uexp<<(32-6-DECECONL)) & 0x03ffffff; /* exponent continuation */ } else encode=num->exponent; /* special [already in word] */ encode|=num->sign; /* add sign */ /* private macro to extract a declet, n (where 0<=n=umsd) dpd=BCD2DPD[(*ub*256)+(*(ub+1)*16)+*(ub+2)]; \ else {dpd=*(ub+2); if (ub+1==umsd) dpd+=*(ub+1)*16; dpd=BCD2DPD[dpd];} /* place the declets in the encoding words and copy to result (df), */ /* according to endianness; in all cases complete the sign word */ /* first */ #if DECPMAX==7 getDPDt(dpd, 1); encode|=dpd<<10; getDPDt(dpd, 0); encode|=dpd; DFWORD(df, 0)=encode; /* just the one word */ #elif DECPMAX==16 getDPDt(dpd, 4); encode|=dpd<<8; getDPDt(dpd, 3); encode|=dpd>>2; DFWORD(df, 0)=encode; encode=dpd<<30; getDPDt(dpd, 2); encode|=dpd<<20; getDPDt(dpd, 1); encode|=dpd<<10; getDPDt(dpd, 0); encode|=dpd; DFWORD(df, 1)=encode; #elif DECPMAX==34 getDPDt(dpd,10); encode|=dpd<<4; getDPDt(dpd, 9); encode|=dpd>>6; DFWORD(df, 0)=encode; encode=dpd<<26; getDPDt(dpd, 8); encode|=dpd<<16; getDPDt(dpd, 7); encode|=dpd<<6; getDPDt(dpd, 6); encode|=dpd>>4; DFWORD(df, 1)=encode; encode=dpd<<28; getDPDt(dpd, 5); encode|=dpd<<18; getDPDt(dpd, 4); encode|=dpd<<8; getDPDt(dpd, 3); encode|=dpd>>2; DFWORD(df, 2)=encode; encode=dpd<<30; getDPDt(dpd, 2); encode|=dpd<<20; getDPDt(dpd, 1); encode|=dpd<<10; getDPDt(dpd, 0); encode|=dpd; DFWORD(df, 3)=encode; #endif /* printf("Status: %08lx\n", (LI)set->status); */ /* decFloatShow(df, "final2"); */ return df; } /* decFinalize */ /* ------------------------------------------------------------------ */ /* decFloatFromBCD -- set decFloat from exponent, BCD8, and sign */ /* */ /* df is the target decFloat */ /* exp is the in-range unbiased exponent, q, or a special value in */ /* the form returned by decFloatGetExponent */ /* bcdar holds DECPMAX digits to set the coefficient from, one */ /* digit in each byte (BCD8 encoding); the first (MSD) is ignored */ /* if df is a NaN; all are ignored if df is infinite. */ /* All bytes must be in 0-9; results are undefined otherwise. */ /* sig is DECFLOAT_Sign to set the sign bit, 0 otherwise */ /* returns df, which will be canonical */ /* */ /* No error is possible, and no status will be set. */ /* ------------------------------------------------------------------ */ decFloat * decFloatFromBCD(decFloat *df, Int exp, const uByte *bcdar, Int sig) { uInt encode, dpd; /* work */ const uByte *ub; /* .. */ if (EXPISSPECIAL(exp)) encode=exp|sig;/* specials already encoded */ else { /* is finite */ /* encode the combination field and exponent continuation */ uInt uexp=(uInt)(exp+DECBIAS); /* biased exponent */ uInt code=(uexp>>DECECONL)<<4; /* top two bits of exp */ code+=bcdar[0]; /* add msd */ /* look up the combination field and make high word */ encode=DECCOMBFROM[code]|sig; /* indexed by (0-2)*16+msd */ encode|=(uexp<<(32-6-DECECONL)) & 0x03ffffff; /* exponent continuation */ } /* private macro to extract a declet, n (where 0<=n>2; DFWORD(df, 0)=encode; encode=dpd<<30; getDPDb(dpd, 2); encode|=dpd<<20; getDPDb(dpd, 1); encode|=dpd<<10; getDPDb(dpd, 0); encode|=dpd; DFWORD(df, 1)=encode; #elif DECPMAX==34 getDPDb(dpd,10); encode|=dpd<<4; getDPDb(dpd, 9); encode|=dpd>>6; DFWORD(df, 0)=encode; encode=dpd<<26; getDPDb(dpd, 8); encode|=dpd<<16; getDPDb(dpd, 7); encode|=dpd<<6; getDPDb(dpd, 6); encode|=dpd>>4; DFWORD(df, 1)=encode; encode=dpd<<28; getDPDb(dpd, 5); encode|=dpd<<18; getDPDb(dpd, 4); encode|=dpd<<8; getDPDb(dpd, 3); encode|=dpd>>2; DFWORD(df, 2)=encode; encode=dpd<<30; getDPDb(dpd, 2); encode|=dpd<<20; getDPDb(dpd, 1); encode|=dpd<<10; getDPDb(dpd, 0); encode|=dpd; DFWORD(df, 3)=encode; #endif /* decFloatShow(df, "fromB"); */ return df; } /* decFloatFromBCD */ /* ------------------------------------------------------------------ */ /* decFloatFromPacked -- set decFloat from exponent and packed BCD */ /* */ /* df is the target decFloat */ /* exp is the in-range unbiased exponent, q, or a special value in */ /* the form returned by decFloatGetExponent */ /* packed holds DECPMAX packed decimal digits plus a sign nibble */ /* (all 6 codes are OK); the first (MSD) is ignored if df is a NaN */ /* and all except sign are ignored if df is infinite. For DOUBLE */ /* and QUAD the first (pad) nibble is also ignored in all cases. */ /* All coefficient nibbles must be in 0-9 and sign in A-F; results */ /* are undefined otherwise. */ /* returns df, which will be canonical */ /* */ /* No error is possible, and no status will be set. */ /* ------------------------------------------------------------------ */ decFloat * decFloatFromPacked(decFloat *df, Int exp, const uByte *packed) { uByte bcdar[DECPMAX+2]; /* work [+1 for pad, +1 for sign] */ const uByte *ip; /* .. */ uByte *op; /* .. */ Int sig=0; /* sign */ /* expand coefficient and sign to BCDAR */ #if SINGLE op=bcdar+1; /* no pad digit */ #else op=bcdar; /* first (pad) digit ignored */ #endif for (ip=packed; ip>4; *op++=(uByte)(*ip&0x0f); /* [final nibble is sign] */ } op--; /* -> sign byte */ if (*op==DECPMINUS || *op==DECPMINUSALT) sig=DECFLOAT_Sign; if (EXPISSPECIAL(exp)) { /* Infinity or NaN */ if (!EXPISINF(exp)) bcdar[1]=0; /* a NaN: ignore MSD */ else memset(bcdar+1, 0, DECPMAX); /* Infinite: coefficient to 0 */ } return decFloatFromBCD(df, exp, bcdar+1, sig); } /* decFloatFromPacked */ /* ------------------------------------------------------------------ */ /* decFloatFromPackedChecked -- set from exponent and packed; checked */ /* */ /* df is the target decFloat */ /* exp is the in-range unbiased exponent, q, or a special value in */ /* the form returned by decFloatGetExponent */ /* packed holds DECPMAX packed decimal digits plus a sign nibble */ /* (all 6 codes are OK); the first (MSD) must be 0 if df is a NaN */ /* and all digits must be 0 if df is infinite. For DOUBLE and */ /* QUAD the first (pad) nibble must be 0. */ /* All coefficient nibbles must be in 0-9 and sign in A-F. */ /* returns df, which will be canonical or NULL if any of the */ /* requirements are not met (if this case df is unchanged); that */ /* is, the input data must be as returned by decFloatToPacked, */ /* except that all six sign codes are acccepted. */ /* */ /* No status will be set. */ /* ------------------------------------------------------------------ */ decFloat * decFloatFromPackedChecked(decFloat *df, Int exp, const uByte *packed) { uByte bcdar[DECPMAX+2]; /* work [+1 for pad, +1 for sign] */ const uByte *ip; /* .. */ uByte *op; /* .. */ Int sig=0; /* sign */ /* expand coefficient and sign to BCDAR */ #if SINGLE op=bcdar+1; /* no pad digit */ #else op=bcdar; /* first (pad) digit here */ #endif for (ip=packed; ip>4; if (*op>9) return NULL; op++; *op=(uByte)(*ip&0x0f); /* [final nibble is sign] */ if (*op>9 && ip sign byte */ if (*op<=9) return NULL; /* bad sign */ if (*op==DECPMINUS || *op==DECPMINUSALT) sig=DECFLOAT_Sign; #if !SINGLE if (bcdar[0]!=0) return NULL; /* bad pad nibble */ #endif if (EXPISNAN(exp)) { /* a NaN */ if (bcdar[1]!=0) return NULL; /* bad msd */ } /* NaN */ else if (EXPISINF(exp)) { /* is infinite */ Int i; for (i=0; iDECEMAX-DECPMAX+1) return NULL; if (exp first character of decimal part */ const char *c; /* work */ uByte *ub; /* .. */ uInt uiwork; /* for macros */ bcdnum num; /* collects data for finishing */ uInt error=DEC_Conversion_syntax; /* assume the worst */ uByte buffer[ROUNDUP(DECSTRING+11, 8)]; /* room for most coefficents, */ /* some common rounding, +3, & pad */ #if DECTRACE /* printf("FromString %s ...\n", string); */ #endif for(;;) { /* once-only 'loop' */ num.sign=0; /* assume non-negative */ num.msd=buffer; /* MSD is here always */ /* detect and validate the coefficient, including any leading, */ /* trailing, or embedded '.' */ /* [could test four-at-a-time here (saving 10% for decQuads), */ /* but that risks storage violation because the position of the */ /* terminator is unknown] */ for (c=string;; c++) { /* -> input character */ if (((unsigned)(*c-'0'))<=9) continue; /* '0' through '9' is good */ if (*c=='\0') break; /* most common non-digit */ if (*c=='.') { if (dotchar!=NULL) break; /* not first '.' */ dotchar=c; /* record offset into decimal part */ continue;} if (c==string) { /* first in string... */ if (*c=='-') { /* valid - sign */ cfirst++; num.sign=DECFLOAT_Sign; continue;} if (*c=='+') { /* valid + sign */ cfirst++; continue;} } /* *c is not a digit, terminator, or a valid +, -, or '.' */ break; } /* c loop */ digits=(uInt)(c-cfirst); /* digits (+1 if a dot) */ if (digits>0) { /* had digits and/or dot */ const char *clast=c-1; /* note last coefficient char position */ Int exp=0; /* exponent accumulator */ if (*c!='\0') { /* something follows the coefficient */ uInt edig; /* unsigned work */ /* had some digits and more to come; expect E[+|-]nnn now */ const char *firstexp; /* exponent first non-zero */ if (*c!='E' && *c!='e') break; c++; /* to (optional) sign */ if (*c=='-' || *c=='+') c++; /* step over sign (c=clast+2) */ if (*c=='\0') break; /* no digits! (e.g., '1.2E') */ for (; *c=='0';) c++; /* skip leading zeros [even last] */ firstexp=c; /* remember start [maybe '\0'] */ /* gather exponent digits */ edig=(uInt)*c-(uInt)'0'; if (edig<=9) { /* [check not bad or terminator] */ exp+=edig; /* avoid initial X10 */ c++; for (;; c++) { edig=(uInt)*c-(uInt)'0'; if (edig>9) break; exp=exp*10+edig; } } /* if not now on the '\0', *c must not be a digit */ if (*c!='\0') break; /* (this next test must be after the syntax checks) */ /* if definitely more than the possible digits for format then */ /* the exponent may have wrapped, so simply set it to a certain */ /* over/underflow value */ if (c>firstexp+DECEMAXD) exp=DECEMAX*2; if (*(clast+2)=='-') exp=-exp; /* was negative */ } /* digits>0 */ if (dotchar!=NULL) { /* had a '.' */ digits--; /* remove from digits count */ if (digits==0) break; /* was dot alone: bad syntax */ exp-=(Int)(clast-dotchar); /* adjust exponent */ /* [the '.' can now be ignored] */ } num.exponent=exp; /* exponent is good; store it */ /* Here when whole string has been inspected and syntax is good */ /* cfirst->first digit or dot, clast->last digit or dot */ error=0; /* no error possible now */ /* if the number of digits in the coefficient will fit in buffer */ /* then it can simply be converted to bcd8 and copied -- decFinalize */ /* will take care of leading zeros and rounding; the buffer is big */ /* enough for all canonical coefficients, including 0.00000nn... */ ub=buffer; if (digits<=(Int)(sizeof(buffer)-3)) { /* [-3 allows by-4s copy] */ c=cfirst; if (dotchar!=NULL) { /* a dot to worry about */ if (*(c+1)=='.') { /* common canonical case */ *ub++=(uByte)(*c-'0'); /* copy leading digit */ c+=2; /* prepare to handle rest */ } else for (; c<=clast;) { /* '.' could be anywhere */ /* as usual, go by fours when safe; NB it has been asserted */ /* that a '.' does not have the same mask as a digit */ if (c<=clast-3 /* safe for four */ && (UBTOUI(c)&0xf0f0f0f0)==CHARMASK) { /* test four */ UBFROMUI(ub, UBTOUI(c)&0x0f0f0f0f); /* to BCD8 */ ub+=4; c+=4; continue; } if (*c=='.') { /* found the dot */ c++; /* step over it .. */ break; /* .. and handle the rest */ } *ub++=(uByte)(*c++-'0'); } } /* had dot */ /* Now no dot; do this by fours (where safe) */ for (; c<=clast-3; c+=4, ub+=4) UBFROMUI(ub, UBTOUI(c)&0x0f0f0f0f); for (; c<=clast; c++, ub++) *ub=(uByte)(*c-'0'); num.lsd=buffer+digits-1; /* record new LSD */ } /* fits */ else { /* too long for buffer */ /* [This is a rare and unusual case; arbitrary-length input] */ /* strip leading zeros [but leave final 0 if all 0's] */ if (*cfirst=='.') cfirst++; /* step past dot at start */ if (*cfirst=='0') { /* [cfirst always -> digit] */ for (; cfirst LSD */ for (; c<=clast; c++) { /* inspect remaining chars */ if (*c!='0') { /* sticky bit needed */ if (*c=='.') continue; /* [ignore] */ *ub=DECSTICKYTAB[*ub]; /* update round-for-reround */ break; /* no need to look at more */ } } num.lsd=ub; /* record LSD */ /* adjust exponent for dropped digits */ num.exponent+=digits-(Int)(ub-buffer+1); } /* too long for buffer */ } /* digits or dot */ else { /* no digits or dot were found */ if (*c=='\0') break; /* nothing to come is bad */ /* only Infinities and NaNs are allowed, here */ buffer[0]=0; /* default a coefficient of 0 */ num.lsd=buffer; /* .. */ if (decBiStr(c, "infinity", "INFINITY") || decBiStr(c, "inf", "INF")) num.exponent=DECFLOAT_Inf; else { /* should be a NaN */ num.exponent=DECFLOAT_qNaN; /* assume quiet NaN */ if (*c=='s' || *c=='S') { /* probably an sNaN */ c++; num.exponent=DECFLOAT_sNaN; /* assume is in fact sNaN */ } if (*c!='N' && *c!='n') break; /* check caseless "NaN" */ c++; if (*c!='a' && *c!='A') break; /* .. */ c++; if (*c!='N' && *c!='n') break; /* .. */ c++; /* now either nothing, or nnnn payload (no dots), expected */ /* -> start of integer, and skip leading 0s [including plain 0] */ for (cfirst=c; *cfirst=='0';) cfirst++; if (*cfirst!='\0') { /* not empty or all-0, payload */ /* payload found; check all valid digits and copy to buffer as bcd8 */ ub=buffer; for (c=cfirst;; c++, ub++) { if ((unsigned)(*c-'0')>9) break; /* quit if not 0-9 */ if (c-cfirst==DECPMAX-1) break; /* too many digits */ *ub=(uByte)(*c-'0'); /* good bcd8 */ } if (*c!='\0') break; /* not all digits, or too many */ num.lsd=ub-1; /* record new LSD */ } } /* NaN or sNaN */ error=0; /* syntax is OK */ break; /* done with specials */ } /* digits=0 (special expected) */ break; } /* [for(;;) break] */ /* decShowNum(&num, "fromStr"); */ if (error!=0) { set->status|=error; num.exponent=DECFLOAT_qNaN; /* set up quiet NaN */ num.sign=0; /* .. with 0 sign */ buffer[0]=0; /* .. and coefficient */ num.lsd=buffer; /* .. */ /* decShowNum(&num, "oops"); */ } /* decShowNum(&num, "dffs"); */ decFinalize(result, &num, set); /* round, check, and lay out */ /* decFloatShow(result, "fromString"); */ return result; } /* decFloatFromString */ /* ------------------------------------------------------------------ */ /* decFloatFromWider -- conversion from next-wider format */ /* */ /* result is the decFloat format number which gets the result of */ /* the conversion */ /* wider is the decFloatWider format number which will be narrowed */ /* set is the context */ /* returns result */ /* */ /* Narrowing can cause rounding, overflow, etc., but not Invalid */ /* operation (sNaNs are copied and do not signal). */ /* ------------------------------------------------------------------ */ /* narrow-to is not possible for decQuad format numbers; simply omit */ #if !QUAD decFloat * decFloatFromWider(decFloat *result, const decFloatWider *wider, decContext *set) { bcdnum num; /* collects data for finishing */ uByte bcdar[DECWPMAX]; /* room for wider coefficient */ uInt widerhi=DFWWORD(wider, 0); /* top word */ Int exp; GETWCOEFF(wider, bcdar); num.msd=bcdar; /* MSD is here always */ num.lsd=bcdar+DECWPMAX-1; /* LSD is here always */ num.sign=widerhi&0x80000000; /* extract sign [DECFLOAT_Sign=Neg] */ /* decode the wider combination field to exponent */ exp=DECCOMBWEXP[widerhi>>26]; /* decode from wider combination field */ /* if it is a special there's nothing to do unless sNaN; if it's */ /* finite then add the (wider) exponent continuation and unbias */ if (EXPISSPECIAL(exp)) exp=widerhi&0x7e000000; /* include sNaN selector */ else exp+=GETWECON(wider)-DECWBIAS; num.exponent=exp; /* decShowNum(&num, "dffw"); */ return decFinalize(result, &num, set);/* round, check, and lay out */ } /* decFloatFromWider */ #endif /* ------------------------------------------------------------------ */ /* decFloatGetCoefficient -- get coefficient as BCD8 */ /* */ /* df is the decFloat from which to extract the coefficient */ /* bcdar is where DECPMAX bytes will be written, one BCD digit in */ /* each byte (BCD8 encoding); if df is a NaN the first byte will */ /* be zero, and if it is infinite they will all be zero */ /* returns the sign of the coefficient (DECFLOAT_Sign if negative, */ /* 0 otherwise) */ /* */ /* No error is possible, and no status will be set. If df is a */ /* special value the array is set to zeros (for Infinity) or to the */ /* payload of a qNaN or sNaN. */ /* ------------------------------------------------------------------ */ Int decFloatGetCoefficient(const decFloat *df, uByte *bcdar) { if (DFISINF(df)) memset(bcdar, 0, DECPMAX); else { GETCOEFF(df, bcdar); /* use macro */ if (DFISNAN(df)) bcdar[0]=0; /* MSD needs correcting */ } return DFISSIGNED(df); } /* decFloatGetCoefficient */ /* ------------------------------------------------------------------ */ /* decFloatGetExponent -- get unbiased exponent */ /* */ /* df is the decFloat from which to extract the exponent */ /* returns the exponent, q. */ /* */ /* No error is possible, and no status will be set. If df is a */ /* special value the first seven bits of the decFloat are returned, */ /* left adjusted and with the first (sign) bit set to 0 (followed by */ /* 25 0 bits). e.g., -sNaN would return 0x7e000000 (DECFLOAT_sNaN). */ /* ------------------------------------------------------------------ */ Int decFloatGetExponent(const decFloat *df) { if (DFISSPECIAL(df)) return DFWORD(df, 0)&0x7e000000; return GETEXPUN(df); } /* decFloatGetExponent */ /* ------------------------------------------------------------------ */ /* decFloatSetCoefficient -- set coefficient from BCD8 */ /* */ /* df is the target decFloat (and source of exponent/special value) */ /* bcdar holds DECPMAX digits to set the coefficient from, one */ /* digit in each byte (BCD8 encoding); the first (MSD) is ignored */ /* if df is a NaN; all are ignored if df is infinite. */ /* sig is DECFLOAT_Sign to set the sign bit, 0 otherwise */ /* returns df, which will be canonical */ /* */ /* No error is possible, and no status will be set. */ /* ------------------------------------------------------------------ */ decFloat * decFloatSetCoefficient(decFloat *df, const uByte *bcdar, Int sig) { uInt exp; /* for exponent */ uByte bcdzero[DECPMAX]; /* for infinities */ /* Exponent/special code is extracted from df */ if (DFISSPECIAL(df)) { exp=DFWORD(df, 0)&0x7e000000; if (DFISINF(df)) { memset(bcdzero, 0, DECPMAX); return decFloatFromBCD(df, exp, bcdzero, sig); } } else exp=GETEXPUN(df); return decFloatFromBCD(df, exp, bcdar, sig); } /* decFloatSetCoefficient */ /* ------------------------------------------------------------------ */ /* decFloatSetExponent -- set exponent or special value */ /* */ /* df is the target decFloat (and source of coefficient/payload) */ /* set is the context for reporting status */ /* exp is the unbiased exponent, q, or a special value in the form */ /* returned by decFloatGetExponent */ /* returns df, which will be canonical */ /* */ /* No error is possible, but Overflow or Underflow might occur. */ /* ------------------------------------------------------------------ */ decFloat * decFloatSetExponent(decFloat *df, decContext *set, Int exp) { uByte bcdcopy[DECPMAX]; /* for coefficient */ bcdnum num; /* work */ num.exponent=exp; num.sign=decFloatGetCoefficient(df, bcdcopy); /* extract coefficient */ if (DFISSPECIAL(df)) { /* MSD or more needs correcting */ if (DFISINF(df)) memset(bcdcopy, 0, DECPMAX); bcdcopy[0]=0; } num.msd=bcdcopy; num.lsd=bcdcopy+DECPMAX-1; return decFinalize(df, &num, set); } /* decFloatSetExponent */ /* ------------------------------------------------------------------ */ /* decFloatRadix -- returns the base (10) */ /* */ /* df is any decFloat of this format */ /* ------------------------------------------------------------------ */ uInt decFloatRadix(const decFloat *df) { if (df) return 10; /* to placate compiler */ return 10; } /* decFloatRadix */ #if (DECCHECK || DECTRACE) /* ------------------------------------------------------------------ */ /* decFloatShow -- printf a decFloat in hexadecimal and decimal */ /* df is the decFloat to show */ /* tag is a tag string displayed with the number */ /* */ /* This is a debug aid; the precise format of the string may change. */ /* ------------------------------------------------------------------ */ void decFloatShow(const decFloat *df, const char *tag) { char hexbuf[DECBYTES*2+DECBYTES/4+1]; /* NB blank after every fourth */ char buff[DECSTRING]; /* for value in decimal */ Int i, j=0; for (i=0; ibytes[DECBYTES-1-i]); #else sprintf(&hexbuf[j], "%02x", df->bytes[i]); #endif j+=2; /* the next line adds blank (and terminator) after final pair, too */ if ((i+1)%4==0) {strcpy(&hexbuf[j], " "); j++;} } decFloatToString(df, buff); printf(">%s> %s [big-endian] %s\n", tag, hexbuf, buff); return; } /* decFloatShow */ #endif /* ------------------------------------------------------------------ */ /* decFloatToBCD -- get sign, exponent, and BCD8 from a decFloat */ /* */ /* df is the source decFloat */ /* exp will be set to the unbiased exponent, q, or to a special */ /* value in the form returned by decFloatGetExponent */ /* bcdar is where DECPMAX bytes will be written, one BCD digit in */ /* each byte (BCD8 encoding); if df is a NaN the first byte will */ /* be zero, and if it is infinite they will all be zero */ /* returns the sign of the coefficient (DECFLOAT_Sign if negative, */ /* 0 otherwise) */ /* */ /* No error is possible, and no status will be set. */ /* ------------------------------------------------------------------ */ Int decFloatToBCD(const decFloat *df, Int *exp, uByte *bcdar) { if (DFISINF(df)) { memset(bcdar, 0, DECPMAX); *exp=DFWORD(df, 0)&0x7e000000; } else { GETCOEFF(df, bcdar); /* use macro */ if (DFISNAN(df)) { bcdar[0]=0; /* MSD needs correcting */ *exp=DFWORD(df, 0)&0x7e000000; } else { /* finite */ *exp=GETEXPUN(df); } } return DFISSIGNED(df); } /* decFloatToBCD */ /* ------------------------------------------------------------------ */ /* decFloatToEngString -- conversion to numeric string, engineering */ /* */ /* df is the decFloat format number to convert */ /* string is the string where the result will be laid out */ /* */ /* string must be at least DECPMAX+9 characters (the worst case is */ /* "-0.00000nnn...nnn\0", which is as long as the exponent form when */ /* DECEMAXD<=4); this condition is asserted above */ /* */ /* No error is possible, and no status will be set */ /* ------------------------------------------------------------------ */ char * decFloatToEngString(const decFloat *df, char *string){ uInt msd; /* coefficient MSD */ Int exp; /* exponent top two bits or full */ uInt comb; /* combination field */ char *cstart; /* coefficient start */ char *c; /* output pointer in string */ char *s, *t; /* .. (source, target) */ Int pre, e; /* work */ const uByte *u; /* .. */ uInt uiwork; /* for macros [one compiler needs */ /* volatile here to avoid bug, but */ /* that doubles execution time] */ /* Source words; macro handles endianness */ uInt sourhi=DFWORD(df, 0); /* word with sign */ #if DECPMAX==16 uInt sourlo=DFWORD(df, 1); #elif DECPMAX==34 uInt sourmh=DFWORD(df, 1); uInt sourml=DFWORD(df, 2); uInt sourlo=DFWORD(df, 3); #endif c=string; /* where result will go */ if (((Int)sourhi)<0) *c++='-'; /* handle sign */ comb=sourhi>>26; /* sign+combination field */ msd=DECCOMBMSD[comb]; /* decode the combination field */ exp=DECCOMBEXP[comb]; /* .. */ if (EXPISSPECIAL(exp)) { /* special */ if (exp==DECFLOAT_Inf) { /* infinity */ strcpy(c, "Inf"); strcpy(c+3, "inity"); return string; /* easy */ } if (sourhi&0x02000000) *c++='s'; /* sNaN */ strcpy(c, "NaN"); /* complete word */ c+=3; /* step past */ /* quick exit if the payload is zero */ #if DECPMAX==7 if ((sourhi&0x000fffff)==0) return string; #elif DECPMAX==16 if (sourlo==0 && (sourhi&0x0003ffff)==0) return string; #elif DECPMAX==34 if (sourlo==0 && sourml==0 && sourmh==0 && (sourhi&0x00003fff)==0) return string; #endif /* otherwise drop through to add integer; set correct exp etc. */ exp=0; msd=0; /* setup for following code */ } else { /* complete exponent; top two bits are in place */ exp+=GETECON(df)-DECBIAS; /* .. + continuation and unbias */ } /* convert the digits of the significand to characters */ cstart=c; /* save start of coefficient */ if (msd) *c++=(char)('0'+(char)msd); /* non-zero most significant digit */ /* Decode the declets. After extracting each declet, it is */ /* decoded to a 4-uByte sequence by table lookup; the four uBytes */ /* are the three encoded BCD8 digits followed by a 1-byte length */ /* (significant digits, except that 000 has length 0). This allows */ /* us to left-align the first declet with non-zero content, then */ /* the remaining ones are full 3-char length. Fixed-length copies */ /* are used because variable-length memcpy causes a subroutine call */ /* in at least two compilers. (The copies are length 4 for speed */ /* and are safe because the last item in the array is of length */ /* three and has the length byte following.) */ #define dpd2char(dpdin) u=&DPD2BCD8[((dpdin)&0x3ff)*4]; \ if (c!=cstart) {UBFROMUI(c, UBTOUI(u)|CHARMASK); c+=3;} \ else if (*(u+3)) { \ UBFROMUI(c, UBTOUI(u+3-*(u+3))|CHARMASK); c+=*(u+3);} #if DECPMAX==7 dpd2char(sourhi>>10); /* declet 1 */ dpd2char(sourhi); /* declet 2 */ #elif DECPMAX==16 dpd2char(sourhi>>8); /* declet 1 */ dpd2char((sourhi<<2) | (sourlo>>30)); /* declet 2 */ dpd2char(sourlo>>20); /* declet 3 */ dpd2char(sourlo>>10); /* declet 4 */ dpd2char(sourlo); /* declet 5 */ #elif DECPMAX==34 dpd2char(sourhi>>4); /* declet 1 */ dpd2char((sourhi<<6) | (sourmh>>26)); /* declet 2 */ dpd2char(sourmh>>16); /* declet 3 */ dpd2char(sourmh>>6); /* declet 4 */ dpd2char((sourmh<<4) | (sourml>>28)); /* declet 5 */ dpd2char(sourml>>18); /* declet 6 */ dpd2char(sourml>>8); /* declet 7 */ dpd2char((sourml<<2) | (sourlo>>30)); /* declet 8 */ dpd2char(sourlo>>20); /* declet 9 */ dpd2char(sourlo>>10); /* declet 10 */ dpd2char(sourlo); /* declet 11 */ #endif if (c==cstart) *c++='0'; /* all zeros, empty -- make "0" */ if (exp==0) { /* integer or NaN case -- easy */ *c='\0'; /* terminate */ return string; } /* non-0 exponent */ e=0; /* assume no E */ pre=(Int)(c-cstart)+exp; /* length+exp [c->LSD+1] */ /* [here, pre-exp is the digits count (==1 for zero)] */ if (exp>0 || pre<-5) { /* need exponential form */ e=pre-1; /* calculate E value */ pre=1; /* assume one digit before '.' */ if (e!=0) { /* engineering: may need to adjust */ Int adj; /* adjustment */ /* The C remainder operator is undefined for negative numbers, so */ /* a positive remainder calculation must be used here */ if (e<0) { adj=(-e)%3; if (adj!=0) adj=3-adj; } else { /* e>0 */ adj=e%3; } e=e-adj; /* if dealing with zero still produce an exponent which is a */ /* multiple of three, as expected, but there will only be the */ /* one zero before the E, still. Otherwise note the padding. */ if (!DFISZERO(df)) pre+=adj; else { /* is zero */ if (adj!=0) { /* 0.00Esnn needed */ e=e+3; pre=-(2-adj); } } /* zero */ } /* engineering adjustment */ } /* exponential form */ /* printf("e=%ld pre=%ld exp=%ld\n", (LI)e, (LI)pre, (LI)exp); */ /* modify the coefficient, adding 0s, '.', and E+nn as needed */ if (pre>0) { /* ddd.ddd (plain), perhaps with E */ /* or dd00 padding for engineering */ char *dotat=cstart+pre; if (dotat=dotat; s-=4, t-=4) UBFROMUI(t, UBTOUI(s)); *dotat='.'; c++; /* length increased by one */ } /* need dot? */ else for (; c0 */ else { /* -5<=pre<=0: here for plain 0.ddd or 0.000ddd forms (may have E, but only for 0.00E+3 kind of case -- with plenty of spare space in this case */ pre=-pre+2; /* gap width, including "0." */ t=cstart+ROUNDDOWN4(c-cstart)+pre; /* preferred first target point */ /* backoff if too far to the right */ if (t>string+DECSTRING-5) t=string+DECSTRING-5; /* adjust to fit */ /* now shift the entire coefficient to the right, being careful not */ /* to access to the left of string [cannot use memcpy] */ for (s=t-pre; s>=string; s-=4, t-=4) UBFROMUI(t, UBTOUI(s)); /* for Quads and Singles there may be a character or two left... */ s+=3; /* where next would come from */ for(; s>=cstart; s--, t--) *(t+3)=*(s); /* now have fill 0. through 0.00000; use overlaps to avoid tests */ if (pre>=4) { memcpy(cstart+pre-4, "0000", 4); memcpy(cstart, "0.00", 4); } else { /* 2 or 3 */ *(cstart+pre-1)='0'; memcpy(cstart, "0.", 2); } c+=pre; /* to end */ } /* finally add the E-part, if needed; it will never be 0, and has */ /* a maximum length of 3 or 4 digits (asserted above) */ if (e!=0) { memcpy(c, "E+", 2); /* starts with E, assume + */ c++; if (e<0) { *c='-'; /* oops, need '-' */ e=-e; /* uInt, please */ } c++; /* Three-character exponents are easy; 4-character a little trickier */ #if DECEMAXD<=3 u=&BIN2BCD8[e*4]; /* -> 3 digits + length byte */ /* copy fixed 4 characters [is safe], starting at non-zero */ /* and with character mask to convert BCD to char */ UBFROMUI(c, UBTOUI(u+3-*(u+3))|CHARMASK); c+=*(u+3); /* bump pointer appropriately */ #elif DECEMAXD==4 if (e<1000) { /* 3 (or fewer) digits case */ u=&BIN2BCD8[e*4]; /* -> 3 digits + length byte */ UBFROMUI(c, UBTOUI(u+3-*(u+3))|CHARMASK); /* [as above] */ c+=*(u+3); /* bump pointer appropriately */ } else { /* 4-digits */ Int thou=((e>>3)*1049)>>17; /* e/1000 */ Int rem=e-(1000*thou); /* e%1000 */ *c++=(char)('0'+(char)thou); /* the thousands digit */ u=&BIN2BCD8[rem*4]; /* -> 3 digits + length byte */ UBFROMUI(c, UBTOUI(u)|CHARMASK);/* copy fixed 3+1 characters [is safe] */ c+=3; /* bump pointer, always 3 digits */ } #endif } *c='\0'; /* terminate */ /*printf("res %s\n", string); */ return string; } /* decFloatToEngString */ /* ------------------------------------------------------------------ */ /* decFloatToPacked -- convert decFloat to Packed decimal + exponent */ /* */ /* df is the source decFloat */ /* exp will be set to the unbiased exponent, q, or to a special */ /* value in the form returned by decFloatGetExponent */ /* packed is where DECPMAX nibbles will be written with the sign as */ /* final nibble (0x0c for +, 0x0d for -); a NaN has a first nibble */ /* of zero, and an infinity is all zeros. decDouble and decQuad */ /* have a additional leading zero nibble, leading to result */ /* lengths of 4, 9, and 18 bytes. */ /* returns the sign of the coefficient (DECFLOAT_Sign if negative, */ /* 0 otherwise) */ /* */ /* No error is possible, and no status will be set. */ /* ------------------------------------------------------------------ */ Int decFloatToPacked(const decFloat *df, Int *exp, uByte *packed) { uByte bcdar[DECPMAX+2]; /* work buffer */ uByte *ip=bcdar, *op=packed; /* work pointers */ if (DFISINF(df)) { memset(bcdar, 0, DECPMAX+2); *exp=DECFLOAT_Inf; } else { GETCOEFF(df, bcdar+1); /* use macro */ if (DFISNAN(df)) { bcdar[1]=0; /* MSD needs clearing */ *exp=DFWORD(df, 0)&0x7e000000; } else { /* finite */ *exp=GETEXPUN(df); } } /* now pack; coefficient currently at bcdar+1 */ #if SINGLE ip++; /* ignore first byte */ #else *ip=0; /* need leading zero */ #endif /* set final byte to Packed BCD sign value */ bcdar[DECPMAX+1]=(DFISSIGNED(df) ? DECPMINUS : DECPPLUS); /* pack an even number of bytes... */ for (; op>26; /* sign+combination field */ msd=DECCOMBMSD[comb]; /* decode the combination field */ exp=DECCOMBEXP[comb]; /* .. */ if (!EXPISSPECIAL(exp)) { /* finite */ /* complete exponent; top two bits are in place */ exp+=GETECON(df)-DECBIAS; /* .. + continuation and unbias */ } else { /* IS special */ if (exp==DECFLOAT_Inf) { /* infinity */ strcpy(c, "Infinity"); return string; /* easy */ } if (sourhi&0x02000000) *c++='s'; /* sNaN */ strcpy(c, "NaN"); /* complete word */ c+=3; /* step past */ /* quick exit if the payload is zero */ #if DECPMAX==7 if ((sourhi&0x000fffff)==0) return string; #elif DECPMAX==16 if (sourlo==0 && (sourhi&0x0003ffff)==0) return string; #elif DECPMAX==34 if (sourlo==0 && sourml==0 && sourmh==0 && (sourhi&0x00003fff)==0) return string; #endif /* otherwise drop through to add integer; set correct exp etc. */ exp=0; msd=0; /* setup for following code */ } /* convert the digits of the significand to characters */ cstart=c; /* save start of coefficient */ if (msd) *c++=(char)('0'+(char)msd); /* non-zero most significant digit */ /* Decode the declets. After extracting each declet, it is */ /* decoded to a 4-uByte sequence by table lookup; the four uBytes */ /* are the three encoded BCD8 digits followed by a 1-byte length */ /* (significant digits, except that 000 has length 0). This allows */ /* us to left-align the first declet with non-zero content, then */ /* the remaining ones are full 3-char length. Fixed-length copies */ /* are used because variable-length memcpy causes a subroutine call */ /* in at least two compilers. (The copies are length 4 for speed */ /* and are safe because the last item in the array is of length */ /* three and has the length byte following.) */ #define dpd2char(dpdin) u=&DPD2BCD8[((dpdin)&0x3ff)*4]; \ if (c!=cstart) {UBFROMUI(c, UBTOUI(u)|CHARMASK); c+=3;} \ else if (*(u+3)) { \ UBFROMUI(c, UBTOUI(u+3-*(u+3))|CHARMASK); c+=*(u+3);} #if DECPMAX==7 dpd2char(sourhi>>10); /* declet 1 */ dpd2char(sourhi); /* declet 2 */ #elif DECPMAX==16 dpd2char(sourhi>>8); /* declet 1 */ dpd2char((sourhi<<2) | (sourlo>>30)); /* declet 2 */ dpd2char(sourlo>>20); /* declet 3 */ dpd2char(sourlo>>10); /* declet 4 */ dpd2char(sourlo); /* declet 5 */ #elif DECPMAX==34 dpd2char(sourhi>>4); /* declet 1 */ dpd2char((sourhi<<6) | (sourmh>>26)); /* declet 2 */ dpd2char(sourmh>>16); /* declet 3 */ dpd2char(sourmh>>6); /* declet 4 */ dpd2char((sourmh<<4) | (sourml>>28)); /* declet 5 */ dpd2char(sourml>>18); /* declet 6 */ dpd2char(sourml>>8); /* declet 7 */ dpd2char((sourml<<2) | (sourlo>>30)); /* declet 8 */ dpd2char(sourlo>>20); /* declet 9 */ dpd2char(sourlo>>10); /* declet 10 */ dpd2char(sourlo); /* declet 11 */ #endif if (c==cstart) *c++='0'; /* all zeros, empty -- make "0" */ /*[This fast path is valid but adds 3-5 cycles to worst case length] */ /*if (exp==0) { // integer or NaN case -- easy */ /* *c='\0'; // terminate */ /* return string; */ /* } */ e=0; /* assume no E */ pre=(Int)(c-cstart)+exp; /* length+exp [c->LSD+1] */ /* [here, pre-exp is the digits count (==1 for zero)] */ if (exp>0 || pre<-5) { /* need exponential form */ e=pre-1; /* calculate E value */ pre=1; /* assume one digit before '.' */ } /* exponential form */ /* modify the coefficient, adding 0s, '.', and E+nn as needed */ if (pre>0) { /* ddd.ddd (plain), perhaps with E */ char *dotat=cstart+pre; if (dotat=dotat; s-=4, t-=4) UBFROMUI(t, UBTOUI(s)); *dotat='.'; c++; /* length increased by one */ } /* need dot? */ /* finally add the E-part, if needed; it will never be 0, and has */ /* a maximum length of 3 or 4 digits (asserted above) */ if (e!=0) { memcpy(c, "E+", 2); /* starts with E, assume + */ c++; if (e<0) { *c='-'; /* oops, need '-' */ e=-e; /* uInt, please */ } c++; /* Three-character exponents are easy; 4-character a little trickier */ #if DECEMAXD<=3 u=&BIN2BCD8[e*4]; /* -> 3 digits + length byte */ /* copy fixed 4 characters [is safe], starting at non-zero */ /* and with character mask to convert BCD to char */ UBFROMUI(c, UBTOUI(u+3-*(u+3))|CHARMASK); c+=*(u+3); /* bump pointer appropriately */ #elif DECEMAXD==4 if (e<1000) { /* 3 (or fewer) digits case */ u=&BIN2BCD8[e*4]; /* -> 3 digits + length byte */ UBFROMUI(c, UBTOUI(u+3-*(u+3))|CHARMASK); /* [as above] */ c+=*(u+3); /* bump pointer appropriately */ } else { /* 4-digits */ Int thou=((e>>3)*1049)>>17; /* e/1000 */ Int rem=e-(1000*thou); /* e%1000 */ *c++=(char)('0'+(char)thou); /* the thousands digit */ u=&BIN2BCD8[rem*4]; /* -> 3 digits + length byte */ UBFROMUI(c, UBTOUI(u)|CHARMASK); /* copy fixed 3+1 characters [is safe] */ c+=3; /* bump pointer, always 3 digits */ } #endif } *c='\0'; /* add terminator */ /*printf("res %s\n", string); */ return string; } /* pre>0 */ /* -5<=pre<=0: here for plain 0.ddd or 0.000ddd forms (can never have E) */ /* Surprisingly, this is close to being the worst-case path, so the */ /* shift is done by fours; this is a little tricky because the */ /* rightmost character to be written must not be beyond where the */ /* rightmost terminator could be -- so backoff to not touch */ /* terminator position if need be (this can make exact alignments */ /* for full Doubles, but in some cases needs care not to access too */ /* far to the left) */ pre=-pre+2; /* gap width, including "0." */ t=cstart+ROUNDDOWN4(c-cstart)+pre; /* preferred first target point */ /* backoff if too far to the right */ if (t>string+DECSTRING-5) t=string+DECSTRING-5; /* adjust to fit */ /* now shift the entire coefficient to the right, being careful not */ /* to access to the left of string [cannot use memcpy] */ for (s=t-pre; s>=string; s-=4, t-=4) UBFROMUI(t, UBTOUI(s)); /* for Quads and Singles there may be a character or two left... */ s+=3; /* where next would come from */ for(; s>=cstart; s--, t--) *(t+3)=*(s); /* now have fill 0. through 0.00000; use overlaps to avoid tests */ if (pre>=4) { memcpy(cstart+pre-4, "0000", 4); memcpy(cstart, "0.00", 4); } else { /* 2 or 3 */ *(cstart+pre-1)='0'; memcpy(cstart, "0.", 2); } *(c+pre)='\0'; /* terminate */ return string; } /* decFloatToString */ /* ------------------------------------------------------------------ */ /* decFloatToWider -- conversion to next-wider format */ /* */ /* source is the decFloat format number which gets the result of */ /* the conversion */ /* wider is the decFloatWider format number which will be narrowed */ /* returns wider */ /* */ /* Widening is always exact; no status is set (sNaNs are copied and */ /* do not signal). The result will be canonical if the source is, */ /* and may or may not be if the source is not. */ /* ------------------------------------------------------------------ */ /* widening is not possible for decQuad format numbers; simply omit */ #if !QUAD decFloatWider * decFloatToWider(const decFloat *source, decFloatWider *wider) { uInt msd; /* Construct and copy the sign word */ if (DFISSPECIAL(source)) { /* copy sign, combination, and first bit of exponent (sNaN selector) */ DFWWORD(wider, 0)=DFWORD(source, 0)&0xfe000000; msd=0; } else { /* is finite number */ uInt exp=GETEXPUN(source)+DECWBIAS; /* get unbiased exponent and rebias */ uInt code=(exp>>DECWECONL)<<29; /* set two bits of exp [msd=0] */ code|=(exp<<(32-6-DECWECONL)) & 0x03ffffff; /* add exponent continuation */ code|=DFWORD(source, 0)&0x80000000; /* add sign */ DFWWORD(wider, 0)=code; /* .. and place top word in wider */ msd=GETMSD(source); /* get source coefficient MSD [0-9] */ } /* Copy the coefficient and clear any 'unused' words to left */ #if SINGLE DFWWORD(wider, 1)=(DFWORD(source, 0)&0x000fffff)|(msd<<20); #elif DOUBLE DFWWORD(wider, 2)=(DFWORD(source, 0)&0x0003ffff)|(msd<<18); DFWWORD(wider, 3)=DFWORD(source, 1); DFWWORD(wider, 1)=0; #endif return wider; } /* decFloatToWider */ #endif /* ------------------------------------------------------------------ */ /* decFloatVersion -- return package version string */ /* */ /* returns a constant string describing this package */ /* ------------------------------------------------------------------ */ const char *decFloatVersion(void) { return DECVERSION; } /* decFloatVersion */ /* ------------------------------------------------------------------ */ /* decFloatZero -- set to canonical (integer) zero */ /* */ /* df is the decFloat format number to integer +0 (q=0, c=+0) */ /* returns df */ /* */ /* No error is possible, and no status can be set. */ /* ------------------------------------------------------------------ */ decFloat * decFloatZero(decFloat *df){ DFWORD(df, 0)=ZEROWORD; /* set appropriate top word */ #if DOUBLE || QUAD DFWORD(df, 1)=0; #if QUAD DFWORD(df, 2)=0; DFWORD(df, 3)=0; #endif #endif /* decFloatShow(df, "zero"); */ return df; } /* decFloatZero */ /* ------------------------------------------------------------------ */ /* Private generic function (not format-specific) for development use */ /* ------------------------------------------------------------------ */ /* This is included once only, for all to use */ #if QUAD && (DECCHECK || DECTRACE) /* ---------------------------------------------------------------- */ /* decShowNum -- display bcd8 number in debug form */ /* */ /* num is the bcdnum to display */ /* tag is a string to label the display */ /* ---------------------------------------------------------------- */ void decShowNum(const bcdnum *num, const char *tag) { const char *csign="+"; /* sign character */ uByte *ub; /* work */ uInt uiwork; /* for macros */ if (num->sign==DECFLOAT_Sign) csign="-"; printf(">%s> ", tag); if (num->exponent==DECFLOAT_Inf) printf("%sInfinity", csign); else if (num->exponent==DECFLOAT_qNaN) printf("%sqNaN", csign); else if (num->exponent==DECFLOAT_sNaN) printf("%ssNaN", csign); else { /* finite */ char qbuf[10]; /* for right-aligned q */ char *c; /* work */ const uByte *u; /* .. */ Int e=num->exponent; /* .. exponent */ strcpy(qbuf, "q="); c=&qbuf[2]; /* where exponent will go */ /* lay out the exponent */ if (e<0) { *c++='-'; /* add '-' */ e=-e; /* uInt, please */ } #if DECEMAXD>4 #error Exponent form is too long for ShowNum to lay out #endif if (e==0) *c++='0'; /* 0-length case */ else if (e<1000) { /* 3 (or fewer) digits case */ u=&BIN2BCD8[e*4]; /* -> 3 digits + length byte */ UBFROMUI(c, UBTOUI(u+3-*(u+3))|CHARMASK); /* [as above] */ c+=*(u+3); /* bump pointer appropriately */ } else { /* 4-digits */ Int thou=((e>>3)*1049)>>17; /* e/1000 */ Int rem=e-(1000*thou); /* e%1000 */ *c++=(char)('0'+(char)thou); /* the thousands digit */ u=&BIN2BCD8[rem*4]; /* -> 3 digits + length byte */ UBFROMUI(c, UBTOUI(u)|CHARMASK); /* copy fixed 3+1 characters [is safe] */ c+=3; /* bump pointer, always 3 digits */ } *c='\0'; /* add terminator */ printf("%7s c=%s", qbuf, csign); } if (!EXPISSPECIAL(num->exponent) || num->msd!=num->lsd || *num->lsd!=0) { for (ub=num->msd; ub<=num->lsd; ub++) { /* coefficient... */ printf("%1x", *ub); if ((num->lsd-ub)%3==0 && ub!=num->lsd) printf(" "); /* 4-space */ } } printf("\n"); } /* decShowNum */ #endif libdfp-1.0.12/libdecnumber/decContext.c000066400000000000000000000475511261375163000177520ustar00rootroot00000000000000/* Decimal context module for the decNumber C Library. Copyright (C) 2005-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------ */ /* Decimal Context module */ /* ------------------------------------------------------------------ */ /* This module comprises the routines for handling arithmetic */ /* context structures. */ /* ------------------------------------------------------------------ */ #include /* for strcmp */ #ifdef DECCHECK #include /* for printf if DECCHECK */ #endif #include "dconfig.h" /* for GCC definitions */ #include "decContext.h" /* context and base types */ #include "decNumberLocal.h" /* decNumber local types, etc. */ /* compile-time endian tester [assumes sizeof(Int)>1] */ static const Int mfcone=1; /* constant 1 */ static const Flag *mfctop=(const Flag *)&mfcone; /* -> top byte */ #define LITEND *mfctop /* named flag; 1=little-endian */ /* ------------------------------------------------------------------ */ /* round-for-reround digits */ /* ------------------------------------------------------------------ */ const uByte DECSTICKYTAB[10]={1,1,2,3,4,6,6,7,8,9}; /* used if sticky */ /* ------------------------------------------------------------------ */ /* Powers of ten (powers[n]==10**n, 0<=n<=9) */ /* ------------------------------------------------------------------ */ const uInt DECPOWERS[10]={1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000}; /* ------------------------------------------------------------------ */ /* decContextClearStatus -- clear bits in current status */ /* */ /* context is the context structure to be queried */ /* mask indicates the bits to be cleared (the status bit that */ /* corresponds to each 1 bit in the mask is cleared) */ /* returns context */ /* */ /* No error is possible. */ /* ------------------------------------------------------------------ */ decContext *decContextClearStatus(decContext *context, uInt mask) { context->status&=~mask; return context; } /* decContextClearStatus */ /* ------------------------------------------------------------------ */ /* decContextDefault -- initialize a context structure */ /* */ /* context is the structure to be initialized */ /* kind selects the required set of default values, one of: */ /* DEC_INIT_BASE -- select ANSI X3-274 defaults */ /* DEC_INIT_DECIMAL32 -- select IEEE 754 defaults, 32-bit */ /* DEC_INIT_DECIMAL64 -- select IEEE 754 defaults, 64-bit */ /* DEC_INIT_DECIMAL128 -- select IEEE 754 defaults, 128-bit */ /* For any other value a valid context is returned, but with */ /* Invalid_operation set in the status field. */ /* returns a context structure with the appropriate initial values. */ /* ------------------------------------------------------------------ */ decContext * decContextDefault(decContext *context, Int kind) { /* set defaults... */ context->digits=9; /* 9 digits */ context->emax=DEC_MAX_EMAX; /* 9-digit exponents */ context->emin=DEC_MIN_EMIN; /* .. balanced */ context->round=DEC_ROUND_HALF_UP; /* 0.5 rises */ context->traps=DEC_Errors; /* all but informational */ context->status=0; /* cleared */ context->clamp=0; /* no clamping */ #if DECSUBSET context->extended=0; /* cleared */ #endif switch (kind) { case DEC_INIT_BASE: /* [use defaults] */ break; case DEC_INIT_DECIMAL32: context->digits=7; /* digits */ context->emax=96; /* Emax */ context->emin=-95; /* Emin */ context->round=DEC_ROUND_HALF_EVEN; /* 0.5 to nearest even */ context->traps=0; /* no traps set */ context->clamp=1; /* clamp exponents */ #if DECSUBSET context->extended=1; /* set */ #endif break; case DEC_INIT_DECIMAL64: context->digits=16; /* digits */ context->emax=384; /* Emax */ context->emin=-383; /* Emin */ context->round=DEC_ROUND_HALF_EVEN; /* 0.5 to nearest even */ context->traps=0; /* no traps set */ context->clamp=1; /* clamp exponents */ #if DECSUBSET context->extended=1; /* set */ #endif break; case DEC_INIT_DECIMAL128: context->digits=34; /* digits */ context->emax=6144; /* Emax */ context->emin=-6143; /* Emin */ context->round=DEC_ROUND_HALF_EVEN; /* 0.5 to nearest even */ context->traps=0; /* no traps set */ context->clamp=1; /* clamp exponents */ #if DECSUBSET context->extended=1; /* set */ #endif break; default: /* invalid Kind */ /* use defaults, and .. */ decContextSetStatus(context, DEC_Invalid_operation); /* trap */ } return context;} /* decContextDefault */ /* ------------------------------------------------------------------ */ /* decContextGetRounding -- return current rounding mode */ /* */ /* context is the context structure to be queried */ /* returns the rounding mode */ /* */ /* No error is possible. */ /* ------------------------------------------------------------------ */ enum rounding decContextGetRounding(decContext *context) { return context->round; } /* decContextGetRounding */ /* ------------------------------------------------------------------ */ /* decContextGetStatus -- return current status */ /* */ /* context is the context structure to be queried */ /* returns status */ /* */ /* No error is possible. */ /* ------------------------------------------------------------------ */ uInt decContextGetStatus(decContext *context) { return context->status; } /* decContextGetStatus */ /* ------------------------------------------------------------------ */ /* decContextRestoreStatus -- restore bits in current status */ /* */ /* context is the context structure to be updated */ /* newstatus is the source for the bits to be restored */ /* mask indicates the bits to be restored (the status bit that */ /* corresponds to each 1 bit in the mask is set to the value of */ /* the correspnding bit in newstatus) */ /* returns context */ /* */ /* No error is possible. */ /* ------------------------------------------------------------------ */ decContext *decContextRestoreStatus(decContext *context, uInt newstatus, uInt mask) { context->status&=~mask; /* clear the selected bits */ context->status|=(mask&newstatus); /* or in the new bits */ return context; } /* decContextRestoreStatus */ /* ------------------------------------------------------------------ */ /* decContextSaveStatus -- save bits in current status */ /* */ /* context is the context structure to be queried */ /* mask indicates the bits to be saved (the status bits that */ /* correspond to each 1 bit in the mask are saved) */ /* returns the AND of the mask and the current status */ /* */ /* No error is possible. */ /* ------------------------------------------------------------------ */ uInt decContextSaveStatus(decContext *context, uInt mask) { return context->status&mask; } /* decContextSaveStatus */ /* ------------------------------------------------------------------ */ /* decContextSetRounding -- set current rounding mode */ /* */ /* context is the context structure to be updated */ /* newround is the value which will replace the current mode */ /* returns context */ /* */ /* No error is possible. */ /* ------------------------------------------------------------------ */ decContext *decContextSetRounding(decContext *context, enum rounding newround) { context->round=newround; return context; } /* decContextSetRounding */ /* ------------------------------------------------------------------ */ /* decContextSetStatus -- set status and raise trap if appropriate */ /* */ /* context is the context structure to be updated */ /* status is the DEC_ exception code */ /* returns the context structure */ /* */ /* Control may never return from this routine, if there is a signal */ /* handler and it takes a long jump. */ /* ------------------------------------------------------------------ */ decContext * decContextSetStatus(decContext *context, uInt status) { context->status|=status; if (status & context->traps) raise(SIGFPE); return context;} /* decContextSetStatus */ /* ------------------------------------------------------------------ */ /* decContextSetStatusFromString -- set status from a string + trap */ /* */ /* context is the context structure to be updated */ /* string is a string exactly equal to one that might be returned */ /* by decContextStatusToString */ /* */ /* The status bit corresponding to the string is set, and a trap */ /* is raised if appropriate. */ /* */ /* returns the context structure, unless the string is equal to */ /* DEC_Condition_MU or is not recognized. In these cases NULL is */ /* returned. */ /* ------------------------------------------------------------------ */ decContext * decContextSetStatusFromString(decContext *context, const char *string) { if (strcmp(string, DEC_Condition_CS)==0) return decContextSetStatus(context, DEC_Conversion_syntax); if (strcmp(string, DEC_Condition_DZ)==0) return decContextSetStatus(context, DEC_Division_by_zero); if (strcmp(string, DEC_Condition_DI)==0) return decContextSetStatus(context, DEC_Division_impossible); if (strcmp(string, DEC_Condition_DU)==0) return decContextSetStatus(context, DEC_Division_undefined); if (strcmp(string, DEC_Condition_IE)==0) return decContextSetStatus(context, DEC_Inexact); if (strcmp(string, DEC_Condition_IS)==0) return decContextSetStatus(context, DEC_Insufficient_storage); if (strcmp(string, DEC_Condition_IC)==0) return decContextSetStatus(context, DEC_Invalid_context); if (strcmp(string, DEC_Condition_IO)==0) return decContextSetStatus(context, DEC_Invalid_operation); #if DECSUBSET if (strcmp(string, DEC_Condition_LD)==0) return decContextSetStatus(context, DEC_Lost_digits); #endif if (strcmp(string, DEC_Condition_OV)==0) return decContextSetStatus(context, DEC_Overflow); if (strcmp(string, DEC_Condition_PA)==0) return decContextSetStatus(context, DEC_Clamped); if (strcmp(string, DEC_Condition_RO)==0) return decContextSetStatus(context, DEC_Rounded); if (strcmp(string, DEC_Condition_SU)==0) return decContextSetStatus(context, DEC_Subnormal); if (strcmp(string, DEC_Condition_UN)==0) return decContextSetStatus(context, DEC_Underflow); if (strcmp(string, DEC_Condition_ZE)==0) return context; return NULL; /* Multiple status, or unknown */ } /* decContextSetStatusFromString */ /* ------------------------------------------------------------------ */ /* decContextSetStatusFromStringQuiet -- set status from a string */ /* */ /* context is the context structure to be updated */ /* string is a string exactly equal to one that might be returned */ /* by decContextStatusToString */ /* */ /* The status bit corresponding to the string is set; no trap is */ /* raised. */ /* */ /* returns the context structure, unless the string is equal to */ /* DEC_Condition_MU or is not recognized. In these cases NULL is */ /* returned. */ /* ------------------------------------------------------------------ */ decContext * decContextSetStatusFromStringQuiet(decContext *context, const char *string) { if (strcmp(string, DEC_Condition_CS)==0) return decContextSetStatusQuiet(context, DEC_Conversion_syntax); if (strcmp(string, DEC_Condition_DZ)==0) return decContextSetStatusQuiet(context, DEC_Division_by_zero); if (strcmp(string, DEC_Condition_DI)==0) return decContextSetStatusQuiet(context, DEC_Division_impossible); if (strcmp(string, DEC_Condition_DU)==0) return decContextSetStatusQuiet(context, DEC_Division_undefined); if (strcmp(string, DEC_Condition_IE)==0) return decContextSetStatusQuiet(context, DEC_Inexact); if (strcmp(string, DEC_Condition_IS)==0) return decContextSetStatusQuiet(context, DEC_Insufficient_storage); if (strcmp(string, DEC_Condition_IC)==0) return decContextSetStatusQuiet(context, DEC_Invalid_context); if (strcmp(string, DEC_Condition_IO)==0) return decContextSetStatusQuiet(context, DEC_Invalid_operation); #if DECSUBSET if (strcmp(string, DEC_Condition_LD)==0) return decContextSetStatusQuiet(context, DEC_Lost_digits); #endif if (strcmp(string, DEC_Condition_OV)==0) return decContextSetStatusQuiet(context, DEC_Overflow); if (strcmp(string, DEC_Condition_PA)==0) return decContextSetStatusQuiet(context, DEC_Clamped); if (strcmp(string, DEC_Condition_RO)==0) return decContextSetStatusQuiet(context, DEC_Rounded); if (strcmp(string, DEC_Condition_SU)==0) return decContextSetStatusQuiet(context, DEC_Subnormal); if (strcmp(string, DEC_Condition_UN)==0) return decContextSetStatusQuiet(context, DEC_Underflow); if (strcmp(string, DEC_Condition_ZE)==0) return context; return NULL; /* Multiple status, or unknown */ } /* decContextSetStatusFromStringQuiet */ /* ------------------------------------------------------------------ */ /* decContextSetStatusQuiet -- set status without trap */ /* */ /* context is the context structure to be updated */ /* status is the DEC_ exception code */ /* returns the context structure */ /* */ /* No error is possible. */ /* ------------------------------------------------------------------ */ decContext * decContextSetStatusQuiet(decContext *context, uInt status) { context->status|=status; return context;} /* decContextSetStatusQuiet */ /* ------------------------------------------------------------------ */ /* decContextStatusToString -- convert status flags to a string */ /* */ /* context is a context with valid status field */ /* */ /* returns a constant string describing the condition. If multiple */ /* (or no) flags are set, a generic constant message is returned. */ /* ------------------------------------------------------------------ */ const char *decContextStatusToString(const decContext *context) { Int status=context->status; /* test the five IEEE first, as some of the others are ambiguous when */ /* DECEXTFLAG=0 */ if (status==DEC_Invalid_operation ) return DEC_Condition_IO; if (status==DEC_Division_by_zero ) return DEC_Condition_DZ; if (status==DEC_Overflow ) return DEC_Condition_OV; if (status==DEC_Underflow ) return DEC_Condition_UN; if (status==DEC_Inexact ) return DEC_Condition_IE; if (status==DEC_Division_impossible ) return DEC_Condition_DI; if (status==DEC_Division_undefined ) return DEC_Condition_DU; if (status==DEC_Rounded ) return DEC_Condition_RO; if (status==DEC_Clamped ) return DEC_Condition_PA; if (status==DEC_Subnormal ) return DEC_Condition_SU; if (status==DEC_Conversion_syntax ) return DEC_Condition_CS; if (status==DEC_Insufficient_storage ) return DEC_Condition_IS; if (status==DEC_Invalid_context ) return DEC_Condition_IC; #if DECSUBSET if (status==DEC_Lost_digits ) return DEC_Condition_LD; #endif if (status==0 ) return DEC_Condition_ZE; return DEC_Condition_MU; /* Multiple errors */ } /* decContextStatusToString */ /* ------------------------------------------------------------------ */ /* decContextTestEndian -- test whether DECLITEND is set correctly */ /* */ /* quiet is 1 to suppress message; 0 otherwise */ /* returns 0 if DECLITEND is correct */ /* 1 if DECLITEND is incorrect and should be 1 */ /* -1 if DECLITEND is incorrect and should be 0 */ /* */ /* A message is displayed if the return value is not 0 and quiet==0. */ /* */ /* No error is possible. */ /* ------------------------------------------------------------------ */ Int decContextTestEndian(Flag quiet) { Int res=0; /* optimist */ uInt dle=(uInt)DECLITEND; /* unsign */ if (dle>1) dle=1; /* ensure 0 or 1 */ if (LITEND!=DECLITEND) { if (!quiet) { #if DECCHECK const char *adj; if (LITEND) adj="little"; else adj="big"; printf("Warning: DECLITEND is set to %d, but this computer appears to be %s-endian\n", DECLITEND, adj); #endif } res=(Int)LITEND-dle; } return res; } /* decContextTestEndian */ /* ------------------------------------------------------------------ */ /* decContextTestSavedStatus -- test bits in saved status */ /* */ /* oldstatus is the status word to be tested */ /* mask indicates the bits to be tested (the oldstatus bits that */ /* correspond to each 1 bit in the mask are tested) */ /* returns 1 if any of the tested bits are 1, or 0 otherwise */ /* */ /* No error is possible. */ /* ------------------------------------------------------------------ */ uInt decContextTestSavedStatus(uInt oldstatus, uInt mask) { return (oldstatus&mask)!=0; } /* decContextTestSavedStatus */ /* ------------------------------------------------------------------ */ /* decContextTestStatus -- test bits in current status */ /* */ /* context is the context structure to be updated */ /* mask indicates the bits to be tested (the status bits that */ /* correspond to each 1 bit in the mask are tested) */ /* returns 1 if any of the tested bits are 1, or 0 otherwise */ /* */ /* No error is possible. */ /* ------------------------------------------------------------------ */ uInt decContextTestStatus(decContext *context, uInt mask) { return (context->status&mask)!=0; } /* decContextTestStatus */ /* ------------------------------------------------------------------ */ /* decContextZeroStatus -- clear all status bits */ /* */ /* context is the context structure to be updated */ /* returns context */ /* */ /* No error is possible. */ /* ------------------------------------------------------------------ */ decContext *decContextZeroStatus(decContext *context) { context->status=0; return context; } /* decContextZeroStatus */ libdfp-1.0.12/libdecnumber/decContext.h000066400000000000000000000257631261375163000177600ustar00rootroot00000000000000/* Decimal context header module for the decNumber C Library. Copyright (C) 2005-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------ */ /* Decimal Context module header */ /* ------------------------------------------------------------------ */ /* */ /* Context variables must always have valid values: */ /* */ /* status -- [any bits may be cleared, but not set, by user] */ /* round -- must be one of the enumerated rounding modes */ /* */ /* The following variables are implied for fixed size formats (i.e., */ /* they are ignored) but should still be set correctly in case used */ /* with decNumber functions: */ /* */ /* clamp -- must be either 0 or 1 */ /* digits -- must be in the range 1 through 999999999 */ /* emax -- must be in the range 0 through 999999999 */ /* emin -- must be in the range 0 through -999999999 */ /* extended -- must be either 0 or 1 [present only if DECSUBSET] */ /* traps -- only defined bits may be set */ /* */ /* ------------------------------------------------------------------ */ #if !defined(DECCONTEXT) #define DECCONTEXT #define DECCNAME "decContext" /* Short name */ #define DECCFULLNAME "Decimal Context Descriptor" /* Verbose name */ #define DECCAUTHOR "Mike Cowlishaw" /* Who to blame */ #include "gstdint.h" /* C99 standard integers */ #include /* for printf, etc. */ #include /* for traps */ /* Extended flags setting -- set this to 0 to use only IEEE flags */ #if !defined(DECEXTFLAG) #define DECEXTFLAG 1 /* 1=enable extended flags */ #endif /* Conditional code flag -- set this to 0 for best performance */ #if !defined(DECSUBSET) #define DECSUBSET 0 /* 1=enable subset arithmetic */ #endif /* Context for operations, with associated constants */ enum rounding { DEC_ROUND_CEILING, /* round towards +infinity */ DEC_ROUND_UP, /* round away from 0 */ DEC_ROUND_HALF_UP, /* 0.5 rounds up */ DEC_ROUND_HALF_EVEN, /* 0.5 rounds to nearest even */ DEC_ROUND_HALF_DOWN, /* 0.5 rounds down */ DEC_ROUND_DOWN, /* round towards 0 (truncate) */ DEC_ROUND_FLOOR, /* round towards -infinity */ DEC_ROUND_05UP, /* round for reround */ DEC_ROUND_MAX /* enum must be less than this */ }; #define DEC_ROUND_DEFAULT DEC_ROUND_HALF_EVEN; typedef struct { int32_t digits; /* working precision */ int32_t emax; /* maximum positive exponent */ int32_t emin; /* minimum negative exponent */ enum rounding round; /* rounding mode */ uint32_t traps; /* trap-enabler flags */ uint32_t status; /* status flags */ uint8_t clamp; /* flag: apply IEEE exponent clamp */ #if DECSUBSET uint8_t extended; /* flag: special-values allowed */ #endif } decContext; /* Maxima and Minima for context settings */ #define DEC_MAX_DIGITS 999999999 #define DEC_MIN_DIGITS 1 #define DEC_MAX_EMAX 999999999 #define DEC_MIN_EMAX 0 #define DEC_MAX_EMIN 0 #define DEC_MIN_EMIN -999999999 #define DEC_MAX_MATH 999999 /* max emax, etc., for math funcs. */ /* Classifications for decimal numbers, aligned with 754 (note that */ /* 'normal' and 'subnormal' are meaningful only with a decContext */ /* or a fixed size format). */ enum decClass { DEC_CLASS_SNAN, DEC_CLASS_QNAN, DEC_CLASS_NEG_INF, DEC_CLASS_NEG_NORMAL, DEC_CLASS_NEG_SUBNORMAL, DEC_CLASS_NEG_ZERO, DEC_CLASS_POS_ZERO, DEC_CLASS_POS_SUBNORMAL, DEC_CLASS_POS_NORMAL, DEC_CLASS_POS_INF }; /* Strings for the decClasses */ #define DEC_ClassString_SN "sNaN" #define DEC_ClassString_QN "NaN" #define DEC_ClassString_NI "-Infinity" #define DEC_ClassString_NN "-Normal" #define DEC_ClassString_NS "-Subnormal" #define DEC_ClassString_NZ "-Zero" #define DEC_ClassString_PZ "+Zero" #define DEC_ClassString_PS "+Subnormal" #define DEC_ClassString_PN "+Normal" #define DEC_ClassString_PI "+Infinity" #define DEC_ClassString_UN "Invalid" /* Trap-enabler and Status flags (exceptional conditions), and */ /* their names. The top byte is reserved for internal use */ #if DECEXTFLAG /* Extended flags */ #define DEC_Conversion_syntax 0x00000001 #define DEC_Division_by_zero 0x00000002 #define DEC_Division_impossible 0x00000004 #define DEC_Division_undefined 0x00000008 #define DEC_Insufficient_storage 0x00000010 /* [when malloc fails] */ #define DEC_Inexact 0x00000020 #define DEC_Invalid_context 0x00000040 #define DEC_Invalid_operation 0x00000080 #if DECSUBSET #define DEC_Lost_digits 0x00000100 #endif #define DEC_Overflow 0x00000200 #define DEC_Clamped 0x00000400 #define DEC_Rounded 0x00000800 #define DEC_Subnormal 0x00001000 #define DEC_Underflow 0x00002000 #else /* IEEE flags only */ #define DEC_Conversion_syntax 0x00000010 #define DEC_Division_by_zero 0x00000002 #define DEC_Division_impossible 0x00000010 #define DEC_Division_undefined 0x00000010 #define DEC_Insufficient_storage 0x00000010 /* [when malloc fails] */ #define DEC_Inexact 0x00000001 #define DEC_Invalid_context 0x00000010 #define DEC_Invalid_operation 0x00000010 #if DECSUBSET #define DEC_Lost_digits 0x00000000 #endif #define DEC_Overflow 0x00000008 #define DEC_Clamped 0x00000000 #define DEC_Rounded 0x00000000 #define DEC_Subnormal 0x00000000 #define DEC_Underflow 0x00000004 #endif /* IEEE 754 groupings for the flags */ /* [DEC_Clamped, DEC_Lost_digits, DEC_Rounded, and DEC_Subnormal */ /* are not in IEEE 754] */ #define DEC_IEEE_754_Division_by_zero (DEC_Division_by_zero) #if DECSUBSET #define DEC_IEEE_754_Inexact (DEC_Inexact | DEC_Lost_digits) #else #define DEC_IEEE_754_Inexact (DEC_Inexact) #endif #define DEC_IEEE_754_Invalid_operation (DEC_Conversion_syntax | \ DEC_Division_impossible | \ DEC_Division_undefined | \ DEC_Insufficient_storage | \ DEC_Invalid_context | \ DEC_Invalid_operation) #define DEC_IEEE_754_Overflow (DEC_Overflow) #define DEC_IEEE_754_Underflow (DEC_Underflow) /* flags which are normally errors (result is qNaN, infinite, or 0) */ #define DEC_Errors (DEC_IEEE_754_Division_by_zero | \ DEC_IEEE_754_Invalid_operation | \ DEC_IEEE_754_Overflow | DEC_IEEE_754_Underflow) /* flags which cause a result to become qNaN */ #define DEC_NaNs DEC_IEEE_754_Invalid_operation /* flags which are normally for information only (finite results) */ #if DECSUBSET #define DEC_Information (DEC_Clamped | DEC_Rounded | DEC_Inexact \ | DEC_Lost_digits) #else #define DEC_Information (DEC_Clamped | DEC_Rounded | DEC_Inexact) #endif /* IEEE 854 names (for compatibility with older decNumber versions) */ #define DEC_IEEE_854_Division_by_zero DEC_IEEE_754_Division_by_zero #define DEC_IEEE_854_Inexact DEC_IEEE_754_Inexact #define DEC_IEEE_854_Invalid_operation DEC_IEEE_754_Invalid_operation #define DEC_IEEE_854_Overflow DEC_IEEE_754_Overflow #define DEC_IEEE_854_Underflow DEC_IEEE_754_Underflow /* Name strings for the exceptional conditions */ #define DEC_Condition_CS "Conversion syntax" #define DEC_Condition_DZ "Division by zero" #define DEC_Condition_DI "Division impossible" #define DEC_Condition_DU "Division undefined" #define DEC_Condition_IE "Inexact" #define DEC_Condition_IS "Insufficient storage" #define DEC_Condition_IC "Invalid context" #define DEC_Condition_IO "Invalid operation" #if DECSUBSET #define DEC_Condition_LD "Lost digits" #endif #define DEC_Condition_OV "Overflow" #define DEC_Condition_PA "Clamped" #define DEC_Condition_RO "Rounded" #define DEC_Condition_SU "Subnormal" #define DEC_Condition_UN "Underflow" #define DEC_Condition_ZE "No status" #define DEC_Condition_MU "Multiple status" #define DEC_Condition_Length 21 /* length of the longest string, */ /* including terminator */ /* Initialization descriptors, used by decContextDefault */ #define DEC_INIT_BASE 0 #define DEC_INIT_DECIMAL32 32 #define DEC_INIT_DECIMAL64 64 #define DEC_INIT_DECIMAL128 128 /* Synonyms */ #define DEC_INIT_DECSINGLE DEC_INIT_DECIMAL32 #define DEC_INIT_DECDOUBLE DEC_INIT_DECIMAL64 #define DEC_INIT_DECQUAD DEC_INIT_DECIMAL128 /* decContext routines */ #ifdef __cplusplus extern "C" { #endif extern decContext * decContextClearStatus(decContext *, uint32_t); extern decContext * decContextDefault(decContext *, int32_t); extern enum rounding decContextGetRounding(decContext *); extern uint32_t decContextGetStatus(decContext *); extern decContext * decContextRestoreStatus(decContext *, uint32_t, uint32_t); extern uint32_t decContextSaveStatus(decContext *, uint32_t); extern decContext * decContextSetRounding(decContext *, enum rounding); extern decContext * decContextSetStatus(decContext *, uint32_t); extern decContext * decContextSetStatusFromString(decContext *, const char *); extern decContext * decContextSetStatusFromStringQuiet(decContext *, const char *); extern decContext * decContextSetStatusQuiet(decContext *, uint32_t); extern const char * decContextStatusToString(const decContext *); extern int32_t decContextTestEndian(uint8_t); extern uint32_t decContextTestSavedStatus(uint32_t, uint32_t); extern uint32_t decContextTestStatus(decContext *, uint32_t); extern decContext * decContextZeroStatus(decContext *); #ifdef __cplusplus } #endif #endif libdfp-1.0.12/libdecnumber/decDPD.h000066400000000000000000002634111261375163000167350ustar00rootroot00000000000000/* Conversion lookup tables for the decNumber C Library. Copyright (C) 2007-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------------ */ /* Binary Coded Decimal and Densely Packed Decimal conversion lookup tables */ /* [Automatically generated -- do not edit. 2008.06.21] */ /* ------------------------------------------------------------------------ */ /* For details, see DPDecimal.html on the General Decimal Arithmetic page. */ /* This include file defines several DPD and BCD conversion tables: */ /* */ /* uint16_t BCD2DPD[2458]; -- BCD -> DPD (0x999 => 2457) */ /* uint16_t BIN2DPD[1000]; -- Bin -> DPD (999 => 2457) */ /* uint8_t BIN2CHAR[4001]; -- Bin -> CHAR (999 => '\3' '9' '9' '9') */ /* uint8_t BIN2BCD8[4000]; -- Bin -> bytes (999 => 9 9 9 3) */ /* uint16_t DPD2BCD[1024]; -- DPD -> BCD (0x3FF => 0x999) */ /* uint16_t DPD2BIN[1024]; -- DPD -> BIN (0x3FF => 999) */ /* uint32_t DPD2BINK[1024]; -- DPD -> BIN * 1000 (0x3FF => 999000) */ /* uint32_t DPD2BINM[1024]; -- DPD -> BIN * 1E+6 (0x3FF => 999000000) */ /* uint8_t DPD2BCD8[4096]; -- DPD -> bytes (x3FF => 9 9 9 3) */ /* */ /* In all cases the result (10 bits or 12 bits, or binary) is right-aligned */ /* in the table entry. BIN2CHAR entries are a single byte length (0 for */ /* value 0) followed by three digit characters; a trailing terminator is */ /* included to allow 4-char moves always. BIN2BCD8 and DPD2BCD8 entries */ /* are similar with the three BCD8 digits followed by a one-byte length */ /* (again, length=0 for value 0). */ /* */ /* To use a table, its name, prefixed with DEC_, must be defined with a */ /* value of 1 before this header file is included. For example: */ /* #define DEC_BCD2DPD 1 */ /* This mechanism allows software to only include tables that are needed. */ /* ------------------------------------------------------------------------ */ #if defined(DEC_BCD2DPD) && DEC_BCD2DPD==1 && !defined(DECBCD2DPD) #define DECBCD2DPD #ifdef __cplusplus extern "C" { #endif const uint16_t BCD2DPD[2458]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 0, 0, 0, 0, 0, 0, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 0, 0, 0, 0, 0, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 0, 0, 0, 0, 0, 0, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 0, 0, 0, 0, 0, 0, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 0, 0, 0, 0, 0, 0, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 0, 0, 0, 0, 0, 0, 10, 11, 42, 43, 74, 75, 106, 107, 78, 79, 0, 0, 0, 0, 0, 0, 26, 27, 58, 59, 90, 91, 122, 123, 94, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 0, 0, 0, 0, 0, 0, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 0, 0, 0, 0, 0, 0, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 0, 0, 0, 0, 0, 0, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 0, 0, 0, 0, 0, 0, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 0, 0, 0, 0, 0, 0, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 0, 0, 0, 0, 0, 0, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 0, 0, 0, 0, 0, 0, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 0, 0, 0, 0, 0, 0, 138, 139, 170, 171, 202, 203, 234, 235, 206, 207, 0, 0, 0, 0, 0, 0, 154, 155, 186, 187, 218, 219, 250, 251, 222, 223, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 0, 0, 0, 0, 0, 0, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 0, 0, 0, 0, 0, 0, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 0, 0, 0, 0, 0, 0, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 0, 0, 0, 0, 0, 0, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 0, 0, 0, 0, 0, 0, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 0, 0, 0, 0, 0, 0, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 0, 0, 0, 0, 0, 0, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 0, 0, 0, 0, 0, 0, 266, 267, 298, 299, 330, 331, 362, 363, 334, 335, 0, 0, 0, 0, 0, 0, 282, 283, 314, 315, 346, 347, 378, 379, 350, 351, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 0, 0, 0, 0, 0, 0, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 0, 0, 0, 0, 0, 0, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 0, 0, 0, 0, 0, 0, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 0, 0, 0, 0, 0, 0, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 0, 0, 0, 0, 0, 0, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 0, 0, 0, 0, 0, 0, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 0, 0, 0, 0, 0, 0, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 0, 0, 0, 0, 0, 0, 394, 395, 426, 427, 458, 459, 490, 491, 462, 463, 0, 0, 0, 0, 0, 0, 410, 411, 442, 443, 474, 475, 506, 507, 478, 479, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 0, 0, 0, 0, 0, 0, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 0, 0, 0, 0, 0, 0, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 0, 0, 0, 0, 0, 0, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 0, 0, 0, 0, 0, 0, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 0, 0, 0, 0, 0, 0, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 0, 0, 0, 0, 0, 0, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 0, 0, 0, 0, 0, 0, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 0, 0, 0, 0, 0, 0, 522, 523, 554, 555, 586, 587, 618, 619, 590, 591, 0, 0, 0, 0, 0, 0, 538, 539, 570, 571, 602, 603, 634, 635, 606, 607, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 0, 0, 0, 0, 0, 0, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 0, 0, 0, 0, 0, 0, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 0, 0, 0, 0, 0, 0, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 0, 0, 0, 0, 0, 0, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 0, 0, 0, 0, 0, 0, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 0, 0, 0, 0, 0, 0, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 0, 0, 0, 0, 0, 0, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 0, 0, 0, 0, 0, 0, 650, 651, 682, 683, 714, 715, 746, 747, 718, 719, 0, 0, 0, 0, 0, 0, 666, 667, 698, 699, 730, 731, 762, 763, 734, 735, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 0, 0, 0, 0, 0, 0, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 0, 0, 0, 0, 0, 0, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 0, 0, 0, 0, 0, 0, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 0, 0, 0, 0, 0, 0, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 0, 0, 0, 0, 0, 0, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 0, 0, 0, 0, 0, 0, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 0, 0, 0, 0, 0, 0, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 0, 0, 0, 0, 0, 0, 778, 779, 810, 811, 842, 843, 874, 875, 846, 847, 0, 0, 0, 0, 0, 0, 794, 795, 826, 827, 858, 859, 890, 891, 862, 863, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 0, 0, 0, 0, 0, 0, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 0, 0, 0, 0, 0, 0, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 0, 0, 0, 0, 0, 0, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 0, 0, 0, 0, 0, 0, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 0, 0, 0, 0, 0, 0, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 0, 0, 0, 0, 0, 0, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 0, 0, 0, 0, 0, 0, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 0, 0, 0, 0, 0, 0, 906, 907, 938, 939, 970, 971, 1002, 1003, 974, 975, 0, 0, 0, 0, 0, 0, 922, 923, 954, 955, 986, 987, 1018, 1019, 990, 991, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 268, 269, 524, 525, 780, 781, 46, 47, 0, 0, 0, 0, 0, 0, 28, 29, 284, 285, 540, 541, 796, 797, 62, 63, 0, 0, 0, 0, 0, 0, 44, 45, 300, 301, 556, 557, 812, 813, 302, 303, 0, 0, 0, 0, 0, 0, 60, 61, 316, 317, 572, 573, 828, 829, 318, 319, 0, 0, 0, 0, 0, 0, 76, 77, 332, 333, 588, 589, 844, 845, 558, 559, 0, 0, 0, 0, 0, 0, 92, 93, 348, 349, 604, 605, 860, 861, 574, 575, 0, 0, 0, 0, 0, 0, 108, 109, 364, 365, 620, 621, 876, 877, 814, 815, 0, 0, 0, 0, 0, 0, 124, 125, 380, 381, 636, 637, 892, 893, 830, 831, 0, 0, 0, 0, 0, 0, 14, 15, 270, 271, 526, 527, 782, 783, 110, 111, 0, 0, 0, 0, 0, 0, 30, 31, 286, 287, 542, 543, 798, 799, 126, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 140, 141, 396, 397, 652, 653, 908, 909, 174, 175, 0, 0, 0, 0, 0, 0, 156, 157, 412, 413, 668, 669, 924, 925, 190, 191, 0, 0, 0, 0, 0, 0, 172, 173, 428, 429, 684, 685, 940, 941, 430, 431, 0, 0, 0, 0, 0, 0, 188, 189, 444, 445, 700, 701, 956, 957, 446, 447, 0, 0, 0, 0, 0, 0, 204, 205, 460, 461, 716, 717, 972, 973, 686, 687, 0, 0, 0, 0, 0, 0, 220, 221, 476, 477, 732, 733, 988, 989, 702, 703, 0, 0, 0, 0, 0, 0, 236, 237, 492, 493, 748, 749, 1004, 1005, 942, 943, 0, 0, 0, 0, 0, 0, 252, 253, 508, 509, 764, 765, 1020, 1021, 958, 959, 0, 0, 0, 0, 0, 0, 142, 143, 398, 399, 654, 655, 910, 911, 238, 239, 0, 0, 0, 0, 0, 0, 158, 159, 414, 415, 670, 671, 926, 927, 254, 255}; #endif #if defined(DEC_DPD2BCD) && DEC_DPD2BCD==1 && !defined(DECDPD2BCD) #define DECDPD2BCD const uint16_t DPD2BCD[1024]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 128, 129, 2048, 2049, 2176, 2177, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 144, 145, 2064, 2065, 2192, 2193, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 130, 131, 2080, 2081, 2056, 2057, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 146, 147, 2096, 2097, 2072, 2073, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 132, 133, 2112, 2113, 136, 137, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 148, 149, 2128, 2129, 152, 153, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 134, 135, 2144, 2145, 2184, 2185, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 150, 151, 2160, 2161, 2200, 2201, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 384, 385, 2304, 2305, 2432, 2433, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 400, 401, 2320, 2321, 2448, 2449, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 386, 387, 2336, 2337, 2312, 2313, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 402, 403, 2352, 2353, 2328, 2329, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 388, 389, 2368, 2369, 392, 393, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 404, 405, 2384, 2385, 408, 409, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 390, 391, 2400, 2401, 2440, 2441, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 406, 407, 2416, 2417, 2456, 2457, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 640, 641, 2050, 2051, 2178, 2179, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 656, 657, 2066, 2067, 2194, 2195, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 642, 643, 2082, 2083, 2088, 2089, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 658, 659, 2098, 2099, 2104, 2105, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 644, 645, 2114, 2115, 648, 649, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 660, 661, 2130, 2131, 664, 665, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 646, 647, 2146, 2147, 2184, 2185, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 662, 663, 2162, 2163, 2200, 2201, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 896, 897, 2306, 2307, 2434, 2435, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 912, 913, 2322, 2323, 2450, 2451, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 898, 899, 2338, 2339, 2344, 2345, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 914, 915, 2354, 2355, 2360, 2361, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 900, 901, 2370, 2371, 904, 905, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 916, 917, 2386, 2387, 920, 921, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 902, 903, 2402, 2403, 2440, 2441, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 918, 919, 2418, 2419, 2456, 2457, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1152, 1153, 2052, 2053, 2180, 2181, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1168, 1169, 2068, 2069, 2196, 2197, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1154, 1155, 2084, 2085, 2120, 2121, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1170, 1171, 2100, 2101, 2136, 2137, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1156, 1157, 2116, 2117, 1160, 1161, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1172, 1173, 2132, 2133, 1176, 1177, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1158, 1159, 2148, 2149, 2184, 2185, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1174, 1175, 2164, 2165, 2200, 2201, 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1408, 1409, 2308, 2309, 2436, 2437, 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1424, 1425, 2324, 2325, 2452, 2453, 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, 1321, 1410, 1411, 2340, 2341, 2376, 2377, 1328, 1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1426, 1427, 2356, 2357, 2392, 2393, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351, 1352, 1353, 1412, 1413, 2372, 2373, 1416, 1417, 1360, 1361, 1362, 1363, 1364, 1365, 1366, 1367, 1368, 1369, 1428, 1429, 2388, 2389, 1432, 1433, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1414, 1415, 2404, 2405, 2440, 2441, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1430, 1431, 2420, 2421, 2456, 2457, 1536, 1537, 1538, 1539, 1540, 1541, 1542, 1543, 1544, 1545, 1664, 1665, 2054, 2055, 2182, 2183, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1680, 1681, 2070, 2071, 2198, 2199, 1568, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1666, 1667, 2086, 2087, 2152, 2153, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593, 1682, 1683, 2102, 2103, 2168, 2169, 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1668, 1669, 2118, 2119, 1672, 1673, 1616, 1617, 1618, 1619, 1620, 1621, 1622, 1623, 1624, 1625, 1684, 1685, 2134, 2135, 1688, 1689, 1632, 1633, 1634, 1635, 1636, 1637, 1638, 1639, 1640, 1641, 1670, 1671, 2150, 2151, 2184, 2185, 1648, 1649, 1650, 1651, 1652, 1653, 1654, 1655, 1656, 1657, 1686, 1687, 2166, 2167, 2200, 2201, 1792, 1793, 1794, 1795, 1796, 1797, 1798, 1799, 1800, 1801, 1920, 1921, 2310, 2311, 2438, 2439, 1808, 1809, 1810, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1936, 1937, 2326, 2327, 2454, 2455, 1824, 1825, 1826, 1827, 1828, 1829, 1830, 1831, 1832, 1833, 1922, 1923, 2342, 2343, 2408, 2409, 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847, 1848, 1849, 1938, 1939, 2358, 2359, 2424, 2425, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1924, 1925, 2374, 2375, 1928, 1929, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1940, 1941, 2390, 2391, 1944, 1945, 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1926, 1927, 2406, 2407, 2440, 2441, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1942, 1943, 2422, 2423, 2456, 2457}; #endif #if defined(DEC_BIN2DPD) && DEC_BIN2DPD==1 && !defined(DECBIN2DPD) #define DECBIN2DPD const uint16_t BIN2DPD[1000]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 10, 11, 42, 43, 74, 75, 106, 107, 78, 79, 26, 27, 58, 59, 90, 91, 122, 123, 94, 95, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 138, 139, 170, 171, 202, 203, 234, 235, 206, 207, 154, 155, 186, 187, 218, 219, 250, 251, 222, 223, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 266, 267, 298, 299, 330, 331, 362, 363, 334, 335, 282, 283, 314, 315, 346, 347, 378, 379, 350, 351, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 394, 395, 426, 427, 458, 459, 490, 491, 462, 463, 410, 411, 442, 443, 474, 475, 506, 507, 478, 479, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 522, 523, 554, 555, 586, 587, 618, 619, 590, 591, 538, 539, 570, 571, 602, 603, 634, 635, 606, 607, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 650, 651, 682, 683, 714, 715, 746, 747, 718, 719, 666, 667, 698, 699, 730, 731, 762, 763, 734, 735, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 778, 779, 810, 811, 842, 843, 874, 875, 846, 847, 794, 795, 826, 827, 858, 859, 890, 891, 862, 863, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 906, 907, 938, 939, 970, 971, 1002, 1003, 974, 975, 922, 923, 954, 955, 986, 987, 1018, 1019, 990, 991, 12, 13, 268, 269, 524, 525, 780, 781, 46, 47, 28, 29, 284, 285, 540, 541, 796, 797, 62, 63, 44, 45, 300, 301, 556, 557, 812, 813, 302, 303, 60, 61, 316, 317, 572, 573, 828, 829, 318, 319, 76, 77, 332, 333, 588, 589, 844, 845, 558, 559, 92, 93, 348, 349, 604, 605, 860, 861, 574, 575, 108, 109, 364, 365, 620, 621, 876, 877, 814, 815, 124, 125, 380, 381, 636, 637, 892, 893, 830, 831, 14, 15, 270, 271, 526, 527, 782, 783, 110, 111, 30, 31, 286, 287, 542, 543, 798, 799, 126, 127, 140, 141, 396, 397, 652, 653, 908, 909, 174, 175, 156, 157, 412, 413, 668, 669, 924, 925, 190, 191, 172, 173, 428, 429, 684, 685, 940, 941, 430, 431, 188, 189, 444, 445, 700, 701, 956, 957, 446, 447, 204, 205, 460, 461, 716, 717, 972, 973, 686, 687, 220, 221, 476, 477, 732, 733, 988, 989, 702, 703, 236, 237, 492, 493, 748, 749, 1004, 1005, 942, 943, 252, 253, 508, 509, 764, 765, 1020, 1021, 958, 959, 142, 143, 398, 399, 654, 655, 910, 911, 238, 239, 158, 159, 414, 415, 670, 671, 926, 927, 254, 255}; #endif #if defined(DEC_DPD2BIN) && DEC_DPD2BIN==1 && !defined(DECDPD2BIN) #define DECDPD2BIN const uint16_t DPD2BIN[1024]={ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 80, 81, 800, 801, 880, 881, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 90, 91, 810, 811, 890, 891, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 82, 83, 820, 821, 808, 809, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 92, 93, 830, 831, 818, 819, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 84, 85, 840, 841, 88, 89, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 94, 95, 850, 851, 98, 99, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 86, 87, 860, 861, 888, 889, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 96, 97, 870, 871, 898, 899, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 180, 181, 900, 901, 980, 981, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 190, 191, 910, 911, 990, 991, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 182, 183, 920, 921, 908, 909, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 192, 193, 930, 931, 918, 919, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 184, 185, 940, 941, 188, 189, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 194, 195, 950, 951, 198, 199, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 186, 187, 960, 961, 988, 989, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 196, 197, 970, 971, 998, 999, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 280, 281, 802, 803, 882, 883, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 290, 291, 812, 813, 892, 893, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 282, 283, 822, 823, 828, 829, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 292, 293, 832, 833, 838, 839, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 284, 285, 842, 843, 288, 289, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 294, 295, 852, 853, 298, 299, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 286, 287, 862, 863, 888, 889, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 296, 297, 872, 873, 898, 899, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 380, 381, 902, 903, 982, 983, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 390, 391, 912, 913, 992, 993, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 382, 383, 922, 923, 928, 929, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 392, 393, 932, 933, 938, 939, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 384, 385, 942, 943, 388, 389, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 394, 395, 952, 953, 398, 399, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 386, 387, 962, 963, 988, 989, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 396, 397, 972, 973, 998, 999, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 480, 481, 804, 805, 884, 885, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 490, 491, 814, 815, 894, 895, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 482, 483, 824, 825, 848, 849, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 492, 493, 834, 835, 858, 859, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 484, 485, 844, 845, 488, 489, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 494, 495, 854, 855, 498, 499, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 486, 487, 864, 865, 888, 889, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 496, 497, 874, 875, 898, 899, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 580, 581, 904, 905, 984, 985, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 590, 591, 914, 915, 994, 995, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 582, 583, 924, 925, 948, 949, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 592, 593, 934, 935, 958, 959, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 584, 585, 944, 945, 588, 589, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 594, 595, 954, 955, 598, 599, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 586, 587, 964, 965, 988, 989, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 596, 597, 974, 975, 998, 999, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 680, 681, 806, 807, 886, 887, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 690, 691, 816, 817, 896, 897, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 682, 683, 826, 827, 868, 869, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 692, 693, 836, 837, 878, 879, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 684, 685, 846, 847, 688, 689, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 694, 695, 856, 857, 698, 699, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 686, 687, 866, 867, 888, 889, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 696, 697, 876, 877, 898, 899, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 780, 781, 906, 907, 986, 987, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 790, 791, 916, 917, 996, 997, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 782, 783, 926, 927, 968, 969, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 792, 793, 936, 937, 978, 979, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 784, 785, 946, 947, 788, 789, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 794, 795, 956, 957, 798, 799, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 786, 787, 966, 967, 988, 989, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 796, 797, 976, 977, 998, 999}; #endif #if defined(DEC_DPD2BINK) && DEC_DPD2BINK==1 && !defined(DECDPD2BINK) #define DECDPD2BINK const uint32_t DPD2BINK[1024]={ 0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 80000, 81000, 800000, 801000, 880000, 881000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 90000, 91000, 810000, 811000, 890000, 891000, 20000, 21000, 22000, 23000, 24000, 25000, 26000, 27000, 28000, 29000, 82000, 83000, 820000, 821000, 808000, 809000, 30000, 31000, 32000, 33000, 34000, 35000, 36000, 37000, 38000, 39000, 92000, 93000, 830000, 831000, 818000, 819000, 40000, 41000, 42000, 43000, 44000, 45000, 46000, 47000, 48000, 49000, 84000, 85000, 840000, 841000, 88000, 89000, 50000, 51000, 52000, 53000, 54000, 55000, 56000, 57000, 58000, 59000, 94000, 95000, 850000, 851000, 98000, 99000, 60000, 61000, 62000, 63000, 64000, 65000, 66000, 67000, 68000, 69000, 86000, 87000, 860000, 861000, 888000, 889000, 70000, 71000, 72000, 73000, 74000, 75000, 76000, 77000, 78000, 79000, 96000, 97000, 870000, 871000, 898000, 899000, 100000, 101000, 102000, 103000, 104000, 105000, 106000, 107000, 108000, 109000, 180000, 181000, 900000, 901000, 980000, 981000, 110000, 111000, 112000, 113000, 114000, 115000, 116000, 117000, 118000, 119000, 190000, 191000, 910000, 911000, 990000, 991000, 120000, 121000, 122000, 123000, 124000, 125000, 126000, 127000, 128000, 129000, 182000, 183000, 920000, 921000, 908000, 909000, 130000, 131000, 132000, 133000, 134000, 135000, 136000, 137000, 138000, 139000, 192000, 193000, 930000, 931000, 918000, 919000, 140000, 141000, 142000, 143000, 144000, 145000, 146000, 147000, 148000, 149000, 184000, 185000, 940000, 941000, 188000, 189000, 150000, 151000, 152000, 153000, 154000, 155000, 156000, 157000, 158000, 159000, 194000, 195000, 950000, 951000, 198000, 199000, 160000, 161000, 162000, 163000, 164000, 165000, 166000, 167000, 168000, 169000, 186000, 187000, 960000, 961000, 988000, 989000, 170000, 171000, 172000, 173000, 174000, 175000, 176000, 177000, 178000, 179000, 196000, 197000, 970000, 971000, 998000, 999000, 200000, 201000, 202000, 203000, 204000, 205000, 206000, 207000, 208000, 209000, 280000, 281000, 802000, 803000, 882000, 883000, 210000, 211000, 212000, 213000, 214000, 215000, 216000, 217000, 218000, 219000, 290000, 291000, 812000, 813000, 892000, 893000, 220000, 221000, 222000, 223000, 224000, 225000, 226000, 227000, 228000, 229000, 282000, 283000, 822000, 823000, 828000, 829000, 230000, 231000, 232000, 233000, 234000, 235000, 236000, 237000, 238000, 239000, 292000, 293000, 832000, 833000, 838000, 839000, 240000, 241000, 242000, 243000, 244000, 245000, 246000, 247000, 248000, 249000, 284000, 285000, 842000, 843000, 288000, 289000, 250000, 251000, 252000, 253000, 254000, 255000, 256000, 257000, 258000, 259000, 294000, 295000, 852000, 853000, 298000, 299000, 260000, 261000, 262000, 263000, 264000, 265000, 266000, 267000, 268000, 269000, 286000, 287000, 862000, 863000, 888000, 889000, 270000, 271000, 272000, 273000, 274000, 275000, 276000, 277000, 278000, 279000, 296000, 297000, 872000, 873000, 898000, 899000, 300000, 301000, 302000, 303000, 304000, 305000, 306000, 307000, 308000, 309000, 380000, 381000, 902000, 903000, 982000, 983000, 310000, 311000, 312000, 313000, 314000, 315000, 316000, 317000, 318000, 319000, 390000, 391000, 912000, 913000, 992000, 993000, 320000, 321000, 322000, 323000, 324000, 325000, 326000, 327000, 328000, 329000, 382000, 383000, 922000, 923000, 928000, 929000, 330000, 331000, 332000, 333000, 334000, 335000, 336000, 337000, 338000, 339000, 392000, 393000, 932000, 933000, 938000, 939000, 340000, 341000, 342000, 343000, 344000, 345000, 346000, 347000, 348000, 349000, 384000, 385000, 942000, 943000, 388000, 389000, 350000, 351000, 352000, 353000, 354000, 355000, 356000, 357000, 358000, 359000, 394000, 395000, 952000, 953000, 398000, 399000, 360000, 361000, 362000, 363000, 364000, 365000, 366000, 367000, 368000, 369000, 386000, 387000, 962000, 963000, 988000, 989000, 370000, 371000, 372000, 373000, 374000, 375000, 376000, 377000, 378000, 379000, 396000, 397000, 972000, 973000, 998000, 999000, 400000, 401000, 402000, 403000, 404000, 405000, 406000, 407000, 408000, 409000, 480000, 481000, 804000, 805000, 884000, 885000, 410000, 411000, 412000, 413000, 414000, 415000, 416000, 417000, 418000, 419000, 490000, 491000, 814000, 815000, 894000, 895000, 420000, 421000, 422000, 423000, 424000, 425000, 426000, 427000, 428000, 429000, 482000, 483000, 824000, 825000, 848000, 849000, 430000, 431000, 432000, 433000, 434000, 435000, 436000, 437000, 438000, 439000, 492000, 493000, 834000, 835000, 858000, 859000, 440000, 441000, 442000, 443000, 444000, 445000, 446000, 447000, 448000, 449000, 484000, 485000, 844000, 845000, 488000, 489000, 450000, 451000, 452000, 453000, 454000, 455000, 456000, 457000, 458000, 459000, 494000, 495000, 854000, 855000, 498000, 499000, 460000, 461000, 462000, 463000, 464000, 465000, 466000, 467000, 468000, 469000, 486000, 487000, 864000, 865000, 888000, 889000, 470000, 471000, 472000, 473000, 474000, 475000, 476000, 477000, 478000, 479000, 496000, 497000, 874000, 875000, 898000, 899000, 500000, 501000, 502000, 503000, 504000, 505000, 506000, 507000, 508000, 509000, 580000, 581000, 904000, 905000, 984000, 985000, 510000, 511000, 512000, 513000, 514000, 515000, 516000, 517000, 518000, 519000, 590000, 591000, 914000, 915000, 994000, 995000, 520000, 521000, 522000, 523000, 524000, 525000, 526000, 527000, 528000, 529000, 582000, 583000, 924000, 925000, 948000, 949000, 530000, 531000, 532000, 533000, 534000, 535000, 536000, 537000, 538000, 539000, 592000, 593000, 934000, 935000, 958000, 959000, 540000, 541000, 542000, 543000, 544000, 545000, 546000, 547000, 548000, 549000, 584000, 585000, 944000, 945000, 588000, 589000, 550000, 551000, 552000, 553000, 554000, 555000, 556000, 557000, 558000, 559000, 594000, 595000, 954000, 955000, 598000, 599000, 560000, 561000, 562000, 563000, 564000, 565000, 566000, 567000, 568000, 569000, 586000, 587000, 964000, 965000, 988000, 989000, 570000, 571000, 572000, 573000, 574000, 575000, 576000, 577000, 578000, 579000, 596000, 597000, 974000, 975000, 998000, 999000, 600000, 601000, 602000, 603000, 604000, 605000, 606000, 607000, 608000, 609000, 680000, 681000, 806000, 807000, 886000, 887000, 610000, 611000, 612000, 613000, 614000, 615000, 616000, 617000, 618000, 619000, 690000, 691000, 816000, 817000, 896000, 897000, 620000, 621000, 622000, 623000, 624000, 625000, 626000, 627000, 628000, 629000, 682000, 683000, 826000, 827000, 868000, 869000, 630000, 631000, 632000, 633000, 634000, 635000, 636000, 637000, 638000, 639000, 692000, 693000, 836000, 837000, 878000, 879000, 640000, 641000, 642000, 643000, 644000, 645000, 646000, 647000, 648000, 649000, 684000, 685000, 846000, 847000, 688000, 689000, 650000, 651000, 652000, 653000, 654000, 655000, 656000, 657000, 658000, 659000, 694000, 695000, 856000, 857000, 698000, 699000, 660000, 661000, 662000, 663000, 664000, 665000, 666000, 667000, 668000, 669000, 686000, 687000, 866000, 867000, 888000, 889000, 670000, 671000, 672000, 673000, 674000, 675000, 676000, 677000, 678000, 679000, 696000, 697000, 876000, 877000, 898000, 899000, 700000, 701000, 702000, 703000, 704000, 705000, 706000, 707000, 708000, 709000, 780000, 781000, 906000, 907000, 986000, 987000, 710000, 711000, 712000, 713000, 714000, 715000, 716000, 717000, 718000, 719000, 790000, 791000, 916000, 917000, 996000, 997000, 720000, 721000, 722000, 723000, 724000, 725000, 726000, 727000, 728000, 729000, 782000, 783000, 926000, 927000, 968000, 969000, 730000, 731000, 732000, 733000, 734000, 735000, 736000, 737000, 738000, 739000, 792000, 793000, 936000, 937000, 978000, 979000, 740000, 741000, 742000, 743000, 744000, 745000, 746000, 747000, 748000, 749000, 784000, 785000, 946000, 947000, 788000, 789000, 750000, 751000, 752000, 753000, 754000, 755000, 756000, 757000, 758000, 759000, 794000, 795000, 956000, 957000, 798000, 799000, 760000, 761000, 762000, 763000, 764000, 765000, 766000, 767000, 768000, 769000, 786000, 787000, 966000, 967000, 988000, 989000, 770000, 771000, 772000, 773000, 774000, 775000, 776000, 777000, 778000, 779000, 796000, 797000, 976000, 977000, 998000, 999000}; #endif #if defined(DEC_DPD2BINM) && DEC_DPD2BINM==1 && !defined(DECDPD2BINM) #define DECDPD2BINM const uint32_t DPD2BINM[1024]={0, 1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 80000000, 81000000, 800000000, 801000000, 880000000, 881000000, 10000000, 11000000, 12000000, 13000000, 14000000, 15000000, 16000000, 17000000, 18000000, 19000000, 90000000, 91000000, 810000000, 811000000, 890000000, 891000000, 20000000, 21000000, 22000000, 23000000, 24000000, 25000000, 26000000, 27000000, 28000000, 29000000, 82000000, 83000000, 820000000, 821000000, 808000000, 809000000, 30000000, 31000000, 32000000, 33000000, 34000000, 35000000, 36000000, 37000000, 38000000, 39000000, 92000000, 93000000, 830000000, 831000000, 818000000, 819000000, 40000000, 41000000, 42000000, 43000000, 44000000, 45000000, 46000000, 47000000, 48000000, 49000000, 84000000, 85000000, 840000000, 841000000, 88000000, 89000000, 50000000, 51000000, 52000000, 53000000, 54000000, 55000000, 56000000, 57000000, 58000000, 59000000, 94000000, 95000000, 850000000, 851000000, 98000000, 99000000, 60000000, 61000000, 62000000, 63000000, 64000000, 65000000, 66000000, 67000000, 68000000, 69000000, 86000000, 87000000, 860000000, 861000000, 888000000, 889000000, 70000000, 71000000, 72000000, 73000000, 74000000, 75000000, 76000000, 77000000, 78000000, 79000000, 96000000, 97000000, 870000000, 871000000, 898000000, 899000000, 100000000, 101000000, 102000000, 103000000, 104000000, 105000000, 106000000, 107000000, 108000000, 109000000, 180000000, 181000000, 900000000, 901000000, 980000000, 981000000, 110000000, 111000000, 112000000, 113000000, 114000000, 115000000, 116000000, 117000000, 118000000, 119000000, 190000000, 191000000, 910000000, 911000000, 990000000, 991000000, 120000000, 121000000, 122000000, 123000000, 124000000, 125000000, 126000000, 127000000, 128000000, 129000000, 182000000, 183000000, 920000000, 921000000, 908000000, 909000000, 130000000, 131000000, 132000000, 133000000, 134000000, 135000000, 136000000, 137000000, 138000000, 139000000, 192000000, 193000000, 930000000, 931000000, 918000000, 919000000, 140000000, 141000000, 142000000, 143000000, 144000000, 145000000, 146000000, 147000000, 148000000, 149000000, 184000000, 185000000, 940000000, 941000000, 188000000, 189000000, 150000000, 151000000, 152000000, 153000000, 154000000, 155000000, 156000000, 157000000, 158000000, 159000000, 194000000, 195000000, 950000000, 951000000, 198000000, 199000000, 160000000, 161000000, 162000000, 163000000, 164000000, 165000000, 166000000, 167000000, 168000000, 169000000, 186000000, 187000000, 960000000, 961000000, 988000000, 989000000, 170000000, 171000000, 172000000, 173000000, 174000000, 175000000, 176000000, 177000000, 178000000, 179000000, 196000000, 197000000, 970000000, 971000000, 998000000, 999000000, 200000000, 201000000, 202000000, 203000000, 204000000, 205000000, 206000000, 207000000, 208000000, 209000000, 280000000, 281000000, 802000000, 803000000, 882000000, 883000000, 210000000, 211000000, 212000000, 213000000, 214000000, 215000000, 216000000, 217000000, 218000000, 219000000, 290000000, 291000000, 812000000, 813000000, 892000000, 893000000, 220000000, 221000000, 222000000, 223000000, 224000000, 225000000, 226000000, 227000000, 228000000, 229000000, 282000000, 283000000, 822000000, 823000000, 828000000, 829000000, 230000000, 231000000, 232000000, 233000000, 234000000, 235000000, 236000000, 237000000, 238000000, 239000000, 292000000, 293000000, 832000000, 833000000, 838000000, 839000000, 240000000, 241000000, 242000000, 243000000, 244000000, 245000000, 246000000, 247000000, 248000000, 249000000, 284000000, 285000000, 842000000, 843000000, 288000000, 289000000, 250000000, 251000000, 252000000, 253000000, 254000000, 255000000, 256000000, 257000000, 258000000, 259000000, 294000000, 295000000, 852000000, 853000000, 298000000, 299000000, 260000000, 261000000, 262000000, 263000000, 264000000, 265000000, 266000000, 267000000, 268000000, 269000000, 286000000, 287000000, 862000000, 863000000, 888000000, 889000000, 270000000, 271000000, 272000000, 273000000, 274000000, 275000000, 276000000, 277000000, 278000000, 279000000, 296000000, 297000000, 872000000, 873000000, 898000000, 899000000, 300000000, 301000000, 302000000, 303000000, 304000000, 305000000, 306000000, 307000000, 308000000, 309000000, 380000000, 381000000, 902000000, 903000000, 982000000, 983000000, 310000000, 311000000, 312000000, 313000000, 314000000, 315000000, 316000000, 317000000, 318000000, 319000000, 390000000, 391000000, 912000000, 913000000, 992000000, 993000000, 320000000, 321000000, 322000000, 323000000, 324000000, 325000000, 326000000, 327000000, 328000000, 329000000, 382000000, 383000000, 922000000, 923000000, 928000000, 929000000, 330000000, 331000000, 332000000, 333000000, 334000000, 335000000, 336000000, 337000000, 338000000, 339000000, 392000000, 393000000, 932000000, 933000000, 938000000, 939000000, 340000000, 341000000, 342000000, 343000000, 344000000, 345000000, 346000000, 347000000, 348000000, 349000000, 384000000, 385000000, 942000000, 943000000, 388000000, 389000000, 350000000, 351000000, 352000000, 353000000, 354000000, 355000000, 356000000, 357000000, 358000000, 359000000, 394000000, 395000000, 952000000, 953000000, 398000000, 399000000, 360000000, 361000000, 362000000, 363000000, 364000000, 365000000, 366000000, 367000000, 368000000, 369000000, 386000000, 387000000, 962000000, 963000000, 988000000, 989000000, 370000000, 371000000, 372000000, 373000000, 374000000, 375000000, 376000000, 377000000, 378000000, 379000000, 396000000, 397000000, 972000000, 973000000, 998000000, 999000000, 400000000, 401000000, 402000000, 403000000, 404000000, 405000000, 406000000, 407000000, 408000000, 409000000, 480000000, 481000000, 804000000, 805000000, 884000000, 885000000, 410000000, 411000000, 412000000, 413000000, 414000000, 415000000, 416000000, 417000000, 418000000, 419000000, 490000000, 491000000, 814000000, 815000000, 894000000, 895000000, 420000000, 421000000, 422000000, 423000000, 424000000, 425000000, 426000000, 427000000, 428000000, 429000000, 482000000, 483000000, 824000000, 825000000, 848000000, 849000000, 430000000, 431000000, 432000000, 433000000, 434000000, 435000000, 436000000, 437000000, 438000000, 439000000, 492000000, 493000000, 834000000, 835000000, 858000000, 859000000, 440000000, 441000000, 442000000, 443000000, 444000000, 445000000, 446000000, 447000000, 448000000, 449000000, 484000000, 485000000, 844000000, 845000000, 488000000, 489000000, 450000000, 451000000, 452000000, 453000000, 454000000, 455000000, 456000000, 457000000, 458000000, 459000000, 494000000, 495000000, 854000000, 855000000, 498000000, 499000000, 460000000, 461000000, 462000000, 463000000, 464000000, 465000000, 466000000, 467000000, 468000000, 469000000, 486000000, 487000000, 864000000, 865000000, 888000000, 889000000, 470000000, 471000000, 472000000, 473000000, 474000000, 475000000, 476000000, 477000000, 478000000, 479000000, 496000000, 497000000, 874000000, 875000000, 898000000, 899000000, 500000000, 501000000, 502000000, 503000000, 504000000, 505000000, 506000000, 507000000, 508000000, 509000000, 580000000, 581000000, 904000000, 905000000, 984000000, 985000000, 510000000, 511000000, 512000000, 513000000, 514000000, 515000000, 516000000, 517000000, 518000000, 519000000, 590000000, 591000000, 914000000, 915000000, 994000000, 995000000, 520000000, 521000000, 522000000, 523000000, 524000000, 525000000, 526000000, 527000000, 528000000, 529000000, 582000000, 583000000, 924000000, 925000000, 948000000, 949000000, 530000000, 531000000, 532000000, 533000000, 534000000, 535000000, 536000000, 537000000, 538000000, 539000000, 592000000, 593000000, 934000000, 935000000, 958000000, 959000000, 540000000, 541000000, 542000000, 543000000, 544000000, 545000000, 546000000, 547000000, 548000000, 549000000, 584000000, 585000000, 944000000, 945000000, 588000000, 589000000, 550000000, 551000000, 552000000, 553000000, 554000000, 555000000, 556000000, 557000000, 558000000, 559000000, 594000000, 595000000, 954000000, 955000000, 598000000, 599000000, 560000000, 561000000, 562000000, 563000000, 564000000, 565000000, 566000000, 567000000, 568000000, 569000000, 586000000, 587000000, 964000000, 965000000, 988000000, 989000000, 570000000, 571000000, 572000000, 573000000, 574000000, 575000000, 576000000, 577000000, 578000000, 579000000, 596000000, 597000000, 974000000, 975000000, 998000000, 999000000, 600000000, 601000000, 602000000, 603000000, 604000000, 605000000, 606000000, 607000000, 608000000, 609000000, 680000000, 681000000, 806000000, 807000000, 886000000, 887000000, 610000000, 611000000, 612000000, 613000000, 614000000, 615000000, 616000000, 617000000, 618000000, 619000000, 690000000, 691000000, 816000000, 817000000, 896000000, 897000000, 620000000, 621000000, 622000000, 623000000, 624000000, 625000000, 626000000, 627000000, 628000000, 629000000, 682000000, 683000000, 826000000, 827000000, 868000000, 869000000, 630000000, 631000000, 632000000, 633000000, 634000000, 635000000, 636000000, 637000000, 638000000, 639000000, 692000000, 693000000, 836000000, 837000000, 878000000, 879000000, 640000000, 641000000, 642000000, 643000000, 644000000, 645000000, 646000000, 647000000, 648000000, 649000000, 684000000, 685000000, 846000000, 847000000, 688000000, 689000000, 650000000, 651000000, 652000000, 653000000, 654000000, 655000000, 656000000, 657000000, 658000000, 659000000, 694000000, 695000000, 856000000, 857000000, 698000000, 699000000, 660000000, 661000000, 662000000, 663000000, 664000000, 665000000, 666000000, 667000000, 668000000, 669000000, 686000000, 687000000, 866000000, 867000000, 888000000, 889000000, 670000000, 671000000, 672000000, 673000000, 674000000, 675000000, 676000000, 677000000, 678000000, 679000000, 696000000, 697000000, 876000000, 877000000, 898000000, 899000000, 700000000, 701000000, 702000000, 703000000, 704000000, 705000000, 706000000, 707000000, 708000000, 709000000, 780000000, 781000000, 906000000, 907000000, 986000000, 987000000, 710000000, 711000000, 712000000, 713000000, 714000000, 715000000, 716000000, 717000000, 718000000, 719000000, 790000000, 791000000, 916000000, 917000000, 996000000, 997000000, 720000000, 721000000, 722000000, 723000000, 724000000, 725000000, 726000000, 727000000, 728000000, 729000000, 782000000, 783000000, 926000000, 927000000, 968000000, 969000000, 730000000, 731000000, 732000000, 733000000, 734000000, 735000000, 736000000, 737000000, 738000000, 739000000, 792000000, 793000000, 936000000, 937000000, 978000000, 979000000, 740000000, 741000000, 742000000, 743000000, 744000000, 745000000, 746000000, 747000000, 748000000, 749000000, 784000000, 785000000, 946000000, 947000000, 788000000, 789000000, 750000000, 751000000, 752000000, 753000000, 754000000, 755000000, 756000000, 757000000, 758000000, 759000000, 794000000, 795000000, 956000000, 957000000, 798000000, 799000000, 760000000, 761000000, 762000000, 763000000, 764000000, 765000000, 766000000, 767000000, 768000000, 769000000, 786000000, 787000000, 966000000, 967000000, 988000000, 989000000, 770000000, 771000000, 772000000, 773000000, 774000000, 775000000, 776000000, 777000000, 778000000, 779000000, 796000000, 797000000, 976000000, 977000000, 998000000, 999000000}; #endif #if defined(DEC_BIN2CHAR) && DEC_BIN2CHAR==1 && !defined(DECBIN2CHAR) #define DECBIN2CHAR const uint8_t BIN2CHAR[4001]={ '\0','0','0','0', '\1','0','0','1', '\1','0','0','2', '\1','0','0','3', '\1','0','0','4', '\1','0','0','5', '\1','0','0','6', '\1','0','0','7', '\1','0','0','8', '\1','0','0','9', '\2','0','1','0', '\2','0','1','1', '\2','0','1','2', '\2','0','1','3', '\2','0','1','4', '\2','0','1','5', '\2','0','1','6', '\2','0','1','7', '\2','0','1','8', '\2','0','1','9', '\2','0','2','0', '\2','0','2','1', '\2','0','2','2', '\2','0','2','3', '\2','0','2','4', '\2','0','2','5', '\2','0','2','6', '\2','0','2','7', '\2','0','2','8', '\2','0','2','9', '\2','0','3','0', '\2','0','3','1', '\2','0','3','2', '\2','0','3','3', '\2','0','3','4', '\2','0','3','5', '\2','0','3','6', '\2','0','3','7', '\2','0','3','8', '\2','0','3','9', '\2','0','4','0', '\2','0','4','1', '\2','0','4','2', '\2','0','4','3', '\2','0','4','4', '\2','0','4','5', '\2','0','4','6', '\2','0','4','7', '\2','0','4','8', '\2','0','4','9', '\2','0','5','0', '\2','0','5','1', '\2','0','5','2', '\2','0','5','3', '\2','0','5','4', '\2','0','5','5', '\2','0','5','6', '\2','0','5','7', '\2','0','5','8', '\2','0','5','9', '\2','0','6','0', '\2','0','6','1', '\2','0','6','2', '\2','0','6','3', '\2','0','6','4', '\2','0','6','5', '\2','0','6','6', '\2','0','6','7', '\2','0','6','8', '\2','0','6','9', '\2','0','7','0', '\2','0','7','1', '\2','0','7','2', '\2','0','7','3', '\2','0','7','4', '\2','0','7','5', '\2','0','7','6', '\2','0','7','7', '\2','0','7','8', '\2','0','7','9', '\2','0','8','0', '\2','0','8','1', '\2','0','8','2', '\2','0','8','3', '\2','0','8','4', '\2','0','8','5', '\2','0','8','6', '\2','0','8','7', '\2','0','8','8', '\2','0','8','9', '\2','0','9','0', '\2','0','9','1', '\2','0','9','2', '\2','0','9','3', '\2','0','9','4', '\2','0','9','5', '\2','0','9','6', '\2','0','9','7', '\2','0','9','8', '\2','0','9','9', '\3','1','0','0', '\3','1','0','1', '\3','1','0','2', '\3','1','0','3', '\3','1','0','4', '\3','1','0','5', '\3','1','0','6', '\3','1','0','7', '\3','1','0','8', '\3','1','0','9', '\3','1','1','0', '\3','1','1','1', '\3','1','1','2', '\3','1','1','3', '\3','1','1','4', '\3','1','1','5', '\3','1','1','6', '\3','1','1','7', '\3','1','1','8', '\3','1','1','9', '\3','1','2','0', '\3','1','2','1', '\3','1','2','2', '\3','1','2','3', '\3','1','2','4', '\3','1','2','5', '\3','1','2','6', '\3','1','2','7', '\3','1','2','8', '\3','1','2','9', '\3','1','3','0', '\3','1','3','1', '\3','1','3','2', '\3','1','3','3', '\3','1','3','4', '\3','1','3','5', '\3','1','3','6', '\3','1','3','7', '\3','1','3','8', '\3','1','3','9', '\3','1','4','0', '\3','1','4','1', '\3','1','4','2', '\3','1','4','3', '\3','1','4','4', '\3','1','4','5', '\3','1','4','6', '\3','1','4','7', '\3','1','4','8', '\3','1','4','9', '\3','1','5','0', '\3','1','5','1', '\3','1','5','2', '\3','1','5','3', '\3','1','5','4', '\3','1','5','5', '\3','1','5','6', '\3','1','5','7', '\3','1','5','8', '\3','1','5','9', '\3','1','6','0', '\3','1','6','1', '\3','1','6','2', '\3','1','6','3', '\3','1','6','4', '\3','1','6','5', '\3','1','6','6', '\3','1','6','7', '\3','1','6','8', '\3','1','6','9', '\3','1','7','0', '\3','1','7','1', '\3','1','7','2', '\3','1','7','3', '\3','1','7','4', '\3','1','7','5', '\3','1','7','6', '\3','1','7','7', '\3','1','7','8', '\3','1','7','9', '\3','1','8','0', '\3','1','8','1', '\3','1','8','2', '\3','1','8','3', '\3','1','8','4', '\3','1','8','5', '\3','1','8','6', '\3','1','8','7', '\3','1','8','8', '\3','1','8','9', '\3','1','9','0', '\3','1','9','1', '\3','1','9','2', '\3','1','9','3', '\3','1','9','4', '\3','1','9','5', '\3','1','9','6', '\3','1','9','7', '\3','1','9','8', '\3','1','9','9', '\3','2','0','0', '\3','2','0','1', '\3','2','0','2', '\3','2','0','3', '\3','2','0','4', '\3','2','0','5', '\3','2','0','6', '\3','2','0','7', '\3','2','0','8', '\3','2','0','9', '\3','2','1','0', '\3','2','1','1', '\3','2','1','2', '\3','2','1','3', '\3','2','1','4', '\3','2','1','5', '\3','2','1','6', '\3','2','1','7', '\3','2','1','8', '\3','2','1','9', '\3','2','2','0', '\3','2','2','1', '\3','2','2','2', '\3','2','2','3', '\3','2','2','4', '\3','2','2','5', '\3','2','2','6', '\3','2','2','7', '\3','2','2','8', '\3','2','2','9', '\3','2','3','0', '\3','2','3','1', '\3','2','3','2', '\3','2','3','3', '\3','2','3','4', '\3','2','3','5', '\3','2','3','6', '\3','2','3','7', '\3','2','3','8', '\3','2','3','9', '\3','2','4','0', '\3','2','4','1', '\3','2','4','2', '\3','2','4','3', '\3','2','4','4', '\3','2','4','5', '\3','2','4','6', '\3','2','4','7', '\3','2','4','8', '\3','2','4','9', '\3','2','5','0', '\3','2','5','1', '\3','2','5','2', '\3','2','5','3', '\3','2','5','4', '\3','2','5','5', '\3','2','5','6', '\3','2','5','7', '\3','2','5','8', '\3','2','5','9', '\3','2','6','0', '\3','2','6','1', '\3','2','6','2', '\3','2','6','3', '\3','2','6','4', '\3','2','6','5', '\3','2','6','6', '\3','2','6','7', '\3','2','6','8', '\3','2','6','9', '\3','2','7','0', '\3','2','7','1', '\3','2','7','2', '\3','2','7','3', '\3','2','7','4', '\3','2','7','5', '\3','2','7','6', '\3','2','7','7', '\3','2','7','8', '\3','2','7','9', '\3','2','8','0', '\3','2','8','1', '\3','2','8','2', '\3','2','8','3', '\3','2','8','4', '\3','2','8','5', '\3','2','8','6', '\3','2','8','7', '\3','2','8','8', '\3','2','8','9', '\3','2','9','0', '\3','2','9','1', '\3','2','9','2', '\3','2','9','3', '\3','2','9','4', '\3','2','9','5', '\3','2','9','6', '\3','2','9','7', '\3','2','9','8', '\3','2','9','9', '\3','3','0','0', '\3','3','0','1', '\3','3','0','2', '\3','3','0','3', '\3','3','0','4', '\3','3','0','5', '\3','3','0','6', '\3','3','0','7', '\3','3','0','8', '\3','3','0','9', '\3','3','1','0', '\3','3','1','1', '\3','3','1','2', '\3','3','1','3', '\3','3','1','4', '\3','3','1','5', '\3','3','1','6', '\3','3','1','7', '\3','3','1','8', '\3','3','1','9', '\3','3','2','0', '\3','3','2','1', '\3','3','2','2', '\3','3','2','3', '\3','3','2','4', '\3','3','2','5', '\3','3','2','6', '\3','3','2','7', '\3','3','2','8', '\3','3','2','9', '\3','3','3','0', '\3','3','3','1', '\3','3','3','2', '\3','3','3','3', '\3','3','3','4', '\3','3','3','5', '\3','3','3','6', '\3','3','3','7', '\3','3','3','8', '\3','3','3','9', '\3','3','4','0', '\3','3','4','1', '\3','3','4','2', '\3','3','4','3', '\3','3','4','4', '\3','3','4','5', '\3','3','4','6', '\3','3','4','7', '\3','3','4','8', '\3','3','4','9', '\3','3','5','0', '\3','3','5','1', '\3','3','5','2', '\3','3','5','3', '\3','3','5','4', '\3','3','5','5', '\3','3','5','6', '\3','3','5','7', '\3','3','5','8', '\3','3','5','9', '\3','3','6','0', '\3','3','6','1', '\3','3','6','2', '\3','3','6','3', '\3','3','6','4', '\3','3','6','5', '\3','3','6','6', '\3','3','6','7', '\3','3','6','8', '\3','3','6','9', '\3','3','7','0', '\3','3','7','1', '\3','3','7','2', '\3','3','7','3', '\3','3','7','4', '\3','3','7','5', '\3','3','7','6', '\3','3','7','7', '\3','3','7','8', '\3','3','7','9', '\3','3','8','0', '\3','3','8','1', '\3','3','8','2', '\3','3','8','3', '\3','3','8','4', '\3','3','8','5', '\3','3','8','6', '\3','3','8','7', '\3','3','8','8', '\3','3','8','9', '\3','3','9','0', '\3','3','9','1', '\3','3','9','2', '\3','3','9','3', '\3','3','9','4', '\3','3','9','5', '\3','3','9','6', '\3','3','9','7', '\3','3','9','8', '\3','3','9','9', '\3','4','0','0', '\3','4','0','1', '\3','4','0','2', '\3','4','0','3', '\3','4','0','4', '\3','4','0','5', '\3','4','0','6', '\3','4','0','7', '\3','4','0','8', '\3','4','0','9', '\3','4','1','0', '\3','4','1','1', '\3','4','1','2', '\3','4','1','3', '\3','4','1','4', '\3','4','1','5', '\3','4','1','6', '\3','4','1','7', '\3','4','1','8', '\3','4','1','9', '\3','4','2','0', '\3','4','2','1', '\3','4','2','2', '\3','4','2','3', '\3','4','2','4', '\3','4','2','5', '\3','4','2','6', '\3','4','2','7', '\3','4','2','8', '\3','4','2','9', '\3','4','3','0', '\3','4','3','1', '\3','4','3','2', '\3','4','3','3', '\3','4','3','4', '\3','4','3','5', '\3','4','3','6', '\3','4','3','7', '\3','4','3','8', '\3','4','3','9', '\3','4','4','0', '\3','4','4','1', '\3','4','4','2', '\3','4','4','3', '\3','4','4','4', '\3','4','4','5', '\3','4','4','6', '\3','4','4','7', '\3','4','4','8', '\3','4','4','9', '\3','4','5','0', '\3','4','5','1', '\3','4','5','2', '\3','4','5','3', '\3','4','5','4', '\3','4','5','5', '\3','4','5','6', '\3','4','5','7', '\3','4','5','8', '\3','4','5','9', '\3','4','6','0', '\3','4','6','1', '\3','4','6','2', '\3','4','6','3', '\3','4','6','4', '\3','4','6','5', '\3','4','6','6', '\3','4','6','7', '\3','4','6','8', '\3','4','6','9', '\3','4','7','0', '\3','4','7','1', '\3','4','7','2', '\3','4','7','3', '\3','4','7','4', '\3','4','7','5', '\3','4','7','6', '\3','4','7','7', '\3','4','7','8', '\3','4','7','9', '\3','4','8','0', '\3','4','8','1', '\3','4','8','2', '\3','4','8','3', '\3','4','8','4', '\3','4','8','5', '\3','4','8','6', '\3','4','8','7', '\3','4','8','8', '\3','4','8','9', '\3','4','9','0', '\3','4','9','1', '\3','4','9','2', '\3','4','9','3', '\3','4','9','4', '\3','4','9','5', '\3','4','9','6', '\3','4','9','7', '\3','4','9','8', '\3','4','9','9', '\3','5','0','0', '\3','5','0','1', '\3','5','0','2', '\3','5','0','3', '\3','5','0','4', '\3','5','0','5', '\3','5','0','6', '\3','5','0','7', '\3','5','0','8', '\3','5','0','9', '\3','5','1','0', '\3','5','1','1', '\3','5','1','2', '\3','5','1','3', '\3','5','1','4', '\3','5','1','5', '\3','5','1','6', '\3','5','1','7', '\3','5','1','8', '\3','5','1','9', '\3','5','2','0', '\3','5','2','1', '\3','5','2','2', '\3','5','2','3', '\3','5','2','4', '\3','5','2','5', '\3','5','2','6', '\3','5','2','7', '\3','5','2','8', '\3','5','2','9', '\3','5','3','0', '\3','5','3','1', '\3','5','3','2', '\3','5','3','3', '\3','5','3','4', '\3','5','3','5', '\3','5','3','6', '\3','5','3','7', '\3','5','3','8', '\3','5','3','9', '\3','5','4','0', '\3','5','4','1', '\3','5','4','2', '\3','5','4','3', '\3','5','4','4', '\3','5','4','5', '\3','5','4','6', '\3','5','4','7', '\3','5','4','8', '\3','5','4','9', '\3','5','5','0', '\3','5','5','1', '\3','5','5','2', '\3','5','5','3', '\3','5','5','4', '\3','5','5','5', '\3','5','5','6', '\3','5','5','7', '\3','5','5','8', '\3','5','5','9', '\3','5','6','0', '\3','5','6','1', '\3','5','6','2', '\3','5','6','3', '\3','5','6','4', '\3','5','6','5', '\3','5','6','6', '\3','5','6','7', '\3','5','6','8', '\3','5','6','9', '\3','5','7','0', '\3','5','7','1', '\3','5','7','2', '\3','5','7','3', '\3','5','7','4', '\3','5','7','5', '\3','5','7','6', '\3','5','7','7', '\3','5','7','8', '\3','5','7','9', '\3','5','8','0', '\3','5','8','1', '\3','5','8','2', '\3','5','8','3', '\3','5','8','4', '\3','5','8','5', '\3','5','8','6', '\3','5','8','7', '\3','5','8','8', '\3','5','8','9', '\3','5','9','0', '\3','5','9','1', '\3','5','9','2', '\3','5','9','3', '\3','5','9','4', '\3','5','9','5', '\3','5','9','6', '\3','5','9','7', '\3','5','9','8', '\3','5','9','9', '\3','6','0','0', '\3','6','0','1', '\3','6','0','2', '\3','6','0','3', '\3','6','0','4', '\3','6','0','5', '\3','6','0','6', '\3','6','0','7', '\3','6','0','8', '\3','6','0','9', '\3','6','1','0', '\3','6','1','1', '\3','6','1','2', '\3','6','1','3', '\3','6','1','4', '\3','6','1','5', '\3','6','1','6', '\3','6','1','7', '\3','6','1','8', '\3','6','1','9', '\3','6','2','0', '\3','6','2','1', '\3','6','2','2', '\3','6','2','3', '\3','6','2','4', '\3','6','2','5', '\3','6','2','6', '\3','6','2','7', '\3','6','2','8', '\3','6','2','9', '\3','6','3','0', '\3','6','3','1', '\3','6','3','2', '\3','6','3','3', '\3','6','3','4', '\3','6','3','5', '\3','6','3','6', '\3','6','3','7', '\3','6','3','8', '\3','6','3','9', '\3','6','4','0', '\3','6','4','1', '\3','6','4','2', '\3','6','4','3', '\3','6','4','4', '\3','6','4','5', '\3','6','4','6', '\3','6','4','7', '\3','6','4','8', '\3','6','4','9', '\3','6','5','0', '\3','6','5','1', '\3','6','5','2', '\3','6','5','3', '\3','6','5','4', '\3','6','5','5', '\3','6','5','6', '\3','6','5','7', '\3','6','5','8', '\3','6','5','9', '\3','6','6','0', '\3','6','6','1', '\3','6','6','2', '\3','6','6','3', '\3','6','6','4', '\3','6','6','5', '\3','6','6','6', '\3','6','6','7', '\3','6','6','8', '\3','6','6','9', '\3','6','7','0', '\3','6','7','1', '\3','6','7','2', '\3','6','7','3', '\3','6','7','4', '\3','6','7','5', '\3','6','7','6', '\3','6','7','7', '\3','6','7','8', '\3','6','7','9', '\3','6','8','0', '\3','6','8','1', '\3','6','8','2', '\3','6','8','3', '\3','6','8','4', '\3','6','8','5', '\3','6','8','6', '\3','6','8','7', '\3','6','8','8', '\3','6','8','9', '\3','6','9','0', '\3','6','9','1', '\3','6','9','2', '\3','6','9','3', '\3','6','9','4', '\3','6','9','5', '\3','6','9','6', '\3','6','9','7', '\3','6','9','8', '\3','6','9','9', '\3','7','0','0', '\3','7','0','1', '\3','7','0','2', '\3','7','0','3', '\3','7','0','4', '\3','7','0','5', '\3','7','0','6', '\3','7','0','7', '\3','7','0','8', '\3','7','0','9', '\3','7','1','0', '\3','7','1','1', '\3','7','1','2', '\3','7','1','3', '\3','7','1','4', '\3','7','1','5', '\3','7','1','6', '\3','7','1','7', '\3','7','1','8', '\3','7','1','9', '\3','7','2','0', '\3','7','2','1', '\3','7','2','2', '\3','7','2','3', '\3','7','2','4', '\3','7','2','5', '\3','7','2','6', '\3','7','2','7', '\3','7','2','8', '\3','7','2','9', '\3','7','3','0', '\3','7','3','1', '\3','7','3','2', '\3','7','3','3', '\3','7','3','4', '\3','7','3','5', '\3','7','3','6', '\3','7','3','7', '\3','7','3','8', '\3','7','3','9', '\3','7','4','0', '\3','7','4','1', '\3','7','4','2', '\3','7','4','3', '\3','7','4','4', '\3','7','4','5', '\3','7','4','6', '\3','7','4','7', '\3','7','4','8', '\3','7','4','9', '\3','7','5','0', '\3','7','5','1', '\3','7','5','2', '\3','7','5','3', '\3','7','5','4', '\3','7','5','5', '\3','7','5','6', '\3','7','5','7', '\3','7','5','8', '\3','7','5','9', '\3','7','6','0', '\3','7','6','1', '\3','7','6','2', '\3','7','6','3', '\3','7','6','4', '\3','7','6','5', '\3','7','6','6', '\3','7','6','7', '\3','7','6','8', '\3','7','6','9', '\3','7','7','0', '\3','7','7','1', '\3','7','7','2', '\3','7','7','3', '\3','7','7','4', '\3','7','7','5', '\3','7','7','6', '\3','7','7','7', '\3','7','7','8', '\3','7','7','9', '\3','7','8','0', '\3','7','8','1', '\3','7','8','2', '\3','7','8','3', '\3','7','8','4', '\3','7','8','5', '\3','7','8','6', '\3','7','8','7', '\3','7','8','8', '\3','7','8','9', '\3','7','9','0', '\3','7','9','1', '\3','7','9','2', '\3','7','9','3', '\3','7','9','4', '\3','7','9','5', '\3','7','9','6', '\3','7','9','7', '\3','7','9','8', '\3','7','9','9', '\3','8','0','0', '\3','8','0','1', '\3','8','0','2', '\3','8','0','3', '\3','8','0','4', '\3','8','0','5', '\3','8','0','6', '\3','8','0','7', '\3','8','0','8', '\3','8','0','9', '\3','8','1','0', '\3','8','1','1', '\3','8','1','2', '\3','8','1','3', '\3','8','1','4', '\3','8','1','5', '\3','8','1','6', '\3','8','1','7', '\3','8','1','8', '\3','8','1','9', '\3','8','2','0', '\3','8','2','1', '\3','8','2','2', '\3','8','2','3', '\3','8','2','4', '\3','8','2','5', '\3','8','2','6', '\3','8','2','7', '\3','8','2','8', '\3','8','2','9', '\3','8','3','0', '\3','8','3','1', '\3','8','3','2', '\3','8','3','3', '\3','8','3','4', '\3','8','3','5', '\3','8','3','6', '\3','8','3','7', '\3','8','3','8', '\3','8','3','9', '\3','8','4','0', '\3','8','4','1', '\3','8','4','2', '\3','8','4','3', '\3','8','4','4', '\3','8','4','5', '\3','8','4','6', '\3','8','4','7', '\3','8','4','8', '\3','8','4','9', '\3','8','5','0', '\3','8','5','1', '\3','8','5','2', '\3','8','5','3', '\3','8','5','4', '\3','8','5','5', '\3','8','5','6', '\3','8','5','7', '\3','8','5','8', '\3','8','5','9', '\3','8','6','0', '\3','8','6','1', '\3','8','6','2', '\3','8','6','3', '\3','8','6','4', '\3','8','6','5', '\3','8','6','6', '\3','8','6','7', '\3','8','6','8', '\3','8','6','9', '\3','8','7','0', '\3','8','7','1', '\3','8','7','2', '\3','8','7','3', '\3','8','7','4', '\3','8','7','5', '\3','8','7','6', '\3','8','7','7', '\3','8','7','8', '\3','8','7','9', '\3','8','8','0', '\3','8','8','1', '\3','8','8','2', '\3','8','8','3', '\3','8','8','4', '\3','8','8','5', '\3','8','8','6', '\3','8','8','7', '\3','8','8','8', '\3','8','8','9', '\3','8','9','0', '\3','8','9','1', '\3','8','9','2', '\3','8','9','3', '\3','8','9','4', '\3','8','9','5', '\3','8','9','6', '\3','8','9','7', '\3','8','9','8', '\3','8','9','9', '\3','9','0','0', '\3','9','0','1', '\3','9','0','2', '\3','9','0','3', '\3','9','0','4', '\3','9','0','5', '\3','9','0','6', '\3','9','0','7', '\3','9','0','8', '\3','9','0','9', '\3','9','1','0', '\3','9','1','1', '\3','9','1','2', '\3','9','1','3', '\3','9','1','4', '\3','9','1','5', '\3','9','1','6', '\3','9','1','7', '\3','9','1','8', '\3','9','1','9', '\3','9','2','0', '\3','9','2','1', '\3','9','2','2', '\3','9','2','3', '\3','9','2','4', '\3','9','2','5', '\3','9','2','6', '\3','9','2','7', '\3','9','2','8', '\3','9','2','9', '\3','9','3','0', '\3','9','3','1', '\3','9','3','2', '\3','9','3','3', '\3','9','3','4', '\3','9','3','5', '\3','9','3','6', '\3','9','3','7', '\3','9','3','8', '\3','9','3','9', '\3','9','4','0', '\3','9','4','1', '\3','9','4','2', '\3','9','4','3', '\3','9','4','4', '\3','9','4','5', '\3','9','4','6', '\3','9','4','7', '\3','9','4','8', '\3','9','4','9', '\3','9','5','0', '\3','9','5','1', '\3','9','5','2', '\3','9','5','3', '\3','9','5','4', '\3','9','5','5', '\3','9','5','6', '\3','9','5','7', '\3','9','5','8', '\3','9','5','9', '\3','9','6','0', '\3','9','6','1', '\3','9','6','2', '\3','9','6','3', '\3','9','6','4', '\3','9','6','5', '\3','9','6','6', '\3','9','6','7', '\3','9','6','8', '\3','9','6','9', '\3','9','7','0', '\3','9','7','1', '\3','9','7','2', '\3','9','7','3', '\3','9','7','4', '\3','9','7','5', '\3','9','7','6', '\3','9','7','7', '\3','9','7','8', '\3','9','7','9', '\3','9','8','0', '\3','9','8','1', '\3','9','8','2', '\3','9','8','3', '\3','9','8','4', '\3','9','8','5', '\3','9','8','6', '\3','9','8','7', '\3','9','8','8', '\3','9','8','9', '\3','9','9','0', '\3','9','9','1', '\3','9','9','2', '\3','9','9','3', '\3','9','9','4', '\3','9','9','5', '\3','9','9','6', '\3','9','9','7', '\3','9','9','8', '\3','9','9','9', '\0'}; #endif #if defined(DEC_DPD2BCD8) && DEC_DPD2BCD8==1 && !defined(DECDPD2BCD8) #define DECDPD2BCD8 const uint8_t DPD2BCD8[4096]={ 0,0,0,0, 0,0,1,1, 0,0,2,1, 0,0,3,1, 0,0,4,1, 0,0,5,1, 0,0,6,1, 0,0,7,1, 0,0,8,1, 0,0,9,1, 0,8,0,2, 0,8,1,2, 8,0,0,3, 8,0,1,3, 8,8,0,3, 8,8,1,3, 0,1,0,2, 0,1,1,2, 0,1,2,2, 0,1,3,2, 0,1,4,2, 0,1,5,2, 0,1,6,2, 0,1,7,2, 0,1,8,2, 0,1,9,2, 0,9,0,2, 0,9,1,2, 8,1,0,3, 8,1,1,3, 8,9,0,3, 8,9,1,3, 0,2,0,2, 0,2,1,2, 0,2,2,2, 0,2,3,2, 0,2,4,2, 0,2,5,2, 0,2,6,2, 0,2,7,2, 0,2,8,2, 0,2,9,2, 0,8,2,2, 0,8,3,2, 8,2,0,3, 8,2,1,3, 8,0,8,3, 8,0,9,3, 0,3,0,2, 0,3,1,2, 0,3,2,2, 0,3,3,2, 0,3,4,2, 0,3,5,2, 0,3,6,2, 0,3,7,2, 0,3,8,2, 0,3,9,2, 0,9,2,2, 0,9,3,2, 8,3,0,3, 8,3,1,3, 8,1,8,3, 8,1,9,3, 0,4,0,2, 0,4,1,2, 0,4,2,2, 0,4,3,2, 0,4,4,2, 0,4,5,2, 0,4,6,2, 0,4,7,2, 0,4,8,2, 0,4,9,2, 0,8,4,2, 0,8,5,2, 8,4,0,3, 8,4,1,3, 0,8,8,2, 0,8,9,2, 0,5,0,2, 0,5,1,2, 0,5,2,2, 0,5,3,2, 0,5,4,2, 0,5,5,2, 0,5,6,2, 0,5,7,2, 0,5,8,2, 0,5,9,2, 0,9,4,2, 0,9,5,2, 8,5,0,3, 8,5,1,3, 0,9,8,2, 0,9,9,2, 0,6,0,2, 0,6,1,2, 0,6,2,2, 0,6,3,2, 0,6,4,2, 0,6,5,2, 0,6,6,2, 0,6,7,2, 0,6,8,2, 0,6,9,2, 0,8,6,2, 0,8,7,2, 8,6,0,3, 8,6,1,3, 8,8,8,3, 8,8,9,3, 0,7,0,2, 0,7,1,2, 0,7,2,2, 0,7,3,2, 0,7,4,2, 0,7,5,2, 0,7,6,2, 0,7,7,2, 0,7,8,2, 0,7,9,2, 0,9,6,2, 0,9,7,2, 8,7,0,3, 8,7,1,3, 8,9,8,3, 8,9,9,3, 1,0,0,3, 1,0,1,3, 1,0,2,3, 1,0,3,3, 1,0,4,3, 1,0,5,3, 1,0,6,3, 1,0,7,3, 1,0,8,3, 1,0,9,3, 1,8,0,3, 1,8,1,3, 9,0,0,3, 9,0,1,3, 9,8,0,3, 9,8,1,3, 1,1,0,3, 1,1,1,3, 1,1,2,3, 1,1,3,3, 1,1,4,3, 1,1,5,3, 1,1,6,3, 1,1,7,3, 1,1,8,3, 1,1,9,3, 1,9,0,3, 1,9,1,3, 9,1,0,3, 9,1,1,3, 9,9,0,3, 9,9,1,3, 1,2,0,3, 1,2,1,3, 1,2,2,3, 1,2,3,3, 1,2,4,3, 1,2,5,3, 1,2,6,3, 1,2,7,3, 1,2,8,3, 1,2,9,3, 1,8,2,3, 1,8,3,3, 9,2,0,3, 9,2,1,3, 9,0,8,3, 9,0,9,3, 1,3,0,3, 1,3,1,3, 1,3,2,3, 1,3,3,3, 1,3,4,3, 1,3,5,3, 1,3,6,3, 1,3,7,3, 1,3,8,3, 1,3,9,3, 1,9,2,3, 1,9,3,3, 9,3,0,3, 9,3,1,3, 9,1,8,3, 9,1,9,3, 1,4,0,3, 1,4,1,3, 1,4,2,3, 1,4,3,3, 1,4,4,3, 1,4,5,3, 1,4,6,3, 1,4,7,3, 1,4,8,3, 1,4,9,3, 1,8,4,3, 1,8,5,3, 9,4,0,3, 9,4,1,3, 1,8,8,3, 1,8,9,3, 1,5,0,3, 1,5,1,3, 1,5,2,3, 1,5,3,3, 1,5,4,3, 1,5,5,3, 1,5,6,3, 1,5,7,3, 1,5,8,3, 1,5,9,3, 1,9,4,3, 1,9,5,3, 9,5,0,3, 9,5,1,3, 1,9,8,3, 1,9,9,3, 1,6,0,3, 1,6,1,3, 1,6,2,3, 1,6,3,3, 1,6,4,3, 1,6,5,3, 1,6,6,3, 1,6,7,3, 1,6,8,3, 1,6,9,3, 1,8,6,3, 1,8,7,3, 9,6,0,3, 9,6,1,3, 9,8,8,3, 9,8,9,3, 1,7,0,3, 1,7,1,3, 1,7,2,3, 1,7,3,3, 1,7,4,3, 1,7,5,3, 1,7,6,3, 1,7,7,3, 1,7,8,3, 1,7,9,3, 1,9,6,3, 1,9,7,3, 9,7,0,3, 9,7,1,3, 9,9,8,3, 9,9,9,3, 2,0,0,3, 2,0,1,3, 2,0,2,3, 2,0,3,3, 2,0,4,3, 2,0,5,3, 2,0,6,3, 2,0,7,3, 2,0,8,3, 2,0,9,3, 2,8,0,3, 2,8,1,3, 8,0,2,3, 8,0,3,3, 8,8,2,3, 8,8,3,3, 2,1,0,3, 2,1,1,3, 2,1,2,3, 2,1,3,3, 2,1,4,3, 2,1,5,3, 2,1,6,3, 2,1,7,3, 2,1,8,3, 2,1,9,3, 2,9,0,3, 2,9,1,3, 8,1,2,3, 8,1,3,3, 8,9,2,3, 8,9,3,3, 2,2,0,3, 2,2,1,3, 2,2,2,3, 2,2,3,3, 2,2,4,3, 2,2,5,3, 2,2,6,3, 2,2,7,3, 2,2,8,3, 2,2,9,3, 2,8,2,3, 2,8,3,3, 8,2,2,3, 8,2,3,3, 8,2,8,3, 8,2,9,3, 2,3,0,3, 2,3,1,3, 2,3,2,3, 2,3,3,3, 2,3,4,3, 2,3,5,3, 2,3,6,3, 2,3,7,3, 2,3,8,3, 2,3,9,3, 2,9,2,3, 2,9,3,3, 8,3,2,3, 8,3,3,3, 8,3,8,3, 8,3,9,3, 2,4,0,3, 2,4,1,3, 2,4,2,3, 2,4,3,3, 2,4,4,3, 2,4,5,3, 2,4,6,3, 2,4,7,3, 2,4,8,3, 2,4,9,3, 2,8,4,3, 2,8,5,3, 8,4,2,3, 8,4,3,3, 2,8,8,3, 2,8,9,3, 2,5,0,3, 2,5,1,3, 2,5,2,3, 2,5,3,3, 2,5,4,3, 2,5,5,3, 2,5,6,3, 2,5,7,3, 2,5,8,3, 2,5,9,3, 2,9,4,3, 2,9,5,3, 8,5,2,3, 8,5,3,3, 2,9,8,3, 2,9,9,3, 2,6,0,3, 2,6,1,3, 2,6,2,3, 2,6,3,3, 2,6,4,3, 2,6,5,3, 2,6,6,3, 2,6,7,3, 2,6,8,3, 2,6,9,3, 2,8,6,3, 2,8,7,3, 8,6,2,3, 8,6,3,3, 8,8,8,3, 8,8,9,3, 2,7,0,3, 2,7,1,3, 2,7,2,3, 2,7,3,3, 2,7,4,3, 2,7,5,3, 2,7,6,3, 2,7,7,3, 2,7,8,3, 2,7,9,3, 2,9,6,3, 2,9,7,3, 8,7,2,3, 8,7,3,3, 8,9,8,3, 8,9,9,3, 3,0,0,3, 3,0,1,3, 3,0,2,3, 3,0,3,3, 3,0,4,3, 3,0,5,3, 3,0,6,3, 3,0,7,3, 3,0,8,3, 3,0,9,3, 3,8,0,3, 3,8,1,3, 9,0,2,3, 9,0,3,3, 9,8,2,3, 9,8,3,3, 3,1,0,3, 3,1,1,3, 3,1,2,3, 3,1,3,3, 3,1,4,3, 3,1,5,3, 3,1,6,3, 3,1,7,3, 3,1,8,3, 3,1,9,3, 3,9,0,3, 3,9,1,3, 9,1,2,3, 9,1,3,3, 9,9,2,3, 9,9,3,3, 3,2,0,3, 3,2,1,3, 3,2,2,3, 3,2,3,3, 3,2,4,3, 3,2,5,3, 3,2,6,3, 3,2,7,3, 3,2,8,3, 3,2,9,3, 3,8,2,3, 3,8,3,3, 9,2,2,3, 9,2,3,3, 9,2,8,3, 9,2,9,3, 3,3,0,3, 3,3,1,3, 3,3,2,3, 3,3,3,3, 3,3,4,3, 3,3,5,3, 3,3,6,3, 3,3,7,3, 3,3,8,3, 3,3,9,3, 3,9,2,3, 3,9,3,3, 9,3,2,3, 9,3,3,3, 9,3,8,3, 9,3,9,3, 3,4,0,3, 3,4,1,3, 3,4,2,3, 3,4,3,3, 3,4,4,3, 3,4,5,3, 3,4,6,3, 3,4,7,3, 3,4,8,3, 3,4,9,3, 3,8,4,3, 3,8,5,3, 9,4,2,3, 9,4,3,3, 3,8,8,3, 3,8,9,3, 3,5,0,3, 3,5,1,3, 3,5,2,3, 3,5,3,3, 3,5,4,3, 3,5,5,3, 3,5,6,3, 3,5,7,3, 3,5,8,3, 3,5,9,3, 3,9,4,3, 3,9,5,3, 9,5,2,3, 9,5,3,3, 3,9,8,3, 3,9,9,3, 3,6,0,3, 3,6,1,3, 3,6,2,3, 3,6,3,3, 3,6,4,3, 3,6,5,3, 3,6,6,3, 3,6,7,3, 3,6,8,3, 3,6,9,3, 3,8,6,3, 3,8,7,3, 9,6,2,3, 9,6,3,3, 9,8,8,3, 9,8,9,3, 3,7,0,3, 3,7,1,3, 3,7,2,3, 3,7,3,3, 3,7,4,3, 3,7,5,3, 3,7,6,3, 3,7,7,3, 3,7,8,3, 3,7,9,3, 3,9,6,3, 3,9,7,3, 9,7,2,3, 9,7,3,3, 9,9,8,3, 9,9,9,3, 4,0,0,3, 4,0,1,3, 4,0,2,3, 4,0,3,3, 4,0,4,3, 4,0,5,3, 4,0,6,3, 4,0,7,3, 4,0,8,3, 4,0,9,3, 4,8,0,3, 4,8,1,3, 8,0,4,3, 8,0,5,3, 8,8,4,3, 8,8,5,3, 4,1,0,3, 4,1,1,3, 4,1,2,3, 4,1,3,3, 4,1,4,3, 4,1,5,3, 4,1,6,3, 4,1,7,3, 4,1,8,3, 4,1,9,3, 4,9,0,3, 4,9,1,3, 8,1,4,3, 8,1,5,3, 8,9,4,3, 8,9,5,3, 4,2,0,3, 4,2,1,3, 4,2,2,3, 4,2,3,3, 4,2,4,3, 4,2,5,3, 4,2,6,3, 4,2,7,3, 4,2,8,3, 4,2,9,3, 4,8,2,3, 4,8,3,3, 8,2,4,3, 8,2,5,3, 8,4,8,3, 8,4,9,3, 4,3,0,3, 4,3,1,3, 4,3,2,3, 4,3,3,3, 4,3,4,3, 4,3,5,3, 4,3,6,3, 4,3,7,3, 4,3,8,3, 4,3,9,3, 4,9,2,3, 4,9,3,3, 8,3,4,3, 8,3,5,3, 8,5,8,3, 8,5,9,3, 4,4,0,3, 4,4,1,3, 4,4,2,3, 4,4,3,3, 4,4,4,3, 4,4,5,3, 4,4,6,3, 4,4,7,3, 4,4,8,3, 4,4,9,3, 4,8,4,3, 4,8,5,3, 8,4,4,3, 8,4,5,3, 4,8,8,3, 4,8,9,3, 4,5,0,3, 4,5,1,3, 4,5,2,3, 4,5,3,3, 4,5,4,3, 4,5,5,3, 4,5,6,3, 4,5,7,3, 4,5,8,3, 4,5,9,3, 4,9,4,3, 4,9,5,3, 8,5,4,3, 8,5,5,3, 4,9,8,3, 4,9,9,3, 4,6,0,3, 4,6,1,3, 4,6,2,3, 4,6,3,3, 4,6,4,3, 4,6,5,3, 4,6,6,3, 4,6,7,3, 4,6,8,3, 4,6,9,3, 4,8,6,3, 4,8,7,3, 8,6,4,3, 8,6,5,3, 8,8,8,3, 8,8,9,3, 4,7,0,3, 4,7,1,3, 4,7,2,3, 4,7,3,3, 4,7,4,3, 4,7,5,3, 4,7,6,3, 4,7,7,3, 4,7,8,3, 4,7,9,3, 4,9,6,3, 4,9,7,3, 8,7,4,3, 8,7,5,3, 8,9,8,3, 8,9,9,3, 5,0,0,3, 5,0,1,3, 5,0,2,3, 5,0,3,3, 5,0,4,3, 5,0,5,3, 5,0,6,3, 5,0,7,3, 5,0,8,3, 5,0,9,3, 5,8,0,3, 5,8,1,3, 9,0,4,3, 9,0,5,3, 9,8,4,3, 9,8,5,3, 5,1,0,3, 5,1,1,3, 5,1,2,3, 5,1,3,3, 5,1,4,3, 5,1,5,3, 5,1,6,3, 5,1,7,3, 5,1,8,3, 5,1,9,3, 5,9,0,3, 5,9,1,3, 9,1,4,3, 9,1,5,3, 9,9,4,3, 9,9,5,3, 5,2,0,3, 5,2,1,3, 5,2,2,3, 5,2,3,3, 5,2,4,3, 5,2,5,3, 5,2,6,3, 5,2,7,3, 5,2,8,3, 5,2,9,3, 5,8,2,3, 5,8,3,3, 9,2,4,3, 9,2,5,3, 9,4,8,3, 9,4,9,3, 5,3,0,3, 5,3,1,3, 5,3,2,3, 5,3,3,3, 5,3,4,3, 5,3,5,3, 5,3,6,3, 5,3,7,3, 5,3,8,3, 5,3,9,3, 5,9,2,3, 5,9,3,3, 9,3,4,3, 9,3,5,3, 9,5,8,3, 9,5,9,3, 5,4,0,3, 5,4,1,3, 5,4,2,3, 5,4,3,3, 5,4,4,3, 5,4,5,3, 5,4,6,3, 5,4,7,3, 5,4,8,3, 5,4,9,3, 5,8,4,3, 5,8,5,3, 9,4,4,3, 9,4,5,3, 5,8,8,3, 5,8,9,3, 5,5,0,3, 5,5,1,3, 5,5,2,3, 5,5,3,3, 5,5,4,3, 5,5,5,3, 5,5,6,3, 5,5,7,3, 5,5,8,3, 5,5,9,3, 5,9,4,3, 5,9,5,3, 9,5,4,3, 9,5,5,3, 5,9,8,3, 5,9,9,3, 5,6,0,3, 5,6,1,3, 5,6,2,3, 5,6,3,3, 5,6,4,3, 5,6,5,3, 5,6,6,3, 5,6,7,3, 5,6,8,3, 5,6,9,3, 5,8,6,3, 5,8,7,3, 9,6,4,3, 9,6,5,3, 9,8,8,3, 9,8,9,3, 5,7,0,3, 5,7,1,3, 5,7,2,3, 5,7,3,3, 5,7,4,3, 5,7,5,3, 5,7,6,3, 5,7,7,3, 5,7,8,3, 5,7,9,3, 5,9,6,3, 5,9,7,3, 9,7,4,3, 9,7,5,3, 9,9,8,3, 9,9,9,3, 6,0,0,3, 6,0,1,3, 6,0,2,3, 6,0,3,3, 6,0,4,3, 6,0,5,3, 6,0,6,3, 6,0,7,3, 6,0,8,3, 6,0,9,3, 6,8,0,3, 6,8,1,3, 8,0,6,3, 8,0,7,3, 8,8,6,3, 8,8,7,3, 6,1,0,3, 6,1,1,3, 6,1,2,3, 6,1,3,3, 6,1,4,3, 6,1,5,3, 6,1,6,3, 6,1,7,3, 6,1,8,3, 6,1,9,3, 6,9,0,3, 6,9,1,3, 8,1,6,3, 8,1,7,3, 8,9,6,3, 8,9,7,3, 6,2,0,3, 6,2,1,3, 6,2,2,3, 6,2,3,3, 6,2,4,3, 6,2,5,3, 6,2,6,3, 6,2,7,3, 6,2,8,3, 6,2,9,3, 6,8,2,3, 6,8,3,3, 8,2,6,3, 8,2,7,3, 8,6,8,3, 8,6,9,3, 6,3,0,3, 6,3,1,3, 6,3,2,3, 6,3,3,3, 6,3,4,3, 6,3,5,3, 6,3,6,3, 6,3,7,3, 6,3,8,3, 6,3,9,3, 6,9,2,3, 6,9,3,3, 8,3,6,3, 8,3,7,3, 8,7,8,3, 8,7,9,3, 6,4,0,3, 6,4,1,3, 6,4,2,3, 6,4,3,3, 6,4,4,3, 6,4,5,3, 6,4,6,3, 6,4,7,3, 6,4,8,3, 6,4,9,3, 6,8,4,3, 6,8,5,3, 8,4,6,3, 8,4,7,3, 6,8,8,3, 6,8,9,3, 6,5,0,3, 6,5,1,3, 6,5,2,3, 6,5,3,3, 6,5,4,3, 6,5,5,3, 6,5,6,3, 6,5,7,3, 6,5,8,3, 6,5,9,3, 6,9,4,3, 6,9,5,3, 8,5,6,3, 8,5,7,3, 6,9,8,3, 6,9,9,3, 6,6,0,3, 6,6,1,3, 6,6,2,3, 6,6,3,3, 6,6,4,3, 6,6,5,3, 6,6,6,3, 6,6,7,3, 6,6,8,3, 6,6,9,3, 6,8,6,3, 6,8,7,3, 8,6,6,3, 8,6,7,3, 8,8,8,3, 8,8,9,3, 6,7,0,3, 6,7,1,3, 6,7,2,3, 6,7,3,3, 6,7,4,3, 6,7,5,3, 6,7,6,3, 6,7,7,3, 6,7,8,3, 6,7,9,3, 6,9,6,3, 6,9,7,3, 8,7,6,3, 8,7,7,3, 8,9,8,3, 8,9,9,3, 7,0,0,3, 7,0,1,3, 7,0,2,3, 7,0,3,3, 7,0,4,3, 7,0,5,3, 7,0,6,3, 7,0,7,3, 7,0,8,3, 7,0,9,3, 7,8,0,3, 7,8,1,3, 9,0,6,3, 9,0,7,3, 9,8,6,3, 9,8,7,3, 7,1,0,3, 7,1,1,3, 7,1,2,3, 7,1,3,3, 7,1,4,3, 7,1,5,3, 7,1,6,3, 7,1,7,3, 7,1,8,3, 7,1,9,3, 7,9,0,3, 7,9,1,3, 9,1,6,3, 9,1,7,3, 9,9,6,3, 9,9,7,3, 7,2,0,3, 7,2,1,3, 7,2,2,3, 7,2,3,3, 7,2,4,3, 7,2,5,3, 7,2,6,3, 7,2,7,3, 7,2,8,3, 7,2,9,3, 7,8,2,3, 7,8,3,3, 9,2,6,3, 9,2,7,3, 9,6,8,3, 9,6,9,3, 7,3,0,3, 7,3,1,3, 7,3,2,3, 7,3,3,3, 7,3,4,3, 7,3,5,3, 7,3,6,3, 7,3,7,3, 7,3,8,3, 7,3,9,3, 7,9,2,3, 7,9,3,3, 9,3,6,3, 9,3,7,3, 9,7,8,3, 9,7,9,3, 7,4,0,3, 7,4,1,3, 7,4,2,3, 7,4,3,3, 7,4,4,3, 7,4,5,3, 7,4,6,3, 7,4,7,3, 7,4,8,3, 7,4,9,3, 7,8,4,3, 7,8,5,3, 9,4,6,3, 9,4,7,3, 7,8,8,3, 7,8,9,3, 7,5,0,3, 7,5,1,3, 7,5,2,3, 7,5,3,3, 7,5,4,3, 7,5,5,3, 7,5,6,3, 7,5,7,3, 7,5,8,3, 7,5,9,3, 7,9,4,3, 7,9,5,3, 9,5,6,3, 9,5,7,3, 7,9,8,3, 7,9,9,3, 7,6,0,3, 7,6,1,3, 7,6,2,3, 7,6,3,3, 7,6,4,3, 7,6,5,3, 7,6,6,3, 7,6,7,3, 7,6,8,3, 7,6,9,3, 7,8,6,3, 7,8,7,3, 9,6,6,3, 9,6,7,3, 9,8,8,3, 9,8,9,3, 7,7,0,3, 7,7,1,3, 7,7,2,3, 7,7,3,3, 7,7,4,3, 7,7,5,3, 7,7,6,3, 7,7,7,3, 7,7,8,3, 7,7,9,3, 7,9,6,3, 7,9,7,3, 9,7,6,3, 9,7,7,3, 9,9,8,3, 9,9,9,3}; #endif #if defined(DEC_BIN2BCD8) && DEC_BIN2BCD8==1 && !defined(DECBIN2BCD8) #define DECBIN2BCD8 const uint8_t BIN2BCD8[4000]={ 0,0,0,0, 0,0,1,1, 0,0,2,1, 0,0,3,1, 0,0,4,1, 0,0,5,1, 0,0,6,1, 0,0,7,1, 0,0,8,1, 0,0,9,1, 0,1,0,2, 0,1,1,2, 0,1,2,2, 0,1,3,2, 0,1,4,2, 0,1,5,2, 0,1,6,2, 0,1,7,2, 0,1,8,2, 0,1,9,2, 0,2,0,2, 0,2,1,2, 0,2,2,2, 0,2,3,2, 0,2,4,2, 0,2,5,2, 0,2,6,2, 0,2,7,2, 0,2,8,2, 0,2,9,2, 0,3,0,2, 0,3,1,2, 0,3,2,2, 0,3,3,2, 0,3,4,2, 0,3,5,2, 0,3,6,2, 0,3,7,2, 0,3,8,2, 0,3,9,2, 0,4,0,2, 0,4,1,2, 0,4,2,2, 0,4,3,2, 0,4,4,2, 0,4,5,2, 0,4,6,2, 0,4,7,2, 0,4,8,2, 0,4,9,2, 0,5,0,2, 0,5,1,2, 0,5,2,2, 0,5,3,2, 0,5,4,2, 0,5,5,2, 0,5,6,2, 0,5,7,2, 0,5,8,2, 0,5,9,2, 0,6,0,2, 0,6,1,2, 0,6,2,2, 0,6,3,2, 0,6,4,2, 0,6,5,2, 0,6,6,2, 0,6,7,2, 0,6,8,2, 0,6,9,2, 0,7,0,2, 0,7,1,2, 0,7,2,2, 0,7,3,2, 0,7,4,2, 0,7,5,2, 0,7,6,2, 0,7,7,2, 0,7,8,2, 0,7,9,2, 0,8,0,2, 0,8,1,2, 0,8,2,2, 0,8,3,2, 0,8,4,2, 0,8,5,2, 0,8,6,2, 0,8,7,2, 0,8,8,2, 0,8,9,2, 0,9,0,2, 0,9,1,2, 0,9,2,2, 0,9,3,2, 0,9,4,2, 0,9,5,2, 0,9,6,2, 0,9,7,2, 0,9,8,2, 0,9,9,2, 1,0,0,3, 1,0,1,3, 1,0,2,3, 1,0,3,3, 1,0,4,3, 1,0,5,3, 1,0,6,3, 1,0,7,3, 1,0,8,3, 1,0,9,3, 1,1,0,3, 1,1,1,3, 1,1,2,3, 1,1,3,3, 1,1,4,3, 1,1,5,3, 1,1,6,3, 1,1,7,3, 1,1,8,3, 1,1,9,3, 1,2,0,3, 1,2,1,3, 1,2,2,3, 1,2,3,3, 1,2,4,3, 1,2,5,3, 1,2,6,3, 1,2,7,3, 1,2,8,3, 1,2,9,3, 1,3,0,3, 1,3,1,3, 1,3,2,3, 1,3,3,3, 1,3,4,3, 1,3,5,3, 1,3,6,3, 1,3,7,3, 1,3,8,3, 1,3,9,3, 1,4,0,3, 1,4,1,3, 1,4,2,3, 1,4,3,3, 1,4,4,3, 1,4,5,3, 1,4,6,3, 1,4,7,3, 1,4,8,3, 1,4,9,3, 1,5,0,3, 1,5,1,3, 1,5,2,3, 1,5,3,3, 1,5,4,3, 1,5,5,3, 1,5,6,3, 1,5,7,3, 1,5,8,3, 1,5,9,3, 1,6,0,3, 1,6,1,3, 1,6,2,3, 1,6,3,3, 1,6,4,3, 1,6,5,3, 1,6,6,3, 1,6,7,3, 1,6,8,3, 1,6,9,3, 1,7,0,3, 1,7,1,3, 1,7,2,3, 1,7,3,3, 1,7,4,3, 1,7,5,3, 1,7,6,3, 1,7,7,3, 1,7,8,3, 1,7,9,3, 1,8,0,3, 1,8,1,3, 1,8,2,3, 1,8,3,3, 1,8,4,3, 1,8,5,3, 1,8,6,3, 1,8,7,3, 1,8,8,3, 1,8,9,3, 1,9,0,3, 1,9,1,3, 1,9,2,3, 1,9,3,3, 1,9,4,3, 1,9,5,3, 1,9,6,3, 1,9,7,3, 1,9,8,3, 1,9,9,3, 2,0,0,3, 2,0,1,3, 2,0,2,3, 2,0,3,3, 2,0,4,3, 2,0,5,3, 2,0,6,3, 2,0,7,3, 2,0,8,3, 2,0,9,3, 2,1,0,3, 2,1,1,3, 2,1,2,3, 2,1,3,3, 2,1,4,3, 2,1,5,3, 2,1,6,3, 2,1,7,3, 2,1,8,3, 2,1,9,3, 2,2,0,3, 2,2,1,3, 2,2,2,3, 2,2,3,3, 2,2,4,3, 2,2,5,3, 2,2,6,3, 2,2,7,3, 2,2,8,3, 2,2,9,3, 2,3,0,3, 2,3,1,3, 2,3,2,3, 2,3,3,3, 2,3,4,3, 2,3,5,3, 2,3,6,3, 2,3,7,3, 2,3,8,3, 2,3,9,3, 2,4,0,3, 2,4,1,3, 2,4,2,3, 2,4,3,3, 2,4,4,3, 2,4,5,3, 2,4,6,3, 2,4,7,3, 2,4,8,3, 2,4,9,3, 2,5,0,3, 2,5,1,3, 2,5,2,3, 2,5,3,3, 2,5,4,3, 2,5,5,3, 2,5,6,3, 2,5,7,3, 2,5,8,3, 2,5,9,3, 2,6,0,3, 2,6,1,3, 2,6,2,3, 2,6,3,3, 2,6,4,3, 2,6,5,3, 2,6,6,3, 2,6,7,3, 2,6,8,3, 2,6,9,3, 2,7,0,3, 2,7,1,3, 2,7,2,3, 2,7,3,3, 2,7,4,3, 2,7,5,3, 2,7,6,3, 2,7,7,3, 2,7,8,3, 2,7,9,3, 2,8,0,3, 2,8,1,3, 2,8,2,3, 2,8,3,3, 2,8,4,3, 2,8,5,3, 2,8,6,3, 2,8,7,3, 2,8,8,3, 2,8,9,3, 2,9,0,3, 2,9,1,3, 2,9,2,3, 2,9,3,3, 2,9,4,3, 2,9,5,3, 2,9,6,3, 2,9,7,3, 2,9,8,3, 2,9,9,3, 3,0,0,3, 3,0,1,3, 3,0,2,3, 3,0,3,3, 3,0,4,3, 3,0,5,3, 3,0,6,3, 3,0,7,3, 3,0,8,3, 3,0,9,3, 3,1,0,3, 3,1,1,3, 3,1,2,3, 3,1,3,3, 3,1,4,3, 3,1,5,3, 3,1,6,3, 3,1,7,3, 3,1,8,3, 3,1,9,3, 3,2,0,3, 3,2,1,3, 3,2,2,3, 3,2,3,3, 3,2,4,3, 3,2,5,3, 3,2,6,3, 3,2,7,3, 3,2,8,3, 3,2,9,3, 3,3,0,3, 3,3,1,3, 3,3,2,3, 3,3,3,3, 3,3,4,3, 3,3,5,3, 3,3,6,3, 3,3,7,3, 3,3,8,3, 3,3,9,3, 3,4,0,3, 3,4,1,3, 3,4,2,3, 3,4,3,3, 3,4,4,3, 3,4,5,3, 3,4,6,3, 3,4,7,3, 3,4,8,3, 3,4,9,3, 3,5,0,3, 3,5,1,3, 3,5,2,3, 3,5,3,3, 3,5,4,3, 3,5,5,3, 3,5,6,3, 3,5,7,3, 3,5,8,3, 3,5,9,3, 3,6,0,3, 3,6,1,3, 3,6,2,3, 3,6,3,3, 3,6,4,3, 3,6,5,3, 3,6,6,3, 3,6,7,3, 3,6,8,3, 3,6,9,3, 3,7,0,3, 3,7,1,3, 3,7,2,3, 3,7,3,3, 3,7,4,3, 3,7,5,3, 3,7,6,3, 3,7,7,3, 3,7,8,3, 3,7,9,3, 3,8,0,3, 3,8,1,3, 3,8,2,3, 3,8,3,3, 3,8,4,3, 3,8,5,3, 3,8,6,3, 3,8,7,3, 3,8,8,3, 3,8,9,3, 3,9,0,3, 3,9,1,3, 3,9,2,3, 3,9,3,3, 3,9,4,3, 3,9,5,3, 3,9,6,3, 3,9,7,3, 3,9,8,3, 3,9,9,3, 4,0,0,3, 4,0,1,3, 4,0,2,3, 4,0,3,3, 4,0,4,3, 4,0,5,3, 4,0,6,3, 4,0,7,3, 4,0,8,3, 4,0,9,3, 4,1,0,3, 4,1,1,3, 4,1,2,3, 4,1,3,3, 4,1,4,3, 4,1,5,3, 4,1,6,3, 4,1,7,3, 4,1,8,3, 4,1,9,3, 4,2,0,3, 4,2,1,3, 4,2,2,3, 4,2,3,3, 4,2,4,3, 4,2,5,3, 4,2,6,3, 4,2,7,3, 4,2,8,3, 4,2,9,3, 4,3,0,3, 4,3,1,3, 4,3,2,3, 4,3,3,3, 4,3,4,3, 4,3,5,3, 4,3,6,3, 4,3,7,3, 4,3,8,3, 4,3,9,3, 4,4,0,3, 4,4,1,3, 4,4,2,3, 4,4,3,3, 4,4,4,3, 4,4,5,3, 4,4,6,3, 4,4,7,3, 4,4,8,3, 4,4,9,3, 4,5,0,3, 4,5,1,3, 4,5,2,3, 4,5,3,3, 4,5,4,3, 4,5,5,3, 4,5,6,3, 4,5,7,3, 4,5,8,3, 4,5,9,3, 4,6,0,3, 4,6,1,3, 4,6,2,3, 4,6,3,3, 4,6,4,3, 4,6,5,3, 4,6,6,3, 4,6,7,3, 4,6,8,3, 4,6,9,3, 4,7,0,3, 4,7,1,3, 4,7,2,3, 4,7,3,3, 4,7,4,3, 4,7,5,3, 4,7,6,3, 4,7,7,3, 4,7,8,3, 4,7,9,3, 4,8,0,3, 4,8,1,3, 4,8,2,3, 4,8,3,3, 4,8,4,3, 4,8,5,3, 4,8,6,3, 4,8,7,3, 4,8,8,3, 4,8,9,3, 4,9,0,3, 4,9,1,3, 4,9,2,3, 4,9,3,3, 4,9,4,3, 4,9,5,3, 4,9,6,3, 4,9,7,3, 4,9,8,3, 4,9,9,3, 5,0,0,3, 5,0,1,3, 5,0,2,3, 5,0,3,3, 5,0,4,3, 5,0,5,3, 5,0,6,3, 5,0,7,3, 5,0,8,3, 5,0,9,3, 5,1,0,3, 5,1,1,3, 5,1,2,3, 5,1,3,3, 5,1,4,3, 5,1,5,3, 5,1,6,3, 5,1,7,3, 5,1,8,3, 5,1,9,3, 5,2,0,3, 5,2,1,3, 5,2,2,3, 5,2,3,3, 5,2,4,3, 5,2,5,3, 5,2,6,3, 5,2,7,3, 5,2,8,3, 5,2,9,3, 5,3,0,3, 5,3,1,3, 5,3,2,3, 5,3,3,3, 5,3,4,3, 5,3,5,3, 5,3,6,3, 5,3,7,3, 5,3,8,3, 5,3,9,3, 5,4,0,3, 5,4,1,3, 5,4,2,3, 5,4,3,3, 5,4,4,3, 5,4,5,3, 5,4,6,3, 5,4,7,3, 5,4,8,3, 5,4,9,3, 5,5,0,3, 5,5,1,3, 5,5,2,3, 5,5,3,3, 5,5,4,3, 5,5,5,3, 5,5,6,3, 5,5,7,3, 5,5,8,3, 5,5,9,3, 5,6,0,3, 5,6,1,3, 5,6,2,3, 5,6,3,3, 5,6,4,3, 5,6,5,3, 5,6,6,3, 5,6,7,3, 5,6,8,3, 5,6,9,3, 5,7,0,3, 5,7,1,3, 5,7,2,3, 5,7,3,3, 5,7,4,3, 5,7,5,3, 5,7,6,3, 5,7,7,3, 5,7,8,3, 5,7,9,3, 5,8,0,3, 5,8,1,3, 5,8,2,3, 5,8,3,3, 5,8,4,3, 5,8,5,3, 5,8,6,3, 5,8,7,3, 5,8,8,3, 5,8,9,3, 5,9,0,3, 5,9,1,3, 5,9,2,3, 5,9,3,3, 5,9,4,3, 5,9,5,3, 5,9,6,3, 5,9,7,3, 5,9,8,3, 5,9,9,3, 6,0,0,3, 6,0,1,3, 6,0,2,3, 6,0,3,3, 6,0,4,3, 6,0,5,3, 6,0,6,3, 6,0,7,3, 6,0,8,3, 6,0,9,3, 6,1,0,3, 6,1,1,3, 6,1,2,3, 6,1,3,3, 6,1,4,3, 6,1,5,3, 6,1,6,3, 6,1,7,3, 6,1,8,3, 6,1,9,3, 6,2,0,3, 6,2,1,3, 6,2,2,3, 6,2,3,3, 6,2,4,3, 6,2,5,3, 6,2,6,3, 6,2,7,3, 6,2,8,3, 6,2,9,3, 6,3,0,3, 6,3,1,3, 6,3,2,3, 6,3,3,3, 6,3,4,3, 6,3,5,3, 6,3,6,3, 6,3,7,3, 6,3,8,3, 6,3,9,3, 6,4,0,3, 6,4,1,3, 6,4,2,3, 6,4,3,3, 6,4,4,3, 6,4,5,3, 6,4,6,3, 6,4,7,3, 6,4,8,3, 6,4,9,3, 6,5,0,3, 6,5,1,3, 6,5,2,3, 6,5,3,3, 6,5,4,3, 6,5,5,3, 6,5,6,3, 6,5,7,3, 6,5,8,3, 6,5,9,3, 6,6,0,3, 6,6,1,3, 6,6,2,3, 6,6,3,3, 6,6,4,3, 6,6,5,3, 6,6,6,3, 6,6,7,3, 6,6,8,3, 6,6,9,3, 6,7,0,3, 6,7,1,3, 6,7,2,3, 6,7,3,3, 6,7,4,3, 6,7,5,3, 6,7,6,3, 6,7,7,3, 6,7,8,3, 6,7,9,3, 6,8,0,3, 6,8,1,3, 6,8,2,3, 6,8,3,3, 6,8,4,3, 6,8,5,3, 6,8,6,3, 6,8,7,3, 6,8,8,3, 6,8,9,3, 6,9,0,3, 6,9,1,3, 6,9,2,3, 6,9,3,3, 6,9,4,3, 6,9,5,3, 6,9,6,3, 6,9,7,3, 6,9,8,3, 6,9,9,3, 7,0,0,3, 7,0,1,3, 7,0,2,3, 7,0,3,3, 7,0,4,3, 7,0,5,3, 7,0,6,3, 7,0,7,3, 7,0,8,3, 7,0,9,3, 7,1,0,3, 7,1,1,3, 7,1,2,3, 7,1,3,3, 7,1,4,3, 7,1,5,3, 7,1,6,3, 7,1,7,3, 7,1,8,3, 7,1,9,3, 7,2,0,3, 7,2,1,3, 7,2,2,3, 7,2,3,3, 7,2,4,3, 7,2,5,3, 7,2,6,3, 7,2,7,3, 7,2,8,3, 7,2,9,3, 7,3,0,3, 7,3,1,3, 7,3,2,3, 7,3,3,3, 7,3,4,3, 7,3,5,3, 7,3,6,3, 7,3,7,3, 7,3,8,3, 7,3,9,3, 7,4,0,3, 7,4,1,3, 7,4,2,3, 7,4,3,3, 7,4,4,3, 7,4,5,3, 7,4,6,3, 7,4,7,3, 7,4,8,3, 7,4,9,3, 7,5,0,3, 7,5,1,3, 7,5,2,3, 7,5,3,3, 7,5,4,3, 7,5,5,3, 7,5,6,3, 7,5,7,3, 7,5,8,3, 7,5,9,3, 7,6,0,3, 7,6,1,3, 7,6,2,3, 7,6,3,3, 7,6,4,3, 7,6,5,3, 7,6,6,3, 7,6,7,3, 7,6,8,3, 7,6,9,3, 7,7,0,3, 7,7,1,3, 7,7,2,3, 7,7,3,3, 7,7,4,3, 7,7,5,3, 7,7,6,3, 7,7,7,3, 7,7,8,3, 7,7,9,3, 7,8,0,3, 7,8,1,3, 7,8,2,3, 7,8,3,3, 7,8,4,3, 7,8,5,3, 7,8,6,3, 7,8,7,3, 7,8,8,3, 7,8,9,3, 7,9,0,3, 7,9,1,3, 7,9,2,3, 7,9,3,3, 7,9,4,3, 7,9,5,3, 7,9,6,3, 7,9,7,3, 7,9,8,3, 7,9,9,3, 8,0,0,3, 8,0,1,3, 8,0,2,3, 8,0,3,3, 8,0,4,3, 8,0,5,3, 8,0,6,3, 8,0,7,3, 8,0,8,3, 8,0,9,3, 8,1,0,3, 8,1,1,3, 8,1,2,3, 8,1,3,3, 8,1,4,3, 8,1,5,3, 8,1,6,3, 8,1,7,3, 8,1,8,3, 8,1,9,3, 8,2,0,3, 8,2,1,3, 8,2,2,3, 8,2,3,3, 8,2,4,3, 8,2,5,3, 8,2,6,3, 8,2,7,3, 8,2,8,3, 8,2,9,3, 8,3,0,3, 8,3,1,3, 8,3,2,3, 8,3,3,3, 8,3,4,3, 8,3,5,3, 8,3,6,3, 8,3,7,3, 8,3,8,3, 8,3,9,3, 8,4,0,3, 8,4,1,3, 8,4,2,3, 8,4,3,3, 8,4,4,3, 8,4,5,3, 8,4,6,3, 8,4,7,3, 8,4,8,3, 8,4,9,3, 8,5,0,3, 8,5,1,3, 8,5,2,3, 8,5,3,3, 8,5,4,3, 8,5,5,3, 8,5,6,3, 8,5,7,3, 8,5,8,3, 8,5,9,3, 8,6,0,3, 8,6,1,3, 8,6,2,3, 8,6,3,3, 8,6,4,3, 8,6,5,3, 8,6,6,3, 8,6,7,3, 8,6,8,3, 8,6,9,3, 8,7,0,3, 8,7,1,3, 8,7,2,3, 8,7,3,3, 8,7,4,3, 8,7,5,3, 8,7,6,3, 8,7,7,3, 8,7,8,3, 8,7,9,3, 8,8,0,3, 8,8,1,3, 8,8,2,3, 8,8,3,3, 8,8,4,3, 8,8,5,3, 8,8,6,3, 8,8,7,3, 8,8,8,3, 8,8,9,3, 8,9,0,3, 8,9,1,3, 8,9,2,3, 8,9,3,3, 8,9,4,3, 8,9,5,3, 8,9,6,3, 8,9,7,3, 8,9,8,3, 8,9,9,3, 9,0,0,3, 9,0,1,3, 9,0,2,3, 9,0,3,3, 9,0,4,3, 9,0,5,3, 9,0,6,3, 9,0,7,3, 9,0,8,3, 9,0,9,3, 9,1,0,3, 9,1,1,3, 9,1,2,3, 9,1,3,3, 9,1,4,3, 9,1,5,3, 9,1,6,3, 9,1,7,3, 9,1,8,3, 9,1,9,3, 9,2,0,3, 9,2,1,3, 9,2,2,3, 9,2,3,3, 9,2,4,3, 9,2,5,3, 9,2,6,3, 9,2,7,3, 9,2,8,3, 9,2,9,3, 9,3,0,3, 9,3,1,3, 9,3,2,3, 9,3,3,3, 9,3,4,3, 9,3,5,3, 9,3,6,3, 9,3,7,3, 9,3,8,3, 9,3,9,3, 9,4,0,3, 9,4,1,3, 9,4,2,3, 9,4,3,3, 9,4,4,3, 9,4,5,3, 9,4,6,3, 9,4,7,3, 9,4,8,3, 9,4,9,3, 9,5,0,3, 9,5,1,3, 9,5,2,3, 9,5,3,3, 9,5,4,3, 9,5,5,3, 9,5,6,3, 9,5,7,3, 9,5,8,3, 9,5,9,3, 9,6,0,3, 9,6,1,3, 9,6,2,3, 9,6,3,3, 9,6,4,3, 9,6,5,3, 9,6,6,3, 9,6,7,3, 9,6,8,3, 9,6,9,3, 9,7,0,3, 9,7,1,3, 9,7,2,3, 9,7,3,3, 9,7,4,3, 9,7,5,3, 9,7,6,3, 9,7,7,3, 9,7,8,3, 9,7,9,3, 9,8,0,3, 9,8,1,3, 9,8,2,3, 9,8,3,3, 9,8,4,3, 9,8,5,3, 9,8,6,3, 9,8,7,3, 9,8,8,3, 9,8,9,3, 9,9,0,3, 9,9,1,3, 9,9,2,3, 9,9,3,3, 9,9,4,3, 9,9,5,3, 9,9,6,3, 9,9,7,3, 9,9,8,3, 9,9,9,3}; #ifdef __cplusplus } #endif #endif libdfp-1.0.12/libdecnumber/decDebug.h000066400000000000000000000054661261375163000173600ustar00rootroot00000000000000/* Debug directives for libdecnumber. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #if DECTRACE || DECCHECK /* ------------------------------------------------------------------ */ /* decNumberShow -- display a number [debug aid] */ /* dn is the number to show */ /* */ /* Shows: sign, exponent, coefficient (msu first), digits */ /* or: sign, special-value */ /* ------------------------------------------------------------------ */ /* this is public so other modules can use it */ static inline void decNumberShow (const decNumber * dn) { const Unit *up; /* work */ uInt u, d; /* .. */ Int cut; /* .. */ char isign = '+'; /* main sign */ if (dn == NULL) { printf ("NULL\n"); return; } if (decNumberIsNegative (dn)) isign = '-'; printf (" >> %c ", isign); if (dn->bits & DECSPECIAL) { /* Is a special value */ if (decNumberIsInfinite (dn)) printf ("Infinity"); else { /* a NaN */ if (dn->bits & DECSNAN) printf ("sNaN"); /* signalling NaN */ else printf ("NaN"); } /* if coefficient and exponent are 0, no more to do */ if (dn->exponent == 0 && dn->digits == 1 && *dn->lsu == 0) { printf ("\n"); return; } /* drop through to report other information */ printf (" "); } /* now carefully display the coefficient */ up = dn->lsu + D2U (dn->digits) - 1; /* msu */ printf ("%ld", (LI) * up); for (up = up - 1; up >= dn->lsu; up--) { u = *up; printf (":"); for (cut = DECDPUN - 1; cut >= 0; cut--) { d = u / DECPOWERS[cut]; u -= d * DECPOWERS[cut]; printf ("%ld", (LI) d); } /* cut */ } /* up */ if (dn->exponent != 0) { char esign = '+'; if (dn->exponent < 0) esign = '-'; printf (" E%c%ld", esign, (LI) abs (dn->exponent)); } printf (" [%ld]\n", (LI) dn->digits); } /* decNumberShow */ #else # define decimal64Show(__x) # define decNumberShow(__x) #endif libdfp-1.0.12/libdecnumber/decDouble.c000066400000000000000000000141711261375163000175300ustar00rootroot00000000000000/* decDouble module for the decNumber C Library. Copyright (C) 2007-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------ */ /* decDouble.c -- decDouble operations module */ /* ------------------------------------------------------------------ */ /* This module comprises decDouble operations (including conversions) */ /* ------------------------------------------------------------------ */ #include "decContext.h" /* public includes */ #include "decDouble.h" /* .. */ /* Constant mappings for shared code */ #define DECPMAX DECDOUBLE_Pmax #define DECEMIN DECDOUBLE_Emin #define DECEMAX DECDOUBLE_Emax #define DECEMAXD DECDOUBLE_EmaxD #define DECBYTES DECDOUBLE_Bytes #define DECSTRING DECDOUBLE_String #define DECECONL DECDOUBLE_EconL #define DECBIAS DECDOUBLE_Bias #define DECLETS DECDOUBLE_Declets #define DECQTINY (-DECDOUBLE_Bias) /* parameters of next-wider format */ #define DECWBYTES DECQUAD_Bytes #define DECWPMAX DECQUAD_Pmax #define DECWECONL DECQUAD_EconL #define DECWBIAS DECQUAD_Bias /* Type and function mappings for shared code */ #define decFloat decDouble /* Type name */ #define decFloatWider decQuad /* Type name */ /* Utilities and conversions (binary results, extractors, etc.) */ #define decFloatFromBCD decDoubleFromBCD #define decFloatFromInt32 decDoubleFromInt32 #define decFloatFromPacked decDoubleFromPacked #define decFloatFromPackedChecked decDoubleFromPackedChecked #define decFloatFromString decDoubleFromString #define decFloatFromUInt32 decDoubleFromUInt32 #define decFloatFromWider decDoubleFromWider #define decFloatGetCoefficient decDoubleGetCoefficient #define decFloatGetExponent decDoubleGetExponent #define decFloatSetCoefficient decDoubleSetCoefficient #define decFloatSetExponent decDoubleSetExponent #define decFloatShow decDoubleShow #define decFloatToBCD decDoubleToBCD #define decFloatToEngString decDoubleToEngString #define decFloatToInt32 decDoubleToInt32 #define decFloatToInt32Exact decDoubleToInt32Exact #define decFloatToPacked decDoubleToPacked #define decFloatToString decDoubleToString #define decFloatToUInt32 decDoubleToUInt32 #define decFloatToUInt32Exact decDoubleToUInt32Exact #define decFloatToWider decDoubleToWider #define decFloatZero decDoubleZero /* Computational (result is a decFloat) */ #define decFloatAbs decDoubleAbs #define decFloatAdd decDoubleAdd #define decFloatAnd decDoubleAnd #define decFloatDivide decDoubleDivide #define decFloatDivideInteger decDoubleDivideInteger #define decFloatFMA decDoubleFMA #define decFloatInvert decDoubleInvert #define decFloatLogB decDoubleLogB #define decFloatMax decDoubleMax #define decFloatMaxMag decDoubleMaxMag #define decFloatMin decDoubleMin #define decFloatMinMag decDoubleMinMag #define decFloatMinus decDoubleMinus #define decFloatMultiply decDoubleMultiply #define decFloatNextMinus decDoubleNextMinus #define decFloatNextPlus decDoubleNextPlus #define decFloatNextToward decDoubleNextToward #define decFloatOr decDoubleOr #define decFloatPlus decDoublePlus #define decFloatQuantize decDoubleQuantize #define decFloatReduce decDoubleReduce #define decFloatRemainder decDoubleRemainder #define decFloatRemainderNear decDoubleRemainderNear #define decFloatRotate decDoubleRotate #define decFloatScaleB decDoubleScaleB #define decFloatShift decDoubleShift #define decFloatSubtract decDoubleSubtract #define decFloatToIntegralValue decDoubleToIntegralValue #define decFloatToIntegralExact decDoubleToIntegralExact #define decFloatXor decDoubleXor /* Comparisons */ #define decFloatCompare decDoubleCompare #define decFloatCompareSignal decDoubleCompareSignal #define decFloatCompareTotal decDoubleCompareTotal #define decFloatCompareTotalMag decDoubleCompareTotalMag /* Copies */ #define decFloatCanonical decDoubleCanonical #define decFloatCopy decDoubleCopy #define decFloatCopyAbs decDoubleCopyAbs #define decFloatCopyNegate decDoubleCopyNegate #define decFloatCopySign decDoubleCopySign /* Non-computational */ #define decFloatClass decDoubleClass #define decFloatClassString decDoubleClassString #define decFloatDigits decDoubleDigits #define decFloatIsCanonical decDoubleIsCanonical #define decFloatIsFinite decDoubleIsFinite #define decFloatIsInfinite decDoubleIsInfinite #define decFloatIsInteger decDoubleIsInteger #define decFloatIsNaN decDoubleIsNaN #define decFloatIsNormal decDoubleIsNormal #define decFloatIsSignaling decDoubleIsSignaling #define decFloatIsSignalling decDoubleIsSignalling #define decFloatIsSigned decDoubleIsSigned #define decFloatIsSubnormal decDoubleIsSubnormal #define decFloatIsZero decDoubleIsZero #define decFloatRadix decDoubleRadix #define decFloatSameQuantum decDoubleSameQuantum #define decFloatVersion decDoubleVersion #include "decNumberLocal.h" /* local includes (need DECPMAX) */ #include "decCommon.c" /* non-arithmetic decFloat routines */ #include "decBasic.c" /* basic formats routines */ libdfp-1.0.12/libdecnumber/decDouble.h000066400000000000000000000235001261375163000175310ustar00rootroot00000000000000/* decDouble module header for the decNumber C Library. Copyright (C) 2007-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------ */ /* decDouble.h -- Decimal 64-bit format module header */ /* ------------------------------------------------------------------ */ #if !defined(DECDOUBLE) #define DECDOUBLE #define DECDOUBLENAME "decimalDouble" /* Short name */ #define DECDOUBLETITLE "Decimal 64-bit datum" /* Verbose name */ #define DECDOUBLEAUTHOR "Mike Cowlishaw" /* Who to blame */ /* parameters for decDoubles */ #define DECDOUBLE_Bytes 8 /* length */ #define DECDOUBLE_Pmax 16 /* maximum precision (digits) */ #define DECDOUBLE_Emin -383 /* minimum adjusted exponent */ #define DECDOUBLE_Emax 384 /* maximum adjusted exponent */ #define DECDOUBLE_EmaxD 3 /* maximum exponent digits */ #define DECDOUBLE_Bias 398 /* bias for the exponent */ #define DECDOUBLE_String 25 /* maximum string length, +1 */ #define DECDOUBLE_EconL 8 /* exponent continuation length */ #define DECDOUBLE_Declets 5 /* count of declets */ /* highest biased exponent (Elimit-1) */ #define DECDOUBLE_Ehigh (DECDOUBLE_Emax + DECDOUBLE_Bias - (DECDOUBLE_Pmax-1)) /* Required includes */ #include "decContext.h" #include "decQuad.h" /* The decDouble decimal 64-bit type, accessible by all sizes */ typedef union { uint8_t bytes[DECDOUBLE_Bytes]; /* fields: 1, 5, 8, 50 bits */ uint16_t shorts[DECDOUBLE_Bytes/2]; uint32_t words[DECDOUBLE_Bytes/4]; #if DECUSE64 uint64_t longs[DECDOUBLE_Bytes/8]; #endif } decDouble; /* ---------------------------------------------------------------- */ /* Routines -- implemented as decFloat routines in common files */ /* ---------------------------------------------------------------- */ #include "decDoubleSymbols.h" /* Utilities and conversions, extractors, etc.) */ extern decDouble * decDoubleFromBCD(decDouble *, int32_t, const uint8_t *, int32_t); extern decDouble * decDoubleFromInt32(decDouble *, int32_t); extern decDouble * decDoubleFromPacked(decDouble *, int32_t, const uint8_t *); extern decDouble * decDoubleFromPackedChecked(decDouble *, int32_t, const uint8_t *); extern decDouble * decDoubleFromString(decDouble *, const char *, decContext *); extern decDouble * decDoubleFromUInt32(decDouble *, uint32_t); extern decDouble * decDoubleFromWider(decDouble *, const decQuad *, decContext *); extern int32_t decDoubleGetCoefficient(const decDouble *, uint8_t *); extern int32_t decDoubleGetExponent(const decDouble *); extern decDouble * decDoubleSetCoefficient(decDouble *, const uint8_t *, int32_t); extern decDouble * decDoubleSetExponent(decDouble *, decContext *, int32_t); extern void decDoubleShow(const decDouble *, const char *); extern int32_t decDoubleToBCD(const decDouble *, int32_t *, uint8_t *); extern char * decDoubleToEngString(const decDouble *, char *); extern int32_t decDoubleToInt32(const decDouble *, decContext *, enum rounding); extern int32_t decDoubleToInt32Exact(const decDouble *, decContext *, enum rounding); extern int32_t decDoubleToPacked(const decDouble *, int32_t *, uint8_t *); extern char * decDoubleToString(const decDouble *, char *); extern uint32_t decDoubleToUInt32(const decDouble *, decContext *, enum rounding); extern uint32_t decDoubleToUInt32Exact(const decDouble *, decContext *, enum rounding); extern decQuad * decDoubleToWider(const decDouble *, decQuad *); extern decDouble * decDoubleZero(decDouble *); /* Computational (result is a decDouble) */ extern decDouble * decDoubleAbs(decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleAdd(decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleAnd(decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleDivide(decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleDivideInteger(decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleFMA(decDouble *, const decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleInvert(decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleLogB(decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleMax(decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleMaxMag(decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleMin(decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleMinMag(decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleMinus(decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleMultiply(decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleNextMinus(decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleNextPlus(decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleNextToward(decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleOr(decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoublePlus(decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleQuantize(decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleReduce(decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleRemainder(decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleRemainderNear(decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleRotate(decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleScaleB(decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleShift(decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleSubtract(decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleToIntegralValue(decDouble *, const decDouble *, decContext *, enum rounding); extern decDouble * decDoubleToIntegralExact(decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleXor(decDouble *, const decDouble *, const decDouble *, decContext *); /* Comparisons */ extern decDouble * decDoubleCompare(decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleCompareSignal(decDouble *, const decDouble *, const decDouble *, decContext *); extern decDouble * decDoubleCompareTotal(decDouble *, const decDouble *, const decDouble *); extern decDouble * decDoubleCompareTotalMag(decDouble *, const decDouble *, const decDouble *); /* Copies */ extern decDouble * decDoubleCanonical(decDouble *, const decDouble *); extern decDouble * decDoubleCopy(decDouble *, const decDouble *); extern decDouble * decDoubleCopyAbs(decDouble *, const decDouble *); extern decDouble * decDoubleCopyNegate(decDouble *, const decDouble *); extern decDouble * decDoubleCopySign(decDouble *, const decDouble *, const decDouble *); /* Non-computational */ extern enum decClass decDoubleClass(const decDouble *); extern const char * decDoubleClassString(const decDouble *); extern uint32_t decDoubleDigits(const decDouble *); extern uint32_t decDoubleIsCanonical(const decDouble *); extern uint32_t decDoubleIsFinite(const decDouble *); extern uint32_t decDoubleIsInfinite(const decDouble *); extern uint32_t decDoubleIsInteger(const decDouble *); extern uint32_t decDoubleIsNaN(const decDouble *); extern uint32_t decDoubleIsNormal(const decDouble *); extern uint32_t decDoubleIsSignaling(const decDouble *); extern uint32_t decDoubleIsSignalling(const decDouble *); extern uint32_t decDoubleIsSigned(const decDouble *); extern uint32_t decDoubleIsSubnormal(const decDouble *); extern uint32_t decDoubleIsZero(const decDouble *); extern uint32_t decDoubleRadix(const decDouble *); extern uint32_t decDoubleSameQuantum(const decDouble *, const decDouble *); extern const char * decDoubleVersion(void); /* decNumber conversions; these are implemented as macros so as not */ /* to force a dependency on decimal64 and decNumber in decDouble. */ /* decDoubleFromNumber returns a decimal64 * to avoid warnings. */ #define decDoubleToNumber(dq, dn) decimal64ToNumber((decimal64 *)(dq), dn) #define decDoubleFromNumber(dq, dn, set) decimal64FromNumber((decimal64 *)(dq), dn, set) #endif libdfp-1.0.12/libdecnumber/decExcept.c000066400000000000000000000031401261375163000175400ustar00rootroot00000000000000/* Temporary library support for decimal floating point. Copyright (C) 2005-2015 Free Software Foundation, Inc. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ #include #include "dconfig.h" #include "decContext.h" #include "decExcept.h" /* Internal, non-documented functions for testing libgcc functions. This support is not sufficient for real use. */ static int __dfp_except_flags = 0; /* Clear the dummy exception flags. */ void __dfp_clear_except (void) { __dfp_except_flags = 0; } /* Return the dummy exception flags corresponding to the mask. */ int __dfp_test_except (int mask) { return __dfp_except_flags & mask; } /* Set dummy exception flags. */ void __dfp_raise_except (int flags) { __dfp_except_flags |= flags; } libdfp-1.0.12/libdecnumber/decExcept.h000066400000000000000000000024051261375163000175500ustar00rootroot00000000000000/* Temporary library support for decimal floating point. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ #include #include "dconfig.h" #include "decContext.h" #define DFP_EXCEPTIONS_ENABLED 1 #define DFP_HANDLE_EXCEPTIONS(A) __dfp_raise_except(A) void __dfp_clear_except (void); int __dfp_test_except (int); void __dfp_raise_except (int); libdfp-1.0.12/libdecnumber/decLibrary.c000066400000000000000000000036721261375163000177260ustar00rootroot00000000000000/* Temporary library support for decimal floating point. Copyright (C) 2005-2015 Free Software Foundation, Inc. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ #include "dconfig.h" #include "decContext.h" #include "decimal128.h" #include "decimal64.h" #include "decimal32.h" void __host_to_ieee_32 (_Decimal32, decimal32 *); void __host_to_ieee_64 (_Decimal64, decimal64 *); void __host_to_ieee_128 (_Decimal128, decimal128 *); extern int isinfd32 (_Decimal32); extern int isinfd64 (_Decimal64); extern int isinfd128 (_Decimal128); uint32_t __dec_byte_swap (uint32_t); int isinfd32 (_Decimal32 arg) { decNumber dn; decimal32 d32; __host_to_ieee_32 (arg, &d32); decimal32ToNumber (&d32, &dn); return (decNumberIsInfinite (&dn)); } int isinfd64 (_Decimal64 arg) { decNumber dn; decimal64 d64; __host_to_ieee_64 (arg, &d64); decimal64ToNumber (&d64, &dn); return (decNumberIsInfinite (&dn)); } int isinfd128 (_Decimal128 arg) { decNumber dn; decimal128 d128; __host_to_ieee_128 (arg, &d128); decimal128ToNumber (&d128, &dn); return (decNumberIsInfinite (&dn)); } libdfp-1.0.12/libdecnumber/decNumber.c000066400000000000000000011771411261375163000175560ustar00rootroot00000000000000/* Decimal number arithmetic module for the decNumber C Library. Copyright (C) 2005-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------ */ /* Decimal Number arithmetic module */ /* ------------------------------------------------------------------ */ /* This module comprises the routines for arbitrary-precision General */ /* Decimal Arithmetic as defined in the specification which may be */ /* found on the General Decimal Arithmetic pages. It implements both */ /* the full ('extended') arithmetic and the simpler ('subset') */ /* arithmetic. */ /* */ /* Usage notes: */ /* */ /* 1. This code is ANSI C89 except: */ /* */ /* a) C99 line comments (double forward slash) are used. (Most C */ /* compilers accept these. If yours does not, a simple script */ /* can be used to convert them to ANSI C comments.) */ /* */ /* b) Types from C99 stdint.h are used. If you do not have this */ /* header file, see the User's Guide section of the decNumber */ /* documentation; this lists the necessary definitions. */ /* */ /* c) If DECDPUN>4 or DECUSE64=1, the C99 64-bit int64_t and */ /* uint64_t types may be used. To avoid these, set DECUSE64=0 */ /* and DECDPUN<=4 (see documentation). */ /* */ /* The code also conforms to C99 restrictions; in particular, */ /* strict aliasing rules are observed. */ /* */ /* 2. The decNumber format which this library uses is optimized for */ /* efficient processing of relatively short numbers; in particular */ /* it allows the use of fixed sized structures and minimizes copy */ /* and move operations. It does, however, support arbitrary */ /* precision (up to 999,999,999 digits) and arbitrary exponent */ /* range (Emax in the range 0 through 999,999,999 and Emin in the */ /* range -999,999,999 through 0). Mathematical functions (for */ /* example decNumberExp) as identified below are restricted more */ /* tightly: digits, emax, and -emin in the context must be <= */ /* DEC_MAX_MATH (999999), and their operand(s) must be within */ /* these bounds. */ /* */ /* 3. Logical functions are further restricted; their operands must */ /* be finite, positive, have an exponent of zero, and all digits */ /* must be either 0 or 1. The result will only contain digits */ /* which are 0 or 1 (and will have exponent=0 and a sign of 0). */ /* */ /* 4. Operands to operator functions are never modified unless they */ /* are also specified to be the result number (which is always */ /* permitted). Other than that case, operands must not overlap. */ /* */ /* 5. Error handling: the type of the error is ORed into the status */ /* flags in the current context (decContext structure). The */ /* SIGFPE signal is then raised if the corresponding trap-enabler */ /* flag in the decContext is set (is 1). */ /* */ /* It is the responsibility of the caller to clear the status */ /* flags as required. */ /* */ /* The result of any routine which returns a number will always */ /* be a valid number (which may be a special value, such as an */ /* Infinity or NaN). */ /* */ /* 6. The decNumber format is not an exchangeable concrete */ /* representation as it comprises fields which may be machine- */ /* dependent (packed or unpacked, or special length, for example). */ /* Canonical conversions to and from strings are provided; other */ /* conversions are available in separate modules. */ /* */ /* 7. Normally, input operands are assumed to be valid. Set DECCHECK */ /* to 1 for extended operand checking (including NULL operands). */ /* Results are undefined if a badly-formed structure (or a NULL */ /* pointer to a structure) is provided, though with DECCHECK */ /* enabled the operator routines are protected against exceptions. */ /* (Except if the result pointer is NULL, which is unrecoverable.) */ /* */ /* However, the routines will never cause exceptions if they are */ /* given well-formed operands, even if the value of the operands */ /* is inappropriate for the operation and DECCHECK is not set. */ /* (Except for SIGFPE, as and where documented.) */ /* */ /* 8. Subset arithmetic is available only if DECSUBSET is set to 1. */ /* ------------------------------------------------------------------ */ /* Implementation notes for maintenance of this module: */ /* */ /* 1. Storage leak protection: Routines which use malloc are not */ /* permitted to use return for fastpath or error exits (i.e., */ /* they follow strict structured programming conventions). */ /* Instead they have a do{}while(0); construct surrounding the */ /* code which is protected -- break may be used to exit this. */ /* Other routines can safely use the return statement inline. */ /* */ /* Storage leak accounting can be enabled using DECALLOC. */ /* */ /* 2. All loops use the for(;;) construct. Any do construct does */ /* not loop; it is for allocation protection as just described. */ /* */ /* 3. Setting status in the context must always be the very last */ /* action in a routine, as non-0 status may raise a trap and hence */ /* the call to set status may not return (if the handler uses long */ /* jump). Therefore all cleanup must be done first. In general, */ /* to achieve this status is accumulated and is only applied just */ /* before return by calling decContextSetStatus (via decStatus). */ /* */ /* Routines which allocate storage cannot, in general, use the */ /* 'top level' routines which could cause a non-returning */ /* transfer of control. The decXxxxOp routines are safe (do not */ /* call decStatus even if traps are set in the context) and should */ /* be used instead (they are also a little faster). */ /* */ /* 4. Exponent checking is minimized by allowing the exponent to */ /* grow outside its limits during calculations, provided that */ /* the decFinalize function is called later. Multiplication and */ /* division, and intermediate calculations in exponentiation, */ /* require more careful checks because of the risk of 31-bit */ /* overflow (the most negative valid exponent is -1999999997, for */ /* a 999999999-digit number with adjusted exponent of -999999999). */ /* */ /* 5. Rounding is deferred until finalization of results, with any */ /* 'off to the right' data being represented as a single digit */ /* residue (in the range -1 through 9). This avoids any double- */ /* rounding when more than one shortening takes place (for */ /* example, when a result is subnormal). */ /* */ /* 6. The digits count is allowed to rise to a multiple of DECDPUN */ /* during many operations, so whole Units are handled and exact */ /* accounting of digits is not needed. The correct digits value */ /* is found by decGetDigits, which accounts for leading zeros. */ /* This must be called before any rounding if the number of digits */ /* is not known exactly. */ /* */ /* 7. The multiply-by-reciprocal 'trick' is used for partitioning */ /* numbers up to four digits, using appropriate constants. This */ /* is not useful for longer numbers because overflow of 32 bits */ /* would lead to 4 multiplies, which is almost as expensive as */ /* a divide (unless a floating-point or 64-bit multiply is */ /* assumed to be available). */ /* */ /* 8. Unusual abbreviations that may be used in the commentary: */ /* lhs -- left hand side (operand, of an operation) */ /* lsd -- least significant digit (of coefficient) */ /* lsu -- least significant Unit (of coefficient) */ /* msd -- most significant digit (of coefficient) */ /* msi -- most significant item (in an array) */ /* msu -- most significant Unit (of coefficient) */ /* rhs -- right hand side (operand, of an operation) */ /* +ve -- positive */ /* -ve -- negative */ /* ** -- raise to the power */ /* ------------------------------------------------------------------ */ #include /* for malloc, free, etc. */ #include /* for printf [if needed] */ #include /* for strcpy */ #include /* for lower */ #include "dconfig.h" /* for GCC definitions */ #include "decNumber.h" /* base number library */ #include "decNumberLocal.h" /* decNumber local types, etc. */ #include "decDebug.h" /* Constants */ /* Public lookup table used by the D2U macro */ const uByte d2utable[DECMAXD2U+1]=D2UTABLE; #define DECVERB 1 /* set to 1 for verbose DECCHECK */ #define powers DECPOWERS /* old internal name */ /* Local constants */ #define DIVIDE 0x80 /* Divide operators */ #define REMAINDER 0x40 /* .. */ #define DIVIDEINT 0x20 /* .. */ #define REMNEAR 0x10 /* .. */ #define COMPARE 0x01 /* Compare operators */ #define COMPMAX 0x02 /* .. */ #define COMPMIN 0x03 /* .. */ #define COMPTOTAL 0x04 /* .. */ #define COMPNAN 0x05 /* .. [NaN processing] */ #define COMPSIG 0x06 /* .. [signaling COMPARE] */ #define COMPMAXMAG 0x07 /* .. */ #define COMPMINMAG 0x08 /* .. */ #define DEC_sNaN 0x40000000 /* local status: sNaN signal */ #define BADINT (Int)0x80000000 /* most-negative Int; error indicator */ /* Next two indicate an integer >= 10**6, and its parity (bottom bit) */ #define BIGEVEN (Int)0x80000002 #define BIGODD (Int)0x80000003 static Unit uarrone[1]={1}; /* Unit array of 1, used for incrementing */ /* Granularity-dependent code */ #if DECDPUN<=4 #define eInt Int /* extended integer */ #define ueInt uInt /* unsigned extended integer */ /* Constant multipliers for divide-by-power-of five using reciprocal */ /* multiply, after removing powers of 2 by shifting, and final shift */ /* of 17 [we only need up to **4] */ static const uInt multies[]={131073, 26215, 5243, 1049, 210}; /* QUOT10 -- macro to return the quotient of unit u divided by 10**n */ #define QUOT10(u, n) ((((uInt)(u)>>(n))*multies[n])>>17) #else /* For DECDPUN>4 non-ANSI-89 64-bit types are needed. */ #if !DECUSE64 #error decNumber.c: DECUSE64 must be 1 when DECDPUN>4 #endif #define eInt Long /* extended integer */ #define ueInt uLong /* unsigned extended integer */ #endif /* Local routines */ static decNumber * decAddOp(decNumber *, const decNumber *, const decNumber *, decContext *, uByte, uInt *); static Flag decBiStr(const char *, const char *, const char *); static uInt decCheckMath(const decNumber *, decContext *, uInt *); static void decApplyRound(decNumber *, decContext *, Int, uInt *); static Int decCompare(const decNumber *lhs, const decNumber *rhs, Flag); static decNumber * decCompareOp(decNumber *, const decNumber *, const decNumber *, decContext *, Flag, uInt *); static void decCopyFit(decNumber *, const decNumber *, decContext *, Int *, uInt *); static decNumber * decDecap(decNumber *, Int); static decNumber * decDivideOp(decNumber *, const decNumber *, const decNumber *, decContext *, Flag, uInt *); static decNumber * decExpOp(decNumber *, const decNumber *, decContext *, uInt *); static void decFinalize(decNumber *, decContext *, Int *, uInt *); static Int decGetDigits(Unit *, Int); static Int decGetInt(const decNumber *); static decNumber * decLnOp(decNumber *, const decNumber *, decContext *, uInt *); static decNumber * decMultiplyOp(decNumber *, const decNumber *, const decNumber *, decContext *, uInt *); static decNumber * decNaNs(decNumber *, const decNumber *, const decNumber *, decContext *, uInt *); static decNumber * decQuantizeOp(decNumber *, const decNumber *, const decNumber *, decContext *, Flag, uInt *); static void decReverse(Unit *, Unit *); static void decSetCoeff(decNumber *, decContext *, const Unit *, Int, Int *, uInt *); static void decSetMaxValue(decNumber *, decContext *); static void decSetOverflow(decNumber *, decContext *, uInt *); static void decSetSubnormal(decNumber *, decContext *, Int *, uInt *); static Int decShiftToLeast(Unit *, Int, Int); static Int decShiftToMost(Unit *, Int, Int); static void decStatus(decNumber *, uInt, decContext *); static void decToString(const decNumber *, char[], Flag); static decNumber * decTrim(decNumber *, decContext *, Flag, Flag, Int *); static Int decUnitAddSub(const Unit *, Int, const Unit *, Int, Int, Unit *, Int); static Int decUnitCompare(const Unit *, Int, const Unit *, Int, Int); #if !DECSUBSET /* decFinish == decFinalize when no subset arithmetic needed */ #define decFinish(a,b,c,d) decFinalize(a,b,c,d) #else static void decFinish(decNumber *, decContext *, Int *, uInt *); static decNumber * decRoundOperand(const decNumber *, decContext *, uInt *); #endif /* Local macros */ /* masked special-values bits */ #define SPECIALARG (rhs->bits & DECSPECIAL) #define SPECIALARGS ((lhs->bits | rhs->bits) & DECSPECIAL) /* Diagnostic macros, etc. */ #if DECALLOC /* Handle malloc/free accounting. If enabled, our accountable routines */ /* are used; otherwise the code just goes straight to the system malloc */ /* and free routines. */ #define malloc(a) decMalloc(a) #define free(a) decFree(a) #define DECFENCE 0x5a /* corruption detector */ /* 'Our' malloc and free: */ static void *decMalloc(size_t); static void decFree(void *); uInt decAllocBytes=0; /* count of bytes allocated */ /* Note that DECALLOC code only checks for storage buffer overflow. */ /* To check for memory leaks, the decAllocBytes variable must be */ /* checked to be 0 at appropriate times (e.g., after the test */ /* harness completes a set of tests). This checking may be unreliable */ /* if the testing is done in a multi-thread environment. */ #endif #if DECCHECK /* Optional checking routines. Enabling these means that decNumber */ /* and decContext operands to operator routines are checked for */ /* correctness. This roughly doubles the execution time of the */ /* fastest routines (and adds 600+ bytes), so should not normally be */ /* used in 'production'. */ /* decCheckInexact is used to check that inexact results have a full */ /* complement of digits (where appropriate -- this is not the case */ /* for Quantize, for example) */ #define DECUNRESU ((decNumber *)(void *)0xffffffff) #define DECUNUSED ((const decNumber *)(void *)0xffffffff) #define DECUNCONT ((decContext *)(void *)(0xffffffff)) static Flag decCheckOperands(decNumber *, const decNumber *, const decNumber *, decContext *); static Flag decCheckNumber(const decNumber *); static void decCheckInexact(const decNumber *, decContext *); #endif #if DECTRACE || DECCHECK /* Optional trace/debugging routines (may or may not be used) */ static void decDumpAr(char, const Unit *, Int); #endif /* ================================================================== */ /* Conversions */ /* ================================================================== */ /* ------------------------------------------------------------------ */ /* from-int32 -- conversion from Int or uInt */ /* */ /* dn is the decNumber to receive the integer */ /* in or uin is the integer to be converted */ /* returns dn */ /* */ /* No error is possible. */ /* ------------------------------------------------------------------ */ decNumber * decNumberFromInt32(decNumber *dn, Int in) { uInt unsig; if (in>=0) unsig=in; else { /* negative (possibly BADINT) */ if (in==BADINT) unsig=(uInt)1073741824*2; /* special case */ else unsig=-in; /* invert */ } /* in is now positive */ decNumberFromUInt32(dn, unsig); if (in<0) dn->bits=DECNEG; /* sign needed */ return dn; } /* decNumberFromInt32 */ decNumber * decNumberFromUInt32(decNumber *dn, uInt uin) { Unit *up; /* work pointer */ decNumberZero(dn); /* clean */ if (uin==0) return dn; /* [or decGetDigits bad call] */ for (up=dn->lsu; uin>0; up++) { *up=(Unit)(uin%(DECDPUNMAX+1)); uin=uin/(DECDPUNMAX+1); } dn->digits=decGetDigits(dn->lsu, up-dn->lsu); return dn; } /* decNumberFromUInt32 */ /* ------------------------------------------------------------------ */ /* to-int32 -- conversion to Int or uInt */ /* */ /* dn is the decNumber to convert */ /* set is the context for reporting errors */ /* returns the converted decNumber, or 0 if Invalid is set */ /* */ /* Invalid is set if the decNumber does not have exponent==0 or if */ /* it is a NaN, Infinite, or out-of-range. */ /* ------------------------------------------------------------------ */ Int decNumberToInt32(const decNumber *dn, decContext *set) { #if DECCHECK if (decCheckOperands(DECUNRESU, DECUNUSED, dn, set)) return 0; #endif /* special or too many digits, or bad exponent */ if (dn->bits&DECSPECIAL || dn->digits>10 || dn->exponent!=0) ; /* bad */ else { /* is a finite integer with 10 or fewer digits */ Int d; /* work */ const Unit *up; /* .. */ uInt hi=0, lo; /* .. */ up=dn->lsu; /* -> lsu */ lo=*up; /* get 1 to 9 digits */ #if DECDPUN>1 /* split to higher */ hi=lo/10; lo=lo%10; #endif up++; /* collect remaining Units, if any, into hi */ for (d=DECDPUN; ddigits; up++, d+=DECDPUN) hi+=*up*powers[d-1]; /* now low has the lsd, hi the remainder */ if (hi>214748364 || (hi==214748364 && lo>7)) { /* out of range? */ /* most-negative is a reprieve */ if (dn->bits&DECNEG && hi==214748364 && lo==8) return 0x80000000; /* bad -- drop through */ } else { /* in-range always */ Int i=X10(hi)+lo; if (dn->bits&DECNEG) return -i; return i; } } /* integer */ decContextSetStatus(set, DEC_Invalid_operation); /* [may not return] */ return 0; } /* decNumberToInt32 */ uInt decNumberToUInt32(const decNumber *dn, decContext *set) { #if DECCHECK if (decCheckOperands(DECUNRESU, DECUNUSED, dn, set)) return 0; #endif /* special or too many digits, or bad exponent, or negative (<0) */ if (dn->bits&DECSPECIAL || dn->digits>10 || dn->exponent!=0 || (dn->bits&DECNEG && !ISZERO(dn))); /* bad */ else { /* is a finite integer with 10 or fewer digits */ Int d; /* work */ const Unit *up; /* .. */ uInt hi=0, lo; /* .. */ up=dn->lsu; /* -> lsu */ lo=*up; /* get 1 to 9 digits */ #if DECDPUN>1 /* split to higher */ hi=lo/10; lo=lo%10; #endif up++; /* collect remaining Units, if any, into hi */ for (d=DECDPUN; ddigits; up++, d+=DECDPUN) hi+=*up*powers[d-1]; /* now low has the lsd, hi the remainder */ if (hi>429496729 || (hi==429496729 && lo>5)) ; /* no reprieve possible */ else return X10(hi)+lo; } /* integer */ decContextSetStatus(set, DEC_Invalid_operation); /* [may not return] */ return 0; } /* decNumberToUInt32 */ /* ------------------------------------------------------------------ */ /* to-scientific-string -- conversion to numeric string */ /* to-engineering-string -- conversion to numeric string */ /* */ /* decNumberToString(dn, string); */ /* decNumberToEngString(dn, string); */ /* */ /* dn is the decNumber to convert */ /* string is the string where the result will be laid out */ /* */ /* string must be at least dn->digits+14 characters long */ /* */ /* No error is possible, and no status can be set. */ /* ------------------------------------------------------------------ */ char * decNumberToString(const decNumber *dn, char *string){ decToString(dn, string, 0); return string; } /* DecNumberToString */ char * decNumberToEngString(const decNumber *dn, char *string){ decToString(dn, string, 1); return string; } /* DecNumberToEngString */ /* ------------------------------------------------------------------ */ /* to-number -- conversion from numeric string */ /* */ /* decNumberFromString -- convert string to decNumber */ /* dn -- the number structure to fill */ /* chars[] -- the string to convert ('\0' terminated) */ /* set -- the context used for processing any error, */ /* determining the maximum precision available */ /* (set.digits), determining the maximum and minimum */ /* exponent (set.emax and set.emin), determining if */ /* extended values are allowed, and checking the */ /* rounding mode if overflow occurs or rounding is */ /* needed. */ /* */ /* The length of the coefficient and the size of the exponent are */ /* checked by this routine, so the correct error (Underflow or */ /* Overflow) can be reported or rounding applied, as necessary. */ /* */ /* If bad syntax is detected, the result will be a quiet NaN. */ /* ------------------------------------------------------------------ */ decNumber * decNumberFromString(decNumber *dn, const char chars[], decContext *set) { Int exponent=0; /* working exponent [assume 0] */ uByte bits=0; /* working flags [assume +ve] */ Unit *res; /* where result will be built */ Unit resbuff[SD2U(DECBUFFER+9)];/* local buffer in case need temporary */ /* [+9 allows for ln() constants] */ Unit *allocres=NULL; /* -> allocated result, iff allocated */ Int d=0; /* count of digits found in decimal part */ const char *dotchar=NULL; /* where dot was found */ const char *cfirst=chars; /* -> first character of decimal part */ const char *last=NULL; /* -> last digit of decimal part */ const char *c; /* work */ Unit *up; /* .. */ #if DECDPUN>1 Int cut, out; /* .. */ #endif Int residue; /* rounding residue */ uInt status=0; /* error code */ #if DECCHECK if (decCheckOperands(DECUNRESU, DECUNUSED, DECUNUSED, set)) return decNumberZero(dn); #endif do { /* status & malloc protection */ for (c=chars;; c++) { /* -> input character */ if (*c>='0' && *c<='9') { /* test for Arabic digit */ last=c; d++; /* count of real digits */ continue; /* still in decimal part */ } if (*c=='.' && dotchar==NULL) { /* first '.' */ dotchar=c; /* record offset into decimal part */ if (c==cfirst) cfirst++; /* first digit must follow */ continue;} if (c==chars) { /* first in string... */ if (*c=='-') { /* valid - sign */ cfirst++; bits=DECNEG; continue;} if (*c=='+') { /* valid + sign */ cfirst++; continue;} } /* *c is not a digit, or a valid +, -, or '.' */ break; } /* c */ if (last==NULL) { /* no digits yet */ status=DEC_Conversion_syntax;/* assume the worst */ if (*c=='\0') break; /* and no more to come... */ #if DECSUBSET /* if subset then infinities and NaNs are not allowed */ if (!set->extended) break; /* hopeless */ #endif /* Infinities and NaNs are possible, here */ if (dotchar!=NULL) break; /* .. unless had a dot */ decNumberZero(dn); /* be optimistic */ if (decBiStr(c, "infinity", "INFINITY") || decBiStr(c, "inf", "INF")) { dn->bits=bits | DECINF; status=0; /* is OK */ break; /* all done */ } /* a NaN expected */ /* 2003.09.10 NaNs are now permitted to have a sign */ dn->bits=bits | DECNAN; /* assume simple NaN */ if (*c=='s' || *c=='S') { /* looks like an sNaN */ c++; dn->bits=bits | DECSNAN; } if (*c!='n' && *c!='N') break; /* check caseless "NaN" */ c++; if (*c!='a' && *c!='A') break; /* .. */ c++; if (*c!='n' && *c!='N') break; /* .. */ c++; /* now either nothing, or nnnn payload, expected */ /* -> start of integer and skip leading 0s [including plain 0] */ for (cfirst=c; *cfirst=='0';) cfirst++; if (*cfirst=='\0') { /* "NaN" or "sNaN", maybe with all 0s */ status=0; /* it's good */ break; /* .. */ } /* something other than 0s; setup last and d as usual [no dots] */ for (c=cfirst;; c++, d++) { if (*c<'0' || *c>'9') break; /* test for Arabic digit */ last=c; } if (*c!='\0') break; /* not all digits */ if (d>set->digits-1) { /* [NB: payload in a decNumber can be full length unless */ /* clamped, in which case can only be digits-1] */ if (set->clamp) break; if (d>set->digits) break; } /* too many digits? */ /* good; drop through to convert the integer to coefficient */ status=0; /* syntax is OK */ bits=dn->bits; /* for copy-back */ } /* last==NULL */ else if (*c!='\0') { /* more to process... */ /* had some digits; exponent is only valid sequence now */ Flag nege; /* 1=negative exponent */ const char *firstexp; /* -> first significant exponent digit */ status=DEC_Conversion_syntax;/* assume the worst */ if (*c!='e' && *c!='E') break; /* Found 'e' or 'E' -- now process explicit exponent */ /* 1998.07.11: sign no longer required */ nege=0; c++; /* to (possible) sign */ if (*c=='-') {nege=1; c++;} else if (*c=='+') c++; if (*c=='\0') break; for (; *c=='0' && *(c+1)!='\0';) c++; /* strip insignificant zeros */ firstexp=c; /* save exponent digit place */ for (; ;c++) { if (*c<'0' || *c>'9') break; /* not a digit */ exponent=X10(exponent)+(Int)*c-(Int)'0'; } /* c */ /* if not now on a '\0', *c must not be a digit */ if (*c!='\0') break; /* (this next test must be after the syntax checks) */ /* if it was too long the exponent may have wrapped, so check */ /* carefully and set it to a certain overflow if wrap possible */ if (c>=firstexp+9+1) { if (c>firstexp+9+1 || *firstexp>'1') exponent=DECNUMMAXE*2; /* [up to 1999999999 is OK, for example 1E-1000000998] */ } if (nege) exponent=-exponent; /* was negative */ status=0; /* is OK */ } /* stuff after digits */ /* Here when whole string has been inspected; syntax is good */ /* cfirst->first digit (never dot), last->last digit (ditto) */ /* strip leading zeros/dot [leave final 0 if all 0's] */ if (*cfirst=='0') { /* [cfirst has stepped over .] */ for (c=cfirst; cextended) { decNumberZero(dn); /* clean result */ break; /* [could be return] */ } #endif } /* at least one leading 0 */ /* Handle decimal point... */ if (dotchar!=NULL && dotchardigits) res=dn->lsu; /* fits into supplied decNumber */ else { /* rounding needed */ Int needbytes=D2U(d)*sizeof(Unit);/* bytes needed */ res=resbuff; /* assume use local buffer */ if (needbytes>(Int)sizeof(resbuff)) { /* too big for local */ allocres=(Unit *)malloc(needbytes); if (allocres==NULL) {status|=DEC_Insufficient_storage; break;} res=allocres; } } /* res now -> number lsu, buffer, or allocated storage for Unit array */ /* Place the coefficient into the selected Unit array */ /* [this is often 70% of the cost of this function when DECDPUN>1] */ #if DECDPUN>1 out=0; /* accumulator */ up=res+D2U(d)-1; /* -> msu */ cut=d-(up-res)*DECDPUN; /* digits in top unit */ for (c=cfirst;; c++) { /* along the digits */ if (*c=='.') continue; /* ignore '.' [don't decrement cut] */ out=X10(out)+(Int)*c-(Int)'0'; if (c==last) break; /* done [never get to trailing '.'] */ cut--; if (cut>0) continue; /* more for this unit */ *up=(Unit)out; /* write unit */ up--; /* prepare for unit below.. */ cut=DECDPUN; /* .. */ out=0; /* .. */ } /* c */ *up=(Unit)out; /* write lsu */ #else /* DECDPUN==1 */ up=res; /* -> lsu */ for (c=last; c>=cfirst; c--) { /* over each character, from least */ if (*c=='.') continue; /* ignore . [don't step up] */ *up=(Unit)((Int)*c-(Int)'0'); up++; } /* c */ #endif dn->bits=bits; dn->exponent=exponent; dn->digits=d; /* if not in number (too long) shorten into the number */ if (d>set->digits) { residue=0; decSetCoeff(dn, set, res, d, &residue, &status); /* always check for overflow or subnormal and round as needed */ decFinalize(dn, set, &residue, &status); } else { /* no rounding, but may still have overflow or subnormal */ /* [these tests are just for performance; finalize repeats them] */ if ((dn->exponent-1emin-dn->digits) || (dn->exponent-1>set->emax-set->digits)) { residue=0; decFinalize(dn, set, &residue, &status); } } /* decNumberShow(dn); */ } while(0); /* [for break] */ free(allocres); /* drop any storage used */ if (status!=0) decStatus(dn, status, set); return dn; } /* decNumberFromString */ /* ================================================================== */ /* Operators */ /* ================================================================== */ /* ------------------------------------------------------------------ */ /* decNumberAbs -- absolute value operator */ /* */ /* This computes C = abs(A) */ /* */ /* res is C, the result. C may be A */ /* rhs is A */ /* set is the context */ /* */ /* See also decNumberCopyAbs for a quiet bitwise version of this. */ /* C must have space for set->digits digits. */ /* ------------------------------------------------------------------ */ /* This has the same effect as decNumberPlus unless A is negative, */ /* in which case it has the same effect as decNumberMinus. */ /* ------------------------------------------------------------------ */ decNumber * decNumberAbs(decNumber *res, const decNumber *rhs, decContext *set) { decNumber dzero; /* for 0 */ uInt status=0; /* accumulator */ #if DECCHECK if (decCheckOperands(res, DECUNUSED, rhs, set)) return res; #endif decNumberZero(&dzero); /* set 0 */ dzero.exponent=rhs->exponent; /* [no coefficient expansion] */ decAddOp(res, &dzero, rhs, set, (uByte)(rhs->bits & DECNEG), &status); if (status!=0) decStatus(res, status, set); #if DECCHECK decCheckInexact(res, set); #endif return res; } /* decNumberAbs */ /* ------------------------------------------------------------------ */ /* decNumberAdd -- add two Numbers */ /* */ /* This computes C = A + B */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X+X) */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* */ /* C must have space for set->digits digits. */ /* ------------------------------------------------------------------ */ /* This just calls the routine shared with Subtract */ decNumber * decNumberAdd(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ decAddOp(res, lhs, rhs, set, 0, &status); if (status!=0) decStatus(res, status, set); #if DECCHECK decCheckInexact(res, set); #endif return res; } /* decNumberAdd */ /* ------------------------------------------------------------------ */ /* decNumberAnd -- AND two Numbers, digitwise */ /* */ /* This computes C = A & B */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X&X) */ /* lhs is A */ /* rhs is B */ /* set is the context (used for result length and error report) */ /* */ /* C must have space for set->digits digits. */ /* */ /* Logical function restrictions apply (see above); a NaN is */ /* returned with Invalid_operation if a restriction is violated. */ /* ------------------------------------------------------------------ */ decNumber * decNumberAnd(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { const Unit *ua, *ub; /* -> operands */ const Unit *msua, *msub; /* -> operand msus */ Unit *uc, *msuc; /* -> result and its msu */ Int msudigs; /* digits in res msu */ #if DECCHECK if (decCheckOperands(res, lhs, rhs, set)) return res; #endif if (lhs->exponent!=0 || decNumberIsSpecial(lhs) || decNumberIsNegative(lhs) || rhs->exponent!=0 || decNumberIsSpecial(rhs) || decNumberIsNegative(rhs)) { decStatus(res, DEC_Invalid_operation, set); return res; } /* operands are valid */ ua=lhs->lsu; /* bottom-up */ ub=rhs->lsu; /* .. */ uc=res->lsu; /* .. */ msua=ua+D2U(lhs->digits)-1; /* -> msu of lhs */ msub=ub+D2U(rhs->digits)-1; /* -> msu of rhs */ msuc=uc+D2U(set->digits)-1; /* -> msu of result */ msudigs=MSUDIGITS(set->digits); /* [faster than remainder] */ for (; uc<=msuc; ua++, ub++, uc++) { /* Unit loop */ Unit a, b; /* extract units */ if (ua>msua) a=0; else a=*ua; if (ub>msub) b=0; else b=*ub; *uc=0; /* can now write back */ if (a|b) { /* maybe 1 bits to examine */ Int i, j; *uc=0; /* can now write back */ /* This loop could be unrolled and/or use BIN2BCD tables */ for (i=0; i1) { decStatus(res, DEC_Invalid_operation, set); return res; } if (uc==msuc && i==msudigs-1) break; /* just did final digit */ } /* each digit */ } /* both OK */ } /* each unit */ /* [here uc-1 is the msu of the result] */ res->digits=decGetDigits(res->lsu, uc-res->lsu); res->exponent=0; /* integer */ res->bits=0; /* sign=0 */ return res; /* [no status to set] */ } /* decNumberAnd */ /* ------------------------------------------------------------------ */ /* decNumberCompare -- compare two Numbers */ /* */ /* This computes C = A ? B */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X?X) */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* */ /* C must have space for one digit (or NaN). */ /* ------------------------------------------------------------------ */ decNumber * decNumberCompare(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ decCompareOp(res, lhs, rhs, set, COMPARE, &status); if (status!=0) decStatus(res, status, set); return res; } /* decNumberCompare */ /* ------------------------------------------------------------------ */ /* decNumberCompareSignal -- compare, signalling on all NaNs */ /* */ /* This computes C = A ? B */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X?X) */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* */ /* C must have space for one digit (or NaN). */ /* ------------------------------------------------------------------ */ decNumber * decNumberCompareSignal(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ decCompareOp(res, lhs, rhs, set, COMPSIG, &status); if (status!=0) decStatus(res, status, set); return res; } /* decNumberCompareSignal */ /* ------------------------------------------------------------------ */ /* decNumberCompareTotal -- compare two Numbers, using total ordering */ /* */ /* This computes C = A ? B, under total ordering */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X?X) */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* */ /* C must have space for one digit; the result will always be one of */ /* -1, 0, or 1. */ /* ------------------------------------------------------------------ */ decNumber * decNumberCompareTotal(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ decCompareOp(res, lhs, rhs, set, COMPTOTAL, &status); if (status!=0) decStatus(res, status, set); return res; } /* decNumberCompareTotal */ /* ------------------------------------------------------------------ */ /* decNumberCompareTotalMag -- compare, total ordering of magnitudes */ /* */ /* This computes C = |A| ? |B|, under total ordering */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X?X) */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* */ /* C must have space for one digit; the result will always be one of */ /* -1, 0, or 1. */ /* ------------------------------------------------------------------ */ decNumber * decNumberCompareTotalMag(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ uInt needbytes; /* for space calculations */ decNumber bufa[D2N(DECBUFFER+1)];/* +1 in case DECBUFFER=0 */ decNumber *allocbufa=NULL; /* -> allocated bufa, iff allocated */ decNumber bufb[D2N(DECBUFFER+1)]; decNumber *allocbufb=NULL; /* -> allocated bufb, iff allocated */ decNumber *a, *b; /* temporary pointers */ #if DECCHECK if (decCheckOperands(res, lhs, rhs, set)) return res; #endif do { /* protect allocated storage */ /* if either is negative, take a copy and absolute */ if (decNumberIsNegative(lhs)) { /* lhs<0 */ a=bufa; needbytes=sizeof(decNumber)+(D2U(lhs->digits)-1)*sizeof(Unit); if (needbytes>sizeof(bufa)) { /* need malloc space */ allocbufa=(decNumber *)malloc(needbytes); if (allocbufa==NULL) { /* hopeless -- abandon */ status|=DEC_Insufficient_storage; break;} a=allocbufa; /* use the allocated space */ } decNumberCopy(a, lhs); /* copy content */ a->bits&=~DECNEG; /* .. and clear the sign */ lhs=a; /* use copy from here on */ } if (decNumberIsNegative(rhs)) { /* rhs<0 */ b=bufb; needbytes=sizeof(decNumber)+(D2U(rhs->digits)-1)*sizeof(Unit); if (needbytes>sizeof(bufb)) { /* need malloc space */ allocbufb=(decNumber *)malloc(needbytes); if (allocbufb==NULL) { /* hopeless -- abandon */ status|=DEC_Insufficient_storage; break;} b=allocbufb; /* use the allocated space */ } decNumberCopy(b, rhs); /* copy content */ b->bits&=~DECNEG; /* .. and clear the sign */ rhs=b; /* use copy from here on */ } decCompareOp(res, lhs, rhs, set, COMPTOTAL, &status); } while(0); /* end protected */ free(allocbufa); /* drop any storage used */ free(allocbufb); /* .. */ if (status!=0) decStatus(res, status, set); return res; } /* decNumberCompareTotalMag */ /* ------------------------------------------------------------------ */ /* decNumberDivide -- divide one number by another */ /* */ /* This computes C = A / B */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X/X) */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* */ /* C must have space for set->digits digits. */ /* ------------------------------------------------------------------ */ decNumber * decNumberDivide(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ decDivideOp(res, lhs, rhs, set, DIVIDE, &status); if (status!=0) decStatus(res, status, set); #if DECCHECK decCheckInexact(res, set); #endif return res; } /* decNumberDivide */ /* ------------------------------------------------------------------ */ /* decNumberDivideInteger -- divide and return integer quotient */ /* */ /* This computes C = A # B, where # is the integer divide operator */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X#X) */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* */ /* C must have space for set->digits digits. */ /* ------------------------------------------------------------------ */ decNumber * decNumberDivideInteger(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ decDivideOp(res, lhs, rhs, set, DIVIDEINT, &status); if (status!=0) decStatus(res, status, set); return res; } /* decNumberDivideInteger */ /* ------------------------------------------------------------------ */ /* decNumberExp -- exponentiation */ /* */ /* This computes C = exp(A) */ /* */ /* res is C, the result. C may be A */ /* rhs is A */ /* set is the context; note that rounding mode has no effect */ /* */ /* C must have space for set->digits digits. */ /* */ /* Mathematical function restrictions apply (see above); a NaN is */ /* returned with Invalid_operation if a restriction is violated. */ /* */ /* Finite results will always be full precision and Inexact, except */ /* when A is a zero or -Infinity (giving 1 or 0 respectively). */ /* */ /* An Inexact result is rounded using DEC_ROUND_HALF_EVEN; it will */ /* almost always be correctly rounded, but may be up to 1 ulp in */ /* error in rare cases. */ /* ------------------------------------------------------------------ */ /* This is a wrapper for decExpOp which can handle the slightly wider */ /* (double) range needed by Ln (which has to be able to calculate */ /* exp(-a) where a can be the tiniest number (Ntiny). */ /* ------------------------------------------------------------------ */ decNumber * decNumberExp(decNumber *res, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ #if DECSUBSET decNumber *allocrhs=NULL; /* non-NULL if rounded rhs allocated */ #endif #if DECCHECK if (decCheckOperands(res, DECUNUSED, rhs, set)) return res; #endif /* Check restrictions; these restrictions ensure that if h=8 (see */ /* decExpOp) then the result will either overflow or underflow to 0. */ /* Other math functions restrict the input range, too, for inverses. */ /* If not violated then carry out the operation. */ if (!decCheckMath(rhs, set, &status)) do { /* protect allocation */ #if DECSUBSET if (!set->extended) { /* reduce operand and set lostDigits status, as needed */ if (rhs->digits>set->digits) { allocrhs=decRoundOperand(rhs, set, &status); if (allocrhs==NULL) break; rhs=allocrhs; } } #endif decExpOp(res, rhs, set, &status); } while(0); /* end protected */ #if DECSUBSET free(allocrhs); /* drop any storage used */ #endif /* apply significant status */ if (status!=0) decStatus(res, status, set); #if DECCHECK decCheckInexact(res, set); #endif return res; } /* decNumberExp */ /* ------------------------------------------------------------------ */ /* decNumberFMA -- fused multiply add */ /* */ /* This computes D = (A * B) + C with only one rounding */ /* */ /* res is D, the result. D may be A or B or C (e.g., X=FMA(X,X,X)) */ /* lhs is A */ /* rhs is B */ /* fhs is C [far hand side] */ /* set is the context */ /* */ /* Mathematical function restrictions apply (see above); a NaN is */ /* returned with Invalid_operation if a restriction is violated. */ /* */ /* C must have space for set->digits digits. */ /* ------------------------------------------------------------------ */ decNumber * decNumberFMA(decNumber *res, const decNumber *lhs, const decNumber *rhs, const decNumber *fhs, decContext *set) { uInt status=0; /* accumulator */ decContext dcmul; /* context for the multiplication */ uInt needbytes; /* for space calculations */ decNumber bufa[D2N(DECBUFFER*2+1)]; decNumber *allocbufa=NULL; /* -> allocated bufa, iff allocated */ decNumber *acc; /* accumulator pointer */ decNumber dzero; /* work */ #if DECCHECK if (decCheckOperands(res, lhs, rhs, set)) return res; if (decCheckOperands(res, fhs, DECUNUSED, set)) return res; #endif do { /* protect allocated storage */ #if DECSUBSET if (!set->extended) { /* [undefined if subset] */ status|=DEC_Invalid_operation; break;} #endif /* Check math restrictions [these ensure no overflow or underflow] */ if ((!decNumberIsSpecial(lhs) && decCheckMath(lhs, set, &status)) || (!decNumberIsSpecial(rhs) && decCheckMath(rhs, set, &status)) || (!decNumberIsSpecial(fhs) && decCheckMath(fhs, set, &status))) break; /* set up context for multiply */ dcmul=*set; dcmul.digits=lhs->digits+rhs->digits; /* just enough */ /* [The above may be an over-estimate for subset arithmetic, but that's OK] */ dcmul.emax=DEC_MAX_EMAX; /* effectively unbounded .. */ dcmul.emin=DEC_MIN_EMIN; /* [thanks to Math restrictions] */ /* set up decNumber space to receive the result of the multiply */ acc=bufa; /* may fit */ needbytes=sizeof(decNumber)+(D2U(dcmul.digits)-1)*sizeof(Unit); if (needbytes>sizeof(bufa)) { /* need malloc space */ allocbufa=(decNumber *)malloc(needbytes); if (allocbufa==NULL) { /* hopeless -- abandon */ status|=DEC_Insufficient_storage; break;} acc=allocbufa; /* use the allocated space */ } /* multiply with extended range and necessary precision */ /*printf("emin=%ld\n", dcmul.emin); */ decMultiplyOp(acc, lhs, rhs, &dcmul, &status); /* Only Invalid operation (from sNaN or Inf * 0) is possible in */ /* status; if either is seen than ignore fhs (in case it is */ /* another sNaN) and set acc to NaN unless we had an sNaN */ /* [decMultiplyOp leaves that to caller] */ /* Note sNaN has to go through addOp to shorten payload if */ /* necessary */ if ((status&DEC_Invalid_operation)!=0) { if (!(status&DEC_sNaN)) { /* but be true invalid */ decNumberZero(res); /* acc not yet set */ res->bits=DECNAN; break; } decNumberZero(&dzero); /* make 0 (any non-NaN would do) */ fhs=&dzero; /* use that */ } #if DECCHECK else { /* multiply was OK */ if (status!=0) printf("Status=%08lx after FMA multiply\n", (LI)status); } #endif /* add the third operand and result -> res, and all is done */ decAddOp(res, acc, fhs, set, 0, &status); } while(0); /* end protected */ free(allocbufa); /* drop any storage used */ if (status!=0) decStatus(res, status, set); #if DECCHECK decCheckInexact(res, set); #endif return res; } /* decNumberFMA */ /* ------------------------------------------------------------------ */ /* decNumberInvert -- invert a Number, digitwise */ /* */ /* This computes C = ~A */ /* */ /* res is C, the result. C may be A (e.g., X=~X) */ /* rhs is A */ /* set is the context (used for result length and error report) */ /* */ /* C must have space for set->digits digits. */ /* */ /* Logical function restrictions apply (see above); a NaN is */ /* returned with Invalid_operation if a restriction is violated. */ /* ------------------------------------------------------------------ */ decNumber * decNumberInvert(decNumber *res, const decNumber *rhs, decContext *set) { const Unit *ua, *msua; /* -> operand and its msu */ Unit *uc, *msuc; /* -> result and its msu */ Int msudigs; /* digits in res msu */ #if DECCHECK if (decCheckOperands(res, DECUNUSED, rhs, set)) return res; #endif if (rhs->exponent!=0 || decNumberIsSpecial(rhs) || decNumberIsNegative(rhs)) { decStatus(res, DEC_Invalid_operation, set); return res; } /* operand is valid */ ua=rhs->lsu; /* bottom-up */ uc=res->lsu; /* .. */ msua=ua+D2U(rhs->digits)-1; /* -> msu of rhs */ msuc=uc+D2U(set->digits)-1; /* -> msu of result */ msudigs=MSUDIGITS(set->digits); /* [faster than remainder] */ for (; uc<=msuc; ua++, uc++) { /* Unit loop */ Unit a; /* extract unit */ Int i, j; /* work */ if (ua>msua) a=0; else a=*ua; *uc=0; /* can now write back */ /* always need to examine all bits in rhs */ /* This loop could be unrolled and/or use BIN2BCD tables */ for (i=0; i1) { decStatus(res, DEC_Invalid_operation, set); return res; } if (uc==msuc && i==msudigs-1) break; /* just did final digit */ } /* each digit */ } /* each unit */ /* [here uc-1 is the msu of the result] */ res->digits=decGetDigits(res->lsu, uc-res->lsu); res->exponent=0; /* integer */ res->bits=0; /* sign=0 */ return res; /* [no status to set] */ } /* decNumberInvert */ /* ------------------------------------------------------------------ */ /* decNumberLn -- natural logarithm */ /* */ /* This computes C = ln(A) */ /* */ /* res is C, the result. C may be A */ /* rhs is A */ /* set is the context; note that rounding mode has no effect */ /* */ /* C must have space for set->digits digits. */ /* */ /* Notable cases: */ /* A<0 -> Invalid */ /* A=0 -> -Infinity (Exact) */ /* A=+Infinity -> +Infinity (Exact) */ /* A=1 exactly -> 0 (Exact) */ /* */ /* Mathematical function restrictions apply (see above); a NaN is */ /* returned with Invalid_operation if a restriction is violated. */ /* */ /* An Inexact result is rounded using DEC_ROUND_HALF_EVEN; it will */ /* almost always be correctly rounded, but may be up to 1 ulp in */ /* error in rare cases. */ /* ------------------------------------------------------------------ */ /* This is a wrapper for decLnOp which can handle the slightly wider */ /* (+11) range needed by Ln, Log10, etc. (which may have to be able */ /* to calculate at p+e+2). */ /* ------------------------------------------------------------------ */ decNumber * decNumberLn(decNumber *res, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ #if DECSUBSET decNumber *allocrhs=NULL; /* non-NULL if rounded rhs allocated */ #endif #if DECCHECK if (decCheckOperands(res, DECUNUSED, rhs, set)) return res; #endif /* Check restrictions; this is a math function; if not violated */ /* then carry out the operation. */ if (!decCheckMath(rhs, set, &status)) do { /* protect allocation */ #if DECSUBSET if (!set->extended) { /* reduce operand and set lostDigits status, as needed */ if (rhs->digits>set->digits) { allocrhs=decRoundOperand(rhs, set, &status); if (allocrhs==NULL) break; rhs=allocrhs; } /* special check in subset for rhs=0 */ if (ISZERO(rhs)) { /* +/- zeros -> error */ status|=DEC_Invalid_operation; break;} } /* extended=0 */ #endif decLnOp(res, rhs, set, &status); } while(0); /* end protected */ #if DECSUBSET free(allocrhs); /* drop any storage used */ #endif /* apply significant status */ if (status!=0) decStatus(res, status, set); #if DECCHECK decCheckInexact(res, set); #endif return res; } /* decNumberLn */ /* ------------------------------------------------------------------ */ /* decNumberLogB - get adjusted exponent, by 754 rules */ /* */ /* This computes C = adjustedexponent(A) */ /* */ /* res is C, the result. C may be A */ /* rhs is A */ /* set is the context, used only for digits and status */ /* */ /* C must have space for 10 digits (A might have 10**9 digits and */ /* an exponent of +999999999, or one digit and an exponent of */ /* -1999999999). */ /* */ /* This returns the adjusted exponent of A after (in theory) padding */ /* with zeros on the right to set->digits digits while keeping the */ /* same value. The exponent is not limited by emin/emax. */ /* */ /* Notable cases: */ /* A<0 -> Use |A| */ /* A=0 -> -Infinity (Division by zero) */ /* A=Infinite -> +Infinity (Exact) */ /* A=1 exactly -> 0 (Exact) */ /* NaNs are propagated as usual */ /* ------------------------------------------------------------------ */ decNumber * decNumberLogB(decNumber *res, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ #if DECCHECK if (decCheckOperands(res, DECUNUSED, rhs, set)) return res; #endif /* NaNs as usual; Infinities return +Infinity; 0->oops */ if (decNumberIsNaN(rhs)) decNaNs(res, rhs, NULL, set, &status); else if (decNumberIsInfinite(rhs)) decNumberCopyAbs(res, rhs); else if (decNumberIsZero(rhs)) { decNumberZero(res); /* prepare for Infinity */ res->bits=DECNEG|DECINF; /* -Infinity */ status|=DEC_Division_by_zero; /* as per 754 */ } else { /* finite non-zero */ Int ae=rhs->exponent+rhs->digits-1; /* adjusted exponent */ decNumberFromInt32(res, ae); /* lay it out */ } if (status!=0) decStatus(res, status, set); return res; } /* decNumberLogB */ /* ------------------------------------------------------------------ */ /* decNumberLog10 -- logarithm in base 10 */ /* */ /* This computes C = log10(A) */ /* */ /* res is C, the result. C may be A */ /* rhs is A */ /* set is the context; note that rounding mode has no effect */ /* */ /* C must have space for set->digits digits. */ /* */ /* Notable cases: */ /* A<0 -> Invalid */ /* A=0 -> -Infinity (Exact) */ /* A=+Infinity -> +Infinity (Exact) */ /* A=10**n (if n is an integer) -> n (Exact) */ /* */ /* Mathematical function restrictions apply (see above); a NaN is */ /* returned with Invalid_operation if a restriction is violated. */ /* */ /* An Inexact result is rounded using DEC_ROUND_HALF_EVEN; it will */ /* almost always be correctly rounded, but may be up to 1 ulp in */ /* error in rare cases. */ /* ------------------------------------------------------------------ */ /* This calculates ln(A)/ln(10) using appropriate precision. For */ /* ln(A) this is the max(p, rhs->digits + t) + 3, where p is the */ /* requested digits and t is the number of digits in the exponent */ /* (maximum 6). For ln(10) it is p + 3; this is often handled by the */ /* fastpath in decLnOp. The final division is done to the requested */ /* precision. */ /* ------------------------------------------------------------------ */ decNumber * decNumberLog10(decNumber *res, const decNumber *rhs, decContext *set) { uInt status=0, ignore=0; /* status accumulators */ uInt needbytes; /* for space calculations */ Int p; /* working precision */ Int t; /* digits in exponent of A */ /* buffers for a and b working decimals */ /* (adjustment calculator, same size) */ decNumber bufa[D2N(DECBUFFER+2)]; decNumber *allocbufa=NULL; /* -> allocated bufa, iff allocated */ decNumber *a=bufa; /* temporary a */ decNumber bufb[D2N(DECBUFFER+2)]; decNumber *allocbufb=NULL; /* -> allocated bufb, iff allocated */ decNumber *b=bufb; /* temporary b */ decNumber bufw[D2N(10)]; /* working 2-10 digit number */ decNumber *w=bufw; /* .. */ #if DECSUBSET decNumber *allocrhs=NULL; /* non-NULL if rounded rhs allocated */ #endif decContext aset; /* working context */ #if DECCHECK if (decCheckOperands(res, DECUNUSED, rhs, set)) return res; #endif /* Check restrictions; this is a math function; if not violated */ /* then carry out the operation. */ if (!decCheckMath(rhs, set, &status)) do { /* protect malloc */ #if DECSUBSET if (!set->extended) { /* reduce operand and set lostDigits status, as needed */ if (rhs->digits>set->digits) { allocrhs=decRoundOperand(rhs, set, &status); if (allocrhs==NULL) break; rhs=allocrhs; } /* special check in subset for rhs=0 */ if (ISZERO(rhs)) { /* +/- zeros -> error */ status|=DEC_Invalid_operation; break;} } /* extended=0 */ #endif decContextDefault(&aset, DEC_INIT_DECIMAL64); /* clean context */ /* handle exact powers of 10; only check if +ve finite */ if (!(rhs->bits&(DECNEG|DECSPECIAL)) && !ISZERO(rhs)) { Int residue=0; /* (no residue) */ uInt copystat=0; /* clean status */ /* round to a single digit... */ aset.digits=1; decCopyFit(w, rhs, &aset, &residue, ©stat); /* copy & shorten */ /* if exact and the digit is 1, rhs is a power of 10 */ if (!(copystat&DEC_Inexact) && w->lsu[0]==1) { /* the exponent, conveniently, is the power of 10; making */ /* this the result needs a little care as it might not fit, */ /* so first convert it into the working number, and then move */ /* to res */ decNumberFromInt32(w, w->exponent); residue=0; decCopyFit(res, w, set, &residue, &status); /* copy & round */ decFinish(res, set, &residue, &status); /* cleanup/set flags */ break; } /* not a power of 10 */ } /* not a candidate for exact */ /* simplify the information-content calculation to use 'total */ /* number of digits in a, including exponent' as compared to the */ /* requested digits, as increasing this will only rarely cost an */ /* iteration in ln(a) anyway */ t=6; /* it can never be >6 */ /* allocate space when needed... */ p=(rhs->digits+t>set->digits?rhs->digits+t:set->digits)+3; needbytes=sizeof(decNumber)+(D2U(p)-1)*sizeof(Unit); if (needbytes>sizeof(bufa)) { /* need malloc space */ allocbufa=(decNumber *)malloc(needbytes); if (allocbufa==NULL) { /* hopeless -- abandon */ status|=DEC_Insufficient_storage; break;} a=allocbufa; /* use the allocated space */ } aset.digits=p; /* as calculated */ aset.emax=DEC_MAX_MATH; /* usual bounds */ aset.emin=-DEC_MAX_MATH; /* .. */ aset.clamp=0; /* and no concrete format */ decLnOp(a, rhs, &aset, &status); /* a=ln(rhs) */ /* skip the division if the result so far is infinite, NaN, or */ /* zero, or there was an error; note NaN from sNaN needs copy */ if (status&DEC_NaNs && !(status&DEC_sNaN)) break; if (a->bits&DECSPECIAL || ISZERO(a)) { decNumberCopy(res, a); /* [will fit] */ break;} /* for ln(10) an extra 3 digits of precision are needed */ p=set->digits+3; needbytes=sizeof(decNumber)+(D2U(p)-1)*sizeof(Unit); if (needbytes>sizeof(bufb)) { /* need malloc space */ allocbufb=(decNumber *)malloc(needbytes); if (allocbufb==NULL) { /* hopeless -- abandon */ status|=DEC_Insufficient_storage; break;} b=allocbufb; /* use the allocated space */ } decNumberZero(w); /* set up 10... */ #if DECDPUN==1 w->lsu[1]=1; w->lsu[0]=0; /* .. */ #else w->lsu[0]=10; /* .. */ #endif w->digits=2; /* .. */ aset.digits=p; decLnOp(b, w, &aset, &ignore); /* b=ln(10) */ aset.digits=set->digits; /* for final divide */ decDivideOp(res, a, b, &aset, DIVIDE, &status); /* into result */ } while(0); /* [for break] */ free(allocbufa); /* drop any storage used */ free(allocbufb); /* .. */ #if DECSUBSET free(allocrhs); /* .. */ #endif /* apply significant status */ if (status!=0) decStatus(res, status, set); #if DECCHECK decCheckInexact(res, set); #endif return res; } /* decNumberLog10 */ /* ------------------------------------------------------------------ */ /* decNumberMax -- compare two Numbers and return the maximum */ /* */ /* This computes C = A ? B, returning the maximum by 754 rules */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X?X) */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* */ /* C must have space for set->digits digits. */ /* ------------------------------------------------------------------ */ decNumber * decNumberMax(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ decCompareOp(res, lhs, rhs, set, COMPMAX, &status); if (status!=0) decStatus(res, status, set); #if DECCHECK decCheckInexact(res, set); #endif return res; } /* decNumberMax */ /* ------------------------------------------------------------------ */ /* decNumberMaxMag -- compare and return the maximum by magnitude */ /* */ /* This computes C = A ? B, returning the maximum by 754 rules */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X?X) */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* */ /* C must have space for set->digits digits. */ /* ------------------------------------------------------------------ */ decNumber * decNumberMaxMag(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ decCompareOp(res, lhs, rhs, set, COMPMAXMAG, &status); if (status!=0) decStatus(res, status, set); #if DECCHECK decCheckInexact(res, set); #endif return res; } /* decNumberMaxMag */ /* ------------------------------------------------------------------ */ /* decNumberMin -- compare two Numbers and return the minimum */ /* */ /* This computes C = A ? B, returning the minimum by 754 rules */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X?X) */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* */ /* C must have space for set->digits digits. */ /* ------------------------------------------------------------------ */ decNumber * decNumberMin(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ decCompareOp(res, lhs, rhs, set, COMPMIN, &status); if (status!=0) decStatus(res, status, set); #if DECCHECK decCheckInexact(res, set); #endif return res; } /* decNumberMin */ /* ------------------------------------------------------------------ */ /* decNumberMinMag -- compare and return the minimum by magnitude */ /* */ /* This computes C = A ? B, returning the minimum by 754 rules */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X?X) */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* */ /* C must have space for set->digits digits. */ /* ------------------------------------------------------------------ */ decNumber * decNumberMinMag(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ decCompareOp(res, lhs, rhs, set, COMPMINMAG, &status); if (status!=0) decStatus(res, status, set); #if DECCHECK decCheckInexact(res, set); #endif return res; } /* decNumberMinMag */ /* ------------------------------------------------------------------ */ /* decNumberMinus -- prefix minus operator */ /* */ /* This computes C = 0 - A */ /* */ /* res is C, the result. C may be A */ /* rhs is A */ /* set is the context */ /* */ /* See also decNumberCopyNegate for a quiet bitwise version of this. */ /* C must have space for set->digits digits. */ /* ------------------------------------------------------------------ */ /* Simply use AddOp for the subtract, which will do the necessary. */ /* ------------------------------------------------------------------ */ decNumber * decNumberMinus(decNumber *res, const decNumber *rhs, decContext *set) { decNumber dzero; uInt status=0; /* accumulator */ #if DECCHECK if (decCheckOperands(res, DECUNUSED, rhs, set)) return res; #endif decNumberZero(&dzero); /* make 0 */ dzero.exponent=rhs->exponent; /* [no coefficient expansion] */ decAddOp(res, &dzero, rhs, set, DECNEG, &status); if (status!=0) decStatus(res, status, set); #if DECCHECK decCheckInexact(res, set); #endif return res; } /* decNumberMinus */ /* ------------------------------------------------------------------ */ /* decNumberNextMinus -- next towards -Infinity */ /* */ /* This computes C = A - infinitesimal, rounded towards -Infinity */ /* */ /* res is C, the result. C may be A */ /* rhs is A */ /* set is the context */ /* */ /* This is a generalization of 754 NextDown. */ /* ------------------------------------------------------------------ */ decNumber * decNumberNextMinus(decNumber *res, const decNumber *rhs, decContext *set) { decNumber dtiny; /* constant */ decContext workset=*set; /* work */ uInt status=0; /* accumulator */ #if DECCHECK if (decCheckOperands(res, DECUNUSED, rhs, set)) return res; #endif /* +Infinity is the special case */ if ((rhs->bits&(DECINF|DECNEG))==DECINF) { decSetMaxValue(res, set); /* is +ve */ /* there is no status to set */ return res; } decNumberZero(&dtiny); /* start with 0 */ dtiny.lsu[0]=1; /* make number that is .. */ dtiny.exponent=DEC_MIN_EMIN-1; /* .. smaller than tiniest */ workset.round=DEC_ROUND_FLOOR; decAddOp(res, rhs, &dtiny, &workset, DECNEG, &status); status&=DEC_Invalid_operation|DEC_sNaN; /* only sNaN Invalid please */ if (status!=0) decStatus(res, status, set); return res; } /* decNumberNextMinus */ /* ------------------------------------------------------------------ */ /* decNumberNextPlus -- next towards +Infinity */ /* */ /* This computes C = A + infinitesimal, rounded towards +Infinity */ /* */ /* res is C, the result. C may be A */ /* rhs is A */ /* set is the context */ /* */ /* This is a generalization of 754 NextUp. */ /* ------------------------------------------------------------------ */ decNumber * decNumberNextPlus(decNumber *res, const decNumber *rhs, decContext *set) { decNumber dtiny; /* constant */ decContext workset=*set; /* work */ uInt status=0; /* accumulator */ #if DECCHECK if (decCheckOperands(res, DECUNUSED, rhs, set)) return res; #endif /* -Infinity is the special case */ if ((rhs->bits&(DECINF|DECNEG))==(DECINF|DECNEG)) { decSetMaxValue(res, set); res->bits=DECNEG; /* negative */ /* there is no status to set */ return res; } decNumberZero(&dtiny); /* start with 0 */ dtiny.lsu[0]=1; /* make number that is .. */ dtiny.exponent=DEC_MIN_EMIN-1; /* .. smaller than tiniest */ workset.round=DEC_ROUND_CEILING; decAddOp(res, rhs, &dtiny, &workset, 0, &status); status&=DEC_Invalid_operation|DEC_sNaN; /* only sNaN Invalid please */ if (status!=0) decStatus(res, status, set); return res; } /* decNumberNextPlus */ /* ------------------------------------------------------------------ */ /* decNumberNextToward -- next towards rhs */ /* */ /* This computes C = A +/- infinitesimal, rounded towards */ /* +/-Infinity in the direction of B, as per 754-1985 nextafter */ /* modified during revision but dropped from 754-2008. */ /* */ /* res is C, the result. C may be A or B. */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* */ /* This is a generalization of 754-1985 NextAfter. */ /* ------------------------------------------------------------------ */ decNumber * decNumberNextToward(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { decNumber dtiny; /* constant */ decContext workset=*set; /* work */ Int result; /* .. */ uInt status=0; /* accumulator */ #if DECCHECK if (decCheckOperands(res, lhs, rhs, set)) return res; #endif if (decNumberIsNaN(lhs) || decNumberIsNaN(rhs)) { decNaNs(res, lhs, rhs, set, &status); } else { /* Is numeric, so no chance of sNaN Invalid, etc. */ result=decCompare(lhs, rhs, 0); /* sign matters */ if (result==BADINT) status|=DEC_Insufficient_storage; /* rare */ else { /* valid compare */ if (result==0) decNumberCopySign(res, lhs, rhs); /* easy */ else { /* differ: need NextPlus or NextMinus */ uByte sub; /* add or subtract */ if (result<0) { /* lhsbits&(DECINF|DECNEG))==(DECINF|DECNEG)) { decSetMaxValue(res, set); res->bits=DECNEG; /* negative */ return res; /* there is no status to set */ } workset.round=DEC_ROUND_CEILING; sub=0; /* add, please */ } /* plus */ else { /* lhs>rhs, do nextminus */ /* +Infinity is the special case */ if ((lhs->bits&(DECINF|DECNEG))==DECINF) { decSetMaxValue(res, set); return res; /* there is no status to set */ } workset.round=DEC_ROUND_FLOOR; sub=DECNEG; /* subtract, please */ } /* minus */ decNumberZero(&dtiny); /* start with 0 */ dtiny.lsu[0]=1; /* make number that is .. */ dtiny.exponent=DEC_MIN_EMIN-1; /* .. smaller than tiniest */ decAddOp(res, lhs, &dtiny, &workset, sub, &status); /* + or - */ /* turn off exceptions if the result is a normal number */ /* (including Nmin), otherwise let all status through */ if (decNumberIsNormal(res, set)) status=0; } /* unequal */ } /* compare OK */ } /* numeric */ if (status!=0) decStatus(res, status, set); return res; } /* decNumberNextToward */ /* ------------------------------------------------------------------ */ /* decNumberOr -- OR two Numbers, digitwise */ /* */ /* This computes C = A | B */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X|X) */ /* lhs is A */ /* rhs is B */ /* set is the context (used for result length and error report) */ /* */ /* C must have space for set->digits digits. */ /* */ /* Logical function restrictions apply (see above); a NaN is */ /* returned with Invalid_operation if a restriction is violated. */ /* ------------------------------------------------------------------ */ decNumber * decNumberOr(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { const Unit *ua, *ub; /* -> operands */ const Unit *msua, *msub; /* -> operand msus */ Unit *uc, *msuc; /* -> result and its msu */ Int msudigs; /* digits in res msu */ #if DECCHECK if (decCheckOperands(res, lhs, rhs, set)) return res; #endif if (lhs->exponent!=0 || decNumberIsSpecial(lhs) || decNumberIsNegative(lhs) || rhs->exponent!=0 || decNumberIsSpecial(rhs) || decNumberIsNegative(rhs)) { decStatus(res, DEC_Invalid_operation, set); return res; } /* operands are valid */ ua=lhs->lsu; /* bottom-up */ ub=rhs->lsu; /* .. */ uc=res->lsu; /* .. */ msua=ua+D2U(lhs->digits)-1; /* -> msu of lhs */ msub=ub+D2U(rhs->digits)-1; /* -> msu of rhs */ msuc=uc+D2U(set->digits)-1; /* -> msu of result */ msudigs=MSUDIGITS(set->digits); /* [faster than remainder] */ for (; uc<=msuc; ua++, ub++, uc++) { /* Unit loop */ Unit a, b; /* extract units */ if (ua>msua) a=0; else a=*ua; if (ub>msub) b=0; else b=*ub; *uc=0; /* can now write back */ if (a|b) { /* maybe 1 bits to examine */ Int i, j; /* This loop could be unrolled and/or use BIN2BCD tables */ for (i=0; i1) { decStatus(res, DEC_Invalid_operation, set); return res; } if (uc==msuc && i==msudigs-1) break; /* just did final digit */ } /* each digit */ } /* non-zero */ } /* each unit */ /* [here uc-1 is the msu of the result] */ res->digits=decGetDigits(res->lsu, uc-res->lsu); res->exponent=0; /* integer */ res->bits=0; /* sign=0 */ return res; /* [no status to set] */ } /* decNumberOr */ /* ------------------------------------------------------------------ */ /* decNumberPlus -- prefix plus operator */ /* */ /* This computes C = 0 + A */ /* */ /* res is C, the result. C may be A */ /* rhs is A */ /* set is the context */ /* */ /* See also decNumberCopy for a quiet bitwise version of this. */ /* C must have space for set->digits digits. */ /* ------------------------------------------------------------------ */ /* This simply uses AddOp; Add will take fast path after preparing A. */ /* Performance is a concern here, as this routine is often used to */ /* check operands and apply rounding and overflow/underflow testing. */ /* ------------------------------------------------------------------ */ decNumber * decNumberPlus(decNumber *res, const decNumber *rhs, decContext *set) { decNumber dzero; uInt status=0; /* accumulator */ #if DECCHECK if (decCheckOperands(res, DECUNUSED, rhs, set)) return res; #endif decNumberZero(&dzero); /* make 0 */ dzero.exponent=rhs->exponent; /* [no coefficient expansion] */ decAddOp(res, &dzero, rhs, set, 0, &status); if (status!=0) decStatus(res, status, set); #if DECCHECK decCheckInexact(res, set); #endif return res; } /* decNumberPlus */ /* ------------------------------------------------------------------ */ /* decNumberMultiply -- multiply two Numbers */ /* */ /* This computes C = A x B */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X+X) */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* */ /* C must have space for set->digits digits. */ /* ------------------------------------------------------------------ */ decNumber * decNumberMultiply(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ decMultiplyOp(res, lhs, rhs, set, &status); if (status!=0) decStatus(res, status, set); #if DECCHECK decCheckInexact(res, set); #endif return res; } /* decNumberMultiply */ /* ------------------------------------------------------------------ */ /* decNumberPower -- raise a number to a power */ /* */ /* This computes C = A ** B */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X**X) */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* */ /* C must have space for set->digits digits. */ /* */ /* Mathematical function restrictions apply (see above); a NaN is */ /* returned with Invalid_operation if a restriction is violated. */ /* */ /* However, if 1999999997<=B<=999999999 and B is an integer then the */ /* restrictions on A and the context are relaxed to the usual bounds, */ /* for compatibility with the earlier (integer power only) version */ /* of this function. */ /* */ /* When B is an integer, the result may be exact, even if rounded. */ /* */ /* The final result is rounded according to the context; it will */ /* almost always be correctly rounded, but may be up to 1 ulp in */ /* error in rare cases. */ /* ------------------------------------------------------------------ */ decNumber * decNumberPower(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { #if DECSUBSET decNumber *alloclhs=NULL; /* non-NULL if rounded lhs allocated */ decNumber *allocrhs=NULL; /* .., rhs */ #endif decNumber *allocdac=NULL; /* -> allocated acc buffer, iff used */ decNumber *allocinv=NULL; /* -> allocated 1/x buffer, iff used */ Int reqdigits=set->digits; /* requested DIGITS */ Int n; /* rhs in binary */ Flag rhsint=0; /* 1 if rhs is an integer */ Flag useint=0; /* 1 if can use integer calculation */ Flag isoddint=0; /* 1 if rhs is an integer and odd */ Int i; /* work */ #if DECSUBSET Int dropped; /* .. */ #endif uInt needbytes; /* buffer size needed */ Flag seenbit; /* seen a bit while powering */ Int residue=0; /* rounding residue */ uInt status=0; /* accumulators */ uByte bits=0; /* result sign if errors */ decContext aset; /* working context */ decNumber dnOne; /* work value 1... */ /* local accumulator buffer [a decNumber, with digits+elength+1 digits] */ decNumber dacbuff[D2N(DECBUFFER+9)]; decNumber *dac=dacbuff; /* -> result accumulator */ /* same again for possible 1/lhs calculation */ decNumber invbuff[D2N(DECBUFFER+9)]; #if DECCHECK if (decCheckOperands(res, lhs, rhs, set)) return res; #endif do { /* protect allocated storage */ #if DECSUBSET if (!set->extended) { /* reduce operands and set status, as needed */ if (lhs->digits>reqdigits) { alloclhs=decRoundOperand(lhs, set, &status); if (alloclhs==NULL) break; lhs=alloclhs; } if (rhs->digits>reqdigits) { allocrhs=decRoundOperand(rhs, set, &status); if (allocrhs==NULL) break; rhs=allocrhs; } } #endif /* [following code does not require input rounding] */ /* handle NaNs and rhs Infinity (lhs infinity is harder) */ if (SPECIALARGS) { if (decNumberIsNaN(lhs) || decNumberIsNaN(rhs)) { /* NaNs */ decNaNs(res, lhs, rhs, set, &status); break;} if (decNumberIsInfinite(rhs)) { /* rhs Infinity */ Flag rhsneg=rhs->bits&DECNEG; /* save rhs sign */ if (decNumberIsNegative(lhs) /* lhs<0 */ && !decNumberIsZero(lhs)) /* .. */ status|=DEC_Invalid_operation; else { /* lhs >=0 */ decNumberZero(&dnOne); /* set up 1 */ dnOne.lsu[0]=1; decNumberCompare(dac, lhs, &dnOne, set); /* lhs ? 1 */ decNumberZero(res); /* prepare for 0/1/Infinity */ if (decNumberIsNegative(dac)) { /* lhs<1 */ if (rhsneg) res->bits|=DECINF; /* +Infinity [else is +0] */ } else if (dac->lsu[0]==0) { /* lhs=1 */ /* 1**Infinity is inexact, so return fully-padded 1.0000 */ Int shift=set->digits-1; *res->lsu=1; /* was 0, make int 1 */ res->digits=decShiftToMost(res->lsu, 1, shift); res->exponent=-shift; /* make 1.0000... */ status|=DEC_Inexact|DEC_Rounded; /* deemed inexact */ } else { /* lhs>1 */ if (!rhsneg) res->bits|=DECINF; /* +Infinity [else is +0] */ } } /* lhs>=0 */ break;} /* [lhs infinity drops through] */ } /* specials */ /* Original rhs may be an integer that fits and is in range */ n=decGetInt(rhs); if (n!=BADINT) { /* it is an integer */ rhsint=1; /* record the fact for 1**n */ isoddint=(Flag)n&1; /* [works even if big] */ if (n!=BIGEVEN && n!=BIGODD) /* can use integer path? */ useint=1; /* looks good */ } if (decNumberIsNegative(lhs) /* -x .. */ && isoddint) bits=DECNEG; /* .. to an odd power */ /* handle LHS infinity */ if (decNumberIsInfinite(lhs)) { /* [NaNs already handled] */ uByte rbits=rhs->bits; /* save */ decNumberZero(res); /* prepare */ if (n==0) *res->lsu=1; /* [-]Inf**0 => 1 */ else { /* -Inf**nonint -> error */ if (!rhsint && decNumberIsNegative(lhs)) { status|=DEC_Invalid_operation; /* -Inf**nonint is error */ break;} if (!(rbits & DECNEG)) bits|=DECINF; /* was not a **-n */ /* [otherwise will be 0 or -0] */ res->bits=bits; } break;} /* similarly handle LHS zero */ if (decNumberIsZero(lhs)) { if (n==0) { /* 0**0 => Error */ #if DECSUBSET if (!set->extended) { /* [unless subset] */ decNumberZero(res); *res->lsu=1; /* return 1 */ break;} #endif status|=DEC_Invalid_operation; } else { /* 0**x */ uByte rbits=rhs->bits; /* save */ if (rbits & DECNEG) { /* was a 0**(-n) */ #if DECSUBSET if (!set->extended) { /* [bad if subset] */ status|=DEC_Invalid_operation; break;} #endif bits|=DECINF; } decNumberZero(res); /* prepare */ /* [otherwise will be 0 or -0] */ res->bits=bits; } break;} /* here both lhs and rhs are finite; rhs==0 is handled in the */ /* integer path. Next handle the non-integer cases */ if (!useint) { /* non-integral rhs */ /* any -ve lhs is bad, as is either operand or context out of */ /* bounds */ if (decNumberIsNegative(lhs)) { status|=DEC_Invalid_operation; break;} if (decCheckMath(lhs, set, &status) || decCheckMath(rhs, set, &status)) break; /* variable status */ decContextDefault(&aset, DEC_INIT_DECIMAL64); /* clean context */ aset.emax=DEC_MAX_MATH; /* usual bounds */ aset.emin=-DEC_MAX_MATH; /* .. */ aset.clamp=0; /* and no concrete format */ /* calculate the result using exp(ln(lhs)*rhs), which can */ /* all be done into the accumulator, dac. The precision needed */ /* is enough to contain the full information in the lhs (which */ /* is the total digits, including exponent), or the requested */ /* precision, if larger, + 4; 6 is used for the exponent */ /* maximum length, and this is also used when it is shorter */ /* than the requested digits as it greatly reduces the >0.5 ulp */ /* cases at little cost (because Ln doubles digits each */ /* iteration so a few extra digits rarely causes an extra */ /* iteration) */ aset.digits=MAXI(lhs->digits, set->digits)+6+4; } /* non-integer rhs */ else { /* rhs is in-range integer */ if (n==0) { /* x**0 = 1 */ /* (0**0 was handled above) */ decNumberZero(res); /* result=1 */ *res->lsu=1; /* .. */ break;} /* rhs is a non-zero integer */ if (n<0) n=-n; /* use abs(n) */ aset=*set; /* clone the context */ aset.round=DEC_ROUND_HALF_EVEN; /* internally use balanced */ /* calculate the working DIGITS */ aset.digits=reqdigits+(rhs->digits+rhs->exponent)+2; #if DECSUBSET if (!set->extended) aset.digits--; /* use classic precision */ #endif /* it's an error if this is more than can be handled */ if (aset.digits>DECNUMMAXP) {status|=DEC_Invalid_operation; break;} } /* integer path */ /* aset.digits is the count of digits for the accumulator needed */ /* if accumulator is too long for local storage, then allocate */ needbytes=sizeof(decNumber)+(D2U(aset.digits)-1)*sizeof(Unit); /* [needbytes also used below if 1/lhs needed] */ if (needbytes>sizeof(dacbuff)) { allocdac=(decNumber *)malloc(needbytes); if (allocdac==NULL) { /* hopeless -- abandon */ status|=DEC_Insufficient_storage; break;} dac=allocdac; /* use the allocated space */ } /* here, aset is set up and accumulator is ready for use */ if (!useint) { /* non-integral rhs */ /* x ** y; special-case x=1 here as it will otherwise always */ /* reduce to integer 1; decLnOp has a fastpath which detects */ /* the case of x=1 */ decLnOp(dac, lhs, &aset, &status); /* dac=ln(lhs) */ /* [no error possible, as lhs 0 already handled] */ if (ISZERO(dac)) { /* x==1, 1.0, etc. */ /* need to return fully-padded 1.0000 etc., but rhsint->1 */ *dac->lsu=1; /* was 0, make int 1 */ if (!rhsint) { /* add padding */ Int shift=set->digits-1; dac->digits=decShiftToMost(dac->lsu, 1, shift); dac->exponent=-shift; /* make 1.0000... */ status|=DEC_Inexact|DEC_Rounded; /* deemed inexact */ } } else { decMultiplyOp(dac, dac, rhs, &aset, &status); /* dac=dac*rhs */ decExpOp(dac, dac, &aset, &status); /* dac=exp(dac) */ } /* and drop through for final rounding */ } /* non-integer rhs */ else { /* carry on with integer */ decNumberZero(dac); /* acc=1 */ *dac->lsu=1; /* .. */ /* if a negative power the constant 1 is needed, and if not subset */ /* invert the lhs now rather than inverting the result later */ if (decNumberIsNegative(rhs)) { /* was a **-n [hence digits>0] */ decNumber *inv=invbuff; /* asssume use fixed buffer */ decNumberCopy(&dnOne, dac); /* dnOne=1; [needed now or later] */ #if DECSUBSET if (set->extended) { /* need to calculate 1/lhs */ #endif /* divide lhs into 1, putting result in dac [dac=1/dac] */ decDivideOp(dac, &dnOne, lhs, &aset, DIVIDE, &status); /* now locate or allocate space for the inverted lhs */ if (needbytes>sizeof(invbuff)) { allocinv=(decNumber *)malloc(needbytes); if (allocinv==NULL) { /* hopeless -- abandon */ status|=DEC_Insufficient_storage; break;} inv=allocinv; /* use the allocated space */ } /* [inv now points to big-enough buffer or allocated storage] */ decNumberCopy(inv, dac); /* copy the 1/lhs */ decNumberCopy(dac, &dnOne); /* restore acc=1 */ lhs=inv; /* .. and go forward with new lhs */ #if DECSUBSET } #endif } /* Raise-to-the-power loop... */ seenbit=0; /* set once a 1-bit is encountered */ for (i=1;;i++){ /* for each bit [top bit ignored] */ /* abandon if had overflow or terminal underflow */ if (status & (DEC_Overflow|DEC_Underflow)) { /* interesting? */ if (status&DEC_Overflow || ISZERO(dac)) break; } /* [the following two lines revealed an optimizer bug in a C++ */ /* compiler, with symptom: 5**3 -> 25, when n=n+n was used] */ n=n<<1; /* move next bit to testable position */ if (n<0) { /* top bit is set */ seenbit=1; /* OK, significant bit seen */ decMultiplyOp(dac, dac, lhs, &aset, &status); /* dac=dac*x */ } if (i==31) break; /* that was the last bit */ if (!seenbit) continue; /* no need to square 1 */ decMultiplyOp(dac, dac, dac, &aset, &status); /* dac=dac*dac [square] */ } /*i*/ /* 32 bits */ /* complete internal overflow or underflow processing */ if (status & (DEC_Overflow|DEC_Underflow)) { #if DECSUBSET /* If subset, and power was negative, reverse the kind of -erflow */ /* [1/x not yet done] */ if (!set->extended && decNumberIsNegative(rhs)) { if (status & DEC_Overflow) status^=DEC_Overflow | DEC_Underflow | DEC_Subnormal; else { /* trickier -- Underflow may or may not be set */ status&=~(DEC_Underflow | DEC_Subnormal); /* [one or both] */ status|=DEC_Overflow; } } #endif dac->bits=(dac->bits & ~DECNEG) | bits; /* force correct sign */ /* round subnormals [to set.digits rather than aset.digits] */ /* or set overflow result similarly as required */ decFinalize(dac, set, &residue, &status); decNumberCopy(res, dac); /* copy to result (is now OK length) */ break; } #if DECSUBSET if (!set->extended && /* subset math */ decNumberIsNegative(rhs)) { /* was a **-n [hence digits>0] */ /* so divide result into 1 [dac=1/dac] */ decDivideOp(dac, &dnOne, dac, &aset, DIVIDE, &status); } #endif } /* rhs integer path */ /* reduce result to the requested length and copy to result */ decCopyFit(res, dac, set, &residue, &status); decFinish(res, set, &residue, &status); /* final cleanup */ #if DECSUBSET if (!set->extended) decTrim(res, set, 0, 1, &dropped); /* trailing zeros */ #endif } while(0); /* end protected */ free(allocdac); /* drop any storage used */ free(allocinv); /* .. */ #if DECSUBSET free(alloclhs); /* .. */ free(allocrhs); /* .. */ #endif if (status!=0) decStatus(res, status, set); #if DECCHECK decCheckInexact(res, set); #endif return res; } /* decNumberPower */ /* ------------------------------------------------------------------ */ /* decNumberQuantize -- force exponent to requested value */ /* */ /* This computes C = op(A, B), where op adjusts the coefficient */ /* of C (by rounding or shifting) such that the exponent (-scale) */ /* of C has exponent of B. The numerical value of C will equal A, */ /* except for the effects of any rounding that occurred. */ /* */ /* res is C, the result. C may be A or B */ /* lhs is A, the number to adjust */ /* rhs is B, the number with exponent to match */ /* set is the context */ /* */ /* C must have space for set->digits digits. */ /* */ /* Unless there is an error or the result is infinite, the exponent */ /* after the operation is guaranteed to be equal to that of B. */ /* ------------------------------------------------------------------ */ decNumber * decNumberQuantize(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ decQuantizeOp(res, lhs, rhs, set, 1, &status); if (status!=0) decStatus(res, status, set); return res; } /* decNumberQuantize */ /* ------------------------------------------------------------------ */ /* decNumberReduce -- remove trailing zeros */ /* */ /* This computes C = 0 + A, and normalizes the result */ /* */ /* res is C, the result. C may be A */ /* rhs is A */ /* set is the context */ /* */ /* C must have space for set->digits digits. */ /* ------------------------------------------------------------------ */ /* Previously known as Normalize */ decNumber * decNumberNormalize(decNumber *res, const decNumber *rhs, decContext *set) { return decNumberReduce(res, rhs, set); } /* decNumberNormalize */ decNumber * decNumberReduce(decNumber *res, const decNumber *rhs, decContext *set) { #if DECSUBSET decNumber *allocrhs=NULL; /* non-NULL if rounded rhs allocated */ #endif uInt status=0; /* as usual */ Int residue=0; /* as usual */ Int dropped; /* work */ #if DECCHECK if (decCheckOperands(res, DECUNUSED, rhs, set)) return res; #endif do { /* protect allocated storage */ #if DECSUBSET if (!set->extended) { /* reduce operand and set lostDigits status, as needed */ if (rhs->digits>set->digits) { allocrhs=decRoundOperand(rhs, set, &status); if (allocrhs==NULL) break; rhs=allocrhs; } } #endif /* [following code does not require input rounding] */ /* Infinities copy through; NaNs need usual treatment */ if (decNumberIsNaN(rhs)) { decNaNs(res, rhs, NULL, set, &status); break; } /* reduce result to the requested length and copy to result */ decCopyFit(res, rhs, set, &residue, &status); /* copy & round */ decFinish(res, set, &residue, &status); /* cleanup/set flags */ decTrim(res, set, 1, 0, &dropped); /* normalize in place */ /* [may clamp] */ } while(0); /* end protected */ #if DECSUBSET free(allocrhs); /* .. */ #endif if (status!=0) decStatus(res, status, set);/* then report status */ return res; } /* decNumberReduce */ /* ------------------------------------------------------------------ */ /* decNumberRescale -- force exponent to requested value */ /* */ /* This computes C = op(A, B), where op adjusts the coefficient */ /* of C (by rounding or shifting) such that the exponent (-scale) */ /* of C has the value B. The numerical value of C will equal A, */ /* except for the effects of any rounding that occurred. */ /* */ /* res is C, the result. C may be A or B */ /* lhs is A, the number to adjust */ /* rhs is B, the requested exponent */ /* set is the context */ /* */ /* C must have space for set->digits digits. */ /* */ /* Unless there is an error or the result is infinite, the exponent */ /* after the operation is guaranteed to be equal to B. */ /* ------------------------------------------------------------------ */ decNumber * decNumberRescale(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ decQuantizeOp(res, lhs, rhs, set, 0, &status); if (status!=0) decStatus(res, status, set); return res; } /* decNumberRescale */ /* ------------------------------------------------------------------ */ /* decNumberRemainder -- divide and return remainder */ /* */ /* This computes C = A % B */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X%X) */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* */ /* C must have space for set->digits digits. */ /* ------------------------------------------------------------------ */ decNumber * decNumberRemainder(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ decDivideOp(res, lhs, rhs, set, REMAINDER, &status); if (status!=0) decStatus(res, status, set); #if DECCHECK decCheckInexact(res, set); #endif return res; } /* decNumberRemainder */ /* ------------------------------------------------------------------ */ /* decNumberRemainderNear -- divide and return remainder from nearest */ /* */ /* This computes C = A % B, where % is the IEEE remainder operator */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X%X) */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* */ /* C must have space for set->digits digits. */ /* ------------------------------------------------------------------ */ decNumber * decNumberRemainderNear(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ decDivideOp(res, lhs, rhs, set, REMNEAR, &status); if (status!=0) decStatus(res, status, set); #if DECCHECK decCheckInexact(res, set); #endif return res; } /* decNumberRemainderNear */ /* ------------------------------------------------------------------ */ /* decNumberRotate -- rotate the coefficient of a Number left/right */ /* */ /* This computes C = A rot B (in base ten and rotating set->digits */ /* digits). */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=XrotX) */ /* lhs is A */ /* rhs is B, the number of digits to rotate (-ve to right) */ /* set is the context */ /* */ /* The digits of the coefficient of A are rotated to the left (if B */ /* is positive) or to the right (if B is negative) without adjusting */ /* the exponent or the sign of A. If lhs->digits is less than */ /* set->digits the coefficient is padded with zeros on the left */ /* before the rotate. Any leading zeros in the result are removed */ /* as usual. */ /* */ /* B must be an integer (q=0) and in the range -set->digits through */ /* +set->digits. */ /* C must have space for set->digits digits. */ /* NaNs are propagated as usual. Infinities are unaffected (but */ /* B must be valid). No status is set unless B is invalid or an */ /* operand is an sNaN. */ /* ------------------------------------------------------------------ */ decNumber * decNumberRotate(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ Int rotate; /* rhs as an Int */ #if DECCHECK if (decCheckOperands(res, lhs, rhs, set)) return res; #endif /* NaNs propagate as normal */ if (decNumberIsNaN(lhs) || decNumberIsNaN(rhs)) decNaNs(res, lhs, rhs, set, &status); /* rhs must be an integer */ else if (decNumberIsInfinite(rhs) || rhs->exponent!=0) status=DEC_Invalid_operation; else { /* both numeric, rhs is an integer */ rotate=decGetInt(rhs); /* [cannot fail] */ if (rotate==BADINT /* something bad .. */ || rotate==BIGODD || rotate==BIGEVEN /* .. very big .. */ || abs(rotate)>set->digits) /* .. or out of range */ status=DEC_Invalid_operation; else { /* rhs is OK */ decNumberCopy(res, lhs); /* convert -ve rotate to equivalent positive rotation */ if (rotate<0) rotate=set->digits+rotate; if (rotate!=0 && rotate!=set->digits /* zero or full rotation */ && !decNumberIsInfinite(res)) { /* lhs was infinite */ /* left-rotate to do; 0 < rotate < set->digits */ uInt units, shift; /* work */ uInt msudigits; /* digits in result msu */ Unit *msu=res->lsu+D2U(res->digits)-1; /* current msu */ Unit *msumax=res->lsu+D2U(set->digits)-1; /* rotation msu */ for (msu++; msu<=msumax; msu++) *msu=0; /* ensure high units=0 */ res->digits=set->digits; /* now full-length */ msudigits=MSUDIGITS(res->digits); /* actual digits in msu */ /* rotation here is done in-place, in three steps */ /* 1. shift all to least up to one unit to unit-align final */ /* lsd [any digits shifted out are rotated to the left, */ /* abutted to the original msd (which may require split)] */ /* */ /* [if there are no whole units left to rotate, the */ /* rotation is now complete] */ /* */ /* 2. shift to least, from below the split point only, so that */ /* the final msd is in the right place in its Unit [any */ /* digits shifted out will fit exactly in the current msu, */ /* left aligned, no split required] */ /* */ /* 3. rotate all the units by reversing left part, right */ /* part, and then whole */ /* */ /* example: rotate right 8 digits (2 units + 2), DECDPUN=3. */ /* */ /* start: 00a bcd efg hij klm npq */ /* */ /* 1a 000 0ab cde fgh|ijk lmn [pq saved] */ /* 1b 00p qab cde fgh|ijk lmn */ /* */ /* 2a 00p qab cde fgh|00i jkl [mn saved] */ /* 2b mnp qab cde fgh|00i jkl */ /* */ /* 3a fgh cde qab mnp|00i jkl */ /* 3b fgh cde qab mnp|jkl 00i */ /* 3c 00i jkl mnp qab cde fgh */ /* Step 1: amount to shift is the partial right-rotate count */ rotate=set->digits-rotate; /* make it right-rotate */ units=rotate/DECDPUN; /* whole units to rotate */ shift=rotate%DECDPUN; /* left-over digits count */ if (shift>0) { /* not an exact number of units */ uInt save=res->lsu[0]%powers[shift]; /* save low digit(s) */ decShiftToLeast(res->lsu, D2U(res->digits), shift); if (shift>msudigits) { /* msumax-1 needs >0 digits */ uInt rem=save%powers[shift-msudigits];/* split save */ *msumax=(Unit)(save/powers[shift-msudigits]); /* and insert */ *(msumax-1)=*(msumax-1) +(Unit)(rem*powers[DECDPUN-(shift-msudigits)]); /* .. */ } else { /* all fits in msumax */ *msumax=*msumax+(Unit)(save*powers[msudigits-shift]); /* [maybe *1] */ } } /* digits shift needed */ /* If whole units to rotate... */ if (units>0) { /* some to do */ /* Step 2: the units to touch are the whole ones in rotate, */ /* if any, and the shift is DECDPUN-msudigits (which may be */ /* 0, again) */ shift=DECDPUN-msudigits; if (shift>0) { /* not an exact number of units */ uInt save=res->lsu[0]%powers[shift]; /* save low digit(s) */ decShiftToLeast(res->lsu, units, shift); *msumax=*msumax+(Unit)(save*powers[msudigits]); } /* partial shift needed */ /* Step 3: rotate the units array using triple reverse */ /* (reversing is easy and fast) */ decReverse(res->lsu+units, msumax); /* left part */ decReverse(res->lsu, res->lsu+units-1); /* right part */ decReverse(res->lsu, msumax); /* whole */ } /* whole units to rotate */ /* the rotation may have left an undetermined number of zeros */ /* on the left, so true length needs to be calculated */ res->digits=decGetDigits(res->lsu, msumax-res->lsu+1); } /* rotate needed */ } /* rhs OK */ } /* numerics */ if (status!=0) decStatus(res, status, set); return res; } /* decNumberRotate */ /* ------------------------------------------------------------------ */ /* decNumberSameQuantum -- test for equal exponents */ /* */ /* res is the result number, which will contain either 0 or 1 */ /* lhs is a number to test */ /* rhs is the second (usually a pattern) */ /* */ /* No errors are possible and no context is needed. */ /* ------------------------------------------------------------------ */ decNumber * decNumberSameQuantum(decNumber *res, const decNumber *lhs, const decNumber *rhs) { Unit ret=0; /* return value */ #if DECCHECK if (decCheckOperands(res, lhs, rhs, DECUNCONT)) return res; #endif if (SPECIALARGS) { if (decNumberIsNaN(lhs) && decNumberIsNaN(rhs)) ret=1; else if (decNumberIsInfinite(lhs) && decNumberIsInfinite(rhs)) ret=1; /* [anything else with a special gives 0] */ } else if (lhs->exponent==rhs->exponent) ret=1; decNumberZero(res); /* OK to overwrite an operand now */ *res->lsu=ret; return res; } /* decNumberSameQuantum */ /* ------------------------------------------------------------------ */ /* decNumberScaleB -- multiply by a power of 10 */ /* */ /* This computes C = A x 10**B where B is an integer (q=0) with */ /* maximum magnitude 2*(emax+digits) */ /* */ /* res is C, the result. C may be A or B */ /* lhs is A, the number to adjust */ /* rhs is B, the requested power of ten to use */ /* set is the context */ /* */ /* C must have space for set->digits digits. */ /* */ /* The result may underflow or overflow. */ /* ------------------------------------------------------------------ */ decNumber * decNumberScaleB(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { Int reqexp; /* requested exponent change [B] */ uInt status=0; /* accumulator */ Int residue; /* work */ #if DECCHECK if (decCheckOperands(res, lhs, rhs, set)) return res; #endif /* Handle special values except lhs infinite */ if (decNumberIsNaN(lhs) || decNumberIsNaN(rhs)) decNaNs(res, lhs, rhs, set, &status); /* rhs must be an integer */ else if (decNumberIsInfinite(rhs) || rhs->exponent!=0) status=DEC_Invalid_operation; else { /* lhs is a number; rhs is a finite with q==0 */ reqexp=decGetInt(rhs); /* [cannot fail] */ if (reqexp==BADINT /* something bad .. */ || reqexp==BIGODD || reqexp==BIGEVEN /* .. very big .. */ || abs(reqexp)>(2*(set->digits+set->emax))) /* .. or out of range */ status=DEC_Invalid_operation; else { /* rhs is OK */ decNumberCopy(res, lhs); /* all done if infinite lhs */ if (!decNumberIsInfinite(res)) { /* prepare to scale */ res->exponent+=reqexp; /* adjust the exponent */ residue=0; decFinalize(res, set, &residue, &status); /* .. and check */ } /* finite LHS */ } /* rhs OK */ } /* rhs finite */ if (status!=0) decStatus(res, status, set); return res; } /* decNumberScaleB */ /* ------------------------------------------------------------------ */ /* decNumberShift -- shift the coefficient of a Number left or right */ /* */ /* This computes C = A << B or C = A >> -B (in base ten). */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X<digits through */ /* +set->digits. */ /* C must have space for set->digits digits. */ /* NaNs are propagated as usual. Infinities are unaffected (but */ /* B must be valid). No status is set unless B is invalid or an */ /* operand is an sNaN. */ /* ------------------------------------------------------------------ */ decNumber * decNumberShift(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ Int shift; /* rhs as an Int */ #if DECCHECK if (decCheckOperands(res, lhs, rhs, set)) return res; #endif /* NaNs propagate as normal */ if (decNumberIsNaN(lhs) || decNumberIsNaN(rhs)) decNaNs(res, lhs, rhs, set, &status); /* rhs must be an integer */ else if (decNumberIsInfinite(rhs) || rhs->exponent!=0) status=DEC_Invalid_operation; else { /* both numeric, rhs is an integer */ shift=decGetInt(rhs); /* [cannot fail] */ if (shift==BADINT /* something bad .. */ || shift==BIGODD || shift==BIGEVEN /* .. very big .. */ || abs(shift)>set->digits) /* .. or out of range */ status=DEC_Invalid_operation; else { /* rhs is OK */ decNumberCopy(res, lhs); if (shift!=0 && !decNumberIsInfinite(res)) { /* something to do */ if (shift>0) { /* to left */ if (shift==set->digits) { /* removing all */ *res->lsu=0; /* so place 0 */ res->digits=1; /* .. */ } else { /* */ /* first remove leading digits if necessary */ if (res->digits+shift>set->digits) { decDecap(res, res->digits+shift-set->digits); /* that updated res->digits; may have gone to 1 (for a */ /* single digit or for zero */ } if (res->digits>1 || *res->lsu) /* if non-zero.. */ res->digits=decShiftToMost(res->lsu, res->digits, shift); } /* partial left */ } /* left */ else { /* to right */ if (-shift>=res->digits) { /* discarding all */ *res->lsu=0; /* so place 0 */ res->digits=1; /* .. */ } else { decShiftToLeast(res->lsu, D2U(res->digits), -shift); res->digits-=(-shift); } } /* to right */ } /* non-0 non-Inf shift */ } /* rhs OK */ } /* numerics */ if (status!=0) decStatus(res, status, set); return res; } /* decNumberShift */ /* ------------------------------------------------------------------ */ /* decNumberSquareRoot -- square root operator */ /* */ /* This computes C = squareroot(A) */ /* */ /* res is C, the result. C may be A */ /* rhs is A */ /* set is the context; note that rounding mode has no effect */ /* */ /* C must have space for set->digits digits. */ /* ------------------------------------------------------------------ */ /* This uses the following varying-precision algorithm in: */ /* */ /* Properly Rounded Variable Precision Square Root, T. E. Hull and */ /* A. Abrham, ACM Transactions on Mathematical Software, Vol 11 #3, */ /* pp229-237, ACM, September 1985. */ /* */ /* The square-root is calculated using Newton's method, after which */ /* a check is made to ensure the result is correctly rounded. */ /* */ /* % [Reformatted original Numerical Turing source code follows.] */ /* function sqrt(x : real) : real */ /* % sqrt(x) returns the properly rounded approximation to the square */ /* % root of x, in the precision of the calling environment, or it */ /* % fails if x < 0. */ /* % t e hull and a abrham, august, 1984 */ /* if x <= 0 then */ /* if x < 0 then */ /* assert false */ /* else */ /* result 0 */ /* end if */ /* end if */ /* var f := setexp(x, 0) % fraction part of x [0.1 <= x < 1] */ /* var e := getexp(x) % exponent part of x */ /* var approx : real */ /* if e mod 2 = 0 then */ /* approx := .259 + .819 * f % approx to root of f */ /* else */ /* f := f/l0 % adjustments */ /* e := e + 1 % for odd */ /* approx := .0819 + 2.59 * f % exponent */ /* end if */ /* */ /* var p:= 3 */ /* const maxp := currentprecision + 2 */ /* loop */ /* p := min(2*p - 2, maxp) % p = 4,6,10, . . . , maxp */ /* precision p */ /* approx := .5 * (approx + f/approx) */ /* exit when p = maxp */ /* end loop */ /* */ /* % approx is now within 1 ulp of the properly rounded square root */ /* % of f; to ensure proper rounding, compare squares of (approx - */ /* % l/2 ulp) and (approx + l/2 ulp) with f. */ /* p := currentprecision */ /* begin */ /* precision p + 2 */ /* const approxsubhalf := approx - setexp(.5, -p) */ /* if mulru(approxsubhalf, approxsubhalf) > f then */ /* approx := approx - setexp(.l, -p + 1) */ /* else */ /* const approxaddhalf := approx + setexp(.5, -p) */ /* if mulrd(approxaddhalf, approxaddhalf) < f then */ /* approx := approx + setexp(.l, -p + 1) */ /* end if */ /* end if */ /* end */ /* result setexp(approx, e div 2) % fix exponent */ /* end sqrt */ /* ------------------------------------------------------------------ */ decNumber * decNumberSquareRoot(decNumber *res, const decNumber *rhs, decContext *set) { decContext workset, approxset; /* work contexts */ decNumber dzero; /* used for constant zero */ Int maxp; /* largest working precision */ Int workp; /* working precision */ Int residue=0; /* rounding residue */ uInt status=0, ignore=0; /* status accumulators */ uInt rstatus; /* .. */ Int exp; /* working exponent */ Int ideal; /* ideal (preferred) exponent */ Int needbytes; /* work */ Int dropped; /* .. */ #if DECSUBSET decNumber *allocrhs=NULL; /* non-NULL if rounded rhs allocated */ #endif /* buffer for f [needs +1 in case DECBUFFER 0] */ decNumber buff[D2N(DECBUFFER+1)]; /* buffer for a [needs +2 to match likely maxp] */ decNumber bufa[D2N(DECBUFFER+2)]; /* buffer for temporary, b [must be same size as a] */ decNumber bufb[D2N(DECBUFFER+2)]; decNumber *allocbuff=NULL; /* -> allocated buff, iff allocated */ decNumber *allocbufa=NULL; /* -> allocated bufa, iff allocated */ decNumber *allocbufb=NULL; /* -> allocated bufb, iff allocated */ decNumber *f=buff; /* reduced fraction */ decNumber *a=bufa; /* approximation to result */ decNumber *b=bufb; /* intermediate result */ /* buffer for temporary variable, up to 3 digits */ decNumber buft[D2N(3)]; decNumber *t=buft; /* up-to-3-digit constant or work */ #if DECCHECK if (decCheckOperands(res, DECUNUSED, rhs, set)) return res; #endif do { /* protect allocated storage */ #if DECSUBSET if (!set->extended) { /* reduce operand and set lostDigits status, as needed */ if (rhs->digits>set->digits) { allocrhs=decRoundOperand(rhs, set, &status); if (allocrhs==NULL) break; /* [Note: 'f' allocation below could reuse this buffer if */ /* used, but as this is rare they are kept separate for clarity.] */ rhs=allocrhs; } } #endif /* [following code does not require input rounding] */ /* handle infinities and NaNs */ if (SPECIALARG) { if (decNumberIsInfinite(rhs)) { /* an infinity */ if (decNumberIsNegative(rhs)) status|=DEC_Invalid_operation; else decNumberCopy(res, rhs); /* +Infinity */ } else decNaNs(res, rhs, NULL, set, &status); /* a NaN */ break; } /* calculate the ideal (preferred) exponent [floor(exp/2)] */ /* [It would be nicer to write: ideal=rhs->exponent>>1, but this */ /* generates a compiler warning. Generated code is the same.] */ ideal=(rhs->exponent&~1)/2; /* target */ /* handle zeros */ if (ISZERO(rhs)) { decNumberCopy(res, rhs); /* could be 0 or -0 */ res->exponent=ideal; /* use the ideal [safe] */ /* use decFinish to clamp any out-of-range exponent, etc. */ decFinish(res, set, &residue, &status); break; } /* any other -x is an oops */ if (decNumberIsNegative(rhs)) { status|=DEC_Invalid_operation; break; } /* space is needed for three working variables */ /* f -- the same precision as the RHS, reduced to 0.01->0.99... */ /* a -- Hull's approximation -- precision, when assigned, is */ /* currentprecision+1 or the input argument precision, */ /* whichever is larger (+2 for use as temporary) */ /* b -- intermediate temporary result (same size as a) */ /* if any is too long for local storage, then allocate */ workp=MAXI(set->digits+1, rhs->digits); /* actual rounding precision */ workp=MAXI(workp, 7); /* at least 7 for low cases */ maxp=workp+2; /* largest working precision */ needbytes=sizeof(decNumber)+(D2U(rhs->digits)-1)*sizeof(Unit); if (needbytes>(Int)sizeof(buff)) { allocbuff=(decNumber *)malloc(needbytes); if (allocbuff==NULL) { /* hopeless -- abandon */ status|=DEC_Insufficient_storage; break;} f=allocbuff; /* use the allocated space */ } /* a and b both need to be able to hold a maxp-length number */ needbytes=sizeof(decNumber)+(D2U(maxp)-1)*sizeof(Unit); if (needbytes>(Int)sizeof(bufa)) { /* [same applies to b] */ allocbufa=(decNumber *)malloc(needbytes); allocbufb=(decNumber *)malloc(needbytes); if (allocbufa==NULL || allocbufb==NULL) { /* hopeless */ status|=DEC_Insufficient_storage; break;} a=allocbufa; /* use the allocated spaces */ b=allocbufb; /* .. */ } /* copy rhs -> f, save exponent, and reduce so 0.1 <= f < 1 */ decNumberCopy(f, rhs); exp=f->exponent+f->digits; /* adjusted to Hull rules */ f->exponent=-(f->digits); /* to range */ /* set up working context */ decContextDefault(&workset, DEC_INIT_DECIMAL64); workset.emax=DEC_MAX_EMAX; workset.emin=DEC_MIN_EMIN; /* [Until further notice, no error is possible and status bits */ /* (Rounded, etc.) should be ignored, not accumulated.] */ /* Calculate initial approximation, and allow for odd exponent */ workset.digits=workp; /* p for initial calculation */ t->bits=0; t->digits=3; a->bits=0; a->digits=3; if ((exp & 1)==0) { /* even exponent */ /* Set t=0.259, a=0.819 */ t->exponent=-3; a->exponent=-3; #if DECDPUN>=3 t->lsu[0]=259; a->lsu[0]=819; #elif DECDPUN==2 t->lsu[0]=59; t->lsu[1]=2; a->lsu[0]=19; a->lsu[1]=8; #else t->lsu[0]=9; t->lsu[1]=5; t->lsu[2]=2; a->lsu[0]=9; a->lsu[1]=1; a->lsu[2]=8; #endif } else { /* odd exponent */ /* Set t=0.0819, a=2.59 */ f->exponent--; /* f=f/10 */ exp++; /* e=e+1 */ t->exponent=-4; a->exponent=-2; #if DECDPUN>=3 t->lsu[0]=819; a->lsu[0]=259; #elif DECDPUN==2 t->lsu[0]=19; t->lsu[1]=8; a->lsu[0]=59; a->lsu[1]=2; #else t->lsu[0]=9; t->lsu[1]=1; t->lsu[2]=8; a->lsu[0]=9; a->lsu[1]=5; a->lsu[2]=2; #endif } decMultiplyOp(a, a, f, &workset, &ignore); /* a=a*f */ decAddOp(a, a, t, &workset, 0, &ignore); /* ..+t */ /* [a is now the initial approximation for sqrt(f), calculated with */ /* currentprecision, which is also a's precision.] */ /* the main calculation loop */ decNumberZero(&dzero); /* make 0 */ decNumberZero(t); /* set t = 0.5 */ t->lsu[0]=5; /* .. */ t->exponent=-1; /* .. */ workset.digits=3; /* initial p */ for (; workset.digitsexponent+=exp/2; /* set correct exponent */ rstatus=0; /* clear status */ residue=0; /* .. and accumulator */ decCopyFit(a, a, &approxset, &residue, &rstatus); /* reduce (if needed) */ decFinish(a, &approxset, &residue, &rstatus); /* clean and finalize */ /* Overflow was possible if the input exponent was out-of-range, */ /* in which case quit */ if (rstatus&DEC_Overflow) { status=rstatus; /* use the status as-is */ decNumberCopy(res, a); /* copy to result */ break; } /* Preserve status except Inexact/Rounded */ status|=(rstatus & ~(DEC_Rounded|DEC_Inexact)); /* Carry out the Hull correction */ a->exponent-=exp/2; /* back to 0.1->1 */ /* a is now at final precision and within 1 ulp of the properly */ /* rounded square root of f; to ensure proper rounding, compare */ /* squares of (a - l/2 ulp) and (a + l/2 ulp) with f. */ /* Here workset.digits=maxp and t=0.5, and a->digits determines */ /* the ulp */ workset.digits--; /* maxp-1 is OK now */ t->exponent=-a->digits-1; /* make 0.5 ulp */ decAddOp(b, a, t, &workset, DECNEG, &ignore); /* b = a - 0.5 ulp */ workset.round=DEC_ROUND_UP; decMultiplyOp(b, b, b, &workset, &ignore); /* b = mulru(b, b) */ decCompareOp(b, f, b, &workset, COMPARE, &ignore); /* b ? f, reversed */ if (decNumberIsNegative(b)) { /* f < b [i.e., b > f] */ /* this is the more common adjustment, though both are rare */ t->exponent++; /* make 1.0 ulp */ t->lsu[0]=1; /* .. */ decAddOp(a, a, t, &workset, DECNEG, &ignore); /* a = a - 1 ulp */ /* assign to approx [round to length] */ approxset.emin-=exp/2; /* adjust to match a */ approxset.emax-=exp/2; decAddOp(a, &dzero, a, &approxset, 0, &ignore); } else { decAddOp(b, a, t, &workset, 0, &ignore); /* b = a + 0.5 ulp */ workset.round=DEC_ROUND_DOWN; decMultiplyOp(b, b, b, &workset, &ignore); /* b = mulrd(b, b) */ decCompareOp(b, b, f, &workset, COMPARE, &ignore); /* b ? f */ if (decNumberIsNegative(b)) { /* b < f */ t->exponent++; /* make 1.0 ulp */ t->lsu[0]=1; /* .. */ decAddOp(a, a, t, &workset, 0, &ignore); /* a = a + 1 ulp */ /* assign to approx [round to length] */ approxset.emin-=exp/2; /* adjust to match a */ approxset.emax-=exp/2; decAddOp(a, &dzero, a, &approxset, 0, &ignore); } } /* [no errors are possible in the above, and rounding/inexact during */ /* estimation are irrelevant, so status was not accumulated] */ /* Here, 0.1 <= a < 1 (still), so adjust back */ a->exponent+=exp/2; /* set correct exponent */ /* count droppable zeros [after any subnormal rounding] by */ /* trimming a copy */ decNumberCopy(b, a); decTrim(b, set, 1, 1, &dropped); /* [drops trailing zeros] */ /* Set Inexact and Rounded. The answer can only be exact if */ /* it is short enough so that squaring it could fit in workp */ /* digits, so this is the only (relatively rare) condition that */ /* a careful check is needed */ if (b->digits*2-1 > workp) { /* cannot fit */ status|=DEC_Inexact|DEC_Rounded; } else { /* could be exact/unrounded */ uInt mstatus=0; /* local status */ decMultiplyOp(b, b, b, &workset, &mstatus); /* try the multiply */ if (mstatus&DEC_Overflow) { /* result just won't fit */ status|=DEC_Inexact|DEC_Rounded; } else { /* plausible */ decCompareOp(t, b, rhs, &workset, COMPARE, &mstatus); /* b ? rhs */ if (!ISZERO(t)) status|=DEC_Inexact|DEC_Rounded; /* not equal */ else { /* is Exact */ /* here, dropped is the count of trailing zeros in 'a' */ /* use closest exponent to ideal... */ Int todrop=ideal-a->exponent; /* most that can be dropped */ if (todrop<0) status|=DEC_Rounded; /* ideally would add 0s */ else { /* unrounded */ /* there are some to drop, but emax may not allow all */ Int maxexp=set->emax-set->digits+1; Int maxdrop=maxexp-a->exponent; if (todrop>maxdrop && set->clamp) { /* apply clamping */ todrop=maxdrop; status|=DEC_Clamped; } if (dropped0) { /* have some to drop */ decShiftToLeast(a->lsu, D2U(a->digits), todrop); a->exponent+=todrop; /* maintain numerical value */ a->digits-=todrop; /* new length */ } } } } } /* double-check Underflow, as perhaps the result could not have */ /* been subnormal (initial argument too big), or it is now Exact */ if (status&DEC_Underflow) { Int ae=rhs->exponent+rhs->digits-1; /* adjusted exponent */ /* check if truly subnormal */ #if DECEXTFLAG /* DEC_Subnormal too */ if (ae>=set->emin*2) status&=~(DEC_Subnormal|DEC_Underflow); #else if (ae>=set->emin*2) status&=~DEC_Underflow; #endif /* check if truly inexact */ if (!(status&DEC_Inexact)) status&=~DEC_Underflow; } decNumberCopy(res, a); /* a is now the result */ } while(0); /* end protected */ free(allocbuff); /* drop any storage used */ free(allocbufa); /* .. */ free(allocbufb); /* .. */ #if DECSUBSET free(allocrhs); /* .. */ #endif if (status!=0) decStatus(res, status, set);/* then report status */ #if DECCHECK decCheckInexact(res, set); #endif return res; } /* decNumberSquareRoot */ /* ------------------------------------------------------------------ */ /* decNumberSubtract -- subtract two Numbers */ /* */ /* This computes C = A - B */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X-X) */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* */ /* C must have space for set->digits digits. */ /* ------------------------------------------------------------------ */ decNumber * decNumberSubtract(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { uInt status=0; /* accumulator */ decAddOp(res, lhs, rhs, set, DECNEG, &status); if (status!=0) decStatus(res, status, set); #if DECCHECK decCheckInexact(res, set); #endif return res; } /* decNumberSubtract */ /* ------------------------------------------------------------------ */ /* decNumberToIntegralExact -- round-to-integral-value with InExact */ /* decNumberToIntegralValue -- round-to-integral-value */ /* */ /* res is the result */ /* rhs is input number */ /* set is the context */ /* */ /* res must have space for any value of rhs. */ /* */ /* This implements the IEEE special operators and therefore treats */ /* special values as valid. For finite numbers it returns */ /* rescale(rhs, 0) if rhs->exponent is <0. */ /* Otherwise the result is rhs (so no error is possible, except for */ /* sNaN). */ /* */ /* The context is used for rounding mode and status after sNaN, but */ /* the digits setting is ignored. The Exact version will signal */ /* Inexact if the result differs numerically from rhs; the other */ /* never signals Inexact. */ /* ------------------------------------------------------------------ */ decNumber * decNumberToIntegralExact(decNumber *res, const decNumber *rhs, decContext *set) { decNumber dn; decContext workset; /* working context */ uInt status=0; /* accumulator */ #if DECCHECK if (decCheckOperands(res, DECUNUSED, rhs, set)) return res; #endif /* handle infinities and NaNs */ if (SPECIALARG) { if (decNumberIsInfinite(rhs)) decNumberCopy(res, rhs); /* an Infinity */ else decNaNs(res, rhs, NULL, set, &status); /* a NaN */ } else { /* finite */ /* have a finite number; no error possible (res must be big enough) */ if (rhs->exponent>=0) return decNumberCopy(res, rhs); /* that was easy, but if negative exponent there is work to do... */ workset=*set; /* clone rounding, etc. */ workset.digits=rhs->digits; /* no length rounding */ workset.traps=0; /* no traps */ decNumberZero(&dn); /* make a number with exponent 0 */ decNumberQuantize(res, rhs, &dn, &workset); status|=workset.status; } if (status!=0) decStatus(res, status, set); return res; } /* decNumberToIntegralExact */ decNumber * decNumberToIntegralValue(decNumber *res, const decNumber *rhs, decContext *set) { decContext workset=*set; /* working context */ workset.traps=0; /* no traps */ decNumberToIntegralExact(res, rhs, &workset); /* this never affects set, except for sNaNs; NaN will have been set */ /* or propagated already, so no need to call decStatus */ set->status|=workset.status&DEC_Invalid_operation; return res; } /* decNumberToIntegralValue */ /* ------------------------------------------------------------------ */ /* decNumberXor -- XOR two Numbers, digitwise */ /* */ /* This computes C = A ^ B */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X^X) */ /* lhs is A */ /* rhs is B */ /* set is the context (used for result length and error report) */ /* */ /* C must have space for set->digits digits. */ /* */ /* Logical function restrictions apply (see above); a NaN is */ /* returned with Invalid_operation if a restriction is violated. */ /* ------------------------------------------------------------------ */ decNumber * decNumberXor(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { const Unit *ua, *ub; /* -> operands */ const Unit *msua, *msub; /* -> operand msus */ Unit *uc, *msuc; /* -> result and its msu */ Int msudigs; /* digits in res msu */ #if DECCHECK if (decCheckOperands(res, lhs, rhs, set)) return res; #endif if (lhs->exponent!=0 || decNumberIsSpecial(lhs) || decNumberIsNegative(lhs) || rhs->exponent!=0 || decNumberIsSpecial(rhs) || decNumberIsNegative(rhs)) { decStatus(res, DEC_Invalid_operation, set); return res; } /* operands are valid */ ua=lhs->lsu; /* bottom-up */ ub=rhs->lsu; /* .. */ uc=res->lsu; /* .. */ msua=ua+D2U(lhs->digits)-1; /* -> msu of lhs */ msub=ub+D2U(rhs->digits)-1; /* -> msu of rhs */ msuc=uc+D2U(set->digits)-1; /* -> msu of result */ msudigs=MSUDIGITS(set->digits); /* [faster than remainder] */ for (; uc<=msuc; ua++, ub++, uc++) { /* Unit loop */ Unit a, b; /* extract units */ if (ua>msua) a=0; else a=*ua; if (ub>msub) b=0; else b=*ub; *uc=0; /* can now write back */ if (a|b) { /* maybe 1 bits to examine */ Int i, j; /* This loop could be unrolled and/or use BIN2BCD tables */ for (i=0; i1) { decStatus(res, DEC_Invalid_operation, set); return res; } if (uc==msuc && i==msudigs-1) break; /* just did final digit */ } /* each digit */ } /* non-zero */ } /* each unit */ /* [here uc-1 is the msu of the result] */ res->digits=decGetDigits(res->lsu, uc-res->lsu); res->exponent=0; /* integer */ res->bits=0; /* sign=0 */ return res; /* [no status to set] */ } /* decNumberXor */ /* ================================================================== */ /* Utility routines */ /* ================================================================== */ /* ------------------------------------------------------------------ */ /* decNumberClass -- return the decClass of a decNumber */ /* dn -- the decNumber to test */ /* set -- the context to use for Emin */ /* returns the decClass enum */ /* ------------------------------------------------------------------ */ enum decClass decNumberClass(const decNumber *dn, decContext *set) { if (decNumberIsSpecial(dn)) { if (decNumberIsQNaN(dn)) return DEC_CLASS_QNAN; if (decNumberIsSNaN(dn)) return DEC_CLASS_SNAN; /* must be an infinity */ if (decNumberIsNegative(dn)) return DEC_CLASS_NEG_INF; return DEC_CLASS_POS_INF; } /* is finite */ if (decNumberIsNormal(dn, set)) { /* most common */ if (decNumberIsNegative(dn)) return DEC_CLASS_NEG_NORMAL; return DEC_CLASS_POS_NORMAL; } /* is subnormal or zero */ if (decNumberIsZero(dn)) { /* most common */ if (decNumberIsNegative(dn)) return DEC_CLASS_NEG_ZERO; return DEC_CLASS_POS_ZERO; } if (decNumberIsNegative(dn)) return DEC_CLASS_NEG_SUBNORMAL; return DEC_CLASS_POS_SUBNORMAL; } /* decNumberClass */ /* ------------------------------------------------------------------ */ /* decNumberClassToString -- convert decClass to a string */ /* */ /* eclass is a valid decClass */ /* returns a constant string describing the class (max 13+1 chars) */ /* ------------------------------------------------------------------ */ const char *decNumberClassToString(enum decClass eclass) { if (eclass==DEC_CLASS_POS_NORMAL) return DEC_ClassString_PN; if (eclass==DEC_CLASS_NEG_NORMAL) return DEC_ClassString_NN; if (eclass==DEC_CLASS_POS_ZERO) return DEC_ClassString_PZ; if (eclass==DEC_CLASS_NEG_ZERO) return DEC_ClassString_NZ; if (eclass==DEC_CLASS_POS_SUBNORMAL) return DEC_ClassString_PS; if (eclass==DEC_CLASS_NEG_SUBNORMAL) return DEC_ClassString_NS; if (eclass==DEC_CLASS_POS_INF) return DEC_ClassString_PI; if (eclass==DEC_CLASS_NEG_INF) return DEC_ClassString_NI; if (eclass==DEC_CLASS_QNAN) return DEC_ClassString_QN; if (eclass==DEC_CLASS_SNAN) return DEC_ClassString_SN; return DEC_ClassString_UN; /* Unknown */ } /* decNumberClassToString */ /* ------------------------------------------------------------------ */ /* decNumberCopy -- copy a number */ /* */ /* dest is the target decNumber */ /* src is the source decNumber */ /* returns dest */ /* */ /* (dest==src is allowed and is a no-op) */ /* All fields are updated as required. This is a utility operation, */ /* so special values are unchanged and no error is possible. */ /* ------------------------------------------------------------------ */ decNumber * decNumberCopy(decNumber *dest, const decNumber *src) { #if DECCHECK if (src==NULL) return decNumberZero(dest); #endif if (dest==src) return dest; /* no copy required */ /* Use explicit assignments here as structure assignment could copy */ /* more than just the lsu (for small DECDPUN). This would not affect */ /* the value of the results, but could disturb test harness spill */ /* checking. */ dest->bits=src->bits; dest->exponent=src->exponent; dest->digits=src->digits; dest->lsu[0]=src->lsu[0]; if (src->digits>DECDPUN) { /* more Units to come */ const Unit *smsup, *s; /* work */ Unit *d; /* .. */ /* memcpy for the remaining Units would be safe as they cannot */ /* overlap. However, this explicit loop is faster in short cases. */ d=dest->lsu+1; /* -> first destination */ smsup=src->lsu+D2U(src->digits); /* -> source msu+1 */ for (s=src->lsu+1; sdigits digits. */ /* No exception or error can occur; this is a quiet bitwise operation.*/ /* See also decNumberAbs for a checking version of this. */ /* ------------------------------------------------------------------ */ decNumber * decNumberCopyAbs(decNumber *res, const decNumber *rhs) { #if DECCHECK if (decCheckOperands(res, DECUNUSED, rhs, DECUNCONT)) return res; #endif decNumberCopy(res, rhs); res->bits&=~DECNEG; /* turn off sign */ return res; } /* decNumberCopyAbs */ /* ------------------------------------------------------------------ */ /* decNumberCopyNegate -- quiet negate value operator */ /* */ /* This sets C = negate(A) */ /* */ /* res is C, the result. C may be A */ /* rhs is A */ /* */ /* C must have space for set->digits digits. */ /* No exception or error can occur; this is a quiet bitwise operation.*/ /* See also decNumberMinus for a checking version of this. */ /* ------------------------------------------------------------------ */ decNumber * decNumberCopyNegate(decNumber *res, const decNumber *rhs) { #if DECCHECK if (decCheckOperands(res, DECUNUSED, rhs, DECUNCONT)) return res; #endif decNumberCopy(res, rhs); res->bits^=DECNEG; /* invert the sign */ return res; } /* decNumberCopyNegate */ /* ------------------------------------------------------------------ */ /* decNumberCopySign -- quiet copy and set sign operator */ /* */ /* This sets C = A with the sign of B */ /* */ /* res is C, the result. C may be A */ /* lhs is A */ /* rhs is B */ /* */ /* C must have space for set->digits digits. */ /* No exception or error can occur; this is a quiet bitwise operation.*/ /* ------------------------------------------------------------------ */ decNumber * decNumberCopySign(decNumber *res, const decNumber *lhs, const decNumber *rhs) { uByte sign; /* rhs sign */ #if DECCHECK if (decCheckOperands(res, DECUNUSED, rhs, DECUNCONT)) return res; #endif sign=rhs->bits & DECNEG; /* save sign bit */ decNumberCopy(res, lhs); res->bits&=~DECNEG; /* clear the sign */ res->bits|=sign; /* set from rhs */ return res; } /* decNumberCopySign */ /* ------------------------------------------------------------------ */ /* decNumberGetBCD -- get the coefficient in BCD8 */ /* dn is the source decNumber */ /* bcd is the uInt array that will receive dn->digits BCD bytes, */ /* most-significant at offset 0 */ /* returns bcd */ /* */ /* bcd must have at least dn->digits bytes. No error is possible; if */ /* dn is a NaN or Infinite, digits must be 1 and the coefficient 0. */ /* ------------------------------------------------------------------ */ uByte * decNumberGetBCD(const decNumber *dn, uByte *bcd) { uByte *ub=bcd+dn->digits-1; /* -> lsd */ const Unit *up=dn->lsu; /* Unit pointer, -> lsu */ #if DECDPUN==1 /* trivial simple copy */ for (; ub>=bcd; ub--, up++) *ub=*up; #else /* chopping needed */ uInt u=*up; /* work */ uInt cut=DECDPUN; /* downcounter through unit */ for (; ub>=bcd; ub--) { *ub=(uByte)(u%10); /* [*6554 trick inhibits, here] */ u=u/10; cut--; if (cut>0) continue; /* more in this unit */ up++; u=*up; cut=DECDPUN; } #endif return bcd; } /* decNumberGetBCD */ /* ------------------------------------------------------------------ */ /* decNumberSetBCD -- set (replace) the coefficient from BCD8 */ /* dn is the target decNumber */ /* bcd is the uInt array that will source n BCD bytes, most- */ /* significant at offset 0 */ /* n is the number of digits in the source BCD array (bcd) */ /* returns dn */ /* */ /* dn must have space for at least n digits. No error is possible; */ /* if dn is a NaN, or Infinite, or is to become a zero, n must be 1 */ /* and bcd[0] zero. */ /* ------------------------------------------------------------------ */ decNumber * decNumberSetBCD(decNumber *dn, const uByte *bcd, uInt n) { Unit *up=dn->lsu+D2U(dn->digits)-1; /* -> msu [target pointer] */ const uByte *ub=bcd; /* -> source msd */ #if DECDPUN==1 /* trivial simple copy */ for (; ub=dn->lsu; up--) { /* each Unit from msu */ *up=0; /* will take <=DECDPUN digits */ for (; cut>0; ub++, cut--) *up=X10(*up)+*ub; cut=DECDPUN; /* next Unit has all digits */ } #endif dn->digits=n; /* set digit count */ return dn; } /* decNumberSetBCD */ /* ------------------------------------------------------------------ */ /* decNumberIsNormal -- test normality of a decNumber */ /* dn is the decNumber to test */ /* set is the context to use for Emin */ /* returns 1 if |dn| is finite and >=Nmin, 0 otherwise */ /* ------------------------------------------------------------------ */ Int decNumberIsNormal(const decNumber *dn, decContext *set) { Int ae; /* adjusted exponent */ #if DECCHECK if (decCheckOperands(DECUNRESU, DECUNUSED, dn, set)) return 0; #endif if (decNumberIsSpecial(dn)) return 0; /* not finite */ if (decNumberIsZero(dn)) return 0; /* not non-zero */ ae=dn->exponent+dn->digits-1; /* adjusted exponent */ if (aeemin) return 0; /* is subnormal */ return 1; } /* decNumberIsNormal */ /* ------------------------------------------------------------------ */ /* decNumberIsSubnormal -- test subnormality of a decNumber */ /* dn is the decNumber to test */ /* set is the context to use for Emin */ /* returns 1 if |dn| is finite, non-zero, and exponent+dn->digits-1; /* adjusted exponent */ if (aeemin) return 1; /* is subnormal */ return 0; } /* decNumberIsSubnormal */ /* ------------------------------------------------------------------ */ /* decNumberTrim -- remove insignificant zeros */ /* */ /* dn is the number to trim */ /* returns dn */ /* */ /* All fields are updated as required. This is a utility operation, */ /* so special values are unchanged and no error is possible. The */ /* zeros are removed unconditionally. */ /* ------------------------------------------------------------------ */ decNumber * decNumberTrim(decNumber *dn) { Int dropped; /* work */ decContext set; /* .. */ #if DECCHECK if (decCheckOperands(DECUNRESU, DECUNUSED, dn, DECUNCONT)) return dn; #endif decContextDefault(&set, DEC_INIT_BASE); /* clamp=0 */ return decTrim(dn, &set, 0, 1, &dropped); } /* decNumberTrim */ /* ------------------------------------------------------------------ */ /* decNumberVersion -- return the name and version of this module */ /* */ /* No error is possible. */ /* ------------------------------------------------------------------ */ const char * decNumberVersion(void) { return DECVERSION; } /* decNumberVersion */ /* ------------------------------------------------------------------ */ /* decNumberZero -- set a number to 0 */ /* */ /* dn is the number to set, with space for one digit */ /* returns dn */ /* */ /* No error is possible. */ /* ------------------------------------------------------------------ */ /* Memset is not used as it is much slower in some environments. */ decNumber * decNumberZero(decNumber *dn) { #if DECCHECK if (decCheckOperands(dn, DECUNUSED, DECUNUSED, DECUNCONT)) return dn; #endif dn->bits=0; dn->exponent=0; dn->digits=1; dn->lsu[0]=0; return dn; } /* decNumberZero */ /* ================================================================== */ /* Local routines */ /* ================================================================== */ /* ------------------------------------------------------------------ */ /* decToString -- lay out a number into a string */ /* */ /* dn is the number to lay out */ /* string is where to lay out the number */ /* eng is 1 if Engineering, 0 if Scientific */ /* */ /* string must be at least dn->digits+14 characters long */ /* No error is possible. */ /* */ /* Note that this routine can generate a -0 or 0.000. These are */ /* never generated in subset to-number or arithmetic, but can occur */ /* in non-subset arithmetic (e.g., -1*0 or 1.234-1.234). */ /* ------------------------------------------------------------------ */ /* If DECCHECK is enabled the string "?" is returned if a number is */ /* invalid. */ static void decToString(const decNumber *dn, char *string, Flag eng) { Int exp=dn->exponent; /* local copy */ Int e; /* E-part value */ Int pre; /* digits before the '.' */ Int cut; /* for counting digits in a Unit */ char *c=string; /* work [output pointer] */ const Unit *up=dn->lsu+D2U(dn->digits)-1; /* -> msu [input pointer] */ uInt u, pow; /* work */ #if DECCHECK if (decCheckOperands(DECUNRESU, dn, DECUNUSED, DECUNCONT)) { strcpy(string, "?"); return;} #endif if (decNumberIsNegative(dn)) { /* Negatives get a minus */ *c='-'; c++; } if (dn->bits&DECSPECIAL) { /* Is a special value */ if (decNumberIsInfinite(dn)) { strcpy(c, "Inf"); strcpy(c+3, "inity"); return;} /* a NaN */ if (dn->bits&DECSNAN) { /* signalling NaN */ *c='s'; c++; } strcpy(c, "NaN"); c+=3; /* step past */ /* if not a clean non-zero coefficient, that's all there is in a */ /* NaN string */ if (exp!=0 || (*dn->lsu==0 && dn->digits==1)) return; /* [drop through to add integer] */ } /* calculate how many digits in msu, and hence first cut */ cut=MSUDIGITS(dn->digits); /* [faster than remainder] */ cut--; /* power of ten for digit */ if (exp==0) { /* simple integer [common fastpath] */ for (;up>=dn->lsu; up--) { /* each Unit from msu */ u=*up; /* contains DECDPUN digits to lay out */ for (; cut>=0; c++, cut--) TODIGIT(u, cut, c, pow); cut=DECDPUN-1; /* next Unit has all digits */ } *c='\0'; /* terminate the string */ return;} /* non-0 exponent -- assume plain form */ pre=dn->digits+exp; /* digits before '.' */ e=0; /* no E */ if ((exp>0) || (pre<-5)) { /* need exponential form */ e=exp+dn->digits-1; /* calculate E value */ pre=1; /* assume one digit before '.' */ if (eng && (e!=0)) { /* engineering: may need to adjust */ Int adj; /* adjustment */ /* The C remainder operator is undefined for negative numbers, so */ /* a positive remainder calculation must be used here */ if (e<0) { adj=(-e)%3; if (adj!=0) adj=3-adj; } else { /* e>0 */ adj=e%3; } e=e-adj; /* if dealing with zero still produce an exponent which is a */ /* multiple of three, as expected, but there will only be the */ /* one zero before the E, still. Otherwise note the padding. */ if (!ISZERO(dn)) pre+=adj; else { /* is zero */ if (adj!=0) { /* 0.00Esnn needed */ e=e+3; pre=-(2-adj); } } /* zero */ } /* eng */ } /* need exponent */ /* lay out the digits of the coefficient, adding 0s and . as needed */ u=*up; if (pre>0) { /* xxx.xxx or xx00 (engineering) form */ Int n=pre; for (; pre>0; pre--, c++, cut--) { if (cut<0) { /* need new Unit */ if (up==dn->lsu) break; /* out of input digits (pre>digits) */ up--; cut=DECDPUN-1; u=*up; } TODIGIT(u, cut, c, pow); } if (ndigits) { /* more to come, after '.' */ *c='.'; c++; for (;; c++, cut--) { if (cut<0) { /* need new Unit */ if (up==dn->lsu) break; /* out of input digits */ up--; cut=DECDPUN-1; u=*up; } TODIGIT(u, cut, c, pow); } } else for (; pre>0; pre--, c++) *c='0'; /* 0 padding (for engineering) needed */ } else { /* 0.xxx or 0.000xxx form */ *c='0'; c++; *c='.'; c++; for (; pre<0; pre++, c++) *c='0'; /* add any 0's after '.' */ for (; ; c++, cut--) { if (cut<0) { /* need new Unit */ if (up==dn->lsu) break; /* out of input digits */ up--; cut=DECDPUN-1; u=*up; } TODIGIT(u, cut, c, pow); } } /* Finally add the E-part, if needed. It will never be 0, has a base maximum and minimum of +999999999 through -999999999, but could range down to -1999999998 for anormal numbers */ if (e!=0) { Flag had=0; /* 1=had non-zero */ *c='E'; c++; *c='+'; c++; /* assume positive */ u=e; /* .. */ if (e<0) { *(c-1)='-'; /* oops, need - */ u=-e; /* uInt, please */ } /* lay out the exponent [_itoa or equivalent is not ANSI C] */ for (cut=9; cut>=0; cut--) { TODIGIT(u, cut, c, pow); if (*c=='0' && !had) continue; /* skip leading zeros */ had=1; /* had non-0 */ c++; /* step for next */ } /* cut */ } *c='\0'; /* terminate the string (all paths) */ return; } /* decToString */ /* ------------------------------------------------------------------ */ /* decAddOp -- add/subtract operation */ /* */ /* This computes C = A + B */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X+X) */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* negate is DECNEG if rhs should be negated, or 0 otherwise */ /* status accumulates status for the caller */ /* */ /* C must have space for set->digits digits. */ /* Inexact in status must be 0 for correct Exact zero sign in result */ /* ------------------------------------------------------------------ */ /* If possible, the coefficient is calculated directly into C. */ /* However, if: */ /* -- a digits+1 calculation is needed because the numbers are */ /* unaligned and span more than set->digits digits */ /* -- a carry to digits+1 digits looks possible */ /* -- C is the same as A or B, and the result would destructively */ /* overlap the A or B coefficient */ /* then the result must be calculated into a temporary buffer. In */ /* this case a local (stack) buffer is used if possible, and only if */ /* too long for that does malloc become the final resort. */ /* */ /* Misalignment is handled as follows: */ /* Apad: (AExp>BExp) Swap operands and proceed as for BExp>AExp. */ /* BPad: Apply the padding by a combination of shifting (whole */ /* units) and multiplication (part units). */ /* */ /* Addition, especially x=x+1, is speed-critical. */ /* The static buffer is larger than might be expected to allow for */ /* calls from higher-level funtions (notable exp). */ /* ------------------------------------------------------------------ */ static decNumber * decAddOp(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set, uByte negate, uInt *status) { #if DECSUBSET decNumber *alloclhs=NULL; /* non-NULL if rounded lhs allocated */ decNumber *allocrhs=NULL; /* .., rhs */ #endif Int rhsshift; /* working shift (in Units) */ Int maxdigits; /* longest logical length */ Int mult; /* multiplier */ Int residue; /* rounding accumulator */ uByte bits; /* result bits */ Flag diffsign; /* non-0 if arguments have different sign */ Unit *acc; /* accumulator for result */ Unit accbuff[SD2U(DECBUFFER*2+20)]; /* local buffer [*2+20 reduces many */ /* allocations when called from */ /* other operations, notable exp] */ Unit *allocacc=NULL; /* -> allocated acc buffer, iff allocated */ Int reqdigits=set->digits; /* local copy; requested DIGITS */ Int padding; /* work */ #if DECCHECK if (decCheckOperands(res, lhs, rhs, set)) return res; #endif do { /* protect allocated storage */ #if DECSUBSET if (!set->extended) { /* reduce operands and set lostDigits status, as needed */ if (lhs->digits>reqdigits) { alloclhs=decRoundOperand(lhs, set, status); if (alloclhs==NULL) break; lhs=alloclhs; } if (rhs->digits>reqdigits) { allocrhs=decRoundOperand(rhs, set, status); if (allocrhs==NULL) break; rhs=allocrhs; } } #endif /* [following code does not require input rounding] */ /* note whether signs differ [used all paths] */ diffsign=(Flag)((lhs->bits^rhs->bits^negate)&DECNEG); /* handle infinities and NaNs */ if (SPECIALARGS) { /* a special bit set */ if (SPECIALARGS & (DECSNAN | DECNAN)) /* a NaN */ decNaNs(res, lhs, rhs, set, status); else { /* one or two infinities */ if (decNumberIsInfinite(lhs)) { /* LHS is infinity */ /* two infinities with different signs is invalid */ if (decNumberIsInfinite(rhs) && diffsign) { *status|=DEC_Invalid_operation; break; } bits=lhs->bits & DECNEG; /* get sign from LHS */ } else bits=(rhs->bits^negate) & DECNEG;/* RHS must be Infinity */ bits|=DECINF; decNumberZero(res); res->bits=bits; /* set +/- infinity */ } /* an infinity */ break; } /* Quick exit for add 0s; return the non-0, modified as need be */ if (ISZERO(lhs)) { Int adjust; /* work */ Int lexp=lhs->exponent; /* save in case LHS==RES */ bits=lhs->bits; /* .. */ residue=0; /* clear accumulator */ decCopyFit(res, rhs, set, &residue, status); /* copy (as needed) */ res->bits^=negate; /* flip if rhs was negated */ #if DECSUBSET if (set->extended) { /* exponents on zeros count */ #endif /* exponent will be the lower of the two */ adjust=lexp-res->exponent; /* adjustment needed [if -ve] */ if (ISZERO(res)) { /* both 0: special IEEE 754 rules */ if (adjust<0) res->exponent=lexp; /* set exponent */ /* 0-0 gives +0 unless rounding to -infinity, and -0-0 gives -0 */ if (diffsign) { if (set->round!=DEC_ROUND_FLOOR) res->bits=0; else res->bits=DECNEG; /* preserve 0 sign */ } } else { /* non-0 res */ if (adjust<0) { /* 0-padding needed */ if ((res->digits-adjust)>set->digits) { adjust=res->digits-set->digits; /* to fit exactly */ *status|=DEC_Rounded; /* [but exact] */ } res->digits=decShiftToMost(res->lsu, res->digits, -adjust); res->exponent+=adjust; /* set the exponent. */ } } /* non-0 res */ #if DECSUBSET } /* extended */ #endif decFinish(res, set, &residue, status); /* clean and finalize */ break;} if (ISZERO(rhs)) { /* [lhs is non-zero] */ Int adjust; /* work */ Int rexp=rhs->exponent; /* save in case RHS==RES */ bits=rhs->bits; /* be clean */ residue=0; /* clear accumulator */ decCopyFit(res, lhs, set, &residue, status); /* copy (as needed) */ #if DECSUBSET if (set->extended) { /* exponents on zeros count */ #endif /* exponent will be the lower of the two */ /* [0-0 case handled above] */ adjust=rexp-res->exponent; /* adjustment needed [if -ve] */ if (adjust<0) { /* 0-padding needed */ if ((res->digits-adjust)>set->digits) { adjust=res->digits-set->digits; /* to fit exactly */ *status|=DEC_Rounded; /* [but exact] */ } res->digits=decShiftToMost(res->lsu, res->digits, -adjust); res->exponent+=adjust; /* set the exponent. */ } #if DECSUBSET } /* extended */ #endif decFinish(res, set, &residue, status); /* clean and finalize */ break;} /* [NB: both fastpath and mainpath code below assume these cases */ /* (notably 0-0) have already been handled] */ /* calculate the padding needed to align the operands */ padding=rhs->exponent-lhs->exponent; /* Fastpath cases where the numbers are aligned and normal, the RHS */ /* is all in one unit, no operand rounding is needed, and no carry, */ /* lengthening, or borrow is needed */ if (padding==0 && rhs->digits<=DECDPUN && rhs->exponent>=set->emin /* [some normals drop through] */ && rhs->exponent<=set->emax-set->digits+1 /* [could clamp] */ && rhs->digits<=reqdigits && lhs->digits<=reqdigits) { Int partial=*lhs->lsu; if (!diffsign) { /* adding */ partial+=*rhs->lsu; if ((partial<=DECDPUNMAX) /* result fits in unit */ && (lhs->digits>=DECDPUN || /* .. and no digits-count change */ partial<(Int)powers[lhs->digits])) { /* .. */ if (res!=lhs) decNumberCopy(res, lhs); /* not in place */ *res->lsu=(Unit)partial; /* [copy could have overwritten RHS] */ break; } /* else drop out for careful add */ } else { /* signs differ */ partial-=*rhs->lsu; if (partial>0) { /* no borrow needed, and non-0 result */ if (res!=lhs) decNumberCopy(res, lhs); /* not in place */ *res->lsu=(Unit)partial; /* this could have reduced digits [but result>0] */ res->digits=decGetDigits(res->lsu, D2U(res->digits)); break; } /* else drop out for careful subtract */ } } /* Now align (pad) the lhs or rhs so they can be added or */ /* subtracted, as necessary. If one number is much larger than */ /* the other (that is, if in plain form there is a least one */ /* digit between the lowest digit of one and the highest of the */ /* other) padding with up to DIGITS-1 trailing zeros may be */ /* needed; then apply rounding (as exotic rounding modes may be */ /* affected by the residue). */ rhsshift=0; /* rhs shift to left (padding) in Units */ bits=lhs->bits; /* assume sign is that of LHS */ mult=1; /* likely multiplier */ /* [if padding==0 the operands are aligned; no padding is needed] */ if (padding!=0) { /* some padding needed; always pad the RHS, as any required */ /* padding can then be effected by a simple combination of */ /* shifts and a multiply */ Flag swapped=0; if (padding<0) { /* LHS needs the padding */ const decNumber *t; padding=-padding; /* will be +ve */ bits=(uByte)(rhs->bits^negate); /* assumed sign is now that of RHS */ t=lhs; lhs=rhs; rhs=t; swapped=1; } /* If, after pad, rhs would be longer than lhs by digits+1 or */ /* more then lhs cannot affect the answer, except as a residue, */ /* so only need to pad up to a length of DIGITS+1. */ if (rhs->digits+padding > lhs->digits+reqdigits+1) { /* The RHS is sufficient */ /* for residue use the relative sign indication... */ Int shift=reqdigits-rhs->digits; /* left shift needed */ residue=1; /* residue for rounding */ if (diffsign) residue=-residue; /* signs differ */ /* copy, shortening if necessary */ decCopyFit(res, rhs, set, &residue, status); /* if it was already shorter, then need to pad with zeros */ if (shift>0) { res->digits=decShiftToMost(res->lsu, res->digits, shift); res->exponent-=shift; /* adjust the exponent. */ } /* flip the result sign if unswapped and rhs was negated */ if (!swapped) res->bits^=negate; decFinish(res, set, &residue, status); /* done */ break;} /* LHS digits may affect result */ rhsshift=D2U(padding+1)-1; /* this much by Unit shift .. */ mult=powers[padding-(rhsshift*DECDPUN)]; /* .. this by multiplication */ } /* padding needed */ if (diffsign) mult=-mult; /* signs differ */ /* determine the longer operand */ maxdigits=rhs->digits+padding; /* virtual length of RHS */ if (lhs->digits>maxdigits) maxdigits=lhs->digits; /* Decide on the result buffer to use; if possible place directly */ /* into result. */ acc=res->lsu; /* assume add direct to result */ /* If destructive overlap, or the number is too long, or a carry or */ /* borrow to DIGITS+1 might be possible, a buffer must be used. */ /* [Might be worth more sophisticated tests when maxdigits==reqdigits] */ if ((maxdigits>=reqdigits) /* is, or could be, too large */ || (res==rhs && rhsshift>0)) { /* destructive overlap */ /* buffer needed, choose it; units for maxdigits digits will be */ /* needed, +1 Unit for carry or borrow */ Int need=D2U(maxdigits)+1; acc=accbuff; /* assume use local buffer */ if (need*sizeof(Unit)>sizeof(accbuff)) { /* printf("malloc add %ld %ld\n", need, sizeof(accbuff)); */ allocacc=(Unit *)malloc(need*sizeof(Unit)); if (allocacc==NULL) { /* hopeless -- abandon */ *status|=DEC_Insufficient_storage; break;} acc=allocacc; } } res->bits=(uByte)(bits&DECNEG); /* it's now safe to overwrite.. */ res->exponent=lhs->exponent; /* .. operands (even if aliased) */ #if DECTRACE decDumpAr('A', lhs->lsu, D2U(lhs->digits)); decDumpAr('B', rhs->lsu, D2U(rhs->digits)); printf(" :h: %ld %ld\n", rhsshift, mult); #endif /* add [A+B*m] or subtract [A+B*(-m)] */ res->digits=decUnitAddSub(lhs->lsu, D2U(lhs->digits), rhs->lsu, D2U(rhs->digits), rhsshift, acc, mult) *DECDPUN; /* [units -> digits] */ if (res->digits<0) { /* borrowed... */ res->digits=-res->digits; res->bits^=DECNEG; /* flip the sign */ } #if DECTRACE decDumpAr('+', acc, D2U(res->digits)); #endif /* If a buffer was used the result must be copied back, possibly */ /* shortening. (If no buffer was used then the result must have */ /* fit, so can't need rounding and residue must be 0.) */ residue=0; /* clear accumulator */ if (acc!=res->lsu) { #if DECSUBSET if (set->extended) { /* round from first significant digit */ #endif /* remove leading zeros that were added due to rounding up to */ /* integral Units -- before the test for rounding. */ if (res->digits>reqdigits) res->digits=decGetDigits(acc, D2U(res->digits)); decSetCoeff(res, set, acc, res->digits, &residue, status); #if DECSUBSET } else { /* subset arithmetic rounds from original significant digit */ /* May have an underestimate. This only occurs when both */ /* numbers fit in DECDPUN digits and are padding with a */ /* negative multiple (-10, -100...) and the top digit(s) become */ /* 0. (This only matters when using X3.274 rules where the */ /* leading zero could be included in the rounding.) */ if (res->digitsdigits))=0; /* ensure leading 0 is there */ res->digits=maxdigits; } else { /* remove leading zeros that added due to rounding up to */ /* integral Units (but only those in excess of the original */ /* maxdigits length, unless extended) before test for rounding. */ if (res->digits>reqdigits) { res->digits=decGetDigits(acc, D2U(res->digits)); if (res->digitsdigits=maxdigits; } } decSetCoeff(res, set, acc, res->digits, &residue, status); /* Now apply rounding if needed before removing leading zeros. */ /* This is safe because subnormals are not a possibility */ if (residue!=0) { decApplyRound(res, set, residue, status); residue=0; /* did what needed to be done */ } } /* subset */ #endif } /* used buffer */ /* strip leading zeros [these were left on in case of subset subtract] */ res->digits=decGetDigits(res->lsu, D2U(res->digits)); /* apply checks and rounding */ decFinish(res, set, &residue, status); /* "When the sum of two operands with opposite signs is exactly */ /* zero, the sign of that sum shall be '+' in all rounding modes */ /* except round toward -Infinity, in which mode that sign shall be */ /* '-'." [Subset zeros also never have '-', set by decFinish.] */ if (ISZERO(res) && diffsign #if DECSUBSET && set->extended #endif && (*status&DEC_Inexact)==0) { if (set->round==DEC_ROUND_FLOOR) res->bits|=DECNEG; /* sign - */ else res->bits&=~DECNEG; /* sign + */ } } while(0); /* end protected */ free(allocacc); /* drop any storage used */ #if DECSUBSET free(allocrhs); /* .. */ free(alloclhs); /* .. */ #endif return res; } /* decAddOp */ /* ------------------------------------------------------------------ */ /* decDivideOp -- division operation */ /* */ /* This routine performs the calculations for all four division */ /* operators (divide, divideInteger, remainder, remainderNear). */ /* */ /* C=A op B */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X/X) */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* op is DIVIDE, DIVIDEINT, REMAINDER, or REMNEAR respectively. */ /* status is the usual accumulator */ /* */ /* C must have space for set->digits digits. */ /* */ /* ------------------------------------------------------------------ */ /* The underlying algorithm of this routine is the same as in the */ /* 1981 S/370 implementation, that is, non-restoring long division */ /* with bi-unit (rather than bi-digit) estimation for each unit */ /* multiplier. In this pseudocode overview, complications for the */ /* Remainder operators and division residues for exact rounding are */ /* omitted for clarity. */ /* */ /* Prepare operands and handle special values */ /* Test for x/0 and then 0/x */ /* Exp =Exp1 - Exp2 */ /* Exp =Exp +len(var1) -len(var2) */ /* Sign=Sign1 * Sign2 */ /* Pad accumulator (Var1) to double-length with 0's (pad1) */ /* Pad Var2 to same length as Var1 */ /* msu2pair/plus=1st 2 or 1 units of var2, +1 to allow for round */ /* have=0 */ /* Do until (have=digits+1 OR residue=0) */ /* if exp<0 then if integer divide/residue then leave */ /* this_unit=0 */ /* Do forever */ /* compare numbers */ /* if <0 then leave inner_loop */ /* if =0 then (* quick exit without subtract *) do */ /* this_unit=this_unit+1; output this_unit */ /* leave outer_loop; end */ /* Compare lengths of numbers (mantissae): */ /* If same then tops2=msu2pair -- {units 1&2 of var2} */ /* else tops2=msu2plus -- {0, unit 1 of var2} */ /* tops1=first_unit_of_Var1*10**DECDPUN +second_unit_of_var1 */ /* mult=tops1/tops2 -- Good and safe guess at divisor */ /* if mult=0 then mult=1 */ /* this_unit=this_unit+mult */ /* subtract */ /* end inner_loop */ /* if have\=0 | this_unit\=0 then do */ /* output this_unit */ /* have=have+1; end */ /* var2=var2/10 */ /* exp=exp-1 */ /* end outer_loop */ /* exp=exp+1 -- set the proper exponent */ /* if have=0 then generate answer=0 */ /* Return (Result is defined by Var1) */ /* */ /* ------------------------------------------------------------------ */ /* Two working buffers are needed during the division; one (digits+ */ /* 1) to accumulate the result, and the other (up to 2*digits+1) for */ /* long subtractions. These are acc and var1 respectively. */ /* var1 is a copy of the lhs coefficient, var2 is the rhs coefficient.*/ /* The static buffers may be larger than might be expected to allow */ /* for calls from higher-level funtions (notable exp). */ /* ------------------------------------------------------------------ */ static decNumber * decDivideOp(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set, Flag op, uInt *status) { #if DECSUBSET decNumber *alloclhs=NULL; /* non-NULL if rounded lhs allocated */ decNumber *allocrhs=NULL; /* .., rhs */ #endif Unit accbuff[SD2U(DECBUFFER+DECDPUN+10)]; /* local buffer */ Unit *acc=accbuff; /* -> accumulator array for result */ Unit *allocacc=NULL; /* -> allocated buffer, iff allocated */ Unit *accnext; /* -> where next digit will go */ Int acclength; /* length of acc needed [Units] */ Int accunits; /* count of units accumulated */ Int accdigits; /* count of digits accumulated */ Unit varbuff[SD2U(DECBUFFER*2+DECDPUN)]; /* buffer for var1 */ Unit *var1=varbuff; /* -> var1 array for long subtraction */ Unit *varalloc=NULL; /* -> allocated buffer, iff used */ Unit *msu1; /* -> msu of var1 */ const Unit *var2; /* -> var2 array */ const Unit *msu2; /* -> msu of var2 */ Int msu2plus; /* msu2 plus one [does not vary] */ eInt msu2pair; /* msu2 pair plus one [does not vary] */ Int var1units, var2units; /* actual lengths */ Int var2ulen; /* logical length (units) */ Int var1initpad=0; /* var1 initial padding (digits) */ Int maxdigits; /* longest LHS or required acc length */ Int mult; /* multiplier for subtraction */ Unit thisunit; /* current unit being accumulated */ Int residue; /* for rounding */ Int reqdigits=set->digits; /* requested DIGITS */ Int exponent; /* working exponent */ Int maxexponent=0; /* DIVIDE maximum exponent if unrounded */ uByte bits; /* working sign */ Unit *target; /* work */ const Unit *source; /* .. */ uInt const *pow; /* .. */ Int shift, cut; /* .. */ #if DECSUBSET Int dropped; /* work */ #endif #if DECCHECK if (decCheckOperands(res, lhs, rhs, set)) return res; #endif do { /* protect allocated storage */ #if DECSUBSET if (!set->extended) { /* reduce operands and set lostDigits status, as needed */ if (lhs->digits>reqdigits) { alloclhs=decRoundOperand(lhs, set, status); if (alloclhs==NULL) break; lhs=alloclhs; } if (rhs->digits>reqdigits) { allocrhs=decRoundOperand(rhs, set, status); if (allocrhs==NULL) break; rhs=allocrhs; } } #endif /* [following code does not require input rounding] */ bits=(lhs->bits^rhs->bits)&DECNEG; /* assumed sign for divisions */ /* handle infinities and NaNs */ if (SPECIALARGS) { /* a special bit set */ if (SPECIALARGS & (DECSNAN | DECNAN)) { /* one or two NaNs */ decNaNs(res, lhs, rhs, set, status); break; } /* one or two infinities */ if (decNumberIsInfinite(lhs)) { /* LHS (dividend) is infinite */ if (decNumberIsInfinite(rhs) || /* two infinities are invalid .. */ op & (REMAINDER | REMNEAR)) { /* as is remainder of infinity */ *status|=DEC_Invalid_operation; break; } /* [Note that infinity/0 raises no exceptions] */ decNumberZero(res); res->bits=bits|DECINF; /* set +/- infinity */ break; } else { /* RHS (divisor) is infinite */ residue=0; if (op&(REMAINDER|REMNEAR)) { /* result is [finished clone of] lhs */ decCopyFit(res, lhs, set, &residue, status); } else { /* a division */ decNumberZero(res); res->bits=bits; /* set +/- zero */ /* for DIVIDEINT the exponent is always 0. For DIVIDE, result */ /* is a 0 with infinitely negative exponent, clamped to minimum */ if (op&DIVIDE) { res->exponent=set->emin-set->digits+1; *status|=DEC_Clamped; } } decFinish(res, set, &residue, status); break; } } /* handle 0 rhs (x/0) */ if (ISZERO(rhs)) { /* x/0 is always exceptional */ if (ISZERO(lhs)) { decNumberZero(res); /* [after lhs test] */ *status|=DEC_Division_undefined;/* 0/0 will become NaN */ } else { decNumberZero(res); if (op&(REMAINDER|REMNEAR)) *status|=DEC_Invalid_operation; else { *status|=DEC_Division_by_zero; /* x/0 */ res->bits=bits|DECINF; /* .. is +/- Infinity */ } } break;} /* handle 0 lhs (0/x) */ if (ISZERO(lhs)) { /* 0/x [x!=0] */ #if DECSUBSET if (!set->extended) decNumberZero(res); else { #endif if (op&DIVIDE) { residue=0; exponent=lhs->exponent-rhs->exponent; /* ideal exponent */ decNumberCopy(res, lhs); /* [zeros always fit] */ res->bits=bits; /* sign as computed */ res->exponent=exponent; /* exponent, too */ decFinalize(res, set, &residue, status); /* check exponent */ } else if (op&DIVIDEINT) { decNumberZero(res); /* integer 0 */ res->bits=bits; /* sign as computed */ } else { /* a remainder */ exponent=rhs->exponent; /* [save in case overwrite] */ decNumberCopy(res, lhs); /* [zeros always fit] */ if (exponentexponent) res->exponent=exponent; /* use lower */ } #if DECSUBSET } #endif break;} /* Precalculate exponent. This starts off adjusted (and hence fits */ /* in 31 bits) and becomes the usual unadjusted exponent as the */ /* division proceeds. The order of evaluation is important, here, */ /* to avoid wrap. */ exponent=(lhs->exponent+lhs->digits)-(rhs->exponent+rhs->digits); /* If the working exponent is -ve, then some quick exits are */ /* possible because the quotient is known to be <1 */ /* [for REMNEAR, it needs to be < -1, as -0.5 could need work] */ if (exponent<0 && !(op==DIVIDE)) { if (op&DIVIDEINT) { decNumberZero(res); /* integer part is 0 */ #if DECSUBSET if (set->extended) #endif res->bits=bits; /* set +/- zero */ break;} /* fastpath remainders so long as the lhs has the smaller */ /* (or equal) exponent */ if (lhs->exponent<=rhs->exponent) { if (op&REMAINDER || exponent<-1) { /* It is REMAINDER or safe REMNEAR; result is [finished */ /* clone of] lhs (r = x - 0*y) */ residue=0; decCopyFit(res, lhs, set, &residue, status); decFinish(res, set, &residue, status); break; } /* [unsafe REMNEAR drops through] */ } } /* fastpaths */ /* Long (slow) division is needed; roll up the sleeves... */ /* The accumulator will hold the quotient of the division. */ /* If it needs to be too long for stack storage, then allocate. */ acclength=D2U(reqdigits+DECDPUN); /* in Units */ if (acclength*sizeof(Unit)>sizeof(accbuff)) { /* printf("malloc dvacc %ld units\n", acclength); */ allocacc=(Unit *)malloc(acclength*sizeof(Unit)); if (allocacc==NULL) { /* hopeless -- abandon */ *status|=DEC_Insufficient_storage; break;} acc=allocacc; /* use the allocated space */ } /* var1 is the padded LHS ready for subtractions. */ /* If it needs to be too long for stack storage, then allocate. */ /* The maximum units needed for var1 (long subtraction) is: */ /* Enough for */ /* (rhs->digits+reqdigits-1) -- to allow full slide to right */ /* or (lhs->digits) -- to allow for long lhs */ /* whichever is larger */ /* +1 -- for rounding of slide to right */ /* +1 -- for leading 0s */ /* +1 -- for pre-adjust if a remainder or DIVIDEINT */ /* [Note: unused units do not participate in decUnitAddSub data] */ maxdigits=rhs->digits+reqdigits-1; if (lhs->digits>maxdigits) maxdigits=lhs->digits; var1units=D2U(maxdigits)+2; /* allocate a guard unit above msu1 for REMAINDERNEAR */ if (!(op&DIVIDE)) var1units++; if ((var1units+1)*sizeof(Unit)>sizeof(varbuff)) { /* printf("malloc dvvar %ld units\n", var1units+1); */ varalloc=(Unit *)malloc((var1units+1)*sizeof(Unit)); if (varalloc==NULL) { /* hopeless -- abandon */ *status|=DEC_Insufficient_storage; break;} var1=varalloc; /* use the allocated space */ } /* Extend the lhs and rhs to full long subtraction length. The lhs */ /* is truly extended into the var1 buffer, with 0 padding, so a */ /* subtract in place is always possible. The rhs (var2) has */ /* virtual padding (implemented by decUnitAddSub). */ /* One guard unit was allocated above msu1 for rem=rem+rem in */ /* REMAINDERNEAR. */ msu1=var1+var1units-1; /* msu of var1 */ source=lhs->lsu+D2U(lhs->digits)-1; /* msu of input array */ for (target=msu1; source>=lhs->lsu; source--, target--) *target=*source; for (; target>=var1; target--) *target=0; /* rhs (var2) is left-aligned with var1 at the start */ var2ulen=var1units; /* rhs logical length (units) */ var2units=D2U(rhs->digits); /* rhs actual length (units) */ var2=rhs->lsu; /* -> rhs array */ msu2=var2+var2units-1; /* -> msu of var2 [never changes] */ /* now set up the variables which will be used for estimating the */ /* multiplication factor. If these variables are not exact, add */ /* 1 to make sure that the multiplier is never overestimated. */ msu2plus=*msu2; /* it's value .. */ if (var2units>1) msu2plus++; /* .. +1 if any more */ msu2pair=(eInt)*msu2*(DECDPUNMAX+1);/* top two pair .. */ if (var2units>1) { /* .. [else treat 2nd as 0] */ msu2pair+=*(msu2-1); /* .. */ if (var2units>2) msu2pair++; /* .. +1 if any more */ } /* The calculation is working in units, which may have leading zeros, */ /* but the exponent was calculated on the assumption that they are */ /* both left-aligned. Adjust the exponent to compensate: add the */ /* number of leading zeros in var1 msu and subtract those in var2 msu. */ /* [This is actually done by counting the digits and negating, as */ /* lead1=DECDPUN-digits1, and similarly for lead2.] */ for (pow=&powers[1]; *msu1>=*pow; pow++) exponent--; for (pow=&powers[1]; *msu2>=*pow; pow++) exponent++; /* Now, if doing an integer divide or remainder, ensure that */ /* the result will be Unit-aligned. To do this, shift the var1 */ /* accumulator towards least if need be. (It's much easier to */ /* do this now than to reassemble the residue afterwards, if */ /* doing a remainder.) Also ensure the exponent is not negative. */ if (!(op&DIVIDE)) { Unit *u; /* work */ /* save the initial 'false' padding of var1, in digits */ var1initpad=(var1units-D2U(lhs->digits))*DECDPUN; /* Determine the shift to do. */ if (exponent<0) cut=-exponent; else cut=DECDPUN-exponent%DECDPUN; decShiftToLeast(var1, var1units, cut); exponent+=cut; /* maintain numerical value */ var1initpad-=cut; /* .. and reduce padding */ /* clean any most-significant units which were just emptied */ for (u=msu1; cut>=DECDPUN; cut-=DECDPUN, u--) *u=0; } /* align */ else { /* is DIVIDE */ maxexponent=lhs->exponent-rhs->exponent; /* save */ /* optimization: if the first iteration will just produce 0, */ /* preadjust to skip it [valid for DIVIDE only] */ if (*msu1<*msu2) { var2ulen--; /* shift down */ exponent-=DECDPUN; /* update the exponent */ } } /* ---- start the long-division loops ------------------------------ */ accunits=0; /* no units accumulated yet */ accdigits=0; /* .. or digits */ accnext=acc+acclength-1; /* -> msu of acc [NB: allows digits+1] */ for (;;) { /* outer forever loop */ thisunit=0; /* current unit assumed 0 */ /* find the next unit */ for (;;) { /* inner forever loop */ /* strip leading zero units [from either pre-adjust or from */ /* subtract last time around]. Leave at least one unit. */ for (; *msu1==0 && msu1>var1; msu1--) var1units--; if (var1units msu */ for (pv1=msu1; ; pv1--, pv2--) { /* v1=*pv1 -- always OK */ v2=0; /* assume in padding */ if (pv2>=var2) v2=*pv2; /* in range */ if (*pv1!=v2) break; /* no longer the same */ if (pv1==var1) break; /* done; leave pv1 as is */ } /* here when all inspected or a difference seen */ if (*pv1v2. Prepare for real subtraction; the lengths are equal */ /* Estimate the multiplier (there's always a msu1-1)... */ /* Bring in two units of var2 to provide a good estimate. */ mult=(Int)(((eInt)*msu1*(DECDPUNMAX+1)+*(msu1-1))/msu2pair); } /* lengths the same */ else { /* var1units > var2ulen, so subtraction is safe */ /* The var2 msu is one unit towards the lsu of the var1 msu, */ /* so only one unit for var2 can be used. */ mult=(Int)(((eInt)*msu1*(DECDPUNMAX+1)+*(msu1-1))/msu2plus); } if (mult==0) mult=1; /* must always be at least 1 */ /* subtraction needed; var1 is > var2 */ thisunit=(Unit)(thisunit+mult); /* accumulate */ /* subtract var1-var2, into var1; only the overlap needs */ /* processing, as this is an in-place calculation */ shift=var2ulen-var2units; #if DECTRACE decDumpAr('1', &var1[shift], var1units-shift); decDumpAr('2', var2, var2units); printf("m=%ld\n", -mult); #endif decUnitAddSub(&var1[shift], var1units-shift, var2, var2units, 0, &var1[shift], -mult); #if DECTRACE decDumpAr('#', &var1[shift], var1units-shift); #endif /* var1 now probably has leading zeros; these are removed at the */ /* top of the inner loop. */ } /* inner loop */ /* The next unit has been calculated in full; unless it's a */ /* leading zero, add to acc */ if (accunits!=0 || thisunit!=0) { /* is first or non-zero */ *accnext=thisunit; /* store in accumulator */ /* account exactly for the new digits */ if (accunits==0) { accdigits++; /* at least one */ for (pow=&powers[1]; thisunit>=*pow; pow++) accdigits++; } else accdigits+=DECDPUN; accunits++; /* update count */ accnext--; /* ready for next */ if (accdigits>reqdigits) break; /* have enough digits */ } /* if the residue is zero, the operation is done (unless divide */ /* or divideInteger and still not enough digits yet) */ if (*var1==0 && var1units==1) { /* residue is 0 */ if (op&(REMAINDER|REMNEAR)) break; if ((op&DIVIDE) && (exponent<=maxexponent)) break; /* [drop through if divideInteger] */ } /* also done enough if calculating remainder or integer */ /* divide and just did the last ('units') unit */ if (exponent==0 && !(op&DIVIDE)) break; /* to get here, var1 is less than var2, so divide var2 by the per- */ /* Unit power of ten and go for the next digit */ var2ulen--; /* shift down */ exponent-=DECDPUN; /* update the exponent */ } /* outer loop */ /* ---- division is complete --------------------------------------- */ /* here: acc has at least reqdigits+1 of good results (or fewer */ /* if early stop), starting at accnext+1 (its lsu) */ /* var1 has any residue at the stopping point */ /* accunits is the number of digits collected in acc */ if (accunits==0) { /* acc is 0 */ accunits=1; /* show have a unit .. */ accdigits=1; /* .. */ *accnext=0; /* .. whose value is 0 */ } else accnext++; /* back to last placed */ /* accnext now -> lowest unit of result */ residue=0; /* assume no residue */ if (op&DIVIDE) { /* record the presence of any residue, for rounding */ if (*var1!=0 || var1units>1) residue=1; else { /* no residue */ /* Had an exact division; clean up spurious trailing 0s. */ /* There will be at most DECDPUN-1, from the final multiply, */ /* and then only if the result is non-0 (and even) and the */ /* exponent is 'loose'. */ #if DECDPUN>1 Unit lsu=*accnext; if (!(lsu&0x01) && (lsu!=0)) { /* count the trailing zeros */ Int drop=0; for (;; drop++) { /* [will terminate because lsu!=0] */ if (exponent>=maxexponent) break; /* don't chop real 0s */ #if DECDPUN<=4 if ((lsu-QUOT10(lsu, drop+1) *powers[drop+1])!=0) break; /* found non-0 digit */ #else if (lsu%powers[drop+1]!=0) break; /* found non-0 digit */ #endif exponent++; } if (drop>0) { accunits=decShiftToLeast(accnext, accunits, drop); accdigits=decGetDigits(accnext, accunits); accunits=D2U(accdigits); /* [exponent was adjusted in the loop] */ } } /* neither odd nor 0 */ #endif } /* exact divide */ } /* divide */ else /* op!=DIVIDE */ { /* check for coefficient overflow */ if (accdigits+exponent>reqdigits) { *status|=DEC_Division_impossible; break; } if (op & (REMAINDER|REMNEAR)) { /* [Here, the exponent will be 0, because var1 was adjusted */ /* appropriately.] */ Int postshift; /* work */ Flag wasodd=0; /* integer was odd */ Unit *quotlsu; /* for save */ Int quotdigits; /* .. */ bits=lhs->bits; /* remainder sign is always as lhs */ /* Fastpath when residue is truly 0 is worthwhile [and */ /* simplifies the code below] */ if (*var1==0 && var1units==1) { /* residue is 0 */ Int exp=lhs->exponent; /* save min(exponents) */ if (rhs->exponentexponent; decNumberZero(res); /* 0 coefficient */ #if DECSUBSET if (set->extended) #endif res->exponent=exp; /* .. with proper exponent */ res->bits=(uByte)(bits&DECNEG); /* [cleaned] */ decFinish(res, set, &residue, status); /* might clamp */ break; } /* note if the quotient was odd */ if (*accnext & 0x01) wasodd=1; /* acc is odd */ quotlsu=accnext; /* save in case need to reinspect */ quotdigits=accdigits; /* .. */ /* treat the residue, in var1, as the value to return, via acc */ /* calculate the unused zero digits. This is the smaller of: */ /* var1 initial padding (saved above) */ /* var2 residual padding, which happens to be given by: */ postshift=var1initpad+exponent-lhs->exponent+rhs->exponent; /* [the 'exponent' term accounts for the shifts during divide] */ if (var1initpadexponent; /* exponent is smaller of lhs & rhs */ if (rhs->exponentexponent; /* Now correct the result if doing remainderNear; if it */ /* (looking just at coefficients) is > rhs/2, or == rhs/2 and */ /* the integer was odd then the result should be rem-rhs. */ if (op&REMNEAR) { Int compare, tarunits; /* work */ Unit *up; /* .. */ /* calculate remainder*2 into the var1 buffer (which has */ /* 'headroom' of an extra unit and hence enough space) */ /* [a dedicated 'double' loop would be faster, here] */ tarunits=decUnitAddSub(accnext, accunits, accnext, accunits, 0, accnext, 1); /* decDumpAr('r', accnext, tarunits); */ /* Here, accnext (var1) holds tarunits Units with twice the */ /* remainder's coefficient, which must now be compared to the */ /* RHS. The remainder's exponent may be smaller than the RHS's. */ compare=decUnitCompare(accnext, tarunits, rhs->lsu, D2U(rhs->digits), rhs->exponent-exponent); if (compare==BADINT) { /* deep trouble */ *status|=DEC_Insufficient_storage; break;} /* now restore the remainder by dividing by two; the lsu */ /* is known to be even. */ for (up=accnext; up0 || (compare==0 && wasodd)) { /* adjustment needed */ Int exp, expunits, exprem; /* work */ /* This is effectively causing round-up of the quotient, */ /* so if it was the rare case where it was full and all */ /* nines, it would overflow and hence division-impossible */ /* should be raised */ Flag allnines=0; /* 1 if quotient all nines */ if (quotdigits==reqdigits) { /* could be borderline */ for (up=quotlsu; ; up++) { if (quotdigits>DECDPUN) { if (*up!=DECDPUNMAX) break;/* non-nines */ } else { /* this is the last Unit */ if (*up==powers[quotdigits]-1) allnines=1; break; } quotdigits-=DECDPUN; /* checked those digits */ } /* up */ } /* borderline check */ if (allnines) { *status|=DEC_Division_impossible; break;} /* rem-rhs is needed; the sign will invert. Again, var1 */ /* can safely be used for the working Units array. */ exp=rhs->exponent-exponent; /* RHS padding needed */ /* Calculate units and remainder from exponent. */ expunits=exp/DECDPUN; exprem=exp%DECDPUN; /* subtract [A+B*(-m)]; the result will always be negative */ accunits=-decUnitAddSub(accnext, accunits, rhs->lsu, D2U(rhs->digits), expunits, accnext, -(Int)powers[exprem]); accdigits=decGetDigits(accnext, accunits); /* count digits exactly */ accunits=D2U(accdigits); /* and recalculate the units for copy */ /* [exponent is as for original remainder] */ bits^=DECNEG; /* flip the sign */ } } /* REMNEAR */ } /* REMAINDER or REMNEAR */ } /* not DIVIDE */ /* Set exponent and bits */ res->exponent=exponent; res->bits=(uByte)(bits&DECNEG); /* [cleaned] */ /* Now the coefficient. */ decSetCoeff(res, set, accnext, accdigits, &residue, status); decFinish(res, set, &residue, status); /* final cleanup */ #if DECSUBSET /* If a divide then strip trailing zeros if subset [after round] */ if (!set->extended && (op==DIVIDE)) decTrim(res, set, 0, 1, &dropped); #endif } while(0); /* end protected */ free(varalloc); /* drop any storage used */ free(allocacc); /* .. */ #if DECSUBSET free(allocrhs); /* .. */ free(alloclhs); /* .. */ #endif return res; } /* decDivideOp */ /* ------------------------------------------------------------------ */ /* decMultiplyOp -- multiplication operation */ /* */ /* This routine performs the multiplication C=A x B. */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X*X) */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* status is the usual accumulator */ /* */ /* C must have space for set->digits digits. */ /* */ /* ------------------------------------------------------------------ */ /* 'Classic' multiplication is used rather than Karatsuba, as the */ /* latter would give only a minor improvement for the short numbers */ /* expected to be handled most (and uses much more memory). */ /* */ /* There are two major paths here: the general-purpose ('old code') */ /* path which handles all DECDPUN values, and a fastpath version */ /* which is used if 64-bit ints are available, DECDPUN<=4, and more */ /* than two calls to decUnitAddSub would be made. */ /* */ /* The fastpath version lumps units together into 8-digit or 9-digit */ /* chunks, and also uses a lazy carry strategy to minimise expensive */ /* 64-bit divisions. The chunks are then broken apart again into */ /* units for continuing processing. Despite this overhead, the */ /* fastpath can speed up some 16-digit operations by 10x (and much */ /* more for higher-precision calculations). */ /* */ /* A buffer always has to be used for the accumulator; in the */ /* fastpath, buffers are also always needed for the chunked copies of */ /* of the operand coefficients. */ /* Static buffers are larger than needed just for multiply, to allow */ /* for calls from other operations (notably exp). */ /* ------------------------------------------------------------------ */ #define FASTMUL (DECUSE64 && DECDPUN<5) static decNumber * decMultiplyOp(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set, uInt *status) { Int accunits; /* Units of accumulator in use */ Int exponent; /* work */ Int residue=0; /* rounding residue */ uByte bits; /* result sign */ Unit *acc; /* -> accumulator Unit array */ Int needbytes; /* size calculator */ void *allocacc=NULL; /* -> allocated accumulator, iff allocated */ Unit accbuff[SD2U(DECBUFFER*4+1)]; /* buffer (+1 for DECBUFFER==0, */ /* *4 for calls from other operations) */ const Unit *mer, *mermsup; /* work */ Int madlength; /* Units in multiplicand */ Int shift; /* Units to shift multiplicand by */ #if FASTMUL /* if DECDPUN is 1 or 3 work in base 10**9, otherwise */ /* (DECDPUN is 2 or 4) then work in base 10**8 */ #if DECDPUN & 1 /* odd */ #define FASTBASE 1000000000 /* base */ #define FASTDIGS 9 /* digits in base */ #define FASTLAZY 18 /* carry resolution point [1->18] */ #else #define FASTBASE 100000000 #define FASTDIGS 8 #define FASTLAZY 1844 /* carry resolution point [1->1844] */ #endif /* three buffers are used, two for chunked copies of the operands */ /* (base 10**8 or base 10**9) and one base 2**64 accumulator with */ /* lazy carry evaluation */ uInt zlhibuff[(DECBUFFER*2+1)/8+1]; /* buffer (+1 for DECBUFFER==0) */ uInt *zlhi=zlhibuff; /* -> lhs array */ uInt *alloclhi=NULL; /* -> allocated buffer, iff allocated */ uInt zrhibuff[(DECBUFFER*2+1)/8+1]; /* buffer (+1 for DECBUFFER==0) */ uInt *zrhi=zrhibuff; /* -> rhs array */ uInt *allocrhi=NULL; /* -> allocated buffer, iff allocated */ uLong zaccbuff[(DECBUFFER*2+1)/4+2]; /* buffer (+1 for DECBUFFER==0) */ /* [allocacc is shared for both paths, as only one will run] */ uLong *zacc=zaccbuff; /* -> accumulator array for exact result */ #if DECDPUN==1 Int zoff; /* accumulator offset */ #endif uInt *lip, *rip; /* item pointers */ uInt *lmsi, *rmsi; /* most significant items */ Int ilhs, irhs, iacc; /* item counts in the arrays */ Int lazy; /* lazy carry counter */ uLong lcarry; /* uLong carry */ uInt carry; /* carry (NB not uLong) */ Int count; /* work */ const Unit *cup; /* .. */ Unit *up; /* .. */ uLong *lp; /* .. */ Int p; /* .. */ #endif #if DECSUBSET decNumber *alloclhs=NULL; /* -> allocated buffer, iff allocated */ decNumber *allocrhs=NULL; /* -> allocated buffer, iff allocated */ #endif #if DECCHECK if (decCheckOperands(res, lhs, rhs, set)) return res; #endif /* precalculate result sign */ bits=(uByte)((lhs->bits^rhs->bits)&DECNEG); /* handle infinities and NaNs */ if (SPECIALARGS) { /* a special bit set */ if (SPECIALARGS & (DECSNAN | DECNAN)) { /* one or two NaNs */ decNaNs(res, lhs, rhs, set, status); return res;} /* one or two infinities; Infinity * 0 is invalid */ if (((lhs->bits & DECINF)==0 && ISZERO(lhs)) ||((rhs->bits & DECINF)==0 && ISZERO(rhs))) { *status|=DEC_Invalid_operation; return res;} decNumberZero(res); res->bits=bits|DECINF; /* infinity */ return res;} /* For best speed, as in DMSRCN [the original Rexx numerics */ /* module], use the shorter number as the multiplier (rhs) and */ /* the longer as the multiplicand (lhs) to minimise the number of */ /* adds (partial products) */ if (lhs->digitsdigits) { /* swap... */ const decNumber *hold=lhs; lhs=rhs; rhs=hold; } do { /* protect allocated storage */ #if DECSUBSET if (!set->extended) { /* reduce operands and set lostDigits status, as needed */ if (lhs->digits>set->digits) { alloclhs=decRoundOperand(lhs, set, status); if (alloclhs==NULL) break; lhs=alloclhs; } if (rhs->digits>set->digits) { allocrhs=decRoundOperand(rhs, set, status); if (allocrhs==NULL) break; rhs=allocrhs; } } #endif /* [following code does not require input rounding] */ #if FASTMUL /* fastpath can be used */ /* use the fast path if there are enough digits in the shorter */ /* operand to make the setup and takedown worthwhile */ #define NEEDTWO (DECDPUN*2) /* within two decUnitAddSub calls */ if (rhs->digits>NEEDTWO) { /* use fastpath... */ /* calculate the number of elements in each array */ ilhs=(lhs->digits+FASTDIGS-1)/FASTDIGS; /* [ceiling] */ irhs=(rhs->digits+FASTDIGS-1)/FASTDIGS; /* .. */ iacc=ilhs+irhs; /* allocate buffers if required, as usual */ needbytes=ilhs*sizeof(uInt); if (needbytes>(Int)sizeof(zlhibuff)) { alloclhi=(uInt *)malloc(needbytes); zlhi=alloclhi;} needbytes=irhs*sizeof(uInt); if (needbytes>(Int)sizeof(zrhibuff)) { allocrhi=(uInt *)malloc(needbytes); zrhi=allocrhi;} /* Allocating the accumulator space needs a special case when */ /* DECDPUN=1 because when converting the accumulator to Units */ /* after the multiplication each 8-byte item becomes 9 1-byte */ /* units. Therefore iacc extra bytes are needed at the front */ /* (rounded up to a multiple of 8 bytes), and the uLong */ /* accumulator starts offset the appropriate number of units */ /* to the right to avoid overwrite during the unchunking. */ needbytes=iacc*sizeof(uLong); #if DECDPUN==1 zoff=(iacc+7)/8; /* items to offset by */ needbytes+=zoff*8; #endif if (needbytes>(Int)sizeof(zaccbuff)) { allocacc=(uLong *)malloc(needbytes); zacc=(uLong *)allocacc;} if (zlhi==NULL||zrhi==NULL||zacc==NULL) { *status|=DEC_Insufficient_storage; break;} acc=(Unit *)zacc; /* -> target Unit array */ #if DECDPUN==1 zacc+=zoff; /* start uLong accumulator to right */ #endif /* assemble the chunked copies of the left and right sides */ for (count=lhs->digits, cup=lhs->lsu, lip=zlhi; count>0; lip++) for (p=0, *lip=0; p0; p+=DECDPUN, cup++, count-=DECDPUN) *lip+=*cup*powers[p]; lmsi=lip-1; /* save -> msi */ for (count=rhs->digits, cup=rhs->lsu, rip=zrhi; count>0; rip++) for (p=0, *rip=0; p0; p+=DECDPUN, cup++, count-=DECDPUN) *rip+=*cup*powers[p]; rmsi=rip-1; /* save -> msi */ /* zero the accumulator */ for (lp=zacc; lp0 && rip!=rmsi) continue; lazy=FASTLAZY; /* reset delay count */ /* spin up the accumulator resolving overflows */ for (lp=zacc; lp assume buffer for accumulator */ needbytes=(D2U(lhs->digits)+D2U(rhs->digits))*sizeof(Unit); if (needbytes>(Int)sizeof(accbuff)) { allocacc=(Unit *)malloc(needbytes); if (allocacc==NULL) {*status|=DEC_Insufficient_storage; break;} acc=(Unit *)allocacc; /* use the allocated space */ } /* Now the main long multiplication loop */ /* Unlike the equivalent in the IBM Java implementation, there */ /* is no advantage in calculating from msu to lsu. So, do it */ /* by the book, as it were. */ /* Each iteration calculates ACC=ACC+MULTAND*MULT */ accunits=1; /* accumulator starts at '0' */ *acc=0; /* .. (lsu=0) */ shift=0; /* no multiplicand shift at first */ madlength=D2U(lhs->digits); /* this won't change */ mermsup=rhs->lsu+D2U(rhs->digits); /* -> msu+1 of multiplier */ for (mer=rhs->lsu; merlsu, madlength, 0, &acc[shift], *mer) + shift; else { /* extend acc with a 0; it will be used shortly */ *(acc+accunits)=0; /* [this avoids length of <=0 later] */ accunits++; } /* multiply multiplicand by 10**DECDPUN for next Unit to left */ shift++; /* add this for 'logical length' */ } /* n */ #if FASTMUL } /* unchunked units */ #endif /* common end-path */ #if DECTRACE decDumpAr('*', acc, accunits); /* Show exact result */ #endif /* acc now contains the exact result of the multiplication, */ /* possibly with a leading zero unit; build the decNumber from */ /* it, noting if any residue */ res->bits=bits; /* set sign */ res->digits=decGetDigits(acc, accunits); /* count digits exactly */ /* There can be a 31-bit wrap in calculating the exponent. */ /* This can only happen if both input exponents are negative and */ /* both their magnitudes are large. If there was a wrap, set a */ /* safe very negative exponent, from which decFinalize() will */ /* raise a hard underflow shortly. */ exponent=lhs->exponent+rhs->exponent; /* calculate exponent */ if (lhs->exponent<0 && rhs->exponent<0 && exponent>0) exponent=-2*DECNUMMAXE; /* force underflow */ res->exponent=exponent; /* OK to overwrite now */ /* Set the coefficient. If any rounding, residue records */ decSetCoeff(res, set, acc, res->digits, &residue, status); decFinish(res, set, &residue, status); /* final cleanup */ } while(0); /* end protected */ free(allocacc); /* drop any storage used */ #if DECSUBSET free(allocrhs); /* .. */ free(alloclhs); /* .. */ #endif #if FASTMUL free(allocrhi); /* .. */ free(alloclhi); /* .. */ #endif return res; } /* decMultiplyOp */ /* ------------------------------------------------------------------ */ /* decExpOp -- effect exponentiation */ /* */ /* This computes C = exp(A) */ /* */ /* res is C, the result. C may be A */ /* rhs is A */ /* set is the context; note that rounding mode has no effect */ /* */ /* C must have space for set->digits digits. status is updated but */ /* not set. */ /* */ /* Restrictions: */ /* */ /* digits, emax, and -emin in the context must be less than */ /* 2*DEC_MAX_MATH (1999998), and the rhs must be within these */ /* bounds or a zero. This is an internal routine, so these */ /* restrictions are contractual and not enforced. */ /* */ /* A finite result is rounded using DEC_ROUND_HALF_EVEN; it will */ /* almost always be correctly rounded, but may be up to 1 ulp in */ /* error in rare cases. */ /* */ /* Finite results will always be full precision and Inexact, except */ /* when A is a zero or -Infinity (giving 1 or 0 respectively). */ /* ------------------------------------------------------------------ */ /* This approach used here is similar to the algorithm described in */ /* */ /* Variable Precision Exponential Function, T. E. Hull and */ /* A. Abrham, ACM Transactions on Mathematical Software, Vol 12 #2, */ /* pp79-91, ACM, June 1986. */ /* */ /* with the main difference being that the iterations in the series */ /* evaluation are terminated dynamically (which does not require the */ /* extra variable-precision variables which are expensive in this */ /* context). */ /* */ /* The error analysis in Hull & Abrham's paper applies except for the */ /* round-off error accumulation during the series evaluation. This */ /* code does not precalculate the number of iterations and so cannot */ /* use Horner's scheme. Instead, the accumulation is done at double- */ /* precision, which ensures that the additions of the terms are exact */ /* and do not accumulate round-off (and any round-off errors in the */ /* terms themselves move 'to the right' faster than they can */ /* accumulate). This code also extends the calculation by allowing, */ /* in the spirit of other decNumber operators, the input to be more */ /* precise than the result (the precision used is based on the more */ /* precise of the input or requested result). */ /* */ /* Implementation notes: */ /* */ /* 1. This is separated out as decExpOp so it can be called from */ /* other Mathematical functions (notably Ln) with a wider range */ /* than normal. In particular, it can handle the slightly wider */ /* (double) range needed by Ln (which has to be able to calculate */ /* exp(-x) where x can be the tiniest number (Ntiny). */ /* */ /* 2. Normalizing x to be <=0.1 (instead of <=1) reduces loop */ /* iterations by appoximately a third with additional (although */ /* diminishing) returns as the range is reduced to even smaller */ /* fractions. However, h (the power of 10 used to correct the */ /* result at the end, see below) must be kept <=8 as otherwise */ /* the final result cannot be computed. Hence the leverage is a */ /* sliding value (8-h), where potentially the range is reduced */ /* more for smaller values. */ /* */ /* The leverage that can be applied in this way is severely */ /* limited by the cost of the raise-to-the power at the end, */ /* which dominates when the number of iterations is small (less */ /* than ten) or when rhs is short. As an example, the adjustment */ /* x**10,000,000 needs 31 multiplications, all but one full-width. */ /* */ /* 3. The restrictions (especially precision) could be raised with */ /* care, but the full decNumber range seems very hard within the */ /* 32-bit limits. */ /* */ /* 4. The working precisions for the static buffers are twice the */ /* obvious size to allow for calls from decNumberPower. */ /* ------------------------------------------------------------------ */ decNumber * decExpOp(decNumber *res, const decNumber *rhs, decContext *set, uInt *status) { uInt ignore=0; /* working status */ Int h; /* adjusted exponent for 0.xxxx */ Int p; /* working precision */ Int residue; /* rounding residue */ uInt needbytes; /* for space calculations */ const decNumber *x=rhs; /* (may point to safe copy later) */ decContext aset, tset, dset; /* working contexts */ Int comp; /* work */ /* the argument is often copied to normalize it, so (unusually) it */ /* is treated like other buffers, using DECBUFFER, +1 in case */ /* DECBUFFER is 0 */ decNumber bufr[D2N(DECBUFFER*2+1)]; decNumber *allocrhs=NULL; /* non-NULL if rhs buffer allocated */ /* the working precision will be no more than set->digits+8+1 */ /* so for on-stack buffers DECBUFFER+9 is used, +1 in case DECBUFFER */ /* is 0 (and twice that for the accumulator) */ /* buffer for t, term (working precision plus) */ decNumber buft[D2N(DECBUFFER*2+9+1)]; decNumber *allocbuft=NULL; /* -> allocated buft, iff allocated */ decNumber *t=buft; /* term */ /* buffer for a, accumulator (working precision * 2), at least 9 */ decNumber bufa[D2N(DECBUFFER*4+18+1)]; decNumber *allocbufa=NULL; /* -> allocated bufa, iff allocated */ decNumber *a=bufa; /* accumulator */ /* decNumber for the divisor term; this needs at most 9 digits */ /* and so can be fixed size [16 so can use standard context] */ decNumber bufd[D2N(16)]; decNumber *d=bufd; /* divisor */ decNumber numone; /* constant 1 */ #if DECCHECK Int iterations=0; /* for later sanity check */ if (decCheckOperands(res, DECUNUSED, rhs, set)) return res; #endif do { /* protect allocated storage */ if (SPECIALARG) { /* handle infinities and NaNs */ if (decNumberIsInfinite(rhs)) { /* an infinity */ if (decNumberIsNegative(rhs)) /* -Infinity -> +0 */ decNumberZero(res); else decNumberCopy(res, rhs); /* +Infinity -> self */ } else decNaNs(res, rhs, NULL, set, status); /* a NaN */ break;} if (ISZERO(rhs)) { /* zeros -> exact 1 */ decNumberZero(res); /* make clean 1 */ *res->lsu=1; /* .. */ break;} /* [no status to set] */ /* e**x when 0 < x < 0.66 is < 1+3x/2, hence can fast-path */ /* positive and negative tiny cases which will result in inexact */ /* 1. This also allows the later add-accumulate to always be */ /* exact (because its length will never be more than twice the */ /* working precision). */ /* The comparator (tiny) needs just one digit, so use the */ /* decNumber d for it (reused as the divisor, etc., below); its */ /* exponent is such that if x is positive it will have */ /* set->digits-1 zeros between the decimal point and the digit, */ /* which is 4, and if x is negative one more zero there as the */ /* more precise result will be of the form 0.9999999 rather than */ /* 1.0000001. Hence, tiny will be 0.0000004 if digits=7 and x>0 */ /* or 0.00000004 if digits=7 and x<0. If RHS not larger than */ /* this then the result will be 1.000000 */ decNumberZero(d); /* clean */ *d->lsu=4; /* set 4 .. */ d->exponent=-set->digits; /* * 10**(-d) */ if (decNumberIsNegative(rhs)) d->exponent--; /* negative case */ comp=decCompare(d, rhs, 1); /* signless compare */ if (comp==BADINT) { *status|=DEC_Insufficient_storage; break;} if (comp>=0) { /* rhs < d */ Int shift=set->digits-1; decNumberZero(res); /* set 1 */ *res->lsu=1; /* .. */ res->digits=decShiftToMost(res->lsu, 1, shift); res->exponent=-shift; /* make 1.0000... */ *status|=DEC_Inexact | DEC_Rounded; /* .. inexactly */ break;} /* tiny */ /* set up the context to be used for calculating a, as this is */ /* used on both paths below */ decContextDefault(&aset, DEC_INIT_DECIMAL64); /* accumulator bounds are as requested (could underflow) */ aset.emax=set->emax; /* usual bounds */ aset.emin=set->emin; /* .. */ aset.clamp=0; /* and no concrete format */ /* calculate the adjusted (Hull & Abrham) exponent (where the */ /* decimal point is just to the left of the coefficient msd) */ h=rhs->exponent+rhs->digits; /* if h>8 then 10**h cannot be calculated safely; however, when */ /* h=8 then exp(|rhs|) will be at least exp(1E+7) which is at */ /* least 6.59E+4342944, so (due to the restriction on Emax/Emin) */ /* overflow (or underflow to 0) is guaranteed -- so this case can */ /* be handled by simply forcing the appropriate excess */ if (h>8) { /* overflow/underflow */ /* set up here so Power call below will over or underflow to */ /* zero; set accumulator to either 2 or 0.02 */ /* [stack buffer for a is always big enough for this] */ decNumberZero(a); *a->lsu=2; /* not 1 but < exp(1) */ if (decNumberIsNegative(rhs)) a->exponent=-2; /* make 0.02 */ h=8; /* clamp so 10**h computable */ p=9; /* set a working precision */ } else { /* h<=8 */ Int maxlever=(rhs->digits>8?1:0); /* [could/should increase this for precisions >40 or so, too] */ /* if h is 8, cannot normalize to a lower upper limit because */ /* the final result will not be computable (see notes above), */ /* but leverage can be applied whenever h is less than 8. */ /* Apply as much as possible, up to a MAXLEVER digits, which */ /* sets the tradeoff against the cost of the later a**(10**h). */ /* As h is increased, the working precision below also */ /* increases to compensate for the "constant digits at the */ /* front" effect. */ Int lever=MINI(8-h, maxlever); /* leverage attainable */ Int use=-rhs->digits-lever; /* exponent to use for RHS */ h+=lever; /* apply leverage selected */ if (h<0) { /* clamp */ use+=h; /* [may end up subnormal] */ h=0; } /* Take a copy of RHS if it needs normalization (true whenever x>=1) */ if (rhs->exponent!=use) { decNumber *newrhs=bufr; /* assume will fit on stack */ needbytes=sizeof(decNumber)+(D2U(rhs->digits)-1)*sizeof(Unit); if (needbytes>sizeof(bufr)) { /* need malloc space */ allocrhs=(decNumber *)malloc(needbytes); if (allocrhs==NULL) { /* hopeless -- abandon */ *status|=DEC_Insufficient_storage; break;} newrhs=allocrhs; /* use the allocated space */ } decNumberCopy(newrhs, rhs); /* copy to safe space */ newrhs->exponent=use; /* normalize; now <1 */ x=newrhs; /* ready for use */ /* decNumberShow(x); */ } /* Now use the usual power series to evaluate exp(x). The */ /* series starts as 1 + x + x^2/2 ... so prime ready for the */ /* third term by setting the term variable t=x, the accumulator */ /* a=1, and the divisor d=2. */ /* First determine the working precision. From Hull & Abrham */ /* this is set->digits+h+2. However, if x is 'over-precise' we */ /* need to allow for all its digits to potentially participate */ /* (consider an x where all the excess digits are 9s) so in */ /* this case use x->digits+h+2 */ p=MAXI(x->digits, set->digits)+h+2; /* [h<=8] */ /* a and t are variable precision, and depend on p, so space */ /* must be allocated for them if necessary */ /* the accumulator needs to be able to hold 2p digits so that */ /* the additions on the second and subsequent iterations are */ /* sufficiently exact. */ needbytes=sizeof(decNumber)+(D2U(p*2)-1)*sizeof(Unit); if (needbytes>sizeof(bufa)) { /* need malloc space */ allocbufa=(decNumber *)malloc(needbytes); if (allocbufa==NULL) { /* hopeless -- abandon */ *status|=DEC_Insufficient_storage; break;} a=allocbufa; /* use the allocated space */ } /* the term needs to be able to hold p digits (which is */ /* guaranteed to be larger than x->digits, so the initial copy */ /* is safe); it may also be used for the raise-to-power */ /* calculation below, which needs an extra two digits */ needbytes=sizeof(decNumber)+(D2U(p+2)-1)*sizeof(Unit); if (needbytes>sizeof(buft)) { /* need malloc space */ allocbuft=(decNumber *)malloc(needbytes); if (allocbuft==NULL) { /* hopeless -- abandon */ *status|=DEC_Insufficient_storage; break;} t=allocbuft; /* use the allocated space */ } decNumberCopy(t, x); /* term=x */ decNumberZero(a); *a->lsu=1; /* accumulator=1 */ decNumberZero(d); *d->lsu=2; /* divisor=2 */ decNumberZero(&numone); *numone.lsu=1; /* constant 1 for increment */ /* set up the contexts for calculating a, t, and d */ decContextDefault(&tset, DEC_INIT_DECIMAL64); dset=tset; /* accumulator bounds are set above, set precision now */ aset.digits=p*2; /* double */ /* term bounds avoid any underflow or overflow */ tset.digits=p; tset.emin=DEC_MIN_EMIN; /* [emax is plenty] */ /* [dset.digits=16, etc., are sufficient] */ /* finally ready to roll */ for (;;) { #if DECCHECK iterations++; #endif /* only the status from the accumulation is interesting */ /* [but it should remain unchanged after first add] */ decAddOp(a, a, t, &aset, 0, status); /* a=a+t */ decMultiplyOp(t, t, x, &tset, &ignore); /* t=t*x */ decDivideOp(t, t, d, &tset, DIVIDE, &ignore); /* t=t/d */ /* the iteration ends when the term cannot affect the result, */ /* if rounded to p digits, which is when its value is smaller */ /* than the accumulator by p+1 digits. There must also be */ /* full precision in a. */ if (((a->digits+a->exponent)>=(t->digits+t->exponent+p+1)) && (a->digits>=p)) break; decAddOp(d, d, &numone, &dset, 0, &ignore); /* d=d+1 */ } /* iterate */ #if DECCHECK /* just a sanity check; comment out test to show always */ if (iterations>p+3) printf("Exp iterations=%ld, status=%08lx, p=%ld, d=%ld\n", (LI)iterations, (LI)*status, (LI)p, (LI)x->digits); #endif } /* h<=8 */ /* apply postconditioning: a=a**(10**h) -- this is calculated */ /* at a slightly higher precision than Hull & Abrham suggest */ if (h>0) { Int seenbit=0; /* set once a 1-bit is seen */ Int i; /* counter */ Int n=powers[h]; /* always positive */ aset.digits=p+2; /* sufficient precision */ /* avoid the overhead and many extra digits of decNumberPower */ /* as all that is needed is the short 'multipliers' loop; here */ /* accumulate the answer into t */ decNumberZero(t); *t->lsu=1; /* acc=1 */ for (i=1;;i++){ /* for each bit [top bit ignored] */ /* abandon if have had overflow or terminal underflow */ if (*status & (DEC_Overflow|DEC_Underflow)) { /* interesting? */ if (*status&DEC_Overflow || ISZERO(t)) break;} n=n<<1; /* move next bit to testable position */ if (n<0) { /* top bit is set */ seenbit=1; /* OK, have a significant bit */ decMultiplyOp(t, t, a, &aset, status); /* acc=acc*x */ } if (i==31) break; /* that was the last bit */ if (!seenbit) continue; /* no need to square 1 */ decMultiplyOp(t, t, t, &aset, status); /* acc=acc*acc [square] */ } /*i*/ /* 32 bits */ /* decNumberShow(t); */ a=t; /* and carry on using t instead of a */ } /* Copy and round the result to res */ residue=1; /* indicate dirt to right .. */ if (ISZERO(a)) residue=0; /* .. unless underflowed to 0 */ aset.digits=set->digits; /* [use default rounding] */ decCopyFit(res, a, &aset, &residue, status); /* copy & shorten */ decFinish(res, set, &residue, status); /* cleanup/set flags */ } while(0); /* end protected */ free(allocrhs); /* drop any storage used */ free(allocbufa); /* .. */ free(allocbuft); /* .. */ /* [status is handled by caller] */ return res; } /* decExpOp */ /* ------------------------------------------------------------------ */ /* Initial-estimate natural logarithm table */ /* */ /* LNnn -- 90-entry 16-bit table for values from .10 through .99. */ /* The result is a 4-digit encode of the coefficient (c=the */ /* top 14 bits encoding 0-9999) and a 2-digit encode of the */ /* exponent (e=the bottom 2 bits encoding 0-3) */ /* */ /* The resulting value is given by: */ /* */ /* v = -c * 10**(-e-3) */ /* */ /* where e and c are extracted from entry k = LNnn[x-10] */ /* where x is truncated (NB) into the range 10 through 99, */ /* and then c = k>>2 and e = k&3. */ /* ------------------------------------------------------------------ */ const uShort LNnn[90]={9016, 8652, 8316, 8008, 7724, 7456, 7208, 6972, 6748, 6540, 6340, 6148, 5968, 5792, 5628, 5464, 5312, 5164, 5020, 4884, 4748, 4620, 4496, 4376, 4256, 4144, 4032, 39233, 38181, 37157, 36157, 35181, 34229, 33297, 32389, 31501, 30629, 29777, 28945, 28129, 27329, 26545, 25777, 25021, 24281, 23553, 22837, 22137, 21445, 20769, 20101, 19445, 18801, 18165, 17541, 16925, 16321, 15721, 15133, 14553, 13985, 13421, 12865, 12317, 11777, 11241, 10717, 10197, 9685, 9177, 8677, 8185, 7697, 7213, 6737, 6269, 5801, 5341, 4889, 4437, 39930, 35534, 31186, 26886, 22630, 18418, 14254, 10130, 6046, 20055}; /* ------------------------------------------------------------------ */ /* decLnOp -- effect natural logarithm */ /* */ /* This computes C = ln(A) */ /* */ /* res is C, the result. C may be A */ /* rhs is A */ /* set is the context; note that rounding mode has no effect */ /* */ /* C must have space for set->digits digits. */ /* */ /* Notable cases: */ /* A<0 -> Invalid */ /* A=0 -> -Infinity (Exact) */ /* A=+Infinity -> +Infinity (Exact) */ /* A=1 exactly -> 0 (Exact) */ /* */ /* Restrictions (as for Exp): */ /* */ /* digits, emax, and -emin in the context must be less than */ /* DEC_MAX_MATH+11 (1000010), and the rhs must be within these */ /* bounds or a zero. This is an internal routine, so these */ /* restrictions are contractual and not enforced. */ /* */ /* A finite result is rounded using DEC_ROUND_HALF_EVEN; it will */ /* almost always be correctly rounded, but may be up to 1 ulp in */ /* error in rare cases. */ /* ------------------------------------------------------------------ */ /* The result is calculated using Newton's method, with each */ /* iteration calculating a' = a + x * exp(-a) - 1. See, for example, */ /* Epperson 1989. */ /* */ /* The iteration ends when the adjustment x*exp(-a)-1 is tiny enough. */ /* This has to be calculated at the sum of the precision of x and the */ /* working precision. */ /* */ /* Implementation notes: */ /* */ /* 1. This is separated out as decLnOp so it can be called from */ /* other Mathematical functions (e.g., Log 10) with a wider range */ /* than normal. In particular, it can handle the slightly wider */ /* (+9+2) range needed by a power function. */ /* */ /* 2. The speed of this function is about 10x slower than exp, as */ /* it typically needs 4-6 iterations for short numbers, and the */ /* extra precision needed adds a squaring effect, twice. */ /* */ /* 3. Fastpaths are included for ln(10) and ln(2), up to length 40, */ /* as these are common requests. ln(10) is used by log10(x). */ /* */ /* 4. An iteration might be saved by widening the LNnn table, and */ /* would certainly save at least one if it were made ten times */ /* bigger, too (for truncated fractions 0.100 through 0.999). */ /* However, for most practical evaluations, at least four or five */ /* iterations will be neede -- so this would only speed up by */ /* 20-25% and that probably does not justify increasing the table */ /* size. */ /* */ /* 5. The static buffers are larger than might be expected to allow */ /* for calls from decNumberPower. */ /* ------------------------------------------------------------------ */ decNumber * decLnOp(decNumber *res, const decNumber *rhs, decContext *set, uInt *status) { uInt ignore=0; /* working status accumulator */ uInt needbytes; /* for space calculations */ Int residue; /* rounding residue */ Int r; /* rhs=f*10**r [see below] */ Int p; /* working precision */ Int pp; /* precision for iteration */ Int t; /* work */ /* buffers for a (accumulator, typically precision+2) and b */ /* (adjustment calculator, same size) */ decNumber bufa[D2N(DECBUFFER+12)]; decNumber *allocbufa=NULL; /* -> allocated bufa, iff allocated */ decNumber *a=bufa; /* accumulator/work */ decNumber bufb[D2N(DECBUFFER*2+2)]; decNumber *allocbufb=NULL; /* -> allocated bufa, iff allocated */ decNumber *b=bufb; /* adjustment/work */ decNumber numone; /* constant 1 */ decNumber cmp; /* work */ decContext aset, bset; /* working contexts */ #if DECCHECK Int iterations=0; /* for later sanity check */ if (decCheckOperands(res, DECUNUSED, rhs, set)) return res; #endif do { /* protect allocated storage */ if (SPECIALARG) { /* handle infinities and NaNs */ if (decNumberIsInfinite(rhs)) { /* an infinity */ if (decNumberIsNegative(rhs)) /* -Infinity -> error */ *status|=DEC_Invalid_operation; else decNumberCopy(res, rhs); /* +Infinity -> self */ } else decNaNs(res, rhs, NULL, set, status); /* a NaN */ break;} if (ISZERO(rhs)) { /* +/- zeros -> -Infinity */ decNumberZero(res); /* make clean */ res->bits=DECINF|DECNEG; /* set - infinity */ break;} /* [no status to set] */ /* Non-zero negatives are bad... */ if (decNumberIsNegative(rhs)) { /* -x -> error */ *status|=DEC_Invalid_operation; break;} /* Here, rhs is positive, finite, and in range */ /* lookaside fastpath code for ln(2) and ln(10) at common lengths */ if (rhs->exponent==0 && set->digits<=40) { #if DECDPUN==1 if (rhs->lsu[0]==0 && rhs->lsu[1]==1 && rhs->digits==2) { /* ln(10) */ #else if (rhs->lsu[0]==10 && rhs->digits==2) { /* ln(10) */ #endif aset=*set; aset.round=DEC_ROUND_HALF_EVEN; #define LN10 "2.302585092994045684017991454684364207601" decNumberFromString(res, LN10, &aset); *status|=(DEC_Inexact | DEC_Rounded); /* is inexact */ break;} if (rhs->lsu[0]==2 && rhs->digits==1) { /* ln(2) */ aset=*set; aset.round=DEC_ROUND_HALF_EVEN; #define LN2 "0.6931471805599453094172321214581765680755" decNumberFromString(res, LN2, &aset); *status|=(DEC_Inexact | DEC_Rounded); break;} } /* integer and short */ /* Determine the working precision. This is normally the */ /* requested precision + 2, with a minimum of 9. However, if */ /* the rhs is 'over-precise' then allow for all its digits to */ /* potentially participate (consider an rhs where all the excess */ /* digits are 9s) so in this case use rhs->digits+2. */ p=MAXI(rhs->digits, MAXI(set->digits, 7))+2; /* Allocate space for the accumulator and the high-precision */ /* adjustment calculator, if necessary. The accumulator must */ /* be able to hold p digits, and the adjustment up to */ /* rhs->digits+p digits. They are also made big enough for 16 */ /* digits so that they can be used for calculating the initial */ /* estimate. */ needbytes=sizeof(decNumber)+(D2U(MAXI(p,16))-1)*sizeof(Unit); if (needbytes>sizeof(bufa)) { /* need malloc space */ allocbufa=(decNumber *)malloc(needbytes); if (allocbufa==NULL) { /* hopeless -- abandon */ *status|=DEC_Insufficient_storage; break;} a=allocbufa; /* use the allocated space */ } pp=p+rhs->digits; needbytes=sizeof(decNumber)+(D2U(MAXI(pp,16))-1)*sizeof(Unit); if (needbytes>sizeof(bufb)) { /* need malloc space */ allocbufb=(decNumber *)malloc(needbytes); if (allocbufb==NULL) { /* hopeless -- abandon */ *status|=DEC_Insufficient_storage; break;} b=allocbufb; /* use the allocated space */ } /* Prepare an initial estimate in acc. Calculate this by */ /* considering the coefficient of x to be a normalized fraction, */ /* f, with the decimal point at far left and multiplied by */ /* 10**r. Then, rhs=f*10**r and 0.1<=f<1, and */ /* ln(x) = ln(f) + ln(10)*r */ /* Get the initial estimate for ln(f) from a small lookup */ /* table (see above) indexed by the first two digits of f, */ /* truncated. */ decContextDefault(&aset, DEC_INIT_DECIMAL64); /* 16-digit extended */ r=rhs->exponent+rhs->digits; /* 'normalised' exponent */ decNumberFromInt32(a, r); /* a=r */ decNumberFromInt32(b, 2302585); /* b=ln(10) (2.302585) */ b->exponent=-6; /* .. */ decMultiplyOp(a, a, b, &aset, &ignore); /* a=a*b */ /* now get top two digits of rhs into b by simple truncate and */ /* force to integer */ residue=0; /* (no residue) */ aset.digits=2; aset.round=DEC_ROUND_DOWN; decCopyFit(b, rhs, &aset, &residue, &ignore); /* copy & shorten */ b->exponent=0; /* make integer */ t=decGetInt(b); /* [cannot fail] */ if (t<10) t=X10(t); /* adjust single-digit b */ t=LNnn[t-10]; /* look up ln(b) */ decNumberFromInt32(b, t>>2); /* b=ln(b) coefficient */ b->exponent=-(t&3)-3; /* set exponent */ b->bits=DECNEG; /* ln(0.10)->ln(0.99) always -ve */ aset.digits=16; aset.round=DEC_ROUND_HALF_EVEN; /* restore */ decAddOp(a, a, b, &aset, 0, &ignore); /* acc=a+b */ /* the initial estimate is now in a, with up to 4 digits correct. */ /* When rhs is at or near Nmax the estimate will be low, so we */ /* will approach it from below, avoiding overflow when calling exp. */ decNumberZero(&numone); *numone.lsu=1; /* constant 1 for adjustment */ /* accumulator bounds are as requested (could underflow, but */ /* cannot overflow) */ aset.emax=set->emax; aset.emin=set->emin; aset.clamp=0; /* no concrete format */ /* set up a context to be used for the multiply and subtract */ bset=aset; bset.emax=DEC_MAX_MATH*2; /* use double bounds for the */ bset.emin=-DEC_MAX_MATH*2; /* adjustment calculation */ /* [see decExpOp call below] */ /* for each iteration double the number of digits to calculate, */ /* up to a maximum of p */ pp=9; /* initial precision */ /* [initially 9 as then the sequence starts 7+2, 16+2, and */ /* 34+2, which is ideal for standard-sized numbers] */ aset.digits=pp; /* working context */ bset.digits=pp+rhs->digits; /* wider context */ for (;;) { /* iterate */ #if DECCHECK iterations++; if (iterations>24) break; /* consider 9 * 2**24 */ #endif /* calculate the adjustment (exp(-a)*x-1) into b. This is a */ /* catastrophic subtraction but it really is the difference */ /* from 1 that is of interest. */ /* Use the internal entry point to Exp as it allows the double */ /* range for calculating exp(-a) when a is the tiniest subnormal. */ a->bits^=DECNEG; /* make -a */ decExpOp(b, a, &bset, &ignore); /* b=exp(-a) */ a->bits^=DECNEG; /* restore sign of a */ /* now multiply by rhs and subtract 1, at the wider precision */ decMultiplyOp(b, b, rhs, &bset, &ignore); /* b=b*rhs */ decAddOp(b, b, &numone, &bset, DECNEG, &ignore); /* b=b-1 */ /* the iteration ends when the adjustment cannot affect the */ /* result by >=0.5 ulp (at the requested digits), which */ /* is when its value is smaller than the accumulator by */ /* set->digits+1 digits (or it is zero) -- this is a looser */ /* requirement than for Exp because all that happens to the */ /* accumulator after this is the final rounding (but note that */ /* there must also be full precision in a, or a=0). */ if (decNumberIsZero(b) || (a->digits+a->exponent)>=(b->digits+b->exponent+set->digits+1)) { if (a->digits==p) break; if (decNumberIsZero(a)) { decCompareOp(&cmp, rhs, &numone, &aset, COMPARE, &ignore); /* rhs=1 ? */ if (cmp.lsu[0]==0) a->exponent=0; /* yes, exact 0 */ else *status|=(DEC_Inexact | DEC_Rounded); /* no, inexact */ break; } /* force padding if adjustment has gone to 0 before full length */ if (decNumberIsZero(b)) b->exponent=a->exponent-p; } /* not done yet ... */ decAddOp(a, a, b, &aset, 0, &ignore); /* a=a+b for next estimate */ if (pp==p) continue; /* precision is at maximum */ /* lengthen the next calculation */ pp=pp*2; /* double precision */ if (pp>p) pp=p; /* clamp to maximum */ aset.digits=pp; /* working context */ bset.digits=pp+rhs->digits; /* wider context */ } /* Newton's iteration */ #if DECCHECK /* just a sanity check; remove the test to show always */ if (iterations>24) printf("Ln iterations=%ld, status=%08lx, p=%ld, d=%ld\n", (LI)iterations, (LI)*status, (LI)p, (LI)rhs->digits); #endif /* Copy and round the result to res */ residue=1; /* indicate dirt to right */ if (ISZERO(a)) residue=0; /* .. unless underflowed to 0 */ aset.digits=set->digits; /* [use default rounding] */ decCopyFit(res, a, &aset, &residue, status); /* copy & shorten */ decFinish(res, set, &residue, status); /* cleanup/set flags */ } while(0); /* end protected */ free(allocbufa); /* drop any storage used */ free(allocbufb); /* .. */ /* [status is handled by caller] */ return res; } /* decLnOp */ /* ------------------------------------------------------------------ */ /* decQuantizeOp -- force exponent to requested value */ /* */ /* This computes C = op(A, B), where op adjusts the coefficient */ /* of C (by rounding or shifting) such that the exponent (-scale) */ /* of C has the value B or matches the exponent of B. */ /* The numerical value of C will equal A, except for the effects of */ /* any rounding that occurred. */ /* */ /* res is C, the result. C may be A or B */ /* lhs is A, the number to adjust */ /* rhs is B, the requested exponent */ /* set is the context */ /* quant is 1 for quantize or 0 for rescale */ /* status is the status accumulator (this can be called without */ /* risk of control loss) */ /* */ /* C must have space for set->digits digits. */ /* */ /* Unless there is an error or the result is infinite, the exponent */ /* after the operation is guaranteed to be that requested. */ /* ------------------------------------------------------------------ */ static decNumber * decQuantizeOp(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set, Flag quant, uInt *status) { #if DECSUBSET decNumber *alloclhs=NULL; /* non-NULL if rounded lhs allocated */ decNumber *allocrhs=NULL; /* .., rhs */ #endif const decNumber *inrhs=rhs; /* save original rhs */ Int reqdigits=set->digits; /* requested DIGITS */ Int reqexp; /* requested exponent [-scale] */ Int residue=0; /* rounding residue */ Int etiny=set->emin-(reqdigits-1); #if DECCHECK if (decCheckOperands(res, lhs, rhs, set)) return res; #endif do { /* protect allocated storage */ #if DECSUBSET if (!set->extended) { /* reduce operands and set lostDigits status, as needed */ if (lhs->digits>reqdigits) { alloclhs=decRoundOperand(lhs, set, status); if (alloclhs==NULL) break; lhs=alloclhs; } if (rhs->digits>reqdigits) { /* [this only checks lostDigits] */ allocrhs=decRoundOperand(rhs, set, status); if (allocrhs==NULL) break; rhs=allocrhs; } } #endif /* [following code does not require input rounding] */ /* Handle special values */ if (SPECIALARGS) { /* NaNs get usual processing */ if (SPECIALARGS & (DECSNAN | DECNAN)) decNaNs(res, lhs, rhs, set, status); /* one infinity but not both is bad */ else if ((lhs->bits ^ rhs->bits) & DECINF) *status|=DEC_Invalid_operation; /* both infinity: return lhs */ else decNumberCopy(res, lhs); /* [nop if in place] */ break; } /* set requested exponent */ if (quant) reqexp=inrhs->exponent; /* quantize -- match exponents */ else { /* rescale -- use value of rhs */ /* Original rhs must be an integer that fits and is in range, */ /* which could be from -1999999997 to +999999999, thanks to */ /* subnormals */ reqexp=decGetInt(inrhs); /* [cannot fail] */ } #if DECSUBSET if (!set->extended) etiny=set->emin; /* no subnormals */ #endif if (reqexp==BADINT /* bad (rescale only) or .. */ || reqexp==BIGODD || reqexp==BIGEVEN /* very big (ditto) or .. */ || (reqexpset->emax)) { /* > emax */ *status|=DEC_Invalid_operation; break;} /* the RHS has been processed, so it can be overwritten now if necessary */ if (ISZERO(lhs)) { /* zero coefficient unchanged */ decNumberCopy(res, lhs); /* [nop if in place] */ res->exponent=reqexp; /* .. just set exponent */ #if DECSUBSET if (!set->extended) res->bits=0; /* subset specification; no -0 */ #endif } else { /* non-zero lhs */ Int adjust=reqexp-lhs->exponent; /* digit adjustment needed */ /* if adjusted coefficient will definitely not fit, give up now */ if ((lhs->digits-adjust)>reqdigits) { *status|=DEC_Invalid_operation; break; } if (adjust>0) { /* increasing exponent */ /* this will decrease the length of the coefficient by adjust */ /* digits, and must round as it does so */ decContext workset; /* work */ workset=*set; /* clone rounding, etc. */ workset.digits=lhs->digits-adjust; /* set requested length */ /* [note that the latter can be <1, here] */ decCopyFit(res, lhs, &workset, &residue, status); /* fit to result */ decApplyRound(res, &workset, residue, status); /* .. and round */ residue=0; /* [used] */ /* If just rounded a 999s case, exponent will be off by one; */ /* adjust back (after checking space), if so. */ if (res->exponent>reqexp) { /* re-check needed, e.g., for quantize(0.9999, 0.001) under */ /* set->digits==3 */ if (res->digits==reqdigits) { /* cannot shift by 1 */ *status&=~(DEC_Inexact | DEC_Rounded); /* [clean these] */ *status|=DEC_Invalid_operation; break; } res->digits=decShiftToMost(res->lsu, res->digits, 1); /* shift */ res->exponent--; /* (re)adjust the exponent. */ } #if DECSUBSET if (ISZERO(res) && !set->extended) res->bits=0; /* subset; no -0 */ #endif } /* increase */ else /* adjust<=0 */ { /* decreasing or = exponent */ /* this will increase the length of the coefficient by -adjust */ /* digits, by adding zero or more trailing zeros; this is */ /* already checked for fit, above */ decNumberCopy(res, lhs); /* [it will fit] */ /* if padding needed (adjust<0), add it now... */ if (adjust<0) { res->digits=decShiftToMost(res->lsu, res->digits, -adjust); res->exponent+=adjust; /* adjust the exponent */ } } /* decrease */ } /* non-zero */ /* Check for overflow [do not use Finalize in this case, as an */ /* overflow here is a "don't fit" situation] */ if (res->exponent>set->emax-res->digits+1) { /* too big */ *status|=DEC_Invalid_operation; break; } else { decFinalize(res, set, &residue, status); /* set subnormal flags */ *status&=~DEC_Underflow; /* suppress Underflow [as per 754] */ } } while(0); /* end protected */ #if DECSUBSET free(allocrhs); /* drop any storage used */ free(alloclhs); /* .. */ #endif return res; } /* decQuantizeOp */ /* ------------------------------------------------------------------ */ /* decCompareOp -- compare, min, or max two Numbers */ /* */ /* This computes C = A ? B and carries out one of four operations: */ /* COMPARE -- returns the signum (as a number) giving the */ /* result of a comparison unless one or both */ /* operands is a NaN (in which case a NaN results) */ /* COMPSIG -- as COMPARE except that a quiet NaN raises */ /* Invalid operation. */ /* COMPMAX -- returns the larger of the operands, using the */ /* 754 maxnum operation */ /* COMPMAXMAG -- ditto, comparing absolute values */ /* COMPMIN -- the 754 minnum operation */ /* COMPMINMAG -- ditto, comparing absolute values */ /* COMTOTAL -- returns the signum (as a number) giving the */ /* result of a comparison using 754 total ordering */ /* */ /* res is C, the result. C may be A and/or B (e.g., X=X?X) */ /* lhs is A */ /* rhs is B */ /* set is the context */ /* op is the operation flag */ /* status is the usual accumulator */ /* */ /* C must have space for one digit for COMPARE or set->digits for */ /* COMPMAX, COMPMIN, COMPMAXMAG, or COMPMINMAG. */ /* ------------------------------------------------------------------ */ /* The emphasis here is on speed for common cases, and avoiding */ /* coefficient comparison if possible. */ /* ------------------------------------------------------------------ */ decNumber * decCompareOp(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set, Flag op, uInt *status) { #if DECSUBSET decNumber *alloclhs=NULL; /* non-NULL if rounded lhs allocated */ decNumber *allocrhs=NULL; /* .., rhs */ #endif Int result=0; /* default result value */ uByte merged; /* work */ #if DECCHECK if (decCheckOperands(res, lhs, rhs, set)) return res; #endif do { /* protect allocated storage */ #if DECSUBSET if (!set->extended) { /* reduce operands and set lostDigits status, as needed */ if (lhs->digits>set->digits) { alloclhs=decRoundOperand(lhs, set, status); if (alloclhs==NULL) {result=BADINT; break;} lhs=alloclhs; } if (rhs->digits>set->digits) { allocrhs=decRoundOperand(rhs, set, status); if (allocrhs==NULL) {result=BADINT; break;} rhs=allocrhs; } } #endif /* [following code does not require input rounding] */ /* If total ordering then handle differing signs 'up front' */ if (op==COMPTOTAL) { /* total ordering */ if (decNumberIsNegative(lhs) & !decNumberIsNegative(rhs)) { result=-1; break; } if (!decNumberIsNegative(lhs) & decNumberIsNegative(rhs)) { result=+1; break; } } /* handle NaNs specially; let infinities drop through */ /* This assumes sNaN (even just one) leads to NaN. */ merged=(lhs->bits | rhs->bits) & (DECSNAN | DECNAN); if (merged) { /* a NaN bit set */ if (op==COMPARE); /* result will be NaN */ else if (op==COMPSIG) /* treat qNaN as sNaN */ *status|=DEC_Invalid_operation | DEC_sNaN; else if (op==COMPTOTAL) { /* total ordering, always finite */ /* signs are known to be the same; compute the ordering here */ /* as if the signs are both positive, then invert for negatives */ if (!decNumberIsNaN(lhs)) result=-1; else if (!decNumberIsNaN(rhs)) result=+1; /* here if both NaNs */ else if (decNumberIsSNaN(lhs) && decNumberIsQNaN(rhs)) result=-1; else if (decNumberIsQNaN(lhs) && decNumberIsSNaN(rhs)) result=+1; else { /* both NaN or both sNaN */ /* now it just depends on the payload */ result=decUnitCompare(lhs->lsu, D2U(lhs->digits), rhs->lsu, D2U(rhs->digits), 0); /* [Error not possible, as these are 'aligned'] */ } /* both same NaNs */ if (decNumberIsNegative(lhs)) result=-result; break; } /* total order */ else if (merged & DECSNAN); /* sNaN -> qNaN */ else { /* here if MIN or MAX and one or two quiet NaNs */ /* min or max -- 754 rules ignore single NaN */ if (!decNumberIsNaN(lhs) || !decNumberIsNaN(rhs)) { /* just one NaN; force choice to be the non-NaN operand */ op=COMPMAX; if (lhs->bits & DECNAN) result=-1; /* pick rhs */ else result=+1; /* pick lhs */ break; } } /* max or min */ op=COMPNAN; /* use special path */ decNaNs(res, lhs, rhs, set, status); /* propagate NaN */ break; } /* have numbers */ if (op==COMPMAXMAG || op==COMPMINMAG) result=decCompare(lhs, rhs, 1); else result=decCompare(lhs, rhs, 0); /* sign matters */ } while(0); /* end protected */ if (result==BADINT) *status|=DEC_Insufficient_storage; /* rare */ else { if (op==COMPARE || op==COMPSIG ||op==COMPTOTAL) { /* returning signum */ if (op==COMPTOTAL && result==0) { /* operands are numerically equal or same NaN (and same sign, */ /* tested first); if identical, leave result 0 */ if (lhs->exponent!=rhs->exponent) { if (lhs->exponentexponent) result=-1; else result=+1; if (decNumberIsNegative(lhs)) result=-result; } /* lexp!=rexp */ } /* total-order by exponent */ decNumberZero(res); /* [always a valid result] */ if (result!=0) { /* must be -1 or +1 */ *res->lsu=1; if (result<0) res->bits=DECNEG; } } else if (op==COMPNAN); /* special, drop through */ else { /* MAX or MIN, non-NaN result */ Int residue=0; /* rounding accumulator */ /* choose the operand for the result */ const decNumber *choice; if (result==0) { /* operands are numerically equal */ /* choose according to sign then exponent (see 754) */ uByte slhs=(lhs->bits & DECNEG); uByte srhs=(rhs->bits & DECNEG); #if DECSUBSET if (!set->extended) { /* subset: force left-hand */ op=COMPMAX; result=+1; } else #endif if (slhs!=srhs) { /* signs differ */ if (slhs) result=-1; /* rhs is max */ else result=+1; /* lhs is max */ } else if (slhs && srhs) { /* both negative */ if (lhs->exponentexponent) result=+1; else result=-1; /* [if equal, use lhs, technically identical] */ } else { /* both positive */ if (lhs->exponent>rhs->exponent) result=+1; else result=-1; /* [ditto] */ } } /* numerically equal */ /* here result will be non-0; reverse if looking for MIN */ if (op==COMPMIN || op==COMPMINMAG) result=-result; choice=(result>0 ? lhs : rhs); /* choose */ /* copy chosen to result, rounding if need be */ decCopyFit(res, choice, set, &residue, status); decFinish(res, set, &residue, status); } } #if DECSUBSET free(allocrhs); /* free any storage used */ free(alloclhs); /* .. */ #endif return res; } /* decCompareOp */ /* ------------------------------------------------------------------ */ /* decCompare -- compare two decNumbers by numerical value */ /* */ /* This routine compares A ? B without altering them. */ /* */ /* Arg1 is A, a decNumber which is not a NaN */ /* Arg2 is B, a decNumber which is not a NaN */ /* Arg3 is 1 for a sign-independent compare, 0 otherwise */ /* */ /* returns -1, 0, or 1 for AB, or BADINT if failure */ /* (the only possible failure is an allocation error) */ /* ------------------------------------------------------------------ */ static Int decCompare(const decNumber *lhs, const decNumber *rhs, Flag abs) { Int result; /* result value */ Int sigr; /* rhs signum */ Int compare; /* work */ result=1; /* assume signum(lhs) */ if (ISZERO(lhs)) result=0; if (abs) { if (ISZERO(rhs)) return result; /* LHS wins or both 0 */ /* RHS is non-zero */ if (result==0) return -1; /* LHS is 0; RHS wins */ /* [here, both non-zero, result=1] */ } else { /* signs matter */ if (result && decNumberIsNegative(lhs)) result=-1; sigr=1; /* compute signum(rhs) */ if (ISZERO(rhs)) sigr=0; else if (decNumberIsNegative(rhs)) sigr=-1; if (result > sigr) return +1; /* L > R, return 1 */ if (result < sigr) return -1; /* L < R, return -1 */ if (result==0) return 0; /* both 0 */ } /* signums are the same; both are non-zero */ if ((lhs->bits | rhs->bits) & DECINF) { /* one or more infinities */ if (decNumberIsInfinite(rhs)) { if (decNumberIsInfinite(lhs)) result=0;/* both infinite */ else result=-result; /* only rhs infinite */ } return result; } /* must compare the coefficients, allowing for exponents */ if (lhs->exponent>rhs->exponent) { /* LHS exponent larger */ /* swap sides, and sign */ const decNumber *temp=lhs; lhs=rhs; rhs=temp; result=-result; } compare=decUnitCompare(lhs->lsu, D2U(lhs->digits), rhs->lsu, D2U(rhs->digits), rhs->exponent-lhs->exponent); if (compare!=BADINT) compare*=result; /* comparison succeeded */ return compare; } /* decCompare */ /* ------------------------------------------------------------------ */ /* decUnitCompare -- compare two >=0 integers in Unit arrays */ /* */ /* This routine compares A ? B*10**E where A and B are unit arrays */ /* A is a plain integer */ /* B has an exponent of E (which must be non-negative) */ /* */ /* Arg1 is A first Unit (lsu) */ /* Arg2 is A length in Units */ /* Arg3 is B first Unit (lsu) */ /* Arg4 is B length in Units */ /* Arg5 is E (0 if the units are aligned) */ /* */ /* returns -1, 0, or 1 for AB, or BADINT if failure */ /* (the only possible failure is an allocation error, which can */ /* only occur if E!=0) */ /* ------------------------------------------------------------------ */ static Int decUnitCompare(const Unit *a, Int alength, const Unit *b, Int blength, Int exp) { Unit *acc; /* accumulator for result */ Unit accbuff[SD2U(DECBUFFER*2+1)]; /* local buffer */ Unit *allocacc=NULL; /* -> allocated acc buffer, iff allocated */ Int accunits, need; /* units in use or needed for acc */ const Unit *l, *r, *u; /* work */ Int expunits, exprem, result; /* .. */ if (exp==0) { /* aligned; fastpath */ if (alength>blength) return 1; if (alength=a; l--, r--) { if (*l>*r) return 1; if (*l<*r) return -1; } return 0; /* all units match */ } /* aligned */ /* Unaligned. If one is >1 unit longer than the other, padded */ /* approximately, then can return easily */ if (alength>blength+(Int)D2U(exp)) return 1; if (alength+1sizeof(accbuff)) { allocacc=(Unit *)malloc(need*sizeof(Unit)); if (allocacc==NULL) return BADINT; /* hopeless -- abandon */ acc=allocacc; } /* Calculate units and remainder from exponent. */ expunits=exp/DECDPUN; exprem=exp%DECDPUN; /* subtract [A+B*(-m)] */ accunits=decUnitAddSub(a, alength, b, blength, expunits, acc, -(Int)powers[exprem]); /* [UnitAddSub result may have leading zeros, even on zero] */ if (accunits<0) result=-1; /* negative result */ else { /* non-negative result */ /* check units of the result before freeing any storage */ for (u=acc; u=0 integers in Unit arrays */ /* */ /* This routine performs the calculation: */ /* */ /* C=A+(B*M) */ /* */ /* Where M is in the range -DECDPUNMAX through +DECDPUNMAX. */ /* */ /* A may be shorter or longer than B. */ /* */ /* Leading zeros are not removed after a calculation. The result is */ /* either the same length as the longer of A and B (adding any */ /* shift), or one Unit longer than that (if a Unit carry occurred). */ /* */ /* A and B content are not altered unless C is also A or B. */ /* C may be the same array as A or B, but only if no zero padding is */ /* requested (that is, C may be B only if bshift==0). */ /* C is filled from the lsu; only those units necessary to complete */ /* the calculation are referenced. */ /* */ /* Arg1 is A first Unit (lsu) */ /* Arg2 is A length in Units */ /* Arg3 is B first Unit (lsu) */ /* Arg4 is B length in Units */ /* Arg5 is B shift in Units (>=0; pads with 0 units if positive) */ /* Arg6 is C first Unit (lsu) */ /* Arg7 is M, the multiplier */ /* */ /* returns the count of Units written to C, which will be non-zero */ /* and negated if the result is negative. That is, the sign of the */ /* returned Int is the sign of the result (positive for zero) and */ /* the absolute value of the Int is the count of Units. */ /* */ /* It is the caller's responsibility to make sure that C size is */ /* safe, allowing space if necessary for a one-Unit carry. */ /* */ /* This routine is severely performance-critical; *any* change here */ /* must be measured (timed) to assure no performance degradation. */ /* In particular, trickery here tends to be counter-productive, as */ /* increased complexity of code hurts register optimizations on */ /* register-poor architectures. Avoiding divisions is nearly */ /* always a Good Idea, however. */ /* */ /* Special thanks to Rick McGuire (IBM Cambridge, MA) and Dave Clark */ /* (IBM Warwick, UK) for some of the ideas used in this routine. */ /* ------------------------------------------------------------------ */ static Int decUnitAddSub(const Unit *a, Int alength, const Unit *b, Int blength, Int bshift, Unit *c, Int m) { const Unit *alsu=a; /* A lsu [need to remember it] */ Unit *clsu=c; /* C ditto */ Unit *minC; /* low water mark for C */ Unit *maxC; /* high water mark for C */ eInt carry=0; /* carry integer (could be Long) */ Int add; /* work */ #if DECDPUN<=4 /* myriadal, millenary, etc. */ Int est; /* estimated quotient */ #endif #if DECTRACE if (alength<1 || blength<1) printf("decUnitAddSub: alen blen m %ld %ld [%ld]\n", alength, blength, m); #endif maxC=c+alength; /* A is usually the longer */ minC=c+blength; /* .. and B the shorter */ if (bshift!=0) { /* B is shifted; low As copy across */ minC+=bshift; /* if in place [common], skip copy unless there's a gap [rare] */ if (a==c && bshift<=alength) { c+=bshift; a+=bshift; } else for (; cmaxC) { /* swap */ Unit *hold=minC; minC=maxC; maxC=hold; } /* For speed, do the addition as two loops; the first where both A */ /* and B contribute, and the second (if necessary) where only one or */ /* other of the numbers contribute. */ /* Carry handling is the same (i.e., duplicated) in each case. */ for (; c=0) { est=(((ueInt)carry>>11)*53687)>>18; *c=(Unit)(carry-est*(DECDPUNMAX+1)); /* remainder */ carry=est; /* likely quotient [89%] */ if (*c>11)*53687)>>18; *c=(Unit)(carry-est*(DECDPUNMAX+1)); carry=est-(DECDPUNMAX+1); /* correctly negative */ if (*c=0) { est=(((ueInt)carry>>3)*16777)>>21; *c=(Unit)(carry-est*(DECDPUNMAX+1)); /* remainder */ carry=est; /* likely quotient [99%] */ if (*c>3)*16777)>>21; *c=(Unit)(carry-est*(DECDPUNMAX+1)); carry=est-(DECDPUNMAX+1); /* correctly negative */ if (*c=0) { est=QUOT10(carry, DECDPUN); *c=(Unit)(carry-est*(DECDPUNMAX+1)); /* remainder */ carry=est; /* quotient */ continue; } /* negative case */ carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); /* make positive */ est=QUOT10(carry, DECDPUN); *c=(Unit)(carry-est*(DECDPUNMAX+1)); carry=est-(DECDPUNMAX+1); /* correctly negative */ #else /* remainder operator is undefined if negative, so must test */ if ((ueInt)carry<(DECDPUNMAX+1)*2) { /* fastpath carry +1 */ *c=(Unit)(carry-(DECDPUNMAX+1)); /* [helps additions] */ carry=1; continue; } if (carry>=0) { *c=(Unit)(carry%(DECDPUNMAX+1)); carry=carry/(DECDPUNMAX+1); continue; } /* negative case */ carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); /* make positive */ *c=(Unit)(carry%(DECDPUNMAX+1)); carry=carry/(DECDPUNMAX+1)-(DECDPUNMAX+1); #endif } /* c */ /* now may have one or other to complete */ /* [pretest to avoid loop setup/shutdown] */ if (cDECDPUNMAX */ #if DECDPUN==4 /* use divide-by-multiply */ if (carry>=0) { est=(((ueInt)carry>>11)*53687)>>18; *c=(Unit)(carry-est*(DECDPUNMAX+1)); /* remainder */ carry=est; /* likely quotient [79.7%] */ if (*c>11)*53687)>>18; *c=(Unit)(carry-est*(DECDPUNMAX+1)); carry=est-(DECDPUNMAX+1); /* correctly negative */ if (*c=0) { est=(((ueInt)carry>>3)*16777)>>21; *c=(Unit)(carry-est*(DECDPUNMAX+1)); /* remainder */ carry=est; /* likely quotient [99%] */ if (*c>3)*16777)>>21; *c=(Unit)(carry-est*(DECDPUNMAX+1)); carry=est-(DECDPUNMAX+1); /* correctly negative */ if (*c=0) { est=QUOT10(carry, DECDPUN); *c=(Unit)(carry-est*(DECDPUNMAX+1)); /* remainder */ carry=est; /* quotient */ continue; } /* negative case */ carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); /* make positive */ est=QUOT10(carry, DECDPUN); *c=(Unit)(carry-est*(DECDPUNMAX+1)); carry=est-(DECDPUNMAX+1); /* correctly negative */ #else if ((ueInt)carry<(DECDPUNMAX+1)*2){ /* fastpath carry 1 */ *c=(Unit)(carry-(DECDPUNMAX+1)); carry=1; continue; } /* remainder operator is undefined if negative, so must test */ if (carry>=0) { *c=(Unit)(carry%(DECDPUNMAX+1)); carry=carry/(DECDPUNMAX+1); continue; } /* negative case */ carry=carry+(eInt)(DECDPUNMAX+1)*(DECDPUNMAX+1); /* make positive */ *c=(Unit)(carry%(DECDPUNMAX+1)); carry=carry/(DECDPUNMAX+1)-(DECDPUNMAX+1); #endif } /* c */ /* OK, all A and B processed; might still have carry or borrow */ /* return number of Units in the result, negated if a borrow */ if (carry==0) return c-clsu; /* no carry, so no more to do */ if (carry>0) { /* positive carry */ *c=(Unit)carry; /* place as new unit */ c++; /* .. */ return c-clsu; } /* -ve carry: it's a borrow; complement needed */ add=1; /* temporary carry... */ for (c=clsu; c current Unit */ #if DECCHECK if (decCheckOperands(dn, DECUNUSED, DECUNUSED, DECUNCONT)) return dn; #endif *dropped=0; /* assume no zeros dropped */ if ((dn->bits & DECSPECIAL) /* fast exit if special .. */ || (*dn->lsu & 0x01)) return dn; /* .. or odd */ if (ISZERO(dn)) { /* .. or 0 */ dn->exponent=0; /* (sign is preserved) */ return dn; } /* have a finite number which is even */ exp=dn->exponent; cut=1; /* digit (1-DECDPUN) in Unit */ up=dn->lsu; /* -> current Unit */ for (d=0; ddigits-1; d++) { /* [don't strip the final digit] */ /* slice by powers */ #if DECDPUN<=4 uInt quot=QUOT10(*up, cut); if ((*up-quot*powers[cut])!=0) break; /* found non-0 digit */ #else if (*up%powers[cut]!=0) break; /* found non-0 digit */ #endif /* have a trailing 0 */ if (!all) { /* trimming */ /* [if exp>0 then all trailing 0s are significant for trim] */ if (exp<=0) { /* if digit might be significant */ if (exp==0) break; /* then quit */ exp++; /* next digit might be significant */ } } cut++; /* next power */ if (cut>DECDPUN) { /* need new Unit */ up++; cut=1; } } /* d */ if (d==0) return dn; /* none to drop */ /* may need to limit drop if clamping */ if (set->clamp && !noclamp) { Int maxd=set->emax-set->digits+1-dn->exponent; if (maxd<=0) return dn; /* nothing possible */ if (d>maxd) d=maxd; } /* effect the drop */ decShiftToLeast(dn->lsu, D2U(dn->digits), d); dn->exponent+=d; /* maintain numerical value */ dn->digits-=d; /* new length */ *dropped=d; /* report the count */ return dn; } /* decTrim */ /* ------------------------------------------------------------------ */ /* decReverse -- reverse a Unit array in place */ /* */ /* ulo is the start of the array */ /* uhi is the end of the array (highest Unit to include) */ /* */ /* The units ulo through uhi are reversed in place (if the number */ /* of units is odd, the middle one is untouched). Note that the */ /* digit(s) in each unit are unaffected. */ /* ------------------------------------------------------------------ */ static void decReverse(Unit *ulo, Unit *uhi) { Unit temp; for (; ulo=uar; source--, target--) *target=*source; } else { first=uar+D2U(digits+shift)-1; /* where msu of source will end up */ for (; source>=uar; source--, target--) { /* split the source Unit and accumulate remainder for next */ #if DECDPUN<=4 uInt quot=QUOT10(*source, cut); uInt rem=*source-quot*powers[cut]; next+=quot; #else uInt rem=*source%powers[cut]; next+=*source/powers[cut]; #endif if (target<=first) *target=(Unit)next; /* write to target iff valid */ next=rem*powers[DECDPUN-cut]; /* save remainder for next Unit */ } } /* shift-move */ /* propagate any partial unit to one below and clear the rest */ for (; target>=uar; target--) { *target=(Unit)next; next=0; } return digits+shift; } /* decShiftToMost */ /* ------------------------------------------------------------------ */ /* decShiftToLeast -- shift digits in array towards least significant */ /* */ /* uar is the array */ /* units is length of the array, in units */ /* shift is the number of digits to remove from the lsu end; it */ /* must be zero or positive and <= than units*DECDPUN. */ /* */ /* returns the new length of the integer in the array, in units */ /* */ /* Removed digits are discarded (lost). Units not required to hold */ /* the final result are unchanged. */ /* ------------------------------------------------------------------ */ static Int decShiftToLeast(Unit *uar, Int units, Int shift) { Unit *target, *up; /* work */ Int cut, count; /* work */ Int quot, rem; /* for division */ if (shift==0) return units; /* [fastpath] nothing to do */ if (shift==units*DECDPUN) { /* [fastpath] little to do */ *uar=0; /* all digits cleared gives zero */ return 1; /* leaves just the one */ } target=uar; /* both paths */ cut=MSUDIGITS(shift); if (cut==DECDPUN) { /* unit-boundary case; easy */ up=uar+D2U(shift); for (; updigits is > set->digits) */ /* set is the relevant context */ /* status is the status accumulator */ /* */ /* returns an allocated decNumber with the rounded result. */ /* */ /* lostDigits and other status may be set by this. */ /* */ /* Since the input is an operand, it must not be modified. */ /* Instead, return an allocated decNumber, rounded as required. */ /* It is the caller's responsibility to free the allocated storage. */ /* */ /* If no storage is available then the result cannot be used, so NULL */ /* is returned. */ /* ------------------------------------------------------------------ */ static decNumber *decRoundOperand(const decNumber *dn, decContext *set, uInt *status) { decNumber *res; /* result structure */ uInt newstatus=0; /* status from round */ Int residue=0; /* rounding accumulator */ /* Allocate storage for the returned decNumber, big enough for the */ /* length specified by the context */ res=(decNumber *)malloc(sizeof(decNumber) +(D2U(set->digits)-1)*sizeof(Unit)); if (res==NULL) { *status|=DEC_Insufficient_storage; return NULL; } decCopyFit(res, dn, set, &residue, &newstatus); decApplyRound(res, set, residue, &newstatus); /* If that set Inexact then "lost digits" is raised... */ if (newstatus & DEC_Inexact) newstatus|=DEC_Lost_digits; *status|=newstatus; return res; } /* decRoundOperand */ #endif /* ------------------------------------------------------------------ */ /* decCopyFit -- copy a number, truncating the coefficient if needed */ /* */ /* dest is the target decNumber */ /* src is the source decNumber */ /* set is the context [used for length (digits) and rounding mode] */ /* residue is the residue accumulator */ /* status contains the current status to be updated */ /* */ /* (dest==src is allowed and will be a no-op if fits) */ /* All fields are updated as required. */ /* ------------------------------------------------------------------ */ static void decCopyFit(decNumber *dest, const decNumber *src, decContext *set, Int *residue, uInt *status) { dest->bits=src->bits; dest->exponent=src->exponent; decSetCoeff(dest, set, src->lsu, src->digits, residue, status); } /* decCopyFit */ /* ------------------------------------------------------------------ */ /* decSetCoeff -- set the coefficient of a number */ /* */ /* dn is the number whose coefficient array is to be set. */ /* It must have space for set->digits digits */ /* set is the context [for size] */ /* lsu -> lsu of the source coefficient [may be dn->lsu] */ /* len is digits in the source coefficient [may be dn->digits] */ /* residue is the residue accumulator. This has values as in */ /* decApplyRound, and will be unchanged unless the */ /* target size is less than len. In this case, the */ /* coefficient is truncated and the residue is updated to */ /* reflect the previous residue and the dropped digits. */ /* status is the status accumulator, as usual */ /* */ /* The coefficient may already be in the number, or it can be an */ /* external intermediate array. If it is in the number, lsu must == */ /* dn->lsu and len must == dn->digits. */ /* */ /* Note that the coefficient length (len) may be < set->digits, and */ /* in this case this merely copies the coefficient (or is a no-op */ /* if dn->lsu==lsu). */ /* */ /* Note also that (only internally, from decQuantizeOp and */ /* decSetSubnormal) the value of set->digits may be less than one, */ /* indicating a round to left. This routine handles that case */ /* correctly; caller ensures space. */ /* */ /* dn->digits, dn->lsu (and as required), and dn->exponent are */ /* updated as necessary. dn->bits (sign) is unchanged. */ /* */ /* DEC_Rounded status is set if any digits are discarded. */ /* DEC_Inexact status is set if any non-zero digits are discarded, or */ /* incoming residue was non-0 (implies rounded) */ /* ------------------------------------------------------------------ */ /* mapping array: maps 0-9 to canonical residues, so that a residue */ /* can be adjusted in the range [-1, +1] and achieve correct rounding */ /* 0 1 2 3 4 5 6 7 8 9 */ static const uByte resmap[10]={0, 3, 3, 3, 3, 5, 7, 7, 7, 7}; static void decSetCoeff(decNumber *dn, decContext *set, const Unit *lsu, Int len, Int *residue, uInt *status) { Int discard; /* number of digits to discard */ uInt cut; /* cut point in Unit */ const Unit *up; /* work */ Unit *target; /* .. */ Int count; /* .. */ #if DECDPUN<=4 uInt temp; /* .. */ #endif discard=len-set->digits; /* digits to discard */ if (discard<=0) { /* no digits are being discarded */ if (dn->lsu!=lsu) { /* copy needed */ /* copy the coefficient array to the result number; no shift needed */ count=len; /* avoids D2U */ up=lsu; for (target=dn->lsu; count>0; target++, up++, count-=DECDPUN) *target=*up; dn->digits=len; /* set the new length */ } /* dn->exponent and residue are unchanged, record any inexactitude */ if (*residue!=0) *status|=(DEC_Inexact | DEC_Rounded); return; } /* some digits must be discarded ... */ dn->exponent+=discard; /* maintain numerical value */ *status|=DEC_Rounded; /* accumulate Rounded status */ if (*residue>1) *residue=1; /* previous residue now to right, so reduce */ if (discard>len) { /* everything, +1, is being discarded */ /* guard digit is 0 */ /* residue is all the number [NB could be all 0s] */ if (*residue<=0) { /* not already positive */ count=len; /* avoids D2U */ for (up=lsu; count>0; up++, count-=DECDPUN) if (*up!=0) { /* found non-0 */ *residue=1; break; /* no need to check any others */ } } if (*residue!=0) *status|=DEC_Inexact; /* record inexactitude */ *dn->lsu=0; /* coefficient will now be 0 */ dn->digits=1; /* .. */ return; } /* total discard */ /* partial discard [most common case] */ /* here, at least the first (most significant) discarded digit exists */ /* spin up the number, noting residue during the spin, until get to */ /* the Unit with the first discarded digit. When reach it, extract */ /* it and remember its position */ count=0; for (up=lsu;; up++) { count+=DECDPUN; if (count>=discard) break; /* full ones all checked */ if (*up!=0) *residue=1; } /* up */ /* here up -> Unit with first discarded digit */ cut=discard-(count-DECDPUN)-1; if (cut==DECDPUN-1) { /* unit-boundary case (fast) */ Unit half=(Unit)powers[DECDPUN]>>1; /* set residue directly */ if (*up>=half) { if (*up>half) *residue=7; else *residue+=5; /* add sticky bit */ } else { /* digits<=0) { /* special for Quantize/Subnormal :-( */ *dn->lsu=0; /* .. result is 0 */ dn->digits=1; /* .. */ } else { /* shift to least */ count=set->digits; /* now digits to end up with */ dn->digits=count; /* set the new length */ up++; /* move to next */ /* on unit boundary, so shift-down copy loop is simple */ for (target=dn->lsu; count>0; target++, up++, count-=DECDPUN) *target=*up; } } /* unit-boundary case */ else { /* discard digit is in low digit(s), and not top digit */ uInt discard1; /* first discarded digit */ uInt quot, rem; /* for divisions */ if (cut==0) quot=*up; /* is at bottom of unit */ else /* cut>0 */ { /* it's not at bottom of unit */ #if DECDPUN<=4 quot=QUOT10(*up, cut); rem=*up-quot*powers[cut]; #else rem=*up%powers[cut]; quot=*up/powers[cut]; #endif if (rem!=0) *residue=1; } /* discard digit is now at bottom of quot */ #if DECDPUN<=4 temp=(quot*6554)>>16; /* fast /10 */ /* Vowels algorithm here not a win (9 instructions) */ discard1=quot-X10(temp); quot=temp; #else discard1=quot%10; quot=quot/10; #endif /* here, discard1 is the guard digit, and residue is everything */ /* else [use mapping array to accumulate residue safely] */ *residue+=resmap[discard1]; cut++; /* update cut */ /* here: up -> Unit of the array with bottom digit */ /* cut is the division point for each Unit */ /* quot holds the uncut high-order digits for the current unit */ if (set->digits<=0) { /* special for Quantize/Subnormal :-( */ *dn->lsu=0; /* .. result is 0 */ dn->digits=1; /* .. */ } else { /* shift to least needed */ count=set->digits; /* now digits to end up with */ dn->digits=count; /* set the new length */ /* shift-copy the coefficient array to the result number */ for (target=dn->lsu; ; target++) { *target=(Unit)quot; count-=(DECDPUN-cut); if (count<=0) break; up++; quot=*up; #if DECDPUN<=4 quot=QUOT10(quot, cut); rem=*up-quot*powers[cut]; #else rem=quot%powers[cut]; quot=quot/powers[cut]; #endif *target=(Unit)(*target+rem*powers[DECDPUN-cut]); count-=cut; if (count<=0) break; } /* shift-copy loop */ } /* shift to least */ } /* not unit boundary */ if (*residue!=0) *status|=DEC_Inexact; /* record inexactitude */ return; } /* decSetCoeff */ /* ------------------------------------------------------------------ */ /* decApplyRound -- apply pending rounding to a number */ /* */ /* dn is the number, with space for set->digits digits */ /* set is the context [for size and rounding mode] */ /* residue indicates pending rounding, being any accumulated */ /* guard and sticky information. It may be: */ /* 6-9: rounding digit is >5 */ /* 5: rounding digit is exactly half-way */ /* 1-4: rounding digit is <5 and >0 */ /* 0: the coefficient is exact */ /* -1: as 1, but the hidden digits are subtractive, that */ /* is, of the opposite sign to dn. In this case the */ /* coefficient must be non-0. This case occurs when */ /* subtracting a small number (which can be reduced to */ /* a sticky bit); see decAddOp. */ /* status is the status accumulator, as usual */ /* */ /* This routine applies rounding while keeping the length of the */ /* coefficient constant. The exponent and status are unchanged */ /* except if: */ /* */ /* -- the coefficient was increased and is all nines (in which */ /* case Overflow could occur, and is handled directly here so */ /* the caller does not need to re-test for overflow) */ /* */ /* -- the coefficient was decreased and becomes all nines (in which */ /* case Underflow could occur, and is also handled directly). */ /* */ /* All fields in dn are updated as required. */ /* */ /* ------------------------------------------------------------------ */ static void decApplyRound(decNumber *dn, decContext *set, Int residue, uInt *status) { Int bump; /* 1 if coefficient needs to be incremented */ /* -1 if coefficient needs to be decremented */ if (residue==0) return; /* nothing to apply */ bump=0; /* assume a smooth ride */ /* now decide whether, and how, to round, depending on mode */ switch (set->round) { case DEC_ROUND_05UP: { /* round zero or five up (for reround) */ /* This is the same as DEC_ROUND_DOWN unless there is a */ /* positive residue and the lsd of dn is 0 or 5, in which case */ /* it is bumped; when residue is <0, the number is therefore */ /* bumped down unless the final digit was 1 or 6 (in which */ /* case it is bumped down and then up -- a no-op) */ Int lsd5=*dn->lsu%5; /* get lsd and quintate */ if (residue<0 && lsd5!=1) bump=-1; else if (residue>0 && lsd5==0) bump=1; /* [bump==1 could be applied directly; use common path for clarity] */ break;} /* r-05 */ case DEC_ROUND_DOWN: { /* no change, except if negative residue */ if (residue<0) bump=-1; break;} /* r-d */ case DEC_ROUND_HALF_DOWN: { if (residue>5) bump=1; break;} /* r-h-d */ case DEC_ROUND_HALF_EVEN: { if (residue>5) bump=1; /* >0.5 goes up */ else if (residue==5) { /* exactly 0.5000... */ /* 0.5 goes up iff [new] lsd is odd */ if (*dn->lsu & 0x01) bump=1; } break;} /* r-h-e */ case DEC_ROUND_HALF_UP: { if (residue>=5) bump=1; break;} /* r-h-u */ case DEC_ROUND_UP: { if (residue>0) bump=1; break;} /* r-u */ case DEC_ROUND_CEILING: { /* same as _UP for positive numbers, and as _DOWN for negatives */ /* [negative residue cannot occur on 0] */ if (decNumberIsNegative(dn)) { if (residue<0) bump=-1; } else { if (residue>0) bump=1; } break;} /* r-c */ case DEC_ROUND_FLOOR: { /* same as _UP for negative numbers, and as _DOWN for positive */ /* [negative residue cannot occur on 0] */ if (!decNumberIsNegative(dn)) { if (residue<0) bump=-1; } else { if (residue>0) bump=1; } break;} /* r-f */ default: { /* e.g., DEC_ROUND_MAX */ *status|=DEC_Invalid_context; #if DECTRACE || (DECCHECK && DECVERB) printf("Unknown rounding mode: %d\n", set->round); #endif break;} } /* switch */ /* now bump the number, up or down, if need be */ if (bump==0) return; /* no action required */ /* Simply use decUnitAddSub unless bumping up and the number is */ /* all nines. In this special case set to 100... explicitly */ /* and adjust the exponent by one (as otherwise could overflow */ /* the array) */ /* Similarly handle all-nines result if bumping down. */ if (bump>0) { Unit *up; /* work */ uInt count=dn->digits; /* digits to be checked */ for (up=dn->lsu; ; up++) { if (count<=DECDPUN) { /* this is the last Unit (the msu) */ if (*up!=powers[count]-1) break; /* not still 9s */ /* here if it, too, is all nines */ *up=(Unit)powers[count-1]; /* here 999 -> 100 etc. */ for (up=up-1; up>=dn->lsu; up--) *up=0; /* others all to 0 */ dn->exponent++; /* and bump exponent */ /* [which, very rarely, could cause Overflow...] */ if ((dn->exponent+dn->digits)>set->emax+1) { decSetOverflow(dn, set, status); } return; /* done */ } /* a full unit to check, with more to come */ if (*up!=DECDPUNMAX) break; /* not still 9s */ count-=DECDPUN; } /* up */ } /* bump>0 */ else { /* -1 */ /* here checking for a pre-bump of 1000... (leading 1, all */ /* other digits zero) */ Unit *up, *sup; /* work */ uInt count=dn->digits; /* digits to be checked */ for (up=dn->lsu; ; up++) { if (count<=DECDPUN) { /* this is the last Unit (the msu) */ if (*up!=powers[count-1]) break; /* not 100.. */ /* here if have the 1000... case */ sup=up; /* save msu pointer */ *up=(Unit)powers[count]-1; /* here 100 in msu -> 999 */ /* others all to all-nines, too */ for (up=up-1; up>=dn->lsu; up--) *up=(Unit)powers[DECDPUN]-1; dn->exponent--; /* and bump exponent */ /* iff the number was at the subnormal boundary (exponent=etiny) */ /* then the exponent is now out of range, so it will in fact get */ /* clamped to etiny and the final 9 dropped. */ /* printf(">> emin=%d exp=%d sdig=%d\n", set->emin, */ /* dn->exponent, set->digits); */ if (dn->exponent+1==set->emin-set->digits+1) { if (count==1 && dn->digits==1) *sup=0; /* here 9 -> 0[.9] */ else { *sup=(Unit)powers[count-1]-1; /* here 999.. in msu -> 99.. */ dn->digits--; } dn->exponent++; *status|=DEC_Underflow | DEC_Subnormal | DEC_Inexact | DEC_Rounded; } return; /* done */ } /* a full unit to check, with more to come */ if (*up!=0) break; /* not still 0s */ count-=DECDPUN; } /* up */ } /* bump<0 */ /* Actual bump needed. Do it. */ decUnitAddSub(dn->lsu, D2U(dn->digits), uarrone, 1, 0, dn->lsu, bump); } /* decApplyRound */ #if DECSUBSET /* ------------------------------------------------------------------ */ /* decFinish -- finish processing a number */ /* */ /* dn is the number */ /* set is the context */ /* residue is the rounding accumulator (as in decApplyRound) */ /* status is the accumulator */ /* */ /* This finishes off the current number by: */ /* 1. If not extended: */ /* a. Converting a zero result to clean '0' */ /* b. Reducing positive exponents to 0, if would fit in digits */ /* 2. Checking for overflow and subnormals (always) */ /* Note this is just Finalize when no subset arithmetic. */ /* All fields are updated as required. */ /* ------------------------------------------------------------------ */ static void decFinish(decNumber *dn, decContext *set, Int *residue, uInt *status) { if (!set->extended) { if ISZERO(dn) { /* value is zero */ dn->exponent=0; /* clean exponent .. */ dn->bits=0; /* .. and sign */ return; /* no error possible */ } if (dn->exponent>=0) { /* non-negative exponent */ /* >0; reduce to integer if possible */ if (set->digits >= (dn->exponent+dn->digits)) { dn->digits=decShiftToMost(dn->lsu, dn->digits, dn->exponent); dn->exponent=0; } } } /* !extended */ decFinalize(dn, set, residue, status); } /* decFinish */ #endif /* ------------------------------------------------------------------ */ /* decFinalize -- final check, clamp, and round of a number */ /* */ /* dn is the number */ /* set is the context */ /* residue is the rounding accumulator (as in decApplyRound) */ /* status is the status accumulator */ /* */ /* This finishes off the current number by checking for subnormal */ /* results, applying any pending rounding, checking for overflow, */ /* and applying any clamping. */ /* Underflow and overflow conditions are raised as appropriate. */ /* All fields are updated as required. */ /* ------------------------------------------------------------------ */ static void decFinalize(decNumber *dn, decContext *set, Int *residue, uInt *status) { Int shift; /* shift needed if clamping */ Int tinyexp=set->emin-dn->digits+1; /* precalculate subnormal boundary */ /* Must be careful, here, when checking the exponent as the */ /* adjusted exponent could overflow 31 bits [because it may already */ /* be up to twice the expected]. */ /* First test for subnormal. This must be done before any final */ /* round as the result could be rounded to Nmin or 0. */ if (dn->exponent<=tinyexp) { /* prefilter */ Int comp; decNumber nmin; /* A very nasty case here is dn == Nmin and residue<0 */ if (dn->exponentemin; comp=decCompare(dn, &nmin, 1); /* (signless compare) */ if (comp==BADINT) { /* oops */ *status|=DEC_Insufficient_storage; /* abandon... */ return; } if (*residue<0 && comp==0) { /* neg residue and dn==Nmin */ decApplyRound(dn, set, *residue, status); /* might force down */ decSetSubnormal(dn, set, residue, status); return; } } /* now apply any pending round (this could raise overflow). */ if (*residue!=0) decApplyRound(dn, set, *residue, status); /* Check for overflow [redundant in the 'rare' case] or clamp */ if (dn->exponent<=set->emax-set->digits+1) return; /* neither needed */ /* here when might have an overflow or clamp to do */ if (dn->exponent>set->emax-dn->digits+1) { /* too big */ decSetOverflow(dn, set, status); return; } /* here when the result is normal but in clamp range */ if (!set->clamp) return; /* here when need to apply the IEEE exponent clamp (fold-down) */ shift=dn->exponent-(set->emax-set->digits+1); /* shift coefficient (if non-zero) */ if (!ISZERO(dn)) { dn->digits=decShiftToMost(dn->lsu, dn->digits, shift); } dn->exponent-=shift; /* adjust the exponent to match */ *status|=DEC_Clamped; /* and record the dirty deed */ return; } /* decFinalize */ /* ------------------------------------------------------------------ */ /* decSetOverflow -- set number to proper overflow value */ /* */ /* dn is the number (used for sign [only] and result) */ /* set is the context [used for the rounding mode, etc.] */ /* status contains the current status to be updated */ /* */ /* This sets the sign of a number and sets its value to either */ /* Infinity or the maximum finite value, depending on the sign of */ /* dn and the rounding mode, following IEEE 754 rules. */ /* ------------------------------------------------------------------ */ static void decSetOverflow(decNumber *dn, decContext *set, uInt *status) { Flag needmax=0; /* result is maximum finite value */ uByte sign=dn->bits&DECNEG; /* clean and save sign bit */ if (ISZERO(dn)) { /* zero does not overflow magnitude */ Int emax=set->emax; /* limit value */ if (set->clamp) emax-=set->digits-1; /* lower if clamping */ if (dn->exponent>emax) { /* clamp required */ dn->exponent=emax; *status|=DEC_Clamped; } return; } decNumberZero(dn); switch (set->round) { case DEC_ROUND_DOWN: { needmax=1; /* never Infinity */ break;} /* r-d */ case DEC_ROUND_05UP: { needmax=1; /* never Infinity */ break;} /* r-05 */ case DEC_ROUND_CEILING: { if (sign) needmax=1; /* Infinity if non-negative */ break;} /* r-c */ case DEC_ROUND_FLOOR: { if (!sign) needmax=1; /* Infinity if negative */ break;} /* r-f */ default: break; /* Infinity in all other cases */ } if (needmax) { decSetMaxValue(dn, set); dn->bits=sign; /* set sign */ } else dn->bits=sign|DECINF; /* Value is +/-Infinity */ *status|=DEC_Overflow | DEC_Inexact | DEC_Rounded; } /* decSetOverflow */ /* ------------------------------------------------------------------ */ /* decSetMaxValue -- set number to +Nmax (maximum normal value) */ /* */ /* dn is the number to set */ /* set is the context [used for digits and emax] */ /* */ /* This sets the number to the maximum positive value. */ /* ------------------------------------------------------------------ */ static void decSetMaxValue(decNumber *dn, decContext *set) { Unit *up; /* work */ Int count=set->digits; /* nines to add */ dn->digits=count; /* fill in all nines to set maximum value */ for (up=dn->lsu; ; up++) { if (count>DECDPUN) *up=DECDPUNMAX; /* unit full o'nines */ else { /* this is the msu */ *up=(Unit)(powers[count]-1); break; } count-=DECDPUN; /* filled those digits */ } /* up */ dn->bits=0; /* + sign */ dn->exponent=set->emax-set->digits+1; } /* decSetMaxValue */ /* ------------------------------------------------------------------ */ /* decSetSubnormal -- process value whose exponent is extended) { decNumberZero(dn); /* always full overflow */ *status|=DEC_Underflow | DEC_Subnormal | DEC_Inexact | DEC_Rounded; return; } #endif /* Full arithmetic -- allow subnormals, rounded to minimum exponent */ /* (Etiny) if needed */ etiny=set->emin-(set->digits-1); /* smallest allowed exponent */ if ISZERO(dn) { /* value is zero */ /* residue can never be non-zero here */ #if DECCHECK if (*residue!=0) { printf("++ Subnormal 0 residue %ld\n", (LI)*residue); *status|=DEC_Invalid_operation; } #endif if (dn->exponentexponent=etiny; *status|=DEC_Clamped; } return; } *status|=DEC_Subnormal; /* have a non-zero subnormal */ adjust=etiny-dn->exponent; /* calculate digits to remove */ if (adjust<=0) { /* not out of range; unrounded */ /* residue can never be non-zero here, except in the Nmin-residue */ /* case (which is a subnormal result), so can take fast-path here */ /* it may already be inexact (from setting the coefficient) */ if (*status&DEC_Inexact) *status|=DEC_Underflow; return; } /* adjust>0, so need to rescale the result so exponent becomes Etiny */ /* [this code is similar to that in rescale] */ workset=*set; /* clone rounding, etc. */ workset.digits=dn->digits-adjust; /* set requested length */ workset.emin-=adjust; /* and adjust emin to match */ /* [note that the latter can be <1, here, similar to Rescale case] */ decSetCoeff(dn, &workset, dn->lsu, dn->digits, residue, status); decApplyRound(dn, &workset, *residue, status); /* Use 754 default rule: Underflow is set iff Inexact */ /* [independent of whether trapped] */ if (*status&DEC_Inexact) *status|=DEC_Underflow; /* if rounded up a 999s case, exponent will be off by one; adjust */ /* back if so [it will fit, because it was shortened earlier] */ if (dn->exponent>etiny) { dn->digits=decShiftToMost(dn->lsu, dn->digits, 1); dn->exponent--; /* (re)adjust the exponent. */ } /* if rounded to zero, it is by definition clamped... */ if (ISZERO(dn)) *status|=DEC_Clamped; } /* decSetSubnormal */ /* ------------------------------------------------------------------ */ /* decCheckMath - check entry conditions for a math function */ /* */ /* This checks the context and the operand */ /* */ /* rhs is the operand to check */ /* set is the context to check */ /* status is unchanged if both are good */ /* */ /* returns non-zero if status is changed, 0 otherwise */ /* */ /* Restrictions enforced: */ /* */ /* digits, emax, and -emin in the context must be less than */ /* DEC_MAX_MATH (999999), and A must be within these bounds if */ /* non-zero. Invalid_operation is set in the status if a */ /* restriction is violated. */ /* ------------------------------------------------------------------ */ static uInt decCheckMath(const decNumber *rhs, decContext *set, uInt *status) { uInt save=*status; /* record */ if (set->digits>DEC_MAX_MATH || set->emax>DEC_MAX_MATH || -set->emin>DEC_MAX_MATH) *status|=DEC_Invalid_context; else if ((rhs->digits>DEC_MAX_MATH || rhs->exponent+rhs->digits>DEC_MAX_MATH+1 || rhs->exponent+rhs->digits<2*(1-DEC_MAX_MATH)) && !ISZERO(rhs)) *status|=DEC_Invalid_operation; return (*status!=save); } /* decCheckMath */ /* ------------------------------------------------------------------ */ /* decGetInt -- get integer from a number */ /* */ /* dn is the number [which will not be altered] */ /* */ /* returns one of: */ /* BADINT if there is a non-zero fraction */ /* the converted integer */ /* BIGEVEN if the integer is even and magnitude > 2*10**9 */ /* BIGODD if the integer is odd and magnitude > 2*10**9 */ /* */ /* This checks and gets a whole number from the input decNumber. */ /* The sign can be determined from dn by the caller when BIGEVEN or */ /* BIGODD is returned. */ /* ------------------------------------------------------------------ */ static Int decGetInt(const decNumber *dn) { Int theInt; /* result accumulator */ const Unit *up; /* work */ Int got; /* digits (real or not) processed */ Int ilength=dn->digits+dn->exponent; /* integral length */ Flag neg=decNumberIsNegative(dn); /* 1 if -ve */ /* The number must be an integer that fits in 10 digits */ /* Assert, here, that 10 is enough for any rescale Etiny */ #if DEC_MAX_EMAX > 999999999 #error GetInt may need updating [for Emax] #endif #if DEC_MIN_EMIN < -999999999 #error GetInt may need updating [for Emin] #endif if (ISZERO(dn)) return 0; /* zeros are OK, with any exponent */ up=dn->lsu; /* ready for lsu */ theInt=0; /* ready to accumulate */ if (dn->exponent>=0) { /* relatively easy */ /* no fractional part [usual]; allow for positive exponent */ got=dn->exponent; } else { /* -ve exponent; some fractional part to check and discard */ Int count=-dn->exponent; /* digits to discard */ /* spin up whole units until reach the Unit with the unit digit */ for (; count>=DECDPUN; up++) { if (*up!=0) return BADINT; /* non-zero Unit to discard */ count-=DECDPUN; } if (count==0) got=0; /* [a multiple of DECDPUN] */ else { /* [not multiple of DECDPUN] */ Int rem; /* work */ /* slice off fraction digits and check for non-zero */ #if DECDPUN<=4 theInt=QUOT10(*up, count); rem=*up-theInt*powers[count]; #else rem=*up%powers[count]; /* slice off discards */ theInt=*up/powers[count]; #endif if (rem!=0) return BADINT; /* non-zero fraction */ /* it looks good */ got=DECDPUN-count; /* number of digits so far */ up++; /* ready for next */ } } /* now it's known there's no fractional part */ /* tricky code now, to accumulate up to 9.3 digits */ if (got==0) {theInt=*up; got+=DECDPUN; up++;} /* ensure lsu is there */ if (ilength<10) { Int save=theInt; /* collect any remaining unit(s) */ for (; got1999999997) ilength=11; else if (!neg && theInt>999999999) ilength=11; if (ilength==11) theInt=save; /* restore correct low bit */ } } if (ilength>10) { /* too big */ if (theInt&1) return BIGODD; /* bottom bit 1 */ return BIGEVEN; /* bottom bit 0 */ } if (neg) theInt=-theInt; /* apply sign */ return theInt; } /* decGetInt */ /* ------------------------------------------------------------------ */ /* decDecap -- decapitate the coefficient of a number */ /* */ /* dn is the number to be decapitated */ /* drop is the number of digits to be removed from the left of dn; */ /* this must be <= dn->digits (if equal, the coefficient is */ /* set to 0) */ /* */ /* Returns dn; dn->digits will be <= the initial digits less drop */ /* (after removing drop digits there may be leading zero digits */ /* which will also be removed). Only dn->lsu and dn->digits change. */ /* ------------------------------------------------------------------ */ static decNumber *decDecap(decNumber *dn, Int drop) { Unit *msu; /* -> target cut point */ Int cut; /* work */ if (drop>=dn->digits) { /* losing the whole thing */ #if DECCHECK if (drop>dn->digits) printf("decDecap called with drop>digits [%ld>%ld]\n", (LI)drop, (LI)dn->digits); #endif dn->lsu[0]=0; dn->digits=1; return dn; } msu=dn->lsu+D2U(dn->digits-drop)-1; /* -> likely msu */ cut=MSUDIGITS(dn->digits-drop); /* digits to be in use in msu */ if (cut!=DECDPUN) *msu%=powers[cut]; /* clear left digits */ /* that may have left leading zero digits, so do a proper count... */ dn->digits=decGetDigits(dn->lsu, msu-dn->lsu+1); return dn; } /* decDecap */ /* ------------------------------------------------------------------ */ /* decBiStr -- compare string with pairwise options */ /* */ /* targ is the string to compare */ /* str1 is one of the strings to compare against (length may be 0) */ /* str2 is the other; it must be the same length as str1 */ /* */ /* returns 1 if strings compare equal, (that is, it is the same */ /* length as str1 and str2, and each character of targ is in either */ /* str1 or str2 in the corresponding position), or 0 otherwise */ /* */ /* This is used for generic caseless compare, including the awkward */ /* case of the Turkish dotted and dotless Is. Use as (for example): */ /* if (decBiStr(test, "mike", "MIKE")) ... */ /* ------------------------------------------------------------------ */ static Flag decBiStr(const char *targ, const char *str1, const char *str2) { for (;;targ++, str1++, str2++) { if (*targ!=*str1 && *targ!=*str2) return 0; /* *targ has a match in one (or both, if terminator) */ if (*targ=='\0') break; } /* forever */ return 1; } /* decBiStr */ /* ------------------------------------------------------------------ */ /* decNaNs -- handle NaN operand or operands */ /* */ /* res is the result number */ /* lhs is the first operand */ /* rhs is the second operand, or NULL if none */ /* context is used to limit payload length */ /* status contains the current status */ /* returns res in case convenient */ /* */ /* Called when one or both operands is a NaN, and propagates the */ /* appropriate result to res. When an sNaN is found, it is changed */ /* to a qNaN and Invalid operation is set. */ /* ------------------------------------------------------------------ */ static decNumber * decNaNs(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set, uInt *status) { /* This decision tree ends up with LHS being the source pointer, */ /* and status updated if need be */ if (lhs->bits & DECSNAN) *status|=DEC_Invalid_operation | DEC_sNaN; else if (rhs==NULL); else if (rhs->bits & DECSNAN) { lhs=rhs; *status|=DEC_Invalid_operation | DEC_sNaN; } else if (lhs->bits & DECNAN); else lhs=rhs; /* propagate the payload */ if (lhs->digits<=set->digits) decNumberCopy(res, lhs); /* easy */ else { /* too long */ const Unit *ul; Unit *ur, *uresp1; /* copy safe number of units, then decapitate */ res->bits=lhs->bits; /* need sign etc. */ uresp1=res->lsu+D2U(set->digits); for (ur=res->lsu, ul=lhs->lsu; urdigits=D2U(set->digits)*DECDPUN; /* maybe still too long */ if (res->digits>set->digits) decDecap(res, res->digits-set->digits); } res->bits&=~DECSNAN; /* convert any sNaN to NaN, while */ res->bits|=DECNAN; /* .. preserving sign */ res->exponent=0; /* clean exponent */ /* [coefficient was copied/decapitated] */ return res; } /* decNaNs */ /* ------------------------------------------------------------------ */ /* decStatus -- apply non-zero status */ /* */ /* dn is the number to set if error */ /* status contains the current status (not yet in context) */ /* set is the context */ /* */ /* If the status is an error status, the number is set to a NaN, */ /* unless the error was an overflow, divide-by-zero, or underflow, */ /* in which case the number will have already been set. */ /* */ /* The context status is then updated with the new status. Note that */ /* this may raise a signal, so control may never return from this */ /* routine (hence resources must be recovered before it is called). */ /* ------------------------------------------------------------------ */ static void decStatus(decNumber *dn, uInt status, decContext *set) { if (status & DEC_NaNs) { /* error status -> NaN */ /* if cause was an sNaN, clear and propagate [NaN is already set up] */ if (status & DEC_sNaN) status&=~DEC_sNaN; else { decNumberZero(dn); /* other error: clean throughout */ dn->bits=DECNAN; /* and make a quiet NaN */ } } decContextSetStatus(set, status); /* [may not return] */ return; } /* decStatus */ /* ------------------------------------------------------------------ */ /* decGetDigits -- count digits in a Units array */ /* */ /* uar is the Unit array holding the number (this is often an */ /* accumulator of some sort) */ /* len is the length of the array in units [>=1] */ /* */ /* returns the number of (significant) digits in the array */ /* */ /* All leading zeros are excluded, except the last if the array has */ /* only zero Units. */ /* ------------------------------------------------------------------ */ /* This may be called twice during some operations. */ static Int decGetDigits(Unit *uar, Int len) { Unit *up=uar+(len-1); /* -> msu */ Int digits=(len-1)*DECDPUN+1; /* possible digits excluding msu */ #if DECDPUN>4 uInt const *pow; /* work */ #endif /* (at least 1 in final msu) */ #if DECCHECK if (len<1) printf("decGetDigits called with len<1 [%ld]\n", (LI)len); #endif for (; up>=uar; up--) { if (*up==0) { /* unit is all 0s */ if (digits==1) break; /* a zero has one digit */ digits-=DECDPUN; /* adjust for 0 unit */ continue;} /* found the first (most significant) non-zero Unit */ #if DECDPUN>1 /* not done yet */ if (*up<10) break; /* is 1-9 */ digits++; #if DECDPUN>2 /* not done yet */ if (*up<100) break; /* is 10-99 */ digits++; #if DECDPUN>3 /* not done yet */ if (*up<1000) break; /* is 100-999 */ digits++; #if DECDPUN>4 /* count the rest ... */ for (pow=&powers[4]; *up>=*pow; pow++) digits++; #endif #endif #endif #endif break; } /* up */ return digits; } /* decGetDigits */ #if DECTRACE || DECCHECK /* ------------------------------------------------------------------ */ /* decDumpAr -- display a unit array [debug/check aid] */ /* name is a single-character tag name */ /* ar is the array to display */ /* len is the length of the array in Units */ /* ------------------------------------------------------------------ */ static void decDumpAr(char name, const Unit *ar, Int len) { Int i; const char *spec; #if DECDPUN==9 spec="%09d "; #elif DECDPUN==8 spec="%08d "; #elif DECDPUN==7 spec="%07d "; #elif DECDPUN==6 spec="%06d "; #elif DECDPUN==5 spec="%05d "; #elif DECDPUN==4 spec="%04d "; #elif DECDPUN==3 spec="%03d "; #elif DECDPUN==2 spec="%02d "; #else spec="%d "; #endif printf(" :%c: ", name); for (i=len-1; i>=0; i--) { if (i==len-1) printf("%ld ", (LI)ar[i]); else printf(spec, ar[i]); } printf("\n"); return;} #endif #if DECCHECK /* ------------------------------------------------------------------ */ /* decCheckOperands -- check operand(s) to a routine */ /* res is the result structure (not checked; it will be set to */ /* quiet NaN if error found (and it is not NULL)) */ /* lhs is the first operand (may be DECUNRESU) */ /* rhs is the second (may be DECUNUSED) */ /* set is the context (may be DECUNCONT) */ /* returns 0 if both operands, and the context are clean, or 1 */ /* otherwise (in which case the context will show an error, */ /* unless NULL). Note that res is not cleaned; caller should */ /* handle this so res=NULL case is safe. */ /* The caller is expected to abandon immediately if 1 is returned. */ /* ------------------------------------------------------------------ */ static Flag decCheckOperands(decNumber *res, const decNumber *lhs, const decNumber *rhs, decContext *set) { Flag bad=0; if (set==NULL) { /* oops; hopeless */ #if DECTRACE || DECVERB printf("Reference to context is NULL.\n"); #endif bad=1; return 1;} else if (set!=DECUNCONT && (set->digits<1 || set->round>=DEC_ROUND_MAX)) { bad=1; #if DECTRACE || DECVERB printf("Bad context [digits=%ld round=%ld].\n", (LI)set->digits, (LI)set->round); #endif } else { if (res==NULL) { bad=1; #if DECTRACE /* this one not DECVERB as standard tests include NULL */ printf("Reference to result is NULL.\n"); #endif } if (!bad && lhs!=DECUNUSED) bad=(decCheckNumber(lhs)); if (!bad && rhs!=DECUNUSED) bad=(decCheckNumber(rhs)); } if (bad) { if (set!=DECUNCONT) decContextSetStatus(set, DEC_Invalid_operation); if (res!=DECUNRESU && res!=NULL) { decNumberZero(res); res->bits=DECNAN; /* qNaN */ } } return bad; } /* decCheckOperands */ /* ------------------------------------------------------------------ */ /* decCheckNumber -- check a number */ /* dn is the number to check */ /* returns 0 if the number is clean, or 1 otherwise */ /* */ /* The number is considered valid if it could be a result from some */ /* operation in some valid context. */ /* ------------------------------------------------------------------ */ static Flag decCheckNumber(const decNumber *dn) { const Unit *up; /* work */ uInt maxuint; /* .. */ Int ae, d, digits; /* .. */ Int emin, emax; /* .. */ if (dn==NULL) { /* hopeless */ #if DECTRACE /* this one not DECVERB as standard tests include NULL */ printf("Reference to decNumber is NULL.\n"); #endif return 1;} /* check special values */ if (dn->bits & DECSPECIAL) { if (dn->exponent!=0) { #if DECTRACE || DECVERB printf("Exponent %ld (not 0) for a special value [%02x].\n", (LI)dn->exponent, dn->bits); #endif return 1;} /* 2003.09.08: NaNs may now have coefficients, so next tests Inf only */ if (decNumberIsInfinite(dn)) { if (dn->digits!=1) { #if DECTRACE || DECVERB printf("Digits %ld (not 1) for an infinity.\n", (LI)dn->digits); #endif return 1;} if (*dn->lsu!=0) { #if DECTRACE || DECVERB printf("LSU %ld (not 0) for an infinity.\n", (LI)*dn->lsu); #endif decDumpAr('I', dn->lsu, D2U(dn->digits)); return 1;} } /* Inf */ /* 2002.12.26: negative NaNs can now appear through proposed IEEE */ /* concrete formats (decimal64, etc.). */ return 0; } /* check the coefficient */ if (dn->digits<1 || dn->digits>DECNUMMAXP) { #if DECTRACE || DECVERB printf("Digits %ld in number.\n", (LI)dn->digits); #endif return 1;} d=dn->digits; for (up=dn->lsu; d>0; up++) { if (d>DECDPUN) maxuint=DECDPUNMAX; else { /* reached the msu */ maxuint=powers[d]-1; if (dn->digits>1 && *upmaxuint) { #if DECTRACE || DECVERB printf("Bad Unit [%08lx] in %ld-digit number at offset %ld [maxuint %ld].\n", (LI)*up, (LI)dn->digits, (LI)(up-dn->lsu), (LI)maxuint); #endif return 1;} d-=DECDPUN; } /* check the exponent. Note that input operands can have exponents */ /* which are out of the set->emin/set->emax and set->digits range */ /* (just as they can have more digits than set->digits). */ ae=dn->exponent+dn->digits-1; /* adjusted exponent */ emax=DECNUMMAXE; emin=DECNUMMINE; digits=DECNUMMAXP; if (ae+emax) { #if DECTRACE || DECVERB printf("Adjusted exponent overflow [%ld].\n", (LI)ae); decNumberShow(dn); #endif return 1;} return 0; /* it's OK */ } /* decCheckNumber */ /* ------------------------------------------------------------------ */ /* decCheckInexact -- check a normal finite inexact result has digits */ /* dn is the number to check */ /* set is the context (for status and precision) */ /* sets Invalid operation, etc., if some digits are missing */ /* [this check is not made for DECSUBSET compilation or when */ /* subnormal is not set] */ /* ------------------------------------------------------------------ */ static void decCheckInexact(const decNumber *dn, decContext *set) { #if !DECSUBSET && DECEXTFLAG if ((set->status & (DEC_Inexact|DEC_Subnormal))==DEC_Inexact && (set->digits!=dn->digits) && !(dn->bits & DECSPECIAL)) { #if DECTRACE || DECVERB printf("Insufficient digits [%ld] on normal Inexact result.\n", (LI)dn->digits); decNumberShow(dn); #endif decContextSetStatus(set, DEC_Invalid_operation); } #else /* next is a noop for quiet compiler */ if (dn!=NULL && dn->digits==0) set->status|=DEC_Invalid_operation; #endif return; } /* decCheckInexact */ #endif #if DECALLOC #undef malloc #undef free /* ------------------------------------------------------------------ */ /* decMalloc -- accountable allocation routine */ /* n is the number of bytes to allocate */ /* */ /* Semantics is the same as the stdlib malloc routine, but bytes */ /* allocated are accounted for globally, and corruption fences are */ /* added before and after the 'actual' storage. */ /* ------------------------------------------------------------------ */ /* This routine allocates storage with an extra twelve bytes; 8 are */ /* at the start and hold: */ /* 0-3 the original length requested */ /* 4-7 buffer corruption detection fence (DECFENCE, x4) */ /* The 4 bytes at the end also hold a corruption fence (DECFENCE, x4) */ /* ------------------------------------------------------------------ */ static void *decMalloc(size_t n) { uInt size=n+12; /* true size */ void *alloc; /* -> allocated storage */ uByte *b, *b0; /* work */ uInt uiwork; /* for macros */ alloc=malloc(size); /* -> allocated storage */ if (alloc==NULL) return NULL; /* out of strorage */ b0=(uByte *)alloc; /* as bytes */ decAllocBytes+=n; /* account for storage */ UBFROMUI(alloc, n); /* save n */ /* printf(" alloc ++ dAB: %ld (%ld)\n", (LI)decAllocBytes, (LI)n); */ for (b=b0+4; b play area */ } /* decMalloc */ /* ------------------------------------------------------------------ */ /* decFree -- accountable free routine */ /* alloc is the storage to free */ /* */ /* Semantics is the same as the stdlib malloc routine, except that */ /* the global storage accounting is updated and the fences are */ /* checked to ensure that no routine has written 'out of bounds'. */ /* ------------------------------------------------------------------ */ /* This routine first checks that the fences have not been corrupted. */ /* It then frees the storage using the 'truw' storage address (that */ /* is, offset by 8). */ /* ------------------------------------------------------------------ */ static void decFree(void *alloc) { uInt n; /* original length */ uByte *b, *b0; /* work */ uInt uiwork; /* for macros */ if (alloc==NULL) return; /* allowed; it's a nop */ b0=(uByte *)alloc; /* as bytes */ b0-=8; /* -> true start of storage */ n=UBTOUI(b0); /* lift length */ for (b=b0+4; b. */ /* ------------------------------------------------------------------ */ /* Decimal Number arithmetic module header */ /* ------------------------------------------------------------------ */ #if !defined(DECNUMBER) #define DECNUMBER #define DECNAME "decNumber" /* Short name */ #define DECFULLNAME "Decimal Number Module" /* Verbose name */ #define DECAUTHOR "Mike Cowlishaw" /* Who to blame */ #if !defined(DECCONTEXT) #include "decContext.h" #endif /* Bit settings for decNumber.bits */ #define DECNEG 0x80 /* Sign; 1=negative, 0=positive or zero */ #define DECINF 0x40 /* 1=Infinity */ #define DECNAN 0x20 /* 1=NaN */ #define DECSNAN 0x10 /* 1=sNaN */ /* The remaining bits are reserved; they must be 0 */ #define DECSPECIAL (DECINF|DECNAN|DECSNAN) /* any special value */ /* Define the decNumber data structure. The size and shape of the */ /* units array in the structure is determined by the following */ /* constant. This must not be changed without recompiling the */ /* decNumber library modules. */ #define DECDPUN 3 /* DECimal Digits Per UNit [must be >0 */ /* and <10; 3 or powers of 2 are best]. */ /* DECNUMDIGITS is the default number of digits that can be held in */ /* the structure. If undefined, 1 is assumed and it is assumed */ /* that the structure will be immediately followed by extra space, */ /* as required. DECNUMDIGITS is always >0. */ #if !defined(DECNUMDIGITS) #define DECNUMDIGITS 1 #endif /* The size (integer data type) of each unit is determined by the */ /* number of digits it will hold. */ #if DECDPUN<=2 #define decNumberUnit uint8_t #elif DECDPUN<=4 #define decNumberUnit uint16_t #else #define decNumberUnit uint32_t #endif /* The number of units needed is ceil(DECNUMDIGITS/DECDPUN) */ #define DECNUMUNITS ((DECNUMDIGITS+DECDPUN-1)/DECDPUN) /* The data structure... */ typedef struct { int32_t digits; /* Count of digits in the coefficient; >0 */ int32_t exponent; /* Unadjusted exponent, unbiased, in */ /* range: -1999999997 through 999999999 */ uint8_t bits; /* Indicator bits (see above) */ /* Coefficient, from least significant unit */ decNumberUnit lsu[DECNUMUNITS]; } decNumber; /* Notes: */ /* 1. If digits is > DECDPUN then there will one or more */ /* decNumberUnits immediately following the first element of lsu.*/ /* These contain the remaining (more significant) digits of the */ /* number, and may be in the lsu array, or may be guaranteed by */ /* some other mechanism (such as being contained in another */ /* structure, or being overlaid on dynamically allocated */ /* storage). */ /* */ /* Each integer of the coefficient (except potentially the last) */ /* contains DECDPUN digits (e.g., a value in the range 0 through */ /* 99999999 if DECDPUN is 8, or 0 through 999 if DECDPUN is 3). */ /* */ /* 2. A decNumber converted to a string may need up to digits+14 */ /* characters. The worst cases (non-exponential and exponential */ /* formats) are -0.00000{9...}# and -9.{9...}E+999999999# */ /* (where # is '\0') */ /* ---------------------------------------------------------------- */ /* decNumber public functions and macros */ /* ---------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif /* Conversions */ decNumber * decNumberFromInt32(decNumber *, int32_t); decNumber * decNumberFromUInt32(decNumber *, uint32_t); decNumber * decNumberFromString(decNumber *, const char *, decContext *); char * decNumberToString(const decNumber *, char *); char * decNumberToEngString(const decNumber *, char *); uint32_t decNumberToUInt32(const decNumber *, decContext *); int32_t decNumberToInt32(const decNumber *, decContext *); uint8_t * decNumberGetBCD(const decNumber *, uint8_t *); decNumber * decNumberSetBCD(decNumber *, const uint8_t *, uint32_t); /* Operators and elementary functions */ decNumber * decNumberAbs(decNumber *, const decNumber *, decContext *); decNumber * decNumberAdd(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberAnd(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberCompare(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberCompareSignal(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberCompareTotal(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberCompareTotalMag(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberDivide(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberDivideInteger(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberExp(decNumber *, const decNumber *, decContext *); decNumber * decNumberFMA(decNumber *, const decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberInvert(decNumber *, const decNumber *, decContext *); decNumber * decNumberLn(decNumber *, const decNumber *, decContext *); decNumber * decNumberLogB(decNumber *, const decNumber *, decContext *); decNumber * decNumberLog10(decNumber *, const decNumber *, decContext *); decNumber * decNumberMax(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberMaxMag(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberMin(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberMinMag(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberMinus(decNumber *, const decNumber *, decContext *); decNumber * decNumberMultiply(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberNormalize(decNumber *, const decNumber *, decContext *); decNumber * decNumberOr(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberPlus(decNumber *, const decNumber *, decContext *); decNumber * decNumberPower(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberQuantize(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberReduce(decNumber *, const decNumber *, decContext *); decNumber * decNumberRemainder(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberRemainderNear(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberRescale(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberRotate(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberSameQuantum(decNumber *, const decNumber *, const decNumber *); decNumber * decNumberScaleB(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberShift(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberSquareRoot(decNumber *, const decNumber *, decContext *); decNumber * decNumberSubtract(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberToIntegralExact(decNumber *, const decNumber *, decContext *); decNumber * decNumberToIntegralValue(decNumber *, const decNumber *, decContext *); decNumber * decNumberXor(decNumber *, const decNumber *, const decNumber *, decContext *); /* Utilities */ enum decClass decNumberClass(const decNumber *, decContext *); const char * decNumberClassToString(enum decClass); decNumber * decNumberCopy(decNumber *, const decNumber *); decNumber * decNumberCopyAbs(decNumber *, const decNumber *); decNumber * decNumberCopyNegate(decNumber *, const decNumber *); decNumber * decNumberCopySign(decNumber *, const decNumber *, const decNumber *); decNumber * decNumberNextMinus(decNumber *, const decNumber *, decContext *); decNumber * decNumberNextPlus(decNumber *, const decNumber *, decContext *); decNumber * decNumberNextToward(decNumber *, const decNumber *, const decNumber *, decContext *); decNumber * decNumberTrim(decNumber *); const char * decNumberVersion(void); decNumber * decNumberZero(decNumber *); /* Functions for testing decNumbers (normality depends on context) */ int32_t decNumberIsNormal(const decNumber *, decContext *); int32_t decNumberIsSubnormal(const decNumber *, decContext *); /* Macros for testing decNumber *dn */ #define decNumberIsCanonical(dn) (1) /* All decNumbers are saintly */ #define decNumberIsFinite(dn) (((dn)->bits&DECSPECIAL)==0) #define decNumberIsInfinite(dn) (((dn)->bits&DECINF)!=0) #define decNumberIsNaN(dn) (((dn)->bits&(DECNAN|DECSNAN))!=0) #define decNumberIsNegative(dn) (((dn)->bits&DECNEG)!=0) #define decNumberIsQNaN(dn) (((dn)->bits&(DECNAN))!=0) #define decNumberIsSNaN(dn) (((dn)->bits&(DECSNAN))!=0) #define decNumberIsSpecial(dn) (((dn)->bits&DECSPECIAL)!=0) #define decNumberIsZero(dn) (*(dn)->lsu==0 \ && (dn)->digits==1 \ && (((dn)->bits&DECSPECIAL)==0)) #define decNumberRadix(dn) (10) #ifdef __cplusplus } #endif #endif libdfp-1.0.12/libdecnumber/decNumberLocal.h000066400000000000000000001023051261375163000205230ustar00rootroot00000000000000/* Local definitions for the decNumber C Library. Copyright (C) 2007-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------ */ /* decNumber package local type, tuning, and macro definitions */ /* ------------------------------------------------------------------ */ /* This header file is included by all modules in the decNumber */ /* library, and contains local type definitions, tuning parameters, */ /* etc. It should not need to be used by application programs. */ /* decNumber.h or one of decDouble (etc.) must be included first. */ /* ------------------------------------------------------------------ */ #if !defined(DECNUMBERLOC) #define DECNUMBERLOC #define DECVERSION "decNumber 3.61" /* Package Version [16 max.] */ #define DECNLAUTHOR "Mike Cowlishaw" /* Who to blame */ #include /* for abs */ #include /* for memset, strcpy */ #include "dconfig.h" /* for WORDS_BIGENDIAN */ /* Conditional code flag -- set this to match hardware platform */ /* 1=little-endian, 0=big-endian */ #if WORDS_BIGENDIAN #define DECLITEND 0 #else #define DECLITEND 1 #endif #if !defined(DECLITEND) #define DECLITEND 1 /* 1=little-endian, 0=big-endian */ #endif /* Conditional code flag -- set this to 1 for best performance */ #if !defined(DECUSE64) #define DECUSE64 1 /* 1=use int64s, 0=int32 & smaller only */ #endif /*#define DECUSE128 1*/ /* 1=use int128s */ /* Conditional check flags -- set these to 0 for best performance */ #if !defined(DECCHECK) #define DECCHECK 0 /* 1 to enable robust checking */ #endif #if !defined(DECALLOC) #define DECALLOC 0 /* 1 to enable memory accounting */ #endif #if !defined(DECTRACE) #define DECTRACE 0 /* 1 to trace certain internals, etc. */ #endif /* Tuning parameter for decNumber (arbitrary precision) module */ #if !defined(DECBUFFER) #define DECBUFFER 36 /* Size basis for local buffers. This */ /* should be a common maximum precision */ /* rounded up to a multiple of 4; must */ /* be zero or positive. */ #endif /* ---------------------------------------------------------------- */ /* Definitions for all modules (general-purpose) */ /* ---------------------------------------------------------------- */ /* Local names for common types -- for safety, decNumber modules do */ /* not use int or long directly. */ #define Flag uint8_t #define Byte int8_t #define uByte uint8_t #define Short int16_t #define uShort uint16_t #define Int int32_t #define uInt uint32_t #define Unit decNumberUnit #if DECUSE64 #define Long int64_t #define uLong uint64_t #endif #if DECUSE128 #include "decUInt128.h" #endif /* Development-use definitions */ typedef long int LI; /* for printf arguments only */ #define DECNOINT 0 /* 1 to check no internal use of 'int' */ /* or stdint types */ #if DECNOINT /* if these interfere with your C includes, do not set DECNOINT */ #define int ? /* enable to ensure that plain C 'int' */ #define long ?? /* .. or 'long' types are not used */ #endif /* Shared lookup tables */ extern const uByte DECSTICKYTAB[10]; /* re-round digits if sticky */ extern const uInt DECPOWERS[10]; /* powers of ten table */ /* The following are included from decDPD.h */ extern const uShort DPD2BIN[1024]; /* DPD -> 0-999 */ extern const uShort BIN2DPD[1000]; /* 0-999 -> DPD */ extern const uInt DPD2BINK[1024]; /* DPD -> 0-999000 */ extern const uInt DPD2BINM[1024]; /* DPD -> 0-999000000 */ extern const uByte DPD2BCD8[4096]; /* DPD -> ddd + len */ extern const uByte BIN2BCD8[4000]; /* 0-999 -> ddd + len */ extern const uShort BCD2DPD[2458]; /* 0-0x999 -> DPD (0x999=2457)*/ /* LONGMUL32HI -- set w=(u*v)>>32, where w, u, and v are uInts */ /* (that is, sets w to be the high-order word of the 64-bit result; */ /* the low-order word is simply u*v.) */ /* This version is derived from Knuth via Hacker's Delight; */ /* it seems to optimize better than some others tried */ #define LONGMUL32HI(w, u, v) { \ uInt u0, u1, v0, v1, w0, w1, w2, t; \ u0=u & 0xffff; u1=u>>16; \ v0=v & 0xffff; v1=v>>16; \ w0=u0*v0; \ t=u1*v0 + (w0>>16); \ w1=t & 0xffff; w2=t>>16; \ w1=u0*v1 + w1; \ (w)=u1*v1 + w2 + (w1>>16);} /* ROUNDUP -- round an integer up to a multiple of n */ #define ROUNDUP(i, n) ((((i)+(n)-1)/n)*n) #define ROUNDUP4(i) (((i)+3)&~3) /* special for n=4 */ /* ROUNDDOWN -- round an integer down to a multiple of n */ #define ROUNDDOWN(i, n) (((i)/n)*n) #define ROUNDDOWN4(i) ((i)&~3) /* special for n=4 */ /* References to multi-byte sequences under different sizes; these */ /* require locally declared variables, but do not violate strict */ /* aliasing or alignment (as did the UINTAT simple cast to uInt). */ /* Variables needed are uswork, uiwork, etc. [so do not use at same */ /* level in an expression, e.g., UBTOUI(x)==UBTOUI(y) may fail]. */ #if DECLITEND==1 # define BSWAP16(x) (__builtin_bswap16 (x)) # define BSWAP32(x) (__builtin_bswap32 (x)) #else # define BSWAP16(x) (x) # define BSWAP32(x) (x) #endif /* Return a uInt, etc., from bytes starting at a char* or uByte* */ #define UBTOUS(b) (memcpy((void *)&uswork, b, 2), uswork) #define UBTOUI(b) (memcpy((void *)&uiwork, b, 4), uiwork) /* Return a uInt, etc., from bytes starting at a char* or uByte* */ /* Byte swap if necessary. */ #define UBTOUSBW(b) (memcpy((void *)&uswork, b, 2), BSWAP16 (uswork)) #define UBTOUIBW(b) (memcpy((void *)&uiwork, b, 4), BSWAP32 (uiwork)) /* Store a uInt, etc., into bytes starting at a char* or uByte*. */ /* Has to use uiwork because i may be an expression. */ #define UBFROMUS(b, i) (uswork=(i), memcpy(b, (void *)&uswork, 2)) #define UBFROMUI(b, i) (uiwork=(i), memcpy(b, (void *)&uiwork, 4)) /* Store a uInt, etc., into bytes starting at a char* or uByte*. */ /* Byte swap if necessary. */ /* Has to use uiwork because i may be an expression. */ #define UBFROMUSBW(b, i) (uswork= BSWAP16 (i), memcpy(b, (void *)&uswork, 2)) #define UBFROMUIBW(b, i) (uiwork= BSWAP32 (i), memcpy(b, (void *)&uiwork, 4)) /* X10 and X100 -- multiply integer i by 10 or 100 */ /* [shifts are usually faster than multiply; could be conditional] */ #define X10(i) (((i)<<1)+((i)<<3)) #define X100(i) (((i)<<2)+((i)<<5)+((i)<<6)) /* MAXI and MINI -- general max & min (not in ANSI) for integers */ #define MAXI(x,y) ((x)<(y)?(y):(x)) #define MINI(x,y) ((x)>(y)?(y):(x)) /* Useful constants */ #define BILLION 1000000000 /* 10**9 */ /* CHARMASK: 0x30303030 for ASCII/UTF8; 0xF0F0F0F0 for EBCDIC */ #define CHARMASK ((((((((uInt)'0')<<8)+'0')<<8)+'0')<<8)+'0') /* ---------------------------------------------------------------- */ /* Definitions for arbitary-precision modules (only valid after */ /* decNumber.h has been included) */ /* ---------------------------------------------------------------- */ /* Limits and constants */ #define DECNUMMAXP 999999999 /* maximum precision code can handle */ #define DECNUMMAXE 999999999 /* maximum adjusted exponent ditto */ #define DECNUMMINE -999999999 /* minimum adjusted exponent ditto */ #if (DECNUMMAXP != DEC_MAX_DIGITS) #error Maximum digits mismatch #endif #if (DECNUMMAXE != DEC_MAX_EMAX) #error Maximum exponent mismatch #endif #if (DECNUMMINE != DEC_MIN_EMIN) #error Minimum exponent mismatch #endif /* Set DECDPUNMAX -- the maximum integer that fits in DECDPUN */ /* digits, and D2UTABLE -- the initializer for the D2U table */ #if DECDPUN==1 #define DECDPUNMAX 9 #define D2UTABLE {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17, \ 18,19,20,21,22,23,24,25,26,27,28,29,30,31,32, \ 33,34,35,36,37,38,39,40,41,42,43,44,45,46,47, \ 48,49} #elif DECDPUN==2 #define DECDPUNMAX 99 #define D2UTABLE {0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10, \ 11,11,12,12,13,13,14,14,15,15,16,16,17,17,18, \ 18,19,19,20,20,21,21,22,22,23,23,24,24,25} #elif DECDPUN==3 #define DECDPUNMAX 999 #define D2UTABLE {0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7, \ 8,8,8,9,9,9,10,10,10,11,11,11,12,12,12,13,13, \ 13,14,14,14,15,15,15,16,16,16,17} #elif DECDPUN==4 #define DECDPUNMAX 9999 #define D2UTABLE {0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6, \ 6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,11, \ 11,11,11,12,12,12,12,13} #elif DECDPUN==5 #define DECDPUNMAX 99999 #define D2UTABLE {0,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5, \ 5,5,5,5,6,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9,9, \ 9,9,10,10,10,10} #elif DECDPUN==6 #define DECDPUNMAX 999999 #define D2UTABLE {0,1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,4,4,4, \ 4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,7,7,7,7,7,7,8, \ 8,8,8,8,8,9} #elif DECDPUN==7 #define DECDPUNMAX 9999999 #define D2UTABLE {0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3, \ 4,4,4,4,4,4,4,5,5,5,5,5,5,5,6,6,6,6,6,6,6,7, \ 7,7,7,7,7,7} #elif DECDPUN==8 #define DECDPUNMAX 99999999 #define D2UTABLE {0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3, \ 3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6, \ 6,6,6,6,6,7} #elif DECDPUN==9 #define DECDPUNMAX 999999999 #define D2UTABLE {0,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,3,3,3, \ 3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5, \ 5,5,6,6,6,6} #elif defined(DECDPUN) #error DECDPUN must be in the range 1-9 #endif /* ----- Shared data (in decNumber.c) ----- */ /* Public lookup table used by the D2U macro (see below) */ #define DECMAXD2U 49 extern const uByte d2utable[DECMAXD2U+1]; /* ----- Macros ----- */ /* ISZERO -- return true if decNumber dn is a zero */ /* [performance-critical in some situations] */ #define ISZERO(dn) decNumberIsZero(dn) /* now just a local name */ /* D2U -- return the number of Units needed to hold d digits */ /* (runtime version, with table lookaside for small d) */ #if DECDPUN==8 #define D2U(d) ((unsigned)((d)<=DECMAXD2U?d2utable[d]:((d)+7)>>3)) #elif DECDPUN==4 #define D2U(d) ((unsigned)((d)<=DECMAXD2U?d2utable[d]:((d)+3)>>2)) #else #define D2U(d) ((d)<=DECMAXD2U?d2utable[d]:((d)+DECDPUN-1)/DECDPUN) #endif /* SD2U -- static D2U macro (for compile-time calculation) */ #define SD2U(d) (((d)+DECDPUN-1)/DECDPUN) /* MSUDIGITS -- returns digits in msu, from digits, calculated */ /* using D2U */ #define MSUDIGITS(d) ((d)-(D2U(d)-1)*DECDPUN) /* D2N -- return the number of decNumber structs that would be */ /* needed to contain that number of digits (and the initial */ /* decNumber struct) safely. Note that one Unit is included in the */ /* initial structure. Used for allocating space that is aligned on */ /* a decNumber struct boundary. */ #define D2N(d) \ ((((SD2U(d)-1)*sizeof(Unit))+sizeof(decNumber)*2-1)/sizeof(decNumber)) /* TODIGIT -- macro to remove the leading digit from the unsigned */ /* integer u at column cut (counting from the right, LSD=0) and */ /* place it as an ASCII character into the character pointed to by */ /* c. Note that cut must be <= 9, and the maximum value for u is */ /* 2,000,000,000 (as is needed for negative exponents of */ /* subnormals). The unsigned integer pow is used as a temporary */ /* variable. */ #define TODIGIT(u, cut, c, pow) { \ *(c)='0'; \ pow=DECPOWERS[cut]*2; \ if ((u)>pow) { \ pow*=4; \ if ((u)>=pow) {(u)-=pow; *(c)+=8;} \ pow/=2; \ if ((u)>=pow) {(u)-=pow; *(c)+=4;} \ pow/=2; \ } \ if ((u)>=pow) {(u)-=pow; *(c)+=2;} \ pow/=2; \ if ((u)>=pow) {(u)-=pow; *(c)+=1;} \ } /* ---------------------------------------------------------------- */ /* Definitions for fixed-precision modules (only valid after */ /* decSingle.h, decDouble.h, or decQuad.h has been included) */ /* ---------------------------------------------------------------- */ /* bcdnum -- a structure describing a format-independent finite */ /* number, whose coefficient is a string of bcd8 uBytes */ typedef struct { uByte *msd; /* -> most significant digit */ uByte *lsd; /* -> least ditto */ uInt sign; /* 0=positive, DECFLOAT_Sign=negative */ Int exponent; /* Unadjusted signed exponent (q), or */ /* DECFLOAT_NaN etc. for a special */ } bcdnum; /* Test if exponent or bcdnum exponent must be a special, etc. */ #define EXPISSPECIAL(exp) ((exp)>=DECFLOAT_MinSp) #define EXPISINF(exp) (exp==DECFLOAT_Inf) #define EXPISNAN(exp) (exp==DECFLOAT_qNaN || exp==DECFLOAT_sNaN) #define NUMISSPECIAL(num) (EXPISSPECIAL((num)->exponent)) /* Refer to a 32-bit word or byte in a decFloat (df) by big-endian */ /* (array) notation (the 0 word or byte contains the sign bit), */ /* automatically adjusting for endianness; similarly address a word */ /* in the next-wider format (decFloatWider, or dfw) */ #define DECWORDS (DECBYTES/4) #define DECWWORDS (DECWBYTES/4) #if DECLITEND #define DFBYTE(df, off) ((df)->bytes[DECBYTES-1-(off)]) #define DFWORD(df, off) ((df)->words[DECWORDS-1-(off)]) #define DFWWORD(dfw, off) ((dfw)->words[DECWWORDS-1-(off)]) #else #define DFBYTE(df, off) ((df)->bytes[off]) #define DFWORD(df, off) ((df)->words[off]) #define DFWWORD(dfw, off) ((dfw)->words[off]) #endif /* Tests for sign or specials, directly on DECFLOATs */ #define DFISSIGNED(df) (DFWORD(df, 0)&0x80000000) #define DFISSPECIAL(df) ((DFWORD(df, 0)&0x78000000)==0x78000000) #define DFISINF(df) ((DFWORD(df, 0)&0x7c000000)==0x78000000) #define DFISNAN(df) ((DFWORD(df, 0)&0x7c000000)==0x7c000000) #define DFISQNAN(df) ((DFWORD(df, 0)&0x7e000000)==0x7c000000) #define DFISSNAN(df) ((DFWORD(df, 0)&0x7e000000)==0x7e000000) /* Shared lookup tables */ extern const uInt DECCOMBMSD[64]; /* Combination field -> MSD */ extern const uInt DECCOMBFROM[48]; /* exp+msd -> Combination */ /* Private generic (utility) routine */ #if DECCHECK || DECTRACE extern void decShowNum(const bcdnum *, const char *); #endif /* Format-dependent macros and constants */ #if defined(DECPMAX) /* Useful constants */ #define DECPMAX9 (ROUNDUP(DECPMAX, 9)/9) /* 'Pmax' in 10**9s */ /* Top words for a zero */ #define SINGLEZERO 0x22500000 #define DOUBLEZERO 0x22380000 #define QUADZERO 0x22080000 /* [ZEROWORD is defined to be one of these in the DFISZERO macro] */ /* Format-dependent common tests: */ /* DFISZERO -- test for (any) zero */ /* DFISCCZERO -- test for coefficient continuation being zero */ /* DFISCC01 -- test for coefficient contains only 0s and 1s */ /* DFISINT -- test for finite and exponent q=0 */ /* DFISUINT01 -- test for sign=0, finite, exponent q=0, and */ /* MSD=0 or 1 */ /* ZEROWORD is also defined here. */ /* In DFISZERO the first test checks the least-significant word */ /* (most likely to be non-zero); the penultimate tests MSD and */ /* DPDs in the signword, and the final test excludes specials and */ /* MSD>7. DFISINT similarly has to allow for the two forms of */ /* MSD codes. DFISUINT01 only has to allow for one form of MSD */ /* code. */ #if DECPMAX==7 #define ZEROWORD SINGLEZERO /* [test macros not needed except for Zero] */ #define DFISZERO(df) ((DFWORD(df, 0)&0x1c0fffff)==0 \ && (DFWORD(df, 0)&0x60000000)!=0x60000000) #elif DECPMAX==16 #define ZEROWORD DOUBLEZERO #define DFISZERO(df) ((DFWORD(df, 1)==0 \ && (DFWORD(df, 0)&0x1c03ffff)==0 \ && (DFWORD(df, 0)&0x60000000)!=0x60000000)) #define DFISINT(df) ((DFWORD(df, 0)&0x63fc0000)==0x22380000 \ ||(DFWORD(df, 0)&0x7bfc0000)==0x6a380000) #define DFISUINT01(df) ((DFWORD(df, 0)&0xfbfc0000)==0x22380000) #define DFISCCZERO(df) (DFWORD(df, 1)==0 \ && (DFWORD(df, 0)&0x0003ffff)==0) #define DFISCC01(df) ((DFWORD(df, 0)&~0xfffc9124)==0 \ && (DFWORD(df, 1)&~0x49124491)==0) #elif DECPMAX==34 #define ZEROWORD QUADZERO #define DFISZERO(df) ((DFWORD(df, 3)==0 \ && DFWORD(df, 2)==0 \ && DFWORD(df, 1)==0 \ && (DFWORD(df, 0)&0x1c003fff)==0 \ && (DFWORD(df, 0)&0x60000000)!=0x60000000)) #define DFISINT(df) ((DFWORD(df, 0)&0x63ffc000)==0x22080000 \ ||(DFWORD(df, 0)&0x7bffc000)==0x6a080000) #define DFISUINT01(df) ((DFWORD(df, 0)&0xfbffc000)==0x22080000) #define DFISCCZERO(df) (DFWORD(df, 3)==0 \ && DFWORD(df, 2)==0 \ && DFWORD(df, 1)==0 \ && (DFWORD(df, 0)&0x00003fff)==0) #define DFISCC01(df) ((DFWORD(df, 0)&~0xffffc912)==0 \ && (DFWORD(df, 1)&~0x44912449)==0 \ && (DFWORD(df, 2)&~0x12449124)==0 \ && (DFWORD(df, 3)&~0x49124491)==0) #endif /* Macros to test if a certain 10 bits of a uInt or pair of uInts */ /* are a canonical declet [higher or lower bits are ignored]. */ /* declet is at offset 0 (from the right) in a uInt: */ #define CANONDPD(dpd) (((dpd)&0x300)==0 || ((dpd)&0x6e)!=0x6e) /* declet is at offset k (a multiple of 2) in a uInt: */ #define CANONDPDOFF(dpd, k) (((dpd)&(0x300<<(k)))==0 \ || ((dpd)&(((uInt)0x6e)<<(k)))!=(((uInt)0x6e)<<(k))) /* declet is at offset k (a multiple of 2) in a pair of uInts: */ /* [the top 2 bits will always be in the more-significant uInt] */ #define CANONDPDTWO(hi, lo, k) (((hi)&(0x300>>(32-(k))))==0 \ || ((hi)&(0x6e>>(32-(k))))!=(0x6e>>(32-(k))) \ || ((lo)&(((uInt)0x6e)<<(k)))!=(((uInt)0x6e)<<(k))) /* Macro to test whether a full-length (length DECPMAX) BCD8 */ /* coefficient, starting at uByte u, is all zeros */ /* Test just the LSWord first, then the remainder as a sequence */ /* of tests in order to avoid same-level use of UBTOUI */ #if DECPMAX==7 #define ISCOEFFZERO(u) ( \ UBTOUI((u)+DECPMAX-4)==0 \ && UBTOUS((u)+DECPMAX-6)==0 \ && *(u)==0) #elif DECPMAX==16 #define ISCOEFFZERO(u) ( \ UBTOUI((u)+DECPMAX-4)==0 \ && UBTOUI((u)+DECPMAX-8)==0 \ && UBTOUI((u)+DECPMAX-12)==0 \ && UBTOUI(u)==0) #elif DECPMAX==34 #define ISCOEFFZERO(u) ( \ UBTOUI((u)+DECPMAX-4)==0 \ && UBTOUI((u)+DECPMAX-8)==0 \ && UBTOUI((u)+DECPMAX-12)==0 \ && UBTOUI((u)+DECPMAX-16)==0 \ && UBTOUI((u)+DECPMAX-20)==0 \ && UBTOUI((u)+DECPMAX-24)==0 \ && UBTOUI((u)+DECPMAX-28)==0 \ && UBTOUI((u)+DECPMAX-32)==0 \ && UBTOUS(u)==0) #endif /* Macros and masks for the exponent continuation field and MSD */ /* Get the exponent continuation from a decFloat *df as an Int */ #define GETECON(df) ((Int)((DFWORD((df), 0)&0x03ffffff)>>(32-6-DECECONL))) /* Ditto, from the next-wider format */ #define GETWECON(df) ((Int)((DFWWORD((df), 0)&0x03ffffff)>>(32-6-DECWECONL))) /* Get the biased exponent similarly */ #define GETEXP(df) ((Int)(DECCOMBEXP[DFWORD((df), 0)>>26]+GETECON(df))) /* Get the unbiased exponent similarly */ #define GETEXPUN(df) ((Int)GETEXP(df)-DECBIAS) /* Get the MSD similarly (as uInt) */ #define GETMSD(df) (DECCOMBMSD[DFWORD((df), 0)>>26]) /* Compile-time computes of the exponent continuation field masks */ /* full exponent continuation field: */ #define ECONMASK ((0x03ffffff>>(32-6-DECECONL))<<(32-6-DECECONL)) /* same, not including its first digit (the qNaN/sNaN selector): */ #define ECONNANMASK ((0x01ffffff>>(32-6-DECECONL))<<(32-6-DECECONL)) /* Macros to decode the coefficient in a finite decFloat *df into */ /* a BCD string (uByte *bcdin) of length DECPMAX uBytes. */ /* In-line sequence to convert least significant 10 bits of uInt */ /* dpd to three BCD8 digits starting at uByte u. Note that an */ /* extra byte is written to the right of the three digits because */ /* four bytes are moved at a time for speed; the alternative */ /* macro moves exactly three bytes (usually slower). */ #define dpd2bcd8(u, dpd) memcpy(u, &DPD2BCD8[((dpd)&0x3ff)*4], 4) #define dpd2bcd83(u, dpd) memcpy(u, &DPD2BCD8[((dpd)&0x3ff)*4], 3) /* Decode the declets. After extracting each one, it is decoded */ /* to BCD8 using a table lookup (also used for variable-length */ /* decode). Each DPD decode is 3 bytes BCD8 plus a one-byte */ /* length which is not used, here). Fixed-length 4-byte moves */ /* are fast, however, almost everywhere, and so are used except */ /* for the final three bytes (to avoid overrun). The code below */ /* is 36 instructions for Doubles and about 70 for Quads, even */ /* on IA32. */ /* Two macros are defined for each format: */ /* GETCOEFF extracts the coefficient of the current format */ /* GETWCOEFF extracts the coefficient of the next-wider format. */ /* The latter is a copy of the next-wider GETCOEFF using DFWWORD. */ #if DECPMAX==7 #define GETCOEFF(df, bcd) { \ uInt sourhi=DFWORD(df, 0); \ *(bcd)=(uByte)DECCOMBMSD[sourhi>>26]; \ dpd2bcd8(bcd+1, sourhi>>10); \ dpd2bcd83(bcd+4, sourhi);} #define GETWCOEFF(df, bcd) { \ uInt sourhi=DFWWORD(df, 0); \ uInt sourlo=DFWWORD(df, 1); \ *(bcd)=(uByte)DECCOMBMSD[sourhi>>26]; \ dpd2bcd8(bcd+1, sourhi>>8); \ dpd2bcd8(bcd+4, (sourhi<<2) | (sourlo>>30)); \ dpd2bcd8(bcd+7, sourlo>>20); \ dpd2bcd8(bcd+10, sourlo>>10); \ dpd2bcd83(bcd+13, sourlo);} #elif DECPMAX==16 #define GETCOEFF(df, bcd) { \ uInt sourhi=DFWORD(df, 0); \ uInt sourlo=DFWORD(df, 1); \ *(bcd)=(uByte)DECCOMBMSD[sourhi>>26]; \ dpd2bcd8(bcd+1, sourhi>>8); \ dpd2bcd8(bcd+4, (sourhi<<2) | (sourlo>>30)); \ dpd2bcd8(bcd+7, sourlo>>20); \ dpd2bcd8(bcd+10, sourlo>>10); \ dpd2bcd83(bcd+13, sourlo);} #define GETWCOEFF(df, bcd) { \ uInt sourhi=DFWWORD(df, 0); \ uInt sourmh=DFWWORD(df, 1); \ uInt sourml=DFWWORD(df, 2); \ uInt sourlo=DFWWORD(df, 3); \ *(bcd)=(uByte)DECCOMBMSD[sourhi>>26]; \ dpd2bcd8(bcd+1, sourhi>>4); \ dpd2bcd8(bcd+4, ((sourhi)<<6) | (sourmh>>26)); \ dpd2bcd8(bcd+7, sourmh>>16); \ dpd2bcd8(bcd+10, sourmh>>6); \ dpd2bcd8(bcd+13, ((sourmh)<<4) | (sourml>>28)); \ dpd2bcd8(bcd+16, sourml>>18); \ dpd2bcd8(bcd+19, sourml>>8); \ dpd2bcd8(bcd+22, ((sourml)<<2) | (sourlo>>30)); \ dpd2bcd8(bcd+25, sourlo>>20); \ dpd2bcd8(bcd+28, sourlo>>10); \ dpd2bcd83(bcd+31, sourlo);} #elif DECPMAX==34 #define GETCOEFF(df, bcd) { \ uInt sourhi=DFWORD(df, 0); \ uInt sourmh=DFWORD(df, 1); \ uInt sourml=DFWORD(df, 2); \ uInt sourlo=DFWORD(df, 3); \ *(bcd)=(uByte)DECCOMBMSD[sourhi>>26]; \ dpd2bcd8(bcd+1, sourhi>>4); \ dpd2bcd8(bcd+4, ((sourhi)<<6) | (sourmh>>26)); \ dpd2bcd8(bcd+7, sourmh>>16); \ dpd2bcd8(bcd+10, sourmh>>6); \ dpd2bcd8(bcd+13, ((sourmh)<<4) | (sourml>>28)); \ dpd2bcd8(bcd+16, sourml>>18); \ dpd2bcd8(bcd+19, sourml>>8); \ dpd2bcd8(bcd+22, ((sourml)<<2) | (sourlo>>30)); \ dpd2bcd8(bcd+25, sourlo>>20); \ dpd2bcd8(bcd+28, sourlo>>10); \ dpd2bcd83(bcd+31, sourlo);} #define GETWCOEFF(df, bcd) {??} /* [should never be used] */ #endif /* Macros to decode the coefficient in a finite decFloat *df into */ /* a base-billion uInt array, with the least-significant */ /* 0-999999999 'digit' at offset 0. */ /* Decode the declets. After extracting each one, it is decoded */ /* to binary using a table lookup. Three tables are used; one */ /* the usual DPD to binary, the other two pre-multiplied by 1000 */ /* and 1000000 to avoid multiplication during decode. These */ /* tables can also be used for multiplying up the MSD as the DPD */ /* code for 0 through 9 is the identity. */ #define DPD2BIN0 DPD2BIN /* for prettier code */ #if DECPMAX==7 #define GETCOEFFBILL(df, buf) { \ uInt sourhi=DFWORD(df, 0); \ (buf)[0]=DPD2BIN0[sourhi&0x3ff] \ +DPD2BINK[(sourhi>>10)&0x3ff] \ +DPD2BINM[DECCOMBMSD[sourhi>>26]];} #elif DECPMAX==16 #define GETCOEFFBILL(df, buf) { \ uInt sourhi, sourlo; \ sourlo=DFWORD(df, 1); \ (buf)[0]=DPD2BIN0[sourlo&0x3ff] \ +DPD2BINK[(sourlo>>10)&0x3ff] \ +DPD2BINM[(sourlo>>20)&0x3ff]; \ sourhi=DFWORD(df, 0); \ (buf)[1]=DPD2BIN0[((sourhi<<2) | (sourlo>>30))&0x3ff] \ +DPD2BINK[(sourhi>>8)&0x3ff] \ +DPD2BINM[DECCOMBMSD[sourhi>>26]];} #elif DECPMAX==34 #define GETCOEFFBILL(df, buf) { \ uInt sourhi, sourmh, sourml, sourlo; \ sourlo=DFWORD(df, 3); \ (buf)[0]=DPD2BIN0[sourlo&0x3ff] \ +DPD2BINK[(sourlo>>10)&0x3ff] \ +DPD2BINM[(sourlo>>20)&0x3ff]; \ sourml=DFWORD(df, 2); \ (buf)[1]=DPD2BIN0[((sourml<<2) | (sourlo>>30))&0x3ff] \ +DPD2BINK[(sourml>>8)&0x3ff] \ +DPD2BINM[(sourml>>18)&0x3ff]; \ sourmh=DFWORD(df, 1); \ (buf)[2]=DPD2BIN0[((sourmh<<4) | (sourml>>28))&0x3ff] \ +DPD2BINK[(sourmh>>6)&0x3ff] \ +DPD2BINM[(sourmh>>16)&0x3ff]; \ sourhi=DFWORD(df, 0); \ (buf)[3]=DPD2BIN0[((sourhi<<6) | (sourmh>>26))&0x3ff] \ +DPD2BINK[(sourhi>>4)&0x3ff] \ +DPD2BINM[DECCOMBMSD[sourhi>>26]];} #endif /* Macros to decode the coefficient in a finite decFloat *df into */ /* a base-thousand uInt array (of size DECLETS+1, to allow for */ /* the MSD), with the least-significant 0-999 'digit' at offset 0.*/ /* Decode the declets. After extracting each one, it is decoded */ /* to binary using a table lookup. */ #if DECPMAX==7 #define GETCOEFFTHOU(df, buf) { \ uInt sourhi=DFWORD(df, 0); \ (buf)[0]=DPD2BIN[sourhi&0x3ff]; \ (buf)[1]=DPD2BIN[(sourhi>>10)&0x3ff]; \ (buf)[2]=DECCOMBMSD[sourhi>>26];} #elif DECPMAX==16 #define GETCOEFFTHOU(df, buf) { \ uInt sourhi, sourlo; \ sourlo=DFWORD(df, 1); \ (buf)[0]=DPD2BIN[sourlo&0x3ff]; \ (buf)[1]=DPD2BIN[(sourlo>>10)&0x3ff]; \ (buf)[2]=DPD2BIN[(sourlo>>20)&0x3ff]; \ sourhi=DFWORD(df, 0); \ (buf)[3]=DPD2BIN[((sourhi<<2) | (sourlo>>30))&0x3ff]; \ (buf)[4]=DPD2BIN[(sourhi>>8)&0x3ff]; \ (buf)[5]=DECCOMBMSD[sourhi>>26];} #elif DECPMAX==34 #define GETCOEFFTHOU(df, buf) { \ uInt sourhi, sourmh, sourml, sourlo; \ sourlo=DFWORD(df, 3); \ (buf)[0]=DPD2BIN[sourlo&0x3ff]; \ (buf)[1]=DPD2BIN[(sourlo>>10)&0x3ff]; \ (buf)[2]=DPD2BIN[(sourlo>>20)&0x3ff]; \ sourml=DFWORD(df, 2); \ (buf)[3]=DPD2BIN[((sourml<<2) | (sourlo>>30))&0x3ff]; \ (buf)[4]=DPD2BIN[(sourml>>8)&0x3ff]; \ (buf)[5]=DPD2BIN[(sourml>>18)&0x3ff]; \ sourmh=DFWORD(df, 1); \ (buf)[6]=DPD2BIN[((sourmh<<4) | (sourml>>28))&0x3ff]; \ (buf)[7]=DPD2BIN[(sourmh>>6)&0x3ff]; \ (buf)[8]=DPD2BIN[(sourmh>>16)&0x3ff]; \ sourhi=DFWORD(df, 0); \ (buf)[9]=DPD2BIN[((sourhi<<6) | (sourmh>>26))&0x3ff]; \ (buf)[10]=DPD2BIN[(sourhi>>4)&0x3ff]; \ (buf)[11]=DECCOMBMSD[sourhi>>26];} #endif /* Macros to decode the coefficient in a finite decFloat *df and */ /* add to a base-thousand uInt array (as for GETCOEFFTHOU). */ /* After the addition then most significant 'digit' in the array */ /* might have a value larger then 10 (with a maximum of 19). */ #if DECPMAX==7 #define ADDCOEFFTHOU(df, buf) { \ uInt sourhi=DFWORD(df, 0); \ (buf)[0]+=DPD2BIN[sourhi&0x3ff]; \ if (buf[0]>999) {buf[0]-=1000; buf[1]++;} \ (buf)[1]+=DPD2BIN[(sourhi>>10)&0x3ff]; \ if (buf[1]>999) {buf[1]-=1000; buf[2]++;} \ (buf)[2]+=DECCOMBMSD[sourhi>>26];} #elif DECPMAX==16 #define ADDCOEFFTHOU(df, buf) { \ uInt sourhi, sourlo; \ sourlo=DFWORD(df, 1); \ (buf)[0]+=DPD2BIN[sourlo&0x3ff]; \ if (buf[0]>999) {buf[0]-=1000; buf[1]++;} \ (buf)[1]+=DPD2BIN[(sourlo>>10)&0x3ff]; \ if (buf[1]>999) {buf[1]-=1000; buf[2]++;} \ (buf)[2]+=DPD2BIN[(sourlo>>20)&0x3ff]; \ if (buf[2]>999) {buf[2]-=1000; buf[3]++;} \ sourhi=DFWORD(df, 0); \ (buf)[3]+=DPD2BIN[((sourhi<<2) | (sourlo>>30))&0x3ff]; \ if (buf[3]>999) {buf[3]-=1000; buf[4]++;} \ (buf)[4]+=DPD2BIN[(sourhi>>8)&0x3ff]; \ if (buf[4]>999) {buf[4]-=1000; buf[5]++;} \ (buf)[5]+=DECCOMBMSD[sourhi>>26];} #elif DECPMAX==34 #define ADDCOEFFTHOU(df, buf) { \ uInt sourhi, sourmh, sourml, sourlo; \ sourlo=DFWORD(df, 3); \ (buf)[0]+=DPD2BIN[sourlo&0x3ff]; \ if (buf[0]>999) {buf[0]-=1000; buf[1]++;} \ (buf)[1]+=DPD2BIN[(sourlo>>10)&0x3ff]; \ if (buf[1]>999) {buf[1]-=1000; buf[2]++;} \ (buf)[2]+=DPD2BIN[(sourlo>>20)&0x3ff]; \ if (buf[2]>999) {buf[2]-=1000; buf[3]++;} \ sourml=DFWORD(df, 2); \ (buf)[3]+=DPD2BIN[((sourml<<2) | (sourlo>>30))&0x3ff]; \ if (buf[3]>999) {buf[3]-=1000; buf[4]++;} \ (buf)[4]+=DPD2BIN[(sourml>>8)&0x3ff]; \ if (buf[4]>999) {buf[4]-=1000; buf[5]++;} \ (buf)[5]+=DPD2BIN[(sourml>>18)&0x3ff]; \ if (buf[5]>999) {buf[5]-=1000; buf[6]++;} \ sourmh=DFWORD(df, 1); \ (buf)[6]+=DPD2BIN[((sourmh<<4) | (sourml>>28))&0x3ff]; \ if (buf[6]>999) {buf[6]-=1000; buf[7]++;} \ (buf)[7]+=DPD2BIN[(sourmh>>6)&0x3ff]; \ if (buf[7]>999) {buf[7]-=1000; buf[8]++;} \ (buf)[8]+=DPD2BIN[(sourmh>>16)&0x3ff]; \ if (buf[8]>999) {buf[8]-=1000; buf[9]++;} \ sourhi=DFWORD(df, 0); \ (buf)[9]+=DPD2BIN[((sourhi<<6) | (sourmh>>26))&0x3ff]; \ if (buf[9]>999) {buf[9]-=1000; buf[10]++;} \ (buf)[10]+=DPD2BIN[(sourhi>>4)&0x3ff]; \ if (buf[10]>999) {buf[10]-=1000; buf[11]++;} \ (buf)[11]+=DECCOMBMSD[sourhi>>26];} #endif /* Set a decFloat to the maximum positive finite number (Nmax) */ #if DECPMAX==7 #define DFSETNMAX(df) \ {DFWORD(df, 0)=0x77f3fcff;} #elif DECPMAX==16 #define DFSETNMAX(df) \ {DFWORD(df, 0)=0x77fcff3f; \ DFWORD(df, 1)=0xcff3fcff;} #elif DECPMAX==34 #define DFSETNMAX(df) \ {DFWORD(df, 0)=0x77ffcff3; \ DFWORD(df, 1)=0xfcff3fcf; \ DFWORD(df, 2)=0xf3fcff3f; \ DFWORD(df, 3)=0xcff3fcff;} #endif /* [end of format-dependent macros and constants] */ #endif #else #error decNumberLocal included more than once #endif libdfp-1.0.12/libdecnumber/decPacked.c000066400000000000000000000210571261375163000175060ustar00rootroot00000000000000/* Packed decimal conversion module for the decNumber C Library. Copyright (C) 2007-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------ */ /* Packed Decimal conversion module */ /* ------------------------------------------------------------------ */ /* This module comprises the routines for Packed Decimal format */ /* numbers. Conversions are supplied to and from decNumber, which in */ /* turn supports: */ /* conversions to and from string */ /* arithmetic routines */ /* utilities. */ /* Conversions from decNumber to and from densely packed decimal */ /* formats are provided by the decimal32 through decimal128 modules. */ /* ------------------------------------------------------------------ */ #include /* for NULL */ #include "decNumber.h" /* base number library */ #include "decPacked.h" /* packed decimal */ #include "decNumberLocal.h" /* decNumber local types, etc. */ /* ------------------------------------------------------------------ */ /* decPackedFromNumber -- convert decNumber to BCD Packed Decimal */ /* */ /* bcd is the BCD bytes */ /* length is the length of the BCD array */ /* scale is the scale result */ /* dn is the decNumber */ /* returns bcd, or NULL if error */ /* */ /* The number is converted to a BCD packed decimal byte array, */ /* right aligned in the bcd array, whose length is indicated by the */ /* second parameter. The final 4-bit nibble in the array will be a */ /* sign nibble, C (1100) for + and D (1101) for -. Unused bytes and */ /* nibbles to the left of the number are set to 0. */ /* */ /* scale is set to the scale of the number (this is the exponent, */ /* negated). To force the number to a specified scale, first use the */ /* decNumberRescale routine, which will round and change the exponent */ /* as necessary. */ /* */ /* If there is an error (that is, the decNumber has too many digits */ /* to fit in length bytes, or it is a NaN or Infinity), NULL is */ /* returned and the bcd and scale results are unchanged. Otherwise */ /* bcd is returned. */ /* ------------------------------------------------------------------ */ uByte * decPackedFromNumber(uByte *bcd, Int length, Int *scale, const decNumber *dn) { const Unit *up=dn->lsu; /* Unit array pointer */ uByte obyte, *out; /* current output byte, and where it goes */ Int indigs=dn->digits; /* digits processed */ uInt cut=DECDPUN; /* downcounter per Unit */ uInt u=*up; /* work */ uInt nib; /* .. */ #if DECDPUN<=4 uInt temp; /* .. */ #endif if (dn->digits>length*2-1 /* too long .. */ ||(dn->bits & DECSPECIAL)) return NULL; /* .. or special -- hopeless */ if (dn->bits&DECNEG) obyte=DECPMINUS; /* set the sign .. */ else obyte=DECPPLUS; *scale=-dn->exponent; /* .. and scale */ /* loop from lowest (rightmost) byte */ out=bcd+length-1; /* -> final byte */ for (; out>=bcd; out--) { if (indigs>0) { if (cut==0) { up++; u=*up; cut=DECDPUN; } #if DECDPUN<=4 temp=(u*6554)>>16; /* fast /10 */ nib=u-X10(temp); u=temp; #else nib=u%10; /* cannot use *6554 trick :-( */ u=u/10; #endif obyte|=(nib<<4); indigs--; cut--; } *out=obyte; obyte=0; /* assume 0 */ if (indigs>0) { if (cut==0) { up++; u=*up; cut=DECDPUN; } #if DECDPUN<=4 temp=(u*6554)>>16; /* as above */ obyte=(uByte)(u-X10(temp)); u=temp; #else obyte=(uByte)(u%10); u=u/10; #endif indigs--; cut--; } } /* loop */ return bcd; } /* decPackedFromNumber */ /* ------------------------------------------------------------------ */ /* decPackedToNumber -- convert BCD Packed Decimal to a decNumber */ /* */ /* bcd is the BCD bytes */ /* length is the length of the BCD array */ /* scale is the scale associated with the BCD integer */ /* dn is the decNumber [with space for length*2 digits] */ /* returns dn, or NULL if error */ /* */ /* The BCD packed decimal byte array, together with an associated */ /* scale, is converted to a decNumber. The BCD array is assumed full */ /* of digits, and must be ended by a 4-bit sign nibble in the least */ /* significant four bits of the final byte. */ /* */ /* The scale is used (negated) as the exponent of the decNumber. */ /* Note that zeros may have a sign and/or a scale. */ /* */ /* The decNumber structure is assumed to have sufficient space to */ /* hold the converted number (that is, up to length*2-1 digits), so */ /* no error is possible unless the adjusted exponent is out of range, */ /* no sign nibble was found, or a sign nibble was found before the */ /* final nibble. In these error cases, NULL is returned and the */ /* decNumber will be 0. */ /* ------------------------------------------------------------------ */ decNumber * decPackedToNumber(const uByte *bcd, Int length, const Int *scale, decNumber *dn) { const uByte *last=bcd+length-1; /* -> last byte */ const uByte *first; /* -> first non-zero byte */ uInt nib; /* work nibble */ Unit *up=dn->lsu; /* output pointer */ Int digits; /* digits count */ Int cut=0; /* phase of output */ decNumberZero(dn); /* default result */ last=&bcd[length-1]; nib=*last & 0x0f; /* get the sign */ if (nib==DECPMINUS || nib==DECPMINUSALT) dn->bits=DECNEG; else if (nib<=9) return NULL; /* not a sign nibble */ /* skip leading zero bytes [final byte is always non-zero, due to sign] */ for (first=bcd; *first==0;) first++; digits=(last-first)*2+1; /* calculate digits .. */ if ((*first & 0xf0)==0) digits--; /* adjust for leading zero nibble */ if (digits!=0) dn->digits=digits; /* count of actual digits [if 0, */ /* leave as 1] */ /* check the adjusted exponent; note that scale could be unbounded */ dn->exponent=-*scale; /* set the exponent */ if (*scale>=0) { /* usual case */ if ((dn->digits-*scale-1)<-DECNUMMAXE) { /* underflow */ decNumberZero(dn); return NULL;} } else { /* -ve scale; +ve exponent */ /* need to be careful to avoid wrap, here, also BADINT case */ if ((*scale<-DECNUMMAXE) /* overflow even without digits */ || ((dn->digits-*scale-1)>DECNUMMAXE)) { /* overflow */ decNumberZero(dn); return NULL;} } if (digits==0) return dn; /* result was zero */ /* copy the digits to the number's units, starting at the lsu */ /* [unrolled] */ for (;;) { /* forever */ /* left nibble first */ nib=(unsigned)(*last & 0xf0)>>4; /* got a digit, in nib */ if (nib>9) {decNumberZero(dn); return NULL;} if (cut==0) *up=(Unit)nib; else *up=(Unit)(*up+nib*DECPOWERS[cut]); digits--; if (digits==0) break; /* got them all */ cut++; if (cut==DECDPUN) { up++; cut=0; } last--; /* ready for next */ nib=*last & 0x0f; /* get right nibble */ if (nib>9) {decNumberZero(dn); return NULL;} /* got a digit, in nib */ if (cut==0) *up=(Unit)nib; else *up=(Unit)(*up+nib*DECPOWERS[cut]); digits--; if (digits==0) break; /* got them all */ cut++; if (cut==DECDPUN) { up++; cut=0; } } /* forever */ return dn; } /* decPackedToNumber */ libdfp-1.0.12/libdecnumber/decPacked.h000066400000000000000000000052121261375163000175060ustar00rootroot00000000000000/* Packed decimal conversion module header for the decNumber C Library. Copyright (C) 2007-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------ */ /* Packed Decimal conversion module header */ /* ------------------------------------------------------------------ */ #if !defined(DECPACKED) #define DECPACKED #define DECPNAME "decPacked" /* Short name */ #define DECPFULLNAME "Packed Decimal conversions" /* Verbose name */ #define DECPAUTHOR "Mike Cowlishaw" /* Who to blame */ #define DECPACKED_DefP 32 /* default precision */ #ifndef DECNUMDIGITS #define DECNUMDIGITS DECPACKED_DefP /* size if not already defined*/ #endif #include "decNumber.h" /* context and number library */ /* Sign nibble constants */ #if !defined(DECPPLUSALT) #define DECPPLUSALT 0x0A /* alternate plus nibble */ #define DECPMINUSALT 0x0B /* alternate minus nibble */ #define DECPPLUS 0x0C /* preferred plus nibble */ #define DECPMINUS 0x0D /* preferred minus nibble */ #define DECPPLUSALT2 0x0E /* alternate plus nibble */ #define DECPUNSIGNED 0x0F /* alternate plus nibble (unsigned) */ #endif /* ---------------------------------------------------------------- */ /* decPacked public routines */ /* ---------------------------------------------------------------- */ #include "decPackedSymbols.h" /* Conversions */ uint8_t * decPackedFromNumber(uint8_t *, int32_t, int32_t *, const decNumber *); decNumber * decPackedToNumber(const uint8_t *, int32_t, const int32_t *, decNumber *); #endif libdfp-1.0.12/libdecnumber/decQuad.c000066400000000000000000000133361261375163000172120ustar00rootroot00000000000000/* decQuad module for the decNumber C Library. Copyright (C) 2007-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------ */ /* decQuad.c -- decQuad operations module */ /* ------------------------------------------------------------------ */ /* This module comprises decQuad operations (including conversions) */ /* ------------------------------------------------------------------ */ #include "decContext.h" /* public includes */ #include "decQuad.h" /* .. */ /* Constant mappings for shared code */ #define DECPMAX DECQUAD_Pmax #define DECEMIN DECQUAD_Emin #define DECEMAX DECQUAD_Emax #define DECEMAXD DECQUAD_EmaxD #define DECBYTES DECQUAD_Bytes #define DECSTRING DECQUAD_String #define DECECONL DECQUAD_EconL #define DECBIAS DECQUAD_Bias #define DECLETS DECQUAD_Declets #define DECQTINY (-DECQUAD_Bias) /* Type and function mappings for shared code */ #define decFloat decQuad /* Type name */ /* Utilities and conversions (binary results, extractors, etc.) */ #define decFloatFromBCD decQuadFromBCD #define decFloatFromInt32 decQuadFromInt32 #define decFloatFromPacked decQuadFromPacked #define decFloatFromPackedChecked decQuadFromPackedChecked #define decFloatFromString decQuadFromString #define decFloatFromUInt32 decQuadFromUInt32 #define decFloatFromWider decQuadFromWider #define decFloatGetCoefficient decQuadGetCoefficient #define decFloatGetExponent decQuadGetExponent #define decFloatSetCoefficient decQuadSetCoefficient #define decFloatSetExponent decQuadSetExponent #define decFloatShow decQuadShow #define decFloatToBCD decQuadToBCD #define decFloatToEngString decQuadToEngString #define decFloatToInt32 decQuadToInt32 #define decFloatToInt32Exact decQuadToInt32Exact #define decFloatToPacked decQuadToPacked #define decFloatToString decQuadToString #define decFloatToUInt32 decQuadToUInt32 #define decFloatToUInt32Exact decQuadToUInt32Exact #define decFloatToWider decQuadToWider #define decFloatZero decQuadZero /* Computational (result is a decFloat) */ #define decFloatAbs decQuadAbs #define decFloatAdd decQuadAdd #define decFloatAnd decQuadAnd #define decFloatDivide decQuadDivide #define decFloatDivideInteger decQuadDivideInteger #define decFloatFMA decQuadFMA #define decFloatInvert decQuadInvert #define decFloatLogB decQuadLogB #define decFloatMax decQuadMax #define decFloatMaxMag decQuadMaxMag #define decFloatMin decQuadMin #define decFloatMinMag decQuadMinMag #define decFloatMinus decQuadMinus #define decFloatMultiply decQuadMultiply #define decFloatNextMinus decQuadNextMinus #define decFloatNextPlus decQuadNextPlus #define decFloatNextToward decQuadNextToward #define decFloatOr decQuadOr #define decFloatPlus decQuadPlus #define decFloatQuantize decQuadQuantize #define decFloatReduce decQuadReduce #define decFloatRemainder decQuadRemainder #define decFloatRemainderNear decQuadRemainderNear #define decFloatRotate decQuadRotate #define decFloatScaleB decQuadScaleB #define decFloatShift decQuadShift #define decFloatSubtract decQuadSubtract #define decFloatToIntegralValue decQuadToIntegralValue #define decFloatToIntegralExact decQuadToIntegralExact #define decFloatXor decQuadXor /* Comparisons */ #define decFloatCompare decQuadCompare #define decFloatCompareSignal decQuadCompareSignal #define decFloatCompareTotal decQuadCompareTotal #define decFloatCompareTotalMag decQuadCompareTotalMag /* Copies */ #define decFloatCanonical decQuadCanonical #define decFloatCopy decQuadCopy #define decFloatCopyAbs decQuadCopyAbs #define decFloatCopyNegate decQuadCopyNegate #define decFloatCopySign decQuadCopySign /* Non-computational */ #define decFloatClass decQuadClass #define decFloatClassString decQuadClassString #define decFloatDigits decQuadDigits #define decFloatIsCanonical decQuadIsCanonical #define decFloatIsFinite decQuadIsFinite #define decFloatIsInfinite decQuadIsInfinite #define decFloatIsInteger decQuadIsInteger #define decFloatIsNaN decQuadIsNaN #define decFloatIsNormal decQuadIsNormal #define decFloatIsSignaling decQuadIsSignaling #define decFloatIsSignalling decQuadIsSignalling #define decFloatIsSigned decQuadIsSigned #define decFloatIsSubnormal decQuadIsSubnormal #define decFloatIsZero decQuadIsZero #define decFloatRadix decQuadRadix #define decFloatSameQuantum decQuadSameQuantum #define decFloatVersion decQuadVersion #include "decNumberLocal.h" /* local includes (need DECPMAX) */ #include "decCommon.c" /* non-arithmetic decFloat routines */ #include "decBasic.c" /* basic formats routines */ libdfp-1.0.12/libdecnumber/decQuad.h000066400000000000000000000245621261375163000172220ustar00rootroot00000000000000/* decQuad module header for the decNumber C Library. Copyright (C) 2007-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------ */ /* decQuad.h -- Decimal 128-bit format module header */ /* ------------------------------------------------------------------ */ /* This include file is always included by decSingle and decDouble, */ /* and therefore also holds useful constants used by all three. */ #if !defined(DECQUAD) #define DECQUAD #define DECQUADNAME "decimalQuad" /* Short name */ #define DECQUADTITLE "Decimal 128-bit datum" /* Verbose name */ #define DECQUADAUTHOR "Mike Cowlishaw" /* Who to blame */ /* parameters for decQuads */ #define DECQUAD_Bytes 16 /* length */ #define DECQUAD_Pmax 34 /* maximum precision (digits) */ #define DECQUAD_Emin -6143 /* minimum adjusted exponent */ #define DECQUAD_Emax 6144 /* maximum adjusted exponent */ #define DECQUAD_EmaxD 4 /* maximum exponent digits */ #define DECQUAD_Bias 6176 /* bias for the exponent */ #define DECQUAD_String 43 /* maximum string length, +1 */ #define DECQUAD_EconL 12 /* exponent continuation length */ #define DECQUAD_Declets 11 /* count of declets */ /* highest biased exponent (Elimit-1) */ #define DECQUAD_Ehigh (DECQUAD_Emax + DECQUAD_Bias - (DECQUAD_Pmax-1)) /* Required include */ #include "decContext.h" /* The decQuad decimal 128-bit type, accessible by all sizes */ typedef union { uint8_t bytes[DECQUAD_Bytes]; /* fields: 1, 5, 12, 110 bits */ uint16_t shorts[DECQUAD_Bytes/2]; uint32_t words[DECQUAD_Bytes/4]; #if DECUSE64 uint64_t longs[DECQUAD_Bytes/8]; #endif } decQuad; /* ---------------------------------------------------------------- */ /* Shared constants */ /* ---------------------------------------------------------------- */ /* sign and special values [top 32-bits; last two bits are don't-care for Infinity on input, last bit don't-care for NaNs] */ #define DECFLOAT_Sign 0x80000000 /* 1 00000 00 Sign */ #define DECFLOAT_NaN 0x7c000000 /* 0 11111 00 NaN generic */ #define DECFLOAT_qNaN 0x7c000000 /* 0 11111 00 qNaN */ #define DECFLOAT_sNaN 0x7e000000 /* 0 11111 10 sNaN */ #define DECFLOAT_Inf 0x78000000 /* 0 11110 00 Infinity */ #define DECFLOAT_MinSp 0x78000000 /* minimum special value */ /* [specials are all >=MinSp] */ /* Sign nibble constants */ #if !defined(DECPPLUSALT) #define DECPPLUSALT 0x0A /* alternate plus nibble */ #define DECPMINUSALT 0x0B /* alternate minus nibble */ #define DECPPLUS 0x0C /* preferred plus nibble */ #define DECPMINUS 0x0D /* preferred minus nibble */ #define DECPPLUSALT2 0x0E /* alternate plus nibble */ #define DECPUNSIGNED 0x0F /* alternate plus nibble (unsigned) */ #endif /* ---------------------------------------------------------------- */ /* Routines -- implemented as decFloat routines in common files */ /* ---------------------------------------------------------------- */ #include "decQuadSymbols.h" /* Utilities and conversions, extractors, etc.) */ extern decQuad * decQuadFromBCD(decQuad *, int32_t, const uint8_t *, int32_t); extern decQuad * decQuadFromInt32(decQuad *, int32_t); extern decQuad * decQuadFromPacked(decQuad *, int32_t, const uint8_t *); extern decQuad * decQuadFromPackedChecked(decQuad *, int32_t, const uint8_t *); extern decQuad * decQuadFromString(decQuad *, const char *, decContext *); extern decQuad * decQuadFromUInt32(decQuad *, uint32_t); extern int32_t decQuadGetCoefficient(const decQuad *, uint8_t *); extern int32_t decQuadGetExponent(const decQuad *); extern decQuad * decQuadSetCoefficient(decQuad *, const uint8_t *, int32_t); extern decQuad * decQuadSetExponent(decQuad *, decContext *, int32_t); extern void decQuadShow(const decQuad *, const char *); extern int32_t decQuadToBCD(const decQuad *, int32_t *, uint8_t *); extern char * decQuadToEngString(const decQuad *, char *); extern int32_t decQuadToInt32(const decQuad *, decContext *, enum rounding); extern int32_t decQuadToInt32Exact(const decQuad *, decContext *, enum rounding); extern int32_t decQuadToPacked(const decQuad *, int32_t *, uint8_t *); extern char * decQuadToString(const decQuad *, char *); extern uint32_t decQuadToUInt32(const decQuad *, decContext *, enum rounding); extern uint32_t decQuadToUInt32Exact(const decQuad *, decContext *, enum rounding); extern decQuad * decQuadZero(decQuad *); /* Computational (result is a decQuad) */ extern decQuad * decQuadAbs(decQuad *, const decQuad *, decContext *); extern decQuad * decQuadAdd(decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadAnd(decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadDivide(decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadDivideInteger(decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadFMA(decQuad *, const decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadInvert(decQuad *, const decQuad *, decContext *); extern decQuad * decQuadLogB(decQuad *, const decQuad *, decContext *); extern decQuad * decQuadMax(decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadMaxMag(decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadMin(decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadMinMag(decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadMinus(decQuad *, const decQuad *, decContext *); extern decQuad * decQuadMultiply(decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadNextMinus(decQuad *, const decQuad *, decContext *); extern decQuad * decQuadNextPlus(decQuad *, const decQuad *, decContext *); extern decQuad * decQuadNextToward(decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadOr(decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadPlus(decQuad *, const decQuad *, decContext *); extern decQuad * decQuadQuantize(decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadReduce(decQuad *, const decQuad *, decContext *); extern decQuad * decQuadRemainder(decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadRemainderNear(decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadRotate(decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadScaleB(decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadShift(decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadSubtract(decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadToIntegralValue(decQuad *, const decQuad *, decContext *, enum rounding); extern decQuad * decQuadToIntegralExact(decQuad *, const decQuad *, decContext *); extern decQuad * decQuadXor(decQuad *, const decQuad *, const decQuad *, decContext *); /* Comparisons */ extern decQuad * decQuadCompare(decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadCompareSignal(decQuad *, const decQuad *, const decQuad *, decContext *); extern decQuad * decQuadCompareTotal(decQuad *, const decQuad *, const decQuad *); extern decQuad * decQuadCompareTotalMag(decQuad *, const decQuad *, const decQuad *); /* Copies */ extern decQuad * decQuadCanonical(decQuad *, const decQuad *); extern decQuad * decQuadCopy(decQuad *, const decQuad *); extern decQuad * decQuadCopyAbs(decQuad *, const decQuad *); extern decQuad * decQuadCopyNegate(decQuad *, const decQuad *); extern decQuad * decQuadCopySign(decQuad *, const decQuad *, const decQuad *); /* Non-computational */ extern enum decClass decQuadClass(const decQuad *); extern const char * decQuadClassString(const decQuad *); extern uint32_t decQuadDigits(const decQuad *); extern uint32_t decQuadIsCanonical(const decQuad *); extern uint32_t decQuadIsFinite(const decQuad *); extern uint32_t decQuadIsInteger(const decQuad *); extern uint32_t decQuadIsInfinite(const decQuad *); extern uint32_t decQuadIsNaN(const decQuad *); extern uint32_t decQuadIsNormal(const decQuad *); extern uint32_t decQuadIsSignaling(const decQuad *); extern uint32_t decQuadIsSignalling(const decQuad *); extern uint32_t decQuadIsSigned(const decQuad *); extern uint32_t decQuadIsSubnormal(const decQuad *); extern uint32_t decQuadIsZero(const decQuad *); extern uint32_t decQuadRadix(const decQuad *); extern uint32_t decQuadSameQuantum(const decQuad *, const decQuad *); extern const char * decQuadVersion(void); /* decNumber conversions; these are implemented as macros so as not */ /* to force a dependency on decimal128 and decNumber in decQuad. */ /* decQuadFromNumber returns a decimal128 * to avoid warnings. */ #define decQuadToNumber(dq, dn) decimal128ToNumber((decimal128 *)(dq), dn) #define decQuadFromNumber(dq, dn, set) decimal128FromNumber((decimal128 *)(dq), dn, set) #endif libdfp-1.0.12/libdecnumber/decRound.c000066400000000000000000000055141261375163000174060ustar00rootroot00000000000000/* Internal testing support for rounding for decimal float. Copyright (C) 2005-2015 Free Software Foundation, Inc. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ #include "dconfig.h" #include "decContext.h" #include "decRound.h" /* Internal, non-documented functions for testing libgcc functions. This support is not sufficient for application use. */ #define FE_DEC_DOWNWARD 0 #define FE_DEC_TONEAREST 1 #define FE_DEC_TONEARESTFROMZERO 2 #define FE_DEC_TOWARDZERO 3 #define FE_DEC_UPWARD 4 #define FE_DEC_MAX 5 static enum rounding __dfp_rounding_mode = DEC_ROUND_HALF_EVEN; /* Set the decNumber rounding mode from the FE_DEC_* value in MODE. */ void __dfp_set_round (int mode) { switch (mode) { case FE_DEC_DOWNWARD: __dfp_rounding_mode = DEC_ROUND_FLOOR; break; case FE_DEC_TONEAREST: __dfp_rounding_mode = DEC_ROUND_HALF_EVEN; break; case FE_DEC_TONEARESTFROMZERO: __dfp_rounding_mode = DEC_ROUND_HALF_UP; break; case FE_DEC_TOWARDZERO: __dfp_rounding_mode = DEC_ROUND_DOWN; break; case FE_DEC_UPWARD: __dfp_rounding_mode = DEC_ROUND_CEILING; break; default: /* We can't use assert in libgcc, so just return the default mode. */ __dfp_rounding_mode = DEC_ROUND_HALF_EVEN; break; } } /* Return the decNumber rounding mode as an FE_DEC_* value. */ int __dfp_get_round (void) { int mode; switch (__dfp_rounding_mode) { case DEC_ROUND_FLOOR: mode = FE_DEC_DOWNWARD; break; case DEC_ROUND_HALF_EVEN: mode = FE_DEC_TONEAREST; break; case DEC_ROUND_HALF_UP: mode = FE_DEC_TONEARESTFROMZERO; break; case DEC_ROUND_DOWN: mode = FE_DEC_TOWARDZERO; break; case DEC_ROUND_CEILING: mode = FE_DEC_UPWARD; break; default: /* We shouldn't get here, but can't use assert in libgcc. */ mode = -1; } return mode; } /* Return the decNumber version of the current rounding mode. */ enum rounding __decGetRound (void) { return __dfp_rounding_mode; } libdfp-1.0.12/libdecnumber/decRound.h000066400000000000000000000023221261375163000174050ustar00rootroot00000000000000/* Internal testing support for rounding for decimal float. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ #include "decContext.h" #define DFP_INIT_ROUNDMODE(A) A = __decGetRound() extern void __dfp_set_round (int); extern int __dfp_get_round (void); extern enum rounding __decGetRound (void); libdfp-1.0.12/libdecnumber/decSingle.c000066400000000000000000000062701261375163000175400ustar00rootroot00000000000000/* decSingle module for the decNumber C Library. Copyright (C) 2007-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------ */ /* decSingle.c -- decSingle operations module */ /* ------------------------------------------------------------------ */ #include "decContext.h" /* public includes */ #include "decSingle.h" /* public includes */ /* Constant mappings for shared code */ #define DECPMAX DECSINGLE_Pmax #define DECEMIN DECSINGLE_Emin #define DECEMAX DECSINGLE_Emax #define DECEMAXD DECSINGLE_EmaxD #define DECBYTES DECSINGLE_Bytes #define DECSTRING DECSINGLE_String #define DECECONL DECSINGLE_EconL #define DECBIAS DECSINGLE_Bias #define DECLETS DECSINGLE_Declets #define DECQTINY (-DECSINGLE_Bias) /* parameters of next-wider format */ #define DECWBYTES DECDOUBLE_Bytes #define DECWPMAX DECDOUBLE_Pmax #define DECWECONL DECDOUBLE_EconL #define DECWBIAS DECDOUBLE_Bias /* Type and function mappings for shared code */ #define decFloat decSingle /* Type name */ #define decFloatWider decDouble /* Type name */ /* Utility (binary results, extractors, etc.) */ #define decFloatFromBCD decSingleFromBCD #define decFloatFromPacked decSingleFromPacked #define decFloatFromPackedChecked decSingleFromPackedChecked #define decFloatFromString decSingleFromString #define decFloatFromWider decSingleFromWider #define decFloatGetCoefficient decSingleGetCoefficient #define decFloatGetExponent decSingleGetExponent #define decFloatSetCoefficient decSingleSetCoefficient #define decFloatSetExponent decSingleSetExponent #define decFloatShow decSingleShow #define decFloatToBCD decSingleToBCD #define decFloatToEngString decSingleToEngString #define decFloatToPacked decSingleToPacked #define decFloatToString decSingleToString #define decFloatToWider decSingleToWider #define decFloatZero decSingleZero /* Non-computational */ #define decFloatRadix decSingleRadix #define decFloatVersion decSingleVersion #include "decNumberLocal.h" /* local includes (need DECPMAX) */ #include "decCommon.c" /* non-basic decFloat routines */ /* [Do not include decBasic.c for decimal32] */ libdfp-1.0.12/libdecnumber/decSingle.h000066400000000000000000000113131261375163000175370ustar00rootroot00000000000000/* decSingle module header for the decNumber C Library. Copyright (C) 2005-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------ */ /* decSingle.h -- Decimal 32-bit format module header */ /* ------------------------------------------------------------------ */ #if !defined(DECSINGLE) #define DECSINGLE #define DECSINGLENAME "decSingle" /* Short name */ #define DECSINGLETITLE "Decimal 32-bit datum" /* Verbose name */ #define DECSINGLEAUTHOR "Mike Cowlishaw" /* Who to blame */ /* parameters for decSingles */ #define DECSINGLE_Bytes 4 /* length */ #define DECSINGLE_Pmax 7 /* maximum precision (digits) */ #define DECSINGLE_Emin -95 /* minimum adjusted exponent */ #define DECSINGLE_Emax 96 /* maximum adjusted exponent */ #define DECSINGLE_EmaxD 3 /* maximum exponent digits */ #define DECSINGLE_Bias 101 /* bias for the exponent */ #define DECSINGLE_String 16 /* maximum string length, +1 */ #define DECSINGLE_EconL 6 /* exponent continuation length */ #define DECSINGLE_Declets 2 /* count of declets */ /* highest biased exponent (Elimit-1) */ #define DECSINGLE_Ehigh (DECSINGLE_Emax + DECSINGLE_Bias - (DECSINGLE_Pmax-1)) /* Required includes */ #include "decContext.h" #include "decQuad.h" #include "decDouble.h" /* The decSingle decimal 32-bit type, accessible by all sizes */ typedef union { uint8_t bytes[DECSINGLE_Bytes]; /* fields: 1, 5, 6, 20 bits */ uint16_t shorts[DECSINGLE_Bytes/2]; uint32_t words[DECSINGLE_Bytes/4]; } decSingle; /* ---------------------------------------------------------------- */ /* Routines -- implemented as decFloat routines in common files */ /* ---------------------------------------------------------------- */ #include "decSingleSymbols.h" /* Utilities (binary argument(s) or result, extractors, etc.) */ extern decSingle * decSingleFromBCD(decSingle *, int32_t, const uint8_t *, int32_t); extern decSingle * decSingleFromPacked(decSingle *, int32_t, const uint8_t *); extern decSingle * decSingleFromPackedChecked(decSingle *, int32_t, const uint8_t *); extern decSingle * decSingleFromString(decSingle *, const char *, decContext *); extern decSingle * decSingleFromWider(decSingle *, const decDouble *, decContext *); extern int32_t decSingleGetCoefficient(const decSingle *, uint8_t *); extern int32_t decSingleGetExponent(const decSingle *); extern decSingle * decSingleSetCoefficient(decSingle *, const uint8_t *, int32_t); extern decSingle * decSingleSetExponent(decSingle *, decContext *, int32_t); extern void decSingleShow(const decSingle *, const char *); extern int32_t decSingleToBCD(const decSingle *, int32_t *, uint8_t *); extern char * decSingleToEngString(const decSingle *, char *); extern int32_t decSingleToPacked(const decSingle *, int32_t *, uint8_t *); extern char * decSingleToString(const decSingle *, char *); extern decDouble * decSingleToWider(const decSingle *, decDouble *); extern decSingle * decSingleZero(decSingle *); /* (No Arithmetic routines for decSingle) */ /* Non-computational */ extern uint32_t decSingleRadix(const decSingle *); extern const char * decSingleVersion(void); /* decNumber conversions; these are implemented as macros so as not */ /* to force a dependency on decimal32 and decNumber in decSingle. */ /* decSingleFromNumber returns a decimal32 * to avoid warnings. */ #define decSingleToNumber(dq, dn) decimal32ToNumber((decimal32 *)(dq), dn) #define decSingleFromNumber(dq, dn, set) decimal32FromNumber((decimal32 *)(dq), dn, set) #endif libdfp-1.0.12/libdecnumber/decUInt128.h000066400000000000000000000105451261375163000174360ustar00rootroot00000000000000/* Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _BID_DECIMAL128_H # define _BID_DECIMAL128_H /* GCC/clang supports 128 types bytes for some architectures (x86_64 for instance). For archs/configurations that does not support it, a multiprecision implementation based on the mini GMP is used. */ #ifdef HAVE_UINT128_T /* Native int 128 bits */ typedef __uint128_t uQuad; #define uQuadInit(__x) #define uQuadInitFromUInt(__ret, __hi, __mh, __ml, __lo) \ __ret = ((__uint128_t)__hi << 96) | \ ((__uint128_t)__mh << 64) | \ ((__uint128_t)__ml << 32) | \ (__uint128_t)__lo #define uQuadSetUInt(__x, __i) ((__x) = (__i)) #define uQuadToUInt(__x, __i) (__i) = (__x) #define uQuadHi(__x) (__x >> 96) #define uQuadMh(__x) ((__x >> 64) & 0xFFFFFFFFU) #define uQuadMl(__x) ((__x >> 32) & 0xFFFFFFFFU) #define uQuadLo(__x) ((__x) & 0xFFFFFFFFU) #define uQuadHi64(__x) (__x >> 64) #define uQuadLo64(__x) ((__x) & 0xFFFFFFFFFFFFFFFFULL) #define uQuadNEUInt(__x, __y) ( __x != __y) #define uQuadAddQuad(__x, __y, __z) __z = __x + __y #define uQuadMulUInt(__x, __y, __z) __z = __x * __y #define uQuadModUInt(__x, __y, __z) __z = __x % __y #define uQuadDivUInt(__x, __y, __z) __z = __x / __y #else /* Multiprecision int 128 bits based on int 32 limbs. */ #include typedef mpz_t uQuad; /* Initialize a multiprecision int 128 bits number from 4 int 32 bits member. Since the MPN implementation does not support bitwise operations we operate on the internal structure directly. */ static inline void uQuadInitFromUInt (uQuad ret, uInt hi, uInt mh, uInt ml, uInt lo) { mpz_init2 (ret, 128); /* mpn_z::_mp_size is total number of mpz_z::_mp_d being used to represent the number (for instance, if mpz_z::_mp_size of 2 the number can be represented in a 64-bits variable. */ ret->_mp_size = 0; ret->_mp_d[3] = hi; ret->_mp_d[2] = mh; ret->_mp_d[1] = ml; ret->_mp_d[0] = lo; if (hi != 0) ret->_mp_size = 4; else if (mh != 0) ret->_mp_size = 3; else if (ml != 0) ret->_mp_size = 2; else if (lo != 0) ret->_mp_size = 1; } static inline unsigned long int __dec_extract_word (mpz_t x, int word) { return (x->_mp_size >= (word + 1)) ? x->_mp_d[word] : 0UL; } static inline unsigned long long int __dec_extract_doubleword (mpz_t x, int word) { unsigned long long int ret; ret = __dec_extract_word(x, 2*word+1); ret <<= 32; ret |= __dec_extract_word(x, 2*word); return ret; } #define uQuadInit(__x) mpz_init2 (__x, 128) #define uQuadSetUInt(__x, __i) mpz_set_ui (__x, __i) #define uQuadToUInt(__x, __i) __i = mpz_get_ui (__x) #define uQuadHi(__x) __dec_extract_word (__x, 3) #define uQuadMh(__x) __dec_extract_word (__x, 2) #define uQuadMl(__x) __dec_extract_word (__x, 1) #define uQuadLo(__x) __dec_extract_word (__x, 0) #define uQuadHi64(__x) __dec_extract_doubleword (__x, 1) #define uQuadLo64(__x) __dec_extract_doubleword (__x, 0) #define uQuadNEUInt(__x, __y) (mpz_cmp_ui (__x, __y) != 0) #define uQuadAddQuad(__x, __y, __z) mpz_add (__z, __x, __y) #define uQuadMulUInt(__x, __y, __z) mpz_mul_ui (__z, __x, __y) #define uQuadModUInt(__x, __y, __z) mpz_mod_ui (__z, __x, __y) #define uQuadDivUInt(__x, __y, __z) mpz_fdiv_q_ui (__z, __x, __y) #endif #endif libdfp-1.0.12/libdecnumber/decimal128.h000066400000000000000000000076661261375163000175130ustar00rootroot00000000000000/* Decimal 128-bit format module header for the decNumber C Library. Copyright (C) 2005-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------ */ /* Decimal 128-bit format module header */ /* ------------------------------------------------------------------ */ #if !defined(DECIMAL128) #define DECIMAL128 #define DEC128NAME "decimal128" /* Short name */ #define DEC128FULLNAME "Decimal 128-bit Number" /* Verbose name */ #define DEC128AUTHOR "Mike Cowlishaw" /* Who to blame */ /* parameters for decimal128s */ #define DECIMAL128_Bytes 16 /* length */ #define DECIMAL128_Pmax 34 /* maximum precision (digits) */ #define DECIMAL128_Emax 6144 /* maximum adjusted exponent */ #define DECIMAL128_Emin -6143 /* minimum adjusted exponent */ #define DECIMAL128_Bias 6176 /* bias for the exponent */ #define DECIMAL128_String 43 /* maximum string length, +1 */ #define DECIMAL128_EconL 12 /* exp. continuation length */ /* highest biased exponent (Elimit-1) */ #define DECIMAL128_Ehigh (DECIMAL128_Emax+DECIMAL128_Bias-DECIMAL128_Pmax+1) /* check enough digits, if pre-defined */ #if defined(DECNUMDIGITS) #if (DECNUMDIGITS=34 for safe use #endif #endif #ifndef DECNUMDIGITS #define DECNUMDIGITS DECIMAL128_Pmax /* size if not already defined*/ #endif #ifndef DECNUMBER #include "decNumber.h" /* context and number library */ #endif /* Decimal 128-bit type, accessible by bytes */ typedef struct { uint8_t bytes[DECIMAL128_Bytes]; /* decimal128: 1, 5, 12, 110 bits*/ } decimal128; /* special values [top byte excluding sign bit; last two bits are */ /* don't-care for Infinity on input, last bit don't-care for NaN] */ #if !defined(DECIMAL_NaN) #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */ #define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */ #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */ #endif #include "decimal128Local.h" /* ---------------------------------------------------------------- */ /* Routines */ /* ---------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif /* String conversions */ decimal128 * decimal128FromString(decimal128 *, const char *, decContext *); char * decimal128ToString(const decimal128 *, char *); char * decimal128ToEngString(const decimal128 *, char *); /* decNumber conversions */ decimal128 * decimal128FromNumber(decimal128 *, const decNumber *, decContext *); decNumber * decimal128ToNumber(const decimal128 *, decNumber *); /* Format-dependent utilities */ uint32_t decimal128IsCanonical(const decimal128 *); decimal128 * decimal128Canonical(decimal128 *, const decimal128 *); #ifdef __cplusplus } #endif #endif libdfp-1.0.12/libdecnumber/decimal128Local.h000066400000000000000000000030421261375163000204460ustar00rootroot00000000000000/* Local definitions for use with the decNumber C Library. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ #if !defined(DECIMAL128LOCAL) /* The compiler needs sign manipulation functions for decimal128 which are not part of the decNumber package. */ /* Set sign; this assumes the sign was previously zero. */ #define decimal128SetSign(d,b) \ { (d)->bytes[WORDS_BIGENDIAN ? 0 : 15] |= ((unsigned) (b) << 7); } /* Clear sign. */ #define decimal128ClearSign(d) \ { (d)->bytes[WORDS_BIGENDIAN ? 0 : 15] &= ~0x80; } /* Flip sign. */ #define decimal128FlipSign(d) \ { (d)->bytes[WORDS_BIGENDIAN ? 0 : 15] ^= 0x80; } #endif libdfp-1.0.12/libdecnumber/decimal32.h000066400000000000000000000075301261375163000174130ustar00rootroot00000000000000/* Decimal 32-bit format module header for the decNumber C Library. Copyright (C) 2005-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------ */ /* Decimal 32-bit format module header */ /* ------------------------------------------------------------------ */ #if !defined(DECIMAL32) #define DECIMAL32 #define DEC32NAME "decimal32" /* Short name */ #define DEC32FULLNAME "Decimal 32-bit Number" /* Verbose name */ #define DEC32AUTHOR "Mike Cowlishaw" /* Who to blame */ /* parameters for decimal32s */ #define DECIMAL32_Bytes 4 /* length */ #define DECIMAL32_Pmax 7 /* maximum precision (digits) */ #define DECIMAL32_Emax 96 /* maximum adjusted exponent */ #define DECIMAL32_Emin -95 /* minimum adjusted exponent */ #define DECIMAL32_Bias 101 /* bias for the exponent */ #define DECIMAL32_String 15 /* maximum string length, +1 */ #define DECIMAL32_EconL 6 /* exp. continuation length */ /* highest biased exponent (Elimit-1) */ #define DECIMAL32_Ehigh (DECIMAL32_Emax+DECIMAL32_Bias-DECIMAL32_Pmax+1) /* check enough digits, if pre-defined */ #if defined(DECNUMDIGITS) #if (DECNUMDIGITS=7 for safe use #endif #endif #ifndef DECNUMDIGITS #define DECNUMDIGITS DECIMAL32_Pmax /* size if not already defined*/ #endif #ifndef DECNUMBER #include "decNumber.h" /* context and number library */ #endif /* Decimal 32-bit type, accessible by bytes */ typedef struct { uint8_t bytes[DECIMAL32_Bytes]; /* decimal32: 1, 5, 6, 20 bits*/ } decimal32; /* special values [top byte excluding sign bit; last two bits are */ /* don't-care for Infinity on input, last bit don't-care for NaN] */ #if !defined(DECIMAL_NaN) #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */ #define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */ #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */ #endif /* ---------------------------------------------------------------- */ /* Routines */ /* ---------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif /* String conversions */ decimal32 * decimal32FromString(decimal32 *, const char *, decContext *); char * decimal32ToString(const decimal32 *, char *); char * decimal32ToEngString(const decimal32 *, char *); /* decNumber conversions */ decimal32 * decimal32FromNumber(decimal32 *, const decNumber *, decContext *); decNumber * decimal32ToNumber(const decimal32 *, decNumber *); /* Format-dependent utilities */ uint32_t decimal32IsCanonical(const decimal32 *); decimal32 * decimal32Canonical(decimal32 *, const decimal32 *); #ifdef __cplusplus } #endif #endif libdfp-1.0.12/libdecnumber/decimal64.h000066400000000000000000000075601261375163000174230ustar00rootroot00000000000000/* Decimal 64-bit format module header for the decNumber C Library. Copyright (C) 2005-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------ */ /* Decimal 64-bit format module header */ /* ------------------------------------------------------------------ */ #if !defined(DECIMAL64) #define DECIMAL64 #define DEC64NAME "decimal64" /* Short name */ #define DEC64FULLNAME "Decimal 64-bit Number" /* Verbose name */ #define DEC64AUTHOR "Mike Cowlishaw" /* Who to blame */ /* parameters for decimal64s */ #define DECIMAL64_Bytes 8 /* length */ #define DECIMAL64_Pmax 16 /* maximum precision (digits) */ #define DECIMAL64_Emax 384 /* maximum adjusted exponent */ #define DECIMAL64_Emin -383 /* minimum adjusted exponent */ #define DECIMAL64_Bias 398 /* bias for the exponent */ #define DECIMAL64_String 24 /* maximum string length, +1 */ #define DECIMAL64_EconL 8 /* exp. continuation length */ /* highest biased exponent (Elimit-1) */ #define DECIMAL64_Ehigh (DECIMAL64_Emax+DECIMAL64_Bias-DECIMAL64_Pmax+1) /* check enough digits, if pre-defined */ #if defined(DECNUMDIGITS) #if (DECNUMDIGITS=16 for safe use #endif #endif #ifndef DECNUMDIGITS #define DECNUMDIGITS DECIMAL64_Pmax /* size if not already defined*/ #endif #ifndef DECNUMBER #include "decNumber.h" /* context and number library */ #endif /* Decimal 64-bit type, accessible by bytes */ typedef struct { uint8_t bytes[DECIMAL64_Bytes]; /* decimal64: 1, 5, 8, 50 bits*/ } decimal64; /* special values [top byte excluding sign bit; last two bits are */ /* don't-care for Infinity on input, last bit don't-care for NaN] */ #if !defined(DECIMAL_NaN) #define DECIMAL_NaN 0x7c /* 0 11111 00 NaN */ #define DECIMAL_sNaN 0x7e /* 0 11111 10 sNaN */ #define DECIMAL_Inf 0x78 /* 0 11110 00 Infinity */ #endif /* ---------------------------------------------------------------- */ /* Routines */ /* ---------------------------------------------------------------- */ #ifdef __cplusplus extern "C" { #endif /* String conversions */ decimal64 * decimal64FromString(decimal64 *, const char *, decContext *); char * decimal64ToString(const decimal64 *, char *); char * decimal64ToEngString(const decimal64 *, char *); /* decNumber conversions */ decimal64 * decimal64FromNumber(decimal64 *, const decNumber *, decContext *); decNumber * decimal64ToNumber(const decimal64 *, decNumber *); /* Format-dependent utilities */ uint32_t decimal64IsCanonical(const decimal64 *); decimal64 * decimal64Canonical(decimal64 *, const decimal64 *); #ifdef __cplusplus } #endif #endif libdfp-1.0.12/libdecnumber/dpd/000077500000000000000000000000001261375163000162415ustar00rootroot00000000000000libdfp-1.0.12/libdecnumber/dpd/decimal128.c000066400000000000000000000524131261375163000202430ustar00rootroot00000000000000/* Decimal 128-bit format module for the decNumber C Library. Copyright (C) 2005-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------ */ /* Decimal 128-bit format module */ /* ------------------------------------------------------------------ */ /* This module comprises the routines for decimal128 format numbers. */ /* Conversions are supplied to and from decNumber and String. */ /* */ /* This is used when decNumber provides operations, either for all */ /* operations or as a proxy between decNumber and decSingle. */ /* */ /* Error handling is the same as decNumber (qv.). */ /* ------------------------------------------------------------------ */ #include /* [for memset/memcpy] */ #include /* [for printf] */ #include "dconfig.h" /* GCC definitions */ #define DECNUMDIGITS 34 /* make decNumbers with space for 34 */ #include "decNumber.h" /* base number library */ #include "decNumberLocal.h" /* decNumber local types, etc. */ #include "decimal128.h" /* our primary include */ /* Utility routines and tables [in decimal64.c] */ extern const uInt COMBEXP[32], COMBMSD[32]; extern const uShort DPD2BIN[1024]; extern const uShort BIN2DPD[1000]; /* [not used] */ extern const uByte BIN2CHAR[4001]; extern void decDigitsFromDPD(decNumber *, const uInt *, Int); extern void decDigitsToDPD(const decNumber *, uInt *, Int); #if DECTRACE || DECCHECK void decimal128Show(const decimal128 *); /* for debug */ #endif /* Useful macro */ /* Clear a structure (e.g., a decNumber) */ #define DEC_clear(d) memset(d, 0, sizeof(*d)) /* ------------------------------------------------------------------ */ /* decimal128FromNumber -- convert decNumber to decimal128 */ /* */ /* ds is the target decimal128 */ /* dn is the source number (assumed valid) */ /* set is the context, used only for reporting errors */ /* */ /* The set argument is used only for status reporting and for the */ /* rounding mode (used if the coefficient is more than DECIMAL128_Pmax*/ /* digits or an overflow is detected). If the exponent is out of the */ /* valid range then Overflow or Underflow will be raised. */ /* After Underflow a subnormal result is possible. */ /* */ /* DEC_Clamped is set if the number has to be 'folded down' to fit, */ /* by reducing its exponent and multiplying the coefficient by a */ /* power of ten, or if the exponent on a zero had to be clamped. */ /* ------------------------------------------------------------------ */ decimal128 * decimal128FromNumber(decimal128 *d128, const decNumber *dn, decContext *set) { uInt status=0; /* status accumulator */ Int ae; /* adjusted exponent */ decNumber dw; /* work */ decContext dc; /* .. */ uInt comb, exp; /* .. */ uInt uiwork; /* for macros */ uInt targar[4]={0,0,0,0}; /* target 128-bit */ #define targhi targar[3] /* name the word with the sign */ #define targmh targar[2] /* name the words */ #define targml targar[1] /* .. */ #define targlo targar[0] /* .. */ /* If the number has too many digits, or the exponent could be */ /* out of range then reduce the number under the appropriate */ /* constraints. This could push the number to Infinity or zero, */ /* so this check and rounding must be done before generating the */ /* decimal128] */ ae=dn->exponent+dn->digits-1; /* [0 if special] */ if (dn->digits>DECIMAL128_Pmax /* too many digits */ || ae>DECIMAL128_Emax /* likely overflow */ || aeround; /* use supplied rounding */ decNumberPlus(&dw, dn, &dc); /* (round and check) */ /* [this changes -0 to 0, so enforce the sign...] */ dw.bits|=dn->bits&DECNEG; status=dc.status; /* save status */ dn=&dw; /* use the work number */ } /* maybe out of range */ if (dn->bits&DECSPECIAL) { /* a special value */ if (dn->bits&DECINF) targhi=DECIMAL_Inf<<24; else { /* sNaN or qNaN */ if ((*dn->lsu!=0 || dn->digits>1) /* non-zero coefficient */ && (dn->digitsbits&DECNAN) targhi|=DECIMAL_NaN<<24; else targhi|=DECIMAL_sNaN<<24; } /* a NaN */ } /* special */ else { /* is finite */ if (decNumberIsZero(dn)) { /* is a zero */ /* set and clamp exponent */ if (dn->exponent<-DECIMAL128_Bias) { exp=0; /* low clamp */ status|=DEC_Clamped; } else { exp=dn->exponent+DECIMAL128_Bias; /* bias exponent */ if (exp>DECIMAL128_Ehigh) { /* top clamp */ exp=DECIMAL128_Ehigh; status|=DEC_Clamped; } } comb=(exp>>9) & 0x18; /* msd=0, exp top 2 bits .. */ } else { /* non-zero finite number */ uInt msd; /* work */ Int pad=0; /* coefficient pad digits */ /* the dn is known to fit, but it may need to be padded */ exp=(uInt)(dn->exponent+DECIMAL128_Bias); /* bias exponent */ if (exp>DECIMAL128_Ehigh) { /* fold-down case */ pad=exp-DECIMAL128_Ehigh; exp=DECIMAL128_Ehigh; /* [to maximum] */ status|=DEC_Clamped; } /* [fastpath for common case is not a win, here] */ decDigitsToDPD(dn, targar, pad); /* save and clear the top digit */ msd=targhi>>14; targhi&=0x00003fff; /* create the combination field */ if (msd>=8) comb=0x18 | ((exp>>11) & 0x06) | (msd & 0x01); else comb=((exp>>9) & 0x18) | msd; } targhi|=comb<<26; /* add combination field .. */ targhi|=(exp&0xfff)<<14; /* .. and exponent continuation */ } /* finite */ if (dn->bits&DECNEG) targhi|=0x80000000; /* add sign bit */ /* now write to storage; this is endian */ /* hi -> lo */ UBFROMUIBW(d128->bytes, targhi); UBFROMUIBW(d128->bytes+4, targmh); UBFROMUIBW(d128->bytes+8, targml); UBFROMUIBW(d128->bytes+12, targlo); if (status!=0) decContextSetStatus(set, status); /* pass on status */ /* decimal128Show(d128); */ return d128; } /* decimal128FromNumber */ /* ------------------------------------------------------------------ */ /* decimal128ToNumber -- convert decimal128 to decNumber */ /* d128 is the source decimal128 */ /* dn is the target number, with appropriate space */ /* No error is possible. */ /* ------------------------------------------------------------------ */ decNumber * decimal128ToNumber(const decimal128 *d128, decNumber *dn) { uInt msd; /* coefficient MSD */ uInt exp; /* exponent top two bits */ uInt comb; /* combination field */ Int need; /* work */ uInt uiwork; /* for macros */ uInt sourar[4]; /* source 128-bit */ #define sourhi sourar[3] /* name the word with the sign */ #define sourmh sourar[2] /* and the mid-high word */ #define sourml sourar[1] /* and the mod-low word */ #define sourlo sourar[0] /* and the lowest word */ /* load source from storage; this is endian */ sourhi=UBTOUIBW(d128->bytes ); /* directly load the high int */ sourmh=UBTOUIBW(d128->bytes+4 ); /* then the mid-high */ sourml=UBTOUIBW(d128->bytes+8 ); /* then the mid-low */ sourlo=UBTOUIBW(d128->bytes+12); /* then the low int */ comb=(sourhi>>26)&0x1f; /* combination field */ decNumberZero(dn); /* clean number */ if (sourhi&0x80000000) dn->bits=DECNEG; /* set sign if negative */ msd=COMBMSD[comb]; /* decode the combination field */ exp=COMBEXP[comb]; /* .. */ if (exp==3) { /* is a special */ if (msd==0) { dn->bits|=DECINF; return dn; /* no coefficient needed */ } else if (sourhi&0x02000000) dn->bits|=DECSNAN; else dn->bits|=DECNAN; msd=0; /* no top digit */ } else { /* is a finite number */ dn->exponent=(exp<<12)+((sourhi>>14)&0xfff)-DECIMAL128_Bias; /* unbiased */ } /* get the coefficient */ sourhi&=0x00003fff; /* clean coefficient continuation */ if (msd) { /* non-zero msd */ sourhi|=msd<<14; /* prefix to coefficient */ need=12; /* process 12 declets */ } else { /* msd=0 */ if (sourhi) need=11; /* declets to process */ else if (sourmh) need=10; else if (sourml) need=7; else if (sourlo) need=4; else return dn; /* easy: coefficient is 0 */ } /*msd=0 */ decDigitsFromDPD(dn, sourar, need); /* process declets */ /* decNumberShow(dn); */ return dn; } /* decimal128ToNumber */ /* ------------------------------------------------------------------ */ /* to-scientific-string -- conversion to numeric string */ /* to-engineering-string -- conversion to numeric string */ /* */ /* decimal128ToString(d128, string); */ /* decimal128ToEngString(d128, string); */ /* */ /* d128 is the decimal128 format number to convert */ /* string is the string where the result will be laid out */ /* */ /* string must be at least 24 characters */ /* */ /* No error is possible, and no status can be set. */ /* ------------------------------------------------------------------ */ char * decimal128ToEngString(const decimal128 *d128, char *string){ decNumber dn; /* work */ decimal128ToNumber(d128, &dn); decNumberToEngString(&dn, string); return string; } /* decimal128ToEngString */ char * decimal128ToString(const decimal128 *d128, char *string){ uInt msd; /* coefficient MSD */ Int exp; /* exponent top two bits or full */ uInt comb; /* combination field */ char *cstart; /* coefficient start */ char *c; /* output pointer in string */ const uByte *u; /* work */ char *s, *t; /* .. (source, target) */ Int dpd; /* .. */ Int pre, e; /* .. */ uInt uiwork; /* for macros */ uInt sourar[4]; /* source 128-bit */ #define sourhi sourar[3] /* name the word with the sign */ #define sourmh sourar[2] /* and the mid-high word */ #define sourml sourar[1] /* and the mod-low word */ #define sourlo sourar[0] /* and the lowest word */ /* load source from storage; this is endian */ if (DECLITEND) { sourlo=UBTOUI(d128->bytes ); /* directly load the low int */ sourml=UBTOUI(d128->bytes+4 ); /* then the mid-low */ sourmh=UBTOUI(d128->bytes+8 ); /* then the mid-high */ sourhi=UBTOUI(d128->bytes+12); /* then the high int */ } else { sourhi=UBTOUI(d128->bytes ); /* directly load the high int */ sourmh=UBTOUI(d128->bytes+4 ); /* then the mid-high */ sourml=UBTOUI(d128->bytes+8 ); /* then the mid-low */ sourlo=UBTOUI(d128->bytes+12); /* then the low int */ } c=string; /* where result will go */ if (((Int)sourhi)<0) *c++='-'; /* handle sign */ comb=(sourhi>>26)&0x1f; /* combination field */ msd=COMBMSD[comb]; /* decode the combination field */ exp=COMBEXP[comb]; /* .. */ if (exp==3) { if (msd==0) { /* infinity */ strcpy(c, "Inf"); strcpy(c+3, "inity"); return string; /* easy */ } if (sourhi&0x02000000) *c++='s'; /* sNaN */ strcpy(c, "NaN"); /* complete word */ c+=3; /* step past */ if (sourlo==0 && sourml==0 && sourmh==0 && (sourhi&0x0003ffff)==0) return string; /* zero payload */ /* otherwise drop through to add integer; set correct exp */ exp=0; msd=0; /* setup for following code */ } else exp=(exp<<12)+((sourhi>>14)&0xfff)-DECIMAL128_Bias; /* unbiased */ /* convert 34 digits of significand to characters */ cstart=c; /* save start of coefficient */ if (msd) *c++='0'+(char)msd; /* non-zero most significant digit */ /* Now decode the declets. After extracting each one, it is */ /* decoded to binary and then to a 4-char sequence by table lookup; */ /* the 4-chars are a 1-char length (significant digits, except 000 */ /* has length 0). This allows us to left-align the first declet */ /* with non-zero content, then remaining ones are full 3-char */ /* length. We use fixed-length memcpys because variable-length */ /* causes a subroutine call in GCC. (These are length 4 for speed */ /* and are safe because the array has an extra terminator byte.) */ #define dpd2char u=&BIN2CHAR[DPD2BIN[dpd]*4]; \ if (c!=cstart) {memcpy(c, u+1, 4); c+=3;} \ else if (*u) {memcpy(c, u+4-*u, 4); c+=*u;} dpd=(sourhi>>4)&0x3ff; /* declet 1 */ dpd2char; dpd=((sourhi&0xf)<<6) | (sourmh>>26); /* declet 2 */ dpd2char; dpd=(sourmh>>16)&0x3ff; /* declet 3 */ dpd2char; dpd=(sourmh>>6)&0x3ff; /* declet 4 */ dpd2char; dpd=((sourmh&0x3f)<<4) | (sourml>>28); /* declet 5 */ dpd2char; dpd=(sourml>>18)&0x3ff; /* declet 6 */ dpd2char; dpd=(sourml>>8)&0x3ff; /* declet 7 */ dpd2char; dpd=((sourml&0xff)<<2) | (sourlo>>30); /* declet 8 */ dpd2char; dpd=(sourlo>>20)&0x3ff; /* declet 9 */ dpd2char; dpd=(sourlo>>10)&0x3ff; /* declet 10 */ dpd2char; dpd=(sourlo)&0x3ff; /* declet 11 */ dpd2char; if (c==cstart) *c++='0'; /* all zeros -- make 0 */ if (exp==0) { /* integer or NaN case -- easy */ *c='\0'; /* terminate */ return string; } /* non-0 exponent */ e=0; /* assume no E */ pre=c-cstart+exp; /* [here, pre-exp is the digits count (==1 for zero)] */ if (exp>0 || pre<-5) { /* need exponential form */ e=pre-1; /* calculate E value */ pre=1; /* assume one digit before '.' */ } /* exponential form */ /* modify the coefficient, adding 0s, '.', and E+nn as needed */ s=c-1; /* source (LSD) */ if (pre>0) { /* ddd.ddd (plain), perhaps with E */ char *dotat=cstart+pre; if (dotat=dotat; s--, t--) *t=*s; /* open the gap; leave t at gap */ *t='.'; /* insert the dot */ c++; /* length increased by one */ } /* finally add the E-part, if needed; it will never be 0, and has */ /* a maximum length of 4 digits */ if (e!=0) { *c++='E'; /* starts with E */ *c++='+'; /* assume positive */ if (e<0) { *(c-1)='-'; /* oops, need '-' */ e=-e; /* uInt, please */ } if (e<1000) { /* 3 (or fewer) digits case */ u=&BIN2CHAR[e*4]; /* -> length byte */ memcpy(c, u+4-*u, 4); /* copy fixed 4 characters [is safe] */ c+=*u; /* bump pointer appropriately */ } else { /* 4-digits */ Int thou=((e>>3)*1049)>>17; /* e/1000 */ Int rem=e-(1000*thou); /* e%1000 */ *c++='0'+(char)thou; u=&BIN2CHAR[rem*4]; /* -> length byte */ memcpy(c, u+1, 4); /* copy fixed 3+1 characters [is safe] */ c+=3; /* bump pointer, always 3 digits */ } } *c='\0'; /* add terminator */ /*printf("res %s\n", string); */ return string; } /* pre>0 */ /* -5<=pre<=0: here for plain 0.ddd or 0.000ddd forms (can never have E) */ t=c+1-pre; *(t+1)='\0'; /* can add terminator now */ for (; s>=cstart; s--, t--) *t=*s; /* shift whole coefficient right */ c=cstart; *c++='0'; /* always starts with 0. */ *c++='.'; for (; pre<0; pre++) *c++='0'; /* add any 0's after '.' */ /*printf("res %s\n", string); */ return string; } /* decimal128ToString */ /* ------------------------------------------------------------------ */ /* to-number -- conversion from numeric string */ /* */ /* decimal128FromString(result, string, set); */ /* */ /* result is the decimal128 format number which gets the result of */ /* the conversion */ /* *string is the character string which should contain a valid */ /* number (which may be a special value) */ /* set is the context */ /* */ /* The context is supplied to this routine is used for error handling */ /* (setting of status and traps) and for the rounding mode, only. */ /* If an error occurs, the result will be a valid decimal128 NaN. */ /* ------------------------------------------------------------------ */ decimal128 * decimal128FromString(decimal128 *result, const char *string, decContext *set) { decContext dc; /* work */ decNumber dn; /* .. */ decContextDefault(&dc, DEC_INIT_DECIMAL128); /* no traps, please */ dc.round=set->round; /* use supplied rounding */ decNumberFromString(&dn, string, &dc); /* will round if needed */ decimal128FromNumber(result, &dn, &dc); if (dc.status!=0) { /* something happened */ decContextSetStatus(set, dc.status); /* .. pass it on */ } return result; } /* decimal128FromString */ /* ------------------------------------------------------------------ */ /* decimal128IsCanonical -- test whether encoding is canonical */ /* d128 is the source decimal128 */ /* returns 1 if the encoding of d128 is canonical, 0 otherwise */ /* No error is possible. */ /* ------------------------------------------------------------------ */ uInt decimal128IsCanonical(const decimal128 *d128) { decNumber dn; /* work */ decimal128 canon; /* .. */ decContext dc; /* .. */ decContextDefault(&dc, DEC_INIT_DECIMAL128); decimal128ToNumber(d128, &dn); decimal128FromNumber(&canon, &dn, &dc);/* canon will now be canonical */ return memcmp(d128, &canon, DECIMAL128_Bytes)==0; } /* decimal128IsCanonical */ /* ------------------------------------------------------------------ */ /* decimal128Canonical -- copy an encoding, ensuring it is canonical */ /* d128 is the source decimal128 */ /* result is the target (may be the same decimal128) */ /* returns result */ /* No error is possible. */ /* ------------------------------------------------------------------ */ decimal128 * decimal128Canonical(decimal128 *result, const decimal128 *d128) { decNumber dn; /* work */ decContext dc; /* .. */ decContextDefault(&dc, DEC_INIT_DECIMAL128); decimal128ToNumber(d128, &dn); decimal128FromNumber(result, &dn, &dc);/* result will now be canonical */ return result; } /* decimal128Canonical */ #if DECTRACE || DECCHECK /* Macros for accessing decimal128 fields. These assume the argument is a reference (pointer) to the decimal128 structure, and the decimal128 is in network byte order (big-endian) */ /* Get sign */ #define decimal128Sign(d) ((unsigned)(d)->bytes[0]>>7) /* Get combination field */ #define decimal128Comb(d) (((d)->bytes[0] & 0x7c)>>2) /* Get exponent continuation [does not remove bias] */ #define decimal128ExpCon(d) ((((d)->bytes[0] & 0x03)<<10) \ | ((unsigned)(d)->bytes[1]<<2) \ | ((unsigned)(d)->bytes[2]>>6)) /* Set sign [this assumes sign previously 0] */ #define decimal128SetSign(d, b) { \ (d)->bytes[0]|=((unsigned)(b)<<7);} /* Set exponent continuation [does not apply bias] */ /* This assumes range has been checked and exponent previously 0; */ /* type of exponent must be unsigned */ #define decimal128SetExpCon(d, e) { \ (d)->bytes[0]|=(uByte)((e)>>10); \ (d)->bytes[1] =(uByte)(((e)&0x3fc)>>2); \ (d)->bytes[2]|=(uByte)(((e)&0x03)<<6);} /* ------------------------------------------------------------------ */ /* decimal128Show -- display a decimal128 in hexadecimal [debug aid] */ /* d128 -- the number to show */ /* ------------------------------------------------------------------ */ /* Also shows sign/cob/expconfields extracted */ void decimal128Show(const decimal128 *d128) { char buf[DECIMAL128_Bytes*2+1]; Int i, j=0; if (DECLITEND) { for (i=0; ibytes[15-i]); } printf(" D128> %s [S:%d Cb:%02x Ec:%02x] LittleEndian\n", buf, d128->bytes[15]>>7, (d128->bytes[15]>>2)&0x1f, ((d128->bytes[15]&0x3)<<10)|(d128->bytes[14]<<2)| (d128->bytes[13]>>6)); } else { for (i=0; ibytes[i]); } printf(" D128> %s [S:%d Cb:%02x Ec:%02x] BigEndian\n", buf, decimal128Sign(d128), decimal128Comb(d128), decimal128ExpCon(d128)); } } /* decimal128Show */ #endif libdfp-1.0.12/libdecnumber/dpd/decimal32.c000066400000000000000000000453611261375163000201610ustar00rootroot00000000000000/* Decimal 32-bit format module for the decNumber C Library. Copyright (C) 2005-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------ */ /* Decimal 32-bit format module */ /* ------------------------------------------------------------------ */ /* This module comprises the routines for decimal32 format numbers. */ /* Conversions are supplied to and from decNumber and String. */ /* */ /* This is used when decNumber provides operations, either for all */ /* operations or as a proxy between decNumber and decSingle. */ /* */ /* Error handling is the same as decNumber (qv.). */ /* ------------------------------------------------------------------ */ #include /* [for memset/memcpy] */ #include /* [for printf] */ #include "dconfig.h" /* GCC definitions */ #define DECNUMDIGITS 7 /* make decNumbers with space for 7 */ #include "decNumber.h" /* base number library */ #include "decNumberLocal.h" /* decNumber local types, etc. */ #include "decimal32.h" /* our primary include */ /* Utility tables and routines [in decimal64.c] */ extern const uInt COMBEXP[32], COMBMSD[32]; extern const uShort DPD2BIN[1024]; extern const uShort BIN2DPD[1000]; extern const uByte BIN2CHAR[4001]; extern void decDigitsToDPD(const decNumber *, uInt *, Int); extern void decDigitsFromDPD(decNumber *, const uInt *, Int); #if DECTRACE || DECCHECK void decimal32Show(const decimal32 *); /* for debug */ #endif /* Useful macro */ /* Clear a structure (e.g., a decNumber) */ #define DEC_clear(d) memset(d, 0, sizeof(*d)) /* ------------------------------------------------------------------ */ /* decimal32FromNumber -- convert decNumber to decimal32 */ /* */ /* ds is the target decimal32 */ /* dn is the source number (assumed valid) */ /* set is the context, used only for reporting errors */ /* */ /* The set argument is used only for status reporting and for the */ /* rounding mode (used if the coefficient is more than DECIMAL32_Pmax */ /* digits or an overflow is detected). If the exponent is out of the */ /* valid range then Overflow or Underflow will be raised. */ /* After Underflow a subnormal result is possible. */ /* */ /* DEC_Clamped is set if the number has to be 'folded down' to fit, */ /* by reducing its exponent and multiplying the coefficient by a */ /* power of ten, or if the exponent on a zero had to be clamped. */ /* ------------------------------------------------------------------ */ decimal32 * decimal32FromNumber(decimal32 *d32, const decNumber *dn, decContext *set) { uInt status=0; /* status accumulator */ Int ae; /* adjusted exponent */ decNumber dw; /* work */ decContext dc; /* .. */ uInt comb, exp; /* .. */ uInt uiwork; /* for macros */ uInt targ=0; /* target 32-bit */ /* If the number has too many digits, or the exponent could be */ /* out of range then reduce the number under the appropriate */ /* constraints. This could push the number to Infinity or zero, */ /* so this check and rounding must be done before generating the */ /* decimal32] */ ae=dn->exponent+dn->digits-1; /* [0 if special] */ if (dn->digits>DECIMAL32_Pmax /* too many digits */ || ae>DECIMAL32_Emax /* likely overflow */ || aeround; /* use supplied rounding */ decNumberPlus(&dw, dn, &dc); /* (round and check) */ /* [this changes -0 to 0, so enforce the sign...] */ dw.bits|=dn->bits&DECNEG; status=dc.status; /* save status */ dn=&dw; /* use the work number */ } /* maybe out of range */ if (dn->bits&DECSPECIAL) { /* a special value */ if (dn->bits&DECINF) targ=DECIMAL_Inf<<24; else { /* sNaN or qNaN */ if ((*dn->lsu!=0 || dn->digits>1) /* non-zero coefficient */ && (dn->digitsbits&DECNAN) targ|=DECIMAL_NaN<<24; else targ|=DECIMAL_sNaN<<24; } /* a NaN */ } /* special */ else { /* is finite */ if (decNumberIsZero(dn)) { /* is a zero */ /* set and clamp exponent */ if (dn->exponent<-DECIMAL32_Bias) { exp=0; /* low clamp */ status|=DEC_Clamped; } else { exp=dn->exponent+DECIMAL32_Bias; /* bias exponent */ if (exp>DECIMAL32_Ehigh) { /* top clamp */ exp=DECIMAL32_Ehigh; status|=DEC_Clamped; } } comb=(exp>>3) & 0x18; /* msd=0, exp top 2 bits .. */ } else { /* non-zero finite number */ uInt msd; /* work */ Int pad=0; /* coefficient pad digits */ /* the dn is known to fit, but it may need to be padded */ exp=(uInt)(dn->exponent+DECIMAL32_Bias); /* bias exponent */ if (exp>DECIMAL32_Ehigh) { /* fold-down case */ pad=exp-DECIMAL32_Ehigh; exp=DECIMAL32_Ehigh; /* [to maximum] */ status|=DEC_Clamped; } /* fastpath common case */ if (DECDPUN==3 && pad==0) { targ=BIN2DPD[dn->lsu[0]]; if (dn->digits>3) targ|=(uInt)(BIN2DPD[dn->lsu[1]])<<10; msd=(dn->digits==7 ? dn->lsu[2] : 0); } else { /* general case */ decDigitsToDPD(dn, &targ, pad); /* save and clear the top digit */ msd=targ>>20; targ&=0x000fffff; } /* create the combination field */ if (msd>=8) comb=0x18 | ((exp>>5) & 0x06) | (msd & 0x01); else comb=((exp>>3) & 0x18) | msd; } targ|=comb<<26; /* add combination field .. */ targ|=(exp&0x3f)<<20; /* .. and exponent continuation */ } /* finite */ if (dn->bits&DECNEG) targ|=0x80000000; /* add sign bit */ /* now write to storage; this is endian */ UBFROMUIBW(d32->bytes, targ); /* directly store the int */ if (status!=0) decContextSetStatus(set, status); /* pass on status */ /* decimal32Show(d32); */ return d32; } /* decimal32FromNumber */ /* ------------------------------------------------------------------ */ /* decimal32ToNumber -- convert decimal32 to decNumber */ /* d32 is the source decimal32 */ /* dn is the target number, with appropriate space */ /* No error is possible. */ /* ------------------------------------------------------------------ */ decNumber * decimal32ToNumber(const decimal32 *d32, decNumber *dn) { uInt msd; /* coefficient MSD */ uInt exp; /* exponent top two bits */ uInt comb; /* combination field */ uInt sour; /* source 32-bit */ uInt uiwork; /* for macros */ /* load source from storage; this is endian */ sour=UBTOUIBW(d32->bytes); /* directly load the int */ comb=(sour>>26)&0x1f; /* combination field */ decNumberZero(dn); /* clean number */ if (sour&0x80000000) dn->bits=DECNEG; /* set sign if negative */ msd=COMBMSD[comb]; /* decode the combination field */ exp=COMBEXP[comb]; /* .. */ if (exp==3) { /* is a special */ if (msd==0) { dn->bits|=DECINF; return dn; /* no coefficient needed */ } else if (sour&0x02000000) dn->bits|=DECSNAN; else dn->bits|=DECNAN; msd=0; /* no top digit */ } else { /* is a finite number */ dn->exponent=(exp<<6)+((sour>>20)&0x3f)-DECIMAL32_Bias; /* unbiased */ } /* get the coefficient */ sour&=0x000fffff; /* clean coefficient continuation */ if (msd) { /* non-zero msd */ sour|=msd<<20; /* prefix to coefficient */ decDigitsFromDPD(dn, &sour, 3); /* process 3 declets */ return dn; } /* msd=0 */ if (!sour) return dn; /* easy: coefficient is 0 */ if (sour&0x000ffc00) /* need 2 declets? */ decDigitsFromDPD(dn, &sour, 2); /* process 2 declets */ else decDigitsFromDPD(dn, &sour, 1); /* process 1 declet */ return dn; } /* decimal32ToNumber */ /* ------------------------------------------------------------------ */ /* to-scientific-string -- conversion to numeric string */ /* to-engineering-string -- conversion to numeric string */ /* */ /* decimal32ToString(d32, string); */ /* decimal32ToEngString(d32, string); */ /* */ /* d32 is the decimal32 format number to convert */ /* string is the string where the result will be laid out */ /* */ /* string must be at least 24 characters */ /* */ /* No error is possible, and no status can be set. */ /* ------------------------------------------------------------------ */ char * decimal32ToEngString(const decimal32 *d32, char *string){ decNumber dn; /* work */ decimal32ToNumber(d32, &dn); decNumberToEngString(&dn, string); return string; } /* decimal32ToEngString */ char * decimal32ToString(const decimal32 *d32, char *string){ uInt msd; /* coefficient MSD */ Int exp; /* exponent top two bits or full */ uInt comb; /* combination field */ char *cstart; /* coefficient start */ char *c; /* output pointer in string */ const uByte *u; /* work */ char *s, *t; /* .. (source, target) */ Int dpd; /* .. */ Int pre, e; /* .. */ uInt uiwork; /* for macros */ uInt sour; /* source 32-bit */ /* load source from storage; this is endian */ sour=UBTOUI(d32->bytes); /* directly load the int */ c=string; /* where result will go */ if (((Int)sour)<0) *c++='-'; /* handle sign */ comb=(sour>>26)&0x1f; /* combination field */ msd=COMBMSD[comb]; /* decode the combination field */ exp=COMBEXP[comb]; /* .. */ if (exp==3) { if (msd==0) { /* infinity */ strcpy(c, "Inf"); strcpy(c+3, "inity"); return string; /* easy */ } if (sour&0x02000000) *c++='s'; /* sNaN */ strcpy(c, "NaN"); /* complete word */ c+=3; /* step past */ if ((sour&0x000fffff)==0) return string; /* zero payload */ /* otherwise drop through to add integer; set correct exp */ exp=0; msd=0; /* setup for following code */ } else exp=(exp<<6)+((sour>>20)&0x3f)-DECIMAL32_Bias; /* unbiased */ /* convert 7 digits of significand to characters */ cstart=c; /* save start of coefficient */ if (msd) *c++='0'+(char)msd; /* non-zero most significant digit */ /* Now decode the declets. After extracting each one, it is */ /* decoded to binary and then to a 4-char sequence by table lookup; */ /* the 4-chars are a 1-char length (significant digits, except 000 */ /* has length 0). This allows us to left-align the first declet */ /* with non-zero content, then remaining ones are full 3-char */ /* length. We use fixed-length memcpys because variable-length */ /* causes a subroutine call in GCC. (These are length 4 for speed */ /* and are safe because the array has an extra terminator byte.) */ #define dpd2char u=&BIN2CHAR[DPD2BIN[dpd]*4]; \ if (c!=cstart) {memcpy(c, u+1, 4); c+=3;} \ else if (*u) {memcpy(c, u+4-*u, 4); c+=*u;} dpd=(sour>>10)&0x3ff; /* declet 1 */ dpd2char; dpd=(sour)&0x3ff; /* declet 2 */ dpd2char; if (c==cstart) *c++='0'; /* all zeros -- make 0 */ if (exp==0) { /* integer or NaN case -- easy */ *c='\0'; /* terminate */ return string; } /* non-0 exponent */ e=0; /* assume no E */ pre=c-cstart+exp; /* [here, pre-exp is the digits count (==1 for zero)] */ if (exp>0 || pre<-5) { /* need exponential form */ e=pre-1; /* calculate E value */ pre=1; /* assume one digit before '.' */ } /* exponential form */ /* modify the coefficient, adding 0s, '.', and E+nn as needed */ s=c-1; /* source (LSD) */ if (pre>0) { /* ddd.ddd (plain), perhaps with E */ char *dotat=cstart+pre; if (dotat=dotat; s--, t--) *t=*s; /* open the gap; leave t at gap */ *t='.'; /* insert the dot */ c++; /* length increased by one */ } /* finally add the E-part, if needed; it will never be 0, and has */ /* a maximum length of 3 digits (E-101 case) */ if (e!=0) { *c++='E'; /* starts with E */ *c++='+'; /* assume positive */ if (e<0) { *(c-1)='-'; /* oops, need '-' */ e=-e; /* uInt, please */ } u=&BIN2CHAR[e*4]; /* -> length byte */ memcpy(c, u+4-*u, 4); /* copy fixed 4 characters [is safe] */ c+=*u; /* bump pointer appropriately */ } *c='\0'; /* add terminator */ /*printf("res %s\n", string); */ return string; } /* pre>0 */ /* -5<=pre<=0: here for plain 0.ddd or 0.000ddd forms (can never have E) */ t=c+1-pre; *(t+1)='\0'; /* can add terminator now */ for (; s>=cstart; s--, t--) *t=*s; /* shift whole coefficient right */ c=cstart; *c++='0'; /* always starts with 0. */ *c++='.'; for (; pre<0; pre++) *c++='0'; /* add any 0's after '.' */ /*printf("res %s\n", string); */ return string; } /* decimal32ToString */ /* ------------------------------------------------------------------ */ /* to-number -- conversion from numeric string */ /* */ /* decimal32FromString(result, string, set); */ /* */ /* result is the decimal32 format number which gets the result of */ /* the conversion */ /* *string is the character string which should contain a valid */ /* number (which may be a special value) */ /* set is the context */ /* */ /* The context is supplied to this routine is used for error handling */ /* (setting of status and traps) and for the rounding mode, only. */ /* If an error occurs, the result will be a valid decimal32 NaN. */ /* ------------------------------------------------------------------ */ decimal32 * decimal32FromString(decimal32 *result, const char *string, decContext *set) { decContext dc; /* work */ decNumber dn; /* .. */ decContextDefault(&dc, DEC_INIT_DECIMAL32); /* no traps, please */ dc.round=set->round; /* use supplied rounding */ decNumberFromString(&dn, string, &dc); /* will round if needed */ decimal32FromNumber(result, &dn, &dc); if (dc.status!=0) { /* something happened */ decContextSetStatus(set, dc.status); /* .. pass it on */ } return result; } /* decimal32FromString */ /* ------------------------------------------------------------------ */ /* decimal32IsCanonical -- test whether encoding is canonical */ /* d32 is the source decimal32 */ /* returns 1 if the encoding of d32 is canonical, 0 otherwise */ /* No error is possible. */ /* ------------------------------------------------------------------ */ uInt decimal32IsCanonical(const decimal32 *d32) { decNumber dn; /* work */ decimal32 canon; /* .. */ decContext dc; /* .. */ decContextDefault(&dc, DEC_INIT_DECIMAL32); decimal32ToNumber(d32, &dn); decimal32FromNumber(&canon, &dn, &dc);/* canon will now be canonical */ return memcmp(d32, &canon, DECIMAL32_Bytes)==0; } /* decimal32IsCanonical */ /* ------------------------------------------------------------------ */ /* decimal32Canonical -- copy an encoding, ensuring it is canonical */ /* d32 is the source decimal32 */ /* result is the target (may be the same decimal32) */ /* returns result */ /* No error is possible. */ /* ------------------------------------------------------------------ */ decimal32 * decimal32Canonical(decimal32 *result, const decimal32 *d32) { decNumber dn; /* work */ decContext dc; /* .. */ decContextDefault(&dc, DEC_INIT_DECIMAL32); decimal32ToNumber(d32, &dn); decimal32FromNumber(result, &dn, &dc);/* result will now be canonical */ return result; } /* decimal32Canonical */ #if DECTRACE || DECCHECK /* Macros for accessing decimal32 fields. These assume the argument is a reference (pointer) to the decimal32 structure, and the decimal32 is in network byte order (big-endian) */ /* Get sign */ #define decimal32Sign(d) ((unsigned)(d)->bytes[0]>>7) /* Get combination field */ #define decimal32Comb(d) (((d)->bytes[0] & 0x7c)>>2) /* Get exponent continuation [does not remove bias] */ #define decimal32ExpCon(d) ((((d)->bytes[0] & 0x03)<<4) \ | ((unsigned)(d)->bytes[1]>>4)) /* Set sign [this assumes sign previously 0] */ #define decimal32SetSign(d, b) { \ (d)->bytes[0]|=((unsigned)(b)<<7);} /* Set exponent continuation [does not apply bias] */ /* This assumes range has been checked and exponent previously 0; */ /* type of exponent must be unsigned */ #define decimal32SetExpCon(d, e) { \ (d)->bytes[0]|=(uByte)((e)>>4); \ (d)->bytes[1]|=(uByte)(((e)&0x0F)<<4);} /* ------------------------------------------------------------------ */ /* decimal32Show -- display a decimal32 in hexadecimal [debug aid] */ /* d32 -- the number to show */ /* ------------------------------------------------------------------ */ /* Also shows sign/cob/expconfields extracted - valid bigendian only */ void decimal32Show(const decimal32 *d32) { char buf[DECIMAL32_Bytes*2+1]; Int i, j=0; if (DECLITEND) { for (i=0; ibytes[3-i]); } printf(" D32> %s [S:%d Cb:%02x Ec:%02x] LittleEndian\n", buf, d32->bytes[3]>>7, (d32->bytes[3]>>2)&0x1f, ((d32->bytes[3]&0x3)<<4)| (d32->bytes[2]>>4)); } else { for (i=0; ibytes[i]); } printf(" D32> %s [S:%d Cb:%02x Ec:%02x] BigEndian\n", buf, decimal32Sign(d32), decimal32Comb(d32), decimal32ExpCon(d32)); } } /* decimal32Show */ #endif libdfp-1.0.12/libdecnumber/dpd/decimal64.c000066400000000000000000000733131261375163000201640ustar00rootroot00000000000000/* Decimal 64-bit format module for the decNumber C Library. Copyright (C) 2005-2015 Free Software Foundation, Inc. Contributed by IBM Corporation. Author Mike Cowlishaw. This file is part of GCC. GCC 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, or (at your option) any later version. GCC 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. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* ------------------------------------------------------------------ */ /* Decimal 64-bit format module */ /* ------------------------------------------------------------------ */ /* This module comprises the routines for decimal64 format numbers. */ /* Conversions are supplied to and from decNumber and String. */ /* */ /* This is used when decNumber provides operations, either for all */ /* operations or as a proxy between decNumber and decSingle. */ /* */ /* Error handling is the same as decNumber (qv.). */ /* ------------------------------------------------------------------ */ #include /* [for memset/memcpy] */ #include /* [for printf] */ #include "dconfig.h" /* GCC definitions */ #define DECNUMDIGITS 16 /* make decNumbers with space for 16 */ #include "decNumber.h" /* base number library */ #include "decNumberLocal.h" /* decNumber local types, etc. */ #include "decimal64.h" /* our primary include */ /* Utility routines and tables [in decimal64.c]; externs for C++ */ extern const uInt COMBEXP[32], COMBMSD[32]; extern const uShort DPD2BIN[1024]; extern const uShort BIN2DPD[1000]; extern const uByte BIN2CHAR[4001]; extern void decDigitsFromDPD(decNumber *, const uInt *, Int); extern void decDigitsToDPD(const decNumber *, uInt *, Int); /* Useful macro */ /* Clear a structure (e.g., a decNumber) */ #define DEC_clear(d) memset(d, 0, sizeof(*d)) /* define and include the tables to use for conversions */ #define DEC_BIN2CHAR 1 #define DEC_DPD2BIN 1 #define DEC_BIN2DPD 1 /* used for all sizes */ #include "decDPD.h" /* lookup tables */ /* ------------------------------------------------------------------ */ /* decimal64FromNumber -- convert decNumber to decimal64 */ /* */ /* ds is the target decimal64 */ /* dn is the source number (assumed valid) */ /* set is the context, used only for reporting errors */ /* */ /* The set argument is used only for status reporting and for the */ /* rounding mode (used if the coefficient is more than DECIMAL64_Pmax */ /* digits or an overflow is detected). If the exponent is out of the */ /* valid range then Overflow or Underflow will be raised. */ /* After Underflow a subnormal result is possible. */ /* */ /* DEC_Clamped is set if the number has to be 'folded down' to fit, */ /* by reducing its exponent and multiplying the coefficient by a */ /* power of ten, or if the exponent on a zero had to be clamped. */ /* ------------------------------------------------------------------ */ decimal64 * decimal64FromNumber(decimal64 *d64, const decNumber *dn, decContext *set) { uInt status=0; /* status accumulator */ Int ae; /* adjusted exponent */ decNumber dw; /* work */ decContext dc; /* .. */ uInt comb, exp; /* .. */ uInt uiwork; /* for macros */ uInt targar[2]={0, 0}; /* target 64-bit */ #define targhi targar[1] /* name the word with the sign */ #define targlo targar[0] /* and the other */ /* If the number has too many digits, or the exponent could be */ /* out of range then reduce the number under the appropriate */ /* constraints. This could push the number to Infinity or zero, */ /* so this check and rounding must be done before generating the */ /* decimal64] */ ae=dn->exponent+dn->digits-1; /* [0 if special] */ if (dn->digits>DECIMAL64_Pmax /* too many digits */ || ae>DECIMAL64_Emax /* likely overflow */ || aeround; /* use supplied rounding */ decNumberPlus(&dw, dn, &dc); /* (round and check) */ /* [this changes -0 to 0, so enforce the sign...] */ dw.bits|=dn->bits&DECNEG; status=dc.status; /* save status */ dn=&dw; /* use the work number */ } /* maybe out of range */ if (dn->bits&DECSPECIAL) { /* a special value */ if (dn->bits&DECINF) targhi=DECIMAL_Inf<<24; else { /* sNaN or qNaN */ if ((*dn->lsu!=0 || dn->digits>1) /* non-zero coefficient */ && (dn->digitsbits&DECNAN) targhi|=DECIMAL_NaN<<24; else targhi|=DECIMAL_sNaN<<24; } /* a NaN */ } /* special */ else { /* is finite */ if (decNumberIsZero(dn)) { /* is a zero */ /* set and clamp exponent */ if (dn->exponent<-DECIMAL64_Bias) { exp=0; /* low clamp */ status|=DEC_Clamped; } else { exp=dn->exponent+DECIMAL64_Bias; /* bias exponent */ if (exp>DECIMAL64_Ehigh) { /* top clamp */ exp=DECIMAL64_Ehigh; status|=DEC_Clamped; } } comb=(exp>>5) & 0x18; /* msd=0, exp top 2 bits .. */ } else { /* non-zero finite number */ uInt msd; /* work */ Int pad=0; /* coefficient pad digits */ /* the dn is known to fit, but it may need to be padded */ exp=(uInt)(dn->exponent+DECIMAL64_Bias); /* bias exponent */ if (exp>DECIMAL64_Ehigh) { /* fold-down case */ pad=exp-DECIMAL64_Ehigh; exp=DECIMAL64_Ehigh; /* [to maximum] */ status|=DEC_Clamped; } /* fastpath common case */ if (DECDPUN==3 && pad==0) { uInt dpd[6]={0,0,0,0,0,0}; uInt i; Int d=dn->digits; for (i=0; d>0; i++, d-=3) dpd[i]=BIN2DPD[dn->lsu[i]]; targlo =dpd[0]; targlo|=dpd[1]<<10; targlo|=dpd[2]<<20; if (dn->digits>6) { targlo|=dpd[3]<<30; targhi =dpd[3]>>2; targhi|=dpd[4]<<8; } msd=dpd[5]; /* [did not really need conversion] */ } else { /* general case */ decDigitsToDPD(dn, targar, pad); /* save and clear the top digit */ msd=targhi>>18; targhi&=0x0003ffff; } /* create the combination field */ if (msd>=8) comb=0x18 | ((exp>>7) & 0x06) | (msd & 0x01); else comb=((exp>>5) & 0x18) | msd; } targhi|=comb<<26; /* add combination field .. */ targhi|=(exp&0xff)<<18; /* .. and exponent continuation */ } /* finite */ if (dn->bits&DECNEG) targhi|=0x80000000; /* add sign bit */ /* now write to storage; this is now always endian */ UBFROMUIBW(d64->bytes, targar[1]); UBFROMUIBW(d64->bytes+4, targar[0]); if (status!=0) decContextSetStatus(set, status); /* pass on status */ /* decimal64Show(d64); */ return d64; } /* decimal64FromNumber */ /* ------------------------------------------------------------------ */ /* decimal64ToNumber -- convert decimal64 to decNumber */ /* d64 is the source decimal64 */ /* dn is the target number, with appropriate space */ /* No error is possible. */ /* ------------------------------------------------------------------ */ decNumber * decimal64ToNumber(const decimal64 *d64, decNumber *dn) { uInt msd; /* coefficient MSD */ uInt exp; /* exponent top two bits */ uInt comb; /* combination field */ Int need; /* work */ uInt uiwork; /* for macros */ uInt sourar[2]; /* source 64-bit */ #define sourhi sourar[1] /* name the word with the sign */ #define sourlo sourar[0] /* and the lower word */ /* load source from storage; this is endian */ sourhi=UBTOUIBW(d64->bytes ); /* directly load the high int */ sourlo=UBTOUIBW(d64->bytes+4); /* then the low int */ comb=(sourhi>>26)&0x1f; /* combination field */ decNumberZero(dn); /* clean number */ if (sourhi&0x80000000) dn->bits=DECNEG; /* set sign if negative */ msd=COMBMSD[comb]; /* decode the combination field */ exp=COMBEXP[comb]; /* .. */ if (exp==3) { /* is a special */ if (msd==0) { dn->bits|=DECINF; return dn; /* no coefficient needed */ } else if (sourhi&0x02000000) dn->bits|=DECSNAN; else dn->bits|=DECNAN; msd=0; /* no top digit */ } else { /* is a finite number */ dn->exponent=(exp<<8)+((sourhi>>18)&0xff)-DECIMAL64_Bias; /* unbiased */ } /* get the coefficient */ sourhi&=0x0003ffff; /* clean coefficient continuation */ if (msd) { /* non-zero msd */ sourhi|=msd<<18; /* prefix to coefficient */ need=6; /* process 6 declets */ } else { /* msd=0 */ if (!sourhi) { /* top word 0 */ if (!sourlo) return dn; /* easy: coefficient is 0 */ need=3; /* process at least 3 declets */ if (sourlo&0xc0000000) need++; /* process 4 declets */ /* [could reduce some more, here] */ } else { /* some bits in top word, msd=0 */ need=4; /* process at least 4 declets */ if (sourhi&0x0003ff00) need++; /* top declet!=0, process 5 */ } } /*msd=0 */ decDigitsFromDPD(dn, sourar, need); /* process declets */ return dn; } /* decimal64ToNumber */ /* ------------------------------------------------------------------ */ /* to-scientific-string -- conversion to numeric string */ /* to-engineering-string -- conversion to numeric string */ /* */ /* decimal64ToString(d64, string); */ /* decimal64ToEngString(d64, string); */ /* */ /* d64 is the decimal64 format number to convert */ /* string is the string where the result will be laid out */ /* */ /* string must be at least 24 characters */ /* */ /* No error is possible, and no status can be set. */ /* ------------------------------------------------------------------ */ char * decimal64ToEngString(const decimal64 *d64, char *string){ decNumber dn; /* work */ decimal64ToNumber(d64, &dn); decNumberToEngString(&dn, string); return string; } /* decimal64ToEngString */ char * decimal64ToString(const decimal64 *d64, char *string){ uInt msd; /* coefficient MSD */ Int exp; /* exponent top two bits or full */ uInt comb; /* combination field */ char *cstart; /* coefficient start */ char *c; /* output pointer in string */ const uByte *u; /* work */ char *s, *t; /* .. (source, target) */ Int dpd; /* .. */ Int pre, e; /* .. */ uInt uiwork; /* for macros */ uInt sourar[2]; /* source 64-bit */ #define sourhi sourar[1] /* name the word with the sign */ #define sourlo sourar[0] /* and the lower word */ /* load source from storage; this is endian */ if (DECLITEND) { sourlo=UBTOUI(d64->bytes ); /* directly load the low int */ sourhi=UBTOUI(d64->bytes+4); /* then the high int */ } else { sourhi=UBTOUI(d64->bytes ); /* directly load the high int */ sourlo=UBTOUI(d64->bytes+4); /* then the low int */ } c=string; /* where result will go */ if (((Int)sourhi)<0) *c++='-'; /* handle sign */ comb=(sourhi>>26)&0x1f; /* combination field */ msd=COMBMSD[comb]; /* decode the combination field */ exp=COMBEXP[comb]; /* .. */ if (exp==3) { if (msd==0) { /* infinity */ strcpy(c, "Inf"); strcpy(c+3, "inity"); return string; /* easy */ } if (sourhi&0x02000000) *c++='s'; /* sNaN */ strcpy(c, "NaN"); /* complete word */ c+=3; /* step past */ if (sourlo==0 && (sourhi&0x0003ffff)==0) return string; /* zero payload */ /* otherwise drop through to add integer; set correct exp */ exp=0; msd=0; /* setup for following code */ } else exp=(exp<<8)+((sourhi>>18)&0xff)-DECIMAL64_Bias; /* convert 16 digits of significand to characters */ cstart=c; /* save start of coefficient */ if (msd) *c++='0'+(char)msd; /* non-zero most significant digit */ /* Now decode the declets. After extracting each one, it is */ /* decoded to binary and then to a 4-char sequence by table lookup; */ /* the 4-chars are a 1-char length (significant digits, except 000 */ /* has length 0). This allows us to left-align the first declet */ /* with non-zero content, then remaining ones are full 3-char */ /* length. We use fixed-length memcpys because variable-length */ /* causes a subroutine call in GCC. (These are length 4 for speed */ /* and are safe because the array has an extra terminator byte.) */ #define dpd2char u=&BIN2CHAR[DPD2BIN[dpd]*4]; \ if (c!=cstart) {memcpy(c, u+1, 4); c+=3;} \ else if (*u) {memcpy(c, u+4-*u, 4); c+=*u;} dpd=(sourhi>>8)&0x3ff; /* declet 1 */ dpd2char; dpd=((sourhi&0xff)<<2) | (sourlo>>30); /* declet 2 */ dpd2char; dpd=(sourlo>>20)&0x3ff; /* declet 3 */ dpd2char; dpd=(sourlo>>10)&0x3ff; /* declet 4 */ dpd2char; dpd=(sourlo)&0x3ff; /* declet 5 */ dpd2char; if (c==cstart) *c++='0'; /* all zeros -- make 0 */ if (exp==0) { /* integer or NaN case -- easy */ *c='\0'; /* terminate */ return string; } /* non-0 exponent */ e=0; /* assume no E */ pre=c-cstart+exp; /* [here, pre-exp is the digits count (==1 for zero)] */ if (exp>0 || pre<-5) { /* need exponential form */ e=pre-1; /* calculate E value */ pre=1; /* assume one digit before '.' */ } /* exponential form */ /* modify the coefficient, adding 0s, '.', and E+nn as needed */ s=c-1; /* source (LSD) */ if (pre>0) { /* ddd.ddd (plain), perhaps with E */ char *dotat=cstart+pre; if (dotat=dotat; s--, t--) *t=*s; /* open the gap; leave t at gap */ *t='.'; /* insert the dot */ c++; /* length increased by one */ } /* finally add the E-part, if needed; it will never be 0, and has */ /* a maximum length of 3 digits */ if (e!=0) { *c++='E'; /* starts with E */ *c++='+'; /* assume positive */ if (e<0) { *(c-1)='-'; /* oops, need '-' */ e=-e; /* uInt, please */ } u=&BIN2CHAR[e*4]; /* -> length byte */ memcpy(c, u+4-*u, 4); /* copy fixed 4 characters [is safe] */ c+=*u; /* bump pointer appropriately */ } *c='\0'; /* add terminator */ /*printf("res %s\n", string); */ return string; } /* pre>0 */ /* -5<=pre<=0: here for plain 0.ddd or 0.000ddd forms (can never have E) */ t=c+1-pre; *(t+1)='\0'; /* can add terminator now */ for (; s>=cstart; s--, t--) *t=*s; /* shift whole coefficient right */ c=cstart; *c++='0'; /* always starts with 0. */ *c++='.'; for (; pre<0; pre++) *c++='0'; /* add any 0's after '.' */ /*printf("res %s\n", string); */ return string; } /* decimal64ToString */ /* ------------------------------------------------------------------ */ /* to-number -- conversion from numeric string */ /* */ /* decimal64FromString(result, string, set); */ /* */ /* result is the decimal64 format number which gets the result of */ /* the conversion */ /* *string is the character string which should contain a valid */ /* number (which may be a special value) */ /* set is the context */ /* */ /* The context is supplied to this routine is used for error handling */ /* (setting of status and traps) and for the rounding mode, only. */ /* If an error occurs, the result will be a valid decimal64 NaN. */ /* ------------------------------------------------------------------ */ decimal64 * decimal64FromString(decimal64 *result, const char *string, decContext *set) { decContext dc; /* work */ decNumber dn; /* .. */ decContextDefault(&dc, DEC_INIT_DECIMAL64); /* no traps, please */ dc.round=set->round; /* use supplied rounding */ decNumberFromString(&dn, string, &dc); /* will round if needed */ decimal64FromNumber(result, &dn, &dc); if (dc.status!=0) { /* something happened */ decContextSetStatus(set, dc.status); /* .. pass it on */ } return result; } /* decimal64FromString */ /* ------------------------------------------------------------------ */ /* decimal64IsCanonical -- test whether encoding is canonical */ /* d64 is the source decimal64 */ /* returns 1 if the encoding of d64 is canonical, 0 otherwise */ /* No error is possible. */ /* ------------------------------------------------------------------ */ uInt decimal64IsCanonical(const decimal64 *d64) { decNumber dn; /* work */ decimal64 canon; /* .. */ decContext dc; /* .. */ decContextDefault(&dc, DEC_INIT_DECIMAL64); decimal64ToNumber(d64, &dn); decimal64FromNumber(&canon, &dn, &dc);/* canon will now be canonical */ return memcmp(d64, &canon, DECIMAL64_Bytes)==0; } /* decimal64IsCanonical */ /* ------------------------------------------------------------------ */ /* decimal64Canonical -- copy an encoding, ensuring it is canonical */ /* d64 is the source decimal64 */ /* result is the target (may be the same decimal64) */ /* returns result */ /* No error is possible. */ /* ------------------------------------------------------------------ */ decimal64 * decimal64Canonical(decimal64 *result, const decimal64 *d64) { decNumber dn; /* work */ decContext dc; /* .. */ decContextDefault(&dc, DEC_INIT_DECIMAL64); decimal64ToNumber(d64, &dn); decimal64FromNumber(result, &dn, &dc);/* result will now be canonical */ return result; } /* decimal64Canonical */ /* ================================================================== */ /* Shared utility routines and tables */ /* ================================================================== */ /* define and include the conversion tables to use for shared code */ #if DECDPUN==3 #define DEC_DPD2BIN 1 #else #define DEC_DPD2BCD 1 #endif #include "decDPD.h" /* lookup tables */ /* The maximum number of decNumberUnits needed for a working copy of */ /* the units array is the ceiling of digits/DECDPUN, where digits is */ /* the maximum number of digits in any of the formats for which this */ /* is used. decimal128.h must not be included in this module, so, as */ /* a very special case, that number is defined as a literal here. */ #define DECMAX754 34 #define DECMAXUNITS ((DECMAX754+DECDPUN-1)/DECDPUN) /* ------------------------------------------------------------------ */ /* Combination field lookup tables (uInts to save measurable work) */ /* */ /* COMBEXP - 2-bit most-significant-bits of exponent */ /* [11 if an Infinity or NaN] */ /* COMBMSD - 4-bit most-significant-digit */ /* [0=Infinity, 1=NaN if COMBEXP=11] */ /* */ /* Both are indexed by the 5-bit combination field (0-31) */ /* ------------------------------------------------------------------ */ const uInt COMBEXP[32]={0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 1, 1, 2, 2, 3, 3}; const uInt COMBMSD[32]={0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 9, 8, 9, 0, 1}; /* ------------------------------------------------------------------ */ /* decDigitsToDPD -- pack coefficient into DPD form */ /* */ /* dn is the source number (assumed valid, max DECMAX754 digits) */ /* targ is 1, 2, or 4-element uInt array, which the caller must */ /* have cleared to zeros */ /* shift is the number of 0 digits to add on the right (normally 0) */ /* */ /* The coefficient must be known small enough to fit. The full */ /* coefficient is copied, including the leading 'odd' digit. This */ /* digit is retrieved and packed into the combination field by the */ /* caller. */ /* */ /* The target uInts are altered only as necessary to receive the */ /* digits of the decNumber. When more than one uInt is needed, they */ /* are filled from left to right (that is, the uInt at offset 0 will */ /* end up with the least-significant digits). */ /* */ /* shift is used for 'fold-down' padding. */ /* */ /* No error is possible. */ /* ------------------------------------------------------------------ */ #if DECDPUN<=4 /* Constant multipliers for divide-by-power-of five using reciprocal */ /* multiply, after removing powers of 2 by shifting, and final shift */ /* of 17 [we only need up to **4] */ static const uInt multies[]={131073, 26215, 5243, 1049, 210}; /* QUOT10 -- macro to return the quotient of unit u divided by 10**n */ #define QUOT10(u, n) ((((uInt)(u)>>(n))*multies[n])>>17) #endif void decDigitsToDPD(const decNumber *dn, uInt *targ, Int shift) { Int cut; /* work */ Int n; /* output bunch counter */ Int digits=dn->digits; /* digit countdown */ uInt dpd; /* densely packed decimal value */ uInt bin; /* binary value 0-999 */ uInt *uout=targ; /* -> current output uInt */ uInt uoff=0; /* -> current output offset [from right] */ const Unit *inu=dn->lsu; /* -> current input unit */ Unit uar[DECMAXUNITS]; /* working copy of units, iff shifted */ #if DECDPUN!=3 /* not fast path */ Unit in; /* current unit */ #endif if (shift!=0) { /* shift towards most significant required */ /* shift the units array to the left by pad digits and copy */ /* [this code is a special case of decShiftToMost, which could */ /* be used instead if exposed and the array were copied first] */ const Unit *source; /* .. */ Unit *target, *first; /* .. */ uInt next=0; /* work */ source=dn->lsu+D2U(digits)-1; /* where msu comes from */ target=uar+D2U(digits)-1+D2U(shift);/* where upper part of first cut goes */ cut=DECDPUN-MSUDIGITS(shift); /* where to slice */ if (cut==0) { /* unit-boundary case */ for (; source>=dn->lsu; source--, target--) *target=*source; } else { first=uar+D2U(digits+shift)-1; /* where msu will end up */ for (; source>=dn->lsu; source--, target--) { /* split the source Unit and accumulate remainder for next */ #if DECDPUN<=4 uInt quot=QUOT10(*source, cut); uInt rem=*source-quot*DECPOWERS[cut]; next+=quot; #else uInt rem=*source%DECPOWERS[cut]; next+=*source/DECPOWERS[cut]; #endif if (target<=first) *target=(Unit)next; /* write to target iff valid */ next=rem*DECPOWERS[DECDPUN-cut]; /* save remainder for next Unit */ } } /* shift-move */ /* propagate remainder to one below and clear the rest */ for (; target>=uar; target--) { *target=(Unit)next; next=0; } digits+=shift; /* add count (shift) of zeros added */ inu=uar; /* use units in working array */ } /* now densely pack the coefficient into DPD declets */ #if DECDPUN!=3 /* not fast path */ in=*inu; /* current unit */ cut=0; /* at lowest digit */ bin=0; /* [keep compiler quiet] */ #endif for(n=0; digits>0; n++) { /* each output bunch */ #if DECDPUN==3 /* fast path, 3-at-a-time */ bin=*inu; /* 3 digits ready for convert */ digits-=3; /* [may go negative] */ inu++; /* may need another */ #else /* must collect digit-by-digit */ Unit dig; /* current digit */ Int j; /* digit-in-declet count */ for (j=0; j<3; j++) { #if DECDPUN<=4 Unit temp=(Unit)((uInt)(in*6554)>>16); dig=(Unit)(in-X10(temp)); in=temp; #else dig=in%10; in=in/10; #endif if (j==0) bin=dig; else if (j==1) bin+=X10(dig); else /* j==2 */ bin+=X100(dig); digits--; if (digits==0) break; /* [also protects *inu below] */ cut++; if (cut==DECDPUN) {inu++; in=*inu; cut=0;} } #endif /* here there are 3 digits in bin, or have used all input digits */ dpd=BIN2DPD[bin]; /* write declet to uInt array */ *uout|=dpd<>(10-uoff); /* collect top bits */ } /* n declets */ return; } /* decDigitsToDPD */ /* ------------------------------------------------------------------ */ /* decDigitsFromDPD -- unpack a format's coefficient */ /* */ /* dn is the target number, with 7, 16, or 34-digit space. */ /* sour is a 1, 2, or 4-element uInt array containing only declets */ /* declets is the number of (right-aligned) declets in sour to */ /* be processed. This may be 1 more than the obvious number in */ /* a format, as any top digit is prefixed to the coefficient */ /* continuation field. It also may be as small as 1, as the */ /* caller may pre-process leading zero declets. */ /* */ /* When doing the 'extra declet' case care is taken to avoid writing */ /* extra digits when there are leading zeros, as these could overflow */ /* the units array when DECDPUN is not 3. */ /* */ /* The target uInts are used only as necessary to process declets */ /* declets into the decNumber. When more than one uInt is needed, */ /* they are used from left to right (that is, the uInt at offset 0 */ /* provides the least-significant digits). */ /* */ /* dn->digits is set, but not the sign or exponent. */ /* No error is possible [the redundant 888 codes are allowed]. */ /* ------------------------------------------------------------------ */ void decDigitsFromDPD(decNumber *dn, const uInt *sour, Int declets) { uInt dpd; /* collector for 10 bits */ Int n; /* counter */ Unit *uout=dn->lsu; /* -> current output unit */ Unit *last=uout; /* will be unit containing msd */ const uInt *uin=sour; /* -> current input uInt */ uInt uoff=0; /* -> current input offset [from right] */ #if DECDPUN!=3 uInt bcd; /* BCD result */ uInt nibble; /* work */ Unit out=0; /* accumulator */ Int cut=0; /* power of ten in current unit */ #endif #if DECDPUN>4 uInt const *pow; /* work */ #endif /* Expand the densely-packed integer, right to left */ for (n=declets-1; n>=0; n--) { /* count down declets of 10 bits */ dpd=*uin>>uoff; uoff+=10; if (uoff>32) { /* crossed uInt boundary */ uin++; uoff-=32; dpd|=*uin<<(10-uoff); /* get waiting bits */ } dpd&=0x3ff; /* clear uninteresting bits */ #if DECDPUN==3 if (dpd==0) *uout=0; else { *uout=DPD2BIN[dpd]; /* convert 10 bits to binary 0-999 */ last=uout; /* record most significant unit */ } uout++; } /* n */ #else /* DECDPUN!=3 */ if (dpd==0) { /* fastpath [e.g., leading zeros] */ /* write out three 0 digits (nibbles); out may have digit(s) */ cut++; if (cut==DECDPUN) {*uout=out; if (out) {last=uout; out=0;} uout++; cut=0;} if (n==0) break; /* [as below, works even if MSD=0] */ cut++; if (cut==DECDPUN) {*uout=out; if (out) {last=uout; out=0;} uout++; cut=0;} cut++; if (cut==DECDPUN) {*uout=out; if (out) {last=uout; out=0;} uout++; cut=0;} continue; } bcd=DPD2BCD[dpd]; /* convert 10 bits to 12 bits BCD */ /* now accumulate the 3 BCD nibbles into units */ nibble=bcd & 0x00f; if (nibble) out=(Unit)(out+nibble*DECPOWERS[cut]); cut++; if (cut==DECDPUN) {*uout=out; if (out) {last=uout; out=0;} uout++; cut=0;} bcd>>=4; /* if this is the last declet and the remaining nibbles in bcd */ /* are 00 then process no more nibbles, because this could be */ /* the 'odd' MSD declet and writing any more Units would then */ /* overflow the unit array */ if (n==0 && !bcd) break; nibble=bcd & 0x00f; if (nibble) out=(Unit)(out+nibble*DECPOWERS[cut]); cut++; if (cut==DECDPUN) {*uout=out; if (out) {last=uout; out=0;} uout++; cut=0;} bcd>>=4; nibble=bcd & 0x00f; if (nibble) out=(Unit)(out+nibble*DECPOWERS[cut]); cut++; if (cut==DECDPUN) {*uout=out; if (out) {last=uout; out=0;} uout++; cut=0;} } /* n */ if (cut!=0) { /* some more left over */ *uout=out; /* write out final unit */ if (out) last=uout; /* and note if non-zero */ } #endif /* here, last points to the most significant unit with digits; */ /* inspect it to get the final digits count -- this is essentially */ /* the same code as decGetDigits in decNumber.c */ dn->digits=(last-dn->lsu)*DECDPUN+1; /* floor of digits, plus */ /* must be at least 1 digit */ #if DECDPUN>1 if (*last<10) return; /* common odd digit or 0 */ dn->digits++; /* must be 2 at least */ #if DECDPUN>2 if (*last<100) return; /* 10-99 */ dn->digits++; /* must be 3 at least */ #if DECDPUN>3 if (*last<1000) return; /* 100-999 */ dn->digits++; /* must be 4 at least */ #if DECDPUN>4 for (pow=&DECPOWERS[4]; *last>=*pow; pow++) dn->digits++; #endif #endif #endif #endif return; } /*decDigitsFromDPD */ libdfp-1.0.12/libdecnumber/mini-gmp.c000066400000000000000000002426601261375163000173650ustar00rootroot00000000000000/* mini-gmp, a minimalistic implementation of a GNU GMP subset. Contributed to the GNU project by Niels Möller Copyright 1991-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/. */ /* NOTE: All functions in this file which are not declared in mini-gmp.h are internal, and are not intended to be compatible neither with GMP nor with future versions of mini-gmp. */ /* Much of the material copied from GMP files, including: gmp-impl.h, longlong.h, mpn/generic/add_n.c, mpn/generic/addmul_1.c, mpn/generic/lshift.c, mpn/generic/mul_1.c, mpn/generic/mul_basecase.c, mpn/generic/rshift.c, mpn/generic/sbpi1_div_qr.c, mpn/generic/sub_n.c, mpn/generic/submul_1.c. */ #include #include #include #include #include #include #include "mini-gmp.h" /* Macros */ #define GMP_LIMB_BITS (sizeof(mp_limb_t) * CHAR_BIT) #define GMP_LIMB_MAX (~ (mp_limb_t) 0) #define GMP_LIMB_HIGHBIT ((mp_limb_t) 1 << (GMP_LIMB_BITS - 1)) #define GMP_HLIMB_BIT ((mp_limb_t) 1 << (GMP_LIMB_BITS / 2)) #define GMP_LLIMB_MASK (GMP_HLIMB_BIT - 1) #define GMP_ULONG_BITS (sizeof(unsigned long) * CHAR_BIT) #define GMP_ULONG_HIGHBIT ((unsigned long) 1 << (GMP_ULONG_BITS - 1)) #define GMP_ABS(x) ((x) >= 0 ? (x) : -(x)) #define GMP_NEG_CAST(T,x) (-((T)((x) + 1) - 1)) #define GMP_MIN(a, b) ((a) < (b) ? (a) : (b)) #define GMP_MAX(a, b) ((a) > (b) ? (a) : (b)) #define gmp_assert_nocarry(x) do { \ mp_limb_t __cy = x; \ assert (__cy == 0); \ } while (0) #define gmp_clz(count, x) do { \ mp_limb_t __clz_x = (x); \ unsigned __clz_c; \ for (__clz_c = 0; \ (__clz_x & ((mp_limb_t) 0xff << (GMP_LIMB_BITS - 8))) == 0; \ __clz_c += 8) \ __clz_x <<= 8; \ for (; (__clz_x & GMP_LIMB_HIGHBIT) == 0; __clz_c++) \ __clz_x <<= 1; \ (count) = __clz_c; \ } while (0) #define gmp_ctz(count, x) do { \ mp_limb_t __ctz_x = (x); \ unsigned __ctz_c = 0; \ gmp_clz (__ctz_c, __ctz_x & - __ctz_x); \ (count) = GMP_LIMB_BITS - 1 - __ctz_c; \ } while (0) #define gmp_add_ssaaaa(sh, sl, ah, al, bh, bl) \ do { \ mp_limb_t __x; \ __x = (al) + (bl); \ (sh) = (ah) + (bh) + (__x < (al)); \ (sl) = __x; \ } while (0) #define gmp_sub_ddmmss(sh, sl, ah, al, bh, bl) \ do { \ mp_limb_t __x; \ __x = (al) - (bl); \ (sh) = (ah) - (bh) - ((al) < (bl)); \ (sl) = __x; \ } while (0) #define gmp_umul_ppmm(w1, w0, u, v) \ do { \ mp_limb_t __x0, __x1, __x2, __x3; \ unsigned __ul, __vl, __uh, __vh; \ mp_limb_t __u = (u), __v = (v); \ \ __ul = __u & GMP_LLIMB_MASK; \ __uh = __u >> (GMP_LIMB_BITS / 2); \ __vl = __v & GMP_LLIMB_MASK; \ __vh = __v >> (GMP_LIMB_BITS / 2); \ \ __x0 = (mp_limb_t) __ul * __vl; \ __x1 = (mp_limb_t) __ul * __vh; \ __x2 = (mp_limb_t) __uh * __vl; \ __x3 = (mp_limb_t) __uh * __vh; \ \ __x1 += __x0 >> (GMP_LIMB_BITS / 2);/* this can't give carry */ \ __x1 += __x2; /* but this indeed can */ \ if (__x1 < __x2) /* did we get it? */ \ __x3 += GMP_HLIMB_BIT; /* yes, add it in the proper pos. */ \ \ (w1) = __x3 + (__x1 >> (GMP_LIMB_BITS / 2)); \ (w0) = (__x1 << (GMP_LIMB_BITS / 2)) + (__x0 & GMP_LLIMB_MASK); \ } while (0) #define gmp_udiv_qrnnd_preinv(q, r, nh, nl, d, di) \ do { \ mp_limb_t _qh, _ql, _r, _mask; \ gmp_umul_ppmm (_qh, _ql, (nh), (di)); \ gmp_add_ssaaaa (_qh, _ql, _qh, _ql, (nh) + 1, (nl)); \ _r = (nl) - _qh * (d); \ _mask = -(mp_limb_t) (_r > _ql); /* both > and >= are OK */ \ _qh += _mask; \ _r += _mask & (d); \ if (_r >= (d)) \ { \ _r -= (d); \ _qh++; \ } \ \ (r) = _r; \ (q) = _qh; \ } while (0) #define gmp_udiv_qr_3by2(q, r1, r0, n2, n1, n0, d1, d0, dinv) \ do { \ mp_limb_t _q0, _t1, _t0, _mask; \ gmp_umul_ppmm ((q), _q0, (n2), (dinv)); \ gmp_add_ssaaaa ((q), _q0, (q), _q0, (n2), (n1)); \ \ /* Compute the two most significant limbs of n - q'd */ \ (r1) = (n1) - (d1) * (q); \ gmp_sub_ddmmss ((r1), (r0), (r1), (n0), (d1), (d0)); \ gmp_umul_ppmm (_t1, _t0, (d0), (q)); \ gmp_sub_ddmmss ((r1), (r0), (r1), (r0), _t1, _t0); \ (q)++; \ \ /* Conditionally adjust q and the remainders */ \ _mask = - (mp_limb_t) ((r1) >= _q0); \ (q) += _mask; \ gmp_add_ssaaaa ((r1), (r0), (r1), (r0), _mask & (d1), _mask & (d0)); \ if ((r1) >= (d1)) \ { \ if ((r1) > (d1) || (r0) >= (d0)) \ { \ (q)++; \ gmp_sub_ddmmss ((r1), (r0), (r1), (r0), (d1), (d0)); \ } \ } \ } while (0) /* Swap macros. */ #define MP_LIMB_T_SWAP(x, y) \ do { \ mp_limb_t __mp_limb_t_swap__tmp = (x); \ (x) = (y); \ (y) = __mp_limb_t_swap__tmp; \ } while (0) #define MP_SIZE_T_SWAP(x, y) \ do { \ mp_size_t __mp_size_t_swap__tmp = (x); \ (x) = (y); \ (y) = __mp_size_t_swap__tmp; \ } while (0) #define MP_BITCNT_T_SWAP(x,y) \ do { \ mp_bitcnt_t __mp_bitcnt_t_swap__tmp = (x); \ (x) = (y); \ (y) = __mp_bitcnt_t_swap__tmp; \ } while (0) #define MP_PTR_SWAP(x, y) \ do { \ mp_ptr __mp_ptr_swap__tmp = (x); \ (x) = (y); \ (y) = __mp_ptr_swap__tmp; \ } while (0) #define MP_SRCPTR_SWAP(x, y) \ do { \ mp_srcptr __mp_srcptr_swap__tmp = (x); \ (x) = (y); \ (y) = __mp_srcptr_swap__tmp; \ } while (0) #define MPN_PTR_SWAP(xp,xs, yp,ys) \ do { \ MP_PTR_SWAP (xp, yp); \ MP_SIZE_T_SWAP (xs, ys); \ } while(0) #define MPN_SRCPTR_SWAP(xp,xs, yp,ys) \ do { \ MP_SRCPTR_SWAP (xp, yp); \ MP_SIZE_T_SWAP (xs, ys); \ } while(0) #define MPZ_PTR_SWAP(x, y) \ do { \ mpz_ptr __mpz_ptr_swap__tmp = (x); \ (x) = (y); \ (y) = __mpz_ptr_swap__tmp; \ } while (0) #define MPZ_SRCPTR_SWAP(x, y) \ do { \ mpz_srcptr __mpz_srcptr_swap__tmp = (x); \ (x) = (y); \ (y) = __mpz_srcptr_swap__tmp; \ } while (0) const int mp_bits_per_limb = GMP_LIMB_BITS; /* Memory allocation and other helper functions. */ static void gmp_die (const char *msg) { fprintf (stderr, "%s\n", msg); abort(); } static void * gmp_default_alloc (size_t size) { void *p; assert (size > 0); p = malloc (size); if (!p) gmp_die("gmp_default_alloc: Virtual memory exhausted."); return p; } static void * gmp_default_realloc (void *old, size_t old_size __attribute__ ((unused)), size_t new_size) { mp_ptr p; p = realloc (old, new_size); if (!p) gmp_die("gmp_default_realoc: Virtual memory exhausted."); return p; } static void gmp_default_free (void *p, size_t size __attribute__ ((unused))) { free (p); } static void * (*gmp_allocate_func) (size_t) = gmp_default_alloc; static void * (*gmp_reallocate_func) (void *, size_t, size_t) = gmp_default_realloc; static void (*gmp_free_func) (void *, size_t) = gmp_default_free; void mp_get_memory_functions (void *(**alloc_func) (size_t), void *(**realloc_func) (void *, size_t, size_t), void (**free_func) (void *, size_t)) { if (alloc_func) *alloc_func = gmp_allocate_func; if (realloc_func) *realloc_func = gmp_reallocate_func; if (free_func) *free_func = gmp_free_func; } void mp_set_memory_functions (void *(*alloc_func) (size_t), void *(*realloc_func) (void *, size_t, size_t), void (*free_func) (void *, size_t)) { if (!alloc_func) alloc_func = gmp_default_alloc; if (!realloc_func) realloc_func = gmp_default_realloc; if (!free_func) free_func = gmp_default_free; gmp_allocate_func = alloc_func; gmp_reallocate_func = realloc_func; gmp_free_func = free_func; } #define gmp_xalloc(size) ((*gmp_allocate_func)((size))) #define gmp_free(p) ((*gmp_free_func) ((p), 0)) static mp_ptr gmp_xalloc_limbs (mp_size_t size) { return gmp_xalloc (size * sizeof (mp_limb_t)); } static mp_ptr gmp_xrealloc_limbs (mp_ptr old, mp_size_t size) { assert (size > 0); return (*gmp_reallocate_func) (old, 0, size * sizeof (mp_limb_t)); } /* MPN interface */ void mpn_copyi (mp_ptr d, mp_srcptr s, mp_size_t n) { mp_size_t i; for (i = 0; i < n; i++) d[i] = s[i]; } void mpn_copyd (mp_ptr d, mp_srcptr s, mp_size_t n) { while (--n >= 0) d[n] = s[n]; } int mpn_cmp (mp_srcptr ap, mp_srcptr bp, mp_size_t n) { while (--n >= 0) { if (ap[n] != bp[n]) return ap[n] > bp[n] ? 1 : -1; } return 0; } static int mpn_cmp4 (mp_srcptr ap, mp_size_t an, mp_srcptr bp, mp_size_t bn) { if (an != bn) return an < bn ? -1 : 1; else return mpn_cmp (ap, bp, an); } static mp_size_t mpn_normalized_size (mp_srcptr xp, mp_size_t n) { for (; n > 0 && xp[n-1] == 0; n--) ; return n; } #define mpn_zero_p(xp, n) (mpn_normalized_size ((xp), (n)) == 0) void mpn_zero (mp_ptr rp, mp_size_t n) { mp_size_t i; for (i = 0; i < n; i++) rp[i] = 0; } mp_limb_t mpn_add_1 (mp_ptr rp, mp_srcptr ap, mp_size_t n, mp_limb_t b) { mp_size_t i; assert (n > 0); i = 0; do { mp_limb_t r = ap[i] + b; /* Carry out */ b = (r < b); rp[i] = r; } while (++i < n); return b; } mp_limb_t mpn_add_n (mp_ptr rp, mp_srcptr ap, mp_srcptr bp, mp_size_t n) { mp_size_t i; mp_limb_t cy; for (i = 0, cy = 0; i < n; i++) { mp_limb_t a, b, r; a = ap[i]; b = bp[i]; r = a + cy; cy = (r < cy); r += b; cy += (r < b); rp[i] = r; } return cy; } mp_limb_t mpn_add (mp_ptr rp, mp_srcptr ap, mp_size_t an, mp_srcptr bp, mp_size_t bn) { mp_limb_t cy; assert (an >= bn); cy = mpn_add_n (rp, ap, bp, bn); if (an > bn) cy = mpn_add_1 (rp + bn, ap + bn, an - bn, cy); return cy; } mp_limb_t mpn_sub_1 (mp_ptr rp, mp_srcptr ap, mp_size_t n, mp_limb_t b) { mp_size_t i; assert (n > 0); i = 0; do { mp_limb_t a = ap[i]; /* Carry out */ mp_limb_t cy = a < b;; rp[i] = a - b; b = cy; } while (++i < n); return b; } mp_limb_t mpn_sub_n (mp_ptr rp, mp_srcptr ap, mp_srcptr bp, mp_size_t n) { mp_size_t i; mp_limb_t cy; for (i = 0, cy = 0; i < n; i++) { mp_limb_t a, b; a = ap[i]; b = bp[i]; b += cy; cy = (b < cy); cy += (a < b); rp[i] = a - b; } return cy; } mp_limb_t mpn_sub (mp_ptr rp, mp_srcptr ap, mp_size_t an, mp_srcptr bp, mp_size_t bn) { mp_limb_t cy; assert (an >= bn); cy = mpn_sub_n (rp, ap, bp, bn); if (an > bn) cy = mpn_sub_1 (rp + bn, ap + bn, an - bn, cy); return cy; } mp_limb_t mpn_mul_1 (mp_ptr rp, mp_srcptr up, mp_size_t n, mp_limb_t vl) { mp_limb_t ul, cl, hpl, lpl; assert (n >= 1); cl = 0; do { ul = *up++; gmp_umul_ppmm (hpl, lpl, ul, vl); lpl += cl; cl = (lpl < cl) + hpl; *rp++ = lpl; } while (--n != 0); return cl; } mp_limb_t mpn_addmul_1 (mp_ptr rp, mp_srcptr up, mp_size_t n, mp_limb_t vl) { mp_limb_t ul, cl, hpl, lpl, rl; assert (n >= 1); cl = 0; do { ul = *up++; gmp_umul_ppmm (hpl, lpl, ul, vl); lpl += cl; cl = (lpl < cl) + hpl; rl = *rp; lpl = rl + lpl; cl += lpl < rl; *rp++ = lpl; } while (--n != 0); return cl; } mp_limb_t mpn_submul_1 (mp_ptr rp, mp_srcptr up, mp_size_t n, mp_limb_t vl) { mp_limb_t ul, cl, hpl, lpl, rl; assert (n >= 1); cl = 0; do { ul = *up++; gmp_umul_ppmm (hpl, lpl, ul, vl); lpl += cl; cl = (lpl < cl) + hpl; rl = *rp; lpl = rl - lpl; cl += lpl > rl; *rp++ = lpl; } while (--n != 0); return cl; } mp_limb_t mpn_mul (mp_ptr rp, mp_srcptr up, mp_size_t un, mp_srcptr vp, mp_size_t vn) { assert (un >= vn); assert (vn >= 1); /* We first multiply by the low order limb. This result can be stored, not added, to rp. We also avoid a loop for zeroing this way. */ rp[un] = mpn_mul_1 (rp, up, un, vp[0]); /* Now accumulate the product of up[] and the next higher limb from vp[]. */ while (--vn >= 1) { rp += 1, vp += 1; rp[un] = mpn_addmul_1 (rp, up, un, vp[0]); } return rp[un]; } void mpn_mul_n (mp_ptr rp, mp_srcptr ap, mp_srcptr bp, mp_size_t n) { mpn_mul (rp, ap, n, bp, n); } void mpn_sqr (mp_ptr rp, mp_srcptr ap, mp_size_t n) { mpn_mul (rp, ap, n, ap, n); } mp_limb_t mpn_lshift (mp_ptr rp, mp_srcptr up, mp_size_t n, unsigned int cnt) { mp_limb_t high_limb, low_limb; unsigned int tnc; mp_size_t i; mp_limb_t retval; assert (n >= 1); assert (cnt >= 1); assert (cnt < GMP_LIMB_BITS); up += n; rp += n; tnc = GMP_LIMB_BITS - cnt; low_limb = *--up; retval = low_limb >> tnc; high_limb = (low_limb << cnt); for (i = n; --i != 0;) { low_limb = *--up; *--rp = high_limb | (low_limb >> tnc); high_limb = (low_limb << cnt); } *--rp = high_limb; return retval; } mp_limb_t mpn_rshift (mp_ptr rp, mp_srcptr up, mp_size_t n, unsigned int cnt) { mp_limb_t high_limb, low_limb; unsigned int tnc; mp_size_t i; mp_limb_t retval; assert (n >= 1); assert (cnt >= 1); assert (cnt < GMP_LIMB_BITS); tnc = GMP_LIMB_BITS - cnt; high_limb = *up++; retval = (high_limb << tnc); low_limb = high_limb >> cnt; for (i = n; --i != 0;) { high_limb = *up++; *rp++ = low_limb | (high_limb << tnc); low_limb = high_limb >> cnt; } *rp = low_limb; return retval; } static mp_bitcnt_t mpn_common_scan (mp_limb_t limb, mp_size_t i, mp_srcptr up, mp_size_t un, mp_limb_t ux) { unsigned cnt; assert (ux == 0 || ux == GMP_LIMB_MAX); assert (0 <= i && i <= un ); while (limb == 0) { i++; if (i == un) return (ux == 0 ? ~(mp_bitcnt_t) 0 : un * GMP_LIMB_BITS); limb = ux ^ up[i]; } gmp_ctz (cnt, limb); return (mp_bitcnt_t) i * GMP_LIMB_BITS + cnt; } mp_bitcnt_t mpn_scan1 (mp_srcptr ptr, mp_bitcnt_t bit) { mp_size_t i; i = bit / GMP_LIMB_BITS; return mpn_common_scan ( ptr[i] & (GMP_LIMB_MAX << (bit % GMP_LIMB_BITS)), i, ptr, i, 0); } mp_bitcnt_t mpn_scan0 (mp_srcptr ptr, mp_bitcnt_t bit) { mp_size_t i; i = bit / GMP_LIMB_BITS; return mpn_common_scan (~ptr[i] & (GMP_LIMB_MAX << (bit % GMP_LIMB_BITS)), i, ptr, i, GMP_LIMB_MAX); } /* MPN division interface. */ mp_limb_t mpn_invert_3by2 (mp_limb_t u1, mp_limb_t u0) { mp_limb_t r, p, m; unsigned ul, uh; unsigned ql, qh; /* First, do a 2/1 inverse. */ /* The inverse m is defined as floor( (B^2 - 1 - u1)/u1 ), so that 0 < * B^2 - (B + m) u1 <= u1 */ assert (u1 >= GMP_LIMB_HIGHBIT); ul = u1 & GMP_LLIMB_MASK; uh = u1 >> (GMP_LIMB_BITS / 2); qh = ~u1 / uh; r = ((~u1 - (mp_limb_t) qh * uh) << (GMP_LIMB_BITS / 2)) | GMP_LLIMB_MASK; p = (mp_limb_t) qh * ul; /* Adjustment steps taken from udiv_qrnnd_c */ if (r < p) { qh--; r += u1; if (r >= u1) /* i.e. we didn't get carry when adding to r */ if (r < p) { qh--; r += u1; } } r -= p; /* Do a 3/2 division (with half limb size) */ p = (r >> (GMP_LIMB_BITS / 2)) * qh + r; ql = (p >> (GMP_LIMB_BITS / 2)) + 1; /* By the 3/2 method, we don't need the high half limb. */ r = (r << (GMP_LIMB_BITS / 2)) + GMP_LLIMB_MASK - ql * u1; if (r >= (p << (GMP_LIMB_BITS / 2))) { ql--; r += u1; } m = ((mp_limb_t) qh << (GMP_LIMB_BITS / 2)) + ql; if (r >= u1) { m++; r -= u1; } if (u0 > 0) { mp_limb_t th, tl; r = ~r; r += u0; if (r < u0) { m--; if (r >= u1) { m--; r -= u1; } r -= u1; } gmp_umul_ppmm (th, tl, u0, m); r += th; if (r < th) { m--; m -= ((r > u1) | ((r == u1) & (tl > u0))); } } return m; } struct gmp_div_inverse { /* Normalization shift count. */ unsigned shift; /* Normalized divisor (d0 unused for mpn_div_qr_1) */ mp_limb_t d1, d0; /* Inverse, for 2/1 or 3/2. */ mp_limb_t di; }; static void mpn_div_qr_1_invert (struct gmp_div_inverse *inv, mp_limb_t d) { unsigned shift; assert (d > 0); gmp_clz (shift, d); inv->shift = shift; inv->d1 = d << shift; inv->di = mpn_invert_limb (inv->d1); } static void mpn_div_qr_2_invert (struct gmp_div_inverse *inv, mp_limb_t d1, mp_limb_t d0) { unsigned shift; assert (d1 > 0); gmp_clz (shift, d1); inv->shift = shift; if (shift > 0) { d1 = (d1 << shift) | (d0 >> (GMP_LIMB_BITS - shift)); d0 <<= shift; } inv->d1 = d1; inv->d0 = d0; inv->di = mpn_invert_3by2 (d1, d0); } static void mpn_div_qr_invert (struct gmp_div_inverse *inv, mp_srcptr dp, mp_size_t dn) { assert (dn > 0); if (dn == 1) mpn_div_qr_1_invert (inv, dp[0]); else if (dn == 2) mpn_div_qr_2_invert (inv, dp[1], dp[0]); else { unsigned shift; mp_limb_t d1, d0; d1 = dp[dn-1]; d0 = dp[dn-2]; assert (d1 > 0); gmp_clz (shift, d1); inv->shift = shift; if (shift > 0) { d1 = (d1 << shift) | (d0 >> (GMP_LIMB_BITS - shift)); d0 = (d0 << shift) | (dp[dn-3] >> (GMP_LIMB_BITS - shift)); } inv->d1 = d1; inv->d0 = d0; inv->di = mpn_invert_3by2 (d1, d0); } } /* Not matching current public gmp interface, rather corresponding to the sbpi1_div_* functions. */ static mp_limb_t mpn_div_qr_1_preinv (mp_ptr qp, mp_srcptr np, mp_size_t nn, const struct gmp_div_inverse *inv) { mp_limb_t d, di; mp_limb_t r; mp_ptr tp = NULL; if (inv->shift > 0) { tp = gmp_xalloc_limbs (nn); r = mpn_lshift (tp, np, nn, inv->shift); np = tp; } else r = 0; d = inv->d1; di = inv->di; while (--nn >= 0) { mp_limb_t q; gmp_udiv_qrnnd_preinv (q, r, r, np[nn], d, di); if (qp) qp[nn] = q; } if (inv->shift > 0) gmp_free (tp); return r >> inv->shift; } static mp_limb_t mpn_div_qr_1 (mp_ptr qp, mp_srcptr np, mp_size_t nn, mp_limb_t d) { assert (d > 0); /* Special case for powers of two. */ if ((d & (d-1)) == 0) { mp_limb_t r = np[0] & (d-1); if (qp) { if (d <= 1) mpn_copyi (qp, np, nn); else { unsigned shift; gmp_ctz (shift, d); mpn_rshift (qp, np, nn, shift); } } return r; } else { struct gmp_div_inverse inv; mpn_div_qr_1_invert (&inv, d); return mpn_div_qr_1_preinv (qp, np, nn, &inv); } } static void mpn_div_qr_2_preinv (mp_ptr qp, mp_ptr rp, mp_srcptr np, mp_size_t nn, const struct gmp_div_inverse *inv) { unsigned shift; mp_size_t i; mp_limb_t d1, d0, di, r1, r0; mp_ptr tp; assert (nn >= 2); shift = inv->shift; d1 = inv->d1; d0 = inv->d0; di = inv->di; if (shift > 0) { tp = gmp_xalloc_limbs (nn); r1 = mpn_lshift (tp, np, nn, shift); np = tp; } else r1 = 0; r0 = np[nn - 1]; i = nn - 2; do { mp_limb_t n0, q; n0 = np[i]; gmp_udiv_qr_3by2 (q, r1, r0, r1, r0, n0, d1, d0, di); if (qp) qp[i] = q; } while (--i >= 0); if (shift > 0) { assert ((r0 << (GMP_LIMB_BITS - shift)) == 0); r0 = (r0 >> shift) | (r1 << (GMP_LIMB_BITS - shift)); r1 >>= shift; gmp_free (tp); } rp[1] = r1; rp[0] = r0; } #if 0 static void mpn_div_qr_2 (mp_ptr qp, mp_ptr rp, mp_srcptr np, mp_size_t nn, mp_limb_t d1, mp_limb_t d0) { struct gmp_div_inverse inv; assert (nn >= 2); mpn_div_qr_2_invert (&inv, d1, d0); mpn_div_qr_2_preinv (qp, rp, np, nn, &inv); } #endif static void mpn_div_qr_pi1 (mp_ptr qp, mp_ptr np, mp_size_t nn, mp_limb_t n1, mp_srcptr dp, mp_size_t dn, mp_limb_t dinv) { mp_size_t i; mp_limb_t d1, d0; mp_limb_t cy, cy1; mp_limb_t q; assert (dn > 2); assert (nn >= dn); d1 = dp[dn - 1]; d0 = dp[dn - 2]; assert ((d1 & GMP_LIMB_HIGHBIT) != 0); /* Iteration variable is the index of the q limb. * * We divide * by */ i = nn - dn; do { mp_limb_t n0 = np[dn-1+i]; if (n1 == d1 && n0 == d0) { q = GMP_LIMB_MAX; mpn_submul_1 (np+i, dp, dn, q); n1 = np[dn-1+i]; /* update n1, last loop's value will now be invalid */ } else { gmp_udiv_qr_3by2 (q, n1, n0, n1, n0, np[dn-2+i], d1, d0, dinv); cy = mpn_submul_1 (np + i, dp, dn-2, q); cy1 = n0 < cy; n0 = n0 - cy; cy = n1 < cy1; n1 = n1 - cy1; np[dn-2+i] = n0; if (cy != 0) { n1 += d1 + mpn_add_n (np + i, np + i, dp, dn - 1); q--; } } if (qp) qp[i] = q; } while (--i >= 0); np[dn - 1] = n1; } static void mpn_div_qr_preinv (mp_ptr qp, mp_ptr np, mp_size_t nn, mp_srcptr dp, mp_size_t dn, const struct gmp_div_inverse *inv) { assert (dn > 0); assert (nn >= dn); if (dn == 1) np[0] = mpn_div_qr_1_preinv (qp, np, nn, inv); else if (dn == 2) mpn_div_qr_2_preinv (qp, np, np, nn, inv); else { mp_limb_t nh; unsigned shift; assert (inv->d1 == dp[dn-1]); assert (inv->d0 == dp[dn-2]); assert ((inv->d1 & GMP_LIMB_HIGHBIT) != 0); shift = inv->shift; if (shift > 0) nh = mpn_lshift (np, np, nn, shift); else nh = 0; mpn_div_qr_pi1 (qp, np, nn, nh, dp, dn, inv->di); if (shift > 0) gmp_assert_nocarry (mpn_rshift (np, np, dn, shift)); } } static void mpn_div_qr (mp_ptr qp, mp_ptr np, mp_size_t nn, mp_srcptr dp, mp_size_t dn) { struct gmp_div_inverse inv; mp_ptr tp = NULL; assert (dn > 0); assert (nn >= dn); mpn_div_qr_invert (&inv, dp, dn); if (dn > 2 && inv.shift > 0) { tp = gmp_xalloc_limbs (dn); gmp_assert_nocarry (mpn_lshift (tp, dp, dn, inv.shift)); dp = tp; } mpn_div_qr_preinv (qp, np, nn, dp, dn, &inv); if (tp) gmp_free (tp); } /* MPN base conversion. */ static unsigned mpn_base_power_of_two_p (unsigned b) { switch (b) { case 2: return 1; case 4: return 2; case 8: return 3; case 16: return 4; case 32: return 5; case 64: return 6; case 128: return 7; case 256: return 8; default: return 0; } } struct mpn_base_info { /* bb is the largest power of the base which fits in one limb, and exp is the corresponding exponent. */ unsigned exp; mp_limb_t bb; }; static void mpn_get_base_info (struct mpn_base_info *info, mp_limb_t b) { mp_limb_t m; mp_limb_t p; unsigned exp; m = GMP_LIMB_MAX / b; for (exp = 1, p = b; p <= m; exp++) p *= b; info->exp = exp; info->bb = p; } static mp_bitcnt_t mpn_limb_size_in_base_2 (mp_limb_t u) { unsigned shift; assert (u > 0); gmp_clz (shift, u); return GMP_LIMB_BITS - shift; } static size_t mpn_get_str_bits (unsigned char *sp, unsigned bits, mp_srcptr up, mp_size_t un) { unsigned char mask; size_t sn, j; mp_size_t i; unsigned int shift; sn = ((un - 1) * GMP_LIMB_BITS + mpn_limb_size_in_base_2 (up[un-1]) + bits - 1) / bits; mask = (1U << bits) - 1; for (i = 0, j = sn, shift = 0; j-- > 0;) { unsigned char digit = up[i] >> shift; shift += bits; if (shift >= GMP_LIMB_BITS && ++i < un) { shift -= GMP_LIMB_BITS; digit |= up[i] << (bits - shift); } sp[j] = digit & mask; } return sn; } /* We generate digits from the least significant end, and reverse at the end. */ static size_t mpn_limb_get_str (unsigned char *sp, mp_limb_t w, const struct gmp_div_inverse *binv) { mp_size_t i; for (i = 0; w > 0; i++) { mp_limb_t h, l, r; h = w >> (GMP_LIMB_BITS - binv->shift); l = w << binv->shift; gmp_udiv_qrnnd_preinv (w, r, h, l, binv->d1, binv->di); assert ( (r << (GMP_LIMB_BITS - binv->shift)) == 0); r >>= binv->shift; sp[i] = r; } return i; } static size_t mpn_get_str_other (unsigned char *sp, int base, const struct mpn_base_info *info, mp_ptr up, mp_size_t un) { struct gmp_div_inverse binv; size_t sn; size_t i; mpn_div_qr_1_invert (&binv, base); sn = 0; if (un > 1) { struct gmp_div_inverse bbinv; mpn_div_qr_1_invert (&bbinv, info->bb); do { mp_limb_t w; size_t done; w = mpn_div_qr_1_preinv (up, up, un, &bbinv); un -= (up[un-1] == 0); done = mpn_limb_get_str (sp + sn, w, &binv); for (sn += done; done < info->exp; done++) sp[sn++] = 0; } while (un > 1); } sn += mpn_limb_get_str (sp + sn, up[0], &binv); /* Reverse order */ for (i = 0; 2*i + 1 < sn; i++) { unsigned char t = sp[i]; sp[i] = sp[sn - i - 1]; sp[sn - i - 1] = t; } return sn; } size_t mpn_get_str (unsigned char *sp, int base, mp_ptr up, mp_size_t un) { unsigned bits; assert (un > 0); assert (up[un-1] > 0); bits = mpn_base_power_of_two_p (base); if (bits) return mpn_get_str_bits (sp, bits, up, un); else { struct mpn_base_info info; mpn_get_base_info (&info, base); return mpn_get_str_other (sp, base, &info, up, un); } } static mp_size_t mpn_set_str_bits (mp_ptr rp, const unsigned char *sp, size_t sn, unsigned bits) { mp_size_t rn; size_t j; unsigned shift; for (j = sn, rn = 0, shift = 0; j-- > 0; ) { if (shift == 0) { rp[rn++] = sp[j]; shift += bits; } else { rp[rn-1] |= (mp_limb_t) sp[j] << shift; shift += bits; if (shift >= GMP_LIMB_BITS) { shift -= GMP_LIMB_BITS; if (shift > 0) rp[rn++] = (mp_limb_t) sp[j] >> (bits - shift); } } } rn = mpn_normalized_size (rp, rn); return rn; } static mp_size_t mpn_set_str_other (mp_ptr rp, const unsigned char *sp, size_t sn, mp_limb_t b, const struct mpn_base_info *info) { mp_size_t rn; mp_limb_t w; unsigned k; size_t j; k = 1 + (sn - 1) % info->exp; j = 0; w = sp[j++]; for (; --k > 0; ) w = w * b + sp[j++]; rp[0] = w; for (rn = (w > 0); j < sn;) { mp_limb_t cy; w = sp[j++]; for (k = 1; k < info->exp; k++) w = w * b + sp[j++]; cy = mpn_mul_1 (rp, rp, rn, info->bb); cy += mpn_add_1 (rp, rp, rn, w); if (cy > 0) rp[rn++] = cy; } assert (j == sn); return rn; } mp_size_t mpn_set_str (mp_ptr rp, const unsigned char *sp, size_t sn, int base) { unsigned bits; if (sn == 0) return 0; bits = mpn_base_power_of_two_p (base); if (bits) return mpn_set_str_bits (rp, sp, sn, bits); else { struct mpn_base_info info; mpn_get_base_info (&info, base); return mpn_set_str_other (rp, sp, sn, base, &info); } } /* MPZ interface */ void mpz_init (mpz_t r) { r->_mp_alloc = 1; r->_mp_size = 0; r->_mp_d = gmp_xalloc_limbs (1); } /* The utility of this function is a bit limited, since many functions assigns the result variable using mpz_swap. */ void mpz_init2 (mpz_t r, mp_bitcnt_t bits) { mp_size_t rn; bits -= (bits != 0); /* Round down, except if 0 */ rn = 1 + bits / GMP_LIMB_BITS; r->_mp_alloc = rn; r->_mp_size = 0; r->_mp_d = gmp_xalloc_limbs (rn); } void mpz_clear (mpz_t r) { gmp_free (r->_mp_d); } static void * mpz_realloc (mpz_t r, mp_size_t size) { size = GMP_MAX (size, 1); r->_mp_d = gmp_xrealloc_limbs (r->_mp_d, size); r->_mp_alloc = size; if (GMP_ABS (r->_mp_size) > size) r->_mp_size = 0; return r->_mp_d; } /* Realloc for an mpz_t WHAT if it has less than NEEDED limbs. */ #define MPZ_REALLOC(z,n) ((int)(n) > (z)->_mp_alloc \ ? mpz_realloc(z,n) \ : (z)->_mp_d) /* MPZ assignment and basic conversions. */ void mpz_set_si (mpz_t r, signed long int x) { if (x >= 0) mpz_set_ui (r, x); else /* (x < 0) */ { r->_mp_size = -1; r->_mp_d[0] = GMP_NEG_CAST (unsigned long int, x); } } void mpz_set_ui (mpz_t r, unsigned long int x) { if (x > 0) { r->_mp_size = 1; r->_mp_d[0] = x; } else r->_mp_size = 0; } void mpz_set (mpz_t r, const mpz_t x) { /* Allow the NOP r == x */ if (r != x) { mp_size_t n; mp_ptr rp; n = GMP_ABS (x->_mp_size); rp = MPZ_REALLOC (r, n); mpn_copyi (rp, x->_mp_d, n); r->_mp_size = x->_mp_size; } } void mpz_init_set_si (mpz_t r, signed long int x) { mpz_init (r); mpz_set_si (r, x); } void mpz_init_set_ui (mpz_t r, unsigned long int x) { mpz_init (r); mpz_set_ui (r, x); } void mpz_init_set (mpz_t r, const mpz_t x) { mpz_init (r); mpz_set (r, x); } int mpz_fits_slong_p (const mpz_t u) { mp_size_t us = u->_mp_size; if (us == 1) return u->_mp_d[0] < GMP_LIMB_HIGHBIT; else if (us == -1) return u->_mp_d[0] <= GMP_LIMB_HIGHBIT; else return (us == 0); } int mpz_fits_ulong_p (const mpz_t u) { mp_size_t us = u->_mp_size; return (us == (us > 0)); } long int mpz_get_si (const mpz_t u) { mp_size_t us = u->_mp_size; if (us > 0) return (long) (u->_mp_d[0] & ~GMP_LIMB_HIGHBIT); else if (us < 0) return (long) (- u->_mp_d[0] | GMP_LIMB_HIGHBIT); else return 0; } unsigned long int mpz_get_ui (const mpz_t u) { return u->_mp_size == 0 ? 0 : u->_mp_d[0]; } size_t mpz_size (const mpz_t u) { return GMP_ABS (u->_mp_size); } mp_limb_t mpz_getlimbn (const mpz_t u, mp_size_t n) { if (n >= 0 && n < GMP_ABS (u->_mp_size)) return u->_mp_d[n]; else return 0; } void mpz_realloc2 (mpz_t x, mp_bitcnt_t n) { mpz_realloc (x, 1 + (n - (n != 0)) / GMP_LIMB_BITS); } mp_srcptr mpz_limbs_read (mpz_srcptr x) { return x->_mp_d;; } mp_ptr mpz_limbs_modify (mpz_t x, mp_size_t n) { assert (n > 0); return MPZ_REALLOC (x, n); } mp_ptr mpz_limbs_write (mpz_t x, mp_size_t n) { return mpz_limbs_modify (x, n); } void mpz_limbs_finish (mpz_t x, mp_size_t xs) { mp_size_t xn; xn = mpn_normalized_size (x->_mp_d, GMP_ABS (xs)); x->_mp_size = xs < 0 ? -xn : xn; } mpz_srcptr mpz_roinit_n (mpz_t x, mp_srcptr xp, mp_size_t xs) { x->_mp_alloc = 0; x->_mp_d = (mp_ptr) xp; mpz_limbs_finish (x, xs); return x; } /* Conversions and comparison to double. */ void mpz_set_d (mpz_t r, double x) { int sign; mp_ptr rp; mp_size_t rn, i; double B; double Bi; mp_limb_t f; /* x != x is true when x is a NaN, and x == x * 0.5 is true when x is zero or infinity. */ if (x != x || x == x * 0.5) { r->_mp_size = 0; return; } sign = x < 0.0 ; if (sign) x = - x; if (x < 1.0) { r->_mp_size = 0; return; } B = 2.0 * (double) GMP_LIMB_HIGHBIT; Bi = 1.0 / B; for (rn = 1; x >= B; rn++) x *= Bi; rp = MPZ_REALLOC (r, rn); f = (mp_limb_t) x; x -= f; assert (x < 1.0); i = rn-1; rp[i] = f; while (--i >= 0) { x = B * x; f = (mp_limb_t) x; x -= f; assert (x < 1.0); rp[i] = f; } r->_mp_size = sign ? - rn : rn; } void mpz_init_set_d (mpz_t r, double x) { mpz_init (r); mpz_set_d (r, x); } double mpz_get_d (const mpz_t u) { mp_size_t un; double x; double B = 2.0 * (double) GMP_LIMB_HIGHBIT; un = GMP_ABS (u->_mp_size); if (un == 0) return 0.0; x = u->_mp_d[--un]; while (un > 0) x = B*x + u->_mp_d[--un]; if (u->_mp_size < 0) x = -x; return x; } int mpz_cmpabs_d (const mpz_t x, double d) { mp_size_t xn; double B, Bi; mp_size_t i; xn = x->_mp_size; d = GMP_ABS (d); if (xn != 0) { xn = GMP_ABS (xn); B = 2.0 * (double) GMP_LIMB_HIGHBIT; Bi = 1.0 / B; /* Scale d so it can be compared with the top limb. */ for (i = 1; i < xn; i++) d *= Bi; if (d >= B) return -1; /* Compare floor(d) to top limb, subtract and cancel when equal. */ for (i = xn; i-- > 0;) { mp_limb_t f, xl; f = (mp_limb_t) d; xl = x->_mp_d[i]; if (xl > f) return 1; else if (xl < f) return -1; d = B * (d - f); } } return - (d > 0.0); } int mpz_cmp_d (const mpz_t x, double d) { if (x->_mp_size < 0) { if (d >= 0.0) return -1; else return -mpz_cmpabs_d (x, d); } else { if (d < 0.0) return 1; else return mpz_cmpabs_d (x, d); } } /* MPZ comparisons and the like. */ int mpz_sgn (const mpz_t u) { mp_size_t usize = u->_mp_size; return (usize > 0) - (usize < 0); } int mpz_cmp_si (const mpz_t u, long v) { mp_size_t usize = u->_mp_size; if (usize < -1) return -1; else if (v >= 0) return mpz_cmp_ui (u, v); else if (usize >= 0) return 1; else /* usize == -1 */ { mp_limb_t ul = u->_mp_d[0]; if ((mp_limb_t)GMP_NEG_CAST (unsigned long int, v) < ul) return -1; else return (mp_limb_t)GMP_NEG_CAST (unsigned long int, v) > ul; } } int mpz_cmp_ui (const mpz_t u, unsigned long v) { mp_size_t usize = u->_mp_size; if (usize > 1) return 1; else if (usize < 0) return -1; else { mp_limb_t ul = (usize > 0) ? u->_mp_d[0] : 0; return (ul > v) - (ul < v); } } int mpz_cmp (const mpz_t a, const mpz_t b) { mp_size_t asize = a->_mp_size; mp_size_t bsize = b->_mp_size; if (asize != bsize) return (asize < bsize) ? -1 : 1; else if (asize >= 0) return mpn_cmp (a->_mp_d, b->_mp_d, asize); else return mpn_cmp (b->_mp_d, a->_mp_d, -asize); } int mpz_cmpabs_ui (const mpz_t u, unsigned long v) { mp_size_t un = GMP_ABS (u->_mp_size); mp_limb_t ul; if (un > 1) return 1; ul = (un == 1) ? u->_mp_d[0] : 0; return (ul > v) - (ul < v); } int mpz_cmpabs (const mpz_t u, const mpz_t v) { return mpn_cmp4 (u->_mp_d, GMP_ABS (u->_mp_size), v->_mp_d, GMP_ABS (v->_mp_size)); } void mpz_abs (mpz_t r, const mpz_t u) { mpz_set (r, u); r->_mp_size = GMP_ABS (r->_mp_size); } void mpz_neg (mpz_t r, const mpz_t u) { mpz_set (r, u); r->_mp_size = -r->_mp_size; } void mpz_swap (mpz_t u, mpz_t v) { MP_SIZE_T_SWAP (u->_mp_size, v->_mp_size); MP_SIZE_T_SWAP (u->_mp_alloc, v->_mp_alloc); MP_PTR_SWAP (u->_mp_d, v->_mp_d); } /* MPZ addition and subtraction */ /* Adds to the absolute value. Returns new size, but doesn't store it. */ static mp_size_t mpz_abs_add_ui (mpz_t r, const mpz_t a, unsigned long b) { mp_size_t an; mp_ptr rp; mp_limb_t cy; an = GMP_ABS (a->_mp_size); if (an == 0) { r->_mp_d[0] = b; return b > 0; } rp = MPZ_REALLOC (r, an + 1); cy = mpn_add_1 (rp, a->_mp_d, an, b); rp[an] = cy; an += cy; return an; } /* Subtract from the absolute value. Returns new size, (or -1 on underflow), but doesn't store it. */ static mp_size_t mpz_abs_sub_ui (mpz_t r, const mpz_t a, unsigned long b) { mp_size_t an = GMP_ABS (a->_mp_size); mp_ptr rp = MPZ_REALLOC (r, an); if (an == 0) { rp[0] = b; return -(b > 0); } else if (an == 1 && a->_mp_d[0] < b) { rp[0] = b - a->_mp_d[0]; return -1; } else { gmp_assert_nocarry (mpn_sub_1 (rp, a->_mp_d, an, b)); return mpn_normalized_size (rp, an); } } void mpz_add_ui (mpz_t r, const mpz_t a, unsigned long b) { if (a->_mp_size >= 0) r->_mp_size = mpz_abs_add_ui (r, a, b); else r->_mp_size = -mpz_abs_sub_ui (r, a, b); } void mpz_sub_ui (mpz_t r, const mpz_t a, unsigned long b) { if (a->_mp_size < 0) r->_mp_size = -mpz_abs_add_ui (r, a, b); else r->_mp_size = mpz_abs_sub_ui (r, a, b); } void mpz_ui_sub (mpz_t r, unsigned long a, const mpz_t b) { if (b->_mp_size < 0) r->_mp_size = mpz_abs_add_ui (r, b, a); else r->_mp_size = -mpz_abs_sub_ui (r, b, a); } static mp_size_t mpz_abs_add (mpz_t r, const mpz_t a, const mpz_t b) { mp_size_t an = GMP_ABS (a->_mp_size); mp_size_t bn = GMP_ABS (b->_mp_size); mp_ptr rp; mp_limb_t cy; if (an < bn) { MPZ_SRCPTR_SWAP (a, b); MP_SIZE_T_SWAP (an, bn); } rp = MPZ_REALLOC (r, an + 1); cy = mpn_add (rp, a->_mp_d, an, b->_mp_d, bn); rp[an] = cy; return an + cy; } static mp_size_t mpz_abs_sub (mpz_t r, const mpz_t a, const mpz_t b) { mp_size_t an = GMP_ABS (a->_mp_size); mp_size_t bn = GMP_ABS (b->_mp_size); int cmp; mp_ptr rp; cmp = mpn_cmp4 (a->_mp_d, an, b->_mp_d, bn); if (cmp > 0) { rp = MPZ_REALLOC (r, an); gmp_assert_nocarry (mpn_sub (rp, a->_mp_d, an, b->_mp_d, bn)); return mpn_normalized_size (rp, an); } else if (cmp < 0) { rp = MPZ_REALLOC (r, bn); gmp_assert_nocarry (mpn_sub (rp, b->_mp_d, bn, a->_mp_d, an)); return -mpn_normalized_size (rp, bn); } else return 0; } void mpz_add (mpz_t r, const mpz_t a, const mpz_t b) { mp_size_t rn; if ( (a->_mp_size ^ b->_mp_size) >= 0) rn = mpz_abs_add (r, a, b); else rn = mpz_abs_sub (r, a, b); r->_mp_size = a->_mp_size >= 0 ? rn : - rn; } void mpz_sub (mpz_t r, const mpz_t a, const mpz_t b) { mp_size_t rn; if ( (a->_mp_size ^ b->_mp_size) >= 0) rn = mpz_abs_sub (r, a, b); else rn = mpz_abs_add (r, a, b); r->_mp_size = a->_mp_size >= 0 ? rn : - rn; } /* MPZ multiplication */ void mpz_mul_si (mpz_t r, const mpz_t u, long int v) { if (v < 0) { mpz_mul_ui (r, u, GMP_NEG_CAST (unsigned long int, v)); mpz_neg (r, r); } else mpz_mul_ui (r, u, (unsigned long int) v); } void mpz_mul_ui (mpz_t r, const mpz_t u, unsigned long int v) { mp_size_t un, us; mp_ptr tp; mp_limb_t cy; us = u->_mp_size; if (us == 0 || v == 0) { r->_mp_size = 0; return; } un = GMP_ABS (us); tp = MPZ_REALLOC (r, un + 1); cy = mpn_mul_1 (tp, u->_mp_d, un, v); tp[un] = cy; un += (cy > 0); r->_mp_size = (us < 0) ? - un : un; } void mpz_mul (mpz_t r, const mpz_t u, const mpz_t v) { int sign; mp_size_t un, vn, rn; mpz_t t; mp_ptr tp; un = u->_mp_size; vn = v->_mp_size; if (un == 0 || vn == 0) { r->_mp_size = 0; return; } sign = (un ^ vn) < 0; un = GMP_ABS (un); vn = GMP_ABS (vn); mpz_init2 (t, (un + vn) * GMP_LIMB_BITS); tp = t->_mp_d; if (un >= vn) mpn_mul (tp, u->_mp_d, un, v->_mp_d, vn); else mpn_mul (tp, v->_mp_d, vn, u->_mp_d, un); rn = un + vn; rn -= tp[rn-1] == 0; t->_mp_size = sign ? - rn : rn; mpz_swap (r, t); mpz_clear (t); } void mpz_mul_2exp (mpz_t r, const mpz_t u, mp_bitcnt_t bits) { mp_size_t un, rn; mp_size_t limbs; unsigned shift; mp_ptr rp; un = GMP_ABS (u->_mp_size); if (un == 0) { r->_mp_size = 0; return; } limbs = bits / GMP_LIMB_BITS; shift = bits % GMP_LIMB_BITS; rn = un + limbs + (shift > 0); rp = MPZ_REALLOC (r, rn); if (shift > 0) { mp_limb_t cy = mpn_lshift (rp + limbs, u->_mp_d, un, shift); rp[rn-1] = cy; rn -= (cy == 0); } else mpn_copyd (rp + limbs, u->_mp_d, un); while (limbs > 0) rp[--limbs] = 0; r->_mp_size = (u->_mp_size < 0) ? - rn : rn; } void mpz_addmul_ui (mpz_t r, const mpz_t u, unsigned long int v) { mpz_t t; mpz_init (t); mpz_mul_ui (t, u, v); mpz_add (r, r, t); mpz_clear (t); } void mpz_submul_ui (mpz_t r, const mpz_t u, unsigned long int v) { mpz_t t; mpz_init (t); mpz_mul_ui (t, u, v); mpz_sub (r, r, t); mpz_clear (t); } void mpz_addmul (mpz_t r, const mpz_t u, const mpz_t v) { mpz_t t; mpz_init (t); mpz_mul (t, u, v); mpz_add (r, r, t); mpz_clear (t); } void mpz_submul (mpz_t r, const mpz_t u, const mpz_t v) { mpz_t t; mpz_init (t); mpz_mul (t, u, v); mpz_sub (r, r, t); mpz_clear (t); } /* MPZ division */ enum mpz_div_round_mode { GMP_DIV_FLOOR, GMP_DIV_CEIL, GMP_DIV_TRUNC }; /* Allows q or r to be zero. Returns 1 iff remainder is non-zero. */ static int mpz_div_qr (mpz_t q, mpz_t r, const mpz_t n, const mpz_t d, enum mpz_div_round_mode mode) { mp_size_t ns, ds, nn, dn, qs; ns = n->_mp_size; ds = d->_mp_size; if (ds == 0) gmp_die("mpz_div_qr: Divide by zero."); if (ns == 0) { if (q) q->_mp_size = 0; if (r) r->_mp_size = 0; return 0; } nn = GMP_ABS (ns); dn = GMP_ABS (ds); qs = ds ^ ns; if (nn < dn) { if (mode == GMP_DIV_CEIL && qs >= 0) { /* q = 1, r = n - d */ if (r) mpz_sub (r, n, d); if (q) mpz_set_ui (q, 1); } else if (mode == GMP_DIV_FLOOR && qs < 0) { /* q = -1, r = n + d */ if (r) mpz_add (r, n, d); if (q) mpz_set_si (q, -1); } else { /* q = 0, r = d */ if (r) mpz_set (r, n); if (q) q->_mp_size = 0; } return 1; } else { mp_ptr np, qp; mp_size_t qn, rn; mpz_t tq, tr; mpz_init_set (tr, n); np = tr->_mp_d; qn = nn - dn + 1; if (q) { mpz_init2 (tq, qn * GMP_LIMB_BITS); qp = tq->_mp_d; } else qp = NULL; mpn_div_qr (qp, np, nn, d->_mp_d, dn); if (qp) { qn -= (qp[qn-1] == 0); tq->_mp_size = qs < 0 ? -qn : qn; } rn = mpn_normalized_size (np, dn); tr->_mp_size = ns < 0 ? - rn : rn; if (mode == GMP_DIV_FLOOR && qs < 0 && rn != 0) { if (q) mpz_sub_ui (tq, tq, 1); if (r) mpz_add (tr, tr, d); } else if (mode == GMP_DIV_CEIL && qs >= 0 && rn != 0) { if (q) mpz_add_ui (tq, tq, 1); if (r) mpz_sub (tr, tr, d); } if (q) { mpz_swap (tq, q); mpz_clear (tq); } if (r) mpz_swap (tr, r); mpz_clear (tr); return rn != 0; } } void mpz_cdiv_qr (mpz_t q, mpz_t r, const mpz_t n, const mpz_t d) { mpz_div_qr (q, r, n, d, GMP_DIV_CEIL); } void mpz_fdiv_qr (mpz_t q, mpz_t r, const mpz_t n, const mpz_t d) { mpz_div_qr (q, r, n, d, GMP_DIV_FLOOR); } void mpz_tdiv_qr (mpz_t q, mpz_t r, const mpz_t n, const mpz_t d) { mpz_div_qr (q, r, n, d, GMP_DIV_TRUNC); } void mpz_cdiv_q (mpz_t q, const mpz_t n, const mpz_t d) { mpz_div_qr (q, NULL, n, d, GMP_DIV_CEIL); } void mpz_fdiv_q (mpz_t q, const mpz_t n, const mpz_t d) { mpz_div_qr (q, NULL, n, d, GMP_DIV_FLOOR); } void mpz_tdiv_q (mpz_t q, const mpz_t n, const mpz_t d) { mpz_div_qr (q, NULL, n, d, GMP_DIV_TRUNC); } void mpz_cdiv_r (mpz_t r, const mpz_t n, const mpz_t d) { mpz_div_qr (NULL, r, n, d, GMP_DIV_CEIL); } void mpz_fdiv_r (mpz_t r, const mpz_t n, const mpz_t d) { mpz_div_qr (NULL, r, n, d, GMP_DIV_FLOOR); } void mpz_tdiv_r (mpz_t r, const mpz_t n, const mpz_t d) { mpz_div_qr (NULL, r, n, d, GMP_DIV_TRUNC); } void mpz_mod (mpz_t r, const mpz_t n, const mpz_t d) { mpz_div_qr (NULL, r, n, d, d->_mp_size >= 0 ? GMP_DIV_FLOOR : GMP_DIV_CEIL); } static void mpz_div_q_2exp (mpz_t q, const mpz_t u, mp_bitcnt_t bit_index, enum mpz_div_round_mode mode) { mp_size_t un, qn; mp_size_t limb_cnt; mp_ptr qp; int adjust; un = u->_mp_size; if (un == 0) { q->_mp_size = 0; return; } limb_cnt = bit_index / GMP_LIMB_BITS; qn = GMP_ABS (un) - limb_cnt; bit_index %= GMP_LIMB_BITS; if (mode == ((un > 0) ? GMP_DIV_CEIL : GMP_DIV_FLOOR)) /* un != 0 here. */ /* Note: Below, the final indexing at limb_cnt is valid because at that point we have qn > 0. */ adjust = (qn <= 0 || !mpn_zero_p (u->_mp_d, limb_cnt) || (u->_mp_d[limb_cnt] & (((mp_limb_t) 1 << bit_index) - 1))); else adjust = 0; if (qn <= 0) qn = 0; else { qp = MPZ_REALLOC (q, qn); if (bit_index != 0) { mpn_rshift (qp, u->_mp_d + limb_cnt, qn, bit_index); qn -= qp[qn - 1] == 0; } else { mpn_copyi (qp, u->_mp_d + limb_cnt, qn); } } q->_mp_size = qn; if (adjust) mpz_add_ui (q, q, 1); if (un < 0) mpz_neg (q, q); } static void mpz_div_r_2exp (mpz_t r, const mpz_t u, mp_bitcnt_t bit_index, enum mpz_div_round_mode mode) { mp_size_t us, un, rn; mp_ptr rp; mp_limb_t mask; us = u->_mp_size; if (us == 0 || bit_index == 0) { r->_mp_size = 0; return; } rn = (bit_index + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS; assert (rn > 0); rp = MPZ_REALLOC (r, rn); un = GMP_ABS (us); mask = GMP_LIMB_MAX >> (rn * GMP_LIMB_BITS - bit_index); if (rn > un) { /* Quotient (with truncation) is zero, and remainder is non-zero */ if (mode == ((us > 0) ? GMP_DIV_CEIL : GMP_DIV_FLOOR)) /* us != 0 here. */ { /* Have to negate and sign extend. */ mp_size_t i; mp_limb_t cy; for (cy = 1, i = 0; i < un; i++) { mp_limb_t s = ~u->_mp_d[i] + cy; cy = s < cy; rp[i] = s; } assert (cy == 0); for (; i < rn - 1; i++) rp[i] = GMP_LIMB_MAX; rp[rn-1] = mask; us = -us; } else { /* Just copy */ if (r != u) mpn_copyi (rp, u->_mp_d, un); rn = un; } } else { if (r != u) mpn_copyi (rp, u->_mp_d, rn - 1); rp[rn-1] = u->_mp_d[rn-1] & mask; if (mode == ((us > 0) ? GMP_DIV_CEIL : GMP_DIV_FLOOR)) /* us != 0 here. */ { /* If r != 0, compute 2^{bit_count} - r. */ mp_size_t i; for (i = 0; i < rn && rp[i] == 0; i++) ; if (i < rn) { /* r > 0, need to flip sign. */ rp[i] = ~rp[i] + 1; while (++i < rn) rp[i] = ~rp[i]; rp[rn-1] &= mask; /* us is not used for anything else, so we can modify it here to indicate flipped sign. */ us = -us; } } } rn = mpn_normalized_size (rp, rn); r->_mp_size = us < 0 ? -rn : rn; } void mpz_cdiv_q_2exp (mpz_t r, const mpz_t u, mp_bitcnt_t cnt) { mpz_div_q_2exp (r, u, cnt, GMP_DIV_CEIL); } void mpz_fdiv_q_2exp (mpz_t r, const mpz_t u, mp_bitcnt_t cnt) { mpz_div_q_2exp (r, u, cnt, GMP_DIV_FLOOR); } void mpz_tdiv_q_2exp (mpz_t r, const mpz_t u, mp_bitcnt_t cnt) { mpz_div_q_2exp (r, u, cnt, GMP_DIV_TRUNC); } void mpz_cdiv_r_2exp (mpz_t r, const mpz_t u, mp_bitcnt_t cnt) { mpz_div_r_2exp (r, u, cnt, GMP_DIV_CEIL); } void mpz_fdiv_r_2exp (mpz_t r, const mpz_t u, mp_bitcnt_t cnt) { mpz_div_r_2exp (r, u, cnt, GMP_DIV_FLOOR); } void mpz_tdiv_r_2exp (mpz_t r, const mpz_t u, mp_bitcnt_t cnt) { mpz_div_r_2exp (r, u, cnt, GMP_DIV_TRUNC); } void mpz_divexact (mpz_t q, const mpz_t n, const mpz_t d) { gmp_assert_nocarry (mpz_div_qr (q, NULL, n, d, GMP_DIV_TRUNC)); } int mpz_divisible_p (const mpz_t n, const mpz_t d) { return mpz_div_qr (NULL, NULL, n, d, GMP_DIV_TRUNC) == 0; } int mpz_congruent_p (const mpz_t a, const mpz_t b, const mpz_t m) { mpz_t t; int res; /* a == b (mod 0) iff a == b */ if (mpz_sgn (m) == 0) return (mpz_cmp (a, b) == 0); mpz_init (t); mpz_sub (t, a, b); res = mpz_divisible_p (t, m); mpz_clear (t); return res; } static unsigned long mpz_div_qr_ui (mpz_t q, mpz_t r, const mpz_t n, unsigned long d, enum mpz_div_round_mode mode) { mp_size_t ns, qn; mp_ptr qp; mp_limb_t rl; mp_size_t rs; ns = n->_mp_size; if (ns == 0) { if (q) q->_mp_size = 0; if (r) r->_mp_size = 0; return 0; } qn = GMP_ABS (ns); if (q) qp = MPZ_REALLOC (q, qn); else qp = NULL; rl = mpn_div_qr_1 (qp, n->_mp_d, qn, d); assert (rl < d); rs = rl > 0; rs = (ns < 0) ? -rs : rs; if (rl > 0 && ( (mode == GMP_DIV_FLOOR && ns < 0) || (mode == GMP_DIV_CEIL && ns >= 0))) { if (q) gmp_assert_nocarry (mpn_add_1 (qp, qp, qn, 1)); rl = d - rl; rs = -rs; } if (r) { r->_mp_d[0] = rl; r->_mp_size = rs; } if (q) { qn -= (qp[qn-1] == 0); assert (qn == 0 || qp[qn-1] > 0); q->_mp_size = (ns < 0) ? - qn : qn; } return rl; } unsigned long mpz_cdiv_qr_ui (mpz_t q, mpz_t r, const mpz_t n, unsigned long d) { return mpz_div_qr_ui (q, r, n, d, GMP_DIV_CEIL); } unsigned long mpz_fdiv_qr_ui (mpz_t q, mpz_t r, const mpz_t n, unsigned long d) { return mpz_div_qr_ui (q, r, n, d, GMP_DIV_FLOOR); } unsigned long mpz_tdiv_qr_ui (mpz_t q, mpz_t r, const mpz_t n, unsigned long d) { return mpz_div_qr_ui (q, r, n, d, GMP_DIV_TRUNC); } unsigned long mpz_cdiv_q_ui (mpz_t q, const mpz_t n, unsigned long d) { return mpz_div_qr_ui (q, NULL, n, d, GMP_DIV_CEIL); } unsigned long mpz_fdiv_q_ui (mpz_t q, const mpz_t n, unsigned long d) { return mpz_div_qr_ui (q, NULL, n, d, GMP_DIV_FLOOR); } unsigned long mpz_tdiv_q_ui (mpz_t q, const mpz_t n, unsigned long d) { return mpz_div_qr_ui (q, NULL, n, d, GMP_DIV_TRUNC); } unsigned long mpz_cdiv_r_ui (mpz_t r, const mpz_t n, unsigned long d) { return mpz_div_qr_ui (NULL, r, n, d, GMP_DIV_CEIL); } unsigned long mpz_fdiv_r_ui (mpz_t r, const mpz_t n, unsigned long d) { return mpz_div_qr_ui (NULL, r, n, d, GMP_DIV_FLOOR); } unsigned long mpz_tdiv_r_ui (mpz_t r, const mpz_t n, unsigned long d) { return mpz_div_qr_ui (NULL, r, n, d, GMP_DIV_TRUNC); } unsigned long mpz_cdiv_ui (const mpz_t n, unsigned long d) { return mpz_div_qr_ui (NULL, NULL, n, d, GMP_DIV_CEIL); } unsigned long mpz_fdiv_ui (const mpz_t n, unsigned long d) { return mpz_div_qr_ui (NULL, NULL, n, d, GMP_DIV_FLOOR); } unsigned long mpz_tdiv_ui (const mpz_t n, unsigned long d) { return mpz_div_qr_ui (NULL, NULL, n, d, GMP_DIV_TRUNC); } unsigned long mpz_mod_ui (mpz_t r, const mpz_t n, unsigned long d) { return mpz_div_qr_ui (NULL, r, n, d, GMP_DIV_FLOOR); } void mpz_divexact_ui (mpz_t q, const mpz_t n, unsigned long d) { gmp_assert_nocarry (mpz_div_qr_ui (q, NULL, n, d, GMP_DIV_TRUNC)); } int mpz_divisible_ui_p (const mpz_t n, unsigned long d) { return mpz_div_qr_ui (NULL, NULL, n, d, GMP_DIV_TRUNC) == 0; } /* GCD */ static mp_limb_t mpn_gcd_11 (mp_limb_t u, mp_limb_t v) { unsigned shift; assert ( (u | v) > 0); if (u == 0) return v; else if (v == 0) return u; gmp_ctz (shift, u | v); u >>= shift; v >>= shift; if ( (u & 1) == 0) MP_LIMB_T_SWAP (u, v); while ( (v & 1) == 0) v >>= 1; while (u != v) { if (u > v) { u -= v; do u >>= 1; while ( (u & 1) == 0); } else { v -= u; do v >>= 1; while ( (v & 1) == 0); } } return u << shift; } unsigned long mpz_gcd_ui (mpz_t g, const mpz_t u, unsigned long v) { mp_size_t un; if (v == 0) { if (g) mpz_abs (g, u); } else { un = GMP_ABS (u->_mp_size); if (un != 0) v = mpn_gcd_11 (mpn_div_qr_1 (NULL, u->_mp_d, un, v), v); if (g) mpz_set_ui (g, v); } return v; } static mp_bitcnt_t mpz_make_odd (mpz_t r) { mp_bitcnt_t shift; assert (r->_mp_size > 0); /* Count trailing zeros, equivalent to mpn_scan1, because we know that there is a 1 */ shift = mpn_common_scan (r->_mp_d[0], 0, r->_mp_d, 0, 0); mpz_tdiv_q_2exp (r, r, shift); return shift; } void mpz_gcd (mpz_t g, const mpz_t u, const mpz_t v) { mpz_t tu, tv; mp_bitcnt_t uz, vz, gz; if (u->_mp_size == 0) { mpz_abs (g, v); return; } if (v->_mp_size == 0) { mpz_abs (g, u); return; } mpz_init (tu); mpz_init (tv); mpz_abs (tu, u); uz = mpz_make_odd (tu); mpz_abs (tv, v); vz = mpz_make_odd (tv); gz = GMP_MIN (uz, vz); if (tu->_mp_size < tv->_mp_size) mpz_swap (tu, tv); mpz_tdiv_r (tu, tu, tv); if (tu->_mp_size == 0) { mpz_swap (g, tv); } else for (;;) { int c; mpz_make_odd (tu); c = mpz_cmp (tu, tv); if (c == 0) { mpz_swap (g, tu); break; } if (c < 0) mpz_swap (tu, tv); if (tv->_mp_size == 1) { mp_limb_t vl = tv->_mp_d[0]; mp_limb_t ul = mpz_tdiv_ui (tu, vl); mpz_set_ui (g, mpn_gcd_11 (ul, vl)); break; } mpz_sub (tu, tu, tv); } mpz_clear (tu); mpz_clear (tv); mpz_mul_2exp (g, g, gz); } void mpz_gcdext (mpz_t g, mpz_t s, mpz_t t, const mpz_t u, const mpz_t v) { mpz_t tu, tv, s0, s1, t0, t1; mp_bitcnt_t uz, vz, gz; mp_bitcnt_t power; if (u->_mp_size == 0) { /* g = 0 u + sgn(v) v */ signed long sign = mpz_sgn (v); mpz_abs (g, v); if (s) mpz_set_ui (s, 0); if (t) mpz_set_si (t, sign); return; } if (v->_mp_size == 0) { /* g = sgn(u) u + 0 v */ signed long sign = mpz_sgn (u); mpz_abs (g, u); if (s) mpz_set_si (s, sign); if (t) mpz_set_ui (t, 0); return; } mpz_init (tu); mpz_init (tv); mpz_init (s0); mpz_init (s1); mpz_init (t0); mpz_init (t1); mpz_abs (tu, u); uz = mpz_make_odd (tu); mpz_abs (tv, v); vz = mpz_make_odd (tv); gz = GMP_MIN (uz, vz); uz -= gz; vz -= gz; /* Cofactors corresponding to odd gcd. gz handled later. */ if (tu->_mp_size < tv->_mp_size) { mpz_swap (tu, tv); MPZ_SRCPTR_SWAP (u, v); MPZ_PTR_SWAP (s, t); MP_BITCNT_T_SWAP (uz, vz); } /* Maintain * * u = t0 tu + t1 tv * v = s0 tu + s1 tv * * where u and v denote the inputs with common factors of two * eliminated, and det (s0, t0; s1, t1) = 2^p. Then * * 2^p tu = s1 u - t1 v * 2^p tv = -s0 u + t0 v */ /* After initial division, tu = q tv + tu', we have * * u = 2^uz (tu' + q tv) * v = 2^vz tv * * or * * t0 = 2^uz, t1 = 2^uz q * s0 = 0, s1 = 2^vz */ mpz_setbit (t0, uz); mpz_tdiv_qr (t1, tu, tu, tv); mpz_mul_2exp (t1, t1, uz); mpz_setbit (s1, vz); power = uz + vz; if (tu->_mp_size > 0) { mp_bitcnt_t shift; shift = mpz_make_odd (tu); mpz_mul_2exp (t0, t0, shift); mpz_mul_2exp (s0, s0, shift); power += shift; for (;;) { int c; c = mpz_cmp (tu, tv); if (c == 0) break; if (c < 0) { /* tv = tv' + tu * * u = t0 tu + t1 (tv' + tu) = (t0 + t1) tu + t1 tv' * v = s0 tu + s1 (tv' + tu) = (s0 + s1) tu + s1 tv' */ mpz_sub (tv, tv, tu); mpz_add (t0, t0, t1); mpz_add (s0, s0, s1); shift = mpz_make_odd (tv); mpz_mul_2exp (t1, t1, shift); mpz_mul_2exp (s1, s1, shift); } else { mpz_sub (tu, tu, tv); mpz_add (t1, t0, t1); mpz_add (s1, s0, s1); shift = mpz_make_odd (tu); mpz_mul_2exp (t0, t0, shift); mpz_mul_2exp (s0, s0, shift); } power += shift; } } /* Now tv = odd part of gcd, and -s0 and t0 are corresponding cofactors. */ mpz_mul_2exp (tv, tv, gz); mpz_neg (s0, s0); /* 2^p g = s0 u + t0 v. Eliminate one factor of two at a time. To adjust cofactors, we need u / g and v / g */ mpz_divexact (s1, v, tv); mpz_abs (s1, s1); mpz_divexact (t1, u, tv); mpz_abs (t1, t1); while (power-- > 0) { /* s0 u + t0 v = (s0 - v/g) u - (t0 + u/g) v */ if (mpz_odd_p (s0) || mpz_odd_p (t0)) { mpz_sub (s0, s0, s1); mpz_add (t0, t0, t1); } mpz_divexact_ui (s0, s0, 2); mpz_divexact_ui (t0, t0, 2); } /* Arrange so that |s| < |u| / 2g */ mpz_add (s1, s0, s1); if (mpz_cmpabs (s0, s1) > 0) { mpz_swap (s0, s1); mpz_sub (t0, t0, t1); } if (u->_mp_size < 0) mpz_neg (s0, s0); if (v->_mp_size < 0) mpz_neg (t0, t0); mpz_swap (g, tv); if (s) mpz_swap (s, s0); if (t) mpz_swap (t, t0); mpz_clear (tu); mpz_clear (tv); mpz_clear (s0); mpz_clear (s1); mpz_clear (t0); mpz_clear (t1); } void mpz_lcm (mpz_t r, const mpz_t u, const mpz_t v) { mpz_t g; if (u->_mp_size == 0 || v->_mp_size == 0) { r->_mp_size = 0; return; } mpz_init (g); mpz_gcd (g, u, v); mpz_divexact (g, u, g); mpz_mul (r, g, v); mpz_clear (g); mpz_abs (r, r); } void mpz_lcm_ui (mpz_t r, const mpz_t u, unsigned long v) { if (v == 0 || u->_mp_size == 0) { r->_mp_size = 0; return; } v /= mpz_gcd_ui (NULL, u, v); mpz_mul_ui (r, u, v); mpz_abs (r, r); } int mpz_invert (mpz_t r, const mpz_t u, const mpz_t m) { mpz_t g, tr; int invertible; if (u->_mp_size == 0 || mpz_cmpabs_ui (m, 1) <= 0) return 0; mpz_init (g); mpz_init (tr); mpz_gcdext (g, tr, NULL, u, m); invertible = (mpz_cmp_ui (g, 1) == 0); if (invertible) { if (tr->_mp_size < 0) { if (m->_mp_size >= 0) mpz_add (tr, tr, m); else mpz_sub (tr, tr, m); } mpz_swap (r, tr); } mpz_clear (g); mpz_clear (tr); return invertible; } /* Higher level operations (sqrt, pow and root) */ void mpz_pow_ui (mpz_t r, const mpz_t b, unsigned long e) { unsigned long bit; mpz_t tr; mpz_init_set_ui (tr, 1); bit = GMP_ULONG_HIGHBIT; do { mpz_mul (tr, tr, tr); if (e & bit) mpz_mul (tr, tr, b); bit >>= 1; } while (bit > 0); mpz_swap (r, tr); mpz_clear (tr); } void mpz_ui_pow_ui (mpz_t r, unsigned long blimb, unsigned long e) { mpz_t b; mpz_pow_ui (r, mpz_roinit_n (b, &blimb, 1), e); } void mpz_powm (mpz_t r, const mpz_t b, const mpz_t e, const mpz_t m) { mpz_t tr; mpz_t base; mp_size_t en, mn; mp_srcptr mp; struct gmp_div_inverse minv; unsigned shift; mp_ptr tp = NULL; en = GMP_ABS (e->_mp_size); mn = GMP_ABS (m->_mp_size); if (mn == 0) gmp_die ("mpz_powm: Zero modulo."); if (en == 0) { mpz_set_ui (r, 1); return; } mp = m->_mp_d; mpn_div_qr_invert (&minv, mp, mn); shift = minv.shift; if (shift > 0) { /* To avoid shifts, we do all our reductions, except the final one, using a *normalized* m. */ minv.shift = 0; tp = gmp_xalloc_limbs (mn); gmp_assert_nocarry (mpn_lshift (tp, mp, mn, shift)); mp = tp; } mpz_init (base); if (e->_mp_size < 0) { if (!mpz_invert (base, b, m)) gmp_die ("mpz_powm: Negative exponent and non-invertible base."); } else { mp_size_t bn; mpz_abs (base, b); bn = base->_mp_size; if (bn >= mn) { mpn_div_qr_preinv (NULL, base->_mp_d, base->_mp_size, mp, mn, &minv); bn = mn; } /* We have reduced the absolute value. Now take care of the sign. Note that we get zero represented non-canonically as m. */ if (b->_mp_size < 0) { mp_ptr bp = MPZ_REALLOC (base, mn); gmp_assert_nocarry (mpn_sub (bp, mp, mn, bp, bn)); bn = mn; } base->_mp_size = mpn_normalized_size (base->_mp_d, bn); } mpz_init_set_ui (tr, 1); while (--en >= 0) { mp_limb_t w = e->_mp_d[en]; mp_limb_t bit; bit = GMP_LIMB_HIGHBIT; do { mpz_mul (tr, tr, tr); if (w & bit) mpz_mul (tr, tr, base); if (tr->_mp_size > mn) { mpn_div_qr_preinv (NULL, tr->_mp_d, tr->_mp_size, mp, mn, &minv); tr->_mp_size = mpn_normalized_size (tr->_mp_d, mn); } bit >>= 1; } while (bit > 0); } /* Final reduction */ if (tr->_mp_size >= mn) { minv.shift = shift; mpn_div_qr_preinv (NULL, tr->_mp_d, tr->_mp_size, mp, mn, &minv); tr->_mp_size = mpn_normalized_size (tr->_mp_d, mn); } if (tp) gmp_free (tp); mpz_swap (r, tr); mpz_clear (tr); mpz_clear (base); } void mpz_powm_ui (mpz_t r, const mpz_t b, unsigned long elimb, const mpz_t m) { mpz_t e; mpz_powm (r, b, mpz_roinit_n (e, &elimb, 1), m); } /* x=trunc(y^(1/z)), r=y-x^z */ void mpz_rootrem (mpz_t x, mpz_t r, const mpz_t y, unsigned long z) { int sgn; mpz_t t, u; sgn = y->_mp_size < 0; if ((~z & sgn) != 0) gmp_die ("mpz_rootrem: Negative argument, with even root."); if (z == 0) gmp_die ("mpz_rootrem: Zeroth root."); if (mpz_cmpabs_ui (y, 1) <= 0) { if (x) mpz_set (x, y); if (r) r->_mp_size = 0; return; } mpz_init (u); { mp_bitcnt_t tb; tb = mpz_sizeinbase (y, 2) / z + 1; mpz_init2 (t, tb + 1); mpz_setbit (t, tb); } if (z == 2) /* simplify sqrt loop: z-1 == 1 */ do { mpz_swap (u, t); /* u = x */ mpz_tdiv_q (t, y, u); /* t = y/x */ mpz_add (t, t, u); /* t = y/x + x */ mpz_tdiv_q_2exp (t, t, 1); /* x'= (y/x + x)/2 */ } while (mpz_cmpabs (t, u) < 0); /* |x'| < |x| */ else /* z != 2 */ { mpz_t v; mpz_init (v); if (sgn) mpz_neg (t, t); do { mpz_swap (u, t); /* u = x */ mpz_pow_ui (t, u, z - 1); /* t = x^(z-1) */ mpz_tdiv_q (t, y, t); /* t = y/x^(z-1) */ mpz_mul_ui (v, u, z - 1); /* v = x*(z-1) */ mpz_add (t, t, v); /* t = y/x^(z-1) + x*(z-1) */ mpz_tdiv_q_ui (t, t, z); /* x'=(y/x^(z-1) + x*(z-1))/z */ } while (mpz_cmpabs (t, u) < 0); /* |x'| < |x| */ mpz_clear (v); } if (r) { mpz_pow_ui (t, u, z); mpz_sub (r, y, t); } if (x) mpz_swap (x, u); mpz_clear (u); mpz_clear (t); } int mpz_root (mpz_t x, const mpz_t y, unsigned long z) { int res; mpz_t r; mpz_init (r); mpz_rootrem (x, r, y, z); res = r->_mp_size == 0; mpz_clear (r); return res; } /* Compute s = floor(sqrt(u)) and r = u - s^2. Allows r == NULL */ void mpz_sqrtrem (mpz_t s, mpz_t r, const mpz_t u) { mpz_rootrem (s, r, u, 2); } void mpz_sqrt (mpz_t s, const mpz_t u) { mpz_rootrem (s, NULL, u, 2); } int mpz_perfect_square_p (const mpz_t u) { if (u->_mp_size <= 0) return (u->_mp_size == 0); else return mpz_root (NULL, u, 2); } int mpn_perfect_square_p (mp_srcptr p, mp_size_t n) { mpz_t t; assert (n > 0); assert (p [n-1] != 0); return mpz_root (NULL, mpz_roinit_n (t, p, n), 2); } mp_size_t mpn_sqrtrem (mp_ptr sp, mp_ptr rp, mp_srcptr p, mp_size_t n) { mpz_t s, r, u; mp_size_t res; assert (n > 0); assert (p [n-1] != 0); mpz_init (r); mpz_init (s); mpz_rootrem (s, r, mpz_roinit_n (u, p, n), 2); assert (s->_mp_size == (n+1)/2); mpn_copyd (sp, s->_mp_d, s->_mp_size); mpz_clear (s); res = r->_mp_size; if (rp) mpn_copyd (rp, r->_mp_d, res); mpz_clear (r); return res; } /* Combinatorics */ void mpz_fac_ui (mpz_t x, unsigned long n) { mpz_set_ui (x, n + (n == 0)); for (;n > 2;) mpz_mul_ui (x, x, --n); } void mpz_bin_uiui (mpz_t r, unsigned long n, unsigned long k) { mpz_t t; mpz_set_ui (r, k <= n); if (k > (n >> 1)) k = (k <= n) ? n - k : 0; mpz_init (t); mpz_fac_ui (t, k); for (; k > 0; k--) mpz_mul_ui (r, r, n--); mpz_divexact (r, r, t); mpz_clear (t); } /* Primality testing */ static int gmp_millerrabin (const mpz_t n, const mpz_t nm1, mpz_t y, const mpz_t q, mp_bitcnt_t k) { assert (k > 0); /* Caller must initialize y to the base. */ mpz_powm (y, y, q, n); if (mpz_cmp_ui (y, 1) == 0 || mpz_cmp (y, nm1) == 0) return 1; while (--k > 0) { mpz_powm_ui (y, y, 2, n); if (mpz_cmp (y, nm1) == 0) return 1; /* y == 1 means that the previous y was a non-trivial square root of 1 (mod n). y == 0 means that n is a power of the base. In either case, n is not prime. */ if (mpz_cmp_ui (y, 1) <= 0) return 0; } return 0; } /* This product is 0xc0cfd797, and fits in 32 bits. */ #define GMP_PRIME_PRODUCT \ (3UL*5UL*7UL*11UL*13UL*17UL*19UL*23UL*29UL) /* Bit (p+1)/2 is set, for each odd prime <= 61 */ #define GMP_PRIME_MASK 0xc96996dcUL int mpz_probab_prime_p (const mpz_t n, int reps) { mpz_t nm1; mpz_t q; mpz_t y; mp_bitcnt_t k; int is_prime; int j; /* Note that we use the absolute value of n only, for compatibility with the real GMP. */ if (mpz_even_p (n)) return (mpz_cmpabs_ui (n, 2) == 0) ? 2 : 0; /* Above test excludes n == 0 */ assert (n->_mp_size != 0); if (mpz_cmpabs_ui (n, 64) < 0) return (GMP_PRIME_MASK >> (n->_mp_d[0] >> 1)) & 2; if (mpz_gcd_ui (NULL, n, GMP_PRIME_PRODUCT) != 1) return 0; /* All prime factors are >= 31. */ if (mpz_cmpabs_ui (n, 31*31) < 0) return 2; /* Use Miller-Rabin, with a deterministic sequence of bases, a[j] = j^2 + j + 41 using Euler's polynomial. We potentially stop early, if a[j] >= n - 1. Since n >= 31*31, this can happen only if reps > 30 (a[30] == 971 > 31*31 == 961). */ mpz_init (nm1); mpz_init (q); mpz_init (y); /* Find q and k, where q is odd and n = 1 + 2**k * q. */ nm1->_mp_size = mpz_abs_sub_ui (nm1, n, 1); k = mpz_scan1 (nm1, 0); mpz_tdiv_q_2exp (q, nm1, k); for (j = 0, is_prime = 1; is_prime & (j < reps); j++) { mpz_set_ui (y, (unsigned long) j*j+j+41); if (mpz_cmp (y, nm1) >= 0) { /* Don't try any further bases. This "early" break does not affect the result for any reasonable reps value (<=5000 was tested) */ assert (j >= 30); break; } is_prime = gmp_millerrabin (n, nm1, y, q, k); } mpz_clear (nm1); mpz_clear (q); mpz_clear (y); return is_prime; } /* Logical operations and bit manipulation. */ /* Numbers are treated as if represented in two's complement (and infinitely sign extended). For a negative values we get the two's complement from -x = ~x + 1, where ~ is bitwise complement. Negation transforms xxxx10...0 into yyyy10...0 where yyyy is the bitwise complement of xxxx. So least significant bits, up to and including the first one bit, are unchanged, and the more significant bits are all complemented. To change a bit from zero to one in a negative number, subtract the corresponding power of two from the absolute value. This can never underflow. To change a bit from one to zero, add the corresponding power of two, and this might overflow. E.g., if x = -001111, the two's complement is 110001. Clearing the least significant bit, we get two's complement 110000, and -010000. */ int mpz_tstbit (const mpz_t d, mp_bitcnt_t bit_index) { mp_size_t limb_index; unsigned shift; mp_size_t ds; mp_size_t dn; mp_limb_t w; int bit; ds = d->_mp_size; dn = GMP_ABS (ds); limb_index = bit_index / GMP_LIMB_BITS; if (limb_index >= dn) return ds < 0; shift = bit_index % GMP_LIMB_BITS; w = d->_mp_d[limb_index]; bit = (w >> shift) & 1; if (ds < 0) { /* d < 0. Check if any of the bits below is set: If so, our bit must be complemented. */ if (shift > 0 && (w << (GMP_LIMB_BITS - shift)) > 0) return bit ^ 1; while (--limb_index >= 0) if (d->_mp_d[limb_index] > 0) return bit ^ 1; } return bit; } static void mpz_abs_add_bit (mpz_t d, mp_bitcnt_t bit_index) { mp_size_t dn, limb_index; mp_limb_t bit; mp_ptr dp; dn = GMP_ABS (d->_mp_size); limb_index = bit_index / GMP_LIMB_BITS; bit = (mp_limb_t) 1 << (bit_index % GMP_LIMB_BITS); if (limb_index >= dn) { mp_size_t i; /* The bit should be set outside of the end of the number. We have to increase the size of the number. */ dp = MPZ_REALLOC (d, limb_index + 1); dp[limb_index] = bit; for (i = dn; i < limb_index; i++) dp[i] = 0; dn = limb_index + 1; } else { mp_limb_t cy; dp = d->_mp_d; cy = mpn_add_1 (dp + limb_index, dp + limb_index, dn - limb_index, bit); if (cy > 0) { dp = MPZ_REALLOC (d, dn + 1); dp[dn++] = cy; } } d->_mp_size = (d->_mp_size < 0) ? - dn : dn; } static void mpz_abs_sub_bit (mpz_t d, mp_bitcnt_t bit_index) { mp_size_t dn, limb_index; mp_ptr dp; mp_limb_t bit; dn = GMP_ABS (d->_mp_size); dp = d->_mp_d; limb_index = bit_index / GMP_LIMB_BITS; bit = (mp_limb_t) 1 << (bit_index % GMP_LIMB_BITS); assert (limb_index < dn); gmp_assert_nocarry (mpn_sub_1 (dp + limb_index, dp + limb_index, dn - limb_index, bit)); dn -= (dp[dn-1] == 0); d->_mp_size = (d->_mp_size < 0) ? - dn : dn; } void mpz_setbit (mpz_t d, mp_bitcnt_t bit_index) { if (!mpz_tstbit (d, bit_index)) { if (d->_mp_size >= 0) mpz_abs_add_bit (d, bit_index); else mpz_abs_sub_bit (d, bit_index); } } void mpz_clrbit (mpz_t d, mp_bitcnt_t bit_index) { if (mpz_tstbit (d, bit_index)) { if (d->_mp_size >= 0) mpz_abs_sub_bit (d, bit_index); else mpz_abs_add_bit (d, bit_index); } } void mpz_combit (mpz_t d, mp_bitcnt_t bit_index) { if (mpz_tstbit (d, bit_index) ^ (d->_mp_size < 0)) mpz_abs_sub_bit (d, bit_index); else mpz_abs_add_bit (d, bit_index); } void mpz_com (mpz_t r, const mpz_t u) { mpz_neg (r, u); mpz_sub_ui (r, r, 1); } void mpz_and (mpz_t r, const mpz_t u, const mpz_t v) { mp_size_t un, vn, rn, i; mp_ptr up, vp, rp; mp_limb_t ux, vx, rx; mp_limb_t uc, vc, rc; mp_limb_t ul, vl, rl; un = GMP_ABS (u->_mp_size); vn = GMP_ABS (v->_mp_size); if (un < vn) { MPZ_SRCPTR_SWAP (u, v); MP_SIZE_T_SWAP (un, vn); } if (vn == 0) { r->_mp_size = 0; return; } uc = u->_mp_size < 0; vc = v->_mp_size < 0; rc = uc & vc; ux = -uc; vx = -vc; rx = -rc; /* If the smaller input is positive, higher limbs don't matter. */ rn = vx ? un : vn; rp = MPZ_REALLOC (r, rn + rc); up = u->_mp_d; vp = v->_mp_d; i = 0; do { ul = (up[i] ^ ux) + uc; uc = ul < uc; vl = (vp[i] ^ vx) + vc; vc = vl < vc; rl = ( (ul & vl) ^ rx) + rc; rc = rl < rc; rp[i] = rl; } while (++i < vn); assert (vc == 0); for (; i < rn; i++) { ul = (up[i] ^ ux) + uc; uc = ul < uc; rl = ( (ul & vx) ^ rx) + rc; rc = rl < rc; rp[i] = rl; } if (rc) rp[rn++] = rc; else rn = mpn_normalized_size (rp, rn); r->_mp_size = rx ? -rn : rn; } void mpz_ior (mpz_t r, const mpz_t u, const mpz_t v) { mp_size_t un, vn, rn, i; mp_ptr up, vp, rp; mp_limb_t ux, vx, rx; mp_limb_t uc, vc, rc; mp_limb_t ul, vl, rl; un = GMP_ABS (u->_mp_size); vn = GMP_ABS (v->_mp_size); if (un < vn) { MPZ_SRCPTR_SWAP (u, v); MP_SIZE_T_SWAP (un, vn); } if (vn == 0) { mpz_set (r, u); return; } uc = u->_mp_size < 0; vc = v->_mp_size < 0; rc = uc | vc; ux = -uc; vx = -vc; rx = -rc; /* If the smaller input is negative, by sign extension higher limbs don't matter. */ rn = vx ? vn : un; rp = MPZ_REALLOC (r, rn + rc); up = u->_mp_d; vp = v->_mp_d; i = 0; do { ul = (up[i] ^ ux) + uc; uc = ul < uc; vl = (vp[i] ^ vx) + vc; vc = vl < vc; rl = ( (ul | vl) ^ rx) + rc; rc = rl < rc; rp[i] = rl; } while (++i < vn); assert (vc == 0); for (; i < rn; i++) { ul = (up[i] ^ ux) + uc; uc = ul < uc; rl = ( (ul | vx) ^ rx) + rc; rc = rl < rc; rp[i] = rl; } if (rc) rp[rn++] = rc; else rn = mpn_normalized_size (rp, rn); r->_mp_size = rx ? -rn : rn; } void mpz_xor (mpz_t r, const mpz_t u, const mpz_t v) { mp_size_t un, vn, i; mp_ptr up, vp, rp; mp_limb_t ux, vx, rx; mp_limb_t uc, vc, rc; mp_limb_t ul, vl, rl; un = GMP_ABS (u->_mp_size); vn = GMP_ABS (v->_mp_size); if (un < vn) { MPZ_SRCPTR_SWAP (u, v); MP_SIZE_T_SWAP (un, vn); } if (vn == 0) { mpz_set (r, u); return; } uc = u->_mp_size < 0; vc = v->_mp_size < 0; rc = uc ^ vc; ux = -uc; vx = -vc; rx = -rc; rp = MPZ_REALLOC (r, un + rc); up = u->_mp_d; vp = v->_mp_d; i = 0; do { ul = (up[i] ^ ux) + uc; uc = ul < uc; vl = (vp[i] ^ vx) + vc; vc = vl < vc; rl = (ul ^ vl ^ rx) + rc; rc = rl < rc; rp[i] = rl; } while (++i < vn); assert (vc == 0); for (; i < un; i++) { ul = (up[i] ^ ux) + uc; uc = ul < uc; rl = (ul ^ ux) + rc; rc = rl < rc; rp[i] = rl; } if (rc) rp[un++] = rc; else un = mpn_normalized_size (rp, un); r->_mp_size = rx ? -un : un; } static unsigned gmp_popcount_limb (mp_limb_t x) { unsigned c; /* Do 16 bits at a time, to avoid limb-sized constants. */ for (c = 0; x > 0; x >>= 16) { unsigned w = ((x >> 1) & 0x5555) + (x & 0x5555); w = ((w >> 2) & 0x3333) + (w & 0x3333); w = ((w >> 4) & 0x0f0f) + (w & 0x0f0f); w = (w >> 8) + (w & 0x00ff); c += w; } return c; } mp_bitcnt_t mpn_popcount (mp_srcptr p, mp_size_t n) { mp_size_t i; mp_bitcnt_t c; for (c = 0, i = 0; i < n; i++) c += gmp_popcount_limb (p[i]); return c; } mp_bitcnt_t mpz_popcount (const mpz_t u) { mp_size_t un; un = u->_mp_size; if (un < 0) return ~(mp_bitcnt_t) 0; return mpn_popcount (u->_mp_d, un); } mp_bitcnt_t mpz_hamdist (const mpz_t u, const mpz_t v) { mp_size_t un, vn, i; mp_limb_t uc, vc, ul, vl, comp; mp_srcptr up, vp; mp_bitcnt_t c; un = u->_mp_size; vn = v->_mp_size; if ( (un ^ vn) < 0) return ~(mp_bitcnt_t) 0; comp = - (uc = vc = (un < 0)); if (uc) { assert (vn < 0); un = -un; vn = -vn; } up = u->_mp_d; vp = v->_mp_d; if (un < vn) MPN_SRCPTR_SWAP (up, un, vp, vn); for (i = 0, c = 0; i < vn; i++) { ul = (up[i] ^ comp) + uc; uc = ul < uc; vl = (vp[i] ^ comp) + vc; vc = vl < vc; c += gmp_popcount_limb (ul ^ vl); } assert (vc == 0); for (; i < un; i++) { ul = (up[i] ^ comp) + uc; uc = ul < uc; c += gmp_popcount_limb (ul ^ comp); } return c; } mp_bitcnt_t mpz_scan1 (const mpz_t u, mp_bitcnt_t starting_bit) { mp_ptr up; mp_size_t us, un, i; mp_limb_t limb, ux; us = u->_mp_size; un = GMP_ABS (us); i = starting_bit / GMP_LIMB_BITS; /* Past the end there's no 1 bits for u>=0, or an immediate 1 bit for u<0. Notice this test picks up any u==0 too. */ if (i >= un) return (us >= 0 ? ~(mp_bitcnt_t) 0 : starting_bit); up = u->_mp_d; ux = 0; limb = up[i]; if (starting_bit != 0) { if (us < 0) { ux = mpn_zero_p (up, i); limb = ~ limb + ux; ux = - (mp_limb_t) (limb >= ux); } /* Mask to 0 all bits before starting_bit, thus ignoring them. */ limb &= (GMP_LIMB_MAX << (starting_bit % GMP_LIMB_BITS)); } return mpn_common_scan (limb, i, up, un, ux); } mp_bitcnt_t mpz_scan0 (const mpz_t u, mp_bitcnt_t starting_bit) { mp_ptr up; mp_size_t us, un, i; mp_limb_t limb, ux; us = u->_mp_size; ux = - (mp_limb_t) (us >= 0); un = GMP_ABS (us); i = starting_bit / GMP_LIMB_BITS; /* When past end, there's an immediate 0 bit for u>=0, or no 0 bits for u<0. Notice this test picks up all cases of u==0 too. */ if (i >= un) return (ux ? starting_bit : ~(mp_bitcnt_t) 0); up = u->_mp_d; limb = up[i] ^ ux; if (ux == 0) limb -= mpn_zero_p (up, i); /* limb = ~(~limb + zero_p) */ /* Mask all bits before starting_bit, thus ignoring them. */ limb &= (GMP_LIMB_MAX << (starting_bit % GMP_LIMB_BITS)); return mpn_common_scan (limb, i, up, un, ux); } /* MPZ base conversion. */ size_t mpz_sizeinbase (const mpz_t u, int base) { mp_size_t un; mp_srcptr up; mp_ptr tp; mp_bitcnt_t bits; struct gmp_div_inverse bi; size_t ndigits; assert (base >= 2); assert (base <= 36); un = GMP_ABS (u->_mp_size); if (un == 0) return 1; up = u->_mp_d; bits = (un - 1) * GMP_LIMB_BITS + mpn_limb_size_in_base_2 (up[un-1]); switch (base) { case 2: return bits; case 4: return (bits + 1) / 2; case 8: return (bits + 2) / 3; case 16: return (bits + 3) / 4; case 32: return (bits + 4) / 5; /* FIXME: Do something more clever for the common case of base 10. */ } tp = gmp_xalloc_limbs (un); mpn_copyi (tp, up, un); mpn_div_qr_1_invert (&bi, base); ndigits = 0; do { ndigits++; mpn_div_qr_1_preinv (tp, tp, un, &bi); un -= (tp[un-1] == 0); } while (un > 0); gmp_free (tp); return ndigits; } char * mpz_get_str (char *sp, int base, const mpz_t u) { unsigned bits; const char *digits; mp_size_t un; size_t i, sn; if (base >= 0) { digits = "0123456789abcdefghijklmnopqrstuvwxyz"; } else { base = -base; digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; } if (base <= 1) base = 10; if (base > 36) return NULL; sn = 1 + mpz_sizeinbase (u, base); if (!sp) sp = gmp_xalloc (1 + sn); un = GMP_ABS (u->_mp_size); if (un == 0) { sp[0] = '0'; sp[1] = '\0'; return sp; } i = 0; if (u->_mp_size < 0) sp[i++] = '-'; bits = mpn_base_power_of_two_p (base); if (bits) /* Not modified in this case. */ sn = i + mpn_get_str_bits ((unsigned char *) sp + i, bits, u->_mp_d, un); else { struct mpn_base_info info; mp_ptr tp; mpn_get_base_info (&info, base); tp = gmp_xalloc_limbs (un); mpn_copyi (tp, u->_mp_d, un); sn = i + mpn_get_str_other ((unsigned char *) sp + i, base, &info, tp, un); gmp_free (tp); } for (; i < sn; i++) sp[i] = digits[(unsigned char) sp[i]]; sp[sn] = '\0'; return sp; } int mpz_set_str (mpz_t r, const char *sp, int base) { unsigned bits; mp_size_t rn, alloc; mp_ptr rp; size_t sn; int sign; unsigned char *dp; assert (base == 0 || (base >= 2 && base <= 36)); while (isspace( (unsigned char) *sp)) sp++; sign = (*sp == '-'); sp += sign; if (base == 0) { if (*sp == '0') { sp++; if (*sp == 'x' || *sp == 'X') { base = 16; sp++; } else if (*sp == 'b' || *sp == 'B') { base = 2; sp++; } else base = 8; } else base = 10; } sn = strlen (sp); dp = gmp_xalloc (sn + (sn == 0)); for (sn = 0; *sp; sp++) { unsigned digit; if (isspace ((unsigned char) *sp)) continue; if (*sp >= '0' && *sp <= '9') digit = *sp - '0'; else if (*sp >= 'a' && *sp <= 'z') digit = *sp - 'a' + 10; else if (*sp >= 'A' && *sp <= 'Z') digit = *sp - 'A' + 10; else digit = base; /* fail */ if (digit >= (unsigned)base) { gmp_free (dp); r->_mp_size = 0; return -1; } dp[sn++] = digit; } bits = mpn_base_power_of_two_p (base); if (bits > 0) { alloc = (sn * bits + GMP_LIMB_BITS - 1) / GMP_LIMB_BITS; rp = MPZ_REALLOC (r, alloc); rn = mpn_set_str_bits (rp, dp, sn, bits); } else { struct mpn_base_info info; mpn_get_base_info (&info, base); alloc = (sn + info.exp - 1) / info.exp; rp = MPZ_REALLOC (r, alloc); rn = mpn_set_str_other (rp, dp, sn, base, &info); } assert (rn <= alloc); gmp_free (dp); r->_mp_size = sign ? - rn : rn; return 0; } int mpz_init_set_str (mpz_t r, const char *sp, int base) { mpz_init (r); return mpz_set_str (r, sp, base); } size_t mpz_out_str (FILE *stream, int base, const mpz_t x) { char *str; size_t len; str = mpz_get_str (NULL, base, x); len = strlen (str); len = fwrite (str, 1, len, stream); gmp_free (str); return len; } static int gmp_detect_endian (void) { static const int i = 2; const unsigned char *p = (const unsigned char *) &i; return 1 - *p; } /* Import and export. Does not support nails. */ void mpz_import (mpz_t r, size_t count, int order, size_t size, int endian, size_t nails, const void *src) { const unsigned char *p; ptrdiff_t word_step; mp_ptr rp; mp_size_t rn; /* The current (partial) limb. */ mp_limb_t limb; /* The number of bytes already copied to this limb (starting from the low end). */ size_t bytes; /* The index where the limb should be stored, when completed. */ mp_size_t i; if (nails != 0) gmp_die ("mpz_import: Nails not supported."); assert (order == 1 || order == -1); assert (endian >= -1 && endian <= 1); if (endian == 0) endian = gmp_detect_endian (); p = (unsigned char *) src; word_step = (order != endian) ? 2 * size : 0; /* Process bytes from the least significant end, so point p at the least significant word. */ if (order == 1) { p += size * (count - 1); word_step = - word_step; } /* And at least significant byte of that word. */ if (endian == 1) p += (size - 1); rn = (size * count + sizeof(mp_limb_t) - 1) / sizeof(mp_limb_t); rp = MPZ_REALLOC (r, rn); for (limb = 0, bytes = 0, i = 0; count > 0; count--, p += word_step) { size_t j; for (j = 0; j < size; j++, p -= (ptrdiff_t) endian) { limb |= (mp_limb_t) *p << (bytes++ * CHAR_BIT); if (bytes == sizeof(mp_limb_t)) { rp[i++] = limb; bytes = 0; limb = 0; } } } assert (i + (bytes > 0) == rn); if (limb != 0) rp[i++] = limb; else i = mpn_normalized_size (rp, i); r->_mp_size = i; } void * mpz_export (void *r, size_t *countp, int order, size_t size, int endian, size_t nails, const mpz_t u) { size_t count; mp_size_t un; if (nails != 0) gmp_die ("mpz_import: Nails not supported."); assert (order == 1 || order == -1); assert (endian >= -1 && endian <= 1); assert (size > 0 || u->_mp_size == 0); un = u->_mp_size; count = 0; if (un != 0) { size_t k; unsigned char *p; ptrdiff_t word_step; /* The current (partial) limb. */ mp_limb_t limb; /* The number of bytes left to to in this limb. */ size_t bytes; /* The index where the limb was read. */ mp_size_t i; un = GMP_ABS (un); /* Count bytes in top limb. */ limb = u->_mp_d[un-1]; assert (limb != 0); k = 0; do { k++; limb >>= CHAR_BIT; } while (limb != 0); count = (k + (un-1) * sizeof (mp_limb_t) + size - 1) / size; if (!r) r = gmp_xalloc (count * size); if (endian == 0) endian = gmp_detect_endian (); p = (unsigned char *) r; word_step = (order != endian) ? 2 * size : 0; /* Process bytes from the least significant end, so point p at the least significant word. */ if (order == 1) { p += size * (count - 1); word_step = - word_step; } /* And at least significant byte of that word. */ if (endian == 1) p += (size - 1); for (bytes = 0, i = 0, k = 0; k < count; k++, p += word_step) { size_t j; for (j = 0; j < size; j++, p -= (ptrdiff_t) endian) { if (bytes == 0) { if (i < un) limb = u->_mp_d[i++]; bytes = sizeof (mp_limb_t); } *p = limb; limb >>= CHAR_BIT; bytes--; } } assert (i == un); assert (k == count); } if (countp) *countp = count; return r; } libdfp-1.0.12/libdecnumber/mini-gmp.h000066400000000000000000000256331261375163000173710ustar00rootroot00000000000000/* mini-gmp, a minimalistic implementation of a GNU GMP subset. Copyright 2011-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/. */ /* About mini-gmp: This is a minimal implementation of a subset of the GMP interface. It is intended for inclusion into applications which have modest bignums needs, as a fallback when the real GMP library is not installed. This file defines the public interface. */ #ifndef __MINI_GMP_H__ #define __MINI_GMP_H__ /* For size_t */ #include #if defined (__cplusplus) extern "C" { #endif void mp_set_memory_functions (void *(*) (size_t), void *(*) (void *, size_t, size_t), void (*) (void *, size_t)); void mp_get_memory_functions (void *(**) (size_t), void *(**) (void *, size_t, size_t), void (**) (void *, size_t)); typedef unsigned long mp_limb_t; typedef long mp_size_t; typedef unsigned long mp_bitcnt_t; typedef mp_limb_t *mp_ptr; typedef const mp_limb_t *mp_srcptr; typedef struct { int _mp_alloc; /* Number of *limbs* allocated and pointed to by the _mp_d field. */ int _mp_size; /* abs(_mp_size) is the number of limbs the last field points to. If _mp_size is negative this is a negative number. */ mp_limb_t *_mp_d; /* Pointer to the limbs. */ } __mpz_struct; typedef __mpz_struct mpz_t[1]; typedef __mpz_struct *mpz_ptr; typedef const __mpz_struct *mpz_srcptr; extern const int mp_bits_per_limb; void mpn_copyi (mp_ptr, mp_srcptr, mp_size_t); void mpn_copyd (mp_ptr, mp_srcptr, mp_size_t); void mpn_zero (mp_ptr, mp_size_t); int mpn_cmp (mp_srcptr, mp_srcptr, mp_size_t); mp_limb_t mpn_add_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); mp_limb_t mpn_add_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); mp_limb_t mpn_add (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); mp_limb_t mpn_sub_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); mp_limb_t mpn_sub_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); mp_limb_t mpn_sub (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); mp_limb_t mpn_mul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); mp_limb_t mpn_addmul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); mp_limb_t mpn_submul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); mp_limb_t mpn_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); void mpn_mul_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); void mpn_sqr (mp_ptr, mp_srcptr, mp_size_t); int mpn_perfect_square_p (mp_srcptr, mp_size_t); mp_size_t mpn_sqrtrem (mp_ptr, mp_ptr, mp_srcptr, mp_size_t); mp_limb_t mpn_lshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int); mp_limb_t mpn_rshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int); mp_bitcnt_t mpn_scan0 (mp_srcptr, mp_bitcnt_t); mp_bitcnt_t mpn_scan1 (mp_srcptr, mp_bitcnt_t); mp_bitcnt_t mpn_popcount (mp_srcptr, mp_size_t); mp_limb_t mpn_invert_3by2 (mp_limb_t, mp_limb_t); #define mpn_invert_limb(x) mpn_invert_3by2 ((x), 0) size_t mpn_get_str (unsigned char *, int, mp_ptr, mp_size_t); mp_size_t mpn_set_str (mp_ptr, const unsigned char *, size_t, int); void mpz_init (mpz_t); void mpz_init2 (mpz_t, mp_bitcnt_t); void mpz_clear (mpz_t); #define mpz_odd_p(z) (((z)->_mp_size != 0) & (int) (z)->_mp_d[0]) #define mpz_even_p(z) (! mpz_odd_p (z)) int mpz_sgn (const mpz_t); int mpz_cmp_si (const mpz_t, long); int mpz_cmp_ui (const mpz_t, unsigned long); int mpz_cmp (const mpz_t, const mpz_t); int mpz_cmpabs_ui (const mpz_t, unsigned long); int mpz_cmpabs (const mpz_t, const mpz_t); int mpz_cmp_d (const mpz_t, double); int mpz_cmpabs_d (const mpz_t, double); void mpz_abs (mpz_t, const mpz_t); void mpz_neg (mpz_t, const mpz_t); void mpz_swap (mpz_t, mpz_t); void mpz_add_ui (mpz_t, const mpz_t, unsigned long); void mpz_add (mpz_t, const mpz_t, const mpz_t); void mpz_sub_ui (mpz_t, const mpz_t, unsigned long); void mpz_ui_sub (mpz_t, unsigned long, const mpz_t); void mpz_sub (mpz_t, const mpz_t, const mpz_t); void mpz_mul_si (mpz_t, const mpz_t, long int); void mpz_mul_ui (mpz_t, const mpz_t, unsigned long int); void mpz_mul (mpz_t, const mpz_t, const mpz_t); void mpz_mul_2exp (mpz_t, const mpz_t, mp_bitcnt_t); void mpz_addmul_ui (mpz_t, const mpz_t, unsigned long int); void mpz_addmul (mpz_t, const mpz_t, const mpz_t); void mpz_submul_ui (mpz_t, const mpz_t, unsigned long int); void mpz_submul (mpz_t, const mpz_t, const mpz_t); void mpz_cdiv_qr (mpz_t, mpz_t, const mpz_t, const mpz_t); void mpz_fdiv_qr (mpz_t, mpz_t, const mpz_t, const mpz_t); void mpz_tdiv_qr (mpz_t, mpz_t, const mpz_t, const mpz_t); void mpz_cdiv_q (mpz_t, const mpz_t, const mpz_t); void mpz_fdiv_q (mpz_t, const mpz_t, const mpz_t); void mpz_tdiv_q (mpz_t, const mpz_t, const mpz_t); void mpz_cdiv_r (mpz_t, const mpz_t, const mpz_t); void mpz_fdiv_r (mpz_t, const mpz_t, const mpz_t); void mpz_tdiv_r (mpz_t, const mpz_t, const mpz_t); void mpz_cdiv_q_2exp (mpz_t, const mpz_t, mp_bitcnt_t); void mpz_fdiv_q_2exp (mpz_t, const mpz_t, mp_bitcnt_t); void mpz_tdiv_q_2exp (mpz_t, const mpz_t, mp_bitcnt_t); void mpz_cdiv_r_2exp (mpz_t, const mpz_t, mp_bitcnt_t); void mpz_fdiv_r_2exp (mpz_t, const mpz_t, mp_bitcnt_t); void mpz_tdiv_r_2exp (mpz_t, const mpz_t, mp_bitcnt_t); void mpz_mod (mpz_t, const mpz_t, const mpz_t); void mpz_divexact (mpz_t, const mpz_t, const mpz_t); int mpz_divisible_p (const mpz_t, const mpz_t); int mpz_congruent_p (const mpz_t, const mpz_t, const mpz_t); unsigned long mpz_cdiv_qr_ui (mpz_t, mpz_t, const mpz_t, unsigned long); unsigned long mpz_fdiv_qr_ui (mpz_t, mpz_t, const mpz_t, unsigned long); unsigned long mpz_tdiv_qr_ui (mpz_t, mpz_t, const mpz_t, unsigned long); unsigned long mpz_cdiv_q_ui (mpz_t, const mpz_t, unsigned long); unsigned long mpz_fdiv_q_ui (mpz_t, const mpz_t, unsigned long); unsigned long mpz_tdiv_q_ui (mpz_t, const mpz_t, unsigned long); unsigned long mpz_cdiv_r_ui (mpz_t, const mpz_t, unsigned long); unsigned long mpz_fdiv_r_ui (mpz_t, const mpz_t, unsigned long); unsigned long mpz_tdiv_r_ui (mpz_t, const mpz_t, unsigned long); unsigned long mpz_cdiv_ui (const mpz_t, unsigned long); unsigned long mpz_fdiv_ui (const mpz_t, unsigned long); unsigned long mpz_tdiv_ui (const mpz_t, unsigned long); unsigned long mpz_mod_ui (mpz_t, const mpz_t, unsigned long); void mpz_divexact_ui (mpz_t, const mpz_t, unsigned long); int mpz_divisible_ui_p (const mpz_t, unsigned long); unsigned long mpz_gcd_ui (mpz_t, const mpz_t, unsigned long); void mpz_gcd (mpz_t, const mpz_t, const mpz_t); void mpz_gcdext (mpz_t, mpz_t, mpz_t, const mpz_t, const mpz_t); void mpz_lcm_ui (mpz_t, const mpz_t, unsigned long); void mpz_lcm (mpz_t, const mpz_t, const mpz_t); int mpz_invert (mpz_t, const mpz_t, const mpz_t); void mpz_sqrtrem (mpz_t, mpz_t, const mpz_t); void mpz_sqrt (mpz_t, const mpz_t); int mpz_perfect_square_p (const mpz_t); void mpz_pow_ui (mpz_t, const mpz_t, unsigned long); void mpz_ui_pow_ui (mpz_t, unsigned long, unsigned long); void mpz_powm (mpz_t, const mpz_t, const mpz_t, const mpz_t); void mpz_powm_ui (mpz_t, const mpz_t, unsigned long, const mpz_t); void mpz_rootrem (mpz_t, mpz_t, const mpz_t, unsigned long); int mpz_root (mpz_t, const mpz_t, unsigned long); void mpz_fac_ui (mpz_t, unsigned long); void mpz_bin_uiui (mpz_t, unsigned long, unsigned long); int mpz_probab_prime_p (const mpz_t, int); int mpz_tstbit (const mpz_t, mp_bitcnt_t); void mpz_setbit (mpz_t, mp_bitcnt_t); void mpz_clrbit (mpz_t, mp_bitcnt_t); void mpz_combit (mpz_t, mp_bitcnt_t); void mpz_com (mpz_t, const mpz_t); void mpz_and (mpz_t, const mpz_t, const mpz_t); void mpz_ior (mpz_t, const mpz_t, const mpz_t); void mpz_xor (mpz_t, const mpz_t, const mpz_t); mp_bitcnt_t mpz_popcount (const mpz_t); mp_bitcnt_t mpz_hamdist (const mpz_t, const mpz_t); mp_bitcnt_t mpz_scan0 (const mpz_t, mp_bitcnt_t); mp_bitcnt_t mpz_scan1 (const mpz_t, mp_bitcnt_t); int mpz_fits_slong_p (const mpz_t); int mpz_fits_ulong_p (const mpz_t); long int mpz_get_si (const mpz_t); unsigned long int mpz_get_ui (const mpz_t); double mpz_get_d (const mpz_t); size_t mpz_size (const mpz_t); mp_limb_t mpz_getlimbn (const mpz_t, mp_size_t); void mpz_realloc2 (mpz_t, mp_bitcnt_t); mp_srcptr mpz_limbs_read (mpz_srcptr); mp_ptr mpz_limbs_modify (mpz_t, mp_size_t); mp_ptr mpz_limbs_write (mpz_t, mp_size_t); void mpz_limbs_finish (mpz_t, mp_size_t); mpz_srcptr mpz_roinit_n (mpz_t, mp_srcptr, mp_size_t); #define MPZ_ROINIT_N(xp, xs) {{0, (xs),(xp) }} void mpz_set_si (mpz_t, signed long int); void mpz_set_ui (mpz_t, unsigned long int); void mpz_set (mpz_t, const mpz_t); void mpz_set_d (mpz_t, double); void mpz_init_set_si (mpz_t, signed long int); void mpz_init_set_ui (mpz_t, unsigned long int); void mpz_init_set (mpz_t, const mpz_t); void mpz_init_set_d (mpz_t, double); size_t mpz_sizeinbase (const mpz_t, int); char *mpz_get_str (char *, int, const mpz_t); int mpz_set_str (mpz_t, const char *, int); int mpz_init_set_str (mpz_t, const char *, int); /* This long list taken from gmp.h. */ /* For reference, "defined(EOF)" cannot be used here. In g++ 2.95.4, defines EOF but not FILE. */ #if defined (FILE) \ || defined (H_STDIO) \ || defined (_H_STDIO) /* AIX */ \ || defined (_STDIO_H) /* glibc, Sun, SCO */ \ || defined (_STDIO_H_) /* BSD, OSF */ \ || defined (__STDIO_H) /* Borland */ \ || defined (__STDIO_H__) /* IRIX */ \ || defined (_STDIO_INCLUDED) /* HPUX */ \ || defined (__dj_include_stdio_h_) /* DJGPP */ \ || defined (_FILE_DEFINED) /* Microsoft */ \ || defined (__STDIO__) /* Apple MPW MrC */ \ || defined (_MSL_STDIO_H) /* Metrowerks */ \ || defined (_STDIO_H_INCLUDED) /* QNX4 */ \ || defined (_ISO_STDIO_ISO_H) /* Sun C++ */ \ || defined (__STDIO_LOADED) /* VMS */ size_t mpz_out_str (FILE *, int, const mpz_t); #endif void mpz_import (mpz_t, size_t, int, size_t, int, size_t, const void *); void *mpz_export (void *, size_t *, int, size_t, int, size_t, const mpz_t); #if defined (__cplusplus) } #endif #endif /* __MINI_GMP_H__ */ libdfp-1.0.12/libdfp-version.c000066400000000000000000000027041261375163000161310ustar00rootroot00000000000000/* Entry point for shared-libraries. Copyright (C) 2012-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include "config.h" void __libdfp_version (void); const char __invoke_dynamic_linker__[] __attribute__ ((section (".interp"))) = LIBDFP_RUNTIME_LOADER; void __attribute__ ((noreturn)) __libdfp_version (void) { printf ("Decimal Floating Point C Library (" PACKAGE_STRING").\n" "Copyright (C) 2014 Free Software Foundation.\n" "Compiled by GNU version "__VERSION__".\n" "For bug reporting please contact:\n" "<"PACKAGE_BUGREPORT">.\n"); exit (0); } libdfp-1.0.12/mapround.h000066400000000000000000000023671261375163000150450ustar00rootroot00000000000000/* Prototype for getting the decimal rounding mode mapped to the decNumber rounding mode enumeration values. Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _MAPROUND_H #define _MAPROUND_H /* Get the rounding mode mapped to the decNumber rounding modes. */ extern int __dn_getround(void); #endif /* _MAPROUND_H */ libdfp-1.0.12/numdigits.h000066400000000000000000000022071261375163000152140ustar00rootroot00000000000000/* Number of digits functions, generic (use libdecNumber). Copyright (C) 2006, 2007 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _NUMDIGITS_H #define _NUMDIGITS_H 1 #define NUMDIGITS_SUPPORT 0 #endif /* _NUMDIGITS_H */ libdfp-1.0.12/old_printf_dfp.c000066400000000000000000000117061261375163000162010ustar00rootroot00000000000000/* Function definition to convert DFP values to strings Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #warn "This is an incomplete implementation. Please adapt sysdeps/dpd/printf_dfp.c for BID. */ #include "printf_dfp.h" #include #include #include static int pa_d128; static int pa_d64; static int pa_d32; void __d128_va (void *mem, va_list *ap) { _Decimal128 d = va_arg (*ap, _Decimal128); memcpy (mem, &d, sizeof (d)); } strong_alias(__d128_va, d128_va) hidden_def(__d128_va) void __d64_va (void *mem, va_list *ap) { _Decimal64 d = va_arg (*ap, _Decimal64); memcpy (mem, &d, sizeof (d)); } strong_alias(__d64_va, d64_va) hidden_def(__d64_va) void __d32_va (void *mem, va_list *ap) { _Decimal32 d = va_arg (*ap, _Decimal32); memcpy (mem, &d, sizeof (d)); } strong_alias(__d32_va, d32_va) hidden_def(__d32_va) int __d128_ais (const struct printf_info *info __attribute__ ((unused)), size_t n __attribute__ ((unused)), int *argtype, int *size) { argtype[0] = pa_d128; size[0] = sizeof (_Decimal128); /* Isn't this going to say it always handles this type? */ return 1; } strong_alias(__d128_ais, d128_ais) hidden_def(__d128_ais) int __d64_ais (const struct printf_info *info __attribute__ ((unused)), size_t n __attribute__ ((unused)), int *argtype, int *size) { argtype[0] = pa_d64; size[0] = sizeof (_Decimal64); return 1; } strong_alias(__d64_ais, d64_ais) hidden_def(__d64_ais) int __d32_ais (const struct printf_info *info __attribute__ ((unused)), size_t n __attribute__ ((unused)), int *argtype, int *size) { argtype[0] = pa_d32; size[0] = sizeof (_Decimal32); return 1; } strong_alias(__d32_ais, d32_ais) hidden_def(__d32_ais) static int mod_H; static int mod_D; static int mod_DD; #define DECIMAL_PRINTF_BUF_SIZE 97 /* ((DECIMAL128_PMAX + 14) * 2) + 1 */ int __printf_dfp (FILE *fp, const struct printf_info *info, const void *const *args) { char str[DECIMAL_PRINTF_BUF_SIZE]; int len = 0; if (info->user & mod_H) /* %H */ { __fmt_d32 (info, args, str, DECIMAL_PRINTF_BUF_SIZE); } else if (info->user & mod_DD) /* %DD */ { __fmt_d128 (info, args, str, DECIMAL_PRINTF_BUF_SIZE); } else /* %D */ { __fmt_d64 (info, args, str, DECIMAL_PRINTF_BUF_SIZE); } len=strlen(str); len = fprintf(fp,"%*s", len, &str[0]); return len; } strong_alias (__printf_dfp, printf_dfp) hidden_def (__printf_dfp) int __register_printf_dfp (void) { pa_d128 = register_printf_type (d128_va); pa_d32 = register_printf_type (d32_va); pa_d64 = register_printf_type (d64_va); mod_DD = register_printf_modifier (L"DD"); mod_H = register_printf_modifier (L"H"); mod_D = register_printf_modifier (L"D"); register_printf_specifier ('f', printf_dfp, d128_ais); register_printf_specifier ('F', printf_dfp, d128_ais); register_printf_specifier ('e', printf_dfp, d128_ais); register_printf_specifier ('E', printf_dfp, d128_ais); register_printf_specifier ('g', printf_dfp, d128_ais); register_printf_specifier ('G', printf_dfp, d128_ais); register_printf_specifier ('a', printf_dfp, d128_ais); register_printf_specifier ('A', printf_dfp, d128_ais); register_printf_specifier ('f', printf_dfp, d32_ais); register_printf_specifier ('F', printf_dfp, d32_ais); register_printf_specifier ('e', printf_dfp, d32_ais); register_printf_specifier ('E', printf_dfp, d32_ais); register_printf_specifier ('g', printf_dfp, d32_ais); register_printf_specifier ('G', printf_dfp, d32_ais); register_printf_specifier ('a', printf_dfp, d32_ais); register_printf_specifier ('A', printf_dfp, d32_ais); register_printf_specifier ('f', printf_dfp, d64_ais); register_printf_specifier ('F', printf_dfp, d64_ais); register_printf_specifier ('e', printf_dfp, d64_ais); register_printf_specifier ('E', printf_dfp, d64_ais); register_printf_specifier ('g', printf_dfp, d64_ais); register_printf_specifier ('G', printf_dfp, d64_ais); register_printf_specifier ('a', printf_dfp, d64_ais); register_printf_specifier ('A', printf_dfp, d64_ais); return 0; } strong_alias (__register_printf_dfp, register_printf_dfp) libdfp-1.0.12/printf_dfp.c000066400000000000000000000557541261375163000153560ustar00rootroot00000000000000/* Function definition to convert DFP values to strings Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ /* Based on GLIBC stdio-common/printf_fp.c by: Ulrich Drepper */ #include "printf_dfp.h" #include /* wchar.h has to be included BEFORE stdio.h or it loses function * definitions when dfp/wchar.h uses #include_next . */ #include #include #include #include #include #include #include #include #include #include /* For CHAR_MAX */ #include #include #define _DECIMAL_SIZE 128 #define DEC_TYPE _Decimal128 #include #undef _DECIMAL_SIZE #undef DEC_TYPE #undef ADJUST #undef Q #undef DECIMAL_BIAS #define _DECIMAL_SIZE 64 #define DEC_TYPE _Decimal64 #include #undef _DECIMAL_SIZE #undef DEC_TYPE #undef ADJUST #undef Q #undef DECIMAL_BIAS #define _DECIMAL_SIZE 32 #define DEC_TYPE _Decimal32 #include static int wpadn (FILE *fp, wint_t pad, int count) { int i; int written = 0; for (i=0;i 999)\ {\ outchar('0' + __builtin_abs(pr) / 1000);\ t_pr = (__builtin_abs(pr) % 1000);\ outchar('0' + t_pr/100);\ t_pr = (__builtin_abs(t_pr) % 100);\ outchar('0' + t_pr/10);\ t_pr = (__builtin_abs(t_pr) % 10);\ outchar('0' + t_pr);\ }\ else if (__builtin_abs(pr) > 99)\ {\ outchar('0' + __builtin_abs(pr)/100);\ t_pr = (__builtin_abs(pr) % 100);\ outchar('0' + t_pr/10);\ t_pr = (__builtin_abs(t_pr) % 10);\ outchar('0' + t_pr);\ }\ else if (__builtin_abs(pr) > 9)\ {\ outchar('0' + __builtin_abs(pr)/10);\ t_pr = (__builtin_abs(pr) % 10);\ outchar('0' + t_pr);\ }\ else\ {\ outchar('0' + __builtin_abs(pr));\ }\ } while (0) #define OUT_DIGITS(xp) \ do \ { \ int ia; \ outchar('['); \ outchar('d'); \ outchar('i'); \ outchar('g'); \ outchar('i'); \ outchar('t'); \ outchar('s'); \ outchar(':'); \ for (ia = 0; digits[ia] != '\0'; ia++) \ outchar(digits[ia]); \ outchar('e'); \ _OUT(xp); \ outchar(']');\ } while (0) #define OUT(pr,val) \ do \ { \ int slen = strlen(pr); \ int ia; \ outchar('['); \ for (ia = 0; ia < slen; ia++) \ outchar(pr[ia]); \ outchar(':'); \ _OUT(val); \ outchar(']');\ } while (0) #define OUT_PREC(pr) \ do \ { \ OUT("prec",pr); \ } while (0) #define OUT_INPUT_PREC(pr) \ do \ { \ OUT("input_prec",pr); \ } while (0) #define OUT_INDEX(idx) \ do \ { \ OUT("index",idx); \ } while (0) #define OUT_DEFAULT_PREC(pr) \ do \ { \ OUT("default_prec",pr); \ } while (0) #define OUT_LEN(ln) \ do \ { \ OUT("len",ln); \ } while (0) #define OUT_SIG(sg) \ do \ { \ OUT("sig",sg); \ } while (0) #define OUT_N(na) \ do \ { \ OUT("n",na); \ } while (0) #define OUT_WIDTH(wd) \ do \ { \ OUT("width",wd); \ } while (0) #define OUT_DECPT(dpt) \ do \ { \ OUT("decpt",dpt); \ } while (0) static int pa_d128; static int pa_d64; static int pa_d32; static int mod_H; static int mod_D; static int mod_DD; void __d128_va (void *mem, va_list *ap) { _Decimal128 d = va_arg (*ap, _Decimal128); memcpy (mem, &d, sizeof (d)); } strong_alias(__d128_va, d128_va) hidden_def(__d128_va) void __d64_va (void *mem, va_list *ap) { _Decimal64 d = va_arg (*ap, _Decimal64); memcpy (mem, &d, sizeof (d)); } strong_alias(__d64_va, d64_va) hidden_def(__d64_va) void __d32_va (void *mem, va_list *ap) { _Decimal32 d = va_arg (*ap, _Decimal32); memcpy (mem, &d, sizeof (d)); } strong_alias(__d32_va, d32_va) hidden_def(__d32_va) int __dfp_ais (const struct printf_info *info, size_t n __attribute__ ((unused)), int *argtype, int *size) { if ((info->user & mod_D) == mod_D) { argtype[0] = pa_d64; size[0] = sizeof (_Decimal64); return 1; } else if ((info->user & mod_DD) == mod_DD) { argtype[0] = pa_d128; size[0] = sizeof (_Decimal128); return 1; } else if ((info->user & mod_H) == mod_H) { argtype[0] = pa_d32; size[0] = sizeof (_Decimal32); return 1; } return -1; } strong_alias(__dfp_ais, dfp_ais) hidden_def(__dfp_ais) #define EXP_BIAS_D128 -6109 #define EXP_BIAS_D64 -368 #define EXP_BIAS_D32 -87 /* this includes the max digits in a _Decimal128, plus a bunch of formatting * characters. */ #define DECIMAL_PRINTF_BUF_SIZE 65 /* ((DECIMAL128_PMAX + 14) * 2) + 1 */ /* fe_decround.c will initialize this function pointer to fe_decgetround */ int (*__printf_dfp_getround_callback)(void) = NULL; int __printf_dfp (FILE *fp, const struct printf_info *info, const void *const *args) { int wide = info->wide; /* Counter for number of written characters. */ int done = 0; /* Locale-dependent representation of decimal point. */ const char *decimal; union { const char *mb; int wc; } decimalwc; char spec = tolower(info->spec); /* Locale-dependent thousands separator and grouping specification. */ const char *thousands_sep = NULL; wchar_t thousands_sepwc = 0; const char * thousands_sepmb; const char *grouping; #ifdef OPTION_EGLIBC_LOCALE_CODE if (info->extra == 0) { decimal = nl_langinfo (__DECIMAL_POINT); decimalwc.mb = nl_langinfo (_NL_NUMERIC_DECIMAL_POINT_WC); } else { decimal = nl_langinfo (__MON_DECIMAL_POINT); if (*decimal == '\0') decimal = nl_langinfo (__DECIMAL_POINT); decimalwc.mb = nl_langinfo (_NL_MONETARY_DECIMAL_POINT_WC); if (decimalwc.wc == L'\0') decimalwc.mb = nl_langinfo (_NL_NUMERIC_DECIMAL_POINT_WC); } /* The decimal point character must not be zero. */ assert (*decimal != '\0'); assert (decimalwc.wc != L'\0'); #else /* Hard-code values from 'C' locale. */ decimal = "."; decimalwc.wc = L'.'; #endif #ifdef OPTION_EGLIBC_LOCALE_CODE if (info->group) { if (info->extra == 0) grouping = nl_langinfo (__GROUPING); else grouping = nl_langinfo (__MON_GROUPING); if (*grouping <= 0 || *grouping == CHAR_MAX) grouping = NULL; else { /* Figure out the thousands separator character. */ if (wide) { if (info->extra == 0) { thousands_sepmb = nl_langinfo (_NL_NUMERIC_THOUSANDS_SEP_WC); mbrtowc(&thousands_sepwc,thousands_sepmb, CHAR_MAX, NULL); } else { thousands_sepmb = nl_langinfo (_NL_MONETARY_THOUSANDS_SEP_WC); mbrtowc(&thousands_sepwc,thousands_sepmb, CHAR_MAX, NULL); } } else { if (info->extra == 0) thousands_sep = nl_langinfo (__THOUSANDS_SEP); else thousands_sep = nl_langinfo (__MON_THOUSANDS_SEP); } if ((wide && thousands_sepwc == L'\0') || (! wide && *thousands_sep == '\0')) grouping = NULL; else if (thousands_sepwc == L'\0') /* If we are printing multibyte characters and there is a multibyte representation for the thousands separator, we must ensure the wide character thousands separator is available, even if it is fake. */ thousands_sepwc = 0xfffffffe; } } else grouping = NULL; #else grouping = NULL; #endif /* Seriously, only touch this code if you MUST. */ { char digits[DECIMAL_PRINTF_BUF_SIZE]; int exp, /* The exponent. */ is_neg, /* Is negative? */ is_nan, /* Is not a number? */ is_inf, /* Is infinite? */ decpt = 2, /* decimal point offset into digits[] */ prec, /* number of digits that follow the decimal point, or number of significant digits for %g */ default_prec = 6, /* Default precision, per the C Spec. */ input_prec = 0, /* Precision of the _Decimal* value. */ mw, /* Mantissa Width */ n, /* Current digit offset into digits[] */ nd, /* num_digits before the get_digits call. */ width, /* Width of the field */ is_zero = 0; /* Used in some of the output tests. */ digits[0] = '0'; /* need an extra digit for rounding up */ if (info->user & mod_D) { _Decimal64 d64 = **(_Decimal64**)args[0]; if (d64 == 0) is_zero = 1; nd = numdigitsd64(d64); __get_digits_d64 (d64, digits+1, &exp, &is_neg, &is_nan, &is_inf); mw = __DEC64_MANT_DIG__ + 1; } else if (info->user & mod_DD) { _Decimal128 d128 = **(_Decimal128**)args[0]; if (d128 == 0) is_zero = 1; nd = numdigitsd128(d128); __get_digits_d128 (d128, digits+1, &exp, &is_neg, &is_nan, &is_inf); mw = __DEC128_MANT_DIG__ + 1; } else if (info->user & mod_H) { _Decimal32 d32 = **(_Decimal32**)args[0]; if (d32 == 0) is_zero = 1; nd = numdigitsd32(d32); __get_digits_d32 (d32, digits+1, &exp, &is_neg, &is_nan, &is_inf); mw = __DEC32_MANT_DIG__ + 1; } else /* We shouldn't get here, but it is possible. */ return -2; /* The first digit is always a zero to allow rounding. */ n = 0; /* 'n' = position of first non-zero digit in the right-justified mantissa. */ n = mw - nd; /* Width and precision can not both be set or the results are undefined per * the C Spec. */ width = info->width; /* The user specified precision overrides the input's inherent precision. * This gets complicated quickly. */ prec = info->prec; if (is_nan || is_inf) { width -= 3; /*if (is_nan) is_neg = 0;*/ if (is_neg || info->showsign || info->space) width--; if (!info->left && width > 0) PADN (' ', width); if (is_neg) outchar ('-'); else if (info->showsign) outchar ('+'); else if (info->space) outchar (' '); if (is_nan) { if (isupper(info->spec)) { outchar ('N'); outchar ('A'); outchar ('N'); } else { outchar ('n'); outchar ('a'); outchar ('n'); } } else { if (isupper(info->spec)) { outchar ('I'); outchar ('N'); outchar ('F'); } else { outchar ('i'); outchar ('n'); outchar ('f'); } } if (info->left && width > 0) PADN (' ', width); return 0; } /* The term "precision" refers to the number of significant digits right of * the decimal place. Determine the implicit precision of the input value. * There are special rules for each of the supported flags.*/ switch (spec) { case 'a': { /* The DFP spec addition for %a refers to all of the significant * digits in the precision. */ input_prec = nd; /* This same check is done in two different places but it'll only * effect a single pass through once. If prec is not set it'll hit * this instance. If prec is set it'll hit the next instance. This * is because the DFP spec requires this to be run after rounding * when prec < input_prec. */ if (prec < 0 || prec >= input_prec) { /* Per the DFP specification (s,c,q), c == digits, q = exp, s == * is_neg. */ if (exp >= -(nd+5) && exp <= 0) { prec = -exp; spec = 'f'; } else { prec = nd - 1; spec = 'e'; input_prec = nd - 1; } } break; } case 'g': { int P = prec; /* When the C specification refers to X as the exponent it means the * exponent when the input value encoding is normalized to the form * d.dddd. This means we have to do that before we can do the goof * check. * * e.g., 123.456E-5 * right-justified -> 00123456E-9 * normalized -> 1.23456E-4 * * Normalize X to d.ddd... form by taking (exp) + (nd - 1) * * X == -4 */ int X = exp + (nd -1); /* The C Specification also indicates how to compute P. */ if (prec < 0) P = 6; else if (prec == 0) P = 1; /* Straight from the specification which assumes X is exponent normalized to * d.ddd... form. */ if (X >= -4 && P > X) { prec = (P - (X + 1)); spec = 'f'; } else { prec = P - 1; spec = 'e'; } input_prec = nd - 1; break; } case 'e': input_prec = nd - 1; break; case 'f': if(exp < 0 && (-exp) > default_prec) /* 00123456E-7 has an input_prec of 7. */ input_prec = (-exp); else /* 01234567E-6 has an input_prec of 6. */ /* 00000190E6 has an input_prec of 6. */ /* 00000123E1 has an input_prec of 6. */ /* 00000123E0 has an input_prec of 6. */ input_prec = default_prec; break; } /* The specs 'g' and 'a' may have already modified prec so this won't happen for * those cases. */ if (prec < 0) prec = default_prec; /* Do rounding if precision is less than the decimal type. On hardware DFP * this could probably easily be done with quantize but on soft-dfp the * existing method would be faster. */ if (prec < input_prec) { int index, roundmode = 0; char rounddigit = '4'; if (spec == 'f') /* This may force index to negative, in which case we ignore it at a * later time. */ index = n + nd + exp + prec; /* Goofy special case where we round significant digits which aren't * right of the decimal place. */ else if (tolower(info->spec) == 'a' && prec > 0) { index = n + prec; } else index = n + prec + 1; /* FIXME: we should check rounding mode for %a */ if (__printf_dfp_getround_callback) { roundmode = (*__printf_dfp_getround_callback)(); switch (roundmode) { case FE_DEC_TONEAREST: rounddigit = '4'; break; case FE_DEC_TOWARDZERO: rounddigit = '9'; break; case FE_DEC_UPWARD: rounddigit = (is_neg ? '9' : '0'-1); break; case FE_DEC_DOWNWARD: rounddigit = (is_neg ? '0'-1 : '9'); break; case FE_DEC_TONEARESTFROMZERO: rounddigit = '4'; break; case 5: rounddigit = '4'; break; /* nearest, ties toward zero */ case 6: rounddigit = '0'-1; break; /* away from zero */ case 7: rounddigit = '4'; break; /* round for shorter precision */ default: rounddigit = '4'; break; } } /* If this is true then the requested precision is smaller than the * default and rounding is required. If 'exp' was sufficiently negative * 'index' may be negative, in which case we don't need to round. */ if (index > 0 && index < mw && digits[index] > rounddigit) do { int trailzero = index+1; if (digits[index] == rounddigit+1) { while (trailzero < mw) { if (digits[trailzero] != '0') { trailzero = 0; break; } ++trailzero; } if (roundmode == FE_DEC_TONEAREST && trailzero && (digits[index-1] & 1) == 0) break; if (roundmode == FE_DEC_UPWARD && !trailzero) break; if (roundmode == FE_DEC_DOWNWARD && !trailzero) break; if (roundmode == 5 && trailzero) break; if (roundmode == 6 && trailzero) break; } while (digits[--index] == '9') digits[index] = '0'; digits[index]++; if (index < n) { n--; nd++; } } while (0); } /* Done rounding. */ /* If spec == 'a' at this point it means that prec was set by the user * and rounding had to be considered. The spec now requires that the * 'a' format presentation algorithm be calculated again. If prec * wasn't set by the user then this was handled earlier and spec has already * been set to either 'e' or 'f'. */ if (spec == 'a') { int old_exp = exp; /* The goofy DFP specification requires that we now assume that after * rounding the digits are right justified and truncated and the * algorithm recomputed using the new values for nd and exp, e.g., * * 00654300E-2 with %.1Hf -> 00000007E3. */ exp = nd + exp - prec; nd = prec; /* Per the DFP specification (s,c,q), c == digits, q = exp, s == * is_neg. */ if (exp >= -(nd+5) && exp <= 0) { prec = -exp; spec = 'f'; } else { prec = nd - 1; if (prec < 0) prec = 0; spec = 'e'; input_prec = nd - 1; /* Return exp to the original value because the 'e' case below will * recompute it. */ exp = old_exp; } /* spec will have been changed to 'e' or 'f' at this point, so determine * the decimal point now. */ } /* Calculate decimal point, adjust prec and exp if necessary. * By this point everything should be represented as either %e or %f. */ if (spec == 'f') { if (exp < 0) decpt = exp + nd + n; else if (is_zero) decpt = n + 1; else decpt = n + nd + exp; } else if (spec == 'e') { decpt = n + 1; exp = mw + exp - decpt; } /* Remove trailing zeroes for %g */ if (tolower(info->spec) == 'g' && !info->alt) { while (prec > 0 && decpt+prec > mw) prec--; while (prec > 0 && digits[decpt+prec-1] == '0') prec--; } /* Remove trailing zeroes for %a, but only if they are not significant. */ if (tolower(info->spec) == 'a') { while (prec > 0 && decpt+prec > mw) prec--; while (prec > 0 && decpt+prec > n+nd && digits[decpt+prec-1] == '0') prec--; } /* Digits to the left of the decimal pt. */ if (n < decpt) { width -= decpt - n; if (grouping) width -= (decpt-n)/3; } else width--; /* none to the left of the decimal point */ /* Digits to the right of the decimal pt. */ if (prec > 0) width -= 1 + prec; else if (info->alt) width -= 1; if (spec != 'f') { width -= 3; if (0!=(exp/10) || spec!='a') --width; if (0!=(exp/100)) --width; if (0!=(exp/1000)) --width; } if (is_neg || info->showsign || info->space) width--; if (!info->left && info->pad != '0' && width > 0) PADN (info->pad, width); if (is_neg) outchar ('-'); else if (info->showsign) outchar ('+'); else if (info->space) outchar (' '); if (!info->left && info->pad == '0' && width > 0) PADN ('0', width); /* Print zero, decimal point and leading zeroes if needed */ if (decpt <= n) { n = decpt; outchar ('0'); if (n < 0) { outchar (wide ? decimalwc.wc : *decimal); while (n < 0 && n < decpt + prec) { outchar ('0'); n++; } } } /* Print the digits. If decpt exceeds mw then we know that * they're simply trailing zeros and we don't need to display them. */ while (n < mw && n < decpt + prec) { if (n == decpt) { outchar (wide ? decimalwc.wc : *decimal); } else if (grouping && n < decpt && (decpt-n)%3 == 0) outchar (wide ? thousands_sepwc : *thousands_sep); outchar (digits[n]); n++; } /* print trailing zeroes */ while (n < decpt + prec) { if (n == decpt) outchar (wide ? decimalwc.wc : *decimal); else if (grouping && n < decpt && (decpt-n)%3 == 0) outchar (wide ? thousands_sepwc : *thousands_sep); outchar ('0'); n++; } /* print decimal point, if needed */ if (n == decpt && info->alt) outchar (wide ? decimalwc.wc : *decimal); /* The C spec says that for %e, if the value is zero the exponent is zero. * This isn't true for the DFP spec for %a so make sure to check info->spec * and not spec since it could have promoted 'a' to 'e'. */ if(spec == 'e' && (tolower(info->spec) != 'a' && is_zero)) exp = 0; /* Don't display the exponent part for 'f' because it is never used and don't * do it for 'g' if the value is zero. */ if (spec != 'f' && !((tolower(info->spec) == 'g') && is_zero)) { outchar (isupper(info->spec) ? 'E' : 'e'); if (exp < 0) { outchar ('-'); n = -exp; } else { outchar ('+'); n = exp; } if (n >= 1000) outchar ('0'+((n/1000)%10)); if (n >= 100) outchar ('0'+((n/100)%10)); if (n >= 10 || (tolower(info->spec) != 'a')) outchar ('0'+((n/10)%10)); outchar ('0'+(n%10)); } if (info->left && width > 0) PADN (info->pad, width); } /* Done output block. */ return 0; } strong_alias (__printf_dfp, printf_dfp) hidden_def (__printf_dfp) int __register_printf_dfp (void) { pa_d128 = register_printf_type (d128_va); pa_d32 = register_printf_type (d32_va); pa_d64 = register_printf_type (d64_va); mod_DD = register_printf_modifier (L"DD"); mod_H = register_printf_modifier (L"H"); mod_D = register_printf_modifier (L"D"); register_printf_specifier ('f', printf_dfp, dfp_ais); register_printf_specifier ('F', printf_dfp, dfp_ais); register_printf_specifier ('e', printf_dfp, dfp_ais); register_printf_specifier ('E', printf_dfp, dfp_ais); register_printf_specifier ('g', printf_dfp, dfp_ais); register_printf_specifier ('G', printf_dfp, dfp_ais); register_printf_specifier ('a', printf_dfp, dfp_ais); register_printf_specifier ('A', printf_dfp, dfp_ais); return 0; } strong_alias (__register_printf_dfp, register_printf_dfp) hidden_def (__register_printf_dfp) libdfp-1.0.12/scripts/000077500000000000000000000000001261375163000145265ustar00rootroot00000000000000libdfp-1.0.12/scripts/README000066400000000000000000000000501261375163000154010ustar00rootroot00000000000000These files are an autotools formality. libdfp-1.0.12/scripts/abilist.awk000066400000000000000000000075541261375163000166740ustar00rootroot00000000000000# This awk script processes the output of objdump --dynamic-syms # into a simple format that should not change when the ABI is not changing. BEGIN { if (combine_fullname) combine = 1; if (combine) parse_names = 1; } # Per-file header. /[^ :]+\.so\.[0-9.]+:[ ]+.file format .*$/ { emit(0); seen_opd = 0; sofullname = $1; sub(/:$/, "", sofullname); soname = sofullname; sub(/^.*\//, "", soname); sub(/\.so\.[0-9.]+$/, "", soname); suppress = ((filename_regexp != "" && sofullname !~ filename_regexp) \ || (libname_regexp != "" && soname !~ libname_regexp)); next } suppress { next } # Normalize columns. /^[0-9a-fA-F]+ / { sub(/ /, " - ") } # Skip undefineds. $4 == "*UND*" { next } # Skip locals. $2 == "l" { next } # If the target uses ST_OTHER, it will be output before the symbol name. $2 == "g" || $2 == "w" && (NF == 7 || NF == 8) { weak = $2; type = $3; size = $5; sub(/^0*/, "", size); size = " 0x" size; version = $6; symbol = $NF; gsub(/[()]/, "", version); if (version == "GLIBC_PRIVATE") next; desc = ""; if (type == "D" && $4 == ".tbss") { type = "T"; } else if (type == "D" && $4 == ".opd") { type = "F"; size = ""; if (seen_opd < 0) type = "O"; seen_opd = 1; } else if (type == "D" && NF == 8 && $7 == "0x80") { # Alpha functions avoiding plt entry in users type = "F"; size = ""; seen_opd = -1; } else if ($4 == "*ABS*") { type = "A"; size = ""; } else if (type == "DO") { type = "D"; } else if (type == "DF") { if (symbol ~ /^\./ && seen_opd >= 0) next; seen_opd = -1; type = "F"; size = ""; } else if (type == "iD" && ($4 == ".text" || $4 == ".opd")) { # Indirect functions. type = "F"; size = ""; } else { desc = symbol " " version " " weak " ? " type " " $4 " " $5; } if (size == " 0x") { desc = symbol " " version " " weak " ? " type " " $4 " " $5; } # Disabled -- weakness should not matter to shared library ABIs any more. #if (weak == "w") type = tolower(type); if (desc == "") desc = " " symbol " " type size; if (combine) version = soname " " version (combine_fullname ? " " sofullname : ""); if (version in versions) { versions[version] = versions[version] "\n" desc; } else { versions[version] = desc; } next; } # Header crapola. NF == 0 || /DYNAMIC SYMBOL TABLE/ || /file format/ { next } { print "Don't grok this line:", $0 } function emit(end) { if (!end && (combine || ! parse_names || soname == "")) return; tofile = parse_names && !combine; nverslist = 0; for (version in versions) { if (nverslist == 0) { verslist = version; nverslist = 1; continue; } split(verslist, s, "\n"); if (version < s[1]) { verslist = version; for (i = 1; i <= nverslist; ++i) { verslist = verslist "\n" s[i]; } } else { verslist = s[1]; for (i = 2; i <= nverslist; ++i) { if (version < s[i]) break; verslist = verslist "\n" s[i]; } verslist = verslist "\n" version; for (; i <= nverslist; ++i) { verslist = verslist "\n" s[i]; } } ++nverslist; } if (tofile) { out = prefix soname ".symlist"; if (soname in outfiles) out = out "." ++outfiles[soname]; else outfiles[soname] = 1; printf "" > out; } split(verslist, order, "\n"); for (i = 1; i <= nverslist; ++i) { version = order[i]; if (tofile) { print version >> out; close(out); outpipe = "sort >> " out; } else { if (combine) print ""; print prefix version; outpipe = "sort"; } print versions[version] | outpipe; close(outpipe); delete versions[version]; } for (version in versions) delete versions[version]; if (tofile) print "wrote", out, "for", sofullname; } END { emit(1); } libdfp-1.0.12/scripts/check-localplt.awk000066400000000000000000000022211261375163000201140ustar00rootroot00000000000000# This is an awk script to process the output of elf/check-localplt. # The first file argument is the file of expected results. # Each line is either a comment starting with # or it looks like: # libfoo.so: function # or # libfoo.so: function ? # The latter means that a PLT entry for function is optional in libfoo.so. # The former means one is required. # The second file argument is - and this (stdin) receives the output # of the check-localplt program. BEGIN { result = 0 } FILENAME != "-" && /^#/ { next } FILENAME != "-" { if (NF != 2 && !(NF == 3 && $3 == "?")) { printf "%s:%d: bad data line: %s\n", FILENAME, FNR, $0 > "/dev/stderr"; result = 2; } else { accept[$1 " " $2] = NF == 2; } next; } NF != 2 { print "Unexpected output from check-localplt:", $0 > "/dev/stderr"; result = 2; next } { key = $1 " " $2 if (key in accept) { delete accept[key] } else { print "Extra PLT reference:", $0; if (result == 0) result = 1; } } END { for (key in accept) { if (accept[key]) { # It's mandatory. print "Missing required PLT reference:", key; result = 1; } } exit(result); } libdfp-1.0.12/scripts/compile000077500000000000000000000071501261375163000161070ustar00rootroot00000000000000#! /bin/sh # Wrapper for compilers which do not understand `-c -o'. scriptversion=2005-05-14.22 # Copyright (C) 1999-2015 Free Software Foundation, Inc. # Written by Tom Tromey . # # 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, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . 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 . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; esac ofile= cfile= eat= 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 -e 's|^.*/||' -e '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 mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then 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-end: "$" # End: libdfp-1.0.12/scripts/config.guess000077500000000000000000001262631261375163000170600ustar00rootroot00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, # Inc. timestamp='2006-02-27' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner . # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit build system type. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerppc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm:riscos:*:*|arm:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep __LP64__ >/dev/null then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) case ${UNAME_MACHINE} in pc98) echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:MSYS_NT-*:*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; x86:Interix*:[345]*) echo i586-pc-interix${UNAME_RELEASE} exit ;; EM64T:Interix*:[345]*) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo cris-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo crisv32-axis-linux-gnu exit ;; frv:Linux:*:*) echo frv-unknown-linux-gnu exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips #undef mipsel #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mipsel #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips #else CPU= #endif #endif EOF eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' /^CPU/{ s: ::g p }'`" test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips64 #undef mips64el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mips64el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips64 #else CPU= #endif #endif EOF eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' /^CPU/{ s: ::g p }'`" test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo or32-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; ppcle:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; ppc64le:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. # Set LC_ALL=C to ensure ld outputs messages in English. ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g s/.*supported targets: *// s/ .*// p'` case "$ld_supported_targets" in elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" exit ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. echo "${UNAME_MACHINE}-pc-linux-gnuoldld" exit ;; esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 LIBC=gnu # else LIBC=gnulibc1 # endif # else LIBC=gnulibc1 # endif #else #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__sun) LIBC=gnu #else LIBC=gnuaout #endif #endif #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' /^LIBC/{ s: ::g p }'`" test x"${LIBC}" != x && { echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit } test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: libdfp-1.0.12/scripts/config.sub000077500000000000000000000773351261375163000165300ustar00rootroot00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, # Inc. timestamp='2006-02-27' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray) os= basic_machine=$1 ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | m32r | m32rle | m68000 | m68k | m88k | maxq | mb | microblaze | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64vr | mips64vrel \ | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | mt \ | msp430 \ | nios | nios2 \ | ns16k | ns32k \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc64v2 | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sparcv9v2 \ | strongarm \ | tahoe | thumb | tic4x | tic80 | tron \ | v850 | v850e \ | we32k \ | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ | z8k) basic_machine=$basic_machine-unknown ;; m32c) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64vr-* | mips64vrel-* \ | mips64orion-* | mips64orionel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc64v2-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sparcv9v2-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ | xstormy16-* | xtensa-* \ | ymp-* \ | z8k-*) ;; m32c-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; c90) basic_machine=c90-cray os=-unicos ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16c) basic_machine=cr16c-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tic55x | c55x*) basic_machine=tic55x-unknown os=-coff ;; tic6x | c6x*) basic_machine=tic6x-unknown os=-coff ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sparcv9v2) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: libdfp-1.0.12/scripts/depcomp000077500000000000000000000370551261375163000161150ustar00rootroot00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2005-07-09.11 # Copyright (C) 1999-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 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, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by `PROGRAMS ARGS'. object Object file output by `PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputing dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> $depfile echo >> $depfile # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> $depfile else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` tmpdepfile="$stripped.u" if test "$libtool" = yes; then "$@" -Wc,-M else "$@" -M fi stat=$? if test -f "$tmpdepfile"; then : else stripped=`echo "$stripped" | sed 's,^.*/,,'` tmpdepfile="$stripped.u" fi if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi if test -f "$tmpdepfile"; then outname="$stripped.o" # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; icc) # Intel's C compiler understands `-MD -MF file'. However on # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h # which is wrong. We want: # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using \ : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a # static library. This mecanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # # With libtool 1.5 this exception was removed, and libtool now # generates 2 separate objects for the 2 libraries. These two # compilations output dependencies in in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 tmpdepfile2=$dir$base.o.d # libtool 1.5 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.o.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d tmpdepfile4=$dir$base.d "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test $1 != '--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for `:' # in the target name. This is to cope with DOS-style filenames: # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. "$@" $dashmflag | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test $1 != '--mode=compile'; do shift done shift fi # X makedepend shift cleared=no for arg in "$@"; do case $cleared in no) set ""; shift cleared=yes ;; esac case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix="`echo $object | sed 's/^.*\././'`" touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test $1 != '--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o, # because we must use -o when running libtool. "$@" || exit $? IFS=" " for arg do case "$arg" in "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # 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-end: "$" # End: libdfp-1.0.12/scripts/firstversions.awk000066400000000000000000000051061261375163000201540ustar00rootroot00000000000000# Script to preprocess Versions.all lists based on "earliest version" # specifications in the shlib-versions file. # Return -1, 0 or 1 according to whether v1 is less than, equal to or # greater than v2 as a version string. Simplified from GNU Autoconf # version; this one does not need to handle .0x fraction-style versions. function vers_compare (v1, v2) { while (length(v1) && length(v2)) { if (v1 ~ /^[0-9]/ && v2 ~ /^[0-9]/) { for (len1 = 1; substr(v1, len1 + 1) ~ /^[0-9]/; len1++) continue; for (len2 = 1; substr(v2, len2 + 1) ~ /^[0-9]/; len2++) continue; d1 = substr(v1, 1, len1); v1 = substr(v1, len1 + 1); d2 = substr(v2, 1, len2); v2 = substr(v2, len2 + 1); d1 += 0; d2 += 0; } else { d1 = substr(v1, 1, 1); v1 = substr(v1, 2); d2 = substr(v2, 1, 1); v2 = substr(v2, 2); } if (d1 < d2) return -1; if (d1 > d2) return 1; } if (length(v2)) return -1; if (length(v1)) return 1; return 0; } NF > 2 && $2 == ":" { for (i = 0; i <= NF - 3; ++i) firstversion[$1, i] = $(3 + i); idx[$1] = 0; next; } NF == 2 && $2 == "{" { thislib = $1; print; next } $1 == "}" { if ((thislib, idx[thislib]) in firstversion) { # We haven't seen the stated version, but have produced # others pointing to it, so we synthesize it now. printf " %s\n", firstversion[thislib, idx[thislib]]; idx[thislib]++; } print; next; } /GLIBC_PRIVATE/ { print; next } { if ((thislib, idx[thislib]) in firstversion) { f = v = firstversion[thislib, idx[thislib]]; while (vers_compare($1, v) >= 0) { delete firstversion[thislib, idx[thislib]]; idx[thislib]++; if ((thislib, idx[thislib]) in firstversion) v = firstversion[thislib, idx[thislib]]; else break; } if ($1 == v || $1 == f) # This version was the specified earliest version itself. print; else if (vers_compare($1, v) < 0) { # This version is older than the specified earliest version. print " " $1, "=", v; # Record that V has been referred to, so we will be sure to emit it # if we hit a later one without hitting V itself. usedversion[thislib, v] = 1; } else { # This version is newer than the specified earliest version. # We haven't seen that version itself or else we wouldn't be here # because we would have removed it from the firstversion array. # If there were any earlier versions that used that one, emit it now. if ((thislib, v) in usedversion) { print " " v; } print " " $1; } } else print; } libdfp-1.0.12/scripts/install-sh000077500000000000000000000220211261375163000165270ustar00rootroot00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2005-05-14.22 # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" chmodcmd="$chmodprog 0755" chowncmd= chgrpcmd= stripcmd= rmcmd="$rmprog -f" mvcmd="$mvprog" src= dst= dir_arg= dstarg= no_target_directory= usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: -c (ignored) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. --help display this help and exit. --version display version info and exit. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test -n "$1"; do case $1 in -c) shift continue;; -d) dir_arg=true shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; --help) echo "$usage"; exit $?;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -s) stripcmd=$stripprog shift continue;; -t) dstarg=$2 shift shift continue;; -T) no_target_directory=true shift continue;; --version) echo "$0 $scriptversion"; exit $?;; *) # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. test -n "$dir_arg$dstarg" && break # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dstarg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dstarg" shift # fnord fi shift # arg dstarg=$arg done break;; esac done if test -z "$1"; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi for src do # Protect names starting with `-'. case $src in -*) src=./$src ;; esac if test -n "$dir_arg"; then dst=$src src= if test -d "$dst"; then mkdircmd=: chmodcmd= else mkdircmd=$mkdirprog fi else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dstarg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dstarg # Protect names starting with `-'. case $dst in -*) dst=./$dst ;; esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dstarg: Is a directory" >&2 exit 1 fi dst=$dst/`basename "$src"` fi fi # This sed command emulates the dirname command. dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'` # Make sure that the destination directory exists. # Skip lots of stat calls in the usual case. if test ! -d "$dstdir"; then defaultIFS=' ' IFS="${IFS-$defaultIFS}" oIFS=$IFS # Some sh's can't handle IFS=/ for some reason. IFS='%' set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` shift IFS=$oIFS pathcomp= while test $# -ne 0 ; do pathcomp=$pathcomp$1 shift if test ! -d "$pathcomp"; then $mkdirprog "$pathcomp" # mkdir can fail with a `File exist' error in case several # install-sh are creating the directory concurrently. This # is OK. test -d "$pathcomp" || exit fi pathcomp=$pathcomp/ done fi if test -n "$dir_arg"; then $doit $mkdircmd "$dst" \ && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; } else dstfile=`basename "$dst"` # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 trap '(exit $?); exit' 1 2 13 15 # Copy the file name to the temp name. $doit $cpprog "$src" "$dsttmp" && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && # Now rename the file to the real destination. { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \ || { # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { if test -f "$dstdir/$dstfile"; then $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ || { echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 (exit 1); exit 1 } else : fi } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" } } fi || { (exit 1); exit 1; } done # The final little trick to "correctly" pass the exit status to the exit trap. { (exit 0); exit 0 } # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-end: "$" # End: libdfp-1.0.12/scripts/localplt.awk000066400000000000000000000030051261375163000170420ustar00rootroot00000000000000# This awk script expects to get command-line files that are each # the output of 'readelf -WSdr' on a single shared object, and named # .../NAME.jmprel where NAME is the unadorned file name of the shared object. # It writes "NAME: SYMBOL" for each PLT entry in NAME that refers to a # symbol defined in the same object. BEGIN { result = 0 } FILENAME != lastfile { if (lastfile && jmprel_offset == 0) { print FILENAME ": *** failed to find expected output (readelf -WSdr)"; result = 2; } lastfile = FILENAME; jmprel_offset = 0; delete section_offset_by_address; } /^Section Headers:/ { in_shdrs = 1; next } in_shdrs && !/^ +\[/ { in_shdrs = 0 } in_shdrs && /^ +\[/ { sub(/\[ +/, "[") } in_shdrs { address = strtonum("0x" $4); offset = strtonum("0x" $5); section_offset_by_address[address] = offset; } in_shdrs { next } $1 == "Offset" && $2 == "Info" { in_relocs = 1; next } NF == 0 { in_relocs = 0 } in_relocs && relocs_offset == jmprel_offset && NF >= 5 { symval = strtonum("0x" $4); if (symval != 0) print whatfile, $5 } in_relocs { next } $1 == "Relocation" && $2 == "section" && $5 == "offset" { relocs_offset = strtonum($6); whatfile = gensub(/([^/]+)\.jmprel$/, "\\1:", 1, FILENAME); next } $2 == "(JMPREL)" { jmprel_addr = strtonum($3); if (jmprel_addr in section_offset_by_address) { jmprel_offset = section_offset_by_address[jmprel_addr]; } else { print FILENAME ": *** DT_JMPREL does not match any section's address"; result = 2; } next } END { exit(result) } libdfp-1.0.12/scripts/missing000077500000000000000000000253351261375163000161350ustar00rootroot00000000000000#! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2005-06-08.21 # Copyright (C) 1996-2015 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # 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, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi msg="missing on your system" case "$1" in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 # Exit code 63 means version mismatch. This often happens # when the user try to use an ancient version of a tool on # a file that requires a minimum version. In this case we # we should proceed has if the program had been absent, or # if --run hadn't been passed. if test $? = 63; then run=: msg="probably too old" fi ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch] Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). case "$1" in lex|yacc) # Not GNU programs, they don't have --version. ;; tar) if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then exit 1 fi ;; *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then # Could not run --version or --help. This is probably someone # running `$TOOL --version' or `$TOOL --help' to check whether # $TOOL exists and not knowing $TOOL uses missing. exit 1 fi ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case "$1" in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case "$f" in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison|yacc) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.h fi ;; esac fi if [ ! -f y.tab.h ]; then echo >y.tab.h fi if [ ! -f y.tab.c ]; then echo 'main() { return 0; }' >y.tab.c fi ;; lex|flex) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if [ ! -f lex.yy.c ]; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` fi if [ -f "$file" ]; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit 1 fi ;; makeinfo) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi # If the file does not exist, the user really needs makeinfo; # let's fail without touching anything. test -f $file || exit 1 touch $file ;; tar) shift # We have already tried tar in the generic part. # Look for gnutar/gtar before invocation to avoid ugly error # messages. if (gnutar --version > /dev/null 2>&1); then gnutar "$@" && exit 0 fi if (gtar --version > /dev/null 2>&1); then gtar "$@" && exit 0 fi firstarg="$1" if shift; then case "$firstarg" in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac case "$firstarg" in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 ;; esac fi echo 1>&2 "\ WARNING: I can't seem to be able to run \`tar' with the given arguments. You may want to install GNU tar or Free paxutils, or check the command line arguments." exit 1 ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-end: "$" # End: libdfp-1.0.12/scripts/move-if-change000077500000000000000000000003451261375163000172430ustar00rootroot00000000000000#!/bin/sh # Like mv $1 $2, but if the files are the same, just delete $1. # Status is 0 if $2 is changed, 1 otherwise. if test -r $2 then if cmp -s $1 $2 then echo $2 is unchanged rm -f $1 else mv -f $1 $2 fi else mv -f $1 $2 fi libdfp-1.0.12/scripts/update-copyrights000077500000000000000000000050161261375163000201310ustar00rootroot00000000000000#! /bin/sh # Update copyright year lists. # Copyright (C) 2012-2015 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # The GNU C Library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # You should have received a copy of the GNU Lesser General Public # License along with the GNU C Library; if not, see # . # Run this script with the first argument being the location of # gnulib's update-copyright script. Any other arguments are ignored. # FSF copyright notices in the glibc source directory containing this # script will be updated; glibc must then be built to update generated # files. Copyright dates in --version copyright notices are not # updated. set -e export LC_ALL=C export UPDATE_COPYRIGHT_FORCE=1 export UPDATE_COPYRIGHT_USE_INTERVALS=2 export UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79 update_script=$1 if ! [ -f "$update_script" ]; then echo "error: first argument must point to gnulib update-copyright script" >&2 exit 1 fi cd "$(dirname "$0")/.." files=$(find . -type f | sed 's|^\./||' | grep -v '^\.git/') for f in $files; do case $f in COPYING | COPYING.LIB | manual/fdl-1.3.texi | manual/lgpl-2.1.texi) # Licenses imported verbatim from FSF sources. ;; manual/texinfo.tex | scripts/config.guess | scripts/config.sub \ | scripts/install-sh | scripts/mkinstalldirs | scripts/move-if-change) # Other files imported verbatim from other GNU repositories. ;; po/*.po) # Files imported verbatim from the Translation Project. ;; INSTALL | */Implies | */Versions | */*.input | */*.abilist) # Generated files. ;; configure | */configure | preconfigure | */preconfigure) # Possibly generated files. if ! [ -f "$f.ac" ]; then "$update_script" "$f" fi ;; grp/initgroups.c | misc/bits/stab.def | posix/regex.h \ | sysdeps/wordsize-32/divdi3.c) # Pre-1991 gaps in copyright years, so cannot use a single range. UPDATE_COPYRIGHT_USE_INTERVALS=1 "$update_script" "$f" ;; *) "$update_script" "$f" ;; esac done libdfp-1.0.12/scripts/versions.awk000066400000000000000000000064471261375163000171150ustar00rootroot00000000000000# Combine version map fragments into version scripts for our shared objects. # Copyright (C) 1998-2015 Free Software Foundation, Inc. # Written by Ulrich Drepper , 1998. # This script expects the following variables to be defined: # defsfile name of Versions.def file # buildroot name of build directory with trailing slash # move_if_change move-if-change command # Read definitions for the versions. BEGIN { lossage = 0; nlibs=0; while (getline < defsfile) { if (/^[a-zA-Z0-9_.]+ \{/) { libs[$1] = 1; curlib = $1; while (getline < defsfile && ! /^}/) { if ($2 == "=") { renamed[curlib "::" $1] = $3; } else versions[curlib "::" $1] = 1; } } } close(defsfile); tmpfile = buildroot "Versions.tmp"; # POSIX sort needed. sort = "sort -t. -k 1,1 -k 2n,2n -k 3 > " tmpfile; } # Remove comment lines. /^ *#/ { next; } # This matches the beginning of the version information for a new library. /^[a-zA-Z0-9_.]+/ { actlib = $1; if (!libs[$1]) { printf("no versions defined for %s\n", $1) > "/dev/stderr"; ++lossage; } next; } # This matches the beginning of a new version for the current library. /^ [A-Za-z_]/ { if (renamed[actlib "::" $1]) actver = renamed[actlib "::" $1]; else if (!versions[actlib "::" $1] && $1 != "GLIBC_PRIVATE") { printf("version %s not defined for %s\n", $1, actlib) > "/dev/stderr"; ++lossage; } else actver = $1; next; } # This matches lines with names to be added to the current version in the # current library. This is the only place where we print something to # the intermediate file. /^ / { sortver=actver # Ensure GLIBC_ versions come always first sub(/^GLIBC_/," GLIBC_",sortver) printf("%s %s %s\n", actlib, sortver, $0) | sort; } function closeversion(name, oldname) { if (firstinfile) { printf(" local:\n *;\n") > outfile; firstinfile = 0; } # This version inherits from the last one only if they # have the same nonnumeric prefix, i.e. GLIBC_x.y and GLIBC_x.z # or FOO_x and FOO_y but not GLIBC_x and FOO_y. pfx = oldname; sub(/[0-9.]+/,".+",pfx); if (oldname == "" || name !~ pfx) print "};" > outfile; else printf("} %s;\n", oldname) > outfile; } function close_and_move(name, real_name) { close(name); system(move_if_change " " name " " real_name " >&2"); } # Now print the accumulated information. END { close(sort); if (lossage) { system("rm -f " tmpfile); exit 1; } oldlib = ""; oldver = ""; printf("version-maps ="); while (getline < tmpfile) { if ($1 != oldlib) { if (oldlib != "") { closeversion(oldver, veryoldver); oldver = ""; close_and_move(outfile, real_outfile); } oldlib = $1; real_outfile = buildroot oldlib ".map"; outfile = real_outfile "T"; firstinfile = 1; veryoldver = ""; printf(" %s.map", oldlib); } if ($2 != oldver) { if (oldver != "") { closeversion(oldver, veryoldver); veryoldver = oldver; } printf("%s {\n global:\n", $2) > outfile; oldver = $2; } printf(" ") > outfile; for (n = 3; n <= NF; ++n) { printf(" %s", $n) > outfile; } printf("\n") > outfile; } printf("\n"); closeversion(oldver, veryoldver); close_and_move(outfile, real_outfile); #system("rm -f " tmpfile); } libdfp-1.0.12/strtod128.c000066400000000000000000000026331261375163000147610ustar00rootroot00000000000000/* Convert string representing a number to Decimal Float value, using given locale. Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef FLOAT #define FLOAT _Decimal128 #define FLOAT_HUGE_VAL DEC_INFINITY #define FLT DEC128 #define FLOAT_SIZE 128 #define FLOAT_ZERO 0.DL #define SET_MANTISSA(x,y) #define PRINTF_SPEC "%DDf" #define __DEC_MANT_DIG__ __DEC128_MANT_DIG__ #define __DEC_MAX_EXP__ __DEC128_MAX_EXP__ #define __DEC_MIN_EXP__ __DEC128_MIN_EXP__ #endif #include "strtod32.c" libdfp-1.0.12/strtod32.c000066400000000000000000000655611261375163000147040ustar00rootroot00000000000000/* Convert string representing a number to Decimal Float value, using given locale. Copyright (C) 1997-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian Pete Eberlein Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ /* Adapted primarily from stdlib/strtod_l.c by Ulrich Drepper */ /* * TODO: SET_MANTISSA macro for preserving NaN info (or parse as mantissa) * TODO: Check that hexadecimal input is done properly... particularly hex * exponants */ #define _GNU_SOURCE #include //#include /* wchar.h has to be included BEFORE stdio.h or it loses function * definitions when dfp/wchar.h uses #include_next . */ #include #include /* Pick up the strtod* prototypes. */ #include #include /* For newlocale prototype. */ #include /* For nl_langinfo prototype. */ #include /* isspace_l et. al. */ #include /* strncasecmp_l */ #include /* wcstod* internal interfaces */ #include /* strtod* internal interfaces. */ //#include #include /* HUGE_VAL_D32, etc. */ #include #define __set_errno(the_errno) *__errno_location() = the_errno //#include #include /* For CHAR_MAX */ #include #ifndef FLOAT # define FLOAT _Decimal32 # define FLOAT_HUGE_VAL HUGE_VAL_D32 # define FLOAT_SIZE 32 # define FLT DEC32 # define FLOAT_ZERO 0.DF # define SET_MANTISSA(x,y) # define PRINTF_SPEC "%Hf" # define __DEC_MANT_DIG__ __DEC32_MANT_DIG__ # define __DEC_MAX_EXP__ __DEC32_MAX_EXP__ # define __DEC_MIN_EXP__ __DEC32_MIN_EXP__ #endif #define DEC_TYPE FLOAT #define _DECIMAL_SIZE FLOAT_SIZE #include #ifdef USE_WIDE_CHAR extern unsigned long long int ____wcstoull_l_internal (const wchar_t *, wchar_t **, int, int, __locale_t); # include # define STRTO_PREFIX wcsto # define STRING_TYPE wchar_t # define CHAR_TYPE wint_t # define L_(Ch) L##Ch # define ISSPACE(Ch) iswspace_l ((Ch), loc) # define ISDIGIT(Ch) iswdigit_l ((Ch), loc) # define ISXDIGIT(Ch) iswxdigit_l ((Ch), loc) # define TOLOWER(Ch) towlower_l ((Ch), loc) //# define TOLOWER_C(Ch) towlower_l ((Ch), nl_C_locobj_ptr) # define TOLOWER_C(Ch) towlower_l ((Ch), C_locale) # define STRNCASECMP(S1, S2, N) \ wcsncasecmp_l ((S1), (S2), (N), C_locale) //__wcsncasecmp_l ((S1), (S2), (N), C_locale) // __wcsncasecmp_l ((S1), (S2), (N), _nl_C_locobj_ptr) //# define STRTOULL(S, E, B) ____wcstoull_l_internal ((S), (E), (B), 0, loc) # define STRTOULL(S, E, B) wcstoull_l ((S), (E), (B), loc) #else # define STRTO_PREFIX strto # define STRING_TYPE char # define CHAR_TYPE char # define L_(Ch) Ch # define ISSPACE(Ch) isspace_l ((Ch), loc) # define ISDIGIT(Ch) isdigit_l ((Ch), loc) # define ISXDIGIT(Ch) isxdigit_l ((Ch), loc) # define TOLOWER(Ch) tolower_l ((Ch), loc) # define TOLOWER_C(Ch) tolower_l ((Ch), C_locale) //# define TOLOWER_C(Ch) tolower_l ((Ch), _nl_C_locobj_ptr) # define STRNCASECMP(S1, S2, N) \ strncasecmp_l ((S1), (S2), (N), C_locale) //__strncasecmp_l ((S1), (S2), (N), C_locale) // __strncasecmp_l ((S1), (S2), (N), _nl_C_locobj_ptr) //# define STRTOULL(S, E, B) ____strtoull_l_internal ((S), (E), (B), 0, loc) # define STRTOULL(S, E, B) strtoull_l ((S), (E), (B), loc) #endif /* Constants we need from float.h; select the set for the FLOAT precision. */ #define MANT_DIG PASTE(PASTE(__,FLT),_MANT_DIG__) #define DIG PASTE(PASTE(__,FLT),_DIG__) //#define MAX_EXP PASTE(FLT,_MAX_EXP) //#define MIN_EXP PASTE(FLT,_MIN_EXP) #define MAX_10_EXP PASTE(PASTE(__,FLT),_MAX_EXP__) #define MIN_10_EXP PASTE(PASTE(__,FLT),_MIN_EXP__) #define FUNCTION_NAME PASTE(PASTE(STRTO_PREFIX,d),FLOAT_SIZE) #define __FUNCTION_NAME PASTE(__,FUNCTION_NAME) #define FUNCTION_INTERNAL PASTE(__FUNCTION_NAME,_internal) #define FUNCTION_L_INTERNAL PASTE(__FUNCTION_NAME,_l_internal) /* Extra macros required to get FLT expanded before the pasting. */ #ifndef PASTE # define PASTE(a,b) PASTE1(a,b) # define PASTE1(a,b) a##b #endif #ifndef FUNC_D # define FUNC_D(x) PASTE(x,PASTE(d,_DECIMAL_SIZE)) #endif #define RETURN(val,end) \ do { if (endptr != NULL) *endptr = (STRING_TYPE *) (end); \ return val; } while (0) #define NDEBUG 1 #include /* From glibc's stdlib/grouping.c */ #ifndef MAX #define MAX(a,b) ({ typeof(a) _a = (a); typeof(b) _b = (b); \ _a > _b ? _a : _b; }) #endif /* Find the maximum prefix of the string between BEGIN and END which satisfies the grouping rules. It is assumed that at least one digit follows BEGIN directly. */ static const STRING_TYPE * #ifdef USE_WIDE_CHAR __correctly_grouped_prefixwc (const STRING_TYPE *begin, const STRING_TYPE *end, wchar_t thousands, #else __correctly_grouped_prefixmb (const STRING_TYPE *begin, const STRING_TYPE *end, const char *thousands, #endif const char *grouping) { #ifndef USE_WIDE_CHAR size_t thousands_len; int cnt; #endif if (grouping == NULL) return end; #ifndef USE_WIDE_CHAR thousands_len = strlen (thousands); #endif while (end > begin) { const STRING_TYPE *cp = end - 1; const char *gp = grouping; /* Check first group. */ while (cp >= begin) { #ifdef USE_WIDE_CHAR if (*cp == thousands) break; #else if (cp[thousands_len - 1] == *thousands) { for (cnt = 1; thousands[cnt] != '\0'; ++cnt) if (thousands[cnt] != cp[thousands_len - 1 - cnt]) break; if (thousands[cnt] == '\0') break; } #endif --cp; } /* We allow the representation to contain no grouping at all even if the locale specifies we can have grouping. */ if (cp < begin) return end; if (end - cp == (int) *gp + 1) { /* This group matches the specification. */ const STRING_TYPE *new_end; if (cp < begin) /* There is just one complete group. We are done. */ return end; /* CP points to a thousands separator character. The preceding remainder of the string from BEGIN to NEW_END is the part we will consider if there is a grouping error in this trailing portion from CP to END. */ new_end = cp - 1; /* Loop while the grouping is correct. */ while (1) { /* Get the next grouping rule. */ ++gp; if (*gp == 0) /* If end is reached use last rule. */ --gp; /* Skip the thousands separator. */ --cp; if (*gp == CHAR_MAX #if CHAR_MIN < 0 || *gp < 0 #endif ) { /* No more thousands separators are allowed to follow. */ while (cp >= begin) { #ifdef USE_WIDE_CHAR if (*cp == thousands) break; #else for (cnt = 0; thousands[cnt] != '\0'; ++cnt) if (thousands[cnt] != cp[thousands_len - cnt - 1]) break; if (thousands[cnt] == '\0') break; #endif --cp; } if (cp < begin) /* OK, only digits followed. */ return end; } else { /* Check the next group. */ const STRING_TYPE *group_end = cp; while (cp >= begin) { #ifdef USE_WIDE_CHAR if (*cp == thousands) break; #else for (cnt = 0; thousands[cnt] != '\0'; ++cnt) if (thousands[cnt] != cp[thousands_len - cnt - 1]) break; if (thousands[cnt] == '\0') break; #endif --cp; } if (cp < begin && group_end - cp <= (int) *gp) /* Final group is correct. */ return end; if (cp < begin || group_end - cp != (int) *gp) /* Incorrect group. Punt. */ break; } } /* The trailing portion of the string starting at NEW_END contains a grouping error. So we will look for a correctly grouped number in the preceding portion instead. */ end = new_end; } else { /* Even the first group was wrong; determine maximum shift. */ if (end - cp > (int) *gp + 1) end = cp + (int) *gp + 1; else if (cp < begin) /* This number does not fill the first group, but is correct. */ return end; else /* CP points to a thousands separator character. */ end = cp; } } return MAX (begin, end); } /* This is of the form __strtod32_l_internal() */ FLOAT FUNCTION_L_INTERNAL (const STRING_TYPE * nptr, STRING_TYPE ** endptr, int group, locale_t loc) { FLOAT d32 = FLOAT_ZERO; int negative; /* The sign of the number. */ int exponent; /* Exponent of the number. */ /* Numbers starting `0X' or `0x' have to be processed with base 16. */ int base = 10; /* Running pointer after the last character processed in the string. */ const STRING_TYPE *cp, *tp; /* Start of significant part of the number. */ const STRING_TYPE *startp, *start_of_digits; /* Points at the character following the integer and fractional digits. */ const STRING_TYPE *expp; /* Total number of digit and number of digits in integer part. */ int dig_no, int_no, lead_zero; /* Contains the last character read. */ CHAR_TYPE c; __locale_t C_locale; /* We should get wint_t from , but not all GCC versions define it there. So define it ourselves if it remains undefined. */ #ifndef _WINT_T typedef unsigned int wint_t; #endif /* The radix character of the current locale. */ #ifdef USE_WIDE_CHAR const char *decimalmb; wchar_t decimal; #else const char *decimal; size_t decimal_len; #endif /* The thousands character of the current locale. */ #ifdef USE_WIDE_CHAR const char *thousandsmb = NULL; wchar_t thousands = L'\0'; #else const char *thousands = NULL; /* Used in several places. */ int cnt; #endif /* The numeric grouping specification of the current locale, in the format described in . */ const char *grouping; C_locale = newlocale(LC_ALL_MASK, setlocale (LC_ALL, NULL),NULL); if (group) { //grouping = _NL_CURRENT (LC_NUMERIC, GROUPING); grouping = nl_langinfo (__GROUPING); if (*grouping <= 0 || *grouping == CHAR_MAX) grouping = NULL; else { /* Figure out the thousands separator character. */ #ifdef USE_WIDE_CHAR thousandsmb = nl_langinfo(_NL_NUMERIC_THOUSANDS_SEP_WC); mbrtowc(&thousands,thousandsmb, CHAR_MAX, NULL); if (thousands == L'\0') grouping = NULL; #else thousands = nl_langinfo (__THOUSANDS_SEP); if (*thousands == '\0') { thousands = NULL; grouping = NULL; } #endif } } else grouping = NULL; /* Find the locale's decimal point character. */ #ifdef USE_WIDE_CHAR decimalmb = nl_langinfo(_NL_NUMERIC_DECIMAL_POINT_WC); mbrtowc(&decimal,decimalmb, CHAR_MAX, NULL); assert (decimal != L'\0'); # define decimal_len 1 #else // decimal = _NL_CURRENT (LC_NUMERIC, DECIMAL_POINT); decimal = nl_langinfo(__DECIMAL_POINT); decimal_len = strlen (decimal); assert (decimal_len > 0); #endif /* Prepare number representation. */ exponent = 0; negative = 0; /* Parse string to get maximal legal prefix. We need the number of characters of the integer part, the fractional part and the exponent. */ cp = nptr - 1; /* Ignore leading white space. */ do c = *++cp; /* c is last character read, cp is last character processed. */ while (ISSPACE (c)); /* Get sign of the result. */ if (c == L_('-')) { negative = 1; c = *++cp; } else if (c == L_('+')) c = *++cp; /* Return 0.0 if no legal string is found. No character is used even if a sign was found. */ #ifdef USE_WIDE_CHAR if (c == (wint_t) decimal && (wint_t) cp[1] >= L'0' && (wint_t) cp[1] <= L'9') { /* We accept it. This funny construct is here only to indent the code directly. */ } #else for (cnt = 0; decimal[cnt] != '\0'; ++cnt) if (cp[cnt] != decimal[cnt]) break; if (decimal[cnt] == '\0' && cp[cnt] >= '0' && cp[cnt] <= '9') { /* We accept it. This funny construct is here only to indent the code directly. */ } #endif else if (c < L_('0') || c > L_('9')) { /* Check for `INF' or `INFINITY'. */ if (TOLOWER_C (c) == L_('i') && STRNCASECMP (cp, L_("inf"), 3) == 0) { /* Return +/- infinity. */ if (endptr != NULL) *endptr = (STRING_TYPE *) (cp + (STRNCASECMP (cp + 3, L_("inity"), 5) == 0 ? 8 : 3)); freelocale(C_locale); return negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL; } if (TOLOWER_C (c) == L_('n') && STRNCASECMP (cp, L_("nan"), 3) == 0) { /* Return NaN. */ FLOAT retval = DEC_NAN; cp += 3; /* Match `(n-char-sequence-digit)'. */ if (*cp == L_('(')) { startp = cp; do ++cp; while ((*cp >= L_('0') && *cp <= L_('9')) || (TOLOWER (*cp) >= L_('a') && TOLOWER (*cp) <= L_('z')) || *cp == L_('_')); if (*cp != L_(')')) /* The closing brace is missing. Only match the NAN part. */ cp = startp; #if 0 else { /* This is a system-dependent way to specify the bitmask used for the NaN. We expect it to be a number which is put in the mantissa of the number. */ STRING_TYPE *endp; unsigned long long int mant; mant = STRTOULL (startp + 1, &endp, 0); if (endp == cp) { SET_MANTISSA (retval, mant); } } #endif } if (endptr != NULL) *endptr = (STRING_TYPE *) cp; freelocale(C_locale); return retval; } /* It is really a text we do not recognize. */ RETURN (0.0, nptr); } /* First look whether we are faced with a hexadecimal number. */ if (c == L_('0') && TOLOWER (cp[1]) == L_('x')) { /* Okay, it is a hexa-decimal number. Remember this and skip the characters. BTW: hexadecimal numbers must not be grouped. */ base = 16; cp += 2; c = *cp; grouping = NULL; } /* Record the start of the digits, in case we will check their grouping. */ start_of_digits = startp = cp; /* Ignore leading zeroes. This helps us to avoid useless computations. */ #ifdef USE_WIDE_CHAR while (c == L'0' || ((wint_t) thousands != L'\0' && c == (wint_t) thousands)) c = *++cp; #else if (thousands == NULL) while (c == '0') c = *++cp; else { /* We also have the multibyte thousands string. */ while (1) { if (c != '0') { for (cnt = 0; thousands[cnt] != '\0'; ++cnt) if (c != thousands[cnt]) break; if (thousands[cnt] != '\0') break; } c = *++cp; } } #endif /* If no other digit but a '0' is found the result is 0.0. Return current read pointer. */ if ((c < L_('0') || c > L_('9')) && (base == 16 && (c < (CHAR_TYPE) TOLOWER (L_('a')) || c > (CHAR_TYPE) TOLOWER (L_('f')))) #ifdef USE_WIDE_CHAR && c != (wint_t) decimal #else && ({ for (cnt = 0; decimal[cnt] != '\0'; ++cnt) if (decimal[cnt] != cp[cnt]) break; decimal[cnt] != '\0'; }) #endif && (base == 16 && (cp == start_of_digits || (CHAR_TYPE) TOLOWER (c) != L_('p'))) && (base != 16 && (CHAR_TYPE) TOLOWER (c) != L_('e'))) { #ifdef USE_WIDE_CHAR tp = __correctly_grouped_prefixwc (start_of_digits, cp, thousands, grouping); #else tp = __correctly_grouped_prefixmb (start_of_digits, cp, thousands, grouping); #endif /* If TP is at the start of the digits, there was no correctly grouped prefix of the string; so no number found. */ RETURN (negative ? -FLOAT_ZERO : FLOAT_ZERO, tp == start_of_digits ? (base == 16 ? cp - 1 : nptr) : tp); } /* Remember first significant digit and read following characters until the decimal point, exponent character or any non-FP number character. */ startp = cp; dig_no = 0; while (1) { if ((c >= L_('0') && c <= L_('9')) || (base == 16 && (wint_t) TOLOWER (c) >= L_('a') && (wint_t) TOLOWER (c) <= L_('f'))) ++dig_no; else { #ifdef USE_WIDE_CHAR if ((wint_t) thousands == L'\0' || c != (wint_t) thousands) /* Not a digit or separator: end of the integer part. */ break; #else if (thousands == NULL) break; else { for (cnt = 0; thousands[cnt] != '\0'; ++cnt) if (thousands[cnt] != cp[cnt]) break; if (thousands[cnt] != '\0') break; } #endif } c = *++cp; } if (grouping && dig_no > 0) { /* Check the grouping of the digits. */ #ifdef USE_WIDE_CHAR tp = __correctly_grouped_prefixwc (start_of_digits, cp, thousands, grouping); #else tp = __correctly_grouped_prefixmb (start_of_digits, cp, thousands, grouping); #endif if (cp != tp) { /* Less than the entire string was correctly grouped. */ if (tp == start_of_digits) /* No valid group of numbers at all: no valid number. */ RETURN (FLOAT_ZERO, nptr); if (tp < startp) /* The number is validly grouped, but consists only of zeroes. The whole value is zero. */ RETURN (negative ? -FLOAT_ZERO : FLOAT_ZERO, tp); /* Recompute DIG_NO so we won't read more digits than are properly grouped. */ cp = tp; dig_no = 0; for (tp = startp; tp < cp; ++tp) if (*tp >= L_('0') && *tp <= L_('9')) ++dig_no; int_no = dig_no; lead_zero = 0; goto number_parsed; } } /* We have the number digits in the integer part. Whether these are all or any is really a fractional digit will be decided later. */ int_no = dig_no; lead_zero = int_no == 0 ? -1 : 0; /* FIXME: Why was this -1 */ /* Read the fractional digits. A special case are the 'american style' numbers like `16.' i.e. with decimal but without trailing digits. */ if ( #ifdef USE_WIDE_CHAR c == (wint_t) decimal #else ({ for (cnt = 0; decimal[cnt] != '\0'; ++cnt) if (decimal[cnt] != cp[cnt]) break; decimal[cnt] == '\0'; }) #endif ) { cp += decimal_len; c = *cp; while ((c >= L_('0') && c <= L_('9')) || (base == 16 && TOLOWER (c) >= L_('a') && TOLOWER (c) <= L_('f'))) { if (c != L_('0') && lead_zero == -1) lead_zero = dig_no - int_no; ++dig_no; c = *++cp; } } /* Remember start of exponent (if any). */ expp = cp; /* Read exponent. */ if ((base == 16 && TOLOWER (c) == L_('p')) || (base != 16 && TOLOWER (c) == L_('e'))) { int exp_negative = 0; c = *++cp; if (c == L_('-')) { exp_negative = 1; c = *++cp; } else if (c == L_('+')) c = *++cp; if (c >= L_('0') && c <= L_('9')) { int exp_limit; /* Get the exponent limit. */ #if 0 if (base == 16) exp_limit = (exp_negative ? -MIN_EXP + MANT_DIG + 4 * int_no : MAX_EXP - 4 * int_no + lead_zero); else #endif exp_limit = (exp_negative ? -MIN_10_EXP + MANT_DIG + int_no : MAX_10_EXP - int_no + lead_zero); do { exponent *= 10; if (exponent > exp_limit) /* The exponent is too large/small to represent a valid number. */ { FLOAT result; /* We have to take care for special situation: a joker might have written "0.0e100000" which is in fact zero. */ if (lead_zero == -1) result = negative ? -FLOAT_ZERO : FLOAT_ZERO; else { /* Overflow or underflow. */ __set_errno (ERANGE); result = (exp_negative ? FLOAT_ZERO : negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL); } /* Accept all following digits as part of the exponent. */ do ++cp; while (*cp >= L_('0') && *cp <= L_('9')); RETURN (result, cp); /* NOTREACHED */ } exponent += c - L_('0'); c = *++cp; } while (c >= L_('0') && c <= L_('9')); if (exp_negative) exponent = -exponent; } else cp = expp; } /* We don't want to have to work with trailing zeroes after the radix. */ #if 0 /* Actually, for DFP, we do. */ if (dig_no > int_no) { while (expp[-1] == L_('0')) { --expp; /*--exponent;*/ /* FIXME: This can't be here */ --dig_no; } assert (dig_no >= int_no); } if (dig_no == int_no && dig_no > 0 && exponent < 0) do { while (! (base == 16 ? ISXDIGIT (expp[-1]) : ISDIGIT (expp[-1]))) --expp; if (expp[-1] != L_('0')) break; --expp; --dig_no; --int_no; ++exponent; } while (dig_no > 0 && exponent < 0); #endif number_parsed: /* The whole string is parsed. Store the address of the next character. */ if (endptr) *endptr = (STRING_TYPE *) cp; if (dig_no == 0) { if (exponent == 0) { freelocale(C_locale); return negative ? -FLOAT_ZERO : FLOAT_ZERO; } #if NUMDIGITS_SUPPORT==0 d32 += 1; while(exponent-- > 0) /* FIXME: this doesn't work right for exponent>0 */ d32 *= 10; while(++exponent < 0) d32 /= 10; d32 -= d32; #else d32 = FUNC_D(setexp) (d32, exponent); #endif freelocale(C_locale); return negative ? -d32 : d32; } if (lead_zero) { /* Find the decimal point */ #ifdef USE_WIDE_CHAR while (*startp != decimal) ++startp; #else while (1) { if (*startp == decimal[0]) { for (cnt = 1; decimal[cnt] != '\0'; ++cnt) if (decimal[cnt] != startp[cnt]) break; if (decimal[cnt] == '\0') break; } ++startp; } #endif lead_zero = (lead_zero < 0? 0 : lead_zero); startp += lead_zero + decimal_len; exponent -= base == 16 ? 4 * lead_zero : lead_zero; dig_no -= lead_zero; } /* Now we have the number of digits in total and the integer digits as well as the exponent and its sign. We can decide whether the read digits are really integer digits or belong to the fractional part; i.e. we normalize 123e-2 to 1.23. */ { register int incr = (exponent < 0 ? MAX (-int_no, exponent) : MIN (dig_no - int_no, exponent)); int_no += incr; exponent -= incr; } if (int_no + exponent > MAX_10_EXP) { __set_errno (ERANGE); freelocale(C_locale); return negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL; } /* Obvious underflow before normalization. */ if (exponent < MIN_10_EXP - MANT_DIG + 1 ) { __set_errno (ERANGE); freelocale(C_locale); return FLOAT_ZERO; } /* Read in the integer portion of the input string */ if (int_no > 0) { /* Read the integer part as a d32. */ int digcnt = int_no; while (int_no > MAX_10_EXP + 1) { digcnt--; exponent++; } do { /* There might be thousands separators or radix characters in the string. But these all can be ignored because we know the format of the number is correct and we have an exact number of characters to read. */ #ifdef USE_WIDE_CHAR if (*startp < L_('0') || *startp > L_('9')) if (base==10 || (*startp < L_('a') || *startp > L_('h'))) ++startp; #else if (*startp < L_('0') || *startp > L_('9')) if (base==10 || (*startp < L_('a') || *startp > L_('h'))) { int inner = 0; if (thousands != NULL && *startp == *thousands && ({ for (inner = 1; thousands[inner] != '\0'; ++inner) if (thousands[inner] != startp[inner]) break; thousands[inner] == '\0'; })) startp += inner; else startp += decimal_len; } #endif if(base == 10) d32 = d32 * base + (*startp - L_('0')); else d32 = d32 * base + (*startp >= L_('0') && *startp <= L_('9') ? -L_('0') : 10-L_('a')) + *startp; ++startp; } while (--digcnt > 0); } /* If we haven't filled our datatype, read in the fractional digits */ if (int_no <= MANT_DIG && dig_no > int_no) { /* Read the decimal part as a FLOAT. */ int digcnt = dig_no - int_no; /* There might be radix characters in the string. But these all can be ignored because we know the format of the number is correct and we have an exact number of characters to read. */ /*do { if(base == 10) frac = frac/10 + *(startp+digcnt-1) - L_('0'); else frac = frac/10 + (*(startp+digcnt-1) >= L_('0') && *(startp+digcnt-1) <= L_('9') ? -L_('0') : 10-L_('a')) + *(startp+digcnt-1); } while (--digcnt > 0); frac /= 10; d32 += frac;*/ int_no = 0; do { #ifdef USE_WIDE_CHAR if (*startp < L_('0') || *startp > L_('9')) ++startp; #else if (*startp < '0' || *startp > '9') startp += decimal_len; #endif /* We need the extra digit to get proper rounding. */ if (int_no < MANT_DIG + 1) { if(base == 10) d32 = d32*10 + (*startp - L_('0')); else d32 = d32*10 + (*startp >= L_('0') && *startp <= L_('9') ? -L_('0') : 10-L_('a')) + *startp; ++startp; --exponent; int_no++; } } while (--digcnt > 0); } #if NUMDIGITS_SUPPORT==0 while(exponent-- > 0) d32 *= 10; while(++exponent < 0) d32 /= 10; #else /* Computed underflow after normalization. */ if ( exponent < (__DEC_MIN_EXP__ - __DEC_MANT_DIG__)) { __set_errno (ERANGE); freelocale(C_locale); return FLOAT_ZERO; } /* Left justification allows us to set a positive exponent that's near * __DEC*_MAX_EXP__, i.e. _almost_ overflowing. Complete left justification * may be overkill for most numbers in this situation, so perhaps a specific * digit shift will be a better solution in the future. */ if (exponent > (__DEC_MAX_EXP__ - __DEC_MANT_DIG__)) d32 = FUNC_D(left_justify) (d32); d32 = FUNC_D(setexp) (d32, FUNC_D (getexp) (d32) + exponent); #endif return negative? -d32:d32; } hidden_def(FUNCTION_L_INTERNAL) /* This is of the form __strtod32_internal() */ FLOAT FUNCTION_INTERNAL (const STRING_TYPE *nptr, STRING_TYPE **endptr, int group) { char * curlocale; __locale_t cur_locale_t; FLOAT ret_val; curlocale = setlocale(LC_ALL,NULL); cur_locale_t = newlocale(LC_ALL_MASK, curlocale, NULL); ret_val = FUNCTION_L_INTERNAL (nptr,endptr,group,cur_locale_t); freelocale(cur_locale_t); return ret_val; } hidden_def(FUNCTION_INTERNAL) /* This is of the form strtod32() */ FLOAT #ifdef weak_function weak_function #endif FUNCTION_NAME (const STRING_TYPE *nptr, STRING_TYPE **endptr) { char * curlocale; __locale_t cur_locale_t; FLOAT ret_val; curlocale = setlocale(LC_ALL,NULL); cur_locale_t = newlocale(LC_ALL_MASK, curlocale, NULL); ret_val = FUNCTION_L_INTERNAL(nptr, endptr, 0, cur_locale_t); freelocale(cur_locale_t); return ret_val; } libdfp-1.0.12/strtod64.c000066400000000000000000000026241261375163000147000ustar00rootroot00000000000000/* Convert string representing a number to Decimal Float value, using given locale. Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef FLOAT #define FLOAT _Decimal64 #define FLOAT_HUGE_VAL DEC_INFINITY #define FLT DEC64 #define FLOAT_SIZE 64 #define FLOAT_ZERO 0.DD #define SET_MANTISSA(x,y) #define PRINTF_SPEC "%Df" #define __DEC_MANT_DIG__ __DEC64_MANT_DIG__ #define __DEC_MAX_EXP__ __DEC64_MAX_EXP__ #define __DEC_MIN_EXP__ __DEC64_MIN_EXP__ #endif #include "strtod32.c" libdfp-1.0.12/sysdeps/000077500000000000000000000000001261375163000145315ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/bid/000077500000000000000000000000001261375163000152675ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/bid/Makefile000066400000000000000000000016521261375163000167330ustar00rootroot00000000000000# Copyright (C) 2015 Free Software Foundation, Inc. # # This file is part of the Decimal Floating Point C Library. # # The Decimal Floating Point C Library is free software; you can # redistribute it and/or modify it under the terms of the GNU Lesser # General Public License version 2.1. # # The Decimal Floating Point C Library is distributed in the hope that # it will be useful, but WITHOUT ANY WARRANTY; without even the implied # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See # the GNU Lesser General Public License version 2.1 for more details. # # You should have received a copy of the GNU Lesser General Public # License version 2.1 along with the Decimal Floating Point C Library; # if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA. # # Please see libdfp/COPYING.txt for more information. */ libdfp_files += bid-private binpowof10 decpowof2 libdfp-1.0.12/sysdeps/bid/Versions000066400000000000000000000023451261375163000170260ustar00rootroot00000000000000# These are added in this sysdeps/bid/Versions file because the # C source files don't indicate "__bid" in the filename and they # live in the common base-math/ directory. libdfp { LIBDFP_1.0.0 { __bid_addsd3; __bid_adddd3; __bid_addtd3; __bid_subsd3; __bid_subdd3; __bid_subtd3; __bid_mulsd3; __bid_muldd3; __bid_multd3; __bid_divsd3; __bid_divdd3; __bid_divtd3; __bid_extendsddd2; __bid_extendsdtd2; __bid_extendddtd2; __bid_trunctdsd2; __bid_truncddsd2; __bid_trunctddd2; __bid_unordsd2; __bid_unorddd2; __bid_unordtd2; __bid_eqsd2; __bid_eqdd2; __bid_eqtd2; __bid_nesd2; __bid_nedd2; __bid_netd2; __bid_gesd2; __bid_gedd2; __bid_getd2; __bid_gtsd2; __bid_gtdd2; __bid_gttd2; __bid_ltsd2; __bid_ltdd2; __bid_lttd2; __bid_lesd2; __bid_ledd2; __bid_letd2; __bid_fixsdsi; __bid_fixddsi; __bid_fixtdsi; __bid_fixsddi; __bid_fixdddi; __bid_fixtddi; __bid_fixunssdsi; __bid_fixunsddsi; __bid_fixunstdsi; __bid_fixunssddi; __bid_fixunsdddi; __bid_fixunstddi; __bid_floatsisd; __bid_floatsidd; __bid_floatsitd; __bid_floatdisd; __bid_floatdidd; __bid_floatditd; __bid_floatunssisd; __bid_floatunssidd; __bid_floatunssitd; __bid_floatunsdisd; __bid_floatunsdidd; __bid_floatunsditd; } } libdfp-1.0.12/sysdeps/bid/bid-private.c000066400000000000000000000140731261375163000176460ustar00rootroot00000000000000/* Data types for BID format output. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #include #include #include "bid-private.h" #include "get_digits.h" const struct ieee754r_c_field c_decoder[32] = { {0, 0, 0, 0}, {0, 0, 0, 1}, {0, 0, 0, 2}, {0, 0, 0, 3}, /* 00000-00011 */ {0, 0, 0, 4}, {0, 0, 0, 5}, {0, 0, 0, 6}, {0, 0, 0, 7}, /* 00100-00111 */ {0, 0, 1, 0}, {0, 0, 1, 1}, {0, 0, 1, 2}, {0, 0, 1, 3}, /* 01000-01011 */ {0, 0, 1, 4}, {0, 0, 1, 5}, {0, 0, 1, 6}, {0, 0, 1, 7}, /* 01100-01111 */ {0, 0, 2, 0}, {0, 0, 2, 1}, {0, 0, 2, 2}, {0, 0, 2, 3}, /* 10000-10011 */ {0, 0, 2, 4}, {0, 0, 2, 5}, {0, 0, 2, 5}, {0, 0, 2, 7}, /* 10100-10111 */ {0, 0, 0, 8}, {0, 0, 0, 9}, {0, 0, 1, 8}, {0, 0, 1, 9}, /* 11000-11011 */ {0, 0, 2, 8}, {0, 0, 2, 9}, {0, 1, 0, 0}, {1, 0, 0, 0} /* 11100-11111 */ }; /* Return the sign, exponent and coefficient from a _Decimal32 encoded in BID format. The encoding is defined as (−1)^s × 10^(E−Bp) × c sign_p exp_p str */ void __get_digits_d32 (_Decimal32 x, char *str, int *exp_p, int *sign_p, int *nan_p, int *inf_p) { unsigned int result; int i, size, exp = 0; struct ieee754r_c_field c_f; union ieee754r_Decimal32 d; d.sd = x; c_f = c_decoder[d.nan.nan]; if (c_f.is_nan) { exp = 0; result = 1; } else if (d.divided.c != 3) { exp = (d.si >> 23) & 0xFF; // 8 bits. result = d.si & 0x7FFFFFUl; // 23 bits. } else { exp = (d.si >> 21) & 0xFF; result = 4 << 21; result |= d.si & 0x1FFFFFUL; // 21 bits. } if (result >= DECIMAL32_TH) result = 0; exp -= DECIMAL32_Bias; sprintf (str, "%u", result); size = (7 - strlen (str)); for (i = 0; i < size; i++) str[i] = '0'; sprintf (str + i, "%u", result); str[7] = '\0'; if (sign_p) *sign_p = d.divided.negative; if (exp_p) *exp_p = exp; if (nan_p) *nan_p = c_f.is_nan; if (inf_p) *inf_p = c_f.is_inf; } /* Return the sign, exponent and coefficient from a _Decimal64 encoded in BID format. The encoding is defined as (−1)^s × 10^(E−Bp) × c sign_p exp_p str */ void __get_digits_d64 (_Decimal64 x, char *str, int *exp_p, int *sign_p, int *nan_p, int *inf_p) { unsigned long long int result; int i, size, exp = 0; struct ieee754r_c_field c_f; union ieee754r_Decimal64 d; d.dd = x; c_f = c_decoder[d.nan.nan]; if (c_f.is_nan) { exp = 0; result = 1; } else if (d.divided.c != 3) { exp = (d.di[1] >> 21) & 0x3FF; // 10 bits. result = d.di[1] & 0x1FFFFF; // 21 bits. result = result << 32; result |= d.di[0] & 0xFFFFFFFFUL; // 32 bits. } else { exp = (d.di[1] >> 19) & 1023; result = 4 << 19; result |= d.di[1] & 0x7FFFF; // 19 bits. result = result << 32; result |= d.di[0] & 0xFFFFFFFFUL; } if (result >= DECIMAL64_TH) result = 0; exp -= DECIMAL64_Bias; sprintf (str, "%llu", result); size = (16 - strlen (str)); for (i = 0; i < size; i++) str[i] = '0'; sprintf (str + i, "%llu", result); str[16] = '\0'; if (sign_p) *sign_p = d.divided.negative; if (exp_p) *exp_p = exp; if (nan_p) *nan_p = c_f.is_nan; if (inf_p) *inf_p = c_f.is_inf; } void __get_digits_d128 (_Decimal128 x, char *str, int *exp_p, int *sign_p, int *nan_p, int *inf_p) { int i, j, exp = 0; unsigned int digits[NDIGITS_128] = { 0 }; struct ieee754r_c_field c_f; union ieee754r_Decimal128 d; unsigned long long int result[2]; d.td = x; c_f = c_decoder[d.nan.nan]; if (c_f.is_nan) { exp = 0; result[1] = 0; result[0] = 1; } else if (d.divided.c != 3) { exp = (d.ti[3] >> 17) & 0x3FFF; // 14 bits. result[1] = d.ti[3] & 0x1FFFF; // 17 bits. result[1] = result[1] << 32; result[1] |= d.ti[2] & 0xFFFFFFFFUL; // 32 bits. result[0] = d.ti[1] & 0xFFFFFFFFUL; result[0] = result[0] << 32; result[0] |= d.ti[0] & 0xFFFFFFFFUL; } else { exp = (d.ti[3] >> 15) & 0x3FFF; result[1] = 4 << 15; result[1] |= d.ti[3] & 0x7FFF; // 15 bits. result[1] = result[1] << 32; result[1] |= d.ti[2] & 0xFFFFFFFFUL; result[0] = d.ti[1] & 0xFFFFFFFFUL; result[0] = result[0] << 32; result[0] |= d.ti[0] & 0xFFFFFFFFUL; } if (result[1] >= DECIMAL128_TH) { result[0] = 0; result[1] = 0; } exp -= DECIMAL128_Bias; // High for (i = 63; i >= 0; i--) { digits[0] += (result[1] >> i) & 1; // 1 bit. for (j = 0; j < 35; j++) digits[j] *= 2; // Double the digits. for (j = 0; j < 34; j++) { // Handle the carry. digits[j + 1] += digits[j] / 10; digits[j] %= 10; } } // Low for (i = 63; i >= 0; i--) { digits[0] += (result[0] >> i) & 1; if (i > 0) { for (j = 0; j < 35; j++) digits[j] *= 2; } for (j = 0; j < 34; j++) { digits[j + 1] += digits[j] / 10; digits[j] %= 10; } } j = 0; for (i = 33; i >= 0; i--) { sprintf (str + j, "%u", digits[i]); j++; } str[34] = '\0'; if (sign_p) *sign_p = d.divided.negative; if (exp_p) *exp_p = exp; if (nan_p) *nan_p = c_f.is_nan; if (inf_p) *inf_p = c_f.is_inf; } libdfp-1.0.12/sysdeps/bid/bid-private.h000066400000000000000000000100711261375163000176450ustar00rootroot00000000000000/* Data types for BID format output. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #ifndef _BID_PRIVATE_H #define _BID_PRIVATE_H 1 #include struct ieee754r_c_field { unsigned int is_nan:1; unsigned int is_inf:1; unsigned int lm_exp:2; unsigned int lmd:4; }; union ieee754r_Decimal32 { _Decimal32 sd; unsigned int si; struct { #if __BYTE_ORDER == __BIG_ENDIAN unsigned int negative:1; unsigned int c:2; unsigned int els:29; #endif /* Big endian. */ #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int els:29; unsigned int c:2; unsigned int negative:1; #endif /* Little endian. */ } divided; /* This format makes it easier to see if is a NaN. */ struct { #if __BYTE_ORDER == __BIG_ENDIAN unsigned int negative:1; unsigned int nan:5; unsigned int els:26; #endif /* Big endian. */ #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int els:26; unsigned int nan:5; unsigned int negative:1; #endif /* Little endian. */ } nan; }; #define DECIMAL32_Bias 101 /* bias for the exponent */ #define DECIMAL32_TH 10000000 /* threshold */ union ieee754r_Decimal64 { _Decimal64 dd; unsigned int di[2]; struct { #if __BYTE_ORDER == __BIG_ENDIAN unsigned int negative:1; unsigned int c:2; unsigned int else1:29; unsigned int else2:32; #endif /* Big endian. */ #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int else2:32; unsigned int else1:29; unsigned int c:2; unsigned int negative:1; #endif /* Little endian. */ } divided; /* This format makes it easier to see if is a NaN. */ struct { #if __BYTE_ORDER == __BIG_ENDIAN unsigned int negative:1; unsigned int nan:5; unsigned int else1:26; unsigned int else2:32; #endif /* Big endian. */ #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int else2:32; unsigned int else1:26; unsigned int nan:5; unsigned int negative:1; #endif /* Little endian. */ } nan; }; #define DECIMAL64_Bias 398 /* bias for the exponent */ #define DECIMAL64_TH 10000000000000000 /* threshold */ union ieee754r_Decimal128 { _Decimal128 td; unsigned int ti[4]; struct { #if __BYTE_ORDER == __BIG_ENDIAN unsigned int negative:1; unsigned int c:2; unsigned int else1:29; unsigned int else2:32; unsigned int else3:32; unsigned int else4:32; #endif /* Big endian. */ #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int else4:32; unsigned int else3:32; unsigned int else2:32; unsigned int else1:29; unsigned int c:2; unsigned int negative:1; #endif /* Little endian. */ } divided; /* This format makes it easier to see if is a NaN. */ struct { #if __BYTE_ORDER == __BIG_ENDIAN unsigned int negative:1; unsigned int nan:5; unsigned int else1:26; unsigned int else2:32; unsigned int else3:32; unsigned int else4:32; #endif /* Big endian. */ #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int else4:32; unsigned int else3:32; unsigned int else2:32; unsigned int else1:26; unsigned int nan:5; unsigned int negative:1; #endif /* Little endian. */ } nan; }; #define DECIMAL128_Bias 6176 /* bias for the exponent */ #define DECIMAL128_TH 1000000000000000 /* threshold (10³⁴ = 10¹⁵ x 10¹⁹) */ #endif /* _BID_PRIVATE */ libdfp-1.0.12/sysdeps/bid/bid-uint128.h000066400000000000000000000151441261375163000174130ustar00rootroot00000000000000/* Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _BID_UINT128_H # define _BID_UINT128_H /* GCC/clang supports 128 types bytes for some architectures (x86_64 for instance). For archs/configurations that does not support it, a multiprecision implementation based on the mini GMP is used. */ #include #include #ifdef HAVE_UINT128_T typedef __uint128_t u128_t; typedef __uint128_t *u128_ptr; static inline u128_t __u128_from_string (char* sz) { int radix = 10; int size; int i; char ch; unsigned int n; u128_t a; int minus = 0; size = strlen (sz); a = 0; i = 0; if (sz[i] == '-') { ++i; minus = 1; } while (i < size) { ch = sz[i]; if (ch >= 'A' && ch <= 'Z') { if (((ch - 'A') + 10) < radix) n = (ch - 'A') + 10; else break; } else if (ch >= 'a' && ch <= 'z') { if (((ch - 'a') + 10) < radix) n = (ch - 'a') + 10; else break; } else if (ch >= '0' && ch <= '9') { if ((ch - '0') < radix) n = (ch - '0'); else break; } else /* Completely invalid character */ break; a *= radix; a += n; ++i; } if (minus) a = -a; return a; } #define u128_init(__x) #define u128_init_from_u32(__ret, __hi, __mh, __ml, __lo) \ ({ \ __ret = ((__uint128_t)__hi << 96) | \ ((__uint128_t)__mh << 64) | \ ((__uint128_t)__ml << 32) | \ (__uint128_t)__lo; \ }) #define u128_init_from_str(__x,__str) ({ __x = __u128_from_string (__str); }) #define u128_set_u32(__x, __i) ((__x) = (__i)) #define u128_to_u32(__x, __i) ({ (__i) = (__x); }) #define u128_hi(__x) (__x >> 96) #define u128_mh(__x) ((__x >> 64) & 0xFFFFFFFFU) #define u128_ml(__x) ((__x >> 32) & 0xFFFFFFFFU) #define u128_lo(__x) ((__x) & 0xFFFFFFFFU) #define u128_hi64(__x) (__x >> 64) #define u128_lo64(__x) ((__x) & 0xFFFFFFFFFFFFFFFFULL) #define u128_ne_u32(__x, __y) ( __x != __y) #define u128_add_u128(__x, __y, __z) ({ __z = __x + __y; }) #define u128_add_u32(__x, __y, __z) ({ __z = __x + __y; }) #define u128_mul_u32(__x, __y, __z) ({ __z = __x * __y; }) #define u128_mod_u32(__x, __y, __z) ({ __z = __x % __y; }) #define u128_div_u32(__x, __y, __z) ({ __z = __x / __y; }) #else /* Multiprecision int 128 bits based on int 32 limbs. */ #include typedef mpz_t u128_t; typedef mpz_ptr u128_ptr; /* Initialize a multiprecision int 128 bits number from 4 int 32 bits member. Since the MPN implementation does not support bitwise operations we operate on the internal structure directly. */ static inline void u128_init_from_u32 (u128_t ret, uint32_t hi, uint32_t mh, uint32_t ml, uint32_t lo) { mpz_init2 (ret, 128); /* mpn_z::_mp_size is total number of mpz_z::_mp_d being used to represent the number (for instance, if mpz_z::_mp_size of 2 the number can be represented in a 64-bits variable. */ ret->_mp_size = 4; ret->_mp_d[3] = hi; if (hi == 0) ret->_mp_size--; ret->_mp_d[2] = mh; if (mh == 0) ret->_mp_size--; ret->_mp_d[1] = ml; if (ml == 0) ret->_mp_size--; ret->_mp_d[0] = lo; if (lo == 0) ret->_mp_size--; } static inline uint32_t __u128_extract_u32 (mpz_t x, int word) { return (x->_mp_size >= (word + 1)) ? x->_mp_d[word] : 0UL; } static inline uint64_t __u128_extract_64(mpz_t x, int word) { uint64_t ret; ret = __u128_extract_u32(x, 2*word+1); ret <<= 32; ret |= __u128_extract_u32(x, 2*word); return ret; } #define u128_init(__x) mpz_init2 (__x, 128) //#define u128_init_from_str(__x,__str) mpz_init_set_str (__x, __str, 10) #define u128_set_u32(__x, __i) mpz_set_ui (__x, __i) #define u128_to_u32(__x, __i) ({ __i = mpz_get_ui (__x); }) #define u128_hi(__x) __u128_extract_u32 (__x, 3) #define u128_mh(__x) __u128_extract_u32 (__x, 2) #define u128_ml(__x) __u128_extract_u32 (__x, 1) #define u128_lo(__x) __u128_extract_u32 (__x, 0) #define u128_hi64(__x) __u128_extract_u64 (__x, 1) #define u128_lo64(__x) __u128_extract_u64 (__x, 0) #define u128_ne_u32(__x, __y) (mpz_cmp_ui (__x, __y) != 0) #define u128_add_u128(__x, __y, __z) ({ mpz_add (__z, __x, __y); }) #define u128_add_u32(__x, __y, __z) ({ mpz_add_ui (__z, __x, __y); }) #define u128_mul_u32(__x, __y, __z) ({ mpz_mul_ui (__z, __x, __y); }) #define u128_mod_u32(__x, __y, __z) ({ mpz_mod_ui (__z, __x, __y); }) #define u128_div_u32(__x, __y, __z) ({ mpz_fdiv_q_ui (__z, __x, __y); }) static inline void __u128_from_string (mpz_t a, char* sz) { int radix = 10; int size; int i; char ch; unsigned int n; int minus = 0; size = strlen (sz); mpz_init2 (a, 128); mpz_set_ui (a, 0); i = 0; if (sz[i] == '-') { ++i; minus = 1; } while (i < size) { ch = sz[i]; if (ch >= 'A' && ch <= 'Z') { if (((ch - 'A') + 10) < radix) n = (ch - 'A') + 10; else break; } else if (ch >= 'a' && ch <= 'z') { if (((ch - 'a') + 10) < radix) n = (ch - 'a') + 10; else break; } else if (ch >= '0' && ch <= '9') { if ((ch - '0') < radix) n = (ch - '0'); else break; } else /* Completely invalid character */ break; /* a *= radix; */ mpz_mul_ui (a, a, radix); /* a += n; */ mpz_add_ui (a, a, n); ++i; } if (minus) mpz_neg (a, a); } #define u128_init_from_str(__x,__str) __u128_from_string (__x, __str) #endif /* HAVE_UINT128_T */ #endif libdfp-1.0.12/sysdeps/bid/decode.c000066400000000000000000000101111261375163000166500ustar00rootroot00000000000000/* Functions to print the BID declets for use with printf %Z Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #include #include #include #include /* This version is used by all BID implementations. */ #define BID_SIGN_MASK 0x80000000UL /* BID_SPEC_MASK is the mask for _Decimal32 to be used with uint32_t and since we only work with uint32_t it works for all decoded. */ #define BID_SPEC_MASK DEC32_INF_MASK char * __decoded32 (_Decimal32 a, char *str) { union ieee754r_Decimal32 d = { .sd = a }; int exp = -DECIMAL32_Bias; char sign; unsigned int coeff; unsigned int decunits[3] = { 0 }; int n; sign = (d.si & BID_SIGN_MASK ? '-' : '+'); if ((d.si & BID_SPEC_MASK) != BID_SPEC_MASK) { if ((d.si & BID_EXPONENT_ENC_MASK) == BID_EXPONENT_ENC_MASK) coeff = 0x00800000 | (d.si & 0x001FFFFF); else coeff = d.si & 0x007FFFFF; for (n = 0; (coeff != 0) && (n < 3); ++n) { decunits[n] = coeff % 1000; coeff /= 1000; } exp = getexpd32 (a); } sprintf (str, "%c%01u,%03u,%03uE%+d", sign, decunits[2], decunits[1], decunits[0], exp); return str; } weak_alias (__decoded32, decoded32) hidden_def (__decoded32) char * __decoded64 (_Decimal64 a, char *str) { union ieee754r_Decimal64 d = { .dd = a }; int exp = -DECIMAL64_Bias; char sign; unsigned long long int coeff; unsigned int decunits[6] = { 0 }; int n; sign = (d.di[1] & BID_SIGN_MASK ? '-' : '+'); if ((d.di[1] & BID_SPEC_MASK) != BID_SPEC_MASK) { if ((d.di[1] & BID_EXPONENT_ENC_MASK) == BID_EXPONENT_ENC_MASK) coeff = 0x00200000 | (d.di[1] & 0x0007FFFF); else coeff = d.di[1] & 0x001FFFFF; coeff = (coeff << 32) | d.di[0]; for (n = 0; (coeff != 0) && (n < 6); ++n) { decunits[n] = coeff % 1000; coeff /= 1000; } exp = getexpd64 (a); } sprintf (str, "%c%01u,%03u,%03u,%03u,%03u,%03uE%+d", sign, decunits[5], decunits[4], decunits[3], decunits[2], decunits[1], decunits[0], exp); return str; } weak_alias (__decoded64, decoded64) hidden_def (__decoded64) char * __decoded128 (_Decimal128 a, char *str) { union ieee754r_Decimal128 d = { .td = a }; int exp = -DECIMAL128_Bias; char sign; u128_t coeff; unsigned int decunits[12] = { 0 }; unsigned int hi; int n; sign = (d.ti[3] & BID_SIGN_MASK ? '-' : '+'); if ((d.ti[3] & BID_SPEC_MASK) != BID_SPEC_MASK) { if ((d.ti[3] & BID_EXPONENT_ENC_MASK) == BID_EXPONENT_ENC_MASK) hi = 0x00020000UL | (d.ti[3] & 0x00007FFFUL); else hi = d.ti[3] & 0x0001FFFFUL; u128_init_from_u32 (coeff, hi, d.ti[2], d.ti[1], d.ti[0]); for (n = 0; u128_ne_u32 (coeff, 0) && (n < 12); ++n) { u128_t tmp; u128_init (tmp); u128_mod_u32 (coeff, 1000, tmp); u128_to_u32 (tmp, decunits[n]); u128_div_u32 (coeff, 1000, coeff); } exp = getexpd128 (a); } sprintf (str, "%c%01u,%03u,%03u,%03u,%03u,%03u,%03u,%03u,%03u,%03u,%03u,%03uE%+d", sign, decunits[11], decunits[10], decunits[9], decunits[8], decunits[7], decunits[6], decunits[5], decunits[4], decunits[3], decunits[2], decunits[1], decunits[0], exp); return str; } weak_alias (__decoded128, decoded128) hidden_def (__decoded128) libdfp-1.0.12/sysdeps/bid/libdfp.abilist000066400000000000000000000123371261375163000201060ustar00rootroot00000000000000LIBDFP_1.0.0 LIBDFP_1.0.0 A __bid_adddd3 F __bid_addsd3 F __bid_addtd3 F __bid_divdd3 F __bid_divsd3 F __bid_divtd3 F __bid_eqdd2 F __bid_eqsd2 F __bid_eqtd2 F __bid_extendddtd2 F __bid_extendddtf F __bid_extenddfdd F __bid_extenddftd F __bid_extendsddd2 F __bid_extendsddf F __bid_extendsdtd2 F __bid_extendsdtf F __bid_extendsfdd F __bid_extendsfsd F __bid_extendsftd F __bid_extendtftd F __bid_fixdddi F __bid_fixddsi F __bid_fixsddi F __bid_fixsdsi F __bid_fixtddi F __bid_fixtdsi F __bid_fixunsdddi F __bid_fixunsddsi F __bid_fixunssddi F __bid_fixunssdsi F __bid_fixunstddi F __bid_fixunstdsi F __bid_floatdidd F __bid_floatdisd F __bid_floatditd F __bid_floatsidd F __bid_floatsisd F __bid_floatsitd F __bid_floatunsdidd F __bid_floatunsdisd F __bid_floatunsditd F __bid_floatunssidd F __bid_floatunssisd F __bid_floatunssitd F __bid_gedd2 F __bid_gesd2 F __bid_getd2 F __bid_gtdd2 F __bid_gtsd2 F __bid_gttd2 F __bid_ledd2 F __bid_lesd2 F __bid_letd2 F __bid_ltdd2 F __bid_ltsd2 F __bid_lttd2 F __bid_muldd3 F __bid_mulsd3 F __bid_multd3 F __bid_nedd2 F __bid_nesd2 F __bid_netd2 F __bid_subdd3 F __bid_subsd3 F __bid_subtd3 F __bid_truncdddf F __bid_truncddsd2 F __bid_truncddsf F __bid_truncdfsd F __bid_truncsdsf F __bid_trunctddd2 F __bid_trunctddf F __bid_trunctdsd2 F __bid_trunctdsf F __bid_trunctdtf F __bid_trunctfdd F __bid_trunctfsd F __bid_unorddd2 F __bid_unordsd2 F __bid_unordtd2 F acosd128 F acosd32 F acosd64 F acoshd128 F acoshd32 F acoshd64 F asind128 F asind32 F asind64 F asinhd128 F asinhd32 F asinhd64 F atan2d128 F atan2d32 F atan2d64 F atand128 F atand32 F atand64 F atanhd128 F atanhd32 F atanhd64 F cbrtd128 F cbrtd32 F cbrtd64 F ceild128 F ceild32 F ceild64 F copysignd128 F copysignd32 F copysignd64 F cosd128 F cosd32 F cosd64 F coshd128 F coshd32 F coshd64 F decoded128 F decoded32 F decoded64 F erfcd128 F erfcd32 F erfcd64 F erfd128 F erfd32 F erfd64 F exp2d128 F exp2d32 F exp2d64 F expd128 F expd32 F expd64 F expm1d128 F expm1d32 F expm1d64 F fabsd128 F fabsd32 F fabsd64 F fdimd128 F fdimd32 F fdimd64 F fe_dec_getround F fe_dec_setround F finited128 F finited32 F finited64 F floord128 F floord32 F floord64 F fmad128 F fmad32 F fmad64 F fmaxd128 F fmaxd32 F fmaxd64 F fmind128 F fmind32 F fmind64 F fmodd128 F fmodd32 F fmodd64 F fpclassifyd128 F fpclassifyd32 F fpclassifyd64 F frexpd128 F frexpd32 F frexpd64 F hypotd128 F hypotd32 F hypotd64 F ilogbd128 F ilogbd32 F ilogbd64 F isgreaterd128 F isgreaterd32 F isgreaterd64 F isgreaterequald128 F isgreaterequald32 F isgreaterequald64 F isinfd128 F isinfd32 F isinfd64 F islessd128 F islessd32 F islessd64 F islessequald128 F islessequald32 F islessequald64 F islessgreaterd128 F islessgreaterd32 F islessgreaterd64 F isnand128 F isnand32 F isnand64 F isnormald128 F isnormald32 F isnormald64 F isunorderedd128 F isunorderedd32 F isunorderedd64 F ldexpd128 F ldexpd32 F ldexpd64 F lgammad128 F lgammad32 F lgammad64 F llrintd128 F llrintd32 F llrintd64 F llroundd128 F llroundd32 F llroundd64 F log10d128 F log10d32 F log10d64 F log1pd128 F log1pd32 F log1pd64 F log2d128 F log2d32 F log2d64 F logbd128 F logbd32 F logbd64 F logd128 F logd32 F logd64 F lrintd128 F lrintd32 F lrintd64 F lroundd128 F lroundd32 F lroundd64 F modfd128 F modfd32 F modfd64 F nand128 F nand32 F nand64 F nearbyintd128 F nearbyintd32 F nearbyintd64 F nextafterd128 F nextafterd32 F nextafterd64 F nexttowardd128 F nexttowardd32 F nexttowardd64 F powd128 F powd32 F powd64 F printf_dfp F quantized128 F quantized32 F quantized64 F register_printf_dfp F remainderd128 F remainderd32 F remainderd64 F rintd128 F rintd32 F rintd64 F roundd128 F roundd32 F roundd64 F samequantumd128 F samequantumd32 F samequantumd64 F scalblnd128 F scalblnd32 F scalblnd64 F scalbnd128 F scalbnd32 F scalbnd64 F signbitd128 F signbitd32 F signbitd64 F sind128 F sind32 F sind64 F sinhd128 F sinhd32 F sinhd64 F sqrtd128 F sqrtd32 F sqrtd64 F strtod128 F strtod32 F strtod64 F tand128 F tand32 F tand64 F tanhd128 F tanhd32 F tanhd64 F tgammad128 F tgammad32 F tgammad64 F truncd128 F truncd32 F truncd64 F wcstod128 F wcstod32 F wcstod64 F LIBDFP_1.0.2 LIBDFP_1.0.2 A __isinfd128 F __isinfd32 F __isinfd64 F __isnand128 F __isnand32 F __isnand64 F LIBDFP_1.0.3 LIBDFP_1.0.3 A __fabsd128 F __fabsd32 F __fabsd64 F __finited128 F __finited32 F __finited64 F __fpclassifyd128 F __fpclassifyd32 F __fpclassifyd64 F __isfinited128 F __isfinited32 F __isfinited64 F __signbitd128 F __signbitd32 F __signbitd64 F isfinited128 F isfinited32 F isfinited64 F LIBDFP_1.0.9 LIBDFP_1.0.9 A __issignalingd128 F __issignalingd32 F __issignalingd64 F issignalingd128 F issignalingd32 F issignalingd64 F llogbd128 F llogbd32 F llogbd64 F llquantexpd128 F llquantexpd32 F llquantexpd64 F quantumd128 F quantumd32 F quantumd64 F roundevend128 F roundevend32 F roundevend64 F LIBDFP_PRIVATE LIBDFP_PRIVATE A __decoded128 F __decoded32 F __decoded64 F __decrm_location F __fe_dec_getround F __fe_dec_setround F __fmt_d128 F __fmt_d32 F __fmt_d64 F libdfp-1.0.12/sysdeps/bid/symbol-hacks.h000066400000000000000000000065371261375163000200470ustar00rootroot00000000000000/* Hacks for symbol bindings. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #if !defined __ASSEMBLER__ && !defined NOT_IN_libdfp && defined SHARED /* GCC generates intrisics calls to some functions for _Decimal to/from convertions. These bindings avoids intra library PLT calls generations, since libdfp provides such symbols. */ asm ("__bid_floatsidd = __GI___bid_floatsidd"); asm ("__bid_floatditd = __GI___bid_floatditd"); asm ("__bid_floatsitd = __GI___bid_floatsitd"); asm ("__bid_floatdidd = __GI___bid_floatdidd"); asm ("__bid_floatsisd = __GI___bid_floatsisd"); asm ("__bid_truncdddf = __GI___bid_truncdddf"); asm ("__bid_trunctddf = __GI___bid_trunctddf"); asm ("__bid_trunctddd2 = __GI___bid_trunctddd2"); asm ("__bid_truncddsd2 = __GI___bid_truncddsd2"); asm ("__bid_truncdfsd = __GI___bid_truncdfsd"); asm ("__bid_trunctdsd2 = __GI___bid_trunctdsd2"); asm ("__bid_extendsddf = __GI___bid_extendsddf"); asm ("__bid_extenddftd = __GI___bid_extenddftd"); asm ("__bid_extenddfdd = __GI___bid_extenddfdd"); asm ("__bid_extendsdtd2 = __GI___bid_extendsdtd2"); asm ("__bid_extendddtd2 = __GI___bid_extendddtd2"); asm ("__bid_fixsdsi = __GI___bid_fixsdsi"); asm ("__bid_fixdddi = __GI___bid_fixdddi"); asm ("__bid_fixddsi = __GI___bid_fixddsi"); asm ("__bid_fixsddi = __GI___bid_fixsddi"); asm ("__bid_fixtddi = __GI___bid_fixtddi"); asm ("__bid_fixtdsi = __GI___bid_fixtdsi"); asm ("__bid_addsd3 = __GI___bid_addsd3"); asm ("__bid_addtd3 = __GI___bid_addtd3"); asm ("__bid_adddd3 = __GI___bid_adddd3"); asm ("__bid_subdd3 = __GI___bid_subdd3"); asm ("__bid_subsd3 = __GI___bid_subsd3"); asm ("__bid_subtd3 = __GI___bid_subtd3"); asm ("__bid_divsd3 = __GI___bid_divsd3"); asm ("__bid_divtd3 = __GI___bid_divtd3"); asm ("__bid_divdd3 = __GI___bid_divdd3"); asm ("__bid_gtdd2 = __GI___bid_gtdd2"); asm ("__bid_gtds2 = __GI___bid_gtsd2"); asm ("__bid_gtdt2 = __GI___bid_gttd2"); asm ("__bid_mulsd3 = __GI___bid_mulsd3"); asm ("__bid_multd3 = __GI___bid_multd3"); asm ("__bid_muldd3 = __GI___bid_muldd3"); asm ("__bid_gtsd2 = __GI___bid_gtsd2"); asm ("__bid_gttd2 = __GI___bid_gttd2"); asm ("__bid_ltdd2 = __GI___bid_ltdd2"); asm ("__bid_ltsd2 = __GI___bid_ltsd2"); asm ("__bid_lttd2 = __GI___bid_lttd2"); asm ("__bid_eqdd2 = __GI___bid_eqdd2"); asm ("__bid_eqsd2 = __GI___bid_eqsd2"); asm ("__bid_eqtd2 = __GI___bid_eqtd2"); asm ("__bid_nedd2 = __GI___bid_nedd2"); asm ("__bid_nesd2 = __GI___bid_nesd2"); asm ("__bid_netd2 = __GI___bid_netd2"); asm ("__bid_letd2 = __GI___bid_letd2"); asm ("__bid_getd2 = __GI___bid_getd2"); #endif libdfp-1.0.12/sysdeps/dpd/000077500000000000000000000000001261375163000153005ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/dpd/Makefile000066400000000000000000000000611261375163000167350ustar00rootroot00000000000000libdfp_files += dpd-private binpowof10 decpowof2 libdfp-1.0.12/sysdeps/dpd/Versions000066400000000000000000000034531261375163000170400ustar00rootroot00000000000000# These are added in this sysdeps/dpd/Versions file because the # C source files don't indicate "__dpd" in the filename and they # live in the common base-math/ directory. libdfp { LIBDFP_1.0.0 { __dpd_addsd3; __dpd_adddd3; __dpd_addtd3; __dpd_subsd3; __dpd_subdd3; __dpd_subtd3; __dpd_mulsd3; __dpd_muldd3; __dpd_multd3; __dpd_divsd3; __dpd_divdd3; __dpd_divtd3; __dpd_extendsddd2; __dpd_extendsdtd2; __dpd_extendddtd2; __dpd_trunctdsd2; __dpd_truncddsd2; __dpd_trunctddd2; __dpd_unordsd2; __dpd_unorddd2; __dpd_unordtd2; __dpd_eqsd2; __dpd_eqdd2; __dpd_eqtd2; __dpd_nesd2; __dpd_nedd2; __dpd_netd2; __dpd_gesd2; __dpd_gedd2; __dpd_getd2; __dpd_gtsd2; __dpd_gtdd2; __dpd_gttd2; __dpd_ltsd2; __dpd_ltdd2; __dpd_lttd2; __dpd_lesd2; __dpd_ledd2; __dpd_letd2; __dpd_fixsdsi; __dpd_fixddsi; __dpd_fixtdsi; __dpd_fixsddi; __dpd_fixdddi; __dpd_fixtddi; __dpd_fixunssdsi; __dpd_fixunsddsi; __dpd_fixunstdsi; __dpd_fixunssddi; __dpd_fixunsdddi; __dpd_fixunstddi; __dpd_floatsisd; __dpd_floatsidd; __dpd_floatsitd; __dpd_floatdisd; __dpd_floatdidd; __dpd_floatditd; __dpd_floatunssisd; __dpd_floatunssidd; __dpd_floatunssitd; __dpd_floatunsdisd; __dpd_floatunsdidd; __dpd_floatunsditd; # These extend and trunc symbols were moved into here from # sysdeps/soft-dfp/dpd/Versions. This is a bug fix, not an # ABI change. This makes sure that these exports are available in # hard-dfp shared objects at link time. __dpd_extendsfsd; __dpd_extendsddf; __dpd_extendsdtf; __dpd_extendsfdd; __dpd_extenddfdd; __dpd_extendddtf; __dpd_extendsftd; __dpd_extenddftd; __dpd_extendtftd; __dpd_truncsdsf; __dpd_truncdfsd; __dpd_trunctfsd; __dpd_truncddsf; __dpd_truncdddf; __dpd_trunctfdd; __dpd_trunctdsf; __dpd_trunctddf; __dpd_trunctdtf; } } libdfp-1.0.12/sysdeps/dpd/decode.c000066400000000000000000000130421261375163000166670ustar00rootroot00000000000000/* Functions to print the DPD declets for use with printf %Z Copyright (C) 2006, 2007 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steve Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #include #include #include #include #include #include /* This version is used by all DPD implementations. */ #undef DEBUG_PRINT #define DEBUG_PRINT 0 char * __decoded32 (_Decimal32 a, char * str) { union ieee754r_Decimal32 d; struct ieee754r_c_field c_f; int exp; char sign; char lmd; const char *cc0; const char *cc1; char * after_exp = NULL; d.sd = a; if (d.ieee.negative) sign = '-'; else sign = '+'; c_f = c_decoder[d.ieee.c]; exp = c_f.lm_exp << DECIMAL32_BEC_bits; exp += d.ieee.bec; exp -= DECIMAL32_Bias; lmd = '0' + c_f.lmd; cc0 = &dpd_to_char[d.ieee.cc0][0]; cc1 = &dpd_to_char[d.ieee.cc1][0]; str[0] = sign; str[1] = lmd; str[2] = ','; __dpd_cpydeclet(&str[3], cc0); str[6] = ','; __dpd_cpydeclet(&str[7], cc1); str[10] = 'E'; after_exp = __dpd_exptostr(&str[11], exp); if (after_exp != NULL) *after_exp = '\0'; return str; } weak_alias (__decoded32, decoded32) hidden_def(__decoded32) char * __decoded64 ( _Decimal64 a, char * str ) { union ieee754r_Decimal64 d; struct ieee754r_c_field c_f; int exp, i; char sign; char lmd; const char *cc0; const char *cc1; const char *cc2; const char *cc3; const char *cc4; char * after_exp = NULL; d.dd = a; if (d.ieee.negative) sign = '-'; else sign = '+'; c_f = c_decoder[d.ieee.c]; exp = c_f.lm_exp << DECIMAL64_BEC_bits; exp += d.ieee.bec; exp -= DECIMAL64_Bias; lmd = '0' + c_f.lmd; cc0 = &dpd_to_char[d.ieee.cc0][0]; /* Packed fields crossing a word boundary require special handling. */ i = d.ieee.cc1H8 << 2; i = i + d.ieee.cc1L2; cc1 = &dpd_to_char[i][0]; cc2 = &dpd_to_char[d.ieee.cc2][0]; cc3 = &dpd_to_char[d.ieee.cc3][0]; cc4 = &dpd_to_char[d.ieee.cc4][0]; str[0] = sign; str[1] = lmd; str[2] = ','; __dpd_cpydeclet(&str[3], cc0); str[6] = ','; __dpd_cpydeclet(&str[7], cc1); str[10] = ','; __dpd_cpydeclet(&str[11], cc2); str[14] = ','; __dpd_cpydeclet(&str[15], cc3); str[18] = ','; __dpd_cpydeclet(&str[19], cc4); str[22] = 'E'; after_exp = __dpd_exptostr(&str[23], exp); if (after_exp != NULL) *after_exp = '\0'; return str; } weak_alias (__decoded64, decoded64) hidden_def(__decoded64) char * __decoded128 ( _Decimal128 a, char * str ) { union ieee754r_Decimal128 d; struct ieee754r_c_field c_f; int exp;/*, i; */ char sign; char lmd; const char *cc0; const char *cc1; const char *cc2; const char *cc3; const char *cc4; const char *cc5; const char *cc6; const char *cc7; const char *cc8; const char *cc9; const char *cc10; char * after_exp = NULL; d.td = a; if (d.ieee.negative) sign = '-'; else sign = '+'; c_f = c_decoder[d.ieee.c]; exp = c_f.lm_exp << DECIMAL128_BEC_bits; exp += d.ieee.bec; exp -= DECIMAL128_Bias; lmd = '0' + c_f.lmd; cc0 = &dpd_to_char[d.ieee.cc0][0]; /* Packed fields crossing a word boundary require special handling. */ cc1 = &dpd_to_char[((d.ieee.cc1H4<<6) + d.ieee.cc1L6)][0]; cc2 = &dpd_to_char[d.ieee.cc2][0]; cc3 = &dpd_to_char[d.ieee.cc3][0]; cc4 = &dpd_to_char[((d.ieee.cc4H6<<4) + d.ieee.cc4L4)][0]; cc5 = &dpd_to_char[d.ieee.cc5][0]; cc6 = &dpd_to_char[d.ieee.cc6][0]; cc7 = &dpd_to_char[((d.ieee.cc7H8<<2) + d.ieee.cc7L2)][0]; cc8 = &dpd_to_char[d.ieee.cc8][0]; cc9 = &dpd_to_char[d.ieee.cc9][0]; cc10 = &dpd_to_char[d.ieee.cc10][0]; str[0] = sign; str[1] = lmd; str[2] = ','; __dpd_cpydeclet(&str[3], cc0); str[6] = ','; __dpd_cpydeclet(&str[7], cc1); str[10] = ','; __dpd_cpydeclet(&str[11], cc2); str[14] = ','; __dpd_cpydeclet(&str[15], cc3); str[18] = ','; __dpd_cpydeclet(&str[19], cc4); str[22] = ','; __dpd_cpydeclet(&str[23], cc5); str[26] = ','; __dpd_cpydeclet(&str[27], cc6); str[30] = ','; __dpd_cpydeclet(&str[31], cc7); str[34] = ','; __dpd_cpydeclet(&str[35], cc8); str[38] = ','; __dpd_cpydeclet(&str[39], cc9); str[42] = ','; __dpd_cpydeclet(&str[43], cc10); str[46] = 'E'; after_exp = __dpd_exptostr(&str[47], exp); if (after_exp != NULL) *after_exp = '\0'; return str; } weak_alias (__decoded128, decoded128) hidden_def(__decoded128) libdfp-1.0.12/sysdeps/dpd/dpd-private.c000066400000000000000000001361511261375163000176720ustar00rootroot00000000000000/* Data types for DPD format output. Copyright (C) 2006, 2007 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steve Munroe The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #include #include #include #include #include "dpd-private.h" #include "get_digits.h" const struct ieee754r_c_field c_decoder[32] = { {0, 0, 0, 0}, {0, 0, 0, 1}, {0, 0, 0, 2}, {0, 0, 0, 3}, /* 00000-00011 */ {0, 0, 0, 4}, {0, 0, 0, 5}, {0, 0, 0, 6}, {0, 0, 0, 7}, /* 00100-00111 */ {0, 0, 1, 0}, {0, 0, 1, 1}, {0, 0, 1, 2}, {0, 0, 1, 3}, /* 01000-01011 */ {0, 0, 1, 4}, {0, 0, 1, 5}, {0, 0, 1, 6}, {0, 0, 1, 7}, /* 01100-01111 */ {0, 0, 2, 0}, {0, 0, 2, 1}, {0, 0, 2, 2}, {0, 0, 2, 3}, /* 10000-10011 */ {0, 0, 2, 4}, {0, 0, 2, 5}, {0, 0, 2, 5}, {0, 0, 2, 7}, /* 10100-10111 */ {0, 0, 0, 8}, {0, 0, 0, 9}, {0, 0, 1, 8}, {0, 0, 1, 9}, /* 11000-11011 */ {0, 0, 2, 8}, {0, 0, 2, 9}, {0, 1, 0, 0}, {1, 0, 0, 0} /* 11100-11111 */ }; /* Table to encode the "left most" 2 bits of the biased exponent and the "Left Most Digit" into the "C"ombination field. Indexed by [lmd,lm2bits]. */ const unsigned char lm2lmd_to_c[10][4] = { {0x00, 0x08, 0x10, 0x1e}, {0x01, 0x09, 0x11, 0x1e}, {0x02, 0x0a, 0x12, 0x1e}, {0x03, 0x0b, 0x13, 0x1e}, {0x04, 0x0c, 0x14, 0x1e}, {0x05, 0x0d, 0x15, 0x1e}, {0x06, 0x0e, 0x16, 0x1e}, {0x07, 0x0f, 0x17, 0x1e}, {0x18, 0x1a, 0x1c, 0x1e}, {0x19, 0x1b, 0x1d, 0x1e}}; /* Table to convert 3 Densely Packed Decimal digits (10-bits) into 3 ASCII digits (24-bits, 3 bytes). */ const char dpd_to_char[1024][4] = { "000", "001", "002", "003", "004", "005", "006", "007", /* 000-007 */ "008", "009", "080", "081", "800", "801", "880", "881", /* 008-00f */ "010", "011", "012", "013", "014", "015", "016", "017", /* 010-017 */ "018", "019", "090", "091", "810", "811", "890", "891", /* 018-01f */ "020", "021", "022", "023", "024", "025", "026", "027", /* 020-027 */ "028", "029", "082", "083", "820", "821", "808", "809", /* 028-02f */ "030", "031", "032", "033", "034", "035", "036", "037", /* 030-037 */ "038", "039", "092", "093", "830", "831", "818", "819", /* 038-03f */ "040", "041", "042", "043", "044", "045", "046", "047", /* 040-047 */ "048", "049", "084", "085", "840", "841", "088", "089", /* 048-04f */ "050", "051", "052", "053", "054", "055", "056", "057", /* 050-057 */ "058", "059", "094", "095", "850", "851", "098", "099", /* 058-05f */ "060", "061", "062", "063", "064", "065", "066", "067", /* 060-067 */ "068", "069", "086", "087", "860", "861", "888", "889", /* 068-06f */ "070", "071", "072", "073", "074", "075", "076", "077", /* 070-077 */ "078", "079", "096", "097", "870", "871", "898", "899", /* 078-07f */ "100", "101", "102", "103", "104", "105", "106", "107", /* 080-087 */ "108", "109", "180", "181", "900", "901", "980", "981", /* 088-08f */ "110", "111", "112", "113", "114", "115", "116", "117", /* 090-097 */ "118", "119", "190", "191", "910", "911", "990", "991", /* 098-09f */ "120", "121", "122", "123", "124", "125", "126", "127", /* 0a0-0a7 */ "128", "129", "182", "183", "920", "921", "908", "909", /* 0a8-0af */ "130", "131", "132", "133", "134", "135", "136", "137", /* 0b0-0b7 */ "138", "139", "192", "193", "930", "931", "918", "919", /* 0b8-0bf */ "140", "141", "142", "143", "144", "145", "146", "147", /* 0c0-0c7 */ "148", "149", "184", "185", "940", "941", "188", "189", /* 0c8-0cf */ "150", "151", "152", "153", "154", "155", "156", "157", /* 0d0-0d7 */ "158", "159", "194", "195", "950", "951", "198", "199", /* 0d8-0df */ "160", "161", "162", "163", "164", "165", "166", "167", /* 0e0-0e7 */ "168", "169", "186", "187", "960", "961", "988", "989", /* 0e8-0ef */ "170", "171", "172", "173", "174", "175", "176", "177", /* 0f0-0f7 */ "178", "179", "196", "197", "970", "971", "998", "999", /* 0f8-0ff */ "200", "201", "202", "203", "204", "205", "206", "207", /* 100-107 */ "208", "209", "280", "281", "802", "803", "882", "883", /* 108-10f */ "210", "211", "212", "213", "214", "215", "216", "217", /* 110-117 */ "218", "219", "290", "291", "812", "813", "892", "893", /* 118-11f */ "220", "221", "222", "223", "224", "225", "226", "227", /* 120-127 */ "228", "229", "282", "283", "822", "823", "828", "829", /* 128-12f */ "230", "231", "232", "233", "234", "235", "236", "237", /* 130-137 */ "238", "239", "292", "293", "832", "833", "838", "839", /* 138-13f */ "240", "241", "242", "243", "244", "245", "246", "247", /* 140-147 */ "248", "249", "284", "285", "842", "843", "288", "289", /* 148-14f */ "250", "251", "252", "253", "254", "255", "256", "257", /* 150-157 */ "258", "259", "294", "295", "852", "853", "298", "299", /* 158-15f */ "260", "261", "262", "263", "264", "265", "266", "267", /* 160-167 */ "268", "269", "286", "287", "862", "863", "888", "889", /* 168-16f */ "270", "271", "272", "273", "274", "275", "276", "277", /* 170-177 */ "278", "279", "296", "297", "872", "873", "898", "899", /* 178-17f */ "300", "301", "302", "303", "304", "305", "306", "307", /* 180-187 */ "308", "309", "380", "381", "902", "903", "982", "983", /* 188-18f */ "310", "311", "312", "313", "314", "315", "316", "317", /* 190-197 */ "318", "319", "390", "391", "912", "913", "992", "993", /* 198-19f */ "320", "321", "322", "323", "324", "325", "326", "327", /* 1a0-1a7 */ "328", "329", "382", "383", "922", "923", "928", "929", /* 1a8-1af */ "330", "331", "332", "333", "334", "335", "336", "337", /* 1b0-1b7 */ "338", "339", "392", "393", "932", "933", "938", "939", /* 1b8-1bf */ "340", "341", "342", "343", "344", "345", "346", "347", /* 1c0-1c7 */ "348", "349", "384", "385", "942", "943", "388", "389", /* 1c8-1cf */ "350", "351", "352", "353", "354", "355", "356", "357", /* 1d0-1d7 */ "358", "359", "394", "395", "952", "953", "398", "399", /* 1d8-1df */ "360", "361", "362", "363", "364", "365", "366", "367", /* 1e0-1e7 */ "368", "369", "386", "387", "962", "963", "988", "989", /* 1e8-1ef */ "370", "371", "372", "373", "374", "375", "376", "377", /* 1f0-1f7 */ "378", "379", "396", "397", "972", "973", "998", "999", /* 1f8-1ff */ "400", "401", "402", "403", "404", "405", "406", "407", /* 200-207 */ "408", "409", "480", "481", "804", "805", "884", "885", /* 208-20f */ "410", "411", "412", "413", "414", "415", "416", "417", /* 210-217 */ "418", "419", "490", "491", "814", "815", "894", "895", /* 218-21f */ "420", "421", "422", "423", "424", "425", "426", "427", /* 220-227 */ "428", "429", "482", "483", "824", "825", "848", "849", /* 228-22f */ "430", "431", "432", "433", "434", "435", "436", "437", /* 230-237 */ "438", "439", "492", "493", "834", "835", "858", "859", /* 238-23f */ "440", "441", "442", "443", "444", "445", "446", "447", /* 240-247 */ "448", "449", "484", "485", "844", "845", "488", "489", /* 248-24f */ "450", "451", "452", "453", "454", "455", "456", "457", /* 250-257 */ "458", "459", "494", "495", "854", "855", "498", "499", /* 258-25f */ "460", "461", "462", "463", "464", "465", "466", "467", /* 260-267 */ "468", "469", "486", "487", "864", "865", "888", "889", /* 268-26f */ "470", "471", "472", "473", "474", "475", "476", "477", /* 270-277 */ "478", "479", "496", "497", "874", "875", "898", "899", /* 278-27f */ "500", "501", "502", "503", "504", "505", "506", "507", /* 280-287 */ "508", "509", "580", "581", "904", "905", "984", "985", /* 288-28f */ "510", "511", "512", "513", "514", "515", "516", "517", /* 290-297 */ "518", "519", "590", "591", "914", "915", "994", "995", /* 298-29f */ "520", "521", "522", "523", "524", "525", "526", "527", /* 2a0-2a7 */ "528", "529", "582", "583", "924", "925", "948", "949", /* 2a8-2af */ "530", "531", "532", "533", "534", "535", "536", "537", /* 2b0-2b7 */ "538", "539", "592", "593", "934", "935", "958", "959", /* 2b8-2bf */ "540", "541", "542", "543", "544", "545", "546", "547", /* 2c0-2c7 */ "548", "549", "584", "585", "944", "945", "588", "589", /* 2c8-2cf */ "550", "551", "552", "553", "554", "555", "556", "557", /* 2d0-2d7 */ "558", "559", "594", "595", "954", "955", "598", "599", /* 2d8-2df */ "560", "561", "562", "563", "564", "565", "566", "567", /* 2e0-2e7 */ "568", "569", "586", "587", "964", "965", "988", "989", /* 2e8-2ef */ "570", "571", "572", "573", "574", "575", "576", "577", /* 2f0-2f7 */ "578", "579", "596", "597", "974", "975", "998", "999", /* 2f8-2ff */ "600", "601", "602", "603", "604", "605", "606", "607", /* 300-307 */ "608", "609", "680", "681", "806", "807", "886", "887", /* 308-30f */ "610", "611", "612", "613", "614", "615", "616", "617", /* 310-317 */ "618", "619", "690", "691", "816", "817", "896", "897", /* 318-31f */ "620", "621", "622", "623", "624", "625", "626", "627", /* 320-327 */ "628", "629", "682", "683", "826", "827", "868", "869", /* 328-32f */ "630", "631", "632", "633", "634", "635", "636", "637", /* 330-337 */ "638", "639", "692", "693", "836", "837", "878", "879", /* 338-33f */ "640", "641", "642", "643", "644", "645", "646", "647", /* 340-347 */ "648", "649", "684", "685", "846", "847", "688", "689", /* 348-34f */ "650", "651", "652", "653", "654", "655", "656", "657", /* 350-357 */ "658", "659", "694", "695", "856", "857", "698", "699", /* 358-35f */ "660", "661", "662", "663", "664", "665", "666", "667", /* 360-367 */ "668", "669", "686", "687", "866", "867", "888", "889", /* 368-36f */ "670", "671", "672", "673", "674", "675", "676", "677", /* 370-377 */ "678", "679", "696", "697", "876", "877", "898", "899", /* 378-37f */ "700", "701", "702", "703", "704", "705", "706", "707", /* 380-387 */ "708", "709", "780", "781", "906", "907", "986", "987", /* 388-38f */ "710", "711", "712", "713", "714", "715", "716", "717", /* 390-397 */ "718", "719", "790", "791", "916", "917", "996", "997", /* 398-39f */ "720", "721", "722", "723", "724", "725", "726", "727", /* 3a0-3a7 */ "728", "729", "782", "783", "926", "927", "968", "969", /* 3a8-3af */ "730", "731", "732", "733", "734", "735", "736", "737", /* 3b0-3b7 */ "738", "739", "792", "793", "936", "937", "978", "979", /* 3b8-3bf */ "740", "741", "742", "743", "744", "745", "746", "747", /* 3c0-3c7 */ "748", "749", "784", "785", "946", "947", "788", "789", /* 3c8-3cf */ "750", "751", "752", "753", "754", "755", "756", "757", /* 3d0-3d7 */ "758", "759", "794", "795", "956", "957", "798", "799", /* 3d8-3df */ "760", "761", "762", "763", "764", "765", "766", "767", /* 3e0-3e7 */ "768", "769", "786", "787", "966", "967", "988", "989", /* 3e8-3ef */ "770", "771", "772", "773", "774", "775", "776", "777", /* 3f0-3f7 */ "778", "779", "796", "797", "976", "977", "998", "999" /* 3f8-3ff */ }; // "770", "771", "772", "773", "974", "775", "776", "777", /* 3f0-3f7 */ /* Table to convert 3 Densely Packed Decimal digits (10-bits) into 3 Binary coded Decimal digits (12-bits). */ const short int dpd_to_bcd[1024] = { 0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007, /* 000-007 */ 0x008, 0x009, 0x080, 0x081, 0x800, 0x801, 0x880, 0x881, /* 008-00f */ 0x010, 0x011, 0x012, 0x013, 0x014, 0x015, 0x016, 0x017, /* 010-017 */ 0x018, 0x019, 0x090, 0x091, 0x810, 0x811, 0x890, 0x891, /* 018-01f */ 0x020, 0x021, 0x022, 0x023, 0x024, 0x025, 0x026, 0x027, /* 020-027 */ 0x028, 0x029, 0x082, 0x083, 0x820, 0x821, 0x808, 0x809, /* 028-02f */ 0x030, 0x031, 0x032, 0x033, 0x034, 0x035, 0x036, 0x037, /* 030-037 */ 0x038, 0x039, 0x092, 0x093, 0x830, 0x831, 0x818, 0x819, /* 038-03f */ 0x040, 0x041, 0x042, 0x043, 0x044, 0x045, 0x046, 0x047, /* 040-047 */ 0x048, 0x049, 0x084, 0x085, 0x840, 0x841, 0x088, 0x089, /* 048-04f */ 0x050, 0x051, 0x052, 0x053, 0x054, 0x055, 0x056, 0x057, /* 050-057 */ 0x058, 0x059, 0x094, 0x095, 0x850, 0x851, 0x098, 0x099, /* 058-05f */ 0x060, 0x061, 0x062, 0x063, 0x064, 0x065, 0x066, 0x067, /* 060-067 */ 0x068, 0x069, 0x086, 0x087, 0x860, 0x861, 0x888, 0x889, /* 068-06f */ 0x070, 0x071, 0x072, 0x073, 0x074, 0x075, 0x076, 0x077, /* 070-077 */ 0x078, 0x079, 0x096, 0x097, 0x870, 0x871, 0x898, 0x899, /* 078-07f */ 0x100, 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107, /* 080-087 */ 0x108, 0x109, 0x180, 0x181, 0x900, 0x901, 0x980, 0x981, /* 088-08f */ 0x110, 0x111, 0x112, 0x113, 0x114, 0x115, 0x116, 0x117, /* 090-097 */ 0x118, 0x119, 0x190, 0x191, 0x910, 0x911, 0x990, 0x991, /* 098-09f */ 0x120, 0x121, 0x122, 0x123, 0x124, 0x125, 0x126, 0x127, /* 0a0-0a7 */ 0x128, 0x129, 0x182, 0x183, 0x920, 0x921, 0x908, 0x909, /* 0a8-0af */ 0x130, 0x131, 0x132, 0x133, 0x134, 0x135, 0x136, 0x137, /* 0b0-0b7 */ 0x138, 0x139, 0x192, 0x193, 0x930, 0x931, 0x918, 0x919, /* 0b8-0bf */ 0x140, 0x141, 0x142, 0x143, 0x144, 0x145, 0x146, 0x147, /* 0c0-0c7 */ 0x148, 0x149, 0x184, 0x185, 0x940, 0x941, 0x188, 0x189, /* 0c8-0cf */ 0x150, 0x151, 0x152, 0x153, 0x154, 0x155, 0x156, 0x157, /* 0d0-0d7 */ 0x158, 0x159, 0x194, 0x195, 0x950, 0x951, 0x198, 0x199, /* 0d8-0df */ 0x160, 0x161, 0x162, 0x163, 0x164, 0x165, 0x166, 0x167, /* 0e0-0e7 */ 0x168, 0x169, 0x186, 0x187, 0x960, 0x961, 0x988, 0x989, /* 0e8-0ef */ 0x170, 0x171, 0x172, 0x173, 0x174, 0x175, 0x176, 0x177, /* 0f0-0f7 */ 0x178, 0x179, 0x196, 0x197, 0x970, 0x971, 0x998, 0x999, /* 0f8-0ff */ 0x200, 0x201, 0x202, 0x203, 0x204, 0x205, 0x206, 0x207, /* 100-107 */ 0x208, 0x209, 0x280, 0x281, 0x802, 0x803, 0x882, 0x883, /* 108-10f */ 0x210, 0x211, 0x212, 0x213, 0x214, 0x215, 0x216, 0x217, /* 110-117 */ 0x218, 0x219, 0x290, 0x291, 0x812, 0x813, 0x892, 0x893, /* 118-11f */ 0x220, 0x221, 0x222, 0x223, 0x224, 0x225, 0x226, 0x227, /* 120-127 */ 0x228, 0x229, 0x282, 0x283, 0x822, 0x823, 0x828, 0x829, /* 128-12f */ 0x230, 0x231, 0x232, 0x233, 0x234, 0x235, 0x236, 0x237, /* 130-137 */ 0x238, 0x239, 0x292, 0x293, 0x832, 0x833, 0x838, 0x839, /* 138-13f */ 0x240, 0x241, 0x242, 0x243, 0x244, 0x245, 0x246, 0x247, /* 140-147 */ 0x248, 0x249, 0x284, 0x285, 0x842, 0x843, 0x288, 0x289, /* 148-14f */ 0x250, 0x251, 0x252, 0x253, 0x254, 0x255, 0x256, 0x257, /* 150-157 */ 0x258, 0x259, 0x294, 0x295, 0x852, 0x853, 0x298, 0x299, /* 158-15f */ 0x260, 0x261, 0x262, 0x263, 0x264, 0x265, 0x266, 0x267, /* 160-167 */ 0x268, 0x269, 0x286, 0x287, 0x862, 0x863, 0x888, 0x889, /* 168-16f */ 0x270, 0x271, 0x272, 0x273, 0x274, 0x275, 0x276, 0x277, /* 170-177 */ 0x278, 0x279, 0x296, 0x297, 0x872, 0x873, 0x898, 0x899, /* 178-17f */ 0x300, 0x301, 0x302, 0x303, 0x304, 0x305, 0x306, 0x307, /* 180-187 */ 0x308, 0x309, 0x380, 0x381, 0x902, 0x903, 0x982, 0x983, /* 188-18f */ 0x310, 0x311, 0x312, 0x313, 0x314, 0x315, 0x316, 0x317, /* 190-197 */ 0x318, 0x319, 0x390, 0x391, 0x912, 0x913, 0x992, 0x993, /* 198-19f */ 0x320, 0x321, 0x322, 0x323, 0x324, 0x325, 0x326, 0x327, /* 1a0-1a7 */ 0x328, 0x329, 0x382, 0x383, 0x922, 0x923, 0x928, 0x929, /* 1a8-1af */ 0x330, 0x331, 0x332, 0x333, 0x334, 0x335, 0x336, 0x337, /* 1b0-1b7 */ 0x338, 0x339, 0x392, 0x393, 0x932, 0x933, 0x938, 0x939, /* 1b8-1bf */ 0x340, 0x341, 0x342, 0x343, 0x344, 0x345, 0x346, 0x347, /* 1c0-1c7 */ 0x348, 0x349, 0x384, 0x385, 0x942, 0x943, 0x388, 0x389, /* 1c8-1cf */ 0x350, 0x351, 0x352, 0x353, 0x354, 0x355, 0x356, 0x357, /* 1d0-1d7 */ 0x358, 0x359, 0x394, 0x395, 0x952, 0x953, 0x398, 0x399, /* 1d8-1df */ 0x360, 0x361, 0x362, 0x363, 0x364, 0x365, 0x366, 0x367, /* 1e0-1e7 */ 0x368, 0x369, 0x386, 0x387, 0x962, 0x963, 0x988, 0x989, /* 1e8-1ef */ 0x370, 0x371, 0x372, 0x373, 0x374, 0x375, 0x376, 0x377, /* 1f0-1f7 */ 0x378, 0x379, 0x396, 0x397, 0x972, 0x973, 0x998, 0x999, /* 1f8-1ff */ 0x400, 0x401, 0x402, 0x403, 0x404, 0x405, 0x406, 0x407, /* 200-207 */ 0x408, 0x409, 0x480, 0x481, 0x804, 0x805, 0x884, 0x885, /* 208-20f */ 0x410, 0x411, 0x412, 0x413, 0x414, 0x415, 0x416, 0x417, /* 210-217 */ 0x418, 0x419, 0x490, 0x491, 0x814, 0x815, 0x894, 0x895, /* 218-21f */ 0x420, 0x421, 0x422, 0x423, 0x424, 0x425, 0x426, 0x427, /* 220-227 */ 0x428, 0x429, 0x482, 0x483, 0x824, 0x825, 0x848, 0x849, /* 228-22f */ 0x430, 0x431, 0x432, 0x433, 0x434, 0x435, 0x436, 0x437, /* 230-237 */ 0x438, 0x439, 0x492, 0x493, 0x834, 0x835, 0x858, 0x859, /* 238-23f */ 0x440, 0x441, 0x442, 0x443, 0x444, 0x445, 0x446, 0x447, /* 240-247 */ 0x448, 0x449, 0x484, 0x485, 0x844, 0x845, 0x488, 0x489, /* 248-24f */ 0x450, 0x451, 0x452, 0x453, 0x454, 0x455, 0x456, 0x457, /* 250-257 */ 0x458, 0x459, 0x494, 0x495, 0x854, 0x855, 0x498, 0x499, /* 258-25f */ 0x460, 0x461, 0x462, 0x463, 0x464, 0x465, 0x466, 0x467, /* 260-267 */ 0x468, 0x469, 0x486, 0x487, 0x864, 0x865, 0x888, 0x889, /* 268-26f */ 0x470, 0x471, 0x472, 0x473, 0x474, 0x475, 0x476, 0x477, /* 270-277 */ 0x478, 0x479, 0x496, 0x497, 0x874, 0x875, 0x898, 0x899, /* 278-27f */ 0x500, 0x501, 0x502, 0x503, 0x504, 0x505, 0x506, 0x507, /* 280-287 */ 0x508, 0x509, 0x580, 0x581, 0x904, 0x905, 0x984, 0x985, /* 288-28f */ 0x510, 0x511, 0x512, 0x513, 0x514, 0x515, 0x516, 0x517, /* 290-297 */ 0x518, 0x519, 0x590, 0x591, 0x914, 0x915, 0x994, 0x995, /* 298-29f */ 0x520, 0x521, 0x522, 0x523, 0x524, 0x525, 0x526, 0x527, /* 2a0-2a7 */ 0x528, 0x529, 0x582, 0x583, 0x924, 0x925, 0x948, 0x949, /* 2a8-2af */ 0x530, 0x531, 0x532, 0x533, 0x534, 0x535, 0x536, 0x537, /* 2b0-2b7 */ 0x538, 0x539, 0x592, 0x593, 0x934, 0x935, 0x958, 0x959, /* 2b8-2bf */ 0x540, 0x541, 0x542, 0x543, 0x544, 0x545, 0x546, 0x547, /* 2c0-2c7 */ 0x548, 0x549, 0x584, 0x585, 0x944, 0x945, 0x588, 0x589, /* 2c8-2cf */ 0x550, 0x551, 0x552, 0x553, 0x554, 0x555, 0x556, 0x557, /* 2d0-2d7 */ 0x558, 0x559, 0x594, 0x595, 0x954, 0x955, 0x598, 0x599, /* 2d8-2df */ 0x560, 0x561, 0x562, 0x563, 0x564, 0x565, 0x566, 0x567, /* 2e0-2e7 */ 0x568, 0x569, 0x586, 0x587, 0x964, 0x965, 0x988, 0x989, /* 2e8-2ef */ 0x570, 0x571, 0x572, 0x573, 0x574, 0x575, 0x576, 0x577, /* 2f0-2f7 */ 0x578, 0x579, 0x596, 0x597, 0x974, 0x975, 0x998, 0x999, /* 2f8-2ff */ 0x600, 0x601, 0x602, 0x603, 0x604, 0x605, 0x606, 0x607, /* 300-307 */ 0x608, 0x609, 0x680, 0x681, 0x806, 0x807, 0x886, 0x887, /* 308-30f */ 0x610, 0x611, 0x612, 0x613, 0x614, 0x615, 0x616, 0x617, /* 310-317 */ 0x618, 0x619, 0x690, 0x691, 0x816, 0x817, 0x896, 0x897, /* 318-31f */ 0x620, 0x621, 0x622, 0x623, 0x624, 0x625, 0x626, 0x627, /* 320-327 */ 0x628, 0x629, 0x682, 0x683, 0x826, 0x827, 0x868, 0x869, /* 328-32f */ 0x630, 0x631, 0x632, 0x633, 0x634, 0x635, 0x636, 0x637, /* 330-337 */ 0x638, 0x639, 0x692, 0x693, 0x836, 0x837, 0x878, 0x879, /* 338-33f */ 0x640, 0x641, 0x642, 0x643, 0x644, 0x645, 0x646, 0x647, /* 340-347 */ 0x648, 0x649, 0x684, 0x685, 0x846, 0x847, 0x688, 0x689, /* 348-34f */ 0x650, 0x651, 0x652, 0x653, 0x654, 0x655, 0x656, 0x657, /* 350-357 */ 0x658, 0x659, 0x694, 0x695, 0x856, 0x857, 0x698, 0x699, /* 358-35f */ 0x660, 0x661, 0x662, 0x663, 0x664, 0x665, 0x666, 0x667, /* 360-367 */ 0x668, 0x669, 0x686, 0x687, 0x866, 0x867, 0x888, 0x889, /* 368-36f */ 0x670, 0x671, 0x672, 0x673, 0x674, 0x675, 0x676, 0x677, /* 370-377 */ 0x678, 0x679, 0x696, 0x697, 0x876, 0x877, 0x898, 0x899, /* 378-37f */ 0x700, 0x701, 0x702, 0x703, 0x704, 0x705, 0x706, 0x707, /* 380-387 */ 0x708, 0x709, 0x780, 0x781, 0x906, 0x907, 0x986, 0x987, /* 388-38f */ 0x710, 0x711, 0x712, 0x713, 0x714, 0x715, 0x716, 0x717, /* 390-397 */ 0x718, 0x719, 0x790, 0x791, 0x916, 0x917, 0x996, 0x997, /* 398-39f */ 0x720, 0x721, 0x722, 0x723, 0x724, 0x725, 0x726, 0x727, /* 3a0-3a7 */ 0x728, 0x729, 0x782, 0x783, 0x926, 0x927, 0x968, 0x969, /* 3a8-3af */ 0x730, 0x731, 0x732, 0x733, 0x734, 0x735, 0x736, 0x737, /* 3b0-3b7 */ 0x738, 0x739, 0x792, 0x793, 0x936, 0x937, 0x978, 0x979, /* 3b8-3bf */ 0x740, 0x741, 0x742, 0x743, 0x744, 0x745, 0x746, 0x747, /* 3c0-3c7 */ 0x748, 0x749, 0x784, 0x785, 0x946, 0x947, 0x788, 0x789, /* 3c8-3cf */ 0x750, 0x751, 0x752, 0x753, 0x754, 0x755, 0x756, 0x757, /* 3d0-3d7 */ 0x758, 0x759, 0x794, 0x795, 0x956, 0x957, 0x798, 0x799, /* 3d8-3df */ 0x760, 0x761, 0x762, 0x763, 0x764, 0x765, 0x766, 0x767, /* 3e0-3e7 */ 0x768, 0x769, 0x786, 0x787, 0x966, 0x967, 0x988, 0x989, /* 3e8-3ef */ 0x770, 0x771, 0x772, 0x773, 0x974, 0x775, 0x776, 0x777, /* 3f0-3f7 */ 0x778, 0x779, 0x796, 0x797, 0x976, 0x977, 0x998, 0x999 /* 3f8-3ff */ }; /* Table to convert 3 Binary Coded Decimal digits (12-bits) into 3 Densely Packed Decimal digits (10-bits). */ const short int bcd_to_dpd[2464] = { 0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007, /* 000-007 */ 0x008, 0x009, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 008-00f */ 0x010, 0x011, 0x012, 0x013, 0x014, 0x015, 0x016, 0x017, /* 010-017 */ 0x018, 0x019, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 018-01f */ 0x020, 0x021, 0x022, 0x023, 0x024, 0x025, 0x026, 0x027, /* 020-027 */ 0x028, 0x029, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 028-02f */ 0x030, 0x031, 0x032, 0x033, 0x034, 0x035, 0x036, 0x037, /* 030-037 */ 0x038, 0x039, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 038-03f */ 0x040, 0x041, 0x042, 0x043, 0x044, 0x045, 0x046, 0x047, /* 040-047 */ 0x048, 0x049, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 048-04f */ 0x050, 0x051, 0x052, 0x053, 0x054, 0x055, 0x056, 0x057, /* 050-057 */ 0x058, 0x059, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 058-05f */ 0x060, 0x061, 0x062, 0x063, 0x064, 0x065, 0x066, 0x067, /* 060-067 */ 0x068, 0x069, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 068-06f */ 0x070, 0x071, 0x072, 0x073, 0x074, 0x075, 0x076, 0x077, /* 070-077 */ 0x078, 0x079, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 078-07f */ 0x00a, 0x00b, 0x02a, 0x02b, 0x04a, 0x04b, 0x06a, 0x06b, /* 080-087 */ 0x04e, 0x04f, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 088-08f */ 0x01a, 0x01b, 0x03a, 0x03b, 0x05a, 0x05b, 0x07a, 0x07b, /* 090-097 */ 0x05e, 0x05f, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 098-09f */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 0a0-0a7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 0a8-0af */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 0b0-0b7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 0b8-0bf */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 0c0-0c7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 0c8-0cf */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 0d0-0d7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 0d8-0df */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 0e0-0e7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 0e8-0ef */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 0f0-0f7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 0f8-0ff */ 0x080, 0x081, 0x082, 0x083, 0x084, 0x085, 0x086, 0x087, /* 100-107 */ 0x088, 0x089, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 108-10f */ 0x090, 0x091, 0x092, 0x093, 0x094, 0x095, 0x096, 0x097, /* 110-117 */ 0x098, 0x099, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 118-11f */ 0x0a0, 0x0a1, 0x0a2, 0x0a3, 0x0a4, 0x0a5, 0x0a6, 0x0a7, /* 120-127 */ 0x0a8, 0x0a9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 128-12f */ 0x0b0, 0x0b1, 0x0b2, 0x0b3, 0x0b4, 0x0b5, 0x0b6, 0x0b7, /* 130-137 */ 0x0b8, 0x0b9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 138-13f */ 0x0c0, 0x0c1, 0x0c2, 0x0c3, 0x0c4, 0x0c5, 0x0c6, 0x0c7, /* 140-147 */ 0x0c8, 0x0c9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 148-14f */ 0x0d0, 0x0d1, 0x0d2, 0x0d3, 0x0d4, 0x0d5, 0x0d6, 0x0d7, /* 150-157 */ 0x0d8, 0x0d9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 158-15f */ 0x0e0, 0x0e1, 0x0e2, 0x0e3, 0x0e4, 0x0e5, 0x0e6, 0x0e7, /* 160-167 */ 0x0e8, 0x0e9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 168-16f */ 0x0f0, 0x0f1, 0x0f2, 0x0f3, 0x0f4, 0x0f5, 0x0f6, 0x0f7, /* 170-177 */ 0x0f8, 0x0f9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 178-17f */ 0x08a, 0x08b, 0x0aa, 0x0ab, 0x0ca, 0x0cb, 0x0ea, 0x0eb, /* 180-187 */ 0x0ce, 0x0cf, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 188-18f */ 0x09a, 0x09b, 0x0ba, 0x0bb, 0x0da, 0x0db, 0x0fa, 0x0fb, /* 190-197 */ 0x0de, 0x0df, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 198-19f */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 1a0-1a7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 1a8-1af */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 1b0-1b7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 1b8-1bf */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 1c0-1c7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 1c8-1cf */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 1d0-1d7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 1d8-1df */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 1e0-1e7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 1e8-1ef */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 1f0-1f7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 1f8-1ff */ 0x100, 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107, /* 200-207 */ 0x108, 0x109, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 208-20f */ 0x110, 0x111, 0x112, 0x113, 0x114, 0x115, 0x116, 0x117, /* 210-217 */ 0x118, 0x119, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 218-21f */ 0x120, 0x121, 0x122, 0x123, 0x124, 0x125, 0x126, 0x127, /* 220-227 */ 0x128, 0x129, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 228-22f */ 0x130, 0x131, 0x132, 0x133, 0x134, 0x135, 0x136, 0x137, /* 230-237 */ 0x138, 0x139, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 238-23f */ 0x140, 0x141, 0x142, 0x143, 0x144, 0x145, 0x146, 0x147, /* 240-247 */ 0x148, 0x149, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 248-24f */ 0x150, 0x151, 0x152, 0x153, 0x154, 0x155, 0x156, 0x157, /* 250-257 */ 0x158, 0x159, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 258-25f */ 0x160, 0x161, 0x162, 0x163, 0x164, 0x165, 0x166, 0x167, /* 260-267 */ 0x168, 0x169, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 268-26f */ 0x170, 0x171, 0x172, 0x173, 0x174, 0x175, 0x176, 0x177, /* 270-277 */ 0x178, 0x179, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 278-27f */ 0x10a, 0x10b, 0x12a, 0x12b, 0x14a, 0x14b, 0x16a, 0x16b, /* 280-287 */ 0x14e, 0x14f, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 288-28f */ 0x11a, 0x11b, 0x13a, 0x13b, 0x15a, 0x15b, 0x17a, 0x17b, /* 290-297 */ 0x15e, 0x15f, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 298-29f */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 2a0-2a7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 2a8-2af */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 2b0-2b7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 2b8-2bf */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 2c0-2c7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 2c8-2cf */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 2d0-2d7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 2d8-2df */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 2e0-2e7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 2e8-2ef */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 2f0-2f7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 2f8-2ff */ 0x180, 0x181, 0x182, 0x183, 0x184, 0x185, 0x186, 0x187, /* 300-307 */ 0x188, 0x189, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 308-30f */ 0x190, 0x191, 0x192, 0x193, 0x194, 0x195, 0x196, 0x197, /* 310-317 */ 0x198, 0x199, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 318-31f */ 0x1a0, 0x1a1, 0x1a2, 0x1a3, 0x1a4, 0x1a5, 0x1a6, 0x1a7, /* 320-327 */ 0x1a8, 0x1a9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 328-32f */ 0x1b0, 0x1b1, 0x1b2, 0x1b3, 0x1b4, 0x1b5, 0x1b6, 0x1b7, /* 330-337 */ 0x1b8, 0x1b9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 338-33f */ 0x1c0, 0x1c1, 0x1c2, 0x1c3, 0x1c4, 0x1c5, 0x1c6, 0x1c7, /* 340-347 */ 0x1c8, 0x1c9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 348-34f */ 0x1d0, 0x1d1, 0x1d2, 0x1d3, 0x1d4, 0x1d5, 0x1d6, 0x1d7, /* 350-357 */ 0x1d8, 0x1d9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 358-35f */ 0x1e0, 0x1e1, 0x1e2, 0x1e3, 0x1e4, 0x1e5, 0x1e6, 0x1e7, /* 360-367 */ 0x1e8, 0x1e9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 368-36f */ 0x1f0, 0x1f1, 0x1f2, 0x1f3, 0x1f4, 0x1f5, 0x1f6, 0x1f7, /* 370-377 */ 0x1f8, 0x1f9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 378-37f */ 0x18a, 0x18b, 0x1aa, 0x1ab, 0x1ca, 0x1cb, 0x1ea, 0x1eb, /* 380-387 */ 0x1ce, 0x1cf, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 388-38f */ 0x19a, 0x19b, 0x1ba, 0x1bb, 0x1da, 0x1db, 0x1fa, 0x1fb, /* 390-397 */ 0x1de, 0x1df, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 398-39f */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 3a0-3a7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 3a8-3af */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 3b0-3b7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 3b8-3bf */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 3c0-3c7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 3c8-3cf */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 3d0-3d7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 3d8-3df */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 3e0-3e7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 3e8-3ef */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 3f0-3f7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 3f8-3ff */ 0x200, 0x201, 0x202, 0x203, 0x204, 0x205, 0x206, 0x207, /* 400-407 */ 0x208, 0x209, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 408-40f */ 0x210, 0x211, 0x212, 0x213, 0x214, 0x215, 0x216, 0x217, /* 410-417 */ 0x218, 0x219, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 418-41f */ 0x220, 0x221, 0x222, 0x223, 0x224, 0x225, 0x226, 0x227, /* 420-427 */ 0x228, 0x229, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 428-42f */ 0x230, 0x231, 0x232, 0x233, 0x234, 0x235, 0x236, 0x237, /* 430-437 */ 0x238, 0x239, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 438-43f */ 0x240, 0x241, 0x242, 0x243, 0x244, 0x245, 0x246, 0x247, /* 440-447 */ 0x248, 0x249, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 448-44f */ 0x250, 0x251, 0x252, 0x253, 0x254, 0x255, 0x256, 0x257, /* 450-457 */ 0x258, 0x259, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 458-45f */ 0x260, 0x261, 0x262, 0x263, 0x264, 0x265, 0x266, 0x267, /* 460-467 */ 0x268, 0x269, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 468-46f */ 0x270, 0x271, 0x272, 0x273, 0x274, 0x275, 0x276, 0x277, /* 470-477 */ 0x278, 0x279, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 478-47f */ 0x20a, 0x20b, 0x22a, 0x22b, 0x24a, 0x24b, 0x26a, 0x26b, /* 480-487 */ 0x24e, 0x24f, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 488-48f */ 0x21a, 0x21b, 0x23a, 0x23b, 0x25a, 0x25b, 0x27a, 0x27b, /* 490-497 */ 0x25e, 0x25f, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 498-49f */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 4a0-4a7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 4a8-4af */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 4b0-4b7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 4b8-4bf */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 4c0-4c7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 4c8-4cf */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 4d0-4d7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 4d8-4df */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 4e0-4e7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 4e8-4ef */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 4f0-4f7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 4f8-4ff */ 0x280, 0x281, 0x282, 0x283, 0x284, 0x285, 0x286, 0x287, /* 500-507 */ 0x288, 0x289, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 508-50f */ 0x290, 0x291, 0x292, 0x293, 0x294, 0x295, 0x296, 0x297, /* 510-517 */ 0x298, 0x299, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 518-51f */ 0x2a0, 0x2a1, 0x2a2, 0x2a3, 0x2a4, 0x2a5, 0x2a6, 0x2a7, /* 520-527 */ 0x2a8, 0x2a9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 528-52f */ 0x2b0, 0x2b1, 0x2b2, 0x2b3, 0x2b4, 0x2b5, 0x2b6, 0x2b7, /* 530-537 */ 0x2b8, 0x2b9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 538-53f */ 0x2c0, 0x2c1, 0x2c2, 0x2c3, 0x2c4, 0x2c5, 0x2c6, 0x2c7, /* 540-547 */ 0x2c8, 0x2c9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 548-54f */ 0x2d0, 0x2d1, 0x2d2, 0x2d3, 0x2d4, 0x2d5, 0x2d6, 0x2d7, /* 550-557 */ 0x2d8, 0x2d9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 558-55f */ 0x2e0, 0x2e1, 0x2e2, 0x2e3, 0x2e4, 0x2e5, 0x2e6, 0x2e7, /* 560-567 */ 0x2e8, 0x2e9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 568-56f */ 0x2f0, 0x2f1, 0x2f2, 0x2f3, 0x2f4, 0x2f5, 0x2f6, 0x2f7, /* 570-577 */ 0x2f8, 0x2f9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 578-57f */ 0x28a, 0x28b, 0x2aa, 0x2ab, 0x2ca, 0x2cb, 0x2ea, 0x2eb, /* 580-587 */ 0x2ce, 0x2cf, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 588-58f */ 0x29a, 0x29b, 0x2ba, 0x2bb, 0x2da, 0x2db, 0x2fa, 0x2fb, /* 590-597 */ 0x2de, 0x2df, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 598-59f */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 5a0-5a7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 5a8-5af */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 5b0-5b7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 5b8-5bf */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 5c0-5c7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 5c8-5cf */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 5d0-5d7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 5d8-5df */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 5e0-5e7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 5e8-5ef */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 5f0-5f7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 5f8-5ff */ 0x300, 0x301, 0x302, 0x303, 0x304, 0x305, 0x306, 0x307, /* 600-607 */ 0x308, 0x309, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 608-60f */ 0x310, 0x311, 0x312, 0x313, 0x314, 0x315, 0x316, 0x317, /* 610-617 */ 0x318, 0x319, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 618-61f */ 0x320, 0x321, 0x322, 0x323, 0x324, 0x325, 0x326, 0x327, /* 620-627 */ 0x328, 0x329, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 628-62f */ 0x330, 0x331, 0x332, 0x333, 0x334, 0x335, 0x336, 0x337, /* 630-637 */ 0x338, 0x339, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 638-63f */ 0x340, 0x341, 0x342, 0x343, 0x344, 0x345, 0x346, 0x347, /* 640-647 */ 0x348, 0x349, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 648-64f */ 0x350, 0x351, 0x352, 0x353, 0x354, 0x355, 0x356, 0x357, /* 650-657 */ 0x358, 0x359, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 658-65f */ 0x360, 0x361, 0x362, 0x363, 0x364, 0x365, 0x366, 0x367, /* 660-667 */ 0x368, 0x369, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 668-66f */ 0x370, 0x371, 0x372, 0x373, 0x374, 0x375, 0x376, 0x377, /* 670-677 */ 0x378, 0x379, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 678-67f */ 0x30a, 0x30b, 0x32a, 0x32b, 0x34a, 0x34b, 0x36a, 0x36b, /* 680-687 */ 0x34e, 0x34f, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 688-68f */ 0x31a, 0x31b, 0x33a, 0x33b, 0x35a, 0x35b, 0x37a, 0x37b, /* 690-697 */ 0x35e, 0x35f, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 698-69f */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 6a0-6a7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 6a8-6af */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 6b0-6b7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 6b8-6bf */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 6c0-6c7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 6c8-6cf */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 6d0-6d7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 6d8-6df */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 6e0-6e7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 6e8-6ef */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 6f0-6f7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 6f8-6ff */ 0x380, 0x381, 0x382, 0x383, 0x384, 0x385, 0x386, 0x387, /* 700-707 */ 0x388, 0x389, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 708-70f */ 0x390, 0x391, 0x392, 0x393, 0x394, 0x395, 0x396, 0x397, /* 710-717 */ 0x398, 0x399, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 718-71f */ 0x3a0, 0x3a1, 0x3a2, 0x3a3, 0x3a4, 0x3a5, 0x3a6, 0x3a7, /* 720-727 */ 0x3a8, 0x3a9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 728-72f */ 0x3b0, 0x3b1, 0x3b2, 0x3b3, 0x3b4, 0x3b5, 0x3b6, 0x3b7, /* 730-737 */ 0x3b8, 0x3b9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 738-73f */ 0x3c0, 0x3c1, 0x3c2, 0x3c3, 0x3c4, 0x3c5, 0x3c6, 0x3c7, /* 740-747 */ 0x3c8, 0x3c9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 748-74f */ 0x3d0, 0x3d1, 0x3d2, 0x3d3, 0x3d4, 0x3d5, 0x3d6, 0x3d7, /* 750-757 */ 0x3d8, 0x3d9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 758-75f */ 0x3e0, 0x3e1, 0x3e2, 0x3e3, 0x3e4, 0x3e5, 0x3e6, 0x3e7, /* 760-767 */ 0x3e8, 0x3e9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 768-76f */ 0x3f0, 0x3f1, 0x3f2, 0x3f3, 0x000, 0x3f5, 0x3f6, 0x3f7, /* 770-777 */ 0x3f8, 0x3f9, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 778-77f */ 0x38a, 0x38b, 0x3aa, 0x3ab, 0x3ca, 0x3cb, 0x3ea, 0x3eb, /* 780-787 */ 0x3ce, 0x3cf, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 788-78f */ 0x39a, 0x39b, 0x3ba, 0x3bb, 0x3da, 0x3db, 0x3fa, 0x3fb, /* 790-797 */ 0x3de, 0x3df, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 798-79f */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 7a0-7a7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 7a8-7af */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 7b0-7b7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 7b8-7bf */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 7c0-7c7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 7c8-7cf */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 7d0-7d7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 7d8-7df */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 7e0-7e7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 7e8-7ef */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 7f0-7f7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 7f8-7ff */ 0x00c, 0x00d, 0x10c, 0x10d, 0x20c, 0x20d, 0x30c, 0x30d, /* 800-807 */ 0x02e, 0x02f, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 808-80f */ 0x01c, 0x01d, 0x11c, 0x11d, 0x21c, 0x21d, 0x31c, 0x31d, /* 810-817 */ 0x03e, 0x03f, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 818-81f */ 0x02c, 0x02d, 0x12c, 0x12d, 0x22c, 0x22d, 0x32c, 0x32d, /* 820-827 */ 0x12e, 0x12f, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 828-82f */ 0x03c, 0x03d, 0x13c, 0x13d, 0x23c, 0x23d, 0x33c, 0x33d, /* 830-837 */ 0x13e, 0x13f, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 838-83f */ 0x04c, 0x04d, 0x14c, 0x14d, 0x24c, 0x24d, 0x34c, 0x34d, /* 840-847 */ 0x22e, 0x22f, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 848-84f */ 0x05c, 0x05d, 0x15c, 0x15d, 0x25c, 0x25d, 0x35c, 0x35d, /* 850-857 */ 0x23e, 0x23f, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 858-85f */ 0x06c, 0x06d, 0x16c, 0x16d, 0x26c, 0x26d, 0x36c, 0x36d, /* 860-867 */ 0x32e, 0x32f, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 868-86f */ 0x07c, 0x07d, 0x17c, 0x17d, 0x27c, 0x27d, 0x37c, 0x37d, /* 870-877 */ 0x33e, 0x33f, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 878-87f */ 0x00e, 0x00f, 0x10e, 0x10f, 0x20e, 0x20f, 0x30e, 0x30f, /* 880-887 */ 0x06e, 0x06f, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 888-88f */ 0x01e, 0x01f, 0x11e, 0x11f, 0x21e, 0x21f, 0x31e, 0x31f, /* 890-897 */ 0x07e, 0x07f, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 898-89f */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 8a0-8a7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 8a8-8af */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 8b0-8b7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 8b8-8bf */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 8c0-8c7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 8c8-8cf */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 8d0-8d7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 8d8-8df */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 8e0-8e7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 8e8-8ef */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 8f0-8f7 */ 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 8f8-8ff */ 0x08c, 0x08d, 0x18c, 0x18d, 0x28c, 0x28d, 0x38c, 0x38d, /* 900-907 */ 0x0ae, 0x0af, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 908-90f */ 0x09c, 0x09d, 0x19c, 0x19d, 0x29c, 0x29d, 0x39c, 0x39d, /* 910-917 */ 0x0be, 0x0bf, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 918-91f */ 0x0ac, 0x0ad, 0x1ac, 0x1ad, 0x2ac, 0x2ad, 0x3ac, 0x3ad, /* 920-927 */ 0x1ae, 0x1af, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 928-92f */ 0x0bc, 0x0bd, 0x1bc, 0x1bd, 0x2bc, 0x2bd, 0x3bc, 0x3bd, /* 930-937 */ 0x1be, 0x1bf, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 938-93f */ 0x0cc, 0x0cd, 0x1cc, 0x1cd, 0x2cc, 0x2cd, 0x3cc, 0x3cd, /* 940-947 */ 0x2ae, 0x2af, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 948-94f */ 0x0dc, 0x0dd, 0x1dc, 0x1dd, 0x2dc, 0x2dd, 0x3dc, 0x3dd, /* 950-957 */ 0x2be, 0x2bf, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 958-95f */ 0x0ec, 0x0ed, 0x1ec, 0x1ed, 0x2ec, 0x2ed, 0x3ec, 0x3ed, /* 960-967 */ 0x3ae, 0x3af, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 968-96f */ 0x0fc, 0x0fd, 0x1fc, 0x1fd, 0x3f4, 0x2fd, 0x3fc, 0x3fd, /* 970-977 */ 0x3be, 0x3bf, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 978-97f */ 0x08e, 0x08f, 0x18e, 0x18f, 0x28e, 0x28f, 0x38e, 0x38f, /* 980-987 */ 0x0ee, 0x0ef, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 988-98f */ 0x09e, 0x09f, 0x19e, 0x19f, 0x29e, 0x29f, 0x39e, 0x39f, /* 990-997 */ 0x0fe, 0x0ff, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, /* 998-99f */ }; extern void __get_dpd_digits (int bits, const void *const *args, char *str, int *exp_p, int *sign_p, int *nan_p, int *inf_p); void __get_dpd_digits (int bits, const void *const *args, char *str, int *exp_p, int *sign_p, int *nan_p, int *inf_p) { int exp = 0; struct ieee754r_c_field c_f; if (bits == 32) { union ieee754r_Decimal32 d; d.sd = *(_Decimal32*)args[0]; c_f = c_decoder[d.ieee.c]; exp = c_f.lm_exp << DECIMAL32_BEC_bits; exp += d.ieee.bec; exp -= DECIMAL32_Bias; __dpd_cpydeclet (str+1, dpd_to_char[d.ieee.cc0]); __dpd_cpydeclet (str+4, dpd_to_char[d.ieee.cc1]); str[7] = '\0'; if (sign_p) *sign_p = d.ieee.negative; } else if (bits == 64) { union ieee754r_Decimal64 d; d.dd = *(_Decimal64*)args[0]; c_f = c_decoder[d.ieee.c]; exp = c_f.lm_exp << DECIMAL64_BEC_bits; exp += d.ieee.bec; exp -= DECIMAL64_Bias; __dpd_cpydeclet (str+1, dpd_to_char[d.ieee.cc0]); /* Packed fields crossing a word boundary require special handling. */ __dpd_cpydeclet (str+4, dpd_to_char[(d.ieee.cc1H8<<2) + d.ieee.cc1L2]); __dpd_cpydeclet (str+7, dpd_to_char[d.ieee.cc2]); __dpd_cpydeclet (str+10, dpd_to_char[d.ieee.cc3]); __dpd_cpydeclet (str+13, dpd_to_char[d.ieee.cc4]); str[16] = '\0'; if (sign_p) *sign_p = d.ieee.negative; } //else if (bits == 128) else { union ieee754r_Decimal128 d; d.td = *(_Decimal128*)args[0]; c_f = c_decoder[d.ieee.c]; exp = c_f.lm_exp << DECIMAL128_BEC_bits; exp += d.ieee.bec; exp -= DECIMAL128_Bias; __dpd_cpydeclet (str+1, dpd_to_char[d.ieee.cc0]); /* Packed fields crossing a word boundary require special handling. */ __dpd_cpydeclet (str+4, dpd_to_char[(d.ieee.cc1H4<<6) + d.ieee.cc1L6]); __dpd_cpydeclet (str+7, dpd_to_char[d.ieee.cc2]); __dpd_cpydeclet (str+10, dpd_to_char[d.ieee.cc3]); __dpd_cpydeclet (str+13, dpd_to_char[(d.ieee.cc4H6<<4) + d.ieee.cc4L4]); __dpd_cpydeclet (str+16, dpd_to_char[d.ieee.cc5]); __dpd_cpydeclet (str+19, dpd_to_char[d.ieee.cc6]); __dpd_cpydeclet (str+22, dpd_to_char[(d.ieee.cc7H8<<2) + d.ieee.cc7L2]); __dpd_cpydeclet (str+25, dpd_to_char[d.ieee.cc8]); __dpd_cpydeclet (str+28, dpd_to_char[d.ieee.cc9]); __dpd_cpydeclet (str+31, dpd_to_char[d.ieee.cc10]); str[34] = '\0'; if (sign_p) *sign_p = d.ieee.negative; } str[0] = '0' + c_f.lmd; if (exp_p) *exp_p = exp; if (nan_p) *nan_p = c_f.is_nan; if (inf_p) *inf_p = c_f.is_inf; } void __get_digits_d32 (_Decimal32 x, char *str, int *exp_p, int *sign_p, int *nan_p, int *inf_p) { int exp = 0; struct ieee754r_c_field c_f; union ieee754r_Decimal32 d; d.sd = x; c_f = c_decoder[d.ieee.c]; /* Consider replacing with a call to getexp_d* for hardware support */ exp = c_f.lm_exp << DECIMAL32_BEC_bits; exp += d.ieee.bec; exp -= DECIMAL32_Bias; str[0] = '0' + c_f.lmd; __dpd_cpydeclet (str+1, dpd_to_char[d.ieee.cc0]); __dpd_cpydeclet (str+4, dpd_to_char[d.ieee.cc1]); str[7] = '\0'; if (sign_p) *sign_p = d.ieee.negative; if (exp_p) *exp_p = exp; if (nan_p) *nan_p = c_f.is_nan; if (inf_p) *inf_p = c_f.is_inf; } void __get_digits_d64 (_Decimal64 x, char *str, int *exp_p, int *sign_p, int *nan_p, int *inf_p) { int exp = 0; struct ieee754r_c_field c_f; union ieee754r_Decimal64 d; d.dd = x; c_f = c_decoder[d.ieee.c]; /* Consider replacing with a call to getexp_d* for hardware support */ exp = c_f.lm_exp << DECIMAL64_BEC_bits; exp += d.ieee.bec; exp -= DECIMAL64_Bias; str[0] = '0' + c_f.lmd; __dpd_cpydeclet (str+1, dpd_to_char[d.ieee.cc0]); /* Packed fields crossing a word boundary require special handling. */ __dpd_cpydeclet (str+4, dpd_to_char[(d.ieee.cc1H8<<2) + d.ieee.cc1L2]); __dpd_cpydeclet (str+7, dpd_to_char[d.ieee.cc2]); __dpd_cpydeclet (str+10, dpd_to_char[d.ieee.cc3]); __dpd_cpydeclet (str+13, dpd_to_char[d.ieee.cc4]); str[16] = '\0'; if (sign_p) *sign_p = d.ieee.negative; if (exp_p) *exp_p = exp; if (nan_p) *nan_p = c_f.is_nan; if (inf_p) *inf_p = c_f.is_inf; } void __get_digits_d128 (_Decimal128 x, char *str, int *exp_p, int *sign_p, int *nan_p, int *inf_p) { int exp = 0; struct ieee754r_c_field c_f; union ieee754r_Decimal128 d; d.td = x; c_f = c_decoder[d.ieee.c]; /* Consider replacing with a call to getexp_d* for hardware support */ exp = c_f.lm_exp << DECIMAL128_BEC_bits; exp += d.ieee.bec; exp -= DECIMAL128_Bias; str[0] = '0' + c_f.lmd; __dpd_cpydeclet (str+1, dpd_to_char[d.ieee.cc0]); /* Packed fields crossing a word boundary require special handling. */ __dpd_cpydeclet (str+4, dpd_to_char[(d.ieee.cc1H4<<6) + d.ieee.cc1L6]); __dpd_cpydeclet (str+7, dpd_to_char[d.ieee.cc2]); __dpd_cpydeclet (str+10, dpd_to_char[d.ieee.cc3]); __dpd_cpydeclet (str+13, dpd_to_char[(d.ieee.cc4H6<<4) + d.ieee.cc4L4]); __dpd_cpydeclet (str+16, dpd_to_char[d.ieee.cc5]); __dpd_cpydeclet (str+19, dpd_to_char[d.ieee.cc6]); __dpd_cpydeclet (str+22, dpd_to_char[(d.ieee.cc7H8<<2) + d.ieee.cc7L2]); __dpd_cpydeclet (str+25, dpd_to_char[d.ieee.cc8]); __dpd_cpydeclet (str+28, dpd_to_char[d.ieee.cc9]); __dpd_cpydeclet (str+31, dpd_to_char[d.ieee.cc10]); str[34] = '\0'; if (sign_p) *sign_p = d.ieee.negative; if (exp_p) *exp_p = exp; if (nan_p) *nan_p = c_f.is_nan; if (inf_p) *inf_p = c_f.is_inf; } libdfp-1.0.12/sysdeps/dpd/dpd-private.h000066400000000000000000000170701261375163000176750ustar00rootroot00000000000000/* Data types for DPD format output. Copyright (C) 2006, 2007 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steve Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #ifndef _DPD_PRIVATE_H #define _DPD_PRIVATE_H 1 #include /* copy the declet in the 'declet' param to the string in the 'str' param. */ static inline void __dpd_cpydeclet(char * str, const char * declet) { str[0] = declet[0]; str[1] = declet[1]; str[2] = declet[2]; } /* Basically itoa */ static inline char* __dpd_exptostr(char *str, int val) { int digit; if (val < 0) { *str++ = '-'; val = -val; } else { *str++ = '+'; } if (val > 999) { digit = val / 1000; val %= 1000; *str++ = '0' + digit; digit = val / 100; val %= 100; *str++ = '0' + digit; digit = val / 10; val %= 10; *str++ = '0' + digit; } else if (val > 99) { digit = val / 100; val %= 100; *str++ = '0' + digit; digit = val / 10; val %= 10; *str++ = '0' + digit; } else if (val > 9) { digit = val / 10; val %= 10; *str++ = '0' + digit; } *str++ = '0' + val; return str; } union ieee754r_Decimal32 { _Decimal32 sd; unsigned int si; /* This is the IEEE754r single-precision format. */ struct { #if __BYTE_ORDER == __BIG_ENDIAN unsigned int negative:1; unsigned int c:5; unsigned int bec:6; unsigned int cc0:10; unsigned int cc1:10; #endif /* Big endian. */ #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int cc1:10; unsigned int cc0:10; unsigned int bec:6; unsigned int c:5; unsigned int negative:1; #endif /* Little endian. */ } ieee; /* This format makes it easier to see if a NaN is a signalling NaN. */ struct { #if __BYTE_ORDER == __BIG_ENDIAN unsigned int negative:1; unsigned int c:5; unsigned int signaling_nan:1; unsigned int bec:5; unsigned int cc0:10; unsigned int cc1:10; #endif /* Big endian. */ #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int cc1:10; unsigned int cc0:10; unsigned int bec:5; unsigned int signaling_nan:1; unsigned int c:5; unsigned int negative:1; #endif /* Little endian. */ } ieee_nan; }; #define DECIMAL32_Bias 101 /* bias for the exponent */ #define DECIMAL32_BEC_bits 6 /* Bits in BEC */ #define DECIMAL32_CC_bits 20 /* Bits in CC */ union ieee754r_Decimal64 { _Decimal64 dd; unsigned int di[2]; /* This is the IEEE754r _Decimal64 format. */ struct { #if __BYTE_ORDER == __BIG_ENDIAN unsigned int negative:1; unsigned int c:5; unsigned int bec:8; unsigned int cc0:10; unsigned int cc1H8:8; unsigned int cc1L2:2; unsigned int cc2:10; unsigned int cc3:10; unsigned int cc4:10; #endif /* Big endian. */ #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int cc4:10; unsigned int cc3:10; unsigned int cc2:10; unsigned int cc1L2:2; unsigned int cc1H8:8; unsigned int cc0:10; unsigned int bec:8; unsigned int c:5; unsigned int negative:1; #endif /* Little endian. */ } ieee; /* This format makes it easier to see if a NaN is a signalling NaN. */ struct { #if __BYTE_ORDER == __BIG_ENDIAN unsigned int negative:1; unsigned int c:5; unsigned int signaling_nan:1; unsigned int bec:7; unsigned int cc0:10; unsigned int cc1H8:8; unsigned int cc1L2:2; unsigned int cc2:10; unsigned int cc3:10; unsigned int cc4:10; #endif /* Big endian. */ #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int cc4:10; unsigned int cc3:10; unsigned int cc2:10; unsigned int cc1L2:2; unsigned int cc1H8:8; unsigned int cc0:10; unsigned int bec:7; unsigned int signaling_nan:1; unsigned int c:5; unsigned int negative:1; #endif /* Little endian. */ } ieee_nan; }; #define DECIMAL64_Bias 398 /* bias for the exponent */ #define DECIMAL64_BEC_bits 8 /* Bits in BEC */ #define DECIMAL64_CC_bits 50 /* Bits in CC */ union ieee754r_Decimal128 { _Decimal128 td; unsigned int ti[4]; /* This is the IEEE754r _Decimal128 format. */ struct { #if __BYTE_ORDER == __BIG_ENDIAN unsigned int negative:1; unsigned int c:5; unsigned int bec:12; unsigned int cc0:10; unsigned int cc1H4:4; unsigned int cc1L6:6; unsigned int cc2:10; unsigned int cc3:10; unsigned int cc4H6:6; unsigned int cc4L4:4; unsigned int cc5:10; unsigned int cc6:10; unsigned int cc7H8:8; unsigned int cc7L2:2; unsigned int cc8:10; unsigned int cc9:10; unsigned int cc10:10; #endif /* Big endian. */ #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int cc10:10; unsigned int cc9:10; unsigned int cc8:10; unsigned int cc7L2:2; unsigned int cc7H8:8; unsigned int cc6:10; unsigned int cc5:10; unsigned int cc4L4:4; unsigned int cc4H6:6; unsigned int cc3:10; unsigned int cc2:10; unsigned int cc1L6:6; unsigned int cc1H4:4; unsigned int cc0:10; unsigned int bec:12; unsigned int c:5; unsigned int negative:1; #endif /* Little endian. */ } ieee; /* This format makes it easier to see if a NaN is a signalling NaN. */ struct { #if __BYTE_ORDER == __BIG_ENDIAN unsigned int negative:1; unsigned int c:5; unsigned int signaling_nan:1; unsigned int bec:11; unsigned int cc0:10; unsigned int cc1H4:4; unsigned int cc1L6:6; unsigned int cc2:10; unsigned int cc3:10; unsigned int cc4H6:6; unsigned int cc4L4:4; unsigned int cc5:10; unsigned int cc6:10; unsigned int cc7H8:8; unsigned int cc7L2:2; unsigned int cc8:10; unsigned int cc9:10; unsigned int cc10:10; #endif /* Big endian. */ #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int cc10:10; unsigned int cc9:10; unsigned int cc8:10; unsigned int cc7L2:2; unsigned int cc7H8:8; unsigned int cc6:10; unsigned int cc5:10; unsigned int cc4L4:4; unsigned int cc4H6:6; unsigned int cc3:10; unsigned int cc2:10; unsigned int cc1L6:6; unsigned int cc1H4:4; unsigned int cc0:10; unsigned int bec:11; unsigned int signaling_nan:1; unsigned int c:5; unsigned int negative:1; #endif /* Little endian. */ } ieee_nan; }; #define DECIMAL128_Bias 6176 /* bias for the exponent */ #define DECIMAL128_BEC_bits 12 /* Bits in BEC */ #define DECIMAL128_CC_bits 110 /* Bits in CC */ struct ieee754r_c_field { unsigned int is_nan:1; unsigned int is_inf:1; unsigned int lm_exp:2; unsigned int lmd:4; }; extern const struct ieee754r_c_field c_decoder[32]; extern const unsigned char lm2lmd_to_c[10][4]; extern const char dpd_to_char[1024][4]; extern const const short int dpd_to_bcd[1024]; extern const short int bcd_to_dpd[2464]; static inline unsigned int __dfp_declet_to_dpd(char *str) { return bcd_to_dpd[(str[0]<<8) + (str[1]<<4) + str[2] - '0'*0x111]; } #endif /* _DPD_PRIVATE */ libdfp-1.0.12/sysdeps/dpd/symbol-hacks.h000066400000000000000000000066231261375163000200540ustar00rootroot00000000000000/* Hacks for symbol bindings. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #if !defined __ASSEMBLER__ && !defined NOT_IN_libdfp && defined SHARED /* GCC generates intrisics calls to some functions for _Decimal to/from convertions. These bindings avoids intra library PLT calls generations, since libdfp provides such symbols. */ asm ("__dpd_floatsidd = __GI___dpd_floatsidd"); asm ("__dpd_floatditd = __GI___dpd_floatditd"); asm ("__dpd_floatsitd = __GI___dpd_floatsitd"); asm ("__dpd_floatdidd = __GI___dpd_floatdidd"); asm ("__dpd_floatsisd = __GI___dpd_floatsisd"); asm ("__dpd_trunctddd2 = __GI___dpd_trunctddd2"); asm ("__dpd_truncddsd2 = __GI___dpd_truncddsd2"); asm ("__dpd_extendsddf = __GI___dpd_extendsddf"); asm ("__dpd_extenddfdd = __GI___dpd_extenddfdd"); asm ("__dpd_extenddftd = __GI___dpd_extenddftd"); asm ("__dpd_extendsdtd2 = __GI___dpd_extendsdtd2"); asm ("__dpd_extendsddd2 = __GI___dpd_extendsddd2"); asm ("__dpd_extendddtd2 = __GI___dpd_extendddtd2"); asm ("__dpd_truncdddf = __GI___dpd_truncdddf"); asm ("__dpd_trunctddf = __GI___dpd_trunctddf"); asm ("__dpd_truncdfsd = __GI___dpd_truncdfsd"); asm ("__dpd_trunctdsd2 = __GI___dpd_trunctdsd2"); asm ("__dpd_fixddsi = __GI___dpd_fixddsi"); asm ("__dpd_fixsdsi = __GI___dpd_fixsdsi"); asm ("__dpd_fixdddi = __GI___dpd_fixdddi"); asm ("__dpd_fixtdsi = __GI___dpd_fixtdsi"); asm ("__dpd_fixsddi = __GI___dpd_fixsddi"); asm ("__dpd_fixtddi = __GI___dpd_fixtddi"); asm ("__dpd_addsd3 = __GI___dpd_addsd3"); asm ("__dpd_addtd3 = __GI___dpd_addtd3"); asm ("__dpd_adddd3 = __GI___dpd_adddd3"); asm ("__dpd_subdd3 = __GI___dpd_subdd3"); asm ("__dpd_subsd3 = __GI___dpd_subsd3"); asm ("__dpd_subtd3 = __GI___dpd_subtd3"); asm ("__dpd_divsd3 = __GI___dpd_divsd3"); asm ("__dpd_divtd3 = __GI___dpd_divtd3"); asm ("__dpd_divdd3 = __GI___dpd_divdd3"); asm ("__dpd_mulsd3 = __GI___dpd_mulsd3"); asm ("__dpd_multd3 = __GI___dpd_multd3"); asm ("__dpd_muldd3 = __GI___dpd_muldd3"); asm ("__dpd_gtdd2 = __GI___dpd_gtdd2"); asm ("__dpd_gtds2 = __GI___dpd_gtsd2"); asm ("__dpd_gtdt2 = __GI___dpd_gttd2"); asm ("__dpd_eqdd2 = __GI___dpd_eqdd2"); asm ("__dpd_eqsd2 = __GI___dpd_eqsd2"); asm ("__dpd_eqtd2 = __GI___dpd_eqtd2"); asm ("__dpd_ltdd2 = __GI___dpd_ltdd2"); asm ("__dpd_ltsd2 = __GI___dpd_ltsd2"); asm ("__dpd_lttd2 = __GI___dpd_lttd2"); asm ("__dpd_gtsd2 = __GI___dpd_gtsd2"); asm ("__dpd_gttd2 = __GI___dpd_gttd2"); asm ("__dpd_letd2 = __GI___dpd_letd2"); asm ("__dpd_getd2 = __GI___dpd_getd2"); asm ("__dpd_netd2 = __GI___dpd_netd2"); asm ("__dpd_nesd2 = __GI___dpd_nesd2"); asm ("__dpd_nedd2 = __GI___dpd_nedd2"); #endif libdfp-1.0.12/sysdeps/generic/000077500000000000000000000000001261375163000161455ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/generic/binpowof10.c000066400000000000000000000247251261375163000203070ustar00rootroot00000000000000/* Table to ease conversion of exponants from decimal to binary format Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steve Munroe The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ const long double binpowof10 [] = { 1e+00L, /* 10**0 */ 1e+01L, /* 10**1 */ 1e+02L, /* 10**2 */ 1e+03L, /* 10**3 */ 1e+04L, /* 10**4 */ 1e+05L, /* 10**5 */ 1e+06L, /* 10**6 */ 1e+07L, /* 10**7 */ 1e+08L, /* 10**8 */ 1e+09L, /* 10**9 */ 1e+10L, /* 10**10 */ 1e+11L, /* 10**11 */ 1e+12L, /* 10**12 */ 1e+13L, /* 10**13 */ 1e+14L, /* 10**14 */ 1e+15L, /* 10**15 */ 1e+16L, /* 10**16 */ 1e+17L, /* 10**17 */ 1e+18L, /* 10**18 */ 1e+19L, /* 10**19 */ 1e+20L, /* 10**20 */ 1e+21L, /* 10**21 */ 1e+22L, /* 10**22 */ 1e+23L, /* 10**23 */ 1e+24L, /* 10**24 */ 1e+25L, /* 10**25 */ 1e+26L, /* 10**26 */ 1e+27L, /* 10**27 */ 1e+28L, /* 10**28 */ 1e+29L, /* 10**29 */ 1e+30L, /* 10**30 */ 1e+31L, /* 10**31 */ 1e+32L, /* 10**32 */ 1e+33L, /* 10**33 */ 1e+34L, /* 10**34 */ 1e+35L, /* 10**35 */ 1e+36L, /* 10**36 */ 1e+37L, /* 10**37 */ 1e+38L, /* 10**38 */ 1e+39L, /* 10**39 */ 1e+40L, /* 10**40 */ 1e+41L, /* 10**41 */ 1e+42L, /* 10**42 */ 1e+43L, /* 10**43 */ 1e+44L, /* 10**44 */ 1e+45L, /* 10**45 */ 1e+46L, /* 10**46 */ 1e+47L, /* 10**47 */ 1e+48L, /* 10**48 */ 1e+49L, /* 10**49 */ 1e+50L, /* 10**50 */ 1e+51L, /* 10**51 */ 1e+52L, /* 10**52 */ 1e+53L, /* 10**53 */ 1e+54L, /* 10**54 */ 1e+55L, /* 10**55 */ 1e+56L, /* 10**56 */ 1e+57L, /* 10**57 */ 1e+58L, /* 10**58 */ 1e+59L, /* 10**59 */ 1e+60L, /* 10**60 */ 1e+61L, /* 10**61 */ 1e+62L, /* 10**62 */ 1e+63L, /* 10**63 */ 1e+64L, /* 10**64 */ 1e+65L, /* 10**65 */ 1e+66L, /* 10**66 */ 1e+67L, /* 10**67 */ 1e+68L, /* 10**68 */ 1e+69L, /* 10**69 */ 1e+70L, /* 10**70 */ 1e+71L, /* 10**71 */ 1e+72L, /* 10**72 */ 1e+73L, /* 10**73 */ 1e+74L, /* 10**74 */ 1e+75L, /* 10**75 */ 1e+76L, /* 10**76 */ 1e+77L, /* 10**77 */ 1e+78L, /* 10**78 */ 1e+79L, /* 10**79 */ 1e+80L, /* 10**80 */ 1e+81L, /* 10**81 */ 1e+82L, /* 10**82 */ 1e+83L, /* 10**83 */ 1e+84L, /* 10**84 */ 1e+85L, /* 10**85 */ 1e+86L, /* 10**86 */ 1e+87L, /* 10**87 */ 1e+88L, /* 10**88 */ 1e+89L, /* 10**89 */ 1e+90L, /* 10**90 */ 1e+91L, /* 10**91 */ 1e+92L, /* 10**92 */ 1e+93L, /* 10**93 */ 1e+94L, /* 10**94 */ 1e+95L, /* 10**95 */ 1e+96L, /* 10**96 */ 1e+97L, /* 10**97 */ 1e+98L, /* 10**98 */ 1e+99L, /* 10**99 */ 1e+100L, /* 10**100 */ 1e+101L, /* 10**101 */ 1e+102L, /* 10**102 */ 1e+103L, /* 10**103 */ 1e+104L, /* 10**104 */ 1e+105L, /* 10**105 */ 1e+106L, /* 10**106 */ 1e+107L, /* 10**107 */ 1e+108L, /* 10**108 */ 1e+109L, /* 10**109 */ 1e+110L, /* 10**110 */ 1e+111L, /* 10**111 */ 1e+112L, /* 10**112 */ 1e+113L, /* 10**113 */ 1e+114L, /* 10**114 */ 1e+115L, /* 10**115 */ 1e+116L, /* 10**116 */ 1e+117L, /* 10**117 */ 1e+118L, /* 10**118 */ 1e+119L, /* 10**119 */ 1e+120L, /* 10**120 */ 1e+121L, /* 10**121 */ 1e+122L, /* 10**122 */ 1e+123L, /* 10**123 */ 1e+124L, /* 10**124 */ 1e+125L, /* 10**125 */ 1e+126L, /* 10**126 */ 1e+127L, /* 10**127 */ 1e+128L, /* 10**128 */ 1e+129L, /* 10**129 */ 1e+130L, /* 10**130 */ 1e+131L, /* 10**131 */ 1e+132L, /* 10**132 */ 1e+133L, /* 10**133 */ 1e+134L, /* 10**134 */ 1e+135L, /* 10**135 */ 1e+136L, /* 10**136 */ 1e+137L, /* 10**137 */ 1e+138L, /* 10**138 */ 1e+139L, /* 10**139 */ 1e+140L, /* 10**140 */ 1e+141L, /* 10**141 */ 1e+142L, /* 10**142 */ 1e+143L, /* 10**143 */ 1e+144L, /* 10**144 */ 1e+145L, /* 10**145 */ 1e+146L, /* 10**146 */ 1e+147L, /* 10**147 */ 1e+148L, /* 10**148 */ 1e+149L, /* 10**149 */ 1e+150L, /* 10**150 */ 1e+151L, /* 10**151 */ 1e+152L, /* 10**152 */ 1e+153L, /* 10**153 */ 1e+154L, /* 10**154 */ 1e+155L, /* 10**155 */ 1e+156L, /* 10**156 */ 1e+157L, /* 10**157 */ 1e+158L, /* 10**158 */ 1e+159L, /* 10**159 */ 1e+160L, /* 10**160 */ 1e+161L, /* 10**161 */ 1e+162L, /* 10**162 */ 1e+163L, /* 10**163 */ 1e+164L, /* 10**164 */ 1e+165L, /* 10**165 */ 1e+166L, /* 10**166 */ 1e+167L, /* 10**167 */ 1e+168L, /* 10**168 */ 1e+169L, /* 10**169 */ 1e+170L, /* 10**170 */ 1e+171L, /* 10**171 */ 1e+172L, /* 10**172 */ 1e+173L, /* 10**173 */ 1e+174L, /* 10**174 */ 1e+175L, /* 10**175 */ 1e+176L, /* 10**176 */ 1e+177L, /* 10**177 */ 1e+178L, /* 10**178 */ 1e+179L, /* 10**179 */ 1e+180L, /* 10**180 */ 1e+181L, /* 10**181 */ 1e+182L, /* 10**182 */ 1e+183L, /* 10**183 */ 1e+184L, /* 10**184 */ 1e+185L, /* 10**185 */ 1e+186L, /* 10**186 */ 1e+187L, /* 10**187 */ 1e+188L, /* 10**188 */ 1e+189L, /* 10**189 */ 1e+190L, /* 10**190 */ 1e+191L, /* 10**191 */ 1e+192L, /* 10**192 */ 1e+193L, /* 10**193 */ 1e+194L, /* 10**194 */ 1e+195L, /* 10**195 */ 1e+196L, /* 10**196 */ 1e+197L, /* 10**197 */ 1e+198L, /* 10**198 */ 1e+199L, /* 10**199 */ 1e+200L, /* 10**200 */ 1e+201L, /* 10**201 */ 1e+202L, /* 10**202 */ 1e+203L, /* 10**203 */ 1e+204L, /* 10**204 */ 1e+205L, /* 10**205 */ 1e+206L, /* 10**206 */ 1e+207L, /* 10**207 */ 1e+208L, /* 10**208 */ 1e+209L, /* 10**209 */ 1e+210L, /* 10**210 */ 1e+211L, /* 10**211 */ 1e+212L, /* 10**212 */ 1e+213L, /* 10**213 */ 1e+214L, /* 10**214 */ 1e+215L, /* 10**215 */ 1e+216L, /* 10**216 */ 1e+217L, /* 10**217 */ 1e+218L, /* 10**218 */ 1e+219L, /* 10**219 */ 1e+220L, /* 10**220 */ 1e+221L, /* 10**221 */ 1e+222L, /* 10**222 */ 1e+223L, /* 10**223 */ 1e+224L, /* 10**224 */ 1e+225L, /* 10**225 */ 1e+226L, /* 10**226 */ 1e+227L, /* 10**227 */ 1e+228L, /* 10**228 */ 1e+229L, /* 10**229 */ 1e+230L, /* 10**230 */ 1e+231L, /* 10**231 */ 1e+232L, /* 10**232 */ 1e+233L, /* 10**233 */ 1e+234L, /* 10**234 */ 1e+235L, /* 10**235 */ 1e+236L, /* 10**236 */ 1e+237L, /* 10**237 */ 1e+238L, /* 10**238 */ 1e+239L, /* 10**239 */ 1e+240L, /* 10**240 */ 1e+241L, /* 10**241 */ 1e+242L, /* 10**242 */ 1e+243L, /* 10**243 */ 1e+244L, /* 10**244 */ 1e+245L, /* 10**245 */ 1e+246L, /* 10**246 */ 1e+247L, /* 10**247 */ 1e+248L, /* 10**248 */ 1e+249L, /* 10**249 */ 1e+250L, /* 10**250 */ 1e+251L, /* 10**251 */ 1e+252L, /* 10**252 */ 1e+253L, /* 10**253 */ 1e+254L, /* 10**254 */ 1e+255L, /* 10**255 */ 1e+256L, /* 10**256 */ 1e+257L, /* 10**257 */ 1e+258L, /* 10**258 */ 1e+259L, /* 10**259 */ 1e+260L, /* 10**260 */ 1e+261L, /* 10**261 */ 1e+262L, /* 10**262 */ 1e+263L, /* 10**263 */ 1e+264L, /* 10**264 */ 1e+265L, /* 10**265 */ 1e+266L, /* 10**266 */ 1e+267L, /* 10**267 */ 1e+268L, /* 10**268 */ 1e+269L, /* 10**269 */ 1e+270L, /* 10**270 */ 1e+271L, /* 10**271 */ 1e+272L, /* 10**272 */ 1e+273L, /* 10**273 */ 1e+274L, /* 10**274 */ 1e+275L, /* 10**275 */ 1e+276L, /* 10**276 */ 1e+277L, /* 10**277 */ 1e+278L, /* 10**278 */ 1e+279L, /* 10**279 */ 1e+280L, /* 10**280 */ 1e+281L, /* 10**281 */ 1e+282L, /* 10**282 */ 1e+283L, /* 10**283 */ 1e+284L, /* 10**284 */ 1e+285L, /* 10**285 */ 1e+286L, /* 10**286 */ 1e+287L, /* 10**287 */ 1e+288L, /* 10**288 */ 1e+289L, /* 10**289 */ 1e+290L, /* 10**290 */ 1e+291L, /* 10**291 */ 1e+292L, /* 10**292 */ 1e+293L, /* 10**293 */ 1e+294L, /* 10**294 */ 1e+295L, /* 10**295 */ 1e+296L, /* 10**296 */ 1e+297L, /* 10**297 */ 1e+298L, /* 10**298 */ 1e+299L, /* 10**299 */ 1e+300L, /* 10**300 */ 1e+301L, /* 10**301 */ 1e+302L, /* 10**302 */ 1e+303L, /* 10**303 */ 1e+304L, /* 10**304 */ 1e+305L, /* 10**305 */ 1e+306L, /* 10**306 */ 1e+307L, /* 10**307 */ 1e+308L};/* 10**308 */ /* Long Double only supports exponent up to 308. */ /* Is this really necessary? */ /* weak_alias(binpowof10, __dfp_binpowof10) */ libdfp-1.0.12/sysdeps/generic/decpowof2.c000066400000000000000000001702211261375163000202040ustar00rootroot00000000000000/* Table to ease conversion from binary to decimal formats Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steve Munroe The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ /* Table of decimal powers of 2 from 0 to 1076. Only positive powers of * 2 are needed as negative exponents are handled via divide. Entries * 1023-1076 are required to handle denormal doubles (-1022 - 54) */ const _Decimal128 decpowof2 [] = { 1.0E+0DL, /* 2**0 */ 2.0E+0DL, /* 2**1 */ 4.0E+0DL, /* 2**2 */ 8.0E+0DL, /* 2**3 */ 1.6E+1DL, /* 2**4 */ 3.2E+1DL, /* 2**5 */ 6.4E+1DL, /* 2**6 */ 1.28E+2DL, /* 2**7 */ 2.56E+2DL, /* 2**8 */ 5.12E+2DL, /* 2**9 */ 1.024E+3DL, /* 2**10 */ 2.048E+3DL, /* 2**11 */ 4.096E+3DL, /* 2**12 */ 8.192E+3DL, /* 2**13 */ 1.6384E+4DL, /* 2**14 */ 3.2768E+4DL, /* 2**15 */ 6.5536E+4DL, /* 2**16 */ 1.31072E+5DL, /* 2**17 */ 2.62144E+5DL, /* 2**18 */ 5.24288E+5DL, /* 2**19 */ 1.048576E+6DL, /* 2**20 */ 2.097152E+6DL, /* 2**21 */ 4.194304E+6DL, /* 2**22 */ 8.388608E+6DL, /* 2**23 */ 1.6777216E+7DL, /* 2**24 */ 3.3554432E+7DL, /* 2**25 */ 6.7108864E+7DL, /* 2**26 */ 1.34217728E+8DL, /* 2**27 */ 2.68435456E+8DL, /* 2**28 */ 5.36870912E+8DL, /* 2**29 */ 1.073741824E+9DL, /* 2**30 */ 2.147483648E+9DL, /* 2**31 */ 4.294967296E+9DL, /* 2**32 */ 8.589934592E+9DL, /* 2**33 */ 1.7179869184E+10DL, /* 2**34 */ 3.4359738368E+10DL, /* 2**35 */ 6.8719476736E+10DL, /* 2**36 */ 1.37438953472E+11DL, /* 2**37 */ 2.74877906944E+11DL, /* 2**38 */ 5.49755813888E+11DL, /* 2**39 */ 1.099511627776E+12DL, /* 2**40 */ 2.199023255552E+12DL, /* 2**41 */ 4.398046511104E+12DL, /* 2**42 */ 8.796093022208E+12DL, /* 2**43 */ 1.7592186044416E+13DL, /* 2**44 */ 3.5184372088832E+13DL, /* 2**45 */ 7.0368744177664E+13DL, /* 2**46 */ 1.40737488355328E+14DL, /* 2**47 */ 2.81474976710656E+14DL, /* 2**48 */ 5.62949953421312E+14DL, /* 2**49 */ 1.125899906842624E+15DL, /* 2**50 */ 2.251799813685248E+15DL, /* 2**51 */ 4.503599627370496E+15DL, /* 2**52 */ 9.007199254740992E+15DL, /* 2**53 */ 1.8014398509481984E+16DL, /* 2**54 */ 3.6028797018963968E+16DL, /* 2**55 */ 7.2057594037927936E+16DL, /* 2**56 */ 1.44115188075855872E+17DL, /* 2**57 */ 2.88230376151711744E+17DL, /* 2**58 */ 5.76460752303423488E+17DL, /* 2**59 */ 1.152921504606846976E+18DL, /* 2**60 */ 2.305843009213693952E+18DL, /* 2**61 */ 4.611686018427387904E+18DL, /* 2**62 */ 9.223372036854775808E+18DL, /* 2**63 */ 1.8446744073709551616E+19DL, /* 2**64 */ 3.6893488147419103232E+19DL, /* 2**65 */ 7.3786976294838206464E+19DL, /* 2**66 */ 1.47573952589676412928E+20DL, /* 2**67 */ 2.95147905179352825856E+20DL, /* 2**68 */ 5.90295810358705651712E+20DL, /* 2**69 */ 1.180591620717411303424E+21DL, /* 2**70 */ 2.361183241434822606848E+21DL, /* 2**71 */ 4.722366482869645213696E+21DL, /* 2**72 */ 9.444732965739290427392E+21DL, /* 2**73 */ 1.8889465931478580854784E+22DL, /* 2**74 */ 3.7778931862957161709568E+22DL, /* 2**75 */ 7.5557863725914323419136E+22DL, /* 2**76 */ 1.51115727451828646838272E+23DL, /* 2**77 */ 3.02231454903657293676544E+23DL, /* 2**78 */ 6.04462909807314587353088E+23DL, /* 2**79 */ 1.208925819614629174706176E+24DL, /* 2**80 */ 2.417851639229258349412352E+24DL, /* 2**81 */ 4.835703278458516698824704E+24DL, /* 2**82 */ 9.671406556917033397649408E+24DL, /* 2**83 */ 1.9342813113834066795298816E+25DL, /* 2**84 */ 3.8685626227668133590597632E+25DL, /* 2**85 */ 7.7371252455336267181195264E+25DL, /* 2**86 */ 1.54742504910672534362390528E+26DL, /* 2**87 */ 3.09485009821345068724781056E+26DL, /* 2**88 */ 6.18970019642690137449562112E+26DL, /* 2**89 */ 1.237940039285380274899124224E+27DL, /* 2**90 */ 2.475880078570760549798248448E+27DL, /* 2**91 */ 4.951760157141521099596496896E+27DL, /* 2**92 */ 9.903520314283042199192993792E+27DL, /* 2**93 */ 1.9807040628566084398385987584E+28DL, /* 2**94 */ 3.9614081257132168796771975168E+28DL, /* 2**95 */ 7.9228162514264337593543950336E+28DL, /* 2**96 */ 1.58456325028528675187087900672E+29DL, /* 2**97 */ 3.16912650057057350374175801344E+29DL, /* 2**98 */ 6.33825300114114700748351602688E+29DL, /* 2**99 */ 1.267650600228229401496703205376E+30DL, /* 2**100 */ 2.535301200456458802993406410752E+30DL, /* 2**101 */ 5.070602400912917605986812821504E+30DL, /* 2**102 */ 1.0141204801825835211973625643008E+31DL, /* 2**103 */ 2.0282409603651670423947251286016E+31DL, /* 2**104 */ 4.0564819207303340847894502572032E+31DL, /* 2**105 */ 8.1129638414606681695789005144064E+31DL, /* 2**106 */ 1.62259276829213363391578010288128E+32DL, /* 2**107 */ 3.24518553658426726783156020576256E+32DL, /* 2**108 */ 6.49037107316853453566312041152512E+32DL, /* 2**109 */ 1.298074214633706907132624082305024E+33DL, /* 2**110 */ 2.596148429267413814265248164610048E+33DL, /* 2**111 */ 5.192296858534827628530496329220096E+33DL, /* 2**112 */ 1.038459371706965525706099265844019E+34DL, /* 2**113 */ 2.076918743413931051412198531688038E+34DL, /* 2**114 */ 4.153837486827862102824397063376077E+34DL, /* 2**115 */ 8.307674973655724205648794126752154E+34DL, /* 2**116 */ 1.661534994731144841129758825350431E+35DL, /* 2**117 */ 3.323069989462289682259517650700861E+35DL, /* 2**118 */ 6.646139978924579364519035301401723E+35DL, /* 2**119 */ 1.329227995784915872903807060280345E+36DL, /* 2**120 */ 2.658455991569831745807614120560689E+36DL, /* 2**121 */ 5.316911983139663491615228241121378E+36DL, /* 2**122 */ 1.063382396627932698323045648224276E+37DL, /* 2**123 */ 2.126764793255865396646091296448551E+37DL, /* 2**124 */ 4.253529586511730793292182592897103E+37DL, /* 2**125 */ 8.507059173023461586584365185794205E+37DL, /* 2**126 */ 1.701411834604692317316873037158841E+38DL, /* 2**127 */ 3.402823669209384634633746074317682E+38DL, /* 2**128 */ 6.805647338418769269267492148635364E+38DL, /* 2**129 */ 1.361129467683753853853498429727073E+39DL, /* 2**130 */ 2.722258935367507707706996859454146E+39DL, /* 2**131 */ 5.444517870735015415413993718908291E+39DL, /* 2**132 */ 1.088903574147003083082798743781658E+40DL, /* 2**133 */ 2.177807148294006166165597487563317E+40DL, /* 2**134 */ 4.355614296588012332331194975126633E+40DL, /* 2**135 */ 8.711228593176024664662389950253266E+40DL, /* 2**136 */ 1.742245718635204932932477990050653E+41DL, /* 2**137 */ 3.484491437270409865864955980101306E+41DL, /* 2**138 */ 6.968982874540819731729911960202613E+41DL, /* 2**139 */ 1.393796574908163946345982392040523E+42DL, /* 2**140 */ 2.787593149816327892691964784081045E+42DL, /* 2**141 */ 5.575186299632655785383929568162090E+42DL, /* 2**142 */ 1.115037259926531157076785913632418E+43DL, /* 2**143 */ 2.230074519853062314153571827264836E+43DL, /* 2**144 */ 4.460149039706124628307143654529672E+43DL, /* 2**145 */ 8.920298079412249256614287309059345E+43DL, /* 2**146 */ 1.784059615882449851322857461811869E+44DL, /* 2**147 */ 3.568119231764899702645714923623738E+44DL, /* 2**148 */ 7.136238463529799405291429847247476E+44DL, /* 2**149 */ 1.427247692705959881058285969449495E+45DL, /* 2**150 */ 2.854495385411919762116571938898990E+45DL, /* 2**151 */ 5.708990770823839524233143877797981E+45DL, /* 2**152 */ 1.141798154164767904846628775559596E+46DL, /* 2**153 */ 2.283596308329535809693257551119192E+46DL, /* 2**154 */ 4.567192616659071619386515102238384E+46DL, /* 2**155 */ 9.134385233318143238773030204476769E+46DL, /* 2**156 */ 1.826877046663628647754606040895354E+47DL, /* 2**157 */ 3.653754093327257295509212081790708E+47DL, /* 2**158 */ 7.307508186654514591018424163581415E+47DL, /* 2**159 */ 1.461501637330902918203684832716283E+48DL, /* 2**160 */ 2.923003274661805836407369665432566E+48DL, /* 2**161 */ 5.846006549323611672814739330865132E+48DL, /* 2**162 */ 1.169201309864722334562947866173026E+49DL, /* 2**163 */ 2.338402619729444669125895732346053E+49DL, /* 2**164 */ 4.676805239458889338251791464692106E+49DL, /* 2**165 */ 9.353610478917778676503582929384211E+49DL, /* 2**166 */ 1.870722095783555735300716585876842E+50DL, /* 2**167 */ 3.741444191567111470601433171753685E+50DL, /* 2**168 */ 7.482888383134222941202866343507369E+50DL, /* 2**169 */ 1.496577676626844588240573268701474E+51DL, /* 2**170 */ 2.993155353253689176481146537402948E+51DL, /* 2**171 */ 5.986310706507378352962293074805895E+51DL, /* 2**172 */ 1.197262141301475670592458614961179E+52DL, /* 2**173 */ 2.394524282602951341184917229922358E+52DL, /* 2**174 */ 4.789048565205902682369834459844716E+52DL, /* 2**175 */ 9.578097130411805364739668919689432E+52DL, /* 2**176 */ 1.915619426082361072947933783937886E+53DL, /* 2**177 */ 3.831238852164722145895867567875773E+53DL, /* 2**178 */ 7.662477704329444291791735135751546E+53DL, /* 2**179 */ 1.532495540865888858358347027150309E+54DL, /* 2**180 */ 3.064991081731777716716694054300618E+54DL, /* 2**181 */ 6.129982163463555433433388108601237E+54DL, /* 2**182 */ 1.225996432692711086686677621720247E+55DL, /* 2**183 */ 2.451992865385422173373355243440495E+55DL, /* 2**184 */ 4.903985730770844346746710486880989E+55DL, /* 2**185 */ 9.807971461541688693493420973761979E+55DL, /* 2**186 */ 1.961594292308337738698684194752396E+56DL, /* 2**187 */ 3.923188584616675477397368389504792E+56DL, /* 2**188 */ 7.846377169233350954794736779009583E+56DL, /* 2**189 */ 1.569275433846670190958947355801917E+57DL, /* 2**190 */ 3.138550867693340381917894711603833E+57DL, /* 2**191 */ 6.277101735386680763835789423207666E+57DL, /* 2**192 */ 1.255420347077336152767157884641533E+58DL, /* 2**193 */ 2.510840694154672305534315769283067E+58DL, /* 2**194 */ 5.021681388309344611068631538566133E+58DL, /* 2**195 */ 1.004336277661868922213726307713227E+59DL, /* 2**196 */ 2.008672555323737844427452615426453E+59DL, /* 2**197 */ 4.017345110647475688854905230852907E+59DL, /* 2**198 */ 8.034690221294951377709810461705813E+59DL, /* 2**199 */ 1.606938044258990275541962092341163E+60DL, /* 2**200 */ 3.213876088517980551083924184682325E+60DL, /* 2**201 */ 6.427752177035961102167848369364650E+60DL, /* 2**202 */ 1.285550435407192220433569673872930E+61DL, /* 2**203 */ 2.571100870814384440867139347745860E+61DL, /* 2**204 */ 5.142201741628768881734278695491720E+61DL, /* 2**205 */ 1.028440348325753776346855739098344E+62DL, /* 2**206 */ 2.056880696651507552693711478196688E+62DL, /* 2**207 */ 4.113761393303015105387422956393376E+62DL, /* 2**208 */ 8.227522786606030210774845912786753E+62DL, /* 2**209 */ 1.645504557321206042154969182557351E+63DL, /* 2**210 */ 3.291009114642412084309938365114701E+63DL, /* 2**211 */ 6.582018229284824168619876730229402E+63DL, /* 2**212 */ 1.316403645856964833723975346045880E+64DL, /* 2**213 */ 2.632807291713929667447950692091761E+64DL, /* 2**214 */ 5.265614583427859334895901384183522E+64DL, /* 2**215 */ 1.053122916685571866979180276836704E+65DL, /* 2**216 */ 2.106245833371143733958360553673409E+65DL, /* 2**217 */ 4.212491666742287467916721107346817E+65DL, /* 2**218 */ 8.424983333484574935833442214693635E+65DL, /* 2**219 */ 1.684996666696914987166688442938727E+66DL, /* 2**220 */ 3.369993333393829974333376885877454E+66DL, /* 2**221 */ 6.739986666787659948666753771754908E+66DL, /* 2**222 */ 1.347997333357531989733350754350982E+67DL, /* 2**223 */ 2.695994666715063979466701508701963E+67DL, /* 2**224 */ 5.391989333430127958933403017403926E+67DL, /* 2**225 */ 1.078397866686025591786680603480785E+68DL, /* 2**226 */ 2.156795733372051183573361206961570E+68DL, /* 2**227 */ 4.313591466744102367146722413923141E+68DL, /* 2**228 */ 8.627182933488204734293444827846282E+68DL, /* 2**229 */ 1.725436586697640946858688965569256E+69DL, /* 2**230 */ 3.450873173395281893717377931138513E+69DL, /* 2**231 */ 6.901746346790563787434755862277025E+69DL, /* 2**232 */ 1.380349269358112757486951172455405E+70DL, /* 2**233 */ 2.760698538716225514973902344910810E+70DL, /* 2**234 */ 5.521397077432451029947804689821620E+70DL, /* 2**235 */ 1.104279415486490205989560937964324E+71DL, /* 2**236 */ 2.208558830972980411979121875928648E+71DL, /* 2**237 */ 4.417117661945960823958243751857296E+71DL, /* 2**238 */ 8.834235323891921647916487503714593E+71DL, /* 2**239 */ 1.766847064778384329583297500742919E+72DL, /* 2**240 */ 3.533694129556768659166595001485837E+72DL, /* 2**241 */ 7.067388259113537318333190002971674E+72DL, /* 2**242 */ 1.413477651822707463666638000594335E+73DL, /* 2**243 */ 2.826955303645414927333276001188670E+73DL, /* 2**244 */ 5.653910607290829854666552002377339E+73DL, /* 2**245 */ 1.130782121458165970933310400475468E+74DL, /* 2**246 */ 2.261564242916331941866620800950936E+74DL, /* 2**247 */ 4.523128485832663883733241601901871E+74DL, /* 2**248 */ 9.046256971665327767466483203803743E+74DL, /* 2**249 */ 1.809251394333065553493296640760749E+75DL, /* 2**250 */ 3.618502788666131106986593281521497E+75DL, /* 2**251 */ 7.237005577332262213973186563042994E+75DL, /* 2**252 */ 1.447401115466452442794637312608599E+76DL, /* 2**253 */ 2.894802230932904885589274625217198E+76DL, /* 2**254 */ 5.789604461865809771178549250434395E+76DL, /* 2**255 */ 1.157920892373161954235709850086879E+77DL, /* 2**256 */ 2.315841784746323908471419700173758E+77DL, /* 2**257 */ 4.631683569492647816942839400347516E+77DL, /* 2**258 */ 9.263367138985295633885678800695033E+77DL, /* 2**259 */ 1.852673427797059126777135760139007E+78DL, /* 2**260 */ 3.705346855594118253554271520278013E+78DL, /* 2**261 */ 7.410693711188236507108543040556026E+78DL, /* 2**262 */ 1.482138742237647301421708608111205E+79DL, /* 2**263 */ 2.964277484475294602843417216222410E+79DL, /* 2**264 */ 5.928554968950589205686834432444821E+79DL, /* 2**265 */ 1.185710993790117841137366886488964E+80DL, /* 2**266 */ 2.371421987580235682274733772977928E+80DL, /* 2**267 */ 4.742843975160471364549467545955857E+80DL, /* 2**268 */ 9.485687950320942729098935091911713E+80DL, /* 2**269 */ 1.897137590064188545819787018382343E+81DL, /* 2**270 */ 3.794275180128377091639574036764685E+81DL, /* 2**271 */ 7.588550360256754183279148073529371E+81DL, /* 2**272 */ 1.517710072051350836655829614705874E+82DL, /* 2**273 */ 3.035420144102701673311659229411748E+82DL, /* 2**274 */ 6.070840288205403346623318458823497E+82DL, /* 2**275 */ 1.214168057641080669324663691764699E+83DL, /* 2**276 */ 2.428336115282161338649327383529399E+83DL, /* 2**277 */ 4.856672230564322677298654767058797E+83DL, /* 2**278 */ 9.713344461128645354597309534117595E+83DL, /* 2**279 */ 1.942668892225729070919461906823519E+84DL, /* 2**280 */ 3.885337784451458141838923813647038E+84DL, /* 2**281 */ 7.770675568902916283677847627294076E+84DL, /* 2**282 */ 1.554135113780583256735569525458815E+85DL, /* 2**283 */ 3.108270227561166513471139050917630E+85DL, /* 2**284 */ 6.216540455122333026942278101835261E+85DL, /* 2**285 */ 1.243308091024466605388455620367052E+86DL, /* 2**286 */ 2.486616182048933210776911240734104E+86DL, /* 2**287 */ 4.973232364097866421553822481468208E+86DL, /* 2**288 */ 9.946464728195732843107644962936417E+86DL, /* 2**289 */ 1.989292945639146568621528992587283E+87DL, /* 2**290 */ 3.978585891278293137243057985174567E+87DL, /* 2**291 */ 7.957171782556586274486115970349133E+87DL, /* 2**292 */ 1.591434356511317254897223194069827E+88DL, /* 2**293 */ 3.182868713022634509794446388139653E+88DL, /* 2**294 */ 6.365737426045269019588892776279307E+88DL, /* 2**295 */ 1.273147485209053803917778555255861E+89DL, /* 2**296 */ 2.546294970418107607835557110511723E+89DL, /* 2**297 */ 5.092589940836215215671114221023445E+89DL, /* 2**298 */ 1.018517988167243043134222844204689E+90DL, /* 2**299 */ 2.037035976334486086268445688409378E+90DL, /* 2**300 */ 4.074071952668972172536891376818756E+90DL, /* 2**301 */ 8.148143905337944345073782753637513E+90DL, /* 2**302 */ 1.629628781067588869014756550727503E+91DL, /* 2**303 */ 3.259257562135177738029513101455005E+91DL, /* 2**304 */ 6.518515124270355476059026202910010E+91DL, /* 2**305 */ 1.303703024854071095211805240582002E+92DL, /* 2**306 */ 2.607406049708142190423610481164004E+92DL, /* 2**307 */ 5.214812099416284380847220962328008E+92DL, /* 2**308 */ 1.042962419883256876169444192465602E+93DL, /* 2**309 */ 2.085924839766513752338888384931203E+93DL, /* 2**310 */ 4.171849679533027504677776769862406E+93DL, /* 2**311 */ 8.343699359066055009355553539724813E+93DL, /* 2**312 */ 1.668739871813211001871110707944963E+94DL, /* 2**313 */ 3.337479743626422003742221415889925E+94DL, /* 2**314 */ 6.674959487252844007484442831779850E+94DL, /* 2**315 */ 1.334991897450568801496888566355970E+95DL, /* 2**316 */ 2.669983794901137602993777132711940E+95DL, /* 2**317 */ 5.339967589802275205987554265423880E+95DL, /* 2**318 */ 1.067993517960455041197510853084776E+96DL, /* 2**319 */ 2.135987035920910082395021706169552E+96DL, /* 2**320 */ 4.271974071841820164790043412339104E+96DL, /* 2**321 */ 8.543948143683640329580086824678208E+96DL, /* 2**322 */ 1.708789628736728065916017364935642E+97DL, /* 2**323 */ 3.417579257473456131832034729871283E+97DL, /* 2**324 */ 6.835158514946912263664069459742567E+97DL, /* 2**325 */ 1.367031702989382452732813891948513E+98DL, /* 2**326 */ 2.734063405978764905465627783897027E+98DL, /* 2**327 */ 5.468126811957529810931255567794053E+98DL, /* 2**328 */ 1.093625362391505962186251113558811E+99DL, /* 2**329 */ 2.187250724783011924372502227117621E+99DL, /* 2**330 */ 4.374501449566023848745004454235243E+99DL, /* 2**331 */ 8.749002899132047697490008908470485E+99DL, /* 2**332 */ 1.749800579826409539498001781694097E+100DL, /* 2**333 */ 3.499601159652819078996003563388194E+100DL, /* 2**334 */ 6.999202319305638157992007126776388E+100DL, /* 2**335 */ 1.399840463861127631598401425355278E+101DL, /* 2**336 */ 2.799680927722255263196802850710555E+101DL, /* 2**337 */ 5.599361855444510526393605701421111E+101DL, /* 2**338 */ 1.119872371088902105278721140284222E+102DL, /* 2**339 */ 2.239744742177804210557442280568444E+102DL, /* 2**340 */ 4.479489484355608421114884561136889E+102DL, /* 2**341 */ 8.958978968711216842229769122273777E+102DL, /* 2**342 */ 1.791795793742243368445953824454755E+103DL, /* 2**343 */ 3.583591587484486736891907648909511E+103DL, /* 2**344 */ 7.167183174968973473783815297819022E+103DL, /* 2**345 */ 1.433436634993794694756763059563804E+104DL, /* 2**346 */ 2.866873269987589389513526119127609E+104DL, /* 2**347 */ 5.733746539975178779027052238255217E+104DL, /* 2**348 */ 1.146749307995035755805410447651043E+105DL, /* 2**349 */ 2.293498615990071511610820895302087E+105DL, /* 2**350 */ 4.586997231980143023221641790604174E+105DL, /* 2**351 */ 9.173994463960286046443283581208348E+105DL, /* 2**352 */ 1.834798892792057209288656716241670E+106DL, /* 2**353 */ 3.669597785584114418577313432483339E+106DL, /* 2**354 */ 7.339195571168228837154626864966678E+106DL, /* 2**355 */ 1.467839114233645767430925372993336E+107DL, /* 2**356 */ 2.935678228467291534861850745986671E+107DL, /* 2**357 */ 5.871356456934583069723701491973343E+107DL, /* 2**358 */ 1.174271291386916613944740298394669E+108DL, /* 2**359 */ 2.348542582773833227889480596789337E+108DL, /* 2**360 */ 4.697085165547666455778961193578674E+108DL, /* 2**361 */ 9.394170331095332911557922387157348E+108DL, /* 2**362 */ 1.878834066219066582311584477431470E+109DL, /* 2**363 */ 3.757668132438133164623168954862939E+109DL, /* 2**364 */ 7.515336264876266329246337909725878E+109DL, /* 2**365 */ 1.503067252975253265849267581945176E+110DL, /* 2**366 */ 3.006134505950506531698535163890351E+110DL, /* 2**367 */ 6.012269011901013063397070327780703E+110DL, /* 2**368 */ 1.202453802380202612679414065556141E+111DL, /* 2**369 */ 2.404907604760405225358828131112281E+111DL, /* 2**370 */ 4.809815209520810450717656262224562E+111DL, /* 2**371 */ 9.619630419041620901435312524449124E+111DL, /* 2**372 */ 1.923926083808324180287062504889825E+112DL, /* 2**373 */ 3.847852167616648360574125009779650E+112DL, /* 2**374 */ 7.695704335233296721148250019559300E+112DL, /* 2**375 */ 1.539140867046659344229650003911860E+113DL, /* 2**376 */ 3.078281734093318688459300007823720E+113DL, /* 2**377 */ 6.156563468186637376918600015647440E+113DL, /* 2**378 */ 1.231312693637327475383720003129488E+114DL, /* 2**379 */ 2.462625387274654950767440006258976E+114DL, /* 2**380 */ 4.925250774549309901534880012517952E+114DL, /* 2**381 */ 9.850501549098619803069760025035903E+114DL, /* 2**382 */ 1.970100309819723960613952005007181E+115DL, /* 2**383 */ 3.940200619639447921227904010014361E+115DL, /* 2**384 */ 7.880401239278895842455808020028723E+115DL, /* 2**385 */ 1.576080247855779168491161604005745E+116DL, /* 2**386 */ 3.152160495711558336982323208011489E+116DL, /* 2**387 */ 6.304320991423116673964646416022978E+116DL, /* 2**388 */ 1.260864198284623334792929283204596E+117DL, /* 2**389 */ 2.521728396569246669585858566409191E+117DL, /* 2**390 */ 5.043456793138493339171717132818383E+117DL, /* 2**391 */ 1.008691358627698667834343426563677E+118DL, /* 2**392 */ 2.017382717255397335668686853127353E+118DL, /* 2**393 */ 4.034765434510794671337373706254706E+118DL, /* 2**394 */ 8.069530869021589342674747412509412E+118DL, /* 2**395 */ 1.613906173804317868534949482501882E+119DL, /* 2**396 */ 3.227812347608635737069898965003765E+119DL, /* 2**397 */ 6.455624695217271474139797930007530E+119DL, /* 2**398 */ 1.291124939043454294827959586001506E+120DL, /* 2**399 */ 2.582249878086908589655919172003012E+120DL, /* 2**400 */ 5.164499756173817179311838344006024E+120DL, /* 2**401 */ 1.032899951234763435862367668801205E+121DL, /* 2**402 */ 2.065799902469526871724735337602409E+121DL, /* 2**403 */ 4.131599804939053743449470675204819E+121DL, /* 2**404 */ 8.263199609878107486898941350409638E+121DL, /* 2**405 */ 1.652639921975621497379788270081928E+122DL, /* 2**406 */ 3.305279843951242994759576540163855E+122DL, /* 2**407 */ 6.610559687902485989519153080327710E+122DL, /* 2**408 */ 1.322111937580497197903830616065542E+123DL, /* 2**409 */ 2.644223875160994395807661232131084E+123DL, /* 2**410 */ 5.288447750321988791615322464262168E+123DL, /* 2**411 */ 1.057689550064397758323064492852434E+124DL, /* 2**412 */ 2.115379100128795516646128985704867E+124DL, /* 2**413 */ 4.230758200257591033292257971409735E+124DL, /* 2**414 */ 8.461516400515182066584515942819469E+124DL, /* 2**415 */ 1.692303280103036413316903188563894E+125DL, /* 2**416 */ 3.384606560206072826633806377127788E+125DL, /* 2**417 */ 6.769213120412145653267612754255575E+125DL, /* 2**418 */ 1.353842624082429130653522550851115E+126DL, /* 2**419 */ 2.707685248164858261307045101702230E+126DL, /* 2**420 */ 5.415370496329716522614090203404460E+126DL, /* 2**421 */ 1.083074099265943304522818040680892E+127DL, /* 2**422 */ 2.166148198531886609045636081361784E+127DL, /* 2**423 */ 4.332296397063773218091272162723568E+127DL, /* 2**424 */ 8.664592794127546436182544325447137E+127DL, /* 2**425 */ 1.732918558825509287236508865089427E+128DL, /* 2**426 */ 3.465837117651018574473017730178855E+128DL, /* 2**427 */ 6.931674235302037148946035460357709E+128DL, /* 2**428 */ 1.386334847060407429789207092071542E+129DL, /* 2**429 */ 2.772669694120814859578414184143084E+129DL, /* 2**430 */ 5.545339388241629719156828368286167E+129DL, /* 2**431 */ 1.109067877648325943831365673657233E+130DL, /* 2**432 */ 2.218135755296651887662731347314467E+130DL, /* 2**433 */ 4.436271510593303775325462694628934E+130DL, /* 2**434 */ 8.872543021186607550650925389257868E+130DL, /* 2**435 */ 1.774508604237321510130185077851574E+131DL, /* 2**436 */ 3.549017208474643020260370155703147E+131DL, /* 2**437 */ 7.098034416949286040520740311406294E+131DL, /* 2**438 */ 1.419606883389857208104148062281259E+132DL, /* 2**439 */ 2.839213766779714416208296124562518E+132DL, /* 2**440 */ 5.678427533559428832416592249125035E+132DL, /* 2**441 */ 1.135685506711885766483318449825007E+133DL, /* 2**442 */ 2.271371013423771532966636899650014E+133DL, /* 2**443 */ 4.542742026847543065933273799300028E+133DL, /* 2**444 */ 9.085484053695086131866547598600057E+133DL, /* 2**445 */ 1.817096810739017226373309519720011E+134DL, /* 2**446 */ 3.634193621478034452746619039440023E+134DL, /* 2**447 */ 7.268387242956068905493238078880045E+134DL, /* 2**448 */ 1.453677448591213781098647615776009E+135DL, /* 2**449 */ 2.907354897182427562197295231552018E+135DL, /* 2**450 */ 5.814709794364855124394590463104036E+135DL, /* 2**451 */ 1.162941958872971024878918092620807E+136DL, /* 2**452 */ 2.325883917745942049757836185241615E+136DL, /* 2**453 */ 4.651767835491884099515672370483229E+136DL, /* 2**454 */ 9.303535670983768199031344740966458E+136DL, /* 2**455 */ 1.860707134196753639806268948193292E+137DL, /* 2**456 */ 3.721414268393507279612537896386583E+137DL, /* 2**457 */ 7.442828536787014559225075792773166E+137DL, /* 2**458 */ 1.488565707357402911845015158554633E+138DL, /* 2**459 */ 2.977131414714805823690030317109267E+138DL, /* 2**460 */ 5.954262829429611647380060634218533E+138DL, /* 2**461 */ 1.190852565885922329476012126843707E+139DL, /* 2**462 */ 2.381705131771844658952024253687413E+139DL, /* 2**463 */ 4.763410263543689317904048507374827E+139DL, /* 2**464 */ 9.526820527087378635808097014749653E+139DL, /* 2**465 */ 1.905364105417475727161619402949931E+140DL, /* 2**466 */ 3.810728210834951454323238805899861E+140DL, /* 2**467 */ 7.621456421669902908646477611799722E+140DL, /* 2**468 */ 1.524291284333980581729295522359944E+141DL, /* 2**469 */ 3.048582568667961163458591044719889E+141DL, /* 2**470 */ 6.097165137335922326917182089439778E+141DL, /* 2**471 */ 1.219433027467184465383436417887956E+142DL, /* 2**472 */ 2.438866054934368930766872835775911E+142DL, /* 2**473 */ 4.877732109868737861533745671551822E+142DL, /* 2**474 */ 9.755464219737475723067491343103645E+142DL, /* 2**475 */ 1.951092843947495144613498268620729E+143DL, /* 2**476 */ 3.902185687894990289226996537241458E+143DL, /* 2**477 */ 7.804371375789980578453993074482916E+143DL, /* 2**478 */ 1.560874275157996115690798614896583E+144DL, /* 2**479 */ 3.121748550315992231381597229793166E+144DL, /* 2**480 */ 6.243497100631984462763194459586333E+144DL, /* 2**481 */ 1.248699420126396892552638891917267E+145DL, /* 2**482 */ 2.497398840252793785105277783834533E+145DL, /* 2**483 */ 4.994797680505587570210555567669066E+145DL, /* 2**484 */ 9.989595361011175140421111135338132E+145DL, /* 2**485 */ 1.997919072202235028084222227067626E+146DL, /* 2**486 */ 3.995838144404470056168444454135253E+146DL, /* 2**487 */ 7.991676288808940112336888908270506E+146DL, /* 2**488 */ 1.598335257761788022467377781654101E+147DL, /* 2**489 */ 3.196670515523576044934755563308202E+147DL, /* 2**490 */ 6.393341031047152089869511126616405E+147DL, /* 2**491 */ 1.278668206209430417973902225323281E+148DL, /* 2**492 */ 2.557336412418860835947804450646562E+148DL, /* 2**493 */ 5.114672824837721671895608901293124E+148DL, /* 2**494 */ 1.022934564967544334379121780258625E+149DL, /* 2**495 */ 2.045869129935088668758243560517249E+149DL, /* 2**496 */ 4.091738259870177337516487121034499E+149DL, /* 2**497 */ 8.183476519740354675032974242068998E+149DL, /* 2**498 */ 1.636695303948070935006594848413800E+150DL, /* 2**499 */ 3.273390607896141870013189696827599E+150DL, /* 2**500 */ 6.546781215792283740026379393655198E+150DL, /* 2**501 */ 1.309356243158456748005275878731040E+151DL, /* 2**502 */ 2.618712486316913496010551757462079E+151DL, /* 2**503 */ 5.237424972633826992021103514924159E+151DL, /* 2**504 */ 1.047484994526765398404220702984832E+152DL, /* 2**505 */ 2.094969989053530796808441405969663E+152DL, /* 2**506 */ 4.189939978107061593616882811939327E+152DL, /* 2**507 */ 8.379879956214123187233765623878654E+152DL, /* 2**508 */ 1.675975991242824637446753124775731E+153DL, /* 2**509 */ 3.351951982485649274893506249551462E+153DL, /* 2**510 */ 6.703903964971298549787012499102923E+153DL, /* 2**511 */ 1.340780792994259709957402499820585E+154DL, /* 2**512 */ 2.681561585988519419914804999641169E+154DL, /* 2**513 */ 5.363123171977038839829609999282338E+154DL, /* 2**514 */ 1.072624634395407767965921999856468E+155DL, /* 2**515 */ 2.145249268790815535931843999712935E+155DL, /* 2**516 */ 4.290498537581631071863687999425871E+155DL, /* 2**517 */ 8.580997075163262143727375998851742E+155DL, /* 2**518 */ 1.716199415032652428745475199770348E+156DL, /* 2**519 */ 3.432398830065304857490950399540697E+156DL, /* 2**520 */ 6.864797660130609714981900799081393E+156DL, /* 2**521 */ 1.372959532026121942996380159816279E+157DL, /* 2**522 */ 2.745919064052243885992760319632557E+157DL, /* 2**523 */ 5.491838128104487771985520639265115E+157DL, /* 2**524 */ 1.098367625620897554397104127853023E+158DL, /* 2**525 */ 2.196735251241795108794208255706046E+158DL, /* 2**526 */ 4.393470502483590217588416511412092E+158DL, /* 2**527 */ 8.786941004967180435176833022824183E+158DL, /* 2**528 */ 1.757388200993436087035366604564837E+159DL, /* 2**529 */ 3.514776401986872174070733209129673E+159DL, /* 2**530 */ 7.029552803973744348141466418259347E+159DL, /* 2**531 */ 1.405910560794748869628293283651869E+160DL, /* 2**532 */ 2.811821121589497739256586567303739E+160DL, /* 2**533 */ 5.623642243178995478513173134607477E+160DL, /* 2**534 */ 1.124728448635799095702634626921495E+161DL, /* 2**535 */ 2.249456897271598191405269253842991E+161DL, /* 2**536 */ 4.498913794543196382810538507685982E+161DL, /* 2**537 */ 8.997827589086392765621077015371964E+161DL, /* 2**538 */ 1.799565517817278553124215403074393E+162DL, /* 2**539 */ 3.599131035634557106248430806148785E+162DL, /* 2**540 */ 7.198262071269114212496861612297571E+162DL, /* 2**541 */ 1.439652414253822842499372322459514E+163DL, /* 2**542 */ 2.879304828507645684998744644919028E+163DL, /* 2**543 */ 5.758609657015291369997489289838057E+163DL, /* 2**544 */ 1.151721931403058273999497857967611E+164DL, /* 2**545 */ 2.303443862806116547998995715935223E+164DL, /* 2**546 */ 4.606887725612233095997991431870445E+164DL, /* 2**547 */ 9.213775451224466191995982863740891E+164DL, /* 2**548 */ 1.842755090244893238399196572748178E+165DL, /* 2**549 */ 3.685510180489786476798393145496356E+165DL, /* 2**550 */ 7.371020360979572953596786290992713E+165DL, /* 2**551 */ 1.474204072195914590719357258198543E+166DL, /* 2**552 */ 2.948408144391829181438714516397085E+166DL, /* 2**553 */ 5.896816288783658362877429032794170E+166DL, /* 2**554 */ 1.179363257756731672575485806558834E+167DL, /* 2**555 */ 2.358726515513463345150971613117668E+167DL, /* 2**556 */ 4.717453031026926690301943226235336E+167DL, /* 2**557 */ 9.434906062053853380603886452470672E+167DL, /* 2**558 */ 1.886981212410770676120777290494134E+168DL, /* 2**559 */ 3.773962424821541352241554580988269E+168DL, /* 2**560 */ 7.547924849643082704483109161976538E+168DL, /* 2**561 */ 1.509584969928616540896621832395308E+169DL, /* 2**562 */ 3.019169939857233081793243664790615E+169DL, /* 2**563 */ 6.038339879714466163586487329581230E+169DL, /* 2**564 */ 1.207667975942893232717297465916246E+170DL, /* 2**565 */ 2.415335951885786465434594931832492E+170DL, /* 2**566 */ 4.830671903771572930869189863664984E+170DL, /* 2**567 */ 9.661343807543145861738379727329968E+170DL, /* 2**568 */ 1.932268761508629172347675945465994E+171DL, /* 2**569 */ 3.864537523017258344695351890931987E+171DL, /* 2**570 */ 7.729075046034516689390703781863975E+171DL, /* 2**571 */ 1.545815009206903337878140756372795E+172DL, /* 2**572 */ 3.091630018413806675756281512745590E+172DL, /* 2**573 */ 6.183260036827613351512563025491180E+172DL, /* 2**574 */ 1.236652007365522670302512605098236E+173DL, /* 2**575 */ 2.473304014731045340605025210196472E+173DL, /* 2**576 */ 4.946608029462090681210050420392944E+173DL, /* 2**577 */ 9.893216058924181362420100840785888E+173DL, /* 2**578 */ 1.978643211784836272484020168157178E+174DL, /* 2**579 */ 3.957286423569672544968040336314355E+174DL, /* 2**580 */ 7.914572847139345089936080672628710E+174DL, /* 2**581 */ 1.582914569427869017987216134525742E+175DL, /* 2**582 */ 3.165829138855738035974432269051484E+175DL, /* 2**583 */ 6.331658277711476071948864538102968E+175DL, /* 2**584 */ 1.266331655542295214389772907620594E+176DL, /* 2**585 */ 2.532663311084590428779545815241187E+176DL, /* 2**586 */ 5.065326622169180857559091630482374E+176DL, /* 2**587 */ 1.013065324433836171511818326096475E+177DL, /* 2**588 */ 2.026130648867672343023636652192950E+177DL, /* 2**589 */ 4.052261297735344686047273304385900E+177DL, /* 2**590 */ 8.104522595470689372094546608771799E+177DL, /* 2**591 */ 1.620904519094137874418909321754360E+178DL, /* 2**592 */ 3.241809038188275748837818643508720E+178DL, /* 2**593 */ 6.483618076376551497675637287017439E+178DL, /* 2**594 */ 1.296723615275310299535127457403488E+179DL, /* 2**595 */ 2.593447230550620599070254914806976E+179DL, /* 2**596 */ 5.186894461101241198140509829613951E+179DL, /* 2**597 */ 1.037378892220248239628101965922790E+180DL, /* 2**598 */ 2.074757784440496479256203931845581E+180DL, /* 2**599 */ 4.149515568880992958512407863691161E+180DL, /* 2**600 */ 8.299031137761985917024815727382322E+180DL, /* 2**601 */ 1.659806227552397183404963145476464E+181DL, /* 2**602 */ 3.319612455104794366809926290952929E+181DL, /* 2**603 */ 6.639224910209588733619852581905858E+181DL, /* 2**604 */ 1.327844982041917746723970516381172E+182DL, /* 2**605 */ 2.655689964083835493447941032762343E+182DL, /* 2**606 */ 5.311379928167670986895882065524686E+182DL, /* 2**607 */ 1.062275985633534197379176413104937E+183DL, /* 2**608 */ 2.124551971267068394758352826209875E+183DL, /* 2**609 */ 4.249103942534136789516705652419749E+183DL, /* 2**610 */ 8.498207885068273579033411304839498E+183DL, /* 2**611 */ 1.699641577013654715806682260967900E+184DL, /* 2**612 */ 3.399283154027309431613364521935799E+184DL, /* 2**613 */ 6.798566308054618863226729043871598E+184DL, /* 2**614 */ 1.359713261610923772645345808774320E+185DL, /* 2**615 */ 2.719426523221847545290691617548639E+185DL, /* 2**616 */ 5.438853046443695090581383235097279E+185DL, /* 2**617 */ 1.087770609288739018116276647019456E+186DL, /* 2**618 */ 2.175541218577478036232553294038911E+186DL, /* 2**619 */ 4.351082437154956072465106588077823E+186DL, /* 2**620 */ 8.702164874309912144930213176155646E+186DL, /* 2**621 */ 1.740432974861982428986042635231129E+187DL, /* 2**622 */ 3.480865949723964857972085270462258E+187DL, /* 2**623 */ 6.961731899447929715944170540924517E+187DL, /* 2**624 */ 1.392346379889585943188834108184903E+188DL, /* 2**625 */ 2.784692759779171886377668216369807E+188DL, /* 2**626 */ 5.569385519558343772755336432739613E+188DL, /* 2**627 */ 1.113877103911668754551067286547923E+189DL, /* 2**628 */ 2.227754207823337509102134573095845E+189DL, /* 2**629 */ 4.455508415646675018204269146191691E+189DL, /* 2**630 */ 8.911016831293350036408538292383381E+189DL, /* 2**631 */ 1.782203366258670007281707658476676E+190DL, /* 2**632 */ 3.564406732517340014563415316953353E+190DL, /* 2**633 */ 7.128813465034680029126830633906705E+190DL, /* 2**634 */ 1.425762693006936005825366126781341E+191DL, /* 2**635 */ 2.851525386013872011650732253562682E+191DL, /* 2**636 */ 5.703050772027744023301464507125364E+191DL, /* 2**637 */ 1.140610154405548804660292901425073E+192DL, /* 2**638 */ 2.281220308811097609320585802850146E+192DL, /* 2**639 */ 4.562440617622195218641171605700291E+192DL, /* 2**640 */ 9.124881235244390437282343211400583E+192DL, /* 2**641 */ 1.824976247048878087456468642280117E+193DL, /* 2**642 */ 3.649952494097756174912937284560233E+193DL, /* 2**643 */ 7.299904988195512349825874569120466E+193DL, /* 2**644 */ 1.459980997639102469965174913824093E+194DL, /* 2**645 */ 2.919961995278204939930349827648186E+194DL, /* 2**646 */ 5.839923990556409879860699655296373E+194DL, /* 2**647 */ 1.167984798111281975972139931059275E+195DL, /* 2**648 */ 2.335969596222563951944279862118549E+195DL, /* 2**649 */ 4.671939192445127903888559724237098E+195DL, /* 2**650 */ 9.343878384890255807777119448474197E+195DL, /* 2**651 */ 1.868775676978051161555423889694839E+196DL, /* 2**652 */ 3.737551353956102323110847779389679E+196DL, /* 2**653 */ 7.475102707912204646221695558779357E+196DL, /* 2**654 */ 1.495020541582440929244339111755871E+197DL, /* 2**655 */ 2.990041083164881858488678223511743E+197DL, /* 2**656 */ 5.980082166329763716977356447023486E+197DL, /* 2**657 */ 1.196016433265952743395471289404697E+198DL, /* 2**658 */ 2.392032866531905486790942578809394E+198DL, /* 2**659 */ 4.784065733063810973581885157618789E+198DL, /* 2**660 */ 9.568131466127621947163770315237577E+198DL, /* 2**661 */ 1.913626293225524389432754063047515E+199DL, /* 2**662 */ 3.827252586451048778865508126095031E+199DL, /* 2**663 */ 7.654505172902097557731016252190062E+199DL, /* 2**664 */ 1.530901034580419511546203250438012E+200DL, /* 2**665 */ 3.061802069160839023092406500876025E+200DL, /* 2**666 */ 6.123604138321678046184813001752050E+200DL, /* 2**667 */ 1.224720827664335609236962600350410E+201DL, /* 2**668 */ 2.449441655328671218473925200700820E+201DL, /* 2**669 */ 4.898883310657342436947850401401640E+201DL, /* 2**670 */ 9.797766621314684873895700802803279E+201DL, /* 2**671 */ 1.959553324262936974779140160560656E+202DL, /* 2**672 */ 3.919106648525873949558280321121312E+202DL, /* 2**673 */ 7.838213297051747899116560642242623E+202DL, /* 2**674 */ 1.567642659410349579823312128448525E+203DL, /* 2**675 */ 3.135285318820699159646624256897049E+203DL, /* 2**676 */ 6.270570637641398319293248513794099E+203DL, /* 2**677 */ 1.254114127528279663858649702758820E+204DL, /* 2**678 */ 2.508228255056559327717299405517639E+204DL, /* 2**679 */ 5.016456510113118655434598811035279E+204DL, /* 2**680 */ 1.003291302022623731086919762207056E+205DL, /* 2**681 */ 2.006582604045247462173839524414112E+205DL, /* 2**682 */ 4.013165208090494924347679048828223E+205DL, /* 2**683 */ 8.026330416180989848695358097656446E+205DL, /* 2**684 */ 1.605266083236197969739071619531289E+206DL, /* 2**685 */ 3.210532166472395939478143239062579E+206DL, /* 2**686 */ 6.421064332944791878956286478125157E+206DL, /* 2**687 */ 1.284212866588958375791257295625031E+207DL, /* 2**688 */ 2.568425733177916751582514591250063E+207DL, /* 2**689 */ 5.136851466355833503165029182500126E+207DL, /* 2**690 */ 1.027370293271166700633005836500025E+208DL, /* 2**691 */ 2.054740586542333401266011673000050E+208DL, /* 2**692 */ 4.109481173084666802532023346000101E+208DL, /* 2**693 */ 8.218962346169333605064046692000201E+208DL, /* 2**694 */ 1.643792469233866721012809338400040E+209DL, /* 2**695 */ 3.287584938467733442025618676800080E+209DL, /* 2**696 */ 6.575169876935466884051237353600161E+209DL, /* 2**697 */ 1.315033975387093376810247470720032E+210DL, /* 2**698 */ 2.630067950774186753620494941440064E+210DL, /* 2**699 */ 5.260135901548373507240989882880129E+210DL, /* 2**700 */ 1.052027180309674701448197976576026E+211DL, /* 2**701 */ 2.104054360619349402896395953152051E+211DL, /* 2**702 */ 4.208108721238698805792791906304103E+211DL, /* 2**703 */ 8.416217442477397611585583812608206E+211DL, /* 2**704 */ 1.683243488495479522317116762521641E+212DL, /* 2**705 */ 3.366486976990959044634233525043282E+212DL, /* 2**706 */ 6.732973953981918089268467050086565E+212DL, /* 2**707 */ 1.346594790796383617853693410017313E+213DL, /* 2**708 */ 2.693189581592767235707386820034626E+213DL, /* 2**709 */ 5.386379163185534471414773640069252E+213DL, /* 2**710 */ 1.077275832637106894282954728013850E+214DL, /* 2**711 */ 2.154551665274213788565909456027701E+214DL, /* 2**712 */ 4.309103330548427577131818912055401E+214DL, /* 2**713 */ 8.618206661096855154263637824110803E+214DL, /* 2**714 */ 1.723641332219371030852727564822161E+215DL, /* 2**715 */ 3.447282664438742061705455129644321E+215DL, /* 2**716 */ 6.894565328877484123410910259288642E+215DL, /* 2**717 */ 1.378913065775496824682182051857728E+216DL, /* 2**718 */ 2.757826131550993649364364103715457E+216DL, /* 2**719 */ 5.515652263101987298728728207430914E+216DL, /* 2**720 */ 1.103130452620397459745745641486183E+217DL, /* 2**721 */ 2.206260905240794919491491282972366E+217DL, /* 2**722 */ 4.412521810481589838982982565944731E+217DL, /* 2**723 */ 8.825043620963179677965965131889462E+217DL, /* 2**724 */ 1.765008724192635935593193026377892E+218DL, /* 2**725 */ 3.530017448385271871186386052755785E+218DL, /* 2**726 */ 7.060034896770543742372772105511570E+218DL, /* 2**727 */ 1.412006979354108748474554421102314E+219DL, /* 2**728 */ 2.824013958708217496949108842204628E+219DL, /* 2**729 */ 5.648027917416434993898217684409256E+219DL, /* 2**730 */ 1.129605583483286998779643536881851E+220DL, /* 2**731 */ 2.259211166966573997559287073763702E+220DL, /* 2**732 */ 4.518422333933147995118574147527405E+220DL, /* 2**733 */ 9.036844667866295990237148295054809E+220DL, /* 2**734 */ 1.807368933573259198047429659010962E+221DL, /* 2**735 */ 3.614737867146518396094859318021924E+221DL, /* 2**736 */ 7.229475734293036792189718636043847E+221DL, /* 2**737 */ 1.445895146858607358437943727208769E+222DL, /* 2**738 */ 2.891790293717214716875887454417539E+222DL, /* 2**739 */ 5.783580587434429433751774908835078E+222DL, /* 2**740 */ 1.156716117486885886750354981767016E+223DL, /* 2**741 */ 2.313432234973771773500709963534031E+223DL, /* 2**742 */ 4.626864469947543547001419927068062E+223DL, /* 2**743 */ 9.253728939895087094002839854136125E+223DL, /* 2**744 */ 1.850745787979017418800567970827225E+224DL, /* 2**745 */ 3.701491575958034837601135941654450E+224DL, /* 2**746 */ 7.402983151916069675202271883308900E+224DL, /* 2**747 */ 1.480596630383213935040454376661780E+225DL, /* 2**748 */ 2.961193260766427870080908753323560E+225DL, /* 2**749 */ 5.922386521532855740161817506647120E+225DL, /* 2**750 */ 1.184477304306571148032363501329424E+226DL, /* 2**751 */ 2.368954608613142296064727002658848E+226DL, /* 2**752 */ 4.737909217226284592129454005317696E+226DL, /* 2**753 */ 9.475818434452569184258908010635392E+226DL, /* 2**754 */ 1.895163686890513836851781602127078E+227DL, /* 2**755 */ 3.790327373781027673703563204254157E+227DL, /* 2**756 */ 7.580654747562055347407126408508313E+227DL, /* 2**757 */ 1.516130949512411069481425281701663E+228DL, /* 2**758 */ 3.032261899024822138962850563403325E+228DL, /* 2**759 */ 6.064523798049644277925701126806651E+228DL, /* 2**760 */ 1.212904759609928855585140225361330E+229DL, /* 2**761 */ 2.425809519219857711170280450722660E+229DL, /* 2**762 */ 4.851619038439715422340560901445320E+229DL, /* 2**763 */ 9.703238076879430844681121802890641E+229DL, /* 2**764 */ 1.940647615375886168936224360578128E+230DL, /* 2**765 */ 3.881295230751772337872448721156256E+230DL, /* 2**766 */ 7.762590461503544675744897442312513E+230DL, /* 2**767 */ 1.552518092300708935148979488462503E+231DL, /* 2**768 */ 3.105036184601417870297958976925005E+231DL, /* 2**769 */ 6.210072369202835740595917953850010E+231DL, /* 2**770 */ 1.242014473840567148119183590770002E+232DL, /* 2**771 */ 2.484028947681134296238367181540004E+232DL, /* 2**772 */ 4.968057895362268592476734363080008E+232DL, /* 2**773 */ 9.936115790724537184953468726160016E+232DL, /* 2**774 */ 1.987223158144907436990693745232003E+233DL, /* 2**775 */ 3.974446316289814873981387490464007E+233DL, /* 2**776 */ 7.948892632579629747962774980928013E+233DL, /* 2**777 */ 1.589778526515925949592554996185603E+234DL, /* 2**778 */ 3.179557053031851899185109992371205E+234DL, /* 2**779 */ 6.359114106063703798370219984742410E+234DL, /* 2**780 */ 1.271822821212740759674043996948482E+235DL, /* 2**781 */ 2.543645642425481519348087993896964E+235DL, /* 2**782 */ 5.087291284850963038696175987793928E+235DL, /* 2**783 */ 1.017458256970192607739235197558786E+236DL, /* 2**784 */ 2.034916513940385215478470395117571E+236DL, /* 2**785 */ 4.069833027880770430956940790235143E+236DL, /* 2**786 */ 8.139666055761540861913881580470285E+236DL, /* 2**787 */ 1.627933211152308172382776316094057E+237DL, /* 2**788 */ 3.255866422304616344765552632188114E+237DL, /* 2**789 */ 6.511732844609232689531105264376228E+237DL, /* 2**790 */ 1.302346568921846537906221052875246E+238DL, /* 2**791 */ 2.604693137843693075812442105750491E+238DL, /* 2**792 */ 5.209386275687386151624884211500983E+238DL, /* 2**793 */ 1.041877255137477230324976842300197E+239DL, /* 2**794 */ 2.083754510274954460649953684600393E+239DL, /* 2**795 */ 4.167509020549908921299907369200786E+239DL, /* 2**796 */ 8.335018041099817842599814738401572E+239DL, /* 2**797 */ 1.667003608219963568519962947680314E+240DL, /* 2**798 */ 3.334007216439927137039925895360629E+240DL, /* 2**799 */ 6.668014432879854274079851790721258E+240DL, /* 2**800 */ 1.333602886575970854815970358144252E+241DL, /* 2**801 */ 2.667205773151941709631940716288503E+241DL, /* 2**802 */ 5.334411546303883419263881432577006E+241DL, /* 2**803 */ 1.066882309260776683852776286515401E+242DL, /* 2**804 */ 2.133764618521553367705552573030802E+242DL, /* 2**805 */ 4.267529237043106735411105146061605E+242DL, /* 2**806 */ 8.535058474086213470822210292123210E+242DL, /* 2**807 */ 1.707011694817242694164442058424642E+243DL, /* 2**808 */ 3.414023389634485388328884116849284E+243DL, /* 2**809 */ 6.828046779268970776657768233698568E+243DL, /* 2**810 */ 1.365609355853794155331553646739714E+244DL, /* 2**811 */ 2.731218711707588310663107293479427E+244DL, /* 2**812 */ 5.462437423415176621326214586958854E+244DL, /* 2**813 */ 1.092487484683035324265242917391771E+245DL, /* 2**814 */ 2.184974969366070648530485834783542E+245DL, /* 2**815 */ 4.369949938732141297060971669567084E+245DL, /* 2**816 */ 8.739899877464282594121943339134167E+245DL, /* 2**817 */ 1.747979975492856518824388667826833E+246DL, /* 2**818 */ 3.495959950985713037648777335653667E+246DL, /* 2**819 */ 6.991919901971426075297554671307334E+246DL, /* 2**820 */ 1.398383980394285215059510934261467E+247DL, /* 2**821 */ 2.796767960788570430119021868522933E+247DL, /* 2**822 */ 5.593535921577140860238043737045867E+247DL, /* 2**823 */ 1.118707184315428172047608747409173E+248DL, /* 2**824 */ 2.237414368630856344095217494818347E+248DL, /* 2**825 */ 4.474828737261712688190434989636694E+248DL, /* 2**826 */ 8.949657474523425376380869979273387E+248DL, /* 2**827 */ 1.789931494904685075276173995854677E+249DL, /* 2**828 */ 3.579862989809370150552347991709355E+249DL, /* 2**829 */ 7.159725979618740301104695983418710E+249DL, /* 2**830 */ 1.431945195923748060220939196683742E+250DL, /* 2**831 */ 2.863890391847496120441878393367484E+250DL, /* 2**832 */ 5.727780783694992240883756786734968E+250DL, /* 2**833 */ 1.145556156738998448176751357346994E+251DL, /* 2**834 */ 2.291112313477996896353502714693987E+251DL, /* 2**835 */ 4.582224626955993792707005429387974E+251DL, /* 2**836 */ 9.164449253911987585414010858775948E+251DL, /* 2**837 */ 1.832889850782397517082802171755190E+252DL, /* 2**838 */ 3.665779701564795034165604343510379E+252DL, /* 2**839 */ 7.331559403129590068331208687020759E+252DL, /* 2**840 */ 1.466311880625918013666241737404152E+253DL, /* 2**841 */ 2.932623761251836027332483474808303E+253DL, /* 2**842 */ 5.865247522503672054664966949616607E+253DL, /* 2**843 */ 1.173049504500734410932993389923321E+254DL, /* 2**844 */ 2.346099009001468821865986779846643E+254DL, /* 2**845 */ 4.692198018002937643731973559693286E+254DL, /* 2**846 */ 9.384396036005875287463947119386571E+254DL, /* 2**847 */ 1.876879207201175057492789423877314E+255DL, /* 2**848 */ 3.753758414402350114985578847754628E+255DL, /* 2**849 */ 7.507516828804700229971157695509257E+255DL, /* 2**850 */ 1.501503365760940045994231539101851E+256DL, /* 2**851 */ 3.003006731521880091988463078203703E+256DL, /* 2**852 */ 6.006013463043760183976926156407405E+256DL, /* 2**853 */ 1.201202692608752036795385231281481E+257DL, /* 2**854 */ 2.402405385217504073590770462562962E+257DL, /* 2**855 */ 4.804810770435008147181540925125924E+257DL, /* 2**856 */ 9.609621540870016294363081850251849E+257DL, /* 2**857 */ 1.921924308174003258872616370050370E+258DL, /* 2**858 */ 3.843848616348006517745232740100740E+258DL, /* 2**859 */ 7.687697232696013035490465480201479E+258DL, /* 2**860 */ 1.537539446539202607098093096040296E+259DL, /* 2**861 */ 3.075078893078405214196186192080592E+259DL, /* 2**862 */ 6.150157786156810428392372384161183E+259DL, /* 2**863 */ 1.230031557231362085678474476832237E+260DL, /* 2**864 */ 2.460063114462724171356948953664473E+260DL, /* 2**865 */ 4.920126228925448342713897907328947E+260DL, /* 2**866 */ 9.840252457850896685427795814657893E+260DL, /* 2**867 */ 1.968050491570179337085559162931579E+261DL, /* 2**868 */ 3.936100983140358674171118325863157E+261DL, /* 2**869 */ 7.872201966280717348342236651726315E+261DL, /* 2**870 */ 1.574440393256143469668447330345263E+262DL, /* 2**871 */ 3.148880786512286939336894660690526E+262DL, /* 2**872 */ 6.297761573024573878673789321381052E+262DL, /* 2**873 */ 1.259552314604914775734757864276210E+263DL, /* 2**874 */ 2.519104629209829551469515728552421E+263DL, /* 2**875 */ 5.038209258419659102939031457104841E+263DL, /* 2**876 */ 1.007641851683931820587806291420968E+264DL, /* 2**877 */ 2.015283703367863641175612582841937E+264DL, /* 2**878 */ 4.030567406735727282351225165683873E+264DL, /* 2**879 */ 8.061134813471454564702450331367746E+264DL, /* 2**880 */ 1.612226962694290912940490066273549E+265DL, /* 2**881 */ 3.224453925388581825880980132547098E+265DL, /* 2**882 */ 6.448907850777163651761960265094197E+265DL, /* 2**883 */ 1.289781570155432730352392053018839E+266DL, /* 2**884 */ 2.579563140310865460704784106037679E+266DL, /* 2**885 */ 5.159126280621730921409568212075357E+266DL, /* 2**886 */ 1.031825256124346184281913642415071E+267DL, /* 2**887 */ 2.063650512248692368563827284830143E+267DL, /* 2**888 */ 4.127301024497384737127654569660286E+267DL, /* 2**889 */ 8.254602048994769474255309139320572E+267DL, /* 2**890 */ 1.650920409798953894851061827864114E+268DL, /* 2**891 */ 3.301840819597907789702123655728229E+268DL, /* 2**892 */ 6.603681639195815579404247311456458E+268DL, /* 2**893 */ 1.320736327839163115880849462291292E+269DL, /* 2**894 */ 2.641472655678326231761698924582583E+269DL, /* 2**895 */ 5.282945311356652463523397849165166E+269DL, /* 2**896 */ 1.056589062271330492704679569833033E+270DL, /* 2**897 */ 2.113178124542660985409359139666066E+270DL, /* 2**898 */ 4.226356249085321970818718279332133E+270DL, /* 2**899 */ 8.452712498170643941637436558664266E+270DL, /* 2**900 */ 1.690542499634128788327487311732853E+271DL, /* 2**901 */ 3.381084999268257576654974623465706E+271DL, /* 2**902 */ 6.762169998536515153309949246931413E+271DL, /* 2**903 */ 1.352433999707303030661989849386283E+272DL, /* 2**904 */ 2.704867999414606061323979698772565E+272DL, /* 2**905 */ 5.409735998829212122647959397545130E+272DL, /* 2**906 */ 1.081947199765842424529591879509026E+273DL, /* 2**907 */ 2.163894399531684849059183759018052E+273DL, /* 2**908 */ 4.327788799063369698118367518036104E+273DL, /* 2**909 */ 8.655577598126739396236735036072208E+273DL, /* 2**910 */ 1.731115519625347879247347007214442E+274DL, /* 2**911 */ 3.462231039250695758494694014428883E+274DL, /* 2**912 */ 6.924462078501391516989388028857766E+274DL, /* 2**913 */ 1.384892415700278303397877605771553E+275DL, /* 2**914 */ 2.769784831400556606795755211543107E+275DL, /* 2**915 */ 5.539569662801113213591510423086213E+275DL, /* 2**916 */ 1.107913932560222642718302084617243E+276DL, /* 2**917 */ 2.215827865120445285436604169234485E+276DL, /* 2**918 */ 4.431655730240890570873208338468971E+276DL, /* 2**919 */ 8.863311460481781141746416676937941E+276DL, /* 2**920 */ 1.772662292096356228349283335387588E+277DL, /* 2**921 */ 3.545324584192712456698566670775176E+277DL, /* 2**922 */ 7.090649168385424913397133341550353E+277DL, /* 2**923 */ 1.418129833677084982679426668310071E+278DL, /* 2**924 */ 2.836259667354169965358853336620141E+278DL, /* 2**925 */ 5.672519334708339930717706673240282E+278DL, /* 2**926 */ 1.134503866941667986143541334648056E+279DL, /* 2**927 */ 2.269007733883335972287082669296113E+279DL, /* 2**928 */ 4.538015467766671944574165338592226E+279DL, /* 2**929 */ 9.076030935533343889148330677184452E+279DL, /* 2**930 */ 1.815206187106668777829666135436890E+280DL, /* 2**931 */ 3.630412374213337555659332270873781E+280DL, /* 2**932 */ 7.260824748426675111318664541747561E+280DL, /* 2**933 */ 1.452164949685335022263732908349512E+281DL, /* 2**934 */ 2.904329899370670044527465816699025E+281DL, /* 2**935 */ 5.808659798741340089054931633398049E+281DL, /* 2**936 */ 1.161731959748268017810986326679610E+282DL, /* 2**937 */ 2.323463919496536035621972653359220E+282DL, /* 2**938 */ 4.646927838993072071243945306718439E+282DL, /* 2**939 */ 9.293855677986144142487890613436879E+282DL, /* 2**940 */ 1.858771135597228828497578122687376E+283DL, /* 2**941 */ 3.717542271194457656995156245374751E+283DL, /* 2**942 */ 7.435084542388915313990312490749503E+283DL, /* 2**943 */ 1.487016908477783062798062498149901E+284DL, /* 2**944 */ 2.974033816955566125596124996299801E+284DL, /* 2**945 */ 5.948067633911132251192249992599602E+284DL, /* 2**946 */ 1.189613526782226450238449998519920E+285DL, /* 2**947 */ 2.379227053564452900476899997039841E+285DL, /* 2**948 */ 4.758454107128905800953799994079682E+285DL, /* 2**949 */ 9.516908214257811601907599988159364E+285DL, /* 2**950 */ 1.903381642851562320381519997631873E+286DL, /* 2**951 */ 3.806763285703124640763039995263745E+286DL, /* 2**952 */ 7.613526571406249281526079990527491E+286DL, /* 2**953 */ 1.522705314281249856305215998105498E+287DL, /* 2**954 */ 3.045410628562499712610431996210996E+287DL, /* 2**955 */ 6.090821257124999425220863992421993E+287DL, /* 2**956 */ 1.218164251424999885044172798484399E+288DL, /* 2**957 */ 2.436328502849999770088345596968797E+288DL, /* 2**958 */ 4.872657005699999540176691193937594E+288DL, /* 2**959 */ 9.745314011399999080353382387875188E+288DL, /* 2**960 */ 1.949062802279999816070676477575038E+289DL, /* 2**961 */ 3.898125604559999632141352955150075E+289DL, /* 2**962 */ 7.796251209119999264282705910300151E+289DL, /* 2**963 */ 1.559250241823999852856541182060030E+290DL, /* 2**964 */ 3.118500483647999705713082364120060E+290DL, /* 2**965 */ 6.237000967295999411426164728240121E+290DL, /* 2**966 */ 1.247400193459199882285232945648024E+291DL, /* 2**967 */ 2.494800386918399764570465891296048E+291DL, /* 2**968 */ 4.989600773836799529140931782592096E+291DL, /* 2**969 */ 9.979201547673599058281863565184193E+291DL, /* 2**970 */ 1.995840309534719811656372713036839E+292DL, /* 2**971 */ 3.991680619069439623312745426073677E+292DL, /* 2**972 */ 7.983361238138879246625490852147354E+292DL, /* 2**973 */ 1.596672247627775849325098170429471E+293DL, /* 2**974 */ 3.193344495255551698650196340858942E+293DL, /* 2**975 */ 6.386688990511103397300392681717883E+293DL, /* 2**976 */ 1.277337798102220679460078536343577E+294DL, /* 2**977 */ 2.554675596204441358920157072687153E+294DL, /* 2**978 */ 5.109351192408882717840314145374307E+294DL, /* 2**979 */ 1.021870238481776543568062829074861E+295DL, /* 2**980 */ 2.043740476963553087136125658149723E+295DL, /* 2**981 */ 4.087480953927106174272251316299445E+295DL, /* 2**982 */ 8.174961907854212348544502632598891E+295DL, /* 2**983 */ 1.634992381570842469708900526519778E+296DL, /* 2**984 */ 3.269984763141684939417801053039556E+296DL, /* 2**985 */ 6.539969526283369878835602106079113E+296DL, /* 2**986 */ 1.307993905256673975767120421215823E+297DL, /* 2**987 */ 2.615987810513347951534240842431645E+297DL, /* 2**988 */ 5.231975621026695903068481684863290E+297DL, /* 2**989 */ 1.046395124205339180613696336972658E+298DL, /* 2**990 */ 2.092790248410678361227392673945316E+298DL, /* 2**991 */ 4.185580496821356722454785347890632E+298DL, /* 2**992 */ 8.371160993642713444909570695781264E+298DL, /* 2**993 */ 1.674232198728542688981914139156253E+299DL, /* 2**994 */ 3.348464397457085377963828278312506E+299DL, /* 2**995 */ 6.696928794914170755927656556625011E+299DL, /* 2**996 */ 1.339385758982834151185531311325002E+300DL, /* 2**997 */ 2.678771517965668302371062622650005E+300DL, /* 2**998 */ 5.357543035931336604742125245300009E+300DL, /* 2**999 */ 1.071508607186267320948425049060002E+301DL, /* 2**1000 */ 2.143017214372534641896850098120004E+301DL, /* 2**1001 */ 4.286034428745069283793700196240007E+301DL, /* 2**1002 */ 8.572068857490138567587400392480014E+301DL, /* 2**1003 */ 1.714413771498027713517480078496003E+302DL, /* 2**1004 */ 3.428827542996055427034960156992006E+302DL, /* 2**1005 */ 6.857655085992110854069920313984012E+302DL, /* 2**1006 */ 1.371531017198422170813984062796802E+303DL, /* 2**1007 */ 2.743062034396844341627968125593605E+303DL, /* 2**1008 */ 5.486124068793688683255936251187209E+303DL, /* 2**1009 */ 1.097224813758737736651187250237442E+304DL, /* 2**1010 */ 2.194449627517475473302374500474884E+304DL, /* 2**1011 */ 4.388899255034950946604749000949767E+304DL, /* 2**1012 */ 8.777798510069901893209498001899535E+304DL, /* 2**1013 */ 1.755559702013980378641899600379907E+305DL, /* 2**1014 */ 3.511119404027960757283799200759814E+305DL, /* 2**1015 */ 7.022238808055921514567598401519628E+305DL, /* 2**1016 */ 1.404447761611184302913519680303926E+306DL, /* 2**1017 */ 2.808895523222368605827039360607851E+306DL, /* 2**1018 */ 5.617791046444737211654078721215702E+306DL, /* 2**1019 */ 1.123558209288947442330815744243140E+307DL, /* 2**1020 */ 2.247116418577894884661631488486281E+307DL, /* 2**1021 */ 4.494232837155789769323262976972562E+307DL, /* 2**1022 */ 8.988465674311579538646525953945124E+307DL, /* 2**1023 */ 1.797693134862315907729305190789025E+308DL, /* 2**1024 */ 3.595386269724631815458610381578049E+308DL, /* 2**1025 */ 7.190772539449263630917220763156099E+308DL, /* 2**1026 */ 1.438154507889852726183444152631220E+309DL, /* 2**1027 */ 2.876309015779705452366888305262440E+309DL, /* 2**1028 */ 5.752618031559410904733776610524879E+309DL, /* 2**1029 */ 1.150523606311882180946755322104976E+310DL, /* 2**1030 */ 2.301047212623764361893510644209952E+310DL, /* 2**1031 */ 4.602094425247528723787021288419903E+310DL, /* 2**1032 */ 9.204188850495057447574042576839807E+310DL, /* 2**1033 */ 1.840837770099011489514808515367961E+311DL, /* 2**1034 */ 3.681675540198022979029617030735923E+311DL, /* 2**1035 */ 7.363351080396045958059234061471845E+311DL, /* 2**1036 */ 1.472670216079209191611846812294369E+312DL, /* 2**1037 */ 2.945340432158418383223693624588738E+312DL, /* 2**1038 */ 5.890680864316836766447387249177476E+312DL, /* 2**1039 */ 1.178136172863367353289477449835495E+313DL, /* 2**1040 */ 2.356272345726734706578954899670990E+313DL, /* 2**1041 */ 4.712544691453469413157909799341981E+313DL, /* 2**1042 */ 9.425089382906938826315819598683962E+313DL, /* 2**1043 */ 1.885017876581387765263163919736792E+314DL, /* 2**1044 */ 3.770035753162775530526327839473585E+314DL, /* 2**1045 */ 7.540071506325551061052655678947170E+314DL, /* 2**1046 */ 1.508014301265110212210531135789434E+315DL, /* 2**1047 */ 3.016028602530220424421062271578868E+315DL, /* 2**1048 */ 6.032057205060440848842124543157736E+315DL, /* 2**1049 */ 1.206411441012088169768424908631547E+316DL, /* 2**1050 */ 2.412822882024176339536849817263094E+316DL, /* 2**1051 */ 4.825645764048352679073699634526189E+316DL, /* 2**1052 */ 9.651291528096705358147399269052377E+316DL, /* 2**1053 */ 1.930258305619341071629479853810475E+317DL, /* 2**1054 */ 3.860516611238682143258959707620951E+317DL, /* 2**1055 */ 7.721033222477364286517919415241902E+317DL, /* 2**1056 */ 1.544206644495472857303583883048380E+318DL, /* 2**1057 */ 3.088413288990945714607167766096761E+318DL, /* 2**1058 */ 6.176826577981891429214335532193521E+318DL, /* 2**1059 */ 1.235365315596378285842867106438704E+319DL, /* 2**1060 */ 2.470730631192756571685734212877409E+319DL, /* 2**1061 */ 4.941461262385513143371468425754817E+319DL, /* 2**1062 */ 9.882922524771026286742936851509634E+319DL, /* 2**1063 */ 1.976584504954205257348587370301927E+320DL, /* 2**1064 */ 3.953169009908410514697174740603854E+320DL, /* 2**1065 */ 7.906338019816821029394349481207707E+320DL, /* 2**1066 */ 1.581267603963364205878869896241541E+321DL, /* 2**1067 */ 3.162535207926728411757739792483083E+321DL, /* 2**1068 */ 6.325070415853456823515479584966166E+321DL, /* 2**1069 */ 1.265014083170691364703095916993233E+322DL, /* 2**1070 */ 2.530028166341382729406191833986466E+322DL, /* 2**1071 */ 5.060056332682765458812383667972933E+322DL, /* 2**1072 */ 1.012011266536553091762476733594587E+323DL, /* 2**1073 */ 2.024022533073106183524953467189173E+323DL, /* 2**1074 */ 4.048045066146212367049906934378346E+323DL, /* 2**1075 */ 8.096090132292424734099813868756692E+323DL, /* 2**1076 */ 1.619218026458484946819962773751338E+324DL /* 2**1077 */ }; weak_alias(decpowof2, __decpowof2) libdfp-1.0.12/sysdeps/generic/libdfp-test-ulps000066400000000000000000000001241261375163000212630ustar00rootroot00000000000000# File with deltas for libdfp-test # This file is the fallback and contains no data libdfp-1.0.12/sysdeps/generic/localplt.data000066400000000000000000000001401261375163000206050ustar00rootroot00000000000000# See scripts/check-localplt.awk for how this file is processed. libdfp.so: register_printf_dfp libdfp-1.0.12/sysdeps/generic/mapround.c000066400000000000000000000051041261375163000201360ustar00rootroot00000000000000/* Get the Decimal Float rounding mode mapped to the decNumber rounding mode enumeration values. Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include #include int __dn_getround(void) { /* Only match on supported rounding modes. Power6[x] hardware supports the * greatest number of rounding modes. The decNumber library supports * one fewer than Power6[x] hardware. */ /* C Rounding Mode: Hardware Description * DecNumber description * * FE_DEC_TONEAREST: 000 Round to nearest, ties to even. * DEC_ROUND_HALF_EVEN * * FE_DEC_TOWARDZERO: 001 Round toward zero. * DEC_ROUND_DOWN * * FE_DEC_UPWARD: 010 Round toward +Infinity * DEC_ROUND_CEILING * * FE_DEC_DOWNWARD: 011 Round toward -Infinity * DEC_ROUND_FLOOR * * FE_DEC_TONEARESTFROMZERO: 100 Round to nearest, ties away from zero * DEC_ROUND_HALF_UP * * 5: 101 Round to nearest, ties toward zero * DEC_ROUND_HALF_DOWN * * 6: 110 Round away from zero * DEC_ROUND_UP * * 7: 111 Round for prepare for shorter precision * Not supported by decNumber. */ switch(__fe_dec_getround()) { case FE_DEC_TONEAREST: return DEC_ROUND_HALF_EVEN; case FE_DEC_TOWARDZERO: return DEC_ROUND_DOWN; case FE_DEC_UPWARD: return DEC_ROUND_CEILING; case FE_DEC_DOWNWARD: return DEC_ROUND_FLOOR; case FE_DEC_TONEARESTFROMZERO: return DEC_ROUND_HALF_UP; case 5: return DEC_ROUND_HALF_DOWN; case 6: return DEC_ROUND_UP; case 7: default: return DEC_ROUND_HALF_EVEN; } } libdfp-1.0.12/sysdeps/generic/math_private.h000066400000000000000000000100411261375163000207750ustar00rootroot00000000000000/* Helper macros and functions to manipulate IEEE 754 bitwise. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #ifndef _MATH_PRIVATE_H # define _MATH_PRIVATE_H #include #include typedef union { _Decimal128 value; struct { #if __BYTE_ORDER == __LITTLE_ENDIAN uint32_t w4; uint32_t w3; uint32_t w2; uint32_t w1; #elif __BYTE_ORDER == __BIG_ENDIAN uint32_t w1; uint32_t w2; uint32_t w3; uint32_t w4; #endif } parts32; struct { #if __BYTE_ORDER == __LITTLE_ENDIAN uint64_t dw2; uint64_t dw1; #elif __BYTE_ORDER == __BIG_ENDIAN uint64_t dw1; uint64_t dw2; #endif } parts64; } ieee754r_dec128_shape_type; /* Get more significant 64 bit int from a _Decimal128 */ #define GET_DEC128_HIGH_WORD64(i,d) \ do { \ ieee754r_dec128_shape_type gf_u; \ gf_u.value = (d); \ (i) = gf_u.parts64.dw1; \ } while (0) #define DEC128_NAN_MASK64 UINT64_C(0x7C00000000000000) #define DEC128_SNAN_MASK64 UINT64_C(0x7E00000000000000) #define DEC128_INF_MASK64 UINT64_C(0x7800000000000000) typedef union { _Decimal64 value; struct { #if __BYTE_ORDER == __LITTLE_ENDIAN uint32_t lsw; uint32_t msw; #elif __BYTE_ORDER == __BIG_ENDIAN uint32_t msw; uint32_t lsw; #endif } parts; uint64_t word; } ieee754r_dec64_shape_type; /* Get a 64 bit int from a _Decimal64 */ #define GET_DEC64_WORD64(i,d) \ do { \ ieee754r_dec64_shape_type gf_u; \ gf_u.value = (d); \ (i) = gf_u.word; \ } while (0) #define DEC64_NAN_MASK64 UINT64_C(0x7C00000000000000) #define DEC64_SNAN_MASK64 UINT64_C(0x7E00000000000000) #define DEC64_INF_MASK64 UINT64_C(0x7800000000000000) typedef union { _Decimal32 value; uint32_t word; } ieee754r_dec32_shape_type; /* Get a 32 bit int from a _Decimal32 */ #define GET_DEC32_WORD(i,d) \ do { \ ieee754r_dec32_shape_type gf_u; \ gf_u.value = (d); \ (i) = gf_u.word; \ } while (0) #define DEC32_NAN_MASK 0x7C000000 #define DEC32_SNAN_MASK 0x7E000000 #define DEC32_INF_MASK 0x78000000 /* A union which permits us to convert between a float and a 32 bit int. */ typedef union { float value; uint32_t word; } ieee754_float_shape_type; /* Get a 32 bit int from a float. */ #define GET_FLOAT_WORD(i,d) \ do { \ ieee754_float_shape_type gf_u; \ gf_u.value = (d); \ (i) = gf_u.word; \ } while (0) /* A union which permits us to convert between a double and two 32 bit ints. */ typedef union { double value; struct { #if __FLOAT_WORD_ORDER == BIG_ENDIAN uint32_t msw; uint32_t lsw; #else uint32_t lsw; uint32_t msw; #endif } parts; uint64_t word; } ieee754_double_shape_type; #define EXTRACT_WORDS64(i,d) \ do { \ ieee754_double_shape_type gh_u; \ gh_u.value = (d); \ (i) = gh_u.word; \ } while (0) #endif libdfp-1.0.12/sysdeps/powerpc/000077500000000000000000000000001261375163000162105ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/dfpu/000077500000000000000000000000001261375163000171465ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/dfpu/ceild128.c000066400000000000000000000021551261375163000206300ustar00rootroot00000000000000/* _Decimal128 ceild128 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal128 __ceild128 (_Decimal128 x) { _Decimal128 ret; asm ("drintnq 1,%0,%1,0\n" : "=f"(ret) : "f"(x)); return ret; } weak_alias (__ceild128, ceild128) libdfp-1.0.12/sysdeps/powerpc/dfpu/ceild32.c000066400000000000000000000021631261375163000205410ustar00rootroot00000000000000/* _Decimal32 ceild32 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal32 __ceild32 (_Decimal32 x) { _Decimal64 ret; asm ("drintn 1,%0,%1,0\n" : "=f"(ret) : "f"((_Decimal64) x)); return ret; } weak_alias (__ceild32, ceild32) libdfp-1.0.12/sysdeps/powerpc/dfpu/ceild64.c000066400000000000000000000021461261375163000205470ustar00rootroot00000000000000/* _Decimal64 ceild64 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal64 __ceild64 (_Decimal64 x) { _Decimal64 ret; asm ("drintn 1,%0,%1,0\n" : "=f"(ret) : "f"(x)); return ret; } weak_alias (__ceild64, ceild64) libdfp-1.0.12/sysdeps/powerpc/dfpu/copysignd128.c000066400000000000000000000023701261375163000215460ustar00rootroot00000000000000/* _Decimal128 copy sign of a number. Copyright (C) 2014-2015 Free Software Foundation, Inc. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include _Decimal128 __copysignd128 (_Decimal128 x, _Decimal128 y) { /* Half part os decimal128 constainst the sign bit at same position as binary64, so the instruction works for both formats. */ _Decimal128 ret; asm ("fcpsgn %0,%1,%2\n" : "=d"(ret) : "d"(y), "d"(x)); return ret; } weak_alias (__copysignd128, copysignd128) libdfp-1.0.12/sysdeps/powerpc/dfpu/copysignd32.c000066400000000000000000000025051261375163000214600ustar00rootroot00000000000000/* _Decimal32 copy sign of a number. Copyright (C) 2014-2015 Free Software Foundation, Inc. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include _Decimal32 __copysignd32 (_Decimal32 x, _Decimal32 y) { /* Both binary32 and decimal32 have the sign bit at same position, so the instruction works for both format. */ _Decimal64 tmp; asm ("dctdp %1, %1\n" /* DFP Convert To DFP Long */ "dctdp %2, %2\n" "fcpsgn %0, %1, %2\n" : "=f"(tmp) : "f" (y), "f"(x)); return (_Decimal32)tmp; } weak_alias (__copysignd32, copysignd32) libdfp-1.0.12/sysdeps/powerpc/dfpu/copysignd64.c000066400000000000000000000023451261375163000214670ustar00rootroot00000000000000/* _Decimal64 copy sign of a number. Copyright (C) 2014-2015 Free Software Foundation, Inc. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include _Decimal64 __copysignd64 (_Decimal64 x, _Decimal64 y) { /* Both binary64 and decimal64 have the sign bit at same position, so the instruction works for both format. */ _Decimal64 ret; asm ("fcpsgn %0, %1, %2\n" : "=d"(ret) : "d"(y), "d"(x)); return ret; } weak_alias (__copysignd64, copysignd64) libdfp-1.0.12/sysdeps/powerpc/dfpu/ddlogtbls.h000066400000000000000000001763041261375163000213100ustar00rootroot00000000000000/* Generated lookup tables. Copyright (C) 2010-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #ifndef _DDLOGTBLS_H #define _DDLOGTBLS_H 1 const _Decimal128 __LN_10 = 2.302585092994045684017991454684364e+00DL; const _Decimal128 __LN2digits [] = { HUGE_VAL_D128, /* ln(0.00DL) */ -4.605170185988091368035982909368728DL, /* ln(0.01DL) */ -3.912023005428146058618750787910552DL, /* ln(0.02DL) */ -3.506557897319981676640737672446203DL, /* ln(0.03DL) */ -3.218875824868200749201518666452375DL, /* ln(0.04DL) */ -2.995732273553990993435223576142541DL, /* ln(0.05DL) */ -2.813410716760036367223505550988026DL, /* ln(0.06DL) */ -2.659260036932778062930630165925549DL, /* ln(0.07DL) */ -2.525728644308255439784286544994199DL, /* ln(0.08DL) */ -2.407945608651871985245492435523677DL, /* ln(0.09DL) */ -2.302585092994045684017991454684364DL, /* ln(0.10DL) */ -2.207274913189720823974039331403599DL, /* ln(0.11DL) */ -2.120263536200091057806273429529850DL, /* ln(0.12DL) */ -2.040220828526554631982495467803410DL, /* ln(0.13DL) */ -1.966112856372832753513398044467372DL, /* ln(0.14DL) */ -1.897119984885881302039978339220015DL, /* ln(0.15DL) */ -1.832581463748310130367054423536022DL, /* ln(0.16DL) */ -1.771956841931875287786448291495602DL, /* ln(0.17DL) */ -1.714798428091926675828260314065500DL, /* ln(0.18DL) */ -1.660731206821650908026955477480875DL, /* ln(0.19DL) */ -1.609437912434100374600759333226188DL, /* ln(0.20DL) */ -1.560647748264668371535384929003023DL, /* ln(0.21DL) */ -1.514127732629775514556807209945423DL, /* ln(0.22DL) */ -1.469675970058941677229230077558532DL, /* ln(0.23DL) */ -1.427116355640145748389041308071673DL, /* ln(0.24DL) */ -1.386294361119890618834464242916353DL, /* ln(0.25DL) */ -1.347073647966609322565263346345233DL, /* ln(0.26DL) */ -1.309333319983762293850247198601151DL, /* ln(0.27DL) */ -1.272965675812887444096165923009196DL, /* ln(0.28DL) */ -1.237874356001617340852710877006817DL, /* ln(0.29DL) */ -1.203972804325935992622746217761839DL, /* ln(0.30DL) */ -1.171182981502945122106818584826371DL, /* ln(0.31DL) */ -1.139434283188364820949822302077846DL, /* ln(0.32DL) */ -1.108662624521611132578794094481073DL, /* ln(0.33DL) */ -1.078809661371929978369216170037425DL, /* ln(0.34DL) */ -1.049822124498677688329870832699361DL, /* ln(0.35DL) */ -1.021651247531981366411028192607324DL, /* ln(0.36DL) */ -0.9942522733438669236678872383372813DL, /* ln(0.37DL) */ -0.9675840262617055986097233560226983DL, /* ln(0.38DL) */ -0.9416085398584449405872502308808841DL, /* ln(0.39DL) */ -0.9162907318741550651835272117680111DL, /* ln(0.40DL) */ -0.8915981192837835641692195363313208DL, /* ln(0.41DL) */ -0.8675005677047230621181528075448464DL, /* ln(0.42DL) */ -0.8439700702945289445631403960228814DL, /* ln(0.43DL) */ -0.8209805520698302051395750884872460DL, /* ln(0.44DL) */ -0.7985076962177716106447331022974894DL, /* ln(0.45DL) */ -0.7765287894989963678119979561003557DL, /* ln(0.46DL) */ -0.7550225842780327812150322395965547DL, /* ln(0.47DL) */ -0.7339691750802004389718091866134964DL, /* ln(0.48DL) */ -0.7133498878974647578252974224823690DL, /* ln(0.49DL) */ -0.6931471805599453094172321214581766DL, /* ln(0.50DL) */ -0.6733445532637655963912030545730762DL, /* ln(0.51DL) */ -0.6539264674066640131480312248870567DL, /* ln(0.52DL) */ -0.6348782724359695338915137703396706DL, /* ln(0.53DL) */ -0.6161861394238169844330150771429747DL, /* ln(0.54DL) */ -0.5978370007556204493732799981974115DL, /* ln(0.55DL) */ -0.5798184952529421346789338015510190DL, /* ln(0.56DL) */ -0.5621189181535412166317102405583492DL, /* ln(0.57DL) */ -0.5447271754416720314354787555486402DL, /* ln(0.58DL) */ -0.5276327420823719174199325356490308DL, /* ln(0.59DL) */ -0.5108256237659906832055140963036619DL, /* ln(0.60DL) */ -0.4942963218147801192845938059431137DL, /* ln(0.61DL) */ -0.4780358009429998126895864633681946DL, /* ln(0.62DL) */ -0.4620354595965586801401396920804973DL, /* ln(0.63DL) */ -0.4462871026284195115325901806196690DL, /* ln(0.64DL) */ -0.4307829160924542573817361345772222DL, /* ln(0.65DL) */ -0.4155154439616658231615619730228968DL, /* ln(0.66DL) */ -0.4004775665971253083659109130050057DL, /* ln(0.67DL) */ -0.3856624808119846689519840485792487DL, /* ln(0.68DL) */ -0.3710636813908319858339848406360066DL, /* ln(0.69DL) */ -0.3566749439387323789126387112411845DL, /* ln(0.70DL) */ -0.3424903089467759467065283768556943DL, /* ln(0.71DL) */ -0.3285040669720360569937960711491473DL, /* ln(0.72DL) */ -0.3147107448397002389438740519301858DL, /* ln(0.73DL) */ -0.3011050927839216142506551168791047DL, /* ln(0.74DL) */ -0.2876820724517809274392190059938274DL, /* ln(0.75DL) */ -0.2744368457017602891924912345645217DL, /* ln(0.76DL) */ -0.2613647641344075188686865879604194DL, /* ln(0.77DL) */ -0.2484613592984996311700181094227075DL, /* ln(0.78DL) */ -0.2357223335210698738630373678873175DL, /* ln(0.79DL) */ -0.2231435513142097557662950903098345DL, /* ln(0.80DL) */ -0.2107210313156526024550019616786256DL, /* ln(0.81DL) */ -0.1984509387238382547519874148731443DL, /* ln(0.82DL) */ -0.1863295781914934445605106860773580DL, /* ln(0.83DL) */ -0.1743533871447777527009206860866698DL, /* ln(0.84DL) */ -0.1625189294977749131856889582694142DL, /* ln(0.85DL) */ -0.1508228897345836351459082745647048DL, /* ln(0.86DL) */ -0.1392620673335076494574656400842911DL, /* ln(0.87DL) */ -0.1278333715098848957223429670290694DL, /* ln(0.88DL) */ -0.1165338162559515297181673686988792DL, /* ln(0.89DL) */ -0.1053605156578263012275009808393128DL, /* ln(0.90DL) */ -0.09431067947124132687714272436023008DL, /* ln(0.91DL) */ -0.08338160893905105839476583464217916DL, /* ln(0.92DL) */ -0.07257069283483543071157334790384550DL, /* ln(0.93DL) */ -0.06187540371808747179780011813837814DL, /* ln(0.94DL) */ -0.05129329438755053342619614425468724DL, /* ln(0.95DL) */ -0.04082199452025512955457706515531987DL, /* ln(0.96DL) */ -0.03045920748470854591926128766476670DL, /* ln(0.97DL) */ -0.02020270731751944840804530102419239DL, /* ln(0.98DL) */ -0.01005033585350144118354885755854771DL, /* ln(0.99DL) */ 0.0DL}; /* ln(1.00DL) */ const _Decimal64 __factorialDD [] = { 1.0DD, /* 0.0! */ 1.0DD, /* 1.0! */ 2.0DD, /* 2.0DD! */ 6.0DD, /* 3.0DD! */ 24.0DD, /* 4.0DD! */ 120.0DD, /* 5.0DD! */ 720.0DD, /* 6.0DD! */ 5040.0DD, /* 7.0DD! */ 40320.0DD, /* 8.0DD! */ 362880.0DD, /* 9.0DD! */ 3628800.0DD, /* 10.0DD! */ 39916800.0DD, /* 11.0DD! */ 479001600.0DD, /* 12.0DD! */ 6227020800.0DD, /* 13.0DD! */ 87178291200.0DD, /* 14.0DD! */ 1307674368000.0DD, /* 15.0DD! */ 20922789888000.0DD, /* 16.0DD! */ 355687428096000.0DD, /* 17.0DD! */ 6402373705728000.0DD, /* 18.0DD! */ 1.216451004088320e+17DD, /* 19.0DD! */ 2.432902008176640e+18DD}; /* 20.0DD! */ const _Decimal64 __oneOverfactDD [] = { 1.0DD, /* 1.0/0.0! */ 1.0DD, /* 1.0/1.0! */ 0.5DD, /* 1.0DD/2.0DD! */ 0.1666666666666667DD, /* 1.0DD/3.0DD! */ 0.04166666666666667DD, /* 1.0DD/4.0DD! */ 0.008333333333333333DD, /* 1.0DD/5.0DD! */ 0.001388888888888889DD, /* 1.0DD/6.0DD! */ 0.0001984126984126984DD, /* 1.0DD/7.0DD! */ 2.48015873015873e-05DD, /* 1.0DD/8.0DD! */ 2.755731922398589e-06DD, /* 1.0DD/9.0DD! */ 2.755731922398589e-07DD, /* 1.0DD/10.0DD! */ 2.505210838544172e-08DD, /* 1.0DD/11.0DD! */ 2.08767569878681e-09DD, /* 1.0DD/12.0DD! */ 1.605904383682161e-10DD, /* 1.0DD/13.0DD! */ 1.147074559772972e-11DD, /* 1.0DD/14.0DD! */ 7.647163731819816e-13DD, /* 1.0DD/15.0DD! */ 4.779477332387385e-14DD, /* 1.0DD/16.0DD! */ 2.811457254345521e-15DD, /* 1.0DD/17.0DD! */ 1.561920696858623e-16DD, /* 1.0DD/18.0DD! */ 8.22063524662433e-18DD, /* 1.0DD/19.0DD! */ 4.110317623312165e-19DD}; /* 1.0DD/20.0DD! */ const _Decimal128 __expIntXDL [] = { 1.0DL, /* exp(0.0DL) */ 2.718281828459045235360287471352662DL, /* exp(1.0DL) */ 7.389056098930650227230427460575008DL, /* exp(2.0DL) */ 20.08553692318766974092852965458172DL, /* exp(3.0DL) */ 54.59815003314423907811026120286088DL, /* exp(4.0DL) */ 148.4131591025766034211155800405523DL, /* exp(5.0DL) */ 403.4287934927351226083871805433883DL, /* exp(6.0DL) */ 1096.633158428458599263720238288121DL, /* exp(7.0DL) */ 2980.957987041728274743592099452889DL, /* exp(8.0DL) */ 8103.083927575384007709996689432760DL, /* exp(9.0DL) */ 22026.46579480671651695790064528424DL, /* exp(10.0DL) */ 59874.14171519781845532648579225778DL, /* exp(11.0DL) */ 162754.7914190039208080052048984868DL, /* exp(12.0DL) */ 442413.3920089205033261027759490883DL, /* exp(13.0DL) */ 1202604.284164776777749236770767859DL, /* exp(14.0DL) */ 3269017.372472110639301855046091721DL, /* exp(15.0DL) */ 8886110.520507872636763023740781450DL, /* exp(16.0DL) */ 24154952.75357529821477543518038582DL, /* exp(17.0DL) */ 65659969.13733051113878650325906003DL, /* exp(18.0DL) */ 178482300.9631872608449100337887227DL, /* exp(19.0DL) */ 485165195.4097902779691068305415406DL, /* exp(20.0DL) */ 1318815734.483214697209998883745303DL, /* exp(21.0DL) */ 3584912846.131591561681159945978421DL, /* exp(22.0DL) */ 9744803446.248902600034632684822975DL, /* exp(23.0DL) */ 26489122129.84347229413916215281188DL, /* exp(24.0DL) */ 72004899337.38587252416135146612616DL, /* exp(25.0DL) */ 195729609428.8387642697763978760953DL, /* exp(26.0DL) */ 532048240601.7986166837473043411974DL, /* exp(27.0DL) */ 1446257064291.475173677047422996929DL, /* exp(28.0DL) */ 3931334297144.042074388620580843528DL, /* exp(29.0DL) */ 10686474581524.46214699046865074140DL, /* exp(30.0DL) */ 29048849665247.42523108568211167983DL, /* exp(31.0DL) */ 78962960182680.69516097802263510822DL, /* exp(32.0DL) */ 214643579785916.0646242977615312609DL, /* exp(33.0DL) */ 583461742527454.8814029027346103910DL, /* exp(34.0DL) */ 1586013452313430.728129644625974660DL, /* exp(35.0DL) */ 4311231547115195.227113422292856925DL, /* exp(36.0DL) */ 11719142372802611.30877293979119019DL, /* exp(37.0DL) */ 31855931757113756.22032867170129865DL, /* exp(38.0DL) */ 86593400423993746.95360693271926493DL, /* exp(39.0DL) */ 235385266837019985.4078999107490348DL, /* exp(40.0DL) */ 639843493530054949.2226634035155708DL, /* exp(41.0DL) */ 1739274941520501047.394681303611235DL, /* exp(42.0DL) */ 4727839468229346561.474457562744280DL, /* exp(43.0DL) */ 12851600114359308275.80929963214310DL, /* exp(44.0DL) */ 34934271057485095348.03479723340610DL, /* exp(45.0DL) */ 94961194206024488745.13364911711832DL, /* exp(46.0DL) */ 258131288619006739623.2858002152734DL, /* exp(47.0DL) */ 701673591209763173865.4715998861174DL, /* exp(48.0DL) */ 1907346572495099690525.099840953848DL, /* exp(49.0DL) */ 5184705528587072464087.453322933485DL, /* exp(50.0DL) */ 14093490824269387964492.14331237017DL, /* exp(51.0DL) */ 38310080007165768493035.69548786199DL, /* exp(52.0DL) */ 104137594330290877971834.7293349380DL, /* exp(53.0DL) */ 283075330327469390044206.3548014075DL, /* exp(54.0DL) */ 769478526514201713818274.5590129394DL, /* exp(55.0DL) */ 2091659496012996153907071.157214674DL, /* exp(56.0DL) */ 5685719999335932222640348.820633253DL, /* exp(57.0DL) */ 15455389355901039303530766.91117462DL, /* exp(58.0DL) */ 42012104037905142549565934.30719162DL, /* exp(59.0DL) */ 114200738981568428366295718.3144766DL, /* exp(60.0DL) */ 310429793570191990870734214.1107100DL, /* exp(61.0DL) */ 843835666874145448907332948.0373118DL, /* exp(62.0DL) */ 2293783159469609879099352840.268614DL, /* exp(63.0DL) */ 6235149080811616882909238708.928470DL, /* exp(64.0DL) */ 16948892444103337141417836114.37197DL, /* exp(65.0DL) */ 46071866343312915426773184428.06009DL, /* exp(66.0DL) */ 125236317084221378051352196074.4366DL, /* exp(67.0DL) */ 340427604993174052137690718700.4351DL, /* exp(68.0DL) */ 925378172558778760024239791668.7346DL, /* exp(69.0DL) */ 2515438670919167006265781174252.113DL, /* exp(70.0DL) */ 6837671229762743866755892826677.711DL, /* exp(71.0DL) */ 18586717452841279803403701812545.41DL, /* exp(72.0DL) */ 50523936302761041945570383321857.65DL, /* exp(73.0DL) */ 137338297954017618778418852980853.9DL, /* exp(74.0DL) */ 373324199679900164025490831726470.0DL, /* exp(75.0DL) */ 1014800388113888727832461784131717.0DL, /* exp(76.0DL) */ 2758513454523170206286469819902662.0DL, /* exp(77.0DL) */ 7498416996990120434675630591224060.0DL, /* exp(78.0DL) */ 2.038281066512668766832313753717263e+34DL, /* exp(79.0DL) */ 5.540622384393510052571173395831661e+34DL, /* exp(80.0DL) */ 1.506097314585030548352594130167675e+35DL, /* exp(81.0DL) */ 4.093996962127454696660914229327829e+35DL, /* exp(82.0DL) */ 1.112863754791759412087071478183941e+36DL, /* exp(83.0DL) */ 3.025077322201142338266566396443429e+36DL, /* exp(84.0DL) */ 8.223012714622913510304328016407775e+36DL, /* exp(85.0DL) */ 2.235246603734715047443065732332715e+37DL, /* exp(86.0DL) */ 6.076030225056872149522328938130276e+37DL, /* exp(87.0DL) */ 1.651636254994001855528329796264859e+38DL, /* exp(88.0DL) */ 4.489612819174345246284245579645316e+38DL, /* exp(89.0DL) */ 1.220403294317840802002710035136370e+39DL, /* exp(90.0DL) */ 3.317400098335742625755516107852592e+39DL, /* exp(91.0DL) */ 9.017628405034298931400995982170905e+39DL, /* exp(92.0DL) */ 2.451245542920085785552772943110915e+40DL, /* exp(93.0DL) */ 6.663176216410895834244814050240873e+40DL, /* exp(94.0DL) */ 1.811239082889023282193798758098816e+41DL, /* exp(95.0DL) */ 4.923458286012058399754862059113304e+41DL, /* exp(96.0DL) */ 1.338334719204269500461736408706115e+42DL, /* exp(97.0DL) */ 3.637970947608804579287743826760186e+42DL, /* exp(98.0DL) */ 9.889030319346946770560030967138037e+42DL, /* exp(99.0DL) */ 2.688117141816135448412625551580014e+43DL, /* exp(100.0DL) */ 7.307059979368067272647682634061514e+43DL, /* exp(101.0DL) */ 1.986264836137654325874046890613771e+44DL, /* exp(102.0DL) */ 5.399227610580168869761684237193682e+44DL, /* exp(103.0DL) */ 1.467662230155442328510702112087047e+45DL, /* exp(104.0DL) */ 3.989519570547215850763757278730095e+45DL, /* exp(105.0DL) */ 1.084463855290023081336100102856874e+46DL, /* exp(106.0DL) */ 2.947878391455509377387820248707928e+46DL, /* exp(107.0DL) */ 8.013164264000591141056105836293556e+46DL, /* exp(108.0DL) */ 2.178203880729020635553939331393682e+47DL, /* exp(109.0DL) */ 5.920972027664670298955228815588040e+47DL, /* exp(110.0DL) */ 1.609487066961518054926233299337351e+48DL, /* exp(111.0DL) */ 4.375039447261341073462574675087939e+48DL, /* exp(112.0DL) */ 1.189259022828200881968195409638927e+49DL, /* exp(113.0DL) */ 3.232741191084859311426235420582919e+49DL, /* exp(114.0DL) */ 8.787501635837023113106973803049638e+49DL, /* exp(115.0DL) */ 2.388690601424991425462639294944161e+50DL, /* exp(116.0DL) */ 6.493134255664462136224950708771209e+50DL, /* exp(117.0DL) */ 1.765016885691765583291178205644718e+51DL, /* exp(118.0DL) */ 4.797813327299302186003488289501133e+51DL, /* exp(119.0DL) */ 1.304180878393632279733879028098649e+52DL, /* exp(120.0DL) */ 3.545131182761166475189407421247819e+52DL, /* exp(121.0DL) */ 9.636665673603201271763873014194224e+52DL, /* exp(122.0DL) */ 2.619517318749062676188981025374639e+53DL, /* exp(123.0DL) */ 7.120586326889337708833068068270194e+53DL, /* exp(124.0DL) */ 1.935576042035722568720624490527487e+54DL, /* exp(125.0DL) */ 5.261441182666385745176776704161635e+54DL, /* exp(126.0DL) */ 1.430207995834810446358367107290526e+55DL, /* exp(127.0DL) */ 3.887708405994595092222673688357478e+55DL, /* exp(128.0DL) */ 1.056788711436258812564883496042735e+56DL, /* exp(129.0DL) */ 2.872649550817831933267333224962154e+56DL, /* exp(130.0DL) */ 7.808671073519151171721496316178984e+56DL, /* exp(131.0DL) */ 2.122616868356089389087011829556459e+57DL, /* exp(132.0DL) */ 5.769870862033003179413083148549333e+57DL, /* exp(133.0DL) */ 1.568413511681963940672521233331738e+58DL, /* exp(134.0DL) */ 4.263389948314721044893686688076599e+58DL, /* exp(135.0DL) */ 1.158909542413885428348049567600546e+59DL, /* exp(136.0DL) */ 3.150242749971451918411164291133698e+59DL, /* exp(137.0DL) */ 8.563247622482249193195490908623758e+59DL, /* exp(138.0DL) */ 2.327732040478862025474175038514098e+60DL, /* exp(139.0DL) */ 6.327431707155585364343024512351145e+60DL, /* exp(140.0DL) */ 1.719974263037662264183378392554783e+61DL, /* exp(141.0DL) */ 4.675374784632515402720773410063707e+61DL, /* exp(142.0DL) */ 1.270898631830218879555516649914609e+62DL, /* exp(143.0DL) */ 3.454660656717546323125851786688987e+62DL, /* exp(144.0DL) */ 9.390741286647697813154050401690990e+62DL, /* exp(145.0DL) */ 2.552668139525455104766875580865435e+63DL, /* exp(146.0DL) */ 6.938871417758403301622803744045249e+63DL, /* exp(147.0DL) */ 1.886180808490652005219614818181222e+64DL, /* exp(148.0DL) */ 5.127171016908329766825888768465816e+64DL, /* exp(149.0DL) */ 1.393709580666379697318341937141457e+65DL, /* exp(150.0DL) */ 3.788495427274695804249475044194939e+65DL, /* exp(151.0DL) */ 1.029819827716099194399387877391374e+66DL, /* exp(152.0DL) */ 2.799340524267497068373922891089509e+66DL, /* exp(153.0DL) */ 7.609396478785354221820071817478727e+66DL, /* exp(154.0DL) */ 2.068448417382247309127034796628242e+67DL, /* exp(155.0DL) */ 5.622625746075033580789765081966631e+67DL, /* exp(156.0DL) */ 1.528388139378174566610041404084110e+68DL, /* exp(157.0DL) */ 4.154589706104022437390577106831935e+68DL, /* exp(158.0DL) */ 1.129334570280556947872702202187131e+69DL, /* exp(159.0DL) */ 3.069849640644242466736457030165496e+69DL, /* exp(160.0DL) */ 8.344716494264974360965835809202325e+69DL, /* exp(161.0DL) */ 2.268329121000240471305839031261140e+70DL, /* exp(162.0DL) */ 6.165957830579432532004967054378165e+70DL, /* exp(163.0DL) */ 1.676081112590882772586107349772233e+71DL, /* exp(164.0DL) */ 4.556060831379215688011286441179669e+71DL, /* exp(165.0DL) */ 1.238465736729213219826985646784684e+72DL, /* exp(166.0DL) */ 3.366498907320164247795577890175299e+72DL, /* exp(167.0DL) */ 9.151092805295633936008943833619897e+72DL, /* exp(168.0DL) */ 2.487524928317742944660399447996433e+73DL, /* exp(169.0DL) */ 6.761793810485009722629773981761472e+73DL, /* exp(170.0DL) */ 1.838046124282824702661966133225901e+74DL, /* exp(171.0DL) */ 4.996327379507578237479999229144082e+74DL, /* exp(172.0DL) */ 1.358142592474784978909325501195412e+75DL, /* exp(173.0DL) */ 3.691814329580466442392001432233471e+75DL, /* exp(174.0DL) */ 1.003539180614329457194673346475574e+76DL, /* exp(175.0DL) */ 2.727902318810611519255759319952712e+76DL, /* exp(176.0DL) */ 7.415207303034178428338693757660901e+76DL, /* exp(177.0DL) */ 2.015662326609461206632931840914131e+77DL, /* exp(178.0DL) */ 5.479138274731979437986556445096614e+77DL, /* exp(179.0DL) */ 1.489384200781838359564441023032289e+78DL, /* exp(180.0DL) */ 4.048566008579269326227142668956968e+78DL, /* exp(181.0DL) */ 1.100514341243799484328097603121074e+79DL, /* exp(182.0DL) */ 2.991508135761596920718470160144712e+79DL, /* exp(183.0DL) */ 8.131762205128143406112671204492571e+79DL, /* exp(184.0DL) */ 2.210442143554988732756103709321049e+80DL, /* exp(185.0DL) */ 6.008604711685586125034163217853965e+80DL, /* exp(186.0DL) */ 1.633308100216832937727194388108838e+81DL, /* exp(187.0DL) */ 4.439791729094382135615588198841497e+81DL, /* exp(188.0DL) */ 1.206860517934002309536447331447343e+82DL, /* exp(189.0DL) */ 3.280587015384670151825008413705914e+82DL, /* exp(190.0DL) */ 8.917560070598843142077080332491209e+82DL, /* exp(191.0DL) */ 2.424044149410079585237809735246149e+83DL, /* exp(192.0DL) */ 6.589235162723882173675393093453464e+83DL, /* exp(193.0DL) */ 1.791139820627570890043182762414423e+84DL, /* exp(194.0DL) */ 4.868822826641319706709336201865967e+84DL, /* exp(195.0DL) */ 1.323483261564570355306938300562604e+85DL, /* exp(196.0DL) */ 3.597600500180681130758662848849109e+85DL, /* exp(197.0DL) */ 9.779292065696317602741493974881592e+85DL, /* exp(198.0DL) */ 2.658287191737601973400328347238974e+86DL, /* exp(199.0DL) */ 7.225973768125749258177477042189306e+86DL, /* exp(200.0DL) */ 1.964223318681795865648486413742023e+87DL, /* exp(201.0DL) */ 5.339312554208245971622259980208268e+87DL, /* exp(202.0DL) */ 1.451375629256752594052365491439013e+88DL, /* exp(203.0DL) */ 3.945247999276942790032757321114382e+88DL, /* exp(204.0DL) */ 1.072429594519891802192445120936997e+89DL, /* exp(205.0DL) */ 2.915165879085123966049615522455638e+89DL, /* exp(206.0DL) */ 7.924242436060930749118868880226406e+89DL, /* exp(207.0DL) */ 2.154032421824846569020981598875600e+90DL, /* exp(208.0DL) */ 5.855267190158109347508158747532035e+90DL, /* exp(209.0DL) */ 1.591626640377924159157186340777442e+91DL, /* exp(210.0DL) */ 4.326489974230630919937147247796921e+91DL, /* exp(211.0DL) */ 1.176061853430500122733564724127810e+92DL, /* exp(212.0DL) */ 3.196867565323993534884678511593018e+92DL, /* exp(213.0DL) */ 8.689987010810321382206327468404931e+92DL, /* exp(214.0DL) */ 2.362183378103083330074656746951513e+93DL, /* exp(215.0DL) */ 6.421080152185613551677154136222645e+93DL, /* exp(216.0DL) */ 1.745430549676519405028186247908160e+94DL, /* exp(217.0DL) */ 4.744572146022965554458784288916120e+94DL, /* exp(218.0DL) */ 1.289708424834716297481023414701692e+95DL, /* exp(219.0DL) */ 3.505790975238747722402506089127548e+95DL, /* exp(220.0DL) */ 9.529727902367202538635563498630489e+95DL, /* exp(221.0DL) */ 2.590448618716390103183017128713071e+96DL, /* exp(222.0DL) */ 7.041569407813596999108837294967126e+96DL, /* exp(223.0DL) */ 1.914097016509282082010847732006445e+97DL, /* exp(224.0DL) */ 5.203055137884854592302020535807898e+97DL, /* exp(225.0DL) */ 1.414337023378287226503983716837055e+98DL, /* exp(226.0DL) */ 3.844566629966054009345753170667500e+98DL, /* exp(227.0DL) */ 1.045061560853675486398217750709896e+99DL, /* exp(228.0DL) */ 2.840771850489592771853401334776990e+99DL, /* exp(229.0DL) */ 7.722018499983835717562125214027702e+99DL, /* exp(230.0DL) */ 2.099062256753063472456803931261947e+100DL, /* exp(231.0DL) */ 5.705842789336087248197014832689535e+100DL, /* exp(232.0DL) */ 1.551008877029635809755605451888125e+101DL, /* exp(233.0DL) */ 4.216079246208328874118691759609435e+101DL, /* exp(234.0DL) */ 1.146049160231140937063786504289561e+102DL, /* exp(235.0DL) */ 3.115284606777059095420146431240044e+102DL, /* exp(236.0DL) */ 8.468221537080261941894957767724472e+102DL, /* exp(237.0DL) */ 2.301901272361080096270511976626041e+103DL, /* exp(238.0DL) */ 6.257216399565879491491760484687697e+103DL, /* exp(239.0DL) */ 1.700887763567586268539890286071456e+104DL, /* exp(240.0DL) */ 4.623492299954114627342627486156878e+104DL, /* exp(241.0DL) */ 1.256795510298558713635336961328797e+105DL, /* exp(242.0DL) */ 3.416324397733484996690746761911685e+105DL, /* exp(243.0DL) */ 9.286532530480224090839757024909060e+105DL, /* exp(244.0DL) */ 2.524341262699818777063279323441880e+106DL, /* exp(245.0DL) */ 6.861870983226278429650018966343927e+106DL, /* exp(246.0DL) */ 1.865249920293439464789305714127697e+107DL, /* exp(247.0DL) */ 5.070274963868339013421674936745641e+107DL, /* exp(248.0DL) */ 1.378243629957414808885790181914938e+108DL, /* exp(249.0DL) */ 3.746454614502673260349954812202920e+108DL, /* exp(250.0DL) */ 1.018391949974915412131180980115459e+109DL, /* exp(251.0DL) */ 2.768276331865785592998577160396332e+109DL, /* exp(252.0DL) */ 7.524955249064026372695879140572184e+109DL, /* exp(253.0DL) */ 2.045494911349825175079419025332923e+110DL, /* exp(254.0DL) */ 5.560231647727675417404154047338170e+110DL, /* exp(255.0DL) */ 1.511427665004103542520089665707287e+111DL, /* exp(256.0DL) */ 4.108486356810939873274643501419966e+111DL, /* exp(257.0DL) */ 1.116802380619108297575989418836874e+112DL, /* exp(258.0DL) */ 3.035783617216724286527056406009668e+112DL, /* exp(259.0DL) */ 8.252115441813891570820918707846944e+112DL, /* exp(260.0DL) */ 2.243157545182898709013259885403898e+113DL, /* exp(261.0DL) */ 6.097534393441473280354092573194560e+113DL, /* exp(262.0DL) */ 1.657481694009600331028886805596982e+114DL, /* exp(263.0DL) */ 4.505502369829812111710612511284523e+114DL, /* exp(264.0DL) */ 1.224722521998754311169212305099962e+115DL, /* exp(265.0DL) */ 3.329140976453747121049890265064740e+115DL, /* exp(266.0DL) */ 9.049543420672622984741020586915559e+115DL, /* exp(267.0DL) */ 2.459920943626550038596244273961357e+116DL, /* exp(268.0DL) */ 6.686758400505878376783619550171546e+116DL, /* exp(269.0DL) */ 1.817649385139099978254665044531334e+117DL, /* exp(270.0DL) */ 4.940883294133372012968511104760232e+117DL, /* exp(271.0DL) */ 1.343071327497961308585925029761342e+118DL, /* exp(272.0DL) */ 3.650846383862075425813175768321853e+118DL, /* exp(273.0DL) */ 9.924029383747695725897538647368045e+118DL, /* exp(274.0DL) */ 2.697630873893497823276541791257137e+119DL, /* exp(275.0DL) */ 7.332920984394789339791797649312974e+119DL, /* exp(276.0DL) */ 1.993294586140636987940405781793673e+120DL, /* exp(277.0DL) */ 5.418336452271886559100375698876231e+120DL, /* exp(278.0DL) */ 1.472856551868792008087437247897063e+121DL, /* exp(279.0DL) */ 4.003639200871784538400260785305545e+121DL, /* exp(280.0DL) */ 1.088301968743606516792665866534688e+122DL, /* exp(281.0DL) */ 2.958311465511949419164853541312494e+122DL, /* exp(282.0DL) */ 8.041524299623179605925946091442732e+122DL, /* exp(283.0DL) */ 2.185912937677753978514469372345811e+123DL, /* exp(284.0DL) */ 5.941927417082968078603966504162533e+123DL, /* exp(285.0DL) */ 1.615183332387922236604183385718783e+124DL, /* exp(286.0DL) */ 4.390523502060015075404295319039588e+124DL, /* exp(287.0DL) */ 1.193468025307210843923555893375492e+125DL, /* exp(288.0DL) */ 3.244182446039491164974072332126533e+125DL, /* exp(289.0DL) */ 8.818602191274965898609482242773347e+125DL, /* exp(290.0DL) */ 2.397144608895185727195240960392316e+126DL, /* exp(291.0DL) */ 6.516114630548348330102723702830198e+126DL, /* exp(292.0DL) */ 1.771263599237570031534705841604641e+127DL, /* exp(293.0DL) */ 4.814793655218451387395298079782470e+127DL, /* exp(294.0DL) */ 1.308796610076022186332899984750243e+128DL, /* exp(295.0DL) */ 3.557678042318449655544645980637689e+128DL, /* exp(296.0DL) */ 9.670771573941991842072070104579637e+128DL, /* exp(297.0DL) */ 2.628788263662479636370453338953771e+129DL, /* exp(298.0DL) */ 7.145787367980123848171155588996861e+129DL, /* exp(299.0DL) */ 1.942426395241255936584208836017699e+130DL, /* exp(300.0DL) */ 5.280062373303513270087532378038526e+130DL, /* exp(301.0DL) */ 1.435269760248127992550590452903856e+131DL, /* exp(302.0DL) */ 3.901467708219256838066994684078047e+131DL, /* exp(303.0DL) */ 1.060528877557216226495232041821616e+132DL, /* exp(304.0DL) */ 2.882816376419848626953355204155918e+132DL, /* exp(305.0DL) */ 7.836307370806225343172196949344846e+132DL, /* exp(306.0DL) */ 2.130129192828223962100534606173057e+133DL, /* exp(307.0DL) */ 5.790291477135094778361695172898998e+133DL, /* exp(308.0DL) */ 1.573964410377761135100442978373886e+134DL, /* exp(309.0DL) */ 4.278478855371123572078762559314068e+134DL, /* exp(310.0DL) */ 1.163011132600158073507199921010664e+135DL, /* exp(311.0DL) */ 3.161392028042582800233183836456089e+135DL, /* exp(312.0DL) */ 8.593554502463441183638161736499838e+135DL, /* exp(313.0DL) */ 2.335970304591878365299521443432813e+136DL, /* exp(314.0DL) */ 6.349825630792043955046056134266398e+136DL, /* exp(315.0DL) */ 1.726061562606550753116266296636711e+137DL, /* exp(316.0DL) */ 4.691921780435011562208730704150653e+137DL, /* exp(317.0DL) */ 1.275396571630770220251373313489760e+138DL, /* exp(318.0DL) */ 3.466887324742887734754816324854361e+138DL, /* exp(319.0DL) */ 9.423976816163584609582297533804707e+138DL, /* exp(320.0DL) */ 2.561702493119680037517373932936033e+139DL, /* exp(321.0DL) */ 6.963429336965458599034994515731783e+139DL, /* exp(322.0DL) */ 1.892856343043182383234520340542839e+140DL, /* exp(323.0DL) */ 5.145317001177723577131599201722597e+140DL, /* exp(324.0DL) */ 1.398642170596279385193289912251344e+141DL, /* exp(325.0DL) */ 3.801903596848382201568124647481586e+141DL, /* exp(326.0DL) */ 1.033464546086604114115365543361185e+142DL, /* exp(327.0DL) */ 2.809247895983891453424674296054281e+142DL, /* exp(328.0DL) */ 7.636327507289818180166118335081688e+142DL, /* exp(329.0DL) */ 2.075769029922787004644168141919403e+143DL, /* exp(330.0DL) */ 5.642525234117172040733295233660915e+143DL, /* exp(331.0DL) */ 1.533797381052232870519667063383699e+144DL, /* exp(332.0DL) */ 4.169293549452358510538002660315104e+144DL, /* exp(333.0DL) */ 1.133331489298785982963108539898353e+145DL, /* exp(334.0DL) */ 3.080714392981316820196121871645118e+145DL, /* exp(335.0DL) */ 8.374249953113351519453795208709646e+145DL, /* exp(336.0DL) */ 2.276357147452203500020023477143653e+146DL, /* exp(337.0DL) */ 6.187780269002192175178696821538595e+146DL, /* exp(338.0DL) */ 1.682013066372608173189389845168449e+147DL, /* exp(339.0DL) */ 4.572185553551338758077087969419296e+147DL, /* exp(340.0DL) */ 1.242848890656156500469391700684018e+148DL, /* exp(341.0DL) */ 3.378413554991113073078548479226100e+148DL, /* exp(342.0DL) */ 9.183480175552066013537935348151565e+148DL, /* exp(343.0DL) */ 2.496328728321706373106940389410625e+149DL, /* exp(344.0DL) */ 6.785725020057171180597468784050053e+149DL, /* exp(345.0DL) */ 1.844551301494129868022574114528400e+150DL, /* exp(346.0DL) */ 5.014010284511974955246298929888265e+150DL, /* exp(347.0DL) */ 1.362949304409566890038982913575933e+151DL, /* exp(348.0DL) */ 3.704880327287421330770271193329711e+151DL, /* exp(349.0DL) */ 1.007090887028079759823375862957009e+152DL, /* exp(350.0DL) */ 2.737556857815130410127492651946378e+152DL, /* exp(351.0DL) */ 7.441451060972311209407666002648342e+152DL, /* exp(352.0DL) */ 2.022796119640831622539965665246037e+153DL, /* exp(353.0DL) */ 5.498529934697141407184545638353895e+153DL, /* exp(354.0DL) */ 1.494655400472534013870473442859227e+154DL, /* exp(355.0DL) */ 4.062894614912666263108447007703347e+154DL, /* exp(356.0DL) */ 1.104409260266121092478298771074541e+155DL, /* exp(357.0DL) */ 3.002095623363293218544209572921559e+155DL, /* exp(358.0DL) */ 8.160541980284869890205249363477304e+155DL, /* exp(359.0DL) */ 2.218265297538555399989665903558670e+156DL, /* exp(360.0DL) */ 6.029870249000352388763324493423036e+156DL, /* exp(361.0DL) */ 1.639088672582347627161609834531880e+157DL, /* exp(362.0DL) */ 4.455504953913653233974268168963676e+157DL, /* exp(363.0DL) */ 1.211131815283273938722390511523583e+158DL, /* exp(364.0DL) */ 3.292197605353140509174102360167548e+158DL, /* exp(365.0DL) */ 8.949120926327824993420536927303175e+158DL, /* exp(366.0DL) */ 2.432623279471950477227309535201063e+159DL, /* exp(367.0DL) */ 6.612555656075052543831039207709918e+159DL, /* exp(368.0DL) */ 1.797478987958289530151706000979968e+160DL, /* exp(369.0DL) */ 4.886054470003973416856524852609962e+160DL, /* exp(370.0DL) */ 1.328167307867289205100231902804380e+161DL, /* exp(371.0DL) */ 3.610333058129022556282304462831987e+161DL, /* exp(372.0DL) */ 9.813902746597095882542159047202632e+161DL, /* exp(373.0DL) */ 2.667695350233919987120260891628822e+162DL, /* exp(374.0DL) */ 7.251547794405553090112673549867557e+162DL, /* exp(375.0DL) */ 1.971175059773488349115179760489633e+163DL, /* exp(376.0DL) */ 5.358209345693945694819562705760926e+163DL, /* exp(377.0DL) */ 1.456512309747928310205062027767040e+164DL, /* exp(378.0DL) */ 3.959210944514705822310560742686318e+164DL, /* exp(379.0DL) */ 1.076225116551049803541837343424381e+165DL, /* exp(380.0DL) */ 2.925483177651936727218575960974259e+165DL, /* exp(381.0DL) */ 7.952287761273884428431842997922460e+165DL, /* exp(382.0DL) */ 2.161655931614806197980514918359209e+166DL, /* exp(383.0DL) */ 5.875990038289236239608284190826147e+166DL, /* exp(384.0DL) */ 1.597259694528800030822743979435256e+167DL, /* exp(385.0DL) */ 4.341802002967682598837778729247605e+167DL, /* exp(386.0DL) */ 1.180224148743413720203261526035075e+168DL, /* exp(387.0DL) */ 3.208181857037766822452217552625736e+168DL, /* exp(388.0DL) */ 8.720742444377756058815671175404579e+168DL, /* exp(389.0DL) */ 2.370543571722357032999137386012008e+169DL, /* exp(390.0DL) */ 6.443805514583284515942657384226011e+169DL, /* exp(391.0DL) */ 1.751607943641592951129850402000189e+170DL, /* exp(392.0DL) */ 4.761364043785457544777068604957221e+170DL, /* exp(393.0DL) */ 1.294272935890028705274850735971419e+171DL, /* exp(394.0DL) */ 3.518198602696203860423082985485178e+171DL, /* exp(395.0DL) */ 9.563455330619095063990428284178055e+171DL, /* exp(396.0DL) */ 2.599616684250167670535131669841815e+172DL, /* exp(397.0DL) */ 7.066490793756186237436887792483189e+172DL, /* exp(398.0DL) */ 1.920871351564057584139949852666935e+173DL, /* exp(399.0DL) */ 5.221469689764143950588763006649649e+173DL, /* exp(400.0DL) */ 1.419342617553556088952595304761593e+174DL, /* exp(401.0DL) */ 3.858173245653327799310350012971924e+174DL, /* exp(402.0DL) */ 1.048760222470629699020425144346453e+175DL, /* exp(403.0DL) */ 2.850825855152578357724868730105249e+175DL, /* exp(404.0DL) */ 7.749348118162471942799302224427976e+175DL, /* exp(405.0DL) */ 2.106491217200434556446189142703003e+176DL, /* exp(406.0DL) */ 5.726036797524517045075068123598170e+176DL, /* exp(407.0DL) */ 1.556498177579871997750512324010936e+177DL, /* exp(408.0DL) */ 4.231000712144986142316285393091558e+177DL, /* exp(409.0DL) */ 1.150105235202099544968631947814397e+178DL, /* exp(410.0DL) */ 3.126310161665483428917747618858063e+178DL, /* exp(411.0DL) */ 8.498192102582143603633233273858886e+178DL, /* exp(412.0DL) */ 2.310048116720320742890940914625761e+179DL, /* exp(413.0DL) */ 6.279361818546887415165373333420796e+179DL, /* exp(414.0DL) */ 1.706907512567554855051318463039938e+180DL, /* exp(415.0DL) */ 4.639855674272613745723989048870604e+180DL, /* exp(416.0DL) */ 1.261243536604783670309876943451105e+181DL, /* exp(417.0DL) */ 3.428415386814204104981865890924109e+181DL, /* exp(418.0DL) */ 9.319399246386439579008167656003250e+181DL, /* exp(419.0DL) */ 2.533275362360717919371182124925657e+182DL, /* exp(420.0DL) */ 6.886156383988142686207946843675239e+182DL, /* exp(421.0DL) */ 1.871851376652221570940575120188230e+183DL, /* exp(422.0DL) */ 5.088219582729781827872175380623096e+183DL, /* exp(423.0DL) */ 1.383121483094383153302857465179987e+184DL, /* exp(424.0DL) */ 3.759713994046786261231426611578472e+184DL, /* exp(425.0DL) */ 1.021996223022055807099002130897546e+185DL, /* exp(426.0DL) */ 2.778073761794632040373575342429542e+185DL, /* exp(427.0DL) */ 7.551587424805210467125308242295084e+185DL, /* exp(428.0DL) */ 2.052734287286784027926561180001698e+186DL, /* exp(429.0DL) */ 5.579910311786494341713109506348113e+186DL, /* exp(430.0DL) */ 1.516776880496047302726689430200619e+187DL, /* exp(431.0DL) */ 4.123027032079202208926725386245407e+187DL, /* exp(432.0DL) */ 1.120754945954632433560060190129295e+188DL, /* exp(433.0DL) */ 3.046527803744076674512679471700871e+188DL, /* exp(434.0DL) */ 8.281321168812768059667846719239344e+188DL, /* exp(435.0DL) */ 2.251096484881696877600571550111928e+189DL, /* exp(436.0DL) */ 6.119114668961948467907208237768858e+189DL, /* exp(437.0DL) */ 1.663347821089645057719483053444463e+190DL, /* exp(438.0DL) */ 4.521448156474929211386999357759814e+190DL, /* exp(439.0DL) */ 1.229057036206544984605802280424419e+191DL, /* exp(440.0DL) */ 3.340923407659982062775142884958155e+191DL, /* exp(441.0DL) */ 9.081571389315600216037596266916383e+191DL, /* exp(442.0DL) */ 2.468627048143016150001750467926167e+192DL, /* exp(443.0DL) */ 6.710424046209653429991863024228781e+192DL, /* exp(444.0DL) */ 1.824082374606632138258439437597837e+193DL, /* exp(445.0DL) */ 4.958369972505633112676552999612121e+193DL, /* exp(446.0DL) */ 1.347824699503903822885598093098193e+194DL, /* exp(447.0DL) */ 3.663767388609734883217830085985113e+194DL, /* exp(448.0DL) */ 9.959152316158691480158431249145986e+194DL, /* exp(449.0DL) */ 2.707178276786998323373310485814752e+195DL, /* exp(450.0DL) */ 7.358873516189169058322082659934047e+195DL, /* exp(451.0DL) */ 2.000349215698553788688243281159668e+196DL, /* exp(452.0DL) */ 5.437512923605681866194912742254270e+196DL, /* exp(453.0DL) */ 1.478069257224854165421793387461143e+197DL, /* exp(454.0DL) */ 4.017808803118279437877755383682614e+197DL, /* exp(455.0DL) */ 1.092153665973920471826922283630383e+198DL, /* exp(456.0DL) */ 2.968781464101837877130907914264117e+198DL, /* exp(457.0DL) */ 8.069984706534065228728930759424896e+198DL, /* exp(458.0DL) */ 2.193649278371395040318536641341395e+199DL, /* exp(459.0DL) */ 5.962956971409260822395127288810348e+199DL, /* exp(460.0DL) */ 1.620899757926497623081284104932651e+200DL, /* exp(461.0DL) */ 4.406062357725263759379850038557442e+200DL, /* exp(462.0DL) */ 1.197691924206200182564330974252429e+201DL, /* exp(463.0DL) */ 3.255664193661862052431253530725589e+201DL, /* exp(464.0DL) */ 8.849812817195809529800229688135934e+201DL, /* exp(465.0DL) */ 2.405628536624731937016932793996026e+202DL, /* exp(466.0DL) */ 6.539176337129533597548692943530939e+202DL, /* exp(467.0DL) */ 1.777532421030859060107212665651268e+203DL, /* exp(468.0DL) */ 4.831834079584996998891248221490661e+203DL, /* exp(469.0DL) */ 1.313428677666503353580556912107501e+204DL, /* exp(470.0DL) */ 3.570269307477848686807457768952824e+204DL, /* exp(471.0DL) */ 9.704998181222095712433155396791069e+204DL, /* exp(472.0DL) */ 2.638092020124410678145401874749836e+205DL, /* exp(473.0DL) */ 7.171077600106999417891908990001638e+205DL, /* exp(474.0DL) */ 1.949300993084055637799015726409861e+206DL, /* exp(475.0DL) */ 5.298749467697559449928326786096158e+206DL, /* exp(476.0DL) */ 1.440349439159931454920427073875767e+207DL, /* exp(477.0DL) */ 3.915275707099618806936026895522707e+207DL, /* exp(478.0DL) */ 1.064282280801603304708720273641843e+208DL, /* exp(479.0DL) */ 2.893019184253945246534816702118053e+208DL, /* exp(480.0DL) */ 7.864041477940909773300251372520698e+208DL, /* exp(481.0DL) */ 2.137668104773498866567412075545327e+209DL, /* exp(482.0DL) */ 5.810784364482288383246723426978378e+209DL, /* exp(483.0DL) */ 1.579534954706614601625671846157738e+210DL, /* exp(484.0DL) */ 4.293621164794871538041621948303868e+210DL, /* exp(485.0DL) */ 1.167127239054905898759412509410571e+211DL, /* exp(486.0DL) */ 3.172580765422526796995080546191440e+211DL, /* exp(487.0DL) */ 8.623968643966743418277677243565088e+211DL, /* exp(488.0DL) */ 2.344237725409539218615226602961952e+212DL, /* exp(489.0DL) */ 6.372298810568915474216176683121907e+212DL, /* exp(490.0DL) */ 1.732170406228067068251352333408775e+213DL, /* exp(491.0DL) */ 4.708527339044277307003974590883498e+213DL, /* exp(492.0DL) */ 1.279910430452668093157360961475030e+214DL, /* exp(493.0DL) */ 3.479157265154682276532297319760293e+214DL, /* exp(494.0DL) */ 9.457329972221241007049799869879439e+214DL, /* exp(495.0DL) */ 2.570768820923008648805009142884219e+215DL, /* exp(496.0DL) */ 6.988074171084099775590981488496373e+215DL, /* exp(497.0DL) */ 1.899555503518191363230828929983843e+216DL, /* exp(498.0DL) */ 5.163527207362871553289347179917635e+216DL, /* exp(499.0DL) */ 1.403592217852837410739770332840912e+217DL, /* exp(500.0DL) */ 3.815359220355897431846613368265267e+217DL, /* exp(501.0DL) */ 1.037122163773710615291283344833936e+218DL, /* exp(502.0DL) */ 2.819190331678203457443868041149361e+218DL, /* exp(503.0DL) */ 7.663353849568289091387105632648610e+218DL, /* exp(504.0DL) */ 2.083115551433315195369244084979054e+219DL, /* exp(505.0DL) */ 5.662495150041624317958867141543712e+219DL, /* exp(506.0DL) */ 1.539225767009562224598782635629893e+220DL, /* exp(507.0DL) */ 4.184049432358029151851648927429493e+220DL, /* exp(508.0DL) */ 1.137342554135321378980845851741469e+221DL, /* exp(509.0DL) */ 3.091617597639242037871853535963997e+221DL, /* exp(510.0DL) */ 8.403887936206959658993059652628077e+221DL, /* exp(511.0DL) */ 2.284413586539756640378751517122403e+222DL, /* exp(512.0DL) */ 6.209679940975975047577272304764810e+222DL, /* exp(513.0DL) */ 1.687966014410162954642810721076269e+223DL, /* exp(514.0DL) */ 4.588367344027584854489420260908572e+223DL, /* exp(515.0DL) */ 1.247247557356507640804521511751116e+224DL, /* exp(516.0DL) */ 3.390370370752125486061343822971314e+224DL, /* exp(517.0DL) */ 9.215982170561458765936672745568764e+224DL, /* exp(518.0DL) */ 2.505163686563976262517856075647746e+225DL, /* exp(519.0DL) */ 6.809740926502327887940451611871241e+225DL, /* exp(520.0DL) */ 1.851079501702514062383499313500584e+226DL, /* exp(521.0DL) */ 5.031755772510968263221158771737896e+226DL, /* exp(522.0DL) */ 1.367773028166047047346657916452796e+227DL, /* exp(523.0DL) */ 3.717992567920167547029412002398600e+227DL, /* exp(524.0DL) */ 1.010655163572317397121409894131465e+228DL, /* exp(525.0DL) */ 2.747245565976934381873532297306132e+228DL, /* exp(526.0DL) */ 7.467787700309785784821623443995710e+228DL, /* exp(527.0DL) */ 2.029955160454205303196270276480854e+229DL, /* exp(528.0DL) */ 5.517990225249331746261182601797754e+229DL, /* exp(529.0DL) */ 1.499945255890989237667062477851581e+230DL, /* exp(530.0DL) */ 4.077273932771828716711974820084340e+230DL, /* exp(531.0DL) */ 1.108317964110340884306433009332212e+231DL, /* exp(532.0DL) */ 3.012720581995863893384693306677705e+231DL, /* exp(533.0DL) */ 8.189423612263915821186014819241439e+231DL, /* exp(534.0DL) */ 2.226116139077043620640842633613762e+232DL, /* exp(535.0DL) */ 6.051211048892536372953284172187696e+232DL, /* exp(536.0DL) */ 1.644889703437518074758158943467301e+233DL, /* exp(537.0DL) */ 4.471273790673593297092837895112485e+233DL, /* exp(538.0DL) */ 1.215418229525322146855011085035967e+234DL, /* exp(539.0DL) */ 3.303849287296548204875559387097202e+234DL, /* exp(540.0DL) */ 8.980793481625574506121216074127441e+234DL, /* exp(541.0DL) */ 2.441232772624624153754432382496990e+235DL, /* exp(542.0DL) */ 6.635958684864207975159269263875368e+235DL, /* exp(543.0DL) */ 1.803840590747136040282275111336768e+236DL, /* exp(544.0DL) */ 4.903347099264769269875143479995337e+236DL, /* exp(545.0DL) */ 1.332867931855879259014960921483314e+237DL, /* exp(546.0DL) */ 3.623110678899625578225435150399782e+237DL, /* exp(547.0DL) */ 9.848635920948766939626042406624255e+237DL, /* exp(548.0DL) */ 2.677136805902404708530235246447660e+238DL, /* exp(549.0DL) */ 7.277212331783396755856532665739865e+238DL, /* exp(550.0DL) */ 1.978151404332488388116926108277413e+239DL, /* exp(551.0DL) */ 5.377173016337744632419341697026827e+239DL, /* exp(552.0DL) */ 1.461667169879120399766778310399173e+240DL, /* exp(553.0DL) */ 3.973223307137573289325695033361800e+240DL, /* exp(554.0DL) */ 1.080034071620201739655617026903353e+241DL, /* exp(555.0DL) */ 2.935836991001829401203875825325156e+241DL, /* exp(556.0DL) */ 7.980432343958154358562489927847075e+241DL, /* exp(557.0DL) */ 2.169306422382827602890853416049801e+242DL, /* exp(558.0DL) */ 5.896786228322742509426315390702816e+242DL, /* exp(559.0DL) */ 1.602912685075726150454638702193788e+243DL, /* exp(560.0DL) */ 4.357168424447842629467815384115014e+243DL, /* exp(561.0DL) */ 1.184401175171209895839117272848773e+244DL, /* exp(562.0DL) */ 3.219536192073438364850714410685088e+244DL, /* exp(563.0DL) */ 8.751606726979457897693046120404434e+244DL, /* exp(564.0DL) */ 2.378933353576820110235705073981676e+245DL, /* exp(565.0DL) */ 6.466611306143006928877783259904363e+245DL, /* exp(566.0DL) */ 1.757807200519634761305847926330476e+246DL, /* exp(567.0DL) */ 4.778215371106988348935347740794150e+246DL, /* exp(568.0DL) */ 1.298853601574381967235062972107544e+247DL, /* exp(569.0DL) */ 3.530650142988227249099232301413323e+247DL, /* exp(570.0DL) */ 9.597302126331227875023735925726759e+247DL, /* exp(571.0DL) */ 2.608817197223753285500958233820604e+248DL, /* exp(572.0DL) */ 7.091500380984785710244093969315418e+248DL, /* exp(573.0DL) */ 1.927669662214133920207732330925958e+249DL, /* exp(574.0DL) */ 5.239949414068466053847053734169716e+249DL, /* exp(575.0DL) */ 1.424365927430693263406437508712142e+250DL, /* exp(576.0DL) */ 3.871828017611068619756333191738026e+250DL, /* exp(577.0DL) */ 1.052471974319077600436351056214937e+251DL, /* exp(578.0DL) */ 2.860915442753963560149385355110176e+251DL, /* exp(579.0DL) */ 7.776974460795963023293133416439138e+251DL, /* exp(580.0DL) */ 2.113946470080605596467762082192512e+252DL, /* exp(581.0DL) */ 5.746302275955252943010619149104434e+252DL, /* exp(582.0DL) */ 1.562006905756201809684652029738012e+253DL, /* exp(583.0DL) */ 4.245974987844623805253754053684570e+253DL, /* exp(584.0DL) */ 1.154175665354965636494651964287860e+254DL, /* exp(585.0DL) */ 3.137374737984031099197852644697323e+254DL, /* exp(586.0DL) */ 8.528268739328450016147688013915050e+254DL, /* exp(587.0DL) */ 2.318223794233185573296137735139557e+255DL, /* exp(588.0DL) */ 6.301585614165449125684244573161119e+255DL, /* exp(589.0DL) */ 1.712948566546487259520355035835174e+256DL, /* exp(590.0DL) */ 4.656276961528285912678100380088271e+256DL, /* exp(591.0DL) */ 1.265707305279483645812871129507303e+257DL, /* exp(592.0DL) */ 3.440549168089085763485571675208101e+257DL, /* exp(593.0DL) */ 9.352382283536447018650431059979411e+257DL, /* exp(594.0DL) */ 2.542241081413943403300761495150903e+258DL, /* exp(595.0DL) */ 6.910527735169594554573190583467196e+258DL, /* exp(596.0DL) */ 1.878476196757375020647877911959506e+259DL, /* exp(597.0DL) */ 5.106227710838430591467438208104426e+259DL, /* exp(598.0DL) */ 1.388016599834613402215027842278337e+260DL, /* exp(599.0DL) */ 3.773020300929939823401431193483135e+260DL, /* exp(600.0DL) */ 1.025613252242493391514516645079104e+261DL, /* exp(601.0DL) */ 2.787905866597552912328285255652010e+261DL, /* exp(602.0DL) */ 7.578313856626495175545054862949550e+261DL, /* exp(603.0DL) */ 2.059999284682718808696302995082404e+262DL, /* exp(604.0DL) */ 5.599658622191666139792171291558017e+262DL, /* exp(605.0DL) */ 1.522145027827762021100120336211546e+263DL, /* exp(606.0DL) */ 4.137619169423493238416696018145167e+263DL, /* exp(607.0DL) */ 1.124721500132768927172822089404576e+264DL, /* exp(608.0DL) */ 3.057310015888103407800160209739006e+264DL, /* exp(609.0DL) */ 8.310630260154466370620767610925627e+264DL, /* exp(610.0DL) */ 2.259063521921975363206047978936929e+265DL, /* exp(611.0DL) */ 6.140771320975197609781213157045819e+265DL, /* exp(612.0DL) */ 1.669234709452932671770806976793472e+266DL, /* exp(613.0DL) */ 4.537450378139020943054455738228414e+266DL, /* exp(614.0DL) */ 1.233406891042992406398480210225887e+267DL, /* exp(615.0DL) */ 3.352747539018331781648810576495882e+267DL, /* exp(616.0DL) */ 9.113712710724315024083120382834683e+267DL, /* exp(617.0DL) */ 2.477363965135813264401301521582167e+268DL, /* exp(618.0DL) */ 6.734173448907928873072281631157755e+268DL, /* exp(619.0DL) */ 1.830538131585779973659984071493435e+269DL, /* exp(620.0DL) */ 4.975918539390998333056028597620767e+269DL, /* exp(621.0DL) */ 1.352594894551902465257285293765718e+270DL, /* exp(622.0DL) */ 3.676734123126914915853981239838730e+270DL, /* exp(623.0DL) */ 9.994399554971194634376021138137170e+270DL, /* exp(624.0DL) */ 2.716759469663736693407194678125877e+271DL, /* exp(625.0DL) */ 7.384917898680968214434664479009658e+271DL, /* exp(626.0DL) */ 2.007428812864643244165976038645452e+272DL, /* exp(627.0DL) */ 5.456757263935072986189812313850169e+272DL, /* exp(628.0DL) */ 1.483300411286660709274049565156564e+273DL, /* exp(629.0DL) */ 4.032028554146357891230336377029199e+273DL, /* exp(630.0DL) */ 1.096018995056404220473333839077488e+274DL, /* exp(631.0DL) */ 2.979288517907767725080181759267345e+274DL, /* exp(632.0DL) */ 8.098545839965365786039531189385352e+274DL, /* exp(633.0DL) */ 2.201412999372044884674717205317365e+275DL, /* exp(634.0DL) */ 5.984060953126553169633576189715827e+275DL, /* exp(635.0DL) */ 1.626636414927522393392903634887462e+276DL, /* exp(636.0DL) */ 4.421656208207251754959015960656940e+276DL, /* exp(637.0DL) */ 1.201930772246289711810497611562084e+277DL, /* exp(638.0DL) */ 3.267186577262836658270402974456316e+277DL, /* exp(639.0DL) */ 8.881133903158873299234272672967127e+277DL, /* exp(640.0DL) */ 2.414142490506831928910472323441926e+278DL, /* exp(641.0DL) */ 6.562319663255584349955503981011063e+278DL, /* exp(642.0DL) */ 1.783823429316713583233384122083389e+279DL, /* exp(643.0DL) */ 4.848934813091120635935959450934223e+279DL, /* exp(644.0DL) */ 1.318077138980805015534262735851842e+280DL, /* exp(645.0DL) */ 3.582905135398809745024502084539878e+280DL, /* exp(646.0DL) */ 9.739345922647179593882146700607238e+280DL, /* exp(647.0DL) */ 2.647428704260852228681909004375106e+281DL, /* exp(648.0DL) */ 7.196457338933150317666337445002583e+281DL, /* exp(649.0DL) */ 1.956199921370271886821566849827147e+282DL, /* exp(650.0DL) */ 5.317502699093823182683530149803012e+282DL, /* exp(651.0DL) */ 1.445447095972866590256825223241052e+283DL, /* exp(652.0DL) */ 3.929132574981940835735158434038403e+283DL, /* exp(653.0DL) */ 1.068048968017990678959437158369329e+284DL, /* exp(654.0DL) */ 2.903258101667740029588950654122071e+284DL, /* exp(655.0DL) */ 7.891873741089921014851556006624308e+284DL, /* exp(656.0DL) */ 2.145233698289783624753859799313684e+285DL, /* exp(657.0DL) */ 5.831349779859112813154641712075748e+285DL, /* exp(658.0DL) */ 1.585125214197968009236380889475074e+286DL, /* exp(659.0DL) */ 4.308817065586588211059622644869701e+286DL, /* exp(660.0DL) */ 1.171257913153824883863901946336209e+287DL, /* exp(661.0DL) */ 3.183809101764904714912751772693689e+287DL, /* exp(662.0DL) */ 8.654490426610055613160749879342242e+287DL, /* exp(663.0DL) */ 2.352534406122688441013083174382482e+288DL, /* exp(664.0DL) */ 6.394851526987995637863277529865170e+288DL, /* exp(665.0DL) */ 1.738300870150504624084731424404936e+289DL, /* exp(666.0DL) */ 4.725191667724663076744727468708714e+289DL, /* exp(667.0DL) */ 1.284440264636204247017089930798463e+290DL, /* exp(668.0DL) */ 3.491470631101721219149135067460521e+290DL, /* exp(669.0DL) */ 9.490801171122243367142720526726012e+290DL, /* exp(670.0DL) */ 2.579867236097941956885309166553365e+291DL, /* exp(671.0DL) */ 7.012806227721897012192969479137924e+291DL, /* exp(672.0DL) */ 1.906278373532085777127233131597929e+292DL, /* exp(673.0DL) */ 5.181801862756732947542478176037853e+292DL, /* exp(674.0DL) */ 1.408559784220685861163313619793030e+293DL, /* exp(675.0DL) */ 3.828862465745284175763386828853108e+293DL, /* exp(676.0DL) */ 1.040792726430429952342378704515152e+294DL, /* exp(677.0DL) */ 2.829167955448183987744726075009629e+294DL, /* exp(678.0DL) */ 7.690475842953428199469558510214363e+294DL, /* exp(679.0DL) */ 2.090488073610356201828202177433601e+295DL, /* exp(680.0DL) */ 5.682535743105386205805042279863698e+295DL, /* exp(681.0DL) */ 1.544673365005238856979877261448928e+296DL, /* exp(682.0DL) */ 4.198857538998426858121488429544030e+296DL, /* exp(683.0DL) */ 1.141367814854769059625262650135429e+297DL, /* exp(684.0DL) */ 3.102559390707726651118664429334005e+297DL, /* exp(685.0DL) */ 8.433630813475780520653859864366691e+297DL, /* exp(686.0DL) */ 2.292498538820348974912352830338758e+298DL, /* exp(687.0DL) */ 6.231657119844267706438578811036121e+298DL, /* exp(688.0DL) */ 1.693940031006010360564275039893585e+299DL, /* exp(689.0DL) */ 4.604606404782989622120963349708575e+299DL, /* exp(690.0DL) */ 1.251661791732773560414909608460945e+300DL, /* exp(691.0DL) */ 3.402369503843688383092159087116573e+300DL, /* exp(692.0DL) */ 9.248599196001515793928708938024616e+300DL, /* exp(693.0DL) */ 2.514029913319185603777288352959536e+301DL, /* exp(694.0DL) */ 6.833841829578010843769419754835242e+301DL, /* exp(695.0DL) */ 1.857630806390522231607897627268625e+302DL, /* exp(696.0DL) */ 5.049564064997079424341813227011041e+302DL, /* exp(697.0DL) */ 1.372613823952135019694448602262587e+303DL, /* exp(698.0DL) */ 3.731151215140771601712733760653182e+303DL, /* exp(699.0DL) */ 1.014232054735004509455329595231268e+304DL, /* exp(700.0DL) */ 2.756968564226842505826254726602022e+304DL, /* exp(701.0DL) */ 7.494217549770650136851917092620455e+304DL, /* exp(702.0DL) */ 2.037139538406042869372594433878036e+305DL, /* exp(703.0DL) */ 5.537519389284593616073850538300673e+305DL, /* exp(704.0DL) */ 1.505253833063194063830465824095254e+306DL, /* exp(705.0DL) */ 4.091704141634005599423296108553077e+306DL, /* exp(706.0DL) */ 1.112240501563433293848363821483406e+307DL, /* exp(707.0DL) */ 3.023383144276055014775621985096731e+307DL, /* exp(708.0DL) */ 8.218407461554972189241372386597816e+307DL, /* exp(709.0DL) */ 2.233994766161711031253644458116810e+308DL, /* exp(710.0DL) */ 6.072627377729993058870274802931239e+308DL, /* exp(711.0DL) */ 1.650711265188634268635859219882103e+309DL, /* exp(712.0DL) */ 4.487098436194904665811320991414945e+309DL, /* exp(713.0DL) */ 1.219719814161560797699519459504529e+310DL, /* exp(714.0DL) */ 3.315542206646814341669187723053315e+310DL, /* exp(715.0DL) */ 9.012578131817040091646289944365234e+310DL, /* exp(716.0DL) */ 2.449872736328562975159249769074200e+311DL, /* exp(717.0DL) */ 6.659444541199170579579700734839518e+311DL, /* exp(718.0DL) */ 1.810224708397248900192728326006270e+312DL, /* exp(719.0DL) */ 4.920700930263815717908101983834722e+312DL, /* exp(720.0DL) */ 1.337585192201764982860090659029994e+313DL, /* exp(721.0DL) */ 3.635933521977957171804010465462696e+313DL, /* exp(722.0DL) */ 9.883492022277777556027845935179594e+313DL, /* exp(723.0DL) */ 2.686611676587762382032477144990756e+314DL, /* exp(724.0DL) */ 7.302967700594403819661802237302293e+314DL, /* exp(725.0DL) */ 1.985152439434910522842840163468744e+315DL, /* exp(726.0DL) */ 5.396203802837062631836118637081575e+315DL, /* exp(727.0DL) */ 1.466840273991358384174339327079969e+316DL, /* exp(728.0DL) */ 3.987285262042596563546861047334350e+316DL, /* exp(729.0DL) */ 1.083856507269295270218762885555664e+317DL, /* exp(730.0DL) */ 2.946227448367214400878225512361948e+317DL, /* exp(731.0DL) */ 8.008676535403858849347854789488034e+317DL, /* exp(732.0DL) */ 2.176983989619465295637813934827586e+318DL, /* exp(733.0DL) */ 5.917656019828867276099362352692636e+318DL, /* exp(734.0DL) */ 1.608585682577208938684831976797157e+319DL, /* exp(735.0DL) */ 4.372589230469016858241988532693547e+319DL, /* exp(736.0DL) */ 1.188592984849964869521935757602547e+320DL, /* exp(737.0DL) */ 3.230930712151556757737907741524966e+320DL, /* exp(738.0DL) */ 8.782580243851818865661945584396214e+320DL, /* exp(739.0DL) */ 2.387352828384580956238600899756351e+321DL, /* exp(740.0DL) */ 6.489497811518111949732100007150520e+321DL, /* exp(741.0DL) */ 1.764028397687442585608481908129751e+322DL, /* exp(742.0DL) */ 4.795126338319501235251533562592617e+322DL, /* exp(743.0DL) */ 1.303450479061926016436398558519613e+323DL, /* exp(744.0DL) */ 3.543145751530270709100952804291556e+323DL, /* exp(745.0DL) */ 9.631268711966602235896809976117011e+323DL, /* exp(746.0DL) */ 2.618050272474496901344534952692922e+324DL, /* exp(747.0DL) */ 7.116598481659677023880278303144470e+324DL, /* exp(748.0DL) */ 1.934492033313473195934101346006087e+325DL, /* exp(749.0DL) */ 5.258494541454804166807735549286840e+325DL, /* exp(750.0DL) */ 1.429407015708767371435505583554978e+326DL, /* exp(751.0DL) */ 3.885531116273015366004138350574444e+326DL, /* exp(752.0DL) */ 1.056196862727712730194308509475448e+327DL, /* exp(753.0DL) */ 2.871040739228194163929095858500196e+327DL, /* exp(754.0DL) */ 7.804297870209624512932094469324608e+327DL, /* exp(755.0DL) */ 2.121428108447245061685883072308586e+328DL, /* exp(756.0DL) */ 5.766639477574391013185570062882344e+328DL, /* exp(757.0DL) */ 1.567535130316502898552990500196127e+329DL, /* exp(758.0DL) */ 4.261002260210531250477579537542399e+329DL, /* exp(759.0DL) */ 1.158260501495320733780838097543570e+330DL, /* exp(760.0DL) */ 3.148478473836591142185522040052992e+330DL, /* exp(761.0DL) */ 8.558451822724473185317785446579883e+330DL, /* exp(762.0DL) */ 2.326428406945412944180484968414935e+331DL, /* exp(763.0DL) */ 6.323888063810640869736906367024209e+331DL, /* exp(764.0DL) */ 1.719011000906552019388401599159601e+332DL, /* exp(765.0DL) */ 4.672756366685475689938267252485588e+332DL, /* exp(766.0DL) */ 1.270186872037743970562137024901372e+333DL, /* exp(767.0DL) */ 3.452725893007433996921737545743740e+333DL, /* exp(768.0DL) */ 9.385482053612137472931923385909968e+333DL, /* exp(769.0DL) */ 2.551238531766235587117882706264335e+334DL, /* exp(770.0DL) */ 6.934985340964692832704317313855231e+334DL, /* exp(771.0DL) */ 1.885124463297418049480527073185397e+335DL, /* exp(772.0DL) */ 5.124299572964981846159920452385392e+335DL, /* exp(773.0DL) */ 1.392929041277115553629473402158305e+336DL, /* exp(974.0DL) */ 3.786373701236462561280390085789673e+336DL, /* exp(775.0DL) */ 1.029243082782629411817691553637979e+337DL, /* exp(776.0DL) */ 2.797772768995190337381259359131943e+337DL, /* exp(777.0DL) */ 7.605134878117171972732666762336810e+337DL, /* exp(778.0DL) */ 2.067289994216600435830214794233100e+338DL, /* exp(779.0DL) */ 5.619476825434189682607279641036338e+338DL, /* exp(780.0DL) */ 1.527532174002448008606957458439105e+339DL, /* exp(781.0DL) */ 4.152262950977394815646445394711523e+339DL, /* exp(782.0DL) */ 1.128702092662558368976236259107382e+340DL, /* exp(783.0DL) */ 3.068130388228329868155355092030060e+340DL, /* exp(784.0DL) */ 8.340043081664064831576661484892520e+340DL, /* exp(785.0DL) */ 2.267058755745300447162613736782219e+341DL, /* exp(786.0DL) */ 6.162504619791423322029108992107036e+341DL, /* exp(787.0DL) */ 1.675142432577394355012813183678504e+342DL, /* exp(788.0DL) */ 4.553509234555812431045605262925491e+342DL, /* exp(789.0DL) */ 1.237772140801352130137968719139589e+343DL, /* exp(790.0DL) */ 3.364613518113166256879695073686605e+343DL, /* exp(791.0DL) */ 9.145967786074678487937518358486807e+343DL, /* exp(792.0DL) */ 2.486131803655860291965933147405355e+344DL, /* exp(793.0DL) */ 6.758006905031835956303670857496097e+344DL, /* exp(794.0DL) */ 1.837016736654879231178405757986544e+345DL, /* exp(795.0DL) */ 4.993529213824093501885397663400206e+345DL, /* exp(796.0DL) */ 1.357381972181741554798631247078373e+346DL, /* exp(797.0DL) */ 3.689746749259529308695564251354971e+346DL, /* exp(798.0DL) */ 1.002977154012801164059425092238661e+347DL, /* exp(799.0DL) */ 2.726374572112566567364779546367270e+347DL, /* exp(800.0DL) */ 7.411054456946394527643734255031975e+347DL, /* exp(801.0DL) */ 2.014533466003780185206947161220956e+348DL, /* exp(802.0DL) */ 5.476069713460693445797399842131595e+348DL, /* exp(803.0DL) */ 1.488550079347513369645468095661906e+349DL, /* exp(804.0DL) */ 4.046298631441615511213976592495992e+349DL, /* exp(805.0DL) */ 1.099898004236644699470400827438392e+350DL, /* exp(806.0DL) */ 2.989832758074841236490032825474100e+350DL, /* exp(807.0DL) */ 8.127208056406429679254269659776141e+350DL, /* exp(808.0DL) */ 2.209204197583555291455186381500514e+351DL, /* exp(809.0DL) */ 6.005239625646824521234554982136528e+351DL, /* exp(810.0DL) */ 1.632393374993796247932666212255357e+352DL, /* exp(811.0DL) */ 4.437305248142568354514550335867051e+352DL, /* exp(812.0DL) */ 1.206184622335189814332380803085358e+353DL, /* exp(813.0DL) */ 3.278749740660482701078221353658401e+353DL, /* exp(814.0DL) */ 8.912565840102197290438257902201843e+353DL, /* exp(815.0DL) */ 2.422686576809462744120292600053280e+354DL, /* exp(816.0DL) */ 6.585544897792811525640914217004867e+354DL, /* exp(817.0DL) */ 1.790136702617137988676169463619492e+355DL, /* exp(818.0DL) */ 4.866096069181759959966874278606174e+355DL, /* exp(819.0DL) */ 1.322742052039276714359927254015698e+356DL, /* exp(820.0DL) */ 3.595585683796994671507456303747256e+356DL, /* exp(821.0DL) */ 9.773815226932861133048219422303157e+356DL, /* exp(822.0DL) */ 2.656798432608791590522782184502560e+357DL, /* exp(823.0DL) */ 7.221926901238951475359041420051346e+357DL, /* exp(824.0DL) */ 1.963123266209738361537629812032583e+358DL, /* exp(825.0DL) */ 5.336322301563100606580738879236068e+358DL, /* exp(826.0DL) */ 1.450562794313972570108358416386998e+359DL, /* exp(827.0DL) */ 3.943038484822447303136740477606212e+359DL, /* exp(828.0DL) */ 1.071828986220754533990420066011544e+360DL, /* exp(829.0DL) */ 2.913533256459557435440451773626653e+360DL, /* exp(830.0DL) */ 7.919804507645122153121565572979161e+360DL, /* exp(831.0DL) */ 2.152826067807977114589000590698994e+361DL, /* exp(832.0DL) */ 5.851987979955364533013829044052101e+361DL, /* exp(833.0DL) */ 1.590735258627342286079138111639773e+362DL, /* exp(834.0DL) */ 4.324066747415804201377394599833634e+362DL, /* exp(835.0DL) */ 1.175403206454438875839130486743495e+363DL, /* exp(836.0DL) */ 3.195077177217596747680371113061627e+363DL, /* exp(837.0DL) */ 8.685120231354813795861588571062056e+363DL, /* exp(838.0DL) */ 2.360860450287380922234892268978168e+364DL, /* exp(839.0DL) */ 6.417484061543826679679953837133422e+364DL, /* exp(840.0DL) */ 1.744453030892013317040787485731125e+365DL, /* exp(841.0DL) */ 4.741914974474065282186766441410415e+365DL, /* exp(842.0DL) */ 1.288986130721068898936989817415551e+366DL, /* exp(843.0DL) */ 3.503827576274817066469387283511598e+366DL, /* exp(844.0DL) */ 9.524390830641534520220942573435094e+366DL, /* exp(845.0DL) */ 2.588997852207483509886649384554193e+367DL, /* exp(846.0DL) */ 7.037625815575099238948400387904897e+367DL, /* exp(847.0DL) */ 1.913025036997206022941837310382119e+368DL, /* exp(848.0DL) */ 5.200141195456697847293452548102919e+368DL, /* exp(849.0DL) */ 1.413544931703123795815965756251118e+369DL, /* exp(850.0DL) */ 3.842413501558983570866924089658815e+369DL, /* exp(851.0DL) */ 1.044476279871347632101279988319276e+370DL, /* exp(852.0DL) */ 2.839180891830788305933519109095650e+370DL, /* exp(853.0DL) */ 7.717693825971777963654884672708470e+370DL, /* exp(854.0DL) */ 2.097886688474964905823576978118637e+371DL, /* exp(855.0DL) */ 5.702647263447619025108165020564636e+371DL, /* exp(856.0DL) */ 1.550140243034136448104461225796107e+372DL, /* exp(857.0DL) */ 4.213718054202781183259880383059111e+372DL, /* exp(858.0DL) */ 1.145407321698922631344907889538815e+373DL, /* exp(859.0DL) */ 3.113539908758125249535484762623464e+373DL, /* exp(860.0DL) */ 8.463478956159245573379795255424772e+373DL, /* exp(861.0DL) */ 2.300612105207320560570469899879770e+374DL, /* exp(862.0DL) */ 6.253712079917968677677102550660032e+374DL, /* exp(863.0DL) */ 1.699935190725583472080427393935978e+375DL, /* exp(864.0DL) */ 4.620902938507414836577231776192770e+375DL, /* exp(865.0DL) */ 1.256091648881771067050965908374898e+376DL, /* exp(866.0DL) */ 3.414411104034477698615834349236418e+376DL, /* exp(867.0DL) */ 9.281331658985707362486969070681960e+376DL, /* exp(868.0DL) */ 2.522927519252249231103011832368825e+377DL, /* exp(869.0DL) */ 6.858028030102647089906384408884850e+377DL, /* exp(870.0DL) */ 1.864205297329080765037552524479372e+378DL, /* exp(871.0DL) */ 5.067435384246731739018239329665377e+378DL, /* exp(872.0DL) */ 1.377471752188827042319870828033714e+379DL, /* exp(873.0DL) */ 3.744356433190529618458759523623273e+379DL, /* exp(874.0DL) */ 1.017821605161554170369897256012423e+380DL, /* exp(875.0DL) */ 2.766725973923669863850278968760077e+380DL, /* exp(876.0DL) */ 7.520740939242366025852659043295359e+380DL, /* exp(877.0DL) */ 2.044349343169053595033812265286127e+381DL, /* exp(878.0DL) */ 5.557117670558623144732170233962540e+381DL, /* exp(879.0DL) */ 1.510581198248816429203206789026766e+382DL, /* exp(880.0DL) */ 4.106185421611648223691878540343077e+382DL, /* exp(881.0DL) */ 1.116176921585038669288681280743735e+383DL, /* exp(882.0DL) */ 3.034083443289967269077449220617243e+383DL, /* exp(883.0DL) */ 8.247493889923568110575810990828503e+383DL, /* exp(884.0DL) */ 2.241901277130624027773101880668667e+384DL, /* exp(885.0DL) */ 6.094119502823301376410746524099709e+384DL}; /* exp(886.0DL) */ #endif /*_DDLOGTBLS_H */ libdfp-1.0.12/sysdeps/powerpc/dfpu/expd32.c000066400000000000000000000025621261375163000204240ustar00rootroot00000000000000/* Decimal Floating Point 32-bit e^x. POWER6 PowerPC32 version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ extern _Decimal64 __expd64(_Decimal64); #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 32 #endif #include #define FUNCTION_NAME exp #include _Decimal32 INTERNAL_FUNCTION_NAME (_Decimal32 a) { return (_Decimal32) __expd64((_Decimal64) a); } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/sysdeps/powerpc/dfpu/expd64.c000066400000000000000000000126241261375163000204310ustar00rootroot00000000000000/* Decimal Floating Point 64-bit e^x. POWER6 PowerPC64 version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 64 # include #endif #define FUNCTION_NAME exp #include #include "ddlogtbls.h" /* Core implementation of expd64(x). Separate into integer and fractional parts, where e^(i+f) == (e^i)*(e^f). We use a table lookup (expIntXDL(i)) for e^i and taylor series for e^f. Effectively: e^x = e^i * (1 + (x-i) + (((x-i)^2)/2!) + (((x-i)^3)/3!) + ...) The real expd64 will need add checks for NAN, INF and handle negative values of x. */ static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE val) { DEC_TYPE result, top, fraction, a, x, tp; DEC_TYPE t1, t2, t3, t4, t5, t6, t7, t8; DEC_TYPE t9, t10, t11, t12, t13, t14, t15, t16; DEC_TYPE t17, t18, t19, t20; long exp; long tmp; int neg = 0; if (__isinfd64(val)) { if (val < DFP_CONSTANT(0.0)) return DFP_CONSTANT(0.0); /* exp(-inf) = 0 */ else return val; /* exp(inf) = inf */ } if (val < DFP_CONSTANT(0.0)) { neg = 1; val = FUNC_D(__fabs) (val); } tmp = val; top = tmp; fraction = val - top; exp = tmp; if (fraction != 0.0DD) { a = top; x = val; t1 = (x - a); tp = t1 * t1; /* tp == ((x-a))^2 */ t2 = tp * __oneOverfactDD[2]; /* t2 == (((x-a))^2)/2! */ tp = tp * t1; /* tp == ((x-a))^3 */ t3 = tp * __oneOverfactDD[3]; /* t3 == (((x-a))^3)/3! */ tp = tp * t1; /* tp == ((x-a)/a)^4 */ t4 = tp * __oneOverfactDD[4]; /* t4 == (((x-a))^4)/4! */ tp = tp * t1; /* tp == ((x-a))^5 */ t5 = tp * __oneOverfactDD[5]; /* t5 == (((x-a))^5)/5! */ tp = tp * t1; /* tp == ((x-a))^6 */ t6 = tp * __oneOverfactDD[6]; /* t6 == (((x-a))^6)/6! */ tp = tp * t1; /* tp == ((x-a))^7 */ t7 = tp * __oneOverfactDD[7]; /* t7 == (((x-a))^7)/7! */ tp = tp * t1; /* tp == ((x-a))^8 */ t8 = tp * __oneOverfactDD[8]; /* t8 == (((x-a))^8)/8! */ if ( t8 > 1.0E-16DD) { tp = tp * t1; /* tp == ((x-a))^9 */ t9 = tp * __oneOverfactDD[9]; /* t9 == (((x-a))^9)/9! */ tp = tp * t1; /* tp == ((x-a))^10 */ t10 = tp * __oneOverfactDD[10]; /* t10 == (((x-a))^10)/10! */ tp = tp * t1; /* tp == ((x-a))^11 */ t11 = tp * __oneOverfactDD[11]; /* t12 == (((x-a))^11)/11! */ tp = tp * t1; /* tp == ((x-a))^12 */ t12 = tp * __oneOverfactDD[12]; /* t12 == (((x-a))^11)/12! */ if (t12 > 1.0E-16DD) { tp = tp * t1; /* tp == ((x-a))^13 */ t13 = tp * __oneOverfactDD[13]; /* t13 == (((x-a))^13)/13! */ tp = tp * t1; /* tp == ((x-a))^14 */ t14 = tp * __oneOverfactDD[14]; /* t14 == (((x-a))^14)/14! */ tp = tp * t1; /* tp == ((x-a))^15 */ t15 = tp * __oneOverfactDD[15]; /* t15 == (((x-a))^15)/15! */ tp = tp * t1; /* tp == ((x-a))^16 */ t16 = tp * __oneOverfactDD[16]; /* t16 == (((x-a))^16)/16! */ if (t12 > 1.0E-16DD) { tp = tp * t1; /* tp == ((x-a))^17 */ t17 = tp * __oneOverfactDD[17]; /* t17 == (((x-a))^17)/17! */ tp = tp * t1; /* tp == ((x-a))^18 */ t18 = tp * __oneOverfactDD[18]; /* t18 == (((x-a))^18)/18! */ tp = tp * t1; /* tp == ((x-a))^19 */ t19 = tp * __oneOverfactDD[19]; /* t19 == (((x-a))^19)/19! */ tp = tp * t1; /* tp == ((x-a))^20 */ t20 = tp * __oneOverfactDD[20]; /* t20 == (((x-a))^20)/20! */ tp = t19 + t20; tp = tp + t18; tp = tp + t17; tp = tp + t16; tp = tp + t15; } else { tp = t15 + t16; } tp = tp + t14; tp = tp + t13; tp = tp + t12; tp = tp + t11; } else { tp = t11 + t12; } tp = tp + t10; tp = tp + t9; tp = tp + t8; tp = tp + t7; } else tp = t7 + t8; /* now sum the terms from smallest to largest to avoid lose of percision */ tp = tp + t6; tp = tp + t5; tp = tp + t4; tp = tp + t3; tp = tp + t2; tp = tp + t1; tp = tp + 1.DD; if (exp!=0) result = __expIntXDL[exp] * tp; else result = tp; } else { if (exp!=0) result = __expIntXDL[exp]; else result = 1.DD; } if (neg) result = 1/result; return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); if (!FUNC_D(__isfinite) (z) && FUNC_D(__isfinite) (x)) DFP_ERRNO (ERANGE); return z; } weak_alias(INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/sysdeps/powerpc/dfpu/fabsd128.c000066400000000000000000000023501261375163000206240ustar00rootroot00000000000000/* Return absolute value of number. Copyright (C) 2014-2015 Free Software Foundation, Inc. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include _Decimal128 __fabsd128 (_Decimal128 x) { /* Half part os decimal128 constainst the sign bit at same position as binary64, so the instruction works for both formats. */ _Decimal128 ret; asm ("fabs %0, %1\n" : "=f"(ret) : "f"(x)); return ret; } hidden_def (__fabsd128) weak_alias (__fabsd128, fabsd128) libdfp-1.0.12/sysdeps/powerpc/dfpu/fabsd32.c000066400000000000000000000024301261375163000205350ustar00rootroot00000000000000/* Return absolute value of number. Copyright (C) 2014-2015 Free Software Foundation, Inc. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include _Decimal32 __fabsd32 (_Decimal32 x) { /* Both binary32 and decimal32 have the sign bit at same position, so the instruction works for both format. */ _Decimal64 tmp; asm ("dctdp %0, %1\n" /* DFP Convert To DFP Long */ "fabs %0, %0\n" : "=&f"(tmp) : "f" (x)); return (_Decimal32)tmp; } hidden_def (__fabsd32) weak_alias (__fabsd32, fabsd32) libdfp-1.0.12/sysdeps/powerpc/dfpu/fabsd64.c000066400000000000000000000022551261375163000205470ustar00rootroot00000000000000/* Return absolute value of number. Copyright (C) 2014-2015 Free Software Foundation, Inc. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include _Decimal64 __fabsd64 (_Decimal64 x) { /* Both binary64 and decimal64 have the sign bit at same position, so the instruction works for both format. */ asm ("fabs %0, %0\n" : "=&f"(x)); return x; } hidden_def (__fabsd64) weak_alias (__fabsd64, fabsd64) libdfp-1.0.12/sysdeps/powerpc/dfpu/fe_decround.c000066400000000000000000000102131261375163000215640ustar00rootroot00000000000000/* Decimal Float fe_dec_getround and fe_dec_setround definitions. Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #include #include #include int __fe_dec_setround (int rounding_direction) { /* The rounding modes are as follows: * * C Rounding Mode: (DRN) Hardware Description * DecNumber Rounding Mode Equivalent * * FE_DEC_TONEAREST: (000) Round to nearest, ties to even. * DEC_ROUND_HALF_EVEN * * FE_DEC_TOWARDZERO: (001) Round toward zero. * DEC_ROUND_DOWN * * FE_DEC_UPWARD: (010) Round toward +Infinity * DEC_ROUND_CEILING * * FE_DEC_DOWNWARD: (011) Round toward -Infinity * DEC_ROUND_FLOOR * * FE_DEC_TONEARESTFROMZERO: (100) Round to nearest, ties away from zero * DEC_ROUND_HALF_UP * * 5: (101) Round to nearest, ties toward zero * DEC_ROUND_HALF_DOWN * * 6: (110) Round away from zero * DEC_ROUND_UP * * 7: (111) Round for prepare for shorter precision * Not supported by decNumber. */ /* High order bits 29-31 contain DFP Rounding control (DRN) and bit 28 is * reserved for future rounding control. The new Power6[x] form of the mtfsfi * instruction can be used against these four bits to set the rounding mode. * Then new form of the mtfsfi instruction for Power6[x] adds the 'W' parameter: mtfsfi BF,U,W BF: Field [0-7: Bits 28-31 are field 7 of the high order word] U: Bit Pattern [Bit 28 is reserved, use 0000-0111] W: Word [Implicit '0' for bits 32:63 {low order word.}] ['1' indicates the bits 0:31 {high order word}.] */ switch (rounding_direction) { case FE_DEC_TONEAREST: asm ("mtfsfi 7, 0, 1\n"); break; case FE_DEC_TOWARDZERO: asm ("mtfsfi 7, 1, 1\n"); break; case FE_DEC_UPWARD: asm ("mtfsfi 7, 2, 1\n"); break; case FE_DEC_DOWNWARD: asm ("mtfsfi 7, 3, 1\n"); break; case FE_DEC_TONEARESTFROMZERO: asm ("mtfsfi 7, 4, 1\n"); break; case 5: /* Allow covert setting of this rounding mode. */ asm ("mtfsfi 7, 5, 1\n"); break; case 6: /* Allow covert setting of this rounding mode. */ asm ("mtfsfi 7, 6, 1\n"); break; case 7: /* Allow covert setting of this rounding mode. */ asm ("mtfsfi 7, 7, 1\n"); break; default: return 1; } return 0; } strong_alias (__fe_dec_setround, fe_dec_setround) hidden_def (__fe_dec_setround) int __fe_dec_getround (void) { fenv_union_t u = { .fenv = fegetenv_register () }; /* DFP Rounding Control bits are 29:31 (bit 28 is reserved). */ int rounding = (u.l & 0x700000000ULL) >> 32; switch (rounding) { case 0: return FE_DEC_TONEAREST; case 1: return FE_DEC_TOWARDZERO; case 2: return FE_DEC_UPWARD; case 3: return FE_DEC_DOWNWARD; case 4: return FE_DEC_TONEARESTFROMZERO; case 5: return 5; case 6: return 6; case 7: return 7; default: return FE_DEC_TONEAREST; /* Default */ } } strong_alias (__fe_dec_getround, fe_dec_getround) hidden_def (__fe_dec_getround) extern int (*__printf_dfp_getround_callback)(void); static void __attribute__ ((constructor)) __init_printf_dfp_getround (void) { __printf_dfp_getround_callback = &__fe_dec_getround; } libdfp-1.0.12/sysdeps/powerpc/dfpu/floord128.c000066400000000000000000000021601261375163000210310ustar00rootroot00000000000000/* _Decimal32 floord128 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal128 __floord128 (_Decimal128 x) { _Decimal128 ret; asm ("drintnq 1,%0,%1,1\n" : "=f"(ret) : "f"(x)); return ret; } weak_alias (__floord128, floord128) libdfp-1.0.12/sysdeps/powerpc/dfpu/floord32.c000066400000000000000000000021671261375163000207520ustar00rootroot00000000000000/* _Decimal32 floord32 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal32 __floord32 (_Decimal32 x) { _Decimal64 ret; asm ("drintn 1,%0,%1,1\n" : "=f"(ret) : "f"((_Decimal64) x)); return ret; } weak_alias (__floord32, floord32) libdfp-1.0.12/sysdeps/powerpc/dfpu/floord64.c000066400000000000000000000021521261375163000207510ustar00rootroot00000000000000/* _Decimal32 floord64 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal64 __floord64 (_Decimal64 x) { _Decimal64 ret; asm ("drintn 1,%0,%1,1\n" : "=f"(ret) : "f"(x)); return ret; } weak_alias (__floord64, floord64) libdfp-1.0.12/sysdeps/powerpc/dfpu/fpclassifyd128.c000066400000000000000000000032631261375163000220600ustar00rootroot00000000000000/* Returns the type of floating point number from a _Decimal32 type Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include int __fpclassifyd128 (_Decimal128 val) { int result = FP_NAN; /* Check in order, FP_NORMAL, FP_ZERO, FP_SUBNORMAL, FP_INFINITE, FP_NAN. The thought is the most likely case exits early. */ asm ( "dtstdcq cr0,%1,0x08;" "li %0,4;" "beq cr0,1f;" "dtstdcq cr0,%1,0x20;" "li %0,2;" "beq cr0,1f;" "dtstdcq cr0,%1,0x10;" "li %0,3;" "beq cr0,1f;" "dtstdcq cr0,%1,0x04;" "li %0,1;" "beq cr0,1f;" "li %0,0;" "1:;" : "=r" (result) : "f" (val) : "cr0"); return result; } hidden_def (__fpclassifyd128) weak_alias (__fpclassifyd128, fpclassifyd128) libdfp-1.0.12/sysdeps/powerpc/dfpu/fpclassifyd32.c000066400000000000000000000041561261375163000217740ustar00rootroot00000000000000/* _Decimal32 fpclassify classification function. Copyright (C) 2006 IBM Corporation. Copyright (C) 2010-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include int __fpclassifyd32 (_Decimal32 x) { int result = 0; /* Since _Decimal32 is promoted to _Decimal64, __DEC32_SUBNORMAL_MIN__ is well * within the bounds of a _Decimal64. This means that we need to do our range * check for __DEC32_SUBNORMAL_MIN__ before dropping into the asm code. This * is crude. The asm code should probably be broken into two parts with this * code in between so the zero, <-1 and > 1 checks aren't redundant. */ if (x != 0 && x > -1 && x < 1 && x <= 0.000001E-95DF) return FP_SUBNORMAL; /* Check in order, FP_NORMAL, FP_ZERO, FP_SUBNORMAL, FP_INFINITE, FP_NAN. The most likely case exits early. */ asm ( "dtstdc cr0,%1,0x08;" "li %0,4;" "beq cr0,1f;" "dtstdc cr0,%1,0x20;" "li %0,2;" "beq cr0,1f;" "dtstdc cr0,%1,0x04;" "li %0,1;" "beq cr0,1f;" "li %0,0;" "1:;" : "=r" (result) : "f" ((_Decimal64) x) : "cr0"); return result; } hidden_def (__fpclassifyd32) weak_alias (__fpclassifyd32, fpclassifyd32) libdfp-1.0.12/sysdeps/powerpc/dfpu/fpclassifyd64.c000066400000000000000000000031451261375163000217760ustar00rootroot00000000000000/* _Decimal64 fpclassify classification function. Copyright (C) 2010-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include int __fpclassifyd64 (_Decimal64 x) { int result = 0; /* Check in order, FP_NORMAL, FP_ZERO, FP_SUBNORMAL, FP_INFINITE, FP_NAN. The most likely case exits early. */ asm ( "dtstdc cr0,%1,0x08;" "li %0,4;" "beq cr0,1f;" "dtstdc cr0,%1,0x20;" "li %0,2;" "beq cr0,1f;" "dtstdc cr0,%1,0x10;" "li %0,3;" "beq cr0,1f;" "dtstdc cr0,%1,0x04;" "li %0,1;" "beq cr0,1f;" "li %0,0;" "1:;" : "=r" (result) : "f" (x) : "cr0"); return result; } hidden_def (__fpclassifyd64) weak_alias (__fpclassifyd64, fpclassifyd64) libdfp-1.0.12/sysdeps/powerpc/dfpu/isfinited128.c000066400000000000000000000032071261375163000215250ustar00rootroot00000000000000/* Returns non-zero if the _Decimal128 is finite Copyright (C) 2008, 2010 IBM Corporation. Copyright (C) 2014-2015 Free Software Foundation, Inc. Author(s): Pete Eberlein Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include int __isfinited128 (_Decimal128 val) { int cr0; asm ("dtstdcq cr0,%1,0x38\n" "mfcr %0, 128\n" : "=r" (cr0) : "f" (val) : "cr0"); return (cr0 & 0x20000000) ? 1 : 0; } hidden_def (__isfinited128) weak_alias (__isfinited128, isfinited128) /* We erroneously published a version of math.h which used 'finite' instead of * 'isfinite' and math.h contained a polymorphic 'isfinite()' function which * inlined calles to 'finited*' so we've created aliases for compatability. */ strong_alias (__isfinited128, finited128) strong_alias (__isfinited128, __finited128) libdfp-1.0.12/sysdeps/powerpc/dfpu/isfinited32.c000066400000000000000000000032261261375163000214400ustar00rootroot00000000000000/* Returns non-zero if the _Decimal32 is finite Copyright (C) 2008, 2010 IBM Corporation. Copyright (C) 2014-2015 Free Software Foundation, Inc. Author(s): Pete Eberlein Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include int __isfinited32 (_Decimal32 val) { int cr0; _Decimal64 input = val; asm ("dtstdc cr0,%1,0x38\n" "mfcr %0, 128\n" : "=r" (cr0) : "f" (input) : "cr0"); return (cr0 & 0x20000000) ? 1 : 0; } hidden_def (__isfinited32) weak_alias (__isfinited32, isfinited32) /* We erroneously published a version of math.h which used 'finite' instead of * 'isfinite' and math.h contained a polymorphic 'isfinite()' function which * inlined calles to 'finited*' so we've created aliases for compatability. */ strong_alias (__isfinited32, finited32) strong_alias (__isfinited32, __finited32) libdfp-1.0.12/sysdeps/powerpc/dfpu/isfinited64.c000066400000000000000000000031661261375163000214500ustar00rootroot00000000000000/* Returns non-zero if the _Decimal64 is finite Copyright (C) 2008, 2010 IBM Corporation. Copyright (C) 2014-2015 Free Software Foundation, Inc. Author(s): Pete Eberlein Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include int __isfinited64 (_Decimal64 x) { int cr0; asm ("dtstdc cr0,%1,0x38\n" "mfcr %0, 128\n" : "=r" (cr0) : "f" (x) : "cr0"); return (cr0 & 0x20000000) ? 1 : 0; } hidden_def (__isfinited64) weak_alias (__isfinited64, isfinited64) /* We erroneously published a version of math.h which used 'finite' instead of * 'isfinite' and math.h contained a polymorphic 'isfinite()' function which * inlined calles to 'finited*' so we've created aliases for compatability. */ strong_alias (__isfinited64, finited64) strong_alias (__isfinited64, __finited64) libdfp-1.0.12/sysdeps/powerpc/dfpu/isinfd128.c000066400000000000000000000026241261375163000210250ustar00rootroot00000000000000/* Returns non-zero if the _Decimal128 is infinite Copyright (C) 2008 IBM Corporation. Copyright (C) 2014-2015 Free Software Foundation, Inc. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include int __isinfd128 (_Decimal128 x) { int cr0; asm ("dtstdcq cr0,%1,0x04\n" "mfcr %0, 128\n" : "=r" (cr0) : "f" (x) : "cr0"); /* cr0 bits are 28:31 and: - 0010 operand positive with match - 1010 operand negative with math */ return (cr0 & 0x20000000) ? (cr0 & 0x80000000 ? -1 : 1) : 0; } hidden_def (__isinfd128) weak_alias (__isinfd128, isinfd128) libdfp-1.0.12/sysdeps/powerpc/dfpu/isinfd32.c000066400000000000000000000030211261375163000207270ustar00rootroot00000000000000/* _Decimal32 isinf classification function. Copyright (C) 2006 IBM Corporation. Copyright (C) 2010-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include int __isinfd32 (_Decimal32 x) { int cr0; _Decimal64 input = x; asm ("dtstdc cr0,%1,0x04\n" "mfcr %0, 128\n" : "=r" (cr0) : "f" (input) : "cr0"); /* cr0 bits are 28:31 and: - 0010 operand positive with match - 1010 operand negative with math */ return (cr0 & 0x20000000) ? (cr0 & 0x80000000 ? -1 : 1) : 0; } hidden_def (__isinfd32) weak_alias (__isinfd32, isinfd32) libdfp-1.0.12/sysdeps/powerpc/dfpu/isinfd64.c000066400000000000000000000027161261375163000207460ustar00rootroot00000000000000/* _Decimal64 isinf classification function. Copyright (C) 2010-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include int __isinfd64 (_Decimal64 x) { int cr0; asm ("dtstdc cr0,%1,0x04\n" "mfcr %0, 128\n" : "=r" (cr0) : "f" (x) : "cr0"); /* cr0 bits are 28:31 and: - 0010 operand positive with match - 1010 operand negative with math */ return (cr0 & 0x20000000) ? (cr0 & 0x80000000 ? -1 : 1) : 0; } hidden_def (__isinfd64) weak_alias (__isinfd64, isinfd64) libdfp-1.0.12/sysdeps/powerpc/dfpu/isnand128.c000066400000000000000000000023771261375163000210320ustar00rootroot00000000000000/* Returns non-zero if the _Decimal128 is NaN Copyright (C) 2008 IBM Corporation. Copyright (C) 2014-2015 Free Software Foundation, Inc. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include int __isnand128 (_Decimal128 val) { int cr0; asm ("dtstdcq cr0,%1,3\n" "mfcr %0, 128\n" : "=r" (cr0) : "f" (val) : "cr0"); return (cr0 & 0x20000000) ? 1 : 0; } hidden_def (__isnand128) weak_alias (__isnand128, isnand128) libdfp-1.0.12/sysdeps/powerpc/dfpu/isnand32.c000066400000000000000000000025501261375163000207350ustar00rootroot00000000000000/* _Decimal32 isNaN classification function. Copyright (C) 2006 IBM Corporation. Copyright (C) 2010-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include int __isnand32 (_Decimal32 x) { int cr0; asm ("dtstdc 0,%1,3\n" "mfcr %0, 128\n" : "=r" (cr0) : "f" ((_Decimal64)x) : "cr0"); return (cr0 & 0x20000000) ? 1 : 0; } hidden_def (__isnand32) weak_alias (__isnand32, isnand32) libdfp-1.0.12/sysdeps/powerpc/dfpu/isnand64.c000066400000000000000000000024031261375163000207370ustar00rootroot00000000000000/* _Decimal64 isNaN classification function. Copyright (C) 2010-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include int __isnand64 (_Decimal64 x) { int cr0; asm ("dtstdc 0,%1,3\n" "mfcr %0, 128\n" : "=r" (cr0) : "f" (x) : "cr0"); return (cr0 & 0x20000000) ? 1 : 0; } hidden_def (__isnand64) weak_alias (__isnand64, isnand64) libdfp-1.0.12/sysdeps/powerpc/dfpu/isnormald128.c000066400000000000000000000024271261375163000215420ustar00rootroot00000000000000/* Returns non-zero if the _Decimal128 is normalized Copyright (C) 2008 IBM Corporation. Copyright (C) 2014-2015 Free Software Foundation, Inc. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more normalormation. */ #include #include int __isnormald128 (_Decimal128 x) { int cr0; asm ("dtstdcq cr0,%1,0x08\n" "mfcr %0, 128\n" : "=r" (cr0) : "f" (x) : "cr0"); return (cr0 & 0x20000000) ? (cr0 & 0x80000000 ? -1 : 1) : 0; } weak_alias (__isnormald128, isnormald128) libdfp-1.0.12/sysdeps/powerpc/dfpu/isnormald32.c000066400000000000000000000024111261375163000214450ustar00rootroot00000000000000/* Returns non-zero if the _Decimal32 is normalized Copyright (C) 2008 IBM Corporation. Copyright (C) 2014-2015 Free Software Foundation, Inc. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #include #include int __isnormald32 (_Decimal32 val) { int cr0; _Decimal64 input = val; asm ("dtstdc cr0,%1,0x08\n" "mfcr %0, 128\n" : "=r" (cr0) : "f" (input) : "cr0"); return (cr0 & 0x20000000) ? 1 : 0; } weak_alias (__isnormald32, isnormald32) libdfp-1.0.12/sysdeps/powerpc/dfpu/isnormald64.c000066400000000000000000000023511261375163000214550ustar00rootroot00000000000000/* Returns non-zero if the _Decimal64 is normalized Copyright (C) 2008 IBM Corporation. Copyright (C) 2014-2015 Free Software Foundation, Inc. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #include #include int __isnormald64 (_Decimal64 x) { int cr0; asm ("dtstdc cr0,%1,0x08\n" "mfcr %0, 128\n" : "=r" (cr0) : "f" (x) : "cr0"); return (cr0 & 0x20000000) ? 1 : 0; } weak_alias (__isnormald64, isnormald64) libdfp-1.0.12/sysdeps/powerpc/dfpu/issignalingd128.c000066400000000000000000000025321261375163000222220ustar00rootroot00000000000000/* _Decimal32 issignaling classification function. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __issignalingd128 (_Decimal128 x) { int cr0; /* DCM bit 5 is signaling NaN */ asm ("dtstdcq cr0,%1,1\n" "mfcr %0, 128\n" : "=r" (cr0) : "f" (x) : "cr0"); /* cr0 bits are 28:31 and: - 0010 operand positive with match - 1010 operand negative with math */ return (cr0 & 0x20000000) ? 1 : 0; } weak_alias (__issignalingd128, issignalingd128) libdfp-1.0.12/sysdeps/powerpc/dfpu/issignalingd32.c000066400000000000000000000025611261375163000221360ustar00rootroot00000000000000/* _Decimal32 issignaling classification function. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __issignalingd32 (_Decimal32 x) { _Decimal64 input = x; int cr0; /* DCM bit 5 is signaling NaN */ asm ("dtstdc cr0,%1,1\n" "mfcr %0, 128\n" : "=r" (cr0) : "f" (input) : "cr0"); /* cr0 bits are 28:31 and: - 0010 operand positive with match - 1010 operand negative with math */ return (cr0 & 0x20000000) ? 1 : 0; } weak_alias (__issignalingd32, issignalingd32) libdfp-1.0.12/sysdeps/powerpc/dfpu/issignalingd64.c000066400000000000000000000025251261375163000221430ustar00rootroot00000000000000/* _Decimal32 issignaling classification function. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include int __issignalingd64 (_Decimal64 x) { int cr0; /* DCM bit 5 is signaling NaN */ asm ("dtstdc cr0,%1,1\n" "mfcr %0, 128\n" : "=r" (cr0) : "f" (x) : "cr0"); /* cr0 bits are 28:31 and: - 0010 operand positive with match - 1010 operand negative with math */ return (cr0 & 0x20000000) ? 1 : 0; } weak_alias (__issignalingd64, issignalingd64) libdfp-1.0.12/sysdeps/powerpc/dfpu/libdfp-test-ulps000066400000000000000000000013251261375163000222700ustar00rootroot00000000000000# ULP file for PowerPC with hardware floating ponint # exp test exp 88.72269439697265625 # TODO check why these ulps are so high decimal32 15 decimal64 13 # log test log 0.75 decimal32 0 decimal64 0 decimal128 0 test log 1 decimal32 0 decimal64 0 decimal128 0 test log 2.718281828459045235360287471352662 decimal32 0 decimal64 0 decimal128 0 test log 3.141592653589793238462643383279503 decimal32 0 decimal64 0 decimal128 0 test log 2 decimal32 0 decimal64 0 decimal128 0 test log 10 decimal32 0 decimal64 0 decimal128 0 # log1p test log1p 3.141592653589793238462643383279503 decimal32 1 # log10 test log10 3.141592653589793238462643383279503 decimal64 1 test log10 2.718281828459045235360287471352662 decimal128 1 libdfp-1.0.12/sysdeps/powerpc/dfpu/libdfp.abilist000066400000000000000000000123131261375163000217570ustar00rootroot00000000000000LIBDFP_1.0.0 LIBDFP_1.0.0 A __dpd_adddd3 F __dpd_addsd3 F __dpd_addtd3 F __dpd_divdd3 F __dpd_divsd3 F __dpd_divtd3 F __dpd_eqdd2 F __dpd_eqsd2 F __dpd_eqtd2 F __dpd_extendddtd2 F __dpd_extendddtf F __dpd_extenddfdd F __dpd_extenddftd F __dpd_extendsddd2 F __dpd_extendsddf F __dpd_extendsdtd2 F __dpd_extendsdtf F __dpd_extendsfdd F __dpd_extendsfsd F __dpd_extendsftd F __dpd_extendtftd F __dpd_fixdddi F __dpd_fixddsi F __dpd_fixsddi F __dpd_fixsdsi F __dpd_fixtddi F __dpd_fixtdsi F __dpd_fixunsdddi F __dpd_fixunsddsi F __dpd_fixunssddi F __dpd_fixunssdsi F __dpd_fixunstddi F __dpd_fixunstdsi F __dpd_floatdidd F __dpd_floatdisd F __dpd_floatditd F __dpd_floatsidd F __dpd_floatsisd F __dpd_floatsitd F __dpd_floatunsdidd F __dpd_floatunsdisd F __dpd_floatunsditd F __dpd_floatunssidd F __dpd_floatunssisd F __dpd_floatunssitd F __dpd_gedd2 F __dpd_gesd2 F __dpd_getd2 F __dpd_gtdd2 F __dpd_gtsd2 F __dpd_gttd2 F __dpd_ledd2 F __dpd_lesd2 F __dpd_letd2 F __dpd_ltdd2 F __dpd_ltsd2 F __dpd_lttd2 F __dpd_muldd3 F __dpd_mulsd3 F __dpd_multd3 F __dpd_nedd2 F __dpd_nesd2 F __dpd_netd2 F __dpd_subdd3 F __dpd_subsd3 F __dpd_subtd3 F __dpd_truncdddf F __dpd_truncddsd2 F __dpd_truncddsf F __dpd_truncdfsd F __dpd_truncsdsf F __dpd_trunctddd2 F __dpd_trunctddf F __dpd_trunctdsd2 F __dpd_trunctdsf F __dpd_trunctdtf F __dpd_trunctfdd F __dpd_trunctfsd F __dpd_unorddd2 F __dpd_unordsd2 F __dpd_unordtd2 F acosd128 F acosd32 F acosd64 F acoshd128 F acoshd32 F acoshd64 F asind128 F asind32 F asind64 F asinhd128 F asinhd32 F asinhd64 F atan2d128 F atan2d32 F atan2d64 F atand128 F atand32 F atand64 F atanhd128 F atanhd32 F atanhd64 F cbrtd128 F cbrtd32 F cbrtd64 F ceild128 F ceild32 F ceild64 F copysignd128 F copysignd32 F copysignd64 F cosd128 F cosd32 F cosd64 F coshd128 F coshd32 F coshd64 F decoded128 F decoded32 F decoded64 F erfcd128 F erfcd32 F erfcd64 F erfd128 F erfd32 F erfd64 F exp2d128 F exp2d32 F exp2d64 F expd128 F expd32 F expd64 F expm1d128 F expm1d32 F expm1d64 F fabsd128 F fabsd32 F fabsd64 F fdimd128 F fdimd32 F fdimd64 F fe_dec_getround F fe_dec_setround F finited128 F finited32 F finited64 F floord128 F floord32 F floord64 F fmad128 F fmad32 F fmad64 F fmaxd128 F fmaxd32 F fmaxd64 F fmind128 F fmind32 F fmind64 F fmodd128 F fmodd32 F fmodd64 F fpclassifyd128 F fpclassifyd32 F fpclassifyd64 F frexpd128 F frexpd32 F frexpd64 F hypotd128 F hypotd32 F hypotd64 F ilogbd128 F ilogbd32 F ilogbd64 F isgreaterd128 F isgreaterd32 F isgreaterd64 F isgreaterequald128 F isgreaterequald32 F isgreaterequald64 F isinfd128 F isinfd32 F isinfd64 F islessd128 F islessd32 F islessd64 F islessequald128 F islessequald32 F islessequald64 F islessgreaterd128 F islessgreaterd32 F islessgreaterd64 F isnand128 F isnand32 F isnand64 F isnormald128 F isnormald32 F isnormald64 F isunorderedd128 F isunorderedd32 F isunorderedd64 F ldexpd128 F ldexpd32 F ldexpd64 F lgammad128 F lgammad32 F lgammad64 F llrintd128 F llrintd32 F llrintd64 F llroundd128 F llroundd32 F llroundd64 F log10d128 F log10d32 F log10d64 F log1pd128 F log1pd32 F log1pd64 F log2d128 F log2d32 F log2d64 F logbd128 F logbd32 F logbd64 F logd128 F logd32 F logd64 F lrintd128 F lrintd32 F lrintd64 F lroundd128 F lroundd32 F lroundd64 F modfd128 F modfd32 F modfd64 F nand128 F nand32 F nand64 F nearbyintd128 F nearbyintd32 F nearbyintd64 F nextafterd128 F nextafterd32 F nextafterd64 F nexttowardd128 F nexttowardd32 F nexttowardd64 F powd128 F powd32 F powd64 F printf_dfp F quantized128 F quantized32 F quantized64 F register_printf_dfp F remainderd128 F remainderd32 F remainderd64 F rintd128 F rintd32 F rintd64 F roundd128 F roundd32 F roundd64 F samequantumd128 F samequantumd32 F samequantumd64 F scalblnd128 F scalblnd32 F scalblnd64 F scalbnd128 F scalbnd32 F scalbnd64 F signbitd128 F signbitd32 F signbitd64 F sind128 F sind32 F sind64 F sinhd128 F sinhd32 F sinhd64 F sqrtd128 F sqrtd32 F sqrtd64 F strtod128 F strtod32 F strtod64 F tand128 F tand32 F tand64 F tanhd128 F tanhd32 F tanhd64 F tgammad128 F tgammad32 F tgammad64 F truncd128 F truncd32 F truncd64 F wcstod128 F wcstod32 F wcstod64 F LIBDFP_1.0.2 LIBDFP_1.0.2 A __isinfd128 F __isinfd32 F __isinfd64 F __isnand128 F __isnand32 F __isnand64 F LIBDFP_1.0.3 LIBDFP_1.0.3 A __fabsd128 F __fabsd32 F __fabsd64 F __finited128 F __finited32 F __finited64 F __fpclassifyd128 F __fpclassifyd32 F __fpclassifyd64 F __isfinited128 F __isfinited32 F __isfinited64 F __signbitd128 F __signbitd32 F __signbitd64 F isfinited128 F isfinited32 F isfinited64 F LIBDFP_1.0.9 LIBDFP_1.0.9 A __issignalingd128 F __issignalingd32 F __issignalingd64 F issignalingd128 F issignalingd32 F issignalingd64 F llogbd128 F llogbd32 F llogbd64 F llquantexpd128 F llquantexpd32 F llquantexpd64 F quantumd128 F quantumd32 F quantumd64 F roundevend128 F roundevend32 F roundevend64 F LIBDFP_PRIVATE LIBDFP_PRIVATE A __decoded128 F __decoded32 F __decoded64 F __fe_dec_getround F __fe_dec_setround F __fmt_d128 F __fmt_d32 F __fmt_d64 F libdfp-1.0.12/sysdeps/powerpc/dfpu/llquantexpd128.c000066400000000000000000000026301261375163000221070ustar00rootroot00000000000000/* _Decimal128 llquantexpd128 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include long long int __llquantexpd128 (_Decimal128 x) { long long int ret; _Decimal128 r; asm ("dxexq %0,%1\n" "dcffixq %0,%0\n" : "=f"(r) : "f"(x)); ret = (long long int)r; if ((ret == -1) || /* Infinity */ (ret == -2) || /* NaN */ (ret == -3)) /* SNaN */ { errno = EDOM; return LLONG_MIN; } return ret - 6176; } weak_alias (__llquantexpd128, llquantexpd128) libdfp-1.0.12/sysdeps/powerpc/dfpu/llquantexpd32.c000066400000000000000000000026351261375163000220260ustar00rootroot00000000000000/* _Decimal32 llquantexp32 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include long long int __llquantexpd32 (_Decimal32 x) { long long int ret; _Decimal64 r; asm ("dxex %0,%1\n" "dcffix %0,%0\n" : "=f"(r) : "f"((_Decimal64) x)); ret = (long long int)r; if ((ret == -1) || /* Infinity */ (ret == -2) || /* NaN */ (ret == -3)) /* SNaN */ { errno = EDOM; return LLONG_MIN; } return ret - 398; } weak_alias (__llquantexpd32, llquantexpd32) libdfp-1.0.12/sysdeps/powerpc/dfpu/llquantexpd64.c000066400000000000000000000026201261375163000220250ustar00rootroot00000000000000/* _Decimal64 llquantexpd64 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include long long int __llquantexpd64 (_Decimal64 x) { long long int ret; _Decimal64 r; asm ("dxex %0,%1\n" "dcffix %0,%0\n" : "=f"(r) : "f"(x)); ret = (long long int)r; if ((ret == -1) || /* Infinity */ (ret == -2) || /* NaN */ (ret == -3)) /* SNaN */ { errno = EDOM; return LLONG_MIN; } return ret - 398; } weak_alias (__llquantexpd64, llquantexpd64) libdfp-1.0.12/sysdeps/powerpc/dfpu/logd32.c000066400000000000000000000023511261375163000204050ustar00rootroot00000000000000/* Decimal Floating Point 32-bit natural logarithm. POWER6 PowerPC32 version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ extern _Decimal64 __logd64(_Decimal64); #include _Decimal32 __logd32 (_Decimal32 a) { return (_Decimal32) __logd64((_Decimal64) a); } weak_alias(__logd32, logd32) libdfp-1.0.12/sysdeps/powerpc/dfpu/logd64.c000066400000000000000000000120621261375163000204120ustar00rootroot00000000000000/* Calculate the Natural Log of a given a _Decimal64 value Copyright (C) 2010-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 64 #endif #include #include #define FUNCTION_NAME log #include /* __LN2digits lookup table. */ extern _Decimal128 __LN_10; extern _Decimal128 __LN2digits []; /* Core implementation of logd64(x). Separate into exponent "e" and mantisa "x" , where log(10^e*x) == log(10^e) + log(x). Use frexpd64 to separate the exponent from the mantissa. Then separate the high order 2 digits "a" from the remaining digits of the mantisa. Use the high order digits for a table lookup (log(a) == __LN2digits[]) and then use the taylor series to compute: log(x) = log(a) + (((x -a)/a) - ((((x -a)/a)^2)/2) + ((((x -a)/a)^3)/3) - ((((x -a)/a)^4)/4) + ...) then final compute log (10*e * x) by the sum log(val) = (log(10) * exp ) + log(x); The real logd64 will need to add checks for NAN, INF, zero, one, and negative values of x. */ static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE val) { _Decimal64 result, top, fraction, a, x, tp; _Decimal64 t1, t2, t3, t4, t5, t6, t7, t8; _Decimal64 t9, t10, t11, t12, t13, t14, t15, t16; int exp; long tmp; if (__isnand64(val)) return val+val; if (val == DFP_CONSTANT(0.0)) { DFP_EXCEPT (FE_DIVBYZERO); return -DFP_HUGE_VAL; } if (val < DFP_CONSTANT(0.0)) { DFP_EXCEPT (FE_INVALID); return DFP_NAN; } if (__isinfd64(val)) return val; result = __frexpd64 (val, &exp); tmp = result * 100.0DD; top = tmp; top = top * 0.01DD; fraction = result - top; if (fraction != 0.00DD) { a = top; x = result; t1 = (x - a) / a; tp = t1 * t1; /* tp == ((x-a)/a)^2 */ t2 = tp / 2.0DD; /* t2 == (((x-a)/a)^2)/2 */ tp = tp * t1; /* tp == ((x-a)/a)^3 */ t3 = tp / 3.0DD; /* t3 == (((x-a)/a)^3)/3 */ tp = tp * t1; /* tp == ((x-a)/a)^4 */ t4 = tp / 4.0DD; /* t4 == (((x-a)/a)^4)/4 */ tp = tp * t1; /* tp == ((x-a)/a)^5 */ t5 = tp / 5.0DD; /* t5 == (((x-a)/a)^5)/5 */ tp = tp * t1; /* tp == ((x-a)/a)^6 */ t6 = tp / 6.0DD; /* t6 == (((x-a)/a)^6)/6 */ tp = tp * t1; /* tp == ((x-a)/a)^7 */ t7 = tp / 7.0DD; /* t7 == (((x-a)/a)^7)/7 */ tp = tp * t1; /* tp == ((x-a)/a)^8 */ t8 = tp / 8.0DD; /* t8 == (((x-a)/a)^8)/8 */ if ( t8 > 1.0E-16DD) { tp = tp * t1; /* tp == ((x-a)/a)^9 */ t9 = tp / 9.0DD; /* t9 == (((x-a)/a)^9)/9 */ tp = tp * t1; /* tp == ((x-a)/a)^10 */ t10 = tp / 10.0DD; /* t10 == (((x-a)/a)^10)/10 */ tp = tp * t1; /* tp == ((x-a)/a)^11 */ t11 = tp / 11.0DD; /* t12 == (((x-a)/a)^11)/11 */ tp = tp * t1; /* tp == ((x-a)/a)^12 */ t12 = tp / 12.0DD; /* t12 == (((x-a)/a)^11)/12 */ if (t12 > 1.0E-16DD) { tp = tp * t1; /* tp == ((x-a)/a)^13 */ t13 = tp / 13.0DD; /* t13 == (((x-a)/a)^13)/13 */ tp = tp * t1; /* tp == ((x-a)/a)^14 */ t14 = tp / 14.0DD; /* t14 == (((x-a)/a)^14)/14 */ tp = tp * t1; /* tp == ((x-a)/a)^15 */ t15 = tp / 15.0DD; /* t15 == (((x-a)/a)^15)/15 */ tp = tp * t1; /* tp == ((x-a)/a)^16 */ t16 = tp / 16.0DD; /* t16 == (((x-a)/a)^16)/16 */ tp = t15 - t16; tp = tp + (t13 - t14); tp = tp + (t11 - t12); } else { tp = t11 - t12; } tp = tp + (t9 - t10); tp = tp + (t7 - t8); } else tp = t7 - t8; /* now sum the terms from smallest to largest to avoid loss of percision */ tp = tp + (t5 - t6); tp = tp + (t3 - t4); tp = tp + (t1 - t2); if (exp!=0) result = (__LN_10 * exp) + __LN2digits[tmp] + tp; else result = __LN2digits[tmp] + tp; } else { if (exp!=0) result = (__LN_10 * exp) + __LN2digits[tmp]; else result = __LN2digits[tmp]; } return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x) { DEC_TYPE z = IEEE_FUNCTION_NAME (x); if (x == DFP_CONSTANT(0.0)) DFP_ERRNO (ERANGE); if (x < DFP_CONSTANT(0.0)) DFP_ERRNO (EDOM); return z; } weak_alias (INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/sysdeps/powerpc/dfpu/nearbyintd128.c000066400000000000000000000022001261375163000216760ustar00rootroot00000000000000/* _Decimal32 nearbyintd128 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal128 __nearbyintd128 (_Decimal128 x) { _Decimal128 ret; asm ("drintnq 0,%0,%1,3\n" : "=f"(ret) : "f"(x)); return ret; } weak_alias (__nearbyintd128, nearbyintd128) libdfp-1.0.12/sysdeps/powerpc/dfpu/nearbyintd32.c000066400000000000000000000022071261375163000216170ustar00rootroot00000000000000/* _Decimal32 nearbyintd32 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal32 __nearbyintd32 (_Decimal32 x) { _Decimal64 ret; asm ("drintn 0,%0,%1,3\n" : "=f"(ret) : "f"((_Decimal64) x)); return ret; } weak_alias (__nearbyintd32, nearbyintd32) libdfp-1.0.12/sysdeps/powerpc/dfpu/nearbyintd64.c000066400000000000000000000021721261375163000216250ustar00rootroot00000000000000/* _Decimal32 nearbyintd64 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal64 __nearbyintd64 (_Decimal64 x) { _Decimal64 ret; asm ("drintn 0,%0,%1,3\n" : "=f"(ret) : "f"(x)); return ret; } weak_alias (__nearbyintd64, nearbyintd64) libdfp-1.0.12/sysdeps/powerpc/dfpu/numdigits.h000066400000000000000000000114501261375163000213230ustar00rootroot00000000000000/* Number of digits functions, optimized for Power6. Copyright (C) 2006-2008 IBM Corporation. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein Michael Meissner Peter Bergner Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ /* Alow this file to be included more than once, so don't use the usual include guards. */ #define NUMDIGITS_SUPPORT 1 #ifndef DEC_TYPE #error DEC_TYPE must be declared #endif #ifndef _DECIMAL_SIZE #error _DECIMAL_SIZE must be declared #endif #include #undef DECIMAL_BIAS #undef DECIMAL_BIAS_DOUBLE #undef Q #if _DECIMAL_SIZE == 32 // DECIMAL32 gets widened to DECIMAL64, so it ought to use DECIMAL64 bias # define DECIMAL_BIAS (101+297) # define DECIMAL_BIAS_DOUBLE 0x0.000000000018ep-1022 # define Q "" #elif _DECIMAL_SIZE == 64 # define DECIMAL_BIAS 398 # define DECIMAL_BIAS_DOUBLE 0x0.000000000018ep-1022 # define Q "" #elif _DECIMAL_SIZE == 128 # define DECIMAL_BIAS 6176 # define DECIMAL_BIAS_DOUBLE 0x0.000000000182p-1022 # define Q "q" #else #error _DECIMAL_SIZE must be '32', '64' or '128' #endif #ifndef PASTE # define PASTE(x,y) PASTE2(x,y) # define PASTE2(x,y) x##y #endif #ifndef FUNC_D # define FUNC_D(x) PASTE(x,PASTE(d,_DECIMAL_SIZE)) #endif static inline int FUNC_D (getexp) (DEC_TYPE x) { double f; long long i; #if _DECIMAL_SIZE == 32 asm ("dctdp %0,%1\n\t" "dxex %0,%0\n\t" : "=d"(f) : "f"(x)); #elif _DECIMAL_SIZE == 64 asm ("dxex %0,%1" : "=d"(f) : "d"(x)); #elif _DECIMAL_SIZE == 128 asm ("dxexq %0,%1" : "=d"(f) : "d"(x)); #endif asm ("stfd %1,%0" : "=m"(i) : "d"(f)); return i - DECIMAL_BIAS; } static inline DEC_TYPE FUNC_D (setexp) (DEC_TYPE x, int exp) { DEC_TYPE tmp = x; union { long long int l; double f; } e; e.l = exp + DECIMAL_BIAS; asm ( #if _DECIMAL_SIZE == 32 "dctdp %0,%0\n\t" "diex %0,%1,%0\n\t" "drsp %0,%0\n\t" #elif _DECIMAL_SIZE == 64 "diex %0,%1,%0\n\t" #elif _DECIMAL_SIZE == 128 "diexq %0,%1,%0\n\t" #endif : "=f"(tmp) : "f"(e.f), "0"(tmp)); return tmp; } static inline int FUNC_D (numdigits) (DEC_TYPE x) { #if _DECIMAL_SIZE == 32 register _Decimal64 tmp = x; _Decimal64 f3, f4; #else register DEC_TYPE tmp = x; DEC_TYPE f3, f4; #endif double f1, f2; union _ld_t { long long int l; double f; }; static union _ld_t u = { .f = 0x0.0000000000001p-1022 }; static union _ld_t v = { .f = DECIMAL_BIAS_DOUBLE }; union _ld_t t; asm ( "dxex" Q " %0,%3\n\t" "diex" Q " %2,%4,%3\n\t" : "=&d"(f1), "=&d"(f2), "=&d"(f3) : "d"(tmp), "d"(v.f)); /* Check for NaN and infinity, dxex returns < 0 for qnan, snan, and inf. */ t.f = f1; if (t.l < 0) return t.l; asm ( "drrnd" Q " %0,%2,%3,1\n\t" "dxex" Q " %1,%0\n\t" : "=&d"(f4), "=&d"(f2) : "d"(u.f), "d"(f3)); /* v.l holds the normalized reference exponent. f2 holds the computed exponent after reround. */ t.f = f2; return t.l - v.l + 1; } static inline DEC_TYPE FUNC_D (left_justify) (DEC_TYPE x) { #undef ADJUST #if _DECIMAL_SIZE == 32 # define ADJUST 6 _Decimal64 tmp = x; _Decimal64 rnd; #else # if _DECIMAL_SIZE == 64 # define ADJUST 15 # elif _DECIMAL_SIZE == 128 # define ADJUST 33 # endif DEC_TYPE tmp = x; DEC_TYPE rnd; #endif double tmp2; union int_dbl { long long int l; double f; }; static union int_dbl d = { .f = 0x0.0000000000001p-1022 }; union int_dbl d2; asm ("drrnd" Q " %0,%1,%2,1" : "=d"(rnd) : "d"(d.f), "d"(tmp)); asm ("dxex" Q " %0,%1\n\t" : "=d"(tmp2) : "d"(rnd)); d2.f = tmp2; d2.l -= ADJUST; tmp2 = d2.f; asm ("diex" Q " %0,%1,%0\n\t" : "=d"(rnd) : "d"(tmp2), "0"(rnd)); asm ("dqua" Q " %0,%0,%2,1\n\t" : "=d"(rnd) : "0"(rnd), "d"(tmp)); /* cast is necessary if input is _Decimal32 in order to convert it from * _Decima64 back to _Decimal32 since the calculation is done in _Decimal64. */ return (DEC_TYPE)rnd; } libdfp-1.0.12/sysdeps/powerpc/dfpu/powd32.c000066400000000000000000000024041261375163000204300ustar00rootroot00000000000000/* Decimal Floating Point 32-bit x^y. POWER6 PowerPC32 version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include extern _Decimal64 __powd64(_Decimal64, _Decimal64); _Decimal32 __powd32 (_Decimal32 x, _Decimal32 y) { return (_Decimal32) __powd64((_Decimal64) x, (_Decimal64) y); } weak_alias(__powd32, powd32) libdfp-1.0.12/sysdeps/powerpc/dfpu/powd64.c000066400000000000000000000123371261375163000204430ustar00rootroot00000000000000/* Decimal Floating Point 64-bit x^y. POWER6 PowerPC64 version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #ifndef _DECIMAL_SIZE # define _DECIMAL_SIZE 64 # include #endif #define FUNCTION_NAME pow #include static DEC_TYPE intpow (DEC_TYPE val, int N) { DEC_TYPE result = 1; DEC_TYPE p = val; int mask = 1; while (mask <= N) { if (mask & N) result *= p; p *= p; mask <<= 1; } return result; } static DEC_TYPE IEEE_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { DEC_TYPE result = DEC_NAN; DEC_TYPE y_int; DEC_TYPE y_frac; int x_class = FUNC_D(__fpclassify) (x); int y_class = FUNC_D(__fpclassify) (y); if ((x_class == FP_NAN) || (x_class == FP_INFINITE) || (y_class == FP_NAN) || (y_class == FP_INFINITE)) { if ((x_class == FP_NAN) || (y_class == FP_NAN)) return DEC_NAN; if (x == 1.DD) return 1.DD; if (y == 0.DD) return 1.DD; if (y_class == FP_INFINITE && (x_class != FP_NAN)) { DEC_TYPE x_abs = FUNC_D(__fabs) (x); if (x == -1.DD) return 1.DD; if (y < 0.DD) { /* y == -inf */ if (x_abs < 1.DD) return DEC_INFINITY; if (x_abs > 1.DD) return 0.DD; } else { /* y == +inf */ if (x_abs < 1.DD) return 0.DD; if (x_abs > 1.DD) return DEC_INFINITY; } } if (x_class == FP_INFINITE && (y_class != FP_NAN)) { DEC_TYPE y_int = FUNC_D(__trunc) (y); if (y_int == y) { /* y is an int including 0. */ long long int_y = y_int; int odd_y = (int)(int_y & 1LL); if (odd_y) { /* y is an odd integer */ if ((y < 0.DD) && (x < 0.DD)) return -0.DD; if ((y > 0.DD) && (x < 0.DD)) return -DEC_INFINITY; } else { /* y not an odd integer */ if ((y < 0.DD) && (x < 0.DD)) return 0.DD; if ((y > 0.DD) && (x < 0.DD)) return DEC_INFINITY; } } else { if (x > 0.DD) { /* x == +inf */ if (y < 0.DD) return 0.DD; else return DEC_INFINITY; } } return DEC_NAN; } } /* handle the eazy case */ if (y_class == FP_ZERO) return 1.DD; /* Split y into integer and fraction and use the identity: x ^ (m+n) == ( x^m ) * (x^n) */ y_int = FUNC_D(__rint) (y); y_frac = y - y_int; #ifdef __DEBUG_PRINT__ printf ("y_int=%Df,y_frac=%Df)\n", y_int, y_frac); #endif if (y_frac == 0.DD) { /* y is an integer */ /* FIXME does not handle case where y_int is out of range for int */ int int_y = y_int; /* convert to int */ if (y_int > 0.DD) { int odd_y = int_y & 1; if (x == 0.0DD) { if ( odd_y ) result = x; else result = 0.DD; } else { result = intpow(x, int_y); } } else { /* y is negative so use a^-x == 1/(a^x) */ int odd_y = int_y & 1; #ifdef __DEBUG_PRINT__ printf ("int_y=%d, odd_y=%d)\n", int_y, odd_y); #endif if (x == 0.DD) { /* pole error */ result = HUGE_VAL_D64; if ( odd_y ) result = FUNC_D(__copysign) (result, x); } else result = 1.DD / intpow(x, -int_y); } /* else y == 0.0, and handled as special case above. */ } else { /* y is not a integer */ if (x == 1.DD) result = 1.DD; else if (x == 0.DD) { if (y > 0.DD) result = 0.DD; else if (y < 0.DD) result = HUGE_VAL_D64; /* pole error */ /* else y == 0.0, and handled as special case above. */ } else { /* FIXME lots of additional special cases here! */ int int_y = y_int; /* convert to int */ DEC_TYPE log_x; log_x = FUNC_D(__log) (x); result = intpow(x, int_y) * FUNC_D(__exp) (y_frac * log_x); } } return result; } DEC_TYPE INTERNAL_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { DEC_TYPE z = IEEE_FUNCTION_NAME (x, y); /* Pole error: x = 0, y < 0 (non-inf). Set ERANGE in accordance with C99 */ if (x == DFP_CONSTANT(0.0) && FUNC_D(__isfinite)(y) && y < DFP_CONSTANT(0.0)) DFP_ERRNO (ERANGE); if (!FUNC_D(__isfinite) (z) && FUNC_D(__isfinite) (x) && FUNC_D(__isfinite) (y)) { if (FUNC_D(__isnan) (z)) /* Domain error was triggered, x < 0 and y was not an odd int */ DFP_ERRNO (EDOM); else /* Overflow */ DFP_ERRNO (ERANGE); } return z; } weak_alias(INTERNAL_FUNCTION_NAME, EXTERNAL_FUNCTION_NAME) libdfp-1.0.12/sysdeps/powerpc/dfpu/quantized128.c000066400000000000000000000023031261375163000215470ustar00rootroot00000000000000/* Set the exponent of x to the exp of y, trying to preserve the value of x Copyright (C) 2010-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal128 __quantized128(_Decimal128 x, _Decimal128 y) { _Decimal128 result; asm ("dquaq %0,%1,%2,3\n\t" : "=f" (result) : "f" (y), "f" (x)); return result; } weak_alias (__quantized128, quantized128) libdfp-1.0.12/sysdeps/powerpc/dfpu/quantized32.c000066400000000000000000000041421261375163000214640ustar00rootroot00000000000000/* Set the exponent of x to the exp of y, trying to preserve the value of x Copyright (C) 2006 IBM Corporation. Copyright (C) 2010-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal32 __quantized32 (_Decimal32 x, _Decimal32 y) { /* Always use _Decimal64 asm insns for _Decimal32 since there are no * _Decimal32 insns. */ _Decimal64 result; register _Decimal64 tmp; _Decimal64 f3, f4; double f2; union _ld_t { long long int l; double f; }; static union _ld_t u = { .f = 0x0.0000000000001p-1022 }; static union _ld_t v = { .f = 0x0.000000000018ep-1022 }; union _ld_t t; __asm__("dqua %0,%1,%2,3;" : "=f" (result): "f" ((_Decimal64) y), "f" ((_Decimal64) x)); /* Get the number of digits. Based on numdigits.h. */ tmp = result; asm ( "diex %0,%4,%3\n\t" "drrnd %2,%5,%0,1\n\t" "dxex %1,%2\n\t" : "=&d"(f3), "=&d"(f2), "=&d"(f4) : "d"(tmp), "d"(v.f), "d"(u.f)); /* v.l holds the normalized reference exponent. f2 holds the computed exponent after reround. */ t.f = f2; /* Verify if the result don't causes overflow when converted to 32 bits. If yes return NaN */ if (t.l - v.l + 1 > 7) return (_Decimal32) DEC_NAN; return (_Decimal32) result; } weak_alias (__quantized32, quantized32) libdfp-1.0.12/sysdeps/powerpc/dfpu/quantized64.c000066400000000000000000000022611261375163000214710ustar00rootroot00000000000000/* Set the exponent of x to the exp of y, trying to preserve the value of x Copyright (C) 2010-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal64 __quantized64 (_Decimal64 x, _Decimal64 y) { _Decimal64 result; asm ("dqua %0,%1,%2,3;" : "=f" (result) : "f" (y), "f" (x)); return result; } weak_alias (__quantized64, quantized64) libdfp-1.0.12/sysdeps/powerpc/dfpu/quantumd128.c000066400000000000000000000024461261375163000214110ustar00rootroot00000000000000/* _Decimal128 quantum implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include /* Return the quantum 1 * 10^exponent(x) */ _Decimal128 __quantumd128 (_Decimal128 x) { _Decimal128 ret; _Decimal128 ref = 1e-6176DL; asm ("dxexq %1,%1\n" /* Extract exponent */ "diexq %0,%1,%2\n" /* Sets it to reference value */ : "=d"(ret) : "d"(x), "d"(ref)); return ret; } weak_alias (__quantumd128, quantumd128) libdfp-1.0.12/sysdeps/powerpc/dfpu/quantumd32.c000066400000000000000000000023541261375163000213210ustar00rootroot00000000000000/* _Decimal32 quantumd32 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include /* Return the quantum 1 * 10^exponent(x) */ _Decimal32 __quantumd32 (_Decimal32 x) { _Decimal64 ret; _Decimal64 ref = 1e-398DD; asm ("dxex %0,%1\n" "diex %0,%0,%2\n" : "=f"(ret) : "f"((_Decimal64) x), "f"(ref)); return ret; } weak_alias (__quantumd32, quantumd32) libdfp-1.0.12/sysdeps/powerpc/dfpu/quantumd64.c000066400000000000000000000024411261375163000213230ustar00rootroot00000000000000/* _Decimal64 quantumd64 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include /* Return the quantum 1 * 10^exponent(x) */ _Decimal64 __quantumd64 (_Decimal64 x) { _Decimal64 ret; _Decimal64 ref = 1e-398DD; asm ("dxex %0,%1\n" /* Extracts exponent */ "diex %0,%0,%2\n" /* Sets it to reference value */ : "=f"(ret) : "f"(x), "f"(ref)); return ret; } weak_alias (__quantumd64, quantumd64) libdfp-1.0.12/sysdeps/powerpc/dfpu/rintd128.c000066400000000000000000000021471261375163000206710ustar00rootroot00000000000000/* Decimal Floating Point 128-bit round to integer. POWER6 PowerPC32 version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA */ #include _Decimal128 __rintd128 (_Decimal128 a) { _Decimal128 ret; asm ( "drintxq 0,%0,%0,3\n\t" : "=f"(ret) : "f"(a)); return ret; } weak_alias(__rintd128, rintd128) libdfp-1.0.12/sysdeps/powerpc/dfpu/rintd32.c000066400000000000000000000021621261375163000206000ustar00rootroot00000000000000/* Decimal Floating Point 32-bit round to integer. POWER6 PowerPC32 version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA */ #include _Decimal32 __rintd32 (_Decimal32 a) { asm ( "dctdp %0,%0\n\t" "drintx 0,%0,%0,3\n\t" "drsp %0,%0\n\t" : "=f"(a) : "0"(a)); return a; } weak_alias(__rintd32, rintd32) libdfp-1.0.12/sysdeps/powerpc/dfpu/rintd64.c000066400000000000000000000021121261375163000206000ustar00rootroot00000000000000/* Decimal Floating Point 32-bit round to integer. POWER6 PowerPC32 version. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA */ #include _Decimal64 __rintd64 (_Decimal64 a) { asm ( "drintx 0,%0,%0,3\n\t" : "=f"(a) : "0"(a)); return a; } weak_alias(__rintd64, rintd64) libdfp-1.0.12/sysdeps/powerpc/dfpu/roundd128.c000066400000000000000000000021611261375163000210400ustar00rootroot00000000000000/* _Decimal128 roundd128 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal128 __roundd128 (_Decimal128 x) { _Decimal128 ret; asm ("drintnq 0,%0,%1,2\n" : "=f"(ret) : "f"(x)); return ret; } weak_alias (__roundd128, roundd128) libdfp-1.0.12/sysdeps/powerpc/dfpu/roundd32.c000066400000000000000000000021671261375163000207600ustar00rootroot00000000000000/* _Decimal32 roundd32 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal32 __roundd32 (_Decimal32 x) { _Decimal64 ret; asm ("drintn 0,%0,%1,2\n" : "=f"(ret) : "f"((_Decimal64) x)); return ret; } weak_alias (__roundd32, roundd32) libdfp-1.0.12/sysdeps/powerpc/dfpu/roundd64.c000066400000000000000000000021521261375163000207570ustar00rootroot00000000000000/* _Decimal64 roundd64 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal64 __roundd64 (_Decimal64 x) { _Decimal64 ret; asm ("drintn 0,%0,%1,2\n" : "=f"(ret) : "f"(x)); return ret; } weak_alias (__roundd64, roundd64) libdfp-1.0.12/sysdeps/powerpc/dfpu/roundevend128.c000066400000000000000000000022001261375163000217100ustar00rootroot00000000000000/* _Decimal32 roundevend128 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal128 __roundevend128 (_Decimal128 x) { _Decimal128 ret; asm ("drintnq 0,%0,%1,0\n" : "=f"(ret) : "f"(x)); return ret; } weak_alias (__roundevend128, roundevend128) libdfp-1.0.12/sysdeps/powerpc/dfpu/roundevend32.c000066400000000000000000000022071261375163000216310ustar00rootroot00000000000000/* _Decimal32 roundevend32 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal32 __roundevend32 (_Decimal32 x) { _Decimal64 ret; asm ("drintn 0,%0,%1,0\n" : "=f"(ret) : "f"((_Decimal64) x)); return ret; } weak_alias (__roundevend32, roundevend32) libdfp-1.0.12/sysdeps/powerpc/dfpu/roundevend64.c000066400000000000000000000021721261375163000216370ustar00rootroot00000000000000/* _Decimal32 roundevend64 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal64 __roundevend64 (_Decimal64 x) { _Decimal64 ret; asm ("drintn 0,%0,%1,0\n" : "=f"(ret) : "f"(x)); return ret; } weak_alias (__roundevend64, roundevend64) libdfp-1.0.12/sysdeps/powerpc/dfpu/samequantumd128.c000066400000000000000000000024221261375163000222510ustar00rootroot00000000000000/* _Decimal128 quantum implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include /* Return the quantum 1 * 10^exponent(x) */ _Bool __samequantumd128 (_Decimal128 x, _Decimal128 y) { int xnan = __isnand128 (x); int ynan = __isnand128 (y); if (xnan | ynan) return xnan & ynan; return __quantumd128 (x) == __quantumd128 (y); } weak_alias (__samequantumd128, samequantumd128) libdfp-1.0.12/sysdeps/powerpc/dfpu/samequantumd32.c000066400000000000000000000024101261375163000221600ustar00rootroot00000000000000/* _Decimal32 quantum implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include /* Return the quantum 1 * 10^exponent(x) */ _Bool __samequantumd32 (_Decimal32 x, _Decimal32 y) { int xnan = __isnand32 (x); int ynan = __isnand32 (y); if (xnan | ynan) return xnan & ynan; return __quantumd32 (x) == __quantumd32 (y); } weak_alias (__samequantumd32, samequantumd32) libdfp-1.0.12/sysdeps/powerpc/dfpu/samequantumd64.c000066400000000000000000000024101261375163000221650ustar00rootroot00000000000000/* _Decimal64 quantum implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include /* Return the quantum 1 * 10^exponent(x) */ _Bool __samequantumd64 (_Decimal64 x, _Decimal64 y) { int xnan = __isnand64 (x); int ynan = __isnand64 (y); if (xnan | ynan) return xnan & ynan; return __quantumd64 (x) == __quantumd64 (y); } weak_alias (__samequantumd64, samequantumd64) libdfp-1.0.12/sysdeps/powerpc/dfpu/truncd128.c000066400000000000000000000021611261375163000210440ustar00rootroot00000000000000/* _Decimal128 truncd128 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal128 __truncd128 (_Decimal128 x) { _Decimal128 ret; asm ("drintnq 0,%0,%1,1\n" : "=f"(ret) : "f"(x)); return ret; } weak_alias (__truncd128, truncd128) libdfp-1.0.12/sysdeps/powerpc/dfpu/truncd32.c000066400000000000000000000021671261375163000207640ustar00rootroot00000000000000/* _Decimal32 truncd32 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal32 __truncd32 (_Decimal32 x) { _Decimal64 ret; asm ("drintn 0,%0,%1,1\n" : "=f"(ret) : "f"((_Decimal64) x)); return ret; } weak_alias (__truncd32, truncd32) libdfp-1.0.12/sysdeps/powerpc/dfpu/truncd64.c000066400000000000000000000021521261375163000207630ustar00rootroot00000000000000/* _Decimal64 truncd64 implementation. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include _Decimal64 __truncd64 (_Decimal64 x) { _Decimal64 ret; asm ("drintn 0,%0,%1,1\n" : "=f"(ret) : "f"(x)); return ret; } weak_alias (__truncd64, truncd64) libdfp-1.0.12/sysdeps/powerpc/fpu/000077500000000000000000000000001261375163000170025ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/fpu/bits/000077500000000000000000000000001261375163000177435ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/fpu/bits/README000066400000000000000000000003321261375163000206210ustar00rootroot00000000000000# We need a copy of fenvinline.h in here in case we're building sorta-cross, # i.e. if we're building on a system with nofpu for a target with fpu then # we need to make sure we have an fpu set of 'fe*except' macros. libdfp-1.0.12/sysdeps/powerpc/fpu/bits/fenvinline.h000066400000000000000000000052271261375163000222570ustar00rootroot00000000000000/* Inline floating-point environment handling functions for powerpc. Copyright (C) 1995-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #if defined __GNUC__ && !defined _SOFT_FLOAT && !defined __NO_MATH_INLINES /* Adapted from GLIBC's powerpc/fpu/bits/fenvinline.h */ /* NOT USED IN LIBDFP since this comes from elsewhere. */ /* Inline definition for fegetround. */ /*# define fegetround() \ (__extension__ ({ int __fegetround_result; \ __asm__ __volatile__ \ ("mcrfs 7,7 ; mfcr %0" \ : "=r"(__fegetround_result) : : "cr7"); \ __fegetround_result & 3; })) */ /* The weird 'i#*X' constraints on the following suppress a gcc warning when __excepts is not a constant. Otherwise, they mean the same as just plain 'i'. */ /* Inline definition for feraiseexcept. */ # define feraiseexcept(__excepts) \ ((__builtin_constant_p (__excepts) \ && ((__excepts) & ((__excepts)-1)) == 0 \ && (__excepts) != FE_INVALID) \ ? ((__excepts) != 0 \ ? (__extension__ ({ __asm__ __volatile__ \ ("mtfsb1 %s0" \ : : "i#*X"(__builtin_ffs (__excepts))); \ 0; })) \ : 0) \ : (feraiseexcept) (__excepts)) /* Inline definition for feclearexcept. */ # define feclearexcept(__excepts) \ ((__builtin_constant_p (__excepts) \ && ((__excepts) & ((__excepts)-1)) == 0 \ && (__excepts) != FE_INVALID) \ ? ((__excepts) != 0 \ ? (__extension__ ({ __asm__ __volatile__ \ ("mtfsb0 %s0" \ : : "i#*X"(__builtin_ffs (__excepts))); \ 0; })) \ : 0) \ : (feclearexcept) (__excepts)) #endif /* __GNUC__ && !_SOFT_FLOAT */ libdfp-1.0.12/sysdeps/powerpc/fpu/fenv_libdfp.h000066400000000000000000000033111261375163000214270ustar00rootroot00000000000000/* Some FPSCR functions. Copyright (C) 2009 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #ifndef _FENV_LIBDFP_H #define _FENV_LIBDFP_H 1 #include typedef union { fenv_t fenv; unsigned long long l; } fenv_union_t; # define fegetenv_register() \ ({ fenv_t env; asm volatile ("mffs %0" : "=f" (env)); env; }) #ifndef _ARCH_PWR6 /* This could have been done in another sysdeps directory but it is easiest * here. */ # define fesetenv_register(env) \ do { \ double d = (env); \ asm volatile ("mtfsf 0xff,%0" : : "f" (d)); \ } while(0) #else /* Power6 & Power7 have a 64-bit FPSCR. */ # define fesetenv_register(env) \ do { \ double d = (env); \ asm volatile ("mtfsf 0xff,%0,1,0; " : : "f" (d)); \ } while(0) #endif /* _ARCH_PWR6 */ #endif /* _FENV_LIBDFP_H */ libdfp-1.0.12/sysdeps/powerpc/fpu/libdfp-test-ulps000066400000000000000000000004011261375163000221160ustar00rootroot00000000000000# exp test exp 88.72269439697265625 decimal32 15 decimal64 13 # log test log1p 3.141592653589793238462643383279503 decimal32 1 # log10 test log10 3.141592653589793238462643383279503 decimal64 1 test log10 2.718281828459045235360287471352662 decimal128 1 libdfp-1.0.12/sysdeps/powerpc/fpu/libdfp.abilist000066400000000000000000000123371261375163000216210ustar00rootroot00000000000000LIBDFP_1.0.0 LIBDFP_1.0.0 A __dpd_adddd3 F __dpd_addsd3 F __dpd_addtd3 F __dpd_divdd3 F __dpd_divsd3 F __dpd_divtd3 F __dpd_eqdd2 F __dpd_eqsd2 F __dpd_eqtd2 F __dpd_extendddtd2 F __dpd_extendddtf F __dpd_extenddfdd F __dpd_extenddftd F __dpd_extendsddd2 F __dpd_extendsddf F __dpd_extendsdtd2 F __dpd_extendsdtf F __dpd_extendsfdd F __dpd_extendsfsd F __dpd_extendsftd F __dpd_extendtftd F __dpd_fixdddi F __dpd_fixddsi F __dpd_fixsddi F __dpd_fixsdsi F __dpd_fixtddi F __dpd_fixtdsi F __dpd_fixunsdddi F __dpd_fixunsddsi F __dpd_fixunssddi F __dpd_fixunssdsi F __dpd_fixunstddi F __dpd_fixunstdsi F __dpd_floatdidd F __dpd_floatdisd F __dpd_floatditd F __dpd_floatsidd F __dpd_floatsisd F __dpd_floatsitd F __dpd_floatunsdidd F __dpd_floatunsdisd F __dpd_floatunsditd F __dpd_floatunssidd F __dpd_floatunssisd F __dpd_floatunssitd F __dpd_gedd2 F __dpd_gesd2 F __dpd_getd2 F __dpd_gtdd2 F __dpd_gtsd2 F __dpd_gttd2 F __dpd_ledd2 F __dpd_lesd2 F __dpd_letd2 F __dpd_ltdd2 F __dpd_ltsd2 F __dpd_lttd2 F __dpd_muldd3 F __dpd_mulsd3 F __dpd_multd3 F __dpd_nedd2 F __dpd_nesd2 F __dpd_netd2 F __dpd_subdd3 F __dpd_subsd3 F __dpd_subtd3 F __dpd_truncdddf F __dpd_truncddsd2 F __dpd_truncddsf F __dpd_truncdfsd F __dpd_truncsdsf F __dpd_trunctddd2 F __dpd_trunctddf F __dpd_trunctdsd2 F __dpd_trunctdsf F __dpd_trunctdtf F __dpd_trunctfdd F __dpd_trunctfsd F __dpd_unorddd2 F __dpd_unordsd2 F __dpd_unordtd2 F acosd128 F acosd32 F acosd64 F acoshd128 F acoshd32 F acoshd64 F asind128 F asind32 F asind64 F asinhd128 F asinhd32 F asinhd64 F atan2d128 F atan2d32 F atan2d64 F atand128 F atand32 F atand64 F atanhd128 F atanhd32 F atanhd64 F cbrtd128 F cbrtd32 F cbrtd64 F ceild128 F ceild32 F ceild64 F copysignd128 F copysignd32 F copysignd64 F cosd128 F cosd32 F cosd64 F coshd128 F coshd32 F coshd64 F decoded128 F decoded32 F decoded64 F erfcd128 F erfcd32 F erfcd64 F erfd128 F erfd32 F erfd64 F exp2d128 F exp2d32 F exp2d64 F expd128 F expd32 F expd64 F expm1d128 F expm1d32 F expm1d64 F fabsd128 F fabsd32 F fabsd64 F fdimd128 F fdimd32 F fdimd64 F fe_dec_getround F fe_dec_setround F finited128 F finited32 F finited64 F floord128 F floord32 F floord64 F fmad128 F fmad32 F fmad64 F fmaxd128 F fmaxd32 F fmaxd64 F fmind128 F fmind32 F fmind64 F fmodd128 F fmodd32 F fmodd64 F fpclassifyd128 F fpclassifyd32 F fpclassifyd64 F frexpd128 F frexpd32 F frexpd64 F hypotd128 F hypotd32 F hypotd64 F ilogbd128 F ilogbd32 F ilogbd64 F isgreaterd128 F isgreaterd32 F isgreaterd64 F isgreaterequald128 F isgreaterequald32 F isgreaterequald64 F isinfd128 F isinfd32 F isinfd64 F islessd128 F islessd32 F islessd64 F islessequald128 F islessequald32 F islessequald64 F islessgreaterd128 F islessgreaterd32 F islessgreaterd64 F isnand128 F isnand32 F isnand64 F isnormald128 F isnormald32 F isnormald64 F isunorderedd128 F isunorderedd32 F isunorderedd64 F ldexpd128 F ldexpd32 F ldexpd64 F lgammad128 F lgammad32 F lgammad64 F llrintd128 F llrintd32 F llrintd64 F llroundd128 F llroundd32 F llroundd64 F log10d128 F log10d32 F log10d64 F log1pd128 F log1pd32 F log1pd64 F log2d128 F log2d32 F log2d64 F logbd128 F logbd32 F logbd64 F logd128 F logd32 F logd64 F lrintd128 F lrintd32 F lrintd64 F lroundd128 F lroundd32 F lroundd64 F modfd128 F modfd32 F modfd64 F nand128 F nand32 F nand64 F nearbyintd128 F nearbyintd32 F nearbyintd64 F nextafterd128 F nextafterd32 F nextafterd64 F nexttowardd128 F nexttowardd32 F nexttowardd64 F powd128 F powd32 F powd64 F printf_dfp F quantized128 F quantized32 F quantized64 F register_printf_dfp F remainderd128 F remainderd32 F remainderd64 F rintd128 F rintd32 F rintd64 F roundd128 F roundd32 F roundd64 F samequantumd128 F samequantumd32 F samequantumd64 F scalblnd128 F scalblnd32 F scalblnd64 F scalbnd128 F scalbnd32 F scalbnd64 F signbitd128 F signbitd32 F signbitd64 F sind128 F sind32 F sind64 F sinhd128 F sinhd32 F sinhd64 F sqrtd128 F sqrtd32 F sqrtd64 F strtod128 F strtod32 F strtod64 F tand128 F tand32 F tand64 F tanhd128 F tanhd32 F tanhd64 F tgammad128 F tgammad32 F tgammad64 F truncd128 F truncd32 F truncd64 F wcstod128 F wcstod32 F wcstod64 F LIBDFP_1.0.2 LIBDFP_1.0.2 A __isinfd128 F __isinfd32 F __isinfd64 F __isnand128 F __isnand32 F __isnand64 F LIBDFP_1.0.3 LIBDFP_1.0.3 A __fabsd128 F __fabsd32 F __fabsd64 F __finited128 F __finited32 F __finited64 F __fpclassifyd128 F __fpclassifyd32 F __fpclassifyd64 F __isfinited128 F __isfinited32 F __isfinited64 F __signbitd128 F __signbitd32 F __signbitd64 F isfinited128 F isfinited32 F isfinited64 F LIBDFP_1.0.9 LIBDFP_1.0.9 A __issignalingd128 F __issignalingd32 F __issignalingd64 F issignalingd128 F issignalingd32 F issignalingd64 F llogbd128 F llogbd32 F llogbd64 F llquantexpd128 F llquantexpd32 F llquantexpd64 F quantumd128 F quantumd32 F quantumd64 F roundevend128 F roundevend32 F roundevend64 F LIBDFP_PRIVATE LIBDFP_PRIVATE A __decoded128 F __decoded32 F __decoded64 F __decrm_location F __fe_dec_getround F __fe_dec_setround F __fmt_d128 F __fmt_d32 F __fmt_d64 F libdfp-1.0.12/sysdeps/powerpc/nofpu/000077500000000000000000000000001261375163000173375ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/nofpu/bits/000077500000000000000000000000001261375163000203005ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/nofpu/bits/README000066400000000000000000000003351261375163000211610ustar00rootroot00000000000000# We need a copy of fenvinline.h in here in case we're building sorta-cross, # i.e. if we're building on a system with an fpu for a target with nofpu then # we need to make sure we have a nofpu set of 'fe*except' macros. libdfp-1.0.12/sysdeps/powerpc/nofpu/bits/fenvinline.h000066400000000000000000000025661261375163000226170ustar00rootroot00000000000000/* Raise given exceptions (soft-float edition). Copyright (C) 2002-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #if !defined feraiseexcept /* Taken from GLIBC: Contributed by Aldy Hernandez , 2002. */ #include "soft-fp.h" #include "soft-supp.h" #include #include #define feraiseexcept (x) \ { \ __sim_exceptions |= x; \ if (x == 0 || __sim_disabled_exceptions & x) \ /* Ignore exception. */ \ ; \ else \ raise (SIGFPE); \ return 0; \ } #endif /* feraiseexcept */ libdfp-1.0.12/sysdeps/powerpc/powerpc32/000077500000000000000000000000001261375163000200345ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/000077500000000000000000000000001261375163000212565ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/000077500000000000000000000000001261375163000220505ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/Makefile000066400000000000000000000017361261375163000235170ustar00rootroot00000000000000# Copyright (C) 2015 Free Software Foundation, Inc. # # This file is part of the Decimal Floating Point C Library. # # The Decimal Floating Point C Library is free software; you can # redistribute it and/or modify it under the terms of the GNU Lesser # General Public License version 2.1. # # The Decimal Floating Point C Library is distributed in the hope that # it will be useful, but WITHOUT ANY WARRANTY; without even the implied # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See # the GNU Lesser General Public License version 2.1 for more details. # # You should have received a copy of the GNU Lesser General Public # License version 2.1 along with the Decimal Floating Point C Library; # if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA. # # Please see libdfp/COPYING.txt for more information. */ # The files in this directory are simply overrides of those already defined in # base-math/Makefile. libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/Versions000066400000000000000000000002101261375163000235740ustar00rootroot00000000000000# The __dpd_ prefixed symbols are already added in sysdeps/dpd/Versions. The # implementations in this directory are simply overrides. libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/adddd3.S000066400000000000000000000023541261375163000233230ustar00rootroot00000000000000/* Decimal Floating Point 64-bit add. POWER6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal64 __dpd_adddd3 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_adddd3) dadd fp1,fp1,fp2 blr END (__dpd_adddd3) hidden_def (__dpd_adddd3) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/addsd3.S000066400000000000000000000025701261375163000233420ustar00rootroot00000000000000/* Decimal Floating Point 32-bit add. POWER6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal32 __dpd_addsd3 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_addsd3) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ dadd fp1,fp1,fp2 drsp fp1,fp1 /* Round result to _Decimal32. */ blr END (__dpd_addsd3) hidden_def (__dpd_addsd3) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/addtd3.S000066400000000000000000000023611261375163000233410ustar00rootroot00000000000000/* Decimal Floating Point 128-bit add. POWER6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal128 __dpd_addtd3 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_addtd3) daddq fp2,fp2,fp4 blr END (__dpd_addtd3) hidden_def (__dpd_addtd3) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/divdd3.S000066400000000000000000000023601261375163000233520ustar00rootroot00000000000000/* Decimal Floating Point 64-bit divide. POWER6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal64 __dpd_divdd3 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_divdd3) ddiv fp1,fp1,fp2 blr END (__dpd_divdd3) hidden_def (__dpd_divdd3) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/divsd3.S000066400000000000000000000025731261375163000233770ustar00rootroot00000000000000/* Decimal Floating Point 32-bit divide. POWER6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal32 __dpd_divsd3 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_divsd3) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ ddiv fp1,fp1,fp2 drsp fp1,fp1 /* Round result to _Decimal32. */ blr END (__dpd_divsd3) hidden_def (__dpd_divsd3) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/divtd3.S000066400000000000000000000023641261375163000233760ustar00rootroot00000000000000/* Decimal Floating Point 128-bit divide. POWER6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal128 __dpd_divtd3 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_divtd3) ddivq fp2,fp2,fp4 blr END (__dpd_divtd3) hidden_def (__dpd_divtd3) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/eqdd2.S000066400000000000000000000025421261375163000231760ustar00rootroot00000000000000/* Decimal Floating Point 64-bit compare equal. P6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_eqdd2 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_eqdd2) dcmpu cr0,fp1,fp2 /* if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_eqdd2) hidden_def (__dpd_eqdd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/eqsd2.S000066400000000000000000000026761261375163000232250ustar00rootroot00000000000000/* Decimal Floating Point 32-bit compare equal. P6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_eqsd2 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_eqsd2) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ dcmpu cr0,fp1,fp2 /* if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_eqsd2) hidden_def (__dpd_eqsd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/eqtd2.S000066400000000000000000000025171261375163000232200ustar00rootroot00000000000000/* Decimal Floating Point 128-bit compare equal. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_eqtd2 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_eqtd2) dcmpuq cr0,fp2,fp4 /* if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_eqtd2) hidden_def (__dpd_eqtd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/extendddtd2.S000066400000000000000000000024041261375163000244050ustar00rootroot00000000000000/* Decimal Floating Point extend 64-bit to 128-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal128 __dpd_extendddtd2 (_Decimal64 x) */ ENTRY (__dpd_extendddtd2) dctqpq fp2,fp1 /* Convert x to _Decimal128. */ blr END (__dpd_extendddtd2) hidden_def (__dpd_extendddtd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/extendsddd2.S000066400000000000000000000024001261375163000244000ustar00rootroot00000000000000/* Decimal Floating Point extend 32-bit to 64-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal64 __dpd_extendsddd2 (_Decimal32 x) */ ENTRY (__dpd_extendsddd2) dctdp fp1,fp1 /* Convert x to _Decimal64. */ blr END (__dpd_extendsddd2) hidden_def (__dpd_extendsddd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/extendsdtd2.S000066400000000000000000000024621261375163000244300ustar00rootroot00000000000000/* Decimal Floating Point extend 32-bit to 128-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal128 __dpd_extendsdtd2 (_Decimal32 x) */ ENTRY (__dpd_extendsdtd2) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctqpq fp2,fp1 /* Convert x to _Decimal128. */ blr END (__dpd_extendsdtd2) hidden_def (__dpd_extendsdtd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/fixdddi.S000066400000000000000000000027131261375163000236120ustar00rootroot00000000000000/* Decimal Floating Point convert 64-bit to long. P6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* long __dpd_fixdddi (_Decimal64 x) */ ENTRY (__dpd_fixdddi) stwu r1,-16(r1) cfi_adjust_cfa_offset (16) drintn 0,fp1,fp1,1 /* Preround to toward zero. */ dctfix fp0,fp1 /* Convert x to integer. */ stfd fp0,8(r1) ori r1,r1,0 /* Special group ending nop. */ lwz r3,8(r1) lwz r4,12(r1) addi r1,r1,16 blr END (__dpd_fixdddi) hidden_def (__dpd_fixdddi) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/fixddsi.S000066400000000000000000000036661261375163000236410ustar00rootroot00000000000000/* Decimal Floating Point convert 64-bit to int. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_fixddsi (_Decimal64 x) */ ENTRY (__dpd_fixddsi) stwu r1,-16(r1) cfi_adjust_cfa_offset (16) drintn 0,fp1,fp1,1 /* Preround to toward zero. */ dctfix fp0,fp1 /* Convert x to integer. */ stfd fp0,8(r1) ori r1,r1,0 /* Special group ending nop. */ lwz r0,8(r1) lwz r3,12(r1) /* The return is an int, but we have long long, so we need to force overflow if there are any significant bits in the high word or overflow (incorrect sign) from the low word. */ cmpwi cr0,r0,0 cmpwi cr6,r3,0 cmpwi cr7,r0,-1 blt cr0,L(negative) bne cr0,L(posoverflow) bge cr6,L(done) L(posoverflow): lis r3,0x7fff /* return max positive int. */ ori r3,r3,0xffff b L(done) L(negative): bne cr7,L(negoverflow) blt cr6,L(done) L(negoverflow): lis r3,0x8000 /* return max negative int. */ L(done): addi r1,r1,16 blr END (__dpd_fixddsi) hidden_def (__dpd_fixddsi) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/fixsddi.S000066400000000000000000000027731261375163000236370ustar00rootroot00000000000000/* Decimal Floating Point convert 32-bit to long. P6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* long __dpd_fixsddi (_Decimal32 x) */ ENTRY (__dpd_fixsddi) stwu r1,-16(r1) cfi_adjust_cfa_offset (16) dctdp fp1,fp1 /* Convert x to _Decimal64. */ drintn 0,fp1,fp1,1 /* Preround to toward zero. */ dctfix fp0,fp1 /* Convert x to integer. */ stfd fp0,8(r1) ori r1,r1,0 /* Special group ending nop. */ lwz r3,8(r1) lwz r4,12(r1) addi r1,r1,16 blr END (__dpd_fixsddi) hidden_def (__dpd_fixsddi) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/fixsdsi.S000066400000000000000000000040171261375163000236470ustar00rootroot00000000000000/* Decimal Floating Point convert 32-bit to int. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_fixsdsi (_Decimal32 x) */ /* long __dpd_fixsdsi (_Decimal32 x) */ ENTRY (__dpd_fixsdsi) stwu r1,-16(r1) cfi_adjust_cfa_offset (16) dctdp fp1,fp1 /* Convert x to _Decimal64. */ drintn 0,fp1,fp1,1 /* Preround to toward zero. */ dctfix fp0,fp1 /* Convert x to integer. */ stfd fp0,8(r1) ori r1,r1,0 /* Special group ending nop. */ lwz r0,8(r1) lwz r3,12(r1) /* The return is an int, but we have long long, so we need to force overflow if there are any significant bits in the high word or overflow (incorrect sign) from the low word. */ cmpwi cr0,r0,0 cmpwi cr6,r3,0 cmpwi cr7,r0,-1 blt cr0,L(negative) bne cr0,L(posoverflow) bge cr6,L(done) L(posoverflow): lis r3,0x7fff /* return max positive int. */ ori r3,r3,0xffff b L(done) L(negative): bne cr7,L(negoverflow) blt cr6,L(done) L(negoverflow): lis r3,0x8000 /* return max negative int. */ L(done): addi r1,r1,16 blr END (__dpd_fixsdsi) hidden_def (__dpd_fixsdsi) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/fixtddi.S000066400000000000000000000027201261375163000236300ustar00rootroot00000000000000/* Decimal Floating Point convert 128-bit to long. P6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* long __dpd_fixtddi (_Decimal128 x) */ ENTRY (__dpd_fixtddi) stwu r1,-16(r1) cfi_adjust_cfa_offset (16) drintnq 0,fp2,fp2,1 /* Preround to toward zero. */ dctfixq fp0,fp2 /* Convert x to integer. */ stfd fp0,8(r1) ori r1,r1,0 /* Special group ending nop. */ lwz r3,8(r1) lwz r4,12(r1) addi r1,r1,16 blr END (__dpd_fixtddi) hidden_def (__dpd_fixtddi) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/fixtdsi.S000066400000000000000000000036711261375163000236550ustar00rootroot00000000000000/* Decimal Floating Point convert 128-bit to int. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_fixtdsi (_Decimal28 x) */ ENTRY (__dpd_fixtdsi) stwu r1,-16(r1) cfi_adjust_cfa_offset (16) drintnq 0,fp2,fp2,1 /* Preround to toward zero. */ dctfixq fp0,fp2 /* Convert x to integer. */ stfd fp0,8(r1) ori r1,r1,0 /* Special group ending nop. */ lwz r0,8(r1) lwz r3,12(r1) /* The return is an int, but we have long long, so we need to force overflow if there are any significant bits in the high word or overflow (incorrect sign) from the low word. */ cmpwi cr0,r0,0 cmpwi cr6,r3,0 cmpwi cr7,r0,-1 blt cr0,L(negative) bne cr0,L(posoverflow) bge cr6,L(done) L(posoverflow): lis r3,0x7fff /* return max positive int. */ ori r3,r3,0xffff b L(done) L(negative): bne cr7,L(negoverflow) blt cr6,L(done) L(negoverflow): lis r3,0x8000 /* return max negative int. */ L(done): addi r1,r1,16 blr END (__dpd_fixtdsi) hidden_def (__dpd_fixtdsi) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/fixunsdddi.S000066400000000000000000000055331261375163000243430ustar00rootroot00000000000000/* Decimal Floating Point convert 64-bit to unsigned long. P6 PPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .section .rodata.cst16,"aM",@progbits,32 .align 3 .LC1: /* 9223372036854775808.0DL */ .long 0x2207c000 .long 0x00000003 .long 0xa4cfa07a .long 0x2c7f600a .LC2: /* 18446744073709551616.0DL */ .long 0x2207c000 .long 0x0000000c .long 0xa99e40ed .long 0xc5ba58e0 .section ".text" .machine "power6" /* unsigned long long __dpd_fixunsdddi (_Decimal64 x) */ ENTRY (__dpd_fixunsdddi) stwu r1,-16(r1) cfi_adjust_cfa_offset (16) #ifdef SHARED mflr r11 cfi_register(lr,r11) bcl 20,31,1f 1: mflr r9 addis r9,r9,.LC1-1b@ha addi r9,r9,.LC1-1b@l mtlr r11 cfi_same_value (lr) lfd fp10,0(r9) lfd fp11,8(r9) lfd fp8,.LC2-.LC1(r9) lfd fp9,.LC2-.LC1+8(r9) #else lis r9,.LC1@ha lis r10,.LC2@ha addi r9,r9,.LC1@l addi r10,r10,.LC2@l lfd fp10,0(r9) lfd fp11,8(r9) lfd fp8,0(r10) lfd fp9,8(r10) #endif dsubq fp6,fp10,fp10 /* Generate 0.0 constant for later. */ dctqpq fp2,fp1 /* Convert param to _Decimal128. */ drintnq 0,fp2,fp2,1 /* Preround to toward zero. */ dcmpuq cr1,fp2,fp6 /* Check for less than zero. */ dcmpuq cr0,fp2,fp10 /* check if > 2**63-1 */ blt cr1,L(negative) ble cr0,L(poslong) /* The return is an unsigned long, but "DFP convert to fixed" takes signed long, so we need to pre-adjust (-18446744073709551616.0DD) to get the final (signed) conversion result to be the correct unsigned result. */ dsubq fp2,fp2,fp8 dcmpuq cr0,fp2,fp10 /* if x still > 2**63-1 */ li r3,-1 /* return max_unsigned_long */ bgt cr0,L(done) L(poslong): dctfixq fp0,fp2 /* Convert x to integer. */ stfd fp0,8(r1) ori r1,r1,0 /* Special group ending nop. */ lwz r3,8(r1) lwz r4,12(r1) addi r1,r1,16 blr L(negative): li r3,0 /* return 0 for negative floats. */ L(done): mr r4,r3 addi r1,r1,16 blr END (__dpd_fixunsdddi) hidden_def (__dpd_fixunsdddi) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/fixunsddsi.S000066400000000000000000000037161261375163000243630ustar00rootroot00000000000000/* Decimal Floating Point convert 64-bit to unsigned int. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* unsigned int __dpd_fixunsddsi (_Decimal64 x) */ /* unsigned long __dpd_fixunsddsi (_Decimal64 x) */ ENTRY (__dpd_fixunsddsi) stwu r1,-16(r1) cfi_adjust_cfa_offset (16) drintn 0,fp1,fp1,1 /* Preround to toward zero. */ dctfix fp0,fp1 /* Convert x to integer. */ stfd fp0,8(r1) ori r1,r1,0 /* Special group ending nop. */ lwz r0,8(r1) lwz r3,12(r1) /* The return is an int, but we have long long, so we need to force overflow if there are any significant bits in the high word or overflow (incorrect sign) from the low word. */ cmpwi cr0,r0,0 cmpli cr6,r3,0 /* Logical form to cmp unsigned. */ blt cr0,L(negative) bne cr0,L(posoverflow) bge cr6,L(done) L(posoverflow): li r3,-1 /* return max unsigned int. */ b L(done) L(negative): lis r3,0 /* return 0 for negative floats. */ L(done): addi r1,r1,16 blr END (__dpd_fixunsddsi) hidden_def (__dpd_fixunsddsi) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/fixunssddi.S000066400000000000000000000056171261375163000243650ustar00rootroot00000000000000/* Decimal Floating Point convert 64-bit to unsigned long. P6 PPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .section .rodata.cst16,"aM",@progbits,32 .align 3 .LC1: /* 9223372036854775808.0DL */ .long 0x2207c000 .long 0x00000003 .long 0xa4cfa07a .long 0x2c7f600a .LC2: /* 18446744073709551616.0DL */ .long 0x2207c000 .long 0x0000000c .long 0xa99e40ed .long 0xc5ba58e0 .section ".text" .machine "power6" /* unsigned long long __dpd_fixunssddi (_Decimal32 x) */ ENTRY (__dpd_fixunssddi) stwu r1,-16(r1) cfi_adjust_cfa_offset (16) #ifdef SHARED mflr r11 cfi_register(lr,r11) bcl 20,31,1f 1: mflr r9 addis r9,r9,.LC1-1b@ha addi r9,r9,.LC1-1b@l mtlr r11 cfi_same_value (lr) lfd fp10,0(r9) lfd fp11,8(r9) lfd fp8,.LC2-.LC1(r9) lfd fp9,.LC2-.LC1+8(r9) #else lis r9,.LC1@ha lis r10,.LC2@ha addi r9,r9,.LC1@l addi r10,r10,.LC2@l lfd fp10,0(r9) lfd fp11,8(r9) lfd fp8,0(r10) lfd fp9,8(r10) #endif dsubq fp6,fp10,fp10 /* Generate 0.0 constant for later. */ dctdp fp0,fp1 /* Convert param to _Decimal64. */ dctqpq fp2,fp0 /* Convert param to _Decimal128. */ drintnq 0,fp2,fp2,1 /* Preround to toward zero. */ dcmpuq cr1,fp2,fp6 /* Check for less than zero. */ dcmpuq cr0,fp2,fp10 /* check if > 2**63-1 */ blt cr1,L(negative) ble cr0,L(poslong) /* The return is an unsigned long, but "DFP convert to fixed" takes signed long, so we need to pre-adjust (-18446744073709551616.0DD) to get the final (signed) conversion result to be the correct unsigned result. */ dsubq fp2,fp2,fp8 dcmpuq cr0,fp2,fp10 /* if x still > 2**63-1 */ li r3,-1 /* return max_unsigned_long */ bgt cr0,L(done) L(poslong): dctfixq fp0,fp2 /* Convert x to integer. */ stfd fp0,8(r1) ori r1,r1,0 /* Special group ending nop. */ lwz r3,8(r1) lwz r4,12(r1) addi r1,r1,16 blr L(negative): li r3,0 /* return 0 for negative floats. */ L(done): mr r4,r3 addi r1,r1,16 blr END (__dpd_fixunssddi) hidden_def (__dpd_fixunssddi) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/fixunssdsi.S000066400000000000000000000037751261375163000244070ustar00rootroot00000000000000/* Decimal Floating Point convert 32-bit to unsigned int. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* unsigned int __dpd_fixunssdsi (_Decimal32 x) */ /* unsigned long __dpd_fixunssdsi (_Decimal32 x) */ ENTRY (__dpd_fixunssdsi) stwu r1,-16(r1) cfi_adjust_cfa_offset (16) dctdp fp1,fp1 /* Convert x to _Decimal64. */ drintn 0,fp1,fp1,1 /* Preround to toward zero. */ dctfix fp0,fp1 /* Convert x to integer. */ stfd fp0,8(r1) ori r1,r1,0 /* Special group ending nop. */ lwz r0,8(r1) lwz r3,12(r1) /* The return is an int, but we have long long, so we need to force overflow if there are any significant bits in the high word or overflow (incorrect sign) from the low word. */ cmpwi cr0,r0,0 cmpli cr6,r3,0 /* Logical form to cmp unsigned. */ blt cr0,L(negative) bne cr0,L(posoverflow) bge cr6,L(done) L(posoverflow): li r3,-1 /* return max unsigned int. */ b L(done) L(negative): lis r3,0 /* return 0 for negative floats. */ L(done): addi r1,r1,16 blr END (__dpd_fixunssdsi) hidden_def (__dpd_fixunssdsi) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/fixunstddi.S000066400000000000000000000054261261375163000243640ustar00rootroot00000000000000/* Decimal Floating Point convert 128-bit to unsigned long. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .section .rodata.cst16,"aM",@progbits,32 .align 3 .LC1: /* 9223372036854775808.0DL */ .long 0x2207c000 .long 0x00000003 .long 0xa4cfa07a .long 0x2c7f600a .LC2: /* 18446744073709551616.0DL */ .long 0x2207c000 .long 0x0000000c .long 0xa99e40ed .long 0xc5ba58e0 .section ".text" .machine "power6" /* unsigned long long __dpd_fixunstddi (_Decimal128 x) */ ENTRY (__dpd_fixunstddi) stwu r1,-16(r1) cfi_adjust_cfa_offset (16) #ifdef SHARED mflr r11 cfi_register(lr,r11) bcl 20,31,1f 1: mflr r9 addis r9,r9,.LC1-1b@ha addi r9,r9,.LC1-1b@l mtlr r11 cfi_same_value (lr) lfd fp10,0(r9) lfd fp11,8(r9) lfd fp8,.LC2-.LC1(r9) lfd fp9,.LC2-.LC1+8(r9) #else lis r9,.LC1@ha lis r10,.LC2@ha addi r9,r9,.LC1@l addi r10,r10,.LC2@l lfd fp10,0(r9) lfd fp11,8(r9) lfd fp8,0(r10) lfd fp9,8(r10) #endif dsubq fp6,fp10,fp10 /* Generate 0.0 constant for later. */ drintnq 0,fp2,fp2,1 /* Preround to toward zero. */ dcmpuq cr1,fp2,fp6 /* Check for less than zero. */ dcmpuq cr0,fp2,fp10 /* check if > 2**63-1 */ blt cr1,L(negative) ble cr0,L(poslong) /* The return is an unsigned long, but "DFP convert to fixed" takes signed long, so we need to pre-adjust (-18446744073709551616.0DD) to get the final (signed) conversion result to be the correct unsigned result. */ dsubq fp2,fp2,fp8 dcmpuq cr0,fp2,fp10 /* if x still > 2**63-1 */ li r3,-1 /* return max_unsigned_long */ bgt cr0,L(done) L(poslong): dctfixq fp0,fp2 /* Convert x to integer. */ stfd fp0,8(r1) ori r1,r1,0 /* Special group ending nop. */ lwz r3,8(r1) lwz r4,12(r1) addi r1,r1,16 blr L(negative): li r3,0 /* return 0 for negative floats. */ L(done): mr r4,r3 addi r1,r1,16 blr END (__dpd_fixunstddi) hidden_def (__dpd_fixunstddi) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/fixunstdsi.S000066400000000000000000000037221261375163000244000ustar00rootroot00000000000000/* Decimal Floating Point convert 128-bit to unsigned int. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* unsigned int __dpd_fixunstdsi (_Decimal128 x) */ /* unsigned long __dpd_fixunstdsi (_Decimal128 x) */ ENTRY (__dpd_fixunstdsi) stwu r1,-16(r1) cfi_adjust_cfa_offset (16) drintnq 0,fp2,fp2,1 /* Preround to toward zero. */ dctfixq fp0,fp2 /* Convert x to integer. */ stfd fp0,8(r1) ori r1,r1,0 /* Special group ending nop. */ lwz r0,8(r1) lwz r3,12(r1) /* The return is an int, but we have long long, so we need to force overflow if there are any significant bits in the high word or overflow (incorrect sign) from the low word. */ cmpwi cr0,r0,0 cmpli cr6,r3,0 /* Logical form to cmp unsigned. */ blt cr0,L(negative) bne cr0,L(posoverflow) bge cr6,L(done) L(posoverflow): li r3,-1 /* return max unsigned int. */ b L(done) L(negative): lis r3,0 /* return 0 for negative floats. */ L(done): addi r1,r1,16 blr END (__dpd_fixunstdsi) hidden_def (__dpd_fixunstdsi) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/floatdidd.S000066400000000000000000000027261261375163000241350ustar00rootroot00000000000000/* Convert int to Decimal Floating Point 64-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal64 __dpd_floatdidd (long long x) */ ENTRY (__dpd_floatdidd) stwu r1,-16(r1) cfi_adjust_cfa_offset (16) stw r3,8(r1) stw r4,12(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,8(r1) dcffixq fp2,fp0 /* Convert x to _Decimal128 float. */ drdpq fp0,fp2 /* Round result to _Decimal64. */ fmr fp1,fp0 addi r1,r1,16 blr END (__dpd_floatdidd) hidden_def (__dpd_floatdidd) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/floatdisd.S000066400000000000000000000027711261375163000241540ustar00rootroot00000000000000/* Convert int to Decimal Floating Point 32-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal32 __dpd_floatdisd (long long x) */ ENTRY (__dpd_floatdisd) stwu r1,-16(r1) cfi_adjust_cfa_offset (16) stw r3,8(r1) stw r4,12(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,8(r1) dcffixq fp2,fp0 /* Convert x to _Decimal128 float. */ drdpq fp0,fp2 /* Round result to _Decimal64. */ drsp fp1,fp0 /* Round result to _Decimal32. */ addi r1,r1,16 blr END (__dpd_floatdisd) hidden_def (__dpd_floatdisd) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/floatditd.S000066400000000000000000000026621261375163000241540ustar00rootroot00000000000000/* Convert int to Decimal Floating Point 128-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal128 __dpd_floatditd (long long x) */ ENTRY (__dpd_floatditd) cmpwi cr6,r3,0 stwu r1,-16(r1) cfi_adjust_cfa_offset (16) stw r3,8(r1) stw r4,12(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,8(r1) dcffixq fp2,fp0 /* Convert x to _Decimal128 float. */ L(done): addi r1,r1,16 blr END (__dpd_floatditd) hidden_def (__dpd_floatditd) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/floatsidd.S000066400000000000000000000031601261375163000241450ustar00rootroot00000000000000/* Convert int to Decimal Floating Point 64-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal64 __dpd_floatsidd (int x) */ /* _Decimal64 __dpd_floatsidd (long x) */ ENTRY (__dpd_floatsidd) cmpwi cr6,r3,0 stwu r1,-16(r1) cfi_adjust_cfa_offset (16) li r0,-1 /* extend negative. */ blt cr6,L(negative) li r0,0 /* extend positive. */ L(negative): stw r0,8(r1) stw r3,12(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,8(r1) dcffixq fp2,fp0 /* Convert x to _Decimal128 float. */ drdpq fp0,fp2 /* Round result to _Decimal64. */ fmr fp1,fp0 addi r1,r1,16 blr END (__dpd_floatsidd) hidden_def (__dpd_floatsidd) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/floatsisd.S000066400000000000000000000032241261375163000241650ustar00rootroot00000000000000/* Convert int to Decimal Floating Point 32-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal32 __dpd_floatsisd (int x) */ /* _Decimal32 __dpd_floatsisd (long x) */ ENTRY (__dpd_floatsisd) cmpwi cr6,r3,0 stwu r1,-16(r1) cfi_adjust_cfa_offset (16) li r0,-1 /* extend negative. */ blt cr6,L(negative) li r0,0 /* extend positive. */ L(negative): stw r0,8(r1) stw r3,12(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,8(r1) dcffixq fp2,fp0 /* Convert x to _Decimal128 float. */ drdpq fp0,fp2 /* Round result to _Decimal64. */ drsp fp1,fp0 /* Round result to _Decimal32. */ addi r1,r1,16 blr END (__dpd_floatsisd) hidden_def (__dpd_floatsisd) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/floatsitd.S000066400000000000000000000030761261375163000241730ustar00rootroot00000000000000/* Convert int to Decimal Floating Point 128-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal128 __dpd_floatsitd (int x) */ /* _Decimal128 __dpd_floatsitd (long x) */ ENTRY (__dpd_floatsitd) cmpwi cr6,r3,0 stwu r1,-16(r1) cfi_adjust_cfa_offset (16) li r0,-1 /* extend negative. */ blt cr6,L(negative) li r0,0 /* extend positive. */ L(negative): stw r0,8(r1) stw r3,12(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,8(r1) dcffixq fp2,fp0 /* Convert x to _Decimal128 float. */ L(done): addi r1,r1,16 blr END (__dpd_floatsitd) hidden_def (__dpd_floatsitd) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/floatunsdidd.S000066400000000000000000000047441261375163000246650ustar00rootroot00000000000000/* Convert unsigned int to Decimal Floating Point 64-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .section .rodata.cst16,"aM",@progbits,16 .align 3 .LC1: /* 18446744073709551616.0DL (ULLONG_MAX) */ .long 0x2207c000 .long 0x0000000c .long 0xa99e40ed .long 0xc5ba58e0 .section ".text" .machine "power6" /* _Decimal64 __dpd_floatunsdidd (unsigned long long x) */ ENTRY (__dpd_floatunsdidd) stwu r1,-16(r1) cfi_adjust_cfa_offset (16) #ifdef SHARED mflr r11 cfi_register(lr,r11) bcl 20,31,1f 1: mflr r9 addis r9,r9,.LC1-1b@ha addi r9,r9,.LC1-1b@l mtlr r11 cfi_same_value (lr) lfd fp8,0(r9) lfd fp9,8(r9) #else lis r9,.LC1@ha addi r9,r9,.LC1@l lfd fp8,0(r9) lfd fp9,8(r9) #endif stw r3,8(r1) stw r4,12(r1) /* ULL passed in consecutive gprs. */ ori r1,r1,0 /* Special group ending nop. */ lfd fp0,8(r1) /* Since dcffixq requires 'signed' input parameters if the value of the r3-r4 pair is an unsigned long long between ULLONG_MAX and LLONG_MAX then the value is converted to a negative signed _Decimal128 and needs to be adjusted to get the unsigned equivalent. */ dcffixq fp2,fp0 /* Convert signed x to _Decimal128. */ /* Set cr0 if r3 is negative (where unsigned > LLONG_MAX). */ mr. r3,r3 bge cr0,L(noadjust) /* No adjust if orig wasn't neg (unsigned). */ daddq fp2,fp2,fp8 /* Unbias to get unsigned result. */ L(noadjust): drdpq fp0,fp2 /* Round result to __dpd_Decimal64. */ fmr fp1,fp0 addi r1,r1,16 blr END (__dpd_floatunsdidd) hidden_def (__dpd_floatunsdidd) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/floatunsdisd.S000066400000000000000000000050161261375163000246750ustar00rootroot00000000000000/* Convert unsigned int to Decimal Floating Point 32-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .section .rodata.cst16,"aM",@progbits,16 .align 3 .LC1: /* 18446744073709551616.0DL (ULLONG_MAX) */ .long 0x2207c000 .long 0x0000000c .long 0xa99e40ed .long 0xc5ba58e0 .section ".text" .machine "power6" /* _Decimal32 __dpd_floatunsdisd (unsigned long long x) */ ENTRY (__dpd_floatunsdisd) stwu r1,-16(r1) cfi_adjust_cfa_offset (16) #ifdef SHARED mflr r11 cfi_register(lr,r11) bcl 20,31,1f 1: mflr r9 addis r9,r9,.LC1-1b@ha addi r9,r9,.LC1-1b@l mtlr r11 cfi_same_value (lr) lfd fp8,0(r9) lfd fp9,8(r9) #else lis r9,.LC1@ha addi r9,r9,.LC1@l lfd fp8,0(r9) lfd fp9,8(r9) #endif stw r3,8(r1) stw r4,12(r1) /* ULL passed in consecutive gprs. */ ori r1,r1,0 /* Special group ending nop. */ lfd fp0,8(r1) /* Since dcffixq requires 'signed' input parameters if the value of the r3-r4 pair is an unsigned long long between ULLONG_MAX and LLONG_MAX then the value is converted to a negative signed _Decimal128 and needs to be adjusted to get the unsigned equivalent. */ dcffixq fp2,fp0 /* Convert signed x to _Decimal128. */ /* Set cr0 if r3 is negative (where unsigned > LLONG_MAX). */ mr. r3,r3 bge cr0,L(noadjust) /* No adjust if orig wasn't neg (unsigned). */ daddq fp2,fp2,fp8 /* Unbias to get unsigned result. */ L(noadjust): drdpq fp0,fp2 /* Round result to __dpd_Decimal64. */ drsp fp1,fp0 /* Round result to __dpd_Decimal32. */ addi r1,r1,16 blr END (__dpd_floatunsdisd) hidden_def (__dpd_floatunsdisd) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/floatunsditd.S000066400000000000000000000046411261375163000247010ustar00rootroot00000000000000/* Convert unsigned int to Decimal Floating Point 128-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .section .rodata.cst16,"aM",@progbits,16 .align 3 .LC1: /* 18446744073709551616.0DL (ULLONG_MAX) */ .long 0x2207c000 .long 0x0000000c .long 0xa99e40ed .long 0xc5ba58e0 .section ".text" .machine "power6" /* _Decimal128 __dpd_floatunsditd (unsigned long long x) */ ENTRY (__dpd_floatunsditd) stwu r1,-16(r1) cfi_adjust_cfa_offset (16) #ifdef SHARED mflr r11 cfi_register(lr,r11) bcl 20,31,1f 1: mflr r9 addis r9,r9,.LC1-1b@ha addi r9,r9,.LC1-1b@l mtlr r11 cfi_same_value (lr) lfd fp8,0(r9) lfd fp9,8(r9) #else lis r9,.LC1@ha addi r9,r9,.LC1@l lfd fp8,0(r9) lfd fp9,8(r9) #endif stw r3,8(r1) stw r4,12(r1) /* ULL passed in consecutive gprs. */ ori r1,r1,0 /* Special group ending nop. */ lfd fp0,8(r1) /* Since dcffixq requires 'signed' input parameters if the value of the r3-r4 pair is an unsigned long long between ULLONG_MAX and LLONG_MAX then the value is converted to a negative signed _Decimal128 and needs to be adjusted to get the unsigned equivalent. */ dcffixq fp2,fp0 /* Convert signed x to _Decimal128. */ /* Set cr0 if r3 is negative (where unsigned > LLONG_MAX). */ mr. r3,r3 bge cr0,L(noadjust) /* No adjust if orig wasn't neg (unsigned). */ daddq fp2,fp2,fp8 /* Unbias to get unsigned result. */ L(noadjust): addi r1,r1,16 blr END (__dpd_floatunsditd) hidden_def (__dpd_floatunsditd) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/floatunssidd.S000066400000000000000000000031121261375163000246700ustar00rootroot00000000000000/* Convert unsigned int to Decimal Floating Point 64-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal64 __dpd_floatunssidd (unsigned int x) */ /* _Decimal64 __dpd_floatunssidd (unsigned long x) */ ENTRY (__dpd_floatunssidd) stwu r1,-16(r1) cfi_adjust_cfa_offset (16) li r0,0 /* extend unsigned. */ stw r0,8(r1) stw r3,12(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,8(r1) dcffixq fp2,fp0 /* Convert x to _Decimal128 floatuns. */ drdpq fp0,fp2 /* Round result to _Decimal64. */ fmr fp1,fp0 addi r1,r1,16 blr END (__dpd_floatunssidd) hidden_def (__dpd_floatunssidd) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/floatunssisd.S000066400000000000000000000031561261375163000247170ustar00rootroot00000000000000/* Convert unsigned int to Decimal Floating Point 32-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal32 __dpd_floatunssisd (unsigned int x) */ /* _Decimal32 __dpd_floatunssisd (unsigned long x) */ ENTRY (__dpd_floatunssisd) stwu r1,-16(r1) cfi_adjust_cfa_offset (16) li r0,0 /* extend unsigned. */ stw r0,8(r1) stw r3,12(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,8(r1) dcffixq fp2,fp0 /* Convert x to _Decimal128 floatuns. */ drdpq fp0,fp2 /* Round result to _Decimal64. */ drsp fp1,fp0 /* Round result to _Decimal32. */ addi r1,r1,16 blr END (__dpd_floatunssisd) hidden_def (__dpd_floatunssisd) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/floatunssitd.S000066400000000000000000000030271261375163000247150ustar00rootroot00000000000000/* Convert unsigned int to Decimal Floating Point 128-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal128 __dpd_floatunssisd (unsigned int x) */ /* _Decimal128 __dpd_floatunssisd (unsigned long x) */ ENTRY (__dpd_floatunssitd) stwu r1,-16(r1) cfi_adjust_cfa_offset (16) li r0,0 /* extend unsigned. */ stw r0,8(r1) stw r3,12(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,8(r1) dcffixq fp2,fp0 /* Convert x to _Decimal128 floatuns. */ L(done): addi r1,r1,16 blr END (__dpd_floatunssitd) hidden_def (__dpd_floatunssitd) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/gedd2.S000066400000000000000000000026661261375163000231730ustar00rootroot00000000000000/* Decimal Floating Point 64-bit compare >=. P6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_gedd2 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_gedd2) dcmpu cr0,fp1,fp2 /* if ((x > y) && !unordered(x,y)) */ li r3, 1 /* return 1 */ bgtlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, -1 /* return -1 */ blr END (__dpd_gedd2) hidden_def (__dpd_gedd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/gesd2.S000066400000000000000000000030221261375163000231750ustar00rootroot00000000000000/* Decimal Floating Point 32-bit compare >=. P6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_gesd2 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_gesd2) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ dcmpu cr0,fp1,fp2 /* if ((x > y) && !unordered(x,y)) */ li r3, 1 /* return 1 */ bgtlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, -1 /* return -1 */ blr END (__dpd_gesd2) hidden_def (__dpd_gesd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/getd2.S000066400000000000000000000026721261375163000232100ustar00rootroot00000000000000/* Decimal Floating Point 128-bit compare >=. P6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_getd2 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_getd2) dcmpuq cr0,fp2,fp4 /* if ((x > y) && !unordered(x,y)) */ li r3, 1 /* return 1 */ bgtlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, -1 /* return -1 */ blr END (__dpd_getd2) hidden_def (__dpd_getd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/gtdd2.S000066400000000000000000000026661261375163000232120ustar00rootroot00000000000000/* Decimal Floating Point 64-bit compare >=. P6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_gtdd2 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_gtdd2) dcmpu cr0,fp1,fp2 /* if ((x > y) && !unordered(x,y)) */ li r3, 1 /* return 1 */ bgtlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, -1 /* return -1 */ blr END (__dpd_gtdd2) hidden_def (__dpd_gtdd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/gtsd2.S000066400000000000000000000030221261375163000232140ustar00rootroot00000000000000/* Decimal Floating Point 32-bit compare >=. P6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_gtsd2 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_gtsd2) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ dcmpu cr0,fp1,fp2 /* if ((x > y) && !unordered(x,y)) */ li r3, 1 /* return 1 */ bgtlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, -1 /* return -1 */ blr END (__dpd_gtsd2) hidden_def (__dpd_gtsd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/gttd2.S000066400000000000000000000026721261375163000232270ustar00rootroot00000000000000/* Decimal Floating Point 128-bit compare >=. P6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_gttd2 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_gttd2) dcmpuq cr0,fp2,fp4 /* if ((x > y) && !unordered(x,y)) */ li r3, 1 /* return 1 */ bgtlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, -1 /* return -1 */ blr END (__dpd_gttd2) hidden_def (__dpd_gttd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/ledd2.S000066400000000000000000000026651261375163000231770ustar00rootroot00000000000000/* Decimal Floating Point 64-bit compare <. P6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_ledd2 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_ledd2) dcmpu cr0,fp1,fp2 /* if ((x < y) && !unordered(x,y)) */ li r3, -1 /* return -1 */ bltlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_ledd2) hidden_def (__dpd_ledd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/lesd2.S000066400000000000000000000030211261375163000232010ustar00rootroot00000000000000/* Decimal Floating Point 32-bit compare <. P6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_lesd2 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_lesd2) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ dcmpu cr0,fp1,fp2 /* if ((x < y) && !unordered(x,y)) */ li r3, -1 /* return -1 */ bltlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_lesd2) hidden_def (__dpd_lesd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/letd2.S000066400000000000000000000026721261375163000232150ustar00rootroot00000000000000/* Decimal Floating Point 128-bit compare >=. P6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_letd2 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_letd2) dcmpuq cr0,fp2,fp4 /* if ((x < y) && !unordered(x,y)) */ li r3, -1 /* return -1 */ bltlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_letd2) hidden_def (__dpd_letd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/ltdd2.S000066400000000000000000000026651261375163000232160ustar00rootroot00000000000000/* Decimal Floating Point 64-bit compare <. P6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_ltdd2 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_ltdd2) dcmpu cr0,fp1,fp2 /* if ((x < y) && !unordered(x,y)) */ li r3, -1 /* return -1 */ bltlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_ltdd2) hidden_def (__dpd_ltdd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/ltsd2.S000066400000000000000000000030211261375163000232200ustar00rootroot00000000000000/* Decimal Floating Point 32-bit compare <. P6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_ltsd2 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_ltsd2) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ dcmpu cr0,fp1,fp2 /* if ((x < y) && !unordered(x,y)) */ li r3, -1 /* return -1 */ bltlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_ltsd2) hidden_def (__dpd_ltsd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/lttd2.S000066400000000000000000000026721261375163000232340ustar00rootroot00000000000000/* Decimal Floating Point 128-bit compare >=. P6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_lttd2 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_lttd2) dcmpuq cr0,fp2,fp4 /* if ((x < y) && !unordered(x,y)) */ li r3, -1 /* return -1 */ bltlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_lttd2) hidden_def (__dpd_lttd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/muldd3.S000066400000000000000000000023611261375163000233660ustar00rootroot00000000000000/* Decimal Floating Point 64-bit multiply. POWER6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal64 __dpd_muldd3 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_muldd3) dmul fp1,fp1,fp2 blr END (__dpd_muldd3) hidden_def (__dpd_muldd3) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/mulsd3.S000066400000000000000000000025751261375163000234140ustar00rootroot00000000000000/* Decimal Floating Point 32-bit multiply. POWER6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal32 __dpd_mulsd3 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_mulsd3) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ dmul fp1,fp1,fp2 drsp fp1,fp1 /* Round result to _Decimal32. */ blr END (__dpd_mulsd3) hidden_def (__dpd_mulsd3) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/multd3.S000066400000000000000000000023661261375163000234130ustar00rootroot00000000000000/* Decimal Floating Point 128-bit multiply. POWER6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal128 __dpd_multd3 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_multd3) dmulq fp2,fp2,fp4 blr END (__dpd_multd3) hidden_def (__dpd_multd3) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/nedd2.S000066400000000000000000000025521261375163000231740ustar00rootroot00000000000000/* Decimal Floating Point 64-bit compare !=. P6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_nedd2 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_nedd2) dcmpu cr0,fp1,fp2 /* if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ bunlr cr0 li r3, 1 /* return 1 */ blr END (__dpd_nedd2) hidden_def (__dpd_nedd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/nesd2.S000066400000000000000000000027061261375163000232140ustar00rootroot00000000000000/* Decimal Floating Point 32-bit compare !=. P6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_nesd2 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_nesd2) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ dcmpu cr0,fp1,fp2 /* if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ bunlr cr0 li r3, 1 /* return 1 */ blr END (__dpd_nesd2) hidden_def (__dpd_nesd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/netd2.S000066400000000000000000000025561261375163000232200ustar00rootroot00000000000000/* Decimal Floating Point 128-bit compare !=. P6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_netd2 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_netd2) dcmpuq cr0,fp2,fp4 /* if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ bunlr cr0 li r3, 1 /* return 1 */ blr END (__dpd_netd2) hidden_def (__dpd_netd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/subdd3.S000066400000000000000000000023621261375163000233630ustar00rootroot00000000000000/* Decimal Floating Point 64-bit substract. POWER6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal64 __dpd_subdd3 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_subdd3) dsub fp1,fp1,fp2 blr END (__dpd_subdd3) hidden_def (__dpd_subdd3) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/subsd3.S000066400000000000000000000025751261375163000234100ustar00rootroot00000000000000/* Decimal Floating Point 32-bit subtract. POWER6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal32 __dpd_subsd3 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_subsd3) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ dsub fp1,fp1,fp2 drsp fp1,fp1 /* Round result to _Decimal32. */ blr END (__dpd_subsd3) hidden_def (__dpd_subsd3) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/subtd3.S000066400000000000000000000023661261375163000234070ustar00rootroot00000000000000/* Decimal Floating Point 128-bit subtract. POWER6 PowerPC32 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal128 __dpd_subtd3 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_subtd3) dsubq fp2,fp2,fp4 blr END (__dpd_subtd3) hidden_def (__dpd_subtd3) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/truncddsd2.S000066400000000000000000000024001261375163000242440ustar00rootroot00000000000000/* Decimal Floating Point truncate 64-bit to 32-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal32 __dpd_truncddsd2 (_Decimal64 x) */ ENTRY (__dpd_truncddsd2) drsp fp1,fp1 /* Round result to _Decimal32. */ blr END (__dpd_truncddsd2) hidden_def (__dpd_truncddsd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/trunctddd2.S000066400000000000000000000024201261375163000242470ustar00rootroot00000000000000/* Decimal Floating Point truncate 128-bit to 64-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal64 __dpd_trunctddd2 (_Decimal128 x) */ ENTRY (__dpd_trunctddd2) drdpq fp0,fp2 /* Round result to _Decimal64. */ fmr fp1,fp0 blr END (__dpd_trunctddd2) hidden_def (__dpd_trunctddd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/trunctdsd2.S000066400000000000000000000024631261375163000242750ustar00rootroot00000000000000/* Decimal Floating Point truncate 128-bit to 32-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal32 __dpd_trunctdsd2 (_Decimal128 x) */ ENTRY (__dpd_trunctdsd2) drdpq fp0,fp2 /* Round result to _Decimal64. */ drsp fp1,fp0 /* Round result to _Decimal32. */ blr END (__dpd_trunctdsd2) hidden_def (__dpd_trunctdsd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/unorddd2.S000066400000000000000000000025201261375163000237140ustar00rootroot00000000000000/* Decimal Floating Point 64-bit unordered compare. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_unorddd2 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_unorddd2) dcmpu cr0,fp1,fp2 /* if (!unordered(x,y)) */ li r3, 0 /* return 0 */ bnulr+ cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_unorddd2) hidden_def (__dpd_unorddd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/unordsd2.S000066400000000000000000000026541261375163000237430ustar00rootroot00000000000000/* Decimal Floating Point 32-bit unordered compare. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_unordsd2 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_unordsd2) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ dcmpu cr0,fp1,fp2 /* if (!unordered(x,y)) */ li r3, 0 /* return 0 */ bnulr+ cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_unordsd2) hidden_def (__dpd_unordsd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6/fpu/unordtd2.S000066400000000000000000000025241261375163000237400ustar00rootroot00000000000000/* Decimal Floating Point 128-bit unordered compare. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_unordtd2 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_unordtd2) dcmpuq cr0,fp2,fp4 /* if (!unordered(x,y)) */ li r3, 0 /* return 0 */ bnulr+ cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_unordtd2) hidden_def (__dpd_unordtd2) libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6x/000077500000000000000000000000001261375163000214465ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6x/Implies000066400000000000000000000001651261375163000227750ustar00rootroot00000000000000# Pick up the power6 versions of files since power6x is basically the same # thing. sysdeps/powerpc/powerpc32/power6 libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6x/fpu/000077500000000000000000000000001261375163000222405ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/powerpc32/power6x/fpu/Implies000066400000000000000000000001711261375163000235640ustar00rootroot00000000000000# Pick up the power6 versions of files since power6x is basically the same # thing. sysdeps/powerpc/powerpc32/power6/fpu libdfp-1.0.12/sysdeps/powerpc/powerpc32/power7/000077500000000000000000000000001261375163000212575ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/powerpc32/power7/Implies000066400000000000000000000001661261375163000226070ustar00rootroot00000000000000# Pick up the power6 versions of files since power7 supports hardware-dfp as # well. sysdeps/powerpc/powerpc32/power6 libdfp-1.0.12/sysdeps/powerpc/powerpc32/power7/fpu/000077500000000000000000000000001261375163000220515ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/powerpc32/power7/fpu/Implies000066400000000000000000000001721261375163000233760ustar00rootroot00000000000000# Pick up the power6 versions of files since power7 supports hardware-dfp as # well. sysdeps/powerpc/powerpc32/power6/fpu libdfp-1.0.12/sysdeps/powerpc/powerpc32/power8/000077500000000000000000000000001261375163000212605ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/powerpc32/power8/Implies000066400000000000000000000000411261375163000226000ustar00rootroot00000000000000sysdeps/powerpc/powerpc32/power7 libdfp-1.0.12/sysdeps/powerpc/powerpc32/power8/fpu/000077500000000000000000000000001261375163000220525ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/powerpc32/power8/fpu/Implies000066400000000000000000000000451261375163000233760ustar00rootroot00000000000000sysdeps/powerpc/powerpc32/power7/fpu libdfp-1.0.12/sysdeps/powerpc/powerpc32/sysdep.h000066400000000000000000000066471261375163000215310ustar00rootroot00000000000000/* Assembly macros for 32-bit PowerPC. Copyright (C) 1999-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include /* Derived from GLIBC */ #ifdef __ASSEMBLER__ #ifdef __ELF__ #undef ENTRY #define ENTRY(name) \ ASM_GLOBAL_DIRECTIVE name; \ ASM_TYPE_DIRECTIVE (name,@function) \ .align ALIGNARG(2); \ LABEL(name) \ cfi_startproc; #define EALIGN_W_0 /* No words to insert. */ #define EALIGN_W_1 nop #define EALIGN_W_2 nop;nop #define EALIGN_W_3 nop;nop;nop #define EALIGN_W_4 EALIGN_W_3;nop #define EALIGN_W_5 EALIGN_W_4;nop #define EALIGN_W_6 EALIGN_W_5;nop #define EALIGN_W_7 EALIGN_W_6;nop #undef EALIGN /* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes past a 2^align boundary. */ #define EALIGN(name, alignt, words) \ ASM_GLOBAL_DIRECTIVE name; \ ASM_TYPE_DIRECTIVE (name,@function) \ .align ALIGNARG(alignt); \ EALIGN_W_##words; \ LABEL(name) \ cfi_startproc; #undef END #define END(name) \ cfi_endproc; \ ASM_SIZE_DIRECTIVE(name) #define DO_CALL(syscall) \ li 0,syscall; \ sc #undef JUMPTARGET #ifdef PIC # define JUMPTARGET(name) name##@plt #else # define JUMPTARGET(name) name #endif #if defined SHARED && defined DO_VERSIONING && defined PIC \ && !defined NO_HIDDEN # undef HIDDEN_JUMPTARGET # define HIDDEN_JUMPTARGET(name) __GI_##name##@local #endif #define PSEUDO(name, syscall_name, args) \ .section ".text"; \ ENTRY (name) \ DO_CALL (SYS_ify (syscall_name)); #define PSEUDO_RET \ bnslr+; \ b __syscall_error@local #define ret PSEUDO_RET #undef PSEUDO_END #define PSEUDO_END(name) \ END (name) #define PSEUDO_NOERRNO(name, syscall_name, args) \ .section ".text"; \ ENTRY (name) \ DO_CALL (SYS_ify (syscall_name)); #define PSEUDO_RET_NOERRNO \ blr #define ret_NOERRNO PSEUDO_RET_NOERRNO #undef PSEUDO_END_NOERRNO #define PSEUDO_END_NOERRNO(name) \ END (name) #define PSEUDO_ERRVAL(name, syscall_name, args) \ .section ".text"; \ ENTRY (name) \ DO_CALL (SYS_ify (syscall_name)); #define PSEUDO_RET_ERRVAL \ blr #define ret_ERRVAL PSEUDO_RET_ERRVAL #undef PSEUDO_END_ERRVAL #define PSEUDO_END_ERRVAL(name) \ END (name) /* Local labels stripped out by the linker. */ #undef L #define L(x) .L##x #endif /* __ELF__ */ #endif /* __ASSEMBLER__ */ libdfp-1.0.12/sysdeps/powerpc/powerpc64/000077500000000000000000000000001261375163000200415ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/000077500000000000000000000000001261375163000212635ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/000077500000000000000000000000001261375163000220555ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/Makefile000066400000000000000000000017361261375163000235240ustar00rootroot00000000000000# Copyright (C) 2015 Free Software Foundation, Inc. # # This file is part of the Decimal Floating Point C Library. # # The Decimal Floating Point C Library is free software; you can # redistribute it and/or modify it under the terms of the GNU Lesser # General Public License version 2.1. # # The Decimal Floating Point C Library is distributed in the hope that # it will be useful, but WITHOUT ANY WARRANTY; without even the implied # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See # the GNU Lesser General Public License version 2.1 for more details. # # You should have received a copy of the GNU Lesser General Public # License version 2.1 along with the Decimal Floating Point C Library; # if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA. # # Please see libdfp/COPYING.txt for more information. */ # The files in this directory are simply overrides of those already defined in # base-math/Makefile. libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/Versions000066400000000000000000000002101261375163000236010ustar00rootroot00000000000000# The __dpd_ prefixed symbols are already added in sysdeps/dpd/Versions. The # implementations in this directory are simply overrides. libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/adddd3.S000066400000000000000000000023541261375163000233300ustar00rootroot00000000000000/* Decimal Floating Point 64-bit add. POWER6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal64 __dpd_adddd3 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_adddd3) dadd fp1,fp1,fp2 blr END (__dpd_adddd3) hidden_def (__dpd_adddd3) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/addsd3.S000066400000000000000000000025701261375163000233470ustar00rootroot00000000000000/* Decimal Floating Point 32-bit add. POWER6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal32 __dpd_addsd3 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_addsd3) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ dadd fp1,fp1,fp2 drsp fp1,fp1 /* Round result to _Decimal32. */ blr END (__dpd_addsd3) hidden_def (__dpd_addsd3) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/addtd3.S000066400000000000000000000023611261375163000233460ustar00rootroot00000000000000/* Decimal Floating Point 128-bit add. POWER6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal128 __dpd_addtd3 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_addtd3) daddq fp2,fp2,fp4 blr END (__dpd_addtd3) hidden_def (__dpd_addtd3) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/divdd3.S000066400000000000000000000023571261375163000233650ustar00rootroot00000000000000/* Decimal Floating Point 64-bit divide. POWER6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal64 __dpd_divdd3 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_divdd3) ddiv fp1,fp1,fp2 blr END (__dpd_divdd3) hidden_def (__dpd_divdd3) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/divsd3.S000066400000000000000000000025731261375163000234040ustar00rootroot00000000000000/* Decimal Floating Point 32-bit divide. POWER6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal32 __dpd_divsd3 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_divsd3) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ ddiv fp1,fp1,fp2 drsp fp1,fp1 /* Round result to _Decimal32. */ blr END (__dpd_divsd3) hidden_def (__dpd_divsd3) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/divtd3.S000066400000000000000000000023641261375163000234030ustar00rootroot00000000000000/* Decimal Floating Point 128-bit divide. POWER6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal128 __dpd_divtd3 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_divtd3) ddivq fp2,fp2,fp4 blr END (__dpd_divtd3) hidden_def (__dpd_divtd3) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/eqdd2.S000066400000000000000000000025421261375163000232030ustar00rootroot00000000000000/* Decimal Floating Point 64-bit compare equal. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_eqdd2 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_eqdd2) dcmpu cr0,fp1,fp2 /* if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_eqdd2) hidden_def (__dpd_eqdd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/eqsd2.S000066400000000000000000000026761261375163000232320ustar00rootroot00000000000000/* Decimal Floating Point 32-bit compare equal. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_eqsd2 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_eqsd2) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ dcmpu cr0,fp1,fp2 /* if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_eqsd2) hidden_def (__dpd_eqsd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/eqtd2.S000066400000000000000000000025461261375163000232270ustar00rootroot00000000000000/* Decimal Floating Point 128-bit compare equal. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_eqtd2 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_eqtd2) dcmpuq cr0,fp2,fp4 /* if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_eqtd2) hidden_def (__dpd_eqtd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/extendddtd2.S000066400000000000000000000024331261375163000244140ustar00rootroot00000000000000/* Decimal Floating Point extend 64-bit to 128-bit. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal128 __dpd_extendddtd2 (_Decimal64 x) */ ENTRY (__dpd_extendddtd2) dctqpq fp2,fp1 /* Convert x to _Decimal128. */ blr END (__dpd_extendddtd2) hidden_def (__dpd_extendddtd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/extendsddd2.S000066400000000000000000000024271261375163000244160ustar00rootroot00000000000000/* Decimal Floating Point extend 32-bit to 64-bit. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal64 __dpd_extendsddd2 (_Decimal32 x) */ ENTRY (__dpd_extendsddd2) dctdp fp1,fp1 /* Convert x to _Decimal64. */ blr END (__dpd_extendsddd2) hidden_def (__dpd_extendsddd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/extendsdtd2.S000066400000000000000000000025111261375163000244300ustar00rootroot00000000000000/* Decimal Floating Point extend 32-bit to 128-bit. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal128 __dpd_extendsdtd2 (_Decimal32 x) */ ENTRY (__dpd_extendsdtd2) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctqpq fp2,fp1 /* Convert x to _Decimal128. */ blr END (__dpd_extendsdtd2) hidden_def (__dpd_extendsdtd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/fixdddi.S000066400000000000000000000026651261375163000236250ustar00rootroot00000000000000/* Decimal Floating Point convert 64-bit to long. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* long __dpd_fixdddi (_Decimal64 x) */ /* long long __dpd_fixdddi (_Decimal64 x) */ ENTRY (__dpd_fixdddi) drintn 0,fp1,fp1,1 /* Preround to toward zero. */ dctfix fp0,fp1 /* Convert x to integer. */ stfd fp0,-8(r1) ori r1,r1,0 /* Special group ending nop. */ ld r3,-8(r1) blr END (__dpd_fixdddi) hidden_def (__dpd_fixdddi) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/fixddsi.S000066400000000000000000000037401261375163000236370ustar00rootroot00000000000000/* Decimal Floating Point convert 64-bit to int. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_fixddsi (_Decimal64 x) */ ENTRY (__dpd_fixddsi) drintn 0,fp1,fp1,1 /* Preround to toward zero. */ dctfix fp0,fp1 /* Convert x to integer. */ stfd fp0,-8(r1) ori r1,r1,0 /* Special group ending nop. */ oris r4,0,0x8000 /* 0x0000000080000000 */ lis r5,0x8000 /* 0xffffffff80000000 */ ld r3,-8(r1) /* The return is an int, but we have long long, so we need to force overflow if there are any significant bits in the high word or overflow (incorrect sign) from the low word. */ cmpd cr0,r3,r4 cmpd cr7,r3,r5 cmpdi cr6,r3,0 /* Is the answer less than zero? */ blt cr6,L(negative) bltlr cr0 L(posoverflow): addi r3,r4,-1 /* return max positive int. */ blr L(negative): /* If (result >= min negative int */ bgelr cr7 /* return result */ L(negoverflow): /* else */ mr r3,r5 /* return min negative int. */ blr END (__dpd_fixddsi) hidden_def (__dpd_fixddsi) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/fixsddi.S000066400000000000000000000027431261375163000236410ustar00rootroot00000000000000/* Decimal Floating Point convert 32-bit to long. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* long __dpd_fixsddi (_Decimal32 x) */ /* long long __dpd_fixsddi (_Decimal32 x) */ ENTRY (__dpd_fixsddi) dctdp fp1,fp1 /* Convert x to _Decimal64. */ drintn 0,fp1,fp1,1 /* Preround to toward zero. */ dctfix fp0,fp1 /* Convert x to integer. */ stfd fp0,-8(r1) ori r1,r1,0 /* Special group ending nop. */ ld r3,-8(r1) blr END (__dpd_fixsddi) hidden_def (__dpd_fixsddi) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/fixsdsi.S000066400000000000000000000037521261375163000236610ustar00rootroot00000000000000/* Decimal Floating Point convert 32-bit to int. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_fixsdsi (_Decimal32 x) */ ENTRY (__dpd_fixsdsi) dctdp fp1,fp1 /* Convert x to _Decimal64. */ drintn 0,fp1,fp1,1 /* Preround to toward zero. */ dctfix fp0,fp1 /* Convert x to integer. */ stfd fp0,-8(r1) ori r1,r1,0 /* Special group ending nop. */ oris r4,0,0x8000 /* 0x0000000080000000 */ lis r5,0x8000 /* 0xffffffff80000000 */ ld r3,-8(r1) /* The return is an int, but we have long long, so we need to force overflow if there are any significant bits in the high word or overflow (incorrect sign) from the low word. */ cmpd cr0,r3,r4 cmpd cr7,r3,r5 cmpdi cr6,r3,0 blt cr1,L(negative) bltlr cr0 L(posoverflow): addi r3,r4,-1 /* return max positive int. */ blr L(negative): /* If (result >= min negative int */ bgelr cr7 /* return result */ L(negoverflow): /* else */ mr r3,r5 /* return min negative int. */ blr END (__dpd_fixsdsi) hidden_def (__dpd_fixsdsi) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/fixtddi.S000066400000000000000000000026671261375163000236470ustar00rootroot00000000000000/* Decimal Floating Point convert 128-bit to long. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* long __dpd_fixtddi (_Decimal28 x) */ /* long long __dpd_fixtddi (_Decimal28 x) */ ENTRY (__dpd_fixtddi) drintnq 0,fp2,fp2,1 /* Preround to toward zero. */ dctfixq fp0,fp2 /* Convert x to integer. */ stfd fp0,-8(r1) ori r1,r1,0 /* Special group ending nop. */ ld r3,-8(r1) blr END (__dpd_fixtddi) hidden_def (__dpd_fixtddi) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/fixtdsi.S000066400000000000000000000036761261375163000236670ustar00rootroot00000000000000/* Decimal Floating Point convert 128-bit to int. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_fixtdsi (_Decimal28 x) */ ENTRY (__dpd_fixtdsi) drintnq 0,fp2,fp2,1 /* Preround to toward zero. */ dctfixq fp0,fp2 /* Convert x to integer. */ stfd fp0,-8(r1) ori r1,r1,0 /* Special group ending nop. */ oris r4,0,0x8000 /* 0x0000000080000000 */ lis r5,0x8000 /* 0xffffffff80000000 */ ld r3,-8(r1) /* The return is an int, but we have long long, so we need to force overflow if there are any significant bits in the high word or overflow (incorrect sign) from the low word. */ cmpdi cr6,r3,0 cmpd cr0,r3,r4 cmpd cr7,r3,r5 blt cr6,L(negative) bltlr cr0 L(posoverflow): addi r3,r4,-1 /* return max positive int. */ blr L(negative): /* If (result >= min negative int */ bgelr cr7 /* return result */ L(negoverflow): /* else */ mr r3,r5 /* return min negative int. */ blr END (__dpd_fixtdsi) hidden_def (__dpd_fixtdsi) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/fixunsdddi.S000066400000000000000000000047711261375163000243530ustar00rootroot00000000000000/* Decimal Floating Point convert 64-bit to unsigned long. P6 PPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .section ".toc","aw" .LC1: /* 9223372036854775808.0DD */ .tc FT_2207c000_3_a4cfa07a_2c7f600a[TC],0x2207c00000000003,0xa4cfa07a2c7f600a .LC2: /* 18446744073709551616.0DD */ .tc FT_2207c000_c_a99e40ed_c5ba58e0[TC],0x2207c0000000000c,0xa99e40edc5ba58e0 .section ".text" .machine "power6" /* unsigned long __dpd_fixunsdddi (_Decimal64 x) */ /* unsigned long long __dpd_fixunsdddi (_Decimal64 x) */ ENTRY (__dpd_fixunsdddi) dctqpq fp2,fp1 /* Convert x to _Decimal128. */ lfd fp10,.LC1@toc(2) lfd fp11,.LC1@toc+8(2) dsubq fp6,fp10,fp10 /* Generate 0.0 constant for later. */ drintnq 0,fp2,fp2,1 /* Preround to toward zero. */ dcmpuq cr1,fp2,fp6 /* Check for less than zero. */ dcmpuq cr0,fp2,fp10 /* check if > 2**63-1 */ blt cr1,L(negative) lfd fp8,.LC2@toc(2) lfd fp9,.LC2@toc+8(2) ble cr0,L(poslong) /* The return is an unsigned long, but "DFP convert to fixed" takes signed long, so we need to pre-adjust (-18446744073709551616.0DD) to get the final (signed) conversion result to be the correct unsigned result. */ dsubq fp2,fp2,fp8 dcmpuq cr0,fp2,fp10 /* if x still > 2**63-1 */ li r3,-1 /* return max_unsigned_long */ bgelr cr0 /* else */ L(poslong): dctfixq fp0,fp2 /* Convert x to long integer. */ stfd fp0,-8(r1) ori r1,r1,0 /* Special group ending nop. */ ld r3,-8(r1) blr L(negative): li r3,0 /* return 0 for negative floats. */ blr END (__dpd_fixunsdddi) hidden_def (__dpd_fixunsdddi) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/fixunsddsi.S000066400000000000000000000035611261375163000243660ustar00rootroot00000000000000/* Decimal Floating Point convert 64-bit to unsigned int. P6 PPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* unsigned int __dpd_fixunsddsi (_Decimal64 x) */ ENTRY (__dpd_fixunsddsi) drintn 0,fp1,fp1,1 /* Preround to toward zero. */ dctfix fp0,fp1 /* Convert x to integer. */ stfd fp0,-8(r1) ori r1,r1,0 /* Special group ending nop. */ oris r4,0,0xffff /* 0x00000000ffff0000 */ ori r4,r4,0xffff /* 0x00000000ffffffff */ ld r3,-8(r1) /* The return is an unsigned int, but we have long long, so we need to force overflow if there are any significant bits in the high word or return zero if negative. */ cmpdi cr0,r3,0 /* less than zero? */ cmpld cr6,r3,r4 blt cr0,L(negative) blelr cr6 L(posoverflow): mr r3,r4 /* return max unsigned int. */ blr L(negative): li r3,0 /* return 0 for negative floats. */ blr END (__dpd_fixunsddsi) hidden_def (__dpd_fixunsddsi) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/fixunssddi.S000066400000000000000000000050251261375163000243630ustar00rootroot00000000000000/* Decimal Floating Point convert 32-bit to unsigned long. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .section ".toc","aw" .LC1: /* 9223372036854775808.0DD */ .tc FT_2207c000_3_a4cfa07a_2c7f600a[TC],0x2207c00000000003,0xa4cfa07a2c7f600a .LC2: /* 18446744073709551616.0DD */ .tc FT_2207c000_c_a99e40ed_c5ba58e0[TC],0x2207c0000000000c,0xa99e40edc5ba58e0 .section ".text" .machine "power6" /* unsigned long __dpd_fixunssddi (_Decimal32 x) */ /* unsigned long long __dpd_fixunssddi (_Decimal32 x) */ ENTRY (__dpd_fixunssddi) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctqpq fp2,fp1 /* Convert x to _Decimal128. */ lfd fp10,.LC1@toc(2) lfd fp11,.LC1@toc+8(2) dsubq fp6,fp10,fp10 /* Generate 0.0 constant for later. */ drintnq 0,fp2,fp2,1 /* Preround to toward zero. */ dcmpuq cr1,fp2,fp6 /* Check for less than zero. */ dcmpuq cr0,fp2,fp10 /* check if > 2**63-1 */ blt cr1,L(negative) lfd fp8,.LC2@toc(2) lfd fp9,.LC2@toc+8(2) ble cr0,L(poslong) /* The return is an unsigned long, but "DFP convert to fixed" takes signed long, so we need to pre-adjust (-18446744073709551616.0DD) to get the final (signed) conversion result to be the correct unsigned result. */ dsubq fp2,fp2,fp8 dcmpuq cr0,fp2,fp10 /* if x still > 2**63-1 */ li r3,-1 /* return max_unsigned_long */ bgelr cr0 /* else */ L(poslong): dctfixq fp0,fp2 /* Convert x to long integer. */ stfd fp0,-8(r1) ori r1,r1,0 /* Special group ending nop. */ ld r3,-8(r1) blr L(negative): li r3,0 /* return 0 for negative floats. */ blr END (__dpd_fixunssddi) hidden_def (__dpd_fixunssddi) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/fixunssdsi.S000066400000000000000000000035471261375163000244110ustar00rootroot00000000000000/* Decimal Floating Point convert 32-bit to unsigned int. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* unsigned int __dpd_fixunssdsi (_Decimal32 x) */ ENTRY (__dpd_fixunssdsi) dctdp fp1,fp1 /* Convert x to _Decimal64. */ drintn 0,fp1,fp1,1 /* Preround to toward zero. */ dctfix fp0,fp1 /* Convert x to integer. */ stfd fp0,-8(r1) ori r1,r1,0 /* Special group ending nop. */ oris r4,0,0xffff /* 0x00000000ffff0000 */ ori r4,r4,0xffff /* 0x00000000ffffffff */ ld r3,-8(r1) /* The return is an unsigned int, but we have long long, so we need to force overflow if there are any significant bits in the high word or return zero if negative. */ cmpld cr6,r3,r4 blt cr1,L(negative) blelr cr6 L(posoverflow): mr r3,r4 /* return max unsigned int. */ blr L(negative): li r3,0 /* return 0 for negative floats. */ blr END (__dpd_fixunssdsi) hidden_def (__dpd_fixunssdsi) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/fixunstddi.S000066400000000000000000000046701261375163000243710ustar00rootroot00000000000000/* Decimal Floating Point convert 128-bit to unsigned long. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .section ".toc","aw" .LC1: /* 9223372036854775808.0DD */ .tc FT_2207c000_3_a4cfa07a_2c7f600a[TC],0x2207c00000000003,0xa4cfa07a2c7f600a .LC2: /* 18446744073709551616.0DD */ .tc FT_2207c000_c_a99e40ed_c5ba58e0[TC],0x2207c0000000000c,0xa99e40edc5ba58e0 .section ".text" .machine "power6" /* unsigned long __dpd_fixunstddi (_Decimal128 x) */ /* unsigned long long __dpd_fixunstddi (_Decimal128 x) */ ENTRY (__dpd_fixunstddi) lfd fp10,.LC1@toc(2) lfd fp11,.LC1@toc+8(2) dsubq fp6,fp10,fp10 /* Generate 0.0 constant for later. */ drintnq 0,fp2,fp2,1 /* Preround to toward zero. */ dcmpuq cr1,fp2,fp6 /* Check for less than zero. */ dcmpuq cr0,fp2,fp10 /* check if > 2**63-1 */ blt cr1,L(negative) lfd fp8,.LC2@toc(2) lfd fp9,.LC2@toc+8(2) ble cr0,L(poslong) /* The return is an unsigned long, but "DFP convert to fixed" takes signed long, so we need to pre-adjust (-18446744073709551616.0DD) to get the final (signed) conversion result to be the correct unsigned result. */ dsubq fp2,fp2,fp8 dcmpuq cr0,fp2,fp10 /* if x still > 2**63-1 */ li r3,-1 /* return max_unsigned_long */ bgelr cr0 /* else */ L(poslong): dctfixq fp0,fp2 /* Convert x to long integer. */ stfd fp0,-8(r1) ori r1,r1,0 /* Special group ending nop. */ ld r3,-8(r1) blr L(negative): li r3,0 /* return 0 for negative floats. */ blr END (__dpd_fixunstddi) hidden_def (__dpd_fixunstddi) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/fixunstdsi.S000066400000000000000000000035141261375163000244040ustar00rootroot00000000000000/* Decimal Floating Point convert 128-bit to unsigned int. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* unsigned int __dpd_fixunstdsi (_Decimal128 x) */ ENTRY (__dpd_fixunstdsi) drintnq 0,fp2,fp2,1 /* Preround to toward zero. */ dctfixq fp0,fp2 /* Convert x to integer. */ stfd fp0,-8(r1) ori r1,r1,0 /* Special group ending nop. */ oris r4,0,0xffff /* 0x00000000ffff0000 */ ori r4,r4,0xffff /* 0x00000000ffffffff */ ld r3,-8(r1) /* The return is an unsigned int, but we have long long, so we need to force overflow if there are any significant bits in the high word or return zero if negative. */ cmpdi cr0,r3,0 cmpld cr6,r3,r4 blt cr0,L(negative) blelr cr6 L(posoverflow): mr r3,r4 /* return max unsigned int. */ blr L(negative): li r3,0 /* return 0 for negative floats. */ blr END (__dpd_fixunstdsi) hidden_def (__dpd_fixunstdsi) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/floatdidd.S000066400000000000000000000027241261375163000241400ustar00rootroot00000000000000/* Convert long to Decimal Floating Point 64-bit. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal64 __dpd_floatdidd (long x) */ /* _Decimal64 __dpd_floatdidd (long long x) */ ENTRY (__dpd_floatdidd) std r3,-8(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,-8(r1) dcffixq fp2,fp0 /* Convert x to _Decimal128 float. */ drdpq fp0,fp2 /* Round result to _Decimal64. */ fmr fp1,fp0 blr END (__dpd_floatdidd) hidden_def (__dpd_floatdidd) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/floatdisd.S000066400000000000000000000027621261375163000241610ustar00rootroot00000000000000/* Convert long to Decimal Floating Point 32-bit. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal32 __dpd_floatdisd (long x) */ /* _Decimal32 __dpd_floatdisd (long long x) */ ENTRY (__dpd_floatdisd) std r3,-8(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,-8(r1) dcffixq fp2,fp0 /* Convert x to _Decimal128 float. */ drdpq fp0,fp2 /* Round result to _Decimal64. */ drsp fp1,fp0 /* Round result to _Decimal32. */ blr END (__dpd_floatdisd) hidden_def (__dpd_floatdisd) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/floatditd.S000066400000000000000000000026301261375163000241540ustar00rootroot00000000000000/* Convert long to Decimal Floating Point 128-bit. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal128 __dpd_floatditd (long x) */ /* _Decimal128 __dpd_floatditd (long long x) */ ENTRY (__dpd_floatditd) std r3,-8(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,-8(r1) dcffixq fp2,fp0 /* Convert x to _Decimal128 float. */ blr END (__dpd_floatditd) hidden_def (__dpd_floatditd) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/floatsidd.S000066400000000000000000000026311261375163000241540ustar00rootroot00000000000000/* Convert int to Decimal Floating Point 64-bit. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal64 __dpd_floatsidd (int x) */ ENTRY (__dpd_floatsidd) std r3,-8(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,-8(r1) dcffixq fp2,fp0 /* Convert x to decimal float. */ drdpq fp0,fp2 /* Round result to _Decimal64. */ fmr fp1,fp0 blr END (__dpd_floatsidd) hidden_def (__dpd_floatsidd) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/floatsisd.S000066400000000000000000000026741261375163000242020ustar00rootroot00000000000000/* Convert int to Decimal Floating Point 32-bit. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal32 __dpd_floatsisd (int x) */ ENTRY (__dpd_floatsisd) std r3,-8(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,-8(r1) dcffixq fp2,fp0 /* Convert x to _Decimal128 float. */ drdpq fp0,fp2 /* Convert to _Decimal64. */ drsp fp1,fp0 /* Round result to _Decimal32. */ blr END (__dpd_floatsisd) hidden_def (__dpd_floatsisd) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/floatsitd.S000066400000000000000000000025401261375163000241730ustar00rootroot00000000000000/* Convert int to Decimal Floating Point 128-bit. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal128 __dpd_floatsitd (int x) */ ENTRY (__dpd_floatsitd) std r3,-8(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,-8(r1) dcffixq fp2,fp0 /* Convert x to _Decimal128 float. */ blr END (__dpd_floatsitd) hidden_def (__dpd_floatsitd) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/floatunsdidd.S000066400000000000000000000043731261375163000246700ustar00rootroot00000000000000/* Convert unsigned long to Decimal Floating Point 64-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .section ".toc","aw" .LC1: /* 9223372036854775808.0DL */ .tc FT_2207c000_3_a4cfa07a_2c7f600a[TC],0x2207c00000000003,0xa4cfa07a2c7f600a .section ".text" .machine "power6" /* _Decimal64 __dpd_floatunsdidd (unsigned long x) */ /* _Decimal64 __dpd_floatunsdidd (unsigned long long x) */ ENTRY (__dpd_floatunsdidd) cmpdi cr0,r3,0 std r3,-8(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,-8(r1) blt cr0,L(negative) dcffixq fp2,fp0 /* Convert x to _Decimal128 float. */ drdpq fp0,fp2 /* Round result to _Decimal64. Result in fp0. */ fmr fp1,fp0 blr /* we need to do more here. The function converts a unsigned long, but the dcffix instruction provides a signed conversion. So we force the binary to be positive by clearing the sign bit before we convert to decimal. Then we add 9223372036854775808.0DL to the result of the dcffix. This gives the decimal equivalent to the full 64-bit value. */ L(negative): fabs fp0,fp0 lfd fp10,.LC1@toc(2) lfd fp11,.LC1@toc+8(2) dcffixq fp2,fp0 /* Convert x to _Decimal128 float. */ daddq fp2,fp2,fp10 drdpq fp0,fp2 /* Round result to _Decimal64. */ fmr fp1,fp0 blr END (__dpd_floatunsdidd) hidden_def (__dpd_floatunsdidd) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/floatunsdisd.S000066400000000000000000000044621261375163000247060ustar00rootroot00000000000000/* Convert unsigned long to Decimal Floating Point 32-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .section ".toc","aw" .LC1: /* 9223372036854775808.0DD */ .tc FT_2207c000_3_a4cfa07a_2c7f600a[TC],0x2207c00000000003,0xa4cfa07a2c7f600a .section ".text" .machine "power6" /* _Decimal32 __dpd_floatunsdisd (unsigned long x) */ /* _Decimal32 __dpd_floatunsdisd (unsigned long long x) */ ENTRY (__dpd_floatunsdisd) cmpdi cr0,r3,0 std r3,-8(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,-8(r1) blt cr0,L(negative) dcffixq fp2,fp0 /* Convert x to _Decimal128 floatuns. */ drdpq fp0,fp2 /* Round result to _Decimal64. */ drsp fp1,fp0 /* Round result to _Decimal32. */ blr /* we need to do more here. The function converts a unsigned long, but the dcffixq instruction provides a signed conversion. So we force the binary to be positive by clearing the sign bit before we convert to decimal. Then we add 9223372036854775808.0DD to the result of the dcffix. This gives the decimal equivalent to the full 64-bit value. */ L(negative): fabs fp0,fp0 lfd fp10,.LC1@toc(2) lfd fp11,.LC1@toc+8(2) dcffixq fp2,fp0 /* Convert x to _Decimal128 float. */ daddq fp2,fp2,fp10 drdpq fp0,fp2 /* Round result to _Decimal64. */ drsp fp1,fp0 /* Round result to _Decimal32. */ blr END (__dpd_floatunsdisd) hidden_def (__dpd_floatunsdisd) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/floatunsditd.S000066400000000000000000000041531261375163000247040ustar00rootroot00000000000000/* Convert unsigned long to Decimal Floating Point 128-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .section ".toc","aw" .LC1: /* 9223372036854775808.0DL */ .tc FT_2207c000_3_a4cfa07a_2c7f600a[TC],0x2207c00000000003,0xa4cfa07a2c7f600a .section ".text" .machine "power6" /* _Decimal128 __dpd_floatunsditd (unsigned long x) */ /* _Decimal128 __dpd_floatunsditd (unsigned long long x) */ ENTRY (__dpd_floatunsditd) cmpdi cr0,r3,0 std r3,-8(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,-8(r1) blt cr0,L(negative) dcffixq fp2,fp0 /* Convert x to decimal floatuns. */ blr /* we need to do more here. The function converts a unsigned long, but the dcffix instruction provides a signed conversion. So we force the binary to be positive by clearing the sign bit before we convert to decimal. Then we add 9223372036854775808.0DL to the result of the dcffixq. This gives the decimal equivalent to the full 64-bit value. */ L(negative): fabs fp0,fp0 lfd fp10,.LC1@toc(2) lfd fp11,.LC1@toc+8(2) dcffixq fp2,fp0 /* Convert x to decimal float. */ daddq fp2,fp2,fp10 blr END (__dpd_floatunsditd) hidden_def (__dpd_floatunsditd) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/floatunssidd.S000066400000000000000000000027151261375163000247050ustar00rootroot00000000000000/* Convert unsigned int to Decimal Floating Point 64-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal64 __dpd_floatunssidd (unsigned int x) */ ENTRY (__dpd_floatunssidd) clrldi r0,r3,32 /* extend unsigned. */ std r0,-8(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,-8(r1) dcffixq fp2,fp0 /* Convert x to _Decimal floatuns. */ drdpq fp0,fp2 /* Round result to _Decimal64. */ fmr fp1,fp0 blr END (__dpd_floatunssidd) hidden_def (__dpd_floatunssidd) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/floatunssisd.S000066400000000000000000000027621261375163000247260ustar00rootroot00000000000000/* Convert unsigned int to Decimal Floating Point 32-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal32 __dpd_floatunssisd (unsigned int x) */ ENTRY (__dpd_floatunssisd) clrldi r0,r3,32 /* extend unsigned. */ std r0,-8(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,-8(r1) dcffixq fp2,fp0 /* Convert x to _Decimal128 floatuns. */ drdpq fp0,fp2 /* Round result to _Decimal64. */ drsp fp1,fp0 /* Round result to _Decimal32. */ blr END (__dpd_floatunssisd) hidden_def (__dpd_floatunssisd) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/floatunssitd.S000066400000000000000000000026231261375163000247230ustar00rootroot00000000000000/* Convert unsigned int to Decimal Floating Point 128-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal128 __dpd_floatunssitd (unsigned int x) */ ENTRY (__dpd_floatunssitd) clrldi r0,r3,32 /* extend unsigned. */ std r0,-8(r1) ori r1,r1,0 /* Special group ending nop. */ lfd fp0,-8(r1) dcffixq fp2,fp0 /* Convert x to _Decimal128 floatuns. */ blr END (__dpd_floatunssitd) hidden_def (__dpd_floatunssitd) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/gedd2.S000066400000000000000000000026651261375163000231770ustar00rootroot00000000000000/* Decimal Floating Point 64-bit compare >=. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_gedd2 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_gedd2) dcmpu cr0,fp1,fp2 /* if ((x > y) && !unordered(x,y)) */ li r3, 1 /* return 1 */ bgtlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, -1 /* return -1 */ blr END (__dpd_gedd2) hidden_def (__dpd_gedd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/gesd2.S000066400000000000000000000030211261375163000232010ustar00rootroot00000000000000/* Decimal Floating Point 32-bit compare >=. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_gesd2 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_gesd2) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ dcmpu cr0,fp1,fp2 /* if ((x > y) && !unordered(x,y)) */ li r3, 1 /* return 1 */ bgtlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, -1 /* return -1 */ blr END (__dpd_gesd2) hidden_def (__dpd_gesd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/getd2.S000066400000000000000000000026711261375163000232140ustar00rootroot00000000000000/* Decimal Floating Point 128-bit compare >=. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_getd2 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_getd2) dcmpuq cr0,fp2,fp4 /* if ((x > y) && !unordered(x,y)) */ li r3, 1 /* return 1 */ bgtlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, -1 /* return -1 */ blr END (__dpd_getd2) hidden_def (__dpd_getd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/gtdd2.S000066400000000000000000000026651261375163000232160ustar00rootroot00000000000000/* Decimal Floating Point 64-bit compare >=. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_gtdd2 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_gtdd2) dcmpu cr0,fp1,fp2 /* if ((x > y) && !unordered(x,y)) */ li r3, 1 /* return 1 */ bgtlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, -1 /* return -1 */ blr END (__dpd_gtdd2) hidden_def (__dpd_gtdd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/gtsd2.S000066400000000000000000000030211261375163000232200ustar00rootroot00000000000000/* Decimal Floating Point 32-bit compare >=. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_gtsd2 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_gtsd2) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ dcmpu cr0,fp1,fp2 /* if ((x > y) && !unordered(x,y)) */ li r3, 1 /* return 1 */ bgtlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, -1 /* return -1 */ blr END (__dpd_gtsd2) hidden_def (__dpd_gtsd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/gttd2.S000066400000000000000000000026711261375163000232330ustar00rootroot00000000000000/* Decimal Floating Point 128-bit compare >=. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_gttd2 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_gttd2) dcmpuq cr0,fp2,fp4 /* if ((x > y) && !unordered(x,y)) */ li r3, 1 /* return 1 */ bgtlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, -1 /* return -1 */ blr END (__dpd_gttd2) hidden_def (__dpd_gttd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/ledd2.S000066400000000000000000000026641261375163000232030ustar00rootroot00000000000000/* Decimal Floating Point 64-bit compare <. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_ledd2 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_ledd2) dcmpu cr0,fp1,fp2 /* if ((x < y) && !unordered(x,y)) */ li r3, -1 /* return -1 */ bltlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_ledd2) hidden_def (__dpd_ledd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/lesd2.S000066400000000000000000000030201261375163000232050ustar00rootroot00000000000000/* Decimal Floating Point 32-bit compare <. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_lesd2 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_lesd2) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ dcmpu cr0,fp1,fp2 /* if ((x < y) && !unordered(x,y)) */ li r3, -1 /* return -1 */ bltlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_lesd2) hidden_def (__dpd_lesd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/letd2.S000066400000000000000000000026711261375163000232210ustar00rootroot00000000000000/* Decimal Floating Point 128-bit compare >=. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_letd2 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_letd2) dcmpuq cr0,fp2,fp4 /* if ((x < y) && !unordered(x,y)) */ li r3, -1 /* return -1 */ bltlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_letd2) hidden_def (__dpd_letd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/ltdd2.S000066400000000000000000000026641261375163000232220ustar00rootroot00000000000000/* Decimal Floating Point 64-bit compare <. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_ltdd2 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_ltdd2) dcmpu cr0,fp1,fp2 /* if ((x < y) && !unordered(x,y)) */ li r3, -1 /* return -1 */ bltlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_ltdd2) hidden_def (__dpd_ltdd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/ltsd2.S000066400000000000000000000030201261375163000232240ustar00rootroot00000000000000/* Decimal Floating Point 32-bit compare <. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_ltsd2 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_ltsd2) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ dcmpu cr0,fp1,fp2 /* if ((x < y) && !unordered(x,y)) */ li r3, -1 /* return -1 */ bltlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_ltsd2) hidden_def (__dpd_ltsd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/lttd2.S000066400000000000000000000026711261375163000232400ustar00rootroot00000000000000/* Decimal Floating Point 128-bit compare >=. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_lttd2 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_lttd2) dcmpuq cr0,fp2,fp4 /* if ((x < y) && !unordered(x,y)) */ li r3, -1 /* return -1 */ bltlr cr0 /* else if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_lttd2) hidden_def (__dpd_lttd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/muldd3.S000066400000000000000000000023611261375163000233730ustar00rootroot00000000000000/* Decimal Floating Point 64-bit multiply. POWER6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal64 __dpd_muldd3 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_muldd3) dmul fp1,fp1,fp2 blr END (__dpd_muldd3) hidden_def (__dpd_muldd3) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/mulsd3.S000066400000000000000000000025751261375163000234210ustar00rootroot00000000000000/* Decimal Floating Point 32-bit multiply. POWER6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal32 __dpd_mulsd3 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_mulsd3) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ dmul fp1,fp1,fp2 drsp fp1,fp1 /* Round result to _Decimal32. */ blr END (__dpd_mulsd3) hidden_def (__dpd_mulsd3) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/multd3.S000066400000000000000000000023661261375163000234200ustar00rootroot00000000000000/* Decimal Floating Point 128-bit multiply. POWER6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal128 __dpd_multd3 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_multd3) dmulq fp2,fp2,fp4 blr END (__dpd_multd3) hidden_def (__dpd_multd3) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/nedd2.S000066400000000000000000000025521261375163000232010ustar00rootroot00000000000000/* Decimal Floating Point 64-bit compare !=. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_nedd2 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_nedd2) dcmpu cr0,fp1,fp2 /* if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ bunlr cr0 li r3, 1 /* return 1 */ blr END (__dpd_nedd2) hidden_def (__dpd_nedd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/nesd2.S000066400000000000000000000027061261375163000232210ustar00rootroot00000000000000/* Decimal Floating Point 32-bit compare !=. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_nesd2 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_nesd2) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ dcmpu cr0,fp1,fp2 /* if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ bunlr cr0 li r3, 1 /* return 1 */ blr END (__dpd_nesd2) hidden_def (__dpd_nesd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/netd2.S000066400000000000000000000025561261375163000232250ustar00rootroot00000000000000/* Decimal Floating Point 128-bit compare !=. P6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_netd2 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_netd2) dcmpuq cr0,fp2,fp4 /* if ((x == y) && !unordered(x,y)) */ li r3, 0 /* return 0 */ beqlr cr0 /* else */ bunlr cr0 li r3, 1 /* return 1 */ blr END (__dpd_netd2) hidden_def (__dpd_netd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/subdd3.S000066400000000000000000000023621261375163000233700ustar00rootroot00000000000000/* Decimal Floating Point 64-bit substract. POWER6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal64 __dpd_subdd3 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_subdd3) dsub fp1,fp1,fp2 blr END (__dpd_subdd3) hidden_def (__dpd_subdd3) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/subsd3.S000066400000000000000000000025751261375163000234150ustar00rootroot00000000000000/* Decimal Floating Point 32-bit subtract. POWER6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal32 __dpd_subsd3 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_subsd3) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ dsub fp1,fp1,fp2 drsp fp1,fp1 /* Round result to _Decimal32. */ blr END (__dpd_subsd3) hidden_def (__dpd_subsd3) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/subtd3.S000066400000000000000000000023661261375163000234140ustar00rootroot00000000000000/* Decimal Floating Point 128-bit subtract. POWER6 PowerPC64 version. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal128 __dpd_subtd3 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_subtd3) dsubq fp2,fp2,fp4 blr END (__dpd_subtd3) hidden_def (__dpd_subtd3) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/truncddsd2.S000066400000000000000000000024001261375163000242510ustar00rootroot00000000000000/* Decimal Floating Point truncate 64-bit to 32-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal32 __dpd_truncddsd2 (_Decimal64 x) */ ENTRY (__dpd_truncddsd2) drsp fp1,fp1 /* Round result to _Decimal32. */ blr END (__dpd_truncddsd2) hidden_def (__dpd_truncddsd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/trunctddd2.S000066400000000000000000000024201261375163000242540ustar00rootroot00000000000000/* Decimal Floating Point truncate 128-bit to 64-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal64 __dpd_trunctddd2 (_Decimal128 x) */ ENTRY (__dpd_trunctddd2) drdpq fp0,fp2 /* Round result to _Decimal64. */ fmr fp1,fp0 blr END (__dpd_trunctddd2) hidden_def (__dpd_trunctddd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/trunctdsd2.S000066400000000000000000000024631261375163000243020ustar00rootroot00000000000000/* Decimal Floating Point truncate 128-bit to 32-bit. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* _Decimal32 __dpd_trunctdsd2 (_Decimal128 x) */ ENTRY (__dpd_trunctdsd2) drdpq fp0,fp2 /* Round result to _Decimal64. */ drsp fp1,fp0 /* Round result to _Decimal32. */ blr END (__dpd_trunctdsd2) hidden_def (__dpd_trunctdsd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/unorddd2.S000066400000000000000000000025201261375163000237210ustar00rootroot00000000000000/* Decimal Floating Point 64-bit unordered compare. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_unorddd2 (_Decimal64 x, _Decimal64 y) */ ENTRY (__dpd_unorddd2) dcmpu cr0,fp1,fp2 /* if (!unordered(x,y)) */ li r3, 0 /* return 0 */ bnulr+ cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_unorddd2) hidden_def (__dpd_unorddd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/unordsd2.S000066400000000000000000000026541261375163000237500ustar00rootroot00000000000000/* Decimal Floating Point 32-bit unordered compare. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_unordsd2 (_Decimal32 x, _Decimal32 y) */ ENTRY (__dpd_unordsd2) dctdp fp1,fp1 /* Convert x to _Decimal64. */ dctdp fp2,fp2 /* Convert y to _Decimal64. */ dcmpu cr0,fp1,fp2 /* if (!unordered(x,y)) */ li r3, 0 /* return 0 */ bnulr+ cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_unordsd2) hidden_def (__dpd_unordsd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6/fpu/unordtd2.S000066400000000000000000000025241261375163000237450ustar00rootroot00000000000000/* Decimal Floating Point 128-bit unordered compare. Copyright (C) 2006-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Steven J. Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include .machine "power6" /* int __dpd_unordtd2 (_Decimal128 x, _Decimal128 y) */ ENTRY (__dpd_unordtd2) dcmpuq cr0,fp2,fp4 /* if (!unordered(x,y)) */ li r3, 0 /* return 0 */ bnulr+ cr0 /* else */ li r3, 1 /* return 1 */ blr END (__dpd_unordtd2) hidden_def (__dpd_unordtd2) libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6x/000077500000000000000000000000001261375163000214535ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6x/Implies000066400000000000000000000001651261375163000230020ustar00rootroot00000000000000# Pick up the power6 versions of files since power6x is basically the same # thing. sysdeps/powerpc/powerpc64/power6 libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6x/fpu/000077500000000000000000000000001261375163000222455ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/powerpc64/power6x/fpu/Implies000066400000000000000000000001721261375163000235720ustar00rootroot00000000000000# Pick up the power6 versions of files since power6x is basically the same # thing. sysdeps/powerpc/powerpc64/power6/fpu libdfp-1.0.12/sysdeps/powerpc/powerpc64/power7/000077500000000000000000000000001261375163000212645ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/powerpc64/power7/Implies000066400000000000000000000001661261375163000226140ustar00rootroot00000000000000# Pick up the power6 versions of files since power7 supports hardware-dfp as # well. sysdeps/powerpc/powerpc64/power6 libdfp-1.0.12/sysdeps/powerpc/powerpc64/power7/fpu/000077500000000000000000000000001261375163000220565ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/powerpc64/power7/fpu/Implies000066400000000000000000000001731261375163000234040ustar00rootroot00000000000000# Pick up the power6 versions of files since power7 supports hardware-dfp as # well. sysdeps/powerpc/powerpc64/power6/fpu libdfp-1.0.12/sysdeps/powerpc/powerpc64/power8/000077500000000000000000000000001261375163000212655ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/powerpc64/power8/Implies000066400000000000000000000000411261375163000226050ustar00rootroot00000000000000sysdeps/powerpc/powerpc64/power7 libdfp-1.0.12/sysdeps/powerpc/powerpc64/power8/fpu/000077500000000000000000000000001261375163000220575ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/powerpc/powerpc64/power8/fpu/Implies000066400000000000000000000000451261375163000234030ustar00rootroot00000000000000sysdeps/powerpc/powerpc64/power7/fpu libdfp-1.0.12/sysdeps/powerpc/powerpc64/sysdep.h000066400000000000000000000254431261375163000215310ustar00rootroot00000000000000/* Assembly macros for 64-bit PowerPC. Copyright (C) 2002-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #ifdef __ASSEMBLER__ /* Stack frame offsets. */ #if _CALL_ELF != 2 #define FRAME_MIN_SIZE 112 #define FRAME_MIN_SIZE_PARM 112 #define FRAME_BACKCHAIN 0 #define FRAME_CR_SAVE 8 #define FRAME_LR_SAVE 16 #define FRAME_TOC_SAVE 40 #define FRAME_PARM_SAVE 48 #define FRAME_PARM1_SAVE 48 #define FRAME_PARM2_SAVE 56 #define FRAME_PARM3_SAVE 64 #define FRAME_PARM4_SAVE 72 #define FRAME_PARM5_SAVE 80 #define FRAME_PARM6_SAVE 88 #define FRAME_PARM7_SAVE 96 #define FRAME_PARM8_SAVE 104 #define FRAME_PARM9_SAVE 112 #else #define FRAME_MIN_SIZE 32 #define FRAME_MIN_SIZE_PARM 96 #define FRAME_BACKCHAIN 0 #define FRAME_CR_SAVE 8 #define FRAME_LR_SAVE 16 #define FRAME_TOC_SAVE 24 #define FRAME_PARM_SAVE 32 #define FRAME_PARM1_SAVE 32 #define FRAME_PARM2_SAVE 40 #define FRAME_PARM3_SAVE 48 #define FRAME_PARM4_SAVE 56 #define FRAME_PARM5_SAVE 64 #define FRAME_PARM6_SAVE 72 #define FRAME_PARM7_SAVE 80 #define FRAME_PARM8_SAVE 88 #define FRAME_PARM9_SAVE 96 #endif /* Support macros for CALL_MCOUNT. */ #if _CALL_ELF == 2 #define call_mcount_parm_offset (-64) #else #define call_mcount_parm_offset FRAME_PARM_SAVE #endif .macro SAVE_ARG NARG .if \NARG SAVE_ARG \NARG-1 std 2+\NARG,call_mcount_parm_offset-8+8*(\NARG)(1) .endif .endm .macro REST_ARG NARG .if \NARG REST_ARG \NARG-1 ld 2+\NARG,FRAME_MIN_SIZE_PARM+call_mcount_parm_offset-8+8*(\NARG)(1) .endif .endm .macro CFI_SAVE_ARG NARG .if \NARG CFI_SAVE_ARG \NARG-1 cfi_offset(2+\NARG,call_mcount_parm_offset-8+8*(\NARG)) .endif .endm .macro CFI_REST_ARG NARG .if \NARG CFI_REST_ARG \NARG-1 cfi_restore(2+\NARG) .endif .endm /* If compiled for profiling, call `_mcount' at the start of each function. see ppc-mcount.S for more details. */ .macro CALL_MCOUNT NARG #ifdef PROF mflr r0 SAVE_ARG \NARG std r0,FRAME_LR_SAVE(r1) stdu r1,-FRAME_MIN_SIZE_PARM(r1) cfi_adjust_cfa_offset(FRAME_MIN_SIZE_PARM) cfi_offset(lr,FRAME_LR_SAVE) CFI_SAVE_ARG \NARG bl JUMPTARGET (_mcount) #ifndef SHARED nop #endif ld r0,FRAME_MIN_SIZE_PARM+FRAME_LR_SAVE(r1) REST_ARG \NARG mtlr r0 addi r1,r1,FRAME_MIN_SIZE_PARM cfi_adjust_cfa_offset(-FRAME_MIN_SIZE_PARM) cfi_restore(lr) CFI_REST_ARG \NARG #endif .endm #if _CALL_ELF != 2 /* Macro to prepare for calling via a function pointer. */ .macro PPC64_LOAD_FUNCPTR PTR ld r12,0(\PTR) ld r2,8(\PTR) mtctr r12 ld r11,16(\PTR) .endm #ifdef USE_PPC64_OVERLAPPING_OPD # define OPD_ENT(name) .quad BODY_LABEL (name), .TOC.@tocbase #else # define OPD_ENT(name) .quad BODY_LABEL (name), .TOC.@tocbase, 0 #endif #define ENTRY_1(name) \ .type BODY_LABEL(name),@function; \ .globl name; \ .section ".opd","aw"; \ .align 3; \ name##: OPD_ENT (name); \ .previous; #ifdef HAVE_ASM_GLOBAL_DOT_NAME # define DOT_LABEL(X) .##X # define BODY_LABEL(X) .##X # define ENTRY_2(name) \ .globl BODY_LABEL(name); \ ENTRY_1(name) \ .size name, 24; # define END_2(name) \ .size BODY_LABEL(name),.-BODY_LABEL(name); #else # define DOT_LABEL(X) X # define BODY_LABEL(X) .LY##X # define ENTRY_2(name) \ .type name,@function; \ ENTRY_1(name) # define END_2(name) \ .size name,.-BODY_LABEL(name); \ .size BODY_LABEL(name),.-BODY_LABEL(name); #endif #define LOCALENTRY(name) #else /* _CALL_ELF */ /* Macro to prepare for calling via a function pointer. */ .macro PPC64_LOAD_FUNCPTR PTR mr r12,\PTR mtctr r12 .endm #define DOT_LABEL(X) X #define BODY_LABEL(X) X #define ENTRY_2(name) \ .globl name; \ .type name,@function; #define END_2(name) \ .size name,.-name; #define LOCALENTRY(name) \ 1: addis r2,r12,.TOC.-1b@ha; \ addi r2,r2,.TOC.-1b@l; \ .localentry name,.-name; #endif /* _CALL_ELF */ #define ENTRY(name) \ .section ".text"; \ ENTRY_2(name) \ .align ALIGNARG(2); \ BODY_LABEL(name): \ cfi_startproc; \ LOCALENTRY(name) #define EALIGN_W_0 /* No words to insert. */ #define EALIGN_W_1 nop #define EALIGN_W_2 nop;nop #define EALIGN_W_3 nop;nop;nop #define EALIGN_W_4 EALIGN_W_3;nop #define EALIGN_W_5 EALIGN_W_4;nop #define EALIGN_W_6 EALIGN_W_5;nop #define EALIGN_W_7 EALIGN_W_6;nop /* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes past a 2^alignt boundary. */ #define EALIGN(name, alignt, words) \ .section ".text"; \ ENTRY_2(name) \ .align ALIGNARG(alignt); \ EALIGN_W_##words; \ BODY_LABEL(name): \ cfi_startproc; \ LOCALENTRY(name) /* Local labels stripped out by the linker. */ #undef L #define L(x) .L##x #define tostring(s) #s #define stringify(s) tostring(s) #define XGLUE(a,b) a##b #define GLUE(a,b) XGLUE(a,b) #define LT_LABEL(name) GLUE(.LT,name) #define LT_LABELSUFFIX(name,suffix) GLUE(GLUE(.LT,name),suffix) /* Support Traceback tables */ #define TB_ASM 0x000c000000000000 #define TB_GLOBALLINK 0x0000800000000000 #define TB_IS_EPROL 0x0000400000000000 #define TB_HAS_TBOFF 0x0000200000000000 #define TB_INT_PROC 0x0000100000000000 #define TB_HAS_CTL 0x0000080000000000 #define TB_TOCLESS 0x0000040000000000 #define TB_FP_PRESENT 0x0000020000000000 #define TB_LOG_ABORT 0x0000010000000000 #define TB_INT_HANDL 0x0000008000000000 #define TB_NAME_PRESENT 0x0000004000000000 #define TB_USES_ALLOCA 0x0000002000000000 #define TB_SAVES_CR 0x0000000200000000 #define TB_SAVES_LR 0x0000000100000000 #define TB_STORES_BC 0x0000000080000000 #define TB_FIXUP 0x0000000040000000 #define TB_FP_SAVED(fprs) (((fprs) & 0x3f) << 24) #define TB_GPR_SAVED(gprs) (((fprs) & 0x3f) << 16) #define TB_FIXEDPARMS(parms) (((parms) & 0xff) << 8) #define TB_FLOATPARMS(parms) (((parms) & 0x7f) << 1) #define TB_PARMSONSTK 0x0000000000000001 #define PPC_HIGHER(v) (((v) >> 32) & 0xffff) #define TB_DEFAULT TB_ASM | TB_HAS_TBOFF | TB_NAME_PRESENT #define TRACEBACK(name) \ LT_LABEL(name): ; \ .long 0 ; \ .quad TB_DEFAULT ; \ .long LT_LABEL(name)-BODY_LABEL(name) ; \ .short LT_LABELSUFFIX(name,_name_end)-LT_LABELSUFFIX(name,_name_start) ; \ LT_LABELSUFFIX(name,_name_start): ;\ .ascii stringify(name) ; \ LT_LABELSUFFIX(name,_name_end): ; \ .align 2 ; #define TRACEBACK_MASK(name,mask) \ LT_LABEL(name): ; \ .long 0 ; \ .quad TB_DEFAULT | mask ; \ .long LT_LABEL(name)-BODY_LABEL(name) ; \ .short LT_LABELSUFFIX(name,_name_end)-LT_LABELSUFFIX(name,_name_start) ; \ LT_LABELSUFFIX(name,_name_start): ;\ .ascii stringify(name) ; \ LT_LABELSUFFIX(name,_name_end): ; \ .align 2 ; /* END generates Traceback tables */ #undef END #define END(name) \ cfi_endproc; \ TRACEBACK(name) \ END_2(name) /* This form supports more informative traceback tables */ #define END_GEN_TB(name,mask) \ cfi_endproc; \ TRACEBACK_MASK(name,mask) \ END_2(name) #define DO_CALL(syscall) \ li 0,syscall; \ sc /* ppc64 is always PIC */ #undef JUMPTARGET #define JUMPTARGET(name) DOT_LABEL(name) #define PSEUDO(name, syscall_name, args) \ .section ".text"; \ ENTRY (name) \ DO_CALL (SYS_ify (syscall_name)); #ifdef SHARED #define TAIL_CALL_SYSCALL_ERROR \ b JUMPTARGET(__syscall_error) #else /* Static version might be linked into a large app with a toc exceeding 64k. We can't put a toc adjusting stub on a plain branch, so can't tail call __syscall_error. */ #define TAIL_CALL_SYSCALL_ERROR \ .ifdef .Local_syscall_error; \ b .Local_syscall_error; \ .else; \ .Local_syscall_error: \ mflr 0; \ std 0,FRAME_LR_SAVE(1); \ stdu 1,-FRAME_MIN_SIZE(1); \ cfi_adjust_cfa_offset(FRAME_MIN_SIZE); \ cfi_offset(lr,FRAME_LR_SAVE); \ bl JUMPTARGET(__syscall_error); \ nop; \ ld 0,FRAME_MIN_SIZE+FRAME_LR_SAVE(1); \ addi 1,1,FRAME_MIN_SIZE; \ cfi_adjust_cfa_offset(-FRAME_MIN_SIZE); \ mtlr 0; \ cfi_restore(lr); \ blr; \ .endif #endif #define PSEUDO_RET \ bnslr+; \ TAIL_CALL_SYSCALL_ERROR #define ret PSEUDO_RET #undef PSEUDO_END #define PSEUDO_END(name) \ END (name) #define PSEUDO_NOERRNO(name, syscall_name, args) \ .section ".text"; \ ENTRY (name) \ DO_CALL (SYS_ify (syscall_name)); #define PSEUDO_RET_NOERRNO \ blr #define ret_NOERRNO PSEUDO_RET_NOERRNO #undef PSEUDO_END_NOERRNO #define PSEUDO_END_NOERRNO(name) \ END (name) #define PSEUDO_ERRVAL(name, syscall_name, args) \ .section ".text"; \ ENTRY (name) \ DO_CALL (SYS_ify (syscall_name)); #define PSEUDO_RET_ERRVAL \ blr #define ret_ERRVAL PSEUDO_RET_ERRVAL #undef PSEUDO_END_ERRVAL #define PSEUDO_END_ERRVAL(name) \ END (name) #else /* !__ASSEMBLER__ */ #if _CALL_ELF != 2 #define PPC64_LOAD_FUNCPTR(ptr) \ "ld 12,0(" #ptr ");\n" \ "ld 2,8(" #ptr ");\n" \ "mtctr 12;\n" \ "ld 11,16(" #ptr ");" #ifdef USE_PPC64_OVERLAPPING_OPD # define OPD_ENT(name) ".quad " BODY_PREFIX #name ", .TOC.@tocbase;" #else # define OPD_ENT(name) ".quad " BODY_PREFIX #name ", .TOC.@tocbase, 0;" #endif #define ENTRY_1(name) \ ".type " BODY_PREFIX #name ",@function;\n" \ ".globl " #name ";\n" \ ".pushsection \".opd\",\"aw\";\n" \ ".align 3;\n" \ #name ":\n" \ OPD_ENT (name) "\n" \ ".popsection;" #ifdef HAVE_ASM_GLOBAL_DOT_NAME # define DOT_PREFIX "." # define BODY_PREFIX "." # define ENTRY_2(name) \ ".globl " BODY_PREFIX #name ";\n" \ ENTRY_1(name) "\n" \ ".size " #name ", 24;" # define END_2(name) \ ".size " BODY_PREFIX #name ",.-" BODY_PREFIX #name ";" #else # define DOT_PREFIX "" # define BODY_PREFIX ".LY" # define ENTRY_2(name) \ ".type " #name ",@function;\n" \ ENTRY_1(name) # define END_2(name) \ ".size " #name ",.-" BODY_PREFIX #name ";\n" \ ".size " BODY_PREFIX #name ",.-" BODY_PREFIX #name ";" #endif #define LOCALENTRY(name) #else /* _CALL_ELF */ #define PPC64_LOAD_FUNCPTR(ptr) \ "mr 12," #ptr ";\n" \ "mtctr 12;" #define DOT_PREFIX "" #define BODY_PREFIX "" #define ENTRY_2(name) \ ".type " #name ",@function;\n" \ ".globl " #name ";" #define END_2(name) \ ".size " #name ",.-" #name ";" #define LOCALENTRY(name) \ "1: addis 2,12,.TOC.-1b@ha;\n" \ "addi 2,2,.TOC.-1b@l;\n" \ ".localentry " #name ",.-" #name ";" #endif /* _CALL_ELF */ #endif /* __ASSEMBLER__ */ libdfp-1.0.12/sysdeps/powerpc/sysdep.h000066400000000000000000000117521261375163000176760ustar00rootroot00000000000000/* Constructs needed by libdfp PowerPC asm files. Copyright (C) 1999-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ /* * Powerpc Feature masks for the Aux Vector Hardware Capabilities (AT_HWCAP). * This entry is copied to _dl_hwcap or rtld_global._dl_hwcap during startup. * The following must match the kernels linux/asm/cputable.h. */ #define PPC_FEATURE_32 0x80000000 /* 32-bit mode. */ #define PPC_FEATURE_64 0x40000000 /* 64-bit mode. */ #define PPC_FEATURE_601_INSTR 0x20000000 /* 601 chip, Old POWER ISA. */ #define PPC_FEATURE_HAS_ALTIVEC 0x10000000 /* SIMD/Vector Unit. */ #define PPC_FEATURE_HAS_FPU 0x08000000 /* Floating Point Unit. */ #define PPC_FEATURE_HAS_MMU 0x04000000 /* Memory Management Unit. */ #define PPC_FEATURE_HAS_4xxMAC 0x02000000 /* 4xx Multiply Accumulator. */ #define PPC_FEATURE_UNIFIED_CACHE 0x01000000 /* Unified I/D cache. */ #define PPC_FEATURE_HAS_SPE 0x00800000 /* Signal Processing ext. */ #define PPC_FEATURE_HAS_EFP_SINGLE 0x00400000 /* SPE Float. */ #define PPC_FEATURE_HAS_EFP_DOUBLE 0x00200000 /* SPE Double. */ #define PPC_FEATURE_NO_TB 0x00100000 /* 601/403gx have no timebase */ #define PPC_FEATURE_POWER4 0x00080000 /* POWER4 ISA 2.00 */ #define PPC_FEATURE_POWER5 0x00040000 /* POWER5 ISA 2.02 */ #define PPC_FEATURE_POWER5_PLUS 0x00020000 /* POWER5+ ISA 2.03 */ #define PPC_FEATURE_CELL_BE 0x00010000 /* CELL Broadband Engine */ #define PPC_FEATURE_BOOKE 0x00008000 #define PPC_FEATURE_SMT 0x00004000 /* Simultaneous Multi-Threading */ #define PPC_FEATURE_ICACHE_SNOOP 0x00002000 #define PPC_FEATURE_ARCH_2_05 0x00001000 /* ISA 2.05 */ #define PPC_FEATURE_PA6T 0x00000800 /* PA Semi 6T Core */ #define PPC_FEATURE_HAS_DFP 0x00000400 /* Decimal FP Unit */ #define PPC_FEATURE_POWER6_EXT 0x00000200 /* P6 + mffgpr/mftgpr */ #define PPC_FEATURE_HAS_VSX 0x00000100 /* P7 Vector Extension. */ #define PPC_FEATURE_ARCH_2_06 0x00000080 /* ISA 2.06 */ #define PPC_FEATURE_970 (PPC_FEATURE_POWER4 + PPC_FEATURE_HAS_ALTIVEC) #ifdef __ASSEMBLER__ /* Symbolic names for the registers. The only portable way to write asm code is to use number but this produces really unreadable code. Therefore these symbolic names. */ /* Integer registers. */ #define r0 0 #define r1 1 #define r2 2 #define r3 3 #define r4 4 #define r5 5 #define r6 6 #define r7 7 #define r8 8 #define r9 9 #define r10 10 #define r11 11 #define r12 12 #define r13 13 #define r14 14 #define r15 15 #define r16 16 #define r17 17 #define r18 18 #define r19 19 #define r20 20 #define r21 21 #define r22 22 #define r23 23 #define r24 24 #define r25 25 #define r26 26 #define r27 27 #define r28 28 #define r29 29 #define r30 30 #define r31 31 /* Floating-point registers. */ #define fp0 0 #define fp1 1 #define fp2 2 #define fp3 3 #define fp4 4 #define fp5 5 #define fp6 6 #define fp7 7 #define fp8 8 #define fp9 9 #define fp10 10 #define fp11 11 #define fp12 12 #define fp13 13 #define fp14 14 #define fp15 15 #define fp16 16 #define fp17 17 #define fp18 18 #define fp19 19 #define fp20 20 #define fp21 21 #define fp22 22 #define fp23 23 #define fp24 24 #define fp25 25 #define fp26 26 #define fp27 27 #define fp28 28 #define fp29 29 #define fp30 30 #define fp31 31 /* Condition code registers. */ #define cr0 0 #define cr1 1 #define cr2 2 #define cr3 3 #define cr4 4 #define cr5 5 #define cr6 6 #define cr7 7 /* Vector registers. */ #define v0 0 #define v1 1 #define v2 2 #define v3 3 #define v4 4 #define v5 5 #define v6 6 #define v7 7 #define v8 8 #define v9 9 #define v10 10 #define v11 11 #define v12 12 #define v13 13 #define v14 14 #define v15 15 #define v16 16 #define v17 17 #define v18 18 #define v19 19 #define v20 20 #define v21 21 #define v22 22 #define v23 23 #define v24 24 #define v25 25 #define v26 26 #define v27 27 #define v28 28 #define v29 29 #define v30 30 #define v31 31 #define VRSAVE 256 #ifdef __ELF__ /* This seems to always be the case on PPC. */ #define ALIGNARG(log2) log2 /* For ELF we need the `.type' directive to make shared libs work right. */ #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg; #define ASM_SIZE_DIRECTIVE(name) .size name,.-name #endif /* __ELF__ */ #endif /* __ASSEMBLER__ */ libdfp-1.0.12/sysdeps/s390/000077500000000000000000000000001261375163000152275ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/s390/dfpu/000077500000000000000000000000001261375163000161655ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/s390/dfpu/fe_decround.c000066400000000000000000000040771261375163000206160ustar00rootroot00000000000000/* Return current rounding direction. Copyright (C) 2000-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include #include /* Based on the binary floating point variants contributed by Denis Joseph Barrow (djbarrow@de.ibm.com). */ int __fe_dec_getround (void) { fexcept_t cw; _FPU_GETCW (cw); return (cw & FPC_DFP_RM_MASK) >> 4; } strong_alias(__fe_dec_getround, fe_dec_getround) hidden_def(__fe_dec_getround) int __fe_dec_setround (int round) { /* This currently also allows the extended rounding modes (5, 6 and 7) which are not covered by the standard. Please see fe_decround.c in the root dir for more information. */ if (((round << 4) | FPC_DFP_RM_MASK) != FPC_DFP_RM_MASK) { /* ROUND is not a valid rounding mode. */ return 1; } __asm__ volatile ("llgfr %0,%0 \n\t" "srnmt 0(%0)" : "+a" (round)); return 0; } strong_alias(__fe_dec_setround, fe_dec_setround) hidden_def(__fe_dec_setround) extern int (*__printf_dfp_getround_callback)(void); static void __attribute__ ((constructor))__init_printf_dfp_getround (void) { __printf_dfp_getround_callback = &__fe_dec_getround; } libdfp-1.0.12/sysdeps/s390/dfpu/numdigits.h000066400000000000000000000100561261375163000203430ustar00rootroot00000000000000/* Number of digits functions, optimized for S/390 z9-ec. Copyright (C) 2008 IBM Corporation. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ /* Alow this file to be included more than once, so don't use the usual include guards. */ #define NUMDIGITS_SUPPORT 1 #ifndef DEC_TYPE #error DEC_TYPE must be declared #endif #ifndef _DECIMAL_SIZE #error _DECIMAL_SIZE must be declared #endif #include "dpd-private.h" #if _DECIMAL_SIZE == 32 // DECIMAL32 gets widened to DECIMAL64, so it ought to use DECIMAL64 bias # define DECIMAL_BIAS (101+297) #elif _DECIMAL_SIZE == 64 # define DECIMAL_BIAS 398 #elif _DECIMAL_SIZE == 128 # define DECIMAL_BIAS 6176 #endif #ifndef PASTE # define PASTE(x,y) PASTE2(x,y) # define PASTE2(x,y) x##y #endif #ifndef FUNC_D # define FUNC_D(x) PASTE(x,PASTE(d,_DECIMAL_SIZE)) #endif static inline int FUNC_D (getexp) (DEC_TYPE x) { int result; #if _DECIMAL_SIZE == 32 _Decimal64 tmp = (_Decimal64)x; #elif _DECIMAL_SIZE == 64 _Decimal64 tmp = x; #elif _DECIMAL_SIZE == 128 register _Decimal128 tmp asm ("f0") = x; #endif asm ( #if _DECIMAL_SIZE == 128 "eextr %0,%1" #else /* 32 and 64 bit */ "eedtr %0,%1" #endif : "=d"(result) : "f"(tmp)); return result - DECIMAL_BIAS; } static inline DEC_TYPE FUNC_D (setexp) (DEC_TYPE x, int exp) { int biased_exp = exp + DECIMAL_BIAS; #if _DECIMAL_SIZE == 32 _Decimal64 tmp = (_Decimal64)x; #elif _DECIMAL_SIZE == 128 register DEC_TYPE tmp asm ("f0") = x; #else DEC_TYPE tmp = x; #endif asm ( "llgfr %1,%1 \n\t" #if _DECIMAL_SIZE == 128 "iextr %0,%0,%1" #else "iedtr %0,%0,%1" #endif : "+f" (tmp), "+d" (biased_exp)); #if _DECIMAL_SIZE == 32 return (_Decimal32)tmp; #else return tmp; #endif } static inline int FUNC_D (numdigits) (DEC_TYPE x) { int result; #if _DECIMAL_SIZE == 128 register DEC_TYPE tmp asm ("f0") = x; #elif _DECIMAL_SIZE == 32 _Decimal64 tmp = (_Decimal64)x; #else DEC_TYPE tmp = x; #endif asm ( #if _DECIMAL_SIZE == 128 "esxtr %0,%1" #else /* 32 and 64 bit */ "esdtr %0,%1" #endif : "=d"(result) : "f"(tmp)); /* The Power hardware implementation returns 1 even for a zero mantissa. The software implementation in soft-dfp mimics that behaviour. The S/390 instructions return 0 for zero values. So we have to adjust this here in order to match the behaviour of the existing functions. */ return (result == 0 ? 1 : result); } static DEC_TYPE FUNC_D (left_justify) (DEC_TYPE x) { #if _DECIMAL_SIZE == 128 register DEC_TYPE tmp asm ("f0") = x; register DEC_TYPE rnd asm ("f4"); #elif _DECIMAL_SIZE == 64 DEC_TYPE tmp = x; DEC_TYPE rnd; #else _Decimal64 tmp = (_Decimal64)x; _Decimal64 rnd; #endif int exp; asm ("rrdtr %0,%2,%3,1\n\t" "eedtr %1,%0\n\t" /* The following magic numbers result from the precision of the data type minus 1. */ #if _DECIMAL_SIZE == 32 "ahi %1,-6\n\t" #elif _DECIMAL_SIZE == 64 "ahi %1,-15\n\t" #else /* _DECIMAL_SIZE == 128 */ "ahi %1,-33\n\t" #endif "iedtr %0,%0,%1\n\t" "qadtr %0,%2,%0,1" : "=f"(rnd), "=d"(exp), "+f"(tmp) : "d"(1)); #if _DECIMAL_SIZE == 32 return (_Decimal32)rnd; #else return rnd; #endif } libdfp-1.0.12/sysdeps/s390/fpu/000077500000000000000000000000001261375163000160215ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/s390/fpu/fenv_libdfp.h000066400000000000000000000032341261375163000204520ustar00rootroot00000000000000/* s390 fenv macros. Copyright (C) 2000-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Andreas Krebbel The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _FENV_LIBDFP_H #define _FENV_LIBDFP_H 1 /* Based on the binary floating point variants contributed by Denis Joseph Barrow (djbarrow@de.ibm.com). */ #include /* Definitions from asm/s390-regs-common.h that are needed in glibc. */ #define FPC_EXCEPTION_MASK 0xF8000000 #define FPC_FLAGS_MASK 0x00F80000 #define FPC_DXC_MASK 0x0000FF00 #define FPC_RM_MASK 0x00000003 #define FPC_DFP_RM_MASK 0x00000070 #define FPC_VALID_MASK ((FPC_EXCEPTION_MASK|FPC_FLAGS_MASK| \ FPC_DXC_MASK|FPC_BFP_RM_MASK|FPC_DFP_RM_MASK)) #define FPC_EXCEPTION_MASK_SHIFT 24 #define FPC_FLAGS_SHIFT 16 #define FPC_DXC_SHIFT 8 #define FPC_NOT_FPU_EXCEPTION 0x300 #endif /* _FENV_LIBDFP_H */ libdfp-1.0.12/sysdeps/soft-dfp/000077500000000000000000000000001261375163000162535ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/soft-dfp/Makefile000066400000000000000000000001701261375163000177110ustar00rootroot00000000000000# base-math/Makefile defines all of the arithmetic, conversion, and comparison # functions. libdfp_files += decroundtls libdfp-1.0.12/sysdeps/soft-dfp/README000066400000000000000000000012311261375163000171300ustar00rootroot00000000000000This directory is for anything that is soft-dfp specific, like rounding mode. This directory also contains software emulated implementations of the arithmetic, conversion, and classification routines. These are normally provided by libgcc but that library lacks floating point exception and rounding mode support so we provide an override here. The __dpd_ and __bid_ prefixed symbols are added to the 'Versions' scripts in the dpd/ and bid/ directories respectively. The Makefile only contains the files which aren't part of the base-math/ emulation, i.e. the binary->decimal and decimal->binary 'extend' and 'trunc' functions. Everything else is an override. libdfp-1.0.12/sysdeps/soft-dfp/Versions000066400000000000000000000001151261375163000200030ustar00rootroot00000000000000libdfp { LIBDFP_PRIVATE { __decrm_location; } LIBDFP_1.0.0 { } } libdfp-1.0.12/sysdeps/soft-dfp/adddd3.c000066400000000000000000000021651261375163000175460ustar00rootroot00000000000000/* _Decimal64 addition for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #define ACTUAL_FUNCTION_NAME adddd3 #include #include "addsd3.c" libdfp-1.0.12/sysdeps/soft-dfp/addsd3.c000066400000000000000000000043461261375163000175700ustar00rootroot00000000000000/* _Decimal32 addition for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 # define ACTUAL_FUNCTION_NAME addsd3 #endif #include #include #include #define FUNCTION_NAME add #include #include "dfpacc.h" DEC_TYPE PREFIXED_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { DEC_TYPE result; decNumber dn_x, dn_y, dn_result; decContext context; decContextDefault(&context, DEFAULT_CONTEXT); FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&y, &dn_y); decNumberAdd(&dn_result, &dn_x, &dn_y, &context); if (context.status != 0) { int ieee_flags = 0; if (context.status & DEC_IEEE_854_Division_by_zero) ieee_flags |= FE_DIVBYZERO; if (context.status & DEC_IEEE_854_Inexact) ieee_flags |= FE_INEXACT; if (context.status & DEC_IEEE_854_Invalid_operation) ieee_flags |= FE_INVALID; if (context.status & DEC_IEEE_854_Overflow) ieee_flags |= FE_OVERFLOW; if (context.status & DEC_IEEE_854_Underflow) ieee_flags |= FE_UNDERFLOW; if (ieee_flags != 0) feraiseexcept (ieee_flags); } FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/sysdeps/soft-dfp/addtd3.c000066400000000000000000000021701261375163000175620ustar00rootroot00000000000000/* _Decimal128 addition for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #define ACTUAL_FUNCTION_NAME addtd3 #include #include "addsd3.c" libdfp-1.0.12/sysdeps/soft-dfp/bid/000077500000000000000000000000001261375163000170115ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/soft-dfp/bid/Makefile000066400000000000000000000020011261375163000204420ustar00rootroot00000000000000# Copyright (C) 2015 Free Software Foundation, Inc. # # This file is part of the Decimal Floating Point C Library. # # The Decimal Floating Point C Library is free software; you can # redistribute it and/or modify it under the terms of the GNU Lesser # General Public License version 2.1. # # The Decimal Floating Point C Library is distributed in the hope that # it will be useful, but WITHOUT ANY WARRANTY; without even the implied # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See # the GNU Lesser General Public License version 2.1 for more details. # # You should have received a copy of the GNU Lesser General Public # License version 2.1 along with the Decimal Floating Point C Library; # if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA. # # Please see libdfp/COPYING.txt for more information. */ # Empty Makefile so that Versions file is picked up by the build machinery # only searches for Versions files where it finds Makefiles. libdfp-1.0.12/sysdeps/soft-dfp/bid/Versions000066400000000000000000000005631261375163000205500ustar00rootroot00000000000000libdfp { LIBDFP_1.0.0 { __bid_extendsfsd; __bid_extendsddf; __bid_extendsdtf; __bid_extendsfdd; __bid_extenddfdd; __bid_extendddtf; __bid_extendsftd; __bid_extenddftd; __bid_extendtftd; __bid_truncsdsf; __bid_truncdfsd; __bid_trunctfsd; __bid_truncddsf; __bid_truncdddf; __bid_trunctfdd; __bid_trunctdsf; __bid_trunctddf; __bid_trunctdtf; } } libdfp-1.0.12/sysdeps/soft-dfp/bid/numdigits.h000066400000000000000000000247301261375163000211730ustar00rootroot00000000000000/* Number of digits functions. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #define NUMDIGITS_SUPPORT 1 /* NOTE: Little-Endian support only so far. */ #ifndef _BID_NUMDIGITS_H # define _BID_NUMDIGITS_H #include #include #include #include #include #define BID_SIG_MASK 0x80000000u #define BID_EXPONENT_ENC_MASK 0x60000000u #define BID_EXP_SHIFT_LARGE32 21 #define BID_EXP_SHIFT_SMALL32 23 #define BID_EXP_MASK32 0xffu #define BID_EXP_SHIFT_LARGE64 19 #define BID_EXP_SHIFT_SMALL64 21 #define BID_EXP_MASK64 0x3ffu #define BID_EXP_SHIFT_LARGE128 15 #define BID_EXP_SHIFT_SMALL128 17 #define BID_EXP_MASK128 0x3fffu static inline int getexpd32 (_Decimal32 x) { unsigned int hi; unsigned int shift; union ieee754r_Decimal32 d; d.sd = x; hi = d.si; if ((hi & BID_EXPONENT_ENC_MASK) == BID_EXPONENT_ENC_MASK) shift = BID_EXP_SHIFT_LARGE32; else shift = BID_EXP_SHIFT_SMALL32; return ((hi >> shift) & BID_EXP_MASK32) - DECIMAL32_Bias; } static inline int getexpd64 (_Decimal64 x) { unsigned int hi; unsigned int shift; union ieee754r_Decimal64 d; d.dd = x; hi = d.di[1]; if ((hi & BID_EXPONENT_ENC_MASK) == BID_EXPONENT_ENC_MASK) shift = BID_EXP_SHIFT_LARGE64; else shift = BID_EXP_SHIFT_SMALL64; return ((hi >> shift) & BID_EXP_MASK64) - DECIMAL64_Bias; } static inline int getexpd128 (_Decimal128 x) { unsigned int hi; unsigned int shift; union ieee754r_Decimal128 d; d.td = x; hi = d.ti[3]; if ((hi & BID_EXPONENT_ENC_MASK) == BID_EXPONENT_ENC_MASK) shift = BID_EXP_SHIFT_LARGE128; else shift = BID_EXP_SHIFT_SMALL128; return (int)((hi >> shift) & BID_EXP_MASK128) - DECIMAL128_Bias; } static inline _Decimal32 setexpd32 (_Decimal32 x, int exp) { unsigned int shift, large; union ieee754r_Decimal32 d; d.sd = x; large = (d.si & BID_EXPONENT_ENC_MASK) == BID_EXPONENT_ENC_MASK; if (large) shift = BID_EXP_SHIFT_LARGE32; else shift = BID_EXP_SHIFT_SMALL32; d.si &= ~((BID_EXP_MASK32) << shift); d.si |= ((exp + DECIMAL32_Bias) & BID_EXP_MASK32) << shift; /* Verify if a small number did not overflow. */ if (d.divided.c == 3 && !large) d.si = 0x7c000000; return d.sd; } static inline _Decimal64 setexpd64 (_Decimal64 x, int exp) { unsigned int shift, large; union ieee754r_Decimal64 d; d.dd = x; large = (d.di[1] & BID_EXPONENT_ENC_MASK) == BID_EXPONENT_ENC_MASK; if (large) shift = BID_EXP_SHIFT_LARGE64; else shift = BID_EXP_SHIFT_SMALL64; d.di[1] &= ~((BID_EXP_MASK64) << shift); d.di[1] |= ((exp + DECIMAL64_Bias) & BID_EXP_MASK64) << shift; /* Verify if a small number did not overflow. */ if (d.divided.c == 3 && !large) { d.di[0] = 0x0; d.di[1] = 0x7c000000; } return d.dd; } static inline _Decimal128 setexpd128 (_Decimal128 x, int exp) { unsigned int shift, large; union ieee754r_Decimal128 d; d.td = x; large = (d.ti[3] & BID_EXPONENT_ENC_MASK) == BID_EXPONENT_ENC_MASK; if (large) shift = BID_EXP_SHIFT_LARGE128; else shift = BID_EXP_SHIFT_SMALL128; d.ti[3] &= ~((BID_EXP_MASK128) << shift); d.ti[3] |= ((exp + DECIMAL128_Bias) & BID_EXP_MASK128) << shift; /* Verify if a small number did not overflow. */ if (d.divided.c == 3 && !large) { d.ti[0] = 0x0; d.ti[1] = 0x0; d.ti[2] = 0x0; d.ti[3] = 0x7c000000; } return d.td; } static inline int numdigitsd32 (_Decimal32 x) { int firstdigit = 0; int len = 0; char digits[NDIGITS_32] = { 0 }; __get_digits_d32 (x, digits, NULL, NULL, NULL, NULL); while (digits[firstdigit] == '0') firstdigit++; len = strlen (digits + firstdigit); /* Hardware DFP always returns 1 digit if the mantissa is zero. We should * do the same. */ return (len == 0 ? 1 : len); } static inline int numdigitsd64 (_Decimal64 x) { int firstdigit = 0; int len = 0; char digits[NDIGITS_64] = { 0 }; __get_digits_d64 (x, digits, NULL, NULL, NULL, NULL); while (digits[firstdigit] == '0') firstdigit++; len = strlen (digits + firstdigit); /* Hardware DFP always returns 1 digit if the mantissa is zero. We should * do the same. */ return (len == 0 ? 1 : len); } static inline int numdigitsd128 (_Decimal128 x) { int firstdigit = 0; int len = 0; char digits[NDIGITS_128] = { 0 }; __get_digits_d128 (x, digits, NULL, NULL, NULL, NULL); while (digits[firstdigit] == '0') firstdigit++; len = strlen (digits + firstdigit); /* Hardware DFP always returns 1 digit if the mantissa is zero. We should * do the same. */ return (len == 0 ? 1 : len); } static inline int __bid_required_bits_32 (unsigned long int value) { return value == 0 ? 0 : (32 - __builtin_clz (value)); } static inline _Decimal32 setdigitsd32 (_Decimal32 x, char *str) { unsigned long int number; union ieee754r_Decimal32 d; unsigned int sign; int exp; d.sd = x; number = strtol (str, NULL, 10); exp = getexpd32 (x); sign = (d.si & BID_SIG_MASK); if (__bid_required_bits_32 (number) <= 23) d.si = sign | (number & 0x807FFFFFU); else d.si = sign | (0x60800000U | (number & 0x001FFFFFU)); d.sd = setexpd32 (d.sd, exp); return d.sd; } static inline int __bid_required_bits_64 (unsigned long long int value) { return (value == 0ULL ? 0 : 64 - __builtin_clzll (value)); } static inline _Decimal64 setdigitsd64 (_Decimal64 x, char *str) { unsigned long long int number; union ieee754r_Decimal64 d; unsigned int sign; int exp; d.dd = x; number = strtoll (str, NULL, 10); exp = getexpd64 (x); sign = (d.di[1] & BID_SIG_MASK); if (__bid_required_bits_64 (number) <= 53) d.di[1] = sign | ((number >> 32L) & 0x001FFFFFU); else d.di[1] = (sign | (0x60040000U) | ((number >> 32L) & 0x0007FFFFU)); d.di[0] = number & 0xFFFFFFFFU; d.dd = setexpd64 (d.dd, exp); return d.dd; } static inline int __bid_required_bits_128 (u128_t value) { /* Use 64-bits operations to keep it simple, another solution would * be to construct a lookup table for int128. */ uint64_t hi; int ret; hi = u128_hi (value); if ((ret = __bid_required_bits_64 (hi)) == 0) { uint64_t lo = u128_lo (value); return __bid_required_bits_64 (lo); } return ret + 64; } static inline _Decimal128 setdigitsd128 (_Decimal128 x, char *str) { u128_t number; union ieee754r_Decimal128 d; unsigned int sign; int exp; d.td = x; u128_init_from_str (number, str); exp = getexpd128 (x); sign = (d.ti[3] & BID_SIG_MASK); if (__bid_required_bits_128 (number) <= 113) d.ti[3] = sign | (u128_hi(number) & 0x0001FFFF); else d.ti[3] = sign | (0x60020000U | (u128_hi(number) & 0x00007FFFU)); d.ti[2] = u128_mh(number); d.ti[1] = u128_ml(number); d.ti[0] = u128_lo(number); d.td = setexpd128 (d.td, exp); return d.td; } static inline _Decimal32 left_justifyd32 (_Decimal32 x) { int firstdigit = 0, len; char digits[NDIGITS_32+NDIGITS_32-1] = { 0 }; __get_digits_d32 (x, digits, NULL, NULL, NULL, NULL); while (digits[firstdigit] == '0') firstdigit++; len = strlen (digits + firstdigit); if (len) { int exp = getexpd32 (x); /* pad the significant digits with enough trailing zeroes */ if ((exp - firstdigit) < -DECIMAL32_Bias) { firstdigit = DECIMAL32_Bias + exp; /* If the number overflows the data it will become a NaN1. */ if ((exp - firstdigit) <= -DECIMAL32_Bias && firstdigit != 0) { union ieee754r_Decimal32 mask = { .si = 0x7c000001 }; return mask.sd; } } if (firstdigit) memset (digits + firstdigit + len, '0', firstdigit); x = setdigitsd32 (x, digits + firstdigit); x = setexpd32 (x, exp - firstdigit); } return x; } static inline _Decimal64 left_justifyd64 (_Decimal64 x) { int firstdigit = 0, len; char digits[NDIGITS_64+NDIGITS_64-1] = { 0 }; __get_digits_d64 (x, digits, NULL, NULL, NULL, NULL); while (digits[firstdigit] == '0') firstdigit++; len = strlen (digits + firstdigit); if (len) { int exp = getexpd64 (x); /* pad the significant digits with enough trailing zeroes */ if ((exp - firstdigit) < -DECIMAL64_Bias) { firstdigit = DECIMAL64_Bias + exp; /* If the number overflows the data it will become a NaN1. */ if ((exp - firstdigit) <= -DECIMAL64_Bias && firstdigit != 0) { union ieee754r_Decimal64 mask = { .di = { 0x00000001, 0x7c000000 } }; return mask.dd; } } if (firstdigit) memset (digits + firstdigit + len, '0', firstdigit); x = setdigitsd64 (x, digits + firstdigit); x = setexpd64 (x, exp - firstdigit); } return x; } static inline _Decimal128 left_justifyd128 (_Decimal128 x) { int firstdigit = 0, len; char digits[NDIGITS_128+NDIGITS_128-1] = { 0 }; __get_digits_d128 (x, digits, NULL, NULL, NULL, NULL); while (digits[firstdigit] == '0') firstdigit++; len = strlen (digits + firstdigit); if (len) { int exp = getexpd128 (x); /* pad the significant digits with enough trailing zeroes */ if ((exp - firstdigit) < -DECIMAL128_Bias) { firstdigit = DECIMAL128_Bias + exp; /* If the number overflows the data it will become a NaN1. */ if ((exp - firstdigit) <= -DECIMAL128_Bias && firstdigit != 0) { union ieee754r_Decimal128 mask = { .ti = { 0x00000001, 0x0, 0x0, 0x7c000000 } }; return mask.td; } } if (firstdigit) memset(digits + firstdigit + len, '0', firstdigit); x = setdigitsd128 (x, digits + firstdigit); x = setexpd128 (x, exp - firstdigit); } return x; } #endif libdfp-1.0.12/sysdeps/soft-dfp/decroundtls.c000066400000000000000000000025031261375163000207450ustar00rootroot00000000000000/* Decimal Float Rounding Mode accessor function definition and TLS variable. Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ /*#include */ #include #include #include "decroundtls.h" __thread int __dec_round_mode __attribute__ ((tls_model ("initial-exec"))) = FE_DEC_TONEAREST; int *__decrm_location (void) { return &__dec_round_mode; } hidden_def (__decrm_location) libdfp-1.0.12/sysdeps/soft-dfp/decroundtls.h000066400000000000000000000022321261375163000207510ustar00rootroot00000000000000/* Decimal Float Rounding Mode accessor function prototype Copyright (C) 2006 IBM Corporation. Copyright (C) 2009-2015 Free Software Foundation, Inc. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #ifndef _DECROUNDTLS_ #define _DECROUNDTLS_ #include __BEGIN_DECLS extern int * __decrm_location (void); hidden_proto (__decrm_location) __END_DECLS #endif /* _DECROUNDTLS_ */ libdfp-1.0.12/sysdeps/soft-dfp/divdd3.c000066400000000000000000000021651261375163000176000ustar00rootroot00000000000000/* _Decimal64 division for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #define ACTUAL_FUNCTION_NAME divdd3 #include #include "divsd3.c" libdfp-1.0.12/sysdeps/soft-dfp/divsd3.c000066400000000000000000000043501261375163000176150ustar00rootroot00000000000000/* _Decimal32 division for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 # define ACTUAL_FUNCTION_NAME divsd3 #endif #include #include #include #define FUNCTION_NAME div #include #include "dfpacc.h" DEC_TYPE PREFIXED_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { DEC_TYPE result; decNumber dn_x, dn_y, dn_result; decContext context; decContextDefault(&context, DEFAULT_CONTEXT); FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&y, &dn_y); decNumberDivide(&dn_result, &dn_x, &dn_y, &context); if (context.status != 0) { int ieee_flags = 0; if (context.status & DEC_IEEE_854_Division_by_zero) ieee_flags |= FE_DIVBYZERO; if (context.status & DEC_IEEE_854_Inexact) ieee_flags |= FE_INEXACT; if (context.status & DEC_IEEE_854_Invalid_operation) ieee_flags |= FE_INVALID; if (context.status & DEC_IEEE_854_Overflow) ieee_flags |= FE_OVERFLOW; if (context.status & DEC_IEEE_854_Underflow) ieee_flags |= FE_UNDERFLOW; if (ieee_flags != 0) feraiseexcept (ieee_flags); } FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/sysdeps/soft-dfp/divtd3.c000066400000000000000000000021701261375163000176140ustar00rootroot00000000000000/* _Decimal128 division for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #define ACTUAL_FUNCTION_NAME divtd3 #include #include "divsd3.c" libdfp-1.0.12/sysdeps/soft-dfp/dpd/000077500000000000000000000000001261375163000170225ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/soft-dfp/dpd/Makefile000066400000000000000000000020011261375163000204530ustar00rootroot00000000000000# Copyright (C) 2015 Free Software Foundation, Inc. # # This file is part of the Decimal Floating Point C Library. # # The Decimal Floating Point C Library is free software; you can # redistribute it and/or modify it under the terms of the GNU Lesser # General Public License version 2.1. # # The Decimal Floating Point C Library is distributed in the hope that # it will be useful, but WITHOUT ANY WARRANTY; without even the implied # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See # the GNU Lesser General Public License version 2.1 for more details. # # You should have received a copy of the GNU Lesser General Public # License version 2.1 along with the Decimal Floating Point C Library; # if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA. # # Please see libdfp/COPYING.txt for more information. */ # Empty Makefile so that Versions file is picked up by the build machinery # only searches for Versions files where it finds Makefiles. libdfp-1.0.12/sysdeps/soft-dfp/dpd/Versions000066400000000000000000000000001261375163000205430ustar00rootroot00000000000000libdfp-1.0.12/sysdeps/soft-dfp/dpd/numdigits.h000066400000000000000000000160111261375163000211750ustar00rootroot00000000000000/* Number of digits functions. Copyright (C) 2006, 2007, 2008 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ /* Allow this file to be included more than once, so don't use the usual include guards. */ #define NUMDIGITS_SUPPORT 1 #ifndef DEC_TYPE #error DEC_TYPE must be declared #endif #ifndef _DECIMAL_SIZE #error _DECIMAL_SIZE must be declared #endif #include "dpd-private.h" #include #include #ifndef PASTE # define PASTE(x,y) PASTE2(x,y) # define PASTE2(x,y) x##y #endif #ifndef FUNC_D # define FUNC_D(x) PASTE(x,PASTE(d,_DECIMAL_SIZE)) #endif static inline int FUNC_D (getexp) (DEC_TYPE x) { int exp; struct ieee754r_c_field c_f; #undef DECIMAL_BIAS #undef DECIMAL_DEC_BITS #if _DECIMAL_SIZE == 32 union ieee754r_Decimal32 d; d.sd = x; # define DECIMAL_BIAS DECIMAL32_Bias # define DECIMAL_DEC_BITS DECIMAL32_BEC_bits #elif _DECIMAL_SIZE == 64 union ieee754r_Decimal64 d; d.dd = x; # define DECIMAL_BIAS DECIMAL64_Bias # define DECIMAL_DEC_BITS DECIMAL64_BEC_bits #elif _DECIMAL_SIZE == 128 union ieee754r_Decimal128 d; d.td = x; # define DECIMAL_BIAS DECIMAL128_Bias # define DECIMAL_DEC_BITS DECIMAL128_BEC_bits #endif c_f = c_decoder[d.ieee.c]; /* PowerPC dxex instruction returns -1 for infinity and -2 for NaN. */ if (c_f.is_inf) return -1 - DECIMAL_BIAS; else if (c_f.is_nan) return -2 - DECIMAL_BIAS; exp = c_f.lm_exp << DECIMAL_DEC_BITS; exp += d.ieee.bec; exp -= DECIMAL_BIAS; return exp; } #define SETEXP_NAME PASTE(setexp,PASTE(d,_DECIMAL_SIZE)) static inline DEC_TYPE SETEXP_NAME (DEC_TYPE x, int exp) { #if _DECIMAL_SIZE == 32 union ieee754r_Decimal32 d; d.sd = x; exp += DECIMAL32_Bias; d.ieee.bec = exp; d.ieee.c = lm2lmd_to_c[c_decoder[d.ieee.c].lmd][exp >> DECIMAL32_BEC_bits]; return d.sd; #elif _DECIMAL_SIZE == 64 union ieee754r_Decimal64 d; d.dd = x; exp += DECIMAL64_Bias; d.ieee.bec = exp; d.ieee.c = lm2lmd_to_c[c_decoder[d.ieee.c].lmd][exp >> DECIMAL64_BEC_bits]; return d.dd; #elif _DECIMAL_SIZE == 128 union ieee754r_Decimal128 d; d.td = x; exp += DECIMAL128_Bias; d.ieee.bec = exp; d.ieee.c = lm2lmd_to_c[c_decoder[d.ieee.c].lmd][exp >> DECIMAL128_BEC_bits]; return d.td; #endif } static inline DEC_TYPE FUNC_D (setdigits) (DEC_TYPE x, char *str) { #if _DECIMAL_SIZE == 32 union ieee754r_Decimal32 d; d.sd = x; d.ieee.c = lm2lmd_to_c[str[0]-'0'][c_decoder[d.ieee.c].lm_exp]; d.ieee.cc0 = __dfp_declet_to_dpd(str+1); d.ieee.cc1 = __dfp_declet_to_dpd(str+4); return d.sd; #elif _DECIMAL_SIZE == 64 unsigned int bcd; union ieee754r_Decimal64 d; d.dd = x; d.ieee.c = lm2lmd_to_c[str[0]-'0'][c_decoder[d.ieee.c].lm_exp]; d.ieee.cc0 = __dfp_declet_to_dpd(str+1); /* Packed fields crossing a word boundary require special handling. */ bcd = __dfp_declet_to_dpd(str+4); d.ieee.cc1H8 = bcd>>2; d.ieee.cc1L2 = bcd; d.ieee.cc2 = __dfp_declet_to_dpd(str+7); d.ieee.cc3 = __dfp_declet_to_dpd(str+10); d.ieee.cc4 = __dfp_declet_to_dpd(str+13); return d.dd; #elif _DECIMAL_SIZE == 128 unsigned int bcd; union ieee754r_Decimal128 d; d.td = x; d.ieee.c = lm2lmd_to_c[str[0]-'0'][c_decoder[d.ieee.c].lm_exp]; d.ieee.cc0 = __dfp_declet_to_dpd(str+1); /* Packed fields crossing a word boundary require special handling. */ bcd = __dfp_declet_to_dpd(str+4); d.ieee.cc1H4 = bcd>>6; d.ieee.cc1L6 = bcd; d.ieee.cc2 = __dfp_declet_to_dpd(str+7); d.ieee.cc3 = __dfp_declet_to_dpd(str+10); bcd = __dfp_declet_to_dpd(str+13); d.ieee.cc4H6 = bcd>>4; d.ieee.cc4L4 = bcd; d.ieee.cc5 = __dfp_declet_to_dpd(str+16); d.ieee.cc6 = __dfp_declet_to_dpd(str+19); bcd = __dfp_declet_to_dpd(str+22); d.ieee.cc7H8 = bcd>>2; d.ieee.cc7L2 = bcd; d.ieee.cc8 = __dfp_declet_to_dpd(str+25); d.ieee.cc9 = __dfp_declet_to_dpd(str+28); d.ieee.cc10 = __dfp_declet_to_dpd(str+31); return d.td; #endif } static inline int FUNC_D (numdigits) (DEC_TYPE x) { int firstdigit = 0; int len = 0; #if _DECIMAL_SIZE == 32 char digits[NDIGITS_32]; __get_digits_d32(x, digits, NULL, NULL, NULL, NULL); #elif _DECIMAL_SIZE == 64 char digits[NDIGITS_64]; __get_digits_d64(x, digits, NULL, NULL, NULL, NULL); #elif _DECIMAL_SIZE == 128 char digits[NDIGITS_128]; __get_digits_d128(x, digits, NULL, NULL, NULL, NULL); #endif while (digits[firstdigit] == '0') firstdigit++; len = strlen(digits + firstdigit); /* Hardware DFP always returns 1 digit if the mantissa is zero. We should * do the same. */ return (len == 0 ? 1 : len); } static inline DEC_TYPE FUNC_D (left_justify) (DEC_TYPE x) { int firstdigit = 0, len; #undef decfield #if _DECIMAL_SIZE == 32 # define decfield sd union ieee754r_Decimal32 mask = { .si = 0x7c000001 }; char digits[NDIGITS_32+NDIGITS_32-1]; __get_digits_d32(x, digits, NULL, NULL, NULL, NULL); #elif _DECIMAL_SIZE == 64 # define decfield dd union ieee754r_Decimal64 mask = { .di = { # if __BYTE_ORDER == __LITTLE_ENDIAN 0x00000001, 0x7c000000 # else 0x7c000000, 0x00000001 #endif } }; char digits[NDIGITS_64+NDIGITS_64-1]; __get_digits_d64(x, digits, NULL, NULL, NULL, NULL); #elif _DECIMAL_SIZE == 128 # define decfield td union ieee754r_Decimal128 mask = { .ti = { # if __BYTE_ORDER == __LITTLE_ENDIAN 0x00000001, 0x0, 0x0, 0x7c000000 } }; # else 0x7c000000, 0x0, 0x0, 0x00000001 } }; #endif char digits[NDIGITS_128+NDIGITS_128-1]; __get_digits_d128(x, digits, NULL, NULL, NULL, NULL); #endif while (digits[firstdigit] == '0') firstdigit++; len = strlen(digits + firstdigit); if (len) { int exp = FUNC_D (getexp) (x); /* pad the significant digits with enough trailing zeroes */ if ((exp - firstdigit) < -DECIMAL_BIAS) { firstdigit = DECIMAL_BIAS + exp; /* If the number overflows the data it will become a NaN. */ if ((exp - firstdigit) <= -DECIMAL_BIAS && (firstdigit != 0)) return mask.decfield; } if (firstdigit) memset (digits + firstdigit + len, '0', firstdigit); x = FUNC_D (setdigits) (x, digits + firstdigit); x = FUNC_D(setexp) (x, FUNC_D (getexp) (x) - firstdigit); x = FUNC_D(setexp) (x, exp - firstdigit); } return x; } libdfp-1.0.12/sysdeps/soft-dfp/eqdd2.c000066400000000000000000000021731261375163000174210ustar00rootroot00000000000000/* _Decimal64 compare equality for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #define ACTUAL_FUNCTION_NAME eqdd2 #include #include "eqsd2.c" libdfp-1.0.12/sysdeps/soft-dfp/eqsd2.c000066400000000000000000000032641261375163000174420ustar00rootroot00000000000000/* _Decimal32 compare equality for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 # define ACTUAL_FUNCTION_NAME eqsd2 #endif #include #include #include #define FUNCTION_NAME eq #include #include "dfpacc.h" int PREFIXED_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decNumber dn_x, dn_y, result; decContext context; decContextDefault(&context, DEFAULT_CONTEXT); FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&y, &dn_y); if(decNumberIsNaN(&dn_x) || decNumberIsNaN(&dn_y)) return 1; decNumberCompare(&result, &dn_x, &dn_y, &context); return !decNumberIsZero(&result); } hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/sysdeps/soft-dfp/eqtd2.c000066400000000000000000000021761261375163000174440ustar00rootroot00000000000000/* _Decimal128 compare equality for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #define ACTUAL_FUNCTION_NAME eqtd2 #include #include "eqsd2.c" libdfp-1.0.12/sysdeps/soft-dfp/extendddtd2.c000066400000000000000000000022031261375163000206250ustar00rootroot00000000000000/* Handle conversion from Decimal64 to Decimal128 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_DECIMAL #define SRC 64 #define DEST 128 #define NAME extend #include "extendsddd2.c" libdfp-1.0.12/sysdeps/soft-dfp/extendsddd2.c000066400000000000000000000037241261375163000206350ustar00rootroot00000000000000/* Handle conversion from Decimal32 to Decimal64 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef DECIMAL_TO_DECIMAL #define DECIMAL_TO_DECIMAL #define SRC 32 #define DEST 64 #define NAME extend #endif #include "mapround.h" #include "dfpacc.h" #include "convert.h" DEST_TYPE PREFIXED_FUNCTION_NAME (SRC_TYPE a) { DEST_TYPE result; decNumber d; decContext context; IEEE_SRC_TYPE e; IEEE_DEST_TYPE r; decContextDefault(&context, CONTEXT_INIT); context.round = __dn_getround(); PASTE(___host_to_ieee_,SRC) ((&a), &e); PASTE(decimal,PASTE(SRC,ToNumber))(&e, &d); /* PASTE(___decimal,PASTE(SRC,ToNumber))(&a, &d); */ /* PASTE(___decimal,PASTE(DEST,FromNumber))(&result, &d, &context); */ PASTE(decimal,PASTE(DEST,FromNumber))(&r, &d, &context); PASTE(PASTE(___ieee_,DEST),_to_host) (&r, (&result)); if (context.status != 0) { int dec_flags = context.status & (DEC_IEEE_854_Inexact|DEC_IEEE_854_Invalid_operation); DFP_HANDLE_EXCEPTIONS(DFP_IEEE_FLAGS(dec_flags)); } return result; } hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/sysdeps/soft-dfp/extendsdtd2.c000066400000000000000000000022031261375163000206440ustar00rootroot00000000000000/* Handle conversion from Decimal32 to Decimal128 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_DECIMAL #define SRC 32 #define DEST 128 #define NAME extend #include "extendsddd2.c" libdfp-1.0.12/sysdeps/soft-dfp/fe_decround.c000066400000000000000000000055521261375163000207030ustar00rootroot00000000000000/* Decimal Float fe_dec_getround and fe_dec_setround definitions. Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include #include /* The default uses decimal rounding mode stored in TLS. This file should be * overridden in the sysdeps/powerpc/dfpu if hardware supports decimal * rounding mode. */ int __fe_dec_setround(int __rounding_direction) { /* Only match on supported rounding modes. The decNum library supports * additional ones that aren't valid C rounding modes. We also allow rounding * modes to be set covertly for the three additional hardware rounding modes * supported by Power6[x] that aren't in the DFP Draft Technical Report. */ /* C Rounding Mode: Hardware Description * DecNumber description * * FE_DEC_TONEAREST: 000 Round to nearest, ties to even. * DEC_ROUND_HALF_EVEN * * FE_DEC_TOWARDZERO: 001 Round toward zero. * DEC_ROUND_DOWN * * FE_DEC_UPWARD: 010 Round toward +Infinity * DEC_ROUND_CEILING * * FE_DEC_DOWNWARD: 011 Round toward -Infinity * DEC_ROUND_FLOOR * * FE_DEC_TONEARESTFROMZERO: 100 Round to nearest, ties away from zero * DEC_ROUND_HALF_UP * * 5: 101 Round to nearest, ties toward zero * DEC_ROUND_HALF_DOWN * * 6: 110 Round away from zero * DEC_ROUND_UP * * 7: 111 Round for prepare for shorter precision * Not supported by decNumber. */ if (__rounding_direction > 7) return 1; *__decrm_location() = __rounding_direction; return 0; } strong_alias(__fe_dec_setround, fe_dec_setround) hidden_def(__fe_dec_setround) int __fe_dec_getround(void) { return *__decrm_location(); } strong_alias(__fe_dec_getround, fe_dec_getround) hidden_def(__fe_dec_getround) extern int (*__printf_dfp_getround_callback)(void); static void __attribute__ ((constructor))__init_printf_dfp_getround (void) { __printf_dfp_getround_callback = &__fe_dec_getround; } libdfp-1.0.12/sysdeps/soft-dfp/fixdddi.c000066400000000000000000000022031261375163000200270ustar00rootroot00000000000000/* Handle conversion from Decimal64 to binary long (64) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_INTEGER #define SRC 64 #define DEST 64 #define NAME fix #include "fixsdsi.c" libdfp-1.0.12/sysdeps/soft-dfp/fixddsi.c000066400000000000000000000022041261375163000200470ustar00rootroot00000000000000/* Handle conversion from Decimal64 to binary integer (32) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_INTEGER #define SRC 64 #define DEST 32 #define NAME fix #include "fixsdsi.c" libdfp-1.0.12/sysdeps/soft-dfp/fixsddi.c000066400000000000000000000022011261375163000200440ustar00rootroot00000000000000/* Handle conversion from Decimal32 to binary long (64) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_INTEGER #define SRC 32 #define DEST 64 #define NAME fix #include "fixsdsi.c" libdfp-1.0.12/sysdeps/soft-dfp/fixsdsi.c000066400000000000000000000051421261375163000200720ustar00rootroot00000000000000/* Handle conversion from Decimal32 to binary integer (32) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef DECIMAL_TO_INTEGER #define DECIMAL_TO_INTEGER #define SRC 32 #define DEST 32 #define NAME fix #endif #include "dfpacc.h" #include "convert.h" #include /*#include */ #define BUFMAX 128 DEST_TYPE PREFIXED_FUNCTION_NAME (SRC_TYPE a) { /* decNumber's decimal* types have the same format as C's _Decimal* types, but they have different calling conventions. */ /* TODO: Decimal float to integer conversions should raise FE_INVALID if the result value does not fit into the result type. */ char buf[BUFMAX]; char *pos; decNumber qval, n1, n2; decContext context; IEEE_SRC_TYPE e; /* Use a large context to avoid losing precision. */ decContextDefault (&context, DEC_INIT_DECIMAL128); /* Need non-default rounding mode here. */ context.round = DEC_ROUND_DOWN; PASTE(___host_to_ieee_,SRC) ((&a), &e); PASTE(decimal,PASTE(SRC,ToNumber))(&e, &n1); /* PASTE(decimal,PASTE(SRC,ToNumber))(&a, &n1); */ /* Rescale if the exponent is less than zero. */ decNumberToIntegralValue (&n2, &n1, &context); /* Get a value to use for the quantize call. */ decNumberFromString (&qval, (char *) "1.0", &context); /* Force the exponent to zero. */ decNumberQuantize (&n1, &n2, &qval, &context); /* Get a string, which at this point will not include an exponent. */ decNumberToString (&n1, buf); /* Ignore the fractional part. */ pos = strchr (buf, '.'); if (pos) *pos = 0; /* Use a C library function to convert to the integral type. */ return STR_TO_INT (buf, NULL, 10); } hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/sysdeps/soft-dfp/fixtddi.c000066400000000000000000000022021261375163000200460ustar00rootroot00000000000000/* Handle conversion from Decimal64 to binary long (64) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_INTEGER #define SRC 128 #define DEST 64 #define NAME fix #include "fixsdsi.c" libdfp-1.0.12/sysdeps/soft-dfp/fixtdsi.c000066400000000000000000000022051261375163000200700ustar00rootroot00000000000000/* Handle conversion from Decimal64 to binary integer (32) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_INTEGER #define SRC 128 #define DEST 32 #define NAME fix #include "fixsdsi.c" libdfp-1.0.12/sysdeps/soft-dfp/fixunsdddi.c000066400000000000000000000022361261375163000205630ustar00rootroot00000000000000/* Handle conversion from Decimal64 to binary unsigned long (64) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_INTEGER #define SRC 64 #define DEST 64 #define NAME fixuns #define UNSIGNED #include "fixsdsi.c" libdfp-1.0.12/sysdeps/soft-dfp/fixunsddsi.c000066400000000000000000000022411261375163000205760ustar00rootroot00000000000000/* Handle conversion from Decimal64 to binary unsigned integer (32) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_INTEGER #define SRC 64 #define DEST 32 #define NAME fixuns #define UNSIGNED #include "fixsdsi.c" libdfp-1.0.12/sysdeps/soft-dfp/fixunssddi.c000066400000000000000000000022361261375163000206020ustar00rootroot00000000000000/* Handle conversion from Decimal32 to binary unsigned long (64) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_INTEGER #define SRC 32 #define DEST 64 #define NAME fixuns #define UNSIGNED #include "fixsdsi.c" libdfp-1.0.12/sysdeps/soft-dfp/fixunssdsi.c000066400000000000000000000022411261375163000206150ustar00rootroot00000000000000/* Handle conversion from Decimal32 to binary unsigned integer (32) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_INTEGER #define SRC 32 #define DEST 32 #define NAME fixuns #define UNSIGNED #include "fixsdsi.c" libdfp-1.0.12/sysdeps/soft-dfp/fixunstddi.c000066400000000000000000000022371261375163000206040ustar00rootroot00000000000000/* Handle conversion from Decimal64 to binary unsigned long (64) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_INTEGER #define SRC 128 #define DEST 64 #define NAME fixuns #define UNSIGNED #include "fixsdsi.c" libdfp-1.0.12/sysdeps/soft-dfp/fixunstdsi.c000066400000000000000000000022421261375163000206170ustar00rootroot00000000000000/* Handle conversion from Decimal64 to binary unsigned integer (32) Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_INTEGER #define SRC 128 #define DEST 32 #define NAME fixuns #define UNSIGNED #include "fixsdsi.c" libdfp-1.0.12/sysdeps/soft-dfp/floatdidd.c000066400000000000000000000022051261375163000203500ustar00rootroot00000000000000/* Handle conversion from binary long (64) to Decimal64 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define INTEGER_TO_DECIMAL #define SRC 64 #define DEST 64 #define NAME float #include "floatsisd.c" libdfp-1.0.12/sysdeps/soft-dfp/floatdisd.c000066400000000000000000000022051261375163000203670ustar00rootroot00000000000000/* Handle conversion from binary long (64) to Decimal32 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define INTEGER_TO_DECIMAL #define SRC 64 #define DEST 32 #define NAME float #include "floatsisd.c" libdfp-1.0.12/sysdeps/soft-dfp/floatditd.c000066400000000000000000000022071261375163000203720ustar00rootroot00000000000000/* Handle conversion from binary long (64) to Decimal128 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define INTEGER_TO_DECIMAL #define SRC 64 #define DEST 128 #define NAME float #include "floatsisd.c" libdfp-1.0.12/sysdeps/soft-dfp/floatsidd.c000066400000000000000000000022101261375163000203630ustar00rootroot00000000000000/* Handle conversion from binary integer (32) to Decimal64 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define INTEGER_TO_DECIMAL #define SRC 32 #define DEST 64 #define NAME float #include "floatsisd.c" libdfp-1.0.12/sysdeps/soft-dfp/floatsisd.c000066400000000000000000000040431261375163000204100ustar00rootroot00000000000000/* Handle conversion from binary integer (32) to Decimal32 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef INTEGER_TO_DECIMAL #define INTEGER_TO_DECIMAL #define SRC 32 #define DEST 32 #define NAME float #endif #include "dfpacc.h" #include "convert.h" #include #define BUFMAX 128 DEST_TYPE PREFIXED_FUNCTION_NAME (SRC_TYPE a) { DEST_TYPE f; char buf[BUFMAX]; decContext context; IEEE_DEST_TYPE e; decContextDefault (&context, CONTEXT_INIT); context.round = DEC_ROUND_HALF_EVEN; /* Use a C library function to get a floating point string. */ sprintf (buf, INT_FMT "", CAST_FOR_FMT(a)); /* Convert from the floating point string to a decimal* type. */ /* PASTE(___decimal,PASTE(DEST,FromString))(&f, buf, &context); */ PASTE(decimal,PASTE(DEST,FromString))(&e, buf, &context); PASTE(PASTE(___ieee_,DEST),_to_host) (&e, (&f)); if (context.status != 0) { int dec_flags = context.status & (DEC_IEEE_854_Inexact|DEC_IEEE_854_Invalid_operation|DEC_IEEE_854_Overflow); DFP_HANDLE_EXCEPTIONS(DFP_IEEE_FLAGS(dec_flags)); } return f; } hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/sysdeps/soft-dfp/floatsitd.c000066400000000000000000000022121261375163000204050ustar00rootroot00000000000000/* Handle conversion from binary integer (32) to Decimal128 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define INTEGER_TO_DECIMAL #define SRC 32 #define DEST 128 #define NAME float #include "floatsisd.c" libdfp-1.0.12/sysdeps/soft-dfp/floatunsdidd.c000066400000000000000000000022421261375163000210770ustar00rootroot00000000000000/* Handle conversion from binary unsigned long (64) to Decimal64 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define INTEGER_TO_DECIMAL #define SRC 64 #define DEST 64 #define NAME floatuns #define UNSIGNED #include "floatsisd.c" libdfp-1.0.12/sysdeps/soft-dfp/floatunsdisd.c000066400000000000000000000022421261375163000211160ustar00rootroot00000000000000/* Handle conversion from binary unsigned long (64) to Decimal32 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define INTEGER_TO_DECIMAL #define SRC 64 #define DEST 32 #define NAME floatuns #define UNSIGNED #include "floatsisd.c" libdfp-1.0.12/sysdeps/soft-dfp/floatunsditd.c000066400000000000000000000022441261375163000211210ustar00rootroot00000000000000/* Handle conversion from binary unsigned long (64) to Decimal128 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define INTEGER_TO_DECIMAL #define SRC 64 #define DEST 128 #define NAME floatuns #define UNSIGNED #include "floatsisd.c" libdfp-1.0.12/sysdeps/soft-dfp/floatunssidd.c000066400000000000000000000022451261375163000211210ustar00rootroot00000000000000/* Handle conversion from binary unsigned integer (32) to Decimal64 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define INTEGER_TO_DECIMAL #define SRC 32 #define DEST 64 #define NAME floatuns #define UNSIGNED #include "floatsisd.c" libdfp-1.0.12/sysdeps/soft-dfp/floatunssisd.c000066400000000000000000000022451261375163000211400ustar00rootroot00000000000000/* Handle conversion from binary unsigned integer (32) to Decimal32 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define INTEGER_TO_DECIMAL #define SRC 32 #define DEST 32 #define NAME floatuns #define UNSIGNED #include "floatsisd.c" libdfp-1.0.12/sysdeps/soft-dfp/floatunssitd.c000066400000000000000000000022471261375163000211430ustar00rootroot00000000000000/* Handle conversion from binary unsigned integer (32) to Decimal128 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define INTEGER_TO_DECIMAL #define SRC 32 #define DEST 128 #define NAME floatuns #define UNSIGNED #include "floatsisd.c" libdfp-1.0.12/sysdeps/soft-dfp/gedd2.c000066400000000000000000000022111261375163000174000ustar00rootroot00000000000000/* _Decimal64 compare greather-than or equal for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #define ACTUAL_FUNCTION_NAME gedd2 #include #include "gesd2.c" libdfp-1.0.12/sysdeps/soft-dfp/gesd2.c000066400000000000000000000033071261375163000174260ustar00rootroot00000000000000/* _Decimal32 compare greather-than or equal for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 # define ACTUAL_FUNCTION_NAME gesd2 #endif #include #include #include #define FUNCTION_NAME ge #include "dfpacc.h" #include int PREFIXED_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decNumber dn_x, dn_y, result; decContext context; decContextDefault(&context, DEFAULT_CONTEXT); FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&y, &dn_y); if(decNumberIsNaN(&dn_x) || decNumberIsNaN(&dn_y)) return -1; decNumberCompare(&result, &dn_x, &dn_y, &context); return -decNumberIsNegative(&result); } hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/sysdeps/soft-dfp/getd2.c000066400000000000000000000022141261375163000174230ustar00rootroot00000000000000/* _Decimal128 compare greather-than or equal for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #define ACTUAL_FUNCTION_NAME getd2 #include #include "gesd2.c" libdfp-1.0.12/sysdeps/soft-dfp/gtdd2.c000066400000000000000000000021771261375163000174320ustar00rootroot00000000000000/* _Decimal64 compare greater-than for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #define ACTUAL_FUNCTION_NAME gtdd2 #include #include "gtsd2.c" libdfp-1.0.12/sysdeps/soft-dfp/gtsd2.c000066400000000000000000000033321261375163000174430ustar00rootroot00000000000000/* _Decimal32 compare greater-than for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 # define ACTUAL_FUNCTION_NAME gtsd2 #endif #include #include #include #define FUNCTION_NAME gt #include "dfpacc.h" #include int PREFIXED_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decNumber dn_x, dn_y, result; decContext context; decContextDefault(&context, DEFAULT_CONTEXT); FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&y, &dn_y); if(decNumberIsNaN(&dn_x) || decNumberIsNaN(&dn_y)) return -1; decNumberCompare(&result, &dn_x, &dn_y, &context); return !decNumberIsNegative(&result) && !decNumberIsZero(&result); } hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/sysdeps/soft-dfp/gttd2.c000066400000000000000000000022021261375163000174370ustar00rootroot00000000000000/* _Decimal128 compare greater-than for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #define ACTUAL_FUNCTION_NAME gttd2 #include #include "gtsd2.c" libdfp-1.0.12/sysdeps/soft-dfp/ledd2.c000066400000000000000000000022051261375163000174100ustar00rootroot00000000000000/* _Decimal64 compare less-than or equal for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #define ACTUAL_FUNCTION_NAME ledd2 #include #include "lesd2.c" libdfp-1.0.12/sysdeps/soft-dfp/lesd2.c000066400000000000000000000033371261375163000174360ustar00rootroot00000000000000/* _Decimal32 compare less-than or equal for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 # define ACTUAL_FUNCTION_NAME lesd2 #endif #include #include #include #define FUNCTION_NAME le #include "dfpacc.h" #include int PREFIXED_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decNumber dn_x, dn_y, result; decContext context; decContextDefault(&context, DEFAULT_CONTEXT); FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&y, &dn_y); if(decNumberIsNaN(&dn_x) || decNumberIsNaN(&dn_y)) return 1; decNumberCompare(&result, &dn_x, &dn_y, &context); return !decNumberIsNegative(&result) && !decNumberIsZero(&result); } hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/sysdeps/soft-dfp/letd2.c000066400000000000000000000022101261375163000174240ustar00rootroot00000000000000/* _Decimal128 compare less-than or equal for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #define ACTUAL_FUNCTION_NAME letd2 #include #include "lesd2.c" libdfp-1.0.12/sysdeps/soft-dfp/libdfp-test-ulps000066400000000000000000000004011261375163000213670ustar00rootroot00000000000000# exp test exp 88.72269439697265625 decimal32 15 decimal64 13 # log test log1p 3.141592653589793238462643383279503 decimal32 1 # log10 test log10 3.141592653589793238462643383279503 decimal64 1 test log10 2.718281828459045235360287471352662 decimal128 1 libdfp-1.0.12/sysdeps/soft-dfp/ltdd2.c000066400000000000000000000021741261375163000174340ustar00rootroot00000000000000/* _Decimal64 compare less-than for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #define ACTUAL_FUNCTION_NAME ltdd2 #include #include "ltsd2.c" libdfp-1.0.12/sysdeps/soft-dfp/ltsd2.c000066400000000000000000000032711261375163000174520ustar00rootroot00000000000000/* _Decimal32 compare less-than for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 # define ACTUAL_FUNCTION_NAME ltsd2 #endif #include #include #include #define FUNCTION_NAME lt #include "dfpacc.h" #include int PREFIXED_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decNumber dn_x, dn_y, result; decContext context; decContextDefault(&context, DEFAULT_CONTEXT); FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&y, &dn_y); if(decNumberIsNaN(&dn_x) || decNumberIsNaN(&dn_y)) return 1; decNumberCompare(&result, &dn_x, &dn_y, &context); return -decNumberIsNegative(&result); } hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/sysdeps/soft-dfp/lttd2.c000066400000000000000000000021771261375163000174570ustar00rootroot00000000000000/* _Decimal128 compare less-than for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #define ACTUAL_FUNCTION_NAME lttd2 #include #include "ltsd2.c" libdfp-1.0.12/sysdeps/soft-dfp/muldd3.c000066400000000000000000000021731261375163000176120ustar00rootroot00000000000000/* _Decimal64 multiplication for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #define ACTUAL_FUNCTION_NAME muldd3 #include #include "mulsd3.c" libdfp-1.0.12/sysdeps/soft-dfp/mulsd3.c000066400000000000000000000043601261375163000176310ustar00rootroot00000000000000/* _Decimal32 multiplication for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 # define ACTUAL_FUNCTION_NAME mulsd3 #endif #include #include #include #define FUNCTION_NAME mul #include "dfpacc.h" #include DEC_TYPE PREFIXED_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { DEC_TYPE result; decNumber dn_x, dn_y, dn_result; decContext context; decContextDefault(&context, DEFAULT_CONTEXT); FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&y, &dn_y); decNumberMultiply(&dn_result, &dn_x, &dn_y, &context); if (context.status != 0) { int ieee_flags = 0; if (context.status & DEC_IEEE_854_Division_by_zero) ieee_flags |= FE_DIVBYZERO; if (context.status & DEC_IEEE_854_Inexact) ieee_flags |= FE_INEXACT; if (context.status & DEC_IEEE_854_Invalid_operation) ieee_flags |= FE_INVALID; if (context.status & DEC_IEEE_854_Overflow) ieee_flags |= FE_OVERFLOW; if (context.status & DEC_IEEE_854_Underflow) ieee_flags |= FE_UNDERFLOW; if (ieee_flags != 0) feraiseexcept (ieee_flags); } FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/sysdeps/soft-dfp/multd3.c000066400000000000000000000021761261375163000176350ustar00rootroot00000000000000/* _Decimal128 multiplication for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #define ACTUAL_FUNCTION_NAME multd3 #include #include "mulsd3.c" libdfp-1.0.12/sysdeps/soft-dfp/nedd2.c000066400000000000000000000021751261375163000174200ustar00rootroot00000000000000/* _Decimal64 compare inequality for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #define ACTUAL_FUNCTION_NAME nedd2 #include #include "nesd2.c" libdfp-1.0.12/sysdeps/soft-dfp/nesd2.c000066400000000000000000000032661261375163000174410ustar00rootroot00000000000000/* _Decimal32 compare inequality for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 # define ACTUAL_FUNCTION_NAME nesd2 #endif #include #include #include #define FUNCTION_NAME ne #include "dfpacc.h" #include int PREFIXED_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { decNumber dn_x, dn_y, result; decContext context; decContextDefault(&context, DEFAULT_CONTEXT); FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&y, &dn_y); if(decNumberIsNaN(&dn_x) || decNumberIsNaN(&dn_y)) return 1; decNumberCompare(&result, &dn_x, &dn_y, &context); return !decNumberIsZero(&result); } hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/sysdeps/soft-dfp/netd2.c000066400000000000000000000022001261375163000174250ustar00rootroot00000000000000/* _Decimal128 compare inequality for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #define ACTUAL_FUNCTION_NAME netd2 #include #include "nesd2.c" libdfp-1.0.12/sysdeps/soft-dfp/subdd3.c000066400000000000000000000021701261375163000176030ustar00rootroot00000000000000/* _Decimal64 subtraction for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #define ACTUAL_FUNCTION_NAME subdd3 #include #include "subsd3.c" libdfp-1.0.12/sysdeps/soft-dfp/subsd3.c000066400000000000000000000043551261375163000176310ustar00rootroot00000000000000/* _Decimal32 subtraction for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 # define ACTUAL_FUNCTION_NAME subsd3 #endif #include #include #include #define FUNCTION_NAME sub #include "dfpacc.h" #include DEC_TYPE PREFIXED_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { DEC_TYPE result; decNumber dn_x, dn_y, dn_result; decContext context; decContextDefault(&context, DEFAULT_CONTEXT); FUNC_CONVERT_TO_DN(&x, &dn_x); FUNC_CONVERT_TO_DN(&y, &dn_y); decNumberSubtract(&dn_result, &dn_x, &dn_y, &context); if (context.status != 0) { int ieee_flags = 0; if (context.status & DEC_IEEE_854_Division_by_zero) ieee_flags |= FE_DIVBYZERO; if (context.status & DEC_IEEE_854_Inexact) ieee_flags |= FE_INEXACT; if (context.status & DEC_IEEE_854_Invalid_operation) ieee_flags |= FE_INVALID; if (context.status & DEC_IEEE_854_Overflow) ieee_flags |= FE_OVERFLOW; if (context.status & DEC_IEEE_854_Underflow) ieee_flags |= FE_UNDERFLOW; if (ieee_flags != 0) feraiseexcept (ieee_flags); } FUNC_CONVERT_FROM_DN (&dn_result, &result, &context); return result; } hidden_def (PREFIXED_FUNCTION_NAME) libdfp-1.0.12/sysdeps/soft-dfp/subtd3.c000066400000000000000000000021731261375163000176260ustar00rootroot00000000000000/* _Decimal128 subtraction for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #define ACTUAL_FUNCTION_NAME subtd3 #include #include "subsd3.c" libdfp-1.0.12/sysdeps/soft-dfp/truncddsd2.c000066400000000000000000000022001261375163000204650ustar00rootroot00000000000000/* Handle conversion from Decimal64 to Decimal32 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_DECIMAL #define SRC 64 #define DEST 32 #define NAME trunc #include "extendsddd2.c" libdfp-1.0.12/sysdeps/soft-dfp/trunctddd2.c000066400000000000000000000022021261375163000204700ustar00rootroot00000000000000/* Handle conversion from Decimal128 to Decimal64 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_DECIMAL #define SRC 128 #define DEST 64 #define NAME trunc #include "extendsddd2.c" libdfp-1.0.12/sysdeps/soft-dfp/trunctdsd2.c000066400000000000000000000022021261375163000205070ustar00rootroot00000000000000/* Handle conversion from Decimal128 to Decimal32 Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define DECIMAL_TO_DECIMAL #define SRC 128 #define DEST 32 #define NAME trunc #include "extendsddd2.c" libdfp-1.0.12/sysdeps/soft-dfp/unorddd2.c000066400000000000000000000022021261375163000201340ustar00rootroot00000000000000/* _Decimal64 compare unordered for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 64 #define ACTUAL_FUNCTION_NAME unorddd2 #include #include "unordsd2.c" libdfp-1.0.12/sysdeps/soft-dfp/unordsd2.c000066400000000000000000000025641261375163000201660ustar00rootroot00000000000000/* _Decimal32 compare unordered for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DECIMAL_SIZE # include # define _DECIMAL_SIZE 32 # define ACTUAL_FUNCTION_NAME unordsd2 #endif #include #include #define FUNCTION_NAME unord #include "dfpacc.h" #include int PREFIXED_FUNCTION_NAME (DEC_TYPE x, DEC_TYPE y) { return FUNC_D(__isnan) (x) || FUNC_D(__isnan) (y); } libdfp-1.0.12/sysdeps/soft-dfp/unordtd2.c000066400000000000000000000022051261375163000201570ustar00rootroot00000000000000/* _Decimal128 compare unordered for soft-dfp Copyright (C) 2007, 2008 IBM Corporation. Copyright (C) 2008-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Pete Eberlein The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define _DECIMAL_SIZE 128 #define ACTUAL_FUNCTION_NAME unordtd2 #include #include "unordsd2.c" libdfp-1.0.12/tests/000077500000000000000000000000001261375163000142015ustar00rootroot00000000000000libdfp-1.0.12/tests/README000066400000000000000000000000451261375163000150600ustar00rootroot00000000000000In order to debug do the following: libdfp-1.0.12/tests/TODO000066400000000000000000000003631261375163000146730ustar00rootroot00000000000000 test-param.c: Have it automate checking the return values and use scaffold.c for outputting failure cases. use genddtbls.c to output a table and compare the results to `ddlogtbls.c'. This is a good exercise of the frexp and num-digits code. libdfp-1.0.12/tests/ceil.input000066400000000000000000000025711261375163000162030ustar00rootroot00000000000000# name ceil # arg1 decimal # ret decimal Inf Inf -Inf -Inf NaN NaN sNaN NaN 0.0 0.0 -0.0 -0.0 0.1 1.0 0.25 1.0 0.625 1.0 -0.1 -0.0 -0.25 -0.0 -0.625 -0.0 97152.5 97153.0 -97152.5 -97152.0 -370495.5 -370495.0 -370496.25 -370496.0 -370496.5 -370496.0 -370496.75 -370496.0 -370497.5 -370497.0 2097152.5 2097153.0 decimal64 decimal128 -2097152.5 -2097152.0 decimal64 decimal128 -3599627370495.5 -3599627370495.0 decimal64 decimal128 -3599627370496.25 -3599627370496.0 decimal64 decimal128 -3599627370496.5 -3599627370496.0 decimal64 decimal128 -3599627370496.75 -3599627370496.0 decimal64 decimal128 -3599627370497.5 -3599627370497.0 decimal64 decimal128 -4503599627370495.5 -4503599627370495.0 decimal128 -4503599627370496.25 -4503599627370496.0 decimal128 -4503599627370496.5 -4503599627370496.0 decimal128 -4503599627370496.75 -4503599627370496.0 decimal128 -4503599627370497.5 -4503599627370497.0 decimal128 libdfp-1.0.12/tests/copysign.input000066400000000000000000000023761261375163000171250ustar00rootroot00000000000000# name copysign # arg1 decimal # arg2 decimal # ret decimal 0.0 4 0.0 0.0 -4 -0.0 -0.0 4 0.0 -0.0 -4 -0.0 Inf 0.0 Inf Inf -0.0 -Inf -Inf 0.0 Inf -Inf -0.0 -Inf 0.0 Inf 0.0 0.0 -0.0 -0.0 -0.0 Inf 0.0 -0.0 -0.0 -0.0 0.0 NaN 0.0 0.0 -NaN -0.0 -0.0 NaN 0.0 -0.0 -NaN -0.0 NaN 0.0 NaN NaN -0.0 -NaN -NaN 0.0 NaN -NaN -0.0 -NaN DEC_MIN DEC_SUBNORMAL_MIN DEC_MIN DEC_MIN -DEC_SUBNORMAL_MIN -DEC_MIN -DEC_MIN DEC_SUBNORMAL_MIN DEC_MIN -DEC_MIN -DEC_SUBNORMAL_MIN -DEC_MIN DEC_SUBNORMAL_MIN DEC_MAX DEC_SUBNORMAL_MIN DEC_SUBNORMAL_MIN -DEC_MAX -DEC_SUBNORMAL_MIN -DEC_SUBNORMAL_MIN DEC_MAX DEC_SUBNORMAL_MIN -DEC_SUBNORMAL_MIN -DEC_MAX -DEC_SUBNORMAL_MIN DEC_MAX DEC_MIN DEC_MAX DEC_MAX -DEC_MIN -DEC_MAX -DEC_MAX DEC_MIN DEC_MAX -DEC_MAX -DEC_MIN -DEC_MAX libdfp-1.0.12/tests/debug-test.sh000066400000000000000000000005061261375163000166010ustar00rootroot00000000000000#!/bin/bash if test -z "$1"; then echo "$1 must be the test-*.conf file name you wish to debug." fi source ./debug-test.conf source ./$1 # Depending on whether a [system|standalone] loader or a non-installed glibc # build's loader this will be invoked differently. $DBG -x ${GDB_SCRIPT} -d ${LIBDFP_SRC} ${APP_OR_LOADER} libdfp-1.0.12/tests/decode.h000066400000000000000000000027611261375163000156030ustar00rootroot00000000000000/* Prototypes for decode functions, which output the DPD declets. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef _DFP_DECODE_H #define _DFP_DECODE_H #include __BEGIN_DECLS /* char * should ref a 14 byte char array, +0,000,000E+0\0 */ extern char * decoded32 (_Decimal32, char*); /* char * should ref a 26 byte char array, +0,000,000,000,000,000E+0\0 */ extern char * decoded64 (_Decimal64, char*); /* char * should ref a 50 byte char array, * * +0,000,000,000,000,000,000,000,000,000,000,000E+0\0 */ extern char * decoded128 (_Decimal128, char*); __END_DECLS #endif /* _DFP_DECODE_H */ libdfp-1.0.12/tests/exp.input000066400000000000000000000012761261375163000160640ustar00rootroot00000000000000# name exp # arg1 decimal # ret decimal 0 1 -0 1 1 2.718281828459045235360287471352662 2 7.389056098930650227230427460575008 3 20.08553692318766774092852965458172 0.75 2.117000016612674668545369819837096 50.0 5184705528587072464087.453322933485 88.72269439697265625 3.402331266231607749375541347722904e+38 709.75 1.73983687326416055769825271167383e+308 decimal64 decimal128 NaN NaN sNaN NaN Inf Inf -Inf 0.0 libdfp-1.0.12/tests/fabs.input000066400000000000000000000007441261375163000162020ustar00rootroot00000000000000# name fabs # arg0 decimal # ret decimal 0 0 -0 0 42 42 -42 42 -2.718281828459045235360287471352662 2.718281828459045235360287471352662 Inf Inf -Inf Inf NaN NaN -NaN NaN libdfp-1.0.12/tests/floor.input000066400000000000000000000031421261375163000164030ustar00rootroot00000000000000# name floor # arg1 decimal # ret decimal Inf Inf -Inf -Inf NaN NaN sNaN NaN 0.0 0.0 -0.0 -0.0 0.0 0.0 -0.0 -0.0 0.2 0.0 -0.2 -1.0 0.5 0.0 -0.5 -1.0 0.8 0.0 -0.8 -1.0 1.5 1.0 -1.5 -2.0 0.1 0.0 0.25 0.0 0.625 0.0 -0.1 -1.0 -0.25 -1.0 -0.625 -1.0 97152.5 97152.0 -97152.5 -97153.0 -370495.5 -370496.0 -370496.25 -370497.0 -370496.5 -370497.0 -370496.75 -370497.0 -370497.5 -370498.0 2097152.5 2097152.0 decimal64 decimal128 -2097152.5 -2097153.0 decimal64 decimal128 -3599627370495.5 -3599627370496.0 decimal64 decimal128 -3599627370496.25 -3599627370497.0 decimal64 decimal128 -3599627370496.5 -3599627370497.0 decimal64 decimal128 -3599627370496.75 -3599627370497.0 decimal64 decimal128 -3599627370497.5 -3599627370498.0 decimal64 decimal128 -4503599627370495.5 -4503599627370496.0 decimal128 -4503599627370496.25 -4503599627370497.0 decimal128 -4503599627370496.5 -4503599627370497.0 decimal128 -4503599627370496.75 -4503599627370497.0 decimal128 -4503599627370497.5 -4503599627370498.0 decimal128 libdfp-1.0.12/tests/fpclassify.input000066400000000000000000000007311261375163000174260ustar00rootroot00000000000000# name fpclassify # arg1 decimal # ret int Inf FP_INFINITE -Inf FP_INFINITE NaN FP_NAN -NaN FP_NAN sNaN FP_NAN DEC_SUBNORMAL_MIN FP_SUBNORMAL -DEC_SUBNORMAL_MIN FP_SUBNORMAL DEC_MIN FP_NORMAL DEC_MAX FP_NORMAL 0.1 FP_NORMAL 10E1 FP_NORMAL 0.0 FP_ZERO 0E10 FP_ZERO -0.0 FP_ZERO -0E-3 FP_ZERO libdfp-1.0.12/tests/gdb_start_address.py000066400000000000000000000017731261375163000202410ustar00rootroot00000000000000# gdb_start_address.py created by Ryan S. Arnold, April 2011. No # attribution required or necessary to use/reuse/copy/modify this # function/script. import re class StartAddress(gdb.Function): """Returns the start address of a library or executable from info proc mappings.""" def __init__(self): super (StartAddress, self).__init__ ("start_address") def invoke(self, library): mappings = gdb.execute("info proc mappings", to_string=True) lines = mappings.split('\n') to_mappings = "" for line in lines: if (to_mappings != "true"): if (re.search("Start Addr", line)): to_mappings = "true" continue else: # The first match is the .text segment. Make sure to # match on "/libdfp-1.0.7.so" when passed "libdfp" and # not on "/libdfp" in the following example: # /home/ryanarn/libdfp/build64_power6/libdfp-1.0.7.so if (re.search("/" + library.string() + "[^/]*$", line)): chunks = line.split() return int(str(chunks[0]),16) return 0x0 StartAddress () libdfp-1.0.12/tests/gen-libdfp-tests.py000077500000000000000000000261251261375163000177330ustar00rootroot00000000000000#!/usr/bin/env python import sys import re import os from optparse import OptionParser # Decribes the evaluated function class Function: def __init__ (self): self.name = None self.args = [] self.ret = None self.ulp = False def ret_init_type (self): return self.ret.argtype def ret_type (self): return self.ret.type def ret_field (self): if self.ret.decfield: return "." + self.ret.decfield return "" def ret_printf (self): return self.ret.printf def arg_type (self, i): return self.args[i].argtype; # Describes an operation to perform class Operation: def __init__(self, line): self.args = [] self.ret = None self.line = line # Describe a type handle in operations and functions definition class Type (object): def __init__(self, name, type, printf): self.name = name self.type = type self.printf = printf self.decfield = "" def parse_arg(self, arg): return arg class BoolType(Type): def __init__(self, name, type, printf): super(BoolType, self).__init__(name, type, printf) self.argtype = type def parse_arg (self, arg): if arg == "True": return 1 elif arg == "False": return 0 return arg; class IntegerType(Type): def __init__(self, name, type, printf): super(IntegerType, self).__init__(name, type, printf) self.argtype = type def parse_arg (self, arg): if "DEC_MIN_EXP_SUB" in arg: return arg.replace ("DEC_MIN_EXP_SUB", DECIMAL.minexpsub) if "DEC_MIN_EXP" in arg: return arg.replace ("DEC_MIN_EXP", DECIMAL.minexp) if "DEC_MAX_EXP" in arg: return arg.replace ("DEC_MAX_EXP", DECIMAL.maxexp) return arg class DecimalType(Type): # Regular expression to check for integer numbers and DEC[32|64|128]_[MAX|MIN] intnum_re = re.compile("([-|+]?[0-9]+$)|(-?DEC.*_(MAX|MIN))") def __init__(self, name, type, tname = "", suffix = "", decfield = "", maxvalue = "", minvalue = "", subnormal = "", maxexp = "", minexp = "", minexpsub = "", printf = "", argtype = ""): super(DecimalType, self).__init__(name, type, printf) self.tname = tname self.suffix = suffix self.decfield = decfield self.maxvalue = maxvalue self.minvalue = minvalue self.subnormal = subnormal self.minexp = minexp self.maxexp = maxexp self.minexpsub = minexpsub if not argtype: self.argtype = type else: self.argtype = argtype def parse_arg (self, arg): # NAN values if "NaN" in arg: return "{ .ieee_nan = { .c = 0x1f, .signaling_nan = %d, .negative = %d } }" \ % (int("s" in arg), int("-" in arg)) # Infinity if "Inf" in arg: prefix = "minus" if ("-" in arg) else "plus" return "{ .%s = %s_infty }" % (DECIMAL.decfield, prefix) # Replace E[+-]DEC_[MAX|MIN]_EXP by a expected number, i.e, # 1E-DEC_MIN_EXP -> 1E-383 if "DEC_MAX_EXP" in arg: arg = arg.replace ("DEC_MAX_EXP", DECIMAL.maxexp) if "DEC_MIN_EXP_SUB" in arg: arg = arg.replace ("DEC_MIN_EXP_SUB", DECIMAL.minexpsub) if "DEC_MIN_EXP" in arg: arg = arg.replace ("DEC_MIN_EXP", DECIMAL.minexp) # Macro fox max, min, tiny values if "DEC_MAX" in arg: arg = arg.replace ("DEC_MAX", DECIMAL.maxvalue); if "DEC_MIN" in arg: arg = arg.replace ("DEC_MIN", DECIMAL.minvalue); if "DEC_SUBNORMAL_MIN" in arg: arg = arg.replace ("DEC_SUBNORMAL_MIN", DECIMAL.subnormal); # Normal value if not self.intnum_re.match (arg): arg += DECIMAL.suffix return "{ .%s = %s }" % (DECIMAL.decfield, arg) DecimalTypes = { "bool" : BoolType ("bool", "_Bool", printf = "%d"), "int" : IntegerType("int", "int", printf = "%i"), "longint" : IntegerType("longint", "long int", printf = "%li"), "llongint" : IntegerType("llongint", "long long int", printf = "%lli"), "decimal32" : DecimalType ("decimal32", "_Decimal32", "32", "DF", "sd", "DEC32_MAX", "DEC32_MIN", "DEC32_SUBNORMAL_MIN", "90", "95", "101", "%.7HgDF", "union ieee754r_Decimal32"), "decimal64" : DecimalType ("decimal64", "_Decimal64", "64", "DD", "dd", "DEC64_MAX", "DEC64_MIN", "DEC64_SUBNORMAL_MIN", "369", "383", "398", "%.16DgDD", "union ieee754r_Decimal64"), "decimal128" : DecimalType ("decimal128", "_Decimal128", "128", "DL", "td", "DEC128_MAX", "DEC128_MIN", "DEC128_SUBNORMAL_MIN", "6111", "6143", "6176", "%.34DDgDL", "union ieee754r_Decimal128") } DECIMAL = None # Parse the testname.input file returning a set of (Function, Operation) # Each file has headers (line starting with '#') describing the test # arguments and returns. It follows: # '#' name # '#' arg # '#' ret # # Each test operation is described by one line: # def parse_file (filename): file = open (filename, "r") lines = file.readlines() i = 0; # Parse the header with function description func = Function() for l in range (i, len(lines)): if not lines[l].rstrip().startswith ("#"): break fields = lines[l].split() if fields[1].startswith("name"): func.name = fields[2] if fields[1].startswith("arg"): func.args.append(DecimalTypes[fields[2] + DECIMAL.tname]) elif fields[1].startswith("ret"): rettname = fields[2] if rettname == "decimal": rettname += DECIMAL.tname func.ret = DecimalTypes[rettname] i = i + 1 # Parse the inputs and expected result operations = [] expected_args = len (func.args) for l in range(i, len(lines)): i = i + 1 lines[l] = lines[l].strip() if not lines[l]: continue # Ignore commnets if lines[l].startswith ("#"): continue fields = lines[l].split() # Check if number of arguments is the expected one if len(fields) - 1 < expected_args: print ("warning: %s:%i: line %s not follow specified function" % \ (filename, l, lines[l])) continue # Check if the test applies to decimal type being tested if (len(fields) - 1) > expected_args: declist = fields[expected_args+1].split() if DECIMAL.name not in declist: continue op = Operation(i) for oparg in range (0, expected_args): op.args.append(fields[oparg]) op.ret = fields[expected_args] operations.append(op) return (func, operations) def print_header (func): print ("#ifndef __STDC_WANT_DEC_FP__") print ("# define __STDC_WANT_DEC_FP__") print ("#endif") print ("") print ("#define _GNU_SOURCE") print ("#include ") print ("#include ") print ("#include ") print ("#include ") print ("#include ") print ("#include ") print ("#include ") print ("#include ") print ("#include \"test-common.h\"") print ("") # Macros required for test build print ("#define %s" % DECIMAL.name.upper()) print ("#define FLOAT %s" % DECIMAL.type) print ("#define FUNC(function) function ## %s" % ('d' + DECIMAL.tname)) print ("") print ("#include \"libdfp-test-ulps.h\"") print ("#include \"libdfp-test.c\"") def print_special_ctes (): print ("#ifndef DEC_INFINITY") print ("# define DEC_INFINITY __builtin_infd32()") print ("#endif"); print ("#ifndef DEC_NAN") print ("# define DEC_NAN __builtin_nand32(\"\")") print ("#endif"); print ("#define plus_infty DEC_INFINITY") print ("#define minus_infty -DEC_INFINITY") print ("#define qnan_value DEC_NAN") print ("#define snan_value DEC_NAN") print ("") def print_operations (func, operations): print ("typedef struct {") print (" const char *argname;") for i in range(0, len(func.args)): print (" %s arg%i;" % (func.arg_type(i), i)) print (" %s e;" % func.ret_init_type()) print (" int line;") print ("} operations_t;") print ("") print ("static const operations_t operations[] = {") for op in operations: print (" {"), print ("\"%s\", " % ", ".join(op.args)), for i in range(0, len(op.args)): print ("%s," % func.args[i].parse_arg(op.args[i])), print (" %s, " % func.ret.parse_arg(op.ret)), print (" %d }," % op.line) print ("};") print ("static const int operations_size = \ sizeof(operations)/sizeof(operations[0]);"); print ("") def print_func_call(func): print ("int main (void) {") print (" int i;") print (" for (i = 0; i < operations_size; ++i) {") # (func.name, arg1, arg2, ..., ret, expected) MACROSUFFIX = { "bool" : "b", "int" : "i", "longint" : "l", "llongint" : "L", "decimal32" : "f", "decimal64" : "f", "decimal128" : "f" } macro = "RUN_TEST_" + ('f' * len(func.args)) + "_" + MACROSUFFIX[func.ret.name] print (" %s (%s, operations[i].argname, " % (macro, func.name, )), for i in range(0, len(func.args)): print ("operations[i].arg%i.%s, " % (i, DECIMAL.decfield)), print ("operations[i].e%s);" % func.ret_field()) print (" }") print ("") print (" return noErrors;"); print ("}") def print_output (filename): (func, operations) = parse_file (filename) print_header (func) print_special_ctes () print_operations (func, operations) print_func_call (func) if __name__ == "__main__": parser = OptionParser () parser.add_option ("-o", "--output", dest="filename", help="white output to FILE") parser.add_option ("-t", "--type", dest="dectype", help="DECIMAL type to use") (options, args) = parser.parse_args() try: if options.filename: sys.stdout = open (options.filename, "w") if not args: sys.stderr.write ("usage: gen-libdfp-tests.py ") raise Exception() if not options.dectype: sys.stderr.write ("error: you must specify a type: decimal[32|64|128]") raise Exception() DECIMAL = DecimalTypes[options.dectype] print_output (args[0]) except: if options.filename: os.remove (options.filename) exit (1) libdfp-1.0.12/tests/gen-libdfp-ulps.py000077500000000000000000000055711261375163000175560ustar00rootroot00000000000000#!/usr/bin/env python import sys import os from optparse import OptionParser class ULP (object): def __init__ (self, function, input): self.function = function self.input = input self.ulp32 = 0 self.ulp64 = 0 self.ulp128 = 0 def callstr (self): return "\"%s (%s)\"" % (self.function, self.input) # Parse a ulp description file returning a set of (ulps) for each operation. # Lines starting with '#' are ignored. # Each test is decribed as: # test # decimal # # If not described, ULP is assumed to be 0. def parse_file (filename): try: ulp = None ulps = [] for line in open(filename, 'r').readlines(): # Ignore comments and blank lines if line.rstrip().startswith ("#"): continue fields = line.split() if len(fields) is 0: continue if fields[0] == 'test': ulp = ULP (fields[1], fields[2]) ulps.append (ulp) elif fields[0] == 'decimal32': ulp.ulp32 = fields[1] elif fields[0] == 'decimal64': ulp.ulp64 = fields[1] elif fields[0] == 'decimal128': ulp.ulp128 = fields[1] return ulps except (IOError, OSError) as e: print ("error: open (%s) failed: %s\n" % (filename, e.strerror)) exit (1) def print_header (filename): print ("/* This file is automatically generated") print (" * from %s with gen-libdfp-ulps.py. */" % filename) print ("") print ("#if defined(DECIMAL32)") print ("# define CHOOSE(decimal128, decimal64, decimal32) decimal32") print ("#elif defined(DECIMAL64)") print ("# define CHOOSE(decimal128, decimal64, decimal32) decimal64") print ("#elif defined(DECIMAL128)") print ("# define CHOOSE(decimal128, decimal64, decimal32) decimal128") print ("#endif") print ("") print ("struct ulp_data {") print (" const char *name;") print (" FLOAT max_ulp;") print ("};") print ("") def print_ulps (ulps): print ("/* Maximal error of functions. */") print ("static const struct ulp_data test_ulps[] = {") # The array will be used in a bsearch call, so the itens must be sorted for ulp in sorted(ulps, key=lambda x: x.callstr()): print (" { %s, CHOOSE(%s, %s, %s) }," % (ulp.callstr(), ulp.ulp128, ulp.ulp64, ulp.ulp32)) print ("};") def print_output (filename): ulps = parse_file (filename) print_header (filename) print_ulps (ulps) if __name__ == "__main__": parser = OptionParser () parser.add_option ("-o", "--output", dest="filename", help="white output to FILE") (options, args) = parser.parse_args() try: if options.filename: sys.stdout = open (options.filename, "w") if len(args) == 0: sys.stderr.write ("usage: gen-libdfp-ulps.py \n") raise Exception() print_output (args[0]) except: if options.filename: os.remove (options.filename) exit (1) libdfp-1.0.12/tests/ilogb.input000066400000000000000000000024301261375163000163550ustar00rootroot00000000000000# name ilogb # arg1 decimal # ret int Inf INT_MAX -Inf INT_MIN NaN FP_ILOGBNAN sNaN FP_ILOGBNAN 0 FP_ILOGB0 0.0 FP_ILOGB0 0E0 FP_ILOGB0 1.0 0 10.76 1 1024.0 3 20000.001 4 400032.003 5 1E32 32 1.56E32 32 -1.56E32 32 1E-32 -32 1.54E-32 -32 -1.54E-32 -32 156E32 34 -156E32 34 154E-32 -30 -154E-32 -30 1.542332E124 124 decimal64 decimal128 -1.542332E124 124 decimal64 decimal128 1.542332E-124 -124 decimal64 decimal128 -1.542332E-124 -124 decimal64 decimal128 15423.32E124 128 decimal64 decimal128 -15423.32E124 128 decimal64 decimal128 15423.32E-124 -120 decimal64 decimal128 -15423.32E-124 -120 decimal64 decimal128 1.9433E1024 1024 decimal128 -1.9433E1024 1024 decimal128 1.9433E-1024 -1024 decimal128 -1.9433E-1024 -1024 decimal128 194338E1024 1029 decimal128 -194338E1024 1029 decimal128 194338E-1024 -1019 decimal128 -194338E-1024 -1019 decimal128 libdfp-1.0.12/tests/isfinite.input000066400000000000000000000003751261375163000171010ustar00rootroot00000000000000# name isfinite # arg1 decimal # ret int Inf 0 -Inf 0 NaN 0 -NaN 0 sNaN 0 DEC_SUBNORMAL_MIN 1 DEC_MIN 1 DEC_MAX 1 0.1 1 10E1 1 libdfp-1.0.12/tests/isgreater.input000066400000000000000000000161401261375163000172510ustar00rootroot00000000000000# name isgreater # arg1 decimal # arg2 decimal # ret int -2 -2 0 -2 -1 0 -2 0 0 -2 1 0 -2 2 0 -1 -2 1 -1 -1 0 -1 1 0 -1 2 0 0 -2 1 0 -1 1 0 0 0 0 1 0 0 2 0 1 -2 1 1 -1 1 1 0 1 1 1 0 1 2 0 2 -2 1 2 -1 1 2 0 1 2 1 1 2 2 0 -200 -200 0 -200 -100 0 -200 0 0 -200 100 0 -200 200 0 -100 -200 1 -100 -100 0 -100 100 0 -100 200 0 0 -200 1 0 -100 1 0 0 0 0 100 0 0 200 0 100 -200 1 100 -100 1 100 0 1 100 100 0 100 200 0 200 -200 1 200 -100 1 200 0 1 200 100 1 200 200 0 # some differing length/exponent cases 7.0 7.0 0 7.0 7 0 7 7.0 0 7E+0 7.0 0 70E-1 7.0 0 0.7E+1 7 0 70E-1 7 0 7.0 7E+0 0 7.0 70E-1 0 7 0.7E+1 0 7 70E-1 0 8.0 7.0 1 8.0 7 1 8 7.0 1 8E+0 7.0 1 80E-1 7.0 1 0.8E+1 7 1 80E-1 7 1 8.0 7E+0 1 8.0 70E-1 1 8 0.7E+1 1 8 70E-1 1 8.0 9.0 0 8.0 9 0 8 9.0 0 8E+0 9.0 0 80E-1 9.0 0 0.8E+1 9 0 80E-1 9 0 8.0 9E+0 0 8.0 90E-1 0 8 0.9E+1 0 8 90E-1 0 7.0 -7.0 1 7.0 -7 1 7 -7.0 1 7E+0 -7.0 1 70E-1 -7.0 1 .7E+1 -7 1 70E-1 -7 1 7.0 -7E+0 1 7.0 -70E-1 1 7 -.7E+1 1 7 -70E-1 1 8.0 -7.0 1 8.0 -7 1 8 -7.0 1 8E+0 -7.0 1 80E-1 -7.0 1 .8E+1 -7 1 80E-1 -7 1 8.0 -7E+0 1 8.0 -70E-1 1 8 -.7E+1 1 8 -70E-1 1 8.0 -9.0 1 8.0 -9 1 8 -9.0 1 8E+0 -9.0 1 80E-1 -9.0 1 .8E+1 -9 1 80E-1 -9 1 8.0 -9E+0 1 8.0 -90E-1 1 8 -.9E+1 1 8 -90E-1 1 -7.0 -7.0 0 -7.0 -7 0 -7 -7.0 0 -7E+0 -7.0 0 -70E-1 -7.0 0 -.7E+1 -7 0 -70E-1 -7 0 -7.0 -7E+0 0 -7.0 -70E-1 0 -7 -.7E+1 0 -7 -70E-1 0 -8.0 -7.0 0 -8.0 -7 0 -8 -7.0 0 -8E+0 -7.0 0 -80E-1 -7.0 0 -.8E+1 -7 0 -80E-1 -7 0 -8.0 -7E+0 0 -8.0 -70E-1 0 -8 -.7E+1 0 -8 -70E-1 0 -8.0 -9.0 1 -8.0 -9 1 -8 -9.0 1 -8E+0 -9.0 1 -80E-1 -9.0 1 -.8E+1 -9 1 -80E-1 -9 1 -8.0 -9E+0 1 -8.0 -90E-1 1 -8 -.9E+1 1 -8 -90E-1 1 123.4560000000000000E789 123.456E789 0 decimal128 123.456000000000000E-89 123.456E-89 0 decimal64 decimal128 123.45600000000000E789 123.456E789 0 decimal128 123.4560000000000E-89 123.456E-89 0 decimal64 decimal128 123.456000000000E789 123.456E789 0 decimal128 123.45600000000E-89 123.456E-89 0 123.4560000000E789 123.456E789 0 decimal128 123.456000000E-89 123.456E-89 0 123.45600000E789 123.456E789 0 decimal128 123.4560000E-89 123.456E-89 0 123.456000E789 123.456E789 0 decimal128 123.45600E-89 123.456E-89 0 123.4560E789 123.456E789 0 decimal128 123.456E-89 123.456E-89 0 123.456E-89 123.4560000000000E-89 0 123.456E789 123.4560000000000E789 0 decimal128 123.456E-89 123.45600000000000E-89 0 123.456E789 123.4560000000000E789 0 decimal128 123.456E-89 123.456000000000E-89 0 123.456E789 123.45600000000E789 0 decimal128 123.456E-89 123.4560000000E-89 0 123.456E789 123.456000000E789 0 decimal128 123.456E-89 123.45600000E-89 0 123.456E789 123.4560000E789 0 decimal128 123.456E-89 123.456000E-89 0 123.456E789 123.45600E789 0 decimal128 123.456E-89 123.4560E-89 0 123.456E789 123.456E789 0 decimal128 1 1E-15 1 1 1E-14 1 1 1E-13 1 1 1E-12 1 1 1E-11 1 1 1E-10 1 1 1E-9 1 1 1E-8 1 1 1E-7 1 1 1E-6 1 1 1E-5 1 1 1E-4 1 1 1E-3 1 1 1E-2 1 1 1E-1 1 1 1E-0 0 1 1E+1 0 1 1E+2 0 1 1E+3 0 1 1E+4 0 1 1E+5 0 1 1E+6 0 1 1E+7 0 1 1E+8 0 1 1E+9 0 1 1E+10 0 1 1E+11 0 1 1E+12 0 1 1E+13 0 1 1E+14 0 1 1E+15 0 1E-15 1 0 1E-14 1 0 1E-13 1 0 1E-12 1 0 1E-11 1 0 1E-10 1 0 1E-9 1 0 1E-8 1 0 1E-7 1 0 1E-6 1 0 1E-5 1 0 1E-4 1 0 1E-3 1 0 1E-2 1 0 1E-1 1 0 1E-0 1 0 1E+1 1 1 1E+2 1 1 1E+3 1 1 1E+4 1 1 1E+5 1 1 1E+6 1 1 1E+7 1 1 1E+8 1 1 1E+9 1 1 1E+10 1 1 1E+11 1 1 1E+12 1 1 1E+13 1 1 1E+14 1 1 1E+15 1 1 0.000000987654321 1E-15 1 0.000000987654321 1E-14 1 0.000000987654321 1E-13 1 0.000000987654321 1E-12 1 0.000000987654321 1E-11 1 0.000000987654321 1E-10 1 0.000000987654321 1E-9 1 0.000000987654321 1E-8 1 0.000000987654321 1E-7 1 0.000000987654321 1E-6 0 0.000000987654321 1E-5 0 0.000000987654321 1E-4 0 0.000000987654321 1E-3 0 0.000000987654321 1E-2 0 0.000000987654321 1E-1 0 0.000000987654321 1E-0 0 0.000000987654321 1E+1 0 0.000000987654321 1E+2 0 0.000000987654321 1E+3 0 0.000000987654321 1E+4 0 12 12.2345 0 12.0 12.2345 0 12.00 12.2345 0 12.000 12.2345 0 12.0000 12.2345 0 12.00000 12.2345 0 12.000000 12.2345 0 12.0000000 12.2345 0 12.00000000 12.2345 0 12.000000000 12.2345 0 12.1234 12 1 12.1234 12.0 1 12.1234 12.00 1 12.1234 12.000 1 12.1234 12.0000 1 12.1234 12.00000 1 12.1234 12.000000 1 12.1234 12.0000000 1 12.1234 12.00000000 1 12.1234 12.000000000 1 -12 -12.2345 1 -12.0 -12.2345 1 -12.00 -12.2345 1 -12.000 -12.2345 1 -12.0000 -12.2345 1 -12.00000 -12.2345 1 -12.000000 -12.2345 1 -12.0000000 -12.2345 1 -12.00000000 -12.2345 1 -12.000000000 -12.2345 1 -12.1234 -12 0 -12.1234 -12.0 0 -12.1234 -12.00 0 -12.1234 -12.000 0 -12.1234 -12.0000 0 -12.1234 -12.00000 0 -12.1234 -12.000000 0 -12.1234 -12.0000000 0 -12.1234 -12.00000000 0 -12.1234 -12.000000000 0 0 0 0 0 -0 0 0 -0.0 0 0 0.0 0 -0 0 0 -0 -0 0 -0 -0.0 0 -0 0.0 0 0.0 0 0 0.0 -0 0 0.0 -0.0 0 0.0 0.0 0 -0.0 0 0 -0.0 -0 0 -0.0 -0.0 0 -0.0 0.0 0 -0E1 0.0 0 -0E2 0.0 0 0E1 0.0 0 0E2 0.0 0 -0E1 0 0 -0E2 0 0 0E1 0 0 0E2 0 0 -0E1 -0E1 0 -0E2 -0E1 0 0E1 -0E1 0 0E2 -0E1 0 -0E1 -0E2 0 -0E2 -0E2 0 0E1 -0E2 0 0E2 -0E2 0 -0E1 0E1 0 -0E2 0E1 0 0E1 0E1 0 0E2 0E1 0 -0E1 0E2 0 -0E2 0E2 0 0E1 0E2 0 0E2 0E2 0 # long number checks (decimal32) 12345678000 1 1 1 12345678000 0 1234567800 1 1 1 1234567800 0 1234567890 1 1 1 1234567890 0 1234567891 1 1 1 1234567891 0 12345678901 1 1 1 12345678901 0 1234567896 1 1 1 1234567896 0 -1234567891 1 0 1 -1234567891 1 -12345678901 1 0 1 -12345678901 1 -1234567896 1 0 1 -1234567896 1 # long number checks (decimal64) 12345678000 1 1 1 12345678000 0 1234567800 1 1 1 1234567800 0 1234567890 1 1 1 1234567890 0 1234567891 1 1 1 1234567891 0 12345678901 1 1 1 12345678901 0 1234567896 1 1 1 1234567896 0 # long number checks (decimal128) -36852134.84194296250843579428931 -5830629.8347085025808756560357940 0 -36852134.84194296250843579428931 -36852134.84194296250843579428931 0 -36852134.94194296250843579428931 -36852134.84194296250843579428931 0 -36852134.84194296250843579428931 -36852134.94194296250843579428931 0 decimal32 -36852134.84194296250843579428931 -36852134.94194296250843579428931 1 decimal64 decimal128 # residue case 1 0.9999999 1 1 0.999999 1 1 0.99999 1 1 1.0000 0 1 1.00001 0 1 1.000001 0 1 1.0000001 0 0.9999999 1 0 0.999999 1 0 0.99999 1 0 1.0000 1 0 1.00001 1 1 1.000001 1 1 1.0000001 1 0 decimal32 1.0000001 1 1 decimal64 decimal128 # special cases Inf -1000 1 Inf -1 1 Inf -0 1 Inf 0 1 Inf 1 1 Inf 1000 1 Inf Inf 0 -1000 Inf 0 -Inf Inf 0 -1 Inf 0 -0 Inf 0 0 Inf 0 1 Inf 0 1000 Inf 0 Inf Inf 0 -Inf -Inf 0 -Inf -1000 0 -Inf -1 0 -Inf -0 0 -Inf 0 0 -Inf 1 0 -Inf 1000 0 -Inf Inf 0 -Inf -Inf 0 -1000 -Inf 1 -1 -Inf 1 -0 -Inf 1 0 -Inf 1 1 -Inf 1 1000 -Inf 1 Inf -Inf 1 NaN -Inf 0 NaN -1000 0 NaN -1 0 NaN -0 0 NaN 0 0 NaN 1 0 NaN 1000 0 NaN Inf 0 NaN NaN 0 -Inf NaN 0 -1000 NaN 0 -1 NaN 0 -0 NaN 0 0 NaN 0 1 NaN 0 1000 NaN 0 Inf NaN 0 -NaN -NaN 0 +NaN -NaN 0 -NaN +NaN 0 libdfp-1.0.12/tests/isgreaterequal.input000066400000000000000000000161321261375163000203020ustar00rootroot00000000000000# name isgreaterequal # arg1 decimal # arg2 decimal # ret int -2 -2 1 -2 -1 0 -2 0 0 -2 1 0 -2 2 0 -1 -2 1 -1 -1 1 -1 1 0 -1 2 0 0 -2 1 0 -1 1 0 0 1 0 1 0 0 2 0 1 -2 1 1 -1 1 1 0 1 1 1 1 1 2 0 2 -2 1 2 -1 1 2 0 1 2 1 1 2 2 1 -200 -200 1 -200 -100 0 -200 0 0 -200 100 0 -200 200 0 -100 -200 1 -100 -100 1 -100 100 0 -100 200 0 0 -200 1 0 -100 1 0 0 1 0 100 0 0 200 0 100 -200 1 100 -100 1 100 0 1 100 100 1 100 200 0 200 -200 1 200 -100 1 200 0 1 200 100 1 200 200 1 # some differing length/exponent cases 7.0 7.0 1 7.0 7 1 7 7.0 1 7E+0 7.0 1 70E-1 7.0 1 0.7E+1 7 1 70E-1 7 1 7.0 7E+0 1 7.0 70E-1 1 7 0.7E+1 1 7 70E-1 1 8.0 7.0 1 8.0 7 1 8 7.0 1 8E+0 7.0 1 80E-1 7.0 1 0.8E+1 7 1 80E-1 7 1 8.0 7E+0 1 8.0 70E-1 1 8 0.7E+1 1 8 70E-1 1 8.0 9.0 0 8.0 9 0 8 9.0 0 8E+0 9.0 0 80E-1 9.0 0 0.8E+1 9 0 80E-1 9 0 8.0 9E+0 0 8.0 90E-1 0 8 0.9E+1 0 8 90E-1 0 7.0 -7.0 1 7.0 -7 1 7 -7.0 1 7E+0 -7.0 1 70E-1 -7.0 1 .7E+1 -7 1 70E-1 -7 1 7.0 -7E+0 1 7.0 -70E-1 1 7 -.7E+1 1 7 -70E-1 1 8.0 -7.0 1 8.0 -7 1 8 -7.0 1 8E+0 -7.0 1 80E-1 -7.0 1 .8E+1 -7 1 80E-1 -7 1 8.0 -7E+0 1 8.0 -70E-1 1 8 -.7E+1 1 8 -70E-1 1 8.0 -9.0 1 8.0 -9 1 8 -9.0 1 8E+0 -9.0 1 80E-1 -9.0 1 .8E+1 -9 1 80E-1 -9 1 8.0 -9E+0 1 8.0 -90E-1 1 8 -.9E+1 1 8 -90E-1 1 -7.0 -7.0 1 -7.0 -7 1 -7 -7.0 1 -7E+0 -7.0 1 -70E-1 -7.0 1 -.7E+1 -7 1 -70E-1 -7 1 -7.0 -7E+0 1 -7.0 -70E-1 1 -7 -.7E+1 1 -7 -70E-1 1 -8.0 -7.0 0 -8.0 -7 0 -8 -7.0 0 -8E+0 -7.0 0 -80E-1 -7.0 0 -.8E+1 -7 0 -80E-1 -7 0 -8.0 -7E+0 0 -8.0 -70E-1 0 -8 -.7E+1 0 -8 -70E-1 0 -8.0 -9.0 1 -8.0 -9 1 -8 -9.0 1 -8E+0 -9.0 1 -80E-1 -9.0 1 -.8E+1 -9 1 -80E-1 -9 1 -8.0 -9E+0 1 -8.0 -90E-1 1 -8 -.9E+1 1 -8 -90E-1 1 123.4560000000000000E789 123.456E789 1 decimal128 123.456000000000000E-89 123.456E-89 1 decimal64 decimal128 123.45600000000000E789 123.456E789 1 decimal128 123.4560000000000E-89 123.456E-89 1 decimal64 decimal128 123.456000000000E789 123.456E789 1 decimal128 123.45600000000E-89 123.456E-89 1 123.4560000000E789 123.456E789 1 decimal128 123.456000000E-89 123.456E-89 1 123.45600000E789 123.456E789 1 decimal128 123.4560000E-89 123.456E-89 1 123.456000E789 123.456E789 1 decimal128 123.45600E-89 123.456E-89 1 123.4560E789 123.456E789 1 decimal128 123.456E-89 123.456E-89 1 123.456E-89 123.4560000000000E-89 1 123.456E789 123.4560000000000E789 1 decimal128 123.456E-89 123.45600000000000E-89 1 123.456E789 123.4560000000000E789 1 decimal128 123.456E-89 123.456000000000E-89 1 123.456E789 123.45600000000E789 1 decimal128 123.456E-89 123.4560000000E-89 1 123.456E789 123.456000000E789 1 decimal128 123.456E-89 123.45600000E-89 1 123.456E789 123.4560000E789 1 decimal128 123.456E-89 123.456000E-89 1 123.456E789 123.45600E789 1 decimal128 123.456E-89 123.4560E-89 1 123.456E789 123.456E789 1 decimal128 1 1E-15 1 1 1E-14 1 1 1E-13 1 1 1E-12 1 1 1E-11 1 1 1E-10 1 1 1E-9 1 1 1E-8 1 1 1E-7 1 1 1E-6 1 1 1E-5 1 1 1E-4 1 1 1E-3 1 1 1E-2 1 1 1E-1 1 1 1E-0 1 1 1E+1 0 1 1E+2 0 1 1E+3 0 1 1E+4 0 1 1E+5 0 1 1E+6 0 1 1E+7 0 1 1E+8 0 1 1E+9 0 1 1E+10 0 1 1E+11 0 1 1E+12 0 1 1E+13 0 1 1E+14 0 1 1E+15 0 1E-15 1 0 1E-14 1 0 1E-13 1 0 1E-12 1 0 1E-11 1 0 1E-10 1 0 1E-9 1 0 1E-8 1 0 1E-7 1 0 1E-6 1 0 1E-5 1 0 1E-4 1 0 1E-3 1 0 1E-2 1 0 1E-1 1 0 1E-0 1 1 1E+1 1 1 1E+2 1 1 1E+3 1 1 1E+4 1 1 1E+5 1 1 1E+6 1 1 1E+7 1 1 1E+8 1 1 1E+9 1 1 1E+10 1 1 1E+11 1 1 1E+12 1 1 1E+13 1 1 1E+14 1 1 1E+15 1 1 0.000000987654321 1E-15 1 0.000000987654321 1E-14 1 0.000000987654321 1E-13 1 0.000000987654321 1E-12 1 0.000000987654321 1E-11 1 0.000000987654321 1E-10 1 0.000000987654321 1E-9 1 0.000000987654321 1E-8 1 0.000000987654321 1E-7 1 0.000000987654321 1E-6 0 0.000000987654321 1E-5 0 0.000000987654321 1E-4 0 0.000000987654321 1E-3 0 0.000000987654321 1E-2 0 0.000000987654321 1E-1 0 0.000000987654321 1E-0 0 0.000000987654321 1E+1 0 0.000000987654321 1E+2 0 0.000000987654321 1E+3 0 0.000000987654321 1E+4 0 12 12.2345 0 12.0 12.2345 0 12.00 12.2345 0 12.000 12.2345 0 12.0000 12.2345 0 12.00000 12.2345 0 12.000000 12.2345 0 12.0000000 12.2345 0 12.00000000 12.2345 0 12.000000000 12.2345 0 12.1234 12 1 12.1234 12.0 1 12.1234 12.00 1 12.1234 12.000 1 12.1234 12.0000 1 12.1234 12.00000 1 12.1234 12.000000 1 12.1234 12.0000000 1 12.1234 12.00000000 1 12.1234 12.000000000 1 -12 -12.2345 1 -12.0 -12.2345 1 -12.00 -12.2345 1 -12.000 -12.2345 1 -12.0000 -12.2345 1 -12.00000 -12.2345 1 -12.000000 -12.2345 1 -12.0000000 -12.2345 1 -12.00000000 -12.2345 1 -12.000000000 -12.2345 1 -12.1234 -12 0 -12.1234 -12.0 0 -12.1234 -12.00 0 -12.1234 -12.000 0 -12.1234 -12.0000 0 -12.1234 -12.00000 0 -12.1234 -12.000000 0 -12.1234 -12.0000000 0 -12.1234 -12.00000000 0 -12.1234 -12.000000000 0 0 0 1 0 -0 1 0 -0.0 1 0 0.0 1 -0 0 1 -0 -0 1 -0 -0.0 1 -0 0.0 1 0.0 0 1 0.0 -0 1 0.0 -0.0 1 0.0 0.0 1 -0.0 0 1 -0.0 -0 1 -0.0 -0.0 1 -0.0 0.0 1 -0E1 0.0 1 -0E2 0.0 1 0E1 0.0 1 0E2 0.0 1 -0E1 0 1 -0E2 0 1 0E1 0 1 0E2 0 1 -0E1 -0E1 1 -0E2 -0E1 1 0E1 -0E1 1 0E2 -0E1 1 -0E1 -0E2 1 -0E2 -0E2 1 0E1 -0E2 1 0E2 -0E2 1 -0E1 0E1 1 -0E2 0E1 1 0E1 0E1 1 0E2 0E1 1 -0E1 0E2 1 -0E2 0E2 1 0E1 0E2 1 0E2 0E2 1 # long number checks (decimal32) 12345678000 1 1 1 12345678000 0 1234567800 1 1 1 1234567800 0 1234567890 1 1 1 1234567890 0 1234567891 1 1 1 1234567891 0 12345678901 1 1 1 12345678901 0 1234567896 1 1 1 1234567896 0 -1234567891 1 0 1 -1234567891 1 -12345678901 1 0 1 -12345678901 1 -1234567896 1 0 1 -1234567896 1 # long number checks (decimal64) 12345678000 1 1 1 12345678000 0 1234567800 1 1 1 1234567800 0 1234567890 1 1 1 1234567890 0 1234567891 1 1 1 1234567891 0 12345678901 1 1 1 12345678901 0 1234567896 1 1 1 1234567896 0 # long number checks (decimal128) -36852134.84194296250843579428931 -5830629.8347085025808756560357940 0 -36852134.84194296250843579428931 -36852134.84194296250843579428931 1 -36852134.94194296250843579428931 -36852134.84194296250843579428931 1 decimal32 -36852134.94194296250843579428931 -36852134.84194296250843579428931 0 decimal64 decimal128 -36852134.84194296250843579428931 -36852134.94194296250843579428931 1 # residue case 1 0.9999999 1 1 0.999999 1 1 0.99999 1 1 1.0000 1 1 1.00001 0 1 1.000001 0 1 1.0000001 1 decimal32 1 1.0000001 0 decimal64 decimal128 0.9999999 1 0 0.999999 1 0 0.99999 1 0 1.0000 1 1 1.00001 1 1 1.000001 1 1 1.0000001 1 1 # special cases Inf -1000 1 Inf -1 1 Inf -0 1 Inf 0 1 Inf 1 1 Inf 1000 1 Inf Inf 1 -1000 Inf 0 -Inf Inf 0 -1 Inf 0 -0 Inf 0 0 Inf 0 1 Inf 0 1000 Inf 0 -Inf -Inf 1 -Inf -1000 0 -Inf -1 0 -Inf -0 0 -Inf 0 0 -Inf 1 0 -Inf 1000 0 -Inf Inf 0 -Inf -Inf 1 -1000 -Inf 1 -1 -Inf 1 -0 -Inf 1 0 -Inf 1 1 -Inf 1 1000 -Inf 1 Inf -Inf 1 NaN -Inf 0 NaN -1000 0 NaN -1 0 NaN -0 0 NaN 0 0 NaN 1 0 NaN 1000 0 NaN Inf 0 NaN NaN 0 -Inf NaN 0 -1000 NaN 0 -1 NaN 0 -0 NaN 0 0 NaN 0 1 NaN 0 1000 NaN 0 Inf NaN 0 -NaN -NaN 0 +NaN -NaN 0 -NaN +NaN 0 libdfp-1.0.12/tests/isinf.input000066400000000000000000000003731261375163000163750ustar00rootroot00000000000000# name isinf # arg1 decimal # ret int Inf 1 -Inf -1 NaN 0 -NaN 0 sNaN 0 DEC_SUBNORMAL_MIN 0 DEC_MIN 0 DEC_MAX 0 0.1 0 10E1 0 libdfp-1.0.12/tests/isless.input000066400000000000000000000160721261375163000165720ustar00rootroot00000000000000# name isless # arg1 decimal # arg2 decimal # ret int -2 -2 0 -2 -1 1 -2 0 1 -2 1 1 -2 2 1 -1 -2 0 -1 -1 0 -1 1 1 -1 2 1 0 -2 0 0 -1 0 0 0 0 0 1 1 0 2 1 1 -2 0 1 -1 0 1 0 0 1 1 0 1 2 1 2 -2 0 2 -1 0 2 0 0 2 1 0 2 2 0 -200 -200 0 -200 -100 1 -200 0 1 -200 100 1 -200 200 1 -100 -200 0 -100 -100 0 -100 100 1 -100 200 1 0 -200 0 0 -100 0 0 0 0 0 100 1 0 200 1 100 -200 0 100 -100 0 100 0 0 100 100 0 100 200 1 200 -200 0 200 -100 0 200 0 0 200 100 0 200 200 0 # some differing length/exponent cases 7.0 7.0 0 7.0 7 0 7 7.0 0 7E+0 7.0 0 70E-1 7.0 0 0.7E+1 7 0 70E-1 7 0 7.0 7E+0 0 7.0 70E-1 0 7 0.7E+1 0 7 70E-1 0 8.0 7.0 0 8.0 7 0 8 7.0 0 8E+0 7.0 0 80E-1 7.0 0 0.8E+1 7 0 80E-1 7 0 8.0 7E+0 0 8.0 70E-1 0 8 0.7E+1 0 8 70E-1 0 8.0 9.0 1 8.0 9 1 8 9.0 1 8E+0 9.0 1 80E-1 9.0 1 0.8E+1 9 1 80E-1 9 1 8.0 9E+0 1 8.0 90E-1 1 8 0.9E+1 1 8 90E-1 1 7.0 -7.0 0 7.0 -7 0 7 -7.0 0 7E+0 -7.0 0 70E-1 -7.0 0 .7E+1 -7 0 70E-1 -7 0 7.0 -7E+0 0 7.0 -70E-1 0 7 -.7E+1 0 7 -70E-1 0 8.0 -7.0 0 8.0 -7 0 8 -7.0 0 8E+0 -7.0 0 80E-1 -7.0 0 .8E+1 -7 0 80E-1 -7 0 8.0 -7E+0 0 8.0 -70E-1 0 8 -.7E+1 0 8 -70E-1 0 8.0 -9.0 0 8.0 -9 0 8 -9.0 0 8E+0 -9.0 0 80E-1 -9.0 0 .8E+1 -9 0 80E-1 -9 0 8.0 -9E+0 0 8.0 -90E-1 0 8 -.9E+1 0 8 -90E-1 0 -7.0 -7.0 0 -7.0 -7 0 -7 -7.0 0 -7E+0 -7.0 0 -70E-1 -7.0 0 -.7E+1 -7 0 -70E-1 -7 0 -7.0 -7E+0 0 -7.0 -70E-1 0 -7 -.7E+1 0 -7 -70E-1 0 -8.0 -7.0 1 -8.0 -7 1 -8 -7.0 1 -8E+0 -7.0 1 -80E-1 -7.0 1 -.8E+1 -7 1 -80E-1 -7 1 -8.0 -7E+0 1 -8.0 -70E-1 1 -8 -.7E+1 1 -8 -70E-1 1 -8.0 -9.0 0 -8.0 -9 0 -8 -9.0 0 -8E+0 -9.0 0 -80E-1 -9.0 0 -.8E+1 -9 0 -80E-1 -9 0 -8.0 -9E+0 0 -8.0 -90E-1 0 -8 -.9E+1 0 -8 -90E-1 0 123.4560000000000000E789 123.456E789 0 decimal128 123.456000000000000E-89 123.456E-89 0 decimal64 decimal128 123.45600000000000E789 123.456E789 0 decimal128 123.4560000000000E-89 123.456E-89 0 decimal64 decimal128 123.456000000000E789 123.456E789 0 decimal128 123.45600000000E-89 123.456E-89 0 123.4560000000E789 123.456E789 0 decimal128 123.456000000E-89 123.456E-89 0 123.45600000E789 123.456E789 0 decimal128 123.4560000E-89 123.456E-89 0 123.456000E789 123.456E789 0 decimal128 123.45600E-89 123.456E-89 0 123.4560E789 123.456E789 0 decimal128 123.456E-89 123.456E-89 0 123.456E-89 123.4560000000000E-89 0 123.456E789 123.4560000000000E789 0 decimal128 123.456E-89 123.45600000000000E-89 0 123.456E789 123.4560000000000E789 0 decimal128 123.456E-89 123.456000000000E-89 0 123.456E789 123.45600000000E789 0 decimal128 123.456E-89 123.4560000000E-89 0 123.456E789 123.456000000E789 0 decimal128 123.456E-89 123.45600000E-89 0 123.456E789 123.4560000E789 0 decimal128 123.456E-89 123.456000E-89 0 123.456E789 123.45600E789 0 decimal128 123.456E-89 123.4560E-89 0 123.456E789 123.456E789 0 decimal128 1 1E-15 0 1 1E-14 0 1 1E-13 0 1 1E-12 0 1 1E-11 0 1 1E-10 0 1 1E-9 0 1 1E-8 0 1 1E-7 0 1 1E-6 0 1 1E-5 0 1 1E-4 0 1 1E-3 0 1 1E-2 0 1 1E-1 0 1 1E-0 0 1 1E+1 1 1 1E+2 1 1 1E+3 1 1 1E+4 1 1 1E+5 1 1 1E+6 1 1 1E+7 1 1 1E+8 1 1 1E+9 1 1 1E+10 1 1 1E+11 1 1 1E+12 1 1 1E+13 1 1 1E+14 1 1 1E+15 1 1E-15 1 1 1E-14 1 1 1E-13 1 1 1E-12 1 1 1E-11 1 1 1E-10 1 1 1E-9 1 1 1E-8 1 1 1E-7 1 1 1E-6 1 1 1E-5 1 1 1E-4 1 1 1E-3 1 1 1E-2 1 1 1E-1 1 1 1E-0 1 0 1E+1 1 0 1E+2 1 0 1E+3 1 0 1E+4 1 0 1E+5 1 0 1E+6 1 0 1E+7 1 0 1E+8 1 0 1E+9 1 0 1E+10 1 0 1E+11 1 0 1E+12 1 0 1E+13 1 0 1E+14 1 0 1E+15 1 0 0.000000987654321 1E-15 0 0.000000987654321 1E-14 0 0.000000987654321 1E-13 0 0.000000987654321 1E-12 0 0.000000987654321 1E-11 0 0.000000987654321 1E-10 0 0.000000987654321 1E-9 0 0.000000987654321 1E-8 0 0.000000987654321 1E-7 0 0.000000987654321 1E-6 1 0.000000987654321 1E-5 1 0.000000987654321 1E-4 1 0.000000987654321 1E-3 1 0.000000987654321 1E-2 1 0.000000987654321 1E-1 1 0.000000987654321 1E-0 1 0.000000987654321 1E+1 1 0.000000987654321 1E+2 1 0.000000987654321 1E+3 1 0.000000987654321 1E+4 1 12 12.2345 1 12.0 12.2345 1 12.00 12.2345 1 12.000 12.2345 1 12.0000 12.2345 1 12.00000 12.2345 1 12.000000 12.2345 1 12.0000000 12.2345 1 12.00000000 12.2345 1 12.000000000 12.2345 1 12.1234 12 0 12.1234 12.0 0 12.1234 12.00 0 12.1234 12.000 0 12.1234 12.0000 0 12.1234 12.00000 0 12.1234 12.000000 0 12.1234 12.0000000 0 12.1234 12.00000000 0 12.1234 12.000000000 0 -12 -12.2345 0 -12.0 -12.2345 0 -12.00 -12.2345 0 -12.000 -12.2345 0 -12.0000 -12.2345 0 -12.00000 -12.2345 0 -12.000000 -12.2345 0 -12.0000000 -12.2345 0 -12.00000000 -12.2345 0 -12.000000000 -12.2345 0 -12.1234 -12 1 -12.1234 -12.0 1 -12.1234 -12.00 1 -12.1234 -12.000 1 -12.1234 -12.0000 1 -12.1234 -12.00000 1 -12.1234 -12.000000 1 -12.1234 -12.0000000 1 -12.1234 -12.00000000 1 -12.1234 -12.000000000 1 0 0 0 0 -0 0 0 -0.0 0 0 0.0 0 -0 0 0 -0 -0 0 -0 -0.0 0 -0 0.0 0 0.0 0 0 0.0 -0 0 0.0 -0.0 0 0.0 0.0 0 -0.0 0 0 -0.0 -0 0 -0.0 -0.0 0 -0.0 0.0 0 -0E1 0.0 0 -0E2 0.0 0 0E1 0.0 0 0E2 0.0 0 -0E1 0 0 -0E2 0 0 0E1 0 0 0E2 0 0 -0E1 -0E1 0 -0E2 -0E1 0 0E1 -0E1 0 0E2 -0E1 0 -0E1 -0E2 0 -0E2 -0E2 0 0E1 -0E2 0 0E2 -0E2 0 -0E1 0E1 0 -0E2 0E1 0 0E1 0E1 0 0E2 0E1 0 -0E1 0E2 0 -0E2 0E2 0 0E1 0E2 0 0E2 0E2 0 # long number checks (decimal32) 12345678000 1 0 1 12345678000 1 1234567800 1 0 1 1234567800 1 1234567890 1 0 1 1234567890 1 1234567891 1 0 1 1234567891 1 12345678901 1 0 1 12345678901 1 1234567896 1 0 1 1234567896 1 -1234567891 1 1 1 -1234567891 0 -12345678901 1 1 1 -12345678901 0 -1234567896 1 1 1 -1234567896 0 # long number checks (decimal64) 12345678000 1 0 1 12345678000 1 1234567800 1 0 1 1234567800 1 1234567890 1 0 1 1234567890 1 1234567891 1 0 1 1234567891 1 12345678901 1 0 1 12345678901 1 1234567896 1 0 1 1234567896 1 # long number checks (decimal128) -36852134.84194296250843579428931 -5830629.8347085025808756560357940 1 -36852134.84194296250843579428931 -36852134.84194296250843579428931 0 -36852134.94194296250843579428931 -36852134.84194296250843579428931 0 decimal32 -36852134.94194296250843579428931 -36852134.84194296250843579428931 1 decimal64 decimal128 -36852134.84194296250843579428931 -36852134.94194296250843579428931 0 # residue case 1 0.9999999 0 1 0.999999 0 1 0.99999 0 1 1.0000 0 1 1.00001 1 1 1.000001 1 1 1.0000001 0 decimal32 1 1.0000001 1 decimal64 decimal128 0.9999999 1 1 0.999999 1 1 0.99999 1 1 1.0000 1 0 1.00001 1 0 1.000001 1 0 1.0000001 1 0 # special cases Inf -1000 0 Inf -1 0 Inf -0 0 Inf 0 0 Inf 1 0 Inf 1000 0 Inf Inf 0 -1000 Inf 1 -Inf Inf 1 -1 Inf 1 -0 Inf 1 0 Inf 1 1 Inf 1 1000 Inf 1 -Inf -Inf 0 -Inf -1000 1 -Inf -1 1 -Inf -0 1 -Inf 0 1 -Inf 1 1 -Inf 1000 1 -1000 -Inf 0 -1 -Inf 0 -0 -Inf 0 0 -Inf 0 1 -Inf 0 1000 -Inf 0 Inf -Inf 0 NaN -Inf 0 NaN -1000 0 NaN -1 0 NaN -0 0 NaN 0 0 NaN 1 0 NaN 1000 0 NaN Inf 0 NaN NaN 0 -Inf NaN 0 -1000 NaN 0 -1 NaN 0 -0 NaN 0 0 NaN 0 1 NaN 0 1000 NaN 0 Inf NaN 0 -NaN -NaN 0 +NaN -NaN 0 -NaN +NaN 0 libdfp-1.0.12/tests/islessequal.input000066400000000000000000000161131261375163000176160ustar00rootroot00000000000000# name islessequal # arg1 decimal # arg2 decimal # ret int -2 -2 1 -2 -1 1 -2 0 1 -2 1 1 -2 2 1 -1 -2 0 -1 -1 1 -1 1 1 -1 2 1 0 -2 0 0 -1 0 0 0 1 0 1 1 0 2 1 1 -2 0 1 -1 0 1 0 0 1 1 1 1 2 1 2 -2 0 2 -1 0 2 0 0 2 1 0 2 2 1 -200 -200 1 -200 -100 1 -200 0 1 -200 100 1 -200 200 1 -100 -200 0 -100 -100 1 -100 100 1 -100 200 1 0 -200 0 0 -100 0 0 0 1 0 100 1 0 200 1 100 -200 0 100 -100 0 100 0 0 100 100 1 100 200 1 200 -200 0 200 -100 0 200 0 0 200 100 0 200 200 1 # some differing length/exponent cases 7.0 7.0 1 7.0 7 1 7 7.0 1 7E+0 7.0 1 70E-1 7.0 1 0.7E+1 7 1 70E-1 7 1 7.0 7E+0 1 7.0 70E-1 1 7 0.7E+1 1 7 70E-1 1 8.0 7.0 0 8.0 7 0 8 7.0 0 8E+0 7.0 0 80E-1 7.0 0 0.8E+1 7 0 80E-1 7 0 8.0 7E+0 0 8.0 70E-1 0 8 0.7E+1 0 8 70E-1 0 8.0 9.0 1 8.0 9 1 8 9.0 1 8E+0 9.0 1 80E-1 9.0 1 0.8E+1 9 1 80E-1 9 1 8.0 9E+0 1 8.0 90E-1 1 8 0.9E+1 1 8 90E-1 1 7.0 -7.0 0 7.0 -7 0 7 -7.0 0 7E+0 -7.0 0 70E-1 -7.0 0 .7E+1 -7 0 70E-1 -7 0 7.0 -7E+0 0 7.0 -70E-1 0 7 -.7E+1 0 7 -70E-1 0 8.0 -7.0 0 8.0 -7 0 8 -7.0 0 8E+0 -7.0 0 80E-1 -7.0 0 .8E+1 -7 0 80E-1 -7 0 8.0 -7E+0 0 8.0 -70E-1 0 8 -.7E+1 0 8 -70E-1 0 8.0 -9.0 0 8.0 -9 0 8 -9.0 0 8E+0 -9.0 0 80E-1 -9.0 0 .8E+1 -9 0 80E-1 -9 0 8.0 -9E+0 0 8.0 -90E-1 0 8 -.9E+1 0 8 -90E-1 0 -7.0 -7.0 1 -7.0 -7 1 -7 -7.0 1 -7E+0 -7.0 1 -70E-1 -7.0 1 -.7E+1 -7 1 -70E-1 -7 1 -7.0 -7E+0 1 -7.0 -70E-1 1 -7 -.7E+1 1 -7 -70E-1 1 -8.0 -7.0 1 -8.0 -7 1 -8 -7.0 1 -8E+0 -7.0 1 -80E-1 -7.0 1 -.8E+1 -7 1 -80E-1 -7 1 -8.0 -7E+0 1 -8.0 -70E-1 1 -8 -.7E+1 1 -8 -70E-1 1 -8.0 -9.0 0 -8.0 -9 0 -8 -9.0 0 -8E+0 -9.0 0 -80E-1 -9.0 0 -.8E+1 -9 0 -80E-1 -9 0 -8.0 -9E+0 0 -8.0 -90E-1 0 -8 -.9E+1 0 -8 -90E-1 0 123.4560000000000000E789 123.456E789 1 decimal128 123.456000000000000E-89 123.456E-89 1 decimal64 decimal128 123.45600000000000E789 123.456E789 1 decimal128 123.4560000000000E-89 123.456E-89 1 decimal64 decimal128 123.456000000000E789 123.456E789 1 decimal128 123.45600000000E-89 123.456E-89 1 123.4560000000E789 123.456E789 1 decimal128 123.456000000E-89 123.456E-89 1 123.45600000E789 123.456E789 1 decimal128 123.4560000E-89 123.456E-89 1 123.456000E789 123.456E789 1 decimal128 123.45600E-89 123.456E-89 1 123.4560E789 123.456E789 1 decimal128 123.456E-89 123.456E-89 1 123.456E-89 123.4560000000000E-89 1 123.456E789 123.4560000000000E789 1 decimal128 123.456E-89 123.45600000000000E-89 1 123.456E789 123.4560000000000E789 1 decimal128 123.456E-89 123.456000000000E-89 1 123.456E789 123.45600000000E789 1 decimal128 123.456E-89 123.4560000000E-89 1 123.456E789 123.456000000E789 1 decimal128 123.456E-89 123.45600000E-89 1 123.456E789 123.4560000E789 1 decimal128 123.456E-89 123.456000E-89 1 123.456E789 123.45600E789 1 decimal128 123.456E-89 123.4560E-89 1 123.456E789 123.456E789 1 decimal128 1 1E-15 0 1 1E-14 0 1 1E-13 0 1 1E-12 0 1 1E-11 0 1 1E-10 0 1 1E-9 0 1 1E-8 0 1 1E-7 0 1 1E-6 0 1 1E-5 0 1 1E-4 0 1 1E-3 0 1 1E-2 0 1 1E-1 0 1 1E-0 1 1 1E+1 1 1 1E+2 1 1 1E+3 1 1 1E+4 1 1 1E+5 1 1 1E+6 1 1 1E+7 1 1 1E+8 1 1 1E+9 1 1 1E+10 1 1 1E+11 1 1 1E+12 1 1 1E+13 1 1 1E+14 1 1 1E+15 1 1E-15 1 1 1E-14 1 1 1E-13 1 1 1E-12 1 1 1E-11 1 1 1E-10 1 1 1E-9 1 1 1E-8 1 1 1E-7 1 1 1E-6 1 1 1E-5 1 1 1E-4 1 1 1E-3 1 1 1E-2 1 1 1E-1 1 1 1E-0 1 1 1E+1 1 0 1E+2 1 0 1E+3 1 0 1E+4 1 0 1E+5 1 0 1E+6 1 0 1E+7 1 0 1E+8 1 0 1E+9 1 0 1E+10 1 0 1E+11 1 0 1E+12 1 0 1E+13 1 0 1E+14 1 0 1E+15 1 0 0.000000987654321 1E-15 0 0.000000987654321 1E-14 0 0.000000987654321 1E-13 0 0.000000987654321 1E-12 0 0.000000987654321 1E-11 0 0.000000987654321 1E-10 0 0.000000987654321 1E-9 0 0.000000987654321 1E-8 0 0.000000987654321 1E-7 0 0.000000987654321 1E-6 1 0.000000987654321 1E-5 1 0.000000987654321 1E-4 1 0.000000987654321 1E-3 1 0.000000987654321 1E-2 1 0.000000987654321 1E-1 1 0.000000987654321 1E-0 1 0.000000987654321 1E+1 1 0.000000987654321 1E+2 1 0.000000987654321 1E+3 1 0.000000987654321 1E+4 1 12 12.2345 1 12.0 12.2345 1 12.00 12.2345 1 12.000 12.2345 1 12.0000 12.2345 1 12.00000 12.2345 1 12.000000 12.2345 1 12.0000000 12.2345 1 12.00000000 12.2345 1 12.000000000 12.2345 1 12.1234 12 0 12.1234 12.0 0 12.1234 12.00 0 12.1234 12.000 0 12.1234 12.0000 0 12.1234 12.00000 0 12.1234 12.000000 0 12.1234 12.0000000 0 12.1234 12.00000000 0 12.1234 12.000000000 0 -12 -12.2345 0 -12.0 -12.2345 0 -12.00 -12.2345 0 -12.000 -12.2345 0 -12.0000 -12.2345 0 -12.00000 -12.2345 0 -12.000000 -12.2345 0 -12.0000000 -12.2345 0 -12.00000000 -12.2345 0 -12.000000000 -12.2345 0 -12.1234 -12 1 -12.1234 -12.0 1 -12.1234 -12.00 1 -12.1234 -12.000 1 -12.1234 -12.0000 1 -12.1234 -12.00000 1 -12.1234 -12.000000 1 -12.1234 -12.0000000 1 -12.1234 -12.00000000 1 -12.1234 -12.000000000 1 0 0 1 0 -0 1 0 -0.0 1 0 0.0 1 -0 0 1 -0 -0 1 -0 -0.0 1 -0 0.0 1 0.0 0 1 0.0 -0 1 0.0 -0.0 1 0.0 0.0 1 -0.0 0 1 -0.0 -0 1 -0.0 -0.0 1 -0.0 0.0 1 -0E1 0.0 1 -0E2 0.0 1 0E1 0.0 1 0E2 0.0 1 -0E1 0 1 -0E2 0 1 0E1 0 1 0E2 0 1 -0E1 -0E1 1 -0E2 -0E1 1 0E1 -0E1 1 0E2 -0E1 1 -0E1 -0E2 1 -0E2 -0E2 1 0E1 -0E2 1 0E2 -0E2 1 -0E1 0E1 1 -0E2 0E1 1 0E1 0E1 1 0E2 0E1 1 -0E1 0E2 1 -0E2 0E2 1 0E1 0E2 1 0E2 0E2 1 # long number checks (decimal32) 12345678000 1 0 1 12345678000 1 1234567800 1 0 1 1234567800 1 1234567890 1 0 1 1234567890 1 1234567891 1 0 1 1234567891 1 12345678901 1 0 1 12345678901 1 1234567896 1 0 1 1234567896 1 -1234567891 1 1 1 -1234567891 0 -12345678901 1 1 1 -12345678901 0 -1234567896 1 1 1 -1234567896 0 # long number checks (decimal64) 12345678000 1 0 1 12345678000 1 1234567800 1 0 1 1234567800 1 1234567890 1 0 1 1234567890 1 1234567891 1 0 1 1234567891 1 12345678901 1 0 1 12345678901 1 1234567896 1 0 1 1234567896 1 # long number checks (decimal128) -36852134.84194296250843579428931 -5830629.8347085025808756560357940 1 -36852134.84194296250843579428931 -36852134.84194296250843579428931 1 -36852134.94194296250843579428931 -36852134.84194296250843579428931 1 -36852134.84194296250843579428931 -36852134.94194296250843579428931 1 decimal32 -36852134.84194296250843579428931 -36852134.94194296250843579428931 0 decimal64 decimal128 # residue case 1 0.9999999 0 1 0.999999 0 1 0.99999 0 1 1.0000 1 1 1.00001 1 1 1.000001 1 1 1.0000001 1 0.9999999 1 1 0.999999 1 1 0.99999 1 1 1.0000 1 1 1.00001 1 0 1.000001 1 0 1.0000001 1 1 decimal32 1.0000001 1 0 decimal64 decimal128 # special cases Inf -1000 0 Inf -1 0 Inf -0 0 Inf 0 0 Inf 1 0 Inf 1000 0 Inf Inf 1 -1000 Inf 1 -Inf Inf 1 -1 Inf 1 -0 Inf 1 0 Inf 1 1 Inf 1 1000 Inf 1 -Inf -Inf 1 -Inf -1000 1 -Inf -1 1 -Inf -0 1 -Inf 0 1 -Inf 1 1 -Inf 1000 1 -Inf Inf 1 -1000 -Inf 0 -1 -Inf 0 -0 -Inf 0 0 -Inf 0 1 -Inf 0 1000 -Inf 0 Inf -Inf 0 NaN -Inf 0 NaN -1000 0 NaN -1 0 NaN -0 0 NaN 0 0 NaN 1 0 NaN 1000 0 NaN Inf 0 NaN NaN 0 -Inf NaN 0 -1000 NaN 0 -1 NaN 0 -0 NaN 0 0 NaN 0 1 NaN 0 1000 NaN 0 Inf NaN 0 -NaN -NaN 0 +NaN -NaN 0 -NaN +NaN 0 libdfp-1.0.12/tests/isnan.input000066400000000000000000000003721261375163000163740ustar00rootroot00000000000000# name isnan # arg1 decimal # ret int Inf 0 -Inf 0 NaN 1 -NaN 1 sNaN 1 DEC_SUBNORMAL_MIN 0 DEC_MIN 0 DEC_MAX 0 0.1 0 10E1 0 libdfp-1.0.12/tests/issignaling.input000066400000000000000000000004531261375163000175730ustar00rootroot00000000000000# name issignaling # arg1 decimal # ret int Inf 0 -Inf 0 NaN 0 -NaN 0 sNaN 1 DEC_SUBNORMAL_MIN 0 DEC_MIN 0 DEC_MAX 0 0.0 0 -0.0 0 0.1 0 10E1 0 libdfp-1.0.12/tests/libdfp-test.c000066400000000000000000000267511261375163000165750ustar00rootroot00000000000000/* Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ /* Common setup for an individual test. */ #define COMMON_TEST_SETUP(FUNC_NAME, ARG_STR) \ char *test_name; \ if (asprintf (&test_name, "%s (%s)", #FUNC_NAME, (ARG_STR)) == -1) \ abort () /* Common cleanup after an individual test. */ #define COMMON_TEST_CLEANUP \ free (test_name) /* Run an individual test, including any required setup and checking of results, or loop over all tests in an array. */ #define RUN_TEST_f_f(FUNC_NAME, ARG_STR, ARG, EXPECTED) \ do { \ COMMON_TEST_SETUP (FUNC_NAME, ARG_STR); \ check_float (test_name, FUNC (FUNC_NAME) (ARG), EXPECTED); \ COMMON_TEST_CLEANUP; \ } while (0) #define RUN_TEST_ff_f(FUNC_NAME, ARG_STR, ARG1, ARG2, EXPECTED) \ do { \ COMMON_TEST_SETUP (FUNC_NAME, ARG_STR); \ check_float (test_name, FUNC (FUNC_NAME) (ARG1, ARG2), EXPECTED); \ COMMON_TEST_CLEANUP; \ } while (0) #define RUN_TEST_f_i(FUNC_NAME, ARG_STR, ARG, EXPECTED) \ do { \ COMMON_TEST_SETUP (FUNC_NAME, ARG_STR); \ check_int (test_name, FUNC (FUNC_NAME) (ARG), EXPECTED); \ COMMON_TEST_CLEANUP; \ } while (0) #define RUN_TEST_f_l(FUNC_NAME, ARG_STR, ARG, EXPECTED) \ do { \ COMMON_TEST_SETUP (FUNC_NAME, ARG_STR); \ check_long (test_name, FUNC (FUNC_NAME) (ARG), EXPECTED); \ COMMON_TEST_CLEANUP; \ } while (0) #define RUN_TEST_f_L(FUNC_NAME, ARG_STR, ARG, EXPECTED) \ do { \ COMMON_TEST_SETUP (FUNC_NAME, ARG_STR); \ check_longlong (test_name, FUNC (FUNC_NAME) (ARG), EXPECTED); \ COMMON_TEST_CLEANUP; \ } while (0) #define RUN_TEST_ff_b(FUNC_NAME, ARG_STR, ARG1, ARG2, EXPECTED) \ do { \ COMMON_TEST_SETUP (FUNC_NAME, ARG_STR); \ check_bool (test_name, FUNC (FUNC_NAME) (ARG1, ARG2), EXPECTED); \ COMMON_TEST_CLEANUP; \ } while (0) #define RUN_TEST_ff_i(FUNC_NAME, ARG_STR, ARG1, ARG2, EXPECTED) \ do { \ COMMON_TEST_SETUP (FUNC_NAME, ARG_STR); \ check_int (test_name, FUNC (FUNC_NAME) (ARG1, ARG2), EXPECTED); \ COMMON_TEST_CLEANUP; \ } while (0) #define MANT_DIG CHOOSE ((DEC128_MANT_DIG-1), (DEC64_MANT_DIG-1), (DEC32_MANT_DIG-1)) #define MIN_EXP CHOOSE ((DEC128_MIN_EXP-1), (DEC64_MIN_EXP-1), (DEC32_MIN_EXP-1)) #define PRINTF_EXPR CHOOSE ("DDe", "De", "He") #define PRINTF_NEXPR CHOOSE ("DDf", "Df", "Hf") #define PRINTF_XEXPR CHOOSE (".33DDe", ".15De", ".7He") /* TODO: Add set parse options. */ #define ulps_file_name "ULPs" /* Name of the ULPs file. */ static FILE *ulps_file; /* File to document difference. */ static int output_ulps; /* Should ulps printed? */ static int noErrors; /* number of errors */ static int noTests; /* number of tests (without testing exceptions) */ static int verbose = 99; static int output_points = 1; /* Should the single function results printed? */ /* Compare KEY (a string, with the name of a test or a function) with ULP (a pointer to a struct ulp_data structure), returning a value less than, equal to or greater than zero for use in bsearch. */ static int compare_ulp_data (const void *key, const void *ulp) { const char *keystr = key; const struct ulp_data *ulpdata = ulp; return strcmp (keystr, ulpdata->name); } /* Return the ulps for NAME in array DATA with NMEMB elements, or 0 if no ulps listed. */ static FLOAT find_ulps (const char *name, const struct ulp_data *data, size_t nmemb) { const struct ulp_data *entry = bsearch (name, data, nmemb, sizeof (*data), compare_ulp_data); if (entry == NULL) return 0; else return entry->max_ulp; } /* Return the ulps for test NAME. */ static FLOAT find_test_ulps (const char *name) { return find_ulps (name, test_ulps, sizeof (test_ulps) / sizeof (test_ulps[0])); } /* Returns the size of an ulp for VALUE. */ static FLOAT ulp (FLOAT value) { FLOAT ulp; switch (fpclassify (value)) { case FP_ZERO: /* We compute the distance to the next FP which is the same as the value of the smallest subnormal number. Previously we used 10^(-MANT_DIG) which is too large a value to be useful. Note that we can't use ilogb(0), since that isn't a valid thing to do. */ /* Fall through... */ case FP_SUBNORMAL: /* The next closest subnormal value is a constant distance away. */ /* TODO: check it */ ulp = FUNC(ldexp) (1.0DF, MIN_EXP - MANT_DIG); break; case FP_NORMAL: ulp = FUNC(ldexp) (1.0DF, FUNC(ilogb) (value) - (MANT_DIG) - 1); break; default: /* It should never happen. */ abort (); break; } return ulp; } static void print_ulps (const char *test_name, FLOAT ulp) { if (output_ulps) { fprintf (ulps_file, "Test \"%s\":\n", test_name); fprintf (ulps_file, "%s: %.0" PRINTF_NEXPR "\n", CHOOSE("decimal128", "decimal64", "decimal32"), FUNC(ceil) (ulp)); } } /* Should the message print to screen? This depends on the verbose flag, and the test status. */ static int print_screen (int ok) { if (output_points && (verbose > 1 || (verbose == 1 && ok == 0))) return 1; return 0; } /* Print a FLOAT. */ static void print_float (FLOAT f) { /* As printf doesn't differ between a sNaN and a qNaN, do this manually. */ if (issignaling (f)) printf ("sNaN\n"); else if (isnan (f)) printf ("qNaN\n"); else printf ("% .20" PRINTF_EXPR " %" PRINTF_XEXPR "\n", f, f); } /* Update statistic counters. */ static void update_stats (int ok) { ++noTests; if (!ok) ++noErrors; } /* Returns the number of ulps that GIVEN is away from EXPECTED. */ #define ULPDIFF(given, expected) \ (FUNC(fabs) ((given) - (expected)) / ulp (expected)) static void __attribute__((used)) check_float (const char *test_name, FLOAT computed, FLOAT expected) { int ok = 0; int print_diff = 0; FLOAT diff = 0; FLOAT ulps = 0; FLOAT max_ulp = find_test_ulps (test_name); if (issignaling (computed) && issignaling (expected)) ok = 1; else if (issignaling (computed) || issignaling (expected)) ok = 0; else if (isnan (computed) && isnan (expected)) ok = 1; else if (isinf (computed) && isinf (expected)) ok = 1; /* Don't calculate ULPs for infinities or any kind of NaNs. */ else if (isinf (computed) || isnan (computed) || isinf (expected) || isnan (expected)) ok = 0; else { diff = FUNC(fabs) (computed - expected); ulps = ULPDIFF (computed, expected); print_diff = 1; //if ((exceptions & IGNORE_ZERO_INF_SIGN) == 0 if (signbit(computed) != signbit (expected)) ok = 0; //else if (ulps <= 0.5 || (ulps <= max_ulp && !ignore_max_ulp)) else if ((ulps <= 0.5DF) || (ulps <= max_ulp)) ok = 1; else { ok = 0; print_ulps (test_name, ulps); } } if (print_screen (ok)) { if (!ok) printf ("Failure: "); printf ("Test: %s\n", test_name); printf ("Result:\n"); printf (" is: "); print_float (computed); printf (" should be: "); print_float (expected); if (print_diff) { printf (" difference: % .20" PRINTF_EXPR " %" PRINTF_XEXPR "\n", diff, diff); printf (" ulp : % .4" PRINTF_NEXPR "\n", ulps); printf (" max.ulp : % .4" PRINTF_NEXPR "\n", max_ulp); } } update_stats (ok); errno = 0; } /* Check that computed and expected values are equal (int values). */ static void __attribute__((used)) check_int (const char *test_name, int computed, int expected) { int ok = 0; noTests++; if (computed == expected) ok = 1; if (print_screen (ok)) { if (!ok) printf ("Failure: "); printf ("Test: %s\n", test_name); printf ("Result:\n"); printf (" is: %d\n", computed); printf (" should be: %d\n", expected); } update_stats (ok); errno = 0; } /* check that computed and expected values are equal (long int values) */ static void __attribute__((used)) check_long (const char *test_name, long int computed, long int expected) { int ok = 0; noTests++; if (computed == expected) ok = 1; if (print_screen (ok)) { if (!ok) printf ("Failure:"); printf ("Test: %s\n", test_name); printf ("Result:\n"); printf (" is: %ld\n", computed); printf (" should be: %lxd\n", expected); } update_stats (ok); } /* check that computed and expected values are equal (long int values) */ static void __attribute__((used)) check_longlong (const char *test_name, long long int computed, long long int expected) { int ok = 0; noTests++; if (computed == expected) ok = 1; if (print_screen (ok)) { if (!ok) printf ("Failure:"); printf ("Test: %s\n", test_name); printf ("Result:\n"); printf (" is: %lld\n", computed); printf (" should be: %lld\n", expected); } update_stats (ok); } /* Check that computed value is true/false. */ static void __attribute__((used)) check_bool (const char *test_name, int computed, int expected) { int ok = 0; noTests++; if ((computed == 0) == (expected == 0)) ok = 1; if (print_screen (ok)) { if (!ok) printf ("Failure: "); printf ("Test: %s\n", test_name); printf ("Result:\n"); printf (" is: %d\n", computed); printf (" should be: %d\n", expected); } update_stats (ok); } libdfp-1.0.12/tests/llogb.input000066400000000000000000000024361261375163000163660ustar00rootroot00000000000000# name llogb # arg1 decimal # ret longint Inf LONG_MAX -Inf LONG_MIN NaN FP_LLOGBNAN sNaN FP_LLOGBNAN 0 FP_LLOGB0 0.0 FP_LLOGB0 0E0 FP_LLOGB0 1.0 0 10.76 1 1024.0 3 20000.001 4 400032.003 5 1E32 32 1.56E32 32 -1.56E32 32 1E-32 -32 1.54E-32 -32 -1.54E-32 -32 156E32 34 -156E32 34 154E-32 -30 -154E-32 -30 1.542332E124 124 decimal64 decimal128 -1.542332E124 124 decimal64 decimal128 1.542332E-124 -124 decimal64 decimal128 -1.542332E-124 -124 decimal64 decimal128 15423.32E124 128 decimal64 decimal128 -15423.32E124 128 decimal64 decimal128 15423.32E-124 -120 decimal64 decimal128 -15423.32E-124 -120 decimal64 decimal128 1.9433E1024 1024 decimal128 -1.9433E1024 1024 decimal128 1.9433E-1024 -1024 decimal128 -1.9433E-1024 -1024 decimal128 194338E1024 1029 decimal128 -194338E1024 1029 decimal128 194338E-1024 -1019 decimal128 -194338E-1024 -1019 decimal128 libdfp-1.0.12/tests/llquantexp.input000066400000000000000000000035631261375163000174660ustar00rootroot00000000000000# name llquantexp # arg1 decimal # ret llongint Inf LLONG_MIN -Inf LLONG_MIN NaN LLONG_MIN sNaN LLONG_MIN DEC_SUBNORMAL_MIN -DEC_MIN_EXP_SUB # DEC32_MIN_EXP is -94, but DEC32_MIN is 1E-95DF # DEC64_MIN_EXP is -382, but DEC64_MIN is 1E-383DD # DEC128_MIN_EXP is -6142, but DEC32_MIN is 1E-6143DL DEC_MIN -DEC_MIN_EXP DEC_MAX DEC_MAX_EXP 0.1 -1 0.25 -2 0.625 -3 9.1 -1 9.25 -2 9.625 -3 97.1525 -4 9.15256 -5 9.152456 -6 -20.971525 -6 decimal64 decimal128 -3599.6273704955 -10 decimal64 decimal128 359.962737049625 -12 decimal64 decimal128 -4503599627370495.5 -1 decimal128 4503599627370496.25 -2 decimal128 45035996.273704955 -9 decimal128 1E1 1 1E-1 -1 -1E1 1 -1E-1 -1 9.56E28 26 9.56E-28 -30 -9.56E28 26 -9.58E-28 -30 1E-DEC_MIN_EXP -DEC_MIN_EXP 1E+DEC_MAX_EXP DEC_MAX_EXP 9E343 343 decimal64 decimal128 9.56E343 341 decimal64 decimal128 -9E343 343 decimal64 decimal128 -9.56E343 341 decimal64 decimal128 9.5E-370 -371 decimal64 decimal128 9.567E-370 -373 decimal64 decimal128 9.567E-370 -373 decimal64 decimal128 -9.567E-370 -373 decimal64 decimal128 -9.5678E-370 -374 decimal64 decimal128 9.56789E6050 6045 decimal128 9.56789E-6050 -6055 decimal128 -9E-6050 -6050 decimal128 -9E-6050 -6050 decimal128 libdfp-1.0.12/tests/log.input000066400000000000000000000012561261375163000160470ustar00rootroot00000000000000# name log # arg1 decimal # ret decimal 0.75 -0.2876820724517809274392190059938274 1 0 2.718281828459045235360287471352662 1 3.141592653589793238462643383279503 1.144729885849400174143427351353059 2 0.6931471805599453094172321214581766 10 2.302585092994045684017991454684364 NaN NaN sNaN NaN Inf Inf 0.0 -Inf -1.0 NaN libdfp-1.0.12/tests/log10.input000066400000000000000000000016221261375163000162050ustar00rootroot00000000000000# name log10 # arg1 decimal # ret decimal 1 0 0.1 -1 0.01 -2 0.001 -3 10 1 100 2 1000 3 1.1e-09 -8.958607314841774959249800028756976 2.718281828459045235360287471352662 0.4342944819032518276511289189166050 3.141592653589793238462643383279503 0.4971498726941338543512682882908989 0.75 -0.1249387366082999531324498861938707 NaN NaN sNaN NaN Inf Inf 0.0 -Inf -1.0 NaN libdfp-1.0.12/tests/log1p.input000066400000000000000000000014521261375163000163060ustar00rootroot00000000000000# name log1p # arg1 decimal # ret decimal 0 0 -0 -0 -0.25 -0.2876820724517809274392190059938274 -0.875 -2.07944154167983592825169636437453 1.718281828459045235360287471352662 1 3.141592653589793238462643383279503 1.421080412794292633053772196333719 2 1.098612288668109691395245236922526 10 2.397895272798370544061943577965129 NaN NaN sNaN NaN Inf Inf -1.0 Inf -2.0 NaN libdfp-1.0.12/tests/logb.input000066400000000000000000000045161261375163000162130ustar00rootroot00000000000000# name logb # arg1 decimal # ret decimal 0 -Inf 1E-DEC_MIN_EXP -DEC_MIN_EXP 9E-DEC_MIN_EXP -DEC_MIN_EXP 0.001 -3 0.03 -2 1 0 2 0 2.5 0 2.50 0 10 1 70 1 100 2 250 2 Inf Inf -0 -Inf -1E-DEC_MIN_EXP -DEC_MIN_EXP -9E-DEC_MIN_EXP -DEC_MIN_EXP -0.001 -3 -1 0 -2 0 -10 1 -70 1 -100 2 -100000000 8 -Inf Inf 0 -Inf -0 -Inf 0E+4 -Inf -0E+4 -Inf 0.0000 -Inf -0.0000 -Inf 0E-141 -Inf -0E-141 -Inf 268268268 8 -268268268 8 134134134 8 -134134134 8 9.9999E+DEC_MAX_EXP DEC_MAX_EXP decimal64 decimal128 1E-DEC_MIN_EXP -DEC_MIN_EXP 1.0000E-DEC_MIN_EXP -DEC_MIN_EXP -1.000E-DEC_MIN_EXP -DEC_MIN_EXP -1E-DEC_MIN_EXP -DEC_MIN_EXP -9.999E+DEC_MAX_EXP DEC_MAX_EXP 1 0 1.0 0 1.000000000000000 0 1.000000000000000000 0 1 0 10 1 100 2 1000 3 10000 4 100000 5 1000000 6 10000000 7 100000000 8 1000000000 9 10000000000 10 100000000000 11 1000000000000 12 0.00000000001 -11 0.0000000001 -10 0.000000001 -9 0.00000001 -8 0.0000001 -7 0.000001 -6 0.00001 -5 0.0001 -4 0.001 -3 0.01 -2 0.1 -1 1E-DEC_MIN_EXP -DEC_MIN_EXP 10E-3 -2 10E-2 -1 100E-2 0 1000E-2 1 10000E-2 2 10E-1 0 100E-1 1 1000E-1 2 10000E-1 3 10E0 1 100E0 2 1000E0 3 10000E0 4 10E1 2 100E1 3 1000E1 4 10000E1 5 10E2 3 100E2 4 1000E2 5 10000E2 6 10000E2 6 1E+99 99 decimal64 decimal128 1E-99 -99 decimal64 decimal128 1E+100 1.0E+2 decimal64 decimal128 1E-100 -1.0E+2 decimal64 decimal128 1E-1111 -1.111E+3 decimal128 1E-3333 -3.333E+3 decimal128 Inf Inf -Inf Inf 0 -Inf NaN NaN sNaN NaN sNaN NaN -sNaN -NaN -NaN -NaN libdfp-1.0.12/tests/nearbyint.input000066400000000000000000000055211261375163000172600ustar00rootroot00000000000000# name nearbyint # arg1 decimal # ret decimal Inf Inf -Inf -Inf NaN NaN sNaN NaN 0.0 0.0 -0.0 -0.0 0.0 0.0 -0.0 -0.0 0.2 0.0 -0.2 -0.0 0.5 0.0 -0.5 -0.0 0.8 1.0 -0.8 -1.0 1.5 2.0 -1.5 -2.0 0.1 0.0 0.25 0.0 0.625 1.0 -0.1 -0.0 -0.25 -0.0 -0.625 -1.0 48576.75 48577.0 97152.75 97153.0 92472.75 92473.0 86220.75 86221.0 58792.75 58793.0 -48576.75 -48577.0 -97152.75 -97153.0 -92472.75 -92473.0 -86220.75 -86221.0 -58792.75 -58793.0 1048576.75 1048577.0 decimal64 decimal128 2097152.75 2097153.0 decimal64 decimal128 2492472.75 2492473.0 decimal64 decimal128 2886220.75 2886221.0 decimal64 decimal128 3058792.75 3058793.0 decimal64 decimal128 -1048576.75 -1048577.0 decimal64 decimal128 -2097152.75 -2097153.0 decimal64 decimal128 -2492472.75 -2492473.0 decimal64 decimal128 -2886220.75 -2886221.0 decimal64 decimal128 -3058792.75 -3058793.0 decimal64 decimal128 68744177664.75 68744177665.0 decimal64 decimal128 737488355328.75 737488355329.0 decimal64 decimal128 474976710656.75 474976710657.0 decimal64 decimal128 949953421312.75 949953421313.0 decimal64 decimal128 5899906842624.75 5899906842625.0 decimal64 decimal128 -68744177664.75 -68744177665.0 decimal64 decimal128 -737488355328.75 -737488355329.0 decimal64 decimal128 -474976710656.75 -474976710657.0 decimal64 decimal128 -949953421312.75 -949953421313.0 decimal64 decimal128 -899906842624.75 -899906842625.0 decimal64 decimal128 70368744177664.75 70368744177665.0 decimal128 140737488355328.75 140737488355329.0 decimal128 281474976710656.75 281474976710657.0 decimal128 562949953421312.75 562949953421313.0 decimal128 1125899906842624.75 1125899906842625.0 decimal128 -70368744177664.75 -70368744177665.0 decimal128 -140737488355328.75 -140737488355329.0 decimal128 -281474976710656.75 -281474976710657.0 decimal128 -562949953421312.75 -562949953421313.0 decimal128 -1125899906842624.75 -1125899906842625.0 decimal128 libdfp-1.0.12/tests/quantize.input000066400000000000000000000364201261375163000171270ustar00rootroot00000000000000# name quantize # arg1 decimal # arg2 decimal # ret decimal # TODO: add subnormal rounding testes 0 1e0 0 1 1e0 1 0.1 1e+2 0E+2 0.1 1e+1 0E+1 0.1 1e0 0 0.1 1e-1 0.1 0.1 1e-2 0.10 0.1 1e-3 0.100 0.9 1e+2 0E+2 0.9 1e+1 0E+1 0.9 1e+0 1 0.9 1e-1 0.9 0.9 1e-2 0.90 0.9 1e-3 0.900 -0.0 1e0 -0.0 -1.0 1e0 -1.0 -0.1 1e+2 -0E+2 -0.1 1e+1 -0E+1 -0.1 1e0 -0.0 -0.1 1e-1 -0.1 -0.1 1e-2 -0.10 -0.1 1e-3 -0.100 -0.9 1e+2 -0E+2 -0.9 1e+1 -0E+1 -0.9 1e+0 -1.0 -0.9 1e-1 -0.9 -0.9 1e-2 -0.90 -0.9 1e-3 -0.900 -0.5 1e+2 -0E+2 -0.5 1e+1 -0E+1 #-0.5 1e+0 -1 -0.5 1e-1 -0.5 -0.5 1e-2 -0.50 -0.5 1e-3 -0.500 -0.9 1e+2 -0E+2 -0.9 1e+1 -0E+1 -0.9 1e+0 -1.0 -0.9 1e-1 -0.9 -0.9 1e-2 -0.90 -0.9 1e-3 -0.900 2.17 0.001 2.170 2.17 0.01 2.17 2.17 0.1 2.2 2.17 1e+0 2 2.17 1e+1 0E+1 -Inf Inf -Inf 2 Inf NaN -0.1 1.0 -0.1 -0.1 1 -0.0 -0.0 1e+5 -0E+5 217 1e-1 217.0 217 1e+0 217 217 1e+1 2.2E+2 217 1e+2 2E+2 12 1e+4 0E+4 12 1e+3 0E+3 12 1e+2 0E+2 12 1e+1 1E+1 1.2345 1e-2 1.23 1.2355 1e-2 1.24 1.2345 1e-6 1.234500 9.9999 1e-2 10.00 0.0001 1e-2 0.00 0.001 1e-2 0.00 0.009 1e-2 0.01 92 1e+2 1E+2 -1 1e0 -1 -1 1e-1 -1.0 -1 1e-2 -1.00 0 1e0 0 0 1e-1 0.0 0 1e-2 0.00 0.00 1e0 0 0 1e+1 0E+1 0 1e+2 0E+2 +1 1e0 1 +1 1e-1 1.0 +1 1e-2 1.00 1.04 1e-3 1.040 1.04 1e-2 1.04 1.04 1e-1 1.0 1.04 1e0 1 1.05 1e-3 1.050 1.05 1e-2 1.05 1.05 1e-1 1 1.05 1e0 1 1.06 1e-3 1.060 1.06 1e-2 1.06 1.06 1e-1 1.1 1.06 1e0 1 -10 1e-2 -10.00 +1 1e-2 1.00 +10 1e-2 10.00 1E-10 1e-2 0.00 1E-3 1e-2 0.00 1E-2 1e-2 0.01 1E-1 1e-2 0.10 0E-10 1e-2 0.00 1.0600 1e-5 1.06000 1.0600 1e-4 1.0600 1.0600 1e-3 1.060 1.0600 1e-2 1.06 1.0600 1e-1 1.1 1.0600 1e0 1 # base tests with non-1 coefficients 0 -9e0 0 1 -7e0 1 0.1 -1e+2 0E+2 0.1 0e+1 0E+1 0.1 2e0 0 0.1 3e-1 0.1 0.1 44e-2 0.10 0.1 555e-3 0.100 0.9 6666e+2 0E+2 0.9 -777e+1 0E+1 0.9 -88e+0 1 0.9 -9e-1 0.9 0.9 0e-2 0.90 0.9 1.1e-3 0.9000 -0.0 1.1e0 -0.0 -1.0 -1e0 -1.0 -0.1 11e+2 -0E+2 -0.1 111e+1 -0E+1 -0.1 71e0 -0.0 -0.1 -91e-1 -0.1 -0.1 -.1e-2 -0.100 -0.1 -1e-3 -0.100 -0.9 0e+2 -0E+2 -0.9 -0e+1 -0E+1 -0.9 -10e+0 -1 -0.9 100e-1 -0.9 -0.9 999e-2 -0.90 -1 1e+0 -1 -1 1e+1 -0E+1 -1 1e+2 -0E+2 0 1e+0 0 0 1e+1 0E+1 0 1e+2 0E+2 +1 1e+0 1 +1 1e+1 0E+1 +1 1e+2 0E+2 1.04 1e+3 0E+3 1.04 1e+2 0E+2 1.04 1e+1 0E+1 1.04 1e+0 1 1.05 1e+3 0E+3 1.05 1e+2 0E+2 1.05 1e+1 0E+1 1.05 1e+0 1 1.05 1e+3 0E+3 1.05 1e+2 0E+2 1.05 1e+1 0E+1 1.05 1e+0 1 1.06 1e+3 0E+3 1.06 1e+2 0E+2 1.06 1e+1 0E+1 1.06 1e+0 1 -10 1e+1 -1E+1 +1 1e+1 0E+1 +10 1e+1 1E+1 1E+1 1e+1 1E+1 1E+2 1e+1 1.0E+2 1E+3 1e+1 1.00E+3 1E+4 1e+1 1.000E+4 1E+5 1e+1 1.0000E+5 1E+6 1e+1 1.00000E+6 1E+7 1e+1 1.000000E+7 1E+8 1e+1 qNaN decimal32 1E+8 1e+1 1.0000000E+8 decimal64 decimal128 1E+9 1e+1 qNaN decimal32 1E+9 1e+1 1.00000000E+9 decimal64 decimal128 # 1E+10 1e+1 NaN 1E-10 1e+1 0E+1 1E-2 1e+1 0E+1 0E-10 1e+1 0E+1 -0E-10 1e+1 -0E+1 -0E-1 1e+1 -0E+1 -0.0 1e+1 -0E+1 -0E+1 1e+1 -0E+1 -10 1e+2 -0E+2 +1 1e+2 0E+2 +10 1e+2 0E+2 1E+1 1e+2 0E+2 1E+2 1e+2 1E+2 1E+3 1e+2 1.0E+3 1E+4 1e+2 1.00E+4 1E+5 1e+2 1.000E+5 1E+6 1e+2 1.0000E+6 1E+7 1e+2 1.00000E+7 1E+8 1e+2 1.000000E+8 1E+9 1e+2 qNaN decimal32 1E+9 1e+2 1.0000000E+9 decimal64 decimal128 1E+10 1e+2 qNaN decimal32 1E+10 1e+2 1.00000000E+10 decimal64 decimal128 1E-10 1e+2 0E+2 1E-2 1e+2 0E+2 0E-10 1e+2 0E+2 -10 1e+3 -0E+3 +1 1e+3 0E+3 +10 1e+3 0E+3 1E+1 1e+3 0E+3 1E+2 1e+3 0E+3 1E+3 1e+3 1E+3 1E+4 1e+3 1.0E+4 1E+5 1e+3 1.00E+5 1E+6 1e+3 1.000E+6 1E+7 1e+3 1.0000E+7 1E+8 1e+3 1.00000E+8 1E+9 1e+3 1.000000E+9 1E+10 1e+3 qNaN decimal32 1E+10 1e+3 1.0000000E+10 decimal64 decimal128 1E-10 1e+3 0E+3 1E-2 1e+3 0E+3 0E-10 1e+3 0E+3 0.0078 1e-5 0.00780 0.0078 1e-4 0.0078 0.0078 1e-3 0.008 0.0078 1e-2 0.01 0.0078 1e-1 0.0 0.0078 1e0 0.0 0.0078 1e+1 0E+1 0.0078 1e+2 0E+2 -0.0078 1e-5 -0.00780 -0.0078 1e-4 -0.0078 -0.0078 1e-3 -0.008 -0.0078 1e-2 -0.01 -0.0078 1e-1 -0.0 -0.0078 1e0 -0.0 -0.0078 1e+1 -0E+1 -0.0078 1e+2 -0E+2 0.078 1e-5 0.07800 0.078 1e-4 0.0780 0.078 1e-3 0.078 0.078 1e-2 0.08 0.078 1e-1 0.1 0.078 1e0 0.0 0.078 1e+1 0E+1 0.078 1e+2 0E+2 -0.078 1e-5 -0.07800 -0.078 1e-4 -0.0780 -0.078 1e-3 -0.078 -0.078 1e-2 -0.08 -0.078 1e-1 -0.1 -0.078 1e0 -0.0 -0.078 1e+1 -0E+1 -0.078 1e+2 -0E+2 0.78 1e-5 0.78000 0.78 1e-4 0.7800 0.78 1e-3 0.780 0.78 1e-2 0.78 0.78 1e-1 0.8 0.78 1e0 1 0.78 1e+1 0E+1 0.78 1e+2 0E+2 -0.78 1e-5 -0.78000 -0.78 1e-4 -0.7800 -0.78 1e-3 -0.780 -0.78 1e-2 -0.78 -0.78 1e-1 -0.8 -0.78 1e0 -1 -0.78 1e+1 -0E+1 -0.78 1e+2 -0E+2 7.8 1e-5 7.80000 7.8 1e-4 7.8000 7.8 1e-3 7.800 7.8 1e-2 7.80 7.8 1e-1 7.8 7.8 1e0 8 7.8 1e+1 1E+1 7.8 1e+2 0E+2 7.8 1e+3 0E+3 -7.8 1e-5 -7.80000 -7.8 1e-4 -7.8000 -7.8 1e-3 -7.800 -7.8 1e-2 -7.80 -7.8 1e-1 -7.8 -7.8 1e0 -8 -7.8 1e+1 -1E+1 -7.8 1e+2 -0E+2 -7.8 1e+3 -0E+3 352364.506 1e-2 qNaN decimal32 352364.506 1e-2 352364.51 decimal64 decimal128 3523645.06 1e-2 qNaN decimal32 3523645.06 1e-2 3523645.06 decimal64 decimal128 -352364.506 1e-2 qNaN decimal32 -352364.506 1e-2 -352364.51 decimal64 decimal128 -3523645.06 1e-2 qNaN decimal32 -3523645.06 1e-2 -3523645.06 decimal64 decimal128 12.34567 1e-3 12.346 123.4567 1e-3 123.457 1234.567 1e-3 1234.567 9.999 1e-5 9.99900 9.999 1e-4 9.9990 9.999 1e-3 9.999 9.999 1e-2 10.00 9.999 1e-1 10.0 9.999 1e0 10 9.999 1e1 1E+1 9.999 1e2 0E+2 0.999 1e-5 0.99900 0.999 1e-4 0.9990 0.999 1e-3 0.999 0.999 1e-2 1.00 0.999 1e-1 1.0 0.999 1e0 1 0.999 1e1 0E+1 0.0999 1e-5 0.09990 0.0999 1e-4 0.0999 0.0999 1e-3 0.100 0.0999 1e-2 0.10 0.0999 1e-1 0.1 0.0999 1e0 0 0.0999 1e1 0E+1 0.00999 1e-5 0.00999 0.00999 1e-4 0.0100 0.00999 1e-3 0.010 0.00999 1e-2 0.01 0.00999 1e-1 0.0 0.00999 1e0 0 0.00999 1e1 0E+1 0.000999 1e-5 0.00100 0.000999 1e-4 0.0010 0.000999 1e-3 0.001 0.000999 1e-2 0.00 0.000999 1e-1 0.0 0.000999 1e0 0 0.000999 1e1 0E+1 12345678000 1e+3 qNaN decimal32 12345678000 1e+3 1.2345678E+10 decimal64 decimal128 1234567800 1e+1 qNaN decimal32 1234567800 1e+1 1.23456780E+9 decimal64 decimal128 1234567890 1e+1 qNaN decimal32 1234567890 1e+1 1.23456789E+9 decimal64 decimal128 1234567891 1e+1 qNaN decimal32 1234567891 1e+1 1.23456789E+9 decimal64 decimal128 12345678901 1e+2 qNaN decimal32 12345678901 1e+2 1.23456789E+10 decimal64 decimal128 1234567896 1e+1 qNaN decimal32 1234567896 1e+1 1.23456790E+9 decimal64 decimal128 1234.987643 1e-4 qNaN decimal32 1234.987643 1e-4 1234.9876 decimal64 decimal128 1234.987647 1e-4 qNaN decimal32 1234.987647 1e-4 1234.9876 decimal64 decimal128 12345678000 1e+3 qNaN decimal32 12345678000 1e+3 1.2345678E+10 decimal64 decimal128 1234567800 1e+1 qNaN decimal32 1234567800 1e+1 1.23456780E+9 decimal64 decimal128 1234567890 1e+1 qNaN decimal32 1234567890 1e+1 1.23456789E+9 decimal64 decimal128 1234567891 1e+1 qNaN decimal32 1234567891 1e+1 1.23456789E+9 decimal64 decimal128 12345678901 1e+2 qNaN decimal32 12345678901 1e+2 1.23456789E+10 decimal64 decimal128 1234567896 1e+1 qNaN decimal32 1234567896 1e+1 1.23456790E+9 decimal64 decimal128 1234.987643 1e-4 qNaN decimal32 1234.987643 1e-4 1234.9876 decimal64 decimal128 1234.987647 1e-4 qNaN decimal32 1234.987647 1e-4 1234.9876 decimal64 decimal128 0.0 1e1 0E+1 0.0 1e0 0.0 0.0 1e-1 0.0 0.0 1e-1 0.0 0.0 1e0 0.0 0.0 1e+1 0E+1 0E+1 1e-1 0.0 0E+1 1e0 0.0 0E+1 1e+1 0E+1 -0.0 1e1 -0E+1 -0.0 1e0 -0.0 -0.0 1e-1 -0.0 -0.0 1e-1 -0.0 -0.0 1e0 -0.0 -0.0 1e+1 -0E+1 -0E+1 1e-1 -0.0 -0E+1 1e0 -0.0 -0E+1 1e+1 -0E+1 1.234E+DEC_MAX_EXP 1eDEC_MAX_EXP 1E+DEC_MAX_EXP 1.234 1eDEC_MAX_EXP 0E+DEC_MAX_EXP 0 1e-DEC_MAX_EXP 0E-DEC_MAX_EXP 1.234 1e-DEC_MAX_EXP NaN Inf -Inf Inf Inf 1e-DEC_MIN_EXP NaN Inf 1e-1 NaN Inf 1e0 NaN Inf 1e1 NaN Inf 1eDEC_MAX_EXP NaN Inf Inf Inf -1000 Inf NaN -Inf Inf -Inf -1 Inf NaN 0 Inf NaN 1 Inf NaN 1000 Inf NaN Inf Inf Inf Inf 1e-0 NaN -0.0 Inf NaN -Inf -Inf -Inf -Inf 1e-DEC_MIN_EXP NaN -Inf 1e-1 NaN -Inf 1e0 NaN -Inf 1e1 NaN -Inf 1eDEC_MAX_EXP NaN -Inf Inf -Inf -1000 Inf NaN -Inf -Inf -Inf -1 -Inf NaN 0 -Inf NaN 1 -Inf NaN 1000 -Inf NaN Inf -Inf Inf -Inf 1e-0 NaN -0.0 -Inf NaN NaN -Inf NaN NaN 1e-DEC_MIN_EXP NaN NaN 1e-1 NaN NaN 1e0 NaN NaN 1e1 NaN NaN 1eDEC_MAX_EXP NaN NaN Inf NaN NaN NaN NaN -Inf NaN NaN -1000 NaN NaN -1 NaN NaN 0 NaN NaN 1 NaN NaN 1000 NaN NaN Inf NaN NaN NaN 1e-0 NaN -0.0 NaN NaN sNaN -Inf NaN sNaN 1e-DEC_MIN_EXP NaN sNaN 1e-1 NaN sNaN 1e0 NaN sNaN 1e1 NaN sNaN 1eDEC_MAX_EXP NaN sNaN NaN NaN sNaN sNaN NaN NaN sNaN NaN -Inf sNaN NaN -1000 sNaN NaN -1 sNaN NaN 0 sNaN NaN 1 sNaN NaN 1000 sNaN NaN Inf sNaN NaN NaN sNaN NaN sNaN 1e-0 NaN -0.0 sNaN NaN # decimal64 8.666666666666000E+384 1.000000000000000E+384 8.666666666666000E+384 decimal64 decimal128 8.666666666666000E+384 1E+384 8.666666666666000E+384 decimal64 decimal128 8.666666666666000E+323 1E+31 NaN decimal64 decimal128 8.66666666E+3 1E+10 0E10 decimal64 decimal128 8.66666666E+3 1E+3 9E+3 decimal64 decimal128 1E+17 1e+1 qNaN decimal64 1E+16 1e+1 1.0000000E+16 decimal64 decimal128 1E+18 1e+2 qNaN decimal64 1E+19 1e+2 qNaN decimal64 decimal128 352364567289012.506 1e-2 qNaN decimal64 35236458901.06 1e-2 3.52364589010600000000e+10 decimal64 decimal128 -352364567289012.506 1e-2 qNaN decimal64 -35236458901.06 1e-2 -3.52364589010600000000e+10 decimal64 decimal128 2147483646819039764 0 qNaN decimal64 -2147483646819039764 0 qNaN decimal64 # decimal128 1E+34 1e+1 1.0000000E+34 decimal128 1E+35 1e+1 qNaN decimal128 1E+35 1e+2 1.00000000000000000000e+35 decimal128 1E+36 1e+2 qNaN decimal128 35236456728901291950093363223832.506 1e-2 3.5236456728901291950093363223832510e+31 decimal128 3523645672890129195009336322383.06 1e-2 3.5236456728901291950093363223830600e+30 decimal128 -35236456728901291950093363223832.506 1e-2 -3.5236456728901291950093363223832510e+31 decimal128 -3523645672890129195009336322383.06 1e-2 -3.5236456728901291950093363223830600e+30 decimal128 2147483646819039764880028933478190.0 0 2147483646819039764880028933478190e+0 decimal128 -2147483646819039764880028933478190.0 0 -2147483646819039764880028933478190e+0 decimal128 # Int and uInt32 edge values for testing conversions -2147483646 0 qNaN decimal32 -2147483646 0 -2147483646 decimal64 decimal128 -2147483647 0 qNaN decimal32 -2147483647 0 -2147483647 decimal64 decimal128 -2147483648 0 qNaN decimal32 -2147483648 0 -2147483648 decimal64 decimal128 -2147483649 0 qNaN decimal32 -2147483649 0 -2147483649 decimal64 decimal128 2147483646 0 qNaN decimal32 2147483646 0 2147483646 decimal64 decimal128 2147483647 0 qNaN decimal32 2147483647 0 2147483647 decimal64 decimal128 2147483648 0 qNaN decimal32 2147483648 0 2147483648 decimal64 decimal128 2147483649 0 qNaN decimal32 2147483649 0 2147483649 decimal64 decimal128 4294967294 0 qNaN decimal32 4294967294 0 4294967294 decimal64 decimal128 4294967295 0 qNaN decimal32 4294967295 0 4294967295 decimal64 decimal128 4294967296 0 qNaN decimal32 4294967296 0 4294967296 decimal64 decimal128 4294967297 0 qNaN decimal32 4294967297 0 4294967297 decimal64 decimal128 # and powers of ten for same 5000000000 0 qNaN decimal32 5000000000 0 5000000000 decimal64 decimal128 4000000000 0 qNaN decimal32 4000000000 0 4000000000 decimal64 decimal128 2000000000 0 qNaN decimal32 2000000000 0 2000000000 decimal64 decimal128 1000000000 0 qNaN decimal32 1000000000 0 1000000000 decimal64 decimal128 100000000 0 qNaN decimal32 100000000 0 100000000 decimal64 decimal128 10000000 0 qNaN decimal32 10000000 0 10000000 decimal64 decimal128 1000000 0 1000000 100000 0 100000 10000 0 10000 1000 0 1000 100 0 100 10 0 10 1 0 1 0 0 0 # and powers of ten for same -5000000000 0 qNaN decimal32 -5000000000 0 -5000000000 decimal64 decimal128 -4000000000 0 qNaN decimal32 -4000000000 0 -4000000000 decimal64 decimal128 -2000000000 0 qNaN decimal32 -2000000000 0 -2000000000 decimal64 decimal128 -1000000000 0 qNaN decimal32 -1000000000 0 -1000000000 decimal64 decimal128 -100000000 0 qNaN decimal32 -100000000 0 -100000000 decimal64 decimal128 -10000000 0 qNaN decimal32 -10000000 0 -10000000 decimal64 decimal128 -1000000 0 -1000000 -100000 0 -100000 -10000 0 -10000 -1000 0 -1000 -100 0 -100 -10 0 -10 -1 0 -1 -0.0 0 -0.0 libdfp-1.0.12/tests/quantum.input000066400000000000000000000020571261375163000167600ustar00rootroot00000000000000# name quantum # arg1 decimal # ret decimal Inf Inf -Inf Inf NaN NaN sNaN sNaN DEC_MAX 1E+DEC_MAX_EXP DEC_MIN 1E-DEC_MIN_EXP DEC_SUBNORMAL_MIN 1E-DEC_MIN_EXP_SUB -DEC_MAX 1E+DEC_MAX_EXP -DEC_MIN 1E-DEC_MIN_EXP -DEC_SUBNORMAL_MIN 1E-DEC_MIN_EXP_SUB 1E1 10.0 1E0 1.0 0.25 0.01 0.625 0.001 97.1525 0.0001 18.12456 0.00001 20.971525 0.000001 decimal64 decimal128 3599.6273704955 1e-10 decimal64 decimal128 359.962737049625 1e-12 decimal64 decimal128 3.5443504567320123 1e-15 decimal64 decimal128 4503599627370495.5 0.1 decimal128 4503599627370.49625 0.00001 decimal128 45035996.273704955 1E-9 decimal128 4.5698456892345687912 1E-19 decimal128 libdfp-1.0.12/tests/round.input000066400000000000000000000032031261375163000164070ustar00rootroot00000000000000# name round # arg1 decimal # ret decimal Inf Inf -Inf -Inf NaN NaN sNaN NaN 0.0 0.0 -0.0 -0.0 0.2 0.0 -0.2 -0.0 0.5 1.0 -0.5 -1.0 0.8 1.0 -0.8 -1.0 1.5 2.0 -1.5 -2.0 0.1 0.0 0.25 0.0 0.625 1.0 -0.1 -0.0 -0.25 -0.0 -0.625 -1.0 1234.54 1235.0 -1234.54 -1235.0 97152.5 97153.0 -97152.5 -97153.0 -370495.5 -370496.0 -370496.25 -370496.0 -370496.5 -370497.0 -370496.75 -370497.0 -370497.5 -370498.0 2097152.5 2097153.0 decimal64 decimal128 -2097152.5 -2097153.0 decimal64 decimal128 -3599627370495.5 -3599627370496.0 decimal64 decimal128 -3599627370496.25 -3599627370496.0 decimal64 decimal128 -3599627370496.5 -3599627370497.0 decimal64 decimal128 -3599627370496.75 -3599627370497.0 decimal64 decimal128 -3599627370497.5 -3599627370498.0 decimal64 decimal128 -4503599627370495.5 -4503599627370496.0 decimal128 -4503599627370496.25 -4503599627370496.0 decimal128 -4503599627370496.5 -4503599627370497.0 decimal128 -4503599627370496.75 -4503599627370497.0 decimal128 -4503599627370497.5 -4503599627370498.0 decimal128 libdfp-1.0.12/tests/roundeven.input000066400000000000000000000031761261375163000172760ustar00rootroot00000000000000# name roundeven # arg1 decimal # ret decimal Inf Inf -Inf -Inf NaN NaN sNaN NaN 0.0 0.0 -0.0 -0.0 0.0 0.0 -0.0 -0.0 0.2 0.0 -0.2 -0.0 0.5 0.0 -0.5 -0.0 0.8 1.0 -0.8 -1.0 1.5 2.0 -1.5 -2.0 0.1 0.0 0.25 0.0 0.625 1.0 -0.1 -0.0 -0.25 -0.0 -0.625 -1.0 97152.5 97152.0 -97152.5 -97152.0 -370495.5 -370496.0 -370496.25 -370496.0 -370496.5 -370496.0 -370496.75 -370497.0 -370497.5 -370498.0 2097152.5 2097152.0 decimal64 decimal128 -2097152.5 -2097152.0 decimal64 decimal128 -3599627370495.5 -3599627370496.0 decimal64 decimal128 -3599627370496.25 -3599627370496.0 decimal64 decimal128 -3599627370496.5 -3599627370496.0 decimal64 decimal128 -3599627370496.75 -3599627370497.0 decimal64 decimal128 -3599627370497.5 -3599627370498.0 decimal64 decimal128 -4503599627370495.5 -4503599627370496.0 decimal128 -4503599627370496.25 -4503599627370496.0 decimal128 -4503599627370496.5 -4503599627370496.0 decimal128 -4503599627370496.75 -4503599627370497.0 decimal128 -4503599627370497.5 -4503599627370498.0 decimal128 libdfp-1.0.12/tests/samequantum.input000066400000000000000000000153411261375163000176260ustar00rootroot00000000000000# name samequantum # arg1 decimal # arg2 decimal # ret bool 0 0 1 0 1 1 1 0 1 1 1 1 10 1E+1 0 10E+1 10E+1 1 100 10E+1 0 100 1E+2 0 0.1 1E-2 0 0.1 1E-1 1 0.1 1E-0 0 999 999 1 999E-1 99.9 1 111E-1 22.2 1 111E-1 1234.2 1 0.0 1.1 1 0.0 1.11 0 0.0 0 0 0.0 0.0 1 0.0 0.00 0 0E+1 0E+0 0 0E+1 0E+1 1 0E+1 0E+2 0 0E-17 0E-16 0 0E-17 0E-17 1 0E-17 0E-18 0 0E-17 0.0E-15 0 0E-17 0.0E-16 1 0E-17 0.0E-17 0 -0E-17 0.0E-16 1 0E-17 -0.0E-17 0 0E-17 -0.0E-16 1 -0E-17 0.0E-17 0 -0E-17 -0.0E-16 1 -0E-17 -0.0E-17 0 DEC_MAX DEC_MAX 1 1E-DEC_MIN_EXP 1E-DEC_MIN_EXP 1 1.00000000E-DEC_MIN_EXP 1.00000000E-DEC_MIN_EXP 1 DEC_SUBNORMAL_MIN DEC_SUBNORMAL_MIN 1 DEC_MAX DEC_MAX 1 1E-DEC_MIN_EXP 1E-DEC_MIN_EXP 1 1.00000000E-DEC_MIN_EXP 1.00000000E-DEC_MIN_EXP 1 DEC_SUBNORMAL_MIN DEC_SUBNORMAL_MIN 1 -DEC_SUBNORMAL_MIN -DEC_SUBNORMAL_MIN 1 -1.00000000E-DEC_MIN_EXP -1.00000000E-DEC_MIN_EXP 1 -1E-DEC_MIN_EXP -1E-DEC_MIN_EXP 1 -DEC_MAX -DEC_MAX 1 -DEC_SUBNORMAL_MIN -DEC_SUBNORMAL_MIN 1 -1.00000000E-DEC_MIN_EXP 1.00000000E-DEC_MIN_EXP 1 -1E-DEC_MIN_EXP -1E-DEC_MIN_EXP 1 -DEC_MAX -DEC_MAX 1 -4.00000000E-DEC_MIN_EXP -1.00004000E-DEC_MIN_EXP 1 -4E-DEC_MIN_EXP -1E-DEC_MIN_EXP 1 -4.00000000E-DEC_MIN_EXP -1.00400000E-DEC_MIN_EXP 1 -4E-DEC_MIN_EXP -1E-DEC_MIN_EXP 1 -Inf -Inf 1 -Inf Inf 1 -Inf NaN 0 -Inf -7E+3 0 -Inf -7 0 -Inf -7E-3 0 -Inf -0E-3 0 -Inf -0 0 -Inf -0E+3 0 -Inf 0E-3 0 -Inf 0 0 -Inf 0E+3 0 -Inf 7E-3 0 -Inf 7 0 -Inf 7E+3 0 -Inf sNaN 0 Inf -Inf 1 Inf Inf 1 Inf NaN 0 Inf -7E+3 0 Inf -7 0 Inf -7E-3 0 Inf -0E-3 0 Inf -0 0 Inf -0E+3 0 Inf 0E-3 0 Inf 0 0 Inf 0E+3 0 Inf 7E-3 0 Inf 7 0 Inf 7E+3 0 Inf sNaN 0 NaN -Inf 0 NaN Inf 0 NaN NaN 1 NaN -7E+3 0 NaN -7 0 NaN -7E-3 0 NaN -0E-3 0 NaN -0 0 NaN -0E+3 0 NaN 0E-3 0 NaN 0 0 NaN 0E+3 0 NaN 7E-3 0 NaN 7 0 NaN 7E+3 0 NaN sNaN 1 -7E+3 -Inf 0 -7E+3 Inf 0 -7E+3 NaN 0 -7E+3 -7E+3 1 -7E+3 -7 0 -7E+3 -7E-3 0 -7E+3 -0E-3 0 -7E+3 -0 0 -7E+3 -0E+3 1 -7E+3 0E-3 0 -7E+3 0 0 -7E+3 0E+3 1 -7E+3 7E-3 0 -7E+3 7 0 -7E+3 7E+3 1 -7E+3 sNaN 0 -7 -Inf 0 -7 Inf 0 -7 NaN 0 -7 -7E+3 0 -7 -7 1 -7 -7E-3 0 -7 -0E-3 0 -7 -0 1 -7 -0E+3 0 -7 0E-3 0 -7 0 1 -7 0E+3 0 -7 7E-3 0 -7 7 1 -7 7E+3 0 -7 sNaN 0 -7E-3 -Inf 0 -7E-3 Inf 0 -7E-3 NaN 0 -7E-3 -7E+3 0 -7E-3 -7 0 -7E-3 -7E-3 1 -7E-3 -0E-3 1 -7E-3 -0 0 -7E-3 -0E+3 0 -7E-3 0E-3 1 -7E-3 0 0 -7E-3 0E+3 0 -7E-3 7E-3 1 -7E-3 7 0 -7E-3 7E+3 0 -7E-3 sNaN 0 -0E-3 -Inf 0 -0E-3 Inf 0 -0E-3 NaN 0 -0E-3 -7E+3 0 -0E-3 -7 0 -0E-3 -7E-3 1 -0E-3 -0E-3 1 -0E-3 -0 0 -0E-3 -0E+3 0 -0E-3 0E-3 1 -0E-3 0 0 -0E-3 0E+3 0 -0E-3 7E-3 1 -0E-3 7 0 -0E-3 7E+3 0 -0E-3 sNaN 0 -0 -Inf 0 -0 Inf 0 -0 NaN 0 -0 -7E+3 0 -0 -7 1 -0 -7E-3 0 -0 -0E-3 0 -0 -0 1 -0 -0E+3 0 -0 0E-3 0 -0 0 1 -0 0E+3 0 -0 7E-3 0 -0 7 1 -0 7E+3 0 -0 sNaN 0 -0E+3 -Inf 0 -0E+3 Inf 0 -0E+3 NaN 0 -0E+3 -7E+3 1 -0E+3 -7 0 -0E+3 -7E-3 0 -0E+3 -0E-3 0 -0E+3 -0 0 -0E+3 -0E+3 1 -0E+3 0E-3 0 -0E+3 0 0 -0E+3 0E+3 1 -0E+3 7E-3 0 -0E+3 7 0 -0E+3 7E+3 1 -0E+3 sNaN 0 0E-3 -Inf 0 0E-3 Inf 0 0E-3 NaN 0 0E-3 -7E+3 0 0E-3 -7 0 0E-3 -7E-3 1 0E-3 -0E-3 1 0E-3 -0 0 0E-3 -0E+3 0 0E-3 0E-3 1 0E-3 0 0 0E-3 0E+3 0 0E-3 7E-3 1 0E-3 7 0 0E-3 7E+3 0 0E-3 sNaN 0 0 -Inf 0 0 Inf 0 0 NaN 0 0 -7E+3 0 0 -7 1 0 -7E-3 0 0 -0E-3 0 0 -0 1 0 -0E+3 0 0 0E-3 0 0 0 1 0 0E+3 0 0 7E-3 0 0 7 1 0 7E+3 0 0 sNaN 0 0E+3 -Inf 0 0E+3 Inf 0 0E+3 NaN 0 0E+3 -7E+3 1 0E+3 -7 0 0E+3 -7E-3 0 0E+3 -0E-3 0 0E+3 -0 0 0E+3 -0E+3 1 0E+3 0E-3 0 0E+3 0 0 0E+3 0E+3 1 0E+3 7E-3 0 0E+3 7 0 0E+3 7E+3 1 0E+3 sNaN 0 7E-3 -Inf 0 7E-3 Inf 0 7E-3 NaN 0 7E-3 -7E+3 0 7E-3 -7 0 7E-3 -7E-3 1 7E-3 -0E-3 1 7E-3 -0 0 7E-3 -0E+3 0 7E-3 0E-3 1 7E-3 0 0 7E-3 0E+3 0 7E-3 7E-3 1 7E-3 7 0 7E-3 7E+3 0 7E-3 sNaN 0 7 -Inf 0 7 Inf 0 7 NaN 0 7 -7E+3 0 7 -7 1 7 -7E-3 0 7 -0E-3 0 7 -0 1 7 -0E+3 0 7 0E-3 0 7 0 1 7 0E+3 0 7 7E-3 0 7 7 1 7 7E+3 0 7 sNaN 0 7E+3 -Inf 0 7E+3 Inf 0 7E+3 NaN 0 7E+3 -7E+3 1 7E+3 -7 0 7E+3 -7E-3 0 7E+3 -0E-3 0 7E+3 -0 0 7E+3 -0E+3 1 7E+3 0E-3 0 7E+3 0 0 7E+3 0E+3 1 7E+3 7E-3 0 7E+3 7 0 7E+3 7E+3 1 7E+3 sNaN 0 sNaN -Inf 0 sNaN Inf 0 sNaN NaN 1 sNaN -7E+3 0 sNaN -7 0 sNaN -7E-3 0 sNaN -0E-3 0 sNaN -0 0 sNaN -0E+3 0 sNaN 0E-3 0 sNaN 0 0 sNaN 0E+3 0 sNaN 7E-3 0 sNaN 7 0 sNaN 7E+3 0 sNaN sNaN 1 sNaN sNaN 1 sNaN sNaN 1 NaN NaN 1 NaN NaN 1 sNaN 3 0 NaN 3 0 4 sNaN 0 3 NaN 0 Inf sNaN 0 -Inf NaN 0 libdfp-1.0.12/tests/scaffold.c000066400000000000000000000325201261375163000161300ustar00rootroot00000000000000/* Test facility scaffolding. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #include static int fail = 0; static int testnum = 0; /* String compare macros */ #ifndef _SC #include #include #include #include /* For CHAR_MAX. */ /* Generally don't invoke this directly unless you already have __LINE__ set in * a variable and want _SC_P to output it. The name stands for Compare with * Position. */ #define _SC_P(f,l,x,y) do { \ ++testnum; \ if(strcmp(x,y)) { \ fprintf(stderr, "%-3d Error: Expected: \"%s\"\n Result: \"%s\"\n in: %s:%d.\n\n", testnum,x,y,f,l); \ ++fail; \ } else { \ fprintf(stdout, "%-3d Success: Expected: \"%s\"\n Result: \"%s\"\n in: %s:%d.\n\n", testnum,x,y,f,l); \ } \ } while (0) #define _SC(x,y) _SC_P (__FILE__,__LINE__,x,y) #endif /* _SC */ #ifdef _WANT_OSC #ifndef __cplusplus #warning "_WANT_OSC only available #ifdef __cplusplus. _OSC and _OSC_P use ." #else /* __cplusplus */ #ifndef _OSC #include #define _OSC_P(f,l,x,y,precision,upper,spec) do { \ std::stringstream s; \ ios_base::fmtflags flags = s.flags(); \ if (precision > -1) \ s << setprecision(precision); \ if (upper == 'u') \ flags |= ios::uppercase; \ if (spec == 'f') \ flags |= ios::fixed; \ else if (spec == 'e') \ flags |= ios::scientific; \ else if (spec == 'a') \ flags |= (ios::scientific | ios::fixed); \ /* else if (spec == 'g') this is the default. */ \ s.flags(flags); \ s << y; \ _SC_P(f,l,x,s.str().c_str()); \ } while(0) /* _OSC == Ostream Compare * * Macro used to compare an ostream (operator<<) invocation with an expected * result. * * X: decimal[32|64|128] value * Y: Expected String * precision: Desired precision of output (can't exceed * __DEC[32|64|128]_MANT_DIG__. Equivalent to setprecision(x). * upper: 'l' is default. 'u' means uppercase; equivalent to ios::uppercase. * spec: 'g' is default. 'e' equivalent to ios::scientific, 'f' equivalent to * ios::fixed, 'a' is equivalent to ios::scientific | ios::fixed. * * e.g. * _OSC(4.000000000000000e+384DD, "4.000000000000000e384", -1, 'l', 'a'); * _OSC(4.000000000000000e+384DD, "4.000000000000000e384", -1, 'l', 'g'); * _OSC(4.000000000000000e+384DD, "4.00000e384", -1, 'l', 'f'); * _OSC(4.000000000000000e+384DD, "4.00000e384", -1, 'l', 'f'); * * Equivalent to the following example: * * _Decimal64 y = -9.999E-3DD; * std::stringstream s; * ios_base::fmtflags flags = s.flags(); * flags |= ios::fixed * flags |= ios::upper * s.flags(flags); * s << y; */ #define _OSC(x,y,precision,upper,spec) _OSC_P (__FILE__,__LINE__,x,y,precision,upper,spec) #endif /* _OSC */ #endif /* __cplusplus */ #endif /* _WANT_OSC */ #ifdef _WANT_ISC #ifndef __cplusplus #warning "_WANT_ISC only available #ifdef __cplusplus. _ISC and _ISC_P use ." #else /* __cplusplus */ #ifndef _ISC #include #define _WANT_VC 1 #define _ISC_P(f,l,x,y,z,fmt) do { \ std::stringstream s; \ /* Clear the stringstream. */ \ s.str(std::string()); \ /* Push the string to test onto the stream. */ \ s << y; \ /* invoke operator>>(istream &,decimal[32|64|128] &) */ \ s >> z; \ _VC_P_CPP(f,l,x,z,fmt); \ } while(0) /* _ISC == Istream Compare * * Macro used to compare an istream (operator>>) invocation with an expected * result. * * X: Expected decimal[32|64|128] value * Y: Input string * Z: Input temp decimal[32|64|128] used to store the result * fmt: format string for the decimal type. * e.g. * _ISC("-0.009999",-9.999E-3DD,z,fmt); * * Equivalent to the following example: * */ #define _ISC(x,y,z,fmt) _ISC_P (__FILE__,__LINE__,x,y,z,fmt) #endif /* _ISC */ #endif /* __cplusplus */ #endif /* _WANT_ISC */ #ifdef _WANT_PC static char buf[1024]; #ifndef _PC /* _PC == Printf_dfp Compare with Position */ #define _PC_P(f,l,x,y,args...) do { \ memset(buf,'\0',CHAR_MAX); \ /* Invokes printf dfp. */ \ sprintf(buf, y, ##args); \ _SC_P(f,l,x,buf); \ } while (0) /* _PC == Printf_dfp Compare * * Variadic macro used to compare a printf invocation with an expected result. * * X: Expected String * Y: Format String * ...: Argument list * * Use it like you'd use printf, except you include an 'expected result' string * to precede everything. * * e.g. * _PC("0.000033333","%DDf.\n", (_Decimal128) 0.00033333DL); * */ #define _PC(x,y,...) _PC_P (__FILE__,__LINE__,x,y,__VA_ARGS__) #endif /* _PC */ #endif /* _WANT_PC */ /* Approximate Value Compare (takes a variation limit) */ #ifdef _WANT_AVC static char bufx[CHAR_MAX]; static char bufy[CHAR_MAX]; static char bufz[CHAR_MAX]; #ifndef _AVC /* _AVC_P == Approximate Value Compare with Position */ #define _AVC_P(f,l,x,y,lim,fmt,lfmt) do { \ ++testnum; \ memset(bufx,'\0',CHAR_MAX); \ memset(bufy,'\0',CHAR_MAX); \ memset(bufz,'\0',CHAR_MAX); \ /* Invokes printf dfp. */ \ sprintf(bufx, fmt, x); \ sprintf(bufy, fmt, y); \ sprintf(bufz, lfmt, lim); \ if((y < (x-lim)) && (x > (y+lim))) { \ fprintf(stderr, "%-3d Error: Expected: \"%s\"\n", testnum, bufx); \ fprintf(stderr, " Result: \"%s\"\n", bufy); \ fprintf(stderr, " lim: \"%s\"\n", bufz); \ fprintf(stderr, " in: %s:%d.\n\n", f,l); \ ++fail; \ } else { \ fprintf(stdout, "%-3d Success: Expected: \"%s\"\n", testnum, bufx); \ fprintf(stdout, " Result: \"%s\"\n", bufy); \ fprintf(stderr, " lim: \"%s\"\n", bufz); \ fprintf(stdout, " in: %s:%d.\n\n", f,l); \ } \ } while (0) /* _AVC == Approximate Value Compare * * Macro used to compare the result of an operation against an approximate expected result. * X: Expected Value * Y: Actual Value * lim: The variation +/- from the expected that the actual can fall into for a * "success" */ #define _AVC(x,y,lim, fmt,lfmt) _AVC_P (__FILE__,__LINE__,x,y,lim, fmt,lfmt) #endif /* _AVC */ #endif /* _WANT_AVC */ #ifdef _WANT_VC static char bufx[CHAR_MAX]; static char bufy[CHAR_MAX]; #ifndef _VC /* _VC_P == Value Compare with Position */ #define _VC_P(f,l,x,y,fmt) do { \ ++testnum; \ memset(bufx,'\0',CHAR_MAX); \ memset(bufy,'\0',CHAR_MAX); \ /* Invokes printf dfp. */ \ sprintf(bufx, fmt, x); \ sprintf(bufy, fmt, y); \ if ((isnan(x) && isnan(y)) || \ (x == y)) \ { \ fprintf (stdout, "%-3d Success: Expected: \"%s\"\n", \ testnum, bufx); \ fprintf (stdout, " Result: \"%s\"\n", \ bufy); \ fprintf (stdout, "in: %s:%i\n\n", f, l); \ } \ else \ { \ fprintf (stderr, "%-3d Error: Expected: \"%s\"\n", \ testnum, bufx); \ fprintf (stderr, " Result: \"%s\"\n", \ bufy); \ fprintf (stderr, "in: %s:%i\n\n", f, l); \ ++fail; \ } \ } while (0) /* _VC_P_CPP == Value Compare with Position for C++ types */ #define _VC_P_CPP(f,l,x,y,fmt) do { \ ++testnum; \ memset(bufx,'\0',CHAR_MAX); \ memset(bufy,'\0',CHAR_MAX); \ /* Invokes printf dfp. */ \ sprintf(bufx, fmt, x); \ sprintf(bufy, fmt, y); \ if ((isnan(x.__getval()) && isnan(y.__getval())) || \ (x == y)) \ { \ fprintf (stdout, "%-3d Success: Expected: \"%s\"\n", \ testnum, bufx); \ fprintf (stdout, " Result: \"%s\"\n", \ bufy); \ fprintf (stdout, "in: %s:%i\n\n", f, l); \ } \ else \ { \ fprintf (stderr, "%-3d Error: Expected: \"%s\"\n", \ testnum, bufx); \ fprintf (stderr, " Result: \"%s\"\n", \ bufy); \ fprintf (stderr, "in: %s:%i\n\n", f, l); \ } \ } while (0) /* _VC == Value Compare * * Macro used to compare the result of an operation against an expected result. * X: Expected Value * Y: Actual Value */ #define _VC(x,y,fmt) _VC_P (__FILE__,__LINE__,x,y,fmt) #endif /* _VC */ #endif /* _WANT_VC */ #ifdef _WANT_QC #include /* To pick up __dfp_compatible(). */ /* Provide a polymorphic quantize() function. */ #define quantize(x) \ (!__dfp_compatible(x) \ ? DEC_NAN \ : (sizeof (x) == sizeof (_Decimal128) \ ? quantized128(x) \ : (sizeof (x) == sizeof (_Decimal64) \ ? quantized64(x) \ : quantized32(x))) \ ) /* TODO: Finish this. It doesn't do anything yet. The purpose is to be able to * get the result in the expected precision. */ static char bufx[CHAR_MAX]; static char bufy[CHAR_MAX]; #ifndef _QC /* _QC_P == Quantize Compare with Position */ #define _QC_P(f,l,x,y,fmt,type) do { \ ++testnum; \ memset(bufx,'\0',CHAR_MAX); \ memset(bufy,'\0',CHAR_MAX); \ /* Invokes printf dfp. */ \ sprintf(bufx, fmt, x); \ sprintf(bufy, fmt, y); \ if(x!=y) { \ fprintf(stderr, "%-3d Error: Expected: \"%s\"\n Result: \"%s\"\n in: %s:%d.\n\n", testnum, bufx,bufy,f,l); \ ++fail; \ } else { \ fprintf(stdout, "%-3d Success: Expected: \"%s\"\n Result: \"%s\"\n in: %s:%d.\n\n", testnum, bufx,bufy,f,l); \ } \ } while (0) /* _QC == Quantize Compare * * Macro used to compare the result of an operation against an expected result. * X: Expected Value * Y: Actual Value */ #define _QC(x,y,fmt) _QC_P (__FILE__,__LINE__,x,y,fmt) #endif /* _QC */ #endif /* _WANT_QC */ #ifdef _WANT_DC static char dbuf[CHAR_MAX]; #ifndef _DC /* _DC == Decoded[32|64|128] Compare */ /* Pick up the decoded[32|64|128] prototypes. */ #include "decode.h" /* _DC_P == decoded[32|64|128] Compare with Position. Use this if the position * is pre-determined. Don't call this on Non-_Decimal values. The outcome is * undefined. */ #define _DC_P(f,l,x,y) do { \ memset(dbuf,'\0',CHAR_MAX); \ /* Invoke the correct decoded{32|64|128]() based on arg size. */ \ (sizeof (y) == sizeof (_Decimal128)? decoded128(y,&dbuf[0]): \ (sizeof (y) == sizeof (_Decimal64)? decoded64(y,&dbuf[0]): \ decoded32(y,&dbuf[0]))); \ _SC_P(f,l,x,dbuf); \ } while (0) /* _DC == decoded[32|64|128] Compare * * Macro used to compare a decoded[32|64|128]() invocation with an * expected result. * * X: Expected decoded[32|64|128] Output String * Y: _Decimal[32|64|128] Argument * * It is like decoded[32|64|128], except you include an 'expected * result' string to precede everything and you don't need to define a buffer. * * e.g. * _DC("+0,000,000,000,000,000,000,000,000,000,000,100E-2", (_Decimal128) 1.00DL); * */ #define _DC(x,y) _DC_P (__FILE__,__LINE__,x,y) #endif /* _DC */ #endif /* _WANT_DC */ #ifndef _REPORT /* Don't print anything if there are no failures. */ #define _REPORT() do { \ if(fail) { \ fprintf(stderr, "Found %d failures.\n", fail); \ } \ } while (0) #endif /* _REPORT */ libdfp-1.0.12/tests/test-amort.c000066400000000000000000000215721261375163000164530ustar00rootroot00000000000000/* Amortization Benchmarck Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Peter Eberlein Steven Munroe Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ /* set -ex gcc -m64 -O2 -g -D__STDC_WANT_DEC_FP__=1 -std=gnu99 test_amort.c -ldfp -ldecnumber -lm -o test_amort64 gcc -m64 -O2 -g -D__STDC_WANT_DEC_FP__=1 -std=gnu99 test_amort.c -ldfp -ldecnumber -lm -o test_amort32 gcc -m64 -O2 -mcpu=power6 -g -D__STDC_WANT_DEC_FP__=1 -std=gnu99 test_amort.c -ldfp -ldecnumber -lm -o test_amort64P6 echo "generate input data" rm "amort.input" rm "test_amort.data" ./test_amort64 10000.0 0.075 5.0 ./test_amort64 15000.0 0.050 5.0 ./test_amort64 20000.0 0.065 5.0 ./test_amort64 25000.0 0.080 5.0 ./test_amort64 30000.0 0.090 5.0 ./test_amort64 80000.0 0.055 20.0 ./test_amort64 120000.0 0.055 20.0 ./test_amort64 150000.0 0.055 20.0 ./test_amort64 185000.0 0.055 20.0 ./test_amort64 199500.0 0.055 20.0 ./test_amort64 180000.0 0.055 30.0 ./test_amort64 199500.0 0.055 30.0 ./test_amort64 210000.0 0.055 30.0 ./test_amort64 350000.0 0.055 30.0 ./test_amort64 550000.0 0.055 30.0 echo "verify amortization tables" ./test_amort64 -v > test_amort.data diff test_amort.verify.data test_amort.data echo "$?" echo "performance testing" ./test_amort64 10000 exit */ #include #include #include #include #include #include typedef struct { _Decimal64 month, payment, interest_payed, principal_payed, principal, accum_principal, accum_interest; } tabletype; tabletype *table; typedef struct { _Decimal64 loan, rate, duration; } inputtype; static _Decimal64 armort_monthly_payment (_Decimal64 loan, _Decimal64 yearly_rate, _Decimal64 years) { _Decimal64 payment = -1.0DD; _Decimal64 months = years * 12.0DD; _Decimal64 monthly_rate = yearly_rate / 12.0DD; _Decimal64 temp0, temp1, temp2, temp3; temp0 = 1.0DD / (1.0DD + monthly_rate); #ifdef __DEBUG_PRINT__ printf ("1/(1+r) = %Df\n", temp0); #endif temp1 = 1.0DD - powd64 (temp0, months); #ifdef __DEBUG_PRINT__ printf ("1 - (1/(1+r))**n = %Df\n", temp1); #endif temp2 = temp1 / monthly_rate; #ifdef __DEBUG_PRINT__ printf ("(1 - (1/(1+r))**n)/r = %Df\n", temp2); #endif temp3 = loan / temp2; payment = quantized64 (temp3, 1.00DD); #ifdef __DEBUG_PRINT__ printf ("quantized64(%Df, 1.00DD) = %Df\n", temp3, payment); #endif return payment; } static void armort_monthly_table (_Decimal64 loan, _Decimal64 yearly_rate, _Decimal64 years, int format_enable, int print_enable) { _Decimal64 months = years * 12.0DD; _Decimal64 monthly_rate = yearly_rate / 12.0DD; _Decimal64 temp0; _Decimal64 principal, principal_payed, interest_payed; _Decimal64 accum_principal, accum_interest; _Decimal64 payment; char buf[80]; principal = loan; accum_principal = 0.0DD; accum_interest = 0.0DD; payment = armort_monthly_payment (loan, yearly_rate, years); if (format_enable) { snprintf(buf, 80, "Loan %Df at %Df for %Df years payments %Df", loan, yearly_rate, years, payment); if (print_enable) { printf ("\n%s\n", buf); } } for (temp0 = 0.0DD; temp0 < (months); temp0 += 1.0DD) { interest_payed = quantized64 ((principal * monthly_rate), 1.00DD); principal_payed = payment - interest_payed; principal -= principal_payed; accum_principal += principal_payed; accum_interest += interest_payed; if (temp0 >= (months - 1.0DD) && principal != 0.00DD) { payment += principal; accum_principal += principal; principal = 0.00DD; } if (format_enable) { snprintf(buf, 80, "%Df: %Df-%Df=%Df, total(%Df,%Df) balance=%Df", temp0, payment, interest_payed, principal_payed, accum_interest, accum_principal, principal); if (print_enable) printf ("%s\n", buf); } else { tabletype *t; t = table + (int) temp0; t->month = temp0; t->payment = payment; t->interest_payed = interest_payed; t->principal_payed = principal_payed; t->accum_interest = accum_interest; t->accum_principal = accum_principal; t->principal = principal; } } if ( principal > 0.0DD) { interest_payed = quantized64 ((principal * monthly_rate), 1.00DD); principal_payed = payment - interest_payed; principal -= principal_payed; accum_principal += principal_payed; accum_interest += interest_payed; if (principal != 0.00DD) { payment += principal; accum_principal += principal; principal = 0.00DD; } if (format_enable) { snprintf(buf, 80, "%Df: %Df-%Df=%Df, total(%Df,%Df) balance=%Df\n", temp0, payment, interest_payed, principal_payed, accum_interest, accum_principal, principal); if (print_enable) { printf ("%s\n", buf); } } } } static void armort_verifier (inputtype *inputs, int numinputs) { int i; for (i = 0; i < numinputs; i++) { inputtype *input = &inputs[i]; armort_monthly_table (input->loan, input->rate, input->duration, 1, 1); } } typedef long long msec_t; static msec_t getTimeOfDayMsec (void) { msec_t result, msecs; struct timeval time; int rc; rc = gettimeofday (&time, NULL); if (rc == 0) { msecs = (msec_t) ((time.tv_usec + 500) / 1000); result = (msec_t) (time.tv_sec); result = (result * 1000) + msecs; } else { result = 0; } return result; } int main (int argc, char *argv[]) { int i, iterations; msec_t startt, endt, deltat; double mill_sec; inputtype *inputs; int numinputs; FILE *inputfile; char inputfilename[] = "amort.input"; const char *argv_option; table = (tabletype *) malloc (30 * 12 * sizeof (tabletype)); //printf ("table@%p for %d bytes\n", table, (30 * 12 * sizeof (tabletype))); iterations = 50000; if (argc < 2) { printf ("This application requires parameters.\n"); return 0; } argv_option = argv[1]; if (*argv_option == '-') { argv_option++; if (*argv_option == 'v') ; else { printf ("only v is valid %s is not\n", argv[1]); return 2; } } else { argv_option = " "; if (argc >= 4) { inputtype input; input.loan = strtod64 (argv[1], NULL); input.rate = strtod64 (argv[2], NULL); input.duration = strtod64 (argv[3], NULL); if ( input.duration > 30.0DD) { printf ("Maximum duration is 30 years, exiting\n"); return 1; } inputfile = fopen (inputfilename, "a"); printf ("loan=%Df rate=%Df duration=%Df added to %s\n", input.loan, input.rate, input.duration, inputfilename); fwrite (&input, sizeof (inputtype), 1, inputfile); fclose (inputfile); return 0; } else { iterations = atoi (argv[1]); } } inputfile = fopen (inputfilename, "r"); fseek (inputfile, 0, SEEK_END); numinputs = ftell (inputfile) / sizeof (inputtype); rewind (inputfile); inputs = malloc (numinputs * sizeof (inputtype)); fread (inputs, sizeof (inputtype), numinputs, inputfile); fclose (inputfile); if (*argv_option == 'v') { armort_verifier(inputs, numinputs); return 0; } startt = getTimeOfDayMsec (); for (i = 0; i < iterations; i++) { inputtype *input = &inputs[i % numinputs]; /*printf ("armort_monthly_payment(%Df,%Df,%Df) = %Df\n", 169900.0DD, 0.0725DD, 30.0DD, 0, 0); */ armort_monthly_table (input->loan, input->rate, input->duration, 0, 0); } endt = getTimeOfDayMsec (); deltat = endt - startt; mill_sec = (double) deltat / 1000.0; printf (" %d iterations of amort w/o formating requires %12.3f seconds\n", iterations, mill_sec); startt = getTimeOfDayMsec (); for (i = 0; i < iterations; i++) { inputtype *input = &inputs[i % numinputs]; /*printf ("armort_monthly_payment(%Df,%Df,%Df) = %Df\n", 169900.0DD, 0.0725DD, 30.0DD, 0, 0); */ armort_monthly_table (input->loan, input->rate, input->duration, 1, 0); } endt = getTimeOfDayMsec (); deltat = endt - startt; mill_sec = (double) deltat / 1000.0; printf (" %d iterations of amort with formating requires %12.3f seconds\n", iterations, mill_sec); return 0; } libdfp-1.0.12/tests/test-bfp-conversions.c000066400000000000000000000555251261375163000204530ustar00rootroot00000000000000/* Test bfp -> dfp and dfp -> bfp conversions Copyright (C) 2011-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef __STDC_WANT_DEC_FP__ #define __STDC_WANT_DEC_FP__ #endif #define _WANT_VC 1 /* Pick up the _VC_P(x,y,fmt) macro. */ #include "scaffold.c" /* Pick up the _VC_P(x,y,fmt) macro. */ /* Inspired by GLIBC stdio-common/tfformat.c */ /* Test extendsfsd () - Single float to single decimal conversions, * i.e., float -> _Decimal32. */ typedef struct{ int line; float x; /* sf 'single float' value to convert. */ _Decimal32 e; /* sd 'single decimal' converted value. */ const char *format; /* printf %Hf */ } sfsd_type; sfsd_type sfsd_tests[] = { {__LINE__, 12.345, 12.345DF, "%He"}, {__LINE__, 12.345678, 12.345678DF, "%He"}, {__LINE__, 123456.7, 123456.7DF, "%He"}, {__LINE__, 999999.9, 999999.9DF, "%He"}, {__LINE__, 2.0, 2.0DF, "%He"}, {__LINE__, 30.0, 30.0DF, "%He"}, {__LINE__, 1.0e-20, 1.0e-20DF, "%He"}, {__LINE__, 1.0e-96, 0.0DF, "%He"}, {__LINE__, 3.402819e+38, 3.402819e+38DF, "%He"}, {__LINE__, 100000., 100000.0DF, "%He"}, {__LINE__, 999999., 999999.0DF, "%He"}, {__LINE__, 1.2e-38, 1.2e-38DF, "%He"}, {__LINE__, 1.1e-38, 1.1e-38DF, "%He"}, {__LINE__, -1.2e-38, -1.2e-38DF, "%He"}, {0,0,0,0 } }; /* Test extendsfdd () - Single float to double decimal conversions, * i.e., float -> _Decimal64. */ typedef struct{ int line; float x; /* sf 'single float' value to convert. */ _Decimal64 e; /* dd 'double decimal' converted value. */ const char *format; /* printf %Df */ } sfdd_type; sfdd_type sfdd_tests[] = { {__LINE__, 12.345, 12.345000267028809DD, "%De"}, {__LINE__, 30.0, 30.0DD, "%De"}, {__LINE__, 3.402819e+38f, 3.402819004255176e+38DD, "%De"}, {0,0,0,0 } }; /* Test extendsftd () - Single float to quad decimal conversions, * i.e., float -> _Decimal128. */ typedef struct{ int line; float x; /* sf 'single float' value to convert. */ _Decimal128 e; /* td 'quad decimal' converted value. */ const char *format; /* printf %DDf */ } sftd_type; sftd_type sftd_tests[] = { {__LINE__, 12.345, 12.3450002670288085937500000000000000DL, "%DDe"}, {__LINE__, 30.0, 30.0DL, "%DDe"}, {__LINE__, 3.402819e+38f, 3.402819004255175794749548566449886e+38DL, "%DDe"}, {0,0,0,0 } }; /* Test extenddfdd () - Double float to double decimal conversions, * i.e., double -> _Decimal64. */ typedef struct{ int line; double x; /* df 'double float' value to convert. */ _Decimal64 e; /* dd 'double decimal' converted value. */ const char *format; /* printf %Df */ } dfdd_type; dfdd_type dfdd_tests[] = { {__LINE__, 12.3456789, 12.3456789DD, "%De"}, {__LINE__, -2.0, -2.0DD, "%De"}, {__LINE__, 1.79768e+308, 1.79768e+308DD, "%De"}, {__LINE__, 100000000000000, 100000000000000.0DD, "%De"}, {__LINE__, 999999999999999, 999999999999999.0DD, "%De"}, {0,0,0,0 } }; /* Test extenddftd () - Double float to quad decimal conversions, * i.e., double -> _Decimal128. */ typedef struct{ int line; double x; /* df 'double float' value to convert. */ _Decimal128 e; /* td 'quad decimal' converted value. */ const char *format; /* printf %DDf */ } dftd_type; dftd_type dftd_tests[] = { {__LINE__, 12.3456789, 12.3456788999999993450273905182257295DL, "%DDe"}, {__LINE__, -2.0, -2.0DL, "%DDe"}, {__LINE__, 1.79768e+308, 1.797679999999999908416854000763986e+308DL, "%DDe"}, {0,0,0,0 } }; /* Test extendxftd () - long double float to quad decimal conversions, * i.e., long double -> _Decimal128. (x86) */ typedef struct{ int line; long double x; /* tf 'long double float' value to convert. */ _Decimal128 e; /* td 'quad decimal' converted value. */ const char *format; /* printf %DDe */ } xftd_type; xftd_type xftd_tests[] = { {__LINE__, 12.3456789, 12.3456788999999993450273905182257295DL, "%DDe"}, {__LINE__, -22.0, -22.0DL, "%DDe"}, {__LINE__, 100000000000000000, 100000000000000000.0DL, "%DDe"}, {__LINE__, 999999999999999999, 999999999999999999.0DL, "%DDe"}, {__LINE__, 100000000000000000000545460846592.0L, 100000000000000000000545460846592.0DL, "%DDe"}, {__LINE__, 999999999999999999970270236377088.0L, 999999999999999999970270236377088.0DL, "%DDe"}, {0,0,0,0 } }; /* Test extendtftd () - long double float to quad decimal conversions, * i.e., long double -> _Decimal128. */ typedef struct{ int line; long double x; /* tf 'long double float' value to convert. */ _Decimal128 e; /* td 'quad decimal' converted value. */ const char *format; /* printf %DDe */ } tftd_type; tftd_type tftd_tests[] = { {__LINE__, 12.3456789, 12.3456788999999993450273905182257295DL, "%DDe"}, {__LINE__, -22.0, -22.0DL, "%DDe"}, {__LINE__, 100000000000000000, 100000000000000000.0DL, "%DDe"}, {__LINE__, 999999999999999999, 999999999999999999.0DL, "%DDe"}, {__LINE__, 100000000000000000000000000000000.0L, 100000000000000000000000000000000.0DL, "%DDe"}, {__LINE__, 999999999999999999999999999999999.0L, 1000000000000000000000000000000000.0DL, "%DDe"}, {0,0,0,0 } }; /* Test extendsddf () - Single decimal to double float conversions, * i.e., _Decimal32 -> double. */ typedef struct{ int line; _Decimal32 x; /* sd 'single decimal' value to convert. */ double e; /* df 'double float' converted value. */ const char *format; /* printf %e */ } sddf_type; sddf_type sddf_tests[] = { {__LINE__, 12.345DF, 12.345, "%e"}, {__LINE__, 2.0DF, 2.0, "%e"}, {__LINE__, 3.402819e+38DF, 3.402819e+38, "%e"}, {__LINE__, 9.999998e96DF, 9.999998e96, "%e"}, {__LINE__, 100000.0DF, 100000, "%e"}, {__LINE__, 999999.0DF, 999999, "%e"}, {__LINE__, 1.e-39DF, 1.e-39, "%e"}, {__LINE__, -1.e-39DF, -1.e-39, "%e"}, {__LINE__, 1.2e-38DF, 1.2e-38, "%e"}, {__LINE__, 1.e-40DF, 1.e-40, "%e"}, {__LINE__, 8.e-44DF, 8.e-44, "%e"}, {__LINE__, 9.e-44DF, 9.e-44, "%e"}, {__LINE__, 8.e-46DF, 8.e-46, "%e"}, {__LINE__, -9.e-44DF, -9.e-44, "%e"}, {__LINE__, -8.e-46DF, -8.e-46, "%e"}, {0,0,0,0 } }; /* Test extenddddf () - Double decimal to double float conversions, * i.e., _Decimal64 -> double. */ typedef struct{ int line; _Decimal64 x; /* dd 'double decimal' value to convert. */ double e; /* df 'double float' converted value. */ const char *format; /* printf %e */ } dddf_type; dddf_type dddf_tests[] = { {__LINE__, -7.0DD, -7.0, "%De"}, {__LINE__, 3.402819e+38DD, 3.402819e+38, "%De"}, {__LINE__, 1.79768e+308DD, 1.79768e+308, "%De"}, {__LINE__, 100000000000000.0DD, 100000000000000, "%De"}, {__LINE__, 999999999999999.0DD, 999999999999999, "%De"}, {__LINE__, 1.e290DD, 1.e290, "%De"}, {__LINE__, 1.e291DD, 1.e291, "%De"}, {__LINE__, 1.e308DD, 1.e308, "%De"}, {__LINE__, 1.e-308DD, 1.e-308, "%De"}, {__LINE__, 1.e-291DD, 1.e-291, "%De"}, {__LINE__, 1.e-290DD, 1.e-290, "%De"}, {__LINE__, 1.e-39DD, 1.e-39, "%De"}, {__LINE__, -1.e-39DD, -1.e-39, "%De"}, {0,0,0,0 } }; #if __LDBL_MANT_DIG__ == 64 /* Test extendsdxf () - Single decimal to long double float conversions, * i.e., _Decimal32 -> long double. */ typedef struct{ int line; _Decimal32 x; /* sd 'single decimal' value to convert. */ const char *e;/* string with expected converted value. */ } sdxf_type; sdxf_type sdxf_tests[] = { {__LINE__, 12.345DF, "12.345000000000000000242861286636753"}, {__LINE__, 2.0DF, "2.000000000000000000000000000000000"}, {0,0,0 } }; /* Test extendddxf () - Double decimal to long double float conversions, * i.e., _Decimal64 -> long double. */ typedef struct{ int line; _Decimal64 x; /* dd 'double decimal' value to convert. */ const char *e;/* string with expected converted value. */ } ddxf_type; ddxf_type ddxf_tests[] = { {__LINE__, 12.3456789DD, "12.345678899999999999885502699470408"}, {__LINE__, -7.0DD, "-7.000000000000000000000000000000000"}, {0,0,0 } }; #elif __LDBL_MANT_DIG__ == 106 /* Test extendsdtf () - Single decimal to long double float conversions, * i.e., _Decimal32 -> long double. */ typedef struct{ int line; _Decimal32 x; /* sd 'single decimal' value to convert. */ long double e;/* df 'long double float' converted value. */ const char *format; /* printf %Le */ } sdtf_type; sdtf_type sdtf_tests[] = { {__LINE__, 12.345DF, 12.345, "%Le"}, {__LINE__, 2.0DF, 2.0, "%Le"}, {0,0,0,0 } }; /* Test extendddtf () - Double decimal to long double float conversions, * i.e., _Decimal64 -> long double. */ typedef struct{ int line; _Decimal64 x; /* dd 'double decimal' value to convert. */ long double e;/* df 'long double float' converted value. */ const char *format; /* printf %Le */ } ddtf_type; ddtf_type ddtf_tests[] = { {__LINE__, 12.3456789DD, 12.3456789, "%Le"}, {__LINE__, -7.0DD, -7.0, "%Le"}, {0,0,0,0 } }; #endif /* There is a lack of precision in division with long double on PowerPC. */ union precision_expected{ long double ld; double d[2]; }; /* Test extendtdtf () - Double decimal to long double float conversions, * i.e., _Decimal128 -> long double. */ typedef struct{ int line; _Decimal128 x; /* td 'quad decimal' value to convert. */ long double e;/* tf 'long double float' converted value. */ double ppce1; /* df 'double float' part of the expected value for ppc. */ double ppce2; /* df 'double float' part of the expected value for ppc. */ const char *format; /* printf %DDe */ } tdtf_type; tdtf_type tdtf_tests[] = { {__LINE__, 30.0DL, 30.0, 30, 0, "%DDe"}, /* 2**(-11) = 0.00048828125. */ {__LINE__, 0.00048828125DL, 0.00048828125L, 0.00048828125, 0, "%DDe"}, /* 2**(-25) = 0.298023223876953125E-7. */ {__LINE__, 2.98023223876953125E-8DL, 2.98023223876953125E-8, 2.9802322387695312e-08, 0, "%DDe"}, {__LINE__, 3.402819e+38DL, 3.402819e+38L, 3.4028189999999998e+38, 1.7176206731396606e+22, "%DDe"}, {__LINE__, 100000000000000000.0DL, 100000000000000000, 1e+17, 0, "%DDe"}, {__LINE__, 999999999999999999.0DL, 999999999999999999, 1e+18, -1, "%DDe"}, {__LINE__, 100000000000000000000000000000000.0DL, 100000000000000000000000000000000.L, 1.0000000000000001e+32, -5366162204393472, "%DDe"}, {__LINE__, 999999999999999999999999999999999.0DL, 999999999999999999999999999999999.L, 9.9999999999999995e+32, 54424769012957184, "%DDe"}, {__LINE__, 1.e290DL, 1.e290L, 1.0000000000000001e+290, -6.1727833527867157e+273, "%DDe"}, {__LINE__, 1.e-290DL, 1.e-290L, 1.0000000000000001e-290, -6.9127868599625479e-307, "%DDe"}, {__LINE__, 1.e-308DL, 1.e-308L, 9.9999999999999991e-309, 0, "%DDe"}, {__LINE__, 1.e-291DL, 1.e-291L, 9.9999999999999996e-292, 3.7675676608720188e-308, "%DDe"}, {__LINE__, 3.e-309DL, 3.e-309L, 3.0000000000000007e-309, 0, "%DDe"}, {__LINE__, -3.e-309DL, -3.e-309L, -3.0000000000000007e-309, 0, "%DDe"}, {0,0,0,0,0,0 } }; int main (void) { sfsd_type *sfsdp; sfdd_type *sfddp; sftd_type *sftdp; dfdd_type *dfddp; dftd_type *dftdp; sddf_type *sddfp; dddf_type *dddfp; #if defined(__DECIMAL_BID_FORMAT__) && __LDBL_MANT_DIG__ == 64 xftd_type *xftdp; sdxf_type *sdxfp; ddxf_type *ddxfp; #else tftd_type *tftdp; sdtf_type *sdtfp; ddtf_type *ddtfp; #endif tdtf_type *tdtfp; #include "decode.h" char decodebuf[256]; for (sfsdp = sfsd_tests; sfsdp->line; sfsdp++) { /* This will force the conversion and result in the hidden call to * __dpd_extendsfsd (). */ _Decimal32 retval = sfsdp->x; /* Broken into two because printf has a bug when you do %Hf and %f in the * same printf statement. */ fprintf(stdout, "%He = (_Decimal32) ", retval); fprintf(stdout, "%e; /* float */ in: %s: %d\n", (double) sfsdp->x,__FILE__,__LINE__-4); fprintf(stdout, "expected: %s\n", decoded32(sfsdp->e,decodebuf)); fprintf(stdout, "retval: %s\n", decoded32(retval,decodebuf)); _VC_P(__FILE__,sfsdp->line, sfsdp->e, retval, sfsdp->format); } for (sfddp = sfdd_tests; sfddp->line; sfddp++) { /* This will force the conversion and result in the hidden call to * __dpd_extendsfdd (). */ _Decimal64 retval = sfddp->x; /* Broken into two because printf has a bug when you do %Hf and %f in the * same printf statement. */ fprintf(stdout, "%De = (_Decimal64) ", retval); fprintf(stdout, "%e; /* float */ in: %s: %d\n", (double) sfddp->x,__FILE__,__LINE__-4); fprintf(stdout, "expected: %s\n", decoded64(sfddp->e,decodebuf)); fprintf(stdout, "retval: %s\n", decoded64(retval,decodebuf)); _VC_P(__FILE__,sfddp->line, sfddp->e, retval, sfddp->format); } for (sftdp = sftd_tests; sftdp->line; sftdp++) { /* This will force the conversion and result in the hidden call to * __dpd_extendsftd (). */ _Decimal128 retval = sftdp->x; /* Broken into two because printf has a bug when you do %Hf and %f in the * same printf statement. */ fprintf(stdout, "%DDe = (_Decimal128) ", retval); fprintf(stdout, "%e; /* float */ in: %s: %d\n", (double) sftdp->x,__FILE__,__LINE__-4); fprintf(stdout, "expected: %s\n", decoded128(sftdp->e,decodebuf)); fprintf(stdout, "retval: %s\n", decoded128(retval,decodebuf)); _VC_P(__FILE__,sftdp->line, sftdp->e, retval, sftdp->format); } for (dfddp = dfdd_tests; dfddp->line; dfddp++) { /* This will force the conversion and result in the hidden call to * __dpd_extenddfdd (). */ _Decimal64 retval = dfddp->x; /* Broken into two because printf has a bug when you do %Hf and %f in the * same printf statement. */ fprintf(stdout, "%De = (_Decimal64) ", retval); fprintf(stdout, "%e; /* double */ in: %s: %d\n", dfddp->x,__FILE__,__LINE__-4); fprintf(stdout, "expected: %s\n", decoded64(dfddp->e,decodebuf)); fprintf(stdout, "retval: %s\n", decoded64(retval,decodebuf)); _VC_P(__FILE__,dfddp->line, dfddp->e, retval, dfddp->format); } for (dftdp = dftd_tests; dftdp->line; dftdp++) { /* This will force the conversion and result in the hidden call to * __dpd_extenddftd (). */ _Decimal128 retval = dftdp->x; /* Broken into two because printf has a bug when you do %Hf and %f in the * same printf statement. */ fprintf(stdout, "%DDe = (_Decimal128) ", retval); fprintf(stdout, "%e; /* double */ in: %s: %d\n", dftdp->x,__FILE__,__LINE__-4); fprintf(stdout, "expected: %s\n", decoded128(dftdp->e,decodebuf)); fprintf(stdout, "retval: %s\n", decoded128(retval,decodebuf)); _VC_P(__FILE__,dftdp->line, dftdp->e, retval, dftdp->format); } for (sddfp = sddf_tests; sddfp->line; sddfp++) { /* This will force the conversion and result in the hidden call to * __dpd_extendsddf (). */ double retval = sddfp->x; /* Broken into two because printf has a bug when you do %Hf and %f in the * same printf statement. */ fprintf(stdout, "%e = (double) ", retval); fprintf(stdout, "%He; /* _Decimal32 */ in: %s: %d\n", sddfp->x,__FILE__,__LINE__-4); _VC_P(__FILE__,sddfp->line, sddfp->e, retval, sddfp->format); } for (dddfp = dddf_tests; dddfp->line; dddfp++) { /* This will force the conversion and result in the hidden call to * __dpd_extenddddf (). */ double retval = dddfp->x; /* Broken into two because printf has a bug when you do %Hf and %f in the * same printf statement. */ fprintf(stdout, "%e = (double) ", retval); fprintf(stdout, "%De; /* _Decimal64 */ in: %s: %d\n", dddfp->x,__FILE__,__LINE__-4); _VC_P(__FILE__,dddfp->line, dddfp->e, retval, dddfp->format); } /* Intel long double has a different precision than PowerPC long double. * Intel converts to xf (80 bits) and PowerPC converts to tf (128 bits).*/ #if defined(__DECIMAL_BID_FORMAT__) && __LDBL_MANT_DIG__ == 64 #define DECIMAL_PRINTF_BUF_SIZE 65 /* ((DECIMAL128_PMAX + 14) * 2) + 1 */ for (xftdp = xftd_tests; xftdp->line; xftdp++) { /* This will force the conversion and result in the hidden call to * __dpd_extendxftd (). */ _Decimal128 retval = xftdp->x; /* Broken into two because printf has a bug when you do %Hf and %f in the * same printf statement. */ fprintf(stdout, "%DDe = (_Decimal128) ", retval); fprintf(stdout, "%Le; /* long double */ in: %s: %d\n", xftdp->x,__FILE__,__LINE__-4); fprintf(stdout, "expected: %s\n", decoded128(xftdp->e,decodebuf)); fprintf(stdout, "retval: %s\n", decoded128(retval,decodebuf)); _VC_P(__FILE__,xftdp->line, xftdp->e, retval, xftdp->format); } for (sdxfp = sdxf_tests; sdxfp->line; sdxfp++) { /* This will force the conversion and result in the hidden call to * __bid_extendsdxf (). */ long double retval = sdxfp->x; /* Broken into two because printf has a bug when you do %Hf and %f in the * same printf statement. */ char value[DECIMAL_PRINTF_BUF_SIZE]; sprintf(value, "%.33Lf", retval); fprintf(stdout, "%Le = (long double) ", retval); fprintf(stdout, "%He; /* _Decimal32 */ in: %s: %d\n", sdxfp->x,__FILE__,__LINE__-4); _SC_P (__FILE__,sdxfp->line, sdxfp->e, &value[0]); } for (ddxfp = ddxf_tests; ddxfp->line; ddxfp++) { /* This will force the conversion and result in the hidden call to * __bid_extendddxf (). */ long double retval = ddxfp->x; /* Broken into two because printf has a bug when you do %Hf and %f in the * same printf statement. */ char value[DECIMAL_PRINTF_BUF_SIZE]; sprintf(value, "%.33Lf", retval); fprintf(stdout, "%Le = (long double) ", retval); fprintf(stdout, "%De; /* _Decimal64 */ in: %s: %d\n", ddxfp->x,__FILE__,__LINE__-4); _SC_P (__FILE__,ddxfp->line, ddxfp->e, &value[0]); } for (tdtfp = tdtf_tests; tdtfp->line; tdtfp++) { /* This will force the conversion and result in the hidden call to * __dpd_extendtdtf (). */ long double retval = tdtfp->x; /* Broken into two because printf has a bug when you do %Hf and %f in the * same printf statement. */ fprintf(stdout, "%Le = (long double) ", retval); fprintf(stdout, "%DDe; /* _Decimal128 */ in: %s: %d\n", tdtfp->x,__FILE__,__LINE__-4); _VC_P(__FILE__,tdtfp->line, tdtfp->e, retval, tdtfp->format); } #else for (tftdp = tftd_tests; tftdp->line; tftdp++) { /* This will force the conversion and result in the hidden call to * __dpd_extendtftd (). */ _Decimal128 retval = tftdp->x; /* Broken into two because printf has a bug when you do %Hf and %f in the * same printf statement. */ fprintf(stdout, "%DDe = (_Decimal128) ", retval); fprintf(stdout, "%Le; /* long double */ in: %s: %d\n", tftdp->x,__FILE__,__LINE__-4); fprintf(stdout, "expected: %s\n", decoded128(tftdp->e,decodebuf)); fprintf(stdout, "retval: %s\n", decoded128(retval,decodebuf)); _VC_P(__FILE__,tftdp->line, tftdp->e, retval, tftdp->format); } /* Intel long double has a different precision than PowerPC long double. * Intel converts to xf (80 bits) and PowerPC converts to tf (128 bits).*/ #if defined(__DECIMAL_BID_FORMAT__) && __LDBL_MANT_DIG__ == 64 #define DECIMAL_PRINTF_BUF_SIZE 65 /* ((DECIMAL128_PMAX + 14) * 2) + 1 */ for (sdxfp = sdxf_tests; sdxfp->line; sdxfp++) { /* This will force the conversion and result in the hidden call to * __bid_extendsdxf (). */ long double retval = sdxfp->x; /* Broken into two because printf has a bug when you do %Hf and %f in the * same printf statement. */ char value[DECIMAL_PRINTF_BUF_SIZE]; sprintf(value, "%.33Lf", retval); fprintf(stdout, "%Le = (long double) ", retval); fprintf(stdout, "%He; /* _Decimal32 */ in: %s: %d\n", sdxfp->x,__FILE__,__LINE__-4); _SC_P (__FILE__,sdxfp->line, sdxfp->e, &value[0]); } for (ddxfp = ddxf_tests; ddxfp->line; ddxfp++) { /* This will force the conversion and result in the hidden call to * __bid_extendddxf (). */ long double retval = ddxfp->x; /* Broken into two because printf has a bug when you do %Hf and %f in the * same printf statement. */ char value[DECIMAL_PRINTF_BUF_SIZE]; sprintf(value, "%.33Lf", retval); fprintf(stdout, "%Le = (long double) ", retval); fprintf(stdout, "%De; /* _Decimal64 */ in: %s: %d\n", ddxfp->x,__FILE__,__LINE__-4); _SC_P (__FILE__,ddxfp->line, ddxfp->e, &value[0]); } #else for (sdtfp = sdtf_tests; sdtfp->line; sdtfp++) { /* This will force the conversion and result in the hidden call to * __dpd_extendsdtf (). */ long double retval = sdtfp->x; /* Broken into two because printf has a bug when you do %Hf and %f in the * same printf statement. */ fprintf(stdout, "%Le = (long double) ", retval); fprintf(stdout, "%He; /* _Decimal32 */ in: %s: %d\n", sdtfp->x,__FILE__,__LINE__-4); _VC_P(__FILE__,sdtfp->line, sdtfp->e, retval, sdtfp->format); } for (ddtfp = ddtf_tests; ddtfp->line; ddtfp++) { /* This will force the conversion and result in the hidden call to * __dpd_extendddtf (). */ long double retval = ddtfp->x; /* Broken into two because printf has a bug when you do %Hf and %f in the * same printf statement. */ fprintf(stdout, "%Le = (long double) ", retval); fprintf(stdout, "%De; /* _Decimal64 */ in: %s: %d\n", ddtfp->x,__FILE__,__LINE__-4); _VC_P(__FILE__,ddtfp->line, ddtfp->e, retval, ddtfp->format); } #endif for (tdtfp = tdtf_tests; tdtfp->line; tdtfp++) { /* This will force the conversion and result in the hidden call to * __dpd_extendtdtf (). */ long double retval = tdtfp->x; /* PowerPC has a lack of precision in division with long double, so * the expected value needs to be adjusted. */ union precision_expected e = {.d = {tdtfp->ppce1, tdtfp->ppce2}}; tdtfp->e = e.ld; /* Broken into two because printf has a bug when you do %Hf and %f in the * same printf statement. */ fprintf(stdout, "%Le = (long double) ", retval); fprintf(stdout, "%DDe; /* _Decimal128 */ in: %s: %d\n", tdtfp->x,__FILE__,__LINE__-8); _VC_P(__FILE__,tdtfp->line, tdtfp->e, retval, tdtfp->format); } #endif _REPORT(); /* fail comes from scaffold.c */ return fail; } libdfp-1.0.12/tests/test-common.h000066400000000000000000000046731261375163000166310ustar00rootroot00000000000000/* Common definition for libdfp tests. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see dfp/COPYING.txt for more information. */ #ifndef _TEST_COMMON_H # define _TEST_COMMON_H /* Based on 'sysdeps/dpd/dpd-private.h' without the DPD specific fields. */ union ieee754r_Decimal32 { _Decimal32 sd; struct { #if __BYTE_ORDER == __BIG_ENDIAN unsigned int negative:1; unsigned int c:5; unsigned int signaling_nan:1; unsigned int unused0:25; #else /* __LITTLE_ENDIAN */ unsigned int unused0:25; unsigned int signaling_nan:1; unsigned int c:5; unsigned int negative:1; #endif } ieee_nan; }; union ieee754r_Decimal64 { _Decimal64 dd; struct { #if __BYTE_ORDER == __BIG_ENDIAN unsigned int negative:1; unsigned int c:5; unsigned int signaling_nan:1; unsigned int unused0:25; unsigned int unused1:32; #else /* __LITTLE_ENDIAN */ unsigned int unused1:32; unsigned int unused0:25; unsigned int signaling_nan:1; unsigned int c:5; unsigned int negative:1; #endif } ieee_nan; }; union ieee754r_Decimal128 { _Decimal128 td; struct { #if __BYTE_ORDER == __BIG_ENDIAN unsigned int negative:1; unsigned int c:5; unsigned int signaling_nan:1; unsigned int unused0:25; unsigned int unused1:32; unsigned int unused2:32; unsigned int unused3:32; #endif /* Big endian. */ #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int unused3:32; unsigned int unused2:32; unsigned int unused1:32; unsigned int unused0:25; unsigned int signaling_nan:1; unsigned int c:5; unsigned int negative:1; #endif /* Little endian. */ } ieee_nan; }; #endif libdfp-1.0.12/tests/test-decode.c000066400000000000000000000114651261375163000165540ustar00rootroot00000000000000/* Test decoded facility. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef __STDC_WANT_DEC_FP__ # define __STDC_WANT_DEC_FP__ #endif #include #include #include #define _WANT_DC 1 #include "scaffold.c" /* Pick up the _DC_P(x,y,...) macro. */ typedef struct { int line; _Decimal128 d; const char *expect; } d128_type; static const d128_type d128[] = { {__LINE__, __DEC128_MIN__, "+0,000,000,000,000,000,000,000,000,000,000,001E-6143" }, {__LINE__, __DEC128_MAX__, "+9,999,999,999,999,999,999,999,999,999,999,999E+6111"}, {__LINE__, -__builtin_nand128 (""), "-0,000,000,000,000,000,000,000,000,000,000,000E-6176"}, {__LINE__, __builtin_infd128 (), "+0,000,000,000,000,000,000,000,000,000,000,000E-6176"}, {__LINE__, __DEC128_MIN__, "+0,000,000,000,000,000,000,000,000,000,000,001E-6143"}, {__LINE__, __DEC128_SUBNORMAL_MIN__, "+0,000,000,000,000,000,000,000,000,000,000,001E-6176"}, {__LINE__, 9E70DL, "+0,000,000,000,000,000,000,000,000,000,000,009E+70"}, {__LINE__, 4E84DL, "+0,000,000,000,000,000,000,000,000,000,000,004E+84"}, {__LINE__, 1234567E84DL, "+0,000,000,000,000,000,000,000,000,001,234,567E+84"}, {__LINE__, 1.00DL, "+0,000,000,000,000,000,000,000,000,000,000,100E-2" }, {__LINE__, -8.958607314841774959249800028756976DL, "-8,958,607,314,841,774,959,249,800,028,756,976E-33" }, }; static const int d128s = sizeof (d128) / sizeof (d128[0]); typedef struct { int line; _Decimal64 d; const char *expect; } d64_type; static const d64_type d64[] = { {__LINE__, 1.00DD, "+0,000,000,000,000,100E-2"}, {__LINE__, __DEC64_MIN__, "+0,000,000,000,000,001E-383"}, {__LINE__, __DEC64_MAX__, "+9,999,999,999,999,999E+369"}, {__LINE__, -__builtin_nand64(""), "-0,000,000,000,000,000E-398"}, {__LINE__, __builtin_infd64(), "+0,000,000,000,000,000E-398"}, {__LINE__, 9.999999999999999E369DD, "+9,999,999,999,999,999E+354"}, {__LINE__, 9.999999999999999E370DD, "+9,999,999,999,999,999E+355"}, {__LINE__, 9.999999999999999E384DD, "+9,999,999,999,999,999E+369"}, {__LINE__, __DEC64_MIN__, "+0,000,000,000,000,001E-383"}, {__LINE__, __DEC64_SUBNORMAL_MIN__, "+0,000,000,000,000,001E-398"}, {__LINE__, 1E-398DD, "+0,000,000,000,000,001E-398"}, {__LINE__, 9E370DD, "+0,000,000,000,000,090E+369"}, {__LINE__, 4E384DD, "+4,000,000,000,000,000E+369"}, }; static const int d64s = sizeof (d64) / sizeof (d64[0]); typedef struct { int line; _Decimal32 d; const char *expect; } d32_type; static const d32_type d32[] = { {__LINE__, 1.00DF, "+0,000,100E-2"}, {__LINE__, __DEC32_MIN__, "+0,000,001E-95"}, {__LINE__, __DEC32_MAX__, "+9,999,999E+90"}, {__LINE__, -__builtin_nand32(""), "-0,000,000E-101"}, {__LINE__, __builtin_infd32(), "+0,000,000E-101"}, {__LINE__, __DEC32_MIN__, "+0,000,001E-95"}, {__LINE__, __DEC32_SUBNORMAL_MIN__, "+0,000,001E-101"}, {__LINE__, 9E70DF, "+0,000,009E+70"}, {__LINE__, 4E84DF, "+0,000,004E+84"}, {__LINE__, 1234567E84DF, "+1,234,567E+84"}, }; static const int d32s = sizeof (d32) / sizeof (d32[0]); int main (void) { int i; for (i=0; i The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef __STDC_WANT_DEC_FP__ #define __STDC_WANT_DEC_FP__ #endif #include /* DEC_NAN definition. */ #include #include #include #define _WANT_VC 1 /* Pick up the _VC_P(x,y,fmt) macro. */ #include "scaffold.c" /* Pick up the _VC_P(x,y,fmt) macro. */ typedef struct { int line; int set; /* Set it to this. */ int expect; /* Result should be this. */ } d_type; static const d_type round_env[] = { {__LINE__, FE_DEC_TONEAREST, FE_DEC_TONEAREST}, {__LINE__, FE_DEC_TOWARDZERO, FE_DEC_TOWARDZERO}, {__LINE__, FE_DEC_UPWARD, FE_DEC_UPWARD}, {__LINE__, FE_DEC_DOWNWARD, FE_DEC_DOWNWARD}, {__LINE__, FE_DEC_TONEARESTFROMZERO, FE_DEC_TONEARESTFROMZERO}, {__LINE__, 5, 5}, /* Non-spec hardware rounding mode. */ {__LINE__, 6, 6}, /* Non-spec hardware rounding mode. */ {__LINE__, 7, 7}, /* Non-spec hardware rounding mode. */ }; static const int round_env_size = sizeof (round_env) / sizeof (round_env[0]); int main (void) { int i; for (i = 0; i < round_env_size; ++i) { int retval; fe_dec_setround (round_env[i].set); retval = fe_dec_getround (); _VC_P (__FILE__, round_env[i].line, round_env[i].expect, retval, "%d"); } _REPORT (); /* fail comes from scaffold.c */ return fail; } libdfp-1.0.12/tests/test-get_digits.c000066400000000000000000000171501261375163000174500ustar00rootroot00000000000000/* Test the internal facility to get_digits_d{32|64|128]. Copyright (C) 2010-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef __STDC_WANT_DEC_FP__ #define __STDC_WANT_DEC_FP__ 1 #endif #include #include #include #include #include #include "scaffold.c" #include /* We're going to be comparing fields so we need to extract the data. This is a * sneaky way to get around the fact that get_digits_d* isn't exported from * libdfp. */ #ifdef __DECIMAL_BID_FORMAT__ #include "../sysdeps/bid/bid-private.c" #else #include "../sysdeps/dpd/dpd-private.c" #endif #include "decode.h" typedef struct { int line; _Decimal32 d; const char *expect; const char *format; } d32_type; static const d32_type d32[] = { {__LINE__, 0.00000E-101DF, "+0000000e-101", "%Ha"}, {__LINE__, 0e10DF, "+0000000e+10", "%Ha"}, {__LINE__, 0e-6DF, "+0000000e-6", "%Ha"}, {__LINE__, 0.00000E-95DF, "+0000000e-100", "%Ha"}, {__LINE__, 12e-12DF, "+0000012e-12", "%Ha"}, {__LINE__, -659e-9DF, "-0000659e-9", "%Ha"}, {__LINE__, 10221e12DF, "+0010221e+12", "%Ha"}, {__LINE__, 16116736E2DF, "+1611674e+3", "%Ha"}, {__LINE__, 201432679e1DF, "+2014327e+3", "%Ha"}, {__LINE__, 208055501e1DF, "+2080555e+3", "%Ha"}, {__LINE__, 0.0004E-4DF, "+0000004e-8", "%s"}, {__LINE__, 0.0004E-0DF, "+0000004e-4", "%s"}, {__LINE__, 0.0004E-2DF, "+0000004e-6", "%s"}, {__LINE__, 1.0E+2DF, "+0000010e+1", "%s"}, {__LINE__, 0.9999999E-91DF, "+9999999e-98", "%s"}, {__LINE__, 0.9999999E-92DF, "+9999999e-99", "%s"}, {__LINE__, 0.9999999E-93DF, "+9999999e-100", "%s"}, {__LINE__, 0.9999999E-94DF, "+9999999e-101", "%s"}, {__LINE__, 0.9999999E-95DF, "+1000000e-101", "%s"}, {__LINE__, 0.0000010E-95DF, "+0000001e-101", "%s"}, {__LINE__, 0.0000100E-95DF, "+0000010e-101", "%s"}, {__LINE__, 0.0001000E-95DF, "+0000100e-101", "%s"}, {__LINE__, 0.0010000E-95DF, "+0001000e-101", "%s"}, {__LINE__, 0.0100000E-95DF, "+0010000e-101", "%s"}, {__LINE__, 0.1000000E-95DF, "+0100000e-101", "%s"}, {__LINE__, 1.0000000E-95DF, "+1000000e-101", "%s"}, {__LINE__, 10.0000000E-95DF, "+1000000e-100", "%s"}, {__LINE__, 10.0000000E-96DF, "+1000000e-101", "%s"}, }; static const int d32_s = sizeof (d32) / sizeof (d32[0]); typedef struct { int line; _Decimal64 d; const char *expect; const char *format; } d64_type; d64_type d64[] = { {__LINE__, -853894835028358388E+1DD, "-8538948350283584e+3", "%s"}, {__LINE__, 1.0E+2DD, "+0000000000000010e+1", "%s"}, {__LINE__, 123456789.123456E+300DD, "+0123456789123456e+294", "%s"}, {__LINE__, 2.0E-2DD, "+0000000000000020e-3", "%s"}, {__LINE__, -2.0E-2DD, "-0000000000000020e-3", "%s"}, {__LINE__, 0.0000000000000001E-365DD, "+0000000000000001e-381", "%s"}, {__LINE__, 0.0000000000000001E-366DD, "+0000000000000001e-382", "%s"}, {__LINE__, 0.0000000000000001E-367DD, "+0000000000000001e-383", "%s"}, {__LINE__, 0.000000000000001E-368DD, "+0000000000000001e-383", "%s"}, {__LINE__, 0.00000000000001E-369DD, "+0000000000000001e-383", "%s"}, {__LINE__, 0.1E-382DD, "+0000000000000001e-383", "%s"}, {__LINE__, 1.E-383DD, "+0000000000000001e-383", "%s"}, }; static const int d64_s = sizeof (d64) / sizeof (d64[0]); typedef struct { int line; _Decimal128 d; const char *expect; const char *format; } d128_type; d128_type d128[] = { {__LINE__, 17264850929837472839.48234675928374E+271DL, "+1726485092983747283948234675928374e+257", "%s"}, {__LINE__, 9000000000000000001.83273827374E-212DL, "+0000900000000000000000183273827374e-223", "%s"}, {__LINE__, 12000000000000000005.00000002000001E-157DL, "+1200000000000000000500000002000001e-171", "%s"}, {__LINE__, -1000200300040050607008090.01203456E+300DL, "-0100020030004005060700809001203456e+292", "%s"}, {__LINE__, 2537781477129814100906124727369014E-4DL, "+2537781477129814100906124727369014e-4", "%s"}, {__LINE__, -2456651838715207419210335722224950E-42DL, "-2456651838715207419210335722224950e-42", "%s"}, {__LINE__, 31903802797912746463249044.0008815401650E+13DL, "+3190380279791274646324904400088154e+5", "%s"}, {__LINE__, 0.000000000000000329671851945406791615720896491058158258E-16DL, "+3296718519454067916157208964910582e-65", "%s"}, {__LINE__, 1.0E+2DL, "+0000000000000000000000000000000010e+1", "%s"}, {__LINE__, 123456789.123456E+300DL, "+0000000000000000000123456789123456e+294", "%s"}, {__LINE__, 2.0E-2DL, "+0000000000000000000000000000000020e-3", "%s"}, {__LINE__, -2.0E-2DL, "-0000000000000000000000000000000020e-3", "%s"}, {__LINE__, 0.0000000000000001E-365DL, "+0000000000000000000000000000000001e-381", "%s"}, {__LINE__, 0.0000000000000001E-366DL, "+0000000000000000000000000000000001e-382", "%s"}, {__LINE__, 0.0000000000000001E-367DL, "+0000000000000000000000000000000001e-383", "%s"}, }; static const int d128_s = sizeof (d128) / sizeof (d128[0]); static inline void out_digits (char *digits, int is_neg, int exp) { int i; if (is_neg) digits[0] = '-'; else digits[0] = '+'; i = 1; while (digits[i] != '\0') i++; digits[i++] = 'e'; if (exp < 0) digits[i++] = '-'; else digits[i++] = '+'; if (abs (exp) >= 1000) digits[i++] = '0' + ((abs (exp)/1000) % 10); if (abs(exp) >= 100) digits[i++] = '0' + ((abs (exp)/100) % 10); if (abs(exp) >= 10) digits[i++] = '0' + ((abs (exp)/10) % 10); digits[i++] = '0' + (abs (exp) % 10); digits[i] = '\0'; } int main (void) { #define DECIMAL_PRINTF_BUF_SIZE 65 /* ((DECIMAL128_PMAX + 14) * 2) + 1 */ char digits[DECIMAL_PRINTF_BUF_SIZE]; int exp; /* the exponent */ int is_neg; /* is negative */ int is_nan; /* is not a number */ int is_inf; /* is infinite */ int i; for (i=0; i The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef __STDC_WANT_DEC_FP__ #define __STDC_WANT_DEC_FP__ #endif #include #include #include /* DEC_NAN definition. */ #include #define _DECIMAL_SIZE 32 #define DEC_TYPE _Decimal32 #include #undef _DECIMAL_SIZE #undef DEC_TYPE #define _DECIMAL_SIZE 64 #define DEC_TYPE _Decimal64 #include #undef _DECIMAL_SIZE #undef DEC_TYPE #define _DECIMAL_SIZE 128 #define DEC_TYPE _Decimal128 #include #undef _DECIMAL_SIZE #undef DEC_TYPE #define _WANT_VC 1 /* Pick up the _VC_P(x,y,fmt) macro. */ #include "scaffold.c" /* Pick up the _VC_P(x,y,fmt) macro. */ /* We're going to be comparing fields so we need to extract the data. This is a * sneaky way to get around the fact that get_digits_d* isn't exported from * libdfp. */ #ifdef __DECIMAL_BID_FORMAT__ # include "../sysdeps/bid/bid-private.c" #else # include "../sysdeps/dpd/dpd-private.c" #endif typedef struct{ int line; _Decimal128 x; int e; const char *format; } d128_type; #define RET128_MAX 6111 #define RET128_MIN -6143 #define RET128_MIN_SUB -6176 static const d128_type d128[] = { {__LINE__, __DEC128_MAX__, RET128_MAX, "%d"}, {__LINE__, __DEC128_MIN__, RET128_MIN, "%d"}, {__LINE__, __DEC128_SUBNORMAL_MIN__, RET128_MIN_SUB, "%d"}, {__LINE__, 1E200DL, 200, "%d"}, {__LINE__, 12131E2000DL, 2000, "%d"}, {__LINE__, 1E-200DL, -200, "%d"}, {__LINE__, 12131E-2000DL, -2000, "%d"}, {__LINE__, 9999999999999999999999999999999999E0DL, 0, "%d"}, {__LINE__, 9999999999999999999999999999999999E10DL, 10, "%d"}, {__LINE__, 9999999999999999999999999999999999E100DL, 100, "%d"}, {__LINE__, 9999999999999999999999999999999999E1000DL, 1000, "%d"}, }; static const int d128_len = sizeof (d128) / sizeof (d128[0]); typedef struct { int line; _Decimal64 x; int e; const char *format; } d64_type; #define RET64_MAX 369 #define RET64_MIN -383 #define RET64_MIN_SUB -398 d64_type d64[] = { {__LINE__, __DEC64_MAX__, RET64_MAX, "%d"}, {__LINE__, __DEC64_MIN__, RET64_MIN, "%d"}, {__LINE__, __DEC64_SUBNORMAL_MIN__, RET64_MIN_SUB, "%d"}, {__LINE__, 1E20DD, 20, "%d"}, {__LINE__, 12131E200DD, 200, "%d"}, {__LINE__, 1E-20DD, -20, "%d"}, {__LINE__, 12131E-200DD, -200, "%d"}, {__LINE__, 9999999999999999E0DD, 0, "%d"}, {__LINE__, 9999999999999999E10DD, 10, "%d"}, {__LINE__, 9999999999999999E100DD, 100, "%d"}, }; static const int d64_len = sizeof (d64) / sizeof (d64[0]); typedef struct { int line; _Decimal32 x; int e; const char *format; } d32_type; #define RET32_MAX 90 #define RET32_MIN -95 #define RET32_MIN_SUB -101 d32_type d32[] = { {__LINE__, __DEC32_MAX__, RET32_MAX, "%d"}, {__LINE__, __DEC32_MIN__, RET32_MIN, "%d"}, {__LINE__, __DEC32_SUBNORMAL_MIN__, RET32_MIN_SUB, "%d"}, {__LINE__, 1E2DF, 2, "%d"}, {__LINE__, 12131E20DF, 20, "%d"}, {__LINE__, 1E-2DF, -2, "%d"}, {__LINE__, 12131E-20DF, -20, "%d"}, {__LINE__, 9999999E0DF, 0, "%d"}, {__LINE__, 9999999E10DF, 10, "%d"}, }; static const int d32_len = sizeof (d32) / sizeof (d32[0]); int main (void) { int i; for (i=0; i #include #include #define _WANT_VC 1 #include "scaffold.c" typedef struct { int line; _Decimal128 x; /* Value to test */ int e; /* Result should be this. */ const char *format; /* Value form to printf (%i) */ } id128_type; static id128_type id128[] = { { __LINE__, 1.0DL, 0, "%d" }, { __LINE__, 10.71284590452353602878DL, 1, "%d" }, { __LINE__, 1024.0DL, 3, "%d" }, { __LINE__, -200000.0DL, 5, "%d" }, { __LINE__, 0.0DL, FP_ILOGB0, "%d" }, { __LINE__, DEC_NAN, FP_ILOGBNAN, "%d" }, { __LINE__, DEC_INFINITY, INT_MAX, "%d" }, { __LINE__, -DEC_INFINITY, INT_MIN, "%d" }, }; static const int id128_size = sizeof (id128) / sizeof (id128[0]); typedef struct { int line; _Decimal64 x; /* Value to test */ int e; /* Result should be this. */ const char *format; /* Value form to printf (%i) */ } id64_type; static id64_type id64[] = { { __LINE__, 1.0DL, 0, "%d" }, { __LINE__, 10.7644590452353602878DL, 1, "%d" }, { __LINE__, 1024.0DL, 3, "%d" }, { __LINE__, -200000.0DL, 5, "%d" }, { __LINE__, 0.0DL, FP_ILOGB0, "%d" }, { __LINE__, DEC_NAN, FP_ILOGBNAN, "%d" }, { __LINE__, DEC_INFINITY, INT_MAX, "%d" }, { __LINE__, -DEC_INFINITY, INT_MIN, "%d" }, }; static const int id64_size = sizeof (id64) / sizeof (id64[0]); typedef struct { int line; _Decimal32 x; /* Value to test */ int e; /* Result should be this. */ const char *format; /* Value form to printf (%i) */ } id32_type; static id32_type id32[] = { { __LINE__, 1.0DL, 0, "%d" }, { __LINE__, 10.7324590452353602878DL, 1, "%d" }, { __LINE__, 1024.0DL, 3, "%d" }, { __LINE__, -200000.0DL, 5, "%d" }, { __LINE__, 0.0DL, FP_ILOGB0, "%d" }, { __LINE__, DEC_NAN, FP_ILOGBNAN, "%d" }, { __LINE__, DEC_INFINITY, INT_MAX, "%d" }, { __LINE__, -DEC_INFINITY, INT_MIN, "%d" }, }; static const int id32_size = sizeof (id32) / sizeof (id32[0]); typedef struct { int line; _Decimal128 x; /* Value to test */ long int e; /* Result should be this. */ const char *format; /* Value form to printf (%i) */ } ld128_type; static ld128_type ld128[] = { { __LINE__, 1.0DL, 0, "%ld" }, { __LINE__, 10.71284590452353602878DL, 1, "%ld" }, { __LINE__, 1024.0DL, 3, "%ld" }, { __LINE__, -200000.0DL, 5, "%ld" }, { __LINE__, 0.0DL, FP_LLOGB0, "%ld" }, { __LINE__, DEC_NAN, FP_LLOGBNAN, "%ld" }, { __LINE__, DEC_INFINITY, LONG_MAX, "%ld" }, { __LINE__, -DEC_INFINITY, LONG_MIN, "%ld" }, }; static const int ld128_size = sizeof (ld128) / sizeof (ld128[0]); typedef struct { int line; _Decimal64 x; /* Value to test */ long int e; /* Result should be this. */ const char *format; /* Value form to printf (%i) */ } ld64_type; static ld64_type ld64[] = { { __LINE__, 1.0DL, 0, "%ld" }, { __LINE__, 10.7644590452353602878DL, 1, "%ld" }, { __LINE__, 1024.0DL, 3, "%ld" }, { __LINE__, -200000.0DL, 5, "%ld" }, { __LINE__, 0.0DL, FP_LLOGB0, "%ld" }, { __LINE__, DEC_NAN, FP_LLOGBNAN, "%ld" }, { __LINE__, DEC_INFINITY, LONG_MAX, "%ld" }, { __LINE__, -DEC_INFINITY, LONG_MIN, "%ld" }, }; static const int ld64_size = sizeof (ld64) / sizeof (ld64[0]); typedef struct { int line; _Decimal32 x; /* Value to test */ long int e; /* Result should be this. */ const char *format; /* Value form to printf (%i) */ } ld32_type; static ld32_type ld32[] = { { __LINE__, 1.0DL, 0, "%ld" }, { __LINE__, 10.7324590452353602878DL, 1, "%ld" }, { __LINE__, 1024.0DL, 3, "%ld" }, { __LINE__, -200000.0DL, 5, "%ld" }, { __LINE__, 0.0DL, FP_LLOGB0, "%ld" }, { __LINE__, DEC_NAN, FP_LLOGBNAN, "%ld" }, { __LINE__, DEC_INFINITY, LONG_MAX, "%ld" }, { __LINE__, -DEC_INFINITY, LONG_MIN, "%ld" }, }; static const int ld32_size = sizeof (ld32) / sizeof (ld32[0]); int main (void) { int i; for (i=0; i. Copyright (C) 2012-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef __STDC_WANT_DEC_FP__ #define __STDC_WANT_DEC_FP__ #endif /* This is a CPP compatibility testcase. Pick up the _Decimal[32|64|128] * definitions. */ #include #include #include /* For cout support. */ #include #include using namespace std; using namespace std::decimal; /* Pick up the _OSC(x,y,tmp,fmt) macro. */ #define _WANT_ISC 1 #include "scaffold.c" /* Inspired by GLIBC stdio-common/tfformat.c */ typedef struct{ int line; decimal32 expect; const char *d; const char *fmt; decimal32 tmp; } d32_type; d32_type istream_d32s[] = { {__LINE__, 0.0000006E-90DF, "6e-97", "%Ha", -1.0DF}, {__LINE__, 0.0000006E-90DF, "6E-97", "%Ha", -1.0DF }, /* Test where specified precision '10' exceeds __DEC32_MANT_DIG__. * This should reset precision to __DEC32_MANT_DIG__. */ {__LINE__, 0.6666666666E-90DF, "6.666667E-91", "%Ha", -1.0DF }, {0,0,0,0,0} }; typedef struct{ int line; decimal64 expect; const char *d; const char *fmt; decimal64 tmp; } d64_type; d64_type istream_d64s[] = { {__LINE__, -9.999E-3DD, "-0.009999", "%Da", -1.0DD}, {__LINE__, -9.999E-3DD, "-9.999000e-03", "%Da", -1.0DD}, {__LINE__, -9.999E-3DD, "-9.999E-03", "%Da", -1.0DD}, {__LINE__, -9.999E-3DD, "-0.009999", "%Da", -1.0DD}, {__LINE__, __builtin_infd64(), "inf", "%Da", -1.0DD}, {__LINE__, __builtin_infd64(), "INF", "%Da", -1.0DD}, {__LINE__, 4E384DD, "4.0E384", "%Da", -1.0DD}, /* You can't value compare nan to nan. */ /* {__LINE__, (0.0DD * __builtin_infd64()), "NAN", "%Da", -1.0DD}, */ /* You can't value compare nan to nan. */ /* {__LINE__, (0.0DD * __builtin_infd64()), "nan", "%Da", -1.0DD}, */ {0,0,0,0,0} }; typedef struct{ int line; decimal128 expect; const char *d; const char *fmt; decimal128 tmp; } d128_type; d128_type istream_d128s[] = { {__LINE__, -1234.57DL, "-1234.57", "%DDa", -1.0DL}, {__LINE__, -1234.57DL, "-1234.57", "%DDa", 0.0DL}, {__LINE__, -1234.57DL, "-1234.57000", "%DDa", -1.0DL}, {__LINE__, -1234.5679DL, "-1234.5679", "%DDa", -1.0DL}, {__LINE__, -12345678912345678.9123455678DL, "-12345678912345678.9123455678","%DDa", -1.0DL}, {0,0,0,0,0} }; int main(void) { d32_type *d32ptr; d64_type *d64ptr; d128_type *d128ptr; for (d32ptr = istream_d32s; d32ptr->line; d32ptr++) { _ISC_P(__FILE__,d32ptr->line, d32ptr->expect,d32ptr->d,d32ptr->tmp,d32ptr->fmt); } for (d64ptr = istream_d64s; d64ptr->line; d64ptr++) { _ISC_P(__FILE__,d64ptr->line, d64ptr->expect,d64ptr->d,d64ptr->tmp,d64ptr->fmt); } for (d128ptr = istream_d128s; d128ptr->line; d128ptr++) { _ISC_P(__FILE__,d128ptr->line, d128ptr->expect,d128ptr->d,d128ptr->tmp, d128ptr->fmt); } _REPORT(); /* fail comes from scaffold.c */ return fail; } libdfp-1.0.12/tests/test-left_justify.c000066400000000000000000000207421261375163000200360ustar00rootroot00000000000000/* Unit test the internal left_justifyd[32|64|128]() functions. Copyright (C) 2010-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef __STDC_WANT_DEC_FP__ #define __STDC_WANT_DEC_FP__ #endif #include /* DEC_NAN definition. */ #include #include #include #include #define _DECIMAL_SIZE 32 #define DEC_TYPE _Decimal32 #include #undef _DECIMAL_SIZE #undef DEC_TYPE #define _DECIMAL_SIZE 64 #define DEC_TYPE _Decimal64 #include #undef _DECIMAL_SIZE #undef DEC_TYPE #define _DECIMAL_SIZE 128 #define DEC_TYPE _Decimal128 #include #undef _DECIMAL_SIZE #undef DEC_TYPE #include "scaffold.c" /* Pick up the _SC_P(x,y,fmt) macro. */ /* We're going to be comparing fields so we need to extract the data. This is a * sneaky way to get around the fact that get_digits_d* isn't exported from * libdfp. */ #ifdef __DECIMAL_BID_FORMAT__ # include "sysdeps/bid/bid-private.c" # ifndef HAVE_UINT128_T /* BID required int 128 bits and for system that does not define the type the mini-gmp is required. */ # include "libdecnumber/mini-gmp.c" # endif #else # include "sysdeps/dpd/dpd-private.c" #endif typedef struct { int line; _Decimal32 d; const char *expect; const char *format; } d32_type; static const d32_type d32[] = { {__LINE__, 0.0004E-4DF, "+4000000e-14", "%s"}, {__LINE__, 0.0004E-0DF, "+4000000e-10", "%s"}, {__LINE__, 0.0004E-2DF, "+4000000e-12", "%s"}, {__LINE__, 1.0E+2DF, "+1000000e-4", "%s"}, {__LINE__, 0.9999999E-91DF, "+9999999e-98", "%s"}, {__LINE__, 0.9999999E-92DF, "+9999999e-99", "%s"}, {__LINE__, 0.9999999E-93DF, "+9999999e-100", "%s"}, {__LINE__, 0.9999999E-94DF, "+9999999e-101", "%s"}, /* Notice 1000000e-101 is the answer. */ {__LINE__, 0.9999999E-95DF, "+1000000e-101", "%s"}, {__LINE__, 0.0000010E-95DF, "+0000001e-101", "%s"}, {__LINE__, 0.0000100E-95DF, "+0000010e-101", "%s"}, {__LINE__, 0.0001000E-95DF, "+0000100e-101", "%s"}, {__LINE__, 0.0010000E-95DF, "+0001000e-101", "%s"}, {__LINE__, 0.0100000E-95DF, "+0010000e-101", "%s"}, {__LINE__, 0.1000000E-95DF, "+0100000e-101", "%s"}, {__LINE__, 1E-95DF, "+1000000e-101", "%s"}, {__LINE__, 0.000001E-95DF, "+0000001e-101", "%s"}, {__LINE__, 0.000010E-96DF, "+0000001e-101", "%s"}, {__LINE__, 0.001000E-98DF, "+0000001e-101", "%s"}, {__LINE__, 0.010000E-99DF, "+0000001e-101", "%s"}, {__LINE__, 0.100000E-100DF, "+0000001e-101", "%s"}, {__LINE__, 1.0000000E-95DF, "+1000000e-101", "%s"}, {__LINE__, 10.0000000E-95DF, "+1000000e-100", "%s"}, /* Notice 1000000e-101 is the answer. */ {__LINE__, 10.0000000E-96DF,"+1000000e-101", "%s"}, }; static const int d32_s = sizeof (d32) / sizeof (d32[0]); /* Inspired by GLIBC stdio-common/tfformat.c */ typedef struct{ int line; _Decimal64 d; const char *expect; const char *format; } d64_type; static const d64_type d64[] = { {__LINE__, 1.0E+2DD, "+1000000000000000e-13", "%s"}, {__LINE__, 123456789.123456E+300DD, "+1234567891234560e+293", "%s"}, {__LINE__, 2.0E-2DD, "+2000000000000000e-17", "%s"}, {__LINE__, -2.0E-2DD, "-2000000000000000e-17", "%s"}, {__LINE__, 0.0000000000000001E-365DD, "+1000000000000000e-396", "%s"}, {__LINE__, 0.0000000000000001E-366DD, "+1000000000000000e-397", "%s"}, /* __get_digits_d64 returns +0000000000000001e-398 for a NaN data. */ {__LINE__, 0.0000100E-383DD, "+0000000000000001e-398", "%s"}, {__LINE__, 0.0001000E-383DD, "+0000000000000001e-398", "%s"}, {__LINE__, 0.0010000E-383DD, "+0000000000000001e-398", "%s"}, {__LINE__, 0.0100000E-383DD, "+0000000000000001e-398", "%s"}, /* The minimum exponent we can left-justify if the mantissa is full. */ {__LINE__, 0.0000000000000001E-367DD, "+1000000000000000e-398", "%s"}, /* Notice the 15 digit mantissa. */ {__LINE__, 0.000000000000001E-368DD, "+1000000000000000e-398", "%s"}, /* Notice the 14 digit mantissa. */ {__LINE__, 0.00000000000001E-369DD, "+1000000000000000e-398", "%s"}, /* Notice the 1 digit mantissa. */ {__LINE__, 0.1E-382DD, "+1000000000000000e-398", "%s"}, /* Notice the 1 digit mantissa. */ {__LINE__, 1.E-383DD, "+1000000000000000e-398", "%s"}, }; static const int d64_s = sizeof (d64) / sizeof (d64[0]); typedef struct{ int line; _Decimal128 d; const char *expect; const char *format; } d128_type; static const d128_type d128[] = { {__LINE__, 1.0E+2DL, "+1000000000000000000000000000000000e-31", "%s"}, {__LINE__, 123456789.123456E+300DL, "+1234567891234560000000000000000000e+275", "%s"}, {__LINE__, 2.0E-2DL, "+2000000000000000000000000000000000e-35", "%s"}, {__LINE__, -2.0E-2DL, "-2000000000000000000000000000000000e-35", "%s"}, {__LINE__, 0.0000000000000001E-365DL, "+1000000000000000000000000000000000e-414", "%s"}, {__LINE__, 0.0000000000000001E-366DL, "+1000000000000000000000000000000000e-415", "%s"}, {__LINE__, 0.0000000000000001E-367DL, "+1000000000000000000000000000000000e-416", "%s"}, {__LINE__, 1E-6143DL, "+1000000000000000000000000000000000e-6176", "%s"}, {__LINE__, 0.0000000000000001E-6127DL, "+1000000000000000000000000000000000e-6176", "%s"}, /* __get_digits_d128 returns +0000000000000000000000000000000001e-6176 for a NaN data. */ {__LINE__, 0.0000000000000001E-6140DL, "+0000000000000000000000000000000001e-6176", "%s"}, {__LINE__, 0.0000000000000100E-6143DL, "+0000000000000000000000000000000001e-6176", "%s"}, {__LINE__, 0.0000000000001000E-6143DL, "+0000000000000000000000000000000001e-6176", "%s"}, {__LINE__, 0.0000000000000001E-6143DL, "+0000000000000000000000000000000001e-6176", "%s"}, {__LINE__, 0.0000000000000001E-6160DL, "+0000000000000000000000000000000001e-6176", "%s"}, }; static const int d128_s = sizeof (d128) / sizeof (d128[0]); static inline void out_digits (char *digits, int is_neg, int exp) { int i; if (is_neg) digits[0] = '-'; else digits[0] = '+'; i = 1; while (digits[i] != '\0') i++; digits[i++] = 'e'; if (exp < 0) digits[i++] = '-'; else digits[i++] = '+'; if (abs (exp) >= 1000) digits[i++] = '0' + ((abs (exp)/1000) % 10); if (abs(exp) >= 100) digits[i++] = '0' + ((abs (exp)/100) % 10); if (abs(exp) >= 10) digits[i++] = '0' + ((abs (exp)/10) % 10); digits[i++] = '0' + (abs (exp) % 10); digits[i] = '\0'; } int main (void) { #define DECIMAL_PRINTF_BUF_SIZE 65 /* ((DECIMAL128_PMAX + 14) * 2) + 1 */ char digits[DECIMAL_PRINTF_BUF_SIZE]; int exp; /* the exponent */ int is_neg; /* is negative */ int is_nan; /* is not a number */ int is_inf; /* is infinite */ int i; for (i=0; i The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef __STDC_WANT_DEC_FP__ #define __STDC_WANT_DEC_FP__ #endif #include /* DEC_NAN definition. */ #include #include #include #define _DECIMAL_SIZE 32 #define DEC_TYPE _Decimal32 #include #undef _DECIMAL_SIZE #undef DEC_TYPE #define _DECIMAL_SIZE 64 #define DEC_TYPE _Decimal64 #include #undef _DECIMAL_SIZE #undef DEC_TYPE #define _DECIMAL_SIZE 128 #define DEC_TYPE _Decimal128 #include #undef _DECIMAL_SIZE #undef DEC_TYPE #define _WANT_VC 1 /* Pick up the _VC_P(x,y,fmt) macro. */ #include "scaffold.c" /* Pick up the _VC_P(x,y,fmt) macro. */ /* We're going to be comparing fields so we need to extract the data. This is a * sneaky way to get around the fact that get_digits_d* isn't exported from * libdfp. */ #ifdef __DECIMAL_BID_FORMAT__ # include "../sysdeps/bid/bid-private.c" #else # include "../sysdeps/dpd/dpd-private.c" #endif typedef struct { int line; _Decimal128 x; /* Value to test */ int e; /* Result should be this. */ const char *format; /* printf %d */ } d128_type; static d128_type d128[] = { {__LINE__, 0.02E-2DL, 1, "%d"}, {__LINE__, 0.0200E-2DL, 3, "%d"}, {__LINE__, 1.0E-2DL, 2, "%d"}, {__LINE__, 0.0000345E-2DL, 3, "%d"}, {__LINE__, 0.0000345E-10DL, 3, "%d"}, {__LINE__, 123456.0E-2DL, 7, "%d"}, {__LINE__, 123456.000E-2DL, 9, "%d"}, {__LINE__, 123456.000E-4DL, 9, "%d"}, {__LINE__, 123456.000E-6DL, 9, "%d"}, {__LINE__, 123456.00000000000000E-18DL, 20, "%d"}, {__LINE__, 123.456E-6DL, 6, "%d"}, }; static int d128_s = sizeof (d128) / sizeof (d128[0]); typedef struct{ int line; _Decimal64 x; /* Value to test */ int e; /* Result should be this. */ const char *format; /* printf %d */ } d64_type; static d64_type d64[] = { {__LINE__, 0.02E-2DD, 1, "%d"}, {__LINE__, 0.0200E-2DD, 3, "%d"}, {__LINE__, 1.0E-2DD, 2, "%d"}, {__LINE__, 0.0000345E-2DD, 3, "%d"}, {__LINE__, 0.0000345E-10DD, 3, "%d"}, {__LINE__, 123456.0E-2DD, 7, "%d"}, {__LINE__, 123456.000E-2DD, 9, "%d"}, {__LINE__, 123456.000E-4DD, 9, "%d"}, {__LINE__, 123456.000E-6DD, 9, "%d"}, /* Can't exceed __DEC64_MANT_DIG__. This test has 17 digits but the * compiler will truncate it (or round) before it's passed */ {__LINE__, 9.9999999999999999E300DD, 16, "%d"}, /* There was a known bug with any value where the normalized exponent * exceeded 369. This caused __DEC64_MAX__ to return incorrect results. */ {__LINE__, __DEC64_MAX__, 16, "%d"}, /* The normalized exponent is '369' so the right justified encoding has two * digits, '90', in the mantissa. */ {__LINE__, 9E370DD, 2, "%d"}, /* Fails the same way: the absolute value of the exponent exceeds 369. */ {__LINE__, __DEC64_MIN__, 1, "%d"}, {__LINE__, 1E-398DD, 1, "%d"}, /* 0.000000000000001E-383DD */ {__LINE__, __DEC64_SUBNORMAL_MIN__, 1, "%d"}, }; static int d64_s = sizeof (d64) / sizeof (d64[0]); typedef struct{ int line; _Decimal32 x; /* Value to test */ int e; /* Result should be this. */ const char *format; /* printf %d */ } d32_type; d32_type d32[] = { {__LINE__, 0.02E-2DF, 1, "%d"}, {__LINE__, 0.0200E-2DF, 3, "%d"}, {__LINE__, 1.0E-2DF, 2, "%d"}, {__LINE__, 0.0000345E-2DF, 3, "%d"}, {__LINE__, 0.0000345E-10DF, 3, "%d"}, {__LINE__, 123456.0E-2DF, 7, "%d"}, {__LINE__, 123456.000E-2DF, 7, "%d"}, /* can't exceed __DEC32_MANT_DIG__ */ {__LINE__, 123456.000E-4DF, 7, "%d"}, /* can't exceed __DEC32_MANT_DIG__ */ {__LINE__, 123456.000E-6DF, 7, "%d"}, /* can't exceed __DEC32_MANT_DIG__ */ /* can't exceed __DEC32_MANT_DIG__ */ {__LINE__, 123456.00000000000000E-18DD, 7, "%d"}, /* Problem numbers. These should all return '1'. At some point they were * returning '0' for soft-dfp and '1' for hard-dfp. */ {__LINE__, 0.00000E-101DF, 1, "%d"}, {__LINE__, 0.00000E-97DF, 1, "%d"}, {__LINE__, 0.00000E-96DF, 1, "%d"}, {__LINE__, 0.00000E-95DF, 1, "%d"}, {__LINE__, 0e10DF, 1, "%d"}, {__LINE__, 0.0e10DF, 1, "%d"}, {__LINE__, 0.0e-09DF, 1, "%d"}, {__LINE__, 0e-6DF,1, "%d"}, {__LINE__, 0e-7DF, 1, "%d"}, {__LINE__, 0.e-10DF, 1, "%d"}, {__LINE__, 0.e-10DF, 1, "%d"}, {__LINE__, 0.e-10DF, 1, "%d"}, {__LINE__, 0e2DF, 1, "%d"}, {__LINE__, 0.0e2DF, 1, "%d"}, {__LINE__, 0.0e10DF, 1, "%d"}, }; static int d32_s = sizeof (d32) / sizeof (d32[0]); int main (void) { int i; for (i=0; i. Copyright (C) 2012-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef __STDC_WANT_DEC_FP__ #define __STDC_WANT_DEC_FP__ #endif /* This is a CPP compatibility testcase. Pick up the _Decimal[32|64|128] * definitions. */ #include #include #include /* For cout support. */ #include using namespace std; using namespace std::decimal; /* Pick up the _OSC(x,y,precision,upper,spec) macro. */ #define _WANT_OSC 1 #include "scaffold.c" /* Inspired by GLIBC stdio-common/tfformat.c */ typedef struct{ int line; decimal32 d; const char *expect; int precision; /* -1 means unspecified. */ char upper; /* l or u */ char spec; /* a, e, f, g */ } d32_type; /* The g/G conv spec used to be provided separate from the others so there was a separate test program. */ d32_type ostream_d32s[] = { {__LINE__, 0.0000006E-90DF, "6e-97", -1, 'l', 'g' }, {__LINE__, 0.0000006E-90DF, "6E-97", -1, 'u', 'g' }, /* Test where specified precision '10' exceeds __DEC32_MANT_DIG__. * This should reset precision to __DEC32_MANT_DIG__. */ {__LINE__, 0.6666666666E-90DF, "6.666667E-91", 10, 'u', 'g' }, {__LINE__, 0.6666666666E-90DF, "6.666667e-91", 10, 'l', 'g' }, {0,0,0,0,0,0} }; typedef struct{ int line; decimal64 d; const char *expect; int precision; /* -1 means unspecified. */ char upper; /* l or u */ char spec; /* a, e, f */ } d64_type; d64_type ostream_d64s[] = { {__LINE__, -9.999E-3DD, "-0.009999", -1, 'l', 'g' }, {__LINE__, -9.999E-3DD, "-0.009999", -1, 'u', 'g' }, {__LINE__, -9.999992E-3DD, "-0.00999999", -1, 'l', 'g' }, {__LINE__, __builtin_infd64(), "inf", -1, 'l', 'g' }, {__LINE__, __builtin_infd64(), "INF", -1, 'u', 'g' }, {__LINE__, (0.0DD * __builtin_infd64()), "NAN", -1, 'u', 'g' }, {__LINE__, (0.0DD * __builtin_infd64()), "nan", -1, 'l', 'g' }, {0,0,0,0,0,0} }; typedef struct{ int line; decimal128 d; const char *expect; int precision; /* -1 means unspecified. */ char upper; /* l or u */ char spec; /* a, e, f */ } d128_type; d128_type ostream_d128s[] = { /* Known bug in printf (not truncating). */ {__LINE__, -1234.56789123456789123455678DL, "-1234.57", -1, 'l', 'g' }, /* Known bug in printf (not truncating). */ {__LINE__, -1234.56789123456789123455678DL, "-1234.57", 6, 'l', 'g' }, /* Known bug in printf (not truncating). */ {__LINE__, -1234.56789123456789123455678DL, "-1234.5679", 8, 'l', 'g' }, {__LINE__, -12345678912345678.9123455678DL, "-1.234567891E+16", 10, 'u', 'g' }, {__LINE__, -12345678912345678.9123455678DL, "-1.234567891e+16", 10, 'l', 'g' }, {0,0,0,0,0,0} }; int main(void) { d32_type *d32ptr; d64_type *d64ptr; d128_type *d128ptr; for (d32ptr = ostream_d32s; d32ptr->line; d32ptr++) { _OSC_P(__FILE__,d32ptr->line, d32ptr->expect,d32ptr->d,d32ptr->precision,d32ptr->upper,d32ptr->spec); } for (d64ptr = ostream_d64s; d64ptr->line; d64ptr++) { _OSC_P(__FILE__,d64ptr->line, d64ptr->expect,d64ptr->d,d64ptr->precision,d64ptr->upper,d64ptr->spec); } for (d128ptr = ostream_d128s; d128ptr->line; d128ptr++) { _OSC_P(__FILE__,d128ptr->line, d128ptr->expect,d128ptr->d,d128ptr->precision,d128ptr->upper,d128ptr->spec); } _REPORT(); /* fail comes from scaffold.c */ return fail; } libdfp-1.0.12/tests/test-ostream.cpp000066400000000000000000000112551261375163000173400ustar00rootroot00000000000000/* Test ostream operator in cpp compat header . Copyright (C) 2011-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef __STDC_WANT_DEC_FP__ #define __STDC_WANT_DEC_FP__ #endif /* This is a CPP compatibility testcase. Pick up the _Decimal[32|64|128] * definitions. */ #include #include #include /* For cout support. */ #include using namespace std; using namespace std::decimal; /* Pick up the _OSC(x,y,precision,upper,spec) macro. */ #define _WANT_OSC 1 #include "scaffold.c" /* Inspired by GLIBC stdio-common/tfformat.c */ typedef struct{ int line; decimal32 d; const char *expect; int precision; /* -1 means unspecified. */ char upper; /* l or u */ char spec; /* a, e, f */ } d32_type; d32_type ostream_d32s[] = { {__LINE__, 0.0000006E-90DF, "6e-97", -1, 'l', 'a' }, {__LINE__, 0.0000006E-90DF, "6E-97", -1, 'u', 'a' }, /* Test where specified precision '10' exceeds __DEC32_MANT_DIG__. * This should reset precision to __DEC32_MANT_DIG__. */ {__LINE__, 0.6666666666E-90DF, "6.666667E-91", 10, 'u', 'a' }, {0,0,0,0,0,0} }; typedef struct{ int line; decimal64 d; const char *expect; int precision; /* -1 means unspecified. */ char upper; /* l or u */ char spec; /* a, e, f */ } d64_type; d64_type ostream_d64s[] = { {__LINE__, -9.999E-3DD, "-0.009999", -1, 'l', 'f' }, {__LINE__, -9.999E-3DD, "-9.999000e-03", -1, 'l', 'e' }, {__LINE__, -9.999E-3DD, "-9.999E-03", 3, 'u', 'e' }, {__LINE__, -9.999E-3DD, "-0.009999", -1, 'l', 'a' }, {__LINE__, __builtin_infd64(), "inf", -1, 'l', 'a' }, {__LINE__, __builtin_infd64(), "INF", -1, 'u', 'a' }, {__LINE__, (0.0DD * __builtin_infd64()), "NAN", -1, 'u', 'a' }, {__LINE__, (0.0DD * __builtin_infd64()), "nan", -1, 'l', 'a' }, {__LINE__, -(0.0DD * __builtin_infd64()), "-NAN", -1, 'u', 'a' }, {__LINE__, -(0.0DD * __builtin_infd64()), "-nan", -1, 'l', 'a' }, /* Due to the lack of direction in the C++ DFP TR there is no indication that a/A conv specifiers should accept precision. */ {__LINE__, 4.000000000000000e+384DD, "4.000000000000000e+384", -1, 'l', 'a' }, {__LINE__, 4.000000000000000e+384DD, "4.000000000000000e+384", 7, 'l', 'a' }, {__LINE__, 4.000000000000000e+384DD, "4.000000000000000e+384", 6, 'l', 'a' }, {__LINE__, 4.000000000000000e+384DD, "4.000000000000000e+384", 19, 'l', 'a' }, {0,0,0,0,0,0} }; typedef struct{ int line; decimal128 d; const char *expect; int precision; /* -1 means unspecified. */ char upper; /* l or u */ char spec; /* a, e, f */ } d128_type; d128_type ostream_d128s[] = { {__LINE__, -1234.56789123456789123455678DL, "-1234.56789123456789123455678", -1, 'l', 'a' }, {__LINE__, -1234.56789123456789123455678DL, "-1234.56789123456789123455678", 8, 'l', 'a' }, {__LINE__, -12345678912345678.9123455678DL, "-12345678912345678.9123455678", 10, 'u', 'f' }, {__LINE__, (0.0DL * __builtin_infd128()), "NAN", -1, 'u', 'a' }, {__LINE__, (0.0DL * __builtin_infd128()), "nan", -1, 'l', 'a' }, {__LINE__, -(0.0DL * __builtin_infd128()), "-NAN", -1, 'u', 'a' }, {__LINE__, -(0.0DL * __builtin_infd128()), "-nan", -1, 'l', 'a' }, {0,0,0,0,0,0} }; int main(void) { d32_type *d32ptr; d64_type *d64ptr; d128_type *d128ptr; for (d32ptr = ostream_d32s; d32ptr->line; d32ptr++) { _OSC_P(__FILE__,d32ptr->line, d32ptr->expect,d32ptr->d,d32ptr->precision,d32ptr->upper,d32ptr->spec); } for (d64ptr = ostream_d64s; d64ptr->line; d64ptr++) { _OSC_P(__FILE__,d64ptr->line, d64ptr->expect,d64ptr->d,d64ptr->precision,d64ptr->upper,d64ptr->spec); } for (d128ptr = ostream_d128s; d128ptr->line; d128ptr++) { _OSC_P(__FILE__,d128ptr->line, d128ptr->expect,d128ptr->d,d128ptr->precision,d128ptr->upper,d128ptr->spec); } _REPORT(); /* fail comes from scaffold.c */ return fail; } libdfp-1.0.12/tests/test-printf.c000066400000000000000000000676641261375163000166470ustar00rootroot00000000000000/* Test printf_dfp facility. Copyright (C) 2009-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef __STDC_WANT_DEC_FP__ #define __STDC_WANT_DEC_FP__ 1 #endif #include #include #include #include /* This should pick up the libdfp wchar in dfp/wchar.h. */ #define _WANT_PC 1 /* Pick up the _PC(x,y,...) macro. */ #include "scaffold.c" #include "decode.h" /* Inspired by GLIBC stdio-common/tfformat.c */ typedef struct{ int line; _Decimal32 d; const char *expect; const char *format; } d32_type; d32_type printf_d32s[] = { /* Default precision. */ {__LINE__, 0.0004E-4DF, "0.00000004", "%.8Hf"}, {__LINE__, 123.456E-6DF, "0.000123", "%Hf"}, {__LINE__, 123.456E-6DF, "1.234560e-04", "%He"}, {__LINE__, 12.0E-15DF, "0.000000", "%Hf"}, {__LINE__, 12.0E-5DF, "0.000120", "%Hf"}, {__LINE__, 12.0E-15DF, "1.2e-14", "%Hg"}, {__LINE__, 0.E+0DF, "0.000000", "%Hf"}, {__LINE__, 1.E+2DF, "100.000000", "%Hf"}, {__LINE__, 12.0E+3DF, "1.200000e+04", "%He"}, {__LINE__, 12.000E+3DF, "1.200000e+04", "%He"}, {__LINE__, 12.0E+3DF, "12000.000000", "%Hf"}, {__LINE__, 1900000.E+2DF, "190000000.000000", "%Hf"}, {__LINE__, 1900000.E+2DF, "190000000", "%.Hf"}, {__LINE__, 19.E+2DF, "1900.000000", "%Hf"}, /* Default precision. */ {__LINE__, 1.0E+2DF, "100.000000", "%Hf"}, /* Default precision. */ {__LINE__, 1.00E+2DF, "100.000000", "%Hf"}, {__LINE__, 23456.0E-3DF, "2.35e+01", "%.2He"}, {__LINE__, 23456.0E-3DF, "23.46", "%.2Hf"}, {__LINE__, 23456.E-3DF, "23.46", "%.2Hf"}, {__LINE__, 1234567.E0DF, "1234567.00", "%.2Hf"}, {__LINE__, 1234567.E0DF, "1234567.000000", "%Hf"}, /* Precision of '3'. */ {__LINE__, 123.456E+0DF, "123.456000", "%Hf"}, {__LINE__, 123.456E+0DF, "123.456", "%.3Hf"}, /* Implict precision of '1' since there is one explicit zero in the mantissa * right of the decimal place after it is adjusted for the exponent. */ {__LINE__, 1.000E+2DF, "100.000000", "%Hf"}, /* Implict precision of '1' since there is one explicit zero in the mantissa * right of the decimal place after it is adjusted for the exponent. */ {__LINE__, 100.0E+0DF, "100.000000", "%Hf"}, /* Implict precision of '1' since there is one explicit zero in the mantissa * right of the decimal place after it is adjusted for the exponent. */ {__LINE__, 0.0001000E+6DF, "100.000000", "%Hf"}, /* Implict precision of '4' since there is one explicit zero in the mantissa * right of the decimal place after it is adjusted for the exponent. */ {__LINE__, 1.000000E+2DF, "100.000000", "%Hf"}, /* Because of the 'e' output precision is '5'. */ {__LINE__, 123.456E+0DF, "1.234560e+02", "%He"}, {__LINE__, 123.456E+0DF, "1.23456e+02", "%.5He"}, {__LINE__, 123.456E+0DF, "1.234560E+02", "%HE"}, {__LINE__, 19000E+15DF, "19000000000000000000.000000", "%Hf"}, {__LINE__, 190001E+45DF, "190001000000000000000000000000000000000000000000000.000000", "%Hf"}, {__LINE__, -123.456E+0DF, "-1.234560e+02", "%He"}, /* Encoded as 1234567E1, prec 5*/ {__LINE__, 12.34567E+6DF, "12345670.000000", "%Hf"}, {__LINE__, 123.456E-5DF, "1.234560e-03", "%He"}, {__LINE__, 123.456E-5DF, "0.001235", "%Hf"}, {__LINE__, 123.456E-5DF, "0.00123456", "%Hg"}, {__LINE__, 123.456E-6DF, "1.234560e-04", "%He"}, {__LINE__, 123.456E-6DF, "0.000123", "%Hf"}, {__LINE__, 123.456E-6DF, "0.000123456", "%Hg"}, {__LINE__, 123.456E-7DF, "1.234560e-05", "%He"}, {__LINE__, 123.456E-7DF, "0.000012", "%Hf"}, {__LINE__, 123.456E-7DF, "1.23456e-05", "%Hg"}, {__LINE__, 123.456E-7DF, "1.235e-05", "%.4Hg"}, {__LINE__, 123.456E-9DF, "1.234560e-07", "%He"}, {__LINE__, 6.5DF, "6.5e+00", "%.1He"}, {__LINE__, 6.5DF, "6e+00", "%.0He"}, {__LINE__, 6.6DF, "7e+00", "%.0He"}, {__LINE__, 123.456E-9DF, "1.23456e-7", "%Ha"}, {__LINE__, 0.00000E-101DF, "0.000000e+00", "%He"}, /* Erroneously prints "1e+6" due to the '.' with no explicit precision. FIX * ME. */ {__LINE__, 6.0E5DF, "6e+5", "%.Ha"}, {__LINE__, 6.0E5DF, "6e+5", "%.0Ha"}, {__LINE__, 6.E5DF, "6e+5", "%.0Ha"}, {__LINE__, 0.0e10DF, "0.000000e+00", "%He"}, {__LINE__, 0.0e10DF, "0.000000", "%Hf"}, {__LINE__, 0.0e10DF, "0", "%Hg"}, /* For 'g' when '#' is present the spec says that trailing zeros are NOT * removed. And YES, this SHOULD be five trailing zeros because this falls * into the category where 'g' is converted to 'e' and precision equals P - 1. * Additionally, the C-spec indicates that. This is congruent with how this * works for binary float. */ {__LINE__, 0.0e10DF, "0.00000", "%#Hg"}, {__LINE__, 0.0e10DF, "0", "%.4Hg"}, /* (1,0,-1) */ {__LINE__, 0.0DF, "0.0", "%Ha"}, /* (1,0,0) */ {__LINE__, 0e0DF, "0", "%Ha"}, /* (1,0,0) */ {__LINE__, -0e0DF, "-0", "%Ha"}, /* (-1,0,-1) */ {__LINE__, -0.0DF, "-0.0", "%Ha"}, /* ( 1, 123, 0) */ {__LINE__, 123.DF, "123", "%Ha"}, /* (-1, 123, 0) -123 */ {__LINE__, -123.DF, "-123", "%Ha"}, /* ( 1, 123, -2) 1.23 */ {__LINE__, 1.23DF, "1.23", "%Ha"}, {__LINE__, 123E-2DF, "1.23", "%Ha"}, {__LINE__, 0.123E1DF, "1.23", "%Ha"}, /* ( 1, 123, 1) 1.23e+3 */ {__LINE__, 123e1DF, "1.23e+3", "%Ha"}, /* ( 1, 1230, 0) 1230 */ {__LINE__, 123.0e1DF, "1230", "%Ha"}, /* (-1, 123, 1) -1.23e+3 */ {__LINE__, -123e1DF, "-1.23e+3", "%Ha"}, /* ( 1, 123, -8) 0.00000123 */ {__LINE__, 123e-8DF, "0.00000123", "%Ha"}, {__LINE__, 123.e-8DF, "0.00000123", "%Ha"}, /* ( 1, 123, -9) 1.23e-7 */ {__LINE__, 123e-9DF, "1.23e-7", "%Ha"}, {__LINE__, 123.e-9DF, "1.23e-7", "%Ha"}, /* Can't represent the following in _Decimal32 */ /* ( 1, 1234567890123456, 0) 1234567890123456 */ /* ( 1, 1234567890123456, 1) 1.234567890123456e+16 */ /* ( 1, 1234567890123456, -1) 123456789012345.6 */ /* ( 1, 1234567890123456, -21) 0.000001234567890123456 */ /* ( 1, 1234567890123456, -22) 1.234567890123456e-7 */ /* ( 1, 0, 0) 0 */ {__LINE__, 0e0DF, "0", "%Ha"}, {__LINE__, 0.DF, "0", "%Ha"}, {__LINE__, 0.e0DF, "0", "%Ha"}, /* (-1, 0, 0) -0 */ {__LINE__, -0e0DF, "-0", "%Ha"}, {__LINE__, -0.DF, "-0", "%Ha"}, {__LINE__, -0.e0DF, "-0", "%Ha"}, /* ( 1, 5, -6) 0.000005 */ {__LINE__, 5e-6DF, "0.000005", "%Ha"}, /* ( 1, 50, -7) 0.0000050 */ {__LINE__, 50e-7DF, "0.0000050", "%Ha"}, /* ( 1, 5, -7) 5e-7 */ {__LINE__, 5e-7DF, "5e-7", "%Ha"}, /* Yes, goofy, but it is encoded 00000000e0. */ {__LINE__, 0.00e2DF, "0", "%Ha"}, /* Yes, goofy, but it is encoded 00000000e0. */ {__LINE__, 0.00e2DF, "0", "%.2Ha"}, /* Notice the '#'. The DFP spec doesn't speak about this and doesn't indicate * that this is supposed to work like it does for 'g' so we still expect to * see trailing zeros removed and no exponent. */ {__LINE__, 0.00e2DF, "0.", "%#Ha"}, /* ( 1, 5, -7) */ {__LINE__, 5e-7DF, "5.e-7", "%#Ha"}, {__LINE__, 6543.E-11DF, "6.543e-8", "%Ha"}, /* Continued DPF spec examples. */ {__LINE__, 6543.00DF, "6543.00", "%Ha"}, {__LINE__, 6543.00DF, "6543.00", "%.6Ha"}, {__LINE__, 6543.00DF, "6543.0", "%.5Ha"}, {__LINE__, 6543.09DF, "6543.1", "%.5Ha"}, {__LINE__, 6543.00DF, "6543", "%.4Ha"}, {__LINE__, 6543.00DF, "6.54e+3", "%.3Ha"}, {__LINE__, 6543.00DF, "6.5e+3", "%.2Ha"}, {__LINE__, 6543.00DF, "7e+3", "%.1Ha"}, {__LINE__, 6543.00DF, "7E+3", "%.1HA"}, {__LINE__, 6543.00DF, " 6543.00", "%8Ha"}, /* The following have shown inconsistent results between soft-dfp and * hard-dfp. */ /* In reality this exceeds the ability of _Decimal32 to represent the exponent * so while it SHOULD be 0e-106 it really ends up being encoded as 0e-101 * because that is the min exponent. */ {__LINE__, 0.00000E-101DF, "0e-101", "%Ha"}, /* Likewise, this still exceeds. */ {__LINE__, 0.00000E-97DF, "0e-101", "%Ha"}, /* As shown, this is 0e-101 for real. */ {__LINE__, 0.00000E-96DF, "0e-101", "%Ha"}, {__LINE__, 0.00000E-95DF, "0e-100", "%Ha"}, {__LINE__, 0e10DF, "0e+10", "%Ha"}, {__LINE__, 0.0e10DF, "0e+9", "%.1Ha"}, {__LINE__, 0.0e-09DF, "0e-10", "%.0Ha"}, /* ( 1, 0, -6) 0.000000 */ {__LINE__, 0e-6DF, "0.000000", "%Ha"}, /* ( 1, 0, -7) 0e-7 */ {__LINE__, 0e-7DF, "0e-7", "%Ha"}, {__LINE__, 0.e-10DF, "0e-10", "%.1Ha"}, {__LINE__, 0.e-10DF, "0e-10", "%.3Ha"}, {__LINE__, 0.e-10DF, "0e-10", "%.4Ha"}, /* ( 1, 0, 2) 0e+2 encoded as 00000000e2. */ {__LINE__, 0e2DF, "0e+2", "%Ha"}, /* Yes, goofy, but it is encoded 00000000e1. */ {__LINE__, 0.0e2DF, "0e+1", "%Ha"}, {__LINE__, 0.0e10DF, "0e+9", "%Ha"}, {0,0,0,0 } }; typedef struct{ int line; _Decimal64 d; const char *expect; const char *format; } d64_type; d64_type printf_d64s[] = { /* Default precision. */ {__LINE__, 123.456E-6DD, "0.000123", "%Df"}, {__LINE__, 123.456E-6DD, "1.234560e-04", "%De"}, {__LINE__, 12.0E-15DD, "0.000000", "%Df"}, {__LINE__, 12.0E-5DD, "0.000120", "%Df"}, {__LINE__, 12.0E-15DD, "1.2e-14", "%Dg"}, {__LINE__, 0.E+0DD, "0.000000", "%Df"}, {__LINE__, 1.E+2DD, "100.000000", "%Df"}, {__LINE__, 12.0E+3DD, "1.200000e+04", "%De"}, {__LINE__, 12.000E+3DD, "1.200000e+04", "%De"}, {__LINE__, 12.0E+3DD, "12000.000000", "%Df"}, {__LINE__, 1900000.E+2DD, "190000000.000000", "%Df"}, {__LINE__, 1900000.E+2DD, "190000000", "%.Df"}, {__LINE__, 19.E+2DD, "1900.000000", "%Df"}, /* Default precision. */ {__LINE__, 1.0E+2DD, "100.000000", "%Df"}, /* Default precision. */ {__LINE__, 1.00E+2DD, "100.000000", "%Df"}, {__LINE__, 23456.0E-3DD, "2.35e+01", "%.2De"}, {__LINE__, 23456.0E-3DD, "23.46", "%.2Df"}, {__LINE__, 23456.E-3DD, "23.46", "%.2Df"}, {__LINE__, 1234567.E0DD, "1234567.00", "%.2Df"}, {__LINE__, 1234567.E0DD, "1234567.000000", "%Df"}, /* Precision of '3'. */ {__LINE__, 123.456E+0DD, "123.456000", "%Df"}, {__LINE__, 123.456E+0DD, "123.456", "%.3Df"}, /* Implict precision of '1' since there is one explicit zero in the mantissa * right of the decimal place after it is adjusted for the exponent. */ {__LINE__, 1.000E+2DD, "100.000000", "%Df"}, /* Implict precision of '1' since there is one explicit zero in the mantissa * right of the decimal place after it is adjusted for the exponent. */ {__LINE__, 100.0E+0DD, "100.000000", "%Df"}, /* Implict precision of '1' since there is one explicit zero in the mantissa * right of the decimal place after it is adjusted for the exponent. */ {__LINE__, 0.0001000E+6DD, "100.000000", "%Df"}, /* Implict precision of '4' since there is one explicit zero in the mantissa * right of the decimal place after it is adjusted for the exponent. */ {__LINE__, 1.000000E+2DD, "100.000000", "%Df"}, /* Because of the 'e' output precision is '5'. */ {__LINE__, 123.456E+0DD, "1.234560e+02", "%De"}, {__LINE__, 123.456E+0DD, "1.23456e+02", "%.5De"}, {__LINE__, 123.456E+0DD, "1.234560E+02", "%DE"}, {__LINE__, 19000E+15DD, "19000000000000000000.000000", "%Df"}, {__LINE__, 190001E+45DD, "190001000000000000000000000000000000000000000000000.000000", "%Df"}, {__LINE__, -123.456E+0DD, "-1.234560e+02", "%De"}, /* Encoded as 1234567E1, prec 5*/ {__LINE__, 12.34567E+6DD, "12345670.000000", "%Df"}, {__LINE__, 123.456E-5DD, "1.234560e-03", "%De"}, {__LINE__, 123.456E-5DD, "0.001235", "%Df"}, {__LINE__, 123.456E-5DD, "0.00123456", "%Dg"}, {__LINE__, 123.456E-6DD, "1.234560e-04", "%De"}, {__LINE__, 123.456E-6DD, "0.000123", "%Df"}, {__LINE__, 123.456E-6DD, "0.000123456", "%Dg"}, {__LINE__, 123.456E-7DD, "1.234560e-05", "%De"}, {__LINE__, 123.456E-7DD, "0.000012", "%Df"}, {__LINE__, 123.456E-7DD, "1.23456e-05", "%Dg"}, {__LINE__, 123.456E-7DD, "1.235e-05", "%.4Dg"}, {__LINE__, 123.456E-9DD, "1.234560e-07", "%De"}, {__LINE__, 6.5DD, "6.5e+00", "%.1De"}, {__LINE__, 6.5DD, "6e+00", "%.0De"}, {__LINE__, 6.6DD, "7e+00", "%.0De"}, /* Erroneously prints "1e+6" due to the '.' with no explicit precision. Fix * ME. */ {__LINE__, 6.0E5DD, "6e+5", "%.Da"}, {__LINE__, 123.456E-9DD, "1.23456e-7", "%Da"}, {__LINE__, 0.00000E-101DD, "0.000000e+00", "%De"}, {__LINE__, 0.e-101DD, "0e-101", "%Da"}, /* This returns 0e-106 because the zeros are significant. */ {__LINE__, 0.00000E-101DD, "0e-106", "%Da"}, {__LINE__, 0.0e10DD, "0.000000e+00", "%De"}, {__LINE__, 0.0e10DD, "0.000000", "%Df"}, {__LINE__, 0.0e10DD, "0", "%Dg"}, /* For 'g' when '#' is present the spec says that trailing zeros are NOT * removed. And YES, this SHOULD be five trailing zeros because this falls * into the category where 'g' is converted to 'e' and precision equals P - 1. * Additionally, the C-spec indicates that. This is congruent with how this * works for binary float. */ {__LINE__, 0.0e10DD, "0.00000", "%#Dg"}, {__LINE__, 0.0e10DD, "0", "%.4Dg"}, /* (1,0,-1) */ {__LINE__, 0.0DD, "0.0", "%Da"}, {__LINE__, 0e10DD, "0e+10", "%Da"}, {__LINE__, 0.0e10DD, "0e+9", "%.1Da"}, {__LINE__, 0.0e-09DD, "0e-10", "%.0Da"}, /* (1,0,0) */ {__LINE__, 0e0DD, "0", "%Da"}, /* (1,0,0) */ {__LINE__, -0e0DD, "-0", "%Da"}, /* (-1,0,-1) */ {__LINE__, -0.0DD, "-0.0", "%Da"}, /* ( 1, 123, 0) */ {__LINE__, 123.DD, "123", "%Da"}, /* (-1, 123, 0) -123 */ {__LINE__, -123.DD, "-123", "%Da"}, /* ( 1, 123, -2) 1.23 */ {__LINE__, 1.23DD, "1.23", "%Da"}, {__LINE__, 123E-2DD, "1.23", "%Da"}, {__LINE__, 0.123E1DD, "1.23", "%Da"}, /* ( 1, 123, 1) 1.23e+3 */ {__LINE__, 123e1DD, "1.23e+3", "%Da"}, /* ( 1, 1230, 0) 1230 */ {__LINE__, 123.0e1DD, "1230", "%Da"}, /* (-1, 123, 1) -1.23e+3 */ {__LINE__, -123e1DD, "-1.23e+3", "%Da"}, /* ( 1, 123, -8) 0.00000123 */ {__LINE__, 123e-8DD, "0.00000123", "%Da"}, {__LINE__, 123.e-8DD, "0.00000123", "%Da"}, /* ( 1, 123, -9) 1.23e-7 */ {__LINE__, 123e-9DD, "1.23e-7", "%Da"}, {__LINE__, 123.e-9DD, "1.23e-7", "%Da"}, /* Can represent the following in _Decimal64 */ /* ( 1, 1234567890123456, 0) 1234567890123456 */ {__LINE__, 1234567890123456e0DD, "1234567890123456", "%Da"}, /* ( 1, 1234567890123456, 1) 1.234567890123456e+16 */ {__LINE__, 1234567890123456e1DD, "1.234567890123456e+16", "%Da"}, /* ( 1, 1234567890123456, -1) 123456789012345.6 */ {__LINE__, 1234567890123456e-1DD, "123456789012345.6", "%Da"}, /* ( 1, 1234567890123456, -21) 0.000001234567890123456 */ {__LINE__, 1234567890123456e-21DD, "0.000001234567890123456", "%Da"}, /* ( 1, 1234567890123456, -22) 1.234567890123456e-7 */ {__LINE__, 1234567890123456e-22DD, "1.234567890123456e-7", "%Da"}, /* ( 1, 0, 0) 0 */ {__LINE__, 0e0DD, "0", "%Da"}, {__LINE__, 0.DD, "0", "%Da"}, {__LINE__, 0.e0DD, "0", "%Da"}, /* (-1, 0, 0) -0 */ {__LINE__, -0e0DD, "-0", "%Da"}, {__LINE__, -0.DD, "-0", "%Da"}, {__LINE__, -0.e0DD, "-0", "%Da"}, /* ( 1, 0, -6) 0.000000 */ {__LINE__, 0e-6DD, "0.000000", "%Da"}, /* ( 1, 0, -7) 0e-7 */ {__LINE__, 0e-7DD, "0e-7", "%Da"}, {__LINE__, 0.e-10DD, "0e-10", "%.1Da"}, {__LINE__, 0.e-10DD, "0e-10", "%.3Da"}, {__LINE__, 0.e-10DD, "0e-10", "%.4Da"}, /* ( 1, 5, -6) 0.000005 */ {__LINE__, 5e-6DD, "0.000005", "%Da"}, /* ( 1, 50, -7) 0.0000050 */ {__LINE__, 50e-7DD, "0.0000050", "%Da"}, /* ( 1, 5, -7) 5e-7 */ {__LINE__, 5e-7DD, "5e-7", "%Da"}, /* ( 1, 0, 2) 0e+2 encoded as 00000000e2. */ {__LINE__, 0e2DD, "0e+2", "%Da"}, /* Yes, goofy, but it is encoded 00000000e1. */ {__LINE__, 0.0e2DD, "0e+1", "%Da"}, {__LINE__, 0.0e10DD, "0e+9", "%Da"}, /* Yes, goofy, but it is encoded 00000000e0. */ {__LINE__, 0.00e2DD, "0", "%Da"}, /* Yes, goofy, but it is encoded 00000000e0. */ {__LINE__, 0.00e2DD, "0", "%.2Da"}, /* Notice the '#'. The DDP spec doesn't speak about this and doesn't indicate * that this is supposed to work like it does for 'g' so we still expect to * see trailing zeros removed and no exponent. */ {__LINE__, 0.00e2DD, "0.", "%#Da"}, /* ( 1, 5, -7) */ {__LINE__, 5e-7DD, "5.e-7", "%#Da"}, {__LINE__, 6543.E-11DD, "6.543e-8", "%Da"}, /* Continued DPF spec examples. */ {__LINE__, 6543.00DD, "6543.00", "%Da"}, {__LINE__, 6543.00DD, "6543.00", "%.6Da"}, {__LINE__, 6543.00DD, "6543.0", "%.5Da"}, {__LINE__, 6543.00DD, "6543", "%.4Da"}, {__LINE__, 6543.00DD, "6.54e+3", "%.3Da"}, {__LINE__, 6543.00DD, "6.5e+3", "%.2Da"}, {__LINE__, 6543.00DD, "7e+3", "%.1Da"}, {__LINE__, 6543.00DD, "7E+3", "%.1DA"}, {__LINE__, 6543.00DD, " 6543.00", "%8Da"}, {__LINE__, __DEC64_MAX__, "9.999999999999999e+384", "%.17Dg" }, {__LINE__, __DEC64_MAX__, "9.999999999999999e+384", "%Da" }, {__LINE__, __DEC64_MAX__, "1.000000e+385", "%De" }, {__LINE__, __DEC64_MAX__, "9.999999999999999e+384", "%.16Da" }, {__LINE__, __DEC64_MAX__, "1.00e+385", "%.3Da" }, {__LINE__, 9.999999999999999E16DD, "9.999999999999999e+16", "%.16Dg" }, {__LINE__, 9.999999999999999E23DD, "9.999999999999999e+23", "%.16Dg" }, {__LINE__, 9.999999999999999E300DD, "9.999999999999999e+300", "%.16Dg" }, {__LINE__, 9.999999999999999E360DD, "9.999999999999999e+360", "%.16Dg" }, {__LINE__, 9.999999999999999E369DD, "9.999999999999999e+369", "%.16Dg" }, {__LINE__, 9.999999999999999E370DD, "9.999999999999999e+370", "%.16Dg" }, {__LINE__, 9.999999999999999E379DD, "9.999999999999999e+379", "%.16Dg" }, {__LINE__, 9.999999999999999E380DD, "9.999999999999999e+380", "%.16Dg" }, {__LINE__, 9999999999999999E369DD, "9.999999999999999e+384", "%.16Dg" }, {__LINE__, 4E384DD, "4e+384", "%Dg" }, {__LINE__, 4E384DD, "4e+384", "%.Dg" }, {0,0,0,0 } }; typedef struct{ int line; _Decimal128 d; const char *expect; const char *format; } d128_type; d128_type printf_d128s[] = { /* Default precision. */ {__LINE__, 123.456E-6DL, "0.000123", "%DDf"}, {__LINE__, 123.456E-6DL, "1.234560e-04", "%DDe"}, {__LINE__, 12.0E-15DL, "0.000000", "%DDf"}, {__LINE__, 12.0E-5DL, "0.000120", "%DDf"}, {__LINE__, 12.0E-15DL, "1.2e-14", "%DDg"}, {__LINE__, 0.E+0DL, "0.000000", "%DDf"}, {__LINE__, 1.E+2DL, "100.000000", "%DDf"}, {__LINE__, 12.0E+3DL, "1.200000e+04", "%DDe"}, {__LINE__, 12.000E+3DL, "1.200000e+04", "%DDe"}, {__LINE__, 12.0E+3DL, "12000.000000", "%DDf"}, {__LINE__, 1900000.E+2DL, "190000000.000000", "%DDf"}, {__LINE__, 1900000.E+2DL, "190000000", "%.DDf"}, {__LINE__, 19.E+2DL, "1900.000000", "%DDf"}, /* Default precision. */ {__LINE__, 1.0E+2DL, "100.000000", "%DDf"}, /* Default precision. */ {__LINE__, 1.00E+2DL, "100.000000", "%DDf"}, {__LINE__, 23456.0E-3DL, "2.35e+01", "%.2DDe"}, {__LINE__, 23456.0E-3DL, "23.46", "%.2DDf"}, {__LINE__, 23456.E-3DL, "23.46", "%.2DDf"}, {__LINE__, 1234567.E0DL, "1234567.00", "%.2DDf"}, {__LINE__, 1234567.E0DL, "1234567.000000", "%DDf"}, /* Precision of '3'. */ {__LINE__, 123.456E+0DL, "123.456000", "%DDf"}, {__LINE__, 123.456E+0DL, "123.456", "%.3DDf"}, /* Implict precision of '1' since there is one explicit zero in the mantissa * right of the decimal place after it is adjusted for the exponent. */ {__LINE__, 1.000E+2DL, "100.000000", "%DDf"}, /* Implict precision of '1' since there is one explicit zero in the mantissa * right of the decimal place after it is adjusted for the exponent. */ {__LINE__, 100.0E+0DL, "100.000000", "%DDf"}, /* Implict precision of '1' since there is one explicit zero in the mantissa * right of the decimal place after it is adjusted for the exponent. */ {__LINE__, 0.0001000E+6DL, "100.000000", "%DDf"}, /* Implict precision of '4' since there is one explicit zero in the mantissa * right of the decimal place after it is adjusted for the exponent. */ {__LINE__, 1.000000E+2DL, "100.000000", "%DDf"}, /* Because of the 'e' output precision is '5'. */ {__LINE__, 123.456E+0DL, "1.234560e+02", "%DDe"}, {__LINE__, 123.456E+0DL, "1.23456e+02", "%.5DDe"}, {__LINE__, 123.456E+0DL, "1.234560E+02", "%DDE"}, {__LINE__, 19000E+15DL, "19000000000000000000.000000", "%DDf"}, {__LINE__, 190001E+45DL, "190001000000000000000000000000000000000000000000000.000000", "%DDf"}, {__LINE__, -123.456E+0DL, "-1.234560e+02", "%DDe"}, /* Encoded as 1234567E1, prec 5*/ {__LINE__, 12.34567E+6DL, "12345670.000000", "%DDf"}, {__LINE__, 123.456E-5DL, "1.234560e-03", "%DDe"}, {__LINE__, 123.456E-5DL, "0.001235", "%DDf"}, {__LINE__, 123.456E-5DL, "0.00123456", "%DDg"}, {__LINE__, 123.456E-6DL, "1.234560e-04", "%DDe"}, {__LINE__, 123.456E-6DL, "0.000123", "%DDf"}, {__LINE__, 123.456E-6DL, "0.000123456", "%DDg"}, {__LINE__, 123.456E-7DL, "1.234560e-05", "%DDe"}, {__LINE__, 123.456E-7DL, "0.000012", "%DDf"}, {__LINE__, 123.456E-7DL, "1.23456e-05", "%DDg"}, {__LINE__, 123.456E-7DL, "1.235e-05", "%.4DDg"}, {__LINE__, 123.456E-9DL, "1.234560e-07", "%DDe"}, {__LINE__, 6.5DL, "6.5e+00", "%.1DDe"}, {__LINE__, 6.5DL, "6e+00", "%.0DDe"}, {__LINE__, 6.6DL, "7e+00", "%.0DDe"}, /* Erroneously prints "1e+6" due to the '.' with no explicit precision. FIX * ME. */ {__LINE__, 6.0E5DL, "6e+5", "%.DDa"}, {__LINE__, 123.456E-9DL, "1.23456e-7", "%DDa"}, {__LINE__, 0.00000E-101DL, "0.000000e+00", "%DDe"}, {__LINE__, 0.e-101DL, "0e-101", "%DDa"}, /* This returns 0e-106 because the zeros are significant. */ {__LINE__, 0.00000E-101DL, "0e-106", "%DDa"}, {__LINE__, 0.0e10DL, "0.000000e+00", "%DDe"}, {__LINE__, 0.0e10DL, "0.000000", "%DDf"}, {__LINE__, 0.0e10DL, "0", "%DDg"}, /* For 'g' when '#' is present the spec says that trailing zeros are NOT * removed. And YES, this SHOULD be five trailing zeros because this falls * into the category where 'g' is converted to 'e' and precision equals P - 1. * Additionally, the C-spec indicates that. This is congruent with how this * works for binary float. */ {__LINE__, 0.0e10DL, "0.00000", "%#DDg"}, {__LINE__, 0.0e10DL, "0", "%.4DDg"}, /* (1,0,-1) */ {__LINE__, 0.0DL, "0.0", "%DDa"}, {__LINE__, 0e10DL, "0e+10", "%DDa"}, {__LINE__, 0.0e10DL, "0e+9", "%.1DDa"}, {__LINE__, 0.0e-09DL, "0e-10", "%.0DDa"}, /* (1,0,0) */ {__LINE__, 0e0DL, "0", "%DDa"}, /* (1,0,0) */ {__LINE__, -0e0DL, "-0", "%DDa"}, /* (-1,0,-1) */ {__LINE__, -0.0DL, "-0.0", "%DDa"}, /* ( 1, 123, 0) */ {__LINE__, 123.DL, "123", "%DDa"}, /* (-1, 123, 0) -123 */ {__LINE__, -123.DL, "-123", "%DDa"}, /* ( 1, 123, -2) 1.23 */ {__LINE__, 1.23DL, "1.23", "%DDa"}, {__LINE__, 123E-2DL, "1.23", "%DDa"}, {__LINE__, 0.123E1DL, "1.23", "%DDa"}, /* ( 1, 123, 1) 1.23e+3 */ {__LINE__, 123e1DL, "1.23e+3", "%DDa"}, /* ( 1, 1230, 0) 1230 */ {__LINE__, 123.0e1DL, "1230", "%DDa"}, /* (-1, 123, 1) -1.23e+3 */ {__LINE__, -123e1DL, "-1.23e+3", "%DDa"}, /* ( 1, 123, -8) 0.00000123 */ {__LINE__, 123e-8DL, "0.00000123", "%DDa"}, {__LINE__, 123.e-8DL, "0.00000123", "%DDa"}, /* ( 1, 123, -9) 1.23e-7 */ {__LINE__, 123e-9DL, "1.23e-7", "%DDa"}, {__LINE__, 123.e-9DL, "1.23e-7", "%DDa"}, /* Can represent the following in _Decimal128 */ /* ( 1, 1234567890123456, 0) 1234567890123456 */ {__LINE__, 1234567890123456e0DL, "1234567890123456", "%DDa"}, /* ( 1, 1234567890123456, 1) 1.234567890123456e+16 */ {__LINE__, 1234567890123456e1DL, "1.234567890123456e+16", "%DDa"}, /* ( 1, 1234567890123456, -1) 123456789012345.6 */ {__LINE__, 1234567890123456e-1DL, "123456789012345.6", "%DDa"}, /* ( 1, 1234567890123456, -21) 0.000001234567890123456 */ {__LINE__, 1234567890123456e-21DL, "0.000001234567890123456", "%DDa"}, /* ( 1, 1234567890123456, -22) 1.234567890123456e-7 */ {__LINE__, 1234567890123456e-22DL, "1.234567890123456e-7", "%DDa"}, /* ( 1, 0, 0) 0 */ {__LINE__, 0e0DL, "0", "%DDa"}, {__LINE__, 0.DL, "0", "%DDa"}, {__LINE__, 0.e0DL, "0", "%DDa"}, /* (-1, 0, 0) -0 */ {__LINE__, -0e0DL, "-0", "%DDa"}, {__LINE__, -0.DL, "-0", "%DDa"}, {__LINE__, -0.e0DL, "-0", "%DDa"}, /* ( 1, 0, -6) 0.000000 */ {__LINE__, 0e-6DL, "0.000000", "%DDa"}, /* ( 1, 0, -7) 0e-7 */ {__LINE__, 0e-7DL, "0e-7", "%DDa"}, {__LINE__, 0.e-10DL, "0e-10", "%.1DDa"}, {__LINE__, 0.e-10DL, "0e-10", "%.3DDa"}, {__LINE__, 0.e-10DL, "0e-10", "%.4DDa"}, /* ( 1, 5, -6) 0.000005 */ {__LINE__, 5e-6DL, "0.000005", "%DDa"}, /* ( 1, 50, -7) 0.0000050 */ {__LINE__, 50e-7DL, "0.0000050", "%DDa"}, /* ( 1, 5, -7) 5e-7 */ {__LINE__, 5e-7DL, "5e-7", "%DDa"}, /* ( 1, 0, 2) 0e+2 encoded as 00000000e2. */ {__LINE__, 0e2DL, "0e+2", "%DDa"}, /* Yes, goofy, but it is encoded 00000000e1. */ {__LINE__, 0.0e2DL, "0e+1", "%DDa"}, {__LINE__, 0.0e10DL, "0e+9", "%DDa"}, /* Yes, goofy, but it is encoded 00000000e0. */ {__LINE__, 0.00e2DL, "0", "%DDa"}, /* Yes, goofy, but it is encoded 00000000e0. */ {__LINE__, 0.00e2DL, "0", "%.2DDa"}, /* Notice the '#'. The DLP spec doesn't speak about this and doesn't indicate * that this is supposed to work like it does for 'g' so we still expect to * see trailing zeros removed and no exponent. */ {__LINE__, 0.00e2DL, "0.", "%#DDa"}, /* ( 1, 5, -7) */ {__LINE__, 5e-7DL, "5.e-7", "%#DDa"}, {__LINE__, 6543.E-11DL, "6.543e-8", "%DDa"}, /* Continued DPF spec examples. */ {__LINE__, 6543.00DL, "6543.00", "%DDa"}, {__LINE__, 6543.00DL, "6543.00", "%.6DDa"}, {__LINE__, 6543.00DL, "6543.0", "%.5DDa"}, {__LINE__, 6543.00DL, "6543", "%.4DDa"}, {__LINE__, 6543.00DL, "6.54e+3", "%.3DDa"}, {__LINE__, 6543.00DL, "6.5e+3", "%.2DDa"}, {__LINE__, 6543.00DL, "7e+3", "%.1DDa"}, {__LINE__, 6543.00DL, "7E+3", "%.1DDA"}, {__LINE__, 6543.00DL, "6543.00", "%.8DDa"}, /* Fixed by Andreas Schwab on 2010-20-04 */ {__LINE__, 0.9999999999DL, "1.000000", "%DDf"}, /* Caused a segv due to a the negative exponent generating a negative 'index'. * It was fixed by Andreas Krebbel on 2011-01-18 */ {__LINE__, (1.0DL / 1.000000e-123DL), "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000", "%DDf"}, {__LINE__, -1234.56789123456789123455678DL, "-1234.56789123", "%.8DDf"}, /* This prints like f/F but g/G computes precision based on all digits in * the mantissa, not just those to the right of the decimal place like * regular f/F. */ {__LINE__, -1234.56789123456789123455678DL, "-1234.5679", "%.8DDg"}, {__LINE__, -1234.56789123456789123455678DL, "-1234.56789123", "%.12DDg"}, /* This isn't properly rounding after the truncated. FIX ME. */ {__LINE__, -1234.56789123456789123455678DL, "-1234.57", "%DDg"}, {__LINE__, -1234.56789123456789123455678DL, "-1234.5679", "%.8DDa"}, {__LINE__, -1234.56789123456789123455678DL, "-1.234568e+03", "%.6DDe"}, {__LINE__, -1234.56789123456789123455678DL, "-1.23456789e+03", "%.8DDe"}, {0,0,0,0 } }; typedef struct{ int line; float f; _Decimal32 d; const char *expect; const char *format; } m32_type; m32_type printf_m32s[] = { {__LINE__, 1.0, 123.456E-6DL, "1.000000 0.000123", "%f %Hf"}, {0,0,0,0,0 } }; int main (void) { d32_type *d32ptr; d64_type *d64ptr; d128_type *d128ptr; m32_type *m32ptr; for (d32ptr = printf_d32s; d32ptr->line; d32ptr++) { _PC_P(__FILE__,d32ptr->line, d32ptr->expect,d32ptr->format,d32ptr->d); } for (d64ptr = printf_d64s; d64ptr->line; d64ptr++) { _PC_P(__FILE__,d64ptr->line, d64ptr->expect,d64ptr->format,d64ptr->d); } for (d128ptr = printf_d128s; d128ptr->line; d128ptr++) { _PC_P(__FILE__,d128ptr->line, d128ptr->expect,d128ptr->format,d128ptr->d); } for (m32ptr = printf_m32s; m32ptr->line; m32ptr++) { _PC_P(__FILE__, m32ptr->line, m32ptr->expect, m32ptr->format, \ m32ptr->f, m32ptr->d); } _REPORT(); /* fail comes from scaffold.c */ return fail; } libdfp-1.0.12/tests/test-setexp.c000066400000000000000000000126371261375163000166430ustar00rootroot00000000000000/* Unit test the internal getexpd[32|64|128]() functions. Copyright (C) 2014-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef __STDC_WANT_DEC_FP__ #define __STDC_WANT_DEC_FP__ #endif #include #include #include /* DEC_NAN definition. */ #include #define _DECIMAL_SIZE 32 #define DEC_TYPE _Decimal32 #include #undef _DECIMAL_SIZE #undef DEC_TYPE #define _DECIMAL_SIZE 64 #define DEC_TYPE _Decimal64 #include #undef _DECIMAL_SIZE #undef DEC_TYPE #define _DECIMAL_SIZE 128 #define DEC_TYPE _Decimal128 #include #undef _DECIMAL_SIZE #undef DEC_TYPE #define _WANT_VC 1 /* Pick up the _VC_P(x,y,fmt) macro. */ #include "scaffold.c" /* Pick up the _VC_P(x,y,fmt) macro. */ /* We're going to be comparing fields so we need to extract the data. This is a * sneaky way to get around the fact that get_digits_d* isn't exported from * libdfp. */ #ifdef __DECIMAL_BID_FORMAT__ # include "../sysdeps/bid/bid-private.c" #else # include "../sysdeps/dpd/dpd-private.c" #endif typedef struct{ int line; _Decimal128 x; int e; _Decimal128 r; const char *format; } d128_type; #define RET128_MAX 6111 #define RET128_MIN -6143 #define RET128_MIN_SUB -6176 #define DEC128_TEST(__x, __e, __r) \ { __LINE__, __x, __e, __r, "%DDeDL" } static const d128_type d128[] = { DEC128_TEST (1E0DL, 1, 1E1DL), DEC128_TEST (1E0DL, 10, 1E10DL), DEC128_TEST (1E0DL, 100, 1E100DL), DEC128_TEST (1E100DL, 0, 1E0DL), DEC128_TEST (1E10DL, 0, 1E0DL), DEC128_TEST (1E1DL, 0, 1E0DL), DEC128_TEST (9999999999999999999999999999999999E0DL, 1, 9999999999999999999999999999999999E1DL), DEC128_TEST (9999999999999999999999999999999999E0DL, 10, 9999999999999999999999999999999999E10DL), DEC128_TEST (9999999999999999999999999999999999E0DL, 100, 9999999999999999999999999999999999E100DL) }; static const int d128_len = sizeof (d128) / sizeof (d128[0]); typedef struct { int line; _Decimal64 x; int e; _Decimal64 r; const char *format; } d64_type; #define RET64_MAX 369 #define RET64_MIN -383 #define RET64_MIN_SUB -398 #define DEC64_TEST(__x, __e, __r) \ { __LINE__, __x, __e, __r, "%DeDD" } static const d64_type d64[] = { DEC128_TEST (1E0DD, 1, 1E1DD), DEC128_TEST (1E0DD, 10, 1E10DD), DEC128_TEST (1E0DD, 100, 1E100DD), DEC128_TEST (1E100DD, 0, 1E0DD), DEC128_TEST (1E10DD, 0, 1E0DD), DEC128_TEST (1E1DD, 0, 1E0DD), DEC128_TEST (9999999999999999E0DD, 1, 9999999999999999E1DD), DEC128_TEST (9999999999999999E0DD, 10, 9999999999999999E10DD), DEC128_TEST (9999999999999999E0DD, 100, 9999999999999999E100DD) }; static const int d64_len = sizeof (d64) / sizeof (d64[0]); typedef struct { int line; _Decimal32 x; int e; _Decimal32 r; const char *format; } d32_type; #define RET32_MAX 90 #define RET32_MIN -95 #define RET32_MIN_SUB -101 #define DEC32_TEST(__x, __e, __r) \ { __LINE__, __x, __e, __r, "%HeDF" } static const d32_type d32[] = { DEC128_TEST (1E0DF, 1, 1E1DF), DEC128_TEST (1E0DF, 10, 1E10DF), DEC128_TEST (1E0DF, 90, 1E90DF), DEC128_TEST (1E90DF, 0, 1E0DF), DEC128_TEST (1E10DF, 0, 1E0DF), DEC128_TEST (1E1DF, 0, 1E0DF), DEC128_TEST (9999999E0DF, 1, 9999999E1DF), DEC128_TEST (9999999E0DF, 10, 9999999E10DF), DEC128_TEST (9999999E0DF, 90, 9999999E90DF) }; static const int d32_len = sizeof (d32) / sizeof (d32[0]); int main (void) { int i; for (i=0; i The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef __STDC_WANT_DEC_FP__ # define __STDC_WANT_DEC_FP__ 1 #endif #include #include #include #include #include "decode.h" #define _WANT_VC 1 #define _WANT_DC 1 #include "scaffold.c" /* Inspired by GLIBC stdio-common/tfformat.c */ typedef struct{ int line; const char *input; _Decimal32 d32; _Decimal64 d64; _Decimal128 d128; } d_type; d_type strtods[] = { {__LINE__, "12.04", 12.04DF,12.04DD, 12.04DL}, {__LINE__, "1.0", 1.0DF, 1.0DD, 1.0DL }, {__LINE__, "1", 1.0DF, 1.0DD, 1.0DL }, {__LINE__, "0", 0.0DF, 0.0DD, 0.0DL }, {__LINE__, "0.0", 0.0DF, 0.0DD, 0.0DL }, {__LINE__, "-0.0001", -0.0001DF, -0.0001DD, -0.0001DL }, {__LINE__, "inf", DEC_INFINITY, DEC_INFINITY, DEC_INFINITY }, {__LINE__, "INFINITY", DEC_INFINITY, DEC_INFINITY, DEC_INFINITY }, {__LINE__, "0.0E+100", 0.0DF, 0.0DD, 0.0DL }, {__LINE__, "0.01", 0.01DF, 0.01DD, 0.01DL }, {__LINE__, "0.1", 0.1DF, 0.1DD, 0.1DL }, {__LINE__, "0.11", 0.11DF, 0.11DD, 0.11DL }, {__LINE__, "0.21", 0.21DF, 0.21DD, 0.21DL }, {__LINE__, "0.999999", 0.999999DF, 0.999999DD, 0.999999DL }, {__LINE__, "0.9999999", 0.9999999DF, 0.9999999DD, 0.9999999DL }, {__LINE__, "0.99999999", 1.000000DF, 0.99999999DD, 0.99999999DL }, {__LINE__, "0.999999999", 1.000000DF, 0.999999999DD, 0.999999999DL }, {__LINE__, "19e9", 19000000000.0DF, 19000000000.0DD, 19000000000.0DL }, {__LINE__, "3.14", 3.140000DF, 3.140000DD, 3.140000DL }, {__LINE__, "3.14e-2", 0.031400DF, 0.031400DD, 0.031400DL }, {__LINE__, "1234.5678910111213e-5", 0.01234568DF ,0.01234567891011121DD ,0.012345678910111213DL }, {__LINE__, "-1234.57", -1234.57DF, -1234.57DD, -1234.57DL}, {0,0,0,0,0 } }; const char DECLET32_NAN[] = "+0,000,000E-101"; const char DECLET64_NAN[] = "+0,000,000,000,000,000E-398"; const char DECLET128_NAN[] = "+0,000,000,000,000,000,000,000,000,000,000,000E-6176"; const char DECLET_ZERO_D32[] = "+0,000,000E+0"; const char DECLET_ZERO_D64[] = "+0,000,000,000,000,000E+0"; const char DECLET_HUGE_VAL_D32[] = "+0,000,000E-101"; const char DECLET_HUGE_VAL_D64[] = "+0,000,000,000,000,000E-398"; const char DECLET_HUGE_VAL_D128[] = "+0,000,000,000,000,000,000,000,000,000,000,000E-6176"; /* Inspired by GLIBC stdio-common/tfformat.c */ typedef struct{ int line; const char *input; const char *d32; const char *d64; const char *d128; } d_nan_type; d_nan_type strtods_nan[] = { /* Compare against the decoded declet for each representation of DEC_NAN * since you can't compare DEC_NAN to DEC_NAN. */ {__LINE__, "NaN", DECLET32_NAN, DECLET64_NAN, DECLET128_NAN}, {__LINE__, "4E-382", "+0,000,000E+0", "+0,000,000,000,000,004E-382", "+0,000,000,000,000,000,000,000,000,000,000,004E-382"}, /* __DEC64_SUBNORMAL_MIN__ */ {__LINE__, "0.000000000000001E-383", DECLET_ZERO_D32, "+0,000,000,000,000,001E-398", "+0,000,000,000,000,000,000,000,000,000,000,001E-398"}, /* This exceeds __DEC64_MIN_EXP__ so it can't be encoded in _Decimal64 and will underflow. */ {__LINE__, "4E-399", DECLET_ZERO_D32, "+0,000,000,000,000,000E+0", "+0,000,000,000,000,000,000,000,000,000,000,004E-399"}, {__LINE__, "4000000000000000E-383", DECLET_ZERO_D32, "+4,000,000,000,000,000E-383", "+0,000,000,000,000,000,004,000,000,000,000,000E-383"}, {__LINE__, "4000000000000000E-384", DECLET_ZERO_D32, "+4,000,000,000,000,000E-384", "+0,000,000,000,000,000,004,000,000,000,000,000E-384"}, {__LINE__, "4000000000000000E-398", DECLET_ZERO_D32, "+4,000,000,000,000,000E-398", "+0,000,000,000,000,000,004,000,000,000,000,000E-398"}, /* This exceeds __DEC64_MIN_EXP__ so it can't be encoded in _Decimal64 and will underflow. */ {__LINE__, "4000000000000000E-399", DECLET_ZERO_D32, DECLET_ZERO_D64, "+0,000,000,000,000,000,004,000,000,000,000,000E-399"}, /* This exceeds __DEC64_SUBNORMAL_MIN__ so it can't be encoded in _Decimal64 and will underflow. */ {__LINE__, "4E-400", DECLET_ZERO_D32, DECLET_ZERO_D64, "+0,000,000,000,000,000,000,000,000,000,000,004E-400"}, {__LINE__, "4E369", DECLET_HUGE_VAL_D32, "+0,000,000,000,000,004E+369", "+0,000,000,000,000,000,000,000,000,000,000,004E+369"}, {__LINE__, "4E383", DECLET_HUGE_VAL_D32, "+4,000,000,000,000,000E+368", "+0,000,000,000,000,000,000,000,000,000,000,004E+383"}, {__LINE__, "4E384", DECLET_HUGE_VAL_D32, "+4,000,000,000,000,000E+369", "+0,000,000,000,000,000,000,000,000,000,000,004E+384"}, {__LINE__, "4E385", DECLET_HUGE_VAL_D32, DECLET_HUGE_VAL_D64, "+0,000,000,000,000,000,000,000,000,000,000,004E+385"}, {__LINE__, "4E97", DECLET_HUGE_VAL_D32, "+0,000,000,000,000,004E+97", "+0,000,000,000,000,000,000,000,000,000,000,004E+97"}, {__LINE__, "4E6145",DECLET_HUGE_VAL_D32, DECLET_HUGE_VAL_D64, DECLET_HUGE_VAL_D128}, {__LINE__, "1.23456789E-7", "+1,234,568E-13", "+0,000,000,123,456,789E-15", "+0,000,000,000,000,000,000,000,000,123,456,789E-15" }, {__LINE__, "1234.5678910111213e-5", "+1,234,568E-8", "+1,234,567,891,011,121E-17", "+0,000,000,000,000,000,012,345,678,910,111,213E-18" }, {0,0,0,0,0 } }; int main(void) { d_type *dptr; for (dptr = strtods; dptr->line; dptr++) { fprintf(stdout, "strtod32(\"%s\",NULL) == %Hf\n ", dptr->input, strtod32(dptr->input, NULL)); _VC_P(__FILE__,dptr->line,dptr->d32,strtod32(dptr->input,NULL), "%Hf"); fprintf(stdout, "strtod64(\"%s\",NULL) == %Df\n ", dptr->input, strtod64(dptr->input, NULL)); _VC_P(__FILE__,dptr->line,dptr->d64, strtod64(dptr->input,NULL), "%Df"); fprintf(stdout, "strtod128(\"%s\",NULL) == %DDf\n ", dptr->input, strtod128(dptr->input, NULL)); _VC_P(__FILE__,dptr->line,dptr->d128, strtod128(dptr->input,NULL), "%DDf"); } d_nan_type *dnanptr; for (dnanptr = strtods_nan; dnanptr->line; dnanptr++) { _DC_P(__FILE__,dnanptr->line,dnanptr->d32,strtod32(dnanptr->input,NULL)); _DC_P(__FILE__,dnanptr->line,dnanptr->d64, strtod64(dnanptr->input,NULL)); _DC_P(__FILE__,dnanptr->line,dnanptr->d128, strtod128(dnanptr->input,NULL)); } _REPORT(); /* fail comes from scaffold.c */ return fail; } libdfp-1.0.12/tests/test-wchar.c000066400000000000000000000022101261375163000164210ustar00rootroot00000000000000/* Test wchar.h includes. Copyright (C) 2011-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Ryan S. Arnold The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #ifndef __STDC_WANT_DEC_FP__ #define __STDC_WANT_DEC_FP__ #endif /* In the past wchar.h was missing a #include */ #include int main(void) { return 0; } libdfp-1.0.12/tests/trunc.input000066400000000000000000000031721261375163000164200ustar00rootroot00000000000000# name trunc # arg1 decimal # ret decimal Inf Inf -Inf -Inf NaN NaN sNaN NaN 0.0 0.0 -0.0 -0.0 0.0 0.0 -0.0 -0.0 0.2 0.0 -0.2 -0.0 0.5 0.0 -0.5 -0.0 0.8 0.0 -0.8 -0.0 1.5 1.0 -1.5 -1.0 0.1 0.0 0.25 0.0 0.625 0.0 -0.1 -0.0 -0.25 -0.0 -0.625 -0.0 97152.5 97152.0 -97152.5 -97152.0 -370495.5 -370495.0 -370496.25 -370496.0 -370496.5 -370496.0 -370496.75 -370496.0 -370497.5 -370497.0 2097152.5 2097152.0 decimal64 decimal128 -2097152.5 -2097152.0 decimal64 decimal128 -3599627370495.5 -3599627370495.0 decimal64 decimal128 -3599627370496.25 -3599627370496.0 decimal64 decimal128 -3599627370496.5 -3599627370496.0 decimal64 decimal128 -3599627370496.75 -3599627370496.0 decimal64 decimal128 -3599627370497.5 -3599627370497.0 decimal64 decimal128 -4503599627370495.5 -4503599627370495.0 decimal128 -4503599627370496.25 -4503599627370496.0 decimal128 -4503599627370496.5 -4503599627370496.0 decimal128 -4503599627370496.75 -4503599627370496.0 decimal128 -4503599627370497.5 -4503599627370497.0 decimal128 libdfp-1.0.12/wcstod128.c000066400000000000000000000021201261375163000147340ustar00rootroot00000000000000/* Convert string representing a number to Decimal Float value Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define USE_WIDE_CHAR 1 #include libdfp-1.0.12/wcstod32.c000066400000000000000000000021171261375163000146540ustar00rootroot00000000000000/* Convert string representing a number to Decimal Float value Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define USE_WIDE_CHAR 1 #include libdfp-1.0.12/wcstod64.c000066400000000000000000000021171261375163000146610ustar00rootroot00000000000000/* Convert string representing a number to Decimal Float value Copyright (C) 2006 IBM Corporation. Copyright (C) 2007-2015 Free Software Foundation, Inc. This file is part of the Decimal Floating Point C Library. Author(s): Joseph Kerian The Decimal Floating Point C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1. The Decimal Floating Point C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License version 2.1 for more details. You should have received a copy of the GNU Lesser General Public License version 2.1 along with the Decimal Floating Point C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. Please see libdfp/COPYING.txt for more information. */ #define USE_WIDE_CHAR 1 #include libdfp-1.0.12/ChangeLog.md0000664000175000017500000017661312613751657016145 0ustar00tuliomtuliom00000000000000# ChangeLog ## 1.0.12 - 2015-10-27 - Release 1.0.12 - Fix log10 expected test result - Print correct number of digits testing ulps - Fix quantize test inputs - Remove a workaround from make-release.sh - Minor fixes to make-release.sh - Ensure hardware dfp is disabled with sw only - Fix configure when --with-cpu not supplied - Fix edge case with strtod* - libdfp: powerpc: Simplify _Decimal128 implementation - libdfp: powerpc: Fix fabsd128 implementation - Update the list of contributors - Harden check for the sign bit in the tests - Fix the usage of mfcr extended mnemonic ## 1.0.11 - 2015-07-13 - Release 1.0.11 - Install ChangeLog.md - Fix handle of tags in generate-changelog.sh - Add a bootstrap script and fix warnings - Add release script - Add ChangeLog generator script - Add a printf test for 2 variables - Honor value passed through --docdir - Move system header inclusion - Automatically detect hardware DFP support - Do not clobber configure output - Stop using ldconfig to create symbolic links - Ignore automatically generated files - Cleanup all files after running 'make clean' - Add removing of libdfp-test-ulps.h - Adding support for LDFLAGS passed from env - Allow building from the source code directory - Fix cross compilation ## 1.0.10 - 2015-03-04 - libdfp: Update version for 1.0.10 release. - libdfp: Update copyright dates with scripts/update-copyrights. - libdecnumber: Fixed initialization of int 128 bits. - libdfp: Added more tests to the test-bfp-conversion. - libdfp: Fixed the conversion from float to Decimal32 in x86. - libdfp: truncdddf fixed - libdfp: Add missing ChangeLog - libdfp: Add missing ChangeLog - libdfp: Add missing ChangeLog - libdfp: Add missing ChangeLog - libdfp: Add missing ChangeLog - libdfp: Add missing ChangeLog - libdfp: x86 support added to test-bfp-conversions. - libdfp: Added definitions for the number of digits in strings. - libdfp: Disable C++ tests if compiler does not support it - libdecnumber: Fix warning due braced-groups within expressions - libdfp: Fix __SIZEOF_INT128__ dependency - libdfp: Clean configure.ac from GLIBC support - libdfp: Enable BID for 32bits - libdecnumber: Fix decDebug64 extension - bdfp: Fix setexpd[32|64|128] for x86/BID. - libdfp: Fix NaN1/mask definition for LE/DPD - libdfp: Fix test internal buffer size - libdfp: Add not equal to BID hack alias - Function left_justify fixed for x86/BID. - libdecnumber: Fix potentially out of the bound array access - libdfp: Function left_justify fixed for PPC/DPD. - libdfp: Always link tests with libdfp - libdp: Update documentation - libdfp: Add weak_alias assembler definition - libdfp: Fixes for BID left_justify - libdfp: Makefile.in flags - libdfp: Fix DPD symbol hacks to PLT calls - libdfp: Add BID symbol-hacks to avoid PLT calls - libdfp: base-math symbol hidden_def - libdfp: removing uneeded BID implementation - libdfp: add -shared-libgcc - libdfp: base ABI list for BID encoding - libdfp: Add software expected ULPs - libdfp: implement decode.c for BID encoding - libdfp: Implement sysdeps/soft-dfp/bid/numdigits.h - libdfp: Remove empty decode.c file - libdecnumber: bid-coeffbits optimization - libdfp: test-decode cleanup - libdfp: test_justify cleanup - libdfp: Remove GDB testcase hacks - libdfp: islessd[32|64|128] cleanup - libdfp: islessequald[32|64|128] cleanup - libdfp: isgreaterequald[32|64|128] cleanup - libdfp: isgreaterd32 cleanup - libdfp: islessgreaterd[32|64|128] cleanup - libdecnumber: Fix BID encoding for large coefficients - libdfp: logbd[32|64|128] cleanup - libdfp: test-numdigits cleanup - libdfp: Add test-setexp - libdfp: Add more tests for getexp - libdecnumber: Add initial BID support for _Decimal128 - libdfp: quantumd[32|64|128] refactor - libdecnumber: Add initial BID support for _Decimal32 - libdfp: Remove duplicated function call in truncd - libdecnumber: Add initial BID support for _Decimal64 - libdecnumber: Move common debug directive to common header - libdecnumber: Move common definition under DPD - libdfp: Use libdecnumber compare on ilogbd - libdfp: libdecnumber symbol name cleanup - libdfp: decContextSymbols names cleanup - libcecnumber: decNumberSymbols.h name cleanup - libdecnumber: Cleanup symbol names - libdpf: Fix sign compare compiler warning - libdfp: Fix symbol-hacks paths for BID and DPD - libdfp: _get_digits for BID decoding developed - libdfp: Test get digits improved. - libdfp: Initial BID support - libdfp: Fix quantize decimal128 inputs - libdfp: Add islessequal testcase. - libdfp: Add isless testcase. - libdfp: Add isgreaterequal testcase. - libdfp: Add isgreater testcase. - libdfp: Inputs added to the quantized tests. - PowerPC: quantized[32|64|128] refactor. - libdfp: Fix ChangeLog dates - libdfp: Correct expected output for quantize tests - PowerPC: refactor numdigits - libdfp: Rewrite fpclassify to use libdecnumber - libdfp: Add local PLT calls check - libdfp: Fix missing __dpd_trunctdsd2 software DFP - libdfp: Add check-abi test - libdfp: Move soft-dfp code to soft-dfp folder - libdfp: Move common code to generic place - PowerPC: Optimized copysign implementation - libdfp: Add copysign test using the new framework - libdfp: Fix powerpc/fpu ULPs - libdfp: Fix powerpc/dfpu ULPs - libdfp: Add dfpu in front of fpu in sysdeps selection - PowerPC: Optimized fabsd[32|64|128] - libdfp: Add fabs test using new framework - libdfp: Add log1p test using the new framework - libdfp: Add log10 test using the new framework - libdfp: Adapt exp to new test framework - libdfp: Add support to ULPs file in new test framework - libdfp: Remove compiler warning when including scaffold.c - libdfp: Remove unused constant from test-numdigit - libdfp: Fix test-getexp constant - libdfp: Format test-decode indentation - libdfp: Name change for test-round.c - libdfp: Remove unnecessary tests - libdfp: Adapt quantize test to new framework - libdfp: Adapt fpclassify to new test framework - libdpf: Adapt rounding tests to new framework - libdfp: Adapt quantum test to new test framework - libdfp: Adapt ilogb/llogb tests to new framework - libdfp: Adapt issignaling test to new test framework - libdfp: Adapt isnan/isinf/isfinite to new test framework - libdfp: Adapt llquantexp test to new framework - libdfp: Adapt logb test to new framework - libdfp: Adapt samequantum test to new framework - libdfp: New framework for tests - libdfp: Add HUGE_VAL_D32 and HUGE_VAL_D128 - libdfp: Add entry point for shared-libraries - libdfp: Add fpclassifyd[32|64|128] prototypes - libdfp: Add FP_LLOGB0 and FP_LLOGBNAN return codes - libdfp: Fix logbd[32|64]128] return for negative infinity - libdpf: Remove legacy Makefile support for GLIBC - libdfp: Fix NOT_in_libdfp for cxx tests - PowerPC: Fix issignaling issue with zero values - PowerPC: POWER8 build fixes - PowerPC: Fix powerpc32 build - libdfp: Define DEC_NAN as __builtin_nan - libdfp: Fix configure with compiler plus flags - libdfp: Regenerate using autoconf 2.68 - libdfp: Fix PLT issues with Decima convertion symbols - libdfp: Define __decNumber functions as hidden_proto - PowerPC: More PLT calls fixes - libdfp: More PLT calls fixes - libdfp: Add hidden_def for signbitd - libdfp: Add hidden_def for fabsd[32|64|128] ## 1.0.9-1 - 2014-02-25 - libdfp: Add fpclassifyd[32|64|128] prototypes - PowerPC: Fix issignaling issue with zero values - PowerPC: POWER8 build fixes - libdfp: Fix configure with compiler plus flags ## 1.0.9 - 2014-02-12 - libdfp: Change project maintainer - libdfp: Add NEWS file - libdfp: Fix PLT calls for FP classify functions. - PowerPC: Remove ununsed files - libdfp: Add hidden definitions to FP classify functions - PowerPC: Fix samequantum software implementation - PowerPC: Optimized samequantum implementation - libdfp: Fix test-logb - PowerPC: optimized llquantexpd[32|64|128] - libdfp: Add llquantexpd[32|64|128] software implementation - PowerPC: optimized quantumd[32|64|128] implementation - libdfp: Add quantumd[32|64|128] software implementation - libdfp: Endian fix for floating point classify - PowerPC: optimized roundevend[32|64|128] - libdfp: Add roundevend[32|64|128] implementation - PowerPC: optimized roundd[32|64|128] - PowerPC: optimized nearbyintd[32|64|128] - PowerPC: Optimized floord[32|64|128] - PowerPC: Optimized truncd[32|64|128] - PowerPC: Optimized ceild[32|64|128] - libdfp: Add rounding function tests - libdfp: Cleanup _IEEE_LIBDFP and _IEEE_LIBM - libdfp: Add llogbd[32|64|128] implementation - libdfp: isfinite refactor - libdfp: isinfd refactor - libdfp: Refactor generic isnand - libdfp: Fix test-bfp-convertion tests - libdfp: Sync libdecnumber with GCC - libdfp: New macro named issignaling to check for a signaling NaN (sNaN). - libdfp: Add generic macros and functions - libdfp: Update version for 1.0.9 release. - PowerPC: Fix left_justify for Little Endian - PowerPC: Fix endianess issue with setexp - libdfp: Fix LE issues with decimal to decNumber - libdfp: Add more coverage for logd tests - libdfp: Optimize the host to/from ieee functions - libdfp: Fix compile warnings in tests - PowerPC: fix the numdigits for LE - PowerPC: fix endian issue when reading rounding mode - libdfp: Add support to POWER8 - libdfp: Fix test-bfp-conversions segfault due recursive calls - libdfp: Remove compiler warnings by unused variables - libdfp: Fix issues with getexp when exp is DECIMAL_BIAS - libdfp: Fixes for isfinited - libdfp: Fixes for isinfd - libdfp: Fix endian macro check - PowerPC: initial support for LE build - Miscellaneous changes - Makefile.in (distclean): Add as rule to remove files generated by configure. - Miscellaneous changes - README.user: Added new section on compliance With ISO/IEC TR 24732, the C++ DFP Draft Technical Report, including instructions on how to use (ios::fixed | ios::scientific) as ios\_base::fmtflags in order to get fully encoded precision in output string representation. - Miscellaneous changes - tests/test-printf.c: Add missing 'D' to a/A conv tests. - tests/scaffold.c: Correct comments for \_OSC and added a/A support. - tests/test-ostream.cpp: Modified expectations such that a/A ignores precision and always uses the num of significant digits in the mantissa when output. - tests/test-ostream-g-spec.cpp: Removed unnecessary define that used to be used to get g/G support. - dfp/decimal/decimal (FIND\_DEC\_MANT\_DIG): Remove ".*" from default string string. (LIBDFP\_META): Make g/G spec default. Enable a/A spec by checking flags for ios::fixed | ios::scientific. Condense uppercase/lowercase check. Don't call printf with a precision specifier if a/A is the desires spec conv. - Miscellaneous changes - tests/test-negate.c: New testcase. - Makefile.in (libdfp\_c\_tests): Add test-negate. - Miscellaneous changes - Makefile.in (test-printf.os, test-strtod.os): New rules to depend on printf\_dfp.os and strtod[32|64|128].os respectively. - strtod128.c (\_\_DEC\_MANT\_DIG\_\_, \_\_DEC\_MAX\_EXP\_\_, \_\_DEC\_MIN\_EXP\_\_): Define to \_Decimal128 values. - tests/test-strtod.c: Added tests near \_\_DEC*\_MAX\_EXP\_\_ and \_\_DEC*\_MIN\_EXP\_\_. - strtod64.c (\_\_DEC\_MANT\_DIG\_\_, \_\_DEC\_MAX\_EXP\_\_, \_\_DEC\_MIN\_EXP\_\_): Define to \_Decimal64 values. - sysdeps/powerpc/dfpu/numdigits.h (left\_justify): Fix VSX case by replacing xxlxor with xxlor insn. (getexp): Replace stfwix with stfd to prevent erroneous sign extend. - sysdeps/soft-dfp/dpd/numdigits.h (getexp): Make return value congruent with hardware-dfp for NaN. - strtod32.c (\_\_DEC\_MANT\_DIG\_\_, \_\_DEC\_MAX\_EXP\_\_, \_\_DEC\_MIN\_EXP\_\_): Define to \_Decimal32 values. (FUNCTION\_L\_INTERNAL): Add left\_justify call if proposed exponent is sufficiently close to \_\_DEC*\_MAX\_EXP\_\_. Add zero return if proposed exponent is smaller than \_\_DEC*\_MIN\_EXP\_\_. - Miscellaneous changes - Makefile.in (libdfp\_c\_tests): Added test-getexp. - tests/test-getexp.c: New test. - tests/test-decode.c (d64types): Added test for \_\_DEC64\_MAX\_\_ and \_\_DEC64\_MIN\_\_. - sysdeps/powerpc/dfpu/numdigits.h (getexpd[32|64|128]): Fixed in order to prevent erroneous sign extension due to using stfiwx. - Miscellaneous changes - sysdeps/powerpc/dfpu/numdigits.h: Cleaned up inline asm DEC\_TYPE declarations. Removed redundant macros. Merged macros under similar guards. - Miscellaneous changes - sysdeps/powerpc/dfpu/numdigits.h (numdigits*): Fix inline asm to place result of drrnd[q] into DEC\_TYPE instead of double. Update copyright years to range. - tests/test-decode.c: Update copyright years to range. - tests/test-param.c: Likewise. - tests/test-printf.c: Likewise. - tests/test-numdigits.c: Likewise. - tests/test-istream.cpp: Likewise. - tests/test-strtod.c: Likewise. - sysdeps/dpd/dpd-private.c: Likewise. - printf\_dfp.c: Fix erroneous test for \_Decimal64. Update copyright years to range. - Miscellaneous changes - Makefile.in (check): Add printf\_dfp.o dependency to check in order to have make check automatically rebuild libdfp is printf\_dfp.c has changed. - tests/test-decode.c: Add tests for decoding numbers with high exponents near \_\_DEC*\_MAX\_EXP\_\_. - tests/test-param.c (param\_test): Remove unnecessary assingments. - tests/test-printf.c: Add tests for \_\_DEC64\_MAX\_\_. - tests/test-numdigits.c: Add tests for \_\_DEC64\_MAX\_\_ and numbers approaching \_\_DEC*\_MAX\_EXP\_\_. - tests/test-GCC-PR52140.c (main): Remove unnecessary assignments. - tests/test-ostream.cpp: Formatting. - tests/debug-test.sh: Add ./ as a path prefix. - sysdeps/powerpc/dfpu/numdigits.h (numdigitsd*): Fix for numbers with exponent approaching \_\_DEC*\_MAX\_EXP\_\_ by biasing the exponent toward zero. - sysdeps/dpd/dpd-private.c: Formatting. - TODO: New items. - printf\_dfp.c (\_\_printf\_dfp): Fix for g/G specifier that converst to f/F form. Fix for a/A when the user supplied precision is 0, i.e. %.Ha. - Miscellaneous changes - Makefile.in (libdfp\_c\_tests): Add test-GCC-PR52140.c. - tests/test-istream.cpp: Comment out NaN tests. Two nans can't be compared. - tests/test-GCC-PR52140.c: New testcase for ICE. - TODO: Add item to upgrade libdecnumber version. - Miscellaneous changes - Makefile.in (install-readme): New target. (install): Consolidated by making install-headers and install-readme as dependent rules. - README.maintainer: Updated info on Versioning. - README.user: Added discussion on \_\_STDC\_DEC\_FP\_\_ - README.developer: Updated info on Versioning. - Miscellaneous changes - sysdeps/powerpc/powerpc32/power6x/Implies: Points to power6. - sysdeps/powerpc/powerpc32/power6x/fpu/Implies: Points to power6. - sysdeps/powerpc/powerpc64/power6x/Implies: Points to power6. - sysdeps/powerpc/powerpc64/power6x/fpu/Implies: Points to power6. - Miscellaneous changes - Makefile.in (libdfp\_cxx\_tests): Add test-ostream-g-spec test. - tests/test-ostream-g-spec.cpp: New file to test decimal/decimal's \_LIBDFP\_G\_CONV\_SPEC guard. - tests/test-printf.c: Add newly discovered %DDg failures. - tests/scaffold.c (\_OSC\_P): Add comment regarding \_LIBDFP\_G\_CONV\_SPEC. - tests/test-istream.cpp: Removed unused variable. - README.user: Update with information about NOT using #include . - dfp/float.h: Remove commented out decimal class predeclares. - dfp/decimal/decimal: Move #include to before #include\_next to prevent missing \_Decimal[32|64|128] definition errors. - Miscellaneous changes - Makefile.in (libdfp\_cxx\_tests): Added test-istream. - tests/scaffold.c (\_ISC \_ISC\_P): Added new istream compare macros conditional on #ifdef \_\_cplusplus. - tests/test-istream.cpp: New test for operator>>. - tests/test-strtod.c: Added a new value to test. - dfp/float.h: Correct \_Decimal[32|64|128] declarations. - dfp/decimal/decimal: Added operator>> support for decimal[32|64|128] C++ decimal floating point types. - README.user: Updated information on operator<< and operator>> support. - Miscellaneous changes - tests/test-log10d.c: Added missing #include "decode.h". - tests/scaffold.c (\_OSC \_OSC\_P): Added new ostream compare macros conditional on #ifdef \_\_cpluspluc. - tests/test-ostream.cpp: Added scaffold.c based tests. - Miscellaneous changes - dfp/decimal/decimal(operator<< decimal128): Removed now spurious call to ostream\_d128() (which has been removed from libdfp) in the decimal128 operator<< overload. Updated comments clarifying use of 'a/A' over 'g/G' for the default. - Miscellaneous changes - dfp/decimal/decimal: Added back in erroneously removed #include . - Miscellaneous changes - dfp/decimal/decimal: Removed ostreamd32, ostreamd64, and ostreamd128 prototypes. - Miscellaneous changes - decode.h: Added \_\_BEGIN\_DECLS and \_\_END\_DECLS around decoded[32|64|128] prototypes in order to allow them to be used in C++ compatibility testcases without warnings. - scaffold.c: Removed extra #include "decode.h". - test-strtod.c: Likewise. - Miscellaneous changes - Makefile.in: Copied contents of $(system\_header\_dirs) into $(header\_dirs) in order to have -I added automatically to the compiler invocation. This makes sure that dfp/decimal/decimal always comes before the system include/decimal/decimal header. - Miscellaneous changes - README.user: Add instructions for using to pick up operator<< and operator>> overloads for decimal[32|64|128] types. - README.developer: Removed necessity of including -isystem in CPPFLAGS in order to pick up decimal headers. - dfp/decimal: Created dfp/decimal/ header include directory. - dfp/decimal.tmp: Moved decimal.tmp to decimal/decimal. - dfp/decimal/decimal: Moved decimal.tmp to decimal/decimal. - Miscellaneous changes - Makefile.in: Install dfp/decimal/ directory. Add dfp/decimal/decimal path. - tests/test-ostream.cpp: Change to - TODO: Added directive to test decimal/ directory installs. - dfp/decimal: Moved file "decimal" to "decimal.tmp". - dfp/decimal.tmp: Moved file "decimal" to "decimal.tmp". - Miscellaneous changes - configure: Regenerated. - Makefile.in: (@CXX@, @LLD@, @OBDJUMP@, @GDB@, @CXXFLAGS@, and @CPPFLAGS@): New imports. (header\_dirs): Move dfp/ to $(system\_header\_dirs). (CXX\_DEFINES CXX\_WARNS): New variables. (.c.o): Add $(CPPFLAGS). Add -I$(system\_header\_dirs). (.c.os): Likewise (.S.o): Add -I$(system\_headers). (.cpp.os) Likewise. (GLIBC\_LIBS): Remove unnecessary libpthread.so linkage. (libdfp\_cxx\_tests): New variable. (libdfp\_tests): Renamed to (libdfp\_c\_tests) and replaced with $(libdfp\_c\_tests) $(libdp\_cxx\_tests). Added new rule for $(libdfp\_cxx\_tests).os dependencies on float.h. Added new rule for $(libdfp\_tests) to rely on tests/scaffold.c. Added new rule to link $(libdfp\_cxx\_tests) to their .os files. (.SUFFIXES): Added .cpp. - ieee754r/lgammad32.c: Changed to . - tests/test-printf.c: Discovered a bug in %.Ha. If there is a '.' with no precision specifier it prints a bogus value. This adds this failure to the test suite. - tests/test-ostream.cpp: New test to test operator<< header file additions in dfp/decimal. - configure.ac: Added AC\_PATH\_PROG for OBJDUMP, LDD, GDB. Added AC\_SUBST for CXXFLAGS, CPPFLAGS. - README.user: Added instructions for printf "a,A" Conversion Specifier usage. - README.developer: Added instructions for specifying PATH to pick up toolchain default programs. Added instructions for LDD, GDB, OBJDUMP, CXX, CXXFLAGS, and CPPLAGS. - Versions.def - Makefile.gdb: Use configure exported 'objdump' via $(OBJDUMP). Use configure exported 'ldd' via $(LDD). Use configure exported 'gdb' via $(GDB). - dfp/stdlib.h: Comment update. - dfp/float.h: New file adds \_Decimal[32|64|128] types #ifdef \_\_cplusplus and if they aren't added by the compiler. At the time of this writing the compiler hasn't added them to float.h yet. - dfp/decimal: New file adds operator<< for decimal[32|64|128] C++ types. This use C++ template metaprogramming to create functions that call printf. - printf\_dfp.c: Comment change for a/A spec char. - TODO: New item. - Miscellaneous changes - Makefile.in (libdfp\_tests): Add test-expd, testing expd[64|128]\(-1.0\) which was previously failing. (libdfp\_tests.so): New dummy rule to add $(top\_srcdir)/tests/scaffold.c as a dependency so that scaffold.c changes result in rebuilding the libdfp\_test .so files on make check. - tests/test-expd.c: New file testing expd[32|64|128]. - tests/scaffold.c (\_AVC \_AVC\_P): New macros which do a value compare but allow a +/- variation. - README.user: Added instructions for C++ types compatibility with ISO-C DFP types. - sysdeps/powerpc/dfpu/expd64.c: Existing code only accounts for positive 'n' in e^n. This fix allows for e^-n, which is just 1/(e^n). - Miscellaneous changes - README.user: Updated with instructions for using #include . - sysdeps/soft-dfp/dpd/Versions: Moved \_\_dpd\_extend* and \_\_dpd\_trunc* symbol definitions from here to... - sysdeps/dpd/Versions: here, since these are needed for all versions of libdfp, not just the soft-dfp version. - Miscellaneous changes - Makefile.in: Replace erroneous usage of $? with $^. Fix libdfp\_tests based rules to correct prerequisite usage so that a complete rebuild isn't required when only a few of the test case dependencies change. - Makefile.gdb: Correct prerequisite usage to not require a complete rebuild when only a few of the test case dependencies change. - Miscellaneous changes - dfp/stdlib.h: Added #include to correct include order problem. - dfp/wchar.h: Likewise. - tests/test-stdlib.c: New test to verify inclusion. - tests/test-wchar.c: New test to verify inclusion. - Makefile.in (libdfp\_tests): Added test-stdlib and test-wchar. - Miscellaneous changes - configure: Regenerated. - configure.ac: Incremented the version number to 1.0.8. - Versions.def: Incremented the version number to 1.0.8. - tests/test-bfp-conversions.c: Added tests for extendsddf extendsdtf extenddfdd extendddtf extenddftd and extendtftd. - Miscellaneous changes - base-math/Makefile: Moved 'classify' from sysdeps/soft-dfp/Makefile. - base-math/classify.c: Moved from sysdeps/soft-dfp/ because it's required for the power6 build as well. - base-math/extendsftd.c: Likewise. - base-math/extendsdtf.c: Likewise. - base-math/extenddfdd.c: Likewise. - base-math/trunctdsf.c: Likewise. - base-math/trunctfsd.c: Likewise. - base-math/extendddtf.c: Likewise. - base-math/extenddftd.c: Likewise. - base-math/extendsfsd.c: Likewise. - base-math/extendtftd.c: Likewise. - base-math/truncdddf.c: Likewise. - base-math/trunctfdd.c: Likewise. - base-math/trunctddf.c: Likewise. - base-math/truncsdsf.c: Likewise. - base-math/trunctdtf.c: Likewise. - base-math/extendsddf.c: Likewise. - base-math/extendsfdd.c: Likewise. - base-math/truncddsf.c: Likewise. - base-math/truncdfsd.c: Likewise. - tests/scaffold.c (\_VC\_P): Updated spacing in "Expected" and "Result" output. - tests/test-bfp-conversions.c: Added float -> \_Decimal128 tests. - sysdeps/soft-dfp/Makefile: Moved 'classify' to base-math/Makefile. - sysdeps/soft-dfp/classify.c: Moved to base-math/ because it's required for the power6 build as well. - sysdeps/soft-dfp/extendsftd.c: Likewise. - sysdeps/soft-dfp/extendsdtf.c: Likewise. - sysdeps/soft-dfp/extenddfdd.c: Likewise. - sysdeps/soft-dfp/trunctfsd.c: Likewise. - sysdeps/soft-dfp/trunctdsf.c: Likewise. - sysdeps/soft-dfp/extenddftd.c: Likewise. - sysdeps/soft-dfp/extendddtf.c: Likewise. - sysdeps/soft-dfp/extendsfsd.c: Likewise. - sysdeps/soft-dfp/extendtftd.c: Likewise. - sysdeps/soft-dfp/truncdddf.c: Likewise. - sysdeps/soft-dfp/trunctfdd.c: Likewise. - sysdeps/soft-dfp/trunctddf.c: Likewise. - sysdeps/soft-dfp/truncsdsf.c: Likewise. - sysdeps/soft-dfp/trunctdtf.c: Likewise. - sysdeps/soft-dfp/extendsfdd.c: Likewise. - sysdeps/soft-dfp/extendsddf.c: Likewise. - sysdeps/soft-dfp/truncddsf.c: Likewise. - sysdeps/soft-dfp/truncdfsd.c: Likewise. - Miscellaneous changes - Makefile.in (libdfp\_tests): Added test-bfp-conversions. - base-math/Makefile (libdfp\_files): Moved extendsfsd extendsddf extendsdtf extendsfdd extenddfdd extendddtf extendsftd extenddftd extendtftd truncsdsf truncdfsd trunctfsd truncddsf truncdddf trunctfdd trunctdsf trunctddf trunctdtf from sysdeps/soft-dfp/Makefile since they're required in all builds. - tests/test-bfp-conversions.c: New file to test bfp -> dfp and dfp -> bfp conversions. - include/convert.h: Moved from sysdeps/soft-dfp/ in preparation for moving extend and trunc bfp->dfp and dfp->bfp conversion functions. - sysdeps/soft-dfp/Makefile (libdfp\_files): Removed extendsfsd extendsddf extendsdtf extendsfdd extenddfdd extendddtf extendsftd extenddftd extendtftd truncsdsf truncdfsd trunctfsd truncddsf truncdddf trunctfdd trunctdsf trunctddf trunctdtf and moved to base-math/Makefile since they're required in all builds. - sysdeps/soft-dfp/extendsfsd.c: Replaced magic number '24' with \_\_FLT\_MANT\_DIG\_\_. - sysdeps/soft-dfp/convert.h: Moved to include/convert.h. - sysdeps/soft-dfp/truncdfsd.c: Replaced magic number '53' with \_\_DBL\_MANT\_DIG\_\_. - Miscellaneous changes - tests/gdb\_start\_address.py: New file which provides the start\_address() python convenience function to GDB. - Makefile.gdb (*.gdb): Break on \_dl\_start\_user for powerpc64 and \_dl\_main\_dispatch on powerpc32. Call new python convenience function start\_address() to get the start address of libc and libdfp for the scripts. - Miscellaneous changes - sysdeps/powerpc/powerpc32/power6/fpu/Makefile (ASFLAGS): Remove HAVE\_ASM\_PPC\_REL16 as it is no longer needed since we no longer support building the power[6|7] optimized libdfp with -mbss-plt. - sysdeps/powerpc/powerpc32/power6/fpu/floatunsdisd.S: Remove HAVE\_ASM\_PPC\_REL16 guard and remove the bss-plt form of GOT access. We no longer support building the power[6|7] optimized libdfp with -mbss-plt. - sysdeps/powerpc/powerpc32/power6/fpu/fixunssddi.S: Likewise. - sysdeps/powerpc/powerpc32/power6/fpu/fixunsdddi.S: Likewise. - sysdeps/powerpc/powerpc32/power6/fpu/fixunstddi.S: Likewise. - sysdeps/powerpc/powerpc32/power6/fpu/floatunsdidd.S: Likewise. - sysdeps/powerpc/powerpc32/power6/fpu/floatunsditd.S: Likewise. - Miscellaneous changes - configure: Regenerated. - Miscellaneous changes - Makefile.in: Added $(CFLAGS) to .S.o: rules. - configure.ac: Added -DSHARED to picflag in order to enforce PIC when compiling hand rolled asm functions. - sysdeps/powerpc/powerpc32/power6/fpu/Makefile: Added -DHAVE\_ASM\_PPC\_REL16 to ASFLAGS in order to enforce secure-plt style GOT access. - Miscellaneous changes - sysdeps/s390/dfpu/fe\_decround.c (\_\_init\_printf\_dfp\_getround): Added function definition for callback and added callback pointer. The printf\_dfp () function was graciously skipping over the rounding mode modifiers due to this missing definition. - README.developer: Updated compatibility matrix to put x86 and x86\_64 under TODO. Changed all instances of at05 to at4.0. - Miscellaneous changes - fe\_decround.c (\_\_init\_printf\_dfp\_getround): Remove unnecessary prototype and declare constructor 'static. Remove unnecessary hidden\_def(\_\_init\_printf\_dfp\_getround). - sysdeps/powerpc/dfpu/fe\_decround.c (\_\_init\_printf\_dfp\_getround): Remove unnecessary prototype and declare constructor 'static. Remove unnecessary hidden\_def(\_\_init\_printf\_dfp\_getround). - sysdeps/s390/dfpu/fe\_decround.c: Added - printf\_dfp.c: Add hidden\_def (\_\_register\_printf\_dfp). - include/libdfp-symbols.h (hidden\_def): Fix macro definition. - Miscellaneous changes - printf\_dfp.c (\_\_printf\_dfp): Finished cleaning up 'decimal'. - sysdeps/powerpc/sysdep.h: Updated copyright year. - Miscellaneous changes - README.maintainer: Updated. - sysdeps/powerpc/powerpc32/power6/fpu/fixunstdsi.S (END): Fix erroneous \_\_dpd\_fixunstssi to \_\_dpd\_fixunstdsi. - sysdeps/powerpc/powerpc32/sysdep.h (PROF): Removed PROF macros. (CALL\_MCOUNT): Removed CALL\_MCOUNT. (ENTRY): Removed CALL\_MCOUNT and C\_SYMBOL\_NAME from macro body. Replaced C\_LABEL with LABEL. (C\_TEXT): Removed macro as unnecessary. - sysdeps/powerpc/sysdep.h (C\_LABEL): Removed macro. - include/libdfp-symbols.h (LABEL): New macro which replaces C\_LABEL by removing preceding underscore. - printf\_dfp.c (\_\_dfp\_ais): Return -1 if info->user doesn't match any of the DFP mod\_[H|D|DD] identifiers. (\_\_printf\_dfp): Started cleaning up 'decimal' per Jakub Jelinek's suggestion. Fixed bug found by Jakub Jelinek where random garbage is printed if the modifier is not H/D/DD. The default was dropping into the \_Decimal32 case when it should have been returning -2. - Miscellaneous changes - README.maintainer: Added todo for "Commit Access" - Miscellaneous changes - README.maintainer: New file. - README.developer: Added several TODO items. - TODO: Added an item. - CONTRIBUTORS: Moved DCO from here to... - CONTRIBUTING: here. 2011-1-21 Ryan S. Arnold - configure: Regenerated. - configure.ac: Incremented the version number to 1.0.7. - Versions.def: Incremented the version number to 1.0.7. 2011-1-21 Andreas Krebbel - sysdeps/s390/dfpu/numdigits.h (setexp): Bias the exponent and return '1' for z zero mantissa, which is what is done for soft-dfp. - sysdeps/s390/dfpu/fe\_decround.c (\_\_fe\_dec\_setround): Enable extended rounding modes (5,6 and 7) which are not covered by the standard. 2011-1-18 Ryan S. Arnold - configure: Regenerated. - tests/test-isfinite.c: Changed expectation on isfinite() for negative numbers on Power5 to '1'. Power6 (hardware isfinite) returns '-1' on isfinite. The spec simply says that non-zero means finite. - tests/test-logd.c: Removed half completed 'quantize compare' functionality which was throwing a false error. - tests/test-decode.c: Removed dangling printf that wasn't useful. - tests/test-printf.c: Added a \_Decimal128 test for printing (1.0DL / 1.000000e-123DL) which has a sufficiently negative exponent that it forced the 'index' (rounding digit) position to be negative and caused a segv when \_\_printf\_dfp() tried to erroneously round the result on s390. We got lucky up until now on PowerPC due to the kernel reserving space on the top of the stack. - configure.ac: Incremented the version number to 1.0.6. - Versions.def: Incremented the version number to 1.0.6. 2011-1-18 Andreas Krebbel - printf\_dfp.c (\_\_printf\_dfp): Fixed segv where, if the exponent is sufficiently negative it pushes 'index' (the digit used to round values to the left) into a negative number. In that case we simply don't need to round at all. 2011-1-18 Ryan S. Arnold - tests/test-strtod.c: Adjusted assumptions of tests from truncation on too long of an input to rounding to nearest. 2011-1-18 Andreas Krebbel - strtod32.c (FUNCTION\_L\_INTERNAL): Check an extra digit on the input to see if we need to round rather than truncate. 2011-1-17 Ryan S. Arnold - configure: Regenerated. - tests/test-strtod.c: Removed unnecessary test cases. - configure.ac: Incremented the version number to 1.0.5. - Versions.def: Incremented the version number to 1.0.5. - Miscellaneous changes - Makefile.in (libdfp\_tests): Added test-log10d. - tests/test-decode.c: Added decode of log10d128(0.0000000011DL) to verify that it prints correctly in declets. - tests/test-logd.c (main): Added pbuf[CHAR\_MAX] so that tests work properly. - tests/test-log10d.c: New test-case which verifies that printf now works properly for the result of log10d128(0.0000000011DL). - sysdeps/dpd/dpd-private.c: Fixed dpd\_to\_char[0x3f4] from "974" to "774" since the previous was a typo which was making values print incorrectly. - Miscellaneous changes - configure: Regenerated. - configure.ac: Removed addition of -fPIC to CFLAGS and instead export it to Makefile.in who is now responsible for adding it to CFLAGS. Set (picflags): Default to -fpic since the GOT for libdfp should be small enough that -fPIC isn't needed. - Makefile.in: (BACKEND\_CFLAGS): New variable which passes -mcpu=foo and -fpic to the backend sub make invocation in -DEFS to get around the fact that libdecnumber/Makefile.in won't allow overridden CFLAGS. - sysdeps/dpd/dpd-private.c: Fixed 'used when uninitialized' warning by switching "else if" case to "else" for Decimal128. - Miscellaneous changes - strtod32.c: Fix precedence of arithmetic operation. - tests/test-strtod.c: Add new testcase and fix wrong tests. - Miscellaneous changes - configure: Regenerated. - configure.ac: Incremented the version number to 1.0.4 - README.user: Marked empty sections with (TODO). - Versions.def: Incremented the version number to 1.0.4 - Miscellaneous changes - README.user: Added clarification of how to include dfp/stdlib.h, dfp/fenv.h and dfp/wchar.h. - Miscellaneous changes - README.user: Added clarification of how to include dfp/math.h. - Miscellaneous changes - dfp/math.h: Move #include\_next so that if the compiler invocation has -I//include/dfp/ but doesn't define \_\_STDC\_WANT\_DEC\_FP\_\_ that they still get the system math.h. - Miscellaneous changes - CONTRIBUTORS: Added Luis Machado. Added DCO requirements. - Miscellaneous changes - strtod32.c (FUNCTION\_L\_INTERNAL): Fix comparison operator. - Miscellaneous changes - sysdeps/s390/dfpu/numdigits.h: Remove include guards. - sysdeps/powerpc/dfpu/numdigits.h: Likewise. - sysdeps/soft-dfp/dpd/numdigits.h: Likewise. - Miscellaneous changes - tests/test-printf.c (printf\_d128s): Added 0.9999999999DL which reported 0.100000 rather than 1.000000 and was fixed by Andreas' patch from 2010-10-04. - Miscellaneous changes - printf\_dfp.c (\_\_printf\_dfp): Fix up nd when rounding overflows beyond first digit. - Miscellaneous changes - sysdeps/soft-dfp/floatsisd.c: Don't generate additional decimal digit. - Miscellaneous changes - README.developer: Documentation update. - TODO: Mark some items as [DONE]. - Miscellaneous changes - init\_dfp.c: Changed #include to #include . - Miscellaneous changes - tests/test-amort.c: Added license and copyright. - tests/test-printf.c: Updated copyright year. - tests/test-strtod.c: Added license and copyright. Corrected incorrect expected values. - strtod32.c: Fixed several conversion bugs. - Miscellaneous changes - Makefile.in: Removed test-left\_justify from execution since it is a known failure case for non-power6 systems. No worries since left\_justify isn't used right now. - tests/test-amort.c: Removed spurious #include . - tests/test-get\_digits.c: Likewise. - tests/test-decode.c: Likewise. - tests/test-quantize.c: Likewise. - tests/test-printf.c: Likewise. - tests/test-fpclassify.c: Likewise. - tests/test-numdigits.c: Likewise. - tests/test-left\_justify.c: Likewise. - tests/test-isinf.c: Likewise. - tests/test-isnan.c: Likewise. - tests/test-isfinite.c: Likewise. - tests/test-strtod.c: Likewise. Also changed one value compare test to a decode test since the visual representation was 0.0. - README.user: Added further user notes. - dfp/dfp.h: Moved this to ... - include/dfp.h: here since the user no longer has to call the printf\_dfp registration hooks, and thus doens't need the prototype. configure: Regenerated. configure.ac: Added AC\_SUBST(mzarch) back. We shouldn't be editing CFLAGS. Makefile.in: Pass $(mzarch) along with CFLAGS if it is defined. - Miscellaneous changes - configure: Regenerated. - Makefile.in: Added special sed script which changes libdecnumber/Makefile:CFLAGS = foo into CFLAGS ?= foo. This allows libdfp/Makefile's sub make invocation of libdecnumber/Makefile to accept the updated CFLAGS. This was necessary to allow configure to update CFLAGS with -mzarch for s390 z9-ec and z10. GCC should fix this in their version of libdecnumber. - configure.ac: -mzarch added to CFLAGS when s390 system is z9-ec or z10. - README.developer: Added indication that configure.ac sets -mzarch in CFLAGS when appropriate. - Miscellaneous changes - Makefile.gdb (libdfp\_tests.gdb): Add LD\_LIBRARY\_PATH=./:$LD\_LIBRARY\_PATH to ldd invocations to make sure it reports ./libdfp.so.1 as a dependency and not the system or toolchain libdfp.so.1. - Miscellaneous changes - ieee754r/Versions: Added \_\_fabsd* and \_\_fpclassifyd* under the correct libdfp version number 1.0.3. - Miscellaneous changes - dfp/math.h: Restructure to cleanup presentation. - Miscellaneous changes - ieee754r/Versions: Moved some of the \_\_is* functions under LIBDFP\_1.0.2 and LIBDFP\_1.0.3. Removed unnecessary \_\_is* functions from export that don't have polymorphic versions in math.h - dfp/math.h: Removed accidental undef of isunordered. This was never implemented as a polymorphic function because it doesn't need to be (per the spec). Removed redundant polymoprhic isnan(). - Versions.def: Added Versions LIBDFP\_1.0.2 and LIBDFP\_1.0.3 for Libdfp. - Miscellaneous changes - configure: Regenerated. - configure.ac: Apparently AC\_CANONICAL\_SYSTEM is only for compilers. I removed it, and support for --target. Now you must use --build only. - README.developer: Removed directions for using --target. - Miscellaneous changes - sysdeps/powerpc/dfpu/fe\_decround.c (stdio.h): Removed unnecessary include. - Miscellaneous changes - sysdeps/powerpc/dfpu/fe\_decround.c (\_\_fe\_dec\_getround): The structure which defined the DRN was to small and the compiler started generating code that wasn't properly extracting the DRN field from the structure holding the FPSCR value. This is fixed. - tests/test-round.c: Testcase to prove fe\_dec\_getround() and fe\_dec\_setround(). - Makefile.in (libdfp\_tests): Added test-round. - Miscellaneous changes - configure: Regenerated. - config.log: Removed as unnecessary. - configure.ac: --target now works in lieu of --build. --host is no longer necessary. - README.developer: Removed directive to use --host and replaced with a diective to use --target. - Miscellaneous changes - configure: Regenerated file. - Makefile.in: Removed last comments dealing with -mzarch. - configure.ac: Removed last fragments dealing with -mzarch. - Miscellaneous changes - ieee754r/isinfd32.c: Removed unnecessary static char buffer used for testing. - Miscellaneous changes - ieee754r/isinfd32.c: Removed test-code that shouldn't have been checked in. - Miscellaneous changes - ieee754r/isinfd32.c (isinf): Changed Infinity check such that DEC\_NAN doesn't pass as inf. There was an incorrect mask check which was true for DEC\_NAN as well as Inf. - tests/test-isfinite.c: Added Conditional expectations for s390 for isfinite return values from negative number inputs. - Miscellaneous changes - tests/test-logd.c: Removed unnecessary comments. - tests/test-fpclassify.c: Removed unnecessary comments. - configure.ac: Removed unnecessary comments. - printf\_dfp.c: Removed unnecessary comments. - Miscellaneous changes - Makefile.in: Removed commented out code. - tests/test-logd.c: Corrected expected values for a \_Decimal64 NAN declet series. - tests/test-fpclassify.c: Added cases for + and - \_\_DEC[32|64|128]\_SUBNORMAL\_MIN\_\_. - tests/scaffold.c: Modified spacing in macro output for 'Success'. - tests/test-isfinite.c: Corrected expected values for negative numbers to return -1. Corrected expected value for DEC\_NAN to '0'. - tests/test-strtod.c: Cleaned up. Still failing. - sysdeps/powerpc/dfpu/fpclassifyd32.c (fpclassifyd32): Since \_Decimal32 is promoted to \_Decimal64 and \_\_DEC32\_SUBNORMAL\_MIN\_\_ falls within the bounds of \_Decimal64 a special case to range check for \_Decimal32 as required. - sysdeps/powerpc/dfpu/powd64.c: Whitespace correction. - strtod32.c: Started to cleanup the code. - Miscellaneous changes - Makefile.in: Added test-numdigits, test-get\_digits, and test-left\_justify. - base-math/Makefile: Fixed missing truncd* exports which was exposed by GCC 4.4. - base-math/lttd2.c (lttd3): Renamed lttd3 to lttd2. Typo. - tests/test-get\_digits.c: Added test-cases to show previously failing numdigits for soft-dfp when coefficient was zero. It was returning '0' intead of '1', which is what hardware DFP returns. - tests/test-printf.c: Added test-cases to show failing tests. - tests/test-fpclassify.c: (printf\_d32s): Changed DENORMAL to SUBNORMAL in constant usage. GCC changed usage. - tests/test-numdigits.c: New test. - tests/scaffold.c: Updated output formatting of macros to make output clearer (columns and test numbering). - tests/test-left\_justify.c: New test. - tests/test-strtod.c: Added test-cases to show failing tests. - sysdeps/powerpc/dfpu/numdigits.h (\_NUMDIGITS\_H): Removed guard to allow multiple #includes with different preconditions. (numdigits): New implementation which avoids clobbers and avoids modifying a parameter. (left\_justify): New implementation which avoids clobbers and avoids modifyinig a parameter. (getexp): New implementation which avoids modifying a parameter. - sysdeps/powerpc/dfpu/fe\_decround.c (\_\_fe\_dec\_setround): Fixed errorneous usage of mtfsfi instruction. Previous usage resulted in the set rounding mode not being permanent. - sysdeps/soft-dfp/dpd/numdigits.h (numdigits): Return '1' if coefficient is zero, which is what hardware DFP does. (\_\_dfp\_declet\_to\_dpd): Moved to ... - sysdeps/dpd/dpd-private.h: ... this file. - sysdeps/dpd/dpd-private.c: Formatting. - printf\_dfp.c (printf\_dfp): Major fixes to correct a variety of printing errors. It should now fully support %f, %e, %g, and %a in the myriad of bizarre combinations. - Miscellaneous changes - Makefile.in: Added test-strtod testcase. - tests/test-logd.c: Cleaned up some comments. - tests/scaffold.c: Cleaned up \_QC\_P macro. It is incomplete at this point. - tests/test-strtod.c: New testcase. - sysdeps/powerpc/dfpu/isfinited128.c: Removed spurious . - sysdeps/powerpc/dfpu/isfinited32.c: Likewise. - sysdeps/powerpc/dfpu/isfinited64.c: Likewise. - sysdeps/powerpc/dfpu/is\_template.h: Added and removed redundant macro definitions. - strtod32.c: Fixed bug when calling newlocale(LC\_ALL\_MASK,NULL,NULL); Changed it to newlocale(LC\_ALL\_MASK, setlocale (LC\_ALL, NULL),NULL); - Miscellaneous changes - tests/test-logd.c: Added more expressive output on failure. - sysdeps/powerpc/dfpu/isfinited128.c: Added #include . - sysdeps/powerpc/dfpu/isfinited32.c: Likewise. - sysdeps/powerpc/dfpu/isfinited64.c: Likewise. - Miscellaneous changes - configure: Regenerated. - ieee754r/Versions: Re-added \_\_isfinited* for backward compatability. - configure.ac: Increment library version to 1.0.3 due to interface changes. - README.user: Whitespace. - ieee754r/isfinited32.c: Use 'isfinite' instead of 'finite'. - sysdeps/powerpc/dfpu/isfinited128.c: Use 'isfinite' instead of - 'finite'. - sysdeps/powerpc/dfpu/isfinited32.c: Use 'isfinite' instead of - 'finite'. - sysdeps/powerpc/dfpu/isfinited64.c: Use 'isfinite' instead of - 'finite'. - dfp/math.h: Whitespace. - Miscellaneous changes - ieee754r/isfinited128.c: Change finite to isfinite. - ieee754r/isfinited32.c: Likewise. - ieee754r/isfinited64.c: Likewise. - Miscellaneous changes - Makefile.in: Added new test cases. Changed finited to isfinited. - ieee754r/scalbnd32.c: Changed usage of finited to isfinited. - ieee754r/scalblnd32.c: Likewise. - ieee754r/cbrtd32.c: Likewise. - ieee754r/expd32.c: Likewise. - ieee754r/nextafterd32.c: Likewise. - ieee754r/exp2d32.c: Likewise. - ieee754r/Makefile: Likewise. - ieee754r/expm1d32.c: Likewise. - ieee754r/hypotd32.c: Likewise. - ieee754r/powd32.c: Likewise. - ieee754r/ldexpd32.c: Likewise. - ieee754r/fdimd32.c: Likewise. - ieee754r/nearbyintd32.c: Likewise. - ieee754r/coshd32.c: Likewise. - ieee754r/lgammad32.c: Likewise. - ieee754r/sinhd32.c: Likewise. - ieee754r/tgammad32.c: Likewise. - ieee754r/nexttowardd32.c: Likewise. - ieee754r/Versions: Likewise. - ieee754r/tand32.c: Likewise. - ieee754r/frexpd32.c: Likewise. - ieee754r/isfinited64.c: Renamed to this from... - ieee754r/finited64.c: ...this. - ieee754r/isfinited32.c: Renamed to this from... - ieee754r/finited32.c: ...this. - ieee754r/isfinited128.c: Renamed to this from... - ieee754r/finited128.c: ...this. - tests/test-logd.c: New test. - tests/test-quantize.c: New test. - tests/test-fpclassify.c: New test. - tests/scaffold.c: Started adding \_QC and QC\_P. - tests/test-isfinite.c: Renamed this... - tests/test-finite.c: ...from this. - sysdeps/powerpc/dfpu/logd64.c: Added hard-dfp optimizations. - sysdeps/powerpc/dfpu/isinfd128.c: Likewise. - sysdeps/powerpc/dfpu/isfinited128.c: Likewise. - sysdeps/powerpc/dfpu/expd64.c: Likewise. - sysdeps/powerpc/dfpu/rintd128.c: Likewise. - sysdeps/powerpc/dfpu/isfinited32.c: Likewise. - sysdeps/powerpc/dfpu/powd64.c: Likewise. - sysdeps/powerpc/dfpu/rintd32.c: Likewise. - sysdeps/powerpc/dfpu/finited32.c: Likewise. - sysdeps/powerpc/dfpu/logd32.c: Likewise. - sysdeps/powerpc/dfpu/isnormald64.c: Likewise. - sysdeps/powerpc/dfpu/fpclassifyd128.c: Likewise. - sysdeps/powerpc/dfpu/expd32.c: Likewise. - sysdeps/powerpc/dfpu/isnand128.c: Likewise. - sysdeps/powerpc/dfpu/is\_template.h: Likewise. - sysdeps/powerpc/dfpu/powd32.c: Likewise. - sysdeps/powerpc/dfpu/ddlogtbls.h: Likewise. - sysdeps/powerpc/dfpu/isnormald128.c: Likewise. - sysdeps/powerpc/dfpu/isfinited64.c: Likewise. - sysdeps/powerpc/dfpu/rintd64.c: Likewise. - sysdeps/powerpc/dfpu/finited64.c: Likewise. - sysdeps/powerpc/dfpu/isnormald32.c: Likewise. - dfp/math.h: added islessgreaterd prototypes, etc. Added isnormald prototypes. - Miscellaneous changes - configure: Updated version to 1.0.2. - Makefile.in: Added test cases. - ieee754r/Versions: Exported \_\_isnand*, \_\_isinfd*, etc. - tests/test-printf.c: Define \_WANT\_PC. - tests/test-decode.c: Define \_WANT\_DC. - tests/scaffold.c: Added \_VC\_P and \_VC as well as \_WANT\_PC, \_WANT\_DC, and \_WANT\_VC. - tests/test-fpclassify.c: New classification function test. - tests/test-isnan.c: Likewise. - tests/test-isinf.c: Likewise. - tests/test-finite.c: Likewise. - tests/test-param.c: Likewise. - tests/test-quantize.c: Likewise. - sysdeps/powerpc/dfpu/quantized64.c: Hard-dfp implementation. - sysdeps/powerpc/dfpu/quantized128.c: Likewise. - sysdeps/powerpc/dfpu/fpclassifyd64.c: Likewise. - sysdeps/powerpc/dfpu/isnand32.c: Likewise. - sysdeps/powerpc/dfpu/isinfd32.c: Likewise. - sysdeps/powerpc/dfpu/isnand64.c: Likewise. - sysdeps/powerpc/dfpu/isinfd64.c: Likewise. - sysdeps/powerpc/dfpu/finited32.c: Likewise. - sysdeps/powerpc/dfpu/quantized32.c: Likewise. - sysdeps/powerpc/dfpu/finited64.c: Likewise. - sysdeps/powerpc/dfpu/fpclassifyd32.c: Likewise. - Miscellaneous changes - Makefile.in: Allow make check to work without --with-glibc-build. - tests/test-printf.c: Removed register\_printf\_dfp() invocation. - tests/test-amort.c: New file which is an amortiation benchmark. - tests/scaffold.c: Changed to "decode.h". - tests/decode.h (\_DFP\_DECODE\_H): Added \_DFP onto guard. - tests/debug-test.sh: Allow make check to work without --with-glibc-build by either debugging the app or the loader. - configure.ac: Incrememented the library version from 1.0.1 to 1.0.2 due to the addition of the libdfp constructor which no longer requires register\_printf\_dfp(). - README.user: More todos. - include/init\_dfp.h (\_\_libdfp\_init): New file to add constructor prototype. - Makefile.gdb: Allow make check to work without --with-glibc-build. - init\_dfp.c (\_\_libdfp\_init): New file. Add a constructor to call register\_printf\_dfp(). - Miscellaneous changes - configure: Regenerated. - Makefile.in: Remove appending of cc\_msize to CFLAGS. Remove -e from submake which builds libdecnumber. - configure.ac: Remove cc\_msize and cc\_mzarch and accompanying AC\_SUBST. The preferred method is to require the user to pass -m[31|32|64] in CFLAGS as an env variable when configure is invoked. - README.user: New file. - README.developer: Updated to direct user to pass -m[31|32|64] in CFLAGS and to always use --build and --host values that align with the -m values. - Miscellaneous changes - Makefile.in: Removed unneccesary rule -- backend: $(dfp\_backend)/$(dfp\_backend\_lib). - Miscellaneous changes - Makefile.in: Fixed rule $(top\_builddir)/$(dfp\_backend\_lib): to $(dfp\_backend)/$(dfp\_backend\_lib) to correct problem with make -j* - Miscellaneous changes - Makefile.in: Replaced libdfp.so.1 generation using `ln -s' to using `ldconfig -l' in both $(top\_builddir)/ and $(install\_root)$(libdir)/. Added creation of linkname symlink libdfp.so. Strip trailing / from any install\_root= paths. - Miscellaneous changes - Makefile.in: Fixed `ln -s' to not have the goofy '(cd..)', e.g. (cd $(libdir) ln -s ) when making the .so.1 -> -1.0.1.so symlinks. - Miscellaneous changes - Makefile.in: Fixed libdir=@prefix@/lib to libdir=@libdir@ and includedir=@prefix@/include to includedir=@includedir@. This will allow configure override with --libdir= and --includedir= respectively. This was preventing installation into //lib64. Fix header install so that dfp/README isn't installed with the header files. - Miscellaneous changes - Makefile.in: `install' doesn't handle symlinks so we've done another 'ln -s' in the install stage to set $(SHARED\_LIBRARY) -> ./$(SHARED\_VERSIONED\_LIBRARY) in the $(install\_root)/$(libdir)/ directory. - Miscellaneous changes - Makefile.in: Fixed erroneous attempt to install libdfp.a even if --enable-static=no was configured. - Miscellaneous changes - Makefile.in: Fixed missing libdecnumber.a rule dependency by changing the backend rule to be `libdecnumber.a' rather than `libdecnumber'. Fixed `ln -s' error when rebuilding without a make clean by adding `-f' to always force overwrite the previous versioned library symlink. - README: Renamed to README.developer - README.developer: New file. - Miscellaneous changes - configure: Regenerated. - configure.ac: Added additional help text when warning about the glibc headers lacking the printf-hooks support. - README: Clarified version number. - TODO: Updated. - Miscellaneous changes - configure: Regenerated. - configure.ac: Add check for glibc headers that support the printf-hooks. Add runtime check for printf-hooks in libc specified by --with-glibc-build. - TODO: Updated. - Miscellaneous changes - configure: Regenerated. - configure.ac: Updated libdfp to version 1.0.1 to indicate that power7 support has been added. - Miscellaneous changes - configure.ac: Added POWER 7 support. - README: Added notes on POWER 7 support. - sysdeps/powerpc/powerpc32/power7: New directory. - sysdeps/powerpc/powerpc32/power7/Implies: Imply Power6. - sysdeps/powerpc/powerpc32/power7/fpu: New directory. - sysdeps/powerpc/powerpc32/power7/fpu/Implies: Imply Power6. - sysdeps/powerpc/powerpc64/power7: New directory. - sysdeps/powerpc/powerpc64/power7/Implies: Imply Power6. - sysdeps/powerpc/powerpc64/power7/fpu: New directory. - sysdeps/powerpc/powerpc64/power7/fpu/Implies: Imply Power6. - Miscellaneous changes - configure: Regenerated. - configure.ac (AC\_CACHE\_CHECK): Re-added check for decimal-float-support in the compiler by checking whether the compiler can handle the \_Decimal64 data type rather than checking whether the compiler -v output had a particular flag set. - Miscellaneous changes - configure: Regenerated. - configure.ac (AC\_PROG\_CC): Re-added AC\_PROG\_CC and removed custom $(CC). Removed -m flags from CC and pushed this responsibility onto Makefile.in to put into CFLAGS. These changes allow a user to prepend some custom flags onto CFLAGS at configure time. (dfp\_opts): Changed to $(cc\_mzarch). No need to be obscure until we have to. - Makefile.in (cc\_mzarch): New variable used on s390 only, otherwise empty. (default\_cflags): Inherit defaults from configure. Add -m$(cc\_msize) and $(cc\_mzarch). (default\_asflags): Inherit defaults from configure. Add -m$(cc\_msize) and $(cc\_mzarch). (+cflags): Simplified CFLAGS override mechanism. (+asflags): Simplified ASFLAGS override mechanism. ($(top\_builddir)/$(dfp\_backend)): Manually pass overridden CFLAGS to backend 'make' since the -m flags aren't passed in the top level configure's CFLAGS. ($(top\_builddir)/$(SHARED\_VERSION\_LIBRARY)): Added $(CFLAGS) since it's no longer part of $(CC). ($(libdfp\_tests)): Added $(CFLAGS) since it's no longer part of $(CC). - Miscellaneous changes - configure: Regenerated. - Miscellaneous changes - configure.ac: Add -mzarch when building hw dfp on S/390. This is needed for 31 bit which would otherwise default to -mesa. - Miscellaneous changes - configure: Regenerated. - Makefile.in (.c.o, .c.os): Added -include $(top\_builddir)/config.h to pick up \_BACKEND\_DPD or \_BACKEND\_BID. ($(top\_builddir)/$(STATIC\_LIBRARY)): Add $(top\_builddir) to dfp\_backend path. - README: Added WARNING about making sure to link to a glibc that's the same bitness (32|64) and the same optimization as the libdfp that's being configure. Added --with-glibc-build= examples. - Versions (libdfp): LIBDFP\_1.0.0 tagged. - Versions.def (libdfp): LIBDFP\_1.0.0 tagged. - ieee754r/Versions.def (libdfp): LIBDFP\_1.0.0 tagged. - config.h.in: Regenerated. - configure.ac: (AC\_INIT): Tagged version 1.0.0. (\_DPD\_BACKEND): AC\_DEFINE\_UNQUOTED; Set based on backend. (\_BID\_BACKEND): AC\_DEFINE\_UNQUOTED; Set based on backend. (--with-cpu): Removed submachine\_opt="-mcpu=$withval". ($machine): On s390 cc\_msize=31 NOT 32. (AC\_SUBST): CFLAGS and ASFLAGS. (AC\_CACHE\_CHECK): Removed check for compiler feature decimal-float-support. - ieee754r/frexpd32.c (INTERNAL\_FUNCTION\_NAME): Initialize 'result' to DEC\_NAN because compiler can't see that it's set in a macro and generates warnings. - sysdeps/bid/Versions (libdfp): LIBDFP\_1.0.0 tagged - sysdeps/dpd/Versions (libdfp): LIBDFP\_1.0.0 tagged - sysdeps/dpd/dpd-private.c (\_\_get\_digits\_d32, \_\_get\_digits\_d64, \_\_get\_digits\_d128): initialize exp = 0; - sysdeps/powerpc/dfpu/numdigits.h (numdigits): Conditionally define 'f' based on \_Decimal size to prevent the compiler from messing up the register order requirements. - sysdeps/soft-dfp/Versions (libdfp): LIBDFP\_1.0.0 tagged - sysdeps/soft-dfp/bid/Versions (libdfp): LIBDFP\_1.0.0 tagged - sysdeps/soft-dfp/dpd/Versions (libdfp): LIBDFP\_1.0.0 tagged - tests/decode.h: New file providing non-exported decoded[32|64|128] prototypes used in tests and debugging. - tests/scaffold.c (\_DC, \_DC\_P): Added macros for testing against decoded[32|64|128] output. - tests/test-param.c (main): Updated to use scaffold.c and test the values against the decoded[32|64|128] values that're expected. - Miscellaneous changes - ieee754r/powd32.c (INTERNAL\_FUNCTION\_NAME): Set \_\_isnan -> FUNC\_D(\_\_isnan). Not strictly necessary since \_\_isnan is a polymorphic classification function, but this was we avoid the extra steps of detecting the type/size of the input parameter and call the appropriate \_\_isnand[32|64|128] directly. - Miscellaneous changes - ieee754r/powd32.c: Add dfp prefix to \_\_isnan invocation. - Miscellaneous changes - sysdeps/s390/dfpu/fenv\_libdfp.h: Move file to ... - sysdeps/s390/fpu/fenv\_libdfp.h: ... here. - Miscellaneous changes - configure.ac: Add a march vs mcpu gcc option check. - Miscellaneous changes - Makefile.in (prefix): Set based on @prefix@ to prevent missing --exec-prefix from setting @exec\_prefix@ to the string '$(prefix)', i.e. not the context of $prefix. ($(top\_builddir)/$(SHARED\_VERSION\_LIBRARY)): Added -W,no-whole-archive to close -W,whole-archive to SHARED\_VERSION\_LIBRARY rule. Removed -nodefaultlibs -nostdlib which prevented linking against libc and libm which libdfp relies upon. - tests/test-printf.c (printf\_d128s): Added correct "expected" strings. - sysdeps/soft-dfp/dpd/numdigits.h (left\_justify): Changed erroneous FUNC\_D (getexp(x)) to FUNC\_D (getexp) (x) to correct macro invocation. - Miscellaneous changes - README: Updated the S/390 availability section. - Miscellaneous changes - Makefile.in: Updated comment to reflect update from 0.0.1 to 0.0.9. - configure.ac (AC\_INIT): Updated version from 0.0.1 to 0.0.9. - README: Added two TODO chapters and clarified the intro paragraphs. - Versions.def: Update package versions for symbols. - Versions: Update package versions for symbols. - Miscellaneous changes - Makefile.in: Added test-param to libdfp\_tests. - tests/TODO: New file. - tests/README: N/A. - tests/test-param.c: New test to verify integrity of parameters that are spilled to the stack on being passed to a new function. - Miscellaneous changes - tests/test-printf.c: Added mechanism to easily add new printf test cases based upon GLIBC's stdio-common/tfformat.c testcase. - Miscellaneous changes - tests/scaffold.c: New file which holds \_C, \_C\_P, \_PC, and \_PC\_P macros used for printing debugging messages in the event of test case failures. - Miscellaneous changes - Makefile.in: For .out rules send stdout to /dev/null and stderr to the .out file. - tests/test-printf.c: Added framework for generically adding printf tests. - Makefile.gdb: Squelch echos of .conf and .gdb file creation. - Miscellaneous changes - Makefile.in: Change test-debug to > debug-test. - tests/debug-test.sh: Change test-debug.conf -> debug-test.conf. - Makefile.gdb: Change test-debug to debug-test. - Miscellaneous changes - tests/test-debug.sh: Removed and renamed to ... - tests/debug-test.sh: New. - Miscellaneous changes - CONTRIBUTORS: Added Carlos Eduardo Seo for contribution of Makefile.in make install and make install-headers feature. - README: Added section on Make Rules. - TODO: Added additional todo items. - Miscellaneous changes - Makefile.in: Added 'make install0headers' feature. - Miscellaneous changes - printf\_dfp.c: (padn, wpadn): Changed usage of size\_t to 'int' to avoid compiler warnings about unsigned to signed comparisons. - Miscellaneous changes - tests/test-printf.c: Added print statements for \_Decimal32 and \_Decimal128. - sysdeps/powerpc/dfpu/numdigits.h (numdigits getexp): Use FUNC\_D wrapper. (FUNC\_D PASTE): Conditionally define these macros. - Miscellaneous changes - include/printf\_dfp.h (\_\_d32\_ais, \_\_d64\_ais, \_\_d128\_ais): Removed - printf\_dfp.c (\_\_printf\_dfp): Changed width from unsigned into to int in order to prevent negative default. (\_\_register\_printf\_dfp): Replaced individual decimal sized specifier registrations with a unified registrations. (\_\_d32\_ais, \_\_d64\_ais, \_\_d128\_ais): Removed and replaced with unified \_\_dfp\_ais(). - Miscellaneous changes - ieee754r/ldexpd32.c (ldexpd32): Use FUNC\_D wrapper around getexp. - ieee754r/frexpd32.c (frexpd32): Use FUNC\_D wrapper around numdigits and getexp. - sysdeps/soft-dfp/dpd/numdigits.h (numdigits getexp): Use FUNC\_D wrapper. - Miscellaneous changes - Makefile.in: Added 'make install' feature. - Miscellaneous changes - include/printf\_dfp.h: Add #include . - sysdeps/s390/dfpu/numdigits.h: Wrap function definitions in FUNC\_D macro. Add PASTE and FUNC\_D macro definitions. - strtod32.c (setexp): Refer to 'getexp' using FUNC\_D() macro. Add PASTE and FUNC\_D macro definitions. Reposition dfp*\_private.h header inclusions. - General non-functiopnal maintenance. - Makefile.in: Cleanup comments. - README: Fix typo, spacings, and text. - This commit adds the port of libdfp from a GLIBC add-on to a standalone library. This library was written by Ryan S. Arnold , Joseph Kerian , Pete Eberlein , Steve Munroe , Andreas Krebbel , et al. - This commit adds the top-level sub-directories for the stand-alone libdfp project. It adds the top-level directory libdfp/ per Mark Mitchell's direction on patches@eglibc.org on Mon, 29 Jun 2009.