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

_______________________________________________
gmp-devel mailing list
gmp-devel@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-devel

Reply via email to