mirror of
https://github.com/corda/corda.git
synced 2025-01-01 02:36:44 +00:00
fix Avian_sun_misc_Unsafe_compareAndSwapLong for platforms without atomicCompareAndSwap64
We never define atomicCompareAndSwap64 for ARM or PowerPC, and apparently only very recent ARM chips support it, so we must fall back to synchronization-based emulation.
This commit is contained in:
parent
49d19456d0
commit
d29513c653
5
makefile
5
makefile
@ -246,7 +246,8 @@ ifeq ($(arch),arm)
|
||||
ifeq ($(build-platform),darwin)
|
||||
ios = true
|
||||
else
|
||||
cflags += -marm -Wno-psabi
|
||||
no-psabi = -Wno-psabi
|
||||
cflags += -marm $(no-psabi)
|
||||
endif
|
||||
|
||||
ifneq ($(arch),$(build-arch))
|
||||
@ -586,6 +587,8 @@ endif
|
||||
cflags += $(extra-cflags)
|
||||
lflags += $(extra-lflags)
|
||||
|
||||
openjdk-cflags += $(extra-cflags)
|
||||
|
||||
driver-source = $(src)/main.cpp
|
||||
driver-object = $(build)/main.o
|
||||
driver-dynamic-objects = \
|
||||
|
@ -2594,15 +2594,25 @@ Avian_sun_misc_Unsafe_compareAndSwapObject
|
||||
|
||||
extern "C" JNIEXPORT int64_t JNICALL
|
||||
Avian_sun_misc_Unsafe_compareAndSwapLong
|
||||
(Thread*, object, uintptr_t* arguments)
|
||||
(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
|
||||
(&cast<uint64_t>(target, offset), expect, update);
|
||||
#else
|
||||
ACQUIRE_FIELD_FOR_WRITE(t, local::fieldForOffset(t, target, offset));
|
||||
if (cast<uint64_t>(target, offset) == expect) {
|
||||
cast<uint64_t>(target, offset) = update;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT int64_t JNICALL
|
||||
|
Loading…
Reference in New Issue
Block a user