mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-21 18:57:16 +08:00
[Kernel] move module tolibc/libdl.
This commit is contained in:
+38
-13
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user