[libdl] move libdl to posix folder (#5523)
This commit is contained in:
parent
3606065803
commit
c89735a357
|
@ -1,15 +1,5 @@
|
|||
menu "POSIX layer and C standard library"
|
||||
|
||||
config RT_USING_MODULE
|
||||
bool "Enable dynamic module with dlopen/dlsym/dlclose feature"
|
||||
default n
|
||||
|
||||
if RT_USING_MODULE
|
||||
config RT_USING_CUSTOM_DLMODULE
|
||||
bool "Enable load dynamic module by custom"
|
||||
default n
|
||||
endif
|
||||
|
||||
config RT_LIBC_DEFAULT_TIMEZONE
|
||||
int "Set the default time zone (UTC+)"
|
||||
range -12 12
|
||||
|
|
|
@ -5,25 +5,26 @@
|
|||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2017/10/15 bernard the first version
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <rtthread.h>
|
||||
#include <rtm.h>
|
||||
|
||||
/* some export routines for module */
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
RTM_EXPORT(strstr);
|
||||
RTM_EXPORT(strlen);
|
||||
RTM_EXPORT(strchr);
|
||||
RTM_EXPORT(strcpy);
|
||||
RTM_EXPORT(strncpy);
|
||||
RTM_EXPORT(strcmp);
|
||||
RTM_EXPORT(strncmp);
|
||||
RTM_EXPORT(strlen);
|
||||
RTM_EXPORT(strcat);
|
||||
RTM_EXPORT(strstr);
|
||||
RTM_EXPORT(strchr);
|
||||
RTM_EXPORT(strcmp);
|
||||
RTM_EXPORT(strtol);
|
||||
RTM_EXPORT(strtoul);
|
||||
RTM_EXPORT(strncmp);
|
||||
|
||||
RTM_EXPORT(memcpy);
|
||||
RTM_EXPORT(memcmp);
|
||||
|
@ -31,13 +32,22 @@ RTM_EXPORT(memmove);
|
|||
RTM_EXPORT(memset);
|
||||
RTM_EXPORT(memchr);
|
||||
|
||||
RTM_EXPORT(toupper);
|
||||
RTM_EXPORT(atoi);
|
||||
|
||||
/* import the full stdio for printf */
|
||||
#if defined(RT_USING_MODULE) && defined(__MICROLIB)
|
||||
#error "[RT_USING_LIBC] Please use standard libc but not microlib."
|
||||
#endif
|
||||
|
||||
RTM_EXPORT(putchar);
|
||||
RTM_EXPORT(puts);
|
||||
RTM_EXPORT(printf);
|
||||
RTM_EXPORT(sprintf);
|
||||
RTM_EXPORT(snprintf);
|
||||
|
||||
RTM_EXPORT(fwrite);
|
||||
|
||||
#include <setjmp.h>
|
||||
RTM_EXPORT(longjmp);
|
||||
RTM_EXPORT(setjmp);
|
||||
|
||||
RTM_EXPORT(exit);
|
||||
RTM_EXPORT(abort);
|
||||
|
||||
RTM_EXPORT(rand);
|
||||
|
||||
#include <assert.h>
|
||||
RTM_EXPORT(__assert_func);
|
|
@ -65,6 +65,16 @@ if RT_USING_PTHREADS
|
|||
default 8
|
||||
endif
|
||||
|
||||
config RT_USING_MODULE
|
||||
bool "Enable dynamic module with dlopen/dlsym/dlclose feature"
|
||||
default n
|
||||
|
||||
if RT_USING_MODULE
|
||||
config RT_USING_CUSTOM_DLMODULE
|
||||
bool "Enable load dynamic module by custom"
|
||||
default n
|
||||
endif
|
||||
|
||||
source "$RTT_DIR/components/libc/posix/ipc/Kconfig"
|
||||
|
||||
endmenu
|
||||
|
|
|
@ -7,8 +7,6 @@ group = []
|
|||
CPPPATH = [cwd]
|
||||
|
||||
if rtconfig.PLATFORM == 'gcc':
|
||||
group = DefineGroup('libc', src,
|
||||
depend = ['RT_USING_MODULE'],
|
||||
CPPPATH = CPPPATH)
|
||||
group = DefineGroup('POSIX', src, depend = ['RT_USING_MODULE'], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
|
@ -14,7 +14,7 @@
|
|||
#include "dlmodule.h"
|
||||
#include "dlelf.h"
|
||||
|
||||
#if defined(RT_USING_POSIX)
|
||||
#ifdef RT_USING_POSIX_FS
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/statfs.h>
|
||||
|
@ -423,14 +423,14 @@ struct rt_dlmodule *rt_module_self(void)
|
|||
|
||||
struct rt_dlmodule* dlmodule_load(const char* filename)
|
||||
{
|
||||
#if defined(RT_USING_POSIX)
|
||||
#ifdef RT_USING_POSIX_FS
|
||||
int fd = -1, length = 0;
|
||||
#endif
|
||||
rt_err_t ret = RT_EOK;
|
||||
rt_uint8_t *module_ptr = RT_NULL;
|
||||
struct rt_dlmodule *module = RT_NULL;
|
||||
|
||||
#if defined(RT_USING_POSIX)
|
||||
#ifdef RT_USING_POSIX_FS
|
||||
fd = open(filename, O_RDONLY, 0);
|
||||
if (fd >= 0)
|
||||
{
|
||||
|
@ -522,7 +522,7 @@ struct rt_dlmodule* dlmodule_load(const char* filename)
|
|||
return module;
|
||||
|
||||
__exit:
|
||||
#if defined(RT_USING_POSIX)
|
||||
#ifdef RT_USING_POSIX_FS
|
||||
if (fd >= 0) close(fd);
|
||||
#endif
|
||||
if (module_ptr) rt_free(module_ptr);
|
||||
|
@ -573,7 +573,7 @@ struct rt_dlmodule* dlmodule_exec(const char* pgname, const char* cmd, int cmd_s
|
|||
#if defined(RT_USING_CUSTOM_DLMODULE)
|
||||
struct rt_dlmodule* dlmodule_load_custom(const char* filename, struct rt_dlmodule_ops* ops)
|
||||
{
|
||||
#if defined(RT_USING_POSIX)
|
||||
#ifdef RT_USING_POSIX_FS
|
||||
int fd = -1, length = 0;
|
||||
#endif
|
||||
rt_err_t ret = RT_EOK;
|
||||
|
@ -586,7 +586,7 @@ struct rt_dlmodule* dlmodule_load_custom(const char* filename, struct rt_dlmodul
|
|||
RT_ASSERT(ops->unload);
|
||||
module_ptr = ops->load(filename);
|
||||
}
|
||||
#if defined(RT_USING_POSIX)
|
||||
#ifdef RT_USING_POSIX_FS
|
||||
else
|
||||
{
|
||||
fd = open(filename, O_RDONLY, 0);
|
||||
|
@ -688,7 +688,7 @@ struct rt_dlmodule* dlmodule_load_custom(const char* filename, struct rt_dlmodul
|
|||
return module;
|
||||
|
||||
__exit:
|
||||
#if defined(RT_USING_POSIX)
|
||||
#ifdef RT_USING_POSIX_FS
|
||||
if (fd >= 0) close(fd);
|
||||
#endif
|
||||
if (module_ptr)
|
Loading…
Reference in New Issue