GNU Info

Info Node: (gmp.info)Reentrancy

(gmp.info)Reentrancy


Next: Useful Macros and Constants Prev: Memory Management Up: GMP Basics
Enter node , (file) or (file)node

Reentrancy
==========

   GMP is reentrant and thread-safe, with some exceptions:

   * If configured with `--enable-alloca=malloc-notreentrant' (or with
     `--enable-alloca=notreentrant' when `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.

   * `mp_set_memory_functions' uses global variables to store the
     selected memory allocation functions.

   * `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.

   * If the memory allocation functions set by a call to
     `mp_set_memory_functions' (or `malloc' and friends by default) are
     not reentrant, then GMP will not be reentrant either.

   * If the standard I/O functions such as `fwrite' are not reentrant
     then the GMP I/O functions using them will not be reentrant either.

   * It's safe for two threads to read from the same GMP variable
     simultaneously, but it's not safe for one to read while the
     another might be writing, nor for two threads to write
     simultaneously.  It's not safe for two threads to generate a
     random number from the same `gmp_randstate_t' simultaneously,
     since this involves an update of that variable.

   * On SCO systems the default `<ctype.h>' macros use per-file static
     variables and may not be reentrant, depending whether the compiler
     optimizes away fetches from them.  The GMP text-based input
     functions are affected.


automatically generated by info2www version 1.2.2.9