summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-02-08 10:48:00 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-02-08 14:49:17 +0300
commit2902ec7875314632105501f5fc95765dd7a69fd5 (patch)
treed76e684e5c61c6a2d248068aa2a1918582e73bfc
parent172b5fd5c5eba6076e6275333ddac841e654bfb4 (diff)
downloadlibatomic_ops-2902ec7875314632105501f5fc95765dd7a69fd5.tar.gz
Rename fetch_and_add to fetch_then_add in test_stack
(refactoring) * tests/test_stack.c (fetch_and_add): Rename to fetch_then_add; refine comment. * tests/test_stack.c (run_one_test): Rename fetch_and_add to fetch_then_add.
-rw-r--r--tests/test_stack.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/test_stack.c b/tests/test_stack.c
index 7c2e667..160b0dc 100644
--- a/tests/test_stack.c
+++ b/tests/test_stack.c
@@ -159,11 +159,11 @@ volatile AO_t ops_performed = 0;
#endif
#ifdef AO_HAVE_fetch_and_add
-# define fetch_and_add(addr, val) AO_fetch_and_add(addr, val)
+# define fetch_then_add(addr, val) AO_fetch_and_add(addr, val)
#else
- /* Fake it. This is really quite unacceptable for timing */
- /* purposes. But as a correctness test, it should be OK. */
- AO_INLINE AO_t fetch_and_add(volatile AO_t * addr, AO_t val)
+ /* OK to perform it in two atomic steps, but really quite */
+ /* unacceptable for timing purposes. */
+ AO_INLINE AO_t fetch_then_add(volatile AO_t * addr, AO_t val)
{
AO_t result = AO_load(addr);
AO_store(addr, result + val);
@@ -185,7 +185,7 @@ volatile AO_t ops_performed = 0;
printf("starting thread %u\n", index);
# endif
- while (fetch_and_add(&ops_performed, index + 1) + index + 1 < LIMIT)
+ while (fetch_then_add(&ops_performed, index + 1) + index + 1 < LIMIT)
{
for (i = 0; i <= index; ++i)
{