提交 1cffb60c 编写于 作者: D dzzxzz@gmail.com

fixed the coding style in ipc.c

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2520 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 cb496872
......@@ -68,16 +68,19 @@ rt_inline rt_err_t rt_ipc_object_init(struct rt_ipc_object *ipc)
}
/**
* This function will suspend a thread to a specified list. IPC object or some double-queue
* object (mailbox etc.) contains this kind of list.
* This function will suspend a thread to a specified list. IPC object or some
* double-queue object (mailbox etc.) contains this kind of list.
*
* @param list the IPC suspended thread list
* @param thread the thread object to be suspended
* @param flag the IPC object flag, which shall be RT_IPC_FLAG_FIFO/RT_IPC_FLAG_PRIO.
* @param flag the IPC object flag,
* which shall be RT_IPC_FLAG_FIFO/RT_IPC_FLAG_PRIO.
*
* @return the operation status, RT_EOK on successful
*/
rt_inline rt_err_t rt_ipc_list_suspend(rt_list_t *list, struct rt_thread *thread, rt_uint8_t flag)
rt_inline rt_err_t rt_ipc_list_suspend(rt_list_t *list,
struct rt_thread *thread,
rt_uint8_t flag)
{
/* suspend thread */
rt_thread_suspend(thread);
......@@ -107,7 +110,10 @@ rt_inline rt_err_t rt_ipc_list_suspend(rt_list_t *list, struct rt_thread *thread
}
}
/* not found a suitable position, append to the end of suspend_thread list */
/*
* not found a suitable position,
* append to the end of suspend_thread list
*/
if (n == list)
rt_list_insert_before(list, &(thread->tlist));
}
......@@ -181,8 +187,8 @@ rt_inline rt_err_t rt_ipc_list_resume_all(rt_list_t *list)
#ifdef RT_USING_SEMAPHORE
/**
* This function will initialize a semaphore and put it under control of resource
* management.
* This function will initialize a semaphore and put it under control of
* resource management.
*
* @param sem the semaphore object
* @param name the name of semaphore
......@@ -191,7 +197,10 @@ rt_inline rt_err_t rt_ipc_list_resume_all(rt_list_t *list)
*
* @return the operation status, RT_EOK on successful
*/
rt_err_t rt_sem_init(rt_sem_t sem, const char *name, rt_uint32_t value, rt_uint8_t flag)
rt_err_t rt_sem_init(rt_sem_t sem,
const char *name,
rt_uint32_t value,
rt_uint8_t flag)
{
RT_ASSERT(sem != RT_NULL);
......@@ -356,7 +365,8 @@ rt_err_t rt_sem_take(rt_sem_t sem, rt_int32_t time)
/* suspend thread */
rt_ipc_list_suspend(&(sem->parent.suspend_thread),
thread, sem->parent.parent.flag);
thread,
sem->parent.parent.flag);
/* has waiting time, start thread timer */
if (time > 0)
......@@ -365,7 +375,9 @@ rt_err_t rt_sem_take(rt_sem_t sem, rt_int32_t time)
thread->name));
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer), RT_TIMER_CTRL_SET_TIME, &time);
rt_timer_control(&(thread->thread_timer),
RT_TIMER_CTRL_SET_TIME,
&time);
rt_timer_start(&(thread->thread_timer));
}
......@@ -684,13 +696,15 @@ rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time)
if (thread->current_priority < mutex->owner->current_priority)
{
/* change the owner thread priority */
rt_thread_control(mutex->owner, RT_THREAD_CTRL_CHANGE_PRIORITY,
rt_thread_control(mutex->owner,
RT_THREAD_CTRL_CHANGE_PRIORITY,
&thread->current_priority);
}
/* suspend current thread */
rt_ipc_list_suspend(&(mutex->parent.suspend_thread),
thread, mutex->parent.parent.flag);
thread,
mutex->parent.parent.flag);
/* has waiting time, start thread timer */
if (time > 0)
......@@ -700,7 +714,9 @@ rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time)
thread->name));
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer), RT_TIMER_CTRL_SET_TIME, &time);
rt_timer_control(&(thread->thread_timer),
RT_TIMER_CTRL_SET_TIME,
&time);
rt_timer_start(&(thread->thread_timer));
}
......@@ -781,7 +797,8 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex)
/* change the owner thread to original priority */
if (mutex->original_priority != mutex->owner->current_priority)
{
rt_thread_control(mutex->owner, RT_THREAD_CTRL_CHANGE_PRIORITY,
rt_thread_control(mutex->owner,
RT_THREAD_CTRL_CHANGE_PRIORITY,
&(mutex->original_priority));
}
......@@ -789,7 +806,9 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex)
if (!rt_list_isempty(&mutex->parent.suspend_thread))
{
/* get suspended thread */
thread = rt_list_entry(mutex->parent.suspend_thread.next, struct rt_thread, tlist);
thread = rt_list_entry(mutex->parent.suspend_thread.next,
struct rt_thread,
tlist);
RT_DEBUG_LOG(RT_DEBUG_IPC, ("mutex_release: resume thread: %s\n",
thread->name));
......@@ -1045,8 +1064,8 @@ rt_err_t rt_event_send(rt_event_t event, rt_uint32_t set)
RTM_EXPORT(rt_event_send);
/**
* This function will receive an event from event object, if the event is unavailable,
* the thread shall wait for a specified time.
* This function will receive an event from event object, if the event is
* unavailable, the thread shall wait for a specified time.
*
* @param event the fast event object
* @param set the interested event set
......@@ -1056,7 +1075,11 @@ RTM_EXPORT(rt_event_send);
*
* @return the error code
*/
rt_err_t rt_event_recv(rt_event_t event, rt_uint32_t set, rt_uint8_t option, rt_int32_t timeout, rt_uint32_t *recved)
rt_err_t rt_event_recv(rt_event_t event,
rt_uint32_t set,
rt_uint8_t option,
rt_int32_t timeout,
rt_uint32_t *recved)
{
struct rt_thread *thread;
register rt_ubase_t level;
......@@ -1114,13 +1137,17 @@ rt_err_t rt_event_recv(rt_event_t event, rt_uint32_t set, rt_uint8_t option, rt_
thread->event_info = option;
/* put thread to suspended thread list */
rt_ipc_list_suspend(&(event->parent.suspend_thread), thread, event->parent.parent.flag);
rt_ipc_list_suspend(&(event->parent.suspend_thread),
thread,
event->parent.parent.flag);
/* if there is a waiting timeout, active thread timer */
if (timeout > 0)
{
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer), RT_TIMER_CTRL_SET_TIME, &timeout);
rt_timer_control(&(thread->thread_timer),
RT_TIMER_CTRL_SET_TIME,
&timeout);
rt_timer_start(&(thread->thread_timer));
}
......@@ -1203,7 +1230,11 @@ RTM_EXPORT(rt_event_control);
*
* @return the operation status, RT_EOK on successful
*/
rt_err_t rt_mb_init(rt_mailbox_t mb, const char *name, void *msgpool, rt_size_t size, rt_uint8_t flag)
rt_err_t rt_mb_init(rt_mailbox_t mb,
const char *name,
void *msgpool,
rt_size_t size,
rt_uint8_t flag)
{
RT_ASSERT(mb != RT_NULL);
......@@ -1350,7 +1381,9 @@ RTM_EXPORT(rt_mb_delete);
*
* @return the error code
*/
rt_err_t rt_mb_send_wait(rt_mailbox_t mb, rt_uint32_t value, rt_int32_t timeout)
rt_err_t rt_mb_send_wait(rt_mailbox_t mb,
rt_uint32_t value,
rt_int32_t timeout)
{
struct rt_thread *thread;
register rt_ubase_t temp;
......@@ -1394,7 +1427,9 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb, rt_uint32_t value, rt_int32_t timeout)
RT_DEBUG_NOT_IN_INTERRUPT;
/* suspend current thread */
rt_ipc_list_suspend(&(mb->suspend_sender_thread), thread, mb->parent.parent.flag);
rt_ipc_list_suspend(&(mb->suspend_sender_thread),
thread,
mb->parent.parent.flag);
/* has waiting time, start thread timer */
if (timeout > 0)
......@@ -1406,7 +1441,9 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb, rt_uint32_t value, rt_int32_t timeout)
thread->name));
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer), RT_TIMER_CTRL_SET_TIME, &timeout);
rt_timer_control(&(thread->thread_timer),
RT_TIMER_CTRL_SET_TIME,
&timeout);
rt_timer_start(&(thread->thread_timer));
}
......@@ -1466,9 +1503,9 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb, rt_uint32_t value, rt_int32_t timeout)
RTM_EXPORT(rt_mb_send_wait);
/**
* This function will send a mail to mailbox object, if there are threads suspended
* on mailbox object, it will be waked up. This function will return immediately, if
* you want blocking send, use rt_mb_send_wait instead.
* This function will send a mail to mailbox object, if there are threads
* suspended on mailbox object, it will be waked up. This function will return
* immediately, if you want blocking send, use rt_mb_send_wait instead.
*
* @param mb the mailbox object
* @param value the mail
......@@ -1482,8 +1519,8 @@ rt_err_t rt_mb_send(rt_mailbox_t mb, rt_uint32_t value)
RTM_EXPORT(rt_mb_send);
/**
* This function will receive a mail from mailbox object, if there is no mail in
* mailbox object, the thread shall wait for a specified time.
* This function will receive a mail from mailbox object, if there is no mail
* in mailbox object, the thread shall wait for a specified time.
*
* @param mb the mailbox object
* @param value the received mail will be saved in
......@@ -1537,7 +1574,9 @@ rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_uint32_t *value, rt_int32_t timeout)
RT_DEBUG_NOT_IN_INTERRUPT;
/* suspend current thread */
rt_ipc_list_suspend(&(mb->parent.suspend_thread), thread, mb->parent.parent.flag);
rt_ipc_list_suspend(&(mb->parent.suspend_thread),
thread,
mb->parent.parent.flag);
/* has waiting time, start thread timer */
if (timeout > 0)
......@@ -1549,7 +1588,9 @@ rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_uint32_t *value, rt_int32_t timeout)
thread->name));
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer), RT_TIMER_CTRL_SET_TIME, &timeout);
rt_timer_control(&(thread->thread_timer),
RT_TIMER_CTRL_SET_TIME,
&timeout);
rt_timer_start(&(thread->thread_timer));
}
......@@ -1662,8 +1703,8 @@ struct rt_mq_message
};
/**
* This function will initialize a message queue and put it under control of resource
* management.
* This function will initialize a message queue and put it under control of
* resource management.
*
* @param mq the message object
* @param name the name of message queue
......@@ -1674,7 +1715,12 @@ struct rt_mq_message
*
* @return the operation status, RT_EOK on successful
*/
rt_err_t rt_mq_init(rt_mq_t mq, const char *name, void *msgpool, rt_size_t msg_size, rt_size_t pool_size, rt_uint8_t flag)
rt_err_t rt_mq_init(rt_mq_t mq,
const char *name,
void *msgpool,
rt_size_t msg_size,
rt_size_t pool_size,
rt_uint8_t flag)
{
struct rt_mq_message *head;
register rt_base_t temp;
......@@ -1752,7 +1798,10 @@ RTM_EXPORT(rt_mq_detach);
*
* @return the created message queue, RT_NULL on error happen
*/
rt_mq_t rt_mq_create(const char *name, rt_size_t msg_size, rt_size_t max_msgs, rt_uint8_t flag)
rt_mq_t rt_mq_create(const char *name,
rt_size_t msg_size,
rt_size_t max_msgs,
rt_uint8_t flag)
{
struct rt_messagequeue *mq;
struct rt_mq_message *head;
......@@ -1794,7 +1843,7 @@ rt_mq_t rt_mq_create(const char *name, rt_size_t msg_size, rt_size_t max_msgs, r
mq->msg_queue_free = RT_NULL;
for (temp = 0; temp < mq->max_msgs; temp ++)
{
head = (struct rt_mq_message*)((rt_uint8_t*)mq->msg_pool +
head = (struct rt_mq_message *)((rt_uint8_t *)mq->msg_pool +
temp * (mq->msg_size + sizeof(struct rt_mq_message)));
head->next = mq->msg_queue_free;
mq->msg_queue_free = head;
......@@ -1843,8 +1892,8 @@ RTM_EXPORT(rt_mq_delete);
#endif
/**
* This function will send a message to message queue object, if there are threads
* suspended on message queue object, it will be waked up.
* This function will send a message to message queue object, if there are
* threads suspended on message queue object, it will be waked up.
*
* @param mq the message queue object
* @param buffer the message
......@@ -1930,9 +1979,9 @@ rt_err_t rt_mq_send(rt_mq_t mq, void *buffer, rt_size_t size)
RTM_EXPORT(rt_mq_send);
/**
* This function will send urgently a message to message queue object, which means
* the message will be inserted to the head of message queue. If there are threads
* suspended on message queue object, it will be waked up.
* This function will send an urgent message to message queue object, which
* means the message will be inserted to the head of message queue. If there
* are threads suspended on message queue object, it will be waked up.
*
* @param mq the message queue object
* @param buffer the message
......@@ -2012,8 +2061,9 @@ rt_err_t rt_mq_urgent(rt_mq_t mq, void *buffer, rt_size_t size)
RTM_EXPORT(rt_mq_urgent);
/**
* This function will receive a message from message queue object, if there is no
* message in message queue object, the thread shall wait for a specified time.
* This function will receive a message from message queue object, if there is
* no message in message queue object, the thread shall wait for a specified
* time.
*
* @param mq the message queue object
* @param buffer the received message will be saved in
......@@ -2022,7 +2072,10 @@ RTM_EXPORT(rt_mq_urgent);
*
* @return the error code
*/
rt_err_t rt_mq_recv(rt_mq_t mq, void *buffer, rt_size_t size, rt_int32_t timeout)
rt_err_t rt_mq_recv(rt_mq_t mq,
void *buffer,
rt_size_t size,
rt_int32_t timeout)
{
struct rt_thread *thread;
register rt_ubase_t temp;
......@@ -2070,7 +2123,9 @@ rt_err_t rt_mq_recv(rt_mq_t mq, void *buffer, rt_size_t size, rt_int32_t timeout
}
/* suspend current thread */
rt_ipc_list_suspend(&(mq->parent.suspend_thread), thread, mq->parent.parent.flag);
rt_ipc_list_suspend(&(mq->parent.suspend_thread),
thread,
mq->parent.parent.flag);
/* has waiting time, start thread timer */
if (timeout > 0)
......@@ -2082,7 +2137,9 @@ rt_err_t rt_mq_recv(rt_mq_t mq, void *buffer, rt_size_t size, rt_int32_t timeout
thread->name));
/* reset the timeout of thread timer and start it */
rt_timer_control(&(thread->thread_timer), RT_TIMER_CTRL_SET_TIME, &timeout);
rt_timer_control(&(thread->thread_timer),
RT_TIMER_CTRL_SET_TIME,
&timeout);
rt_timer_start(&(thread->thread_timer));
}
......@@ -2145,7 +2202,8 @@ rt_err_t rt_mq_recv(rt_mq_t mq, void *buffer, rt_size_t size, rt_int32_t timeout
RTM_EXPORT(rt_mq_recv);
/**
* This function can get or set some extra attributions of a message queue object.
* This function can get or set some extra attributions of a message queue
* object.
*
* @param mq the message queue object
* @param cmd the execution command
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册