diff options
| author | guo <[email protected]> | 2021-11-29 10:51:43 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-11-29 10:51:43 +0800 |
| commit | 4e9744c0acd093efd6fb1da1216d918521d14015 (patch) | |
| tree | 084b7a54eebb1ad0574111a429d24b51bc9f6271 /components/libc | |
| parent | 3bc5ffb495a34ee6235e493375770ef2bb4457d3 (diff) | |
| parent | 7c789d4b11c13e45ab1d2a858c68dabb022eb07c (diff) | |
Merge pull request #5302 from mysterywolf/posix
[PSE分支] 新增 RT_USING_POSIX_DEVIO
Diffstat (limited to 'components/libc')
| -rw-r--r-- | components/libc/Kconfig | 6 | ||||
| -rw-r--r-- | components/libc/compilers/armlibc/syscalls.c | 12 | ||||
| -rw-r--r-- | components/libc/compilers/common/sys/ioctl.h | 2 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/syscall_read.c | 8 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/syscall_write.c | 4 | ||||
| -rw-r--r-- | components/libc/compilers/gcc/newlib/syscalls.c | 10 | ||||
| -rw-r--r-- | components/libc/posix/aio/SConscript | 2 | ||||
| -rw-r--r-- | components/libc/posix/src/SConscript | 2 | ||||
| -rw-r--r-- | components/libc/posix/src/libc.c | 9 | ||||
| -rw-r--r-- | components/libc/posix/src/libc.h | 4 | ||||
| -rw-r--r-- | components/libc/posix/termios/SConscript | 4 |
11 files changed, 27 insertions, 36 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/common/sys/ioctl.h b/components/libc/compilers/common/sys/ioctl.h index 04f73837bc..29ed3a8b84 100644 --- a/components/libc/compilers/common/sys/ioctl.h +++ b/components/libc/compilers/common/sys/ioctl.h @@ -11,9 +11,7 @@ #define _SYS_IOCTL_H #include <rtconfig.h> -#ifdef RT_USING_POSIX #include <dfs_posix.h> -#endif #ifdef _WIN32 #include <winsock.h> 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/aio/SConscript b/components/libc/posix/aio/SConscript index 445efaade5..139bc45749 100644 --- a/components/libc/posix/aio/SConscript +++ b/components/libc/posix/aio/SConscript @@ -6,6 +6,6 @@ cwd = GetCurrentDir() src = Glob('*.c') CPPPATH = [cwd] -group = DefineGroup('POSIX', src, depend = ['RT_USING_POSIX', 'RT_USING_POSIX_AIO'], CPPPATH = CPPPATH) +group = DefineGroup('POSIX', src, depend = ['RT_USING_POSIX_AIO'], CPPPATH = CPPPATH) Return('group') 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'): diff --git a/components/libc/posix/src/libc.c b/components/libc/posix/src/libc.c index 068719d5d6..c324d84ef8 100644 --- a/components/libc/posix/src/libc.c +++ b/components/libc/posix/src/libc.c @@ -23,7 +23,7 @@ int libc_system_init(void) { -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_DEVIO rt_device_t dev_console; dev_console = rt_console_get_device(); @@ -31,7 +31,7 @@ int libc_system_init(void) { libc_stdio_set_console(dev_console->parent.name, O_RDWR); } -#endif /* RT_USING_POSIX */ +#endif /* RT_USING_POSIX_DEVIO */ #if defined RT_USING_PTHREADS && !defined RT_USING_COMPONENTS_INIT pthread_system_init(); @@ -41,8 +41,7 @@ int libc_system_init(void) } INIT_COMPONENT_EXPORT(libc_system_init); -#ifdef RT_USING_POSIX - +#ifdef RT_USING_POSIX_DEVIO #if defined(RT_USING_LIBC) && defined(RT_USING_NEWLIB) #define STDIO_DEVICE_NAME_MAX 32 static FILE* std_console = NULL; @@ -145,4 +144,4 @@ int libc_stdio_get_console(void) { return std_fd; } #endif /* defined(RT_USING_LIBC) && defined(RT_USING_NEWLIB) */ -#endif /* RT_USING_POSIX */ +#endif /* RT_USING_POSIX_DEVIO */ diff --git a/components/libc/posix/src/libc.h b/components/libc/posix/src/libc.h index f81380bf78..b019267926 100644 --- a/components/libc/posix/src/libc.h +++ b/components/libc/posix/src/libc.h @@ -17,10 +17,10 @@ extern "C" { #endif int libc_system_init(void); -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_DEVIO int libc_stdio_get_console(void); int libc_stdio_set_console(const char* device_name, int mode); -#endif /* RT_USING_POSIX */ +#endif /* RT_USING_POSIX_DEVIO */ #ifdef __cplusplus } diff --git a/components/libc/posix/termios/SConscript b/components/libc/posix/termios/SConscript index bd9a528461..3615926251 100644 --- a/components/libc/posix/termios/SConscript +++ b/components/libc/posix/termios/SConscript @@ -6,8 +6,6 @@ cwd = GetCurrentDir() src = Glob('*.c') + Glob('*.cpp') CPPPATH = [cwd] -group = DefineGroup('POSIX', src, - depend = ['RT_USING_LIBC', 'RT_USING_POSIX', 'RT_USING_POSIX_TERMIOS'], - CPPPATH = CPPPATH) +group = DefineGroup('POSIX', src, depend = ['RT_USING_LIBC', 'RT_USING_POSIX_TERMIOS'], CPPPATH = CPPPATH) Return('group') |
