GCC Code Coverage Report


Directory: ./
File: Os/Stub/Mutex.cpp
Date: 2026-09-03 22:12:29
Exec Total Coverage
Lines: 0 10 0.0%
Functions: 0 3 0.0%
Branches: 0 4 0.0%

Line Branch Exec Source
1 // ======================================================================
2 // \title Os/Stub/Mutex.cpp
3 // \brief stub implementation for Os::Mutex
4 // ======================================================================
5 #include "Os/Stub/Mutex.hpp"
6
7 namespace Os {
8 namespace Stub {
9 namespace Mutex {
10
11 StubMutex::Status StubMutex::take() {
12 // Attempt to mark the mutex as taken.
13 if (this->m_handle.m_mutex_taken.exchange(true)) {
14 // The mutex was already taken, so fail the operation.
15 // (This stub is for platforms without the ability to block.)
16 return Status::ERROR_BUSY;
17 }
18 // The mutex was not already taken.
19 // Now that it has been marked as taken, we have successfully entered the critical section.
20 return Status::OP_OK;
21 }
22
23 StubMutex::Status StubMutex::release() {
24 // Attempt to mark the mutex as not taken.
25 if (!this->m_handle.m_mutex_taken.exchange(false)) {
26 // The mutex was already not taken, which indicates a coding defect.
27 return Status::ERROR_OTHER;
28 }
29 // The mutex was taken.
30 // Now that it has been marked as not taken, we have successfully exited the critical section.
31 return Status::OP_OK;
32 }
33
34 MutexHandle* StubMutex::getHandle() {
35 return &this->m_handle;
36 }
37 } // namespace Mutex
38 } // namespace Stub
39 } // namespace Os
40