aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pw_sync_freertos/interrupt_spin_lock.cc12
-rw-r--r--pw_sync_freertos/public/pw_sync_freertos/interrupt_spin_lock_inline.h2
-rw-r--r--pw_sync_freertos/public/pw_sync_freertos/interrupt_spin_lock_native.h4
3 files changed, 8 insertions, 10 deletions
diff --git a/pw_sync_freertos/interrupt_spin_lock.cc b/pw_sync_freertos/interrupt_spin_lock.cc
index 656b05c60..825afc473 100644
--- a/pw_sync_freertos/interrupt_spin_lock.cc
+++ b/pw_sync_freertos/interrupt_spin_lock.cc
@@ -27,15 +27,15 @@ void InterruptSpinLock::lock() {
taskENTER_CRITICAL();
}
// We can't deadlock here so crash instead.
- PW_CHECK(!native_type_.locked.load(std::memory_order_relaxed),
+ PW_CHECK(!native_type_.locked,
"Recursive InterruptSpinLock::lock() detected");
- native_type_.locked.store(true, std::memory_order_relaxed);
+ native_type_.locked = true;
}
bool InterruptSpinLock::try_lock() {
if (interrupt::InInterruptContext()) {
UBaseType_t saved_interrupt_mask = taskENTER_CRITICAL_FROM_ISR();
- if (native_type_.locked.load(std::memory_order_relaxed)) {
+ if (native_type_.locked) {
// Already locked, restore interrupts and bail out.
taskEXIT_CRITICAL_FROM_ISR(saved_interrupt_mask);
return false;
@@ -43,18 +43,18 @@ bool InterruptSpinLock::try_lock() {
native_type_.saved_interrupt_mask = saved_interrupt_mask;
} else { // Task context
taskENTER_CRITICAL();
- if (native_type_.locked.load(std::memory_order_relaxed)) {
+ if (native_type_.locked) {
// ALready locked, restore interrupts and bail out.
taskEXIT_CRITICAL();
return false;
}
}
- native_type_.locked.store(true, std::memory_order_relaxed);
+ native_type_.locked = true;
return true;
}
void InterruptSpinLock::unlock() {
- native_type_.locked.store(false, std::memory_order_relaxed);
+ native_type_.locked = false;
if (interrupt::InInterruptContext()) {
taskEXIT_CRITICAL_FROM_ISR(native_type_.saved_interrupt_mask);
} else { // Task context
diff --git a/pw_sync_freertos/public/pw_sync_freertos/interrupt_spin_lock_inline.h b/pw_sync_freertos/public/pw_sync_freertos/interrupt_spin_lock_inline.h
index 8bbd4cfd8..f086d1549 100644
--- a/pw_sync_freertos/public/pw_sync_freertos/interrupt_spin_lock_inline.h
+++ b/pw_sync_freertos/public/pw_sync_freertos/interrupt_spin_lock_inline.h
@@ -18,7 +18,7 @@
namespace pw::sync {
constexpr InterruptSpinLock::InterruptSpinLock()
- : native_type_{.locked{false}, .saved_interrupt_mask = 0} {}
+ : native_type_{.locked = false, .saved_interrupt_mask = 0} {}
inline InterruptSpinLock::native_handle_type
InterruptSpinLock::native_handle() {
diff --git a/pw_sync_freertos/public/pw_sync_freertos/interrupt_spin_lock_native.h b/pw_sync_freertos/public/pw_sync_freertos/interrupt_spin_lock_native.h
index ac476dc8a..e7f0e8f09 100644
--- a/pw_sync_freertos/public/pw_sync_freertos/interrupt_spin_lock_native.h
+++ b/pw_sync_freertos/public/pw_sync_freertos/interrupt_spin_lock_native.h
@@ -13,14 +13,12 @@
// the License.
#pragma once
-#include <atomic>
-
#include "FreeRTOS.h"
namespace pw::sync::backend {
struct NativeInterruptSpinLock {
- std::atomic<bool> locked; // Used to detect recursion.
+ bool locked; // Used to detect recursion.
UBaseType_t saved_interrupt_mask;
};
using NativeInterruptSpinLockHandle = NativeInterruptSpinLock&;