(int64_t*)addr) == 0;
}
-int64_t dvmQuasiAtomicSwap64(int64_t value, volatile int64_t* addr)
+
+static inline int64_t dvmQuasiAtomicSwap64Body(int64_t value,
+ volatile int64_t* addr)
{
int64_t oldValue;
do {
return oldValue;
}
+int64_t dvmQuasiAtomicSwap64(int64_t value, volatile int64_t* addr)
+{
+ return dvmQuasiAtomicSwap64Body(value, addr);
+}
+
+int64_t dvmQuasiAtomicSwap64Sync(int64_t value, volatile int64_t* addr)
+{
+ int64_t oldValue;
+ ANDROID_MEMBAR_STORE();
+ oldValue = dvmQuasiAtomicSwap64Body(value, addr);
+ /* TUNING: barriers can be avoided on some architectures */
+ ANDROID_MEMBAR_FULL();
+ return oldValue;
+}
+
int64_t dvmQuasiAtomicRead64(volatile const int64_t* addr)
{
return OSAtomicAdd64Barrier(0, addr);
#elif __arm__
#include <machine/cpu-features.h>
-#ifdef __ARM_HAVE_LDREXD
-int64_t dvmQuasiAtomicSwap64(int64_t newvalue, volatile int64_t* addr)
+// Clang can not process this assembly at the moment.
+#if defined(__ARM_HAVE_LDREXD) && !defined(__clang__)
+static inline int64_t dvmQuasiAtomicSwap64Body(int64_t newvalue,
+ volatile int64_t* addr)
{
int64_t prev;
int status;
return prev;
}
+int64_t dvmQuasiAtomicSwap64(int64_t newvalue, volatile int64_t* addr)
+{
+ return dvmQuasiAtomicSwap64Body(newvalue, addr);
+}
+
+int64_t dvmQuasiAtomicSwap64Sync(int64_t newvalue, volatile int64_t* addr)
+{
+ int64_t prev;
+ ANDROID_MEMBAR_STORE();
+ prev = dvmQuasiAtomicSwap64Body(newvalue, addr);
+ ANDROID_MEMBAR_FULL();
+ return prev;
+}
+
int dvmQuasiAtomicCas64(int64_t oldvalue, int64_t newvalue,
volatile int64_t* addr)
{
return oldValue;
}
+/* Same as dvmQuasiAtomicSwap64 - mutex handles barrier */
+int64_t dvmQuasiAtomicSwap64Sync(int64_t value, volatile int64_t* addr)
+{
+ return dvmQuasiAtomicSwap64(value, addr);
+}
+
int dvmQuasiAtomicCas64(int64_t oldvalue, int64_t newvalue,
volatile int64_t* addr)
{
return result;
}
+/* Same as dvmQuasiAtomicSwap64 - syscall handles barrier */
+int64_t dvmQuasiAtomicSwap64Sync(int64_t value, volatile int64_t* addr)
+{
+ return dvmQuasiAtomicSwap64(value, addr);
+}
+
#endif /*NEED_QUASIATOMICS*/