aboutsummaryrefslogtreecommitdiff
path: root/pw_chrono_threadx
diff options
context:
space:
mode:
authorEwout van Bekkum <ewout@google.com>2021-03-09 11:39:05 -0800
committerCQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>2021-03-10 17:14:56 +0000
commitdb455e64bb4a11ae8755beb82d4c9401dde99638 (patch)
treefb4abfd68bfdd464c8fcee7cf2aab06e465515b6 /pw_chrono_threadx
parent41b2b3d7dbc2aa812451ca210e927af9311c6277 (diff)
downloadpigweed-db455e64bb4a11ae8755beb82d4c9401dde99638.tar.gz
pw_chrono: simplify RTOS SystemClock backends
Simplifies the SystemClock backends for FreeRTOS, ThreadX, and embOS using the updated pw::sync::SpinLock facade which has a constexpr constructor which removes the need for special early boot handling. Change-Id: I9d69a4e0c34ab7b3a1488dce6693cbc642b282bb Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/36581 Pigweed-Auto-Submit: Ewout van Bekkum <ewout@google.com> Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com> Reviewed-by: Wyatt Hepler <hepler@google.com>
Diffstat (limited to 'pw_chrono_threadx')
-rw-r--r--pw_chrono_threadx/system_clock.cc26
1 files changed, 1 insertions, 25 deletions
diff --git a/pw_chrono_threadx/system_clock.cc b/pw_chrono_threadx/system_clock.cc
index 972fc2941..3017c3382 100644
--- a/pw_chrono_threadx/system_clock.cc
+++ b/pw_chrono_threadx/system_clock.cc
@@ -29,25 +29,7 @@ namespace {
#error "This backend is not compatible with TX_NO_TIMER"
#endif // defined(TX_NO_TIMER) && TX_NO_TIMER
-// Extension wrapping pw::SpinLock to allow an atomic to be used to determine
-// whether it has been constructed and is ready to be used.
-class ConstructionSignalingSpinLock : public sync::SpinLock {
- public:
- ConstructionSignalingSpinLock(std::atomic<bool>& constructed_signal)
- : sync::SpinLock() {
- // Note that the memory order is relaxed because C++ global static
- // construction is a single threaded environment.
- constructed_signal.store(true, std::memory_order_relaxed);
- };
-};
-
-// This is POD, meaning this atomic is available before static C++ global
-// constructors are run.
-std::atomic<bool> system_clock_spin_lock_constructed = {false};
-
-ConstructionSignalingSpinLock system_clock_spin_lock(
- system_clock_spin_lock_constructed);
-
+sync::SpinLock system_clock_spin_lock;
int64_t overflow_tick_count = 0;
ULONG native_tick_count = 0;
static_assert(!SystemClock::is_nmi_safe,
@@ -60,12 +42,6 @@ constexpr int64_t kNativeOverflowTickCount =
} // namespace
int64_t GetSystemClockTickCount() {
- // Note that the memory order is relaxed because C++ global static
- // construction is a single threaded environment.
- if (!system_clock_spin_lock_constructed.load(std::memory_order_relaxed)) {
- return tx_time_get();
- }
-
std::lock_guard lock(system_clock_spin_lock);
const ULONG new_native_tick_count = tx_time_get();
// WARNING: This must be called more than once per overflow period!