This is the mail archive of the
mailing list for the glibc project.
Re: gcc 4.1 implements compiler builtins for atomic ops
On Mon, Jun 27, 2005 at 08:46:32AM +1000, Benjamin Herrenschmidt wrote:
> Yes, but that encourage developers to use them direcltly, which means
> that they'll, for example, produce code that will either be broken for
> 405 or will have a spurrious sync on non-405 which is a significant
> performance issue.
> There are other problems with the use of atomics, like do you barrier
> around atomics that "return" a value ? If not, I can guarantee that 90%
> of the people using them will get it wrong.
> Finally, as I wrote earlier, a lot of people tend to use atomics to
> implement locks. That is totally broken of course in a lot of cases, but
> subtely enough that it won't appear unless you do serious testing.
> Having that in gcc instead of some library will prevent us from moving
> those to the vDSO and thus providing separate implementations for
> different CPUs/machines/firmware environment (like a lock that relax a
> thread on SMT when spinning, or taking into account 970 issues with
> ldarx looops starving the bus, etc....)
You might want to take a look at the defined builtins and what they're
documented to do before you go any further down this concern. There's
a good chapter on them in the GCC manual (in CVS HEAD).