diff options
| author | Meco Jianting Man <[email protected]> | 2021-02-27 01:02:48 -0600 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-02-27 01:02:48 -0600 |
| commit | 8932ffdb96b793031bbc71bb3bd23202939fcb2c (patch) | |
| tree | 33ac8cd4afac62c449384ed20f2af94ab0b90708 /components/libc/compilers/newlib | |
| parent | bc28df8b350f2118f418b966df0843c7f2c02496 (diff) | |
| parent | 2bf53d315d62bd199c01fd2d6a7f05d1a6712153 (diff) | |
Merge pull request #21 from RT-Thread/master
pr
Diffstat (limited to 'components/libc/compilers/newlib')
| -rw-r--r-- | components/libc/compilers/newlib/SConscript | 29 | ||||
| -rw-r--r-- | components/libc/compilers/newlib/minilib.c | 18 | ||||
| -rw-r--r-- | components/libc/compilers/newlib/syscalls.c | 11 |
3 files changed, 44 insertions, 14 deletions
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 <reent.h> +#include <rtthread.h> + +void * _sbrk_r(struct _reent *ptr, ptrdiff_t incr) +{ + /* no use this routine to get memory */ + return RT_NULL; +} diff --git a/components/libc/compilers/newlib/syscalls.c b/components/libc/compilers/newlib/syscalls.c index 45aa4a34de..949d8a61de 100644 --- a/components/libc/compilers/newlib/syscalls.c +++ b/components/libc/compilers/newlib/syscalls.c @@ -8,6 +8,7 @@ * 2021-02-11 Meco Man remove _gettimeofday_r() and _times_r() * 2020-02-13 Meco Man re-implement exit() and abort() * 2020-02-21 Meco Man improve and beautify syscalls + * 2020-02-24 Meco Man fix bug of _isatty_r() */ #include <reent.h> @@ -89,12 +90,14 @@ int _isatty_r(struct _reent *ptr, int fd) { if (fd >=0 && fd < 3) + { return 1; - - ptr->_errno = ENOTTY ; - return 0; + } + else + { + return 0; + } } - int _kill_r(struct _reent *ptr, int pid, int sig) { |
