From 237a71de278b16aa3df3e98f49714ef17cdf0c2b Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Tue, 8 Sep 2020 10:26:03 +0800 Subject: 修复common文件夹,该文件夹为armlibc/newlib/dlib的共同文件的文件夹 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/compilers/common/SConscript | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'components/libc/compilers/common/SConscript') diff --git a/components/libc/compilers/common/SConscript b/components/libc/compilers/common/SConscript index a8d2606820..7979e20944 100644 --- a/components/libc/compilers/common/SConscript +++ b/components/libc/compilers/common/SConscript @@ -13,7 +13,6 @@ else: if GetDepend('RT_LIBC_USING_TIME'): src += ['time.c'] -if (rtconfig.PLATFORM == 'armcc' or rtconfig.PLATFORM == 'iar') and rtconfig.ARCH != 'sim' : - group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH) +group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH) Return('group') -- cgit v1.3.1 From f021cb982a1add837755af2c513ab17605a55f2d Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Tue, 8 Sep 2020 10:52:02 +0800 Subject: 修改common下的sconscript脚本文件,增加unistd.c排除条件 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/compilers/common/SConscript | 3 +++ components/libc/compilers/common/unistd.c | 7 ++----- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'components/libc/compilers/common/SConscript') diff --git a/components/libc/compilers/common/SConscript b/components/libc/compilers/common/SConscript index 7979e20944..deadacb426 100644 --- a/components/libc/compilers/common/SConscript +++ b/components/libc/compilers/common/SConscript @@ -13,6 +13,9 @@ else: if GetDepend('RT_LIBC_USING_TIME'): src += ['time.c'] +if GetDepend('RT_USING_POSIX') == False: + SrcRemove(src, ['unistd.c']) + group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH) Return('group') diff --git a/components/libc/compilers/common/unistd.c b/components/libc/compilers/common/unistd.c index e2f2827beb..4068fc5cf5 100644 --- a/components/libc/compilers/common/unistd.c +++ b/components/libc/compilers/common/unistd.c @@ -8,12 +8,11 @@ * 2020-09-01 Meco Man First Version */ -#include #include -#ifdef RT_USING_POSIX - #ifdef RT_USING_POSIX_TERMIOS +#include + int isatty(int fd) { struct termios ts; @@ -25,5 +24,3 @@ char *ttyname(int fd) { return "/dev/tty0"; /*TODO: need to add more specific*/ } - -#endif -- cgit v1.3.1 From 0607ff84ab4cf9a8b6ed92ce17776bd852d9bc62 Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Tue, 8 Sep 2020 11:12:56 +0800 Subject: 解决minilibc time.c和newlibc仅定义RT_LIBC_USING_TIME时冲突的问题 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/compilers/common/SConscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'components/libc/compilers/common/SConscript') diff --git a/components/libc/compilers/common/SConscript b/components/libc/compilers/common/SConscript index deadacb426..718f05743c 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'): + if GetDepend('RT_LIBC_USING_TIME') and not GetDepend('RT_USING_MINILIBC'): src += ['time.c'] if GetDepend('RT_USING_POSIX') == False: -- cgit v1.3.1 From ff097f0467fb0041817846f2472343b7b9c098c4 Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Tue, 8 Sep 2020 13:16:49 +0800 Subject: 增加 __GNUC__宏定义 和sconscript的平台识别以避免重复定义 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/compilers/common/SConscript | 3 ++- components/libc/compilers/minilibc/SConscript | 2 +- include/libc/libc_errno.h | 4 ++-- include/libc/libc_fcntl.h | 2 +- include/libc/libc_fdset.h | 2 +- include/libc/libc_stat.h | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) (limited to 'components/libc/compilers/common/SConscript') diff --git a/components/libc/compilers/common/SConscript b/components/libc/compilers/common/SConscript index 718f05743c..a5f4a3fda6 100644 --- a/components/libc/compilers/common/SConscript +++ b/components/libc/compilers/common/SConscript @@ -16,6 +16,7 @@ else: if GetDepend('RT_USING_POSIX') == False: SrcRemove(src, ['unistd.c']) -group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH) +if not GetDepend('RT_USING_MINILIBC') and GetDepend('RT_USING_LIBC'): + group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH) Return('group') diff --git a/components/libc/compilers/minilibc/SConscript b/components/libc/compilers/minilibc/SConscript index 518d800571..dec657028f 100644 --- a/components/libc/compilers/minilibc/SConscript +++ b/components/libc/compilers/minilibc/SConscript @@ -8,7 +8,7 @@ group = [] CPPPATH = [cwd] CPPDEFINES = ['RT_USING_MINILIBC'] -if rtconfig.PLATFORM == 'gcc' and rtconfig.ARCH != 'sim' and not GetDepend('RT_USING_LIBC'): +if rtconfig.PLATFORM == 'gcc' and rtconfig.ARCH != 'sim' and not GetDepend('RT_USING_LIBC') and GetDepend('RT_USING_MINILIBC'): group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES) diff --git a/include/libc/libc_errno.h b/include/libc/libc_errno.h index 0f3bc7635a..00c1f733d3 100644 --- a/include/libc/libc_errno.h +++ b/include/libc/libc_errno.h @@ -13,7 +13,7 @@ #include -#if defined(RT_USING_NEWLIB) || defined(_WIN32) +#if defined(RT_USING_NEWLIB) || defined(_WIN32) || defined( __GNUC__ ) /* use errno.h file in toolchains */ #include #endif @@ -45,7 +45,7 @@ defined in armcc/errno.h #define ERROR_BASE_NO 0 #endif -#if !defined(RT_USING_NEWLIB) && !defined(_WIN32) +#if !defined(RT_USING_NEWLIB) && !defined(_WIN32) && !defined(__GNUC__ ) #define EPERM (ERROR_BASE_NO + 1) #define ENOENT (ERROR_BASE_NO + 2) diff --git a/include/libc/libc_fcntl.h b/include/libc/libc_fcntl.h index 385ac7cd9f..39740b7d85 100644 --- a/include/libc/libc_fcntl.h +++ b/include/libc/libc_fcntl.h @@ -12,7 +12,7 @@ #ifndef LIBC_FCNTL_H__ #define LIBC_FCNTL_H__ -#if defined(RT_USING_NEWLIB) || defined(_WIN32) +#if defined(RT_USING_NEWLIB) || defined(_WIN32) || defined( __GNUC__ ) #include #ifndef O_NONBLOCK diff --git a/include/libc/libc_fdset.h b/include/libc/libc_fdset.h index b4d2e2189a..4a778b51c1 100644 --- a/include/libc/libc_fdset.h +++ b/include/libc/libc_fdset.h @@ -13,7 +13,7 @@ #include -#if defined(RT_USING_NEWLIB) || defined(_WIN32) +#if defined(RT_USING_NEWLIB) || defined(_WIN32) || defined( __GNUC__ ) #include #if defined(HAVE_SYS_SELECT_H) #include diff --git a/include/libc/libc_stat.h b/include/libc/libc_stat.h index 9079d1ef15..9388688572 100644 --- a/include/libc/libc_stat.h +++ b/include/libc/libc_stat.h @@ -9,7 +9,7 @@ #include -#if defined(RT_USING_NEWLIB) +#if defined(RT_USING_NEWLIB) || defined( __GNUC__ ) /* use header file of newlib */ #include -- cgit v1.3.1 From 4305a678a38d65712d739f0d79bf55dc05e33073 Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Tue, 8 Sep 2020 16:29:47 +0800 Subject: 修改common文件夹的sconscript 并 取消并恢复上一个commit的提交内容 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/lpc408x/.config | 9 ++------- bsp/lpc408x/rtconfig.h | 3 +-- components/libc/compilers/common/SConscript | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) (limited to 'components/libc/compilers/common/SConscript') diff --git a/bsp/lpc408x/.config b/bsp/lpc408x/.config index c57e7eb755..b07e256c26 100644 --- a/bsp/lpc408x/.config +++ b/bsp/lpc408x/.config @@ -176,14 +176,9 @@ CONFIG_RT_USING_PIN=y # # POSIX layer and C standard library # -CONFIG_RT_USING_LIBC=y +# CONFIG_RT_USING_LIBC is not set # CONFIG_RT_USING_PTHREADS is not set -CONFIG_RT_USING_POSIX=y -# CONFIG_RT_USING_POSIX_MMAP is not set -# CONFIG_RT_USING_POSIX_TERMIOS is not set -# CONFIG_RT_USING_POSIX_GETLINE is not set -# CONFIG_RT_USING_POSIX_AIO is not set -# CONFIG_RT_USING_MODULE is not set +CONFIG_RT_LIBC_USING_TIME=y # # Network diff --git a/bsp/lpc408x/rtconfig.h b/bsp/lpc408x/rtconfig.h index d5e0c160be..25bba085a6 100644 --- a/bsp/lpc408x/rtconfig.h +++ b/bsp/lpc408x/rtconfig.h @@ -107,8 +107,7 @@ /* POSIX layer and C standard library */ -#define RT_USING_LIBC -#define RT_USING_POSIX +#define RT_LIBC_USING_TIME /* Network */ diff --git a/components/libc/compilers/common/SConscript b/components/libc/compilers/common/SConscript index a5f4a3fda6..18ff51d027 100644 --- a/components/libc/compilers/common/SConscript +++ b/components/libc/compilers/common/SConscript @@ -16,7 +16,7 @@ else: if GetDepend('RT_USING_POSIX') == False: SrcRemove(src, ['unistd.c']) -if not GetDepend('RT_USING_MINILIBC') and GetDepend('RT_USING_LIBC'): +if not GetDepend('RT_USING_MINILIBC') and (GetDepend('RT_USING_LIBC') or GetDepend('RT_LIBC_USING_TIME')): group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH) Return('group') -- cgit v1.3.1 From 28e0c99d0032111add7fadee7834043c332feb79 Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Wed, 9 Sep 2020 00:53:53 +0800 Subject: Signed-off-by: mysterywolf --- components/libc/compilers/common/SConscript | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'components/libc/compilers/common/SConscript') diff --git a/components/libc/compilers/common/SConscript b/components/libc/compilers/common/SConscript index 18ff51d027..6c14b4e881 100644 --- a/components/libc/compilers/common/SConscript +++ b/components/libc/compilers/common/SConscript @@ -8,13 +8,13 @@ group = [] CPPPATH = [cwd] if GetDepend('RT_USING_LIBC'): - src += Glob('*.c') + src += Glob('*.c') + if GetDepend('RT_USING_POSIX') == False: + SrcRemove(src, ['unistd.c']) else: if GetDepend('RT_LIBC_USING_TIME') and not GetDepend('RT_USING_MINILIBC'): src += ['time.c'] -if GetDepend('RT_USING_POSIX') == False: - SrcRemove(src, ['unistd.c']) if not GetDepend('RT_USING_MINILIBC') and (GetDepend('RT_USING_LIBC') or GetDepend('RT_LIBC_USING_TIME')): group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH) -- cgit v1.3.1 From b3ab8a99e10f68042a3f2cba11e130004aa124e4 Mon Sep 17 00:00:00 2001 From: mysterywolf <920369182@qq.com> Date: Wed, 9 Sep 2020 08:59:39 +0800 Subject: Signed-off-by: mysterywolf --- components/libc/compilers/common/SConscript | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'components/libc/compilers/common/SConscript') diff --git a/components/libc/compilers/common/SConscript b/components/libc/compilers/common/SConscript index 6c14b4e881..2407301405 100644 --- a/components/libc/compilers/common/SConscript +++ b/components/libc/compilers/common/SConscript @@ -9,12 +9,12 @@ CPPPATH = [cwd] if GetDepend('RT_USING_LIBC'): src += Glob('*.c') - if GetDepend('RT_USING_POSIX') == False: - SrcRemove(src, ['unistd.c']) else: if GetDepend('RT_LIBC_USING_TIME') and not GetDepend('RT_USING_MINILIBC'): src += ['time.c'] +if GetDepend('RT_USING_POSIX') == False: + SrcRemove(src, ['unistd.c']) if not GetDepend('RT_USING_MINILIBC') and (GetDepend('RT_USING_LIBC') or GetDepend('RT_LIBC_USING_TIME')): group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH) -- cgit v1.3.1 From 33769db3cf9c49172c402a4950ec5a8f33fe9948 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 15 Feb 2021 07:17:16 +0800 Subject: [libc][gcc][keil] 在sconscript中定义RT_TICK_PER_SECOND宏 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/compilers/common/SConscript | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'components/libc/compilers/common/SConscript') diff --git a/components/libc/compilers/common/SConscript b/components/libc/compilers/common/SConscript index 2407301405..1cf84df01c 100644 --- a/components/libc/compilers/common/SConscript +++ b/components/libc/compilers/common/SConscript @@ -16,7 +16,14 @@ else: if GetDepend('RT_USING_POSIX') == False: SrcRemove(src, ['unistd.c']) +if rtconfig.CROSS_TOOL == 'keil': + CPPDEFINES = ['__CLK_TCK=RT_TICK_PER_SECOND'] +elif rtconfig.CROSS_TOOL == 'gcc': + CPPDEFINES = ['_CLOCKS_PER_SEC_=RT_TICK_PER_SECOND'] +else: + CPPDEFINES = [] + if not GetDepend('RT_USING_MINILIBC') and (GetDepend('RT_USING_LIBC') or GetDepend('RT_LIBC_USING_TIME')): - group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH) + group = DefineGroup('libc', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES) Return('group') -- cgit v1.3.1 From 4615a7d96c633e63d93ae2ed97a035defdea2736 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 15 Feb 2021 07:35:14 +0800 Subject: remove gcc --- components/libc/compilers/common/SConscript | 2 -- 1 file changed, 2 deletions(-) (limited to 'components/libc/compilers/common/SConscript') diff --git a/components/libc/compilers/common/SConscript b/components/libc/compilers/common/SConscript index 1cf84df01c..8877f07f24 100644 --- a/components/libc/compilers/common/SConscript +++ b/components/libc/compilers/common/SConscript @@ -18,8 +18,6 @@ if GetDepend('RT_USING_POSIX') == False: if rtconfig.CROSS_TOOL == 'keil': CPPDEFINES = ['__CLK_TCK=RT_TICK_PER_SECOND'] -elif rtconfig.CROSS_TOOL == 'gcc': - CPPDEFINES = ['_CLOCKS_PER_SEC_=RT_TICK_PER_SECOND'] else: CPPDEFINES = [] -- cgit v1.3.1 From e927a53b41fa58573e14eccac37374d686ad3cf7 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Wed, 17 Feb 2021 00:02:28 +0800 Subject: 精简exit abort system函数 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/compilers/armlibc/syscalls.c | 23 +++--------- components/libc/compilers/common/SConscript | 8 ++--- components/libc/compilers/common/stdlib.c | 52 ++++++++++++++++++++++++++++ components/libc/compilers/dlib/syscalls.c | 38 +++----------------- components/libc/compilers/newlib/syscalls.c | 42 ++++------------------ 5 files changed, 70 insertions(+), 93 deletions(-) create mode 100644 components/libc/compilers/common/stdlib.c (limited to 'components/libc/compilers/common/SConscript') diff --git a/components/libc/compilers/armlibc/syscalls.c b/components/libc/compilers/armlibc/syscalls.c index 1e08ca1716..43b655e1a6 100644 --- a/components/libc/compilers/armlibc/syscalls.c +++ b/components/libc/compilers/armlibc/syscalls.c @@ -258,23 +258,8 @@ void _ttywrch(int ch) RT_WEAK void _sys_exit(int return_code) { - rt_thread_t self = rt_thread_self(); - -#ifdef RT_USING_MODULE - if (dlmodule_self()) - { - dlmodule_exit(return_code); - } -#endif - - if (self != RT_NULL) - { - rt_kprintf("thread:%-8.*s exit:%d!\n", RT_NAME_MAX, self->name, return_code); - rt_thread_suspend(self); - rt_schedule(); - } - - while(1); /* noreturn */ + extern rt_inline void __exit__(int status); + __exit__(return_code); } /** @@ -320,8 +305,8 @@ int remove(const char *filename) #else int system(const char *string) { - RT_ASSERT(0); - for (;;); + extern rt_inline int __system__(const char *string); + return __system__(string); } #endif diff --git a/components/libc/compilers/common/SConscript b/components/libc/compilers/common/SConscript index 8877f07f24..ecdee2637e 100644 --- a/components/libc/compilers/common/SConscript +++ b/components/libc/compilers/common/SConscript @@ -8,13 +8,13 @@ group = [] CPPPATH = [cwd] if GetDepend('RT_USING_LIBC'): - src += Glob('*.c') + src += Glob('*.c') else: - if GetDepend('RT_LIBC_USING_TIME') and not GetDepend('RT_USING_MINILIBC'): - src += ['time.c'] + if GetDepend('RT_LIBC_USING_TIME') and not GetDepend('RT_USING_MINILIBC'): + src += ['time.c'] if GetDepend('RT_USING_POSIX') == False: - SrcRemove(src, ['unistd.c']) + SrcRemove(src, ['unistd.c']) if rtconfig.CROSS_TOOL == 'keil': CPPDEFINES = ['__CLK_TCK=RT_TICK_PER_SECOND'] diff --git a/components/libc/compilers/common/stdlib.c b/components/libc/compilers/common/stdlib.c new file mode 100644 index 0000000000..01f18aca5f --- /dev/null +++ b/components/libc/compilers/common/stdlib.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2021-02-15 Meco Man first version + */ + +#include + +#define ABORT_STATUS 2 + +rt_inline void __exit__(int status) +{ + rt_thread_t self = rt_thread_self(); + +#ifdef RT_USING_MODULE + if (dlmodule_self()) + { + dlmodule_exit(status); + } +#endif + + if (self != RT_NULL) + { + if(status == ABORT_STATUS) /* abort() */ + { + rt_kprintf("thread:%s abort!\n", RT_NAME_MAX, self->name, status); + } + else /* exit() */ + { + rt_kprintf("thread:%s exit:%d!\n", RT_NAME_MAX, self->name, status); + } + rt_thread_suspend(self); + rt_schedule(); + } + + while(1); /* noreturn */ +} + +rt_inline void __abort__(void) +{ + __exit__(ABORT_STATUS); +} + +rt_inline int __system__(const char *string) +{ + /* TODO */ + return 0; +} diff --git a/components/libc/compilers/dlib/syscalls.c b/components/libc/compilers/dlib/syscalls.c index 0d5f02f952..6f16da2fcb 100644 --- a/components/libc/compilers/dlib/syscalls.c +++ b/components/libc/compilers/dlib/syscalls.c @@ -11,42 +11,12 @@ void exit (int status) { - rt_thread_t self = rt_thread_self(); - -#ifdef RT_USING_MODULE - if (dlmodule_self()) - { - dlmodule_exit(status); - } -#endif - - if (self != RT_NULL) - { - rt_kprintf("thread:%-8.*s exit:%d!\n", RT_NAME_MAX, self->name, status); - rt_thread_suspend(self); - rt_schedule(); - } - - while(1); /* noreturn */ + extern rt_inline void __exit__(int status); + __exit__(return_code); } void abort(void) { - rt_thread_t self = rt_thread_self(); - -#ifdef RT_USING_MODULE - if (dlmodule_self()) - { - dlmodule_exit(-1); - } -#endif - - if (self != RT_NULL) - { - rt_kprintf("thread:%-8.*s abort!\n", RT_NAME_MAX, self->name); - rt_thread_suspend(self); - rt_schedule(); - } - - while(1); /* noreturn */ + extern rt_inline void __abort__(void); + __abort__(); } diff --git a/components/libc/compilers/newlib/syscalls.c b/components/libc/compilers/newlib/syscalls.c index cf98e0c3ec..7fe02eb0a0 100644 --- a/components/libc/compilers/newlib/syscalls.c +++ b/components/libc/compilers/newlib/syscalls.c @@ -286,30 +286,15 @@ _free_r (struct _reent *ptr, void *addr) void exit (int status) { - rt_thread_t self = rt_thread_self(); - -#ifdef RT_USING_MODULE - if (dlmodule_self()) - { - dlmodule_exit(status); - } -#endif - - if (self != RT_NULL) - { - rt_kprintf("thread:%-8.*s exit:%d!\n", RT_NAME_MAX, self->name, status); - rt_thread_suspend(self); - rt_schedule(); - } - - while(1); /* noreturn */ + extern rt_inline void __exit__(int status); + __exit__(status); } void _system(const char *s) { - /* not support this call */ - return; + extern rt_inline int __system__(const char *string); + __system__(string); } void __libc_init_array(void) @@ -319,23 +304,8 @@ void __libc_init_array(void) void abort(void) { - rt_thread_t self = rt_thread_self(); - -#ifdef RT_USING_MODULE - if (dlmodule_self()) - { - dlmodule_exit(-1); - } -#endif - - if (self != RT_NULL) - { - rt_kprintf("thread:%-8.*s abort!\n", RT_NAME_MAX, self->name); - rt_thread_suspend(self); - rt_schedule(); - } - - while(1); /* noreturn */ + extern rt_inline void __abort__(void); + __abort__(); } uid_t getuid(void) -- cgit v1.3.1