diff --git a/components/libc/Kconfig b/components/libc/Kconfig index 0556cf6183..71547e7970 100644 --- a/components/libc/Kconfig +++ b/components/libc/Kconfig @@ -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 diff --git a/components/libc/compilers/armlibc/libc_syms.c b/components/libc/compilers/gcc/newlib/dlsyms.c similarity index 62% rename from components/libc/compilers/armlibc/libc_syms.c rename to components/libc/compilers/gcc/newlib/dlsyms.c index 2b370a25a6..e6ca23b393 100644 --- a/components/libc/compilers/armlibc/libc_syms.c +++ b/components/libc/compilers/gcc/newlib/dlsyms.c @@ -5,25 +5,26 @@ * * Change Logs: * Date Author Notes + * 2017/10/15 bernard the first version */ -#include -#include -#include -#include +#include #include -/* some export routines for module */ +#include +#include +#include -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 +RTM_EXPORT(longjmp); +RTM_EXPORT(setjmp); + +RTM_EXPORT(exit); +RTM_EXPORT(abort); + +RTM_EXPORT(rand); + +#include +RTM_EXPORT(__assert_func); diff --git a/components/libc/posix/Kconfig b/components/libc/posix/Kconfig index 8f527fa46d..5c766d9509 100644 --- a/components/libc/posix/Kconfig +++ b/components/libc/posix/Kconfig @@ -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 diff --git a/components/libc/libdl/SConscript b/components/libc/posix/libdl/SConscript similarity index 65% rename from components/libc/libdl/SConscript rename to components/libc/posix/libdl/SConscript index 93636e4b7a..964e05ef76 100644 --- a/components/libc/libdl/SConscript +++ b/components/libc/posix/libdl/SConscript @@ -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') diff --git a/components/libc/libdl/arch/arm.c b/components/libc/posix/libdl/arch/arm.c similarity index 100% rename from components/libc/libdl/arch/arm.c rename to components/libc/posix/libdl/arch/arm.c diff --git a/components/libc/libdl/arch/riscv.c b/components/libc/posix/libdl/arch/riscv.c similarity index 100% rename from components/libc/libdl/arch/riscv.c rename to components/libc/posix/libdl/arch/riscv.c diff --git a/components/libc/libdl/arch/x86.c b/components/libc/posix/libdl/arch/x86.c similarity index 100% rename from components/libc/libdl/arch/x86.c rename to components/libc/posix/libdl/arch/x86.c diff --git a/components/libc/libdl/dlclose.c b/components/libc/posix/libdl/dlclose.c similarity index 100% rename from components/libc/libdl/dlclose.c rename to components/libc/posix/libdl/dlclose.c diff --git a/components/libc/libdl/dlelf.c b/components/libc/posix/libdl/dlelf.c similarity index 100% rename from components/libc/libdl/dlelf.c rename to components/libc/posix/libdl/dlelf.c diff --git a/components/libc/libdl/dlelf.h b/components/libc/posix/libdl/dlelf.h similarity index 100% rename from components/libc/libdl/dlelf.h rename to components/libc/posix/libdl/dlelf.h diff --git a/components/libc/libdl/dlerror.c b/components/libc/posix/libdl/dlerror.c similarity index 100% rename from components/libc/libdl/dlerror.c rename to components/libc/posix/libdl/dlerror.c diff --git a/components/libc/libdl/dlfcn.h b/components/libc/posix/libdl/dlfcn.h similarity index 100% rename from components/libc/libdl/dlfcn.h rename to components/libc/posix/libdl/dlfcn.h diff --git a/components/libc/libdl/dlmodule.c b/components/libc/posix/libdl/dlmodule.c similarity index 99% rename from components/libc/libdl/dlmodule.c rename to components/libc/posix/libdl/dlmodule.c index 32d6b6b7e7..ffa23de82d 100644 --- a/components/libc/libdl/dlmodule.c +++ b/components/libc/posix/libdl/dlmodule.c @@ -14,7 +14,7 @@ #include "dlmodule.h" #include "dlelf.h" -#if defined(RT_USING_POSIX) +#ifdef RT_USING_POSIX_FS #include #include #include @@ -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) diff --git a/components/libc/libdl/dlmodule.h b/components/libc/posix/libdl/dlmodule.h similarity index 100% rename from components/libc/libdl/dlmodule.h rename to components/libc/posix/libdl/dlmodule.h diff --git a/components/libc/libdl/dlopen.c b/components/libc/posix/libdl/dlopen.c similarity index 100% rename from components/libc/libdl/dlopen.c rename to components/libc/posix/libdl/dlopen.c diff --git a/components/libc/libdl/dlsym.c b/components/libc/posix/libdl/dlsym.c similarity index 100% rename from components/libc/libdl/dlsym.c rename to components/libc/posix/libdl/dlsym.c