diff options
| author | Meco Man <[email protected]> | 2021-09-27 06:51:40 -0400 |
|---|---|---|
| committer | Meco Man <[email protected]> | 2021-09-27 06:51:40 -0400 |
| commit | 86bb54fde6f3ed59050d724a7e98defd7c4f47a9 (patch) | |
| tree | 60a05ee95a35859cc1fd55c5cff2b083d686445c /components/libc/compilers/dlib/syscall_write.c | |
| parent | c8c632512aa6c87211871fe0a85e77b72d4ebe06 (diff) | |
[libc][syscalls] 在标准输入输出前加校验,反正在libc初始化之前调用printf出问题
Diffstat (limited to 'components/libc/compilers/dlib/syscall_write.c')
| -rw-r--r-- | components/libc/compilers/dlib/syscall_write.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/components/libc/compilers/dlib/syscall_write.c b/components/libc/compilers/dlib/syscall_write.c index a5462653bf..bd7cc83d99 100644 --- a/components/libc/compilers/dlib/syscall_write.c +++ b/components/libc/compilers/dlib/syscall_write.c @@ -15,6 +15,10 @@ #include <yfuns.h> #include "libc.h" +#define DBG_TAG "dlib.syscall_write" +#define DBG_LVL DBG_INFO +#include <rtdbg.h> + #pragma module_name = "?__write" size_t __write(int handle, const unsigned char *buf, size_t len) @@ -30,6 +34,11 @@ size_t __write(int handle, const unsigned char *buf, size_t len) #else #ifdef RT_USING_POSIX + if (libc_stdio_get_console() < 0) + { + LOG_E("invoke standard output before initializing libc"); + return _LLIO_ERROR; + } return write(STDOUT_FILENO, (void*)buf, len); #else rt_device_t console_device; |
