[cfe-commits] Patch for review/integration: __sync_swap()

Chris Lattner clattner at apple.com
Fri Apr 8 21:02:21 PDT 2011


On Apr 8, 2011, at 8:52 PM, Dave Zarzycki wrote:

> Eli,
> 
> Thanks for the feedback. I've updated the patch:
> 
> <__sync_swap-v2.patch>
> 
> For whatever it may be worth, plain atomic swaps are invaluable to Apple's modern threading library ("Grand Central Dispatch" a.k.a. libdispatch). <http://www.apple.com/macosx/technology/#grandcentral>

Looks good to me with the doc change.  I applied it in r129189, thanks Dave!

-Chris

> 
> davez
> 
> 
> On Apr 8, 2011, at 7:38 PM, Eli Friedman wrote:
> 
>> On Fri, Apr 8, 2011 at 6:09 PM, Dave Zarzycki <zarzycki at apple.com> wrote:
>>> Background:
>>> 
>>> The __sync_*() atomic intrinsics do not directly expose the fundamental atomic swap operation that many processors support. One can indirectly get at the instruction by using __sync_lock_test_and_set(), but the documentation for that intrinsic does not promise to be an atomic swap on all architectures or even be a full barrier like the other __sync_*() intrinsics. This patch fixes this oversight:
>> 
>> It's not really an oversight; the __sync_ intrinsics were invented by
>> Intel for Itanium, and the Itanium xchg instruction isn't a full
>> barrier.  I don't see any harm in adding this anyway, although I'm not
>> really an expert in lock-free algorithms.
>> 
>>> This is my first clang patch, so please be understanding if I made any newbie mistakes.
>>> 
>>> Thanks for considering this change,
>> 
>> I don't see anything wrong with the patch itself, but you should add a
>> note in docs/LanguageExtensions.html.
>> 
>> -Eli
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list