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
stk_defs.h File Reference

Compiler and platform low-level definitions for STK. More...

#include <stddef.h>
#include <stdint.h>
#include "stk_config.h"
Include dependency graph for stk_defs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  stk
 Namespace of STK package.
namespace  stk::util
 Internal utility namespace containing data structure helpers (linked lists, etc.) used by the kernel implementation. Not part of the public user API.

Macros

#define STK_TICKLESS_IDLE   0
 Enables tickless (dynamic-tick) low-power operation during idle periods.
#define STK_TICKLESS_USE_ARM_DWT   1
 Use DWT timer of ARM Cortex-M for a precise tick calculation.
#define STK_TICKLESS_TICKS_MAX   1000
 Maximum number of kernel ticks the hardware timer may be suppressed in one tickless idle interval when STK_TICKLESS_IDLE=1. Default: 1000.
#define STK_SYNC_DEBUG_NAMES   0
 Enable debug names for synchronization primitives (mutexes, events, etc.) for debugging and tracing purposes.
#define __stk_forceinline
 Forces compiler to always inline the decorated function, regardless of optimisation level.
#define __stk_aligned(x)
 Specifies minimum alignment in bytes for the decorated variable or struct member (data instance prefix).
#define __stk_attr_naked
 Suppresses compiler-generated function prologue and epilogue (function prefix).
#define __stk_attr_noreturn
 Declares that function never returns to its caller (function prefix).
#define __stk_attr_unused
 Suppresses compiler warnings about an unused type, variable, or function (declaration prefix).
#define __stk_attr_used
 Marks a symbol as used, preventing the linker from discarding it even if no references are visible (declaration prefix).
#define __stk_attr_noinline
 Prevents compiler from inlining the decorated function (function prefix).
#define __stk_attr_deprecated
 Marks a function, class, variable, or typedef as deprecated (declaration prefix).
#define __stk_debug_break()
 Triggers a hardware breakpoint, halting execution in an attached debugger (in-code statement).
#define STK_ASSERT(e)
 Runtime assertion. Halts execution if the expression e evaluates to false.
#define STK_STATIC_ASSERT_DESC_N(NAME, X, DESC)
 Compile-time assertion with a user-defined name suffix and a custom error description.
#define STK_STATIC_ASSERT_DESC(X, DESC)
 Compile-time assertion with a custom error description. Produces a compilation error if X is false.
#define STK_STATIC_ASSERT_N(NAME, X)
 Compile-time assertion with a user-defined name suffix.
#define STK_STATIC_ASSERT(X)
 Compile-time assertion. Produces a compilation error if X is false.
#define STK_STACK_MEMORY_FILLER   ((Word)(sizeof(Word) <= 4 ? 0xdeadbeef : 0xdeadbeefdeadbeef))
 Sentinel value written to the entire stack region at initialization (stack watermark pattern).
#define STK_STACK_MEMORY_ALIGN   4
 Stack memory alignment.
#define STK_CRITICAL_SECTION_NESTINGS_MAX   16
 Maximum allowable recursion depth for critical section entry (default: 16).
#define STK_ARCH_CPU_COUNT   1
 Number of physical CPU cores available to the scheduler (default: 1).
#define STK_STACK_SIZE_MIN   32
 Minimum stack size in elements of Word, shared by all stack allocation lower-bound checks.
#define STK_SLEEP_TRAP_STACK_SIZE   (STK_STACK_SIZE_MIN)
 Stack size for the sleep trap in elements of Word (default: STK_STACK_SIZE_MIN).
#define STK_ALLOCATE_COUNT(MODE, FLAG, ONTRUE, ONFALSE)
 Selects a static array element count at compile time based on a mode flag.
#define STK_ENDIAN_IDX_HI   (1)
 Array index of the high 32-bit word when a 64-bit value is viewed as uint32_t[2].
#define STK_ENDIAN_IDX_LO   (0)
 Array index of the low 32-bit word when a 64-bit value is viewed as uint32_t[2].
#define STK_NONCOPYABLE_CLASS(TYPE)
 Disables copy construction and assignment for a class.

Functions

template<typename T>
constexpr T stk::Min (T a, T b) noexcept
 Compile-time minimum of two values.
