summaryrefslogtreecommitdiff
path: root/components/libc/compilers
diff options
context:
space:
mode:
Diffstat (limited to 'components/libc/compilers')
-rw-r--r--components/libc/compilers/armlibc/libc_syms.c1
-rw-r--r--components/libc/compilers/armlibc/syscalls.c30
-rw-r--r--components/libc/compilers/common/compiler_private.h5
-rw-r--r--components/libc/compilers/common/dirent.h1
-rw-r--r--components/libc/compilers/common/nogcc/fcntl.h1
-rw-r--r--components/libc/compilers/common/nogcc/sys/errno.h1
-rw-r--r--components/libc/compilers/common/nogcc/sys/types.h1
-rw-r--r--components/libc/compilers/common/nogcc/sys/unistd.h1
-rw-r--r--components/libc/compilers/common/nogcc/unistd.h1
-rw-r--r--components/libc/compilers/common/sys/ioctl.h1
-rw-r--r--components/libc/compilers/common/sys/statfs.h1
-rw-r--r--components/libc/compilers/common/sys/time.h24
-rw-r--r--components/libc/compilers/common/sys/vfs.h1
-rw-r--r--components/libc/compilers/common/time.c49
-rw-r--r--components/libc/compilers/dlib/syscall_close.c1
-rw-r--r--components/libc/compilers/dlib/syscall_lseek.c1
-rw-r--r--components/libc/compilers/dlib/syscall_mem.c1
-rw-r--r--components/libc/compilers/dlib/syscall_read.c10
-rw-r--r--components/libc/compilers/dlib/syscall_remove.c1
-rw-r--r--components/libc/compilers/dlib/syscall_write.c4
-rw-r--r--components/libc/compilers/dlib/syscalls.c1
-rw-r--r--components/libc/compilers/gcc/newlib/fcntl.h1
-rw-r--r--components/libc/compilers/gcc/newlib/libc_syms.c1
-rw-r--r--components/libc/compilers/gcc/newlib/machine/time.h10
-rw-r--r--components/libc/compilers/gcc/newlib/syscalls.c14
25 files changed, 87 insertions, 76 deletions
diff --git a/components/libc/compilers/armlibc/libc_syms.c b/components/libc/compilers/armlibc/libc_syms.c
index 829d57b559..2b370a25a6 100644
--- a/components/libc/compilers/armlibc/libc_syms.c
+++ b/components/libc/compilers/armlibc/libc_syms.c
@@ -6,6 +6,7 @@
* Change Logs:
* Date Author Notes
*/
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/components/libc/compilers/armlibc/syscalls.c b/components/libc/compilers/armlibc/syscalls.c
index 14b47d3627..82c0f38b4f 100644
--- a/components/libc/compilers/armlibc/syscalls.c
+++ b/components/libc/compilers/armlibc/syscalls.c
@@ -22,9 +22,9 @@
#include <unistd.h>
#include <sys/stat.h>
#include <compiler_private.h>
-#ifdef RT_USING_POSIX_DEVIO
+#ifdef RT_USING_POSIX_STDIO
#include "libc.h"
-#endif /* RT_USING_POSIX_DEVIO */
+#endif /* RT_USING_POSIX_STDIO */
#define DBG_TAG "armlibc.syscalls"
#define DBG_LVL DBG_INFO
@@ -152,7 +152,7 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
if (fh == STDIN)
{
-#ifdef RT_USING_POSIX_DEVIO
+#ifdef RT_USING_POSIX_STDIO
if (libc_stdio_get_console() < 0)
{
LOG_W("Do not invoke standard output before initializing Compiler");
@@ -161,9 +161,9 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
size = read(STDIN_FILENO, buf, len);
return len - size; /* success */
#else
- LOG_W("%s: %s", __func__, _WARNING_WITHOUT_DEVIO);
+ LOG_W("%s: %s", __func__, _WARNING_WITHOUT_STDIO);
return 0; /* error */
-#endif /* RT_USING_POSIX_DEVIO */
+#endif /* RT_USING_POSIX_STDIO */
}
else if (fh == STDOUT || fh == STDERR)
{
@@ -204,7 +204,7 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
if (fh == STDOUT || fh == STDERR)
{
-#ifdef RT_USING_CONSOLE
+#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
rt_device_t console;
console = rt_console_get_device();
if (console)
@@ -214,7 +214,7 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
return 0; /* success */
#else
return 0; /* error */
-#endif /* RT_USING_CONSOLE */
+#endif /* defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) */
}
else if (fh == STDIN)
{
@@ -276,10 +276,7 @@ char *_sys_command_string(char *cmd, int len)
void _ttywrch(int ch)
{
#ifdef RT_USING_CONSOLE
- char c;
-
- c = (char)ch;
- rt_kprintf(&c);
+ rt_kprintf("%c", (char)ch);
#endif /* RT_USING_CONSOLE */
}
@@ -337,10 +334,7 @@ int remove(const char *filename)
int fputc(int c, FILE *f)
{
#ifdef RT_USING_CONSOLE
- char ch[2] = {0};
-
- ch[0] = c;
- rt_kprintf(&ch[0]);
+ rt_kprintf("%c", (char)c);
return 1;
#else
return 0; /* error */
@@ -349,7 +343,7 @@ int fputc(int c, FILE *f)
int fgetc(FILE *f)
{
-#ifdef RT_USING_POSIX_DEVIO
+#ifdef RT_USING_POSIX_STDIO
char ch;
if (libc_stdio_get_console() < 0)
@@ -360,8 +354,8 @@ int fgetc(FILE *f)
if(read(STDIN_FILENO, &ch, 1) == 1)
return ch;
-#endif /* RT_USING_POSIX_DEVIO */
- LOG_W("%s: %s", __func__, _WARNING_WITHOUT_DEVIO);
+#endif /* RT_USING_POSIX_STDIO */
+ LOG_W("%s: %s", __func__, _WARNING_WITHOUT_STDIO);
return 0; /* error */
}
diff --git a/components/libc/compilers/common/compiler_private.h b/components/libc/compilers/common/compiler_private.h
index ed29b8c333..7f6b42e837 100644
--- a/components/libc/compilers/common/compiler_private.h
+++ b/components/libc/compilers/common/compiler_private.h
@@ -7,12 +7,11 @@
* Date Author Notes
* 2021-12-26 Meco Man First Version
*/
+
#ifndef __COMPILER_PRIVATE_H__
#define __COMPILER_PRIVATE_H__
-#include <rtconfig.h>
-
#define _WARNING_WITHOUT_FS "Please enable RT_USING_POSIX_FS"
-#define _WARNING_WITHOUT_DEVIO "Please enable RT_USING_POSIX_FS and RT_USING_POSIX_DEVIO"
+#define _WARNING_WITHOUT_STDIO "Please enable RT_USING_POSIX_FS and RT_USING_POSIX_STDIO"
#endif /* __COMPILER_PRIVATE_H__ */
diff --git a/components/libc/compilers/common/dirent.h b/components/libc/compilers/common/dirent.h
index a6353fd6f8..a9c7ef856d 100644
--- a/components/libc/compilers/common/dirent.h
+++ b/components/libc/compilers/common/dirent.h
@@ -6,6 +6,7 @@
* Change Logs:
* Date Author Notes
*/
+
#ifndef __DIRENT_H__
#define __DIRENT_H__
diff --git a/components/libc/compilers/common/nogcc/fcntl.h b/components/libc/compilers/common/nogcc/fcntl.h
index 51ee1024a8..83c3ec0b6b 100644
--- a/components/libc/compilers/common/nogcc/fcntl.h
+++ b/components/libc/compilers/common/nogcc/fcntl.h
@@ -7,6 +7,7 @@
* Date Author Notes
* 2021-09-02 Meco Man First version
*/
+
#ifndef __FCNTL_H__
#define __FCNTL_H__
diff --git a/components/libc/compilers/common/nogcc/sys/errno.h b/components/libc/compilers/common/nogcc/sys/errno.h
index 1c6cd6d18d..d53ce4b386 100644
--- a/components/libc/compilers/common/nogcc/sys/errno.h
+++ b/components/libc/compilers/common/nogcc/sys/errno.h
@@ -7,6 +7,7 @@
* Date Author Notes
* 2021-05-22 Meco Man The first version.
*/
+
#ifndef __SYS_ERRNO_H__
#define __SYS_ERRNO_H__
diff --git a/components/libc/compilers/common/nogcc/sys/types.h b/components/libc/compilers/common/nogcc/sys/types.h
index 5672f54a4d..32b2493c95 100644
--- a/components/libc/compilers/common/nogcc/sys/types.h
+++ b/components/libc/compilers/common/nogcc/sys/types.h
@@ -8,6 +8,7 @@
* 2020-09-05 Meco Man fix bugs
* 2020-12-16 Meco Man add useconds_t
*/
+
#ifndef __SYS_TYPES_H__
#define __SYS_TYPES_H__
diff --git a/components/libc/compilers/common/nogcc/sys/unistd.h b/components/libc/compilers/common/nogcc/sys/unistd.h
index 6195c4c2aa..650c87dc18 100644
--- a/components/libc/compilers/common/nogcc/sys/unistd.h
+++ b/components/libc/compilers/common/nogcc/sys/unistd.h
@@ -8,6 +8,7 @@
* 2020-12-16 Meco Man add usleep
* 2021-09-11 Meco Man move functions from dfs_posix.h to unistd.h
*/
+
#ifndef __SYS_UNISTD_H__
#define __SYS_UNISTD_H__
diff --git a/components/libc/compilers/common/nogcc/unistd.h b/components/libc/compilers/common/nogcc/unistd.h
index 9b96d45adb..4dd71c842e 100644
--- a/components/libc/compilers/common/nogcc/unistd.h
+++ b/components/libc/compilers/common/nogcc/unistd.h
@@ -6,4 +6,5 @@
* Change Logs:
* Date Author Notes
*/
+
#include "sys/unistd.h"
diff --git a/components/libc/compilers/common/sys/ioctl.h b/components/libc/compilers/common/sys/ioctl.h
index a1642199b1..d93c79115a 100644
--- a/components/libc/compilers/common/sys/ioctl.h
+++ b/components/libc/compilers/common/sys/ioctl.h
@@ -7,6 +7,7 @@
* Date Author Notes
* 2020-09-01 Meco Man First Version
*/
+
#ifndef __SYS_IOCTL_H__
#define __SYS_IOCTL_H__
diff --git a/components/libc/compilers/common/sys/statfs.h b/components/libc/compilers/common/sys/statfs.h
index 0c6dc44df3..a86a789475 100644
--- a/components/libc/compilers/common/sys/statfs.h
+++ b/components/libc/compilers/common/sys/statfs.h
@@ -6,6 +6,7 @@
* Change Logs:
* Date Author Notes
*/
+
#ifndef __SYS_STATFS_H__
#define __SYS_STATFS_H__
diff --git a/components/libc/compilers/common/sys/time.h b/components/libc/compilers/common/sys/time.h
index 55c60d716e..758333796d 100644
--- a/components/libc/compilers/common/sys/time.h
+++ b/components/libc/compilers/common/sys/time.h
@@ -8,6 +8,7 @@
* 2020-09-07 Meco Man combine gcc armcc iccarm
* 2021-02-12 Meco Man move all definitions located in <clock_time.h> to this file
*/
+
#ifndef __SYS_TIME_H__
#define __SYS_TIME_H__
@@ -42,20 +43,14 @@ struct timezone
int tz_dsttime; /* type of dst correction */
};
-/*
- * Structure returned by gettimeofday(2) system call,
- * and used in other calls.
- */
-#ifndef _TIMEVAL_DEFINED
+#if !defined(_TIMEVAL_DEFINED) && !defined(_WIN32)
#define _TIMEVAL_DEFINED
-#if !defined(_WIN32)
struct timeval
{
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* and microseconds */
};
#endif
-#endif /* _TIMEVAL_DEFINED */
#if !(defined(__GNUC__) && !defined(__ARMCC_VERSION)/*GCC*/) && \
!(defined(__ICCARM__) && (__VER__ >= 8010001)) && \
@@ -73,8 +68,22 @@ int gettimeofday(struct timeval *tv, struct timezone *tz);
int settimeofday(const struct timeval *tv, const struct timezone *tz);
#if defined(__ARMCC_VERSION) || defined (__ICCARM__)
struct tm *gmtime_r(const time_t *timep, struct tm *r);
+#elif defined(_WIN32)
+struct tm* gmtime_r(const time_t* timep, struct tm* r);
+struct tm* gmtime(const time_t* t);
+struct tm* localtime_r(const time_t* t, struct tm* r);
+struct tm* localtime(const time_t* t);
+time_t mktime(struct tm* const t);
+char* asctime_r(const struct tm* t, char* buf);
+char* ctime_r(const time_t* tim_p, char* result);
+char* ctime(const time_t* tim_p);
+time_t time(time_t* t);
#endif
+#ifdef RT_USING_POSIX_DELAY
+int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
+#endif /* RT_USING_POSIX_DELAY */
+
#ifdef RT_USING_POSIX_CLOCK
/* POSIX clock and timer */
#define MILLISECOND_PER_SECOND 1000UL
@@ -106,7 +115,6 @@ int clock_getres (clockid_t clockid, struct timespec *res);
int clock_gettime (clockid_t clockid, struct timespec *tp);
int clock_settime (clockid_t clockid, const struct timespec *tp);
int clock_nanosleep(clockid_t clockid, int flags, const struct timespec *rqtp, struct timespec *rmtp);
-int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
int rt_timespec_to_tick(const struct timespec *time);
#endif /* RT_USING_POSIX_CLOCK */
diff --git a/components/libc/compilers/common/sys/vfs.h b/components/libc/compilers/common/sys/vfs.h
index 00739ab1c6..a9330df002 100644
--- a/components/libc/compilers/common/sys/vfs.h
+++ b/components/libc/compilers/common/sys/vfs.h
@@ -7,6 +7,7 @@
* Date Author Notes
* 2021-09-11 Meco Man First version
*/
+
#ifndef __SYS_VFS_H__
#define __SYS_VFS_H__
diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c
index 8890a3e830..46bb0c1355 100644
--- a/components/libc/compilers/common/time.c
+++ b/components/libc/compilers/common/time.c
@@ -56,8 +56,8 @@ static const short __spm[13] =
(31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31),
};
-ALIGN(4) static const char days[] = "Sun Mon Tue Wed Thu Fri Sat ";
-ALIGN(4) static const char months[] = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ";
+ALIGN(4) static const char *days = "Sun Mon Tue Wed Thu Fri Sat ";
+ALIGN(4) static const char *months = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ";
static int __isleap(int year)
{
@@ -217,7 +217,7 @@ struct tm* localtime_r(const time_t* t, struct tm* r)
{
time_t local_tz;
- local_tz = *t + tz_get() * 3600;
+ local_tz = *t + (time_t)tz_get() * 3600;
return gmtime_r(&local_tz, r);
}
RTM_EXPORT(localtime_r);
@@ -234,7 +234,7 @@ time_t mktime(struct tm * const t)
time_t timestamp;
timestamp = timegm(t);
- timestamp = timestamp - 3600 * tz_get();
+ timestamp = timestamp - 3600 * (time_t)tz_get();
return timestamp;
}
RTM_EXPORT(mktime);
@@ -367,7 +367,7 @@ time_t timegm(struct tm * const t)
{
register time_t day;
register time_t i;
- register time_t years = t->tm_year - 70;
+ register time_t years = (time_t)t->tm_year - 70;
if (t->tm_sec > 60)
{
@@ -488,8 +488,18 @@ RTM_EXPORT(settimeofday);
RTM_EXPORT(difftime);
RTM_EXPORT(strftime);
-#ifdef RT_USING_POSIX_CLOCK
+#ifdef RT_USING_POSIX_DELAY
#include <delay.h>
+int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
+{
+ sleep(rqtp->tv_sec);
+ ndelay(rqtp->tv_nsec);
+ return 0;
+}
+RTM_EXPORT(nanosleep);
+#endif /* RT_USING_POSIX_DELAY */
+
+#ifdef RT_USING_POSIX_CLOCK
#ifdef RT_USING_RTC
static volatile struct timeval _timevalue;
static int _rt_clock_time_system_init()
@@ -670,33 +680,6 @@ int clock_settime(clockid_t clockid, const struct timespec *tp)
}
RTM_EXPORT(clock_settime);
-int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
-{
- uint32_t time_ms = rqtp->tv_sec * 1000;
- uint32_t time_us = rqtp->tv_nsec / 1000;
-
- time_ms += time_us / 1000 ;
- time_us = time_us % 1000;
-
- if (rt_thread_self() != RT_NULL)
- {
- rt_thread_mdelay(time_ms);
- }
- else /* scheduler has not run yet */
- {
- while(time_ms > 0)
- {
- udelay(1000u);
- time_ms -= 1;
- }
- }
-
- udelay(time_us);
-
- return 0;
-}
-RTM_EXPORT(nanosleep);
-
int rt_timespec_to_tick(const struct timespec *time)
{
int tick;
diff --git a/components/libc/compilers/dlib/syscall_close.c b/components/libc/compilers/dlib/syscall_close.c
index 294c81f6c0..736023023d 100644
--- a/components/libc/compilers/dlib/syscall_close.c
+++ b/components/libc/compilers/dlib/syscall_close.c
@@ -7,6 +7,7 @@
* Date Author Notes
* 2015-01-28 Bernard first version
*/
+
#include <rtthread.h>
#include <LowLevelIOInterface.h>
#include <unistd.h>
diff --git a/components/libc/compilers/dlib/syscall_lseek.c b/components/libc/compilers/dlib/syscall_lseek.c
index 3bfec38998..b2c47e71c9 100644
--- a/components/libc/compilers/dlib/syscall_lseek.c
+++ b/components/libc/compilers/dlib/syscall_lseek.c
@@ -7,6 +7,7 @@
* Date Author Notes
* 2015-01-28 Bernard first version
*/
+
#include <rtthread.h>
#include <LowLevelIOInterface.h>
#include <unistd.h>
diff --git a/components/libc/compilers/dlib/syscall_mem.c b/components/libc/compilers/dlib/syscall_mem.c
index 57060da842..2de0974e4e 100644
--- a/components/libc/compilers/dlib/syscall_mem.c
+++ b/components/libc/compilers/dlib/syscall_mem.c
@@ -8,6 +8,7 @@
* 2015-01-28 Bernard first version
* 2021-11-13 Meco Man implement no-heap warning
*/
+
#include <rtthread.h>
#include <stddef.h>
diff --git a/components/libc/compilers/dlib/syscall_read.c b/components/libc/compilers/dlib/syscall_read.c
index db523cc0a6..a276a3e401 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_DEVIO
+#ifdef RT_USING_POSIX_STDIO
#include "libc.h"
-#endif /* RT_USING_POSIX_DEVIO */
+#endif /* RT_USING_POSIX_STDIO */
#include <compiler_private.h>
#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_DEVIO
+#ifdef RT_USING_POSIX_STDIO
if (libc_stdio_get_console() < 0)
{
LOG_W("Do not invoke standard input before initializing Compiler");
@@ -47,9 +47,9 @@ 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
- LOG_W(_WARNING_WITHOUT_DEVIO);
+ LOG_W(_WARNING_WITHOUT_STDIO);
return _LLIO_ERROR;
-#endif /* RT_USING_POSIX_DEVIO */
+#endif /* RT_USING_POSIX_STDIO */
}
else if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR))
{
diff --git a/components/libc/compilers/dlib/syscall_remove.c b/components/libc/compilers/dlib/syscall_remove.c
index 40c51164a9..04230544da 100644
--- a/components/libc/compilers/dlib/syscall_remove.c
+++ b/components/libc/compilers/dlib/syscall_remove.c
@@ -7,6 +7,7 @@
* Date Author Notes
* 2015-01-28 Bernard first version
*/
+
#include <rtthread.h>
#include <LowLevelIOInterface.h>
#include <unistd.h>
diff --git a/components/libc/compilers/dlib/syscall_write.c b/components/libc/compilers/dlib/syscall_write.c
index 3af08daba9..4eead9aa38 100644
--- a/components/libc/compilers/dlib/syscall_write.c
+++ b/components/libc/compilers/dlib/syscall_write.c
@@ -40,7 +40,7 @@ size_t __write(int handle, const unsigned char *buf, size_t len)
if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR))
{
-#ifdef RT_USING_CONSOLE
+#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
rt_device_t console_device;
console_device = rt_console_get_device();
@@ -52,7 +52,7 @@ size_t __write(int handle, const unsigned char *buf, size_t len)
return len; /* return the length of the data written */
#else
return _LLIO_ERROR;
-#endif /* RT_USING_CONSOLE */
+#endif /* defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) */
}
else if (handle == _LLIO_STDIN)
{
diff --git a/components/libc/compilers/dlib/syscalls.c b/components/libc/compilers/dlib/syscalls.c
index 1ee6a3bc12..391cbcac8a 100644
--- a/components/libc/compilers/dlib/syscalls.c
+++ b/components/libc/compilers/dlib/syscalls.c
@@ -7,6 +7,7 @@
* Date Author Notes
* 2021-02-13 Meco Man implement exit() and abort()
*/
+
#include <rtthread.h>
/* for exit() and abort() */
diff --git a/components/libc/compilers/gcc/newlib/fcntl.h b/components/libc/compilers/gcc/newlib/fcntl.h
index 239eaaef0d..847ae3d35b 100644
--- a/components/libc/compilers/gcc/newlib/fcntl.h
+++ b/components/libc/compilers/gcc/newlib/fcntl.h
@@ -7,6 +7,7 @@
* Date Author Notes
* 2021-09-02 Meco Man First version
*/
+
#ifndef __FCNTL_H__
#define __FCNTL_H__
diff --git a/components/libc/compilers/gcc/newlib/libc_syms.c b/components/libc/compilers/gcc/newlib/libc_syms.c
index aaf6980d6b..e6ca23b393 100644
--- a/components/libc/compilers/gcc/newlib/libc_syms.c
+++ b/components/libc/compilers/gcc/newlib/libc_syms.c
@@ -7,6 +7,7 @@
* Date Author Notes
* 2017/10/15 bernard the first version
*/
+
#include <rtthread.h>
#include <rtm.h>
diff --git a/components/libc/compilers/gcc/newlib/machine/time.h b/components/libc/compilers/gcc/newlib/machine/time.h
index 9ef838f892..805b061aea 100644
--- a/components/libc/compilers/gcc/newlib/machine/time.h
+++ b/components/libc/compilers/gcc/newlib/machine/time.h
@@ -1,3 +1,13 @@
+/*
+ * Copyright (c) 2006-2021, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2021-02-16 Meco Man The first version
+ */
+
#ifndef _MACHTIME_H_
#define _MACHTIME_H_
diff --git a/components/libc/compilers/gcc/newlib/syscalls.c b/components/libc/compilers/gcc/newlib/syscalls.c
index da0e4dc16f..dcf26ccfb7 100644
--- a/components/libc/compilers/gcc/newlib/syscalls.c
+++ b/components/libc/compilers/gcc/newlib/syscalls.c
@@ -20,9 +20,9 @@
#include <unistd.h>
#include <sys/errno.h>
#include <sys/stat.h>
-#ifdef RT_USING_POSIX_DEVIO
+#ifdef RT_USING_POSIX_STDIO
#include "libc.h"
-#endif /* RT_USING_POSIX_DEVIO */
+#endif /* RT_USING_POSIX_STDIO */
#ifdef RT_USING_MODULE
#include <dlmodule.h>
#endif /* RT_USING_MODULE */
@@ -225,17 +225,17 @@ _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_DEVIO
+#ifdef RT_USING_POSIX_STDIO
if (libc_stdio_get_console() < 0)
{
LOG_W("Do not invoke standard input before initializing Compiler");
return 0;
}
#else
- LOG_W("%s: %s", __func__, _WARNING_WITHOUT_DEVIO);
+ LOG_W("%s: %s", __func__, _WARNING_WITHOUT_STDIO);
ptr->_errno = ENOTSUP;
return -1;
-#endif /* RT_USING_POSIX_DEVIO */
+#endif /* RT_USING_POSIX_STDIO */
}
else if (fd == STDOUT_FILENO || fd == STDERR_FILENO)
{
@@ -297,7 +297,7 @@ _ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
if (fd == STDOUT_FILENO || fd == STDERR_FILENO)
{
-#ifdef RT_USING_CONSOLE
+#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
rt_device_t console;
console = rt_console_get_device();
@@ -306,7 +306,7 @@ _ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
#else
ptr->_errno = ENOTSUP;
return -1;
-#endif /* RT_USING_CONSOLE */
+#endif /* defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) */
}
else if (fd == STDIN_FILENO)
{