summaryrefslogtreecommitdiff
path: root/mini-gmp/README
blob: 5b891aa4d8fbbceab62e8980af1d3014cad5c160 (plain)
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
This is "mini-gmp", a small implementation of a subset of GMP's mpn
and mpz interfaces.

It is intended for applications which need arithmetic on numbers
larger than a machine word, but which don't need to handle very large
numbers very efficiently. Those applications can include a copy of
mini-gmp to get a GMP-compatible interface with small footprint. One
can also arrange for optional linking with the real GMP library, using
mini-gmp as a fallback when for some reason GMP is not available, or
not desired as a dependency.

The supported GMP subset is declared in mini-gmp.h. The implemented
functions are fully compatible with the corresponding GMP functions,
as specified in the GMP manual, with a few exceptions:

  mpz_export and mpz_import support only NAILS = 0.

  The REALLOC_FUNC and FREE_FUNC registered with
  mp_set_memory_functions does not get the correct size of the
  allocated block in the corresponding argument. mini-gmp always
  passes zero for these rarely used arguments.

The implementation is a single file, mini-gmp.c.

The performance target for mini-gmp is to be at most 10 times slower
than the real GMP library, for numbers of size up to a few hundred
bits. No asymptotically fast algorithms are included in mini-gmp, so
it will be many orders of magnitude slower than GMP for very large
numbers.

You should never "install" mini-gmp. Applications can either just
#include mini-gmp.c (but then, beware that it defines several macros
and functions outside of the advertised interface). Or compile
mini-gmp.c as a separate compilation unit, and use the declarations in
mini-gmp.h.

The tests subdirectory contains a testsuite. To use it, you need GMP
and GNU make. Just run make check in the tests directory. If the
hard-coded compiler settings are not right, you have to either edit the
Makefile or pass overriding values on the make command line (e.g.,
make CC=cc check). Testing is not (yet) as thorough as for the real
GMP.

The current version was put together by Niels Möller
<nisse@lysator.liu.se>, with a fair amount of copy-and-paste from the
GMP sources.