kernel: use a union for kobject data values
Rather than stuffing various values in a uintptr_t based on type using casts, use a union for this instead. No functional difference, but the semantics of the data member are now much clearer to the casual observer since it is now formally defined by this union. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
e13bb7e999
commit
f2734ab022
8 changed files with 46 additions and 16 deletions
|
@ -135,6 +135,7 @@ struct k_poll_signal;
|
|||
struct k_mem_domain;
|
||||
struct k_mem_partition;
|
||||
struct k_futex;
|
||||
struct z_futex_data;
|
||||
|
||||
/**
|
||||
* @brief Kernel Object Types
|
||||
|
@ -165,6 +166,24 @@ enum k_objects {
|
|||
*/
|
||||
|
||||
#ifdef CONFIG_USERSPACE
|
||||
/* Object extra data. Only some objects use this, determined by object type */
|
||||
union z_object_data {
|
||||
/* Backing mutex for K_OBJ_SYS_MUTEX */
|
||||
struct k_mutex *mutex;
|
||||
|
||||
/* Numerical thread ID for K_OBJ_THREAD */
|
||||
unsigned int thread_id;
|
||||
|
||||
/* Stack buffer size for K_OBJ__THREAD_STACK_ELEMENT */
|
||||
size_t stack_size;
|
||||
|
||||
/* Futex wait queue and spinlock for K_OBJ_FUTEX */
|
||||
struct z_futex_data *futex_data;
|
||||
|
||||
/* All other objects */
|
||||
int unused;
|
||||
};
|
||||
|
||||
/* Table generated by gperf, these objects are retrieved via
|
||||
* z_object_find() */
|
||||
struct _k_object {
|
||||
|
@ -172,7 +191,7 @@ struct _k_object {
|
|||
u8_t perms[CONFIG_MAX_THREAD_BYTES];
|
||||
u8_t type;
|
||||
u8_t flags;
|
||||
uintptr_t data;
|
||||
union z_object_data data;
|
||||
} __packed __aligned(4);
|
||||
|
||||
struct _k_object_assignment {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue