critical sections: remove unnecessary volatile

Critical section count/state variables are synchronised by IRQ disabling and
critical section calls themselves, so do not need to be volatile.

This eliminates a couple of unnecessary reads of the counter variable.
pull/9231/head
Kevin Bracey 2019-01-03 10:54:31 +02:00
parent 51b8d6e59d
commit 70af016348
2 changed files with 5 additions and 5 deletions

View File

@ -21,8 +21,8 @@
#include <stdbool.h>
static volatile bool critical_interrupts_enabled = false;
static volatile bool state_saved = false;
static bool critical_interrupts_enabled = false;
static bool state_saved = false;
static bool are_interrupts_enabled(void)
{

View File

@ -43,7 +43,7 @@
#endif
#endif
static volatile uint32_t critical_section_reentrancy_counter = 0;
static uint32_t critical_section_reentrancy_counter = 0;
bool core_util_are_interrupts_enabled(void)
{
@ -77,11 +77,11 @@ bool core_util_in_critical_section(void)
void core_util_critical_section_enter(void)
{
hal_critical_section_enter();
// If the reentrancy counter overflows something has gone badly wrong.
MBED_ASSERT(critical_section_reentrancy_counter < UINT32_MAX);
hal_critical_section_enter();
++critical_section_reentrancy_counter;
}