Re: gamma() and lgamma() functions - Mailing list pgsql-hackers

From Tom Lane
Subject Re: gamma() and lgamma() functions
Date
Msg-id 1675034.1725474889@sss.pgh.pa.us
Whole thread Raw
In response to Re: gamma() and lgamma() functions  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: gamma() and lgamma() functions
Next
From: Daniel Gustafsson
Date:
Subject: Re: Avoid possible dereference null pointer (src/bin/pg_dump/pg_dump.c)