diff options
| author | Meco Man <[email protected]> | 2021-10-26 00:51:32 -0400 |
|---|---|---|
| committer | Meco Man <[email protected]> | 2021-10-26 23:09:54 -0400 |
| commit | a9910a780edc43df6b64bcd13c37785a15ec3428 (patch) | |
| tree | 0402e433f252c5ded3472deb266616ee7a47e90f /components/libc/compilers/dlib/syscall_write.c | |
| parent | 50bb6e33d13237f71812e81a6a13ba5ba0693c8f (diff) | |
[posix][libc] 优化libc中posix结构
Diffstat (limited to 'components/libc/compilers/dlib/syscall_write.c')
| -rw-r--r-- | components/libc/compilers/dlib/syscall_write.c | 30 |
1 files changed, 12 insertions, 18 deletions
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 <rtthread.h> -#ifdef RT_USING_DFS -#include <dfs_posix.h> -#endif #include <yfuns.h> +#include <unistd.h> #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 */ } - |
