diff options
| author | Bernard Xiong <[email protected]> | 2021-12-05 13:16:39 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-12-05 13:16:39 +0800 |
| commit | 36d51542565800d503ad204d882e4b1dd3fcfe7d (patch) | |
| tree | debed47f95688577bcbde7846fd9892e9283668e /components/libc/compilers | |
| parent | 04535363844d30971edca03f643fc92ba2cd40a7 (diff) | |
| parent | 1040f4a3479b3751a7ad5d5383b62d602fccabed (diff) | |
Merge pull request #5320 from mysterywolf/pse-master
[POSIX] move PSE branch to master
Diffstat (limited to 'components/libc/compilers')
| -rw-r--r-- | components/libc/compilers/armlibc/syscalls.c | 28 | ||||
| -rw-r--r-- | components/libc/compilers/common/sys/ioctl.h | 2 | ||||
| -rw-r--r-- | components/libc/compilers/common/sys/time.h | 3 | ||||
| -rw-r--r-- | components/libc/compilers/common/time.c | 5 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/syscall_read.c | 8 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/syscall_write.c | 4 | ||||
| -rw-r--r-- | components/libc/compilers/gcc/newlib/syscalls.c | 10 |
7 files changed, 28 insertions, 32 deletions
diff --git a/components/libc/compilers/armlibc/syscalls.c b/components/libc/compilers/armlibc/syscalls.c index 71eacb1c41..0e965d62af 100644 --- a/components/libc/compilers/armlibc/syscalls.c +++ b/components/libc/compilers/armlibc/syscalls.c @@ -21,9 +21,9 @@ #include <fcntl.h> #include <unistd.h> #include <sys/stat.h> -#ifdef RT_USING_POSIX_STDIO +#ifdef RT_USING_POSIX_DEVIO #include "libc.h" -#endif +#endif /* RT_USING_POSIX_DEVIO */ #define DBG_TAG "armlibc.syscalls" #define DBG_LVL DBG_INFO @@ -149,29 +149,33 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode) if (fh == STDIN) { -#ifdef RT_USING_POSIX_STDIO +#ifdef RT_USING_POSIX_DEVIO if (libc_stdio_get_console() < 0) { LOG_W("Do not invoke standard output before initializing libc"); return 0; /* error, but keep going */ } size = read(STDIN_FILENO, buf, len); - return 0; /* success */ + return len - size; /* success */ #else return 0; /* error */ -#endif +#endif /* RT_USING_POSIX_DEVIO */ } else if (fh == STDOUT || fh == STDERR) { - return 0; /* error */ + return -1; /* 100% error */ } else { size = read(fh, buf, len); if (size >= 0) + { return len - size; /* success */ + } else + { return 0; /* error */ + } } #else return 0; /* error */ @@ -209,16 +213,20 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode) } else if (fh == STDIN) { - return 0; /* error */ + return -1; /* 100% error */ } else { #ifdef DFS_USING_POSIX size = write(fh, buf, len); if (size >= 0) - return 0; /* success */ + { + return len - size; /* success */ + } else + { return 0; /* error */ + } #else return 0; /* error */ #endif /* DFS_USING_POSIX */ @@ -332,7 +340,7 @@ int fputc(int c, FILE *f) int fgetc(FILE *f) { -#ifdef RT_USING_POSIX_STDIO +#ifdef RT_USING_POSIX_DEVIO char ch; if (libc_stdio_get_console() < 0) @@ -343,7 +351,7 @@ int fgetc(FILE *f) if(read(STDIN_FILENO, &ch, 1) == 1) return ch; -#endif /* RT_USING_POSIX_STDIO */ +#endif /* RT_USING_POSIX_DEVIO */ return 0; /* error */ } diff --git a/components/libc/compilers/common/sys/ioctl.h b/components/libc/compilers/common/sys/ioctl.h index 04f73837bc..29ed3a8b84 100644 --- a/components/libc/compilers/common/sys/ioctl.h +++ b/components/libc/compilers/common/sys/ioctl.h @@ -11,9 +11,7 @@ #define _SYS_IOCTL_H #include <rtconfig.h> -#ifdef RT_USING_POSIX #include <dfs_posix.h> -#endif #ifdef _WIN32 #include <winsock.h> diff --git a/components/libc/compilers/common/sys/time.h b/components/libc/compilers/common/sys/time.h index d14905ebfb..93e3bb7ba4 100644 --- a/components/libc/compilers/common/sys/time.h +++ b/components/libc/compilers/common/sys/time.h @@ -72,7 +72,6 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz); struct tm *gmtime_r(const time_t *timep, struct tm *r); #endif -#ifdef RT_USING_POSIX /* POSIX clock and timer */ #define MILLISECOND_PER_SECOND 1000UL #define MICROSECOND_PER_SECOND 1000000UL @@ -103,8 +102,8 @@ 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 rt_timespec_to_tick(const struct timespec *time); -#endif /* RT_USING_POSIX */ +/* timezone */ void tz_set(int8_t tz); int8_t tz_get(void); int8_t tz_is_dst(void); diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c index 5bfff15914..73b6d76352 100644 --- a/components/libc/compilers/common/time.c +++ b/components/libc/compilers/common/time.c @@ -486,8 +486,6 @@ RTM_EXPORT(settimeofday); RTM_EXPORT(difftime); RTM_EXPORT(strftime); -#ifdef RT_USING_POSIX - #ifdef RT_USING_RTC static volatile struct timeval _timevalue; static int _rt_clock_time_system_init() @@ -690,9 +688,6 @@ int rt_timespec_to_tick(const struct timespec *time) } RTM_EXPORT(rt_timespec_to_tick); -#endif /* RT_USING_POSIX */ - - /* timezone */ #ifndef RT_LIBC_DEFAULT_TIMEZONE #define RT_LIBC_DEFAULT_TIMEZONE 8 diff --git a/components/libc/compilers/dlib/syscall_read.c b/components/libc/compilers/dlib/syscall_read.c index 469ea7c1dd..62bc05d243 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_STDIO +#ifdef RT_USING_POSIX_DEVIO #include "libc.h" -#endif +#endif /* RT_USING_POSIX_DEVIO */ #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_STDIO +#ifdef RT_USING_POSIX_DEVIO if (libc_stdio_get_console() < 0) { LOG_W("Do not invoke standard input before initializing libc"); @@ -48,7 +48,7 @@ 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 return _LLIO_ERROR; -#endif /* RT_USING_POSIX_STDIO */ +#endif /* RT_USING_POSIX_DEVIO */ } else if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR)) { diff --git a/components/libc/compilers/dlib/syscall_write.c b/components/libc/compilers/dlib/syscall_write.c index d5ede3e59e..2bc5863d8a 100644 --- a/components/libc/compilers/dlib/syscall_write.c +++ b/components/libc/compilers/dlib/syscall_write.c @@ -11,10 +11,6 @@ #include <rtthread.h> #include <LowLevelIOInterface.h> #include <unistd.h> -#ifdef RT_USING_POSIX_STDIO -#include "libc.h" -#endif - #define DBG_TAG "dlib.syscall_write" #define DBG_LVL DBG_INFO #include <rtdbg.h> diff --git a/components/libc/compilers/gcc/newlib/syscalls.c b/components/libc/compilers/gcc/newlib/syscalls.c index 8bb9af940d..8fe8c5be4b 100644 --- a/components/libc/compilers/gcc/newlib/syscalls.c +++ b/components/libc/compilers/gcc/newlib/syscalls.c @@ -20,12 +20,12 @@ #include <unistd.h> #include <sys/errno.h> #include <sys/stat.h> -#ifdef RT_USING_POSIX_STDIO +#ifdef RT_USING_POSIX_DEVIO #include "libc.h" -#endif +#endif /* RT_USING_POSIX_DEVIO */ #ifdef RT_USING_MODULE #include <dlmodule.h> -#endif +#endif /* RT_USING_MODULE */ #define DBG_TAG "newlib.syscalls" #define DBG_LVL DBG_INFO @@ -225,7 +225,7 @@ _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_STDIO +#ifdef RT_USING_POSIX_DEVIO if (libc_stdio_get_console() < 0) { LOG_W("Do not invoke standard input before initializing libc"); @@ -234,7 +234,7 @@ _ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes) #else ptr->_errno = ENOTSUP; return -1; -#endif /* RT_USING_POSIX_STDIO */ +#endif /* RT_USING_POSIX_DEVIO */ } else if (fd == STDOUT_FILENO || fd == STDERR_FILENO) { |
