diff options
| author | Bernard Xiong <[email protected]> | 2021-11-10 22:23:43 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-11-10 22:23:43 +0800 |
| commit | e6ae01e3326a5feb6d11176c3407bee7c920399c (patch) | |
| tree | 80dc67ad821469bed720e01880a2901e5732d6a2 /components/libc/compilers | |
| parent | fdbaa2a808d12d522ad90702795c08ae8443aab9 (diff) | |
| parent | 219d1e20f579cda0aac62d90bf926e8a0a9dd688 (diff) | |
Merge pull request #5259 from mysterywolf/posix
[posix] 优化posix若干
Diffstat (limited to 'components/libc/compilers')
| -rw-r--r-- | components/libc/compilers/armlibc/syscalls.c | 14 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/syscall_read.c | 4 | ||||
| -rw-r--r-- | components/libc/compilers/dlib/syscall_write.c | 4 | ||||
| -rw-r--r-- | components/libc/compilers/gcc/newlib/syscalls.c | 6 | ||||
| -rw-r--r-- | components/libc/compilers/readme.md | 1 |
5 files changed, 16 insertions, 13 deletions
diff --git a/components/libc/compilers/armlibc/syscalls.c b/components/libc/compilers/armlibc/syscalls.c index 755ffef1a6..62657a4b64 100644 --- a/components/libc/compilers/armlibc/syscalls.c +++ b/components/libc/compilers/armlibc/syscalls.c @@ -21,7 +21,7 @@ #include <fcntl.h> #include <unistd.h> #include <sys/stat.h> -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_STDIO #include "libc.h" #endif @@ -144,7 +144,7 @@ int _sys_close(FILEHANDLE fh) */ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode) { -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_STDIO int size; if (fh == STDIN) @@ -169,7 +169,7 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode) return 0; /* error */ #else return 0; /* error */ -#endif /* RT_USING_POSIX */ +#endif /* RT_USING_POSIX_STDIO */ } /* @@ -185,7 +185,7 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode) if ((fh == STDOUT) || (fh == STDERR)) { -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_STDIO if (libc_stdio_get_console() < 0) { LOG_W("Do not invoke standard input before initializing libc"); @@ -200,7 +200,7 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode) } return 0; /* error */ -#endif /* RT_USING_POSIX */ +#endif /* RT_USING_POSIX_STDIO */ } else if (fh == STDIN) { @@ -325,7 +325,7 @@ int fputc(int c, FILE *f) int fgetc(FILE *f) { -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_STDIO char ch; if (libc_stdio_get_console() < 0) @@ -336,7 +336,7 @@ int fgetc(FILE *f) if(read(STDIN_FILENO, &ch, 1) == 1) return ch; -#endif /* RT_USING_POSIX */ +#endif /* RT_USING_POSIX_STDIO */ return 0; /* error */ } diff --git a/components/libc/compilers/dlib/syscall_read.c b/components/libc/compilers/dlib/syscall_read.c index 74cedb966a..c926c577b5 100644 --- a/components/libc/compilers/dlib/syscall_read.c +++ b/components/libc/compilers/dlib/syscall_read.c @@ -11,7 +11,7 @@ #include <rtthread.h> #include <yfuns.h> #include <unistd.h> -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_STDIO #include "libc.h" #endif @@ -22,7 +22,7 @@ #pragma module_name = "?__read" size_t __read(int handle, unsigned char *buf, size_t len) { -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_STDIO int size; if (handle == _LLIO_STDIN) diff --git a/components/libc/compilers/dlib/syscall_write.c b/components/libc/compilers/dlib/syscall_write.c index ab011c1096..72bac6ba49 100644 --- a/components/libc/compilers/dlib/syscall_write.c +++ b/components/libc/compilers/dlib/syscall_write.c @@ -11,7 +11,7 @@ #include <rtthread.h> #include <yfuns.h> #include <unistd.h> -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_STDIO #include "libc.h" #endif @@ -29,7 +29,7 @@ size_t __write(int handle, const unsigned char *buf, size_t len) if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR)) { -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_STDIO if (libc_stdio_get_console() < 0) { LOG_W("Do not invoke standard output before initializing libc"); diff --git a/components/libc/compilers/gcc/newlib/syscalls.c b/components/libc/compilers/gcc/newlib/syscalls.c index f95e695a85..e957aaf003 100644 --- a/components/libc/compilers/gcc/newlib/syscalls.c +++ b/components/libc/compilers/gcc/newlib/syscalls.c @@ -20,7 +20,7 @@ #include <unistd.h> #include <sys/errno.h> #include <sys/stat.h> -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_STDIO #include "libc.h" #endif #ifdef RT_USING_MODULE @@ -216,7 +216,7 @@ int _open_r(struct _reent *ptr, const char *file, int flags, int mode) _ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes) { -#ifdef RT_USING_POSIX +#ifdef RT_USING_POSIX_STDIO _ssize_t rc; if (libc_stdio_get_console() < 0 && fd == STDIN_FILENO) { @@ -271,11 +271,13 @@ _ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes) { #ifdef RT_USING_POSIX _ssize_t rc; +#ifdef RT_USING_POSIX_STDIO if (libc_stdio_get_console() < 0 && fd == STDOUT_FILENO) { LOG_W("Do not invoke standard output before initializing libc"); return 0; } +#endif /* RT_USING_POSIX_STDIO */ rc = write(fd, buf, nbytes); return rc; #elif defined(RT_USING_CONSOLE) diff --git a/components/libc/compilers/readme.md b/components/libc/compilers/readme.md new file mode 100644 index 0000000000..e376cc704f --- /dev/null +++ b/components/libc/compilers/readme.md @@ -0,0 +1 @@ +This folder provides uniformed header files crossing different compiler platforms, and supports basic standard C library functions, such as memory management and time management, etc.
\ No newline at end of file |
