Zephyr API Documentation  3.7.0-rc3
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
LIFO APIs

Macros

#define k_lifo_init(lifo)
 Initialize a LIFO queue.
 
#define k_lifo_put(lifo, data)
 Add an element to a LIFO queue.
 
#define k_lifo_alloc_put(lifo, data)
 Add an element to a LIFO queue.
 
#define k_lifo_get(lifo, timeout)
 Get an element from a LIFO queue.
 
#define K_LIFO_DEFINE(name)
 Statically define and initialize a LIFO queue.
 

Detailed Description

Macro Definition Documentation

◆ k_lifo_alloc_put

#define k_lifo_alloc_put (   lifo,
  data 
)

#include <zephyr/kernel.h>

Value:
({ \
SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_lifo, alloc_put, lifo, data); \
int lap_ret = k_queue_alloc_prepend(&(lifo)->_queue, data); \
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_lifo, alloc_put, lifo, data, lap_ret); \
lap_ret; \
})
int32_t k_queue_alloc_prepend(struct k_queue *queue, void *data)
Prepend an element to a queue.
Definition: kernel.h:2630

Add an element to a LIFO queue.

This routine adds a data item to lifo. There is an implicit memory allocation to create an additional temporary bookkeeping data structure from the calling thread's resource pool, which is automatically freed when the item is removed. The data itself is not copied.

Function properties (list may not be complete)
isr-ok
Parameters
lifoAddress of the LIFO.
dataAddress of the data item.
Return values
0on success
-ENOMEMif there isn't sufficient RAM in the caller's resource pool

◆ K_LIFO_DEFINE

#define K_LIFO_DEFINE (   name)

#include <zephyr/kernel.h>

Value:
Z_LIFO_INITIALIZER(name)
#define STRUCT_SECTION_ITERABLE(struct_type, varname)
Defines a new element for an iterable section.
Definition: iterable_sections.h:216

Statically define and initialize a LIFO queue.

The LIFO queue can be accessed outside the module where it is defined using:

extern struct k_lifo <name>;
Parameters
nameName of the fifo.

◆ k_lifo_get

#define k_lifo_get (   lifo,
  timeout 
)

#include <zephyr/kernel.h>

Value:
({ \
SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_lifo, get, lifo, timeout); \
void *lg_ret = k_queue_get(&(lifo)->_queue, timeout); \
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_lifo, get, lifo, timeout, lg_ret); \
lg_ret; \
})
void * k_queue_get(struct k_queue *queue, k_timeout_t timeout)
Get an element from a queue.

Get an element from a LIFO queue.

This routine removes a data item from LIFO in a "last in, first out" manner. The first word of the data item is reserved for the kernel's use.

Note
timeout must be set to K_NO_WAIT if called from ISR.
Function properties (list may not be complete)
isr-ok
Parameters
lifoAddress of the LIFO queue.
timeoutWaiting period to obtain a data item, or one of the special values K_NO_WAIT and K_FOREVER.
Returns
Address of the data item if successful; NULL if returned without waiting, or waiting period timed out.

◆ k_lifo_init

#define k_lifo_init (   lifo)

#include <zephyr/kernel.h>

Value:
({ \
SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_lifo, init, lifo); \
k_queue_init(&(lifo)->_queue); \
K_OBJ_CORE_INIT(K_OBJ_CORE(lifo), _obj_type_lifo); \
K_OBJ_CORE_LINK(K_OBJ_CORE(lifo)); \
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_lifo, init, lifo); \
})
#define K_OBJ_CORE(kobj)
Convert kernel object pointer into its object core pointer.
Definition: obj_core.h:21

Initialize a LIFO queue.

This routine initializes a LIFO queue object, prior to its first use.

Parameters
lifoAddress of the LIFO queue.

◆ k_lifo_put

#define k_lifo_put (   lifo,
  data 
)

#include <zephyr/kernel.h>

Value:
({ \
SYS_PORT_TRACING_OBJ_FUNC_ENTER(k_lifo, put, lifo, data); \
k_queue_prepend(&(lifo)->_queue, data); \
SYS_PORT_TRACING_OBJ_FUNC_EXIT(k_lifo, put, lifo, data); \
})

Add an element to a LIFO queue.

This routine adds a data item to lifo. A LIFO queue data item must be aligned on a word boundary, and the first word of the item is reserved for the kernel's use.

Function properties (list may not be complete)
isr-ok
Parameters
lifoAddress of the LIFO queue.
dataAddress of the data item.