Fix and improve pg_atomic_flag fallback implementation.

The atomics fallback implementation for pg_atomic_flag was broken,
returning the inverted value from pg_atomic_test_set_flag().  This was
unnoticed because a) atomic flags were unused until recently b) the
test code wasn't run when the fallback implementation was in
use (because it didn't allow to test for some edge cases).

Fix the bug, and improve the fallback so it has the same behaviour as
the non-fallback implementation in the problematic edge cases. That
breaks ABI compatibility in the back branches when fallbacks are in
use, but given they were broken until now...

Author: Andres Freund
Reported-by: Daniel Gustafsson
Backpatch: 9.5-, where the atomics abstraction was introduced.



Modified Files
src/backend/port/atomics.c          | 21 +++++++++++++++++++--
src/include/port/atomics/fallback.h | 13 ++-----------
src/test/regress/regress.c          | 14 --------------
3 files changed, 21 insertions(+), 27 deletions(-)

Reply via email to