template<typename T>
constexpr T stk::Max (T a, T b) noexcept
 Compile-time maximum of two values.

Detailed Description

Compiler and platform low-level definitions for STK.

Note
Includes stk_config.h first so user-level configuration macros (e.g. STK_TICKLESS_IDLE, STK_SEGGER_SYSVIEW) are visible to all definitions below. Refer to stk_config.h and project examples for configuration details.

Definition in file stk_defs.h.

Macro Definition Documentation

◆ __stk_aligned

#define __stk_aligned ( x)

Specifies minimum alignment in bytes for the decorated variable or struct member (data instance prefix).

Parameters
[in]xRequired alignment in bytes. Must be a power of two.
Note
On compilers not listed below the attribute expands to nothing and alignment is not enforced. Verify alignment-sensitive data on new toolchains.

Definition at line 118 of file stk_defs.h.

◆ __stk_attr_deprecated

#define __stk_attr_deprecated

Marks a function, class, variable, or typedef as deprecated (declaration prefix).

Note
The compiler will emit a warning at every call site or use of the decorated symbol, prompting callers to migrate to the replacement API.

Definition at line 200 of file stk_defs.h.

◆ __stk_attr_naked

#define __stk_attr_naked

Suppresses compiler-generated function prologue and epilogue (function prefix).

Note
The decorated function must consist of inline assembly only. C statements that rely on a stack frame (local variables, non-trivial expressions, function calls) produce undefined behaviour. Used for context-switch stubs and ISR entry points where the register save/restore sequence must be precisely hand-written.

Definition at line 133 of file stk_defs.h.

◆ __stk_attr_noinline

◆ __stk_attr_noreturn

#define __stk_attr_noreturn

Declares that function never returns to its caller (function prefix).

Note
Enables compiler to omit return-path code and dead-store warnings after the call site.
Warning
Applying this attribute to a function that does return produces undefined behaviour.

Definition at line 146 of file stk_defs.h.

◆ __stk_attr_unused

#define __stk_attr_unused

Suppresses compiler warnings about an unused type, variable, or function (declaration prefix).

Note
Does not prevent the linker from discarding the symbol. Use __stk_attr_used when the symbol must be retained regardless of whether it appears to be referenced.

Definition at line 159 of file stk_defs.h.

◆ __stk_attr_used

#define __stk_attr_used

Marks a symbol as used, preventing the linker from discarding it even if no references are visible (declaration prefix).

Note
Commonly applied to ISR vector table entries, trap stubs, and objects placed in special linker sections that are referenced only from assembly or linker scripts.

Definition at line 172 of file stk_defs.h.

◆ __stk_debug_break

#define __stk_debug_break ( )

Triggers a hardware breakpoint, halting execution in an attached debugger (in-code statement).

Note
Behaviour by build and architecture:
  • Release build (neither DEBUG nor _DEBUG defined): always expands to nothing, regardless of architecture.
  • Debug build with a recognised architecture (_STK_ARCH_ARM_CORTEX_M, _STK_ARCH_RISC_V, or _STK_ARCH_X86_WIN32): emits the appropriate breakpoint instruction (bkpt, ebreak, or __debugbreak / int $3).
  • Debug build with no recognised architecture: the macro is left undefined. Any usage site will produce a compiler error. Add a definition for your architecture in stk_defs.h or define it to nothing in stk_config.h to suppress.
Used in assertion handlers and fault paths to halt the system at the exact failure point rather than continuing into undefined state.

Definition at line 303 of file stk_defs.h.

◆ __stk_forceinline

◆ STK_ALLOCATE_COUNT

#define STK_ALLOCATE_COUNT ( MODE,
FLAG,
ONTRUE,
ONFALSE )
Value:
((((MODE) & (FLAG)) != 0U) ? (ONTRUE) : (ONFALSE))

Selects a static array element count at compile time based on a mode flag.

Note
On GCC/Clang: expands to ONTRUE if (MODE & FLAG) is non-zero, otherwise ONFALSE. On MSVC: always expands to max(ONTRUE, ONFALSE) because MSVC does not support zero-sized arrays. This means MSVC builds may over-allocate when the flag is not set, but avoids a compile error. Configuration mistakes that would result in ONFALSE on other compilers will be silently masked on MSVC.
Parameters
[in]MODEBitmask of active kernel modes (e.g. EKernelMode flags).
[in]FLAGThe specific mode bit to test.
[in]ONTRUEArray count to use when FLAG is active.
[in]ONFALSEArray count to use when FLAG is inactive (may be 0 on GCC/Clang).

