diff --git a/makefile b/makefile index 89990514f0..218216f537 100755 --- a/makefile +++ b/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 = \ diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index ecbb86a0a0..2b12362a6c 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -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(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(target, offset), expect, update); +#else + ACQUIRE_FIELD_FOR_WRITE(t, local::fieldForOffset(t, target, offset)); + if (cast(target, offset) == expect) { + cast(target, offset) = update; + return true; + } else { + return false; + } +#endif } extern "C" JNIEXPORT int64_t JNICALL diff --git a/src/x86.h b/src/x86.h index 72570e03a8..72cc891ac1 100644 --- a/src/x86.h +++ b/src/x86.h @@ -255,6 +255,8 @@ atomicCompareAndSwap32(uint32_t* p, uint32_t old, uint32_t new_) #endif } +#define AVIAN_HAS_CAS64 + inline bool atomicCompareAndSwap64(uint64_t* p, uint64_t old, uint64_t new_) {