summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Santiago Aboy Solanes <solanes@google.com> 2024-09-19 13:29:47 +0100
committer Santiago Aboy Solanes <solanes@google.com> 2024-09-23 10:31:49 +0000
commit91f44f6bfe830c5d35ea8045c308092ffc0c91d4 (patch)
tree87ff04768b62269ba01f9a19fea035eeb7598be5
parent56d62450fcd69434b94158a42f1a195bd7ee858b (diff)
Update volatile variables to C++20
This gets rid of the -Wdeprecated-volatile warnings. More info in the proposal: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1152r4.html The bool ones weren't causing warnings but we might as well clean them up in this CL too. Bug: 368241186 Test: art/test/testrunner/testrunner.py --host --64 --optimizing -b Change-Id: Iddb60c2fe600ef27f29c943b3b669171e7f9aed3
-rw-r--r--runtime/base/locks.cc2
-rw-r--r--runtime/base/mutex.cc2
-rw-r--r--runtime/thread_pool.h6
3 files changed, 5 insertions, 5 deletions
diff --git a/runtime/base/locks.cc b/runtime/base/locks.cc
index 2c6b96892b..2c10bfd700 100644
--- a/runtime/base/locks.cc
+++ b/runtime/base/locks.cc
@@ -93,7 +93,7 @@ static void BackOff(uint32_t i) {
volatile uint32_t x = 0;
const uint32_t spin_count = 10 * i;
for (uint32_t spin = 0; spin < spin_count; ++spin) {
- ++x; // Volatile; hence should not be optimized away.
+ x = x + 1; // Volatile; hence should not be optimized away.
}
// TODO: Consider adding x86 PAUSE and/or ARM YIELD here.
} else if (i <= kYieldMax) {
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc
index 831c53599d..0abe9667f8 100644
--- a/runtime/base/mutex.cc
+++ b/runtime/base/mutex.cc
@@ -109,7 +109,7 @@ static void BackOff(uint32_t i) {
volatile uint32_t x = 0;
const uint32_t spin_count = 10 * i;
for (uint32_t spin = 0; spin < spin_count; ++spin) {
- ++x; // Volatile; hence should not be optimized away.
+ x = x + 1; // Volatile; hence should not be optimized away.
}
// TODO: Consider adding x86 PAUSE and/or ARM YIELD here.
} else if (i <= kYieldMax) {
diff --git a/runtime/thread_pool.h b/runtime/thread_pool.h
index 6d176546c3..96317ad13d 100644
--- a/runtime/thread_pool.h
+++ b/runtime/thread_pool.h
@@ -192,10 +192,10 @@ class AbstractThreadPool {
Mutex task_queue_lock_;
ConditionVariable task_queue_condition_ GUARDED_BY(task_queue_lock_);
ConditionVariable completion_condition_ GUARDED_BY(task_queue_lock_);
- volatile bool started_ GUARDED_BY(task_queue_lock_);
- volatile bool shutting_down_ GUARDED_BY(task_queue_lock_);
+ bool started_ GUARDED_BY(task_queue_lock_);
+ bool shutting_down_ GUARDED_BY(task_queue_lock_);
// How many worker threads are waiting on the condition.
- volatile size_t waiting_count_ GUARDED_BY(task_queue_lock_);
+ size_t waiting_count_ GUARDED_BY(task_queue_lock_);
std::vector<ThreadPoolWorker*> threads_;
// Work balance detection.
uint64_t start_time_ GUARDED_BY(task_queue_lock_);