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_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_embos/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_embos/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 6d8075a..137d3dc 100644
--- a/pw_sync_embos/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_embos/spin_lock_native.h"
+#include "pw_sync_embos/interrupt_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/interrupt_spin_lock_native.h
similarity index 91%
rename from pw_sync_embos/public_overrides/pw_sync_backend/spin_lock_native.h
rename to pw_sync_embos/public_overrides/pw_sync_backend/interrupt_spin_lock_native.h
index 6d8075a..e4e36f9 100644
--- a/pw_sync_embos/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_embos/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"