* David Malcolm:
>
> My first thought here was that we should have a way to get all three at
> once, but it turns out that parse_basever does its own caching
> internally.
>
> I don't think the current implementation is thread-safe; parse_basever
> has:
>
> static int s_major = -1, s_minor, s_patchlevel;
>
> if (s_major == -1)
> if (sscanf (BASEVER, "%d.%d.%d", &s_major, &s_minor, &s_patchlevel) != 3)
> {
> sscanf (BASEVER, "%d.%d", &s_major, &s_minor);
> s_patchlevel = 0;
> }
>
> I think there's a race here:
Right, it's not thread-safe.
One possiblity would be to store all three numbers in one unsigned
int, and used relaxed MO loads and stores. A zero value would
indicate that initialization is needed.
It will break if there are ever more than 1000 or so GCC releases, but
it will be good for a while.