1Copyright 2011-2013, 2018 Free Software Foundation, Inc. 2 3This file is part of the GNU MP Library. 4 5The GNU MP Library is free software; you can redistribute it and/or modify 6it under the terms of either: 7 8 * the GNU Lesser General Public License as published by the Free 9 Software Foundation; either version 3 of the License, or (at your 10 option) any later version. 11 12or 13 14 * the GNU General Public License as published by the Free Software 15 Foundation; either version 2 of the License, or (at your option) any 16 later version. 17 18or both in parallel, as here. 19 20The GNU MP Library is distributed in the hope that it will be useful, but 21WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 22or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 23for more details. 24 25You should have received copies of the GNU General Public License and the 26GNU Lesser General Public License along with the GNU MP Library. If not, 27see https://www.gnu.org/licenses/. 28 29 30This is "mini-gmp", a small implementation of a subset of GMP's mpn, 31mpz and mpq interfaces. 32 33It is intended for applications which need arithmetic on numbers 34larger than a machine word, but which don't need to handle very large 35numbers very efficiently. Those applications can include a copy of 36mini-gmp to get a GMP-compatible interface with small footprint. One 37can also arrange for optional linking with the real GMP library, using 38mini-gmp as a fallback when for some reason GMP is not available, or 39not desired as a dependency. 40 41The supported GMP subset of the mpn and mpz interfaces is declared in 42mini-gmp.h, and implemented in mini-gmp.c. The implemented 43functions are fully compatible with the corresponding GMP functions, 44as specified in the GMP manual, with a few exceptions: 45 46 mpz_export and mpz_import support only NAILS = 0. 47 48 The REALLOC_FUNC and FREE_FUNC registered with 49 mp_set_memory_functions does not get the correct size of the 50 allocated block in the corresponding argument. mini-gmp always 51 passes zero for these rarely used arguments. 52 53 When mpz_get_str allocates the block, it can be longer than needed. 54 55The performance target for mini-gmp is to be at most 10 times slower 56than the real GMP library, for numbers of size up to a few hundred 57bits. No asymptotically fast algorithms are included in mini-gmp, so 58it will be many orders of magnitude slower than GMP for very large 59numbers. 60 61The supported GMP subset of the mpq layer is declared in mini-mpq.h, 62and implemented in mini-mpq.c. 63 64You should never "install" mini-gmp. Applications can either just 65#include mini-gmp.c (but then, beware that it defines several macros 66and functions outside of the advertised interface), and if needed 67#include mini-mpq.c in a later line (order is important). Or compile 68mini-gmp.c and mini-mpq.c as separate compilation units, and use the 69declarations in mini-gmp.h and mini-mpq.h. 70 71The tests subdirectory contains a testsuite. To use it, you need GMP 72and GNU make. Just run make check in the tests directory. If the 73hard-coded compiler settings are not right, you have to either edit the 74Makefile or pass overriding values on the make command line (e.g., 75make CC=cc check). 76 77The initial version of mini-gmp was put together by Niels Möller 78<nisse@lysator.liu.se>, with a fair amount of copy-and-paste from the 79GMP sources. 80