Merge pull request #5203 from HelloByeAll/master

【更新】ipc init/create增加 flag 判断
This commit is contained in:
guo 2021-10-21 10:16:37 +08:00 committed by GitHub
commit 389d2f948a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 9 deletions

View File

@ -287,6 +287,7 @@ rt_err_t rt_sem_init(rt_sem_t sem,
{
RT_ASSERT(sem != RT_NULL);
RT_ASSERT(value < 0x10000U);
RT_ASSERT((flag == RT_IPC_FLAG_FIFO) || (flag == RT_IPC_FLAG_PRIO));
/* initialize object */
rt_object_init(&(sem->parent.parent), RT_Object_Class_Semaphore, name);
@ -377,8 +378,10 @@ 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;
RT_ASSERT(value < 0x10000U);
RT_ASSERT((flag == RT_IPC_FLAG_FIFO) || (flag == RT_IPC_FLAG_PRIO));
RT_DEBUG_NOT_IN_INTERRUPT;
/* allocate object */
sem = (rt_sem_t)rt_object_allocate(RT_Object_Class_Semaphore, name);
@ -419,13 +422,13 @@ RTM_EXPORT(rt_sem_create);
*/
rt_err_t rt_sem_delete(rt_sem_t sem)
{
RT_DEBUG_NOT_IN_INTERRUPT;
/* parameter check */
RT_ASSERT(sem != RT_NULL);
RT_ASSERT(rt_object_get_type(&sem->parent.parent) == RT_Object_Class_Semaphore);
RT_ASSERT(rt_object_is_systemobject(&sem->parent.parent) == RT_FALSE);
RT_DEBUG_NOT_IN_INTERRUPT;
/* wakeup all suspended threads */
_ipc_list_resume_all(&(sem->parent.suspend_thread));
@ -848,13 +851,13 @@ RTM_EXPORT(rt_mutex_create);
*/
rt_err_t rt_mutex_delete(rt_mutex_t mutex)
{
RT_DEBUG_NOT_IN_INTERRUPT;
/* parameter check */
RT_ASSERT(mutex != RT_NULL);
RT_ASSERT(rt_object_get_type(&mutex->parent.parent) == RT_Object_Class_Mutex);
RT_ASSERT(rt_object_is_systemobject(&mutex->parent.parent) == RT_FALSE);
RT_DEBUG_NOT_IN_INTERRUPT;
/* wakeup all suspended threads */
_ipc_list_resume_all(&(mutex->parent.suspend_thread));
@ -1257,6 +1260,7 @@ rt_err_t rt_event_init(rt_event_t event, const char *name, rt_uint8_t flag)
{
/* parameter check */
RT_ASSERT(event != RT_NULL);
RT_ASSERT((flag == RT_IPC_FLAG_FIFO) || (flag == RT_IPC_FLAG_PRIO));
/* initialize object */
rt_object_init(&(event->parent.parent), RT_Object_Class_Event, name);
@ -1343,6 +1347,8 @@ rt_event_t rt_event_create(const char *name, rt_uint8_t flag)
{
rt_event_t event;
RT_ASSERT((flag == RT_IPC_FLAG_FIFO) || (flag == RT_IPC_FLAG_PRIO));
RT_DEBUG_NOT_IN_INTERRUPT;
/* allocate object */
@ -1766,6 +1772,7 @@ rt_err_t rt_mb_init(rt_mailbox_t mb,
rt_uint8_t flag)
{
RT_ASSERT(mb != RT_NULL);
RT_ASSERT((flag == RT_IPC_FLAG_FIFO) || (flag == RT_IPC_FLAG_PRIO));
/* initialize object */
rt_object_init(&(mb->parent.parent), RT_Object_Class_MailBox, name);
@ -1864,6 +1871,8 @@ rt_mailbox_t rt_mb_create(const char *name, rt_size_t size, rt_uint8_t flag)
{
rt_mailbox_t mb;
RT_ASSERT((flag == RT_IPC_FLAG_FIFO) || (flag == RT_IPC_FLAG_PRIO));
RT_DEBUG_NOT_IN_INTERRUPT;
/* allocate object */
@ -1919,13 +1928,13 @@ RTM_EXPORT(rt_mb_create);
*/
rt_err_t rt_mb_delete(rt_mailbox_t mb)
{
RT_DEBUG_NOT_IN_INTERRUPT;
/* parameter check */
RT_ASSERT(mb != RT_NULL);
RT_ASSERT(rt_object_get_type(&mb->parent.parent) == RT_Object_Class_MailBox);
RT_ASSERT(rt_object_is_systemobject(&mb->parent.parent) == RT_FALSE);
RT_DEBUG_NOT_IN_INTERRUPT;
/* resume all suspended thread */
_ipc_list_resume_all(&(mb->parent.suspend_thread));
@ -2463,6 +2472,7 @@ rt_err_t rt_mq_init(rt_mq_t mq,
/* parameter check */
RT_ASSERT(mq != RT_NULL);
RT_ASSERT((flag == RT_IPC_FLAG_FIFO) || (flag == RT_IPC_FLAG_PRIO));
/* initialize object */
rt_object_init(&(mq->parent.parent), RT_Object_Class_MessageQueue, name);
@ -2584,6 +2594,8 @@ rt_mq_t rt_mq_create(const char *name,
struct rt_mq_message *head;
register rt_base_t temp;
RT_ASSERT((flag == RT_IPC_FLAG_FIFO) || (flag == RT_IPC_FLAG_PRIO));
RT_DEBUG_NOT_IN_INTERRUPT;
/* allocate object */
@ -2658,13 +2670,13 @@ RTM_EXPORT(rt_mq_create);
*/
rt_err_t rt_mq_delete(rt_mq_t mq)
{
RT_DEBUG_NOT_IN_INTERRUPT;
/* parameter check */
RT_ASSERT(mq != RT_NULL);
RT_ASSERT(rt_object_get_type(&mq->parent.parent) == RT_Object_Class_MessageQueue);
RT_ASSERT(rt_object_is_systemobject(&mq->parent.parent) == RT_FALSE);
RT_DEBUG_NOT_IN_INTERRUPT;
/* resume all suspended thread */
_ipc_list_resume_all(&(mq->parent.suspend_thread));
/* also resume all message queue private suspended thread */