Browse Source

kernel: timer: update k_timer API for const correctness

API that takes k_timer structures but doesn't change data in them is
updated to const-qualify the underlying object, allowing information
to be retrieved from contexts where the containing object is
immutable.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
pull/28862/head
Peter A. Bigot 5 years ago committed by Carles Cufí
parent
commit
f1b86caff3
  1. 4
      include/kernel.h
  2. 2
      kernel/timer.c

4
include/kernel.h

@ -2024,9 +2024,9 @@ static inline void z_impl_k_timer_user_data_set(struct k_timer *timer, @@ -2024,9 +2024,9 @@ static inline void z_impl_k_timer_user_data_set(struct k_timer *timer,
*
* @return The user data.
*/
__syscall void *k_timer_user_data_get(struct k_timer *timer);
__syscall void *k_timer_user_data_get(const struct k_timer *timer);
static inline void *z_impl_k_timer_user_data_get(struct k_timer *timer)
static inline void *z_impl_k_timer_user_data_get(const struct k_timer *timer)
{
return timer->user_data;
}

2
kernel/timer.c

@ -256,7 +256,7 @@ static inline k_ticks_t z_vrfy_k_timer_expires_ticks(struct k_timer *timer) @@ -256,7 +256,7 @@ static inline k_ticks_t z_vrfy_k_timer_expires_ticks(struct k_timer *timer)
}
#include <syscalls/k_timer_expires_ticks_mrsh.c>
static inline void *z_vrfy_k_timer_user_data_get(struct k_timer *timer)
static inline void *z_vrfy_k_timer_user_data_get(const struct k_timer *timer)
{
Z_OOPS(Z_SYSCALL_OBJ(timer, K_OBJ_TIMER));
return z_impl_k_timer_user_data_get(timer);

Loading…
Cancel
Save