summaryrefslogtreecommitdiff
path: root/libguile/boolean.c
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2018-09-27 01:00:11 -0400
committerAndy Wingo <wingo@pobox.com>2019-05-23 15:52:32 +0200
commitf65ccc6afeda2d4e14878928123d8d3660712dca (patch)
treee3c8b251c21dd1dd9e93beaa49e7c1cf7f51c906 /libguile/boolean.c
parent827e88b4b798b11013e8a9ef4e0f6ad111966321 (diff)
downloadguile-f65ccc6afeda2d4e14878928123d8d3660712dca.tar.gz
Fix 'atomic-box-compare-and-swap!'.
Fixes <https://bugs.gnu.org/32786>. 'scm_atomic_compare_and_swap_scm' is a thin wrapper around 'atomic_compare_exchange_weak' (where available), and therefore it may spuriously fail on some platforms, leaving the atomic object unchanged even when the observed value is equal to the expected value. Since 'scm_atomic_compare_and_swap_scm' returns both a boolean result and the observed value, the caller is able to detect spurious failures when using that API. 'atomic-box-compare-and-swap!' presents a simpler API, returning only the observed value. The documentation advises callers to assume that the exchange succeeded if the observed value is 'eq?' to the expected value. It's therefore not possible to report spurious failures with this API. 'atomic-box-compare-and-swap!' uses 'scm_atomic_compare_and_swap_scm', and prior to this commit would simply ignore the boolean result and return the observed value. In case of spurious failures, the caller would legitimately conclude that the exchange had succeeded. With this commit, 'atomic-box-compare-and-swap!' now retries in case of spurious failures. * libguile/atomic.c (scm_atomic_box_compare_and_swap_x): If 'scm_atomic_compare_and_swap_scm' returns false and the observed value is equal to 'expected', then try again. * libguile/intrinsics.c (atomic_compare_and_swap_scm): Ditto.
Diffstat (limited to 'libguile/boolean.c')
0 files changed, 0 insertions, 0 deletions