This is the mail archive of the
mailing list for the glibc project.
Re: malloc patch for 2.2.4
On Wed, Aug 22, 2001 at 01:05:02PM +0200, Wolfram Gloger wrote:
> Second, _if_ the compiler would actually reload from the global
> variable in this case (strictly speaking it has the right to do so
> under ANSI C), I'd consider it _unsuitable_ for threaded programs.
> There would definitely need to be a switch to turn this off.
Why? If you had some synchronization primitive in between (like mutex lock)
and compiler could do this accross the synchronization primitive, then it
would of course be unsuitable for threaded programs, but the compiler will
not reread it accross mutexes etc. - as soon as you call some function which
might clobber global data (ie. non-const, non-pure) or as soon as there is a
memory barrier, compiler will have to stop doing it.