Hi,<div><br></div><div>I'm looking into adding support for gcc 4.7's __atomic_* builtins for the clang 3.1 release (these are necessary to support various parts of libstdc++4.7). Our current set of __atomic_* builtins is incompatible with gcc 4.7's builtins in a few ways:</div>
<div><br></div><div>1) In clang, the builtins produce results by value, whereas in gcc, a pointer is passed indicating where the result should be written.</div><div>2) In clang, the argument type must be an _Atomic. gcc does not have this restriction (but also fails to require that the type is trivially copyable, which is probably a bug).</div>
<div>3) Clang is missing the __atomic_*_n, __atomic_always_lock_free and __atomic_fetch_nand builtins.</div><div>4) Clang is missing the __atomic_compare_exchange builtin, and instead provides __atomic_compare_exchange_strong and __atomic_compare_exchange_weak.</div>
<div>5) Clang provides an __atomic_init builtin, which gcc does not provide, and which crashes during CodeGen.</div><div><br></div><div>My current plan is:</div><div><br></div><div>For (1), add support for the gcc-style arguments, then port libc++ over to them, then remove support for the current arguments.</div>
<div>For (2), relax the requirement to the type being either _Atomic or trivially copyable.</div><div>For (3) and (4), add the missing builtins. I don't intend to remove the __atomic_compare_exchange_strong/__atomic_compare_exchange_weak builtins, but will do so if anyone particularly wants to see them gone.</div>
<div>For (5), remove this builtin.</div><div><br></div><div>Please shout now if any part of this displeases you! In particular, if you have code depending on clang's current pass-by-value atomics and you'd like to see them left in until after the clang 3.1 release to give you more time to move to the portable forms (or indeed you believe they should be left in-place forever), please say so.</div>
<div><br></div><div>Thanks!</div><div>Richard</div>