Next: Useful Macros and Constants, Previous: Memory Management, Up: GMP Basics [Index]
GMP is reentrant and thread-safe, with some exceptions:
alloca is not available),
then naturally GMP is not reentrant.
mpf_set_default_prec and mpf_init use a global variable for the
selected precision. mpf_init2 can be used instead, and in the C++
interface an explicit precision to the mpf_class constructor.
mpz_random and the other old random number functions use a global
random state and are hence not reentrant. The newer random number functions
that accept a gmp_randstate_t parameter can be used instead.
gmp_randinit (obsolete) returns an error indication through a global
variable, which is not thread safe. Applications are advised to use
gmp_randinit_default or gmp_randinit_lc_2exp instead.
mp_set_memory_functions uses global variables to store the selected
memory allocation functions.
mp_set_memory_functions (or malloc and friends by default) are
not reentrant, then GMP will not be reentrant either.
fwrite are not reentrant then the
GMP I/O functions using them will not be reentrant either.
gmp_randstate_t simultaneously,
since this involves an update of that variable.