[libc] remove RT_USING_LIBC

This commit is contained in:
Meco Man
2021-12-26 09:41:24 -05:00
committed by Bernard Xiong
parent 5925abce3e
commit ed09f38012
59 changed files with 178 additions and 190 deletions

View File

@@ -1,10 +1,4 @@
# NEWLIB (GCC) porting for RT-Thread
Please define RT_USING_LIBC and compile RT-Thread with GCC compiler.
## More Information
https://sourceware.org/newlib/libc.html#Reentrancy

View File

@@ -10,11 +10,8 @@ LIBS = ['m'] # link libm
CPPPATH = [cwd]
if rtconfig.PLATFORM == 'gcc':
if GetDepend('RT_USING_LIBC'):
LIBS += ['c'] # link libc
src += Glob('*.c')
else:
src += ['syscalls.c']
LIBS += ['c'] # link libc
src += Glob('*.c')
#report newlib version
print('Newlib version:' + GetNewLibVersion(rtconfig))
@@ -22,7 +19,7 @@ if rtconfig.PLATFORM == 'gcc':
# identify this is Newlib, and only enable POSIX.1-1990
CPPDEFINES = ['RT_USING_NEWLIB', '_POSIX_C_SOURCE=1']
group = DefineGroup('libc', src, depend = [], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS)
group = DefineGroup('compiler-libc', src, depend = [], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS)
list = os.listdir(cwd)

View File

@@ -26,7 +26,7 @@
#ifdef RT_USING_MODULE
#include <dlmodule.h>
#endif /* RT_USING_MODULE */
#include <compiler_private.h>
#define DBG_TAG "newlib.syscalls"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
@@ -92,8 +92,6 @@ void __libc_init_array(void)
/* __libc_init_array is ARM code, not Thumb; it will cause a hardfault. */
}
#ifdef RT_USING_LIBC
/* Reentrant versions of system calls. */
#ifndef _REENT_ONLY
int *__errno ()
@@ -112,6 +110,7 @@ int _close_r(struct _reent *ptr, int fd)
#ifdef DFS_USING_POSIX
return close(fd);
#else
LOG_W("%s: %s", __func__, warning_without_fs);
ptr->_errno = ENOTSUP;
return -1;
#endif /* DFS_USING_POSIX */
@@ -185,10 +184,10 @@ _off_t _lseek_r(struct _reent *ptr, int fd, _off_t pos, int whence)
{
#ifdef DFS_USING_POSIX
_off_t rc;
rc = lseek(fd, pos, whence);
return rc;
#else
LOG_W("%s: %s", __func__, warning_without_fs);
ptr->_errno = ENOTSUP;
return -1;
#endif /* DFS_USING_POSIX */
@@ -198,10 +197,10 @@ int _mkdir_r(struct _reent *ptr, const char *name, int mode)
{
#ifdef DFS_USING_POSIX
int rc;
rc = mkdir(name, mode);
return rc;
#else
LOG_W("%s: %s", __func__, warning_without_fs);
ptr->_errno = ENOTSUP;
return -1;
#endif /* DFS_USING_POSIX */
@@ -214,6 +213,7 @@ int _open_r(struct _reent *ptr, const char *file, int flags, int mode)
rc = open(file, flags, mode);
return rc;
#else
LOG_W("%s: %s", __func__, warning_without_fs);
ptr->_errno = ENOTSUP;
return -1;
#endif /* DFS_USING_POSIX */
@@ -228,10 +228,11 @@ _ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes)
#ifdef RT_USING_POSIX_DEVIO
if (libc_stdio_get_console() < 0)
{
LOG_W("Do not invoke standard input before initializing libc");
LOG_W("Do not invoke standard input before initializing compiler-libc");
return 0;
}
#else
LOG_W("%s: %s", __func__, warning_without_devio);
ptr->_errno = ENOTSUP;
return -1;
#endif /* RT_USING_POSIX_DEVIO */
@@ -245,6 +246,7 @@ _ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes)
rc = read(fd, buf, nbytes);
return rc;
#else
LOG_W("%s: %s", __func__, warning_without_fs);
ptr->_errno = ENOTSUP;
return -1;
#endif /* DFS_USING_POSIX */
@@ -254,10 +256,10 @@ int _rename_r(struct _reent *ptr, const char *old, const char *new)
{
#ifdef DFS_USING_POSIX
int rc;
rc = rename(old, new);
return rc;
#else
LOG_W("%s: %s", __func__, warning_without_fs);
ptr->_errno = ENOTSUP;
return -1;
#endif /* DFS_USING_POSIX */
@@ -267,10 +269,10 @@ int _stat_r(struct _reent *ptr, const char *file, struct stat *pstat)
{
#ifdef DFS_USING_POSIX
int rc;
rc = stat(file, pstat);
return rc;
#else
LOG_W("%s: %s", __func__, warning_without_fs);
ptr->_errno = ENOTSUP;
return -1;
#endif /* DFS_USING_POSIX */
@@ -281,6 +283,7 @@ int _unlink_r(struct _reent *ptr, const char *file)
#ifdef DFS_USING_POSIX
return unlink(file);
#else
LOG_W("%s: %s", __func__, warning_without_fs);
ptr->_errno = ENOTSUP;
return -1;
#endif /* DFS_USING_POSIX */
@@ -315,6 +318,7 @@ _ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
rc = write(fd, buf, nbytes);
return rc;
#else
LOG_W("%s: %s", __func__, warning_without_fs);
ptr->_errno = ENOTSUP;
return -1;
#endif /* DFS_USING_POSIX */
@@ -333,5 +337,3 @@ These functions are implemented and replaced by the 'common/time.c' file
int _gettimeofday_r(struct _reent *ptr, struct timeval *__tp, void *__tzp);
_CLOCK_T_ _times_r(struct _reent *ptr, struct tms *ptms);
*/
#endif /* RT_USING_LIBC */