Skip to content

Commit bb8ab66

Browse files
authored
Merge pull request #5597 from 0xc0170/fix_#5555
critical: fix set exclusive access if not yet defined
2 parents 635a824 + 4118542 commit bb8ab66

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

platform/mbed_critical.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@
2424
#include "platform/mbed_critical.h"
2525
#include "platform/mbed_toolchain.h"
2626

27+
// if __EXCLUSIVE_ACCESS rtx macro not defined, we need to get this via own-set architecture macros
28+
#ifndef MBED_EXCLUSIVE_ACCESS
29+
#ifndef __EXCLUSIVE_ACCESS
30+
#if ((__ARM_ARCH_7M__ == 1U) || \
31+
(__ARM_ARCH_7EM__ == 1U) || \
32+
(__ARM_ARCH_8M_BASE__ == 1U) || \
33+
(__ARM_ARCH_8M_MAIN__ == 1U)) || \
34+
(__ARM_ARCH_7A__ == 1U)
35+
#define MBED_EXCLUSIVE_ACCESS 1U
36+
#elif (__ARM_ARCH_6M__ == 1U)
37+
#define MBED_EXCLUSIVE_ACCESS 0U
38+
#else
39+
#error "Unknown architecture for exclusive access"
40+
#endif
41+
#else
42+
#define MBED_EXCLUSIVE_ACCESS __EXCLUSIVE_ACCESS
43+
#endif
44+
#endif
45+
2746
static volatile uint32_t critical_section_reentrancy_counter = 0;
2847

2948
bool core_util_are_interrupts_enabled(void)
@@ -90,7 +109,7 @@ void core_util_critical_section_exit(void)
90109
}
91110
}
92111

93-
#if __EXCLUSIVE_ACCESS
112+
#if MBED_EXCLUSIVE_ACCESS
94113

95114
/* Supress __ldrex and __strex deprecated warnings - "#3731-D: intrinsic is deprecated" */
96115
#if defined (__CC_ARM)

0 commit comments

Comments
 (0)