From 405678552dd1aeaf6755d4878b373a5bc4fa1042 Mon Sep 17 00:00:00 2001 From: dzzxzz Date: Mon, 19 Sep 2011 07:15:31 +0000 Subject: [PATCH] cleanup code in ipc.c and idle.c git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1713 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- src/idle.c | 14 ++--- src/ipc.c | 173 +++++++++++++++++++++++++---------------------------- 2 files changed, 88 insertions(+), 99 deletions(-) diff --git a/src/idle.c b/src/idle.c index 7bda4dc69..cc03bd499 100644 --- a/src/idle.c +++ b/src/idle.c @@ -1,7 +1,7 @@ /* * File : idle.c * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team + * COPYRIGHT (C) 2006 - 2011, RT-Thread Development Team * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -83,7 +83,7 @@ void rt_thread_idle_excute(void) module = (rt_module_t)thread->module_id; /* if the thread is module's main thread */ - if(module != RT_NULL && module->module_thread == thread) + if (module != RT_NULL && module->module_thread == thread) { /* detach module's main thread */ module->module_thread = RT_NULL; @@ -117,7 +117,7 @@ void rt_thread_idle_excute(void) #ifdef RT_USING_HEAP #if defined(RT_USING_MODULE) && defined(RT_USING_SLAB) /* the thread belongs to an application module */ - if(thread->flags & RT_OBJECT_FLAG_MODULE) + if (thread->flags & RT_OBJECT_FLAG_MODULE) rt_module_free((rt_module_t)thread->module_id, thread->stack_addr); else #endif @@ -128,10 +128,10 @@ void rt_thread_idle_excute(void) #endif #ifdef RT_USING_MODULE - if(module != RT_NULL) + if (module != RT_NULL) { /* if sub thread list and main thread are all empty */ - if((module->module_thread == RT_NULL) && + if ((module->module_thread == RT_NULL) && rt_list_isempty(&module->module_object[RT_Object_Class_Thread].object_list) ) { module->nref--; @@ -139,7 +139,7 @@ void rt_thread_idle_excute(void) } /* unload module */ - if(module->nref == 0) rt_module_unload(module); + if (module->nref == 0) rt_module_unload(module); #endif } } @@ -164,7 +164,7 @@ static void rt_thread_idle_entry(void* parameter) * * @note this function must be invoked when system init. */ -void rt_thread_idle_init() +void rt_thread_idle_init(void) { /* init thread */ rt_thread_init(&idle, diff --git a/src/ipc.c b/src/ipc.c index 7c2cf50b2..92adfe4e7 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -1,7 +1,7 @@ /* * File : ipc.c * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006 - 2009, RT-Thread Development Team + * COPYRIGHT (C) 2006 - 2011, RT-Thread Development Team * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -126,14 +126,14 @@ rt_inline rt_err_t rt_ipc_list_suspend(rt_list_t *list, struct rt_thread *thread * * @return the operation status, RT_EOK on successful */ -rt_inline rt_err_t rt_ipc_list_resume(rt_list_t *list) +rt_inline rt_err_t rt_ipc_list_resume(rt_list_t* list) { - struct rt_thread *thread; + struct rt_thread* thread; /* get thread entry */ thread = rt_list_entry(list->next, struct rt_thread, tlist); - RT_DEBUG_LOG(RT_DEBUG_IPC,("resume thread:%s\n", thread->name)); + RT_DEBUG_LOG(RT_DEBUG_IPC, ("resume thread:%s\n", thread->name)); /* resume it */ rt_thread_resume(thread); @@ -149,7 +149,7 @@ rt_inline rt_err_t rt_ipc_list_resume(rt_list_t *list) * * @return the operation status, RT_EOK on successful */ -rt_inline rt_err_t rt_ipc_list_resume_all(rt_list_t *list) +rt_inline rt_err_t rt_ipc_list_resume_all(rt_list_t* list) { struct rt_thread* thread; register rt_ubase_t temp; @@ -180,7 +180,6 @@ 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. @@ -192,7 +191,7 @@ 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); @@ -203,7 +202,7 @@ rt_err_t rt_sem_init (rt_sem_t sem, const char* name, rt_uint32_t value, rt_uint rt_ipc_object_init(&(sem->parent)); /* set init value */ - sem->value = value; + sem->value = value; /* set parent */ sem->parent.parent.flag = flag; @@ -220,7 +219,7 @@ rt_err_t rt_sem_init (rt_sem_t sem, const char* name, rt_uint32_t value, rt_uint * * @see rt_sem_delete */ -rt_err_t rt_sem_detach (rt_sem_t sem) +rt_err_t rt_sem_detach(rt_sem_t sem) { RT_ASSERT(sem != RT_NULL); @@ -245,14 +244,14 @@ rt_err_t rt_sem_detach (rt_sem_t sem) * * @see rt_sem_init */ -rt_sem_t rt_sem_create (const char* name, rt_uint32_t value, rt_uint8_t flag) +rt_sem_t rt_sem_create(const char* name, rt_uint32_t value, rt_uint8_t flag) { rt_sem_t sem; RT_DEBUG_NOT_IN_INTERRUPT; /* allocate object */ - sem = (rt_sem_t) rt_object_allocate(RT_Object_Class_Semaphore, name); + sem = (rt_sem_t)rt_object_allocate(RT_Object_Class_Semaphore, name); if (sem == RT_NULL) return sem; /* init ipc object */ @@ -276,7 +275,7 @@ rt_sem_t rt_sem_create (const char* name, rt_uint32_t value, rt_uint8_t flag) * * @see rt_sem_detach */ -rt_err_t rt_sem_delete (rt_sem_t sem) +rt_err_t rt_sem_delete(rt_sem_t sem) { RT_DEBUG_NOT_IN_INTERRUPT; @@ -301,7 +300,7 @@ rt_err_t rt_sem_delete (rt_sem_t sem) * * @return the error code */ -rt_err_t rt_sem_take (rt_sem_t sem, rt_int32_t time) +rt_err_t rt_sem_take(rt_sem_t sem, rt_int32_t time) { register rt_base_t temp; struct rt_thread* thread; @@ -355,7 +354,7 @@ rt_err_t rt_sem_take (rt_sem_t sem, rt_int32_t time) /* has waiting time, start thread timer */ if (time > 0) { - RT_DEBUG_LOG(RT_DEBUG_IPC,("set thread:%s to timer list\n", thread->name)); + RT_DEBUG_LOG(RT_DEBUG_IPC, ("set thread:%s to timer list\n", thread->name)); /* reset the timeout of thread timer and start it */ rt_timer_control(&(thread->thread_timer), RT_TIMER_CTRL_SET_TIME, &time); @@ -417,7 +416,7 @@ rt_err_t rt_sem_release(rt_sem_t sem) ((struct rt_object*)sem)->name, sem->value)); - if ( !rt_list_isempty(&sem->parent.suspend_thread) ) + if (!rt_list_isempty(&sem->parent.suspend_thread)) { /* resume the suspended thread */ rt_ipc_list_resume(&(sem->parent.suspend_thread)); @@ -471,11 +470,9 @@ rt_err_t rt_sem_control(rt_sem_t sem, rt_uint8_t cmd, void* arg) return -RT_ERROR; } - #endif /* end of RT_USING_SEMAPHORE */ #ifdef RT_USING_MUTEX - /** * This function will initialize a mutex and put it under control of resource * management. @@ -486,7 +483,7 @@ rt_err_t rt_sem_control(rt_sem_t sem, rt_uint8_t cmd, void* arg) * * @return the operation status, RT_EOK on successful */ -rt_err_t rt_mutex_init (rt_mutex_t mutex, const char* name, rt_uint8_t flag) +rt_err_t rt_mutex_init(rt_mutex_t mutex, const char* name, rt_uint8_t flag) { RT_ASSERT(mutex != RT_NULL); @@ -516,7 +513,7 @@ rt_err_t rt_mutex_init (rt_mutex_t mutex, const char* name, rt_uint8_t flag) * * @see rt_mutex_delete */ -rt_err_t rt_mutex_detach (rt_mutex_t mutex) +rt_err_t rt_mutex_detach(rt_mutex_t mutex) { RT_ASSERT(mutex != RT_NULL); @@ -540,14 +537,14 @@ rt_err_t rt_mutex_detach (rt_mutex_t mutex) * * @see rt_mutex_init */ -rt_mutex_t rt_mutex_create (const char* name, rt_uint8_t flag) +rt_mutex_t rt_mutex_create(const char* name, rt_uint8_t flag) { - struct rt_mutex *mutex; + struct rt_mutex* mutex; RT_DEBUG_NOT_IN_INTERRUPT; /* allocate object */ - mutex = (rt_mutex_t) rt_object_allocate(RT_Object_Class_Mutex, name); + mutex = (rt_mutex_t)rt_object_allocate(RT_Object_Class_Mutex, name); if (mutex == RT_NULL) return mutex; /* init ipc object */ @@ -573,7 +570,7 @@ rt_mutex_t rt_mutex_create (const char* name, rt_uint8_t flag) * * @see rt_mutex_detach */ -rt_err_t rt_mutex_delete (rt_mutex_t mutex) +rt_err_t rt_mutex_delete(rt_mutex_t mutex) { RT_DEBUG_NOT_IN_INTERRUPT; @@ -598,7 +595,7 @@ rt_err_t rt_mutex_delete (rt_mutex_t mutex) * * @return the error code */ -rt_err_t rt_mutex_take (rt_mutex_t mutex, rt_int32_t time) +rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time) { register rt_base_t temp; struct rt_thread* thread; @@ -646,7 +643,7 @@ rt_err_t rt_mutex_take (rt_mutex_t mutex, rt_int32_t time) else { /* no waiting, return with timeout */ - if (time == 0 ) + if (time == 0) { /* set error as timeout */ thread->error = -RT_ETIMEOUT; @@ -766,7 +763,7 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex) } /* wakeup suspended thread */ - if( !rt_list_isempty(&mutex->parent.suspend_thread) ) + if (!rt_list_isempty(&mutex->parent.suspend_thread)) { /* get suspended thread */ thread = rt_list_entry(mutex->parent.suspend_thread.next, struct rt_thread, tlist); @@ -817,11 +814,9 @@ rt_err_t rt_mutex_control(rt_mutex_t mutex, rt_uint8_t cmd, void* arg) { return -RT_ERROR; } - #endif /* end of RT_USING_MUTEX */ #ifdef RT_USING_EVENT - /** * This function will initialize an event and put it under control of resource * management. @@ -881,14 +876,14 @@ rt_err_t rt_event_detach(rt_event_t event) * * @return the created event, RT_NULL on error happen */ -rt_event_t rt_event_create (const char* name, rt_uint8_t flag) +rt_event_t rt_event_create(const char* name, rt_uint8_t flag) { rt_event_t event; RT_DEBUG_NOT_IN_INTERRUPT; /* allocate object */ - event = (rt_event_t) rt_object_allocate(RT_Object_Class_Event, name); + event = (rt_event_t)rt_object_allocate(RT_Object_Class_Event, name); if (event == RT_NULL) return event; /* set parent */ @@ -910,7 +905,7 @@ rt_event_t rt_event_create (const char* name, rt_uint8_t flag) * * @return the error code */ -rt_err_t rt_event_delete (rt_event_t event) +rt_err_t rt_event_delete(rt_event_t event) { /* parameter check */ RT_ASSERT(event != RT_NULL); @@ -938,8 +933,8 @@ rt_err_t rt_event_delete (rt_event_t event) */ rt_err_t rt_event_send(rt_event_t event, rt_uint32_t set) { - struct rt_list_node *n; - struct rt_thread *thread; + struct rt_list_node* n; + struct rt_thread* thread; register rt_ubase_t level; register rt_base_t status; rt_bool_t need_schedule; @@ -957,7 +952,7 @@ rt_err_t rt_event_send(rt_event_t event, rt_uint32_t set) /* set event */ event->set |= set; - if( !rt_list_isempty(&event->parent.suspend_thread) ) + if (!rt_list_isempty(&event->parent.suspend_thread)) { /* search thread list to resume thread */ n = event->parent.suspend_thread.next; @@ -1002,7 +997,6 @@ rt_err_t rt_event_send(rt_event_t event, rt_uint32_t set) /* need do a scheduling */ need_schedule = RT_TRUE; - } } } @@ -1031,7 +1025,7 @@ rt_err_t rt_event_send(rt_event_t event, rt_uint32_t set) */ 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; + struct rt_thread* thread; register rt_ubase_t level; register rt_base_t status; @@ -1102,7 +1096,7 @@ rt_err_t rt_event_recv(rt_event_t event, rt_uint32_t set, rt_uint8_t option, rt_ if (thread->error != RT_EOK) { - /* return error */ + /* return error */ return thread->error; } @@ -1130,7 +1124,7 @@ rt_err_t rt_event_recv(rt_event_t event, rt_uint32_t set, rt_uint8_t option, rt_ * * @return the error code */ -rt_err_t rt_event_control (rt_event_t event, rt_uint8_t cmd, void* arg) +rt_err_t rt_event_control(rt_event_t event, rt_uint8_t cmd, void* arg) { rt_ubase_t level; RT_ASSERT(event != RT_NULL); @@ -1154,11 +1148,9 @@ rt_err_t rt_event_control (rt_event_t event, rt_uint8_t cmd, void* arg) return -RT_ERROR; } - #endif /* end of RT_USING_EVENT */ #ifdef RT_USING_MAILBOX - /** * This function will initialize a mailbox and put it under control of resource * management. @@ -1186,10 +1178,10 @@ rt_err_t rt_mb_init(rt_mailbox_t mb, const char* name, void* msgpool, rt_size_t /* init mailbox */ mb->msg_pool = msgpool; - mb->size = size; - mb->entry = 0; - mb->in_offset = 0; - mb->out_offset = 0; + mb->size = size; + mb->entry = 0; + mb->in_offset = 0; + mb->out_offset = 0; /* init an additional list of sender suspend thread */ rt_list_init(&(mb->suspend_sender_thread)); @@ -1230,14 +1222,14 @@ rt_err_t rt_mb_detach(rt_mailbox_t mb) * * @return the created mailbox, RT_NULL on error happen */ -rt_mailbox_t rt_mb_create (const char* name, rt_size_t size, rt_uint8_t flag) +rt_mailbox_t rt_mb_create(const char* name, rt_size_t size, rt_uint8_t flag) { rt_mailbox_t mb; RT_DEBUG_NOT_IN_INTERRUPT; /* allocate object */ - mb = (rt_mailbox_t) rt_object_allocate(RT_Object_Class_MailBox, name); + mb = (rt_mailbox_t)rt_object_allocate(RT_Object_Class_MailBox, name); if (mb == RT_NULL) return mb; /* set parent */ @@ -1247,8 +1239,8 @@ rt_mailbox_t rt_mb_create (const char* name, rt_size_t size, rt_uint8_t flag) rt_ipc_object_init(&(mb->parent)); /* init mailbox */ - mb->size = size; - mb->msg_pool = rt_malloc(mb->size * sizeof(rt_uint32_t)); + mb->size = size; + mb->msg_pool = rt_malloc(mb->size * sizeof(rt_uint32_t)); if (mb->msg_pool == RT_NULL) { /* delete mailbox object */ @@ -1256,9 +1248,9 @@ rt_mailbox_t rt_mb_create (const char* name, rt_size_t size, rt_uint8_t flag) return RT_NULL; } - mb->entry = 0; - mb->in_offset = 0; - mb->out_offset = 0; + mb->entry = 0; + mb->in_offset = 0; + mb->out_offset = 0; /* init an additional list of sender suspend thread */ rt_list_init(&(mb->suspend_sender_thread)); @@ -1273,7 +1265,7 @@ rt_mailbox_t rt_mb_create (const char* name, rt_size_t size, rt_uint8_t flag) * * @return the error code */ -rt_err_t rt_mb_delete (rt_mailbox_t mb) +rt_err_t rt_mb_delete(rt_mailbox_t mb) { RT_DEBUG_NOT_IN_INTERRUPT; @@ -1288,7 +1280,7 @@ rt_err_t rt_mb_delete (rt_mailbox_t mb) #if defined(RT_USING_MODULE) && defined(RT_USING_SLAB) /* the mb object belongs to an application module */ - if(mb->parent.parent.flag & RT_OBJECT_FLAG_MODULE) + if (mb->parent.parent.flag & RT_OBJECT_FLAG_MODULE) rt_module_free(mb->parent.parent.module_id, mb->msg_pool); else #endif @@ -1313,9 +1305,9 @@ rt_err_t rt_mb_delete (rt_mailbox_t mb) * * @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; + struct rt_thread* thread; register rt_ubase_t temp; rt_uint32_t tick_delta; @@ -1348,10 +1340,10 @@ rt_err_t rt_mb_send_wait (rt_mailbox_t mb, rt_uint32_t value, rt_int32_t timeout /* no waiting, return timeout */ if (timeout == 0) { - /* enable interrupt */ - rt_hw_interrupt_enable(temp); - return -RT_EFULL; - } + /* enable interrupt */ + rt_hw_interrupt_enable(temp); + return -RT_EFULL; + } RT_DEBUG_NOT_IN_INTERRUPT; /* suspend current thread */ @@ -1381,7 +1373,7 @@ rt_err_t rt_mb_send_wait (rt_mailbox_t mb, rt_uint32_t value, rt_int32_t timeout /* resume from suspend state */ if (thread->error != RT_EOK) { - /* return error */ + /* return error */ return thread->error; } @@ -1433,9 +1425,9 @@ rt_err_t rt_mb_send_wait (rt_mailbox_t mb, rt_uint32_t value, rt_int32_t timeout * * @return the error code */ -rt_err_t rt_mb_send (rt_mailbox_t mb, rt_uint32_t value) +rt_err_t rt_mb_send(rt_mailbox_t mb, rt_uint32_t value) { - return rt_mb_send_wait(mb,value,0); + return rt_mb_send_wait(mb, value, 0); } /** @@ -1448,9 +1440,9 @@ rt_err_t rt_mb_send (rt_mailbox_t mb, rt_uint32_t value) * * @return the error code */ -rt_err_t rt_mb_recv (rt_mailbox_t mb, rt_uint32_t* value, rt_int32_t timeout) +rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_uint32_t* value, rt_int32_t timeout) { - struct rt_thread *thread; + struct rt_thread* thread; register rt_ubase_t temp; rt_uint32_t tick_delta; @@ -1518,7 +1510,7 @@ rt_err_t rt_mb_recv (rt_mailbox_t mb, rt_uint32_t* value, rt_int32_t timeout) /* resume from suspend state */ if (thread->error != RT_EOK) { - /* return error */ + /* return error */ return thread->error; } @@ -1592,9 +1584,9 @@ rt_err_t rt_mb_control(rt_mailbox_t mb, rt_uint8_t cmd, void* arg) rt_ipc_list_resume_all(&(mb->suspend_sender_thread)); /* re-init mailbox */ - mb->entry = 0; - mb->in_offset = 0; - mb->out_offset = 0; + mb->entry = 0; + mb->in_offset = 0; + mb->out_offset = 0; /* enable interrupt */ rt_hw_interrupt_enable(level); @@ -1604,11 +1596,9 @@ rt_err_t rt_mb_control(rt_mailbox_t mb, rt_uint8_t cmd, void* arg) return -RT_ERROR; } - #endif /* end of RT_USING_MAILBOX */ #ifdef RT_USING_MESSAGEQUEUE - struct rt_mq_message { struct rt_mq_message* next; @@ -1645,11 +1635,11 @@ rt_err_t rt_mq_init(rt_mq_t mq, const char* name, void *msgpool, rt_size_t msg_s rt_ipc_object_init(&(mq->parent)); /* set messasge pool */ - mq->msg_pool = msgpool; + mq->msg_pool = msgpool; /* get correct message size */ - mq->msg_size = RT_ALIGN(msg_size, RT_ALIGN_SIZE); - mq->max_msgs = pool_size / (mq->msg_size + sizeof(struct rt_mq_message)); + mq->msg_size = RT_ALIGN(msg_size, RT_ALIGN_SIZE); + mq->max_msgs = pool_size / (mq->msg_size + sizeof(struct rt_mq_message)); /* init message list */ mq->msg_queue_head = RT_NULL; @@ -1666,7 +1656,7 @@ rt_err_t rt_mq_init(rt_mq_t mq, const char* name, void *msgpool, rt_size_t msg_s } /* the initial entry is zero */ - mq->entry = 0; + mq->entry = 0; return RT_EOK; } @@ -1703,7 +1693,7 @@ rt_err_t rt_mq_detach(rt_mq_t mq) * * @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; @@ -1712,7 +1702,7 @@ rt_mq_t rt_mq_create (const char* name, rt_size_t msg_size, rt_size_t max_msgs, RT_DEBUG_NOT_IN_INTERRUPT; /* allocate object */ - mq = (rt_mq_t) rt_object_allocate(RT_Object_Class_MessageQueue, name); + mq = (rt_mq_t)rt_object_allocate(RT_Object_Class_MessageQueue, name); if (mq == RT_NULL) return mq; /* set parent */ @@ -1724,11 +1714,11 @@ rt_mq_t rt_mq_create (const char* name, rt_size_t msg_size, rt_size_t max_msgs, /* init message queue */ /* get correct message size */ - mq->msg_size = RT_ALIGN(msg_size, RT_ALIGN_SIZE); - mq->max_msgs = max_msgs; + mq->msg_size = RT_ALIGN(msg_size, RT_ALIGN_SIZE); + mq->max_msgs = max_msgs; /* allocate message pool */ - mq->msg_pool = rt_malloc((mq->msg_size + sizeof(struct rt_mq_message))* mq->max_msgs); + mq->msg_pool = rt_malloc((mq->msg_size + sizeof(struct rt_mq_message))* mq->max_msgs); if (mq->msg_pool == RT_NULL) { rt_mq_delete(mq); @@ -1750,7 +1740,7 @@ rt_mq_t rt_mq_create (const char* name, rt_size_t msg_size, rt_size_t max_msgs, } /* the initial entry is zero */ - mq->entry = 0; + mq->entry = 0; return mq; } @@ -1762,7 +1752,7 @@ rt_mq_t rt_mq_create (const char* name, rt_size_t msg_size, rt_size_t max_msgs, * * @return the error code */ -rt_err_t rt_mq_delete (rt_mq_t mq) +rt_err_t rt_mq_delete(rt_mq_t mq) { RT_DEBUG_NOT_IN_INTERRUPT; @@ -1774,7 +1764,7 @@ rt_err_t rt_mq_delete (rt_mq_t mq) #if defined(RT_USING_MODULE) && defined(RT_USING_SLAB) /* the mq object belongs to an application module */ - if(mq->parent.parent.flag & RT_OBJECT_FLAG_MODULE) + if (mq->parent.parent.flag & RT_OBJECT_FLAG_MODULE) rt_module_free(mq->parent.parent.module_id, mq->msg_pool); else #endif @@ -1799,10 +1789,10 @@ rt_err_t rt_mq_delete (rt_mq_t mq) * * @return the error code */ -rt_err_t rt_mq_send (rt_mq_t mq, void* buffer, rt_size_t size) +rt_err_t rt_mq_send(rt_mq_t mq, void* buffer, rt_size_t size) { register rt_ubase_t temp; - struct rt_mq_message *msg; + struct rt_mq_message* msg; /* greater than one message size */ if (size > mq->msg_size) return -RT_ERROR; @@ -1882,7 +1872,7 @@ rt_err_t rt_mq_send (rt_mq_t mq, void* buffer, rt_size_t size) rt_err_t rt_mq_urgent(rt_mq_t mq, void* buffer, rt_size_t size) { register rt_ubase_t temp; - struct rt_mq_message *msg; + struct rt_mq_message* msg; /* greater than one message size */ if (size > mq->msg_size) return -RT_ERROR; @@ -1925,7 +1915,7 @@ rt_err_t rt_mq_urgent(rt_mq_t mq, void* buffer, rt_size_t size) mq->entry ++; /* resume suspended thread */ - if( !rt_list_isempty(&mq->parent.suspend_thread) ) + if (!rt_list_isempty(&mq->parent.suspend_thread)) { rt_ipc_list_resume(&(mq->parent.suspend_thread)); @@ -1953,11 +1943,11 @@ rt_err_t rt_mq_urgent(rt_mq_t mq, void* buffer, rt_size_t size) * * @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; + struct rt_thread* thread; register rt_ubase_t temp; - struct rt_mq_message *msg; + struct rt_mq_message* msg; rt_uint32_t tick_delta; /* initialize delta tick */ @@ -2021,7 +2011,7 @@ rt_err_t rt_mq_recv (rt_mq_t mq, void* buffer, rt_size_t size, rt_int32_t timeou /* recv message */ if (thread->error != RT_EOK) { - /* return error */ + /* return error */ return thread->error; } @@ -2080,7 +2070,7 @@ rt_err_t rt_mq_recv (rt_mq_t mq, void* buffer, rt_size_t size, rt_int32_t timeou rt_err_t rt_mq_control(rt_mq_t mq, rt_uint8_t cmd, void* arg) { rt_ubase_t level; - struct rt_mq_message *msg; + struct rt_mq_message* msg; RT_ASSERT(mq != RT_NULL); @@ -2119,6 +2109,5 @@ rt_err_t rt_mq_control(rt_mq_t mq, rt_uint8_t cmd, void* arg) return -RT_ERROR; } - #endif /* end of RT_USING_MESSAGEQUEUE */ /*@}*/