2013/7/22 Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>: > On 07/22/2013 11:41 PM, Pawel Dziepak wrote: >> >> I will replace the atomic_get{,64}() functions with the "_aligned" >> ones I just introduced. Current atomic_set() apart from setting new >> value also returns the old one so I guess renaming it to atomic_xchg() > > > Hm, not sure about that; pretty much all atomic setters return the old > value. > > >> would be a good idea (while atomic_set{,64}_aligned() becomes >> atomic_set{,64}().). > > > Can't it return the old value as well to join the club? :-) Unfortunately, no. On x86(_64) to atomically set a value all we need is a simple mov instruction since all writes and reads to naturally aligned memory locations are guaranteed to be atomic. If we want to get the old value we need to use xchg instruction, which is more expensive than a simple mov. That's why I though about having both atomic_set() and atomic_xchg(). Paweł