summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorMeco Man <[email protected]>2021-11-13 10:16:31 -0500
committerMeco Man <[email protected]>2021-11-13 10:16:31 -0500
commit9254d1a3affdab5c329d2b8ea5bbe5a6a53e1dc9 (patch)
tree2d8580424b699cd2104e062e3e1cad63049052cd /components
parent215d1d4c6eebf5e82aa4731ec673d0ff5c9b98c1 (diff)
[iar][syscalls] 补充注释
Diffstat (limited to 'components')
-rw-r--r--components/libc/compilers/dlib/syscall_close.c6
-rw-r--r--components/libc/compilers/dlib/syscall_lseek.c15
-rw-r--r--components/libc/compilers/dlib/syscall_open.c5
-rw-r--r--components/libc/compilers/dlib/syscall_read.c12
-rw-r--r--components/libc/compilers/dlib/syscall_remove.c12
-rw-r--r--components/libc/compilers/dlib/syscall_write.c14
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 <LowLevelIOInterface.h>
#include <unistd.h>
+/*
+ * 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 <LowLevelIOInterface.h>
#include <unistd.h>
+/*
+ * 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 <LowLevelIOInterface.h>
#include <fcntl.h>
+/*
+ * 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 <rtdbg.h>
+/*
+ * 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 <LowLevelIOInterface.h>
#include <unistd.h>
+/*
+ * 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 <rtdbg.h>
+/*
+ * 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)