From a8978aba8fff9f9cdb0b695bfb8211f93a95f606 Mon Sep 17 00:00:00 2001 From: Benjamin Walsh Date: Sun, 22 Jan 2017 11:41:59 -0500 Subject: [PATCH] kernel: rename thread states symbols They are not part of the API, so rename from K_ to _THREAD_. Change-Id: Iaebb7d3083b80b9769bee5616e0f96ed2abc5c56 Signed-off-by: Benjamin Walsh --- arch/arc/core/thread.c | 2 +- arch/arm/core/thread.c | 2 +- arch/nios2/core/thread.c | 2 +- arch/riscv32/core/thread.c | 2 +- arch/x86/core/thread.c | 2 +- kernel/include/kernel_structs.h | 10 +++++----- kernel/include/ksched.h | 25 +++++++++++++------------ kernel/mailbox.c | 14 +++++++------- kernel/pipes.c | 10 +++++----- kernel/sem.c | 5 +++-- 10 files changed, 38 insertions(+), 36 deletions(-) diff --git a/arch/arc/core/thread.c b/arch/arc/core/thread.c index 22f0fc6ea0e..ae9799a3238 100644 --- a/arch/arc/core/thread.c +++ b/arch/arc/core/thread.c @@ -113,7 +113,7 @@ void _new_thread(char *pStackMem, size_t stackSize, pInitCtx->status32 = _ARC_V2_STATUS32_E(_ARC_V2_DEF_IRQ_LEVEL); #endif - _init_thread_base(&thread->base, priority, K_PRESTART, options); + _init_thread_base(&thread->base, priority, _THREAD_PRESTART, options); /* static threads overwrite them afterwards with real values */ thread->init_data = NULL; diff --git a/arch/arm/core/thread.c b/arch/arm/core/thread.c index d01ada481db..71a7695217a 100644 --- a/arch/arm/core/thread.c +++ b/arch/arm/core/thread.c @@ -100,7 +100,7 @@ void _new_thread(char *pStackMem, size_t stackSize, pInitCtx->xpsr = 0x01000000UL; /* clear all, thumb bit is 1, even if RO */ - _init_thread_base(&tcs->base, priority, K_PRESTART, options); + _init_thread_base(&tcs->base, priority, _THREAD_PRESTART, options); /* static threads overwrite it afterwards with real value */ tcs->init_data = NULL; diff --git a/arch/nios2/core/thread.c b/arch/nios2/core/thread.c index 64b4b819f9b..83bdb90774a 100644 --- a/arch/nios2/core/thread.c +++ b/arch/nios2/core/thread.c @@ -76,7 +76,7 @@ void _new_thread(char *stack_memory, size_t stack_size, /* Initialize various struct k_thread members */ thread = (struct k_thread *)stack_memory; - _init_thread_base(&thread->base, priority, K_PRESTART, options); + _init_thread_base(&thread->base, priority, _THREAD_PRESTART, options); /* static threads overwrite it afterwards with real value */ thread->init_data = NULL; diff --git a/arch/riscv32/core/thread.c b/arch/riscv32/core/thread.c index b0f1714361a..8c5d62327bf 100644 --- a/arch/riscv32/core/thread.c +++ b/arch/riscv32/core/thread.c @@ -86,7 +86,7 @@ void _new_thread(char *stack_memory, size_t stack_size, /* Initialize various struct k_thread members */ thread = (struct k_thread *)stack_memory; - _init_thread_base(&thread->base, priority, K_PRESTART, options); + _init_thread_base(&thread->base, priority, _THREAD_PRESTART, options); /* static threads overwrite it afterwards with real value */ thread->init_data = NULL; diff --git a/arch/x86/core/thread.c b/arch/x86/core/thread.c index 61f11ab5748..ff4ebeaf1a5 100644 --- a/arch/x86/core/thread.c +++ b/arch/x86/core/thread.c @@ -77,7 +77,7 @@ static void _new_thread_internal(char *pStackMem, unsigned stackSize, thread->arch.excNestCount = 0; #endif /* CONFIG_FP_SHARING || CONFIG_GDB_INFO */ - _init_thread_base(&thread->base, priority, K_PRESTART, options); + _init_thread_base(&thread->base, priority, _THREAD_PRESTART, options); /* static threads overwrite it afterwards with real value */ thread->init_data = NULL; diff --git a/kernel/include/kernel_structs.h b/kernel/include/kernel_structs.h index cc381a97f05..085a79700d5 100644 --- a/kernel/include/kernel_structs.h +++ b/kernel/include/kernel_structs.h @@ -28,19 +28,19 @@ #define K_ESSENTIAL (1 << 0) /* Thread is waiting on an object */ -#define K_PENDING (1 << 1) +#define _THREAD_PENDING (1 << 1) /* Thread has not yet started */ -#define K_PRESTART (1 << 2) +#define _THREAD_PRESTART (1 << 2) /* Thread has terminated */ -#define K_DEAD (1 << 3) +#define _THREAD_DEAD (1 << 3) /* Thread is suspended */ -#define K_SUSPENDED (1 << 4) +#define _THREAD_SUSPENDED (1 << 4) /* Not a real thread */ -#define K_DUMMY (1 << 5) +#define _THREAD_DUMMY (1 << 5) /* end - states */ diff --git a/kernel/include/ksched.h b/kernel/include/ksched.h index 04c430d07c3..d2acb5111c1 100644 --- a/kernel/include/ksched.h +++ b/kernel/include/ksched.h @@ -274,13 +274,13 @@ static inline void _reset_thread_states(struct k_thread *thread, /* mark a thread as being suspended */ static inline void _mark_thread_as_suspended(struct k_thread *thread) { - thread->base.thread_state |= K_SUSPENDED; + thread->base.thread_state |= _THREAD_SUSPENDED; } /* mark a thread as not being suspended */ static inline void _mark_thread_as_not_suspended(struct k_thread *thread) { - thread->base.thread_state &= ~K_SUSPENDED; + thread->base.thread_state &= ~_THREAD_SUSPENDED; } static ALWAYS_INLINE int _is_thread_timeout_expired(struct k_thread *thread) @@ -304,14 +304,15 @@ static inline int _is_thread_timeout_active(struct k_thread *thread) static inline int _has_thread_started(struct k_thread *thread) { - return !(thread->base.thread_state & K_PRESTART); + return !(thread->base.thread_state & _THREAD_PRESTART); } static inline int _is_thread_prevented_from_running(struct k_thread *thread) { - return thread->base.thread_state & (K_PENDING | K_PRESTART | - K_DEAD | K_DUMMY | - K_SUSPENDED); + uint8_t state = thread->base.thread_state; + + return state & (_THREAD_PENDING | _THREAD_PRESTART | _THREAD_DEAD | + _THREAD_DUMMY | _THREAD_SUSPENDED); } @@ -325,19 +326,19 @@ static inline int _is_thread_ready(struct k_thread *thread) /* mark a thread as pending in its TCS */ static inline void _mark_thread_as_pending(struct k_thread *thread) { - thread->base.thread_state |= K_PENDING; + thread->base.thread_state |= _THREAD_PENDING; } /* mark a thread as not pending in its TCS */ static inline void _mark_thread_as_not_pending(struct k_thread *thread) { - thread->base.thread_state &= ~K_PENDING; + thread->base.thread_state &= ~_THREAD_PENDING; } /* check if a thread is pending */ static inline int _is_thread_pending(struct k_thread *thread) { - return !!(thread->base.thread_state & K_PENDING); + return !!(thread->base.thread_state & _THREAD_PENDING); } /** @@ -347,7 +348,7 @@ static inline int _is_thread_pending(struct k_thread *thread) */ static inline void _mark_thread_as_started(struct k_thread *thread) { - thread->base.thread_state &= ~K_PRESTART; + thread->base.thread_state &= ~_THREAD_PRESTART; } /* @@ -385,7 +386,7 @@ static inline void _ready_thread(struct k_thread *thread) */ static inline void _mark_thread_as_dead(struct k_thread *thread) { - thread->base.thread_state |= K_DEAD; + thread->base.thread_state |= _THREAD_DEAD; } /* @@ -454,7 +455,7 @@ static inline struct k_thread *_unpend_first_thread(_wait_q_t *wait_q) /* must be called with interrupts locked */ static inline void _unpend_thread(struct k_thread *thread) { - __ASSERT(thread->base.thread_state & K_PENDING, ""); + __ASSERT(thread->base.thread_state & _THREAD_PENDING, ""); sys_dlist_remove(&thread->base.k_q_node); _mark_thread_as_not_pending(thread); diff --git a/kernel/mailbox.c b/kernel/mailbox.c index 7f7402dd3e9..fc533daf945 100644 --- a/kernel/mailbox.c +++ b/kernel/mailbox.c @@ -67,9 +67,9 @@ static int init_mbox_module(struct device *dev) * Create pool of asynchronous message descriptors. * * A dummy thread requires minimal initialization, since it never gets - * to execute. The K_DUMMY flag is sufficient to distinguish a dummy - * thread from a real one. The threads are *not* added to the kernel's - * list of known threads. + * to execute. The _THREAD_DUMMY flag is sufficient to distinguish a + * dummy thread from a real one. The threads are *not* added to the + * kernel's list of known threads. * * Once initialized, the address of each descriptor is added to a stack * that governs access to them. @@ -78,7 +78,7 @@ static int init_mbox_module(struct device *dev) int i; for (i = 0; i < CONFIG_NUM_MBOX_ASYNC_MSGS; i++) { - _init_thread_base(&async_msg[i].thread, 0, K_DUMMY, 0); + _init_thread_base(&async_msg[i].thread, 0, _THREAD_DUMMY, 0); k_stack_push(&async_msg_free, (uint32_t)&async_msg[i]); } #endif /* CONFIG_NUM_MBOX_ASYNC_MSGS > 0 */ @@ -201,7 +201,7 @@ static void _mbox_message_dispose(struct k_mbox_msg *rx_msg) * asynchronous send: free asynchronous message descriptor + * dummy thread pair, then give semaphore (if needed) */ - if (sending_thread->base.thread_state & K_DUMMY) { + if (sending_thread->base.thread_state & _THREAD_DUMMY) { struct k_sem *async_sem = tx_msg->_async_sem; _mbox_async_free((struct k_mbox_async *)sending_thread); @@ -276,7 +276,7 @@ static int _mbox_message_put(struct k_mbox *mbox, struct k_mbox_msg *tx_msg, * note: dummy sending thread sits (unqueued) * until the receiver consumes the message */ - if (sending_thread->base.thread_state & K_DUMMY) { + if (sending_thread->base.thread_state & _THREAD_DUMMY) { _reschedule_threads(key); return 0; } @@ -300,7 +300,7 @@ static int _mbox_message_put(struct k_mbox *mbox, struct k_mbox_msg *tx_msg, #if (CONFIG_NUM_MBOX_ASYNC_MSGS > 0) /* asynchronous send: dummy thread waits on tx queue for receiver */ - if (sending_thread->base.thread_state & K_DUMMY) { + if (sending_thread->base.thread_state & _THREAD_DUMMY) { _pend_thread(sending_thread, &mbox->tx_msg_queue, K_FOREVER); irq_unlock(key); return 0; diff --git a/kernel/pipes.c b/kernel/pipes.c index 5b205106095..e174ccac495 100644 --- a/kernel/pipes.c +++ b/kernel/pipes.c @@ -92,16 +92,16 @@ static int init_pipes_module(struct device *dev) * Create pool of asynchronous pipe message descriptors. * * A dummy thread requires minimal initialization, since it never gets - * to execute. The K_DUMMY flag is sufficient to distinguish a dummy - * thread from a real one. The threads are *not* added to the kernel's - * list of known threads. + * to execute. The _THREAD_DUMMY flag is sufficient to distinguish a + * dummy thread from a real one. The threads are *not* added to the + * kernel's list of known threads. * * Once initialized, the address of each descriptor is added to a stack * that governs access to them. */ for (int i = 0; i < CONFIG_NUM_PIPE_ASYNC_MSGS; i++) { - async_msg[i].thread.thread_state = K_DUMMY; + async_msg[i].thread.thread_state = _THREAD_DUMMY; async_msg[i].thread.swap_data = &async_msg[i].desc; k_stack_push(&pipe_async_msgs, (uint32_t)&async_msg[i]); } @@ -367,7 +367,7 @@ static void _pipe_thread_ready(struct k_thread *thread) unsigned int key; #if (CONFIG_NUM_PIPE_ASYNC_MSGS > 0) - if (thread->base.thread_state & K_DUMMY) { + if (thread->base.thread_state & _THREAD_DUMMY) { _pipe_async_finish((struct k_pipe_async *)thread); return; } diff --git a/kernel/sem.c b/kernel/sem.c index f38b398fae3..fa41afcebd4 100644 --- a/kernel/sem.c +++ b/kernel/sem.c @@ -114,7 +114,8 @@ int k_sem_group_take(struct k_sem *sem_array[], struct k_sem **sem, for (int i = 0; i < num; i++) { - _init_thread_base(&wait_objects[i].dummy, priority, K_DUMMY, 0); + _init_thread_base(&wait_objects[i].dummy, priority, + _THREAD_DUMMY, 0); sys_dlist_append(&list, &wait_objects[i].desc.semg_node); wait_objects[i].desc.thread = _current; @@ -160,7 +161,7 @@ static int handle_sem_group(struct k_sem *sem, struct k_thread *thread) sys_dnode_t *node; sys_dnode_t *next; - if (!(thread->base.thread_state & K_DUMMY)) { + if (!(thread->base.thread_state & _THREAD_DUMMY)) { /* * The awakened thread is a real thread and thus was not * involved in a semaphore group operation.