Fix Arm32 atomics
This commit is contained in:
committed by
Alexander Shabalin
parent
489c9ae11f
commit
64a0d492b9
@@ -770,7 +770,7 @@ clangNooptFlags.android_arm32 = -O1
|
|||||||
targetSysRoot.android_arm32 = target-sysroot-1-android_ndk
|
targetSysRoot.android_arm32 = target-sysroot-1-android_ndk
|
||||||
linkerKonanFlags.android_arm32 = -lm -lc++_static -lc++abi -landroid -llog -latomic
|
linkerKonanFlags.android_arm32 = -lm -lc++_static -lc++abi -landroid -llog -latomic
|
||||||
runtimeDefinitions.android_arm32 = __ANDROID__ USE_GCC_UNWIND=1 USE_ELF_SYMBOLS=1 ELFSIZE=32 \
|
runtimeDefinitions.android_arm32 = __ANDROID__ USE_GCC_UNWIND=1 USE_ELF_SYMBOLS=1 ELFSIZE=32 \
|
||||||
KONAN_ANDROID=1 KONAN_ARM32=1 KONAN_NO_UNALIGNED_ACCESS=1
|
KONAN_ANDROID=1 KONAN_ARM32=1 KONAN_NO_UNALIGNED_ACCESS=1 KONAN_NO_64BIT_ATOMIC=1
|
||||||
|
|
||||||
# Android ARM64, based on NDK.
|
# Android ARM64, based on NDK.
|
||||||
targetToolchain.macos_x64-android_arm64 = target-toolchain-2-osx-android_ndk
|
targetToolchain.macos_x64-android_arm64 = target-toolchain-2-osx-android_ndk
|
||||||
|
|||||||
@@ -92,14 +92,25 @@ KInt Kotlin_AtomicInt_get(KRef thiz) {
|
|||||||
return getImpl<KInt>(thiz);
|
return getImpl<KInt>(thiz);
|
||||||
}
|
}
|
||||||
|
|
||||||
KLong Kotlin_AtomicLong_addAndGet(KRef thiz, KLong delta) {
|
|
||||||
return addAndGetImpl(thiz, delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if KONAN_NO_64BIT_ATOMIC
|
#if KONAN_NO_64BIT_ATOMIC
|
||||||
static int lock64 = 0;
|
static int lock64 = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
KLong Kotlin_AtomicLong_addAndGet(KRef thiz, KLong delta) {
|
||||||
|
#if KONAN_NO_64BIT_ATOMIC
|
||||||
|
// Potentially huge performance penalty, but correct.
|
||||||
|
while (compareAndSwap(&lock64, 0, 1) != 0);
|
||||||
|
volatile KLong* address = getValueLocation<KLong>(thiz);
|
||||||
|
KLong old = *address;
|
||||||
|
KLong newValue = old + delta;
|
||||||
|
*address = newValue;
|
||||||
|
compareAndSwap(&lock64, 1, 0);
|
||||||
|
return newValue;
|
||||||
|
#else
|
||||||
|
return addAndGetImpl(thiz, delta);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
KLong Kotlin_AtomicLong_compareAndSwap(KRef thiz, KLong expectedValue, KLong newValue) {
|
KLong Kotlin_AtomicLong_compareAndSwap(KRef thiz, KLong expectedValue, KLong newValue) {
|
||||||
#if KONAN_NO_64BIT_ATOMIC
|
#if KONAN_NO_64BIT_ATOMIC
|
||||||
// Potentially huge performance penalty, but correct.
|
// Potentially huge performance penalty, but correct.
|
||||||
|
|||||||
Reference in New Issue
Block a user