]> granicus.if.org Git - gc/commit
Fix data race in collectable_count (gctest)
authorIvan Maidanski <ivmai@mail.ru>
Wed, 27 Sep 2017 22:46:20 +0000 (01:46 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 27 Sep 2017 22:46:20 +0000 (01:46 +0300)
commitc2ded73d56acc85270afea8b16221ac262486e6b
tree5f12d6147b76d35c9da5c9770d2697ab0a616fb9
parent1a51704841b159a4c2f8f181ee60c053fbc888e3
Fix data race in collectable_count (gctest)

* tests/test.c [THREADS && (GC_BUILTIN_ATOMIC || PARALLEL_MARK
|| !GC_WIN32_THREADS)]: Include gc_atomic_ops.h.
* tests/test.c [AO_HAVE_fetch_and_add1] (collectable_count): Change
type to volatile AO_t (and make it static to initalize it without "=0").
* tests/test.c [!AO_HAVE_fetch_and_add1] (AO_fetch_and_add1): Define
to a non-atomic increment (for a single-threaded build).
* tests/test.c (small_cons, reverse_test_inner, mktree, chktree,
alloc8bytes, typed_test, run_one_test): Use
AO_fetch_and_add1(&collectable_count) instead of collectable_count++.
* tests/test.c (check_heap_stats): Cast collectable_count to int in
GC_printf() call.
tests/test.c