On Tue, Oct 18, 2011 at 06:03:16PM -0400, Andrew MacLeod wrote:
>
> Here's the last of the missing intrinsics. compare_exchange is
> slightly different than the others since it doesn't map directly to
> an rtl pattern. Its format is :
>
> bool __atomic_compare_exchange (T* mem, T* expected, T desired,
> bool weak, memory_order success, memory_order failure)
>
> note that the expected parameter is a pointer as well. In the case
> where false is returned, the value of expected is updated.
I think the __sync_* way here was much better (two intrinsics instead of
one, one bool-ish and one returning val). With mandating T*expected
you force it to be addressable, probably until expansion time at which point
it will be just forced into memory, which is highly undesirable.
Jakub