From 9254d1a3affdab5c329d2b8ea5bbe5a6a53e1dc9 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sat, 13 Nov 2021 10:16:31 -0500 Subject: [PATCH] =?UTF-8?q?[iar][syscalls]=20=E8=A1=A5=E5=85=85=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/libc/compilers/dlib/syscall_close.c | 6 ++++++ components/libc/compilers/dlib/syscall_lseek.c | 15 +++++++++++++++ components/libc/compilers/dlib/syscall_open.c | 5 +++++ components/libc/compilers/dlib/syscall_read.c | 12 ++++++++++++ components/libc/compilers/dlib/syscall_remove.c | 12 +++++++++--- components/libc/compilers/dlib/syscall_write.c | 14 ++++++++++++++ 6 files changed, 61 insertions(+), 3 deletions(-) diff --git a/components/libc/compilers/dlib/syscall_close.c b/components/libc/compilers/dlib/syscall_close.c index 2d14510490..aef9673153 100644 --- a/components/libc/compilers/dlib/syscall_close.c +++ b/components/libc/compilers/dlib/syscall_close.c @@ -11,7 +11,13 @@ #include #include +/* + * The "__close" function should close the file corresponding to + * "handle". It should return 0 on success and nonzero on failure. + */ + #pragma module_name = "?__close" + int __close(int handle) { if (handle == _LLIO_STDOUT || diff --git a/components/libc/compilers/dlib/syscall_lseek.c b/components/libc/compilers/dlib/syscall_lseek.c index 07ebfca2e9..b1547f699e 100644 --- a/components/libc/compilers/dlib/syscall_lseek.c +++ b/components/libc/compilers/dlib/syscall_lseek.c @@ -11,7 +11,22 @@ #include #include +/* + * The "__lseek" function makes the next file operation (__read or + * __write) act on a new location. The parameter "whence" specifies + * how the "offset" parameter should be interpreted according to the + * following table: + * + * 0 (=SEEK_SET) - Goto location "offset". + * 1 (=SEEK_CUR) - Go "offset" bytes from the current location. + * 2 (=SEEK_END) - Go to "offset" bytes from the end. + * + * This function should return the current file position, or -1 on + * failure. + */ + #pragma module_name = "?__lseek" + long __lseek(int handle, long offset, int whence) { if (handle == _LLIO_STDOUT || diff --git a/components/libc/compilers/dlib/syscall_open.c b/components/libc/compilers/dlib/syscall_open.c index 93056ffdbe..3336bc8885 100644 --- a/components/libc/compilers/dlib/syscall_open.c +++ b/components/libc/compilers/dlib/syscall_open.c @@ -12,6 +12,11 @@ #include #include +/* + * The "__open" function opens the file named "filename" as specified + * by "mode". + */ + #pragma module_name = "?__open" int __open(const char *filename, int mode) diff --git a/components/libc/compilers/dlib/syscall_read.c b/components/libc/compilers/dlib/syscall_read.c index 0df9766df2..e88f88ead4 100644 --- a/components/libc/compilers/dlib/syscall_read.c +++ b/components/libc/compilers/dlib/syscall_read.c @@ -19,7 +19,19 @@ #define DBG_LVL DBG_INFO #include +/* + * The "__read" function reads a number of bytes, at most "size" into + * the memory area pointed to by "buffer". It returns the number of + * bytes read, 0 at the end of the file, or _LLIO_ERROR if failure + * occurs. + * + * The template implementation below assumes that the application + * provides the function "MyLowLevelGetchar". It should return a + * character value, or -1 on failure. + */ + #pragma module_name = "?__read" + size_t __read(int handle, unsigned char *buf, size_t len) { #ifdef RT_USING_POSIX diff --git a/components/libc/compilers/dlib/syscall_remove.c b/components/libc/compilers/dlib/syscall_remove.c index dcb9bf60ec..cf6541132a 100644 --- a/components/libc/compilers/dlib/syscall_remove.c +++ b/components/libc/compilers/dlib/syscall_remove.c @@ -11,12 +11,18 @@ #include #include +/* + * The "remove" function should remove the file named "filename". It + * should return 0 on success and nonzero on failure. + */ + #pragma module_name = "?remove" -int remove(const char *val) + +int remove(const char *filename) { #ifdef RT_USING_POSIX - return unlink(val); + return unlink(filename); #else - return -1; + return _LLIO_ERROR; #endif /* RT_USING_POSIX */ } diff --git a/components/libc/compilers/dlib/syscall_write.c b/components/libc/compilers/dlib/syscall_write.c index 0f280e1702..c0729afd69 100644 --- a/components/libc/compilers/dlib/syscall_write.c +++ b/components/libc/compilers/dlib/syscall_write.c @@ -19,6 +19,20 @@ #define DBG_LVL DBG_INFO #include +/* + * The "__write" function should output "size" number of bytes from + * "buffer" in some application-specific way. It should return the + * number of characters written, or _LLIO_ERROR on failure. + * + * If "buffer" is zero then __write should perform flushing of + * internal buffers, if any. In this case "handle" can be -1 to + * indicate that all handles should be flushed. + * + * The template implementation below assumes that the application + * provides the function "MyLowLevelPutchar". It should return the + * character written, or -1 on failure. + */ + #pragma module_name = "?__write" size_t __write(int handle, const unsigned char *buf, size_t len)