pw_sync: rename SpinLock -> InterruptSpinLock
Renames the existing pw::sync::SpinLock to InterruptSpinLock to
make it obvious that this is not just a spin lock and that interrupt
masking is included.
This change leaves C++ & GN redirects in place in order to support
migrating Pigweed and customers in follow up changes.
Change-Id: If9fb5594e7d71778b15cd15a9cd7ec71ca0e403b
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/37560
Commit-Queue: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
diff --git a/pw_sync/BUILD b/pw_sync/BUILD
index 18d1962..7151178 100644
--- a/pw_sync/BUILD
+++ b/pw_sync/BUILD
@@ -26,7 +26,7 @@
PW_SYNC_BINARY_SEMAPHORE_BACKEND = "//pw_sync_stl:binary_semaphore"
PW_SYNC_COUNTING_SEMAPHORE_BACKEND = "//pw_sync_stl:counting_semaphore"
PW_SYNC_MUTEX_BACKEND = "//pw_sync_stl:mutex"
-PW_SYNC_SPIN_LOCK_BACKEND = "//pw_sync_stl:spin_lock"
+PW_SYNC_INTERRUPT_SPIN_LOCK_BACKEND = "//pw_sync_stl:interrupt_spin_lock"
pw_cc_library(
name = "binary_semaphore_facade",
@@ -122,32 +122,33 @@
)
pw_cc_library(
- name = "spin_lock_facade",
+ name = "interrupt_spin_lock_facade",
hdrs = [
"public/pw_sync/spin_lock.h",
+ "public/pw_sync/interrupt_spin_lock.h",
],
includes = ["public"],
srcs = [
- "spin_lock.cc"
+ "interrupt_spin_lock.cc"
],
deps = [
- PW_SYNC_SPIN_LOCK_BACKEND + "_headers",
+ PW_SYNC_INTERRUPT_SPIN_LOCK_BACKEND + "_headers",
"//pw_preprocessor",
],
)
pw_cc_library(
- name = "spin_lock",
+ name = "interrupt_spin_lock",
deps = [
- ":spin_lock_facade",
- PW_SYNC_SPIN_LOCK_BACKEND + "_headers",
+ ":interrupt_spin_lock_facade",
+ PW_SYNC_INTERRUPT_SPIN_LOCK_BACKEND + "_headers",
],
)
pw_cc_library(
- name = "spin_lock_backend",
+ name = "interrupt_spin_lock_backend",
deps = [
- PW_SYNC_SPIN_LOCK_BACKEND,
+ PW_SYNC_INTERRUPT_SPIN_LOCK_BACKEND,
],
)
@@ -199,13 +200,13 @@
)
pw_cc_test(
- name = "spin_lock_facade_test",
+ name = "interrupt_spin_lock_facade_test",
srcs = [
- "spin_lock_facade_test.cc",
- "spin_lock_facade_test_c.c",
+ "interrupt_spin_lock_facade_test.cc",
+ "interrupt_spin_lock_facade_test_c.c",
],
deps = [
- ":spin_lock",
+ ":interrupt_spin_lock",
"//pw_preprocessor",
"//pw_unit_test",
],
diff --git a/pw_sync/BUILD.gn b/pw_sync/BUILD.gn
index 615c3db..583f6ea 100644
--- a/pw_sync/BUILD.gn
+++ b/pw_sync/BUILD.gn
@@ -58,12 +58,24 @@
sources = [ "mutex.cc" ]
}
-pw_facade("spin_lock") {
- backend = pw_sync_SPIN_LOCK_BACKEND
- public_configs = [ ":public_include_path" ]
+# TODO(ewout): Finish the migration and remove this logic.
+if (pw_sync_SPIN_LOCK_BACKEND != "") {
+ assert(pw_sync_INTERRUPT_SPIN_LOCK_BACKEND == "",
+ "You cannot define the backend for pw::sync::InterruptSpinLock twice!")
+ pw_sync_INTERRUPT_SPIN_LOCK_BACKEND = pw_sync_SPIN_LOCK_BACKEND
+}
+
+pw_source_set("spin_lock") {
+ public_deps = [ ":interrupt_spin_lock" ]
public = [ "public/pw_sync/spin_lock.h" ]
+}
+
+pw_facade("interrupt_spin_lock") {
+ backend = pw_sync_INTERRUPT_SPIN_LOCK_BACKEND
+ public_configs = [ ":public_include_path" ]
+ public = [ "public/pw_sync/interrupt_spin_lock.h" ]
public_deps = [ "$dir_pw_preprocessor" ]
- sources = [ "spin_lock.cc" ]
+ sources = [ "interrupt_spin_lock.cc" ]
}
pw_source_set("yield_core") {
@@ -76,7 +88,7 @@
":binary_semaphore_facade_test",
":counting_semaphore_facade_test",
":mutex_facade_test",
- ":spin_lock_facade_test",
+ ":interrupt_spin_lock_facade_test",
]
}
@@ -119,16 +131,16 @@
]
}
-pw_test("spin_lock_facade_test") {
- enable_if = pw_sync_SPIN_LOCK_BACKEND != ""
+pw_test("interrupt_spin_lock_facade_test") {
+ enable_if = pw_sync_INTERRUPT_SPIN_LOCK_BACKEND != ""
sources = [
- "spin_lock_facade_test.cc",
- "spin_lock_facade_test_c.c",
+ "interrupt_spin_lock_facade_test.cc",
+ "interrupt_spin_lock_facade_test_c.c",
]
deps = [
- ":spin_lock",
+ ":interrupt_spin_lock",
"$dir_pw_preprocessor",
- pw_sync_SPIN_LOCK_BACKEND,
+ pw_sync_INTERRUPT_SPIN_LOCK_BACKEND,
]
}
diff --git a/pw_sync/backend.gni b/pw_sync/backend.gni
index 59d8b48..ba8e6b0 100644
--- a/pw_sync/backend.gni
+++ b/pw_sync/backend.gni
@@ -22,7 +22,10 @@
# Backend for the pw_sync module's mutex.
pw_sync_MUTEX_BACKEND = ""
- # Backend for the pw_sync module's spin lock.
+ # Backend for the pw_sync module's interrupt spin lock.
+ pw_sync_INTERRUPT_SPIN_LOCK_BACKEND = ""
+
+ # TODO(ewout): migrate all users to pw_sync_INTERRUPT_SPIN_LOCK_BACKEND.
pw_sync_SPIN_LOCK_BACKEND = ""
# Whether the GN asserts should be silenced in ensuring that a compatible
diff --git a/pw_sync/interrupt_spin_lock.cc b/pw_sync/interrupt_spin_lock.cc
new file mode 100644
index 0000000..9a8ec6a
--- /dev/null
+++ b/pw_sync/interrupt_spin_lock.cc
@@ -0,0 +1,30 @@
+// Copyright 2020 The Pigweed Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+#include "pw_sync/interrupt_spin_lock.h"
+
+extern "C" void pw_sync_InterruptSpinLock_Lock(
+ pw_sync_InterruptSpinLock* interrupt_spin_lock) {
+ interrupt_spin_lock->lock();
+}
+
+extern "C" bool pw_sync_InterruptSpinLock_TryLock(
+ pw_sync_InterruptSpinLock* interrupt_spin_lock) {
+ return interrupt_spin_lock->try_lock();
+}
+
+extern "C" void pw_sync_InterruptSpinLock_Unlock(
+ pw_sync_InterruptSpinLock* interrupt_spin_lock) {
+ interrupt_spin_lock->unlock();
+}
diff --git a/pw_sync/interrupt_spin_lock_facade_test.cc b/pw_sync/interrupt_spin_lock_facade_test.cc
new file mode 100644
index 0000000..372623a
--- /dev/null
+++ b/pw_sync/interrupt_spin_lock_facade_test.cc
@@ -0,0 +1,73 @@
+// Copyright 2020 The Pigweed Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+#include "gtest/gtest.h"
+#include "pw_sync/interrupt_spin_lock.h"
+
+namespace pw::sync {
+namespace {
+
+extern "C" {
+
+// Functions defined in interrupt_spin_lock_facade_test_c.c which call the API
+// from C.
+void pw_sync_InterruptSpinLock_CallLock(
+ pw_sync_InterruptSpinLock* interrupt_spin_lock);
+bool pw_sync_InterruptSpinLock_CallTryLock(
+ pw_sync_InterruptSpinLock* interrupt_spin_lock);
+void pw_sync_InterruptSpinLock_CallUnlock(
+ pw_sync_InterruptSpinLock* interrupt_spin_lock);
+
+} // extern "C"
+
+TEST(InterruptSpinLock, LockUnlock) {
+ pw::sync::InterruptSpinLock interrupt_spin_lock;
+ interrupt_spin_lock.lock();
+ interrupt_spin_lock.unlock();
+}
+
+// TODO(pwbug/291): Add real concurrency tests once we have pw::thread.
+
+InterruptSpinLock static_interrupt_spin_lock;
+TEST(InterruptSpinLock, LockUnlockStatic) {
+ static_interrupt_spin_lock.lock();
+ // Ensure it fails to lock when already held.
+ EXPECT_FALSE(static_interrupt_spin_lock.try_lock());
+ static_interrupt_spin_lock.unlock();
+}
+
+TEST(InterruptSpinLock, TryLockUnlock) {
+ pw::sync::InterruptSpinLock interrupt_spin_lock;
+ ASSERT_TRUE(interrupt_spin_lock.try_lock());
+ // Ensure it fails to lock when already held.
+ EXPECT_FALSE(interrupt_spin_lock.try_lock());
+ interrupt_spin_lock.unlock();
+}
+
+TEST(InterruptSpinLock, LockUnlockInC) {
+ pw::sync::InterruptSpinLock interrupt_spin_lock;
+ pw_sync_InterruptSpinLock_CallLock(&interrupt_spin_lock);
+ pw_sync_InterruptSpinLock_CallUnlock(&interrupt_spin_lock);
+}
+
+TEST(InterruptSpinLock, TryLockUnlockInC) {
+ pw::sync::InterruptSpinLock interrupt_spin_lock;
+ ASSERT_TRUE(pw_sync_InterruptSpinLock_CallTryLock(&interrupt_spin_lock));
+ // Ensure it fails to lock when already held.
+ EXPECT_FALSE(pw_sync_InterruptSpinLock_CallTryLock(&interrupt_spin_lock));
+ pw_sync_InterruptSpinLock_CallUnlock(&interrupt_spin_lock);
+}
+
+} // namespace
+} // namespace pw::sync
diff --git a/pw_sync/interrupt_spin_lock_facade_test_c.c b/pw_sync/interrupt_spin_lock_facade_test_c.c
new file mode 100644
index 0000000..3cdbe2a
--- /dev/null
+++ b/pw_sync/interrupt_spin_lock_facade_test_c.c
@@ -0,0 +1,35 @@
+// Copyright 2020 The Pigweed Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+
+// These tests call the pw_sync module interrupt_spin_lock API from C. The
+// return values are checked in the main C++ tests.
+
+#include <stdbool.h>
+
+#include "pw_sync/interrupt_spin_lock.h"
+
+void pw_sync_InterruptSpinLock_CallLock(
+ pw_sync_InterruptSpinLock* interrupt_spin_lock) {
+ pw_sync_InterruptSpinLock_Lock(interrupt_spin_lock);
+}
+
+bool pw_sync_InterruptSpinLock_CallTryLock(
+ pw_sync_InterruptSpinLock* interrupt_spin_lock) {
+ return pw_sync_InterruptSpinLock_TryLock(interrupt_spin_lock);
+}
+
+void pw_sync_InterruptSpinLock_CallUnlock(
+ pw_sync_InterruptSpinLock* interrupt_spin_lock) {
+ pw_sync_InterruptSpinLock_Unlock(interrupt_spin_lock);
+}
diff --git a/pw_sync/public/pw_sync/interrupt_spin_lock.h b/pw_sync/public/pw_sync/interrupt_spin_lock.h
new file mode 100644
index 0000000..e42f60e
--- /dev/null
+++ b/pw_sync/public/pw_sync/interrupt_spin_lock.h
@@ -0,0 +1,91 @@
+// Copyright 2020 The Pigweed Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy of
+// the License at
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations under
+// the License.
+#pragma once
+
+#include <stdbool.h>
+
+#include "pw_preprocessor/util.h"
+
+#ifdef __cplusplus
+
+#include "pw_sync_backend/interrupt_spin_lock_native.h"
+
+namespace pw::sync {
+
+// The InterruptSpinLock is a synchronization primitive that can be used to
+// protect shared data from being simultaneously accessed by multiple threads
+// and/or interrupts as a targeted global lock (except for NMIs).
+// It offers exclusive, non-recursive ownership semantics where IRQs up to a
+// backend defined level of "NMIs" will be masked to solve priority-inversion.
+//
+// NOTE: This InterruptSpinLock relies on built-in local interrupt masking to
+// make it interrupt safe without requiring the caller to separately mask and
+// unmask interrupts when using this primitive.
+//
+// Unlike global interrupt locks, this also works safely and efficiently on SMP
+// systems. This entire API is IRQ safe.
+//
+// Precondition: Code that holds a specific InterruptSpinLock must not try to
+// re-acquire it. However, it is okay to nest distinct spinlocks.
+class InterruptSpinLock {
+ public:
+ using native_handle_type = backend::NativeInterruptSpinLockHandle;
+
+ constexpr InterruptSpinLock();
+ ~InterruptSpinLock() = default;
+ InterruptSpinLock(const InterruptSpinLock&) = delete;
+ InterruptSpinLock(InterruptSpinLock&&) = delete;
+ InterruptSpinLock& operator=(const InterruptSpinLock&) = delete;
+ InterruptSpinLock& operator=(InterruptSpinLock&&) = delete;
+
+ // Locks the spinlock, blocking indefinitely. Failures are fatal.
+ //
+ // Precondition: Recursive locking is undefined behavior.
+ void lock();
+
+ // Attempts to lock the spinlock in a non-blocking manner.
+ // Returns true if the spinlock was successfully acquired.
+ //
+ // Precondition: Recursive locking is undefined behavior.
+ bool try_lock();
+
+ // Unlocks the spinlock. Failures are fatal.
+ void unlock();
+
+ native_handle_type native_handle();
+
+ private:
+ // This may be a wrapper around a native type with additional members.
+ backend::NativeInterruptSpinLock native_type_;
+};
+
+} // namespace pw::sync
+
+#include "pw_sync_backend/interrupt_spin_lock_inline.h"
+
+using pw_sync_InterruptSpinLock = pw::sync::InterruptSpinLock;
+
+#else // !defined(__cplusplus)
+
+typedef struct pw_sync_InterruptSpinLock pw_sync_InterruptSpinLock;
+
+#endif // __cplusplus
+
+PW_EXTERN_C_START
+
+void pw_sync_InterruptSpinLock_Lock(pw_sync_InterruptSpinLock* spin_lock);
+bool pw_sync_InterruptSpinLock_TryLock(pw_sync_InterruptSpinLock* spin_lock);
+void pw_sync_InterruptSpinLock_Unlock(pw_sync_InterruptSpinLock* spin_lock);
+
+PW_EXTERN_C_END
diff --git a/pw_sync/public/pw_sync/spin_lock.h b/pw_sync/public/pw_sync/spin_lock.h
index a59879b..415837d 100644
--- a/pw_sync/public/pw_sync/spin_lock.h
+++ b/pw_sync/public/pw_sync/spin_lock.h
@@ -1,4 +1,4 @@
-// Copyright 2020 The Pigweed Authors
+// Copyright 2021 The Pigweed Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
@@ -13,81 +13,14 @@
// the License.
#pragma once
-#include <stdbool.h>
-
-#include "pw_preprocessor/util.h"
+#include "pw_sync/interrupt_spin_lock.h"
#ifdef __cplusplus
-#include "pw_sync_backend/spin_lock_native.h"
-
namespace pw::sync {
-// The SpinLock is a synchronization primitive that can be used to protect
-// shared data from being simultaneously accessed by multiple threads and/or
-// IRQs as a targeted global lock (except for NMIs).
-// It offers exclusive, non-recursive ownership semantics where IRQs up to a
-// backend defined level of "NMIs" will be masked to solve priority-inversion.
-//
-// NOTE: This SpinLock relies on built-in local interrupt masking to make it IRQ
-// safe without requiring the caller to mask interrupts manually when using this
-// primitive.
-//
-// Unlike global interrupt locks, this also works safely and efficiently on SMP
-// systems. This entire API is IRQ safe.
-//
-// WARNING: Code that holds a specific SpinLock must not try to re-acquire it
-// or it will deadlock. However, it is okay to nest distinct spinlocks.
-//
-// WARNING: In order to support global statically constructed SpinLocks, the
-// backend MUST ensure that any initialization required in your environment
-// prior to the creation and/or initialization of the native semaphore
-// (e.g. kernel initialization), is done before or during the invocation of the
-// global static C++ constructors.
-class SpinLock {
- public:
- using native_handle_type = backend::NativeSpinLockHandle;
-
- constexpr SpinLock();
- ~SpinLock() = default;
- SpinLock(const SpinLock&) = delete;
- SpinLock(SpinLock&&) = delete;
- SpinLock& operator=(const SpinLock&) = delete;
- SpinLock& operator=(SpinLock&&) = delete;
-
- // Locks the spinlock, blocking indefinitely. Failures are fatal.
- void lock();
-
- // Attempts to lock the spinlock in a non-blocking manner.
- // Returns true if the spinlock was successfully acquired.
- bool try_lock();
-
- // Unlocks the spinlock. Failures are fatal.
- void unlock();
-
- native_handle_type native_handle();
-
- private:
- // This may be a wrapper around a native type with additional members.
- backend::NativeSpinLock native_type_;
-};
+using SpinLock = InterruptSpinLock;
} // namespace pw::sync
-#include "pw_sync_backend/spin_lock_inline.h"
-
-using pw_sync_SpinLock = pw::sync::SpinLock;
-
-#else // !defined(__cplusplus)
-
-typedef struct pw_sync_SpinLock pw_sync_SpinLock;
-
#endif // __cplusplus
-
-PW_EXTERN_C_START
-
-void pw_sync_SpinLock_Lock(pw_sync_SpinLock* spin_lock);
-bool pw_sync_SpinLock_TryLock(pw_sync_SpinLock* spin_lock);
-void pw_sync_SpinLock_Unlock(pw_sync_SpinLock* spin_lock);
-
-PW_EXTERN_C_END
diff --git a/pw_sync/spin_lock.cc b/pw_sync/spin_lock.cc
deleted file mode 100644
index 86de70b..0000000
--- a/pw_sync/spin_lock.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2020 The Pigweed Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-#include "pw_sync/spin_lock.h"
-
-extern "C" void pw_sync_SpinLock_Lock(pw_sync_SpinLock* spin_lock) {
- spin_lock->lock();
-}
-
-extern "C" bool pw_sync_SpinLock_TryLock(pw_sync_SpinLock* spin_lock) {
- return spin_lock->try_lock();
-}
-
-extern "C" void pw_sync_SpinLock_Unlock(pw_sync_SpinLock* spin_lock) {
- spin_lock->unlock();
-}
diff --git a/pw_sync/spin_lock_facade_test.cc b/pw_sync/spin_lock_facade_test.cc
deleted file mode 100644
index a373e79..0000000
--- a/pw_sync/spin_lock_facade_test.cc
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2020 The Pigweed Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-#include "gtest/gtest.h"
-#include "pw_sync/spin_lock.h"
-
-namespace pw::sync {
-namespace {
-
-extern "C" {
-
-// Functions defined in spin_lock_facade_test_c.c which call the API from C.
-void pw_sync_SpinLock_CallLock(pw_sync_SpinLock* spin_lock);
-bool pw_sync_SpinLock_CallTryLock(pw_sync_SpinLock* spin_lock);
-void pw_sync_SpinLock_CallUnlock(pw_sync_SpinLock* spin_lock);
-
-} // extern "C"
-
-TEST(SpinLock, LockUnlock) {
- pw::sync::SpinLock spin_lock;
- spin_lock.lock();
- spin_lock.unlock();
-}
-
-// TODO(pwbug/291): Add real concurrency tests once we have pw::thread.
-
-SpinLock static_spin_lock;
-TEST(SpinLock, LockUnlockStatic) {
- static_spin_lock.lock();
- // Ensure it fails to lock when already held.
- EXPECT_FALSE(static_spin_lock.try_lock());
- static_spin_lock.unlock();
-}
-
-TEST(SpinLock, TryLockUnlock) {
- pw::sync::SpinLock spin_lock;
- ASSERT_TRUE(spin_lock.try_lock());
- // Ensure it fails to lock when already held.
- EXPECT_FALSE(spin_lock.try_lock());
- spin_lock.unlock();
-}
-
-TEST(SpinLock, LockUnlockInC) {
- pw::sync::SpinLock spin_lock;
- pw_sync_SpinLock_CallLock(&spin_lock);
- pw_sync_SpinLock_CallUnlock(&spin_lock);
-}
-
-TEST(SpinLock, TryLockUnlockInC) {
- pw::sync::SpinLock spin_lock;
- ASSERT_TRUE(pw_sync_SpinLock_CallTryLock(&spin_lock));
- // Ensure it fails to lock when already held.
- EXPECT_FALSE(pw_sync_SpinLock_CallTryLock(&spin_lock));
- pw_sync_SpinLock_CallUnlock(&spin_lock);
-}
-
-} // namespace
-} // namespace pw::sync
diff --git a/pw_sync/spin_lock_facade_test_c.c b/pw_sync/spin_lock_facade_test_c.c
deleted file mode 100644
index 17d0fd04..0000000
--- a/pw_sync/spin_lock_facade_test_c.c
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2020 The Pigweed Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-// These tests call the pw_sync module spin_lock API from C. The return values
-// are checked in the main C++ tests.
-
-#include <stdbool.h>
-
-#include "pw_sync/spin_lock.h"
-
-void pw_sync_SpinLock_CallLock(pw_sync_SpinLock* spin_lock) {
- pw_sync_SpinLock_Lock(spin_lock);
-}
-
-bool pw_sync_SpinLock_CallTryLock(pw_sync_SpinLock* spin_lock) {
- return pw_sync_SpinLock_TryLock(spin_lock);
-}
-
-void pw_sync_SpinLock_CallUnlock(pw_sync_SpinLock* spin_lock) {
- pw_sync_SpinLock_Unlock(spin_lock);
-}
diff --git a/pw_sync_baremetal/BUILD b/pw_sync_baremetal/BUILD
index aa7c5c4..16774df 100644
--- a/pw_sync_baremetal/BUILD
+++ b/pw_sync_baremetal/BUILD
@@ -22,12 +22,12 @@
licenses(["notice"]) # Apache License 2.0
pw_cc_library(
- name = "spin_lock_headers",
+ name = "interrupt_spin_lock_headers",
hdrs = [
- "public/pw_sync_baremetal/spin_lock_inline.h",
- "public/pw_sync_baremetal/spin_lock_native.h",
- "public_overrides/pw_sync_backend/spin_lock_inline.h",
- "public_overrides/pw_sync_backend/spin_lock_native.h",
+ "public/pw_sync_baremetal/interrupt_spin_lock_inline.h",
+ "public/pw_sync_baremetal/interrupt_spin_lock_native.h",
+ "public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h",
+ "public_overrides/pw_sync_backend/interrupt_spin_lock_native.h",
],
includes = [
"public",
@@ -36,11 +36,11 @@
)
pw_cc_library(
- name = "spin_lock",
+ name = "interrupt_spin_lock",
deps = [
- ":spin_lock_headers",
+ ":interrupt_spin_lock_headers",
"//pw_assert",
- "//pw_sync:spin_lock_facade",
+ "//pw_sync:interrupt_spin_lock_facade",
"//pw_sync:yield_core",
],
)
diff --git a/pw_sync_baremetal/BUILD.gn b/pw_sync_baremetal/BUILD.gn
index fd4fff5..fd99f4a 100644
--- a/pw_sync_baremetal/BUILD.gn
+++ b/pw_sync_baremetal/BUILD.gn
@@ -28,25 +28,29 @@
visibility = [ ":*" ]
}
-# This target provides the backend for pw::sync::SpinLock.
-# The provided implementation makes a single attempt to acquire the lock and asserts
-# if it is unavailable. It does not perform interrupt masking or disable global
-# interrupts, so this implementation does not support simultaneous multi-threaded
-# environments including IRQs, and is only meant to prevent data corruption.
-pw_source_set("spin_lock_backend") {
+# This target provides the backend for pw::sync::InterruptSpinLock.
+# The provided implementation makes a single attempt to acquire the lock and
+# asserts if it is unavailable. It does not perform interrupt masking or disable
+# global interrupts, so this implementation does not support simultaneous
+# multi-threaded environments including IRQs, and is only meant to prevent
+# data corruption.
+pw_source_set("spin_lock") {
+ public_deps = [ ":interrupt_spin_lock" ]
+}
+pw_source_set("interrupt_spin_lock") {
public_configs = [
":public_include_path",
":backend_config",
]
public = [
- "public/pw_sync_baremetal/spin_lock_inline.h",
- "public/pw_sync_baremetal/spin_lock_native.h",
- "public_overrides/pw_sync_backend/spin_lock_inline.h",
- "public_overrides/pw_sync_backend/spin_lock_native.h",
+ "public/pw_sync_baremetal/interrupt_spin_lock_inline.h",
+ "public/pw_sync_baremetal/interrupt_spin_lock_native.h",
+ "public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h",
+ "public_overrides/pw_sync_backend/interrupt_spin_lock_native.h",
]
public_deps = [
"$dir_pw_assert",
- "$dir_pw_sync:spin_lock.facade",
+ "$dir_pw_sync:interrupt_spin_lock.facade",
"$dir_pw_sync:yield_core",
]
}
diff --git a/pw_sync_baremetal/public/pw_sync_baremetal/spin_lock_inline.h b/pw_sync_baremetal/public/pw_sync_baremetal/interrupt_spin_lock_inline.h
similarity index 73%
rename from pw_sync_baremetal/public/pw_sync_baremetal/spin_lock_inline.h
rename to pw_sync_baremetal/public/pw_sync_baremetal/interrupt_spin_lock_inline.h
index 3ed9562..369c956 100644
--- a/pw_sync_baremetal/public/pw_sync_baremetal/spin_lock_inline.h
+++ b/pw_sync_baremetal/public/pw_sync_baremetal/interrupt_spin_lock_inline.h
@@ -14,25 +14,26 @@
#pragma once
#include "pw_assert/light.h"
-#include "pw_sync/spin_lock.h"
+#include "pw_sync/interrupt_spin_lock.h"
#include "pw_sync/yield_core.h"
namespace pw::sync {
-constexpr SpinLock::SpinLock() : native_type_() {}
+constexpr InterruptSpinLock::InterruptSpinLock() : native_type_() {}
-inline void SpinLock::lock() { PW_ASSERT(try_lock()); }
+inline void InterruptSpinLock::lock() { PW_ASSERT(try_lock()); }
-inline bool SpinLock::try_lock() {
+inline bool InterruptSpinLock::try_lock() {
// TODO(pwbug/303): Use the pw_interrupt API here to disable interrupts.
return !native_type_.test_and_set(std::memory_order_acquire);
}
-inline void SpinLock::unlock() {
+inline void InterruptSpinLock::unlock() {
native_type_.clear(std::memory_order_release);
}
-inline SpinLock::native_handle_type SpinLock::native_handle() {
+inline InterruptSpinLock::native_handle_type
+InterruptSpinLock::native_handle() {
return native_type_;
}
diff --git a/pw_sync_baremetal/public/pw_sync_baremetal/spin_lock_native.h b/pw_sync_baremetal/public/pw_sync_baremetal/interrupt_spin_lock_native.h
similarity index 86%
rename from pw_sync_baremetal/public/pw_sync_baremetal/spin_lock_native.h
rename to pw_sync_baremetal/public/pw_sync_baremetal/interrupt_spin_lock_native.h
index 6bb6abd..1e23501 100644
--- a/pw_sync_baremetal/public/pw_sync_baremetal/spin_lock_native.h
+++ b/pw_sync_baremetal/public/pw_sync_baremetal/interrupt_spin_lock_native.h
@@ -17,7 +17,7 @@
namespace pw::sync::backend {
-using NativeSpinLock = std::atomic_flag;
-using NativeSpinLockHandle = std::atomic_flag&;
+using NativeInterruptSpinLock = std::atomic_flag;
+using NativeInterruptSpinLockHandle = std::atomic_flag&;
} // namespace pw::sync::backend
diff --git a/pw_sync_baremetal/public_overrides/pw_sync_backend/spin_lock_inline.h b/pw_sync_baremetal/public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h
similarity index 91%
rename from pw_sync_baremetal/public_overrides/pw_sync_backend/spin_lock_inline.h
rename to pw_sync_baremetal/public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h
index 65a64b0..bd40b93 100644
--- a/pw_sync_baremetal/public_overrides/pw_sync_backend/spin_lock_inline.h
+++ b/pw_sync_baremetal/public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h
@@ -13,4 +13,4 @@
// the License.
#pragma once
-#include "pw_sync_baremetal/spin_lock_inline.h"
+#include "pw_sync_baremetal/interrupt_spin_lock_inline.h"
diff --git a/pw_sync_baremetal/public_overrides/pw_sync_backend/spin_lock_native.h b/pw_sync_baremetal/public_overrides/pw_sync_backend/interrupt_spin_lock_native.h
similarity index 91%
rename from pw_sync_baremetal/public_overrides/pw_sync_backend/spin_lock_native.h
rename to pw_sync_baremetal/public_overrides/pw_sync_backend/interrupt_spin_lock_native.h
index ed8ad48..cbe2f87 100644
--- a/pw_sync_baremetal/public_overrides/pw_sync_backend/spin_lock_native.h
+++ b/pw_sync_baremetal/public_overrides/pw_sync_backend/interrupt_spin_lock_native.h
@@ -13,4 +13,4 @@
// the License.
#pragma once
-#include "pw_sync_baremetal/spin_lock_native.h"
+#include "pw_sync_baremetal/interrupt_spin_lock_native.h"
diff --git a/pw_sync_embos/BUILD b/pw_sync_embos/BUILD
index 98e4739..1adc21c 100644
--- a/pw_sync_embos/BUILD
+++ b/pw_sync_embos/BUILD
@@ -119,12 +119,12 @@
)
pw_cc_library(
- name = "spin_lock_headers",
+ name = "interrupt_spin_lock_headers",
hdrs = [
- "public/pw_sync_embos/spin_lock_inline.h",
- "public/pw_sync_embos/spin_lock_native.h",
- "public_overrides/pw_sync_backend/spin_lock_inline.h",
- "public_overrides/pw_sync_backend/spin_lock_native.h",
+ "public/pw_sync_embos/interrupt_spin_lock_inline.h",
+ "public/pw_sync_embos/interrupt_spin_lock_native.h",
+ "public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h",
+ "public_overrides/pw_sync_backend/interrupt_spin_lock_native.h",
],
includes = [
"public",
@@ -135,13 +135,13 @@
)
pw_cc_library(
- name = "spin_lock",
+ name = "interrupt_spin_lock",
srcs = [
- "spin_lock.cc",
+ "interrupt_spin_lock.cc",
],
deps = [
- ":spin_lock_headers",
- "//pw_sync:spin_lock_facade",
+ ":interrupt_spin_lock_headers",
+ "//pw_sync:interrupt_spin_lock_facade",
],
)
diff --git a/pw_sync_embos/BUILD.gn b/pw_sync_embos/BUILD.gn
index abc95d7..fe19f24 100644
--- a/pw_sync_embos/BUILD.gn
+++ b/pw_sync_embos/BUILD.gn
@@ -112,23 +112,26 @@
"pw::chrono::SystemClock backend.")
}
-# This target provides the backend for pw::sync::SpinLock.
+# This target provides the backend for pw::sync::InterruptSpinLock.
pw_source_set("spin_lock") {
+ public_deps = [ ":interrupt_spin_lock" ]
+}
+pw_source_set("interrupt_spin_lock") {
public_configs = [
":public_include_path",
":backend_config",
]
public = [
- "public/pw_sync_embos/spin_lock_inline.h",
- "public/pw_sync_embos/spin_lock_native.h",
- "public_overrides/pw_sync_backend/spin_lock_inline.h",
- "public_overrides/pw_sync_backend/spin_lock_native.h",
+ "public/pw_sync_embos/interrupt_spin_lock_inline.h",
+ "public/pw_sync_embos/interrupt_spin_lock_native.h",
+ "public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h",
+ "public_overrides/pw_sync_backend/interrupt_spin_lock_native.h",
]
public_deps = [ "$dir_pw_third_party/embos" ]
- sources = [ "spin_lock.cc" ]
+ sources = [ "interrupt_spin_lock.cc" ]
deps = [
"$dir_pw_assert",
- "$dir_pw_sync:spin_lock.facade",
+ "$dir_pw_sync:interrupt_spin_lock.facade",
"$dir_pw_third_party/embos",
]
}
diff --git a/pw_sync_embos/spin_lock.cc b/pw_sync_embos/interrupt_spin_lock.cc
similarity index 85%
rename from pw_sync_embos/spin_lock.cc
rename to pw_sync_embos/interrupt_spin_lock.cc
index 2a5405a..9d17ba6 100644
--- a/pw_sync_embos/spin_lock.cc
+++ b/pw_sync_embos/interrupt_spin_lock.cc
@@ -12,22 +12,22 @@
// License for the specific language governing permissions and limitations under
// the License.
-#include "pw_sync/spin_lock.h"
+#include "pw_sync/interrupt_spin_lock.h"
#include "RTOS.h"
#include "pw_assert/assert.h"
namespace pw::sync {
-void SpinLock::lock() {
+void InterruptSpinLock::lock() {
OS_IncDI();
// We can't deadlock here so crash instead.
PW_CHECK(!native_type_.locked.load(std::memory_order_relaxed),
- "Recursive SpinLock::lock() detected");
+ "Recursive InterruptSpinLock::lock() detected");
native_type_.locked.store(true, std::memory_order_relaxed);
}
-bool SpinLock::try_lock() {
+bool InterruptSpinLock::try_lock() {
OS_IncDI();
if (native_type_.locked.load(std::memory_order_relaxed)) {
OS_DecRI(); // Already locked, restore interrupts and bail out.
@@ -37,7 +37,7 @@
return true;
}
-void SpinLock::unlock() {
+void InterruptSpinLock::unlock() {
native_type_.locked.store(false, std::memory_order_relaxed);
OS_DecRI();
}
diff --git a/pw_sync_embos/public/pw_sync_embos/spin_lock_inline.h b/pw_sync_embos/public/pw_sync_embos/interrupt_spin_lock_inline.h
similarity index 76%
rename from pw_sync_embos/public/pw_sync_embos/spin_lock_inline.h
rename to pw_sync_embos/public/pw_sync_embos/interrupt_spin_lock_inline.h
index 697de73..0484b3c 100644
--- a/pw_sync_embos/public/pw_sync_embos/spin_lock_inline.h
+++ b/pw_sync_embos/public/pw_sync_embos/interrupt_spin_lock_inline.h
@@ -13,13 +13,15 @@
// the License.
#pragma once
-#include "pw_sync/spin_lock.h"
+#include "pw_sync/interrupt_spin_lock.h"
namespace pw::sync {
-constexpr SpinLock::SpinLock() : native_type_{.locked{false}} {}
+constexpr InterruptSpinLock::InterruptSpinLock()
+ : native_type_{.locked{false}} {}
-inline SpinLock::native_handle_type SpinLock::native_handle() {
+inline InterruptSpinLock::native_handle_type
+InterruptSpinLock::native_handle() {
return native_type_;
}
diff --git a/pw_sync_embos/public/pw_sync_embos/spin_lock_native.h b/pw_sync_embos/public/pw_sync_embos/interrupt_spin_lock_native.h
similarity index 88%
rename from pw_sync_embos/public/pw_sync_embos/spin_lock_native.h
rename to pw_sync_embos/public/pw_sync_embos/interrupt_spin_lock_native.h
index 42e7e42..3c91f64 100644
--- a/pw_sync_embos/public/pw_sync_embos/spin_lock_native.h
+++ b/pw_sync_embos/public/pw_sync_embos/interrupt_spin_lock_native.h
@@ -19,9 +19,9 @@
namespace pw::sync::backend {
-struct NativeSpinLock {
+struct NativeInterruptSpinLock {
std::atomic<bool> locked; // Used to detect recursion.
};
-using NativeSpinLockHandle = NativeSpinLock&;
+using NativeInterruptSpinLockHandle = NativeInterruptSpinLock&;
} // namespace pw::sync::backend
diff --git a/pw_sync_baremetal/public_overrides/pw_sync_backend/spin_lock_native.h b/pw_sync_embos/public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h
similarity index 91%
copy from pw_sync_baremetal/public_overrides/pw_sync_backend/spin_lock_native.h
copy to pw_sync_embos/public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h
index ed8ad48..137d3dc 100644
--- a/pw_sync_baremetal/public_overrides/pw_sync_backend/spin_lock_native.h
+++ b/pw_sync_embos/public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h
@@ -13,4 +13,4 @@
// the License.
#pragma once
-#include "pw_sync_baremetal/spin_lock_native.h"
+#include "pw_sync_embos/interrupt_spin_lock_inline.h"
diff --git a/pw_sync_baremetal/public_overrides/pw_sync_backend/spin_lock_native.h b/pw_sync_embos/public_overrides/pw_sync_backend/interrupt_spin_lock_native.h
similarity index 91%
copy from pw_sync_baremetal/public_overrides/pw_sync_backend/spin_lock_native.h
copy to pw_sync_embos/public_overrides/pw_sync_backend/interrupt_spin_lock_native.h
index ed8ad48..e4e36f9 100644
--- a/pw_sync_baremetal/public_overrides/pw_sync_backend/spin_lock_native.h
+++ b/pw_sync_embos/public_overrides/pw_sync_backend/interrupt_spin_lock_native.h
@@ -13,4 +13,4 @@
// the License.
#pragma once
-#include "pw_sync_baremetal/spin_lock_native.h"
+#include "pw_sync_embos/interrupt_spin_lock_native.h"
diff --git a/pw_sync_embos/public_overrides/pw_sync_backend/spin_lock_inline.h b/pw_sync_embos/public_overrides/pw_sync_backend/spin_lock_inline.h
deleted file mode 100644
index 434f3bc..0000000
--- a/pw_sync_embos/public_overrides/pw_sync_backend/spin_lock_inline.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2021 The Pigweed Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-#pragma once
-
-#include "pw_sync_embos/spin_lock_inline.h"
diff --git a/pw_sync_embos/public_overrides/pw_sync_backend/spin_lock_native.h b/pw_sync_embos/public_overrides/pw_sync_backend/spin_lock_native.h
deleted file mode 100644
index 6d8075a..0000000
--- a/pw_sync_embos/public_overrides/pw_sync_backend/spin_lock_native.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2021 The Pigweed Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-#pragma once
-
-#include "pw_sync_embos/spin_lock_native.h"
diff --git a/pw_sync_freertos/BUILD b/pw_sync_freertos/BUILD
index 5837d8f..f82c95a 100644
--- a/pw_sync_freertos/BUILD
+++ b/pw_sync_freertos/BUILD
@@ -118,12 +118,12 @@
)
pw_cc_library(
- name = "spin_lock_headers",
+ name = "interrupt_spin_lock_headers",
hdrs = [
- "public/pw_sync_freertos/spin_lock_inline.h",
- "public/pw_sync_freertos/spin_lock_native.h",
- "public_overrides/pw_sync_backend/spin_lock_inline.h",
- "public_overrides/pw_sync_backend/spin_lock_native.h",
+ "public/pw_sync_freertos/interrupt_spin_lock_inline.h",
+ "public/pw_sync_freertos/interrupt_spin_lock_native.h",
+ "public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h",
+ "public_overrides/pw_sync_backend/interrupt_spin_lock_native.h",
],
includes = [
"public",
@@ -134,13 +134,13 @@
)
pw_cc_library(
- name = "spin_lock",
+ name = "interrupt_spin_lock",
srcs = [
- "spin_lock.cc",
+ "interrupt_spin_lock.cc",
],
deps = [
- ":spin_lock_headers",
+ ":interrupt_spin_lock_headers",
"//pw_interrupt:context",
- "//pw_sync:spin_lock_facade",
+ "//pw_sync:interrupt_spin_lock_facade",
],
)
diff --git a/pw_sync_freertos/BUILD.gn b/pw_sync_freertos/BUILD.gn
index 8869db5..f539afc 100644
--- a/pw_sync_freertos/BUILD.gn
+++ b/pw_sync_freertos/BUILD.gn
@@ -112,24 +112,27 @@
"pw::chrono::SystemClock backend.")
}
-# This target provides the backend for pw::sync::SpinLock.
+# This target provides the backend for pw::sync::InterruptSpinLock.
pw_source_set("spin_lock") {
+ public_deps = [ ":interrupt_spin_lock" ]
+}
+pw_source_set("interrupt_spin_lock") {
public_configs = [
":public_include_path",
":backend_config",
]
public = [
- "public/pw_sync_freertos/spin_lock_inline.h",
- "public/pw_sync_freertos/spin_lock_native.h",
- "public_overrides/pw_sync_backend/spin_lock_inline.h",
- "public_overrides/pw_sync_backend/spin_lock_native.h",
+ "public/pw_sync_freertos/interrupt_spin_lock_inline.h",
+ "public/pw_sync_freertos/interrupt_spin_lock_native.h",
+ "public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h",
+ "public_overrides/pw_sync_backend/interrupt_spin_lock_native.h",
]
public_deps = [ "$dir_pw_third_party/freertos" ]
- sources = [ "spin_lock.cc" ]
+ sources = [ "interrupt_spin_lock.cc" ]
deps = [
"$dir_pw_assert",
"$dir_pw_interrupt:context",
- "$dir_pw_sync:spin_lock.facade",
+ "$dir_pw_sync:interrupt_spin_lock.facade",
"$dir_pw_third_party/freertos",
]
}
diff --git a/pw_sync_freertos/spin_lock.cc b/pw_sync_freertos/interrupt_spin_lock.cc
similarity index 90%
rename from pw_sync_freertos/spin_lock.cc
rename to pw_sync_freertos/interrupt_spin_lock.cc
index b7898f8..7c96aa8 100644
--- a/pw_sync_freertos/spin_lock.cc
+++ b/pw_sync_freertos/interrupt_spin_lock.cc
@@ -12,7 +12,7 @@
// License for the specific language governing permissions and limitations under
// the License.
-#include "pw_sync/spin_lock.h"
+#include "pw_sync/interrupt_spin_lock.h"
#include "pw_assert/assert.h"
#include "pw_interrupt/context.h"
@@ -20,7 +20,7 @@
namespace pw::sync {
-void SpinLock::lock() {
+void InterruptSpinLock::lock() {
if (interrupt::InInterruptContext()) {
native_type_.saved_interrupt_mask = taskENTER_CRITICAL_FROM_ISR();
} else { // Task context
@@ -28,11 +28,11 @@
}
// We can't deadlock here so crash instead.
PW_CHECK(!native_type_.locked.load(std::memory_order_relaxed),
- "Recursive SpinLock::lock() detected");
+ "Recursive InterruptSpinLock::lock() detected");
native_type_.locked.store(true, std::memory_order_relaxed);
}
-bool SpinLock::try_lock() {
+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)) {
@@ -53,7 +53,7 @@
return true;
}
-void SpinLock::unlock() {
+void InterruptSpinLock::unlock() {
native_type_.locked.store(false, std::memory_order_relaxed);
if (interrupt::InInterruptContext()) {
taskEXIT_CRITICAL_FROM_ISR(native_type_.saved_interrupt_mask);
diff --git a/pw_sync_freertos/public/pw_sync_freertos/spin_lock_inline.h b/pw_sync_freertos/public/pw_sync_freertos/interrupt_spin_lock_inline.h
similarity index 81%
rename from pw_sync_freertos/public/pw_sync_freertos/spin_lock_inline.h
rename to pw_sync_freertos/public/pw_sync_freertos/interrupt_spin_lock_inline.h
index ae08b0d..8bbd4cf 100644
--- a/pw_sync_freertos/public/pw_sync_freertos/spin_lock_inline.h
+++ b/pw_sync_freertos/public/pw_sync_freertos/interrupt_spin_lock_inline.h
@@ -13,14 +13,15 @@
// the License.
#pragma once
-#include "pw_sync/spin_lock.h"
+#include "pw_sync/interrupt_spin_lock.h"
namespace pw::sync {
-constexpr SpinLock::SpinLock()
+constexpr InterruptSpinLock::InterruptSpinLock()
: native_type_{.locked{false}, .saved_interrupt_mask = 0} {}
-inline SpinLock::native_handle_type SpinLock::native_handle() {
+inline InterruptSpinLock::native_handle_type
+InterruptSpinLock::native_handle() {
return native_type_;
}
diff --git a/pw_sync_freertos/public/pw_sync_freertos/spin_lock_native.h b/pw_sync_freertos/public/pw_sync_freertos/interrupt_spin_lock_native.h
similarity index 89%
rename from pw_sync_freertos/public/pw_sync_freertos/spin_lock_native.h
rename to pw_sync_freertos/public/pw_sync_freertos/interrupt_spin_lock_native.h
index c291e4a..ac476dc 100644
--- a/pw_sync_freertos/public/pw_sync_freertos/spin_lock_native.h
+++ b/pw_sync_freertos/public/pw_sync_freertos/interrupt_spin_lock_native.h
@@ -19,10 +19,10 @@
namespace pw::sync::backend {
-struct NativeSpinLock {
+struct NativeInterruptSpinLock {
std::atomic<bool> locked; // Used to detect recursion.
UBaseType_t saved_interrupt_mask;
};
-using NativeSpinLockHandle = NativeSpinLock&;
+using NativeInterruptSpinLockHandle = NativeInterruptSpinLock&;
} // namespace pw::sync::backend
diff --git a/pw_sync_freertos/public_overrides/pw_sync_backend/spin_lock_native.h b/pw_sync_freertos/public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h
similarity index 91%
copy from pw_sync_freertos/public_overrides/pw_sync_backend/spin_lock_native.h
copy to pw_sync_freertos/public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h
index 103292e..ad3195f 100644
--- a/pw_sync_freertos/public_overrides/pw_sync_backend/spin_lock_native.h
+++ b/pw_sync_freertos/public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h
@@ -13,4 +13,4 @@
// the License.
#pragma once
-#include "pw_sync_freertos/spin_lock_native.h"
+#include "pw_sync_freertos/interrupt_spin_lock_inline.h"
diff --git a/pw_sync_freertos/public_overrides/pw_sync_backend/spin_lock_native.h b/pw_sync_freertos/public_overrides/pw_sync_backend/interrupt_spin_lock_native.h
similarity index 91%
rename from pw_sync_freertos/public_overrides/pw_sync_backend/spin_lock_native.h
rename to pw_sync_freertos/public_overrides/pw_sync_backend/interrupt_spin_lock_native.h
index 103292e..c9768b3 100644
--- a/pw_sync_freertos/public_overrides/pw_sync_backend/spin_lock_native.h
+++ b/pw_sync_freertos/public_overrides/pw_sync_backend/interrupt_spin_lock_native.h
@@ -13,4 +13,4 @@
// the License.
#pragma once
-#include "pw_sync_freertos/spin_lock_native.h"
+#include "pw_sync_freertos/interrupt_spin_lock_native.h"
diff --git a/pw_sync_stl/BUILD b/pw_sync_stl/BUILD
index 97dc246..9ee8784 100644
--- a/pw_sync_stl/BUILD
+++ b/pw_sync_stl/BUILD
@@ -106,12 +106,12 @@
)
pw_cc_library(
- name = "spin_lock_headers",
+ name = "interrupt_spin_lock_headers",
hdrs = [
- "public/pw_sync_stl/spin_lock_inline.h",
- "public/pw_sync_stl/spin_lock_native.h",
- "public_overrides/pw_sync_backend/spin_lock_inline.h",
- "public_overrides/pw_sync_backend/spin_lock_native.h",
+ "public/pw_sync_stl/interrupt_spin_lock_inline.h",
+ "public/pw_sync_stl/interrupt_spin_lock_native.h",
+ "public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h",
+ "public_overrides/pw_sync_backend/interrupt_spin_lock_native.h",
],
includes = [
"public",
@@ -120,10 +120,10 @@
)
pw_cc_library(
- name = "spin_lock",
+ name = "interrupt_spin_lock",
deps = [
- ":spin_lock_headers",
- "//pw_sync:spin_lock_facade",
+ ":interrupt_spin_lock_headers",
+ "//pw_sync:interrupt_spin_lock_facade",
"//pw_sync:yield_core",
],
)
diff --git a/pw_sync_stl/BUILD.gn b/pw_sync_stl/BUILD.gn
index f3fdebb..5ac5185 100644
--- a/pw_sync_stl/BUILD.gn
+++ b/pw_sync_stl/BUILD.gn
@@ -101,20 +101,23 @@
"pw::chrono::SystemClock backend.")
}
-# This target provides the backend for pw::sync::SpinLock.
-pw_source_set("spin_lock_backend") {
+# This target provides the backend for pw::sync::InterruptSpinLock.
+pw_source_set("spin_lock") {
+ public_deps = [ ":interrupt_spin_lock" ]
+}
+pw_source_set("interrupt_spin_lock") {
public_configs = [
":public_include_path",
":backend_config",
]
public = [
- "public/pw_sync_stl/spin_lock_inline.h",
- "public/pw_sync_stl/spin_lock_native.h",
- "public_overrides/pw_sync_backend/spin_lock_inline.h",
- "public_overrides/pw_sync_backend/spin_lock_native.h",
+ "public/pw_sync_stl/interrupt_spin_lock_inline.h",
+ "public/pw_sync_stl/interrupt_spin_lock_native.h",
+ "public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h",
+ "public_overrides/pw_sync_backend/interrupt_spin_lock_native.h",
]
public_deps = [
- "$dir_pw_sync:spin_lock.facade",
+ "$dir_pw_sync:interrupt_spin_lock.facade",
"$dir_pw_sync:yield_core",
]
}
diff --git a/pw_sync_stl/public/pw_sync_stl/spin_lock_inline.h b/pw_sync_stl/public/pw_sync_stl/interrupt_spin_lock_inline.h
similarity index 74%
rename from pw_sync_stl/public/pw_sync_stl/spin_lock_inline.h
rename to pw_sync_stl/public/pw_sync_stl/interrupt_spin_lock_inline.h
index a50c231..3a028b3 100644
--- a/pw_sync_stl/public/pw_sync_stl/spin_lock_inline.h
+++ b/pw_sync_stl/public/pw_sync_stl/interrupt_spin_lock_inline.h
@@ -13,28 +13,29 @@
// the License.
#pragma once
-#include "pw_sync/spin_lock.h"
+#include "pw_sync/interrupt_spin_lock.h"
#include "pw_sync/yield_core.h"
namespace pw::sync {
-constexpr SpinLock::SpinLock() : native_type_() {}
+constexpr InterruptSpinLock::InterruptSpinLock() : native_type_() {}
-inline void SpinLock::lock() {
+inline void InterruptSpinLock::lock() {
while (!try_lock()) {
PW_SYNC_YIELD_CORE_FOR_SMT();
}
}
-inline bool SpinLock::try_lock() {
+inline bool InterruptSpinLock::try_lock() {
return !native_type_.test_and_set(std::memory_order_acquire);
}
-inline void SpinLock::unlock() {
+inline void InterruptSpinLock::unlock() {
native_type_.clear(std::memory_order_release);
}
-inline SpinLock::native_handle_type SpinLock::native_handle() {
+inline InterruptSpinLock::native_handle_type
+InterruptSpinLock::native_handle() {
return native_type_;
}
diff --git a/pw_sync_stl/public/pw_sync_stl/spin_lock_native.h b/pw_sync_stl/public/pw_sync_stl/interrupt_spin_lock_native.h
similarity index 86%
rename from pw_sync_stl/public/pw_sync_stl/spin_lock_native.h
rename to pw_sync_stl/public/pw_sync_stl/interrupt_spin_lock_native.h
index 3358f8b..21f1646 100644
--- a/pw_sync_stl/public/pw_sync_stl/spin_lock_native.h
+++ b/pw_sync_stl/public/pw_sync_stl/interrupt_spin_lock_native.h
@@ -17,7 +17,7 @@
namespace pw::sync::backend {
-using NativeSpinLock = std::atomic_flag;
-using NativeSpinLockHandle = std::atomic_flag&;
+using NativeInterruptSpinLock = std::atomic_flag;
+using NativeInterruptSpinLockHandle = std::atomic_flag&;
} // namespace pw::sync::backend
diff --git a/pw_sync_stl/public_overrides/pw_sync_backend/spin_lock_inline.h b/pw_sync_stl/public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h
similarity index 92%
rename from pw_sync_stl/public_overrides/pw_sync_backend/spin_lock_inline.h
rename to pw_sync_stl/public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h
index 57c17c2..2bfe80d 100644
--- a/pw_sync_stl/public_overrides/pw_sync_backend/spin_lock_inline.h
+++ b/pw_sync_stl/public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h
@@ -13,4 +13,4 @@
// the License.
#pragma once
-#include "pw_sync_stl/spin_lock_inline.h"
+#include "pw_sync_stl/interrupt_spin_lock_inline.h"
diff --git a/pw_sync_stl/public_overrides/pw_sync_backend/spin_lock_native.h b/pw_sync_stl/public_overrides/pw_sync_backend/interrupt_spin_lock_native.h
similarity index 92%
rename from pw_sync_stl/public_overrides/pw_sync_backend/spin_lock_native.h
rename to pw_sync_stl/public_overrides/pw_sync_backend/interrupt_spin_lock_native.h
index 41ff621..cdd0685 100644
--- a/pw_sync_stl/public_overrides/pw_sync_backend/spin_lock_native.h
+++ b/pw_sync_stl/public_overrides/pw_sync_backend/interrupt_spin_lock_native.h
@@ -13,4 +13,4 @@
// the License.
#pragma once
-#include "pw_sync_stl/spin_lock_native.h"
+#include "pw_sync_stl/interrupt_spin_lock_native.h"
diff --git a/pw_sync_threadx/BUILD b/pw_sync_threadx/BUILD
index 7b25c93..837ed0f 100644
--- a/pw_sync_threadx/BUILD
+++ b/pw_sync_threadx/BUILD
@@ -118,12 +118,12 @@
)
pw_cc_library(
- name = "spin_lock_headers",
+ name = "interrupt_spin_lock_headers",
hdrs = [
- "public/pw_sync_threadx/spin_lock_inline.h",
- "public/pw_sync_threadx/spin_lock_native.h",
- "public_overrides/pw_sync_backend/spin_lock_inline.h",
- "public_overrides/pw_sync_backend/spin_lock_native.h",
+ "public/pw_sync_threadx/interrupt_spin_lock_inline.h",
+ "public/pw_sync_threadx/interrupt_spin_lock_native.h",
+ "public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h",
+ "public_overrides/pw_sync_backend/interrupt_spin_lock_native.h",
],
includes = [
"public",
@@ -134,12 +134,12 @@
)
pw_cc_library(
- name = "spin_lock",
+ name = "interrupt_spin_lock",
srcs = [
- "spin_lock.cc",
+ "interrupt_spin_lock.cc",
],
deps = [
- ":spin_lock_headers",
- "//pw_sync:spin_lock_facade",
+ ":interrupt_spin_lock_headers",
+ "//pw_sync:interrupt_spin_lock_facade",
],
)
diff --git a/pw_sync_threadx/BUILD.gn b/pw_sync_threadx/BUILD.gn
index 0b6e478..046d8e0 100644
--- a/pw_sync_threadx/BUILD.gn
+++ b/pw_sync_threadx/BUILD.gn
@@ -122,24 +122,27 @@
}
}
-# This target provides the backend for pw::sync::SpinLock, note that this
-# implementation does NOT support ThreadX w/ SMP.
+# This target provides the backend for pw::sync::InterruptSpinLock, note that
+# this implementation does NOT support ThreadX w/ SMP.
pw_source_set("spin_lock") {
+ public_deps = [ ":interrupt_spin_lock" ]
+}
+pw_source_set("interrupt_spin_lock") {
public_configs = [
":public_include_path",
":backend_config",
]
public = [
- "public/pw_sync_threadx/spin_lock_inline.h",
- "public/pw_sync_threadx/spin_lock_native.h",
- "public_overrides/pw_sync_backend/spin_lock_inline.h",
- "public_overrides/pw_sync_backend/spin_lock_native.h",
+ "public/pw_sync_threadx/interrupt_spin_lock_inline.h",
+ "public/pw_sync_threadx/interrupt_spin_lock_native.h",
+ "public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h",
+ "public_overrides/pw_sync_backend/interrupt_spin_lock_native.h",
]
public_deps = [ "$dir_pw_third_party/threadx" ]
- sources = [ "spin_lock.cc" ]
+ sources = [ "interrupt_spin_lock.cc" ]
deps = [
"$dir_pw_assert",
- "$dir_pw_sync:spin_lock.facade",
+ "$dir_pw_sync:interrupt_spin_lock.facade",
]
}
diff --git a/pw_sync_threadx/spin_lock.cc b/pw_sync_threadx/interrupt_spin_lock.cc
similarity index 82%
rename from pw_sync_threadx/spin_lock.cc
rename to pw_sync_threadx/interrupt_spin_lock.cc
index 6d8f277..96d5c54 100644
--- a/pw_sync_threadx/spin_lock.cc
+++ b/pw_sync_threadx/interrupt_spin_lock.cc
@@ -12,15 +12,15 @@
// License for the specific language governing permissions and limitations under
// the License.
-#include "pw_sync/spin_lock.h"
+#include "pw_sync/interrupt_spin_lock.h"
#include "pw_assert/assert.h"
#include "tx_api.h"
namespace pw::sync {
-void SpinLock::lock() {
- // In order to be pw::sync::SpinLock compliant, mask the interrupts
+void InterruptSpinLock::lock() {
+ // In order to be pw::sync::InterruptSpinLock compliant, mask the interrupts
// before attempting to grab the internal spin lock.
native_type_.saved_interrupt_mask = tx_interrupt_control(TX_INT_DISABLE);
@@ -28,13 +28,13 @@
// deadlock here due to the global interrupt lock, so we crash on recursion
// on a specific spinlock instead.
PW_CHECK(!native_type_.locked.load(std::memory_order_relaxed),
- "Recursive SpinLock::lock() detected");
+ "Recursive InterruptSpinLock::lock() detected");
native_type_.locked.store(true, std::memory_order_relaxed);
}
-bool SpinLock::try_lock() {
- // In order to be pw::sync::SpinLock compliant, mask the interrupts
+bool InterruptSpinLock::try_lock() {
+ // In order to be pw::sync::InterruptSpinLock compliant, mask the interrupts
// before attempting to grab the internal spin lock.
UINT saved_interrupt_mask = tx_interrupt_control(TX_INT_DISABLE);
@@ -49,7 +49,7 @@
return true;
}
-void SpinLock::unlock() {
+void InterruptSpinLock::unlock() {
native_type_.locked.store(false, std::memory_order_relaxed);
tx_interrupt_control(native_type_.saved_interrupt_mask);
}
diff --git a/pw_sync_threadx/public/pw_sync_threadx/spin_lock_inline.h b/pw_sync_threadx/public/pw_sync_threadx/interrupt_spin_lock_inline.h
similarity index 81%
rename from pw_sync_threadx/public/pw_sync_threadx/spin_lock_inline.h
rename to pw_sync_threadx/public/pw_sync_threadx/interrupt_spin_lock_inline.h
index ae08b0d..8bbd4cf 100644
--- a/pw_sync_threadx/public/pw_sync_threadx/spin_lock_inline.h
+++ b/pw_sync_threadx/public/pw_sync_threadx/interrupt_spin_lock_inline.h
@@ -13,14 +13,15 @@
// the License.
#pragma once
-#include "pw_sync/spin_lock.h"
+#include "pw_sync/interrupt_spin_lock.h"
namespace pw::sync {
-constexpr SpinLock::SpinLock()
+constexpr InterruptSpinLock::InterruptSpinLock()
: native_type_{.locked{false}, .saved_interrupt_mask = 0} {}
-inline SpinLock::native_handle_type SpinLock::native_handle() {
+inline InterruptSpinLock::native_handle_type
+InterruptSpinLock::native_handle() {
return native_type_;
}
diff --git a/pw_sync_threadx/public/pw_sync_threadx/spin_lock_native.h b/pw_sync_threadx/public/pw_sync_threadx/interrupt_spin_lock_native.h
similarity index 89%
rename from pw_sync_threadx/public/pw_sync_threadx/spin_lock_native.h
rename to pw_sync_threadx/public/pw_sync_threadx/interrupt_spin_lock_native.h
index 7756abc..cf6ceb8 100644
--- a/pw_sync_threadx/public/pw_sync_threadx/spin_lock_native.h
+++ b/pw_sync_threadx/public/pw_sync_threadx/interrupt_spin_lock_native.h
@@ -19,10 +19,10 @@
namespace pw::sync::backend {
-struct NativeSpinLock {
+struct NativeInterruptSpinLock {
std::atomic<bool> locked; // Used to detect recursion.
UINT saved_interrupt_mask;
};
-using NativeSpinLockHandle = NativeSpinLock&;
+using NativeInterruptSpinLockHandle = NativeInterruptSpinLock&;
} // namespace pw::sync::backend
diff --git a/pw_sync_freertos/public_overrides/pw_sync_backend/spin_lock_inline.h b/pw_sync_threadx/public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h
similarity index 91%
rename from pw_sync_freertos/public_overrides/pw_sync_backend/spin_lock_inline.h
rename to pw_sync_threadx/public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h
index 94e44eb..c42d7f9 100644
--- a/pw_sync_freertos/public_overrides/pw_sync_backend/spin_lock_inline.h
+++ b/pw_sync_threadx/public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h
@@ -13,4 +13,4 @@
// the License.
#pragma once
-#include "pw_sync_freertos/spin_lock_inline.h"
+#include "pw_sync_threadx/interrupt_spin_lock_inline.h"
diff --git a/pw_sync_freertos/public_overrides/pw_sync_backend/spin_lock_native.h b/pw_sync_threadx/public_overrides/pw_sync_backend/interrupt_spin_lock_native.h
similarity index 91%
copy from pw_sync_freertos/public_overrides/pw_sync_backend/spin_lock_native.h
copy to pw_sync_threadx/public_overrides/pw_sync_backend/interrupt_spin_lock_native.h
index 103292e..9a98526 100644
--- a/pw_sync_freertos/public_overrides/pw_sync_backend/spin_lock_native.h
+++ b/pw_sync_threadx/public_overrides/pw_sync_backend/interrupt_spin_lock_native.h
@@ -13,4 +13,4 @@
// the License.
#pragma once
-#include "pw_sync_freertos/spin_lock_native.h"
+#include "pw_sync_threadx/interrupt_spin_lock_native.h"
diff --git a/pw_sync_threadx/public_overrides/pw_sync_backend/spin_lock_inline.h b/pw_sync_threadx/public_overrides/pw_sync_backend/spin_lock_inline.h
deleted file mode 100644
index 06b7d81..0000000
--- a/pw_sync_threadx/public_overrides/pw_sync_backend/spin_lock_inline.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2020 The Pigweed Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-#pragma once
-
-#include "pw_sync_threadx/spin_lock_inline.h"
diff --git a/pw_sync_threadx/public_overrides/pw_sync_backend/spin_lock_native.h b/pw_sync_threadx/public_overrides/pw_sync_backend/spin_lock_native.h
deleted file mode 100644
index 35738cc..0000000
--- a/pw_sync_threadx/public_overrides/pw_sync_backend/spin_lock_native.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2020 The Pigweed Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// https://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-#pragma once
-
-#include "pw_sync_threadx/spin_lock_native.h"
diff --git a/targets/arduino/target_toolchains.gni b/targets/arduino/target_toolchains.gni
index 8c34283..0b68152 100644
--- a/targets/arduino/target_toolchains.gni
+++ b/targets/arduino/target_toolchains.gni
@@ -44,7 +44,7 @@
# Facade backends
pw_assert_BACKEND = dir_pw_assert_basic
pw_log_BACKEND = dir_pw_log_basic
- pw_sync_SPIN_LOCK_BACKEND = "$dir_pw_sync_baremetal:spin_lock_backend"
+ pw_sync_SPIN_LOCK_BACKEND = "$dir_pw_sync_baremetal:interrupt_spin_lock"
pw_sys_io_BACKEND = dir_pw_sys_io_arduino
pw_rpc_system_server_BACKEND =
"$dir_pigweed/targets/arduino:system_rpc_server"
diff --git a/targets/host/target_toolchains.gni b/targets/host/target_toolchains.gni
index 05d593c..98fd14e 100644
--- a/targets/host/target_toolchains.gni
+++ b/targets/host/target_toolchains.gni
@@ -37,7 +37,7 @@
pw_log_BACKEND = "$dir_pw_log_basic"
# Configure backends for pw_sync's facades.
- pw_sync_SPIN_LOCK_BACKEND = "$dir_pw_sync_stl:spin_lock_backend"
+ pw_sync_SPIN_LOCK_BACKEND = "$dir_pw_sync_stl:interrupt_spin_lock"
# Configure backend for pw_sys_io facade.
pw_sys_io_BACKEND = "$dir_pw_sys_io_stdio"
diff --git a/targets/lm3s6965evb-qemu/target_toolchains.gni b/targets/lm3s6965evb-qemu/target_toolchains.gni
index ce3c496..602d01a 100644
--- a/targets/lm3s6965evb-qemu/target_toolchains.gni
+++ b/targets/lm3s6965evb-qemu/target_toolchains.gni
@@ -40,7 +40,7 @@
pw_boot_BACKEND = dir_pw_boot_armv7m
pw_log_BACKEND = dir_pw_log_basic
pw_sys_io_BACKEND = dir_pw_sys_io_baremetal_lm3s6965evb
- pw_sync_SPIN_LOCK_BACKEND = "$dir_pw_sync_baremetal:spin_lock_backend"
+ pw_sync_SPIN_LOCK_BACKEND = "$dir_pw_sync_baremetal:interrupt_spin_lock"
# pw_cpu_exception_armv7m tests do not work as expected in QEMU. It does not
# appear the divide-by-zero traps as expected when enabled, which prevents the
diff --git a/targets/stm32f429i-disc1/target_toolchains.gni b/targets/stm32f429i-disc1/target_toolchains.gni
index 6efc896..f2bebda 100644
--- a/targets/stm32f429i-disc1/target_toolchains.gni
+++ b/targets/stm32f429i-disc1/target_toolchains.gni
@@ -50,7 +50,7 @@
pw_cpu_exception_HANDLER_BACKEND = "$dir_pw_cpu_exception:basic_handler"
pw_cpu_exception_SUPPORT_BACKEND =
"$dir_pw_cpu_exception_cortex_m:support_armv7m"
- pw_sync_SPIN_LOCK_BACKEND = "$dir_pw_sync_baremetal:spin_lock_backend"
+ pw_sync_SPIN_LOCK_BACKEND = "$dir_pw_sync_baremetal:interrupt_spin_lock"
pw_log_BACKEND = dir_pw_log_basic
pw_sys_io_BACKEND = dir_pw_sys_io_baremetal_stm32f429
pw_rpc_system_server_BACKEND =