<div dir="ltr">We're already using std::atomic<> in Clang: <div><div><br></div><div>$ ack 'std::atomic' | cat</div><div>lib/Basic/VirtualFileSystem.cpp:843:  static std::atomic<unsigned> UID;</div><div>
lib/Frontend/ASTUnit.cpp:214:static std::atomic<unsigned> ActiveASTUnitObjects;</div><div>lib/Frontend/CompilerInvocation.cpp:1956:  static std::atomic<unsigned> GraveYardSize;</div><div>tools/libclang/CIndexCodeCompletion.cpp:319:static std::atomic<unsigned> CodeCompletionResultObjects;</div>
<div><br></div></div><div>I'd use it for pointer-sized values.  I probably wouldn't use it on uint64_t, since that'll probably give some 32-bit toolchain somewhere heartburn.</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Tue, Jun 3, 2014 at 12:45 PM, Zachary Turner <span dir="ltr"><<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">I need an atomic pointer exchange, so I took a look at Support/Atomic.h, and the only supported types are 32-bit values.  I can't figure out an obvious reason for this other than perhaps nobody ever had need of this yet, but given that this is kind of a low level thing, I thought I should ask first.  Is there any reason I should not add 64-bit versions of the atomic functions?  <div>

<br></div><div>Additionally, the function I need looks like __sync_test_and_set() on GNU, for which the documentation has this to say:</div><div><br></div><div><span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium">Many targets have only minimal support for such locks, and do not support a full exchange operation. In this case, a target may support reduced functionality here by which the </span><em style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium">only</em><span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium"> valid value to store is the immediate constant 1. The exact value actually stored in </span><code style="color:rgb(0,0,0)">*</code><var style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium">ptr</var><span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium"> is implementation defined.</span><br>

</div><div><span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium"><br></span></div><div>Does anyone happen to know the details here?  Is this true on any platform we support?<span style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:medium"><br>

</span></div></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>