summaryrefslogtreecommitdiffstats
path: root/runtime/atomic.h
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2014-07-09 22:02:36 -0700
committerIan Rogers <irogers@google.com>2014-07-09 23:46:42 -0700
commit8c1b5f71a8005743756206120624121d7678381f (patch)
tree8cc8f170ac94ca2018d2e6e3e24eeeb3ee7f97f3 /runtime/atomic.h
parent070dfc4cebb9772a646382be9751d8f4c6b7d69a (diff)
downloadandroid_art-8c1b5f71a8005743756206120624121d7678381f.tar.gz
android_art-8c1b5f71a8005743756206120624121d7678381f.tar.bz2
android_art-8c1b5f71a8005743756206120624121d7678381f.zip
Missed use of android_atomic and thread state_.
Move to using art::Atomic, add necessary FetchAnd... operations to art::Atomic. Change-Id: I32f1cdc4e0a2037b73f459bf4bb4d544f357f41b
Diffstat (limited to 'runtime/atomic.h')
-rw-r--r--runtime/atomic.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/runtime/atomic.h b/runtime/atomic.h
index 5cfdbcc4fa..c2abf56453 100644
--- a/runtime/atomic.h
+++ b/runtime/atomic.h
@@ -343,6 +343,14 @@ class Atomic : public std::atomic<T> {
return this->fetch_sub(value, std::memory_order_seq_cst); // Return old value.
}
+ T FetchAndOrSequentiallyConsistent(const T value) {
+ return this->fetch_or(value, std::memory_order_seq_cst); // Return old_value.
+ }
+
+ T FetchAndAndSequentiallyConsistent(const T value) {
+ return this->fetch_and(value, std::memory_order_seq_cst); // Return old_value.
+ }
+
volatile T* Address() {
return reinterpret_cast<T*>(this);
}
@@ -521,6 +529,30 @@ class PACKED(sizeof(T)) Atomic {
}
}
+ T FetchAndOrSequentiallyConsistent(const T value) {
+ if (sizeof(T) <= 4) {
+ return __sync_fetch_and_or(&value_, value); // Return old value.
+ } else {
+ T expected;
+ do {
+ expected = LoadRelaxed();
+ } while (!CompareExchangeWeakSequentiallyConsistent(expected, expected | value));
+ return expected;
+ }
+ }
+
+ T FetchAndAndSequentiallyConsistent(const T value) {
+ if (sizeof(T) <= 4) {
+ return __sync_fetch_and_and(&value_, value); // Return old value.
+ } else {
+ T expected;
+ do {
+ expected = LoadRelaxed();
+ } while (!CompareExchangeWeakSequentiallyConsistent(expected, expected & value));
+ return expected;
+ }
+ }
+
T operator++() { // Prefix operator.
if (sizeof(T) <= 4) {
return __sync_add_and_fetch(&value_, 1); // Return new value.