Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
f706131f
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
f706131f
编写于
7月 07, 2018
作者:
L
liang yongxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[kernel] add assert to ipc object
上级
2bbf98e5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
66 addition
and
1 deletion
+66
-1
src/ipc.c
src/ipc.c
+66
-1
未找到文件。
src/ipc.c
浏览文件 @
f706131f
...
...
@@ -242,7 +242,10 @@ RTM_EXPORT(rt_sem_init);
*/
rt_err_t
rt_sem_detach
(
rt_sem_t
sem
)
{
/* 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
));
/* wakeup all suspend threads */
rt_ipc_list_resume_all
(
&
(
sem
->
parent
.
suspend_thread
));
...
...
@@ -303,7 +306,10 @@ 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
);
/* wakeup all suspend threads */
rt_ipc_list_resume_all
(
&
(
sem
->
parent
.
suspend_thread
));
...
...
@@ -330,7 +336,9 @@ rt_err_t rt_sem_take(rt_sem_t sem, rt_int32_t time)
register
rt_base_t
temp
;
struct
rt_thread
*
thread
;
/* parameter check */
RT_ASSERT
(
sem
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
sem
->
parent
.
parent
)
==
RT_Object_Class_Semaphore
);
RT_OBJECT_HOOK_CALL
(
rt_object_trytake_hook
,
(
&
(
sem
->
parent
.
parent
)));
...
...
@@ -437,6 +445,10 @@ rt_err_t rt_sem_release(rt_sem_t sem)
register
rt_base_t
temp
;
register
rt_bool_t
need_schedule
;
/* parameter check */
RT_ASSERT
(
sem
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
sem
->
parent
.
parent
)
==
RT_Object_Class_Semaphore
);
RT_OBJECT_HOOK_CALL
(
rt_object_put_hook
,
(
&
(
sem
->
parent
.
parent
)));
need_schedule
=
RT_FALSE
;
...
...
@@ -481,7 +493,10 @@ RTM_EXPORT(rt_sem_release);
rt_err_t
rt_sem_control
(
rt_sem_t
sem
,
int
cmd
,
void
*
arg
)
{
rt_ubase_t
level
;
/* parameter check */
RT_ASSERT
(
sem
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
sem
->
parent
.
parent
)
==
RT_Object_Class_Semaphore
);
if
(
cmd
==
RT_IPC_CMD_RESET
)
{
...
...
@@ -524,6 +539,7 @@ RTM_EXPORT(rt_sem_control);
*/
rt_err_t
rt_mutex_init
(
rt_mutex_t
mutex
,
const
char
*
name
,
rt_uint8_t
flag
)
{
/* parameter check */
RT_ASSERT
(
mutex
!=
RT_NULL
);
/* init object */
...
...
@@ -555,7 +571,10 @@ RTM_EXPORT(rt_mutex_init);
*/
rt_err_t
rt_mutex_detach
(
rt_mutex_t
mutex
)
{
/* 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
));
/* wakeup all suspend threads */
rt_ipc_list_resume_all
(
&
(
mutex
->
parent
.
suspend_thread
));
...
...
@@ -617,7 +636,10 @@ 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
);
/* wakeup all suspend threads */
rt_ipc_list_resume_all
(
&
(
mutex
->
parent
.
suspend_thread
));
...
...
@@ -647,7 +669,9 @@ rt_err_t rt_mutex_take(rt_mutex_t mutex, rt_int32_t time)
/* this function must not be used in interrupt even if time = 0 */
RT_DEBUG_IN_THREAD_CONTEXT
;
/* parameter check */
RT_ASSERT
(
mutex
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
mutex
->
parent
.
parent
)
==
RT_Object_Class_Mutex
);
/* get current thread */
thread
=
rt_thread_self
();
...
...
@@ -779,6 +803,10 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex)
struct
rt_thread
*
thread
;
rt_bool_t
need_schedule
;
/* parameter check */
RT_ASSERT
(
mutex
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
mutex
->
parent
.
parent
)
==
RT_Object_Class_Mutex
);
need_schedule
=
RT_FALSE
;
/* only thread could release mutex because we need test the ownership */
...
...
@@ -874,6 +902,10 @@ RTM_EXPORT(rt_mutex_release);
*/
rt_err_t
rt_mutex_control
(
rt_mutex_t
mutex
,
int
cmd
,
void
*
arg
)
{
/* parameter check */
RT_ASSERT
(
mutex
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
mutex
->
parent
.
parent
)
==
RT_Object_Class_Mutex
);
return
-
RT_ERROR
;
}
RTM_EXPORT
(
rt_mutex_control
);
...
...
@@ -892,6 +924,7 @@ RTM_EXPORT(rt_mutex_control);
*/
rt_err_t
rt_event_init
(
rt_event_t
event
,
const
char
*
name
,
rt_uint8_t
flag
)
{
/* parameter check */
RT_ASSERT
(
event
!=
RT_NULL
);
/* init object */
...
...
@@ -921,6 +954,8 @@ rt_err_t rt_event_detach(rt_event_t event)
{
/* parameter check */
RT_ASSERT
(
event
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
event
->
parent
.
parent
)
==
RT_Object_Class_Event
);
RT_ASSERT
(
rt_object_is_systemobject
(
&
event
->
parent
.
parent
));
/* resume all suspended thread */
rt_ipc_list_resume_all
(
&
(
event
->
parent
.
suspend_thread
));
...
...
@@ -976,6 +1011,8 @@ rt_err_t rt_event_delete(rt_event_t event)
{
/* parameter check */
RT_ASSERT
(
event
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
event
->
parent
.
parent
)
==
RT_Object_Class_Event
);
RT_ASSERT
(
rt_object_is_systemobject
(
&
event
->
parent
.
parent
)
==
RT_FALSE
);
RT_DEBUG_NOT_IN_INTERRUPT
;
...
...
@@ -1009,6 +1046,8 @@ rt_err_t rt_event_send(rt_event_t event, rt_uint32_t set)
/* parameter check */
RT_ASSERT
(
event
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
event
->
parent
.
parent
)
==
RT_Object_Class_Event
);
if
(
set
==
0
)
return
-
RT_ERROR
;
...
...
@@ -1109,6 +1148,8 @@ rt_err_t rt_event_recv(rt_event_t event,
/* parameter check */
RT_ASSERT
(
event
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
event
->
parent
.
parent
)
==
RT_Object_Class_Event
);
if
(
set
==
0
)
return
-
RT_ERROR
;
...
...
@@ -1218,8 +1259,11 @@ RTM_EXPORT(rt_event_recv);
rt_err_t
rt_event_control
(
rt_event_t
event
,
int
cmd
,
void
*
arg
)
{
rt_ubase_t
level
;
RT_ASSERT
(
event
!=
RT_NULL
);
/* parameter check */
RT_ASSERT
(
event
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
event
->
parent
.
parent
)
==
RT_Object_Class_Event
);
if
(
cmd
==
RT_IPC_CMD_RESET
)
{
/* disable interrupt */
...
...
@@ -1299,6 +1343,8 @@ rt_err_t rt_mb_detach(rt_mailbox_t mb)
{
/* 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
));
/* resume all suspended thread */
rt_ipc_list_resume_all
(
&
(
mb
->
parent
.
suspend_thread
));
...
...
@@ -1373,6 +1419,8 @@ rt_err_t rt_mb_delete(rt_mailbox_t mb)
/* 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
);
/* resume all suspended thread */
rt_ipc_list_resume_all
(
&
(
mb
->
parent
.
suspend_thread
));
...
...
@@ -1411,6 +1459,7 @@ rt_err_t rt_mb_send_wait(rt_mailbox_t mb,
/* parameter check */
RT_ASSERT
(
mb
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
mb
->
parent
.
parent
)
==
RT_Object_Class_MailBox
);
/* initialize delta tick */
tick_delta
=
0
;
...
...
@@ -1556,6 +1605,7 @@ rt_err_t rt_mb_recv(rt_mailbox_t mb, rt_uint32_t *value, rt_int32_t timeout)
/* parameter check */
RT_ASSERT
(
mb
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
mb
->
parent
.
parent
)
==
RT_Object_Class_MailBox
);
/* initialize delta tick */
tick_delta
=
0
;
...
...
@@ -1686,7 +1736,10 @@ RTM_EXPORT(rt_mb_recv);
rt_err_t
rt_mb_control
(
rt_mailbox_t
mb
,
int
cmd
,
void
*
arg
)
{
rt_ubase_t
level
;
/* parameter check */
RT_ASSERT
(
mb
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
mb
->
parent
.
parent
)
==
RT_Object_Class_MailBox
);
if
(
cmd
==
RT_IPC_CMD_RESET
)
{
...
...
@@ -1796,6 +1849,8 @@ rt_err_t rt_mq_detach(rt_mq_t mq)
{
/* 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
));
/* resume all suspended thread */
rt_ipc_list_resume_all
(
&
mq
->
parent
.
suspend_thread
);
...
...
@@ -1889,6 +1944,8 @@ rt_err_t rt_mq_delete(rt_mq_t mq)
/* 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
);
/* resume all suspended thread */
rt_ipc_list_resume_all
(
&
(
mq
->
parent
.
suspend_thread
));
...
...
@@ -1919,7 +1976,9 @@ 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
;
/* parameter check */
RT_ASSERT
(
mq
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
mq
->
parent
.
parent
)
==
RT_Object_Class_MessageQueue
);
RT_ASSERT
(
buffer
!=
RT_NULL
);
RT_ASSERT
(
size
!=
0
);
...
...
@@ -2007,7 +2066,9 @@ 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
;
/* parameter check */
RT_ASSERT
(
mq
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
mq
->
parent
.
parent
)
==
RT_Object_Class_MessageQueue
);
RT_ASSERT
(
buffer
!=
RT_NULL
);
RT_ASSERT
(
size
!=
0
);
...
...
@@ -2095,7 +2156,9 @@ rt_err_t rt_mq_recv(rt_mq_t mq,
struct
rt_mq_message
*
msg
;
rt_uint32_t
tick_delta
;
/* parameter check */
RT_ASSERT
(
mq
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
mq
->
parent
.
parent
)
==
RT_Object_Class_MessageQueue
);
RT_ASSERT
(
buffer
!=
RT_NULL
);
RT_ASSERT
(
size
!=
0
);
...
...
@@ -2229,7 +2292,9 @@ rt_err_t rt_mq_control(rt_mq_t mq, int cmd, void *arg)
rt_ubase_t
level
;
struct
rt_mq_message
*
msg
;
/* parameter check */
RT_ASSERT
(
mq
!=
RT_NULL
);
RT_ASSERT
(
rt_object_get_type
(
&
mq
->
parent
.
parent
)
==
RT_Object_Class_MessageQueue
);
if
(
cmd
==
RT_IPC_CMD_RESET
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录