diff options
| author | Meco Man <[email protected]> | 2022-01-02 17:51:44 -0500 |
|---|---|---|
| committer | Bernard Xiong <[email protected]> | 2022-01-05 23:11:58 +0800 |
| commit | 918ee6147c6a415cfd4544ea439a8ab894e2e1ee (patch) | |
| tree | 08ac5cff632ff7ea1c70902305991b7122d05edf /components/libc | |
| parent | 0e5dd7d1ab49edc0961c2520544836d464ba21b0 (diff) | |
add RT_USING_POSIX_STDIO
Diffstat (limited to 'components/libc')
| -rw-r--r-- | components/libc/compilers/armlibc/syscalls.c | 16 | ||||
| -rw-r--r-- | components/libc/compilers/common/compiler_private.h | 2 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/syscall_read.c | 10 | ||||
| -rw-r--r-- | components/libc/compilers/gcc/newlib/syscalls.c | 10 | ||||
| -rw-r--r-- | components/libc/posix/Kconfig | 7 | ||||
| -rw-r--r-- | components/libc/posix/io/SConscript | 2 | ||||
| -rw-r--r-- | components/libc/posix/io/libc.c | 8 | ||||
| -rw-r--r-- | components/libc/posix/io/libc.h | 4 |
8 files changed, 32 insertions, 27 deletions
diff --git a/components/libc/compilers/armlibc/syscalls.c b/components/libc/compilers/armlibc/syscalls.c index 14b47d3627..2dd90cb27c 100644 --- a/components/libc/compilers/armlibc/syscalls.c +++ b/components/libc/compilers/armlibc/syscalls.c @@ -22,9 +22,9 @@ #include <unistd.h> #include <sys/stat.h> #include <compiler_private.h> -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO #include "libc.h" -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ #define DBG_TAG "armlibc.syscalls" #define DBG_LVL DBG_INFO @@ -152,7 +152,7 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode) if (fh == STDIN) { -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO if (libc_stdio_get_console() < 0) { LOG_W("Do not invoke standard output before initializing Compiler"); @@ -161,9 +161,9 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode) size = read(STDIN_FILENO, buf, len); return len - size; /* success */ #else - LOG_W("%s: %s", __func__, _WARNING_WITHOUT_DEVIO); + LOG_W("%s: %s", __func__, _WARNING_WITHOUT_STDIO); return 0; /* error */ -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ } else if (fh == STDOUT || fh == STDERR) { @@ -349,7 +349,7 @@ int fputc(int c, FILE *f) int fgetc(FILE *f) { -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO char ch; if (libc_stdio_get_console() < 0) @@ -360,8 +360,8 @@ int fgetc(FILE *f) if(read(STDIN_FILENO, &ch, 1) == 1) return ch; -#endif /* RT_USING_POSIX_DEVIO */ - LOG_W("%s: %s", __func__, _WARNING_WITHOUT_DEVIO); +#endif /* RT_USING_POSIX_STDIO */ + LOG_W("%s: %s", __func__, _WARNING_WITHOUT_STDIO); return 0; /* error */ } diff --git a/components/libc/compilers/common/compiler_private.h b/components/libc/compilers/common/compiler_private.h index ed29b8c333..2fd9c51f65 100644 --- a/components/libc/compilers/common/compiler_private.h +++ b/components/libc/compilers/common/compiler_private.h @@ -13,6 +13,6 @@ #include <rtconfig.h> #define _WARNING_WITHOUT_FS "Please enable RT_USING_POSIX_FS" -#define _WARNING_WITHOUT_DEVIO "Please enable RT_USING_POSIX_FS and RT_USING_POSIX_DEVIO" +#define _WARNING_WITHOUT_STDIO "Please enable RT_USING_POSIX_FS and RT_USING_POSIX_STDIO" #endif /* __COMPILER_PRIVATE_H__ */ diff --git a/components/libc/compilers/dlib/syscall_read.c b/components/libc/compilers/dlib/syscall_read.c index db523cc0a6..a276a3e401 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_DEVIO +#ifdef RT_USING_POSIX_STDIO #include "libc.h" -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ #include <compiler_private.h> #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_DEVIO +#ifdef RT_USING_POSIX_STDIO if (libc_stdio_get_console() < 0) { LOG_W("Do not invoke standard input before initializing Compiler"); @@ -47,9 +47,9 @@ 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 - LOG_W(_WARNING_WITHOUT_DEVIO); + LOG_W(_WARNING_WITHOUT_STDIO); return _LLIO_ERROR; -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ } else if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR)) { diff --git a/components/libc/compilers/gcc/newlib/syscalls.c b/components/libc/compilers/gcc/newlib/syscalls.c index da0e4dc16f..d8a8ba6945 100644 --- a/components/libc/compilers/gcc/newlib/syscalls.c +++ b/components/libc/compilers/gcc/newlib/syscalls.c @@ -20,9 +20,9 @@ #include <unistd.h> #include <sys/errno.h> #include <sys/stat.h> -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO #include "libc.h" -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ #ifdef RT_USING_MODULE #include <dlmodule.h> #endif /* RT_USING_MODULE */ @@ -225,17 +225,17 @@ _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_DEVIO +#ifdef RT_USING_POSIX_STDIO if (libc_stdio_get_console() < 0) { LOG_W("Do not invoke standard input before initializing Compiler"); return 0; } #else - LOG_W("%s: %s", __func__, _WARNING_WITHOUT_DEVIO); + LOG_W("%s: %s", __func__, _WARNING_WITHOUT_STDIO); ptr->_errno = ENOTSUP; return -1; -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ } else if (fd == STDOUT_FILENO || fd == STDERR_FILENO) { diff --git a/components/libc/posix/Kconfig b/components/libc/posix/Kconfig index f7f2855ec9..76dabc2734 100644 --- a/components/libc/posix/Kconfig +++ b/components/libc/posix/Kconfig @@ -12,6 +12,11 @@ if RT_USING_POSIX_FS select RT_USING_DFS_DEVFS default n + config RT_USING_POSIX_STDIO + bool "Enable standard I/O devices, e.g. STDOUT_FILENO" + select RT_USING_POSIX_DEVIO + default n + config RT_USING_POSIX_POLL bool "Enable I/O Multiplexing poll() <poll.h>" default n @@ -23,7 +28,7 @@ if RT_USING_POSIX_FS config RT_USING_POSIX_TERMIOS bool "Enable Terminal I/O <termios.h>" - select RT_USING_POSIX_DEVIO + select RT_USING_POSIX_STDIO default n config RT_USING_POSIX_AIO diff --git a/components/libc/posix/io/SConscript b/components/libc/posix/io/SConscript index 0771ec67be..bb45211ec0 100644 --- a/components/libc/posix/io/SConscript +++ b/components/libc/posix/io/SConscript @@ -10,7 +10,7 @@ group = [] flag = False -if GetDepend('RT_USING_POSIX_DEVIO'): +if GetDepend('RT_USING_POSIX_STDIO'): src += ['libc.c'] flag = True diff --git a/components/libc/posix/io/libc.c b/components/libc/posix/io/libc.c index 4bb647c16b..d8780b1b31 100644 --- a/components/libc/posix/io/libc.c +++ b/components/libc/posix/io/libc.c @@ -20,7 +20,7 @@ int libc_system_init(void) { -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO rt_device_t dev_console; dev_console = rt_console_get_device(); @@ -28,12 +28,12 @@ int libc_system_init(void) { libc_stdio_set_console(dev_console->parent.name, O_RDWR); } -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ return 0; } INIT_COMPONENT_EXPORT(libc_system_init); -#if defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_NEWLIB) +#if defined(RT_USING_POSIX_STDIO) && defined(RT_USING_NEWLIB) #define STDIO_DEVICE_NAME_MAX 32 static FILE* std_console = NULL; int libc_stdio_set_console(const char* device_name, int mode) @@ -134,4 +134,4 @@ int libc_stdio_set_console(const char* device_name, int mode) int libc_stdio_get_console(void) { return std_fd; } -#endif /* defined(RT_USING_POSIX_DEVIO) && defined(RT_USING_NEWLIB) */ +#endif /* defined(RT_USING_POSIX_STDIO) && defined(RT_USING_NEWLIB) */ diff --git a/components/libc/posix/io/libc.h b/components/libc/posix/io/libc.h index b019267926..983a927dc3 100644 --- a/components/libc/posix/io/libc.h +++ b/components/libc/posix/io/libc.h @@ -17,10 +17,10 @@ extern "C" { #endif int libc_system_init(void); -#ifdef RT_USING_POSIX_DEVIO +#ifdef RT_USING_POSIX_STDIO int libc_stdio_get_console(void); int libc_stdio_set_console(const char* device_name, int mode); -#endif /* RT_USING_POSIX_DEVIO */ +#endif /* RT_USING_POSIX_STDIO */ #ifdef __cplusplus } |
