This is the mail archive of the
mailing list for the GCC project.
Re: atomic accesses
Jakub Jelinek wrote:
On Tue, Mar 04, 2008 at 04:37:29PM +0000, Andrew Haley wrote:
We already have these in gcc, and they're even documented.
Typically those would be found in asm statements.
I suspect it would be valuable to have standardized primitives for
atomic actions (semaphores, spinlocks, test-and-set primitives,
circular buffers, pick one).
We don't have atomic read or atomic write builtins (ok, you could
abuse __sync_fetch_and_add (&x, 0) for atomic read and a loop
with __sync_compare_and_swap_val for atomic store, but that's a horrible
There is nothing preventing us from adding __sync_fetch and __sync_store
so that we could avoid the overkill.
Perhaps anything declared volatile should have these semantics.
Although mentioning 'volatile' on the lkml is probably not a good idea.