Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2345VOR
rt-thread
提交
b1eb3943
R
rt-thread
项目概览
2345VOR
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b1eb3943
编写于
4月 10, 2020
作者:
B
Bernard Xiong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Kernel] Add rt_object_get_length/rt_object_get_pointers APIs.
上级
0f57faa5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
79 addition
and
11 deletion
+79
-11
include/rtthread.h
include/rtthread.h
+3
-0
src/object.c
src/object.c
+76
-11
未找到文件。
include/rtthread.h
浏览文件 @
b1eb3943
...
...
@@ -41,6 +41,9 @@ extern "C" {
void
rt_system_object_init
(
void
);
struct
rt_object_information
*
rt_object_get_information
(
enum
rt_object_class_type
type
);
int
rt_object_get_length
(
enum
rt_object_class_type
type
);
int
rt_object_get_pointers
(
enum
rt_object_class_type
type
,
rt_object_t
*
pointers
,
int
maxlen
);
void
rt_object_init
(
struct
rt_object
*
object
,
enum
rt_object_class_type
type
,
const
char
*
name
);
...
...
src/object.c
浏览文件 @
b1eb3943
...
...
@@ -212,7 +212,9 @@ void rt_system_object_init(void)
/**
* This function will return the specified type of object information.
*
* @param type the type of object
* @param type the type of object, which can be
* RT_Object_Class_Thread/Semaphore/Mutex... etc
*
* @return the object type information or RT_NULL
*/
struct
rt_object_information
*
...
...
@@ -227,6 +229,75 @@ rt_object_get_information(enum rt_object_class_type type)
}
RTM_EXPORT
(
rt_object_get_information
);
/**
* This function will return the length of object list in object container.
*
* @param type the type of object, which can be
* RT_Object_Class_Thread/Semaphore/Mutex... etc
* @return the length of object list
*/
int
rt_object_get_length
(
enum
rt_object_class_type
type
)
{
int
count
=
0
;
rt_ubase_t
level
;
struct
rt_list_node
*
node
=
RT_NULL
;
struct
rt_object_information
*
information
=
RT_NULL
;
information
=
rt_object_get_information
((
enum
rt_object_class_type
)
type
);
if
(
information
==
RT_NULL
)
return
0
;
level
=
rt_hw_interrupt_disable
();
/* get the count of objects */
rt_list_for_each
(
node
,
&
(
information
->
object_list
))
{
count
++
;
}
rt_hw_interrupt_enable
(
level
);
return
count
;
}
RTM_EXPORT
(
rt_object_get_length
);
/**
* This function will copy the object pointer of the specified type,
* with the maximum size specified by maxlen.
*
* @param type the type of object, which can be
* RT_Object_Class_Thread/Semaphore/Mutex... etc
* @param pointers the pointers will be saved to
* @param maxlen the maximum number of pointers can be saved
*
* @return the copied number of object pointers
*/
int
rt_object_get_pointers
(
enum
rt_object_class_type
type
,
rt_object_t
*
pointers
,
int
maxlen
)
{
int
index
=
0
;
rt_ubase_t
level
;
struct
rt_object
*
object
;
struct
rt_list_node
*
node
=
RT_NULL
;
struct
rt_object_information
*
information
=
RT_NULL
;
if
(
maxlen
<=
0
)
return
0
;
information
=
rt_object_get_information
((
enum
rt_object_class_type
)
type
);
if
(
information
==
RT_NULL
)
return
0
;
level
=
rt_hw_interrupt_disable
();
/* retrieve pointer of object */
rt_list_for_each
(
node
,
&
(
information
->
object_list
))
{
object
=
rt_list_entry
(
node
,
struct
rt_object
,
list
);
pointers
[
index
]
=
object
;
index
++
;
}
rt_hw_interrupt_enable
(
level
);
return
index
;
}
RTM_EXPORT
(
rt_object_get_pointers
);
/**
* This function will initialize an object and add it to object system
* management.
...
...
@@ -482,9 +553,10 @@ rt_object_t rt_object_find(const char *name, rt_uint8_t type)
struct
rt_list_node
*
node
=
RT_NULL
;
struct
rt_object_information
*
information
=
RT_NULL
;
information
=
rt_object_get_information
((
enum
rt_object_class_type
)
type
);
/* parameter check */
if
((
name
==
RT_NULL
)
||
(
type
>
RT_Object_Class_Unknown
))
return
RT_NULL
;
if
((
name
==
RT_NULL
)
||
(
information
==
RT_NULL
))
return
RT_NULL
;
/* which is invoke in interrupt status */
RT_DEBUG_NOT_IN_INTERRUPT
;
...
...
@@ -493,14 +565,7 @@ rt_object_t rt_object_find(const char *name, rt_uint8_t type)
rt_enter_critical
();
/* try to find object */
if
(
information
==
RT_NULL
)
{
information
=
rt_object_get_information
((
enum
rt_object_class_type
)
type
);
RT_ASSERT
(
information
!=
RT_NULL
);
}
for
(
node
=
information
->
object_list
.
next
;
node
!=
&
(
information
->
object_list
);
node
=
node
->
next
)
rt_list_for_each
(
node
,
&
(
information
->
object_list
))
{
object
=
rt_list_entry
(
node
,
struct
rt_object
,
list
);
if
(
rt_strncmp
(
object
->
name
,
name
,
RT_NAME_MAX
)
==
0
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录