]>
Commit | Line | Data |
---|---|---|
e1599b0c XL |
1 | From 62f535fa4e1a259aabd5f22449af01e32aeb6f47 Mon Sep 17 00:00:00 2001 |
2 | From: Dan Gohman <sunfish@mozilla.com> | |
3 | Date: Tue, 23 Jul 2019 10:23:06 -0700 | |
4 | Subject: [PATCH] maybe | |
5 | ||
6 | --- | |
7 | src/wasi_unstable/constants.rs | 188 +++++++++++++ | |
8 | src/wasi_unstable/minimal_safe.rs | 336 +++++++++++++++++++++++ | |
9 | src/wasi_unstable/mod.rs | 431 ++++-------------------------- | |
10 | src/wasi_unstable/types.rs | 41 +++ | |
11 | 4 files changed, 623 insertions(+), 373 deletions(-) | |
12 | create mode 100644 src/wasi_unstable/constants.rs | |
13 | create mode 100644 src/wasi_unstable/minimal_safe.rs | |
14 | create mode 100644 src/wasi_unstable/types.rs | |
15 | ||
16 | diff --git a/src/wasi_unstable/constants.rs b/src/wasi_unstable/constants.rs | |
17 | new file mode 100644 | |
18 | index 0000000..0af896b | |
19 | --- /dev/null | |
20 | +++ b/src/wasi_unstable/constants.rs | |
21 | @@ -0,0 +1,188 @@ | |
22 | +//! This file defines idiomatic Rust names for constants. | |
23 | + | |
24 | +use crate::wasi_unstable::raw::*; | |
25 | +use crate::wasi_unstable::types::*; | |
26 | + | |
27 | +pub const ADVICE_NORMAL: Advice = __WASI_ADVICE_NORMAL; | |
28 | +pub const ADVICE_SEQUENTIAL: Advice = __WASI_ADVICE_SEQUENTIAL; | |
29 | +pub const ADVICE_RANDOM: Advice = __WASI_ADVICE_RANDOM; | |
30 | +pub const ADVICE_WILLNEED: Advice = __WASI_ADVICE_WILLNEED; | |
31 | +pub const ADVICE_DONTNEED: Advice = __WASI_ADVICE_DONTNEED; | |
32 | +pub const ADVICE_NOREUSE: Advice = __WASI_ADVICE_NOREUSE; | |
33 | +pub const CLOCK_REALTIME: ClockId = __WASI_CLOCK_REALTIME; | |
34 | +pub const CLOCK_MONOTONIC: ClockId = __WASI_CLOCK_MONOTONIC; | |
35 | +pub const CLOCK_PROCESS_CPUTIME_ID: ClockId = __WASI_CLOCK_PROCESS_CPUTIME_ID; | |
36 | +pub const CLOCK_THREAD_CPUTIME_ID: ClockId = __WASI_CLOCK_THREAD_CPUTIME_ID; | |
37 | +pub const DIRCOOKIE_START: DirCookie = __WASI_DIRCOOKIE_START; | |
38 | +pub const ESUCCESS: Errno = __WASI_ESUCCESS; | |
39 | +pub const E2BIG: Errno = __WASI_E2BIG; | |
40 | +pub const EACCES: Errno = __WASI_EACCES; | |
41 | +pub const EADDRINUSE: Errno = __WASI_EADDRINUSE; | |
42 | +pub const EADDRNOTAVAIL: Errno = __WASI_EADDRNOTAVAIL; | |
43 | +pub const EAFNOSUPPORT: Errno = __WASI_EAFNOSUPPORT; | |
44 | +pub const EAGAIN: Errno = __WASI_EAGAIN; | |
45 | +pub const EALREADY: Errno = __WASI_EALREADY; | |
46 | +pub const EBADF: Errno = __WASI_EBADF; | |
47 | +pub const EBADMSG: Errno = __WASI_EBADMSG; | |
48 | +pub const EBUSY: Errno = __WASI_EBUSY; | |
49 | +pub const ECANCELED: Errno = __WASI_ECANCELED; | |
50 | +pub const ECHILD: Errno = __WASI_ECHILD; | |
51 | +pub const ECONNABORTED: Errno = __WASI_ECONNABORTED; | |
52 | +pub const ECONNREFUSED: Errno = __WASI_ECONNREFUSED; | |
53 | +pub const ECONNRESET: Errno = __WASI_ECONNRESET; | |
54 | +pub const EDEADLK: Errno = __WASI_EDEADLK; | |
55 | +pub const EDESTADDRREQ: Errno = __WASI_EDESTADDRREQ; | |
56 | +pub const EDOM: Errno = __WASI_EDOM; | |
57 | +pub const EDQUOT: Errno = __WASI_EDQUOT; | |
58 | +pub const EEXIST: Errno = __WASI_EEXIST; | |
59 | +pub const EFAULT: Errno = __WASI_EFAULT; | |
60 | +pub const EFBIG: Errno = __WASI_EFBIG; | |
61 | +pub const EHOSTUNREACH: Errno = __WASI_EHOSTUNREACH; | |
62 | +pub const EIDRM: Errno = __WASI_EIDRM; | |
63 | +pub const EILSEQ: Errno = __WASI_EILSEQ; | |
64 | +pub const EINPROGRESS: Errno = __WASI_EINPROGRESS; | |
65 | +pub const EINTR: Errno = __WASI_EINTR; | |
66 | +pub const EINVAL: Errno = __WASI_EINVAL; | |
67 | +pub const EIO: Errno = __WASI_EIO; | |
68 | +pub const EISCONN: Errno = __WASI_EISCONN; | |
69 | +pub const EISDIR: Errno = __WASI_EISDIR; | |
70 | +pub const ELOOP: Errno = __WASI_ELOOP; | |
71 | +pub const EMFILE: Errno = __WASI_EMFILE; | |
72 | +pub const EMLINK: Errno = __WASI_EMLINK; | |
73 | +pub const EMSGSIZE: Errno = __WASI_EMSGSIZE; | |
74 | +pub const EMULTIHOP: Errno = __WASI_EMULTIHOP; | |
75 | +pub const ENAMETOOLONG: Errno = __WASI_ENAMETOOLONG; | |
76 | +pub const ENETDOWN: Errno = __WASI_ENETDOWN; | |
77 | +pub const ENETRESET: Errno = __WASI_ENETRESET; | |
78 | +pub const ENETUNREACH: Errno = __WASI_ENETUNREACH; | |
79 | +pub const ENFILE: Errno = __WASI_ENFILE; | |
80 | +pub const ENOBUFS: Errno = __WASI_ENOBUFS; | |
81 | +pub const ENODEV: Errno = __WASI_ENODEV; | |
82 | +pub const ENOENT: Errno = __WASI_ENOENT; | |
83 | +pub const ENOEXEC: Errno = __WASI_ENOEXEC; | |
84 | +pub const ENOLCK: Errno = __WASI_ENOLCK; | |
85 | +pub const ENOLINK: Errno = __WASI_ENOLINK; | |
86 | +pub const ENOMEM: Errno = __WASI_ENOMEM; | |
87 | +pub const ENOMSG: Errno = __WASI_ENOMSG; | |
88 | +pub const ENOPROTOOPT: Errno = __WASI_ENOPROTOOPT; | |
89 | +pub const ENOSPC: Errno = __WASI_ENOSPC; | |
90 | +pub const ENOSYS: Errno = __WASI_ENOSYS; | |
91 | +pub const ENOTCONN: Errno = __WASI_ENOTCONN; | |
92 | +pub const ENOTDIR: Errno = __WASI_ENOTDIR; | |
93 | +pub const ENOTEMPTY: Errno = __WASI_ENOTEMPTY; | |
94 | +pub const ENOTRECOVERABLE: Errno = __WASI_ENOTRECOVERABLE; | |
95 | +pub const ENOTSOCK: Errno = __WASI_ENOTSOCK; | |
96 | +pub const ENOTSUP: Errno = __WASI_ENOTSUP; | |
97 | +pub const ENOTTY: Errno = __WASI_ENOTTY; | |
98 | +pub const ENXIO: Errno = __WASI_ENXIO; | |
99 | +pub const EOVERFLOW: Errno = __WASI_EOVERFLOW; | |
100 | +pub const EOWNERDEAD: Errno = __WASI_EOWNERDEAD; | |
101 | +pub const EPERM: Errno = __WASI_EPERM; | |
102 | +pub const EPIPE: Errno = __WASI_EPIPE; | |
103 | +pub const EPROTO: Errno = __WASI_EPROTO; | |
104 | +pub const EPROTONOSUPPORT: Errno = __WASI_EPROTONOSUPPORT; | |
105 | +pub const EPROTOTYPE: Errno = __WASI_EPROTOTYPE; | |
106 | +pub const ERANGE: Errno = __WASI_ERANGE; | |
107 | +pub const EROFS: Errno = __WASI_EROFS; | |
108 | +pub const ESPIPE: Errno = __WASI_ESPIPE; | |
109 | +pub const ESRCH: Errno = __WASI_ESRCH; | |
110 | +pub const ESTALE: Errno = __WASI_ESTALE; | |
111 | +pub const ETIMEDOUT: Errno = __WASI_ETIMEDOUT; | |
112 | +pub const ETXTBSY: Errno = __WASI_ETXTBSY; | |
113 | +pub const EXDEV: Errno = __WASI_EXDEV; | |
114 | +pub const ENOTCAPABLE: Errno = __WASI_ENOTCAPABLE; | |
115 | +pub const EVENT_FD_READWRITE_HANGUP: EventRwFlags = __WASI_EVENT_FD_READWRITE_HANGUP; | |
116 | +pub const EVENTTYPE_CLOCK: EventType = __WASI_EVENTTYPE_CLOCK; | |
117 | +pub const EVENTTYPE_FD_READ: EventType = __WASI_EVENTTYPE_FD_READ; | |
118 | +pub const EVENTTYPE_FD_WRITE: EventType = __WASI_EVENTTYPE_FD_WRITE; | |
119 | +pub const FDFLAG_APPEND: FdFlags = __WASI_FDFLAG_APPEND; | |
120 | +pub const FDFLAG_DSYNC: FdFlags = __WASI_FDFLAG_DSYNC; | |
121 | +pub const FDFLAG_NONBLOCK: FdFlags = __WASI_FDFLAG_NONBLOCK; | |
122 | +pub const FDFLAG_RSYNC: FdFlags = __WASI_FDFLAG_RSYNC; | |
123 | +pub const FDFLAG_SYNC: FdFlags = __WASI_FDFLAG_SYNC; | |
124 | +pub const FILETYPE_UNKNOWN: FileType = __WASI_FILETYPE_UNKNOWN; | |
125 | +pub const FILETYPE_BLOCK_DEVICE: FileType = __WASI_FILETYPE_BLOCK_DEVICE; | |
126 | +pub const FILETYPE_CHARACTER_DEVICE: FileType = __WASI_FILETYPE_CHARACTER_DEVICE; | |
127 | +pub const FILETYPE_DIRECTORY: FileType = __WASI_FILETYPE_DIRECTORY; | |
128 | +pub const FILETYPE_REGULAR_FILE: FileType = __WASI_FILETYPE_REGULAR_FILE; | |
129 | +pub const FILETYPE_SOCKET_DGRAM: FileType = __WASI_FILETYPE_SOCKET_DGRAM; | |
130 | +pub const FILETYPE_SOCKET_STREAM: FileType = __WASI_FILETYPE_SOCKET_STREAM; | |
131 | +pub const FILETYPE_SYMBOLIC_LINK: FileType = __WASI_FILETYPE_SYMBOLIC_LINK; | |
132 | +pub const FILESTAT_SET_ATIM: FstFlags = __WASI_FILESTAT_SET_ATIM; | |
133 | +pub const FILESTAT_SET_ATIM_NOW: FstFlags = __WASI_FILESTAT_SET_ATIM_NOW; | |
134 | +pub const FILESTAT_SET_MTIM: FstFlags = __WASI_FILESTAT_SET_MTIM; | |
135 | +pub const FILESTAT_SET_MTIM_NOW: FstFlags = __WASI_FILESTAT_SET_MTIM_NOW; | |
136 | +pub const LOOKUP_SYMLINK_FOLLOW: LookupFlags = __WASI_LOOKUP_SYMLINK_FOLLOW; | |
137 | +pub const O_CREAT: OFlags = __WASI_O_CREAT; | |
138 | +pub const O_DIRECTORY: OFlags = __WASI_O_DIRECTORY; | |
139 | +pub const O_EXCL: OFlags = __WASI_O_EXCL; | |
140 | +pub const O_TRUNC: OFlags = __WASI_O_TRUNC; | |
141 | +pub const PREOPENTYPE_DIR: PreopenType = __WASI_PREOPENTYPE_DIR; | |
142 | +pub const SOCK_RECV_PEEK: RiFlags = __WASI_SOCK_RECV_PEEK; | |
143 | +pub const SOCK_RECV_WAITALL: RiFlags = __WASI_SOCK_RECV_WAITALL; | |
144 | +pub const RIGHT_FD_DATASYNC: Rights = __WASI_RIGHT_FD_DATASYNC; | |
145 | +pub const RIGHT_FD_READ: Rights = __WASI_RIGHT_FD_READ; | |
146 | +pub const RIGHT_FD_SEEK: Rights = __WASI_RIGHT_FD_SEEK; | |
147 | +pub const RIGHT_FD_FDSTAT_SET_FLAGS: Rights = __WASI_RIGHT_FD_FDSTAT_SET_FLAGS; | |
148 | +pub const RIGHT_FD_SYNC: Rights = __WASI_RIGHT_FD_SYNC; | |
149 | +pub const RIGHT_FD_TELL: Rights = __WASI_RIGHT_FD_TELL; | |
150 | +pub const RIGHT_FD_WRITE: Rights = __WASI_RIGHT_FD_WRITE; | |
151 | +pub const RIGHT_FD_ADVISE: Rights = __WASI_RIGHT_FD_ADVISE; | |
152 | +pub const RIGHT_FD_ALLOCATE: Rights = __WASI_RIGHT_FD_ALLOCATE; | |
153 | +pub const RIGHT_PATH_CREATE_DIRECTORY: Rights = __WASI_RIGHT_PATH_CREATE_DIRECTORY; | |
154 | +pub const RIGHT_PATH_CREATE_FILE: Rights = __WASI_RIGHT_PATH_CREATE_FILE; | |
155 | +pub const RIGHT_PATH_LINK_SOURCE: Rights = __WASI_RIGHT_PATH_LINK_SOURCE; | |
156 | +pub const RIGHT_PATH_LINK_TARGET: Rights = __WASI_RIGHT_PATH_LINK_TARGET; | |
157 | +pub const RIGHT_PATH_OPEN: Rights = __WASI_RIGHT_PATH_OPEN; | |
158 | +pub const RIGHT_FD_READDIR: Rights = __WASI_RIGHT_FD_READDIR; | |
159 | +pub const RIGHT_PATH_READLINK: Rights = __WASI_RIGHT_PATH_READLINK; | |
160 | +pub const RIGHT_PATH_RENAME_SOURCE: Rights = __WASI_RIGHT_PATH_RENAME_SOURCE; | |
161 | +pub const RIGHT_PATH_RENAME_TARGET: Rights = __WASI_RIGHT_PATH_RENAME_TARGET; | |
162 | +pub const RIGHT_PATH_FILESTAT_GET: Rights = __WASI_RIGHT_PATH_FILESTAT_GET; | |
163 | +pub const RIGHT_PATH_FILESTAT_SET_SIZE: Rights = __WASI_RIGHT_PATH_FILESTAT_SET_SIZE; | |
164 | +pub const RIGHT_PATH_FILESTAT_SET_TIMES: Rights = __WASI_RIGHT_PATH_FILESTAT_SET_TIMES; | |
165 | +pub const RIGHT_FD_FILESTAT_GET: Rights = __WASI_RIGHT_FD_FILESTAT_GET; | |
166 | +pub const RIGHT_FD_FILESTAT_SET_SIZE: Rights = __WASI_RIGHT_FD_FILESTAT_SET_SIZE; | |
167 | +pub const RIGHT_FD_FILESTAT_SET_TIMES: Rights = __WASI_RIGHT_FD_FILESTAT_SET_TIMES; | |
168 | +pub const RIGHT_PATH_SYMLINK: Rights = __WASI_RIGHT_PATH_SYMLINK; | |
169 | +pub const RIGHT_PATH_REMOVE_DIRECTORY: Rights = __WASI_RIGHT_PATH_REMOVE_DIRECTORY; | |
170 | +pub const RIGHT_PATH_UNLINK_FILE: Rights = __WASI_RIGHT_PATH_UNLINK_FILE; | |
171 | +pub const RIGHT_POLL_FD_READWRITE: Rights = __WASI_RIGHT_POLL_FD_READWRITE; | |
172 | +pub const RIGHT_SOCK_SHUTDOWN: Rights = __WASI_RIGHT_SOCK_SHUTDOWN; | |
173 | +pub const SOCK_RECV_DATA_TRUNCATED: RoFlags = __WASI_SOCK_RECV_DATA_TRUNCATED; | |
174 | +pub const SHUT_RD: SdFlags = __WASI_SHUT_RD; | |
175 | +pub const SHUT_WR: SdFlags = __WASI_SHUT_WR; | |
176 | +pub const SIGHUP: Signal = __WASI_SIGHUP; | |
177 | +pub const SIGINT: Signal = __WASI_SIGINT; | |
178 | +pub const SIGQUIT: Signal = __WASI_SIGQUIT; | |
179 | +pub const SIGILL: Signal = __WASI_SIGILL; | |
180 | +pub const SIGTRAP: Signal = __WASI_SIGTRAP; | |
181 | +pub const SIGABRT: Signal = __WASI_SIGABRT; | |
182 | +pub const SIGBUS: Signal = __WASI_SIGBUS; | |
183 | +pub const SIGFPE: Signal = __WASI_SIGFPE; | |
184 | +pub const SIGKILL: Signal = __WASI_SIGKILL; | |
185 | +pub const SIGUSR1: Signal = __WASI_SIGUSR1; | |
186 | +pub const SIGSEGV: Signal = __WASI_SIGSEGV; | |
187 | +pub const SIGUSR2: Signal = __WASI_SIGUSR2; | |
188 | +pub const SIGPIPE: Signal = __WASI_SIGPIPE; | |
189 | +pub const SIGALRM: Signal = __WASI_SIGALRM; | |
190 | +pub const SIGTERM: Signal = __WASI_SIGTERM; | |
191 | +pub const SIGCHLD: Signal = __WASI_SIGCHLD; | |
192 | +pub const SIGCONT: Signal = __WASI_SIGCONT; | |
193 | +pub const SIGSTOP: Signal = __WASI_SIGSTOP; | |
194 | +pub const SIGTSTP: Signal = __WASI_SIGTSTP; | |
195 | +pub const SIGTTIN: Signal = __WASI_SIGTTIN; | |
196 | +pub const SIGTTOU: Signal = __WASI_SIGTTOU; | |
197 | +pub const SIGURG: Signal = __WASI_SIGURG; | |
198 | +pub const SIGXCPU: Signal = __WASI_SIGXCPU; | |
199 | +pub const SIGXFSZ: Signal = __WASI_SIGXFSZ; | |
200 | +pub const SIGVTALRM: Signal = __WASI_SIGVTALRM; | |
201 | +pub const SIGPROF: Signal = __WASI_SIGPROF; | |
202 | +pub const SIGWINCH: Signal = __WASI_SIGWINCH; | |
203 | +pub const SIGPOLL: Signal = __WASI_SIGPOLL; | |
204 | +pub const SIGPWR: Signal = __WASI_SIGPWR; | |
205 | +pub const SIGSYS: Signal = __WASI_SIGSYS; | |
206 | +pub const SUBSCRIPTION_CLOCK_ABSTIME: SubclockFlags = __WASI_SUBSCRIPTION_CLOCK_ABSTIME; | |
207 | +pub const WHENCE_CUR: Whence = __WASI_WHENCE_CUR; | |
208 | +pub const WHENCE_END: Whence = __WASI_WHENCE_END; | |
209 | +pub const WHENCE_SET: Whence = __WASI_WHENCE_SET; | |
210 | diff --git a/src/wasi_unstable/minimal_safe.rs b/src/wasi_unstable/minimal_safe.rs | |
211 | new file mode 100644 | |
212 | index 0000000..91a1ef1 | |
213 | --- /dev/null | |
214 | +++ b/src/wasi_unstable/minimal_safe.rs | |
215 | @@ -0,0 +1,336 @@ | |
216 | +//! This file defines minimally safe wrappers around the raw functions. | |
217 | +//! Pointer-length pairs are translated to Rust slice, and output pointer | |
218 | +//! parameters are translated to output reference parameters. | |
219 | +//! | |
220 | +//! These are primarily useful for writing low-level API tests. For most | |
221 | +//! other use cases, the interfaces defined in the top-level `wasi_unstable` | |
222 | +//! module will be easier to use. | |
223 | + | |
224 | +use crate::wasi_unstable::raw::*; | |
225 | +use core::ffi::c_void; | |
226 | + | |
227 | +pub use crate::wasi_unstable::constants::*; | |
228 | +pub use crate::wasi_unstable::types::*; | |
229 | + | |
230 | +#[inline] | |
231 | +pub fn clock_res_get(clock_id: ClockId, resolution: &mut Timestamp) -> Errno { | |
232 | + unsafe { __wasi_clock_res_get(clock_id, resolution) } | |
233 | +} | |
234 | + | |
235 | +#[inline] | |
236 | +pub fn clock_time_get(clock_id: ClockId, precision: Timestamp, time: &mut Timestamp) -> Errno { | |
237 | + unsafe { __wasi_clock_time_get(clock_id, precision, time) } | |
238 | +} | |
239 | + | |
240 | +#[inline] | |
241 | +pub fn fd_pread(fd: Fd, iovs: &[IoVec], offset: FileSize, nread: &mut usize) -> Errno { | |
242 | + unsafe { __wasi_fd_pread(fd, iovs.as_ptr(), iovs.len(), offset, nread) } | |
243 | +} | |
244 | + | |
245 | +#[inline] | |
246 | +pub fn fd_pwrite(fd: Fd, iovs: &[CIoVec], offset: FileSize, nwritten: &mut usize) -> Errno { | |
247 | + unsafe { __wasi_fd_pwrite(fd, iovs.as_ptr(), iovs.len(), offset, nwritten) } | |
248 | +} | |
249 | + | |
250 | +#[inline] | |
251 | +pub fn random_get(buf: &mut [u8]) -> Errno { | |
252 | + unsafe { __wasi_random_get(buf.as_mut_ptr() as *mut c_void, buf.len()) } | |
253 | +} | |
254 | + | |
255 | +#[inline] | |
256 | +pub fn fd_close(fd: Fd) -> Errno { | |
257 | + unsafe { __wasi_fd_close(fd) } | |
258 | +} | |
259 | + | |
260 | +#[inline] | |
261 | +pub fn fd_datasync(fd: Fd) -> Errno { | |
262 | + unsafe { __wasi_fd_datasync(fd) } | |
263 | +} | |
264 | + | |
265 | +#[inline] | |
266 | +pub fn fd_read(fd: Fd, iovs: &[IoVec], nread: &mut usize) -> Errno { | |
267 | + unsafe { __wasi_fd_read(fd, iovs.as_ptr(), iovs.len(), nread) } | |
268 | +} | |
269 | + | |
270 | +#[inline] | |
271 | +pub fn fd_renumber(from: Fd, to: Fd) -> Errno { | |
272 | + unsafe { __wasi_fd_renumber(from, to) } | |
273 | +} | |
274 | + | |
275 | +#[inline] | |
276 | +pub fn fd_seek(fd: Fd, offset: FileDelta, whence: Whence, newoffset: &mut FileSize) -> Errno { | |
277 | + unsafe { __wasi_fd_seek(fd, offset, whence, newoffset) } | |
278 | +} | |
279 | + | |
280 | +#[inline] | |
281 | +pub fn fd_tell(fd: Fd, newoffset: &mut FileSize) -> Errno { | |
282 | + unsafe { __wasi_fd_tell(fd, newoffset) } | |
283 | +} | |
284 | + | |
285 | +#[inline] | |
286 | +pub fn fd_fdstat_get(fd: Fd, buf: &mut FdStat) -> Errno { | |
287 | + unsafe { __wasi_fd_fdstat_get(fd, buf) } | |
288 | +} | |
289 | + | |
290 | +#[inline] | |
291 | +pub fn fd_fdstat_set_flags(fd: Fd, flags: FdFlags) -> Errno { | |
292 | + unsafe { __wasi_fd_fdstat_set_flags(fd, flags) } | |
293 | +} | |
294 | + | |
295 | +#[inline] | |
296 | +pub fn fd_fdstat_set_rights(fd: Fd, fs_rights_base: Rights, fs_rights_inheriting: Rights) -> Errno { | |
297 | + unsafe { __wasi_fd_fdstat_set_rights(fd, fs_rights_base, fs_rights_inheriting) } | |
298 | +} | |
299 | + | |
300 | +#[inline] | |
301 | +pub fn fd_sync(fd: Fd) -> Errno { | |
302 | + unsafe { __wasi_fd_sync(fd) } | |
303 | +} | |
304 | + | |
305 | +#[inline] | |
306 | +pub fn fd_write(fd: Fd, iovs: &[CIoVec], nwritten: &mut usize) -> Errno { | |
307 | + unsafe { __wasi_fd_write(fd, iovs.as_ptr(), iovs.len(), nwritten) } | |
308 | +} | |
309 | + | |
310 | +#[inline] | |
311 | +pub fn fd_advise(fd: Fd, offset: FileSize, len: FileSize, advice: Advice) -> Errno { | |
312 | + unsafe { __wasi_fd_advise(fd, offset, len, advice) } | |
313 | +} | |
314 | + | |
315 | +#[inline] | |
316 | +pub fn fd_allocate(fd: Fd, offset: FileSize, len: FileSize) -> Errno { | |
317 | + unsafe { __wasi_fd_allocate(fd, offset, len) } | |
318 | +} | |
319 | + | |
320 | +#[inline] | |
321 | +pub fn path_create_directory(fd: Fd, path: &[u8]) -> Errno { | |
322 | + unsafe { __wasi_path_create_directory(fd, path.as_ptr(), path.len()) } | |
323 | +} | |
324 | + | |
325 | +#[inline] | |
326 | +pub fn path_link( | |
327 | + old_fd: Fd, | |
328 | + old_flags: LookupFlags, | |
329 | + old_path: &[u8], | |
330 | + new_fd: Fd, | |
331 | + new_path: &[u8], | |
332 | +) -> Errno { | |
333 | + unsafe { | |
334 | + __wasi_path_link( | |
335 | + old_fd, | |
336 | + old_flags, | |
337 | + old_path.as_ptr(), | |
338 | + old_path.len(), | |
339 | + new_fd, | |
340 | + new_path.as_ptr(), | |
341 | + new_path.len(), | |
342 | + ) | |
343 | + } | |
344 | +} | |
345 | + | |
346 | +#[inline] | |
347 | +#[allow(clippy::too_many_arguments)] | |
348 | +pub fn path_open( | |
349 | + dirfd: Fd, | |
350 | + dirflags: LookupFlags, | |
351 | + path: &[u8], | |
352 | + oflags: OFlags, | |
353 | + fs_rights_base: Rights, | |
354 | + fs_rights_inheriting: Rights, | |
355 | + fs_flags: FdFlags, | |
356 | + fd: &mut Fd, | |
357 | +) -> Errno { | |
358 | + unsafe { | |
359 | + __wasi_path_open( | |
360 | + dirfd, | |
361 | + dirflags, | |
362 | + path.as_ptr(), | |
363 | + path.len(), | |
364 | + oflags, | |
365 | + fs_rights_base, | |
366 | + fs_rights_inheriting, | |
367 | + fs_flags, | |
368 | + fd, | |
369 | + ) | |
370 | + } | |
371 | +} | |
372 | + | |
373 | +#[inline] | |
374 | +pub fn fd_readdir(fd: Fd, buf: &mut [u8], cookie: DirCookie, bufused: &mut usize) -> Errno { | |
375 | + unsafe { | |
376 | + __wasi_fd_readdir( | |
377 | + fd, | |
378 | + buf.as_mut_ptr() as *mut c_void, | |
379 | + buf.len(), | |
380 | + cookie, | |
381 | + bufused, | |
382 | + ) | |
383 | + } | |
384 | +} | |
385 | + | |
386 | +#[inline] | |
387 | +pub fn path_readlink(fd: Fd, path: &[u8], buf: &mut [u8], bufused: &mut usize) -> Errno { | |
388 | + unsafe { | |
389 | + __wasi_path_readlink( | |
390 | + fd, | |
391 | + path.as_ptr(), | |
392 | + path.len(), | |
393 | + buf.as_mut_ptr(), | |
394 | + buf.len(), | |
395 | + bufused, | |
396 | + ) | |
397 | + } | |
398 | +} | |
399 | + | |
400 | +#[inline] | |
401 | +pub fn path_rename(old_fd: Fd, old_path: &[u8], new_fd: Fd, new_path: &[u8]) -> Errno { | |
402 | + unsafe { | |
403 | + __wasi_path_rename( | |
404 | + old_fd, | |
405 | + old_path.as_ptr(), | |
406 | + old_path.len(), | |
407 | + new_fd, | |
408 | + new_path.as_ptr(), | |
409 | + new_path.len(), | |
410 | + ) | |
411 | + } | |
412 | +} | |
413 | + | |
414 | +#[inline] | |
415 | +pub fn fd_filestat_get(fd: Fd, buf: &mut FileStat) -> Errno { | |
416 | + unsafe { __wasi_fd_filestat_get(fd, buf) } | |
417 | +} | |
418 | + | |
419 | +#[inline] | |
420 | +pub fn fd_filestat_set_times( | |
421 | + fd: Fd, | |
422 | + st_atim: Timestamp, | |
423 | + st_mtim: Timestamp, | |
424 | + fstflags: FstFlags, | |
425 | +) -> Errno { | |
426 | + unsafe { __wasi_fd_filestat_set_times(fd, st_atim, st_mtim, fstflags) } | |
427 | +} | |
428 | + | |
429 | +#[inline] | |
430 | +pub fn fd_filestat_set_size(fd: Fd, st_size: FileSize) -> Errno { | |
431 | + unsafe { __wasi_fd_filestat_set_size(fd, st_size) } | |
432 | +} | |
433 | + | |
434 | +#[inline] | |
435 | +pub fn path_filestat_get(fd: Fd, flags: LookupFlags, path: &[u8], buf: &mut FileStat) -> Errno { | |
436 | + unsafe { __wasi_path_filestat_get(fd, flags, path.as_ptr(), path.len(), buf) } | |
437 | +} | |
438 | + | |
439 | +#[inline] | |
440 | +pub fn path_filestat_set_times( | |
441 | + fd: Fd, | |
442 | + flags: LookupFlags, | |
443 | + path: &[u8], | |
444 | + st_atim: Timestamp, | |
445 | + st_mtim: Timestamp, | |
446 | + fstflags: FstFlags, | |
447 | +) -> Errno { | |
448 | + unsafe { | |
449 | + __wasi_path_filestat_set_times( | |
450 | + fd, | |
451 | + flags, | |
452 | + path.as_ptr(), | |
453 | + path.len(), | |
454 | + st_atim, | |
455 | + st_mtim, | |
456 | + fstflags, | |
457 | + ) | |
458 | + } | |
459 | +} | |
460 | + | |
461 | +#[inline] | |
462 | +pub fn path_symlink(old_path: &[u8], fd: Fd, new_path: &[u8]) -> Errno { | |
463 | + unsafe { | |
464 | + __wasi_path_symlink( | |
465 | + old_path.as_ptr(), | |
466 | + old_path.len(), | |
467 | + fd, | |
468 | + new_path.as_ptr(), | |
469 | + new_path.len(), | |
470 | + ) | |
471 | + } | |
472 | +} | |
473 | + | |
474 | +#[inline] | |
475 | +pub fn path_unlink_file(fd: Fd, path: &[u8]) -> Errno { | |
476 | + unsafe { __wasi_path_unlink_file(fd, path.as_ptr(), path.len()) } | |
477 | +} | |
478 | + | |
479 | +#[inline] | |
480 | +pub fn path_remove_directory(fd: Fd, path: &[u8]) -> Errno { | |
481 | + unsafe { __wasi_path_remove_directory(fd, path.as_ptr(), path.len()) } | |
482 | +} | |
483 | + | |
484 | +#[inline] | |
485 | +pub fn poll_oneoff(in_: &[Subscription], out: &mut [Event], nevents: &mut usize) -> Errno { | |
486 | + assert!(out.len() >= in_.len()); | |
487 | + unsafe { __wasi_poll_oneoff(in_.as_ptr(), out.as_mut_ptr(), in_.len(), nevents) } | |
488 | +} | |
489 | + | |
490 | +#[inline] | |
491 | +pub fn proc_exit(rval: ExitCode) { | |
492 | + unsafe { __wasi_proc_exit(rval) } | |
493 | +} | |
494 | + | |
495 | +#[inline] | |
496 | +pub fn proc_raise(sig: Signal) -> Errno { | |
497 | + unsafe { __wasi_proc_raise(sig) } | |
498 | +} | |
499 | + | |
500 | +#[inline] | |
501 | +pub fn sock_recv( | |
502 | + sock: Fd, | |
503 | + ri_data: &[IoVec], | |
504 | + ri_flags: RiFlags, | |
505 | + ro_datalen: &mut usize, | |
506 | + ro_flags: &mut RoFlags, | |
507 | +) -> Errno { | |
508 | + unsafe { | |
509 | + __wasi_sock_recv( | |
510 | + sock, | |
511 | + ri_data.as_ptr(), | |
512 | + ri_data.len(), | |
513 | + ri_flags, | |
514 | + ro_datalen, | |
515 | + ro_flags, | |
516 | + ) | |
517 | + } | |
518 | +} | |
519 | + | |
520 | +#[inline] | |
521 | +pub fn sock_send(sock: Fd, si_data: &[CIoVec], si_flags: SiFlags, so_datalen: &mut usize) -> Errno { | |
522 | + unsafe { __wasi_sock_send(sock, si_data.as_ptr(), si_data.len(), si_flags, so_datalen) } | |
523 | +} | |
524 | + | |
525 | +#[inline] | |
526 | +pub fn sock_shutdown(sock: Fd, how: SdFlags) -> Errno { | |
527 | + unsafe { __wasi_sock_shutdown(sock, how) } | |
528 | +} | |
529 | + | |
530 | +#[inline] | |
531 | +pub fn sched_yield() -> Errno { | |
532 | + unsafe { __wasi_sched_yield() } | |
533 | +} | |
534 | + | |
535 | +#[inline] | |
536 | +pub fn fd_prestat_get(fd: Fd, buf: &mut Prestat) -> Errno { | |
537 | + unsafe { __wasi_fd_prestat_get(fd, buf) } | |
538 | +} | |
539 | + | |
540 | +#[inline] | |
541 | +pub fn fd_prestat_dir_name(fd: Fd, path: &mut [u8]) -> Errno { | |
542 | + unsafe { __wasi_fd_prestat_dir_name(fd, path.as_mut_ptr(), path.len()) } | |
543 | +} | |
544 | + | |
545 | +// TODO: Safe interfaces to the args and environ functions | |
546 | +/* | |
547 | +pub fn args_get(argv: *mut *mut u8, argv_buf: *mut u8) -> Errno {} | |
548 | +pub fn args_sizes_get(argc: *mut usize, argv_buf_size: *mut usize) -> Errno {} | |
549 | +pub fn environ_get(environ: *mut *mut u8, environ_buf: *mut u8) -> Errno {} | |
550 | +pub fn environ_sizes_get(environ_count: *mut usize, environ_buf_size: *mut usize) -> Errno {} | |
551 | +*/ | |
552 | diff --git a/src/wasi_unstable/mod.rs b/src/wasi_unstable/mod.rs | |
553 | index 37bec24..893f59a 100644 | |
554 | --- a/src/wasi_unstable/mod.rs | |
555 | +++ b/src/wasi_unstable/mod.rs | |
556 | @@ -1,241 +1,56 @@ | |
557 | //! This module declares the Rust bindings to the `wasi_unstable` API. | |
558 | //! | |
559 | //! The raw bindings are in the `raw` submodule. They use raw pointers and | |
560 | -//! are unsafe. In the the top-level module, raw pointer-length pairs are | |
561 | -//! replaced by Rust slice types, output parameters are converted to normal | |
562 | +//! are unsafe. Minimally safe versions which replace raw pointers with | |
563 | +//! slices and references are in the `minimal_safe` module. | |
564 | +//! | |
565 | +//! In the the top-level module, output parameters are converted to normal | |
566 | //! return values, names are translated to be more Rust-idiomatic, and the | |
567 | //! functions are safe. | |
568 | -//! | |
569 | -//! TODO: Not all functions are covered yet; implement the rest of the API. | |
570 | ||
571 | +mod constants; | |
572 | +mod types; | |
573 | + | |
574 | +pub mod minimal_safe; | |
575 | pub mod raw; | |
576 | ||
577 | use core::ffi::c_void; | |
578 | use core::mem::MaybeUninit; | |
579 | use raw::*; | |
580 | ||
581 | -pub type Advice = __wasi_advice_t; | |
582 | -pub type ClockId = __wasi_clockid_t; | |
583 | -pub type Device = __wasi_device_t; | |
584 | -pub type DirCookie = __wasi_dircookie_t; | |
585 | -pub type Errno = __wasi_errno_t; | |
586 | -pub type EventRwFlags = __wasi_eventrwflags_t; | |
587 | -pub type EventType = __wasi_eventtype_t; | |
588 | -pub type ExitCode = __wasi_exitcode_t; | |
589 | -pub type Fd = __wasi_fd_t; | |
590 | -pub type FdFlags = __wasi_fdflags_t; | |
591 | -pub type FileDelta = __wasi_filedelta_t; | |
592 | -pub type FileSize = __wasi_filesize_t; | |
593 | -pub type FileType = __wasi_filetype_t; | |
594 | -pub type FstFlags = __wasi_fstflags_t; | |
595 | -pub type Inode = __wasi_inode_t; | |
596 | -pub type LinkCount = __wasi_linkcount_t; | |
597 | -pub type LookupFlags = __wasi_lookupflags_t; | |
598 | -pub type OFlags = __wasi_oflags_t; | |
599 | -pub type PreopenType = __wasi_preopentype_t; | |
600 | -pub type RiFlags = __wasi_riflags_t; | |
601 | -pub type Rights = __wasi_rights_t; | |
602 | -pub type RoFlags = __wasi_roflags_t; | |
603 | -pub type SdFlags = __wasi_sdflags_t; | |
604 | -pub type SiFlags = __wasi_siflags_t; | |
605 | -pub type Signal = __wasi_signal_t; | |
606 | -pub type SubclockFlags = __wasi_subclockflags_t; | |
607 | -pub type Timestamp = __wasi_timestamp_t; | |
608 | -pub type Userdata = __wasi_userdata_t; | |
609 | -pub type Whence = __wasi_whence_t; | |
610 | -pub type Dirent = __wasi_dirent_t; | |
611 | -pub type FdStat = __wasi_fdstat_t; | |
612 | -pub type FileStat = __wasi_filestat_t; | |
613 | -pub type CIoVec = __wasi_ciovec_t; | |
614 | -pub type IoVec = __wasi_iovec_t; | |
615 | -pub type Subscription = __wasi_subscription_t; | |
616 | -pub type Event = __wasi_event_t; | |
617 | -pub type Prestat = __wasi_prestat_t; | |
618 | - | |
619 | -pub const ADVICE_NORMAL: Advice = __WASI_ADVICE_NORMAL; | |
620 | -pub const ADVICE_SEQUENTIAL: Advice = __WASI_ADVICE_SEQUENTIAL; | |
621 | -pub const ADVICE_RANDOM: Advice = __WASI_ADVICE_RANDOM; | |
622 | -pub const ADVICE_WILLNEED: Advice = __WASI_ADVICE_WILLNEED; | |
623 | -pub const ADVICE_DONTNEED: Advice = __WASI_ADVICE_DONTNEED; | |
624 | -pub const ADVICE_NOREUSE: Advice = __WASI_ADVICE_NOREUSE; | |
625 | -pub const CLOCK_REALTIME: ClockId = __WASI_CLOCK_REALTIME; | |
626 | -pub const CLOCK_MONOTONIC: ClockId = __WASI_CLOCK_MONOTONIC; | |
627 | -pub const CLOCK_PROCESS_CPUTIME_ID: ClockId = __WASI_CLOCK_PROCESS_CPUTIME_ID; | |
628 | -pub const CLOCK_THREAD_CPUTIME_ID: ClockId = __WASI_CLOCK_THREAD_CPUTIME_ID; | |
629 | -pub const DIRCOOKIE_START: DirCookie = __WASI_DIRCOOKIE_START; | |
630 | -pub const ESUCCESS: Errno = __WASI_ESUCCESS; | |
631 | -pub const E2BIG: Errno = __WASI_E2BIG; | |
632 | -pub const EACCES: Errno = __WASI_EACCES; | |
633 | -pub const EADDRINUSE: Errno = __WASI_EADDRINUSE; | |
634 | -pub const EADDRNOTAVAIL: Errno = __WASI_EADDRNOTAVAIL; | |
635 | -pub const EAFNOSUPPORT: Errno = __WASI_EAFNOSUPPORT; | |
636 | -pub const EAGAIN: Errno = __WASI_EAGAIN; | |
637 | -pub const EALREADY: Errno = __WASI_EALREADY; | |
638 | -pub const EBADF: Errno = __WASI_EBADF; | |
639 | -pub const EBADMSG: Errno = __WASI_EBADMSG; | |
640 | -pub const EBUSY: Errno = __WASI_EBUSY; | |
641 | -pub const ECANCELED: Errno = __WASI_ECANCELED; | |
642 | -pub const ECHILD: Errno = __WASI_ECHILD; | |
643 | -pub const ECONNABORTED: Errno = __WASI_ECONNABORTED; | |
644 | -pub const ECONNREFUSED: Errno = __WASI_ECONNREFUSED; | |
645 | -pub const ECONNRESET: Errno = __WASI_ECONNRESET; | |
646 | -pub const EDEADLK: Errno = __WASI_EDEADLK; | |
647 | -pub const EDESTADDRREQ: Errno = __WASI_EDESTADDRREQ; | |
648 | -pub const EDOM: Errno = __WASI_EDOM; | |
649 | -pub const EDQUOT: Errno = __WASI_EDQUOT; | |
650 | -pub const EEXIST: Errno = __WASI_EEXIST; | |
651 | -pub const EFAULT: Errno = __WASI_EFAULT; | |
652 | -pub const EFBIG: Errno = __WASI_EFBIG; | |
653 | -pub const EHOSTUNREACH: Errno = __WASI_EHOSTUNREACH; | |
654 | -pub const EIDRM: Errno = __WASI_EIDRM; | |
655 | -pub const EILSEQ: Errno = __WASI_EILSEQ; | |
656 | -pub const EINPROGRESS: Errno = __WASI_EINPROGRESS; | |
657 | -pub const EINTR: Errno = __WASI_EINTR; | |
658 | -pub const EINVAL: Errno = __WASI_EINVAL; | |
659 | -pub const EIO: Errno = __WASI_EIO; | |
660 | -pub const EISCONN: Errno = __WASI_EISCONN; | |
661 | -pub const EISDIR: Errno = __WASI_EISDIR; | |
662 | -pub const ELOOP: Errno = __WASI_ELOOP; | |
663 | -pub const EMFILE: Errno = __WASI_EMFILE; | |
664 | -pub const EMLINK: Errno = __WASI_EMLINK; | |
665 | -pub const EMSGSIZE: Errno = __WASI_EMSGSIZE; | |
666 | -pub const EMULTIHOP: Errno = __WASI_EMULTIHOP; | |
667 | -pub const ENAMETOOLONG: Errno = __WASI_ENAMETOOLONG; | |
668 | -pub const ENETDOWN: Errno = __WASI_ENETDOWN; | |
669 | -pub const ENETRESET: Errno = __WASI_ENETRESET; | |
670 | -pub const ENETUNREACH: Errno = __WASI_ENETUNREACH; | |
671 | -pub const ENFILE: Errno = __WASI_ENFILE; | |
672 | -pub const ENOBUFS: Errno = __WASI_ENOBUFS; | |
673 | -pub const ENODEV: Errno = __WASI_ENODEV; | |
674 | -pub const ENOENT: Errno = __WASI_ENOENT; | |
675 | -pub const ENOEXEC: Errno = __WASI_ENOEXEC; | |
676 | -pub const ENOLCK: Errno = __WASI_ENOLCK; | |
677 | -pub const ENOLINK: Errno = __WASI_ENOLINK; | |
678 | -pub const ENOMEM: Errno = __WASI_ENOMEM; | |
679 | -pub const ENOMSG: Errno = __WASI_ENOMSG; | |
680 | -pub const ENOPROTOOPT: Errno = __WASI_ENOPROTOOPT; | |
681 | -pub const ENOSPC: Errno = __WASI_ENOSPC; | |
682 | -pub const ENOSYS: Errno = __WASI_ENOSYS; | |
683 | -pub const ENOTCONN: Errno = __WASI_ENOTCONN; | |
684 | -pub const ENOTDIR: Errno = __WASI_ENOTDIR; | |
685 | -pub const ENOTEMPTY: Errno = __WASI_ENOTEMPTY; | |
686 | -pub const ENOTRECOVERABLE: Errno = __WASI_ENOTRECOVERABLE; | |
687 | -pub const ENOTSOCK: Errno = __WASI_ENOTSOCK; | |
688 | -pub const ENOTSUP: Errno = __WASI_ENOTSUP; | |
689 | -pub const ENOTTY: Errno = __WASI_ENOTTY; | |
690 | -pub const ENXIO: Errno = __WASI_ENXIO; | |
691 | -pub const EOVERFLOW: Errno = __WASI_EOVERFLOW; | |
692 | -pub const EOWNERDEAD: Errno = __WASI_EOWNERDEAD; | |
693 | -pub const EPERM: Errno = __WASI_EPERM; | |
694 | -pub const EPIPE: Errno = __WASI_EPIPE; | |
695 | -pub const EPROTO: Errno = __WASI_EPROTO; | |
696 | -pub const EPROTONOSUPPORT: Errno = __WASI_EPROTONOSUPPORT; | |
697 | -pub const EPROTOTYPE: Errno = __WASI_EPROTOTYPE; | |
698 | -pub const ERANGE: Errno = __WASI_ERANGE; | |
699 | -pub const EROFS: Errno = __WASI_EROFS; | |
700 | -pub const ESPIPE: Errno = __WASI_ESPIPE; | |
701 | -pub const ESRCH: Errno = __WASI_ESRCH; | |
702 | -pub const ESTALE: Errno = __WASI_ESTALE; | |
703 | -pub const ETIMEDOUT: Errno = __WASI_ETIMEDOUT; | |
704 | -pub const ETXTBSY: Errno = __WASI_ETXTBSY; | |
705 | -pub const EXDEV: Errno = __WASI_EXDEV; | |
706 | -pub const ENOTCAPABLE: Errno = __WASI_ENOTCAPABLE; | |
707 | -pub const EVENT_FD_READWRITE_HANGUP: EventRwFlags = __WASI_EVENT_FD_READWRITE_HANGUP; | |
708 | -pub const EVENTTYPE_CLOCK: EventType = __WASI_EVENTTYPE_CLOCK; | |
709 | -pub const EVENTTYPE_FD_READ: EventType = __WASI_EVENTTYPE_FD_READ; | |
710 | -pub const EVENTTYPE_FD_WRITE: EventType = __WASI_EVENTTYPE_FD_WRITE; | |
711 | -pub const FDFLAG_APPEND: FdFlags = __WASI_FDFLAG_APPEND; | |
712 | -pub const FDFLAG_DSYNC: FdFlags = __WASI_FDFLAG_DSYNC; | |
713 | -pub const FDFLAG_NONBLOCK: FdFlags = __WASI_FDFLAG_NONBLOCK; | |
714 | -pub const FDFLAG_RSYNC: FdFlags = __WASI_FDFLAG_RSYNC; | |
715 | -pub const FDFLAG_SYNC: FdFlags = __WASI_FDFLAG_SYNC; | |
716 | -pub const FILETYPE_UNKNOWN: FileType = __WASI_FILETYPE_UNKNOWN; | |
717 | -pub const FILETYPE_BLOCK_DEVICE: FileType = __WASI_FILETYPE_BLOCK_DEVICE; | |
718 | -pub const FILETYPE_CHARACTER_DEVICE: FileType = __WASI_FILETYPE_CHARACTER_DEVICE; | |
719 | -pub const FILETYPE_DIRECTORY: FileType = __WASI_FILETYPE_DIRECTORY; | |
720 | -pub const FILETYPE_REGULAR_FILE: FileType = __WASI_FILETYPE_REGULAR_FILE; | |
721 | -pub const FILETYPE_SOCKET_DGRAM: FileType = __WASI_FILETYPE_SOCKET_DGRAM; | |
722 | -pub const FILETYPE_SOCKET_STREAM: FileType = __WASI_FILETYPE_SOCKET_STREAM; | |
723 | -pub const FILETYPE_SYMBOLIC_LINK: FileType = __WASI_FILETYPE_SYMBOLIC_LINK; | |
724 | -pub const FILESTAT_SET_ATIM: FstFlags = __WASI_FILESTAT_SET_ATIM; | |
725 | -pub const FILESTAT_SET_ATIM_NOW: FstFlags = __WASI_FILESTAT_SET_ATIM_NOW; | |
726 | -pub const FILESTAT_SET_MTIM: FstFlags = __WASI_FILESTAT_SET_MTIM; | |
727 | -pub const FILESTAT_SET_MTIM_NOW: FstFlags = __WASI_FILESTAT_SET_MTIM_NOW; | |
728 | -pub const LOOKUP_SYMLINK_FOLLOW: LookupFlags = __WASI_LOOKUP_SYMLINK_FOLLOW; | |
729 | -pub const O_CREAT: OFlags = __WASI_O_CREAT; | |
730 | -pub const O_DIRECTORY: OFlags = __WASI_O_DIRECTORY; | |
731 | -pub const O_EXCL: OFlags = __WASI_O_EXCL; | |
732 | -pub const O_TRUNC: OFlags = __WASI_O_TRUNC; | |
733 | -pub const PREOPENTYPE_DIR: PreopenType = __WASI_PREOPENTYPE_DIR; | |
734 | -pub const SOCK_RECV_PEEK: RiFlags = __WASI_SOCK_RECV_PEEK; | |
735 | -pub const SOCK_RECV_WAITALL: RiFlags = __WASI_SOCK_RECV_WAITALL; | |
736 | -pub const RIGHT_FD_DATASYNC: Rights = __WASI_RIGHT_FD_DATASYNC; | |
737 | -pub const RIGHT_FD_READ: Rights = __WASI_RIGHT_FD_READ; | |
738 | -pub const RIGHT_FD_SEEK: Rights = __WASI_RIGHT_FD_SEEK; | |
739 | -pub const RIGHT_FD_FDSTAT_SET_FLAGS: Rights = __WASI_RIGHT_FD_FDSTAT_SET_FLAGS; | |
740 | -pub const RIGHT_FD_SYNC: Rights = __WASI_RIGHT_FD_SYNC; | |
741 | -pub const RIGHT_FD_TELL: Rights = __WASI_RIGHT_FD_TELL; | |
742 | -pub const RIGHT_FD_WRITE: Rights = __WASI_RIGHT_FD_WRITE; | |
743 | -pub const RIGHT_FD_ADVISE: Rights = __WASI_RIGHT_FD_ADVISE; | |
744 | -pub const RIGHT_FD_ALLOCATE: Rights = __WASI_RIGHT_FD_ALLOCATE; | |
745 | -pub const RIGHT_PATH_CREATE_DIRECTORY: Rights = __WASI_RIGHT_PATH_CREATE_DIRECTORY; | |
746 | -pub const RIGHT_PATH_CREATE_FILE: Rights = __WASI_RIGHT_PATH_CREATE_FILE; | |
747 | -pub const RIGHT_PATH_LINK_SOURCE: Rights = __WASI_RIGHT_PATH_LINK_SOURCE; | |
748 | -pub const RIGHT_PATH_LINK_TARGET: Rights = __WASI_RIGHT_PATH_LINK_TARGET; | |
749 | -pub const RIGHT_PATH_OPEN: Rights = __WASI_RIGHT_PATH_OPEN; | |
750 | -pub const RIGHT_FD_READDIR: Rights = __WASI_RIGHT_FD_READDIR; | |
751 | -pub const RIGHT_PATH_READLINK: Rights = __WASI_RIGHT_PATH_READLINK; | |
752 | -pub const RIGHT_PATH_RENAME_SOURCE: Rights = __WASI_RIGHT_PATH_RENAME_SOURCE; | |
753 | -pub const RIGHT_PATH_RENAME_TARGET: Rights = __WASI_RIGHT_PATH_RENAME_TARGET; | |
754 | -pub const RIGHT_PATH_FILESTAT_GET: Rights = __WASI_RIGHT_PATH_FILESTAT_GET; | |
755 | -pub const RIGHT_PATH_FILESTAT_SET_SIZE: Rights = __WASI_RIGHT_PATH_FILESTAT_SET_SIZE; | |
756 | -pub const RIGHT_PATH_FILESTAT_SET_TIMES: Rights = __WASI_RIGHT_PATH_FILESTAT_SET_TIMES; | |
757 | -pub const RIGHT_FD_FILESTAT_GET: Rights = __WASI_RIGHT_FD_FILESTAT_GET; | |
758 | -pub const RIGHT_FD_FILESTAT_SET_SIZE: Rights = __WASI_RIGHT_FD_FILESTAT_SET_SIZE; | |
759 | -pub const RIGHT_FD_FILESTAT_SET_TIMES: Rights = __WASI_RIGHT_FD_FILESTAT_SET_TIMES; | |
760 | -pub const RIGHT_PATH_SYMLINK: Rights = __WASI_RIGHT_PATH_SYMLINK; | |
761 | -pub const RIGHT_PATH_REMOVE_DIRECTORY: Rights = __WASI_RIGHT_PATH_REMOVE_DIRECTORY; | |
762 | -pub const RIGHT_PATH_UNLINK_FILE: Rights = __WASI_RIGHT_PATH_UNLINK_FILE; | |
763 | -pub const RIGHT_POLL_FD_READWRITE: Rights = __WASI_RIGHT_POLL_FD_READWRITE; | |
764 | -pub const RIGHT_SOCK_SHUTDOWN: Rights = __WASI_RIGHT_SOCK_SHUTDOWN; | |
765 | -pub const SOCK_RECV_DATA_TRUNCATED: RoFlags = __WASI_SOCK_RECV_DATA_TRUNCATED; | |
766 | -pub const SHUT_RD: SdFlags = __WASI_SHUT_RD; | |
767 | -pub const SHUT_WR: SdFlags = __WASI_SHUT_WR; | |
768 | -pub const SIGHUP: Signal = __WASI_SIGHUP; | |
769 | -pub const SIGINT: Signal = __WASI_SIGINT; | |
770 | -pub const SIGQUIT: Signal = __WASI_SIGQUIT; | |
771 | -pub const SIGILL: Signal = __WASI_SIGILL; | |
772 | -pub const SIGTRAP: Signal = __WASI_SIGTRAP; | |
773 | -pub const SIGABRT: Signal = __WASI_SIGABRT; | |
774 | -pub const SIGBUS: Signal = __WASI_SIGBUS; | |
775 | -pub const SIGFPE: Signal = __WASI_SIGFPE; | |
776 | -pub const SIGKILL: Signal = __WASI_SIGKILL; | |
777 | -pub const SIGUSR1: Signal = __WASI_SIGUSR1; | |
778 | -pub const SIGSEGV: Signal = __WASI_SIGSEGV; | |
779 | -pub const SIGUSR2: Signal = __WASI_SIGUSR2; | |
780 | -pub const SIGPIPE: Signal = __WASI_SIGPIPE; | |
781 | -pub const SIGALRM: Signal = __WASI_SIGALRM; | |
782 | -pub const SIGTERM: Signal = __WASI_SIGTERM; | |
783 | -pub const SIGCHLD: Signal = __WASI_SIGCHLD; | |
784 | -pub const SIGCONT: Signal = __WASI_SIGCONT; | |
785 | -pub const SIGSTOP: Signal = __WASI_SIGSTOP; | |
786 | -pub const SIGTSTP: Signal = __WASI_SIGTSTP; | |
787 | -pub const SIGTTIN: Signal = __WASI_SIGTTIN; | |
788 | -pub const SIGTTOU: Signal = __WASI_SIGTTOU; | |
789 | -pub const SIGURG: Signal = __WASI_SIGURG; | |
790 | -pub const SIGXCPU: Signal = __WASI_SIGXCPU; | |
791 | -pub const SIGXFSZ: Signal = __WASI_SIGXFSZ; | |
792 | -pub const SIGVTALRM: Signal = __WASI_SIGVTALRM; | |
793 | -pub const SIGPROF: Signal = __WASI_SIGPROF; | |
794 | -pub const SIGWINCH: Signal = __WASI_SIGWINCH; | |
795 | -pub const SIGPOLL: Signal = __WASI_SIGPOLL; | |
796 | -pub const SIGPWR: Signal = __WASI_SIGPWR; | |
797 | -pub const SIGSYS: Signal = __WASI_SIGSYS; | |
798 | -pub const SUBSCRIPTION_CLOCK_ABSTIME: SubclockFlags = __WASI_SUBSCRIPTION_CLOCK_ABSTIME; | |
799 | -pub const WHENCE_CUR: Whence = __WASI_WHENCE_CUR; | |
800 | -pub const WHENCE_END: Whence = __WASI_WHENCE_END; | |
801 | -pub const WHENCE_SET: Whence = __WASI_WHENCE_SET; | |
802 | - | |
803 | +pub use constants::*; | |
804 | +pub use types::*; | |
805 | + | |
806 | +// These are for WASI functions which don't use output parameters, so we can | |
807 | +// just export the minimal_safe versions. | |
808 | +pub use minimal_safe::fd_advise; | |
809 | +pub use minimal_safe::fd_allocate; | |
810 | +pub use minimal_safe::fd_close; | |
811 | +pub use minimal_safe::fd_datasync; | |
812 | +pub use minimal_safe::fd_fdstat_set_flags; | |
813 | +pub use minimal_safe::fd_fdstat_set_rights; | |
814 | +pub use minimal_safe::fd_filestat_set_size; | |
815 | +pub use minimal_safe::fd_filestat_set_times; | |
816 | +pub use minimal_safe::fd_prestat_dir_name; | |
817 | +pub use minimal_safe::fd_renumber; | |
818 | +pub use minimal_safe::fd_sync; | |
819 | +pub use minimal_safe::path_create_directory; | |
820 | +pub use minimal_safe::path_filestat_set_times; | |
821 | +pub use minimal_safe::path_link; | |
822 | +pub use minimal_safe::path_remove_directory; | |
823 | +pub use minimal_safe::path_rename; | |
824 | +pub use minimal_safe::path_symlink; | |
825 | +pub use minimal_safe::path_unlink_file; | |
826 | +pub use minimal_safe::proc_exit; | |
827 | +pub use minimal_safe::proc_raise; | |
828 | +pub use minimal_safe::random_get; | |
829 | +pub use minimal_safe::sched_yield; | |
830 | +pub use minimal_safe::sock_shutdown; | |
831 | + | |
832 | +// The following are for WASI functions which do use output parameters. We | |
833 | +// wrap them separately to avoid creating references to uninitialized data. | |
834 | + | |
835 | +#[inline] | |
836 | pub fn clock_res_get(clock_id: ClockId) -> (Errno, Timestamp) { | |
837 | let mut resolution = MaybeUninit::<Timestamp>::uninit(); | |
838 | unsafe { | |
839 | @@ -246,6 +61,7 @@ pub fn clock_res_get(clock_id: ClockId) -> (Errno, Timestamp) { | |
840 | } | |
841 | } | |
842 | ||
843 | +#[inline] | |
844 | pub fn clock_time_get(clock_id: ClockId, precision: Timestamp) -> (Errno, Timestamp) { | |
845 | let mut time = MaybeUninit::<Timestamp>::uninit(); | |
846 | unsafe { | |
847 | @@ -256,6 +72,7 @@ pub fn clock_time_get(clock_id: ClockId, precision: Timestamp) -> (Errno, Timest | |
848 | } | |
849 | } | |
850 | ||
851 | +#[inline] | |
852 | pub fn fd_pread(fd: Fd, iovs: &[IoVec], offset: FileSize) -> (Errno, usize) { | |
853 | let mut nread = MaybeUninit::<usize>::uninit(); | |
854 | unsafe { | |
855 | @@ -266,6 +83,7 @@ pub fn fd_pread(fd: Fd, iovs: &[IoVec], offset: FileSize) -> (Errno, usize) { | |
856 | } | |
857 | } | |
858 | ||
859 | +#[inline] | |
860 | pub fn fd_pwrite(fd: Fd, iovs: &[CIoVec], offset: FileSize) -> (Errno, usize) { | |
861 | let mut nwritten = MaybeUninit::<usize>::uninit(); | |
862 | unsafe { | |
863 | @@ -276,18 +94,7 @@ pub fn fd_pwrite(fd: Fd, iovs: &[CIoVec], offset: FileSize) -> (Errno, usize) { | |
864 | } | |
865 | } | |
866 | ||
867 | -pub fn random_get(buf: &mut [u8]) -> Errno { | |
868 | - unsafe { __wasi_random_get(buf.as_mut_ptr() as *mut c_void, buf.len()) } | |
869 | -} | |
870 | - | |
871 | -pub fn fd_close(fd: Fd) -> Errno { | |
872 | - unsafe { __wasi_fd_close(fd) } | |
873 | -} | |
874 | - | |
875 | -pub fn fd_datasync(fd: Fd) -> Errno { | |
876 | - unsafe { __wasi_fd_datasync(fd) } | |
877 | -} | |
878 | - | |
879 | +#[inline] | |
880 | pub fn fd_read(fd: Fd, iovs: &[IoVec]) -> (Errno, usize) { | |
881 | let mut nread = MaybeUninit::<usize>::uninit(); | |
882 | unsafe { | |
883 | @@ -298,10 +105,7 @@ pub fn fd_read(fd: Fd, iovs: &[IoVec]) -> (Errno, usize) { | |
884 | } | |
885 | } | |
886 | ||
887 | -pub fn fd_renumber(from: Fd, to: Fd) -> Errno { | |
888 | - unsafe { __wasi_fd_renumber(from, to) } | |
889 | -} | |
890 | - | |
891 | +#[inline] | |
892 | pub fn fd_seek(fd: Fd, offset: FileDelta, whence: Whence) -> (Errno, FileSize) { | |
893 | let mut newoffset = MaybeUninit::<FileSize>::uninit(); | |
894 | unsafe { | |
895 | @@ -312,6 +116,7 @@ pub fn fd_seek(fd: Fd, offset: FileDelta, whence: Whence) -> (Errno, FileSize) { | |
896 | } | |
897 | } | |
898 | ||
899 | +#[inline] | |
900 | pub fn fd_tell(fd: Fd) -> (Errno, FileSize) { | |
901 | let mut newoffset = MaybeUninit::<FileSize>::uninit(); | |
902 | unsafe { | |
903 | @@ -322,6 +127,7 @@ pub fn fd_tell(fd: Fd) -> (Errno, FileSize) { | |
904 | } | |
905 | } | |
906 | ||
907 | +#[inline] | |
908 | pub fn fd_fdstat_get(fd: Fd) -> (Errno, FdStat) { | |
909 | let mut buf = MaybeUninit::<FdStat>::uninit(); | |
910 | unsafe { | |
911 | @@ -332,18 +138,7 @@ pub fn fd_fdstat_get(fd: Fd) -> (Errno, FdStat) { | |
912 | } | |
913 | } | |
914 | ||
915 | -pub fn fd_fdstat_set_flags(fd: Fd, flags: FdFlags) -> Errno { | |
916 | - unsafe { __wasi_fd_fdstat_set_flags(fd, flags) } | |
917 | -} | |
918 | - | |
919 | -pub fn fd_fdstat_set_rights(fd: Fd, fs_rights_base: Rights, fs_rights_inheriting: Rights) -> Errno { | |
920 | - unsafe { __wasi_fd_fdstat_set_rights(fd, fs_rights_base, fs_rights_inheriting) } | |
921 | -} | |
922 | - | |
923 | -pub fn fd_sync(fd: Fd) -> Errno { | |
924 | - unsafe { __wasi_fd_sync(fd) } | |
925 | -} | |
926 | - | |
927 | +#[inline] | |
928 | pub fn fd_write(fd: Fd, iovs: &[CIoVec]) -> (Errno, usize) { | |
929 | let mut nwritten = MaybeUninit::<usize>::uninit(); | |
930 | unsafe { | |
931 | @@ -354,38 +149,7 @@ pub fn fd_write(fd: Fd, iovs: &[CIoVec]) -> (Errno, usize) { | |
932 | } | |
933 | } | |
934 | ||
935 | -pub fn fd_advise(fd: Fd, offset: FileSize, len: FileSize, advice: Advice) -> Errno { | |
936 | - unsafe { __wasi_fd_advise(fd, offset, len, advice) } | |
937 | -} | |
938 | - | |
939 | -pub fn fd_allocate(fd: Fd, offset: FileSize, len: FileSize) -> Errno { | |
940 | - unsafe { __wasi_fd_allocate(fd, offset, len) } | |
941 | -} | |
942 | - | |
943 | -pub fn path_create_directory(fd: Fd, path: &[u8]) -> Errno { | |
944 | - unsafe { __wasi_path_create_directory(fd, path.as_ptr(), path.len()) } | |
945 | -} | |
946 | - | |
947 | -pub fn path_link( | |
948 | - old_fd: Fd, | |
949 | - old_flags: LookupFlags, | |
950 | - old_path: &[u8], | |
951 | - new_fd: Fd, | |
952 | - new_path: &[u8], | |
953 | -) -> Errno { | |
954 | - unsafe { | |
955 | - __wasi_path_link( | |
956 | - old_fd, | |
957 | - old_flags, | |
958 | - old_path.as_ptr(), | |
959 | - old_path.len(), | |
960 | - new_fd, | |
961 | - new_path.as_ptr(), | |
962 | - new_path.len(), | |
963 | - ) | |
964 | - } | |
965 | -} | |
966 | - | |
967 | +#[inline] | |
968 | pub fn path_open( | |
969 | dirfd: Fd, | |
970 | dirflags: LookupFlags, | |
971 | @@ -414,6 +178,7 @@ pub fn path_open( | |
972 | } | |
973 | } | |
974 | ||
975 | +#[inline] | |
976 | pub fn fd_readdir(fd: Fd, buf: &mut [u8], cookie: DirCookie) -> (Errno, usize) { | |
977 | let mut bufused = MaybeUninit::<usize>::uninit(); | |
978 | unsafe { | |
979 | @@ -430,6 +195,7 @@ pub fn fd_readdir(fd: Fd, buf: &mut [u8], cookie: DirCookie) -> (Errno, usize) { | |
980 | } | |
981 | } | |
982 | ||
983 | +#[inline] | |
984 | pub fn path_readlink(fd: Fd, path: &[u8], buf: &mut [u8]) -> (Errno, usize) { | |
985 | let mut bufused = MaybeUninit::<usize>::uninit(); | |
986 | unsafe { | |
987 | @@ -447,19 +213,7 @@ pub fn path_readlink(fd: Fd, path: &[u8], buf: &mut [u8]) -> (Errno, usize) { | |
988 | } | |
989 | } | |
990 | ||
991 | -pub fn path_rename(old_fd: Fd, old_path: &[u8], new_fd: Fd, new_path: &[u8]) -> Errno { | |
992 | - unsafe { | |
993 | - __wasi_path_rename( | |
994 | - old_fd, | |
995 | - old_path.as_ptr(), | |
996 | - old_path.len(), | |
997 | - new_fd, | |
998 | - new_path.as_ptr(), | |
999 | - new_path.len(), | |
1000 | - ) | |
1001 | - } | |
1002 | -} | |
1003 | - | |
1004 | +#[inline] | |
1005 | pub fn fd_filestat_get(fd: Fd) -> (Errno, FileStat) { | |
1006 | let mut buf = MaybeUninit::<FileStat>::uninit(); | |
1007 | unsafe { | |
1008 | @@ -470,19 +224,7 @@ pub fn fd_filestat_get(fd: Fd) -> (Errno, FileStat) { | |
1009 | } | |
1010 | } | |
1011 | ||
1012 | -pub fn fd_filestat_set_times( | |
1013 | - fd: Fd, | |
1014 | - st_atim: Timestamp, | |
1015 | - st_mtim: Timestamp, | |
1016 | - fstflags: FstFlags, | |
1017 | -) -> Errno { | |
1018 | - unsafe { __wasi_fd_filestat_set_times(fd, st_atim, st_mtim, fstflags) } | |
1019 | -} | |
1020 | - | |
1021 | -pub fn fd_filestat_set_size(fd: Fd, st_size: FileSize) -> Errno { | |
1022 | - unsafe { __wasi_fd_filestat_set_size(fd, st_size) } | |
1023 | -} | |
1024 | - | |
1025 | +#[inline] | |
1026 | pub fn path_filestat_get(fd: Fd, flags: LookupFlags, path: &[u8]) -> (Errno, FileStat) { | |
1027 | let mut buf = MaybeUninit::<FileStat>::uninit(); | |
1028 | unsafe { | |
1029 | @@ -493,47 +235,7 @@ pub fn path_filestat_get(fd: Fd, flags: LookupFlags, path: &[u8]) -> (Errno, Fil | |
1030 | } | |
1031 | } | |
1032 | ||
1033 | -pub fn path_filestat_set_times( | |
1034 | - fd: Fd, | |
1035 | - flags: LookupFlags, | |
1036 | - path: &[u8], | |
1037 | - st_atim: Timestamp, | |
1038 | - st_mtim: Timestamp, | |
1039 | - fstflags: FstFlags, | |
1040 | -) -> Errno { | |
1041 | - unsafe { | |
1042 | - __wasi_path_filestat_set_times( | |
1043 | - fd, | |
1044 | - flags, | |
1045 | - path.as_ptr(), | |
1046 | - path.len(), | |
1047 | - st_atim, | |
1048 | - st_mtim, | |
1049 | - fstflags, | |
1050 | - ) | |
1051 | - } | |
1052 | -} | |
1053 | - | |
1054 | -pub fn path_symlink(old_path: &[u8], fd: Fd, new_path: &[u8]) -> Errno { | |
1055 | - unsafe { | |
1056 | - __wasi_path_symlink( | |
1057 | - old_path.as_ptr(), | |
1058 | - old_path.len(), | |
1059 | - fd, | |
1060 | - new_path.as_ptr(), | |
1061 | - new_path.len(), | |
1062 | - ) | |
1063 | - } | |
1064 | -} | |
1065 | - | |
1066 | -pub fn path_unlink_file(fd: Fd, path: &[u8]) -> Errno { | |
1067 | - unsafe { __wasi_path_unlink_file(fd, path.as_ptr(), path.len()) } | |
1068 | -} | |
1069 | - | |
1070 | -pub fn path_remove_directory(fd: Fd, path: &[u8]) -> Errno { | |
1071 | - unsafe { __wasi_path_remove_directory(fd, path.as_ptr(), path.len()) } | |
1072 | -} | |
1073 | - | |
1074 | +#[inline] | |
1075 | pub fn poll_oneoff(in_: &[Subscription], out: &mut [Event]) -> (Errno, usize) { | |
1076 | assert!(out.len() >= in_.len()); | |
1077 | let mut nevents = MaybeUninit::<usize>::uninit(); | |
1078 | @@ -550,14 +252,7 @@ pub fn poll_oneoff(in_: &[Subscription], out: &mut [Event]) -> (Errno, usize) { | |
1079 | } | |
1080 | } | |
1081 | ||
1082 | -pub fn proc_exit(rval: ExitCode) { | |
1083 | - unsafe { __wasi_proc_exit(rval) } | |
1084 | -} | |
1085 | - | |
1086 | -pub fn proc_raise(sig: Signal) -> Errno { | |
1087 | - unsafe { __wasi_proc_raise(sig) } | |
1088 | -} | |
1089 | - | |
1090 | +#[inline] | |
1091 | pub fn sock_recv(sock: Fd, ri_data: &[IoVec], ri_flags: RiFlags) -> (Errno, usize, RoFlags) { | |
1092 | let mut ro_datalen = MaybeUninit::<usize>::uninit(); | |
1093 | let mut ro_flags = MaybeUninit::<RoFlags>::uninit(); | |
1094 | @@ -577,6 +272,7 @@ pub fn sock_recv(sock: Fd, ri_data: &[IoVec], ri_flags: RiFlags) -> (Errno, usiz | |
1095 | } | |
1096 | } | |
1097 | ||
1098 | +#[inline] | |
1099 | pub fn sock_send(sock: Fd, si_data: &[CIoVec], si_flags: SiFlags) -> (Errno, usize) { | |
1100 | let mut so_datalen = MaybeUninit::<usize>::uninit(); | |
1101 | unsafe { | |
1102 | @@ -593,14 +289,7 @@ pub fn sock_send(sock: Fd, si_data: &[CIoVec], si_flags: SiFlags) -> (Errno, usi | |
1103 | } | |
1104 | } | |
1105 | ||
1106 | -pub fn sock_shutdown(sock: Fd, how: SdFlags) -> Errno { | |
1107 | - unsafe { __wasi_sock_shutdown(sock, how) } | |
1108 | -} | |
1109 | - | |
1110 | -pub fn sched_yield() -> Errno { | |
1111 | - unsafe { __wasi_sched_yield() } | |
1112 | -} | |
1113 | - | |
1114 | +#[inline] | |
1115 | pub fn fd_prestat_get(fd: Fd) -> (Errno, Prestat) { | |
1116 | let mut buf = MaybeUninit::<Prestat>::uninit(); | |
1117 | unsafe { | |
1118 | @@ -611,10 +300,6 @@ pub fn fd_prestat_get(fd: Fd) -> (Errno, Prestat) { | |
1119 | } | |
1120 | } | |
1121 | ||
1122 | -pub fn fd_prestat_dir_name(fd: Fd, path: &mut [u8]) -> Errno { | |
1123 | - unsafe { __wasi_fd_prestat_dir_name(fd, path.as_mut_ptr(), path.len()) } | |
1124 | -} | |
1125 | - | |
1126 | // TODO: Safe interfaces to the args and environ functions | |
1127 | /* | |
1128 | pub fn args_get(argv: *mut *mut u8, argv_buf: *mut u8) -> Errno {} | |
1129 | diff --git a/src/wasi_unstable/types.rs b/src/wasi_unstable/types.rs | |
1130 | new file mode 100644 | |
1131 | index 0000000..dd744c9 | |
1132 | --- /dev/null | |
1133 | +++ b/src/wasi_unstable/types.rs | |
1134 | @@ -0,0 +1,41 @@ | |
1135 | +//! This file defines idiomatic Rust names for types. | |
1136 | + | |
1137 | +use crate::wasi_unstable::raw::*; | |
1138 | + | |
1139 | +pub type Advice = __wasi_advice_t; | |
1140 | +pub type ClockId = __wasi_clockid_t; | |
1141 | +pub type Device = __wasi_device_t; | |
1142 | +pub type DirCookie = __wasi_dircookie_t; | |
1143 | +pub type Errno = __wasi_errno_t; | |
1144 | +pub type EventRwFlags = __wasi_eventrwflags_t; | |
1145 | +pub type EventType = __wasi_eventtype_t; | |
1146 | +pub type ExitCode = __wasi_exitcode_t; | |
1147 | +pub type Fd = __wasi_fd_t; | |
1148 | +pub type FdFlags = __wasi_fdflags_t; | |
1149 | +pub type FileDelta = __wasi_filedelta_t; | |
1150 | +pub type FileSize = __wasi_filesize_t; | |
1151 | +pub type FileType = __wasi_filetype_t; | |
1152 | +pub type FstFlags = __wasi_fstflags_t; | |
1153 | +pub type Inode = __wasi_inode_t; | |
1154 | +pub type LinkCount = __wasi_linkcount_t; | |
1155 | +pub type LookupFlags = __wasi_lookupflags_t; | |
1156 | +pub type OFlags = __wasi_oflags_t; | |
1157 | +pub type PreopenType = __wasi_preopentype_t; | |
1158 | +pub type RiFlags = __wasi_riflags_t; | |
1159 | +pub type Rights = __wasi_rights_t; | |
1160 | +pub type RoFlags = __wasi_roflags_t; | |
1161 | +pub type SdFlags = __wasi_sdflags_t; | |
1162 | +pub type SiFlags = __wasi_siflags_t; | |
1163 | +pub type Signal = __wasi_signal_t; | |
1164 | +pub type SubclockFlags = __wasi_subclockflags_t; | |
1165 | +pub type Timestamp = __wasi_timestamp_t; | |
1166 | +pub type Userdata = __wasi_userdata_t; | |
1167 | +pub type Whence = __wasi_whence_t; | |
1168 | +pub type Dirent = __wasi_dirent_t; | |
1169 | +pub type FdStat = __wasi_fdstat_t; | |
1170 | +pub type FileStat = __wasi_filestat_t; | |
1171 | +pub type CIoVec = __wasi_ciovec_t; | |
1172 | +pub type IoVec = __wasi_iovec_t; | |
1173 | +pub type Subscription = __wasi_subscription_t; | |
1174 | +pub type Event = __wasi_event_t; | |
1175 | +pub type Prestat = __wasi_prestat_t; | |
1176 | -- | |
1177 | 2.17.1 | |
1178 |