summaryrefslogtreecommitdiff
path: root/components/libc/compilers
diff options
context:
space:
mode:
authorMeco Man <[email protected]>2021-12-26 09:41:24 -0500
committerBernard Xiong <[email protected]>2021-12-30 01:27:25 +0800
commited09f38012131850cd67c1392554653b56a37341 (patch)
tree63336abe8aac0d277e48c7286e3f303b88b35357 /components/libc/compilers
parent5925abce3ea69ad1e8db468c4015a6e76e217bb9 (diff)
[libc] remove RT_USING_LIBC
Diffstat (limited to 'components/libc/compilers')
-rw-r--r--components/libc/compilers/armlibc/README.md6
-rw-r--r--components/libc/compilers/armlibc/SConscript2
-rw-r--r--components/libc/compilers/armlibc/syscall_mem.c (renamed from components/libc/compilers/armlibc/mem_std.c)2
-rw-r--r--components/libc/compilers/armlibc/syscalls.c14
-rw-r--r--components/libc/compilers/common/SConscript7
-rw-r--r--components/libc/compilers/common/compiler_private.c13
-rw-r--r--components/libc/compilers/common/compiler_private.h18
-rw-r--r--components/libc/compilers/common/nogcc/SConscript5
-rw-r--r--components/libc/compilers/common/time.c18
-rw-r--r--components/libc/compilers/dlib/README.md6
-rw-r--r--components/libc/compilers/dlib/SConscript2
-rw-r--r--components/libc/compilers/dlib/syscall_close.c5
-rw-r--r--components/libc/compilers/dlib/syscall_lseek.c5
-rw-r--r--components/libc/compilers/dlib/syscall_mem.c2
-rw-r--r--components/libc/compilers/dlib/syscall_open.c84
-rw-r--r--components/libc/compilers/dlib/syscall_read.c8
-rw-r--r--components/libc/compilers/dlib/syscall_remove.c5
-rw-r--r--components/libc/compilers/dlib/syscall_write.c4
-rw-r--r--components/libc/compilers/gcc/newlib/README.md6
-rw-r--r--components/libc/compilers/gcc/newlib/SConscript9
-rw-r--r--components/libc/compilers/gcc/newlib/syscalls.c22
21 files changed, 144 insertions, 99 deletions
diff --git a/components/libc/compilers/armlibc/README.md b/components/libc/compilers/armlibc/README.md
index 4d2a73b6be..fc0d750234 100644
--- a/components/libc/compilers/armlibc/README.md
+++ b/components/libc/compilers/armlibc/README.md
@@ -1,9 +1,3 @@
# ARMLIB (Keil-MDK) porting for RT-Thread
-Please define RT_USING_LIBC and compile RT-Thread with Keil-MDK compiler.
-
-
-
-## More Information
-
https://www.keil.com/support/man/docs/armlib/ \ No newline at end of file
diff --git a/components/libc/compilers/armlibc/SConscript b/components/libc/compilers/armlibc/SConscript
index bf1a299304..7fc94ccaa4 100644
--- a/components/libc/compilers/armlibc/SConscript
+++ b/components/libc/compilers/armlibc/SConscript
@@ -7,6 +7,6 @@ group = []
CPPDEFINES = ['RT_USING_ARM_LIBC']
if rtconfig.PLATFORM == 'armcc' or rtconfig.PLATFORM == 'armclang':
- group = DefineGroup('libc', src, depend = ['RT_USING_LIBC'], CPPDEFINES = CPPDEFINES)
+ group = DefineGroup('compiler-libc', src, depend = [], CPPDEFINES = CPPDEFINES)
Return('group')
diff --git a/components/libc/compilers/armlibc/mem_std.c b/components/libc/compilers/armlibc/syscall_mem.c
index f8a81c7873..b5403dfaf3 100644
--- a/components/libc/compilers/armlibc/mem_std.c
+++ b/components/libc/compilers/armlibc/syscall_mem.c
@@ -13,7 +13,7 @@
#include <stddef.h>
#ifndef RT_USING_HEAP
-#define DBG_TAG "armlibc.mem"
+#define DBG_TAG "armlibc.syscall.mem"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
diff --git a/components/libc/compilers/armlibc/syscalls.c b/components/libc/compilers/armlibc/syscalls.c
index 0e965d62af..77bf37dcbc 100644
--- a/components/libc/compilers/armlibc/syscalls.c
+++ b/components/libc/compilers/armlibc/syscalls.c
@@ -21,6 +21,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
+#include <compiler_private.h>
#ifdef RT_USING_POSIX_DEVIO
#include "libc.h"
#endif /* RT_USING_POSIX_DEVIO */
@@ -69,6 +70,7 @@ FILEHANDLE _sys_open(const char *name, int openmode)
return (STDERR);
#ifndef DFS_USING_POSIX
+ LOG_W("%s: %s", __func__, warning_without_fs);
return 0; /* error */
#else
/* Correct openmode from fopen to open */
@@ -113,6 +115,7 @@ int _sys_close(FILEHANDLE fh)
return close(fh);
#else
+ LOG_W("%s: %s", __func__, warning_without_fs);
return 0;
#endif /* DFS_USING_POSIX */
}
@@ -152,12 +155,13 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
#ifdef RT_USING_POSIX_DEVIO
if (libc_stdio_get_console() < 0)
{
- LOG_W("Do not invoke standard output before initializing libc");
+ LOG_W("Do not invoke standard output before initializing compiler-libc");
return 0; /* error, but keep going */
}
size = read(STDIN_FILENO, buf, len);
return len - size; /* success */
#else
+ LOG_W("%s: %s", __func__, warning_without_devio);
return 0; /* error */
#endif /* RT_USING_POSIX_DEVIO */
}
@@ -178,6 +182,7 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
}
}
#else
+ LOG_W("%s: %s", __func__, warning_without_fs);
return 0; /* error */
#endif /* DFS_USING_POSIX */
}
@@ -228,6 +233,7 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
return 0; /* error */
}
#else
+ LOG_W("%s: %s", __func__, warning_without_fs);
return 0; /* error */
#endif /* DFS_USING_POSIX */
}
@@ -246,6 +252,7 @@ int _sys_seek(FILEHANDLE fh, long pos)
/* position is relative to the start of file fh */
return lseek(fh, pos, 0);
#else
+ LOG_W("%s: %s", __func__, warning_without_fs);
return 0; /* error */
#endif /* DFS_USING_POSIX */
}
@@ -301,6 +308,7 @@ long _sys_flen(FILEHANDLE fh)
fstat(fh, &stat);
return stat.st_size;
#else
+ LOG_W("%s: %s", __func__, warning_without_fs);
return 0;
#endif /* DFS_USING_POSIX */
}
@@ -318,6 +326,7 @@ int remove(const char *filename)
#ifdef DFS_USING_POSIX
return unlink(filename);
#else
+ LOG_W("%s: %s", __func__, warning_without_fs);
return 0; /* error */
#endif /* DFS_USING_POSIX */
}
@@ -345,13 +354,14 @@ int fgetc(FILE *f)
if (libc_stdio_get_console() < 0)
{
- LOG_W("Do not invoke standard output before initializing libc");
+ LOG_W("Do not invoke standard output before initializing compiler-libc");
return 0;
}
if(read(STDIN_FILENO, &ch, 1) == 1)
return ch;
#endif /* RT_USING_POSIX_DEVIO */
+ LOG_W("%s: %s", __func__, warning_without_devio);
return 0; /* error */
}
diff --git a/components/libc/compilers/common/SConscript b/components/libc/compilers/common/SConscript
index 504bf84e56..26cd9ab1d8 100644
--- a/components/libc/compilers/common/SConscript
+++ b/components/libc/compilers/common/SConscript
@@ -10,12 +10,9 @@ CPPDEFINES = []
if rtconfig.CROSS_TOOL == 'keil':
CPPDEFINES += ['__CLK_TCK=RT_TICK_PER_SECOND']
-if GetDepend('RT_USING_LIBC'):
- src += Glob('*.c')
-elif GetDepend('RT_LIBC_USING_TIME'):
- src += ['time.c']
+src += Glob('*.c')
-group = DefineGroup('libc', src, depend = [], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)
+group = DefineGroup('compiler-libc', src, depend = [], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)
list = os.listdir(cwd)
for item in list:
diff --git a/components/libc/compilers/common/compiler_private.c b/components/libc/compilers/common/compiler_private.c
new file mode 100644
index 0000000000..6e9a6001f0
--- /dev/null
+++ b/components/libc/compilers/common/compiler_private.c
@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) 2006-2021, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2021-12-26 Meco Man First Version
+ */
+#include "compiler_private.h"
+
+const char *warning_without_fs = "Please enable RT_USING_POSIX_FS";
+const char *warning_without_devio = "Please enable RT_USING_POSIX_FS and RT_USING_POSIX_DEVIO";
diff --git a/components/libc/compilers/common/compiler_private.h b/components/libc/compilers/common/compiler_private.h
new file mode 100644
index 0000000000..79bac3b787
--- /dev/null
+++ b/components/libc/compilers/common/compiler_private.h
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2006-2021, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2021-12-26 Meco Man First Version
+ */
+#ifndef __COMPILER_PRIVATE_H__
+#define __COMPILER_PRIVATE_H__
+
+#include <rtconfig.h>
+
+extern const char *warning_without_fs;
+extern const char *warning_without_devio;
+
+#endif /* __COMPILER_PRIVATE_H__ */
diff --git a/components/libc/compilers/common/nogcc/SConscript b/components/libc/compilers/common/nogcc/SConscript
index c766c8f82d..091848a6d5 100644
--- a/components/libc/compilers/common/nogcc/SConscript
+++ b/components/libc/compilers/common/nogcc/SConscript
@@ -7,9 +7,8 @@ cwd = GetCurrentDir()
CPPPATH = [cwd]
group = []
-if GetDepend('RT_USING_LIBC'):
- src += Glob('*.c')
+src += Glob('*.c')
if rtconfig.PLATFORM != 'gcc' or rtconfig.ARCH == 'sim':
- group = DefineGroup('libc', src, depend = [], CPPPATH = CPPPATH)
+ group = DefineGroup('compiler-libc', src, depend = [], CPPPATH = CPPPATH)
Return('group')
diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c
index 4d204a0c00..1fe11561f7 100644
--- a/components/libc/compilers/common/time.c
+++ b/components/libc/compilers/common/time.c
@@ -25,7 +25,7 @@
#include <sys/errno.h>
#include <rtthread.h>
#include <rthw.h>
-#ifdef RT_USING_DEVICE
+#ifdef RT_USING_RTC
#include <rtdevice.h>
#endif
@@ -33,6 +33,8 @@
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
+#define WARNING_NO_RTC "Cannot find a RTC device!"
+
/* seconds per day */
#define SPD 24*60*60
@@ -108,7 +110,7 @@ static rt_err_t get_timeval(struct timeval *tv)
else
{
/* LOG_W will cause a recursive printing if ulog timestamp function is enabled */
- rt_kprintf("Cannot find a RTC device to provide time!\r\n");
+ rt_kprintf(WARNING_NO_RTC);
return -RT_ENOSYS;
}
@@ -116,7 +118,7 @@ static rt_err_t get_timeval(struct timeval *tv)
#else
/* LOG_W will cause a recursive printing if ulog timestamp function is enabled */
- rt_kprintf("Cannot find a RTC device to provide time!\r\n");
+ rt_kprintf(WARNING_NO_RTC);
return -RT_ENOSYS;
#endif /* RT_USING_RTC */
}
@@ -153,14 +155,14 @@ static int set_timeval(struct timeval *tv)
}
else
{
- LOG_W("Cannot find a RTC device to provide time!");
+ LOG_W(WARNING_NO_RTC);
return -RT_ENOSYS;
}
return rst;
#else
- LOG_W("Cannot find a RTC device to provide time!");
+ LOG_W(WARNING_NO_RTC);
return -RT_ENOSYS;
#endif /* RT_USING_RTC */
}
@@ -525,7 +527,7 @@ INIT_COMPONENT_EXPORT(_rt_clock_time_system_init);
int clock_getres(clockid_t clockid, struct timespec *res)
{
#ifndef RT_USING_RTC
- LOG_W("Cannot find a RTC device to save time!");
+ LOG_W(WARNING_NO_RTC);
return -1;
#else
int ret = 0;
@@ -564,7 +566,7 @@ RTM_EXPORT(clock_getres);
int clock_gettime(clockid_t clockid, struct timespec *tp)
{
#ifndef RT_USING_RTC
- LOG_W("Cannot find a RTC device to save time!");
+ LOG_W(WARNING_NO_RTC);
return -1;
#else
int ret = 0;
@@ -628,7 +630,7 @@ int clock_nanosleep(clockid_t clockid, int flags, const struct timespec *rqtp, s
int clock_settime(clockid_t clockid, const struct timespec *tp)
{
#ifndef RT_USING_RTC
- LOG_W("Cannot find a RTC device to save time!");
+ LOG_W(WARNING_NO_RTC);
return -1;
#else
register rt_base_t level;
diff --git a/components/libc/compilers/dlib/README.md b/components/libc/compilers/dlib/README.md
index acd08f9074..e4d70e8135 100644
--- a/components/libc/compilers/dlib/README.md
+++ b/components/libc/compilers/dlib/README.md
@@ -1,9 +1,3 @@
# DLIB (IAR) porting for RT-Thread
-Please define RT_USING_LIBC and compile RT-Thread with IAR compiler.
-
-
-
-## More Information
-
http://www.iarsys.co.jp/download/LMS2/arm/7502/ewarm7502doc/arm/doc/EWARM_DevelopmentGuide.ENU.pdf P.130 \ No newline at end of file
diff --git a/components/libc/compilers/dlib/SConscript b/components/libc/compilers/dlib/SConscript
index f685873e16..2c5dbc426d 100644
--- a/components/libc/compilers/dlib/SConscript
+++ b/components/libc/compilers/dlib/SConscript
@@ -15,6 +15,6 @@ if rtconfig.PLATFORM == 'iar':
if LooseVersion(IARVersion()) < LooseVersion("8.20.1"):
CPPDEFINES = CPPDEFINES + ['_DLIB_THREAD_SUPPORT']
- group = DefineGroup('libc', src, depend = ['RT_USING_LIBC'], CPPDEFINES = CPPDEFINES)
+ group = DefineGroup('compiler-libc', src, depend = [], CPPDEFINES = CPPDEFINES)
Return('group')
diff --git a/components/libc/compilers/dlib/syscall_close.c b/components/libc/compilers/dlib/syscall_close.c
index 30ee6f2388..9ac60076f4 100644
--- a/components/libc/compilers/dlib/syscall_close.c
+++ b/components/libc/compilers/dlib/syscall_close.c
@@ -10,6 +10,10 @@
#include <rtthread.h>
#include <LowLevelIOInterface.h>
#include <unistd.h>
+#include <compiler_private.h>
+#define DBG_TAG "dlib.syscall.close"
+#define DBG_LVL DBG_INFO
+#include <rtdbg.h>
/*
* The "__close" function should close the file corresponding to
@@ -27,6 +31,7 @@ int __close(int handle)
#ifdef DFS_USING_POSIX
return close(handle);
#else
+ LOG_W(warning_without_fs);
return _LLIO_ERROR;
#endif /* DFS_USING_POSIX */
}
diff --git a/components/libc/compilers/dlib/syscall_lseek.c b/components/libc/compilers/dlib/syscall_lseek.c
index 622f613c51..b7ec0fa7a9 100644
--- a/components/libc/compilers/dlib/syscall_lseek.c
+++ b/components/libc/compilers/dlib/syscall_lseek.c
@@ -10,6 +10,10 @@
#include <rtthread.h>
#include <LowLevelIOInterface.h>
#include <unistd.h>
+#include <compiler_private.h>
+#define DBG_TAG "dlib.syscall.lseek"
+#define DBG_LVL DBG_INFO
+#include <rtdbg.h>
/*
* The "__lseek" function makes the next file operation (__read or
@@ -36,6 +40,7 @@ long __lseek(int handle, long offset, int whence)
#ifdef DFS_USING_POSIX
return lseek(handle, offset, whence);
#else
+ LOG_W(warning_without_fs);
return _LLIO_ERROR;
#endif /* DFS_USING_POSIX */
}
diff --git a/components/libc/compilers/dlib/syscall_mem.c b/components/libc/compilers/dlib/syscall_mem.c
index 74b960f0b9..57060da842 100644
--- a/components/libc/compilers/dlib/syscall_mem.c
+++ b/components/libc/compilers/dlib/syscall_mem.c
@@ -12,7 +12,7 @@
#include <stddef.h>
#ifndef RT_USING_HEAP
-#define DBG_TAG "dlib.syscall_mem"
+#define DBG_TAG "dlib.syscall.mem"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#define _NO_HEAP_ERROR() do{LOG_E("Please enable RT_USING_HEAP");\
diff --git a/components/libc/compilers/dlib/syscall_open.c b/components/libc/compilers/dlib/syscall_open.c
index 66cddc83c1..3d31f0cf69 100644
--- a/components/libc/compilers/dlib/syscall_open.c
+++ b/components/libc/compilers/dlib/syscall_open.c
@@ -11,6 +11,10 @@
#include <rtthread.h>
#include <LowLevelIOInterface.h>
#include <fcntl.h>
+#include <compiler_private.h>
+#define DBG_TAG "dlib.syscall.open"
+#define DBG_LVL DBG_INFO
+#include <rtdbg.h>
/*
* The "__open" function opens the file named "filename" as specified
@@ -22,56 +26,58 @@
int __open(const char *filename, int mode)
{
#ifdef DFS_USING_POSIX
- int handle;
- int open_mode = O_RDONLY;
+ int handle;
+ int open_mode = O_RDONLY;
- if (mode & _LLIO_CREAT)
- {
- open_mode |= O_CREAT;
-
- /* Check what we should do with it if it exists. */
- if (mode & _LLIO_APPEND)
+ if (mode & _LLIO_CREAT)
{
- /* Append to the existing file. */
- open_mode |= O_APPEND;
+ open_mode |= O_CREAT;
+
+ /* Check what we should do with it if it exists. */
+ if (mode & _LLIO_APPEND)
+ {
+ /* Append to the existing file. */
+ open_mode |= O_APPEND;
+ }
+
+ if (mode & _LLIO_TRUNC)
+ {
+ /* Truncate the existsing file. */
+ open_mode |= O_TRUNC;
+ }
}
- if (mode & _LLIO_TRUNC)
+ if (mode & _LLIO_TEXT)
{
- /* Truncate the existsing file. */
- open_mode |= O_TRUNC;
+ /* we didn't support text mode */
}
- }
- if (mode & _LLIO_TEXT)
- {
- /* we didn't support text mode */
- }
-
- switch (mode & _LLIO_RDWRMASK)
- {
- case _LLIO_RDONLY:
- break;
-
- case _LLIO_WRONLY:
- open_mode |= O_WRONLY;
- break;
+ switch (mode & _LLIO_RDWRMASK)
+ {
+ case _LLIO_RDONLY:
+ break;
- case _LLIO_RDWR:
- /* The file should be opened for both reads and writes. */
- open_mode |= O_RDWR;
- break;
+ case _LLIO_WRONLY:
+ open_mode |= O_WRONLY;
+ break;
- default:
- return _LLIO_ERROR;
- }
+ case _LLIO_RDWR:
+ /* The file should be opened for both reads and writes. */
+ open_mode |= O_RDWR;
+ break;
- handle = open(filename, open_mode, 0);
- if (handle < 0)
- return _LLIO_ERROR;
+ default:
+ return _LLIO_ERROR;
+ }
- return handle;
+ handle = open(filename, open_mode, 0);
+ if (handle < 0)
+ {
+ return _LLIO_ERROR;
+ }
+ return handle;
#else
- return _LLIO_ERROR;
+ LOG_W(warning_without_fs);
+ return _LLIO_ERROR;
#endif /* DFS_USING_POSIX */
}
diff --git a/components/libc/compilers/dlib/syscall_read.c b/components/libc/compilers/dlib/syscall_read.c
index 62bc05d243..29941c23db 100644
--- a/components/libc/compilers/dlib/syscall_read.c
+++ b/components/libc/compilers/dlib/syscall_read.c
@@ -14,8 +14,8 @@
#ifdef RT_USING_POSIX_DEVIO
#include "libc.h"
#endif /* RT_USING_POSIX_DEVIO */
-
-#define DBG_TAG "dlib.syscall_read"
+#include <compiler_private.h>
+#define DBG_TAG "dlib.syscall.read"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
@@ -42,11 +42,12 @@ size_t __read(int handle, unsigned char *buf, size_t len)
#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; /* error, but keep going */
}
return read(STDIN_FILENO, buf, len); /* return the length of the data read */
#else
+ LOG_W(warning_without_devio);
return _LLIO_ERROR;
#endif /* RT_USING_POSIX_DEVIO */
}
@@ -58,6 +59,7 @@ size_t __read(int handle, unsigned char *buf, size_t len)
size = read(handle, buf, len);
return size; /* return the length of the data read */
#else
+ LOG_W(warning_without_fs);
return _LLIO_ERROR;
#endif /* DFS_USING_POSIX */
}
diff --git a/components/libc/compilers/dlib/syscall_remove.c b/components/libc/compilers/dlib/syscall_remove.c
index 870f91b8c1..9b5d596eb5 100644
--- a/components/libc/compilers/dlib/syscall_remove.c
+++ b/components/libc/compilers/dlib/syscall_remove.c
@@ -10,6 +10,10 @@
#include <rtthread.h>
#include <LowLevelIOInterface.h>
#include <unistd.h>
+#include <compiler_private.h>
+#define DBG_TAG "dlib.syscall.remove"
+#define DBG_LVL DBG_INFO
+#include <rtdbg.h>
/*
* The "remove" function should remove the file named "filename". It
@@ -23,6 +27,7 @@ int remove(const char *filename)
#ifdef DFS_USING_POSIX
return unlink(filename);
#else
+ LOG_W(warning_without_fs);
return _LLIO_ERROR;
#endif /* DFS_USING_POSIX */
}
diff --git a/components/libc/compilers/dlib/syscall_write.c b/components/libc/compilers/dlib/syscall_write.c
index 2bc5863d8a..11a6f9cca5 100644
--- a/components/libc/compilers/dlib/syscall_write.c
+++ b/components/libc/compilers/dlib/syscall_write.c
@@ -11,7 +11,8 @@
#include <rtthread.h>
#include <LowLevelIOInterface.h>
#include <unistd.h>
-#define DBG_TAG "dlib.syscall_write"
+#include <compiler_private.h>
+#define DBG_TAG "dlib.syscall.write"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
@@ -63,6 +64,7 @@ size_t __write(int handle, const unsigned char *buf, size_t len)
size = write(handle, buf, len);
return size; /* return the length of the data written */
#else
+ LOG_W(warning_without_fs);
return _LLIO_ERROR;
#endif /* DFS_USING_POSIX */
}
diff --git a/components/libc/compilers/gcc/newlib/README.md b/components/libc/compilers/gcc/newlib/README.md
index 62172e6a55..4614375b45 100644
--- a/components/libc/compilers/gcc/newlib/README.md
+++ b/components/libc/compilers/gcc/newlib/README.md
@@ -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
diff --git a/components/libc/compilers/gcc/newlib/SConscript b/components/libc/compilers/gcc/newlib/SConscript
index d51bbdad84..7a2be2e781 100644
--- a/components/libc/compilers/gcc/newlib/SConscript
+++ b/components/libc/compilers/gcc/newlib/SConscript
@@ -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)
diff --git a/components/libc/compilers/gcc/newlib/syscalls.c b/components/libc/compilers/gcc/newlib/syscalls.c
index 8fe8c5be4b..65dece0d02 100644
--- a/components/libc/compilers/gcc/newlib/syscalls.c
+++ b/components/libc/compilers/gcc/newlib/syscalls.c
@@ -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 */