GCC Code Coverage Report


Directory: lib/fprime-samd/fprime-samd/
File: Drv/Types/CriticalSectionStub.cpp
Date: 2026-09-26 00:05:09
Exec Total Coverage
Lines: 0 13 0.0%
Functions: 0 4 0.0%
Branches: 0 2 0.0%

Line Branch Exec Source
1 // ======================================================================
2 // \title CriticalSectionStub.cpp
3 // \author tumbar
4 // \brief Stub CriticalSection implementation for Linux/test builds
5 //
6 // This file is compiled for Linux/test builds so that components depending on
7 // fprime-samd_Drv_Types can link under native unit testing without the SAMD21
8 // CMSIS intrinsics (__disable_irq/__get_PRIMASK/etc.). For SAMD21 target
9 // builds, CriticalSection.cpp is used instead.
10 //
11 // Unit tests run single-threaded with no ISRs, so a critical section is a
12 // no-op: nesting is still reference-counted for parity with the real
13 // implementation, but no interrupts exist to disable.
14 // ======================================================================
15
16 #include "Fw/FPrimeBasicTypes.hpp"
17 #include "fprime-samd/Drv/Types/CriticalSection.hpp"
18
19 namespace Samd21 {
20
21 //! Depth of the currently-held critical section nesting
22 static U32 s_critical_section_counter = 0;
23
24 ✗ void CriticalSection::enter() {
25 ✗ s_critical_section_counter++;
26 ✗ }
27
28 ✗ void CriticalSection::leave() {
29 ✗ if (s_critical_section_counter > 0) {
30 ✗ s_critical_section_counter--;
31 }
32 ✗ }
33
34 ✗ CriticalSection::CriticalSection() {
35 ✗ CriticalSection::enter();
36 ✗ }
37
38 ✗ CriticalSection::~CriticalSection() {
39 ✗ CriticalSection::leave();
40 ✗ }
41
42 } // namespace Samd21
43