LCOV - code coverage report
Current view: top level - /home/runner/zephyrproject/zephyr/kernel/include - timeout_q.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 52.9 % 17 9
Test Date: 2026-03-12 12:01:18 Functions: 42.9 % 7 3
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /*
       2                 :             :  * Copyright (c) 2015 Wind River Systems, Inc.
       3                 :             :  *
       4                 :             :  * SPDX-License-Identifier: Apache-2.0
       5                 :             :  */
       6                 :             : 
       7                 :             : #ifndef ZEPHYR_KERNEL_INCLUDE_TIMEOUT_Q_H_
       8                 :             : #define ZEPHYR_KERNEL_INCLUDE_TIMEOUT_Q_H_
       9                 :             : 
      10                 :             : /**
      11                 :             :  * @file
      12                 :             :  * @brief timeout queue for threads on kernel objects
      13                 :             :  */
      14                 :             : 
      15                 :             : #include <zephyr/kernel.h>
      16                 :             : 
      17                 :             : #include <stdbool.h>
      18                 :             : 
      19                 :             : #ifdef __cplusplus
      20                 :             : extern "C" {
      21                 :             : #endif
      22                 :             : 
      23                 :             : #ifdef CONFIG_SYS_CLOCK_EXISTS
      24                 :             : 
      25                 :             : /* Value written to dticks when timeout is aborted. */
      26                 :             : #define TIMEOUT_DTICKS_ABORTED (IS_ENABLED(CONFIG_TIMEOUT_64BIT) ? INT64_MIN : INT32_MIN)
      27                 :             : 
      28                 :          48 : static inline void z_init_timeout(struct _timeout *to)
      29                 :             : {
      30                 :          48 :         sys_dnode_init(&to->node);
      31                 :          48 : }
      32                 :             : 
      33                 :             : /* Adds the timeout to the queue.
      34                 :             :  *
      35                 :             :  * @return Absolute tick value when timeout will expire.
      36                 :             :  */
      37                 :             : k_ticks_t z_add_timeout(struct _timeout *to, _timeout_func_t fn, k_timeout_t timeout);
      38                 :             : 
      39                 :             : int z_abort_timeout(struct _timeout *to);
      40                 :             : 
      41                 :           0 : static inline bool z_is_inactive_timeout(const struct _timeout *to)
      42                 :             : {
      43                 :           0 :         return !sys_dnode_is_linked(&to->node);
      44                 :             : }
      45                 :             : 
      46                 :           0 : static inline bool z_is_aborted_timeout(const struct _timeout *to)
      47                 :             : {
      48                 :             :         /* When timeout is aborted then dticks is set to special value. */
      49                 :           0 :         return to->dticks == TIMEOUT_DTICKS_ABORTED;
      50                 :             : }
      51                 :             : 
      52                 :          48 : static inline void z_init_thread_timeout(struct _thread_base *thread_base)
      53                 :             : {
      54                 :          48 :         z_init_timeout(&thread_base->timeout);
      55                 :          48 : }
      56                 :             : 
      57                 :             : extern void z_thread_timeout(struct _timeout *timeout);
      58                 :             : 
      59                 :           0 : static inline k_ticks_t z_add_thread_timeout(struct k_thread *thread, k_timeout_t ticks)
      60                 :             : {
      61                 :           0 :         return z_add_timeout(&thread->base.timeout, z_thread_timeout, ticks);
      62                 :             : }
      63                 :             : 
      64                 :         102 : static inline void z_abort_thread_timeout(struct k_thread *thread)
      65                 :             : {
      66                 :         102 :         z_abort_timeout(&thread->base.timeout);
      67                 :         102 : }
      68                 :             : 
      69                 :           0 : static inline bool z_is_aborted_thread_timeout(struct k_thread *thread)
      70                 :             : {
      71                 :             : 
      72                 :           0 :         return z_is_aborted_timeout(&thread->base.timeout);
      73                 :             : }
      74                 :             : 
      75                 :             : int32_t z_get_next_timeout_expiry(void);
      76                 :             : 
      77                 :             : k_ticks_t z_timeout_remaining(const struct _timeout *timeout);
      78                 :             : 
      79                 :             : #else
      80                 :             : 
      81                 :             : /* Stubs when !CONFIG_SYS_CLOCK_EXISTS */
      82                 :             : #define z_init_thread_timeout(thread_base) do {} while (false)
      83                 :             : #define z_abort_thread_timeout(to) do {} while (false)
      84                 :             : #define z_is_aborted_thread_timeout(to) false
      85                 :             : #define z_is_inactive_timeout(to) 1
      86                 :             : #define z_is_aborted_timeout(to) false
      87                 :             : #define z_get_next_timeout_expiry() ((int32_t) K_TICKS_FOREVER)
      88                 :             : #define z_set_timeout_expiry(ticks, is_idle) do {} while (false)
      89                 :             : 
      90                 :             : static inline k_ticks_t z_add_thread_timeout(struct k_thread *thread, k_timeout_t ticks)
      91                 :             : {
      92                 :             :         ARG_UNUSED(thread);
      93                 :             :         ARG_UNUSED(ticks);
      94                 :             :         return 0;
      95                 :             : }
      96                 :             : 
      97                 :             : #endif /* CONFIG_SYS_CLOCK_EXISTS */
      98                 :             : 
      99                 :             : #ifdef __cplusplus
     100                 :             : }
     101                 :             : #endif
     102                 :             : 
     103                 :             : #endif /* ZEPHYR_KERNEL_INCLUDE_TIMEOUT_Q_H_ */
        

Generated by: LCOV version 2.0-1