Definition at line 485 of file stk_defs.h.

◆ STK_ARCH_CPU_COUNT

#define STK_ARCH_CPU_COUNT   1

Number of physical CPU cores available to the scheduler (default: 1).

Note
Controls the number of per-CPU kernel service instances and per-CPU data structures allocated by the kernel. Set to the actual core count for SMP (symmetric multi-processing) targets. Can be defined in the architecture header or stk_config.h.

Definition at line 414 of file stk_defs.h.

◆ STK_ASSERT

#define STK_ASSERT ( e)

Runtime assertion. Halts execution if the expression e evaluates to false.

Note
Behaviour depends on build configuration:
  • If _STK_ASSERT_REDIRECT is defined: always redirects to the custom handler STK_ASSERT_HANDLER (regardless of debug/release build type). Signature:
    void STK_ASSERT_HANDLER(const char *expr, const char *file, int32_t line);
    void STK_ASSERT_HANDLER(const char *message, const char *file, int32_t line)
    Use this on embedded targets where the standard assert handler is unavailable, or where a custom fault logger or LED indicator is preferred.
  • Else if DEBUG or _DEBUG is defined (debug build): maps to the standard assert() macro from <assert.h>, which halts execution on failure.
  • Else (release build): expands to nothing. The expression e is completely elided, including any side effects. Do not rely on side effects inside STK_ASSERT.
Warning
In release builds without _STK_ASSERT_REDIRECT, all assertions are silently removed. Safety-critical applications (ISO 26262, IEC 61508) should define _STK_ASSERT_REDIRECT to retain fault detection in all build configurations.

Definition at line 330 of file stk_defs.h.

