From b2d3317c6a7954423167316436c949fbcb1ce61d Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 23 Feb 2021 03:21:16 +0800 Subject: [PATCH] remove minilibc --- bsp/efm32/copy_this_file_shell.c | 8 ----- bsp/lpc2148/rtconfig.h | 4 --- bsp/microblaze/rtconfig.h | 1 - bsp/sam7x/rtconfig.h | 4 --- bsp/wh44b0/rtconfig.h | 4 --- components/dfs/filesystems/nfs/rpc/types.h | 16 ---------- components/libc/compilers/armlibc/sys/types.h | 6 ++++ components/libc/compilers/common/SConscript | 4 +-- components/libc/compilers/dlib/sys/types.h | 6 ++++ components/libc/compilers/newlib/SConscript | 29 ++++++++++++------- components/libc/compilers/newlib/minilib.c | 18 ++++++++++++ .../net/lwip-1.4.1/src/arch/include/arch/cc.h | 2 +- .../net/lwip-2.0.2/src/arch/include/arch/cc.h | 2 +- .../net/lwip-2.1.2/src/arch/include/arch/cc.h | 2 +- src/kservice.c | 22 -------------- 15 files changed, 54 insertions(+), 74 deletions(-) create mode 100644 components/libc/compilers/newlib/minilib.c diff --git a/bsp/efm32/copy_this_file_shell.c b/bsp/efm32/copy_this_file_shell.c index 45ce3cb45a..32b7439e0d 100644 --- a/bsp/efm32/copy_this_file_shell.c +++ b/bsp/efm32/copy_this_file_shell.c @@ -32,14 +32,6 @@ ALIGN(RT_ALIGN_SIZE) static char finsh_thread_stack[FINSH_THREAD_STACK_SIZE]; struct finsh_shell* shell; -#if !defined (RT_USING_NEWLIB) && !defined (RT_USING_MINILIBC) -int strcmp (const char *s1, const char *s2) -{ - while (*s1 && *s1 == *s2) s1++, s2++; - - return (*s1 - *s2); -} - #ifdef RT_USING_HEAP char *strdup(const char *s) { diff --git a/bsp/lpc2148/rtconfig.h b/bsp/lpc2148/rtconfig.h index 70a6ef0325..60887daac1 100644 --- a/bsp/lpc2148/rtconfig.h +++ b/bsp/lpc2148/rtconfig.h @@ -80,10 +80,6 @@ /* Using QEMU or SkyEye*/ /* #define RT_USING_EMULATOR */ -/* SECTION: a mini libc */ -/* Using mini libc library*/ -/* #define RT_USING_MINILIBC */ - /* SECTION: C++ support */ /* Using C++ support*/ /* #define RT_USING_CPLUSPLUS */ diff --git a/bsp/microblaze/rtconfig.h b/bsp/microblaze/rtconfig.h index d054c175b9..bdfe09a4f8 100755 --- a/bsp/microblaze/rtconfig.h +++ b/bsp/microblaze/rtconfig.h @@ -93,7 +93,6 @@ /* SECTION: a runtime libc library */ /* a runtime libc library*/ /* #define RT_USING_NEWLIB */ -#define RT_USING_MINILIBC /* SECTION: C++ support */ /* Using C++ support*/ diff --git a/bsp/sam7x/rtconfig.h b/bsp/sam7x/rtconfig.h index bb3e3546d0..ae74c2535e 100644 --- a/bsp/sam7x/rtconfig.h +++ b/bsp/sam7x/rtconfig.h @@ -72,10 +72,6 @@ #define FINSH_USING_SYMTAB #define FINSH_USING_DESCRIPTION -/* SECTION: a mini libc */ -/* Using mini libc library*/ -/* #define RT_USING_MINILIBC */ - /* SECTION: C++ support */ /* Using C++ support*/ /* #define RT_USING_CPLUSPLUS */ diff --git a/bsp/wh44b0/rtconfig.h b/bsp/wh44b0/rtconfig.h index 32364bbc4a..b5bc28a458 100644 --- a/bsp/wh44b0/rtconfig.h +++ b/bsp/wh44b0/rtconfig.h @@ -65,10 +65,6 @@ /* Using FinSH as Shell*/ /* #define RT_USING_FINSH */ -/* SECTION: a mini libc */ -/* Using mini libc library*/ -/* #define RT_USING_MINILIBC */ - /* SECTION: C++ support */ /* Using C++ support*/ /* #define RT_USING_CPLUSPLUS */ diff --git a/components/dfs/filesystems/nfs/rpc/types.h b/components/dfs/filesystems/nfs/rpc/types.h index 254fcd339c..d76d89146c 100644 --- a/components/dfs/filesystems/nfs/rpc/types.h +++ b/components/dfs/filesystems/nfs/rpc/types.h @@ -47,15 +47,7 @@ #include #include - -#ifndef RT_USING_MINILIBC -typedef unsigned int u_int; -typedef unsigned char u_char; -typedef unsigned long u_long; -#else #include -#include -#endif typedef long long int64_t; typedef unsigned long long uint64_t; @@ -63,14 +55,6 @@ typedef unsigned long long uint64_t; typedef int bool_t; typedef int enum_t; -#ifndef RT_USING_NEWLIB -typedef unsigned long dev_t; -#endif - -#if !defined(RT_USING_NEWLIB) && !defined(RT_USING_MINILIBC) -typedef rt_int32_t ssize_t; -#endif - /* This needs to be changed to uint32_t in the future */ typedef unsigned long rpcprog_t; typedef unsigned long rpcvers_t; diff --git a/components/libc/compilers/armlibc/sys/types.h b/components/libc/compilers/armlibc/sys/types.h index 78fee1bb99..bcca8fae1a 100644 --- a/components/libc/compilers/armlibc/sys/types.h +++ b/components/libc/compilers/armlibc/sys/types.h @@ -23,4 +23,10 @@ typedef long signed int ssize_t; /* Used for a count of bytes or an error #endif typedef unsigned long useconds_t; /* microseconds (unsigned) */ +typedef unsigned long dev_t; + +typedef unsigned int u_int; +typedef unsigned char u_char; +typedef unsigned long u_long; + #endif diff --git a/components/libc/compilers/common/SConscript b/components/libc/compilers/common/SConscript index ecdee2637e..319e1a3555 100644 --- a/components/libc/compilers/common/SConscript +++ b/components/libc/compilers/common/SConscript @@ -10,7 +10,7 @@ CPPPATH = [cwd] if GetDepend('RT_USING_LIBC'): src += Glob('*.c') else: - if GetDepend('RT_LIBC_USING_TIME') and not GetDepend('RT_USING_MINILIBC'): + if GetDepend('RT_LIBC_USING_TIME'): src += ['time.c'] if GetDepend('RT_USING_POSIX') == False: @@ -21,7 +21,7 @@ if rtconfig.CROSS_TOOL == 'keil': else: CPPDEFINES = [] -if not GetDepend('RT_USING_MINILIBC') and (GetDepend('RT_USING_LIBC') or GetDepend('RT_LIBC_USING_TIME')): +if GetDepend('RT_USING_LIBC') or GetDepend('RT_LIBC_USING_TIME'): group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES) Return('group') diff --git a/components/libc/compilers/dlib/sys/types.h b/components/libc/compilers/dlib/sys/types.h index 7dbeddcaa9..9ae7906fb1 100644 --- a/components/libc/compilers/dlib/sys/types.h +++ b/components/libc/compilers/dlib/sys/types.h @@ -22,4 +22,10 @@ typedef long signed int ssize_t; /* Used for a count of bytes or an error #endif typedef unsigned long useconds_t; /* microseconds (unsigned) */ +typedef unsigned long dev_t; + +typedef unsigned int u_int; +typedef unsigned char u_char; +typedef unsigned long u_long; + #endif diff --git a/components/libc/compilers/newlib/SConscript b/components/libc/compilers/newlib/SConscript index d0868bbdea..b1ad6e4784 100644 --- a/components/libc/compilers/newlib/SConscript +++ b/components/libc/compilers/newlib/SConscript @@ -1,21 +1,30 @@ from building import * Import('rtconfig') -src = Glob('*.c') +src = [] cwd = GetCurrentDir() group = [] CPPPATH = [cwd] -CPPDEFINES = ['RT_USING_NEWLIB'] - -# link with libc and libm: -# libm is a frequently used lib. Newlib is compiled with -ffunction-sections in -# recent GCC tool chains. The linker would just link in the functions that have -# been referenced. So setting this won't result in bigger text size. -LIBS = ['c', 'm'] if rtconfig.PLATFORM == 'gcc': - group = DefineGroup('libc', src, depend = ['RT_USING_LIBC'], - CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS) + if GetDepend('RT_USING_LIBC'): + CPPDEFINES = ['RT_USING_NEWLIB'] + # link with libc and libm: + # libm is a frequently used lib. Newlib is compiled with -ffunction-sections in + # recent GCC tool chains. The linker would just link in the functions that have + # been referenced. So setting this won't result in bigger text size. + LIBS = ['c', 'm'] + + src += Glob('*.c') + SrcRemove(src, ['minilib.c']) + if GetDepend('RT_USING_MODULE') == False: + SrcRemove(src, ['libc_syms.c']) + else: + src += ['minilib.c'] + CPPDEFINES = [] + LIBS = [] + + group = DefineGroup('libc', src, depend = [], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS) Return('group') diff --git a/components/libc/compilers/newlib/minilib.c b/components/libc/compilers/newlib/minilib.c new file mode 100644 index 0000000000..2d07eabe5a --- /dev/null +++ b/components/libc/compilers/newlib/minilib.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-02-23 Meco Man first version + */ + +#include +#include + +void * _sbrk_r(struct _reent *ptr, ptrdiff_t incr) +{ + /* no use this routine to get memory */ + return RT_NULL; +} diff --git a/components/net/lwip-1.4.1/src/arch/include/arch/cc.h b/components/net/lwip-1.4.1/src/arch/include/arch/cc.h index 251de66978..ecf22177ac 100644 --- a/components/net/lwip-1.4.1/src/arch/include/arch/cc.h +++ b/components/net/lwip-1.4.1/src/arch/include/arch/cc.h @@ -66,7 +66,7 @@ typedef uintptr_t mem_ptr_t; #endif /* __CC_ARM/__IAR_SYSTEMS_ICC__ */ #endif -#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) +#if defined(RT_USING_LIBC) || defined(RT_LIBC_USING_TIME) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) #include #define LWIP_TIMEVAL_PRIVATE 0 #else diff --git a/components/net/lwip-2.0.2/src/arch/include/arch/cc.h b/components/net/lwip-2.0.2/src/arch/include/arch/cc.h index ea6a5ff755..51b06f1a7f 100644 --- a/components/net/lwip-2.0.2/src/arch/include/arch/cc.h +++ b/components/net/lwip-2.0.2/src/arch/include/arch/cc.h @@ -45,7 +45,7 @@ #define S32_F "ld" #define X32_F "lx" -#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) +#if defined(RT_USING_LIBC) || defined(RT_LIBC_USING_TIME) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) #include #define LWIP_TIMEVAL_PRIVATE 0 #else diff --git a/components/net/lwip-2.1.2/src/arch/include/arch/cc.h b/components/net/lwip-2.1.2/src/arch/include/arch/cc.h index 49c7541ed7..2c22d3a873 100644 --- a/components/net/lwip-2.1.2/src/arch/include/arch/cc.h +++ b/components/net/lwip-2.1.2/src/arch/include/arch/cc.h @@ -59,7 +59,7 @@ #endif /* __CC_ARM/__IAR_SYSTEMS_ICC__ */ #endif /* RT_USING_LIBC */ -#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) +#if defined(RT_USING_LIBC) || defined(RT_LIBC_USING_TIME) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) #include #define LWIP_TIMEVAL_PRIVATE 0 #else diff --git a/src/kservice.c b/src/kservice.c index 423fe3ddb3..9fc3971c7e 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -1386,26 +1386,4 @@ void rt_assert_handler(const char *ex_string, const char *func, rt_size_t line) RTM_EXPORT(rt_assert_handler); #endif /* RT_DEBUG */ -#if !defined (RT_USING_NEWLIB) && defined (RT_USING_MINILIBC) && defined (__GNUC__) -#include -void *memcpy(void *dest, const void *src, size_t n) __attribute__((weak, alias("rt_memcpy"))); -void *memset(void *s, int c, size_t n) __attribute__((weak, alias("rt_memset"))); -void *memmove(void *dest, const void *src, size_t n) __attribute__((weak, alias("rt_memmove"))); -int memcmp(const void *s1, const void *s2, size_t n) __attribute__((weak, alias("rt_memcmp"))); - -size_t strlen(const char *s) __attribute__((weak, alias("rt_strlen"))); -char *strstr(const char *s1, const char *s2) __attribute__((weak, alias("rt_strstr"))); -int strcasecmp(const char *a, const char *b) __attribute__((weak, alias("rt_strcasecmp"))); -char *strncpy(char *dest, const char *src, size_t n) __attribute__((weak, alias("rt_strncpy"))); -int strncmp(const char *cs, const char *ct, size_t count) __attribute__((weak, alias("rt_strncmp"))); -#ifdef RT_USING_HEAP -char *strdup(const char *s) __attribute__((weak, alias("rt_strdup"))); -#endif - -int sprintf(char *buf, const char *format, ...) __attribute__((weak, alias("rt_sprintf"))); -int snprintf(char *buf, rt_size_t size, const char *fmt, ...) __attribute__((weak, alias("rt_snprintf"))); -int vsprintf(char *buf, const char *format, va_list arg_ptr) __attribute__((weak, alias("rt_vsprintf"))); - -#endif - /**@}*/ -- GitLab