Re: gamma() and lgamma() functions

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: Peter Eisentraut <peter@eisentraut.org>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-09-04T18:34:49Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Add support for gamma() and lgamma() functions.

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