Referenced by stk::Kernel< TMode, TSize, TStrategy, TPlatform >::AddTask(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::AddTask(), stk::SwitchStrategyEDF::AddTask(), stk::SwitchStrategyFixedPriority< 32 >::AddTask(), stk::SwitchStrategyMonotonic< MSS_TYPE_RATE >::AddTask(), stk::SwitchStrategyRoundRobin::AddTask(), stk::SwitchStrategySmoothWeightedRoundRobin::AddTask(), stk::ISyncObject::AddWaitObject(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::AllocateAndAddNewTask(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::AllocateNewTask(), AllocateTask(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::Bind(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService::Delay(), stk::sync::EventFlags::EventFlags(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::FetchNextEvent(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::FindTaskBySP(), FreeTask(), stk::SwitchStrategyEDF::GetFirst(), stk::SwitchStrategyFixedPriority< 32 >::GetFirst(), stk::SwitchStrategyMonotonic< MSS_TYPE_RATE >::GetFirst(), stk::SwitchStrategyRoundRobin::GetFirst(), stk::SwitchStrategySmoothWeightedRoundRobin::GetFirst(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::GetHrtDeadline(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::GetHrtPeriodicity(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::GetHrtRelativeDeadline(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::GetNewFsmState(), stk::SwitchStrategyMonotonic< MSS_TYPE_RATE >::GetNext(), stk::SwitchStrategySmoothWeightedRoundRobin::GetNext(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService::GetTid(), stk::hw::HiResClock::GetTimeUs(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::HrtAllocateAndAddNewTask(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::HrtHardFailDeadline(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::HrtInit(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::HrtOnSwitchedOut(), CTimerWrapper::Initialize(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::Initialize(), stk::PlatformContext::InitStackMemory(), stk::SchedulabilityCheck::IsSchedulableWCRT(), stk::util::DListHead< T, _ClosedLoop >::Link(), stk::sync::SpinLock::LockRecursively(), stk::TaskW< _Weight, _StackSize, _AccessMode >::OnDeadlineMissed(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::OnGetTid(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::OnStart(), stk::SwitchStrategyEDF::OnTaskDeadlineMissed(), stk::SwitchStrategyFixedPriority< 32 >::OnTaskDeadlineMissed(), stk::SwitchStrategyMonotonic< MSS_TYPE_RATE >::OnTaskDeadlineMissed(), stk::SwitchStrategyRoundRobin::OnTaskDeadlineMissed(), stk::SwitchStrategySmoothWeightedRoundRobin::OnTaskDeadlineMissed(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::OnTaskExit(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::OnTaskSleep(), stk::SwitchStrategyEDF::OnTaskSleep(), stk::SwitchStrategyFixedPriority< 32 >::OnTaskSleep(), stk::SwitchStrategyMonotonic< MSS_TYPE_RATE >::OnTaskSleep(), stk::SwitchStrategyRoundRobin::OnTaskSleep(), stk::SwitchStrategySmoothWeightedRoundRobin::OnTaskSleep(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::OnTaskSleepUntil(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::OnTaskWait(), stk::SwitchStrategyEDF::OnTaskWake(), stk::SwitchStrategyFixedPriority< 32 >::OnTaskWake(), stk::SwitchStrategyMonotonic< MSS_TYPE_RATE >::OnTaskWake(), stk::SwitchStrategyRoundRobin::OnTaskWake(), stk::SwitchStrategySmoothWeightedRoundRobin::OnTaskWake(), stk::time::PeriodicTrigger::Poll(), stk::time::TimerHost::ProcessCommands(), stk::time::TimerHost::PushCommand(), stk::sync::RWMutex::ReadUnlock(), stk::util::DListHead< T, _ClosedLoop >::RelinkTo(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::RemoveTask(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::RemoveTask(), stk::SwitchStrategyEDF::RemoveTask(), stk::SwitchStrategyFixedPriority< 32 >::RemoveTask(), stk::SwitchStrategyMonotonic< MSS_TYPE_RATE >::RemoveTask(), stk::SwitchStrategyRoundRobin::RemoveTask(), stk::SwitchStrategySmoothWeightedRoundRobin::RemoveTask(), stk::ISyncObject::RemoveWaitObject(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::RequestAddTask(), stk::time::TimerHost::Restart(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::ScheduleSleep(), stk::sync::Semaphore::Semaphore(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::WaitObject::SetupWait(), stk::sync::Semaphore::Signal(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService::Sleep(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService::SleepUntil(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::Start(), stk::time::TimerHost::Start(), stk::time::TimerHost::StartOrReset(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::StateExit(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::StateSleep(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::StateSwitch(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::StateWake(), stk_cv_create(), stk_cv_notify_all(), stk_cv_notify_one(), stk_cv_wait(), stk_ef_clear(), stk_ef_create(), stk_ef_get(), stk_ef_set(), stk_ef_trywait(), stk_ef_wait(), stk_event_create(), stk_event_pulse(), stk_event_reset(), stk_event_set(), stk_event_trywait(), stk_event_wait(), stk_kernel_add_task(), stk_kernel_add_task_hrt(), stk_kernel_destroy(), stk_kernel_get_state(), stk_kernel_init(), stk_kernel_is_schedulable(), stk_kernel_remove_task(), stk_kernel_start(), stk_mutex_create(), stk_mutex_lock(), stk_mutex_timed_lock(), stk_mutex_trylock(), stk_mutex_unlock(), stk_periodic_trigger_create(), stk_periodic_trigger_get_period(), stk_periodic_trigger_poll(), stk_periodic_trigger_restart(), stk_periodic_trigger_set_period(), stk_pipe_create(), stk_pipe_get_size(), stk_pipe_read(), stk_pipe_read_bulk(), stk_pipe_write(), stk_pipe_write_bulk(), stk_rwmutex_create(), stk_rwmutex_lock(), stk_rwmutex_read_lock(), stk_rwmutex_read_unlock(), stk_rwmutex_timed_lock(), stk_rwmutex_timed_read_lock(), stk_rwmutex_try_read_lock(), stk_rwmutex_trylock(), stk_rwmutex_unlock(), stk_sem_create(), stk_sem_signal(), stk_sem_wait(), stk_spinlock_create(), stk_spinlock_lock(), stk_spinlock_trylock(), stk_spinlock_unlock(), stk_task_create_privileged(), stk_task_create_user(), stk_task_destroy(), stk_task_set_id(), stk_task_set_name(), stk_task_set_priority(), stk_task_set_weight(), stk_timer_create(), stk_timer_destroy(), stk_timer_get_deadline(), stk_timer_get_period(), stk_timer_get_remaining_time(), stk_timer_get_timestamp(), stk_timer_is_active(), stk_timer_reset(), stk_timer_restart(), stk_timer_set_period(), stk_timer_start(), stk_timer_start_or_reset(), stk_timer_stop(), stk_timerhost_get_size(), stk_timerhost_get_time_now(), stk_timerhost_init(), stk_timerhost_is_empty(), stk_timerhost_shutdown(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService::SwitchToNext(), stk::sync::Mutex::TimedLock(), stk::sync::RWMutex::TimedLock(), stk::sync::RWMutex::TimedReadLock(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::Unbind(), stk::util::DListHead< T, _ClosedLoop >::Unlink(), stk::sync::Mutex::Unlock(), stk::sync::RWMutex::Unlock(), stk::sync::SpinLock::Unlock(), stk::test::MutexMock::Unlock(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::UpdateSyncObjects(), stk::time::TimerHost::UpdateTime(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService::Wait(), stk::sync::ConditionVariable::Wait(), stk::sync::Event::Wait(), stk::sync::Semaphore::Wait(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::WaitObject::Wake(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::Wake(), stk::sync::ConditionVariable::~ConditionVariable(), stk::sync::Event::~Event(), stk::sync::Mutex::~Mutex(), stk::test::PlatformTestMock::~PlatformTestMock(), stk::sync::RWMutex::~RWMutex(), stk::sync::Semaphore::~Semaphore(), and stk::sync::SpinLock::~SpinLock().

◆ STK_CRITICAL_SECTION_NESTINGS_MAX

#define STK_CRITICAL_SECTION_NESTINGS_MAX   16

Maximum allowable recursion depth for critical section entry (default: 16).

Note
Establishes a hard deterministic bound for nested calls to Context::EnterCriticalSection() and Context::UnprivEnterCriticalSection(). This limit is mandatory for safety-critical certification (e.g., ISO 26262, IEC 61508) to prevent unbounded stack usage and identify logic deadlocks.
Exceeding this value at runtime shall trigger a Kernel Panic with the code KERNEL_PANIC_CS_NESTING_OVERFLOW to transition the system into a Safe State. Can be overridden in stk_config.h based on Worst-Case Stack Usage (WCSU) analysis.

Definition at line 404 of file stk_defs.h.

◆ STK_ENDIAN_IDX_HI

#define STK_ENDIAN_IDX_HI   (1)

Array index of the high 32-bit word when a 64-bit value is viewed as uint32_t[2].

Note
Big-endian: 0 (high word first). Little-endian: 1 (high word second).
See also
STK_ENDIAN_IDX_LO, hw::ReadVolatile64, hw::WriteVolatile64

Definition at line 502 of file stk_defs.h.

Referenced by stk::hw::ReadVolatile64(), and stk::hw::WriteVolatile64().

◆ STK_ENDIAN_IDX_LO

#define STK_ENDIAN_IDX_LO   (0)

Array index of the low 32-bit word when a 64-bit value is viewed as uint32_t[2].

Note
Big-endian: 1 (low word second). Little-endian: 0 (low word first).
See also
STK_ENDIAN_IDX_HI, hw::ReadVolatile64, hw::WriteVolatile64

Definition at line 503 of file stk_defs.h.

Referenced by stk::hw::ReadVolatile64(), and stk::hw::WriteVolatile64().

◆ STK_NONCOPYABLE_CLASS

#define STK_NONCOPYABLE_CLASS ( TYPE)
Value:
TYPE(const TYPE &) = delete;\
TYPE &operator=(const TYPE &) = delete;

Disables copy construction and assignment for a class.

This macro declares a private copy constructor and copy assignment operator to prevent the compiler from generating default ones. It ensures that instances of a class cannot be duplicated.

Parameters
[in]TYPEThe name of the class to be made non-copyable.
Warning
This macro must be placed within the private or protected section of the class declaration to be effective.
Note
In C++11 and later, it is generally preferred to use = delete, however, this macro provides compatibility for legacy environments.

Definition at line 517 of file stk_defs.h.

517#define STK_NONCOPYABLE_CLASS(TYPE)\
518 TYPE(const TYPE &) = delete;\
519 TYPE &operator=(const TYPE &) = delete;

◆ STK_SLEEP_TRAP_STACK_SIZE

#define STK_SLEEP_TRAP_STACK_SIZE   (STK_STACK_SIZE_MIN)

Stack size for the sleep trap in elements of Word (default: STK_STACK_SIZE_MIN).

See also
Kernel::SleepTrapStackMemory
Note
If IEventOverrider::OnSleep() is overridden with a non-trivial implementation (e.g. calling platform-specific low-power APIs that use the stack), increase this value to accommodate the additional stack frame depth required by that implementation. Can be defined in stk_config.h.

Definition at line 467 of file stk_defs.h.

◆ STK_STACK_MEMORY_ALIGN

#define STK_STACK_MEMORY_ALIGN   4

Stack memory alignment.

Definition at line 389 of file stk_defs.h.

Referenced by stk::PlatformContext::InitStackMemory().

◆ STK_STACK_MEMORY_FILLER

#define STK_STACK_MEMORY_FILLER   ((Word)(sizeof(Word) <= 4 ? 0xdeadbeef : 0xdeadbeefdeadbeef))

Sentinel value written to the entire stack region at initialization (stack watermark pattern).

Note
Used to detect stack overflow and to measure peak stack usage at run-time: any stack word that still contains this value was never written by the task.
Defaults to 0xDEADBEEF on 32-bit targets and 0xDEADBEEFDEADBEEF on 64-bit targets. Can be overridden by defining STK_STACK_MEMORY_FILLER before including this header or in stk_config.h.

Definition at line 377 of file stk_defs.h.

Referenced by stk::PlatformContext::InitStackMemory(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::StateSwitch(), and stk::Kernel< TMode, TSize, TStrategy, TPlatform >::StateWake().

◆ STK_STACK_SIZE_MIN

#define STK_STACK_SIZE_MIN   32

Minimum stack size in elements of Word, shared by all stack allocation lower-bound checks.

See also
TrapStackMemory
Note
This is the smallest stack that can correctly save and restore all CPU registers during a context switch or service trap. The required size depends on the number of registers the architecture mandates saving and specific platform alignment requirements.
Default values by architecture:
  • ARM Cortex-M and RISC-V RV32E (reduced 16-register file): 32 elements.
  • Standard RISC-V (RV32I / RV64I) without FPU: 256 elements (larger register file; smaller sizes may cause memory corruption on RP2350).
  • Standard RISC-V with FPU: 512 elements + (__riscv_flen * 2) (dedicated FP registers significantly expand the required frame size).
Can be overridden to any larger value in stk_config.h if your application's interrupt nesting or stack frame size requires it.

Definition at line 454 of file stk_defs.h.

◆ STK_STATIC_ASSERT

#define STK_STATIC_ASSERT ( X)
Value:
#define STK_STATIC_ASSERT_DESC_N(NAME, X, DESC)
Compile-time assertion with a user-defined name suffix and a custom error description.
Definition stk_defs.h:342

Compile-time assertion. Produces a compilation error if X is false.

Note
Uses a fixed internal symbol name. If more than one STK_STATIC_ASSERT appears in the same scope, use STK_STATIC_ASSERT_N to provide distinct name suffixes and avoid duplicate symbol errors.

Definition at line 367 of file stk_defs.h.

Referenced by stk::hw::PtrToWord(), stk::StackMemoryWrapper<(32)>::StackMemoryWrapper(), and stk::hw::WordToPtr().

◆ STK_STATIC_ASSERT_DESC

#define STK_STATIC_ASSERT_DESC ( X,
DESC )
Value:

Compile-time assertion with a custom error description. Produces a compilation error if X is false.

Note
Uses a fixed internal symbol name. If more than one STK_STATIC_ASSERT_DESC appears in the same scope, use STK_STATIC_ASSERT_DESC_N to provide distinct name suffixes and avoid duplicate symbol errors.

Definition at line 350 of file stk_defs.h.

Referenced by stk::Kernel< TMode, TSize, TStrategy, TPlatform >::Kernel(), and stk::SwitchStrategyFixedPriority< 32 >::SwitchStrategyFixedPriority().

◆ STK_STATIC_ASSERT_DESC_N

#define STK_STATIC_ASSERT_DESC_N ( NAME,
X,
DESC )
Value:
static_assert((X), DESC)

Compile-time assertion with a user-defined name suffix and a custom error description.

Note
NAME is appended to the internal symbol name, allowing multiple assertions in the same scope without symbol-name collisions.
DESC is a string literal shown in the compiler diagnostic — use it to provide a human-readable explanation of the constraint. Prefer this over STK_STATIC_ASSERT_N when the expression alone would not be self-explanatory in a compiler error.

Definition at line 342 of file stk_defs.h.

◆ STK_STATIC_ASSERT_N

#define STK_STATIC_ASSERT_N ( NAME,
X )
Value:

Compile-time assertion with a user-defined name suffix.

Note
NAME is appended to the internal symbol name, allowing multiple assertions in the same scope without symbol-name collisions.
The compiler diagnostic message is the stringified form of expression X. Use STK_STATIC_ASSERT_DESC_N instead when you need a more descriptive error message.

Definition at line 359 of file stk_defs.h.

Referenced by stk::hw::ReadVolatile64(), and stk::hw::WriteVolatile64().

◆ STK_SYNC_DEBUG_NAMES

#define STK_SYNC_DEBUG_NAMES   0

Enable debug names for synchronization primitives (mutexes, events, etc.) for debugging and tracing purposes.

Note
When set to 1, synchronization objects gain a string name field (see ITraceable::SetTraceName) that is visible in SEGGER SystemView and other trace tools.
Automatically set to 1 when STK_SEGGER_SYSVIEW is enabled. Can be manually defined in stk_config.h to override the default.
Default: 0 (disabled) unless STK_SEGGER_SYSVIEW is active.

Definition at line 90 of file stk_defs.h.

◆ STK_TICKLESS_IDLE

#define STK_TICKLESS_IDLE   0

Enables tickless (dynamic-tick) low-power operation during idle periods.

Note
Set to 1 in stk_config.h to activate. Default: 0 (disabled).
When enabled, the tick timer is suppressed while all tasks are sleeping and re-armed for the nearest wakeup deadline, reducing idle power consumption.
Requires the Kernel template to be instantiated with the KERNEL_TICKLESS flag. KERNEL_TICKLESS is incompatible with KERNEL_HRT.
The platform driver must support tickless operation (i.e. implement the variable-advance OnTick overload). Not all platform back-ends support this.
See also
KERNEL_TICKLESS, STK_TICKLESS_USE_ARM_DWT, STK_TICKLESS_TICKS_MAX

Definition at line 36 of file stk_defs.h.

Referenced by stk::IPlatform::IEventHandler::OnTick(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::OnTick(), and stk::test::PlatformTestMock::ProcessTick().

◆ STK_TICKLESS_TICKS_MAX

#define STK_TICKLESS_TICKS_MAX   1000

Maximum number of kernel ticks the hardware timer may be suppressed in one tickless idle interval when STK_TICKLESS_IDLE=1. Default: 1000.

Note
Must not exceed 100000. Values above this limit cause a compile-time error because the internal tick-request calculation uses a uint32_t accumulator that would overflow at higher values.
Increase to allow longer uninterrupted sleep intervals; decrease to improve wakeup responsiveness at the cost of more frequent timer interrupts.
See also
STK_TICKLESS_IDLE, KERNEL_TICKLESS

Definition at line 62 of file stk_defs.h.

Referenced by stk::Kernel< TMode, TSize, TStrategy, TPlatform >::UpdateTaskState().

◆ STK_TICKLESS_USE_ARM_DWT

#define STK_TICKLESS_USE_ARM_DWT   1

Use DWT timer of ARM Cortex-M for a precise tick calculation.

Note
DWT is available on Cortex-M3 and higher only (__CORTEX_M >= 3). It has no effect on Cortex-M0/M0+.
STK_TICKLESS_USE_ARM_DWT has no effect on RISC-V targets. RISC-V tickless uses the CLINT mtime absolute timestamp for drift-free timer rearm and does not require rearm-error compensation.

Definition at line 48 of file stk_defs.h.