define maximum value of ipc type

This commit is contained in:
mysterywolf 2020-10-23 01:04:06 +08:00
parent b43f7365a4
commit 98f0cfbf6e
2 changed files with 16 additions and 8 deletions

View File

@ -33,6 +33,7 @@
* 2019-05-17 Bernard change version number to v4.0.2
* 2019-12-20 Bernard change version number to v4.0.3
* 2020-08-10 Meco Man add macro for struct rt_device_ops
* 2020-10-23 Meco Man define maximum value of ipc type
*/
#ifndef __RT_DEF_H__
@ -102,6 +103,13 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
#define RT_UINT32_MAX 0xffffffff /**< Maxium number of UINT32 */
#define RT_TICK_MAX RT_UINT32_MAX /**< Maxium number of tick */
/* maximum value of ipc type */
#define RT_SEM_VALUE_MAX RT_UINT16_MAX /**< Maxium number of semaphore .value */
#define RT_MUTEX_VALUE_MAX RT_UINT16_MAX /**< Maxium number of mutex .value */
#define RT_MUTEX_HOLD_MAX RT_UINT8_MAX /**< Maxium number of mutex .hold */
#define RT_MB_ENTRY_MAX RT_UINT16_MAX /**< Maxium number of mailbox .entry */
#define RT_MQ_ENTRY_MAX RT_UINT16_MAX /**< Maxium number of message queue .entry */
#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
#define __CLANG_ARM
#endif

View File

@ -465,7 +465,7 @@ rt_err_t rt_sem_release(rt_sem_t sem)
}
else
{
if(sem->value < 65535u)
if(sem->value < RT_SEM_VALUE_MAX)
{
sem->value ++; /* increase value */
}
@ -696,7 +696,7 @@ rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time)
if (mutex->owner == thread)
{
if(mutex->hold < 255u)
if(mutex->hold < RT_MUTEX_HOLD_MAX)
{
/* it's the same thread */
mutex->hold ++;
@ -723,7 +723,7 @@ __again:
/* set mutex owner and original priority */
mutex->owner = thread;
mutex->original_priority = thread->current_priority;
if(mutex->hold < 255u)
if(mutex->hold < RT_MUTEX_HOLD_MAX)
{
mutex->hold ++;
}
@ -888,7 +888,7 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex)
/* set new owner and priority */
mutex->owner = thread;
mutex->original_priority = thread->current_priority;
if(mutex->hold < 255u)
if(mutex->hold < RT_MUTEX_HOLD_MAX)
{
mutex->hold ++;
}
@ -905,7 +905,7 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex)
}
else
{
if(mutex->value < 65535u)
if(mutex->value < RT_MUTEX_VALUE_MAX)
{
/* increase value */
mutex->value ++;
@ -1607,7 +1607,7 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb,
if (mb->in_offset >= mb->size)
mb->in_offset = 0;
if(mb->entry < 65535u)
if(mb->entry < RT_MB_ENTRY_MAX)
{
/* increase message entry */
mb->entry ++;
@ -2179,7 +2179,7 @@ rt_err_t rt_mq_send_wait(rt_mq_t mq,
if (mq->msg_queue_head == RT_NULL)
mq->msg_queue_head = msg;
if(mq->entry < 65535u)
if(mq->entry < RT_MQ_ENTRY_MAX)
{
/* increase message entry */
mq->entry ++;
@ -2287,7 +2287,7 @@ rt_err_t rt_mq_urgent(rt_mq_t mq, const void *buffer, rt_size_t size)
if (mq->msg_queue_tail == RT_NULL)
mq->msg_queue_tail = msg;
if(mq->entry < 65535u)
if(mq->entry < RT_MQ_ENTRY_MAX)
{
/* increase message entry */
mq->entry ++;