Skip to content

Commit 9254d1a

Browse files
committed
[iar][syscalls] 补充注释
1 parent 215d1d4 commit 9254d1a

File tree

6 files changed

+61
-3
lines changed

6 files changed

+61
-3
lines changed

components/libc/compilers/dlib/syscall_close.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111
#include <LowLevelIOInterface.h>
1212
#include <unistd.h>
1313

14+
/*
15+
* The "__close" function should close the file corresponding to
16+
* "handle". It should return 0 on success and nonzero on failure.
17+
*/
18+
1419
#pragma module_name = "?__close"
20+
1521
int __close(int handle)
1622
{
1723
if (handle == _LLIO_STDOUT ||

components/libc/compilers/dlib/syscall_lseek.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,22 @@
1111
#include <LowLevelIOInterface.h>
1212
#include <unistd.h>
1313

14+
/*
15+
* The "__lseek" function makes the next file operation (__read or
16+
* __write) act on a new location. The parameter "whence" specifies
17+
* how the "offset" parameter should be interpreted according to the
18+
* following table:
19+
*
20+
* 0 (=SEEK_SET) - Goto location "offset".
21+
* 1 (=SEEK_CUR) - Go "offset" bytes from the current location.
22+
* 2 (=SEEK_END) - Go to "offset" bytes from the end.
23+
*
24+
* This function should return the current file position, or -1 on
25+
* failure.
26+
*/
27+
1428
#pragma module_name = "?__lseek"
29+
1530
long __lseek(int handle, long offset, int whence)
1631
{
1732
if (handle == _LLIO_STDOUT ||

components/libc/compilers/dlib/syscall_open.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
#include <LowLevelIOInterface.h>
1313
#include <fcntl.h>
1414

15+
/*
16+
* The "__open" function opens the file named "filename" as specified
17+
* by "mode".
18+
*/
19+
1520
#pragma module_name = "?__open"
1621

1722
int __open(const char *filename, int mode)

components/libc/compilers/dlib/syscall_read.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,19 @@
1919
#define DBG_LVL DBG_INFO
2020
#include <rtdbg.h>
2121

22+
/*
23+
* The "__read" function reads a number of bytes, at most "size" into
24+
* the memory area pointed to by "buffer". It returns the number of
25+
* bytes read, 0 at the end of the file, or _LLIO_ERROR if failure
26+
* occurs.
27+
*
28+
* The template implementation below assumes that the application
29+
* provides the function "MyLowLevelGetchar". It should return a
30+
* character value, or -1 on failure.
31+
*/
32+
2233
#pragma module_name = "?__read"
34+
2335
size_t __read(int handle, unsigned char *buf, size_t len)
2436
{
2537
#ifdef RT_USING_POSIX

components/libc/compilers/dlib/syscall_remove.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,18 @@
1111
#include <LowLevelIOInterface.h>
1212
#include <unistd.h>
1313

14+
/*
15+
* The "remove" function should remove the file named "filename". It
16+
* should return 0 on success and nonzero on failure.
17+
*/
18+
1419
#pragma module_name = "?remove"
15-
int remove(const char *val)
20+
21+
int remove(const char *filename)
1622
{
1723
#ifdef RT_USING_POSIX
18-
return unlink(val);
24+
return unlink(filename);
1925
#else
20-
return -1;
26+
return _LLIO_ERROR;
2127
#endif /* RT_USING_POSIX */
2228
}

components/libc/compilers/dlib/syscall_write.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@
1919
#define DBG_LVL DBG_INFO
2020
#include <rtdbg.h>
2121

22+
/*
23+
* The "__write" function should output "size" number of bytes from
24+
* "buffer" in some application-specific way. It should return the
25+
* number of characters written, or _LLIO_ERROR on failure.
26+
*
27+
* If "buffer" is zero then __write should perform flushing of
28+
* internal buffers, if any. In this case "handle" can be -1 to
29+
* indicate that all handles should be flushed.
30+
*
31+
* The template implementation below assumes that the application
32+
* provides the function "MyLowLevelPutchar". It should return the
33+
* character written, or -1 on failure.
34+
*/
35+
2236
#pragma module_name = "?__write"
2337

2438
size_t __write(int handle, const unsigned char *buf, size_t len)

0 commit comments

Comments
 (0)