Skip to content

ARMC5: fix mbed_atomic_impl.h assembly #10594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions platform/internal/mbed_atomic_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ extern "C" {
// inlining. ARM C 5 is being retired anyway.

#ifdef __CC_ARM
#pragma diag_suppress 3732
#define DO_MBED_LOCKFREE_EXCHG_ASM(M) \
__asm { \
LDREX##M oldValue, [valuePtr] \
LDREX##M oldValue, [valuePtr] ; \
STREX##M fail, newValue, [valuePtr] \
}
#elif defined __clang__ || defined __GNUC__
Expand Down Expand Up @@ -133,8 +134,8 @@ extern "C" {
#ifdef __CC_ARM
#define DO_MBED_LOCKFREE_3OP_ASM(OP, Constants, M) \
__asm { \
LDREX##M oldValue, [valuePtr] \
OP newValue, oldValue, arg \
LDREX##M oldValue, [valuePtr] ; \
OP newValue, oldValue, arg ; \
STREX##M fail, newValue, [valuePtr] \
}
#elif defined __clang__ || defined __GNUC__
Expand Down Expand Up @@ -172,9 +173,9 @@ extern "C" {
#ifdef __CC_ARM
#define DO_MBED_LOCKFREE_2OP_ASM(OP, Constants, M) \
__asm { \
LDREX##M oldValue, [valuePtr] \
MOV newValue, oldValue \
OP newValue, arg \
LDREX##M oldValue, [valuePtr] ; \
MOV newValue, oldValue ; \
OP newValue, arg ; \
STREX##M fail, newValue, [valuePtr] \
}
#elif defined __clang__ || defined __GNUC__
Expand Down Expand Up @@ -216,8 +217,8 @@ extern "C" {
#ifdef __CC_ARM
#define DO_MBED_LOCKFREE_CAS_WEAK_ASM(M) \
__asm { \
LDREX##M oldValue, [ptr] \
SUBS fail, oldValue, expectedValue \
LDREX##M oldValue, [ptr] ; \
SUBS fail, oldValue, expectedValue ; \
STREX##M##EQ fail, desiredValue, [ptr] \
}
#elif defined __clang__ || defined __GNUC__
Expand Down Expand Up @@ -251,10 +252,10 @@ extern "C" {
#ifdef __CC_ARM
#define DO_MBED_LOCKFREE_CAS_WEAK_ASM(M) \
__asm { \
LDREX##M oldValue, [ptr] \
SUBS fail, oldValue, expectedValue \
BNE done \
STREX##M fail, desiredValue, [ptr] \
LDREX##M oldValue, [ptr] ; \
SUBS fail, oldValue, expectedValue ; \
BNE done ; \
STREX##M fail, desiredValue, [ptr] ; \
done: \
}
#elif defined __clang__ || defined __GNUC__
Expand Down Expand Up @@ -298,13 +299,13 @@ done: \
#ifdef __CC_ARM
#define DO_MBED_LOCKFREE_CAS_STRONG_ASM(M) \
__asm { \
retry: \
LDREX##M oldValue, [ptr] \
SUBS fail, oldValue, expectedValue \
BNE done \
STREX##M fail, desiredValue, [ptr] \
CMP fail, #0 \
BNE retry \
retry: ; \
LDREX##M oldValue, [ptr] ; \
SUBS fail, oldValue, expectedValue ; \
BNE done ; \
STREX##M fail, desiredValue, [ptr] ; \
CMP fail, 0 ; \
BNE retry ; \
done: \
}
#elif defined __clang__ || defined __GNUC__
Expand Down