Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9920aa5

Browse files
authored
Merge pull request#753 from JakubVanek/sysfs_perf_doc
docs: add ILibc documentation (to sysfs_perf)
2 parentsf943cbe +76c0384 commit9920aa5

File tree

1 file changed

+118
-0
lines changed

1 file changed

+118
-0
lines changed

‎src/main/java/ev3dev/utils/io/ILibc.java‎

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
packageev3dev.utils.io;
22

33
importcom.sun.jna.LastErrorException;
4+
importcom.sun.jna.Native;
45
importcom.sun.jna.NativeLong;
56
importcom.sun.jna.Pointer;
67

@@ -9,38 +10,155 @@
910
/**
1011
* POSIX Standard C Library wrapper interface
1112
*
13+
* For detailed reference, please see the
14+
* <a href="https://man7.org/linux/man-pages/dir_section_2.html">Linux syscall manual pages</a>
1215
* @author Jakub Vaněk
1316
* @since 2.4.7
1417
*/
1518
publicinterfaceILibc {
1619
// file descriptor operations
20+
21+
/**
22+
* Manipulate file descriptor
23+
* @param fd File descriptor to operate upon.
24+
* @param cmd Command code, see manpages for details.
25+
* @param arg Command argument, command-speciic. See manpages for details.
26+
* @return Depends on the command. On failure, -1 is returned.
27+
* @see <a href="https://man7.org/linux/man-pages/man2/fcntl.2.html">man 2 fcntl</a>
28+
* @throws LastErrorException If errno is set during the operation. Use {@link Native#getLastError()} to query the error code.
29+
*/
1730
intfcntl(intfd,intcmd,intarg)throwsLastErrorException;
1831

1932
// ioctls
33+
34+
/**
35+
* Invoke an I/O control request
36+
* @param fd Opened file descriptor to act upon.
37+
* @param cmd IO command code; this is device-specific (see manpages and/or kernel sources for details).
38+
* @param arg IOCTL integer argument, this is device-specific (see manpages and/or kernel sources for details).
39+
* @return -1 on failure, 0 otherwise (usually).
40+
* @see <a href="https://man7.org/linux/man-pages/man2/ioctl.2.html">man 2 ioctl</a>
41+
* @throws LastErrorException If errno is set during the operation. Use {@link Native#getLastError()} to query the error code.
42+
*/
2043
intioctl(intfd,intcmd,intarg)throwsLastErrorException;
2144

45+
/**
46+
* Invoke an I/O control request
47+
* @param fd Opened file descriptor to act upon.
48+
* @param cmd IO command code; this is device-specific (see manpages and/or kernel sources for details).
49+
* @param arg IOCTL integer argument, this is device-specific (see manpages and/or kernel sources for details).
50+
* @return -1 on failure, 0 otherwise (usually).
51+
* @see <a href="https://man7.org/linux/man-pages/man2/ioctl.2.html">man 2 ioctl</a>
52+
* @throws LastErrorException If errno is set during the operation. Use {@link Native#getLastError()} to query the error code.
53+
*/
2254
intioctl(intfd,intcmd,Pointerarg)throwsLastErrorException;
2355

2456
// open/close
2557

58+
/**
59+
* Try to open (or create) a file from the specified path.
60+
* @param path Path to try to open.
61+
* @param flags Open mode; typically O_RDONLY/O_WRONLY/O_RDWR combined with other modifiers (see POSIX).
62+
* @param mode Permissions to be set on the file if it is going to be created (O_CREAT).
63+
* @return File descriptor or -1 if the file cannot be opened.
64+
* @see <a href="https://man7.org/linux/man-pages/man2/open.2.html">man 2 open</a>
65+
* @throws LastErrorException If errno is set during the operation. Use {@link Native#getLastError()} to query the error code. If errno is set during the operation. Use {@link Native#getLastError()} to query the error code.
66+
*/
2667
intopen(Stringpath,intflags,intmode)throwsLastErrorException;
2768

69+
/**
70+
* Close the specified file descriptor.
71+
* @param fd File descriptor to close.
72+
* @return -1 on failure, 0 otherwise.
73+
* @see <a href="https://man7.org/linux/man-pages/man2/close.2.html">man 2 close</a>
74+
* @throws LastErrorException If errno is set during the operation. Use {@link Native#getLastError()} to query the error code. If errno is set during the operation. Use {@link Native#getLastError()} to query the error code.
75+
*/
2876
intclose(intfd)throwsLastErrorException;
2977

3078
// read/write
79+
80+
/**
81+
* Request a write to the current position in the file referred by a file descriptor.
82+
* @param fd File descriptor of the file to write.
83+
* @param buffer Buffer with bytes to write.
84+
* @param count Size of the buffer.
85+
* @return Number of bytes written or -1 if an error occurred.
86+
* @see <a href="https://man7.org/linux/man-pages/man2/write.2.html">man 2 write</a>
87+
* @throws LastErrorException If errno is set during the operation. Use {@link Native#getLastError()} to query the error code.
88+
*/
3189
intwrite(intfd,Bufferbuffer,intcount)throwsLastErrorException;
3290

91+
/**
92+
* Request a read from the current position in the file referred by a file descriptor.
93+
* @param fd File descriptor of the file to read.
94+
* @param buffer Buffer where to put the data.
95+
* @param count Size of the buffer.
96+
* @return Number of bytes read or -1 if an error occurred.
97+
* @see <a href="https://man7.org/linux/man-pages/man2/read.2.html">man 2 read</a>
98+
* @throws LastErrorException If errno is set during the operation. Use {@link Native#getLastError()} to query the error code.
99+
*/
33100
intread(intfd,Bufferbuffer,intcount)throwsLastErrorException;
34101

35102
// read/write with offset
103+
104+
/**
105+
* Request a read from the specified absolute position in the file referred by a file descriptor.
106+
* @param fd File descriptor of the file to read.
107+
* @param buffer Buffer where to put the data.
108+
* @param count Size of the buffer.
109+
* @param offset File offset where the data should be read from.
110+
* @return Number of bytes read or -1 if an error occurred.
111+
* @see <a href="https://man7.org/linux/man-pages/man2/pread.2.html">man 2 pread</a>
112+
* @throws LastErrorException If errno is set during the operation. Use {@link Native#getLastError()} to query the error code.
113+
*/
36114
intpread(intfd,Bufferbuffer,intcount,intoffset)throwsLastErrorException;
37115

116+
/**
117+
* Request a write to the specified absolute position in the file referred by a file descriptor.
118+
* @param fd File descriptor of the file to write.
119+
* @param buffer Buffer with bytes to write.
120+
* @param count Size of the buffer.
121+
* @param offset File offset where the data should be written to.
122+
* @return Number of bytes written or -1 if an error occurred.
123+
* @see <a href="https://man7.org/linux/man-pages/man2/pwrite.2.html">man 2 pwrite</a>
124+
* @throws LastErrorException If errno is set during the operation. Use {@link Native#getLastError()} to query the error code.
125+
*/
38126
intpwrite(intfd,Bufferbuffer,intcount,intoffset)throwsLastErrorException;
39127

40128
// map/unmap
129+
130+
/**
131+
* Map a file to memory.
132+
* @param addr Address hint from the userspace where to put the mapping in memory. Pass NULL to ignore the hint.
133+
* @param len Length of the memory to map.
134+
* @param prot Memory protection flags (PROT_READ/PROT_WRITE/PROT_EXEC). See manpages for details.
135+
* @param flags Memory mapping flags (MAP_SHARED/MAP_FILE/...). See manpages for deatils.
136+
* @param fd Opened file descriptor of the file that needs to be mapped to memory.
137+
* @param off Offset in the file from which to start the mapping.
138+
* @return On success, address of the mapped memory. On failure, -1 (MAP_FAILED) is returned.
139+
* @see <a href="https://man7.org/linux/man-pages/man2/mmap.2.html">man 2 mmap</a>
140+
* @throws LastErrorException If errno is set during the operation. Use {@link Native#getLastError()} to query the error code.
141+
*/
41142
Pointermmap(Pointeraddr,NativeLonglen,intprot,intflags,intfd,NativeLongoff)throwsLastErrorException;
42143

144+
/**
145+
* Unmap a file from memory.
146+
* @param addr Address where the file was mapped.
147+
* @param len Length of the mapped area.
148+
* @return -1 on failure, 0 otherwise.
149+
* @see <a href="https://man7.org/linux/man-pages/man2/munmap.2.html">man 2 munmap</a>
150+
* @throws LastErrorException If errno is set during the operation. Use {@link Native#getLastError()} to query the error code.
151+
*/
43152
intmunmap(Pointeraddr,NativeLonglen)throwsLastErrorException;
44153

154+
/**
155+
* Synchronize memory-mapped data with file contents.
156+
* @param addr Address where the file was mapped.
157+
* @param len Length of the mapped area.
158+
* @param flags Synchronization type (MS_SYNC/MS_ASYNC/MS_INVALIDATE). See manpages for details.
159+
* @return -1 on failure, 0 otherwise.
160+
* @see <a href="https://man7.org/linux/man-pages/man2/msync.2.html">man 2 msync</a>
161+
* @throws LastErrorException If errno is set during the operation. Use {@link Native#getLastError()} to query the error code.
162+
*/
45163
intmsync(Pointeraddr,NativeLonglen,intflags)throwsLastErrorException;
46164
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp