SuperTinyKernel™ RTOS 1.05.3
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
stktest.h File Reference
#include <stdio.h>
#include <exception>
#include <CppUTest/TestHarness.h>
#include <stk_config.h>
#include <stk.h>
#include <arch/stk_arch_common.h>
#include <sync/stk_sync.h>
#include <time/stk_time.h>
#include "stktest_context.h"
Include dependency graph for stktest.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  stk::test::TestAssertPassed
 Throwable class for catching assertions from STK_ASSERT_HANDLER(). More...
class  stk::test::PlatformTestMock
 IPlatform mock. More...
struct  stk::test::PlatformTestMock::StackInfo
class  stk::test::KernelServiceMock
 IKernelService mock. More...
class  stk::test::TaskMock< _AccessMode >
 Task mock. More...
class  stk::test::TaskMockW< _Weight, _AccessMode >
 Task mock for SwitchStrategySmoothWeightedRoundRobin and similar algorithms. More...
struct  stk::test::MutexMock
struct  stk::test::SyncObjectMock

Namespaces

namespace  stk
 Namespace of STK package.
namespace  stk::test
 Namespace of the test inventory.

Macros

#define _STK_UNDER_TEST
#define __stk_relax_cpu   __stktest_relax_cpu
 Emits a CPU pipeline-relaxation hint for use inside hot busy-wait (spin) loops (in-code statement).

Functions

static void __stktest_relax_cpu ()
 __stk_relax_cpu interceptor.

Variables

void(* g_RelaxCpuHandler )()
 __stk_relax_cpu handler.
IKernelServicestk::test::g_KernelService = NULL
int32_t stk::test::g_CriticalSectionState = false
 Critical section state.
bool stk::test::g_InsideISR = false
 ISR state.
EKernelPanicId stk::test::g_PanicValue = KERNEL_PANIC_NONE
 Panic value.

Macro Definition Documentation

◆ __stk_relax_cpu

#define __stk_relax_cpu   __stktest_relax_cpu

Emits a CPU pipeline-relaxation hint for use inside hot busy-wait (spin) loops (in-code statement).

Note
Reduces power consumption and memory-bus contention while spinning by signalling to the CPU that the current thread is in a spin-wait. Platform-specific expansions:
  • x86/x64 (GCC/Clang/MSVC): the PAUSE instruction via __builtin_ia32_pause() or _mm_pause().
  • RISC-V with Zihintpause (GCC/Clang): the PAUSE hint via __builtin_riscv_pause().
  • RISC-V without Zihintpause (GCC/Clang): falls back to __stk_full_memfence().
  • ARM Cortex-M (MSVC): the YIELD instruction via __yield().
  • ARM Cortex-M (GCC/Clang): falls back to __stk_full_memfence() (no dedicated hint).
  • Other/unknown targets: falls back to __stk_full_memfence().
Can be redefined externally (e.g. in test harnesses) to intercept control inside kernel waiting loops without modifying kernel source.

Definition at line 33 of file stktest.h.

Referenced by stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService::Delay(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::OnTaskSleep(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::OnTaskSleepUntil(), and stk::Kernel< TMode, TSize, TStrategy, TPlatform >::OnTaskWait().

◆ _STK_UNDER_TEST

#define _STK_UNDER_TEST

Definition at line 31 of file stktest.h.

Function Documentation

◆ __stktest_relax_cpu()

void __stktest_relax_cpu ( )
inlinestatic

__stk_relax_cpu interceptor.

Definition at line 23 of file stktest.h.

24{
25 if (g_RelaxCpuHandler != NULL)
27}
void(* g_RelaxCpuHandler)()
__stk_relax_cpu handler.
Definition stktest.cpp:17
void(* g_RelaxCpuHandler)()
__stk_relax_cpu handler.
Definition stktest.cpp:17

References g_RelaxCpuHandler.

Variable Documentation

◆ g_RelaxCpuHandler