Re: incorrect use of 'pure' attribute

Bruno Haible via Gnulib discussion list <[email protected]>
Newsgroups gmane.comp.lib.gnulib.bugs
Message-ID <9978251.OUTRe80PYV@cagnes>
Arsen Arsenović wrote:
> > __eloop_threshold.
> 
> ... I am certain this is a race
> condition in linkat etc due to this condition.  ;)
> 
> Those should be atomic accesses.

The code is:

  static long int sysconf_symloop_max;
  if (sysconf_symloop_max == 0)
    sysconf_symloop_max = __sysconf (_SC_SYMLOOP_MAX);

When an expression, such as __sysconf (_SC_SYMLOOP_MAX), is side-effect
free and always returns the same value, it is OK to evaluate it in several
threads in parallel and cache it. In the worst case, the expression gets
evaluated multiple times. Storing the same value in the same location (of
type 'int') is OK not only on those platforms where an 'int' access is atomic,
but even on architectures (such as m68k) where it isn't.

So, no locking / atomic / volatile is needed here.

Bruno
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.