Kaynağa Gözat

[libdl] move libdl to posix folder (#5523)

Man, Jianting (Meco) 3 yıl önce
ebeveyn
işleme
c89735a357

+ 0 - 10
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

+ 28 - 18
components/libc/compilers/armlibc/libc_syms.c → components/libc/compilers/gcc/newlib/dlsyms.c

@@ -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);

+ 10 - 0
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

+ 1 - 3
components/libc/libdl/SConscript → 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')

+ 0 - 0
components/libc/libdl/arch/arm.c → components/libc/posix/libdl/arch/arm.c


+ 0 - 0
components/libc/libdl/arch/riscv.c → components/libc/posix/libdl/arch/riscv.c


+ 0 - 0
components/libc/libdl/arch/x86.c → components/libc/posix/libdl/arch/x86.c


+ 0 - 0
components/libc/libdl/dlclose.c → components/libc/posix/libdl/dlclose.c


+ 0 - 0
components/libc/libdl/dlelf.c → components/libc/posix/libdl/dlelf.c


+ 0 - 0
components/libc/libdl/dlelf.h → components/libc/posix/libdl/dlelf.h


+ 0 - 0
components/libc/libdl/dlerror.c → components/libc/posix/libdl/dlerror.c


+ 0 - 0
components/libc/libdl/dlfcn.h → components/libc/posix/libdl/dlfcn.h


+ 7 - 7
components/libc/libdl/dlmodule.c → 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 <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)

+ 0 - 0
components/libc/libdl/dlmodule.h → components/libc/posix/libdl/dlmodule.h


+ 0 - 0
components/libc/libdl/dlopen.c → components/libc/posix/libdl/dlopen.c


+ 0 - 0
components/libc/libdl/dlsym.c → components/libc/posix/libdl/dlsym.c