mirror of
https://github.com/corda/corda.git
synced 2025-01-06 05:04:20 +00:00
Merge pull request #138 from soc/topic/unsafe-compareAndSwap
Move Unsafe.compareAndSwapLong from classpath-openjdk.cpp to builtin.cpp
This commit is contained in:
commit
dae1f81d27
@ -73,6 +73,9 @@ public final class Unsafe {
|
||||
public native boolean compareAndSwapInt(Object o, long offset, int old,
|
||||
int new_);
|
||||
|
||||
public native boolean compareAndSwapLong(Object o, long offset,
|
||||
long old, long new_);
|
||||
|
||||
public native boolean compareAndSwapObject(Object o, long offset, Object old,
|
||||
Object new_);
|
||||
|
||||
|
@ -681,6 +681,29 @@ Avian_sun_misc_Unsafe_compareAndSwapInt
|
||||
(&fieldAtOffset<uint32_t>(target, offset), expect, update);
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
Avian_sun_misc_Unsafe_compareAndSwapLong
|
||||
(Thread* t UNUSED, object, uintptr_t* arguments)
|
||||
{
|
||||
object target = reinterpret_cast<object>(arguments[1]);
|
||||
int64_t offset; memcpy(&offset, arguments + 2, 8);
|
||||
uint64_t expect; memcpy(&expect, arguments + 4, 8);
|
||||
uint64_t update; memcpy(&update, arguments + 6, 8);
|
||||
|
||||
#ifdef AVIAN_HAS_CAS64
|
||||
return atomicCompareAndSwap64
|
||||
(&fieldAtOffset<uint64_t>(target, offset), expect, update);
|
||||
#else
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, local::fieldForOffset(t, target, offset));
|
||||
if (fieldAtOffset<uint64_t>(target, offset) == expect) {
|
||||
fieldAtOffset<uint64_t>(target, offset) = update;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT void JNICALL
|
||||
Avian_sun_misc_Unsafe_unpark
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
|
@ -2898,29 +2898,6 @@ Avian_sun_misc_Unsafe_putOrderedObject
|
||||
Avian_sun_misc_Unsafe_putObjectVolatile(t, method, arguments);
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
Avian_sun_misc_Unsafe_compareAndSwapLong
|
||||
(Thread* t UNUSED, object, uintptr_t* arguments)
|
||||
{
|
||||
object target = reinterpret_cast<object>(arguments[1]);
|
||||
int64_t offset; memcpy(&offset, arguments + 2, 8);
|
||||
uint64_t expect; memcpy(&expect, arguments + 4, 8);
|
||||
uint64_t update; memcpy(&update, arguments + 6, 8);
|
||||
|
||||
#ifdef AVIAN_HAS_CAS64
|
||||
return atomicCompareAndSwap64
|
||||
(&fieldAtOffset<uint64_t>(target, offset), expect, update);
|
||||
#else
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, local::fieldForOffset(t, target, offset));
|
||||
if (fieldAtOffset<uint64_t>(target, offset) == expect) {
|
||||
fieldAtOffset<uint64_t>(target, offset) = update;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" AVIAN_EXPORT int64_t JNICALL
|
||||
Avian_sun_misc_Unsafe_pageSize
|
||||
(Thread*, object, uintptr_t*)
|
||||
|
Loading…
Reference in New Issue
Block a user