From 7b984c2f547849191036a7b15d132ff967bb9d42 Mon Sep 17 00:00:00 2001 From: liang yongxiang Date: Wed, 11 Jul 2018 11:45:37 +0800 Subject: [PATCH] [kernel] add rt_object_get_type() function who return type of object without static flag --- include/rtthread.h | 1 + src/object.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/rtthread.h b/include/rtthread.h index 1e9409b97b..b3d7ebd949 100644 --- a/include/rtthread.h +++ b/include/rtthread.h @@ -62,6 +62,7 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name); void rt_object_delete(rt_object_t object); rt_bool_t rt_object_is_systemobject(rt_object_t object); +rt_uint8_t rt_object_get_type(rt_object_t object); rt_object_t rt_object_find(const char *name, rt_uint8_t type); #ifdef RT_USING_HOOK diff --git a/src/object.c b/src/object.c index e279d8b1d4..b09af9ddee 100644 --- a/src/object.c +++ b/src/object.c @@ -418,6 +418,22 @@ rt_bool_t rt_object_is_systemobject(rt_object_t object) return RT_FALSE; } +/** + * This function will return the type of object without + * RT_Object_Class_Static flag. + * + * @param object the specified object to be get type. + * + * @return the type of object. + */ +rt_uint8_t rt_object_get_type(rt_object_t object) +{ + /* object check */ + RT_ASSERT(object != RT_NULL); + + return object->type & ~RT_Object_Class_Static; +} + /** * This function will find specified name object from object * container.