I wrote: > AFAICS this patch doesn't inspect signgam, so whether it gets > overwritten by a concurrent thread wouldn't matter. However, > it'd be a good idea to add a comment noting the hazard.
Further to that ... I looked at POSIX issue 8 (I had been reading 7) and found this illuminating discussion: Earlier versions of this standard did not require lgamma(), lgammaf(), and lgammal() to be thread-safe because signgam was a global variable. They are now required to be thread-safe to align with the ISO C standard (which, since the introduction of threads in 2011, requires that they avoid data races), with the exception that they need not avoid data races when storing a value in the signgam variable. Since signgam is not specified by the ISO C standard, this exception is not a conflict with that standard. So the other reason to avoid using signgam is that it might not exist at all in some libraries. regards, tom lane