summaryrefslogtreecommitdiff
path: root/components/libc/compilers/dlib
diff options
context:
space:
mode:
Diffstat (limited to 'components/libc/compilers/dlib')
-rw-r--r--components/libc/compilers/dlib/syscall_read.c9
-rw-r--r--components/libc/compilers/dlib/syscall_write.c9
2 files changed, 18 insertions, 0 deletions
diff --git a/components/libc/compilers/dlib/syscall_read.c b/components/libc/compilers/dlib/syscall_read.c
index e716d0b024..bdc694b7d8 100644
--- a/components/libc/compilers/dlib/syscall_read.c
+++ b/components/libc/compilers/dlib/syscall_read.c
@@ -15,6 +15,10 @@
#include <yfuns.h>
#include "libc.h"
+#define DBG_TAG "dlib.syscall_read"
+#define DBG_LVL DBG_INFO
+#include <rtdbg.h>
+
#pragma module_name = "?__read"
size_t __read(int handle, unsigned char *buf, size_t len)
{
@@ -25,6 +29,11 @@ size_t __read(int handle, unsigned char *buf, size_t len)
if (handle == _LLIO_STDIN)
{
#ifdef RT_USING_POSIX
+ if (libc_stdio_get_console() < 0)
+ {
+ LOG_E("invoke standard input before initializing libc");
+ return _LLIO_ERROR;
+ }
return read(STDIN_FILENO, buf, len);
#else
return _LLIO_ERROR;
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;