wasi_common_lucet/
lib.rs

1#![allow(clippy::too_many_arguments)]
2#![allow(clippy::missing_safety_doc)]
3
4pub use lucet_runtime_internals::{
5    lucet_hostcall, lucet_hostcall_terminate, vmctx::lucet_vmctx, vmctx::Vmctx,
6};
7pub use wasi_common::*;
8
9use std::mem;
10use std::rc::Rc;
11use wasi_common::hostcalls::*;
12
13#[lucet_hostcall]
14#[no_mangle]
15pub unsafe extern "C" fn __wasi_proc_exit(
16    _lucet_vmctx: &mut Vmctx,
17    rval: wasi::__wasi_exitcode_t,
18) -> ! {
19    export_wasi_funcs();
20    lucet_hostcall_terminate!(rval);
21}
22
23#[lucet_hostcall]
24#[no_mangle]
25pub unsafe extern "C" fn __wasi_args_get(
26    lucet_ctx: &mut Vmctx,
27    argv_ptr: wasi32::uintptr_t,
28    argv_buf: wasi32::uintptr_t,
29) -> wasi::__wasi_errno_t {
30    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
31    let heap = &mut lucet_ctx.heap_mut();
32    args_get(wasi_ctx, heap, argv_ptr, argv_buf)
33}
34
35#[lucet_hostcall]
36#[no_mangle]
37pub unsafe extern "C" fn __wasi_args_sizes_get(
38    lucet_ctx: &mut Vmctx,
39    argc_ptr: wasi32::uintptr_t,
40    argv_buf_size_ptr: wasi32::uintptr_t,
41) -> wasi::__wasi_errno_t {
42    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
43    let heap = &mut lucet_ctx.heap_mut();
44    args_sizes_get(wasi_ctx, heap, argc_ptr, argv_buf_size_ptr)
45}
46
47#[lucet_hostcall]
48#[no_mangle]
49pub unsafe extern "C" fn __wasi_sched_yield(_lucet_ctx: &mut Vmctx) -> wasi::__wasi_errno_t {
50    sched_yield()
51}
52
53#[lucet_hostcall]
54#[no_mangle]
55pub unsafe extern "C" fn __wasi_clock_res_get(
56    lucet_ctx: &mut Vmctx,
57    clock_id: wasi::__wasi_clockid_t,
58    resolution_ptr: wasi32::uintptr_t,
59) -> wasi::__wasi_errno_t {
60    let heap = &mut lucet_ctx.heap_mut();
61    clock_res_get(heap, clock_id, resolution_ptr)
62}
63
64#[lucet_hostcall]
65#[no_mangle]
66pub unsafe extern "C" fn __wasi_clock_time_get(
67    lucet_ctx: &mut Vmctx,
68    clock_id: wasi::__wasi_clockid_t,
69    precision: wasi::__wasi_timestamp_t,
70    time_ptr: wasi32::uintptr_t,
71) -> wasi::__wasi_errno_t {
72    let heap = &mut lucet_ctx.heap_mut();
73    clock_time_get(heap, clock_id, precision, time_ptr)
74}
75
76#[lucet_hostcall]
77#[no_mangle]
78pub unsafe extern "C" fn __wasi_environ_get(
79    lucet_ctx: &mut Vmctx,
80    environ_ptr: wasi32::uintptr_t,
81    environ_buf: wasi32::uintptr_t,
82) -> wasi::__wasi_errno_t {
83    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
84    let heap = &mut lucet_ctx.heap_mut();
85    environ_get(wasi_ctx, heap, environ_ptr, environ_buf)
86}
87
88#[lucet_hostcall]
89#[no_mangle]
90pub unsafe extern "C" fn __wasi_environ_sizes_get(
91    lucet_ctx: &mut Vmctx,
92    environ_count_ptr: wasi32::uintptr_t,
93    environ_size_ptr: wasi32::uintptr_t,
94) -> wasi::__wasi_errno_t {
95    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
96    let heap = &mut lucet_ctx.heap_mut();
97    environ_sizes_get(wasi_ctx, heap, environ_count_ptr, environ_size_ptr)
98}
99
100#[lucet_hostcall]
101#[no_mangle]
102pub unsafe extern "C" fn __wasi_fd_close(
103    lucet_ctx: &mut Vmctx,
104    fd: wasi::__wasi_fd_t,
105) -> wasi::__wasi_errno_t {
106    let wasi_ctx = &mut lucet_ctx.get_embed_ctx_mut::<WasiCtx>();
107    fd_close(wasi_ctx, fd)
108}
109
110#[lucet_hostcall]
111#[no_mangle]
112pub unsafe extern "C" fn __wasi_fd_fdstat_get(
113    lucet_ctx: &mut Vmctx,
114    fd: wasi::__wasi_fd_t,
115    fdstat_ptr: wasi32::uintptr_t,
116) -> wasi::__wasi_errno_t {
117    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
118    let heap = &mut lucet_ctx.heap_mut();
119    fd_fdstat_get(wasi_ctx, heap, fd, fdstat_ptr)
120}
121
122#[lucet_hostcall]
123#[no_mangle]
124pub unsafe extern "C" fn __wasi_fd_fdstat_set_flags(
125    lucet_ctx: &mut Vmctx,
126    fd: wasi::__wasi_fd_t,
127    fdflags: wasi::__wasi_fdflags_t,
128) -> wasi::__wasi_errno_t {
129    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
130    fd_fdstat_set_flags(wasi_ctx, fd, fdflags)
131}
132
133#[lucet_hostcall]
134#[no_mangle]
135pub unsafe extern "C" fn __wasi_fd_tell(
136    lucet_ctx: &mut Vmctx,
137    fd: wasi::__wasi_fd_t,
138    offset: wasi32::uintptr_t,
139) -> wasi::__wasi_errno_t {
140    let wasi_ctx = &mut lucet_ctx.get_embed_ctx_mut::<WasiCtx>();
141    let heap = &mut lucet_ctx.heap_mut();
142    fd_tell(wasi_ctx, heap, fd, offset)
143}
144
145#[lucet_hostcall]
146#[no_mangle]
147pub unsafe extern "C" fn __wasi_fd_seek(
148    lucet_ctx: &mut Vmctx,
149    fd: wasi::__wasi_fd_t,
150    offset: wasi::__wasi_filedelta_t,
151    whence: wasi::__wasi_whence_t,
152    newoffset: wasi32::uintptr_t,
153) -> wasi::__wasi_errno_t {
154    let wasi_ctx = &mut lucet_ctx.get_embed_ctx_mut::<WasiCtx>();
155    let heap = &mut lucet_ctx.heap_mut();
156    fd_seek(wasi_ctx, heap, fd, offset, whence, newoffset)
157}
158
159#[lucet_hostcall]
160#[no_mangle]
161pub unsafe extern "C" fn __wasi_fd_prestat_get(
162    lucet_ctx: &mut Vmctx,
163    fd: wasi::__wasi_fd_t,
164    prestat_ptr: wasi32::uintptr_t,
165) -> wasi::__wasi_errno_t {
166    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
167    let heap = &mut lucet_ctx.heap_mut();
168    fd_prestat_get(wasi_ctx, heap, fd, prestat_ptr)
169}
170
171#[lucet_hostcall]
172#[no_mangle]
173pub unsafe extern "C" fn __wasi_fd_prestat_dir_name(
174    lucet_ctx: &mut Vmctx,
175    fd: wasi::__wasi_fd_t,
176    path_ptr: wasi32::uintptr_t,
177    path_len: wasi32::size_t,
178) -> wasi::__wasi_errno_t {
179    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
180    let heap = &mut lucet_ctx.heap_mut();
181    fd_prestat_dir_name(wasi_ctx, heap, fd, path_ptr, path_len)
182}
183
184#[lucet_hostcall]
185#[no_mangle]
186pub unsafe extern "C" fn __wasi_fd_read(
187    lucet_ctx: &mut Vmctx,
188    fd: wasi::__wasi_fd_t,
189    iovs_ptr: wasi32::uintptr_t,
190    iovs_len: wasi32::size_t,
191    nread: wasi32::uintptr_t,
192) -> wasi::__wasi_errno_t {
193    let wasi_ctx = &mut lucet_ctx.get_embed_ctx_mut::<WasiCtx>();
194    let heap = &mut lucet_ctx.heap_mut();
195    fd_read(wasi_ctx, heap, fd, iovs_ptr, iovs_len, nread)
196}
197
198#[lucet_hostcall]
199#[no_mangle]
200pub unsafe extern "C" fn __wasi_fd_write(
201    lucet_ctx: &mut Vmctx,
202    fd: wasi::__wasi_fd_t,
203    iovs_ptr: wasi32::uintptr_t,
204    iovs_len: wasi32::size_t,
205    nwritten: wasi32::uintptr_t,
206) -> wasi::__wasi_errno_t {
207    let wasi_ctx = &mut lucet_ctx.get_embed_ctx_mut::<WasiCtx>();
208    let heap = &mut lucet_ctx.heap_mut();
209    fd_write(wasi_ctx, heap, fd, iovs_ptr, iovs_len, nwritten)
210}
211
212#[lucet_hostcall]
213#[no_mangle]
214pub unsafe extern "C" fn __wasi_path_open(
215    lucet_ctx: &mut Vmctx,
216    dirfd: wasi::__wasi_fd_t,
217    dirflags: wasi::__wasi_lookupflags_t,
218    path_ptr: wasi32::uintptr_t,
219    path_len: wasi32::size_t,
220    oflags: wasi::__wasi_oflags_t,
221    fs_rights_base: wasi::__wasi_rights_t,
222    fs_rights_inheriting: wasi::__wasi_rights_t,
223    fs_flags: wasi::__wasi_fdflags_t,
224    fd_out_ptr: wasi32::uintptr_t,
225) -> wasi::__wasi_errno_t {
226    let wasi_ctx = &mut lucet_ctx.get_embed_ctx_mut::<WasiCtx>();
227    let heap = &mut lucet_ctx.heap_mut();
228    path_open(
229        wasi_ctx,
230        heap,
231        dirfd,
232        dirflags,
233        path_ptr,
234        path_len,
235        oflags,
236        fs_rights_base,
237        fs_rights_inheriting,
238        fs_flags,
239        fd_out_ptr,
240    )
241}
242
243#[lucet_hostcall]
244#[no_mangle]
245pub unsafe extern "C" fn __wasi_random_get(
246    lucet_ctx: &mut Vmctx,
247    buf_ptr: wasi32::uintptr_t,
248    buf_len: wasi32::size_t,
249) -> wasi::__wasi_errno_t {
250    let heap = &mut lucet_ctx.heap_mut();
251    random_get(heap, buf_ptr, buf_len)
252}
253
254#[lucet_hostcall]
255#[no_mangle]
256pub unsafe extern "C" fn __wasi_poll_oneoff(
257    lucet_ctx: &mut Vmctx,
258    input: wasi32::uintptr_t,
259    output: wasi32::uintptr_t,
260    nsubscriptions: wasi32::size_t,
261    nevents: wasi32::uintptr_t,
262) -> wasi::__wasi_errno_t {
263    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
264    let heap = &mut lucet_ctx.heap_mut();
265    poll_oneoff(wasi_ctx, heap, input, output, nsubscriptions, nevents)
266}
267
268#[lucet_hostcall]
269#[no_mangle]
270pub unsafe extern "C" fn __wasi_fd_filestat_get(
271    lucet_ctx: &mut Vmctx,
272    fd: wasi::__wasi_fd_t,
273    filestat_ptr: wasi32::uintptr_t,
274) -> wasi::__wasi_errno_t {
275    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
276    let heap = &mut lucet_ctx.heap_mut();
277    fd_filestat_get(wasi_ctx, heap, fd, filestat_ptr)
278}
279
280#[lucet_hostcall]
281#[no_mangle]
282pub unsafe extern "C" fn __wasi_path_filestat_get(
283    lucet_ctx: &mut Vmctx,
284    dirfd: wasi::__wasi_fd_t,
285    dirflags: wasi::__wasi_lookupflags_t,
286    path_ptr: wasi32::uintptr_t,
287    path_len: wasi32::size_t,
288    filestat_ptr: wasi32::uintptr_t,
289) -> wasi::__wasi_errno_t {
290    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
291    let heap = &mut lucet_ctx.heap_mut();
292    path_filestat_get(
293        wasi_ctx,
294        heap,
295        dirfd,
296        dirflags,
297        path_ptr,
298        path_len,
299        filestat_ptr,
300    )
301}
302
303#[lucet_hostcall]
304#[no_mangle]
305pub unsafe extern "C" fn __wasi_path_create_directory(
306    lucet_ctx: &mut Vmctx,
307    dirfd: wasi::__wasi_fd_t,
308    path_ptr: wasi32::uintptr_t,
309    path_len: wasi32::size_t,
310) -> wasi::__wasi_errno_t {
311    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
312    let heap = &mut lucet_ctx.heap_mut();
313    path_create_directory(wasi_ctx, heap, dirfd, path_ptr, path_len)
314}
315
316#[lucet_hostcall]
317#[no_mangle]
318pub unsafe extern "C" fn __wasi_path_unlink_file(
319    lucet_ctx: &mut Vmctx,
320    dirfd: wasi::__wasi_fd_t,
321    path_ptr: wasi32::uintptr_t,
322    path_len: wasi32::size_t,
323) -> wasi::__wasi_errno_t {
324    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
325    let heap = &mut lucet_ctx.heap_mut();
326    path_unlink_file(wasi_ctx, heap, dirfd, path_ptr, path_len)
327}
328
329#[lucet_hostcall]
330#[no_mangle]
331pub unsafe extern "C" fn __wasi_fd_allocate(
332    lucet_ctx: &mut Vmctx,
333    fd: wasi::__wasi_fd_t,
334    offset: wasi::__wasi_filesize_t,
335    len: wasi::__wasi_filesize_t,
336) -> wasi::__wasi_errno_t {
337    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
338    fd_allocate(wasi_ctx, fd, offset, len)
339}
340
341#[lucet_hostcall]
342#[no_mangle]
343pub unsafe extern "C" fn __wasi_fd_advise(
344    lucet_ctx: &mut Vmctx,
345    fd: wasi::__wasi_fd_t,
346    offset: wasi::__wasi_filesize_t,
347    len: wasi::__wasi_filesize_t,
348    advice: wasi::__wasi_advice_t,
349) -> wasi::__wasi_errno_t {
350    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
351    fd_advise(wasi_ctx, fd, offset, len, advice)
352}
353
354#[lucet_hostcall]
355#[no_mangle]
356pub unsafe extern "C" fn __wasi_fd_datasync(
357    lucet_ctx: &mut Vmctx,
358    fd: wasi::__wasi_fd_t,
359) -> wasi::__wasi_errno_t {
360    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
361    fd_datasync(wasi_ctx, fd)
362}
363
364#[lucet_hostcall]
365#[no_mangle]
366pub unsafe extern "C" fn __wasi_fd_sync(
367    lucet_ctx: &mut Vmctx,
368    fd: wasi::__wasi_fd_t,
369) -> wasi::__wasi_errno_t {
370    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
371    fd_sync(wasi_ctx, fd)
372}
373
374#[lucet_hostcall]
375#[no_mangle]
376pub unsafe extern "C" fn __wasi_fd_fdstat_set_rights(
377    lucet_ctx: &mut Vmctx,
378    fd: wasi::__wasi_fd_t,
379    fs_rights_base: wasi::__wasi_rights_t,
380    fs_rights_inheriting: wasi::__wasi_rights_t,
381) -> wasi::__wasi_errno_t {
382    let wasi_ctx = &mut lucet_ctx.get_embed_ctx_mut::<WasiCtx>();
383    fd_fdstat_set_rights(wasi_ctx, fd, fs_rights_base, fs_rights_inheriting)
384}
385
386#[lucet_hostcall]
387#[no_mangle]
388pub unsafe extern "C" fn __wasi_fd_filestat_set_size(
389    lucet_ctx: &mut Vmctx,
390    fd: wasi::__wasi_fd_t,
391    st_size: wasi::__wasi_filesize_t,
392) -> wasi::__wasi_errno_t {
393    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
394    fd_filestat_set_size(wasi_ctx, fd, st_size)
395}
396
397#[lucet_hostcall]
398#[no_mangle]
399pub unsafe extern "C" fn __wasi_fd_filestat_set_times(
400    lucet_ctx: &mut Vmctx,
401    fd: wasi::__wasi_fd_t,
402    st_atim: wasi::__wasi_timestamp_t,
403    st_mtim: wasi::__wasi_timestamp_t,
404    fst_flags: wasi::__wasi_fstflags_t,
405) -> wasi::__wasi_errno_t {
406    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
407    fd_filestat_set_times(wasi_ctx, fd, st_atim, st_mtim, fst_flags)
408}
409
410#[lucet_hostcall]
411#[no_mangle]
412pub unsafe extern "C" fn __wasi_fd_pread(
413    lucet_ctx: &mut Vmctx,
414    fd: wasi::__wasi_fd_t,
415    iovs_ptr: wasi32::uintptr_t,
416    iovs_len: wasi32::size_t,
417    offset: wasi::__wasi_filesize_t,
418    nread: wasi32::uintptr_t,
419) -> wasi::__wasi_errno_t {
420    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
421    let heap = &mut lucet_ctx.heap_mut();
422    fd_pread(wasi_ctx, heap, fd, iovs_ptr, iovs_len, offset, nread)
423}
424
425#[lucet_hostcall]
426#[no_mangle]
427pub unsafe extern "C" fn __wasi_fd_pwrite(
428    lucet_ctx: &mut Vmctx,
429    fd: wasi::__wasi_fd_t,
430    iovs_ptr: wasi32::uintptr_t,
431    iovs_len: wasi32::size_t,
432    offset: wasi::__wasi_filesize_t,
433    nwritten: wasi32::uintptr_t,
434) -> wasi::__wasi_errno_t {
435    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
436    let heap = &mut lucet_ctx.heap_mut();
437    fd_pwrite(wasi_ctx, heap, fd, iovs_ptr, iovs_len, offset, nwritten)
438}
439
440#[lucet_hostcall]
441#[no_mangle]
442pub unsafe extern "C" fn __wasi_fd_readdir(
443    lucet_ctx: &mut Vmctx,
444    fd: wasi::__wasi_fd_t,
445    buf: wasi32::uintptr_t,
446    buf_len: wasi32::size_t,
447    cookie: wasi::__wasi_dircookie_t,
448    bufused: wasi32::uintptr_t,
449) -> wasi::__wasi_errno_t {
450    let wasi_ctx = &mut lucet_ctx.get_embed_ctx_mut::<WasiCtx>();
451    let heap = &mut lucet_ctx.heap_mut();
452    fd_readdir(wasi_ctx, heap, fd, buf, buf_len, cookie, bufused)
453}
454
455#[lucet_hostcall]
456#[no_mangle]
457pub unsafe extern "C" fn __wasi_fd_renumber(
458    lucet_ctx: &mut Vmctx,
459    from: wasi::__wasi_fd_t,
460    to: wasi::__wasi_fd_t,
461) -> wasi::__wasi_errno_t {
462    let wasi_ctx = &mut lucet_ctx.get_embed_ctx_mut::<WasiCtx>();
463    fd_renumber(wasi_ctx, from, to)
464}
465
466#[lucet_hostcall]
467#[no_mangle]
468pub unsafe extern "C" fn __wasi_path_filestat_set_times(
469    lucet_ctx: &mut Vmctx,
470    dirfd: wasi::__wasi_fd_t,
471    dirflags: wasi::__wasi_lookupflags_t,
472    path_ptr: wasi32::uintptr_t,
473    path_len: wasi32::size_t,
474    st_atim: wasi::__wasi_timestamp_t,
475    st_mtim: wasi::__wasi_timestamp_t,
476    fst_flags: wasi::__wasi_fstflags_t,
477) -> wasi::__wasi_errno_t {
478    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
479    let heap = &mut lucet_ctx.heap_mut();
480    path_filestat_set_times(
481        wasi_ctx, heap, dirfd, dirflags, path_ptr, path_len, st_atim, st_mtim, fst_flags,
482    )
483}
484
485#[lucet_hostcall]
486#[no_mangle]
487pub unsafe extern "C" fn __wasi_path_link(
488    lucet_ctx: &mut Vmctx,
489    old_fd: wasi::__wasi_fd_t,
490    old_flags: wasi::__wasi_lookupflags_t,
491    old_path_ptr: wasi32::uintptr_t,
492    old_path_len: wasi32::size_t,
493    new_fd: wasi::__wasi_fd_t,
494    new_path_ptr: wasi32::uintptr_t,
495    new_path_len: wasi32::size_t,
496) -> wasi::__wasi_errno_t {
497    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
498    let heap = &mut lucet_ctx.heap_mut();
499    path_link(
500        wasi_ctx,
501        heap,
502        old_fd,
503        old_flags,
504        old_path_ptr,
505        old_path_len,
506        new_fd,
507        new_path_ptr,
508        new_path_len,
509    )
510}
511
512#[lucet_hostcall]
513#[no_mangle]
514pub unsafe extern "C" fn __wasi_path_readlink(
515    lucet_ctx: &mut Vmctx,
516    dirfd: wasi::__wasi_fd_t,
517    path_ptr: wasi32::uintptr_t,
518    path_len: wasi32::size_t,
519    buf_ptr: wasi32::uintptr_t,
520    buf_len: wasi32::size_t,
521    bufused: wasi32::uintptr_t,
522) -> wasi::__wasi_errno_t {
523    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
524    let heap = &mut lucet_ctx.heap_mut();
525    path_readlink(
526        wasi_ctx, heap, dirfd, path_ptr, path_len, buf_ptr, buf_len, bufused,
527    )
528}
529
530#[lucet_hostcall]
531#[no_mangle]
532pub unsafe extern "C" fn __wasi_path_remove_directory(
533    lucet_ctx: &mut Vmctx,
534    dirfd: wasi::__wasi_fd_t,
535    path_ptr: wasi32::uintptr_t,
536    path_len: wasi32::size_t,
537) -> wasi::__wasi_errno_t {
538    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
539    let heap = &mut lucet_ctx.heap_mut();
540    path_remove_directory(wasi_ctx, heap, dirfd, path_ptr, path_len)
541}
542
543#[lucet_hostcall]
544#[no_mangle]
545pub unsafe extern "C" fn __wasi_path_rename(
546    lucet_ctx: &mut Vmctx,
547    old_dirfd: wasi::__wasi_fd_t,
548    old_path_ptr: wasi32::uintptr_t,
549    old_path_len: wasi32::size_t,
550    new_dirfd: wasi::__wasi_fd_t,
551    new_path_ptr: wasi32::uintptr_t,
552    new_path_len: wasi32::size_t,
553) -> wasi::__wasi_errno_t {
554    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
555    let heap = &mut lucet_ctx.heap_mut();
556    path_rename(
557        wasi_ctx,
558        heap,
559        old_dirfd,
560        old_path_ptr,
561        old_path_len,
562        new_dirfd,
563        new_path_ptr,
564        new_path_len,
565    )
566}
567
568#[lucet_hostcall]
569#[no_mangle]
570pub unsafe extern "C" fn __wasi_path_symlink(
571    lucet_ctx: &mut Vmctx,
572    old_path_ptr: wasi32::uintptr_t,
573    old_path_len: wasi32::size_t,
574    dir_fd: wasi::__wasi_fd_t,
575    new_path_ptr: wasi32::uintptr_t,
576    new_path_len: wasi32::size_t,
577) -> wasi::__wasi_errno_t {
578    let wasi_ctx = &lucet_ctx.get_embed_ctx::<WasiCtx>();
579    let heap = &mut lucet_ctx.heap_mut();
580    path_symlink(
581        wasi_ctx,
582        heap,
583        old_path_ptr,
584        old_path_len,
585        dir_fd,
586        new_path_ptr,
587        new_path_len,
588    )
589}
590
591pub fn export_wasi_funcs() {
592    let funcs: &[*const extern "C" fn()] = &[
593        __wasi_args_get as _,
594        __wasi_args_sizes_get as _,
595        __wasi_sched_yield as _,
596        __wasi_clock_res_get as _,
597        __wasi_clock_time_get as _,
598        __wasi_environ_get as _,
599        __wasi_environ_sizes_get as _,
600        __wasi_fd_close as _,
601        __wasi_fd_fdstat_get as _,
602        __wasi_fd_fdstat_set_flags as _,
603        __wasi_fd_tell as _,
604        __wasi_fd_seek as _,
605        __wasi_fd_prestat_get as _,
606        __wasi_fd_prestat_dir_name as _,
607        __wasi_fd_read as _,
608        __wasi_fd_write as _,
609        __wasi_path_open as _,
610        __wasi_random_get as _,
611        __wasi_poll_oneoff as _,
612        __wasi_fd_filestat_get as _,
613        __wasi_path_filestat_get as _,
614        __wasi_path_create_directory as _,
615        __wasi_path_unlink_file as _,
616        __wasi_fd_allocate as _,
617        __wasi_fd_advise as _,
618        __wasi_fd_datasync as _,
619        __wasi_fd_sync as _,
620        __wasi_fd_fdstat_set_rights as _,
621        __wasi_fd_filestat_set_size as _,
622        __wasi_fd_filestat_set_times as _,
623        __wasi_fd_pread as _,
624        __wasi_fd_pwrite as _,
625        __wasi_fd_readdir as _,
626        __wasi_fd_renumber as _,
627        __wasi_path_filestat_set_times as _,
628        __wasi_path_link as _,
629        __wasi_path_readlink as _,
630        __wasi_path_remove_directory as _,
631        __wasi_path_rename as _,
632        __wasi_path_symlink as _,
633        __wasi_proc_exit as _,
634    ];
635    mem::forget(Rc::new(funcs));
636}