[Bf-committers] Different behavior of our atomic operation depending on compiler
montagne29 at wanadoo.fr
Wed Jul 1 09:53:02 CEST 2015
So, trying to hunt an strange issue with Windows scons builds of
filebrowser work, I found that our attomic operations (defined in
intern/atomic/atomci_ops.h) do not return the same things on MSVC than
with other OS/compilers.
With GCC & co we use `__sync_add_and_fetch`, on OSX, `OSAtomicAdd64`,
with MSVC `InterlockedExchangeAdd64`, and have a fallback implementation
in plain assembler.
According to documentations (and my limited asm understanding), MSVC
version returns the value of `*p` *before* the operation, while all
others return it *after* the operation (i.e. return the result of the
I doubt this is desired behavior, and think it could easily generate
nasty bug some day… MSVC does not seem to have a 'return value after
operation' variant from quick look at the doc? Maybe we should just
remove the MSVC case completely and use asm version instead?
More information about the Bf-committers