summaryrefslogtreecommitdiff
path: root/components/libc
diff options
context:
space:
mode:
authorMeco Man <[email protected]>2021-11-24 08:41:10 -0500
committerMeco Man <[email protected]>2021-11-24 08:41:10 -0500
commita3284876ff096999c4c3ecb4f0f5b65b752e4d74 (patch)
tree9940ab4f0c87726e984920f4cec4b3c158d64413 /components/libc
parent3bc5ffb495a34ee6235e493375770ef2bb4457d3 (diff)
revise RT_USING_POSIX_STDIO to RT_USING_POSIX_DEVIO
Diffstat (limited to 'components/libc')
-rw-r--r--components/libc/Kconfig6
-rw-r--r--components/libc/compilers/armlibc/syscalls.c12
-rw-r--r--components/libc/compilers/dlib/syscall_read.c8
-rw-r--r--components/libc/compilers/dlib/syscall_write.c4
-rw-r--r--components/libc/compilers/gcc/newlib/syscalls.c10
-rw-r--r--components/libc/posix/src/SConscript2
6 files changed, 19 insertions, 23 deletions
diff --git a/components/libc/Kconfig b/components/libc/Kconfig
index 94793be569..a616754904 100644
--- a/components/libc/Kconfig
+++ b/components/libc/Kconfig
@@ -12,7 +12,7 @@ if RT_USING_LIBC
config RT_LIBC_USING_FILEIO
bool "Enable libc with file operation, eg.fopen/fwrite/fread/getchar"
select RT_USING_POSIX
- select RT_USING_POSIX_STDIO
+ select RT_USING_POSIX_DEVIO
default n
config RT_USING_MODULE
@@ -44,8 +44,8 @@ config RT_USING_POSIX
default n
if RT_USING_POSIX
- config RT_USING_POSIX_STDIO
- bool "Enable standard I/O, STDOUT_FILENO/STDIN_FILENO/STDERR_FILENO"
+ config RT_USING_POSIX_DEVIO
+ bool "Enable devices as file descriptors"
select RT_USING_DFS
select RT_USING_DFS_DEVFS
default n
diff --git a/components/libc/compilers/armlibc/syscalls.c b/components/libc/compilers/armlibc/syscalls.c
index 71eacb1c41..bfd3777193 100644
--- a/components/libc/compilers/armlibc/syscalls.c
+++ b/components/libc/compilers/armlibc/syscalls.c
@@ -21,9 +21,9 @@
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
-#ifdef RT_USING_POSIX_STDIO
+#ifdef RT_USING_POSIX_DEVIO
#include "libc.h"
-#endif
+#endif /* RT_USING_POSIX_DEVIO */
#define DBG_TAG "armlibc.syscalls"
#define DBG_LVL DBG_INFO
@@ -149,7 +149,7 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
if (fh == STDIN)
{
-#ifdef RT_USING_POSIX_STDIO
+#ifdef RT_USING_POSIX_DEVIO
if (libc_stdio_get_console() < 0)
{
LOG_W("Do not invoke standard output before initializing libc");
@@ -159,7 +159,7 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
return 0; /* success */
#else
return 0; /* error */
-#endif
+#endif /* RT_USING_POSIX_DEVIO */
}
else if (fh == STDOUT || fh == STDERR)
{
@@ -332,7 +332,7 @@ int fputc(int c, FILE *f)
int fgetc(FILE *f)
{
-#ifdef RT_USING_POSIX_STDIO
+#ifdef RT_USING_POSIX_DEVIO
char ch;
if (libc_stdio_get_console() < 0)
@@ -343,7 +343,7 @@ int fgetc(FILE *f)
if(read(STDIN_FILENO, &ch, 1) == 1)
return ch;
-#endif /* RT_USING_POSIX_STDIO */
+#endif /* RT_USING_POSIX_DEVIO */
return 0; /* error */
}
diff --git a/components/libc/compilers/dlib/syscall_read.c b/components/libc/compilers/dlib/syscall_read.c
index 469ea7c1dd..62bc05d243 100644
--- a/components/libc/compilers/dlib/syscall_read.c
+++ b/components/libc/compilers/dlib/syscall_read.c
@@ -11,9 +11,9 @@
#include <rtthread.h>
#include <LowLevelIOInterface.h>
#include <unistd.h>
-#ifdef RT_USING_POSIX_STDIO
+#ifdef RT_USING_POSIX_DEVIO
#include "libc.h"
-#endif
+#endif /* RT_USING_POSIX_DEVIO */
#define DBG_TAG "dlib.syscall_read"
#define DBG_LVL DBG_INFO
@@ -39,7 +39,7 @@ size_t __read(int handle, unsigned char *buf, size_t len)
if (handle == _LLIO_STDIN)
{
-#ifdef RT_USING_POSIX_STDIO
+#ifdef RT_USING_POSIX_DEVIO
if (libc_stdio_get_console() < 0)
{
LOG_W("Do not invoke standard input before initializing libc");
@@ -48,7 +48,7 @@ size_t __read(int handle, unsigned char *buf, size_t len)
return read(STDIN_FILENO, buf, len); /* return the length of the data read */
#else
return _LLIO_ERROR;
-#endif /* RT_USING_POSIX_STDIO */
+#endif /* RT_USING_POSIX_DEVIO */
}
else if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR))
{
diff --git a/components/libc/compilers/dlib/syscall_write.c b/components/libc/compilers/dlib/syscall_write.c
index d5ede3e59e..2bc5863d8a 100644
--- a/components/libc/compilers/dlib/syscall_write.c
+++ b/components/libc/compilers/dlib/syscall_write.c
@@ -11,10 +11,6 @@
#include <rtthread.h>
#include <LowLevelIOInterface.h>
#include <unistd.h>
-#ifdef RT_USING_POSIX_STDIO
-#include "libc.h"
-#endif
-
#define DBG_TAG "dlib.syscall_write"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
diff --git a/components/libc/compilers/gcc/newlib/syscalls.c b/components/libc/compilers/gcc/newlib/syscalls.c
index 8bb9af940d..8fe8c5be4b 100644
--- a/components/libc/compilers/gcc/newlib/syscalls.c
+++ b/components/libc/compilers/gcc/newlib/syscalls.c
@@ -20,12 +20,12 @@
#include <unistd.h>
#include <sys/errno.h>
#include <sys/stat.h>
-#ifdef RT_USING_POSIX_STDIO
+#ifdef RT_USING_POSIX_DEVIO
#include "libc.h"
-#endif
+#endif /* RT_USING_POSIX_DEVIO */
#ifdef RT_USING_MODULE
#include <dlmodule.h>
-#endif
+#endif /* RT_USING_MODULE */
#define DBG_TAG "newlib.syscalls"
#define DBG_LVL DBG_INFO
@@ -225,7 +225,7 @@ _ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes)
_ssize_t rc;
if (fd == STDIN_FILENO)
{
-#ifdef RT_USING_POSIX_STDIO
+#ifdef RT_USING_POSIX_DEVIO
if (libc_stdio_get_console() < 0)
{
LOG_W("Do not invoke standard input before initializing libc");
@@ -234,7 +234,7 @@ _ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes)
#else
ptr->_errno = ENOTSUP;
return -1;
-#endif /* RT_USING_POSIX_STDIO */
+#endif /* RT_USING_POSIX_DEVIO */
}
else if (fd == STDOUT_FILENO || fd == STDERR_FILENO)
{
diff --git a/components/libc/posix/src/SConscript b/components/libc/posix/src/SConscript
index 78a2a933ed..067d598b74 100644
--- a/components/libc/posix/src/SConscript
+++ b/components/libc/posix/src/SConscript
@@ -6,7 +6,7 @@ src = ['unistd.c']
cwd = GetCurrentDir()
CPPPATH = [cwd]
-if GetDepend('RT_USING_POSIX_STDIO'):
+if GetDepend('RT_USING_POSIX_DEVIO'):
src += ['libc.c']
if GetDepend('RT_USING_POSIX_DELAY'):