summaryrefslogtreecommitdiffstats
path: root/vm/Atomic.h
diff options
context:
space:
mode:
authorAndy McFadden <fadden@android.com>2010-06-14 15:24:39 -0700
committerAndy McFadden <fadden@android.com>2010-06-16 07:47:47 -0700
commit6e10b9aaa72425a4825a25f0043533d0c6fdbba4 (patch)
tree22c18a831ebc13b4f10f6a8aa5928e0b6fa4d382 /vm/Atomic.h
parentd62676d2403abf59b2822982147215eab2cd975b (diff)
downloadandroid_dalvik-6e10b9aaa72425a4825a25f0043533d0c6fdbba4.tar.gz
android_dalvik-6e10b9aaa72425a4825a25f0043533d0c6fdbba4.tar.bz2
android_dalvik-6e10b9aaa72425a4825a25f0043533d0c6fdbba4.zip
Atomic op cleanup.
Replaced VM-local macros for barrier and CAS calls with the actual versions provided by cutils. ATOMIC_CMP_SWAP(addr,old,new) --> android_atomic_release_cas(old,new,addr) MEM_BARRIER --> ANDROID_MEMBAR_FULL Renamed android_quasiatomic* to dvmQuasiAtomic*. Didn't change how anything works, just the names. Change-Id: I8c68f28e1f7c9cb832183e0918d097dfe6a2cac8
Diffstat (limited to 'vm/Atomic.h')
-rw-r--r--vm/Atomic.h42
1 files changed, 16 insertions, 26 deletions
diff --git a/vm/Atomic.h b/vm/Atomic.h
index 27a5ea081..0585c95cf 100644
--- a/vm/Atomic.h
+++ b/vm/Atomic.h
@@ -24,42 +24,32 @@
#include <cutils/atomic-inline.h> /* and some uncommon ones */
/*
- * Full memory barrier. Ensures compiler ordering and SMP behavior.
- */
-#define MEM_BARRIER() ANDROID_MEMBAR_FULL()
-
-/*
- * 32-bit atomic compare-and-swap macro. Performs a memory barrier
- * before the swap (store-release).
- *
- * If *_addr equals "_old", replace it with "_new" and return nonzero
- * (i.e. returns "false" if the operation fails).
- *
- * Underlying function is currently declared:
- * int release_cas(int32_t old, int32_t new, volatile int32_t* addr)
- *
- * TODO: rename macro to ATOMIC_RELEASE_CAS
- */
-#define ATOMIC_CMP_SWAP(_addr, _old, _new) \
- (android_atomic_release_cas((_old), (_new), (_addr)) == 0)
-
-
-/*
* NOTE: Two "quasiatomic" operations on the exact same memory address
* are guaranteed to operate atomically with respect to each other,
* but no guarantees are made about quasiatomic operations mixed with
* non-quasiatomic operations on the same address, nor about
* quasiatomic operations that are performed on partially-overlapping
* memory.
+ *
+ * None of these provide a memory barrier.
+ */
+
+/*
+ * Swap the 64-bit value at "addr" with "value". Returns the previous
+ * value.
+ */
+int64_t dvmQuasiAtomicSwap64(int64_t value, volatile int64_t* addr);
+
+/*
+ * Read the 64-bit value at "addr".
*/
+int64_t dvmQuasiAtomicRead64(volatile int64_t* addr);
/*
- * TODO: rename android_quasiatomic_* to dvmQuasiatomic*. Don't want to do
- * that yet due to branch merge issues.
+ * If the value at "addr" is equal to "oldvalue", replace it with "newvalue"
+ * and return 0. Otherwise, don't swap, and return nonzero.
*/
-int64_t android_quasiatomic_swap_64(int64_t value, volatile int64_t* addr);
-int64_t android_quasiatomic_read_64(volatile int64_t* addr);
-int android_quasiatomic_cmpxchg_64(int64_t oldvalue, int64_t newvalue,
+int dvmQuasiAtomicCas64(int64_t oldvalue, int64_t newvalue,
volatile int64_t* addr);
#endif /*_DALVIK_ATOMIC*/