kernel: rename thread states symbols They are not part of the API, so rename from K_<state> to _THREAD_<state>. Change-Id: Iaebb7d3083b80b9769bee5616e0f96ed2abc5c56 Signed-off-by: Benjamin Walsh <walsh.benj@gmail.com>
diff --git a/kernel/include/kernel_structs.h b/kernel/include/kernel_structs.h index cc381a9..085a797 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 04c430d..d2acb51 100644 --- a/kernel/include/ksched.h +++ b/kernel/include/ksched.h
@@ -274,13 +274,13 @@ /* 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 _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 @@ /* 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 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 _mark_thread_as_dead(struct k_thread *thread) { - thread->base.thread_state |= K_DEAD; + thread->base.thread_state |= _THREAD_DEAD; } /* @@ -454,7 +455,7 @@ /* 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 7f7402d..fc533da 100644 --- a/kernel/mailbox.c +++ b/kernel/mailbox.c
@@ -67,9 +67,9 @@ * 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 @@ 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 @@ * 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 @@ * 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 @@ #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 5b20510..e174cca 100644 --- a/kernel/pipes.c +++ b/kernel/pipes.c
@@ -92,16 +92,16 @@ * 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 @@ 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 f38b398..fa41afc 100644 --- a/kernel/sem.c +++ b/kernel/sem.c
@@ -114,7 +114,8 @@ 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 @@ 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.