semaphore结构中value仍改为uint16_t,加入对其设置范围的检测,加入对齐变量

This commit is contained in:
shaojinchun 2019-04-24 09:14:00 +08:00
parent fa697a763f
commit 7bcee9bcb1
2 changed files with 5 additions and 2 deletions

View File

@ -655,7 +655,8 @@ struct rt_semaphore
{
struct rt_ipc_object parent; /**< inherit from ipc_object */
rt_uint32_t value; /**< value of semaphore. */
rt_uint16_t value; /**< value of semaphore. */
rt_uint16_t reserved; /**< reserved field */
};
typedef struct rt_semaphore *rt_sem_t;
#endif

View File

@ -201,6 +201,7 @@ rt_err_t rt_sem_init(rt_sem_t sem,
rt_uint8_t flag)
{
RT_ASSERT(sem != RT_NULL);
RT_ASSERT(value < 0x10000U);
/* init object */
rt_object_init(&(sem->parent.parent), RT_Object_Class_Semaphore, name);
@ -209,7 +210,7 @@ rt_err_t rt_sem_init(rt_sem_t sem,
rt_ipc_object_init(&(sem->parent));
/* set init value */
sem->value = value;
sem->value = (rt_uint16_t)value;
/* set parent */
sem->parent.parent.flag = flag;
@ -261,6 +262,7 @@ 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);
/* allocate object */
sem = (rt_sem_t)rt_object_allocate(RT_Object_Class_Semaphore, name);