mini-gmp mpz_{get,set}_d not fully compatible with GMP

Adrien Prost-Boucle adrien.prost-boucle at laposte.net
Sun Mar 11 11:42:16 UTC 2018


On Sun, 2018-03-11 at 00:15 +0100, Niels Möller wrote:
> 
> so that the initializer is evaluated exactly once, after the first entry
> to the function, but before any thread uses the value (likely generating
> code using pthread_once). Has anything like that made it into recent C
> standards?

__attribute__ ((constructor)) is one possible solution,
if you isolate your critical init part in a function.
https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Function-Attributes.html

About it being in a standard or not, I don't know.
But it's pretty common, and handled by clang and gcc.
So it should be rather reliable.

Regards,
Adrien



More information about the gmp-devel mailing list