gmp_mpfr_sys/lib.rs
1// Copyright © 2017–2025 Trevor Spiteri
2
3// This program is free software: you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public License
5// as published by the Free Software Foundation, either version 3 of
6// the License, or (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful, but
9// WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License and a copy of the GNU General Public License along with
15// this program. If not, see <https://www.gnu.org/licenses/>.
16
17/*!
18# Rust low-level bindings for GMP, MPFR and MPC
19
20The gmp-mpfr-sys crate provides Rust FFI bindings to the following
21[GNU] arbitrary-precision libraries:
22
23 * [GMP] for integers and rational numbers,
24 * [MPFR] for floating-point numbers, and
25 * [MPC] for complex numbers.
26
27The source of the three libraries is included in the package.
28
29The gmp-mpfr-sys crate is free software: you can redistribute it
30and/or modify it under the terms of the GNU Lesser General Public
31License as published by the Free Software Foundation, either version 3
32of the License, or (at your option) any later version. See the full
33text of the [GNU LGPL] and [GNU GPL] for details.
34
35## Basic features
36
37This crate contains three modules:
38
39 * [`gmp`] provides external FFI bindings to [GMP].
40 * [`mpfr`] provides external FFI bindings to [MPFR].
41 * [`mpc`] provides external FFI bindings to [MPC].
42
43The versions provided by this crate release are [GMP] version 6.3.0, [MPFR]
44version 4.2.2, and [MPC] version 1.3.1.
45
46If you want a high-level API, consider using [Rug][rug crate], a crate
47which provides integers and floating-point numbers with arbitrary
48precision and correct rounding:
49
50 * [`Integer`] is a bignum integer with arbitrary precision.
51 * [`Rational`] is a bignum rational number with arbitrary precision.
52 * [`Float`] is a multi-precision floating-point number with correct
53 rounding.
54 * [`Complex`] is a multi-precision complex number with correct
55 rounding.
56
57### Name prefixes
58
59Since modules and enumerated types provide namespacing, most prefixes
60in the C names are removed. However, when the prefix is not a whole
61word it is not removed. For example [`mp_set_memory_functions`]
62becomes [`gmp::set_memory_functions`], but [`mpz_init`] becomes
63[`gmp::mpz_init`] not `gmp::z_init`, and [`MPFR_RNDN`] in
64[`enum MPFR_RND_T`] becomes [`mpfr::rnd_t::RNDN`] not
65`mpfr::rnd_t::N`. Also, the types [`mpfr::mpfr_t`] and [`mpc::mpc_t`]
66are *not* shortened to `mpfr::t` or `mpc::t`.
67
68### Types
69
70Unlike in the C libraries, the types [`gmp::mpz_t`], [`gmp::mpq_t`],
71[`gmp::mpf_t`], [`gmp::randstate_t`], [`mpfr::mpfr_t`] and
72[`mpc::mpc_t`] are defined directly as structs, not as single-element
73arrays.
74
75### Undocumented or obsolete functions
76
77The bindings do not cover undocumented or obsolete functions and
78macros.
79
80## Using gmp-mpfr-sys
81
82The gmp-mpfr-sys crate is available on [crates.io][sys crate]. To use
83gmp-mpfr-sys in your crate, add it as a dependency inside
84[*Cargo.toml*]:
85
86```toml
87[dependencies]
88gmp-mpfr-sys = "1.6"
89```
90
91This crate requires rustc version 1.65.0 or later.
92
93If the C libraries have a major version bump with some deprecated
94functions removed, but no features are removed in the Rust bindings,
95then gmp-mpfr-sys will have a minor version bump rather than a major
96version bump. This allows more compatiblity across crates that use the
97Rust bindings but do not use the C libraries directly.
98
99If on the other hand a dependent crate makes use of internal
100implementation details, or includes a C library that directly uses the
101header (*.h*) and library (*.a*) files built using C, it can be a good
102idea to depend on version `"~1.6"` instead of version `"1.6"` in order
103to ensure backwards compatibility at the C level as well.
104
105## Optional features
106
107The gmp-mpfr-sys crate has two optional features:
108
109 1. `mpfr`, enabled by default. Required to include the [MPFR]
110 library.
111 2. `mpc`, enabled by default. Required to include the [MPC] library.
112 This feature requires the `mpfr` feature.
113
114The [GMP] library is always included.
115
116The two optional features are enabled by default; to use features
117selectively, you can add the dependency like this to [*Cargo.toml*]:
118
119```toml
120[dependencies.gmp-mpfr-sys]
121version = "1.6"
122default-features = false
123features = ["mpfr"]
124```
125
126Here only the `mpfr` feature is selected.
127
128## Experimental optional features
129
130It is not considered a breaking change if experimental features are
131removed. The removal of experimental features would however require a
132minor version bump.
133
134Experimental features may also not work on all platforms.
135
136There are three experimental features:
137
138 1. `use-system-libs`, disabled by default. Using this feature, the
139 system libraries for [GMP], and [MPFR] and [MPC] if enabled, will
140 be used instead of building them from source. The major versions
141 of the system libraries must be equal to those provided by the
142 crate, and the minor versions of the system libraries must be
143 greater or equal to those provided by the crate. There are no
144 restriction on the patch version.
145 2. `force-cross`, disabled by default. Without this feature, the
146 build will fail if cross compilation is detected, because cross
147 compilation is not tested or supported and can lead to silent
148 failures that are hard to debug, especially if this crate is an
149 indirect dependency. As an exception, cross compiling from x86_64
150 to i686 does not need this feature. (Compiling on MinGW does not
151 have this exception because MinGW does not support cross
152 compilation from 64-bit to 32-bit.)
153 3. `c-no-tests`, disabled by default. Using this feature will skip
154 testing the C libraries. This is not advised; the risk that the
155 GMP sources are miscompiled is unfortunately quite high. And if
156 they indeed are miscompiled, the tests are very likely to trigger
157 the compiler-introduced bug.
158
159## Metadata
160
161The gmp-mpfr-sys crate passes some metadata to its dependents:
162
163 1. `DEP_GMP_LIMB_BITS` contains the number of bits per limb, which is
164 32 or 64.
165 2. `DEP_GMP_OUT_DIR` contains the path of a directory that contains
166 two subdirectories: the first subdirectory is named *lib* and
167 contains the generated library (*.a*) files, and the second
168 subdirectory is named *include* and contains the corresponding
169 header (*.h*) files.
170 3. `DEP_GMP_LIB_DIR` contains the path of the *lib* subdirectory of
171 the `DEP_GMP_OUT_DIR` directory.
172 4. `DEP_GMP_INCLUDE_DIR` contains the path of the *include*
173 subdirectory of the `DEP_GMP_OUT_DIR` directory.
174
175A dependent crate can use these environment variables in its build
176script.
177
178## Building on GNU/Linux
179
180**Warning:** The build system does not support building in paths that contain
181spaces.
182
183To build on GNU/Linux, simply make sure you have `diffutils`, `gcc`,
184`m4` and `make` installed on your system. For example on Fedora:
185
186```sh
187sudo dnf install diffutils gcc m4 make
188```
189
190Note that you can use Clang instead of GCC by installing `clang` and setting the
191environment variable `CC=clang` before building the crate.
192
193## Building on macOS
194
195**Warning:** The build system does not support building in paths that contain
196spaces.
197
198To build on macOS, you need the command-line developer tools. To
199install them, run the following command in a terminal:
200
201```sh
202xcode-select --install
203```
204
205## Building on Windows
206
207**Warning:** The build system does not support building in paths that contain
208spaces.
209
210You can build on Windows with the Rust GNU toolchain and an up-to-date
211MSYS2 installation.
212
213To install MSYS2:
214
215 1. Install MSYS2 using the [installer][msys].
216
217 2. Launch the MSYS2 MinGW 64-bit terminal from the start menu.
218
219 3. Install the required tools.
220
221 ```sh
222 pacman -S pacman-mirrors
223 pacman -S diffutils m4 make mingw-w64-x86_64-gcc
224 ```
225
226Then, to build a crate with a dependency on this crate:
227
228 1. Launch the MSYS2 MinGW 64-bit terminal from the start menu.
229
230 2. Change to the crate directory.
231
232 3. Build the crate using `cargo`.
233
234Note that you can use Clang instead of GCC by installing
235`mingw-w64-x86_64-clang` and setting the environment variable `CC=clang` before
236building the crate.
237
238## Cross compilation
239
240While some cross compilation is possible, it is not tested
241automatically, and may not work. Merge requests that improve cross
242compilation are accepted.
243
244The experimental feature `force-cross` must be enabled for cross
245compilation. There is one case which is allowed even without the
246feature: when the only difference between host and target is that the
247host is x86_64 and the target is i686.
248
249## Caching the built C libraries
250
251Building the C libraries can take some time. In order to save
252compilation time, the built libraries are cached in the user’s cache
253directory as follows:
254
255 * on GNU/Linux: inside `$XDG_CACHE_HOME/gmp-mpfr-sys` or
256 `$HOME/.cache/gmp-mpfr-sys`
257 * on macOS: inside `$HOME/Library/Caches/gmp-mpfr-sys`
258 * on Windows: inside `{FOLDERID_LocalAppData}\gmp-mpfr-sys`
259
260To use a different directory, you can set the environment variable
261`GMP_MPFR_SYS_CACHE` to the desired cache directory. Setting the
262`GMP_MPFR_SYS_CACHE` variable to an empty string or to a single
263underscore (`"_"`) will disable caching.
264
265[*Cargo.toml*]: https://doc.rust-lang.org/cargo/guide/dependencies.html
266[GMP]: https://gmplib.org/
267[GNU GPL]: https://www.gnu.org/licenses/gpl-3.0.html
268[GNU LGPL]: https://www.gnu.org/licenses/lgpl-3.0.en.html
269[GNU]: https://www.gnu.org/
270[MPC]: https://www.multiprecision.org/
271[MPFR]: https://www.mpfr.org/
272[`Complex`]: https://docs.rs/rug/latest/rug/struct.Complex.html
273[`Float`]: https://docs.rs/rug/latest/rug/struct.Float.html
274[`Integer`]: https://docs.rs/rug/latest/rug/struct.Integer.html
275[`MPFR_RNDN`]: C/MPFR/constant.MPFR_Basics.html#Rounding-Modes
276[`Rational`]: https://docs.rs/rug/latest/rug/struct.Rational.html
277[`enum MPFR_RND_T`]: C/MPFR/constant.MPFR_Basics.html#index-mpfr_005frnd_005ft
278[`mp_set_memory_functions`]: C/GMP/constant.Custom_Allocation.html#index-mp_005fset_005fmemory_005ffunctions
279[`mpz_init`]: C/GMP/constant.Integer_Functions.html#index-mpz_005finit
280[msys]: https://www.msys2.org/
281[rug crate]: https://crates.io/crates/rug
282[sys crate]: https://crates.io/crates/gmp-mpfr-sys
283*/
284#![no_std]
285#![warn(missing_docs)]
286#![doc(html_root_url = "https://docs.rs/gmp-mpfr-sys/~1.6")]
287#![doc(html_logo_url = "data:image/svg+xml;base64,
288PHN2ZyB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCIgdmVyc2lvbj0iMS4xIiB2aWV3Qm94PSIwIDAgMzMuODY3IDMzLjg2NyIgeG1s
289bnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwIC0yNjMuMTMpIj48Y2lyY2xl
290IGN4PSIxNi45MzMiIGN5PSIyODAuMDciIHI9IjE2LjkzMyIgZmlsbD0iI2Y3ZjFhMSIvPjxnIGZpbGw9IiMwMDcyYjIiIHN0cm9r
291ZS13aWR0aD0iLjI2NDU4cHgiPjxnIHN0cm9rZT0iIzAwMCI+PGcgYXJpYS1sYWJlbD0iNiI+PHBhdGggZD0ibTE0LjM2MSAyNzgu
292NzFjMC42NjA0IDAgMS4yODQxIDAuMjc1MTYg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aWEtbGFiZWw9Ii4iPjxwYXRoIGQ9Im0yMC45MiAyODMuOThj
365MC42NTQ3NiAwIDEuMTI4OS0wLjUxOTI5IDEuMTI4OS0xLjE3NCAwLTAuNjU0NzYtMC40NzQxMy0xLjE3NC0xLjEyODktMS4xNzQt
366MC42NTQ3NiAwLTEuMTI4OSAwLjUxOTI5LTEuMTI4OSAxLjE3NCAwIDAuNjU0NzUgMC40NzQxMyAxLjE3NCAxLjEyODkgMS4xNzR6
367Ii8+PC9nPjwvZz48L2c+PC9zdmc+Cg==
368")]
369#![doc(test(attr(deny(warnings))))]
370#![cfg_attr(feature = "fail-on-warnings", deny(warnings))]
371#![warn(unsafe_op_in_unsafe_fn)]
372#![allow(clippy::missing_safety_doc, clippy::useless_conversion)]
373
374pub mod gmp;
375#[cfg(feature = "mpc")]
376pub mod mpc;
377#[cfg(feature = "mpfr")]
378pub mod mpfr;
379
380pub mod C;
381
382#[cfg(test)]
383mod tests {
384 use core::ffi::c_char;
385 use core::slice;
386 use core::str;
387
388 pub unsafe fn str_from_cstr<'a>(cstr: *const c_char) -> &'a str {
389 let s = unsafe { slice::from_raw_parts(cstr.cast(), libc::strlen(cstr)) };
390 str::from_utf8(s).expect("version not utf8")
391 }
392}