aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/target.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-06-22 07:30:31 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-06-22 07:30:31 +0200
commit7879d172dec3300341d3eff15808425e01c15569 (patch)
tree3d16d0b081f49fb4b7dca9a19c161e99cdf12498 /libbuild2/target.cxx
parentcb6e76b0fdffe89ec79dab005dbb14f1be48144f (diff)
Fix wraparound in task_count logic
Diffstat (limited to 'libbuild2/target.cxx')
-rw-r--r--libbuild2/target.cxx5
1 files changed, 3 insertions, 2 deletions
diff --git a/libbuild2/target.cxx b/libbuild2/target.cxx
index 19edad7..fb47b6d 100644
--- a/libbuild2/target.cxx
+++ b/libbuild2/target.cxx
@@ -1009,9 +1009,10 @@ namespace build2
const opstate& s (state[action () /* inner */]);
// Note: already synchronized.
- size_t o (s.task_count.load (memory_order_relaxed) - ctx.count_base ());
+ size_t c (s.task_count.load (memory_order_relaxed));
+ size_t b (ctx.count_base ()); // Note: cannot do (c - b)!
- if (o != offset_applied && o != offset_executed)
+ if (c != (b + offset_applied) && c != (b + offset_executed))
break;
}
// Fall through.