Re: [PATCH] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()'
From: Peter Zijlstra
Date: Tue Mar 15 2016 - 06:51:14 EST
On Tue, Mar 15, 2016 at 10:32:45AM +0100, Ingo Molnar wrote:
> 2) its naming sucks. "fetch_or()" does not really signal that it's a
> fundamentally atomic operation, nor what API family it belongs to.
I disagree there, the fetch-$op naming is widely used for atomic
operations that return the previous value. See for example the C/C++11
I've even thought about reworking our entire atomic*_t bits to match.
That is, introduce all the fetch_$op primitives, then convert all the
$op_return ones over and finally remove all the $op_return ones.
I've not done so because we're all so very used to $op_return that I'm
sure people (and this would very much include me) would curse me for
The reason for fetch_$op is that it also works for irreversible
operations like or. With or_return you simply cannot tell what the
previous state was (with add_return you can do a simple subtraction to
revert to the prior state).
And yes, some people use the xchg-$op naming, but its less widely used
(x86 asm being one). Other also use swap-$op.
In any case, I prefer the name as it was.