[kernel] beautify code (#5890)
This commit is contained in:
parent
4a12bc2ad8
commit
62d2403ebe
|
@ -387,7 +387,7 @@ struct rt_object
|
|||
|
||||
#ifdef RT_USING_MODULE
|
||||
void *module_id; /**< id of application module */
|
||||
#endif
|
||||
#endif /* RT_USING_MODULE */
|
||||
rt_list_t list; /**< list node of kernel object */
|
||||
};
|
||||
typedef struct rt_object *rt_object_t; /**< Type for kernel objects. */
|
||||
|
@ -450,8 +450,8 @@ struct rt_object_information
|
|||
#define __ON_HOOK_ARGS(__hook, argv) do {if ((__hook) != RT_NULL) __hook argv; } while (0)
|
||||
#else
|
||||
#define __ON_HOOK_ARGS(__hook, argv)
|
||||
#endif
|
||||
#endif
|
||||
#endif /* RT_HOOK_USING_FUNC_PTR */
|
||||
#endif /* RT_USING_HOOK */
|
||||
|
||||
#ifndef __on_rt_interrupt_switch_hook
|
||||
#define __on_rt_interrupt_switch_hook() __ON_HOOK_ARGS(rt_interrupt_switch_hook, ())
|
||||
|
@ -528,7 +528,7 @@ typedef void (*rt_sighandler_t)(int signo);
|
|||
typedef siginfo_t rt_siginfo_t;
|
||||
|
||||
#define RT_SIG_MAX 32
|
||||
#endif
|
||||
#endif /* RT_USING_SIGNALS */
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
|
@ -576,11 +576,11 @@ typedef siginfo_t rt_siginfo_t;
|
|||
|
||||
#ifndef RT_SCHEDULE_IPI
|
||||
#define RT_SCHEDULE_IPI 0
|
||||
#endif
|
||||
#endif /* RT_SCHEDULE_IPI */
|
||||
|
||||
#ifndef RT_STOP_IPI
|
||||
#define RT_STOP_IPI 1
|
||||
#endif
|
||||
#endif /* RT_STOP_IPI */
|
||||
|
||||
/**
|
||||
* CPUs definitions
|
||||
|
@ -600,12 +600,12 @@ struct rt_cpu
|
|||
rt_uint8_t ready_table[32];
|
||||
#else
|
||||
rt_uint32_t priority_group;
|
||||
#endif
|
||||
#endif /* RT_THREAD_PRIORITY_MAX > 32 */
|
||||
|
||||
rt_tick_t tick;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif /* RT_USING_SMP */
|
||||
|
||||
/**
|
||||
* Thread structure
|
||||
|
@ -619,7 +619,7 @@ struct rt_thread
|
|||
|
||||
#ifdef RT_USING_MODULE
|
||||
void *module_id; /**< id of application module */
|
||||
#endif
|
||||
#endif /* RT_USING_MODULE */
|
||||
|
||||
rt_list_t list; /**< the object list */
|
||||
rt_list_t tlist; /**< the thread list */
|
||||
|
@ -650,32 +650,32 @@ struct rt_thread
|
|||
#if RT_THREAD_PRIORITY_MAX > 32
|
||||
rt_uint8_t number;
|
||||
rt_uint8_t high_mask;
|
||||
#endif
|
||||
#endif /* RT_THREAD_PRIORITY_MAX > 32 */
|
||||
rt_uint32_t number_mask;
|
||||
|
||||
#if defined(RT_USING_EVENT)
|
||||
#ifdef RT_USING_EVENT
|
||||
/* thread event */
|
||||
rt_uint32_t event_set;
|
||||
rt_uint8_t event_info;
|
||||
#endif
|
||||
#endif /* RT_USING_EVENT */
|
||||
|
||||
#if defined(RT_USING_SIGNALS)
|
||||
#ifdef RT_USING_SIGNALS
|
||||
rt_sigset_t sig_pending; /**< the pending signals */
|
||||
rt_sigset_t sig_mask; /**< the mask bits of signal */
|
||||
|
||||
#ifndef RT_USING_SMP
|
||||
void *sig_ret; /**< the return stack pointer from signal */
|
||||
#endif
|
||||
#endif /* RT_USING_SMP */
|
||||
rt_sighandler_t *sig_vectors; /**< vectors of signal handler */
|
||||
void *si_list; /**< the signal infor list */
|
||||
#endif
|
||||
#endif /* RT_USING_SIGNALS */
|
||||
|
||||
rt_ubase_t init_tick; /**< thread's initialized tick */
|
||||
rt_ubase_t remaining_tick; /**< remaining tick */
|
||||
|
||||
#ifdef RT_USING_CPU_USAGE
|
||||
rt_uint64_t duration_tick; /**< cpu usage tick */
|
||||
#endif
|
||||
#endif /* RT_USING_CPU_USAGE */
|
||||
|
||||
struct rt_timer thread_timer; /**< built-in thread timer */
|
||||
|
||||
|
@ -684,7 +684,7 @@ struct rt_thread
|
|||
/* light weight process if present */
|
||||
#ifdef RT_USING_LWP
|
||||
void *lwp;
|
||||
#endif
|
||||
#endif /* RT_USING_LWP */
|
||||
|
||||
rt_ubase_t user_data; /**< private user data beyond this thread */
|
||||
};
|
||||
|
@ -732,7 +732,7 @@ struct rt_semaphore
|
|||
rt_uint16_t reserved; /**< reserved field */
|
||||
};
|
||||
typedef struct rt_semaphore *rt_sem_t;
|
||||
#endif
|
||||
#endif /* RT_USING_SEMAPHORE */
|
||||
|
||||
#ifdef RT_USING_MUTEX
|
||||
/**
|
||||
|
@ -750,7 +750,7 @@ struct rt_mutex
|
|||
struct rt_thread *owner; /**< current owner of mutex */
|
||||
};
|
||||
typedef struct rt_mutex *rt_mutex_t;
|
||||
#endif
|
||||
#endif /* RT_USING_MUTEX */
|
||||
|
||||
#ifdef RT_USING_EVENT
|
||||
/**
|
||||
|
@ -770,7 +770,7 @@ struct rt_event
|
|||
rt_uint32_t set; /**< event set */
|
||||
};
|
||||
typedef struct rt_event *rt_event_t;
|
||||
#endif
|
||||
#endif /* RT_USING_EVENT */
|
||||
|
||||
#ifdef RT_USING_MAILBOX
|
||||
/**
|
||||
|
@ -791,7 +791,7 @@ struct rt_mailbox
|
|||
rt_list_t suspend_sender_thread; /**< sender thread suspended on this mailbox */
|
||||
};
|
||||
typedef struct rt_mailbox *rt_mailbox_t;
|
||||
#endif
|
||||
#endif /* RT_USING_MAILBOX */
|
||||
|
||||
#ifdef RT_USING_MESSAGEQUEUE
|
||||
/**
|
||||
|
@ -815,7 +815,7 @@ struct rt_messagequeue
|
|||
rt_list_t suspend_sender_thread; /**< sender thread suspended on this message queue */
|
||||
};
|
||||
typedef struct rt_messagequeue *rt_mq_t;
|
||||
#endif
|
||||
#endif /* RT_USING_MESSAGEQUEUE */
|
||||
|
||||
/**@}*/
|
||||
|
||||
|
@ -839,7 +839,7 @@ struct rt_memory
|
|||
rt_size_t max; /**< maximum usage */
|
||||
};
|
||||
typedef struct rt_memory *rt_mem_t;
|
||||
#endif
|
||||
#endif /* RT_USING_HEAP */
|
||||
|
||||
/*
|
||||
* memory management
|
||||
|
@ -848,11 +848,11 @@ typedef struct rt_memory *rt_mem_t;
|
|||
|
||||
#ifdef RT_USING_SMALL_MEM
|
||||
typedef rt_mem_t rt_smem_t;
|
||||
#endif
|
||||
#endif /* RT_USING_SMALL_MEM */
|
||||
|
||||
#ifdef RT_USING_SLAB
|
||||
typedef rt_mem_t rt_slab_t;
|
||||
#endif
|
||||
#endif /* RT_USING_SLAB */
|
||||
|
||||
#ifdef RT_USING_MEMHEAP
|
||||
/**
|
||||
|
@ -870,7 +870,7 @@ struct rt_memheap_item
|
|||
struct rt_memheap_item *prev_free; /**< prev free memheap item */
|
||||
#ifdef RT_USING_MEMTRACE
|
||||
rt_uint8_t owner_thread_name[4]; /**< owner thread name */
|
||||
#endif
|
||||
#endif /* RT_USING_MEMTRACE */
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -894,7 +894,7 @@ struct rt_memheap
|
|||
struct rt_semaphore lock; /**< semaphore lock */
|
||||
rt_bool_t locked; /**< External lock mark */
|
||||
};
|
||||
#endif
|
||||
#endif /* RT_USING_MEMHEAP */
|
||||
|
||||
#ifdef RT_USING_MEMPOOL
|
||||
/**
|
||||
|
@ -916,7 +916,7 @@ struct rt_mempool
|
|||
rt_list_t suspend_thread; /**< threads pended on this resource */
|
||||
};
|
||||
typedef struct rt_mempool *rt_mp_t;
|
||||
#endif
|
||||
#endif /* RT_USING_MEMPOOL */
|
||||
|
||||
/**@}*/
|
||||
|
||||
|
@ -1036,7 +1036,7 @@ struct rt_device_ops
|
|||
rt_size_t (*write) (rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size);
|
||||
rt_err_t (*control)(rt_device_t dev, int cmd, void *args);
|
||||
};
|
||||
#endif
|
||||
#endif /* RT_USING_DEVICE_OPS */
|
||||
|
||||
/**
|
||||
* WaitQueue structure
|
||||
|
@ -1076,12 +1076,12 @@ struct rt_device
|
|||
rt_size_t (*read) (rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size);
|
||||
rt_size_t (*write) (rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size);
|
||||
rt_err_t (*control)(rt_device_t dev, int cmd, void *args);
|
||||
#endif
|
||||
#endif /* RT_USING_DEVICE_OPS */
|
||||
|
||||
#ifdef RT_USING_POSIX_DEVIO
|
||||
const struct dfs_file_ops *fops;
|
||||
struct rt_wqueue wait_queue;
|
||||
#endif
|
||||
#endif /* RT_USING_POSIX_DEVIO */
|
||||
|
||||
void *user_data; /**< device private data */
|
||||
};
|
||||
|
@ -1194,7 +1194,7 @@ struct rt_device_graphic_ops
|
|||
#define rt_graphix_ops(device) ((struct rt_device_graphic_ops *)(device->user_data))
|
||||
|
||||
/**@}*/
|
||||
#endif
|
||||
#endif /* RT_USING_DEVICE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1211,6 +1211,6 @@ enum TICK_WAIT {
|
|||
|
||||
}
|
||||
|
||||
#endif /* end of __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
#endif /* __RT_DEF_H__ */
|
||||
|
|
24
src/thread.c
24
src/thread.c
|
@ -85,8 +85,7 @@ void rt_thread_inited_sethook(void (*hook)(rt_thread_t thread))
|
|||
{
|
||||
rt_thread_inited_hook = hook;
|
||||
}
|
||||
|
||||
#endif /* RT_USING_HOOK */
|
||||
#endif /* defined(RT_USING_HOOK) && defined(RT_HOOK_USING_FUNC_PTR) */
|
||||
|
||||
static void _thread_exit(void)
|
||||
{
|
||||
|
@ -195,7 +194,7 @@ static rt_err_t _thread_init(struct rt_thread *thread,
|
|||
#ifdef RT_USING_EVENT
|
||||
thread->event_set = 0;
|
||||
thread->event_info = 0;
|
||||
#endif
|
||||
#endif /* RT_USING_EVENT */
|
||||
|
||||
#if RT_THREAD_PRIORITY_MAX > 32
|
||||
thread->number = 0;
|
||||
|
@ -251,12 +250,11 @@ static rt_err_t _thread_init(struct rt_thread *thread,
|
|||
|
||||
#ifdef RT_USING_CPU_USAGE
|
||||
thread->duration_tick = 0;
|
||||
#endif
|
||||
|
||||
#endif /* RT_USING_CPU_USAGE */
|
||||
|
||||
#ifdef RT_USING_MODULE
|
||||
thread->module_id = 0;
|
||||
#endif
|
||||
#endif /* RT_USING_MODULE */
|
||||
|
||||
RT_OBJECT_HOOK_CALL(rt_thread_inited_hook, (thread));
|
||||
|
||||
|
@ -473,13 +471,13 @@ rt_thread_t rt_thread_create(const char *name,
|
|||
}
|
||||
|
||||
_thread_init(thread,
|
||||
name,
|
||||
entry,
|
||||
parameter,
|
||||
stack_start,
|
||||
stack_size,
|
||||
priority,
|
||||
tick);
|
||||
name,
|
||||
entry,
|
||||
parameter,
|
||||
stack_start,
|
||||
stack_size,
|
||||
priority,
|
||||
tick);
|
||||
|
||||
return thread;
|
||||
}
|
||||
|
|
|
@ -118,10 +118,10 @@ void rt_timer_exit_sethook(void (*hook)(struct rt_timer *timer))
|
|||
* @param flag the flag of timer
|
||||
*/
|
||||
static void _timer_init(rt_timer_t timer,
|
||||
void (*timeout)(void *parameter),
|
||||
void *parameter,
|
||||
rt_tick_t time,
|
||||
rt_uint8_t flag)
|
||||
void (*timeout)(void *parameter),
|
||||
void *parameter,
|
||||
rt_tick_t time,
|
||||
rt_uint8_t flag)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
Loading…
Reference in New Issue