提交 7bcee9bc 编写于 作者: S shaojinchun

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

上级 fa697a76
......@@ -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
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册