Skip to content

Commit 03f1ac3

Browse files
committed
Atomics: GCC fix for M23 (ARMv8-M baseline)
Add unified syntax directives to make the atomic assembler work when GCC is building for M23. GCC actually uses unified syntax when compiling C code, but puts `.syntax divided` before each piece of inline assembly when targetting Thumb-1 type devices like M0 and M23 for backwards compatibility. We can overcome this with our own `.syntax unified`. The command-line option `-masm-syntax-unified` intended to override this globally has been broken from GCC 6 to 8.0.
1 parent 9cc1caa commit 03f1ac3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

platform/internal/mbed_atomic_impl.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/*
32
* Copyright (c) 2015-2016, ARM Limited, All Rights Reserved
43
* SPDX-License-Identifier: Apache-2.0
@@ -109,6 +108,7 @@ extern "C" {
109108
#elif defined __clang__ || defined __GNUC__
110109
#define DO_MBED_LOCKFREE_EXCHG_ASM(M) \
111110
__asm volatile ( \
111+
".syntax unified\n\t" \
112112
"LDREX"#M "\t%[oldValue], %[value]\n\t" \
113113
"STREX"#M "\t%[fail], %[newValue], %[value]\n\t" \
114114
: [oldValue] "=&r" (oldValue), \
@@ -141,6 +141,7 @@ extern "C" {
141141
#elif defined __clang__ || defined __GNUC__
142142
#define DO_MBED_LOCKFREE_3OP_ASM(OP, Constants, M) \
143143
__asm volatile ( \
144+
".syntax unified\n\t" \
144145
"LDREX"#M "\t%[oldValue], %[value]\n\t" \
145146
#OP "\t%[newValue], %[oldValue], %[arg]\n\t" \
146147
"STREX"#M "\t%[fail], %[newValue], %[value]\n\t" \
@@ -181,6 +182,7 @@ extern "C" {
181182
#elif defined __clang__ || defined __GNUC__
182183
#define DO_MBED_LOCKFREE_2OP_ASM(OP, Constants, M) \
183184
__asm volatile ( \
185+
".syntax unified\n\t" \
184186
"LDREX"#M "\t%[oldValue], %[value]\n\t" \
185187
"MOV" "\t%[newValue], %[oldValue]\n\t" \
186188
#OP "\t%[newValue], %[arg]\n\t" \
@@ -224,6 +226,7 @@ extern "C" {
224226
#elif defined __clang__ || defined __GNUC__
225227
#define DO_MBED_LOCKFREE_CAS_WEAK_ASM(M) \
226228
__asm volatile ( \
229+
".syntax unified\n\t" \
227230
"LDREX"#M "\t%[oldValue], %[value]\n\t" \
228231
"SUBS" "\t%[fail], %[oldValue], %[expectedValue]\n\t"\
229232
"STREX"#M"EQ\t%[fail], %[desiredValue], %[value]\n\t" \
@@ -261,6 +264,7 @@ done: \
261264
#elif defined __clang__ || defined __GNUC__
262265
#define DO_MBED_LOCKFREE_CAS_WEAK_ASM(M) \
263266
__asm volatile ( \
267+
".syntax unified\n\t" \
264268
"LDREX"#M "\t%[oldValue], %[value]\n\t" \
265269
"SUBS" "\t%[fail], %[oldValue], %[expectedValue]\n\t"\
266270
"BNE" "\t%=f\n\t" \
@@ -311,6 +315,7 @@ done: \
311315
#elif defined __clang__ || defined __GNUC__
312316
#define DO_MBED_LOCKFREE_CAS_STRONG_ASM(M) \
313317
__asm volatile ( \
318+
".syntax unified\n\t" \
314319
"\n%=:\n\t" \
315320
"LDREX"#M "\t%[oldValue], %[value]\n\t" \
316321
"SUBS" "\t%[fail], %[oldValue], %[expectedValue]\n\t"\

0 commit comments

Comments
 (0)