Skip to content

Commit b37f24a

Browse files
committed
critical: fix set exclusive access if not yet defined
Fixes #5555 bug. In case there is not yet defined __EXCLUSIVE_ACCESS, neither MBED_EXCLUSIVE_ACCESS that we are introducing, use architecture macros to find out if MBED_EXCLUSIVE_ACCESS can be enabled.
1 parent 635a824 commit b37f24a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

platform/mbed_critical.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,21 @@
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 __EXCLUSIVE_ACCESS
29+
#ifndef MBED_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+
#else
37+
#define MBED_EXCLUSIVE_ACCESS 0U
38+
#endif
39+
#endif
40+
#endif
41+
2742
static volatile uint32_t critical_section_reentrancy_counter = 0;
2843

2944
bool core_util_are_interrupts_enabled(void)
@@ -90,7 +105,7 @@ void core_util_critical_section_exit(void)
90105
}
91106
}
92107

93-
#if __EXCLUSIVE_ACCESS
108+
#if MBED_EXCLUSIVE_ACCESS
94109

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

0 commit comments

Comments
 (0)