From a9910a780edc43df6b64bcd13c37785a15ec3428 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 26 Oct 2021 00:51:32 -0400 Subject: [posix][libc] 优化libc中posix结构 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/compilers/dlib/syscall_write.c | 30 +++++++++++--------------- 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'components/libc/compilers/dlib/syscall_write.c') diff --git a/components/libc/compilers/dlib/syscall_write.c b/components/libc/compilers/dlib/syscall_write.c index ffee51882d..af47d64a3e 100644 --- a/components/libc/compilers/dlib/syscall_write.c +++ b/components/libc/compilers/dlib/syscall_write.c @@ -9,10 +9,8 @@ */ #include -#ifdef RT_USING_DFS -#include -#endif #include +#include #include "libc.h" #define DBG_TAG "dlib.syscall_write" @@ -23,24 +21,20 @@ size_t __write(int handle, const unsigned char *buf, size_t len) { -#ifdef RT_USING_DFS +#ifdef RT_LIBC_USING_FILEIO int size; -#endif +#endif /* RT_LIBC_USING_FILEIO */ if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR)) { -#ifndef RT_USING_CONSOLE - return _LLIO_ERROR; -#else - -#ifdef RT_USING_POSIX +#ifdef RT_LIBC_USING_FILEIO if (libc_stdio_get_console() < 0) { LOG_W("Do not invoke standard output before initializing libc"); return 0; } return write(STDOUT_FILENO, (void*)buf, len); -#else +#elif defined(RT_USING_CONSOLE) rt_device_t console_device; console_device = rt_console_get_device(); @@ -50,19 +44,19 @@ size_t __write(int handle, const unsigned char *buf, size_t len) } return len; -#endif -#endif +#else + return _LLIO_ERROR; +#endif /* RT_LIBC_USING_FILEIO */ } else if (handle == _LLIO_STDIN) { return _LLIO_ERROR; } -#ifndef RT_USING_DFS - return _LLIO_ERROR; -#else +#ifdef RT_LIBC_USING_FILEIO size = write(handle, buf, len); return size; -#endif +#else + return _LLIO_ERROR; +#endif /* RT_LIBC_USING_FILEIO */ } - -- cgit v1.3.1