From 7835db5ec308d7471ebb95ccef7f74f196deee79 Mon Sep 17 00:00:00 2001 From: Martine Lenders <m.lenders@fu-berlin.de> Date: Thu, 15 Nov 2018 13:53:27 +0100 Subject: [PATCH] core: provide function to check msg queue initialization This makes it easier to refactor that part of the `thread_t` structure later on. --- core/include/thread.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/include/thread.h b/core/include/thread.h index 3a13e379c8..02aa5405dc 100644 --- a/core/include/thread.h +++ b/core/include/thread.h @@ -527,6 +527,26 @@ void thread_stack_print(void); */ void thread_print_stack(void); +/** + * @brief Checks if a thread has an initialized message queue + * + * @see @ref msg_init_queue() + * + * @param[in] thread The thread to check for + * + * @return `== 0`, if @p thread has no initialized message queue + * @return `!= 0`, if @p thread has its message queue initialized + */ +static inline int thread_has_msg_queue(const volatile struct _thread *thread) +{ +#if defined(MODULE_CORE_MSG) || defined(DOXYGEN) + return (thread->msg_array != NULL); +#else + (void)thread; + return 0; +#endif +} + #ifdef __cplusplus } #endif -- GitLab