diff options
| author | Bernard Xiong <[email protected]> | 2018-08-30 20:27:45 +0800 |
|---|---|---|
| committer | Bernard Xiong <[email protected]> | 2018-08-30 20:27:45 +0800 |
| commit | efe4523132169a4f28b84b1820a1a71d35118965 (patch) | |
| tree | ac0408e0933701a08122a3d0cd4dc6687a96316e /src/object.c | |
| parent | 240451b978d5775f0e936ed57d682ca1ccee604d (diff) | |
[Kernel] move module tolibc/libdl.
Diffstat (limited to 'src/object.c')
| -rw-r--r-- | src/object.c | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/src/object.c b/src/object.c index b09af9ddee..e9a2b99246 100644 --- a/src/object.c +++ b/src/object.c @@ -32,6 +32,10 @@ #include <rtthread.h> #include <rthw.h> +#ifdef RT_USING_MODULE +#include <dlmodule.h> +#endif + /* * define object_info for the number of rt_object_container items. */ @@ -111,7 +115,7 @@ static struct rt_object_information rt_object_container[RT_Object_Info_Unknown] {RT_Object_Class_Timer, _OBJ_CONTAINER_LIST_INIT(RT_Object_Info_Timer), sizeof(struct rt_timer)}, #ifdef RT_USING_MODULE /* initialize object container - module */ - {RT_Object_Class_Module, _OBJ_CONTAINER_LIST_INIT(RT_Object_Info_Module), sizeof(struct rt_module)}, + {RT_Object_Class_Module, _OBJ_CONTAINER_LIST_INIT(RT_Object_Info_Module), sizeof(struct rt_dlmodule)}, #endif }; @@ -251,6 +255,9 @@ void rt_object_init(struct rt_object *object, { register rt_base_t temp; struct rt_object_information *information; +#ifdef RT_USING_MODULE + struct rt_dlmodule *module = dlmodule_self(); +#endif /* get object information */ information = rt_object_get_information(type); @@ -269,8 +276,18 @@ void rt_object_init(struct rt_object *object, /* lock interrupt */ temp = rt_hw_interrupt_disable(); - /* insert object into information object list */ - rt_list_insert_after(&(information->object_list), &(object->list)); +#ifdef RT_USING_MODULE + if (module) + { + rt_list_insert_after(&(module->object_list), &(object->list)); + object->module_id = (void *)module; + } + else +#endif + { + /* insert object into information object list */ + rt_list_insert_after(&(information->object_list), &(object->list)); + } /* unlock interrupt */ rt_hw_interrupt_enable(temp); @@ -318,6 +335,9 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name) struct rt_object *object; register rt_base_t temp; struct rt_object_information *information; +#ifdef RT_USING_MODULE + struct rt_dlmodule *module = dlmodule_self(); +#endif RT_DEBUG_NOT_IN_INTERRUPT; @@ -332,6 +352,9 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name) return RT_NULL; } + /* clean memory data of object */ + rt_memset(object, 0x0, information->object_size); + /* initialize object's parameters */ /* set object type */ @@ -340,14 +363,6 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name) /* set object flag */ object->flag = 0; -#ifdef RT_USING_MODULE - if (rt_module_self() != RT_NULL) - { - object->flag |= RT_OBJECT_FLAG_MODULE; - } - object->module_id = (void *)rt_module_self(); -#endif - /* copy name */ rt_strncpy(object->name, name, RT_NAME_MAX); @@ -356,8 +371,18 @@ rt_object_t rt_object_allocate(enum rt_object_class_type type, const char *name) /* lock interrupt */ temp = rt_hw_interrupt_disable(); - /* insert object into information object list */ - rt_list_insert_after(&(information->object_list), &(object->list)); +#ifdef RT_USING_MODULE + if (module) + { + rt_list_insert_after(&(module->object_list), &(object->list)); + object->module_id = (void *)module; + } + else +#endif + { + /* insert object into information object list */ + rt_list_insert_after(&(information->object_list), &(object->list)); + } /* unlock interrupt */ rt_hw_interrupt_enable(temp); |
