Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
thread_stack.h File Reference

Macros for declaring thread stacks. More...

#include <arch/cpu.h>
#include <sys/util.h>

Go to the source code of this file.

Macros

#define K_KERNEL_STACK_RESERVED   ((size_t)0)
 
#define K_KERNEL_STACK_EXTERN(sym)   extern k_thread_stack_t sym[]
 Obtain an extern reference to a stack. More...
 
#define K_KERNEL_STACK_ARRAY_EXTERN(sym, nmemb, size)
 Obtain an extern reference to a stack array. More...
 
#define K_KERNEL_PINNED_STACK_ARRAY_EXTERN(sym, nmemb, size)
 Obtain an extern reference to a pinned stack array. More...
 
#define K_KERNEL_STACK_DEFINE(sym, size)    Z_KERNEL_STACK_DEFINE_IN(sym, size, __kstackmem)
 Define a toplevel kernel stack memory region. More...
 
#define K_KERNEL_PINNED_STACK_DEFINE(sym, size)    Z_KERNEL_STACK_DEFINE_IN(sym, size, __kstackmem)
 Define a toplevel kernel stack memory region in pinned section. More...
 
#define K_KERNEL_STACK_ARRAY_DEFINE(sym, nmemb, size)    Z_KERNEL_STACK_ARRAY_DEFINE_IN(sym, nmemb, size, __kstackmem)
 Define a toplevel array of kernel stack memory regions. More...
 
#define K_KERNEL_PINNED_STACK_ARRAY_DEFINE(sym, nmemb, size)    Z_KERNEL_STACK_ARRAY_DEFINE_IN(sym, nmemb, size, __kstackmem)
 Define a toplevel array of kernel stack memory regions in pinned section. More...
 
#define K_KERNEL_STACK_MEMBER(sym, size)    Z_KERNEL_STACK_DEFINE_IN(sym, size,)
 Declare an embedded stack memory region. More...
 
#define K_KERNEL_STACK_SIZEOF(sym)   (sizeof(sym) - K_KERNEL_STACK_RESERVED)
 
#define K_THREAD_STACK_RESERVED   ((size_t)0U)
 Indicate how much additional memory is reserved for stack objects. More...
 
#define K_THREAD_STACK_EXTERN(sym)   extern k_thread_stack_t sym[]
 Obtain an extern reference to a stack. More...
 
#define K_THREAD_STACK_ARRAY_EXTERN(sym, nmemb, size)
 Obtain an extern reference to a thread stack array. More...
 
#define K_THREAD_STACK_SIZEOF(sym)   (sizeof(sym) - K_THREAD_STACK_RESERVED)
 Return the size in bytes of a stack memory region. More...
 
#define K_THREAD_STACK_DEFINE(sym, size)    Z_THREAD_STACK_DEFINE_IN(sym, size, __stackmem)
 Declare a toplevel thread stack memory region. More...
 
#define K_THREAD_PINNED_STACK_DEFINE(sym, size)    K_THREAD_STACK_DEFINE(sym, size)
 Define a toplevel thread stack memory region in pinned section. More...
 
#define K_THREAD_STACK_LEN(size)
 Calculate size of stacks to be allocated in a stack array. More...
 
#define K_THREAD_STACK_ARRAY_DEFINE(sym, nmemb, size)    Z_THREAD_STACK_ARRAY_DEFINE_IN(sym, nmemb, size, __stackmem)
 Declare a toplevel array of thread stack memory regions. More...
 
#define K_THREAD_PINNED_STACK_ARRAY_DEFINE(sym, nmemb, size)    K_THREAD_STACK_ARRAY_DEFINE(sym, nmemb, size)
 Declare a toplevel array of thread stack memory regions in pinned section. More...
 
#define K_THREAD_STACK_MEMBER(sym, size)    Z_THREAD_STACK_DEFINE_IN(sym, size,)
 Declare an embedded stack memory region. More...
 

Detailed Description

Macros for declaring thread stacks.

Macro Definition Documentation

◆ K_KERNEL_STACK_EXTERN

#define K_KERNEL_STACK_EXTERN (   sym)    extern k_thread_stack_t sym[]

Obtain an extern reference to a stack.

This macro properly brings the symbol of a thread stack declared elsewhere into scope.

Parameters
symThread stack symbol name

◆ K_KERNEL_STACK_RESERVED

#define K_KERNEL_STACK_RESERVED   ((size_t)0)

◆ K_THREAD_STACK_ARRAY_EXTERN

#define K_THREAD_STACK_ARRAY_EXTERN (   sym,
  nmemb,
  size 
)
Value:
extern struct z_thread_stack_element \
sym[nmemb][K_THREAD_STACK_LEN(size)]
#define K_THREAD_STACK_LEN(size)
Calculate size of stacks to be allocated in a stack array.
Definition: thread_stack.h:575

Obtain an extern reference to a thread stack array.

This macro properly brings the symbol of a stack array declared elsewhere into scope.

Parameters
symThread stack symbol name
nmembNumber of stacks to declare
sizeSize of the stack memory region

◆ K_THREAD_STACK_EXTERN

#define K_THREAD_STACK_EXTERN (   sym)    extern k_thread_stack_t sym[]

Obtain an extern reference to a stack.

This macro properly brings the symbol of a thread stack declared elsewhere into scope.

Parameters
symThread stack symbol name

◆ K_THREAD_STACK_RESERVED

#define K_THREAD_STACK_RESERVED   ((size_t)0U)

Indicate how much additional memory is reserved for stack objects.

Any given stack declaration may have additional memory in it for guard areas, supervisor mode stacks, or platform-specific data. This macro indicates how much space is reserved for this.

This value only indicates memory that is permanently reserved in the stack object. Memory that is "borrowed" from the thread's stack buffer is never accounted for here.

Reserved memory is at the beginning of the stack object. The reserved area must be appropriately sized such that the stack buffer immediately following it is correctly aligned.